pi-subagents 0.88.0 → 0.89.0

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +54 -1
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +3 -3
  4. package/bundle/{chunk-UVDLJXL6.js → chunk-2I6YN6ET.js} +34 -5
  5. package/bundle/{chunk-6EUQPQY7.js → chunk-443LPCRI.js} +5 -5
  6. package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
  7. package/bundle/{chunk-CKLZ5FGU.js → chunk-4ALRHKGE.js} +1 -1
  8. package/bundle/{chunk-SVIXQDIV.js → chunk-6JD4XCA4.js} +77 -19
  9. package/bundle/{chunk-RHYVKQQL.js → chunk-7W2IQFP4.js} +4 -4
  10. package/bundle/{chunk-W6HIYD2Z.js → chunk-A3INCQ6Z.js} +1 -1
  11. package/bundle/{chunk-4PM6RDE5.js → chunk-AZW4HXNU.js} +54 -36
  12. package/bundle/{chunk-XAOHLFJO.js → chunk-CHEABMO2.js} +68 -41
  13. package/bundle/{chunk-CYKNHFXB.js → chunk-EPMRDKQT.js} +1 -1
  14. package/bundle/{chunk-6PR44R7E.js → chunk-ETDE2VYK.js} +2 -2
  15. package/bundle/{chunk-4MVDMA5C.js → chunk-GHJ6BH5U.js} +13 -7
  16. package/bundle/{chunk-IZEKQEY4.js → chunk-HSHLPYCQ.js} +27 -10
  17. package/bundle/{chunk-3MFYKBKI.js → chunk-HZDLR73C.js} +4 -4
  18. package/bundle/{chunk-2DIEL4WG.js → chunk-JFACGAJT.js} +2 -2
  19. package/bundle/{chunk-L4YY2TOE.js → chunk-JRO2CU4D.js} +1 -1
  20. package/bundle/{chunk-KXW62VBU.js → chunk-KOLLMZ2X.js} +1 -1
  21. package/bundle/{chunk-47ZN7NKR.js → chunk-NONHDYXE.js} +1 -1
  22. package/bundle/{chunk-PJSOS2Q4.js → chunk-NQ26PJSQ.js} +96 -96
  23. package/bundle/{chunk-6OWNDN7R.js → chunk-PPPAEFRA.js} +2 -2
  24. package/bundle/{chunk-YDZ7BZD5.js → chunk-S77ZKDLS.js} +1 -1
  25. package/bundle/{chunk-3DT5X2QC.js → chunk-SLLZJ5EC.js} +50 -18
  26. package/bundle/{chunk-47GJDBIK.js → chunk-TGABNSG5.js} +5 -5
  27. package/bundle/{chunk-XIA5GSEU.js → chunk-UQT2EQ4U.js} +2 -2
  28. package/bundle/{chunk-YZPVALSQ.js → chunk-WW6GQBBS.js} +4 -4
  29. package/bundle/{chunk-4UGWHREQ.js → chunk-X5ZOTDHO.js} +95 -49
  30. package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
  31. package/bundle/{chunk-MTPICU4A.js → chunk-YX7R55CR.js} +75 -32
  32. package/bundle/{chunk-GDR2ILWY.js → chunk-ZSCIHMUI.js} +50 -22
  33. package/bundle/control-channel.js +2 -2
  34. package/bundle/index.js +2 -2
  35. package/bundle/intercom-bridge.js +2 -2
  36. package/bundle/preflight.js +9 -9
  37. package/bundle/project-panes.js +3 -3
  38. package/bundle/required-child-extensions.js +1 -1
  39. package/docs/agents.md +14 -6
  40. package/docs/configuration.md +2 -0
  41. package/docs/extension-api.md +1 -1
  42. package/docs/tool-reference.md +1 -1
  43. package/docs/workflows.md +8 -4
  44. package/package.json +1 -1
  45. package/src/extension/herdr-pi-bridge.js +78 -22
  46. package/src/extension/index.d.ts +1 -1
  47. package/src/extension/index.js +43 -20
  48. package/src/extension/schemas.js +1 -1
  49. package/src/extension/subagent-launch-tool.d.ts +6 -2
  50. package/src/extension/subagent-launch-tool.js +13 -9
  51. package/src/extension/subagent-options.js +5 -0
  52. package/src/intercom/result-intercom.js +3 -2
  53. package/src/runs/background/notify.d.ts +3 -0
  54. package/src/runs/background/notify.js +7 -2
  55. package/src/runs/background/run-status.js +3 -2
  56. package/src/runs/background/runner-child-launch.js +1 -0
  57. package/src/runs/background/stale-run-reconciler.js +17 -8
  58. package/src/runs/background/subagent-runner.js +11 -8
  59. package/src/runs/foreground/execution.js +8 -7
  60. package/src/runs/foreground/subagent-executor.js +42 -11
  61. package/src/runs/shared/child-launch.d.ts +2 -0
  62. package/src/runs/shared/child-launch.js +7 -4
  63. package/src/runs/shared/child-session.d.ts +3 -2
  64. package/src/runs/shared/child-session.js +3 -27
  65. package/src/runs/shared/herdr-connection.d.ts +6 -0
  66. package/src/runs/shared/herdr-connection.js +11 -1
  67. package/src/runs/shared/herdr-machine.d.ts +2 -2
  68. package/src/runs/shared/herdr-machine.js +47 -22
  69. package/src/runs/shared/herdr-pane-host.d.ts +7 -19
  70. package/src/runs/shared/herdr-pane-host.js +48 -33
  71. package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
  72. package/src/runs/shared/herdr-pi-protocol.js +3 -2
  73. package/src/runs/shared/herdr-placed-run.d.ts +2 -12
  74. package/src/runs/shared/herdr-placed-run.js +10 -8
  75. package/src/runs/shared/kept-branch-text.d.ts +8 -0
  76. package/src/runs/shared/kept-branch-text.js +24 -0
  77. package/src/runs/shared/local-machine-access.d.ts +4 -1
  78. package/src/runs/shared/local-machine-access.js +6 -3
  79. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -3
  80. package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -4
  81. package/src/runs/shared/mutation-evidence.d.ts +7 -1
  82. package/src/runs/shared/mutation-evidence.js +18 -2
  83. package/src/runs/shared/parallel-handoff.js +19 -7
  84. package/src/runs/shared/placed-run-owner.d.ts +4 -2
  85. package/src/runs/shared/placed-run-owner.js +15 -7
  86. package/src/runs/shared/rex-machine.d.ts +7 -3
  87. package/src/runs/shared/rex-machine.js +12 -9
  88. package/src/runs/shared/rex-pane-host.js +7 -27
  89. package/src/runs/shared/single-output.js +2 -2
  90. package/src/runs/shared/subagent-prompt-runtime.js +33 -0
  91. package/src/runs/shared/tool-availability.d.ts +4 -0
  92. package/src/runs/shared/tool-availability.js +7 -0
  93. package/src/runs/shared/worktree-cleanup-plan.js +2 -2
  94. package/src/runs/shared/worktree.d.ts +4 -14
  95. package/src/runs/shared/worktree.js +38 -8
  96. package/src/shared/compaction-interruption.d.ts +9 -0
  97. package/src/shared/compaction-interruption.js +47 -0
  98. package/src/shared/parent-wake.d.ts +3 -2
  99. package/src/shared/parent-wake.js +14 -3
  100. package/src/shared/required-child-extensions.d.ts +2 -0
  101. package/src/shared/required-child-extensions.js +27 -0
  102. package/src/shared/types.d.ts +26 -2
  103. package/src/tui/fleet.d.ts +7 -2
  104. package/src/tui/fleet.js +22 -0
  105. package/src/workflows/workflow-child-summary.d.ts +2 -1
  106. package/src/workflows/workflow-child-summary.js +14 -6
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import * as fs from "node:fs";
3
3
  import * as os from "node:os";
