(prompt, opts = {})
| 44 | } |
| 45 | |
| 46 | function runAgent(prompt, opts = {}) { |
| 47 | return new Promise((resolve) => { |
| 48 | const cwd = opts.cwd || freshTmpDir('e2e'); |
| 49 | const env = { |
| 50 | ...process.env, |
| 51 | SMALLCODE_MODEL: MODEL, |
| 52 | SMALLCODE_BASE_URL: BASE_URL, |
| 53 | SMALLCODE_PROVIDER: 'openai', |
| 54 | SMALLCODE_AUTO_APPROVE: 'true', |
| 55 | NO_COLOR: '1', |
| 56 | FORCE_COLOR: '0', |
| 57 | // Keep features deterministic for the smoke run |
| 58 | SMALLCODE_REVIEWER: 'false', |
| 59 | SMALLCODE_PLAN: 'false', |
| 60 | SMALLCODE_BOOTSTRAP: 'false', |
| 61 | ...(opts.env || {}), |
| 62 | }; |
| 63 | const child = spawn('node', [SMALLCODE_BIN, '--non-interactive', '-P', prompt], { |
| 64 | cwd, |
| 65 | env, |
| 66 | stdio: ['ignore', 'pipe', 'pipe'], |
| 67 | }); |
| 68 | let stdout = ''; |
| 69 | let stderr = ''; |
| 70 | child.stdout.on('data', (d) => { stdout += d.toString(); }); |
| 71 | child.stderr.on('data', (d) => { stderr += d.toString(); }); |
| 72 | const t = setTimeout(() => { |
| 73 | try { child.kill('SIGKILL'); } catch {} |
| 74 | }, TURN_TIMEOUT_S * 1000); |
| 75 | child.on('exit', (code) => { |
| 76 | clearTimeout(t); |
| 77 | resolve({ code, stdout, stderr, cwd }); |
| 78 | }); |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | let failures = 0; |
| 83 | function check(name, ok, details) { |
no test coverage detected