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

Function runAgent

eval/run.mjs:52–69  ·  view source on GitHub ↗
(prompt, cwd)

Source from the content-addressed store, hash-verified

50}
51
52function runAgent(prompt, cwd) {
53 return new Promise((resolve) => {
54 const args = ['--print', prompt, '--yes', '--json'];
55 if (model) args.push('--model', model);
56 const child = spawn(process.execPath, [binPath, ...args], {
57 cwd,
58 env: { ...process.env, QODEX_SKIP_SETUP: '1', FORCE_COLOR: '0' },
59 stdio: ['ignore', 'pipe', 'pipe'],
60 });
61 let stdout = '';
62 let stderr = '';
63 const timer = setTimeout(() => { try { child.kill('SIGKILL'); } catch {} }, PER_TASK_TIMEOUT_MS);
64 child.stdout.on('data', d => { stdout += d.toString('utf-8'); });
65 child.stderr.on('data', d => { stderr += d.toString('utf-8'); });
66 child.on('exit', (code) => { clearTimeout(timer); resolve({ code, stdout, stderr }); });
67 child.on('error', (err) => { clearTimeout(timer); resolve({ code: -1, stdout, stderr: stderr + '\n' + err.message }); });
68 });
69}
70
71/** Parse NDJSON agent events to recover iteration/tool/cost telemetry + any error. */
72function parseAgentEvents(stdout) {

Callers 1

runTaskFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected