@mycompbox/compbox-cli 1.21.5 → 1.21.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tsbuildinfo +1 -1
- package/commands/run.d.ts +46 -1
- package/commands/run.d.ts.map +1 -1
- package/commands/run.js +140 -13
- package/commands/run.js.map +1 -1
- package/commands/workspace.d.ts.map +1 -1
- package/commands/workspace.js +43 -1
- package/commands/workspace.js.map +1 -1
- package/index.js +439 -48
- package/package.json +1 -1
- package/utils/agent-invoker.d.ts +33 -1
- package/utils/agent-invoker.d.ts.map +1 -1
- package/utils/agent-invoker.js +151 -17
- package/utils/agent-invoker.js.map +1 -1
- package/utils/mailbox-client.d.ts +27 -1
- package/utils/mailbox-client.d.ts.map +1 -1
- package/utils/mailbox-client.js +28 -3
- package/utils/mailbox-client.js.map +1 -1
- package/utils/process-group.d.ts +42 -0
- package/utils/process-group.d.ts.map +1 -0
- package/utils/process-group.js +127 -0
- package/utils/process-group.js.map +1 -0
- package/utils/run-workspace.d.ts +18 -1
- package/utils/run-workspace.d.ts.map +1 -1
- package/utils/run-workspace.js +57 -6
- package/utils/run-workspace.js.map +1 -1
package/package.json
CHANGED
package/utils/agent-invoker.d.ts
CHANGED
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import Anthropic from '@anthropic-ai/sdk';
|
|
20
20
|
import { spawn } from 'node:child_process';
|
|
21
|
-
import { type PxpipeRouting, type InterviewSeedPayload, extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, type ComplianceSummary, type EpicRequestDraft } from '@mycompbox/shared';
|
|
21
|
+
import { type PxpipeRouting, type InterviewSeedPayload, extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, type ComplianceSummary, type EpicRequestDraft, type StartExecutionFix } from '@mycompbox/shared';
|
|
22
22
|
export { extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, };
|
|
23
23
|
export type { ComplianceSummary, EpicRequestDraft };
|
|
24
24
|
import { type KeyRun } from './key-run.js';
|
|
25
|
+
import { type ProcessGroupDeps } from './process-group.js';
|
|
25
26
|
import type { FinishResult, RunWorkspaceManager } from './run-workspace.js';
|
|
26
27
|
import type { MailboxAttachment, MailboxClient, MailboxJob, MailboxJobTurn } from './mailbox-client.js';
|
|
27
28
|
/**
|
|
@@ -259,6 +260,11 @@ export interface StartExecutionPlanCtx {
|
|
|
259
260
|
projectDir: string | undefined;
|
|
260
261
|
/** Run on the person's saved API key instead of this computer's Claude sign-in. */
|
|
261
262
|
keyRun?: KeyRun;
|
|
263
|
+
/**
|
|
264
|
+
* Aborted when the person cancels the job from the website (ENG-300): the
|
|
265
|
+
* agent's whole process group is terminated and the run reports cancelled.
|
|
266
|
+
*/
|
|
267
|
+
signal?: AbortSignal;
|
|
262
268
|
}
|
|
263
269
|
export interface StartExecutionPlanDeps {
|
|
264
270
|
/** Injectable child spawner (defaults to node's `spawn`) — tests never spawn a real `claude`. */
|
|
@@ -273,6 +279,8 @@ export interface StartExecutionPlanDeps {
|
|
|
273
279
|
heartbeat?: () => void | Promise<void>;
|
|
274
280
|
heartbeatIntervalMs?: number;
|
|
275
281
|
timeoutMs?: number;
|
|
282
|
+
/** Injectable process-group killer (tests never signal real processes). */
|
|
283
|
+
processGroup?: ProcessGroupDeps;
|
|
276
284
|
}
|
|
277
285
|
/**
|
|
278
286
|
* Run the planner headless for a `start_execution`/`plan` job (ENG-164).
|
|
@@ -314,6 +322,11 @@ export interface StartExecutionRefineCtx {
|
|
|
314
322
|
notes?: string | undefined;
|
|
315
323
|
projectDir: string | undefined;
|
|
316
324
|
keyRun?: KeyRun;
|
|
325
|
+
/**
|
|
326
|
+
* Aborted when the person cancels the job from the website (ENG-300): the
|
|
327
|
+
* agent's whole process group is terminated and the run reports cancelled.
|
|
328
|
+
*/
|
|
329
|
+
signal?: AbortSignal;
|
|
317
330
|
}
|
|
318
331
|
export type StartExecutionRefineDeps = StartExecutionPlanDeps;
|
|
319
332
|
/** One-line final mailbox turn for a refine run. */
|
|
@@ -343,6 +356,13 @@ export declare const ORCHESTRATOR_HEARTBEAT_INTERVAL_MS: number;
|
|
|
343
356
|
* run once exited "waiting for the architect review" after one task.
|
|
344
357
|
*/
|
|
345
358
|
export declare const HEADLESS_ORCHESTRATE_REMINDER = "This is a non-interactive run: do NOT start sub-agents or reviews in the background and do not end your turn to wait for them. Run every step in this process and keep going until every feature is done or a hard gate stops the run.";
|
|
359
|
+
/**
|
|
360
|
+
* Guardrails for a fix run (ENG-296), prepended to the server's instructions:
|
|
361
|
+
* work only on the pull request's branch, push normally, never rewrite history.
|
|
362
|
+
*/
|
|
363
|
+
export declare const FIX_RUN_RULES: string;
|
|
364
|
+
/** Claude CLI args for a fix run: the instructions as the prompt, same unattended profile as a build. */
|
|
365
|
+
export declare function buildFixArgs(fix: Pick<StartExecutionFix, 'instructions'>): string[];
|
|
346
366
|
/**
|
|
347
367
|
* Build the `claude` argv for a headless orchestrator run (H1). Pure + exported
|
|
348
368
|
* so a unit test can assert the exact command shape: the `@orchestrator execute
|
|
@@ -387,6 +407,16 @@ export interface StartExecutionOrchestrateCtx {
|
|
|
387
407
|
projectDir: string | undefined;
|
|
388
408
|
/** Run on the person's saved API key instead of this computer's Claude sign-in. */
|
|
389
409
|
keyRun?: KeyRun;
|
|
410
|
+
/**
|
|
411
|
+
* A fix run (ENG-296: Send back / Resolve conflicts): apply these instructions
|
|
412
|
+
* on the open pull request's branch instead of executing the epic's plan.
|
|
413
|
+
*/
|
|
414
|
+
fix?: StartExecutionFix;
|
|
415
|
+
/**
|
|
416
|
+
* Aborted when the person cancels the job from the website (ENG-300): the
|
|
417
|
+
* agent's whole process group is terminated and the run reports cancelled.
|
|
418
|
+
*/
|
|
419
|
+
signal?: AbortSignal;
|
|
390
420
|
}
|
|
391
421
|
export interface StartExecutionOrchestrateDeps {
|
|
392
422
|
/** Injectable child spawner (defaults to node's `spawn`) — tests never spawn a real `claude`. */
|
|
@@ -403,6 +433,8 @@ export interface StartExecutionOrchestrateDeps {
|
|
|
403
433
|
heartbeat?: () => void | Promise<void>;
|
|
404
434
|
heartbeatIntervalMs?: number;
|
|
405
435
|
timeoutMs?: number;
|
|
436
|
+
/** Injectable process-group killer (tests never signal real processes). */
|
|
437
|
+
processGroup?: ProcessGroupDeps;
|
|
406
438
|
/**
|
|
407
439
|
* Runs the orchestrator on its own new branch in a separate git worktree and
|
|
408
440
|
* finishes with a pushed branch + pull request (see run-workspace.ts). The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-invoker.d.ts","sourceRoot":"","sources":["../../src/utils/agent-invoker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAa,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAI7B,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"agent-invoker.d.ts","sourceRoot":"","sources":["../../src/utils/agent-invoker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAa,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAI7B,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACvB,MAA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;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkBzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,4BAA4B,EACjC,IAAI,GAAE,6BAAkC,GACvC,OAAO,CAAC,YAAY,CAAC,CAiTvB"}
|
package/utils/agent-invoker.js
CHANGED
|
@@ -28,6 +28,7 @@ export { extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarge
|
|
|
28
28
|
import { claudeChildEnvPath, claudeNotFoundMessage, resolveClaudeBinary, } from './claude-runtime.js';
|
|
29
29
|
import { isGitRepoDir } from './config-store.js';
|
|
30
30
|
import { keyRunArgs, keyRunEnv, parseClaudeJsonResult } from './key-run.js';
|
|
31
|
+
import { CANCEL_GRACE_MS, cancelledRunResult, groupSpawnOptions, killGroupOnAbort, killProcessGroupNow, } from './process-group.js';
|
|
31
32
|
// Fable is the model CompBox agents run on (ENG-E26): it is pxpipe's 100/100
|
|
32
33
|
// image reader, so routing it through the proxy cuts input tokens without
|
|
33
34
|
// quality loss. Opus/Sonnet are deliberately NOT used here — pxpipe passes
|
|
@@ -466,19 +467,34 @@ async function takeConversationStep(job, ctx) {
|
|
|
466
467
|
const outcome = await runConversationStep({ turns, saved }, {
|
|
467
468
|
reply: async (system, messages) => {
|
|
468
469
|
if (anthropic) {
|
|
469
|
-
const response = await anthropic.messages.create({
|
|
470
|
+
const response = await anthropic.messages.create({
|
|
471
|
+
model: ANTHROPIC_MODEL,
|
|
472
|
+
max_tokens: 4096,
|
|
473
|
+
system,
|
|
474
|
+
messages,
|
|
475
|
+
});
|
|
470
476
|
const text = response.content.find((b) => b.type === 'text');
|
|
471
477
|
return text?.type === 'text' ? text.text : '';
|
|
472
478
|
}
|
|
473
479
|
const prompt = renderConversationPrompt(messages);
|
|
474
480
|
try {
|
|
475
|
-
return (await runClaudeCliTurn(prompt, {
|
|
481
|
+
return (await runClaudeCliTurn(prompt, {
|
|
482
|
+
systemPrompt: system,
|
|
483
|
+
resumeSessionId: undefined,
|
|
484
|
+
routing,
|
|
485
|
+
model: cliModel,
|
|
486
|
+
})).text;
|
|
476
487
|
}
|
|
477
488
|
catch (error) {
|
|
478
489
|
if (cliModel === null || !needsDefaultModel(error))
|
|
479
490
|
throw error;
|
|
480
491
|
cliModel = null;
|
|
481
|
-
return (await runClaudeCliTurn(prompt, {
|
|
492
|
+
return (await runClaudeCliTurn(prompt, {
|
|
493
|
+
systemPrompt: system,
|
|
494
|
+
resumeSessionId: undefined,
|
|
495
|
+
routing,
|
|
496
|
+
model: null,
|
|
497
|
+
})).text;
|
|
482
498
|
}
|
|
483
499
|
},
|
|
484
500
|
save: async (existingId, draft) => {
|
|
@@ -804,6 +820,9 @@ export function buildPlannerFinalTurn(outcome) {
|
|
|
804
820
|
* non-zero exit, fail with a result the web failure banner can display.
|
|
805
821
|
*/
|
|
806
822
|
export async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
823
|
+
// ENG-300: cancelled before it started — don't spawn at all.
|
|
824
|
+
if (ctx.signal?.aborted)
|
|
825
|
+
return cancelledRunResult('planner');
|
|
807
826
|
const spawnImpl = deps.spawnImpl ?? spawn;
|
|
808
827
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
809
828
|
const isGitRepo = deps.isGitRepo ?? isGitRepoDir;
|
|
@@ -852,7 +871,18 @@ export async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
852
871
|
cwd: ctx.projectDir,
|
|
853
872
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
854
873
|
env: childEnv,
|
|
874
|
+
// ENG-300: lead its own process group so a cancel can stop everything it started.
|
|
875
|
+
...groupSpawnOptions(deps.processGroup?.platform),
|
|
855
876
|
});
|
|
877
|
+
// ENG-300: a cancel from the website terminates the whole group; the run is
|
|
878
|
+
// reported once the child has actually exited (or after a grace backstop).
|
|
879
|
+
let cancelled = false;
|
|
880
|
+
const disposeAbort = killGroupOnAbort(ctx.signal, child, () => {
|
|
881
|
+
cancelled = true;
|
|
882
|
+
setTimeout(() => {
|
|
883
|
+
finish(cancelledRunResult('planner'));
|
|
884
|
+
}, (deps.processGroup?.graceMs ?? CANCEL_GRACE_MS) + 5_000).unref();
|
|
885
|
+
}, deps.processGroup);
|
|
856
886
|
// H4: independent keep-alive so the machine stays online during the long run.
|
|
857
887
|
const heartbeatTimer = deps.heartbeat
|
|
858
888
|
? setInterval(() => {
|
|
@@ -868,10 +898,11 @@ export async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
868
898
|
if (heartbeatTimer)
|
|
869
899
|
clearInterval(heartbeatTimer);
|
|
870
900
|
clearTimeout(timer);
|
|
901
|
+
disposeAbort();
|
|
871
902
|
resolve(result);
|
|
872
903
|
};
|
|
873
904
|
const timer = setTimeout(() => {
|
|
874
|
-
child.
|
|
905
|
+
killProcessGroupNow(child, deps.processGroup);
|
|
875
906
|
finish({
|
|
876
907
|
status: 'failed',
|
|
877
908
|
result: {
|
|
@@ -886,6 +917,10 @@ export async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
886
917
|
stderr += chunk.toString('utf-8');
|
|
887
918
|
});
|
|
888
919
|
child.on('error', (error) => {
|
|
920
|
+
if (cancelled) {
|
|
921
|
+
finish(cancelledRunResult('planner'));
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
889
924
|
finish({
|
|
890
925
|
status: 'failed',
|
|
891
926
|
result: {
|
|
@@ -899,6 +934,10 @@ export async function invokeStartExecutionPlan(ctx, deps = {}) {
|
|
|
899
934
|
void (async () => {
|
|
900
935
|
if (ctx.keyRun)
|
|
901
936
|
stdout = await settleKeyRun(ctx, ctx.keyRun, stdout);
|
|
937
|
+
if (cancelled) {
|
|
938
|
+
finish(cancelledRunResult('planner'));
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
902
941
|
const combined = `${stdout}\n${stderr}`;
|
|
903
942
|
// A needs-review outcome wins regardless of exit code: the planner may
|
|
904
943
|
// exit 0 after emitting the marker. Surface it to the web (not silent).
|
|
@@ -1032,6 +1071,9 @@ export function buildRefineFinalTurn(outcome) {
|
|
|
1032
1071
|
* regardless of exit code.
|
|
1033
1072
|
*/
|
|
1034
1073
|
export async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
1074
|
+
// ENG-300: cancelled before it started — don't spawn at all.
|
|
1075
|
+
if (ctx.signal?.aborted)
|
|
1076
|
+
return cancelledRunResult('planner');
|
|
1035
1077
|
const spawnImpl = deps.spawnImpl ?? spawn;
|
|
1036
1078
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
1037
1079
|
const isGitRepo = deps.isGitRepo ?? isGitRepoDir;
|
|
@@ -1063,7 +1105,18 @@ export async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
1063
1105
|
cwd: ctx.projectDir,
|
|
1064
1106
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1065
1107
|
env: childEnv,
|
|
1108
|
+
// ENG-300: lead its own process group so a cancel can stop everything it started.
|
|
1109
|
+
...groupSpawnOptions(deps.processGroup?.platform),
|
|
1066
1110
|
});
|
|
1111
|
+
// ENG-300: a cancel from the website terminates the whole group; the run is
|
|
1112
|
+
// reported once the child has actually exited (or after a grace backstop).
|
|
1113
|
+
let cancelled = false;
|
|
1114
|
+
const disposeAbort = killGroupOnAbort(ctx.signal, child, () => {
|
|
1115
|
+
cancelled = true;
|
|
1116
|
+
setTimeout(() => {
|
|
1117
|
+
finish(cancelledRunResult('planner'));
|
|
1118
|
+
}, (deps.processGroup?.graceMs ?? CANCEL_GRACE_MS) + 5_000).unref();
|
|
1119
|
+
}, deps.processGroup);
|
|
1067
1120
|
const heartbeatTimer = deps.heartbeat
|
|
1068
1121
|
? setInterval(() => {
|
|
1069
1122
|
void Promise.resolve(deps.heartbeat?.()).catch(() => {
|
|
@@ -1078,10 +1131,11 @@ export async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
1078
1131
|
if (heartbeatTimer)
|
|
1079
1132
|
clearInterval(heartbeatTimer);
|
|
1080
1133
|
clearTimeout(timer);
|
|
1134
|
+
disposeAbort();
|
|
1081
1135
|
resolve(result);
|
|
1082
1136
|
};
|
|
1083
1137
|
const timer = setTimeout(() => {
|
|
1084
|
-
child.
|
|
1138
|
+
killProcessGroupNow(child, deps.processGroup);
|
|
1085
1139
|
finish({
|
|
1086
1140
|
status: 'failed',
|
|
1087
1141
|
result: {
|
|
@@ -1096,6 +1150,10 @@ export async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
1096
1150
|
stderr += chunk.toString('utf-8');
|
|
1097
1151
|
});
|
|
1098
1152
|
child.on('error', (error) => {
|
|
1153
|
+
if (cancelled) {
|
|
1154
|
+
finish(cancelledRunResult('planner'));
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1099
1157
|
finish({
|
|
1100
1158
|
status: 'failed',
|
|
1101
1159
|
result: {
|
|
@@ -1109,6 +1167,10 @@ export async function invokeStartExecutionRefine(ctx, deps = {}) {
|
|
|
1109
1167
|
void (async () => {
|
|
1110
1168
|
if (ctx.keyRun)
|
|
1111
1169
|
stdout = await settleKeyRun(ctx, ctx.keyRun, stdout);
|
|
1170
|
+
if (cancelled) {
|
|
1171
|
+
finish(cancelledRunResult('planner'));
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1112
1174
|
const combined = `${stdout}\n${stderr}`;
|
|
1113
1175
|
const review = detectNeedsHumanReview(combined);
|
|
1114
1176
|
if (review.needsReview) {
|
|
@@ -1207,6 +1269,29 @@ export const ORCHESTRATOR_HEARTBEAT_INTERVAL_MS = PLANNER_HEARTBEAT_INTERVAL_MS;
|
|
|
1207
1269
|
* run once exited "waiting for the architect review" after one task.
|
|
1208
1270
|
*/
|
|
1209
1271
|
export const HEADLESS_ORCHESTRATE_REMINDER = 'This is a non-interactive run: do NOT start sub-agents or reviews in the background and do not end your turn to wait for them. Run every step in this process and keep going until every feature is done or a hard gate stops the run.';
|
|
1272
|
+
/**
|
|
1273
|
+
* Guardrails for a fix run (ENG-296), prepended to the server's instructions:
|
|
1274
|
+
* work only on the pull request's branch, push normally, never rewrite history.
|
|
1275
|
+
*/
|
|
1276
|
+
export const FIX_RUN_RULES = [
|
|
1277
|
+
'You are making a focused change to an open pull request, in a checkout of its branch. This is a non-interactive run.',
|
|
1278
|
+
'- Do only what the instructions below ask. Do not execute the epic\'s plan or start other work.',
|
|
1279
|
+
'- Never force-push, rebase, reset or otherwise rewrite the branch\'s existing history.',
|
|
1280
|
+
'- Do not open a new pull request; commits pushed to this branch update the existing one.',
|
|
1281
|
+
'- Run the project\'s tests before finishing, and fix anything your change broke.',
|
|
1282
|
+
'- Do not start sub-agents or reviews in the background, and do not end your turn to wait for them.',
|
|
1283
|
+
].join('\n');
|
|
1284
|
+
/** Claude CLI args for a fix run: the instructions as the prompt, same unattended profile as a build. */
|
|
1285
|
+
export function buildFixArgs(fix) {
|
|
1286
|
+
return [
|
|
1287
|
+
'-p',
|
|
1288
|
+
`${FIX_RUN_RULES}\n\n${fix.instructions}`,
|
|
1289
|
+
'--append-system-prompt',
|
|
1290
|
+
HEADLESS_ORCHESTRATE_REMINDER,
|
|
1291
|
+
'--permission-mode',
|
|
1292
|
+
'bypassPermissions',
|
|
1293
|
+
];
|
|
1294
|
+
}
|
|
1210
1295
|
/** Max chars of orchestrator output relayed in the final mailbox turn (bound turn size). */
|
|
1211
1296
|
const ORCHESTRATOR_FINAL_TURN_MAX_CHARS = 4_000;
|
|
1212
1297
|
/**
|
|
@@ -1315,6 +1400,9 @@ export function buildIncompleteRunResult(epicId, progress) {
|
|
|
1315
1400
|
}
|
|
1316
1401
|
/** Plain-language summary of where a run's code ended up. */
|
|
1317
1402
|
export function describeRunBranch(finish) {
|
|
1403
|
+
if (finish.cancelled) {
|
|
1404
|
+
return `Cancelled: nothing was pushed. The work is kept in ${finish.keptWorktree ?? 'its run folder'} on branch ${finish.branch}.`;
|
|
1405
|
+
}
|
|
1318
1406
|
if (finish.needsAttention) {
|
|
1319
1407
|
return `Needs attention: the run's work was kept in ${finish.keptWorktree ?? 'its run folder'} (branch ${finish.branch}) because it couldn't all be committed.`;
|
|
1320
1408
|
}
|
|
@@ -1373,6 +1461,9 @@ export function buildOrchestrateNeedsReviewResult(epicId, marker) {
|
|
|
1373
1461
|
* complete `{ epicId }`. Never hangs.
|
|
1374
1462
|
*/
|
|
1375
1463
|
export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
1464
|
+
// ENG-300: cancelled before it started — don't spawn at all.
|
|
1465
|
+
if (ctx.signal?.aborted)
|
|
1466
|
+
return cancelledRunResult('orchestrator');
|
|
1376
1467
|
const spawnImpl = deps.spawnImpl ?? spawn;
|
|
1377
1468
|
const isGitRepo = deps.isGitRepo ?? isGitRepoDir;
|
|
1378
1469
|
const worktreeCapable = deps.worktreeCapable ?? defaultWorktreeCapable;
|
|
@@ -1404,7 +1495,9 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1404
1495
|
let workspace = null;
|
|
1405
1496
|
let workspaceNotes = [];
|
|
1406
1497
|
if (deps.workspace) {
|
|
1407
|
-
const prepared =
|
|
1498
|
+
const prepared = ctx.fix
|
|
1499
|
+
? await deps.workspace.prepare(projectDir, ctx.epicId, { branch: ctx.fix.branch })
|
|
1500
|
+
: await deps.workspace.prepare(projectDir, ctx.epicId);
|
|
1408
1501
|
if (!prepared.ok) {
|
|
1409
1502
|
return { status: 'failed', result: { error: prepared.error } };
|
|
1410
1503
|
}
|
|
@@ -1414,7 +1507,8 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1414
1507
|
const runDir = workspace?.dir ?? projectDir;
|
|
1415
1508
|
const routing = await resolveRoutingImpl();
|
|
1416
1509
|
const command = resolveClaudeBinary() ?? 'claude';
|
|
1417
|
-
const
|
|
1510
|
+
const runArgs = ctx.fix ? buildFixArgs(ctx.fix) : buildOrchestratorArgs(ctx.epicId);
|
|
1511
|
+
const args = ctx.keyRun ? keyRunArgs(runArgs) : runArgs;
|
|
1418
1512
|
// pxpipe (ENG-136): inject ANTHROPIC_BASE_URL when routed. COMPBOX_NONINTERACTIVE
|
|
1419
1513
|
// forces the orchestrator's headless serial-in-process path (H3) even if the
|
|
1420
1514
|
// prompt flag were dropped. PATH is augmented (ENG-135) so `claude` and any
|
|
@@ -1432,12 +1526,14 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1432
1526
|
// H4: relay a START turn immediately so the web shows the run began even if the
|
|
1433
1527
|
// orchestrator produces no stdout for minutes. postTurn failures are swallowed.
|
|
1434
1528
|
try {
|
|
1435
|
-
await ctx.mailboxClient.postTurn(ctx.machineToken, ctx.jobId,
|
|
1436
|
-
(
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1529
|
+
await ctx.mailboxClient.postTurn(ctx.machineToken, ctx.jobId, (ctx.fix
|
|
1530
|
+
? `Started a fix run on the pull request's branch ${ctx.fix.branch}${ctx.fix.pullRequestUrl ? ` (${ctx.fix.pullRequestUrl})` : ''}. New commits are pushed to the same branch, so the existing pull request updates.`
|
|
1531
|
+
: `Started the orchestrator for epic ${ctx.epicId} (headless, non-interactive). This executes the full epic — every phase and feature — and may take a long time.` +
|
|
1532
|
+
(workspace
|
|
1533
|
+
? workspace.continued
|
|
1534
|
+
? ` Continuing the earlier unfinished work on ${workspace.branch}, which ends as a pull request into ${workspace.baseBranch}.`
|
|
1535
|
+
: ` Working on a new branch, ${workspace.branch}, which will end as a pull request into ${workspace.baseBranch}.`
|
|
1536
|
+
: '')) +
|
|
1441
1537
|
(workspaceNotes.length > 0 ? ` Note: ${workspaceNotes.join(' ')}` : ''));
|
|
1442
1538
|
}
|
|
1443
1539
|
catch {
|
|
@@ -1451,7 +1547,18 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1451
1547
|
cwd: runDir,
|
|
1452
1548
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1453
1549
|
env: childEnv,
|
|
1550
|
+
// ENG-300: lead its own process group so a cancel can stop everything it started.
|
|
1551
|
+
...groupSpawnOptions(deps.processGroup?.platform),
|
|
1454
1552
|
});
|
|
1553
|
+
// ENG-300: a cancel from the website terminates the whole group; the run is
|
|
1554
|
+
// reported once the child has actually exited (or after a grace backstop).
|
|
1555
|
+
let cancelled = false;
|
|
1556
|
+
const disposeAbort = killGroupOnAbort(ctx.signal, child, () => {
|
|
1557
|
+
cancelled = true;
|
|
1558
|
+
setTimeout(() => {
|
|
1559
|
+
finish(cancelledRunResult('orchestrator'));
|
|
1560
|
+
}, (deps.processGroup?.graceMs ?? CANCEL_GRACE_MS) + 5_000).unref();
|
|
1561
|
+
}, deps.processGroup);
|
|
1455
1562
|
// H4: independent keep-alive so the machine stays online during the long run
|
|
1456
1563
|
// and other jobs are not blocked — the poll loop's own heartbeat is blocked
|
|
1457
1564
|
// for the whole duration of this job.
|
|
@@ -1469,10 +1576,11 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1469
1576
|
if (heartbeatTimer)
|
|
1470
1577
|
clearInterval(heartbeatTimer);
|
|
1471
1578
|
clearTimeout(timer);
|
|
1579
|
+
disposeAbort();
|
|
1472
1580
|
resolve(result);
|
|
1473
1581
|
};
|
|
1474
1582
|
const timer = setTimeout(() => {
|
|
1475
|
-
child.
|
|
1583
|
+
killProcessGroupNow(child, deps.processGroup);
|
|
1476
1584
|
finish({
|
|
1477
1585
|
status: 'failed',
|
|
1478
1586
|
result: {
|
|
@@ -1487,6 +1595,10 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1487
1595
|
stderr += chunk.toString('utf-8');
|
|
1488
1596
|
});
|
|
1489
1597
|
child.on('error', (error) => {
|
|
1598
|
+
if (cancelled) {
|
|
1599
|
+
finish(cancelledRunResult('orchestrator'));
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1490
1602
|
finish({
|
|
1491
1603
|
status: 'failed',
|
|
1492
1604
|
result: {
|
|
@@ -1500,6 +1612,10 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1500
1612
|
// Usage is reported in the background; the run's outcome doesn't wait on it.
|
|
1501
1613
|
if (ctx.keyRun)
|
|
1502
1614
|
stdout = takeKeyRunResult(ctx, ctx.keyRun, stdout).text;
|
|
1615
|
+
if (cancelled) {
|
|
1616
|
+
finish(cancelledRunResult('orchestrator'));
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1503
1619
|
const combined = `${stdout}\n${stderr}`;
|
|
1504
1620
|
// ENG-165-3: a HARD-gate needs-review outcome wins regardless of exit code
|
|
1505
1621
|
// — the orchestrator emits the marker and STOPs, and may exit 0. Surface
|
|
@@ -1524,13 +1640,24 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1524
1640
|
return;
|
|
1525
1641
|
}
|
|
1526
1642
|
// Clean run: the epic executed to completion (no HARD gate tripped).
|
|
1527
|
-
finish({
|
|
1643
|
+
finish({
|
|
1644
|
+
status: 'done',
|
|
1645
|
+
result: ctx.fix
|
|
1646
|
+
? {
|
|
1647
|
+
epicId: ctx.epicId,
|
|
1648
|
+
fix: true,
|
|
1649
|
+
branch: ctx.fix.branch,
|
|
1650
|
+
...(ctx.fix.pullRequestUrl && { prUrl: ctx.fix.pullRequestUrl }),
|
|
1651
|
+
}
|
|
1652
|
+
: { epicId: ctx.epicId },
|
|
1653
|
+
});
|
|
1528
1654
|
});
|
|
1529
1655
|
});
|
|
1530
1656
|
// A clean exit isn't proof the epic is finished: a headless run can end its
|
|
1531
1657
|
// turn early (e.g. "waiting" on a background review). Check CompBox, and flag
|
|
1532
1658
|
// the run for attention when features are still outstanding.
|
|
1533
|
-
|
|
1659
|
+
// A fix run changes one pull request, not the epic's plan, so epic progress says nothing about it.
|
|
1660
|
+
if (outcome.status === 'done' && !ctx.fix) {
|
|
1534
1661
|
const readProgress = deps.epicProgress ??
|
|
1535
1662
|
(async () => {
|
|
1536
1663
|
try {
|
|
@@ -1563,6 +1690,8 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1563
1690
|
jobId: ctx.jobId,
|
|
1564
1691
|
completed: outcome.status === 'done',
|
|
1565
1692
|
...(stopReason ? { stopReason } : {}),
|
|
1693
|
+
// ENG-300: a cancelled run keeps its branch and worktree locally — no push, no PR.
|
|
1694
|
+
...(ctx.signal ? { signal: ctx.signal } : {}),
|
|
1566
1695
|
});
|
|
1567
1696
|
branchLine = describeRunBranch(finished);
|
|
1568
1697
|
outcome.result = {
|
|
@@ -1575,9 +1704,14 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
|
|
|
1575
1704
|
...(finished.notes.length > 0 ? { branchNotes: finished.notes } : {}),
|
|
1576
1705
|
...(finished.keptWorktree ? { keptWorktree: finished.keptWorktree } : {}),
|
|
1577
1706
|
};
|
|
1707
|
+
// ENG-300: a cancel wins over any other outcome — the job is reported cancelled.
|
|
1708
|
+
if (finished.cancelled) {
|
|
1709
|
+
outcome.status = 'failed';
|
|
1710
|
+
outcome.result = { ...outcome.result, cancelled: true };
|
|
1711
|
+
}
|
|
1578
1712
|
// Work that isn't safely on a branch is never "done": the worktree was kept
|
|
1579
1713
|
// and the person needs to look at it.
|
|
1580
|
-
if (finished.needsAttention) {
|
|
1714
|
+
if (finished.needsAttention && !finished.cancelled) {
|
|
1581
1715
|
outcome.status = 'failed';
|
|
1582
1716
|
outcome.result = {
|
|
1583
1717
|
...outcome.result,
|