MCPcopy Create free account
hub / github.com/SethGammon/Citadel / finish

Function finish

scripts/codex-app-server-capture.js:135–182  ·  view source on GitHub ↗
(reason)

Source from the content-addressed store, hash-verified

133}
134
135function 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
184function handleMessage(msg) {
185 serverMessages.push(msg);

Callers 2

scheduleFinishFunction · 0.70

Calls 4

verifyAppServerCaptureFunction · 0.85
writeAppServerDashboardFunction · 0.85
ensureDirFunction · 0.70
jsonlFunction · 0.70

Tested by

no test coverage detected