4
4
  import * as path from "node:path";
5
+ import { AgentSession } from "@earendil-works/pi-coding-agent";
5
6
  import { Box, Container, Spacer, Text } from "@earendil-works/pi-tui";
6
7
  import { clearAgentDiscoveryCache, discoverAgentSnapshot, discoverAgents, discoverAgentsAll } from "../agents/agents.js";
7
8
  import { resolveGlobalNpmRoot } from "../agents/global-npm-root.js";
@@ -13,6 +14,7 @@ import { cleanupAllArtifactDirs, cleanupOldArtifacts, getArtifactsDir } from "..
13
14
  import { resolveCurrentSessionId } from "../shared/session-identity.js";
14
15
  import { recordSessionReplacement, recordSessionStart } from "../shared/session-succession.js";
15
16
  import { createSessionSwitchGuard } from "./session-switch.js";
17
+ import { compactionInProgress, compactionInterruptedRun, installCompactionInterruptionCapture, takeCompactionAbort } from "../shared/compaction-interruption.js";
16
18
  import { reportSessionWarning } from "../shared/session-warnings.js";
17
19
  import { getAgentDir } from "../shared/utils.js";
18
20
  import { isStaleExtensionContextError, MODEL_ONLY_TOOL, withCachedUiContext } from "../shared/extension-context.js";
