MCPcopy Create free account
hub / github.com/AI45Lab/Code / once

Function once

sdk/node/ultracode_test.mjs:47–79  ·  view source on GitHub ↗
(i)

Source from the content-addressed store, hash-verified

45const agent = await Agent.create(CONFIG);
46
47async function once(i) {
48 const session = agent.session('.', {
49 guidelines: GUIDELINES,
50 autoDelegation: { enabled: true, parallel: true },
51 maxParallelTasks: 8,
52 confirmationPolicy: { enabled: true, yoloLanes: ['control', 'query', 'execute', 'generate'], timeoutAction: 'auto_approve' },
53 });
54 let inProgram = false, progArgs = '', scriptForm = false, directParallel = false, programOk = false, errorSeen = null;
55 const t0 = Date.now();
56 const stream = await session.stream(TASK);
57 while (true) {
58 const { value: ev, done } = await stream.next();
59 if (done) break;
60 if (!ev) continue;
61 const ty = ev.type || '';
62 if (ty === 'tool_start' && ev.toolName === 'program') inProgram = true;
63 if (ty === 'tool_start' && ev.toolName === 'parallel_task') directParallel = true;
64 if (ty === 'tool_input_delta' && inProgram) progArgs += (ev.text || '');
65 if (ty === 'tool_end' && ev.toolName === 'program') {
66 inProgram = false;
67 scriptForm = /parallel_task/.test(progArgs);
68 programOk = /exit_code=0/.test(String(ev.toolOutput || '')) && /parallel_task \(ok/.test(String(ev.toolOutput || ''));
69 }
70 if (ty === 'permission_denied') errorSeen = 'permission_denied:' + (ev.toolName || '');
71 }
72 log(`#${i} ${Date.now() - t0}ms scriptForm=${scriptForm} programOk=${programOk} directParallel=${directParallel} err=${errorSeen || 'no'}`);
73 if (scriptForm && i === 0) {
74 // Show the actual generated workflow script once, as evidence.
75 const m = progArgs.match(/"source"\s*:\s*"((?:[^"\\]|\\.)*)"/);
76 if (m) log(' --- generated workflow script ---\n' + JSON.parse('"' + m[1] + '"').split('\n').map((l) => ' | ' + l).join('\n'));
77 }
78 return { i, scriptForm, programOk, directParallel, errorSeen };
79}
80
81log(`\n=== autonomous ultracode test (strengthened guideline, ${ITERS} iters) ===`);
82const rows = [];

Callers 1

ultracode_test.mjsFile · 0.85

Calls 5

logFunction · 0.70
sessionMethod · 0.45
streamMethod · 0.45
nextMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected