51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
const BASE = 'http://localhost:3002';
|
|
const PID = 'b1b5884e-ba85-4d8f-9a92-e524603587a0';
|
|
|
|
async function main() {
|
|
const login = await fetch(`${BASE}/api/auth/login`, {
|
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password: '620f4c96' })
|
|
});
|
|
const { token } = await login.json();
|
|
const auth = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` };
|
|
|
|
const r = await fetch(`${BASE}/api/projects/${PID}/entries`, {
|
|
method: 'POST', headers: auth,
|
|
body: JSON.stringify({ title: 'cobol-java-subagent', repo_url: 'file://D:/Projects/cobol-java/jcl-cobol-git', participant: 'hangshuo' })
|
|
});
|
|
const entry = await r.json();
|
|
if (!r.ok) { console.log('FAIL:', JSON.stringify(entry)); process.exit(1); }
|
|
const eid = entry.id;
|
|
console.log('CREATE:', eid.slice(0, 8));
|
|
|
|
await fetch(`${BASE}/api/projects/${PID}/entries/${eid}/start`, { method: 'POST', headers: auth });
|
|
console.log('START OK');
|
|
const start = Date.now();
|
|
|
|
for (let i = 0; i < 30; i++) {
|
|
await new Promise(r => setTimeout(r, 10000));
|
|
const r3 = await fetch(`${BASE}/api/projects/${PID}/entries/${eid}`, { headers: auth });
|
|
const e2 = await r3.json();
|
|
console.log(`POLL_${i}[${Math.round((Date.now()-start)/1000)}s]: ${e2.status} RAW=${e2.raw_score}`);
|
|
if (e2.status === 'review_done') {
|
|
const report = typeof e2.ai_report === 'string' ? JSON.parse(e2.ai_report) : e2.ai_report;
|
|
console.log(`\n=== 11子Agent结果 (${Math.round((Date.now()-start)/1000)}s) ===`);
|
|
let st = 0, mt = 0;
|
|
for (const d of report.dimensions) {
|
|
st += d.score; mt += d.maxScore;
|
|
console.log(`[${d.score}/${d.maxScore}] ${d.name}`);
|
|
console.log(` ${(d.comment || '').slice(0, 120)}`);
|
|
}
|
|
console.log(`\nTotal: ${st}/${mt} = ${Math.round(st/mt*100)}%`);
|
|
break;
|
|
}
|
|
if (e2.status === 'failed' || e2.status?.includes('fail')) {
|
|
const logs = e2.progress_log ? JSON.parse(typeof e2.progress_log === 'string' ? e2.progress_log : '[]') : [];
|
|
console.log('FAIL:', JSON.stringify(logs.slice(-2)));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|