MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / parseAgentEvents

Function parseAgentEvents

eval/run.mjs:72–85  ·  view source on GitHub ↗

Parse NDJSON agent events to recover iteration/tool/cost telemetry + any error.

(stdout)

Source from the content-addressed store, hash-verified

70
71/** Parse NDJSON agent events to recover iteration/tool/cost telemetry + any error. */
72function parseAgentEvents(stdout) {
73 let iterations = 0, toolCalls = 0, costUsd = 0, error;
74 for (const line of stdout.split('\n')) {
75 const trimmed = line.trim();
76 if (!trimmed.startsWith('{')) continue;
77 let ev;
78 try { ev = JSON.parse(trimmed); } catch { continue; }
79 if (ev.type === 'iteration_start' && typeof ev.iteration === 'number') iterations = Math.max(iterations, ev.iteration);
80 if (ev.type === 'tool_call_start') toolCalls += 1;
81 if (ev.type === 'budget_update' && typeof ev.lastCostUsd === 'number') costUsd += ev.lastCostUsd;
82 if (ev.type === 'error' && ev.message) error = ev.message;
83 }
84 return { iterations, toolCalls, costUsd, error };
85}
86
87async function observeOutcome(task, cwd, runError) {
88 const existingFiles = [];

Callers 1

runTaskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected