(reason)
| 133 | } |
| 134 | |
| 135 | function finish(reason) { |
| 136 | if (finished) return; |
| 137 | finished = true; |
| 138 | clearTimeout(timeoutHandle); |
| 139 | clearTimeout(finishHandle); |
| 140 | try { |
| 141 | proc.stdin.end(); |
| 142 | } catch {} |
| 143 | try { |
| 144 | proc.kill(); |
| 145 | } catch {} |
| 146 | |
| 147 | ensureDir(path.dirname(outPath)); |
| 148 | fs.writeFileSync(outPath, jsonl(serverMessages), 'utf8'); |
| 149 | ensureDir(path.dirname(requestsPath)); |
| 150 | fs.writeFileSync(requestsPath, jsonl(clientMessages), 'utf8'); |
| 151 | const verification = verifyAppServerCapture(serverMessages, { |
| 152 | requireThread: startThread, |
| 153 | requireTurn: Boolean(turnText), |
| 154 | requireTurnCompleted: Boolean(turnText), |
| 155 | requireApproval: expectApproval, |
| 156 | }); |
| 157 | const dashboard = writeAppServerDashboard({ |
| 158 | projectRoot, |
| 159 | source: outPath, |
| 160 | summary: verification.summary, |
| 161 | }); |
| 162 | |
| 163 | const report = { |
| 164 | pass: verification.pass, |
| 165 | reason, |
| 166 | projectRoot, |
| 167 | outPath, |
| 168 | requestsPath, |
| 169 | dashboardPath: dashboard.dashboardPath, |
| 170 | summaryPath: dashboard.summaryPath, |
| 171 | serverMessages: serverMessages.length, |
| 172 | clientMessages: clientMessages.length, |
| 173 | approvalResponses, |
| 174 | unhandledServerRequests, |
| 175 | ignoredStdout, |
| 176 | stderr: stderrChunks.join('').slice(0, 4000), |
| 177 | verification, |
| 178 | }; |
| 179 | process.stdout.write(`${JSON.stringify(report, null, 2)}\n`, () => { |
| 180 | process.exit(verification.pass ? 0 : 1); |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | function handleMessage(msg) { |
| 185 | serverMessages.push(msg); |
no test coverage detected