feat: Enhance login page UI with delayed redirect instead of transparent 307
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 8s
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 8s
This commit is contained in:
67
scripts/mock_dispatcher.ts
Normal file
67
scripts/mock_dispatcher.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
const API_BASE = "http://192.168.0.110:3000/api";
|
||||
const MCP_API_BASE = "http://192.168.0.110:3000/api/mcp";
|
||||
const MCP_API_KEY = "vw_beta_promo_2026";
|
||||
|
||||
async function callMcpTool(tool: string, payload: any) {
|
||||
const res = await fetch(`${MCP_API_BASE}/${tool}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${MCP_API_KEY}`
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
throw new Error(`Tool ${tool} failed. ` + JSON.stringify(data));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("🚀 [Mock Dispatcher] Starting test flow...");
|
||||
|
||||
// 1. Find Open Bounties
|
||||
const openTasksRes = await fetch(`${API_BASE}/open-tasks`);
|
||||
const openTasks = await openTasksRes.json();
|
||||
|
||||
if (!openTasks || !openTasks.tasks || openTasks.tasks.length === 0) {
|
||||
console.log("✅ No open tasks. We need to create a test task first.");
|
||||
return;
|
||||
}
|
||||
|
||||
const task = openTasks.tasks[0];
|
||||
console.log(`🎯 Found Task: "${task.title}"`);
|
||||
|
||||
// 2. Mock Agent
|
||||
const agentId = `mock-agent-${Math.floor(Math.random() * 1000)}`;
|
||||
console.log(`🤖 Agent ID: ${agentId}`);
|
||||
|
||||
// 3. Claim task
|
||||
const claimRes = await callMcpTool("claim_task", {
|
||||
task_id: task.task_id,
|
||||
agent_id: agentId,
|
||||
developer_wallet: "acct_1MockStripeOutboundAgent"
|
||||
});
|
||||
console.log("✅ Claimed successfully. Token:", claimRes.claim_token);
|
||||
|
||||
// 4. Mock Solution
|
||||
console.log("🧠 Mocking solution generation...");
|
||||
const solutionObj = {
|
||||
"solution.ts": "// Fake solution"
|
||||
};
|
||||
|
||||
// 5. Submit solution
|
||||
const solutionRes = await callMcpTool("submit_solution", {
|
||||
task_id: task.task_id,
|
||||
claim_token: claimRes.claim_token,
|
||||
deliverables: solutionObj,
|
||||
github_pr_url: "https://github.com/agent-bounty/external-agents/pull/999"
|
||||
});
|
||||
|
||||
console.log(`🎉 Success! Solution submitted. Submission ID: ${solutionRes.submission_id}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user