@@ -215,6 +217,7 @@ export default function registerSubagentExtension(pi) {
215
217
  if (process.env[SUBAGENT_CHILD_ENV] === "1") {
216
218
  return;
217
219
  }
220
+ installCompactionInterruptionCapture(AgentSession);
218
221
  const runtimeRegistry = getRuntimeRegistry();
219
222
  setMainThinkingLevelSource(() => readMainThinkingLevel(() => pi.getThinkingLevel()));
220
223
  DIRS.results = ensureAccessibleDir(DIRS.results);
@@ -747,7 +750,7 @@ export default function registerSubagentExtension(pi) {
747
750
  try {
748
751
  // The run is still active here, so its signal tells a user stop (Esc) apart from a finished or failed run.
749
752
  // Pi skips agent_before_settle after an abort. Background runs keep going, but they must not restart the parent.
750
- if (ctx.hasUI && ctx.signal?.aborted) {
753
+ if (ctx.hasUI && ctx.signal?.aborted && !takeCompactionAbort(ctx.sessionManager)) {
751
754
  parentWake.userAborted();
752
755
  const active = activeAsyncJobCount();
753
756
  if (active > 0)
@@ -1110,7 +1113,12 @@ export default function registerSubagentExtension(pi) {
1110
1113
  }
1111
1114
  };
1112
1115
  let compactionResumeTimer;
1113
- const cancelCompactionResume = () => { clearTimeout(compactionResumeTimer); compactionResumeTimer = undefined; };
1116
+ let compactionInterruptedParent = false;
1117
+ const cancelCompactionResume = () => {
1118
+ clearTimeout(compactionResumeTimer);
1119
+ compactionResumeTimer = undefined;
1120
+ compactionInterruptedParent = false;
1121
+ };
1114
1122
  pi.on("agent_start", () => {
1115
1123
  cancelCompactionResume();
1116
1124
  parentWake.agentStarted();
@@ -1132,38 +1140,53 @@ export default function registerSubagentExtension(pi) {
1132
1140
  if (event.reason !== "manual")
1133
1141
  suspendWidgetsForCompaction();
1134
1142
  });
1135
- // Pi emits session_compact before it clears its compaction state. sendMessage's run path has no
1136
- // compaction guard (only prompt() refuses), so wait for the parent to go idle before the resume notice
1137
- // starts a run. A run that starts first cancels the pending resume.
1138
- pi.on("session_compact", (event) => {
1143
+ // parentWake only appends wakes during a manual compaction. Once every overlapping compaction has ended, wake
1144
+ // the parent once if a wake was deferred, or if a successful compaction cut off a working parent with
1145
+ // background work (Pi never continues that run). Pi emits session_compact before it clears its compaction
1146
+ // state, so wait until the session is idle and compact() has returned. A run that starts first cancels it.
1147
+ const wakeAfterCompaction = (completed) => (event, ctx) => {
1139
1148
  if (event.reason !== "manual")
1140
1149
  return;
1141
- if (activeAsyncJobCount() === 0 || !withLastUiContext(() => true))
1150
+ const sessionManager = ctx.sessionManager;
1151
+ if (completed && compactionInterruptedRun(sessionManager))
1152
+ compactionInterruptedParent = true;
1153
+ if (compactionResumeTimer)
1142
1154
  return;
1143
- cancelCompactionResume();
1144
1155
  const sessionId = state.currentSessionId;
1145
1156
  const deadline = Date.now() + COMPACTION_RESUME_DEADLINE_MS;
1146
- const resumeWhenIdle = () => {
1147
- if (state.currentSessionId !== sessionId || activeAsyncJobCount() === 0)
1157
+ const wakeWhenIdle = () => {
1158
+ compactionResumeTimer = undefined;
1159
+ if (state.currentSessionId !== sessionId)
1148
1160
  return;
1149
- const idle = withLastUiContext((ctx) => ctx.isIdle());
1150
- if (idle === undefined)
1151
- return;
1152
- if (!idle) {
1161
+ let idle;
1162
+ try {
1163
+ idle = ctx.isIdle();
1164
+ }
1165
+ catch {
1166
+ return; // Replaced or reloaded: the new session's runtime owns its notices.
1167
+ }
1168
+ // Past the deadline the next compaction event polls again.
1169
+ if (!idle || compactionInProgress(sessionManager)) {
1153
1170
  if (Date.now() < deadline)
1154
- compactionResumeTimer = setTimeout(resumeWhenIdle, COMPACTION_RESUME_POLL_MS);
1171
+ compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
1155
1172
  return;
1156
1173
  }
1157
- // Pi's compact() aborts a live run first, which set the user-abort hold; this resume is deliberate.
1158
- parentWake.releaseHold();
1174
+ const interrupted = compactionInterruptedParent && activeAsyncJobCount() > 0 && withLastUiContext(() => true) === true;
1175
+ compactionInterruptedParent = false;
1176
+ if (!parentWake.takeDeferredWake() && !interrupted)
1177
+ return;
1159
1178
  parentWake.sendMessage({
1160
1179
  customType: "subagent-compaction-resume",
1161
- content: "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready.",
1180
+ content: interrupted
1181
+ ? "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready."
1182
+ : "Compaction is complete. Act on the background subagent notices above.",
1162
1183
  display: false,
1163
1184
  }, { triggerTurn: true });
1164
1185
  };
1165
- compactionResumeTimer = setTimeout(resumeWhenIdle, COMPACTION_RESUME_POLL_MS);
1166
- });
1186
+ compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
1187
+ };
1188
+ pi.on("session_compact", wakeAfterCompaction(true));
1189
+ pi.on("session_compact_failed", wakeAfterCompaction(false));
1167
1190
  pi.on("session_start", (event, ctx) => {
1168
1191
  parentWake.bindSession(ctx);
1169
1192
  completionNotifier.bindSession(ctx.sessionManager);
@@ -227,7 +227,7 @@ const SubagentParamProperties = {
227
227
  usageBudget: Type.Optional(UsageBudgetOverride),
228
228
  agentScope: Type.Optional(Type.String({ description: "user/project/both (default); project wins collisions." })),
229
229
  cwd: Type.Optional(Type.String({ description: "Execution/project-pane directory." })),
230
- machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or \"local\" (a Pi child in a Rex pane here). On another machine, cwd is a directory there." })),
230
+ machine: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or \"local\" (a Pi child in a new tab of the Herdr or Rex session this Pi runs in). On another machine, cwd is a directory there." })),
231
231
  requireLauncher: Type.Optional(Type.Object({
232
232
  name: Type.String({ pattern: RUNNER_LAUNCHER_NAME_PATTERN.source }),
233
233
  definitionDigest: Type.String({ pattern: "^[0-9a-f]{64}$" }),
@@ -20,6 +20,10 @@ declare const parameters: Type.TObject<{
20
20
  export type SubagentLaunchArgs = Static<typeof parameters>;
21
21
  /** Not declared to the model, so the system prompt and tool list stay unchanged. */
22
22
  export declare function registerSubagentLaunchTool(pi: ExtensionAPI): void;
23
- /** Offers a workflow child start to the session's `tool_call` handlers; returns the refusal, if any. */
24
- export declare function approveWorkflowChildLaunch(ctx: ExtensionContext, describe: () => SubagentLaunchArgs, signal: AbortSignal): Promise<string | undefined>;
23
+ /** Offers a workflow child start to the session's `tool_call` handlers; returns the refusal, or the task the handlers left. */
24
+ export declare function approveWorkflowChildLaunch(ctx: ExtensionContext, describe: () => SubagentLaunchArgs, signal: AbortSignal): Promise<{
25
+ refusal: string;
26
+ } | {
27
+ task?: string;
28
+ }>;
25
29
  export {};
@@ -22,27 +22,31 @@ export function registerSubagentLaunchTool(pi) {
22
22
  pi.registerTool({
23
23
  name: SUBAGENT_LAUNCH_TOOL,
24
24
  label: "Subagent launch",
25
- description: "A workflow is about to start this subagent. Blocking this call stops that child from starting.",
25
+ description: "A workflow is about to start this subagent. Blocking this call stops that child from starting; changing its task changes what the child is told.",
26
26
  parameters,
27
27
  exposure: "deferred",
28
- async execute() {
29
- return { content: [{ type: "text", text: "Records approval for a workflow child launch; it starts nothing itself." }], details: {} };
28
+ // Pi hands execute the input after every tool_call handler ran, so a handler's change to task arrives here.
29
+ async execute(_toolCallId, params) {
30
+ return { content: [{ type: "text", text: "Records approval for a workflow child launch; it starts nothing itself." }], details: { task: params.task } };
30
31
  },
31
32
  });
32
33
  }
33
- /** Offers a workflow child start to the session's `tool_call` handlers; returns the refusal, if any. */
34
+ /** Offers a workflow child start to the session's `tool_call` handlers; returns the refusal, or the task the handlers left. */
34
35
  export async function approveWorkflowChildLaunch(ctx, describe, signal) {
35
36
  // Starts with no tool call behind them (schedule ticks, auto-resume, RPC) have no executeTool, and a tool
36
37
  // allowlist that leaves the tool out unregisters it: no handler could see the call in either case.
37
38
  if (!("executeTool" in ctx))
38
- return undefined;
39
+ return {};
39
40
  const toolCtx = ctx;
40
41
  if (!toolCtx.tools.some((tool) => tool.name === SUBAGENT_LAUNCH_TOOL))
41
- return undefined;
42
+ return {};
42
43
  const args = describe();
43
44
  const outcome = await toolCtx.executeTool(SUBAGENT_LAUNCH_TOOL, args, { signal });
44
- if (!outcome.isError)
45
- return undefined;
45
+ if (!outcome.isError) {
46
+ // Pi doesn't validate the input again after a handler changes it.
47
+ const task = outcome.result.details?.task;
48
+ return { task: typeof task === "string" ? task : undefined };
49
+ }
46
50
  const reason = outcome.result.content.flatMap((block) => block.type === "text" ? [block.text] : []).join("\n").trim();
47
- return `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}`;
51
+ return { refusal: `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}` };
48
52
  }
@@ -12,6 +12,11 @@ const optionsValidator = Compile(SubagentOptionParams);
12
12
  * Management fields given at the top level keep working, as in the flat shape older sessions declared.
13
13
  */
14
14
  export function flattenSubagentToolOptions(params, disabled) {
15
+ // Some models fill every unset optional parameter with the string "null", and the workflow union with "false" (#3285).
16
+ params = Object.fromEntries(Object.entries(params).filter(([key, value]) => value !== "null" && !(key === "workflow" && value === "false")));
17
+ if (params.options && typeof params.options === "object" && !Array.isArray(params.options)) {
18
+ params.options = Object.fromEntries(Object.entries(params.options).filter(([, value]) => value !== "null"));
19
+ }
15
20
  const removedTopLevel = removedModelWorkflowFieldError(params);
16
21
  if (removedTopLevel)
17
22
  throw new Error(removedTopLevel);
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import * as fs from "node:fs";
3
3
  import { isUnexplainedProcessSignal } from "../runs/shared/process-signal.js";
4
+ import { formatParallelHandoffLines } from "../runs/shared/kept-branch-text.js";
4
5
  import { SUBAGENT_RESULT_INTERCOM_DELIVERY_EVENT, SUBAGENT_RESULT_INTERCOM_EVENT, } from "../shared/types.js";
5
6
  export function resolveSubagentResultStatus(input) {
6
7
  if (input.detached)
@@ -223,7 +224,7 @@ function formatSubagentResultIntercomMessage(input) {
223
224
  if (input.asyncDir)
224
225
  lines.push(`Async dir: ${input.asyncDir}`);
225
226
  if (input.parallelHandoff)
226
- lines.push(`Parallel handoff: ${input.parallelHandoff.path}`);
227
+ lines.push(...formatParallelHandoffLines(input.parallelHandoff.path, input.parallelHandoff.keptBranches));
227
228
  const resumeGuidance = asyncResumeGuidance(input);
228
229
  if (resumeGuidance)
229
230
  lines.push(resumeGuidance);
@@ -345,7 +346,7 @@ export function formatSubagentResultReceipt(input) {
345
346
  `Children: ${formatStatusCounts(counts)}`,
346
347
  ];
347
348
  if (input.payload.parallelHandoff)
348
- lines.push(`Parallel handoff: ${input.payload.parallelHandoff.path}`);
349
+ lines.push(...formatParallelHandoffLines(input.payload.parallelHandoff.path, input.payload.parallelHandoff.keptBranches));
349
350
  const artifacts = input.payload.children.filter((child) => typeof child.artifactPath === "string");
350
351
  if (artifacts.length > 0) {
351
352
  lines.push("Artifacts:");
@@ -8,6 +8,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
8
8
  import { type CompletionBatchConfig } from "./completion-batcher.ts";
9
9
  import { type ChildWatchdogProgress, type ChildWatchdogWarningSummary, type ParallelHandoffReference, type ScheduleOrigin, type SubagentState } from "../../shared/types.ts";
10
10
  import { type ParentWake } from "../../shared/parent-wake.ts";
11
+ import { type KeptBranch } from "../shared/kept-branch-text.ts";
11
12
  import type { ResultDeliveryOwnership } from "./result-delivery-ownership.ts";
12
13
  export interface SubagentNotifyChildOutput {
13
14
  workflowKey?: string;
@@ -54,6 +55,8 @@ export interface SubagentNotifyDetails {
54
55
  sessionLabel?: string;
55
56
  sessionValue?: string;
56
57
  handoffPath?: string;
58
+ /** Branches worktree cleanup kept because their commits are on no other ref. */
59
+ keptBranches?: KeptBranch[];
57
60
  /** Present when a durable schedule launched the run. */
58
61
  scheduleOrigin?: ScheduleOrigin;
59
62
  watchdogBlockers?: SubagentNotifyWatchdogBlocker[];
@@ -13,6 +13,7 @@ import { COMPLETION_ACTION } from "../../shared/parent-wake.js";
13
13
  import { resolveSubagentResultStatus } from "../../intercom/result-intercom.js";
14
14
  import { isUnexplainedProcessSignal } from "../shared/process-signal.js";
15
15
  import { capSummaryOutputs } from "../shared/single-output.js";
16
+ import { formatParallelHandoffLines, parseKeptBranchLines, readKeptBranches } from "../shared/kept-branch-text.js";
16
17
  import { describeWorkflowResume } from "../../workflows/workflow-resume-claim.js";
17
18
  import { isReusableWorkflowStopCause } from "../../workflows/workflow-stop-cause.js";
18
19
  const CHILD_OUTPUT_PREVIEW_MAX_BYTES = 2_000;
@@ -228,7 +229,7 @@ export function formatSingleCompletion(details) {
228
229
  formatResultPreview(details),
229
230
  ...(watchdogLines.length ? ["", ...watchdogLines] : []),
230
231
  details.handoffPath ? "" : undefined,
231
- details.handoffPath ? `Parallel handoff: ${details.handoffPath}` : undefined,
232
+ ...(details.handoffPath ? formatParallelHandoffLines(details.handoffPath, details.keptBranches) : []),
232
233
  correlationLines.length && !details.handoffPath ? "" : undefined,
233
234
  ...correlationLines,
234
235
  sessionLine ? "" : undefined,
@@ -308,6 +309,7 @@ export function parseSubagentNotifyContent(content) {
308
309
  const resultEnd = firstMetadataIndex > 0 && body[firstMetadataIndex - 1]?.trim() === "" ? firstMetadataIndex - 1 : firstMetadataIndex;
309
310
  const resultPreview = body.slice(0, resultEnd).join("\n").trim() || "(no output)";
310
311
  const handoffPath = handoffIndex >= 0 ? body[handoffIndex].slice("Parallel handoff: ".length).trim() : undefined;
312
+ const keptBranches = handoffIndex >= 0 ? parseKeptBranchLines(body.slice(handoffIndex + 1)) : [];
311
313
  const workflowRunId = workflowRunIndex >= 0 ? body[workflowRunIndex].slice("Workflow run: ".length).trim() : undefined;
312
314
  const childRuns = childRunsIndex >= 0
313
315
  ? body[childRunsIndex].slice("Child runs: ".length).split(", ").map((part) => {
@@ -337,6 +339,7 @@ export function parseSubagentNotifyContent(content) {
337
339
  ...(workflowReceiptPath ? { workflowReceiptPath } : {}),
338
340
  resultPreview,
339
341
  ...(handoffPath ? { handoffPath } : {}),
342
+ ...(keptBranches.length ? { keptBranches } : {}),
340
343
  ...(workflowRunId ? { workflowRunId } : {}),
341
344
  ...(resumeNotice ? { resumeNotice } : {}),
342
345
  ...(childRuns?.length ? { childRuns } : {}),
@@ -359,7 +362,7 @@ export function formatGroupedCompletion(details) {
359
362
  blocks.push(formatResultPreview(detail));
360
363
  blocks.push(...formatWatchdogBlockerLines(detail));
361
364
  if (detail.handoffPath)
362
- blocks.push(`Parallel handoff: ${detail.handoffPath}`);
365
+ blocks.push(...formatParallelHandoffLines(detail.handoffPath, detail.keptBranches));
363
366
  blocks.push(...formatCorrelationLines(detail));
364
367
  if (sessionLine)
365
368
  blocks.push(sessionLine);
@@ -542,6 +545,7 @@ export function buildCompletionDetails(result) {
542
545
  ? result.parallelHandoff
543
546
  : undefined;
544
547
  const handoffPath = typeof parallelHandoff?.path === "string" ? parallelHandoff.path : undefined;
548
+ const keptBranches = readKeptBranches(parallelHandoff?.keptBranches);
545
549
  const receipt = result.workflowReceipt;
546
550
  const receiptPath = receipt && typeof receipt === "object" && !Array.isArray(receipt)
547
551
  ? receipt.path : undefined;
@@ -661,6 +665,7 @@ export function buildCompletionDetails(result) {
661
665
  resultPreview: watchdogConcerns.length ? `${resultPreview}\n\nHigh-importance watchdog concerns:\n${watchdogConcerns.map((warning) => `- ${warning}`).join("\n")}` : resultPreview,
662
666
  ...(typeof result.durationMs === "number" ? { durationMs: result.durationMs } : {}),
663
667
  ...(handoffPath ? { handoffPath } : {}),
668
+ ...(handoffPath && keptBranches.length ? { keptBranches } : {}),
664
669
  ...(rawRunId ? { runId: rawRunId } : {}),
665
670
  ...(workflowRunId ? { workflowRunId } : {}),
666
671
  ...(resumeNotice ? { resumeNotice } : {}),
@@ -35,6 +35,7 @@ import { validHostStepNodes } from "../shared/host-step-status.js";
35
35
  import { workflowAsyncChildSteeringGuidance } from "../shared/workflow-async-child-guidance.js";
36
36
  import { formatWorkflowKeyRevival, projectWorkflowKeyRevival } from "../../workflows/workflow-revival.js";
37
37
  import { capSummaryOutputs } from "../shared/single-output.js";
38
+ import { formatParallelHandoffLines } from "../shared/kept-branch-text.js";
38
39
  import { ownsRun } from "../shared/run-ownership.js";
39
40
  import { foregroundChildStateLabel } from "../foreground/foreground-history.js";
40
41
  import { waitToolName } from "../../shared/wait-tool-name.js";
@@ -632,7 +633,7 @@ export function inspectSubagentStatus(params, deps = {}) {
632
633
  status.turnBudget ? `Turn budget: ${status.turnBudget.turnCount}/${status.turnBudget.maxTurns}+${status.turnBudget.graceTurns} (${status.turnBudget.outcome})` : undefined,
633
634
  `Dir: ${asyncDir}`,
634
635
  outputPath ? `Output: ${outputPath}` : undefined,
635
- status.parallelHandoff ? `Parallel handoff: ${status.parallelHandoff.path}` : undefined,
636
+ ...(status.parallelHandoff ? formatParallelHandoffLines(status.parallelHandoff.path, status.parallelHandoff.keptBranches) : []),
636
637
  reconciliation.message ? `Diagnosis: ${reconciliation.message}` : undefined,
637
638
  reconciliation.resultPath && fs.existsSync(reconciliation.resultPath) ? `Result: ${reconciliation.resultPath}` : undefined,
638
639
  ].filter((line) => Boolean(line));
@@ -807,7 +808,7 @@ export function inspectSubagentStatus(params, deps = {}) {
807
808
  const runId = data.runId ?? data.id ?? resolvedId;
808
809
  const lines = [`Run: ${runId}`, data.toolCallId ? `Tool call: ${data.toolCallId}` : undefined, `State: ${status}`, `Result: ${resultPath}`].filter((line) => Boolean(line));
809
810
  if (data.parallelHandoff?.path)
810
- lines.push(`Parallel handoff: ${data.parallelHandoff.path}`);
811
+ lines.push(...formatParallelHandoffLines(data.parallelHandoff.path, data.parallelHandoff.keptBranches));
811
812
  const receipt = data.workflowReceipt;
812
813
  const receiptPath = receipt && typeof receipt === "object" && !Array.isArray(receipt)
813
814
  ? receipt.path : undefined;
@@ -14,6 +14,7 @@ export function buildRunnerChildLaunch(step, ctx, attempt) {
14
14
  machine: step.machine,
15
15
  remoteSkillNames: step.skills,
16
16
  remoteReads: step.remoteReads,
17
+ acceptancePrompt,
17
18
  parentSessionId: step.parentSessionId,
18
19
  parentSessionFile: step.parentSessionFile,
19
20
  forkCacheKey: step.context === "fork" ? deriveForkPromptCacheKey(step.parentSessionId) : undefined,
@@ -450,8 +450,23 @@ export function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
450
450
  const existingResultPath = effectiveStatus.sessionId
451
451
  ? resultPayloadPathForSessionRun(resultsDir, effectiveStatus.sessionId, runId) ?? (regularFileExists(resultPath) ? resultPath : undefined)
452
452
  : regularFileExists(resultPath) ? resultPath : undefined;
453
+ const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1000;
454
+ const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
455
+ const observedScope = options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope();
456
+ const runnerLiveness = (pid) => checkRecordedPidLiveness({ pid, pidNamespaceScope: effectiveStatus.pidNamespaceScope, bootId: effectiveStatus.bootId }, {
457
+ kill: options.kill,
458
+ observedScope,
459
+ observedBootId: options.bootId ? options.bootId() : currentBootId(),
460
+ });
453
461
  if (existingResultPath) {
454
- const terminalStatus = effectiveStatus.state === "running" || effectiveStatus.state === "queued"
462
+ // A live runner writes its result before its final status; repairing in that window would replace
463
+ // its pending exit proof with a placeholder. Only a confirmed-alive pid defers: a result is better
464
+ // evidence than an unprobeable pid, and a pid from another pid namespace can be alive here as an unrelated
465
+ // process. A workflow's pid is its host Pi process, which outlives the workflow.
466
+ const runnerStillFinishing = effectiveStatus.state === "running" && effectiveStatus.mode !== "workflow" && typeof effectiveStatus.pid === "number"
467
+ && effectiveStatus.pidNamespaceScope === observedScope
468
+ && now - lastUpdate <= staleAfterMs && runnerLiveness(effectiveStatus.pid) === "alive";
469
+ const terminalStatus = (effectiveStatus.state === "running" || effectiveStatus.state === "queued") && !runnerStillFinishing
455
470
  ? terminalStatusFromResult(effectiveStatus, existingResultPath, now)
456
471
  : undefined;
457
472
  if (terminalStatus) {
@@ -491,14 +506,8 @@ export function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
491
506
  return { status: null, repaired: false, resultPath };
492
507
  }
493
508
  }
494
- const liveness = checkRecordedPidLiveness({ pid: effectiveStatus.pid, pidNamespaceScope: effectiveStatus.pidNamespaceScope, bootId: effectiveStatus.bootId }, {
495
- kill: options.kill,
496
- observedScope: options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope(),
497
- observedBootId: options.bootId ? options.bootId() : currentBootId(),
498
- });
509
+ const liveness = runnerLiveness(effectiveStatus.pid);
499
510
  if (liveness !== "dead") {
500
- const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1000;
501
- const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
502
511
  if (now - lastUpdate <= staleAfterMs)
503
512
  return { status: status ?? null, repaired: false, resultPath };
504
513
  const probe = liveness === "alive" ? "is still live" : "cannot be probed from this process";
@@ -44,7 +44,7 @@ import { outputEntryFromAsyncResult, resolveOutputReferences } from "../shared/c
44
44
  import { clearStructuredOutputCaptures, createStructuredOutputFileCapture, createStructuredOutputRuntime, formatStructuredOutputRejectionError, MISSING_STRUCTURED_OUTPUT_CALL_ERROR, readStructuredOutput, readStructuredOutputAcceptanceReport } from "../shared/structured-output.js";
45
45
  import { formatMidToolExitError, isOrdinaryToolForMidToolExit, isUnexplainedProcessSignal } from "../shared/process-signal.js";
46
46
  import { formatChildToolDiagnostic } from "../shared/tool-availability.js";
47
- import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, snapshotTrackedMutations } from "../shared/mutation-evidence.js";
47
+ import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, remoteMutationEvidence, remoteMutationSnapshot, snapshotTrackedMutations } from "../shared/mutation-evidence.js";
48
48
  import { collectDynamicResults, DynamicFanoutError, materializeDynamicParallelStep, validateDynamicCollection } from "../shared/dynamic-fanout.js";
49
49
  import { claimRunFanoutBatch, getRunFanoutBudgetSnapshot } from "../shared/run-fanout-budget.js";
50
50
  import { nestedSummaryFromAsyncStatus, projectNestedEvents, resolveNestedAsyncDir, writeNestedEvent } from "../shared/nested-events.js";
@@ -79,7 +79,7 @@ import { resolveCodexExecLaunch } from "../shared/codex-exec-adapter.js";
79
79
  import { resolveCursorAgentLaunch } from "../shared/cursor-agent-adapter.js";
80
80
  import { resolveExternalCliRunnerStatus } from "../shared/external-cli-contract.js";
81
81
  import { formatHerdrMachineHint, prepareHerdrMachineExternalCliRun } from "../shared/herdr-machine.js";
82
- import { isRexLocalMachine } from "../shared/rex-machine.js";
82
+ import { editsLocalDisk } from "../shared/rex-machine.js";
83
83
  import { HerdrExternalNeedsAttentionError, createHerdrExternalAdapter, prepareInternalHerdrExternalAdapter } from "../shared/herdr-external-adapters.js";
84
84
  import { runExternalJob } from "../shared/external-job-runner.js";
85
85
  import { createOrcaProgressTab } from "../shared/orca-progress-tabs.js";
@@ -606,6 +606,8 @@ export async function runSingleStepInner(step, ctx) {
606
606
  if (step.machine) {
607
607
  if (step.machine.provider !== "herdr")
608
608
  throw new Error("Rex supports native Pi children only.");
609
+ if (!("target" in step.machine))
610
+ throw new Error("Machine 'local' runs native Pi children only.");
609
611
  const runner = resolveExternalCliRunnerStatus({ ...step.runner, machine: step.machine });
610
612
  const outputSnapshot = captureSingleOutputSnapshot(step.outputPath);
611
613
  const placedRunId = `${ctx.id}-${ctx.flatIndex}`;
@@ -762,7 +764,7 @@ export async function runSingleStepInner(step, ctx) {
762
764
  }
763
765
  const effectiveCwd = step.cwd ?? ctx.cwd;
764
766
  // A placed child's cwd is a directory on its machine; only machine 'local' shares this disk.
765
- const cwdError = step.machine && !isRexLocalMachine(step.machine) ? undefined : preflightLaunchCwd(step.requestedCwd ?? effectiveCwd, effectiveCwd);
767
+ const cwdError = step.machine && !editsLocalDisk(step.machine) ? undefined : preflightLaunchCwd(step.requestedCwd ?? effectiveCwd, effectiveCwd);
766
768
  if (cwdError)
767
769
  return { agent: step.agent, output: cwdError, error: cwdError, exitCode: 1, context: step.context };
768
770
  if (step.context === "fork" && step.sessionFile && fs.existsSync(step.sessionFile)) {
@@ -781,7 +783,7 @@ export async function runSingleStepInner(step, ctx) {
781
783
  let toolBudgetBlocked = false;
782
784
  let actualLaunchContractDigest = step.launchContractDigest;
783
785
  // A machine 'local' child edits this disk, so its local Git evidence is authoritative, as for an unplaced run.
784
- const mutationSnapshot = step.machine && !isRexLocalMachine(step.machine) ? { source: "tracked-files", trackedOnly: true, cwd: step.cwd ?? ctx.cwd, dirtyFiles: [], fingerprints: {}, unavailable: "Local Git evidence is not authoritative for a pane-native remote run." } : snapshotTrackedMutations(step.cwd ?? ctx.cwd);
786
+ const mutationSnapshot = step.machine && !editsLocalDisk(step.machine) ? remoteMutationSnapshot(step.cwd ?? ctx.cwd) : snapshotTrackedMutations(step.cwd ?? ctx.cwd);
785
787
  let finalMutationEvidence = await collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
786
788
  let contextOverflow = false;
787
789
  let launchWarningsEmitted = false;
@@ -944,7 +946,9 @@ export async function runSingleStepInner(step, ctx) {
944
946
  // A parked run still owes output diagnostics when it actually finishes.
945
947
  // Stopped/timedOut runs already have terminal failures, so terminal output diagnostics are deferred.
946
948
  const terminalDiagnosticsEligible = !run.interrupted && !run.stopped && !run.timedOut;
947
- const toolDiagnostic = run.exitCode === 0 && !run.error ? launch.capture.toolDiagnostic() : undefined;
949
+ const recordedToolDiagnostic = launch.capture.toolDiagnostic();
950
+ // An undeclared allowlisted tool aborts the child itself, so its diagnostic explains that abort's error.
951
+ const toolDiagnostic = (run.exitCode === 0 && !run.error) || recordedToolDiagnostic?.undeclared ? recordedToolDiagnostic : undefined;
948
952
  const toolAvailabilityError = toolDiagnostic ? formatChildToolDiagnostic(toolDiagnostic) : undefined;
949
953
  const runtimeAcknowledgedExtensions = launch.capture.runtimeAcknowledgedExtensions();
950
954
  const midToolExitError = run.currentTool
@@ -1007,8 +1011,7 @@ export async function runSingleStepInner(step, ctx) {
1007
1011
  const truncatedResponseError = hiddenError && !hiddenError.hasError && !validatedStructuredOutput && getTerminalAssistantStopReason(run.messages) === "length"
1008
1012
  ? TRUNCATED_RESPONSE_ERROR
1009
1013
  : undefined;
1010
- const remoteGitChanged = run.nativeMachine?.initialGit && run.nativeMachine.finalGit ? run.nativeMachine.initialGit.head !== run.nativeMachine.finalGit.head || run.nativeMachine.initialGit.dirty !== run.nativeMachine.finalGit.dirty : undefined;
1011
- const mutationEvidence = run.nativeMachine && !isRexLocalMachine(step.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : await collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
1014
+ const mutationEvidence = run.nativeMachine && !editsLocalDisk(step.machine) ? remoteMutationEvidence(run.nativeMachine) : await collectTrackedMutationEvidence(mutationSnapshot, step.cwd ?? ctx.cwd);
1012
1015
  finalMutationEvidence = mutationEvidence;
1013
1016
  const mutationAttemptObserved = run.observedMutationAttempt === true || mutationEvidence.attemptedMutation === true;
1014
1017
  // Validated structured output is persistable file content even when the final text is only
@@ -1289,7 +1292,7 @@ async function runSingleStep(step, ctx) {
1289
1292
  }
1290
1293
  function externalRunnerStatus(runner, machine) {
1291
1294
  if (runner?.type === "external-cli") {
1292
- return resolveExternalCliRunnerStatus(machine?.provider === "herdr" ? { ...runner, machine } : runner);
1295
+ return resolveExternalCliRunnerStatus(machine?.provider === "herdr" && "target" in machine ? { ...runner, machine } : runner);
1293
1296
  }
1294
1297
  if (runner?.type === "external-job") {
1295
1298
  return {
@@ -27,7 +27,7 @@ import { formatMidToolExitError, isOrdinaryToolForMidToolExit } from "../shared/
27
27
  import { formatChildToolDiagnostic } from "../shared/tool-availability.js";
28
28
  import { formatChildModelResolutionDiagnostic, formatInheritedProviderDiagnostic, isChildModelResolutionFailure } from "../shared/model-resolution-diagnostic.js";
29
29
  import { planAbortRecovery } from "../shared/abort-recovery.js";
30
- import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, snapshotTrackedMutations } from "../shared/mutation-evidence.js";
30
+ import { buildTimeoutRecoverySummary, collectTrackedMutationEvidence, remoteMutationEvidence, remoteMutationSnapshot, snapshotTrackedMutations } from "../shared/mutation-evidence.js";
31
31
  import { captureSingleOutputSnapshot, extractChildWrittenOutput, finalizeSingleOutput, formatSavedOutputReference, hasSingleOutputChangedSinceSnapshot, isSettlementFatalOutputError, resolveSingleOutput, validateFileOnlyOutputMode } from "../shared/single-output.js";
32
32
  import { formatSubagentModelVerificationError, isContextOverflow, resolveModelSelection, } from "../shared/model-resolution.js";
33
33
  import { createMutatingFailureState, didMutatingToolFail, isMutatingTool, nextLongRunningTrigger, recordMutatingFailure, resetMutatingFailureState, resolveCurrentPath, shouldEscalateMutatingFailures, summarizeRecentMutatingFailures, } from "../shared/long-running-guard.js";
@@ -44,7 +44,7 @@ import { buildInProcessChildLaunch, createReportedChildSessionInput } from "../s
44
44
  import { childSessionFactory, childSessionHasQueuedMessages, projectChildSessionEventForJson } from "../shared/child-session.js";
45
45
  import { reconcileAttemptUsage } from "../shared/usage-reconciliation.js";
46
46
  import { clearProviderRetry, observeProviderDiagnostics, snapshotProviderDiagnostics } from "../../shared/provider-diagnostics.js";
47
- import { isRexLocalMachine } from "../shared/rex-machine.js";
47
+ import { editsLocalDisk } from "../shared/rex-machine.js";
48
48
  import { pauseForSupervisorWait, startPausableTimer } from "../shared/supervisor-wait-timer.js";
49
49
  const artifactOutputByResult = new WeakMap();
50
50
  const acceptanceOutputByResult = new WeakMap();
@@ -278,6 +278,7 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
278
278
  machine: options.machine,
279
279
  remoteSkillNames: options.skills ?? agent.skills,
280
280
  remoteReads: options.remoteReads,
281
+ acceptancePrompt: shared.acceptancePrompt,
281
282
  extensionBindings: options.extensionBindings,
282
283
  requiredExtensions: options.requiredExtensions,
283
284
  sessionEnabled: shared.sessionEnabled,
@@ -399,6 +400,7 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
399
400
  index: options.index ?? 0,
400
401
  agent: agent.name,
401
402
  ...(childSessionName ? { sessionName: childSessionName } : {}),
403
+ ...(options.sessionFile ? { sessionFile: options.sessionFile } : {}),
402
404
  status: "running",
403
405
  task,
404
406
  skills: shared.resolvedSkillNames,
@@ -447,8 +449,8 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
447
449
  return result;
448
450
  }
449
451
  // A machine 'local' child edits this disk, so its local Git evidence is authoritative, as for an unplaced run.
450
- const mutationCwd = isRexLocalMachine(options.machine) ? options.machine.cwd : options.cwd ?? runtimeCwd;
451
- const mutationSnapshot = options.machine && !isRexLocalMachine(options.machine) ? { source: "tracked-files", trackedOnly: true, cwd: mutationCwd, dirtyFiles: [], fingerprints: {}, unavailable: "Local Git evidence is not authoritative for a pane-native remote run." } : snapshotTrackedMutations(mutationCwd);
452
+ const mutationCwd = editsLocalDisk(options.machine) ? options.machine.cwd : options.cwd ?? runtimeCwd;
453
+ const mutationSnapshot = options.machine && !editsLocalDisk(options.machine) ? remoteMutationSnapshot(mutationCwd) : snapshotTrackedMutations(mutationCwd);
452
454
  let structuredOutputToolInvoked = false;
453
455
  let structuredOutputMessageStartIndex;
454
456
  let toolAvailabilityError;
@@ -1574,8 +1576,7 @@ async function runSingleAttempt(runtimeCwd, agent, task, model, options, shared)
1574
1576
  tokens: progress.tokens,
1575
1577
  durationMs: progress.durationMs,
1576
1578
  };
1577
- const remoteGitChanged = result.nativeMachine?.initialGit && result.nativeMachine.finalGit ? result.nativeMachine.initialGit.head !== result.nativeMachine.finalGit.head || result.nativeMachine.initialGit.dirty !== result.nativeMachine.finalGit.dirty : undefined;
1578
- const mutationEvidence = result.nativeMachine && !isRexLocalMachine(options.machine) ? { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: remoteGitChanged === true, ...(remoteGitChanged === undefined ? { unavailable: "Remote Git before/after evidence was incomplete." } : {}) } : await collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
1579
+ const mutationEvidence = result.nativeMachine && !editsLocalDisk(options.machine) ? remoteMutationEvidence(result.nativeMachine) : await collectTrackedMutationEvidence(mutationSnapshot, mutationCwd);
1579
1580
  const acceptanceOutput = getFinalOutput(result.messages ?? []);
1580
1581
  const structuredText = result.structuredOutput === undefined ? undefined : JSON.stringify(result.structuredOutput, null, 2);
1581
1582
  let fullOutput = stripAcceptanceReport(acceptanceOutput);
@@ -1678,7 +1679,7 @@ function writeStructuredOutputArtifacts(runtime, value, acceptanceReport) {
1678
1679
  async function runSyncCompletionInner(runtimeCwd, agents, agentName, task, options) {
1679
1680
  const effectiveCwd = options.cwd ?? runtimeCwd;
1680
1681
  // A placed child's cwd is a directory on its machine; only machine 'local' shares this disk.
1681
- const cwdError = options.machine && !isRexLocalMachine(options.machine) ? undefined : preflightLaunchCwd(options.requestedCwd ?? effectiveCwd, effectiveCwd);
1682
+ const cwdError = options.machine && !editsLocalDisk(options.machine) ? undefined : preflightLaunchCwd(options.requestedCwd ?? effectiveCwd, effectiveCwd);
1682
1683
  if (cwdError) {
1683
1684
  return redactResultPrompt(withRunContext({
1684
1685
  index: options.index ?? 0,