@mycompbox/compbox-cli 1.21.14 → 1.21.15

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.
@@ -23,7 +23,7 @@ import { mkdirSync } from "node:fs";
23
23
  import { mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
24
24
  import { homedir, tmpdir } from "node:os";
25
25
  import { join } from "node:path";
26
- import { resolveRouting, extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, renderConversationPrompt, runConversationStep, savedContextFromRecord, formatNeedsInputText, parseNeedsInputMarker, stripRunnerOnlyFields, } from "@mycompbox/shared";
26
+ import { resolveRouting, extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, renderConversationPrompt, contentText, runConversationStep, savedContextFromRecord, isConversationChatModel, formatNeedsInputText, parseNeedsInputMarker, stripRunnerOnlyFields, } from "@mycompbox/shared";
27
27
  // Completion parsing lives in @mycompbox/shared so CompBox's server-side
28
28
  // (API-key) interview finishes the same way; re-exported for existing callers.
29
29
  export { extractCompletionJson, looksLikeCompletionAttempt, meetsComplianceTarget, buildAuditFeedback, COMPLETION_REPAIR_INSTRUCTION, };
@@ -35,6 +35,7 @@ import { mergeGuardArgs, withMergeGuardPath } from "./merge-guard.js";
35
35
  import { keyRunArgs, keyRunEnv, parseClaudeJsonResult } from "./key-run.js";
36
36
  import { CANCEL_GRACE_MS, cancelledRunResult, groupSpawnOptions, killGroupOnAbort, killProcessGroupNow, terminateProcessGroup, } from "./process-group.js";
37
37
  import { startProgressWatcher } from "./progress-watcher.js";
38
+ import { parseClaudeStream } from "./claude-stream.js";
38
39
  import { classifyUsageLimit } from "./usage-limit.js";
39
40
  import { defaultCommandRunner, } from "./run-workspace.js";
40
41
  import { createWrapUp } from "./wrap-up.js";
@@ -43,6 +44,44 @@ import { createWrapUp } from "./wrap-up.js";
43
44
  // quality loss. Opus/Sonnet are deliberately NOT used here — pxpipe passes
44
45
  // Opus through uncompressed, defeating the token savings.
45
46
  const ANTHROPIC_MODEL = "claude-fable-5";
47
+ /**
48
+ * Request-conversation models (ENG-390): plain chat turns use the fast model so
49
+ * replies feel instant; turns that write up or improve a saved request (the
50
+ * save/compliance pass and JSON repairs) keep the stronger model.
51
+ */
52
+ export const CHAT_MODEL = "claude-haiku-5-5";
53
+ export const SAVE_MODEL = ANTHROPIC_MODEL;
54
+ /**
55
+ * The model for one AI call in a request conversation step. `chosenChatModel`
56
+ * (the person's pick from the job payload, ENG-390-2) applies to chat turns
57
+ * only; save and repair turns always keep SAVE_MODEL.
58
+ */
59
+ export function modelForTurn(kind, chosenChatModel = null) {
60
+ if (kind !== "chat")
61
+ return SAVE_MODEL;
62
+ return chosenChatModel ?? CHAT_MODEL;
63
+ }
64
+ /**
65
+ * The chat model the person picked for this request conversation, read from
66
+ * the job payload (an object, or the JSON string it is stored as). Only ids in
67
+ * the shared allowlist count; anything else, or no model, returns null so the
68
+ * caller falls back to CHAT_MODEL.
69
+ */
70
+ export function chosenChatModelOf(payload) {
71
+ let p = payload;
72
+ if (typeof p === "string") {
73
+ try {
74
+ p = JSON.parse(p);
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ }
80
+ if (typeof p !== "object" || p === null)
81
+ return null;
82
+ const model = p.model;
83
+ return isConversationChatModel(model) ? model : null;
84
+ }
46
85
  /** Per-turn wall-clock budget for a single `claude -p` child process. */
47
86
  const CLAUDE_CLI_TURN_TIMEOUT_MS = 4 * 60 * 1_000; // 4 minutes: a full write-up can take a while
48
87
  /**
@@ -517,25 +556,43 @@ export function claudeToolArgs(attachmentsDir) {
517
556
  `Read(/${attachmentsDir}/**)`,
518
557
  ];
519
558
  }
520
- function runClaudeCliTurn(prompt, opts) {
559
+ /**
560
+ * ENG-387: true when claude's stderr says it does not know
561
+ * `--include-partial-messages` (an older CLI), as opposed to any other failure.
562
+ */
563
+ function rejectsPartialMessagesFlag(stderr) {
564
+ return (stderr.includes("--include-partial-messages") &&
565
+ /unknown|unrecognized|invalid|unexpected|not supported/i.test(stderr));
566
+ }
567
+ export function runClaudeCliTurn(prompt, opts) {
521
568
  return new Promise((resolve, reject) => {
522
569
  const model = opts.model === undefined ? ANTHROPIC_MODEL : opts.model;
523
- const args = [
524
- "-p",
525
- prompt,
526
- ...(model ? ["--model", model] : []),
527
- "--output-format",
528
- "json",
529
- ...claudeToolArgs(opts.attachmentsDir),
530
- "--permission-mode",
531
- "dontAsk",
532
- "--safe-mode",
533
- "--system-prompt",
534
- opts.systemPrompt,
535
- ];
536
- if (opts.resumeSessionId) {
537
- args.push("--resume", opts.resumeSessionId);
538
- }
570
+ const onText = opts.onText;
571
+ const streaming = typeof onText === "function";
572
+ // ENG-387: `withPartial` adds --include-partial-messages (token deltas).
573
+ // An older claude CLI that rejects the flag gets one retry without it
574
+ // (whole assistant messages still stream as deltas) — see the close handler.
575
+ const buildArgs = (withPartial) => {
576
+ const args = [
577
+ "-p",
578
+ prompt,
579
+ ...(model ? ["--model", model] : []),
580
+ "--output-format",
581
+ ...(streaming
582
+ ? ["stream-json", "--verbose", ...(withPartial ? ["--include-partial-messages"] : [])]
583
+ : ["json"]),
584
+ ...claudeToolArgs(opts.attachmentsDir),
585
+ "--permission-mode",
586
+ "dontAsk",
587
+ "--safe-mode",
588
+ "--system-prompt",
589
+ opts.systemPrompt,
590
+ ];
591
+ if (opts.resumeSessionId) {
592
+ args.push("--resume", opts.resumeSessionId);
593
+ }
594
+ return args;
595
+ };
539
596
  // ENG-135: resolve `claude` to an absolute path using the login-shell PATH
540
597
  // + well-known install dirs. A launchd/GUI-spawned daemon inherits a PATH
541
598
  // that often lacks ~/.local/bin, so a bare-name spawn fails "not found on
@@ -547,67 +604,118 @@ function runClaudeCliTurn(prompt, opts) {
547
604
  // otherwise. Layered on top (ENG-135): augment PATH with the login-shell +
548
605
  // well-known dirs so the child (and any helpers it spawns) can be located.
549
606
  const pxpipeEnv = claudeSpawnEnv(process.env, opts.routing);
550
- const child = spawn(command, args, {
551
- cwd: claudeCliSessionCwd(),
552
- stdio: ["ignore", "pipe", "pipe"],
553
- env: { ...pxpipeEnv, PATH: claudeChildEnvPath(pxpipeEnv.PATH) },
554
- });
555
- let stdout = "";
556
- let stderr = "";
557
- let settled = false;
558
- const timer = setTimeout(() => {
559
- if (settled)
560
- return;
561
- settled = true;
562
- child.kill("SIGKILL");
563
- reject(new Error(`claude CLI timed out after ${String(CLAUDE_CLI_TURN_TIMEOUT_MS / 1000)}s`));
564
- }, CLAUDE_CLI_TURN_TIMEOUT_MS);
565
- child.stdout.on("data", (chunk) => {
566
- stdout += chunk.toString("utf-8");
567
- });
568
- child.stderr.on("data", (chunk) => {
569
- stderr += chunk.toString("utf-8");
570
- });
571
- child.on("error", (error) => {
572
- if (settled)
573
- return;
574
- settled = true;
575
- clearTimeout(timer);
576
- if (error.code === "ENOENT") {
577
- // ENG-135: actionable message naming every location that was searched.
578
- reject(new Error(claudeNotFoundMessage()));
579
- return;
580
- }
581
- reject(error);
582
- });
583
- child.on("close", (code) => {
584
- if (settled)
585
- return;
586
- settled = true;
587
- clearTimeout(timer);
588
- if (code !== 0) {
589
- reject(new Error(stderr.trim() || `claude CLI exited with code ${String(code ?? "null")}`));
590
- return;
591
- }
592
- let parsed;
593
- try {
594
- parsed = JSON.parse(stdout);
595
- }
596
- catch {
597
- reject(new Error(`claude CLI returned non-JSON output: ${stdout.slice(0, 500)}`));
598
- return;
599
- }
600
- const shaped = parsed;
601
- if (shaped.is_error) {
602
- reject(new Error(shaped.result ?? "claude CLI reported an error"));
603
- return;
604
- }
605
- if (typeof shaped.result !== "string" || typeof shaped.session_id !== "string") {
606
- reject(new Error("claude CLI returned an unexpected JSON shape (missing result/session_id)."));
607
- return;
608
- }
609
- resolve({ text: shaped.result, sessionId: shaped.session_id });
610
- });
607
+ const attempt = (withPartial) => {
608
+ const child = spawn(command, buildArgs(withPartial), {
609
+ cwd: claudeCliSessionCwd(),
610
+ stdio: ["ignore", "pipe", "pipe"],
611
+ env: { ...pxpipeEnv, PATH: claudeChildEnvPath(pxpipeEnv.PATH) },
612
+ });
613
+ let stdout = "";
614
+ let stderr = "";
615
+ let settled = false;
616
+ let sawStdout = false;
617
+ const stream = streaming ? parseClaudeStream() : null;
618
+ const emit = (deltas) => {
619
+ if (!onText || settled)
620
+ return;
621
+ for (const delta of deltas) {
622
+ try {
623
+ onText(delta);
624
+ }
625
+ catch {
626
+ // A failing listener must not break the turn itself.
627
+ }
628
+ }
629
+ };
630
+ const timer = setTimeout(() => {
631
+ if (settled)
632
+ return;
633
+ settled = true;
634
+ child.kill("SIGKILL");
635
+ reject(new Error(`claude CLI timed out after ${String(CLAUDE_CLI_TURN_TIMEOUT_MS / 1000)}s`));
636
+ }, CLAUDE_CLI_TURN_TIMEOUT_MS);
637
+ child.stdout.on("data", (chunk) => {
638
+ if (chunk.length > 0)
639
+ sawStdout = true;
640
+ if (stream) {
641
+ emit(stream.push(chunk));
642
+ return;
643
+ }
644
+ stdout += chunk.toString("utf-8");
645
+ });
646
+ child.stderr.on("data", (chunk) => {
647
+ stderr += chunk.toString("utf-8");
648
+ });
649
+ child.on("error", (error) => {
650
+ if (settled)
651
+ return;
652
+ settled = true;
653
+ clearTimeout(timer);
654
+ if (error.code === "ENOENT") {
655
+ // ENG-135: actionable message naming every location that was searched.
656
+ reject(new Error(claudeNotFoundMessage()));
657
+ return;
658
+ }
659
+ reject(error);
660
+ });
661
+ child.on("close", (code) => {
662
+ if (settled)
663
+ return;
664
+ if (stream) {
665
+ // Flush the trailing line before settling so its deltas still reach onText.
666
+ const { deltas, result } = stream.finish();
667
+ emit(deltas);
668
+ settled = true;
669
+ clearTimeout(timer);
670
+ if (code !== 0) {
671
+ // ENG-387: the CLI rejected --include-partial-messages before
672
+ // producing any output → retry once without it. Nothing reached
673
+ // onText yet, so the retry cannot duplicate deltas.
674
+ if (withPartial && !sawStdout && rejectsPartialMessagesFlag(stderr)) {
675
+ attempt(false);
676
+ return;
677
+ }
678
+ reject(new Error(stderr.trim() || `claude CLI exited with code ${String(code ?? "null")}`));
679
+ return;
680
+ }
681
+ if (result.isError) {
682
+ reject(new Error(result.text || "claude CLI reported an error"));
683
+ return;
684
+ }
685
+ if (!result.done || result.sessionId === null) {
686
+ reject(new Error("claude CLI stream ended without a result event (missing result/session_id)."));
687
+ return;
688
+ }
689
+ resolve({ text: result.text, sessionId: result.sessionId });
690
+ return;
691
+ }
692
+ settled = true;
693
+ clearTimeout(timer);
694
+ if (code !== 0) {
695
+ reject(new Error(stderr.trim() || `claude CLI exited with code ${String(code ?? "null")}`));
696
+ return;
697
+ }
698
+ let parsed;
699
+ try {
700
+ parsed = JSON.parse(stdout);
701
+ }
702
+ catch {
703
+ reject(new Error(`claude CLI returned non-JSON output: ${stdout.slice(0, 500)}`));
704
+ return;
705
+ }
706
+ const shaped = parsed;
707
+ if (shaped.is_error) {
708
+ reject(new Error(shaped.result ?? "claude CLI reported an error"));
709
+ return;
710
+ }
711
+ if (typeof shaped.result !== "string" || typeof shaped.session_id !== "string") {
712
+ reject(new Error("claude CLI returned an unexpected JSON shape (missing result/session_id)."));
713
+ return;
714
+ }
715
+ resolve({ text: shaped.result, sessionId: shaped.session_id });
716
+ });
717
+ };
718
+ attempt(streaming);
611
719
  });
612
720
  }
613
721
  // ---------------------------------------------------------------------
@@ -641,6 +749,41 @@ export function needsDefaultModel(error) {
641
749
  const message = error instanceof Error ? error.message : String(error);
642
750
  return /requires usage credits|switch to another model|model.*not available|not have access to/i.test(message);
643
751
  }
752
+ const MAX_CONVERSATION_SESSIONS = 50;
753
+ const conversationSessions = new Map();
754
+ function rememberConversationSession(jobId, session) {
755
+ conversationSessions.delete(jobId);
756
+ conversationSessions.set(jobId, session);
757
+ while (conversationSessions.size > MAX_CONVERSATION_SESSIONS) {
758
+ const oldest = conversationSessions.keys().next().value;
759
+ if (oldest === undefined)
760
+ break;
761
+ conversationSessions.delete(oldest);
762
+ }
763
+ }
764
+ /** Test hook: forget every remembered conversation session. */
765
+ export function resetConversationSessions() {
766
+ conversationSessions.clear();
767
+ }
768
+ /** A comparable fingerprint of one message as the AI saw it. */
769
+ export function sessionMessageKey(m) {
770
+ return `${m.role}\u0000${contentText(m.content)}`;
771
+ }
772
+ /**
773
+ * True when `next` starts with everything the session already saw and adds at
774
+ * least one new message; anything else (an edited or shortened history) means
775
+ * the session no longer matches and the turn must run fresh.
776
+ */
777
+ export function extendsSession(seen, next) {
778
+ if (next.length <= seen.length)
779
+ return false;
780
+ return seen.every((key, i) => next[i] === key);
781
+ }
782
+ /** The prompt for a resumed turn: only the messages the session hasn't seen. */
783
+ export function renderResumePrompt(fresh) {
784
+ const lines = fresh.map((m) => `${m.role === "assistant" ? "You" : "Them"}: ${contentText(m.content)}`);
785
+ return `${lines.join("\n\n")}\n\nWrite your next reply to them.`;
786
+ }
644
787
  function savedRequestIdOf(job) {
645
788
  const result = job.result;
646
789
  if (typeof result?.epicRequestId === "string")
@@ -670,6 +813,8 @@ export async function invokeEpicRequestStep(job, ctx) {
670
813
  }
671
814
  }
672
815
  async function takeConversationStep(job, ctx) {
816
+ // ENG-392: the clock starts as soon as the daemon picks the step up.
817
+ const timer = startTurnTimer();
673
818
  const routing = await resolveRouting();
674
819
  const requestId = savedRequestIdOf(job);
675
820
  const discussed = requestId !== null && parseSeedPayload(job.payload)?.targetEpicRequestId === requestId;
@@ -691,6 +836,7 @@ async function takeConversationStep(job, ctx) {
691
836
  saved,
692
837
  anthropic,
693
838
  attachmentsDir,
839
+ timer,
694
840
  });
695
841
  }
696
842
  finally {
@@ -698,8 +844,30 @@ async function takeConversationStep(job, ctx) {
698
844
  await rm(attachmentsDir, { recursive: true, force: true });
699
845
  }
700
846
  }
847
+ export function startTurnTimer(now = () => performance.now()) {
848
+ const startedAt = now();
849
+ let firstTextAt = null;
850
+ const elapsed = (at) => Math.max(0, Math.round(at - startedAt));
851
+ return {
852
+ markFirstText() {
853
+ firstTextAt ??= now();
854
+ },
855
+ finish(model) {
856
+ const metrics = {
857
+ firstTokenMs: firstTextAt === null ? null : elapsed(firstTextAt),
858
+ totalMs: elapsed(now()),
859
+ };
860
+ if (model)
861
+ metrics.model = model;
862
+ return metrics;
863
+ },
864
+ };
865
+ }
701
866
  async function converseWithAttachments(job, ctx, step) {
702
867
  const { routing, saved, anthropic, attachmentsDir } = step;
868
+ const timer = step.timer ?? startTurnTimer();
869
+ // ENG-392: the model that produced the last reply; null → the sign-in default.
870
+ let replyModel = null;
703
871
  let usedFiles = false;
704
872
  const turns = [];
705
873
  for (const [index, t] of job.turns.entries()) {
@@ -720,41 +888,82 @@ async function converseWithAttachments(job, ctx, step) {
720
888
  }
721
889
  }
722
890
  const readDir = usedFiles ? attachmentsDir : undefined;
723
- let cliModel = ANTHROPIC_MODEL;
891
+ // Once the person's plan rejects a chosen model, use their default for the rest of the step.
892
+ let useDefaultModel = false;
893
+ const chosenChatModel = chosenChatModelOf(job.payload);
724
894
  const outcome = await runConversationStep({ turns, saved }, {
725
- reply: async (system, messages) => {
895
+ reply: async (system, messages, kind) => {
896
+ const model = modelForTurn(kind, chosenChatModel);
726
897
  if (anthropic) {
727
898
  const response = await anthropic.messages.create({
728
- model: ANTHROPIC_MODEL,
899
+ model,
729
900
  max_tokens: 4096,
730
901
  system,
731
902
  messages,
732
903
  });
733
904
  const text = response.content.find((b) => b.type === "text");
734
- return text?.type === "text" ? text.text : "";
905
+ const reply = text?.type === "text" ? text.text : "";
906
+ replyModel = response.model || model;
907
+ if (reply)
908
+ timer.markFirstText();
909
+ return reply;
735
910
  }
736
- const prompt = renderConversationPrompt(messages);
737
- try {
738
- return (await runClaudeCliTurn(prompt, {
739
- systemPrompt: system,
740
- resumeSessionId: undefined,
741
- routing,
742
- model: cliModel,
743
- attachmentsDir: readDir,
744
- })).text;
911
+ // ENG-391: a later turn resumes this job's claude session and sends
912
+ // only what's new; if that fails, forget the session and run once
913
+ // fresh with the whole transcript.
914
+ const sent = messages.map(sessionMessageKey);
915
+ const runFresh = async () => {
916
+ const prompt = renderConversationPrompt(messages);
917
+ try {
918
+ return await runClaudeCliTurn(prompt, {
919
+ systemPrompt: system,
920
+ resumeSessionId: undefined,
921
+ routing,
922
+ model: useDefaultModel ? null : model,
923
+ attachmentsDir: readDir,
924
+ });
925
+ }
926
+ catch (error) {
927
+ if (useDefaultModel || !needsDefaultModel(error))
928
+ throw error;
929
+ useDefaultModel = true;
930
+ return await runClaudeCliTurn(prompt, {
931
+ systemPrompt: system,
932
+ resumeSessionId: undefined,
933
+ routing,
934
+ model: null,
935
+ attachmentsDir: readDir,
936
+ });
937
+ }
938
+ };
939
+ const session = conversationSessions.get(job.id);
940
+ let turn = null;
941
+ if (session && extendsSession(session.sent, sent)) {
942
+ try {
943
+ turn = await runClaudeCliTurn(renderResumePrompt(messages.slice(session.sent.length)), {
944
+ systemPrompt: system,
945
+ resumeSessionId: session.sessionId,
946
+ routing,
947
+ model: useDefaultModel ? null : model,
948
+ attachmentsDir: readDir,
949
+ });
950
+ }
951
+ catch {
952
+ turn = null;
953
+ }
745
954
  }
746
- catch (error) {
747
- if (cliModel === null || !needsDefaultModel(error))
748
- throw error;
749
- cliModel = null;
750
- return (await runClaudeCliTurn(prompt, {
751
- systemPrompt: system,
752
- resumeSessionId: undefined,
753
- routing,
754
- model: null,
755
- attachmentsDir: readDir,
756
- })).text;
955
+ if (!turn) {
956
+ conversationSessions.delete(job.id);
957
+ turn = await runFresh();
757
958
  }
959
+ rememberConversationSession(job.id, {
960
+ sessionId: turn.sessionId,
961
+ sent: [...sent, sessionMessageKey({ role: "assistant", content: turn.text })],
962
+ });
963
+ replyModel = useDefaultModel ? null : model;
964
+ if (turn.text)
965
+ timer.markFirstText();
966
+ return turn.text;
758
967
  },
759
968
  save: async (existingId, draft) => {
760
969
  const submitted = await submitAndScore(ctx, existingId, draft);
@@ -764,7 +973,7 @@ async function converseWithAttachments(job, ctx, step) {
764
973
  if (outcome.kind === "saved") {
765
974
  await ctx.mailboxClient.markRequestSaved(ctx.machineToken, job.id, outcome.saved.id);
766
975
  }
767
- await ctx.mailboxClient.postTurn(ctx.machineToken, job.id, outcome.text);
976
+ await ctx.mailboxClient.postTurn(ctx.machineToken, job.id, outcome.text, timer.finish(replyModel));
768
977
  return { status: "yield" };
769
978
  }
770
979
  // ---------------------------------------------------------------------
@@ -1722,7 +1931,9 @@ export function buildOrchestratorArgs(epicId, sessionId, ownerReply, baseBranch,
1722
1931
  : "") +
1723
1932
  (extra?.followUp ? `\n\n${followUpContext(extra.followUp)}` : "") +
1724
1933
  (extra?.ownerNote ? `\n\n${ownerNoteContext(extra.ownerNote)}` : "") +
1725
- (extra?.deferred && extra.deferred.length > 0 ? `\n\n${deferredFeaturesText(extra.deferred)}` : ""),
1934
+ (extra?.deferred && extra.deferred.length > 0
1935
+ ? `\n\n${deferredFeaturesText(extra.deferred)}`
1936
+ : ""),
1726
1937
  // A known session id lets the runner resume this same conversation when
1727
1938
  // the agent ends its turn early (see buildOrchestratorContinueArgs).
1728
1939
  ...(sessionId ? ["--session-id", sessionId] : []),
@@ -1811,7 +2022,9 @@ function parseReplyAttachments(raw) {
1811
2022
  if (typeof item !== "object" || item === null)
1812
2023
  continue;
1813
2024
  const a = item;
1814
- if (typeof a.id !== "string" || typeof a.mimeType !== "string" || typeof a.signedUrl !== "string")
2025
+ if (typeof a.id !== "string" ||
2026
+ typeof a.mimeType !== "string" ||
2027
+ typeof a.signedUrl !== "string")
1815
2028
  continue;
1816
2029
  if (a.signedUrl.trim() === "")
1817
2030
  continue;
@@ -1845,7 +2058,9 @@ export function parseReplyResume(job) {
1845
2058
  if (r.reply.trim() === "" && attachments.length === 0)
1846
2059
  return null;
1847
2060
  const str = (v) => (typeof v === "string" && v.trim() !== "" ? v : null);
1848
- const result = typeof job.result === "object" && job.result !== null ? job.result : {};
2061
+ const result = typeof job.result === "object" && job.result !== null
2062
+ ? job.result
2063
+ : {};
1849
2064
  return {
1850
2065
  sessionId: str(r.sessionId),
1851
2066
  runDir: str(r.runDir),
@@ -2010,7 +2225,7 @@ export function mergePullRequestsRequest(prs) {
2010
2225
  question: `${count} your review and merge before the build can continue.`,
2011
2226
  why: "The rest of the build builds on this work, so continuing now would redo it or conflict with it.",
2012
2227
  steps: prs.map((pr, i) => `${String(i + 1)}. Merge #${String(pr.number)}${pr.title ? ` ${pr.title}` : ""}: ${pr.htmlUrl}`),
2013
- afterAnswer: "The build continues by itself once they're merged. You can also press \"All merged — continue\".",
2228
+ afterAnswer: 'The build continues by itself once they\'re merged. You can also press "All merged — continue".',
2014
2229
  kind: "merge_prs",
2015
2230
  prNumbers: prs.map((pr) => pr.number),
2016
2231
  };
@@ -2580,7 +2795,10 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
2580
2795
  /** One run, then a resume of the same session for each note the owner sent during it. */
2581
2796
  const runDeliveringNotes = async (runArgsNow, budgetMs) => {
2582
2797
  let result = await runOnce(runArgsNow, budgetMs);
2583
- while (sessionId && pendingNotes.length > 0 && !ctx.signal?.aborted && deadline - Date.now() > 60_000) {
2798
+ while (sessionId &&
2799
+ pendingNotes.length > 0 &&
2800
+ !ctx.signal?.aborted &&
2801
+ deadline - Date.now() > 60_000) {
2584
2802
  const notes = pendingNotes.splice(0);
2585
2803
  try {
2586
2804
  await ctx.mailboxClient.postTurn(ctx.machineToken, ctx.jobId, `Got your note. Stopped the agent's current step and passed the note on; the build carries on from here.`);
@@ -2606,7 +2824,9 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
2606
2824
  (async () => {
2607
2825
  try {
2608
2826
  const job = await ctx.mailboxClient.postTurn(ctx.machineToken, ctx.jobId, `The orchestrator finished. Checking epic ${ctx.epicId}'s progress in CompBox…`);
2609
- return job.progress ? { ...job.progress, waitingPullRequests: job.waitingPullRequests ?? [] } : null;
2827
+ return job.progress
2828
+ ? { ...job.progress, waitingPullRequests: job.waitingPullRequests ?? [] }
2829
+ : null;
2610
2830
  }
2611
2831
  catch {
2612
2832
  return null;
@@ -2678,7 +2898,9 @@ export async function invokeStartExecutionOrchestrate(ctx, deps = {}) {
2678
2898
  ...outcome.result,
2679
2899
  fastMode: { requested: true, used: fastModeUsed },
2680
2900
  ...(fastModeUsed === false
2681
- ? { fastModeNote: "Fast mode was requested but isn't available on this computer's Claude account, so the run used standard speed." }
2901
+ ? {
2902
+ fastModeNote: "Fast mode was requested but isn't available on this computer's Claude account, so the run used standard speed.",
2903
+ }
2682
2904
  : {}),
2683
2905
  };
2684
2906
  }