@vicary/pi-subagents 0.88.1 → 0.89.1

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 (93) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
  5. package/bundle/{chunk-5EMPFFO4.js → chunk-4FFKVLBG.js} +4 -4
  6. package/bundle/{chunk-L4YY2TOE.js → chunk-5TXWZB73.js} +1 -1
  7. package/bundle/{chunk-YDZ7BZD5.js → chunk-77VQEATI.js} +1 -1
  8. package/bundle/{chunk-7OX6O7DQ.js → chunk-BERAWSQQ.js} +5 -5
  9. package/bundle/{chunk-LV3CPYXJ.js → chunk-C22YEYFZ.js} +4 -4
  10. package/bundle/{chunk-AZPP3G4N.js → chunk-DVOXHOTY.js} +34 -5
  11. package/bundle/{chunk-2HKPEANZ.js → chunk-JLZFSOEL.js} +26 -15
  12. package/bundle/{chunk-CPSUJHZE.js → chunk-KCDPTXHT.js} +39 -10
  13. package/bundle/{chunk-4MVDMA5C.js → chunk-LWH7IGI3.js} +21 -7
  14. package/bundle/{chunk-DSHQWGHO.js → chunk-MIX3MCIF.js} +96 -96
  15. package/bundle/{chunk-BKISQ5CJ.js → chunk-NLDROUCR.js} +56 -34
  16. package/bundle/{chunk-2DIEL4WG.js → chunk-OUM6SEVD.js} +2 -2
  17. package/bundle/{chunk-XIA5GSEU.js → chunk-Q4VH72JI.js} +2 -2
  18. package/bundle/{chunk-D32H53HM.js → chunk-R3NH5XAL.js} +1 -1
  19. package/bundle/{chunk-CGWNA6EJ.js → chunk-R5XS4CVE.js} +98 -29
  20. package/bundle/{chunk-V7SZMS6W.js → chunk-RHMU7SXN.js} +2 -2
  21. package/bundle/{chunk-4ZQBZDF3.js → chunk-SG3NCWZW.js} +86 -20
  22. package/bundle/{chunk-KXW62VBU.js → chunk-SWGB2P5J.js} +1 -1
  23. package/bundle/{chunk-6CG2VAG4.js → chunk-TRN65L4F.js} +1 -1
  24. package/bundle/{chunk-GDR2ILWY.js → chunk-TXC7WIPL.js} +51 -22
  25. package/bundle/{chunk-IYT7X46U.js → chunk-UNLGCAC4.js} +5 -5
  26. package/bundle/{chunk-PYKBTBY6.js → chunk-URKQZHVH.js} +9 -9
  27. package/bundle/{chunk-W6HIYD2Z.js → chunk-UUW7P6KJ.js} +1 -1
  28. package/bundle/{chunk-CYKNHFXB.js → chunk-VEEUXJDO.js} +1 -1
  29. package/bundle/{chunk-JQTHG2ID.js → chunk-WMGQNIP7.js} +75 -32
  30. package/bundle/{chunk-47ZN7NKR.js → chunk-YJIU5WF4.js} +1 -1
  31. package/bundle/{chunk-RMZAAXIR.js → chunk-YLU5JFW2.js} +2 -2
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +2 -2
  34. package/bundle/intercom-bridge.js +2 -2
  35. package/bundle/preflight.js +8 -8
  36. package/bundle/project-panes.js +3 -3
  37. package/docs/agents.md +10 -4
  38. package/docs/configuration.md +2 -0
  39. package/docs/extension-api.md +1 -1
  40. package/docs/tool-reference.md +1 -1
  41. package/docs/workflows.md +5 -3
  42. package/package.json +2 -2
  43. package/src/extension/herdr-pi-bridge.js +79 -23
  44. package/src/extension/schemas.js +1 -1
  45. package/src/extension/subagent-options.js +5 -0
  46. package/src/intercom/result-intercom.js +3 -2
  47. package/src/runs/background/async-job-tracker.js +85 -9
  48. package/src/runs/background/async-status.d.ts +2 -0
  49. package/src/runs/background/async-status.js +8 -3
  50. package/src/runs/background/notify.d.ts +3 -0
  51. package/src/runs/background/notify.js +7 -2
  52. package/src/runs/background/run-status.js +3 -2
  53. package/src/runs/background/runner-child-launch.js +1 -0
  54. package/src/runs/background/subagent-runner.js +11 -8
  55. package/src/runs/foreground/execution.js +8 -7
  56. package/src/runs/foreground/subagent-executor.js +31 -5
  57. package/src/runs/shared/child-launch.d.ts +2 -0
  58. package/src/runs/shared/child-launch.js +1 -1
  59. package/src/runs/shared/child-session.d.ts +2 -1
  60. package/src/runs/shared/herdr-connection.d.ts +6 -0
  61. package/src/runs/shared/herdr-connection.js +11 -1
  62. package/src/runs/shared/herdr-machine.d.ts +2 -2
  63. package/src/runs/shared/herdr-machine.js +49 -22
  64. package/src/runs/shared/herdr-pane-host.d.ts +7 -19
  65. package/src/runs/shared/herdr-pane-host.js +48 -33
  66. package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
  67. package/src/runs/shared/herdr-pi-protocol.js +3 -2
  68. package/src/runs/shared/herdr-placed-run.d.ts +2 -12
  69. package/src/runs/shared/herdr-placed-run.js +10 -8
  70. package/src/runs/shared/kept-branch-text.d.ts +8 -0
  71. package/src/runs/shared/kept-branch-text.js +24 -0
  72. package/src/runs/shared/local-machine-access.d.ts +4 -1
  73. package/src/runs/shared/local-machine-access.js +6 -3
  74. package/src/runs/shared/mutation-evidence.d.ts +7 -1
  75. package/src/runs/shared/mutation-evidence.js +18 -2
  76. package/src/runs/shared/parallel-handoff.js +19 -7
  77. package/src/runs/shared/placed-run-owner.d.ts +4 -2
  78. package/src/runs/shared/placed-run-owner.js +15 -7
  79. package/src/runs/shared/rex-machine.d.ts +7 -3
  80. package/src/runs/shared/rex-machine.js +12 -9
  81. package/src/runs/shared/rex-pane-host.js +7 -27
  82. package/src/runs/shared/single-output.js +2 -2
  83. package/src/runs/shared/subagent-prompt-runtime.js +34 -0
  84. package/src/runs/shared/tool-availability.d.ts +4 -0
  85. package/src/runs/shared/tool-availability.js +7 -0
  86. package/src/runs/shared/worktree-cleanup-plan.js +2 -2
  87. package/src/runs/shared/worktree.d.ts +4 -14
  88. package/src/runs/shared/worktree.js +38 -8
  89. package/src/shared/types.d.ts +26 -2
  90. package/src/shared/utils.d.ts +2 -0
  91. package/src/shared/utils.js +9 -0
  92. package/src/workflows/workflow-child-summary.d.ts +2 -1
  93. package/src/workflows/workflow-child-summary.js +14 -6
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.89.1] - 2026-11-18
6
+
7
+ ### Highlights
8
+
9
+ - Subagents limited to a list of `tools` work again alongside extensions that keep a tool switched off on purpose, such as pi-web-access.
10
+ - A background subagent keeps showing as running when its status file can't be read, instead of being marked failed and dropped.
11
+ - Stopping a subagent in a Herdr or Rex pane now actually stops it.
12
+
13
+ ### Fixed
14
+
15
+ - A subagent limited to a list of `tools` no longer stops before its first request when an extension keeps one of those tools inactive on purpose, as pi-web-access does with `web_enable`. 0.89.0 treated that tool as replaced by another extension and failed the child with a misleading error. The check now fails the child only when a tool it can call is missing from the request, so a child whose tools pi-fabric's code mode swapped out still stops early. Thanks to [@chpock](https://github.com/chpock) for the report (#3296).
16
+ - A background subagent whose status file can't be read, for example after its permissions changed, now still counts as running. Before, a session that reopened while the subagent was working showed no active subagents and told hosts such as pi-web it was idle, and a session already open marked the subagent failed and dropped it about 10 seconds later. The run is kept until its status can be read again, then tracked normally, or dropped if it belongs to another session. Thanks to [@jordan-quan](https://github.com/jordan-quan) for the report (#3295).
17
+ - Stopping a subagent that runs in a Herdr or Rex pane now stops its current turn. Before, the stop request failed in the subagent's Pi with `api.abort is not a function`. Thanks to [@guneriu](https://github.com/guneriu) for the report (#3300).
18
+ - `machine: "local"` from a Pi running in a Herdr Core terminal (`hc`, the Herdr app's terminal server) now fails with an error that says Herdr Core is not supported. Before, the error said Pi was not running in Herdr, which was confusing inside the Herdr app. Only the herdr terminal multiplexer and Rex are supported. Thanks to [@guneriu](https://github.com/guneriu) for the report (#3300).
19
+
20
+ ## [0.89.0] - 2026-11-16
21
+
22
+ ### Highlights
23
+
24
+ - From a Pi running inside Herdr, `machine: "local"` opens the subagent in a new tab of your own Herdr session, with no saved machine or SSH.
25
+ - Subagents in Herdr or Rex panes are much more dependable: they get time to load a heavy set of extensions, report their tool calls, keep large messages, and no longer end as failed after doing their job.
26
+ - Editors and other hosts can now show a subagent's transcript while it runs, for foreground subagents and for every child of a workflow.
27
+ - A subagent limited to a list of `tools` now stops right away with a clear error when another extension, such as pi-fabric's code mode, swaps out its tools, instead of wasting turns on tools it can't call.
28
+ - Models such as GLM-5.3 that fill unused options with `"null"` can call `subagent`, and `machine: "local"` works on NixOS.
29
+
30
+ ### Added
31
+
32
+ - Workflow progress now names each child's session file. The `workflowChildren` rows of a workflow's progress updates, status and results carry `sessionFile` from the child's launch, and a finished child keeps it while its siblings still run, so an editor or other host can show any child's transcript during the workflow. Before, a host following a workflow could see a child's state but had no way to read what it was doing until the workflow returned. Thanks to [@zeishr](https://github.com/zeishr) for #3290.
33
+ - Foreground progress updates now name the child's session file. Each `details.progress[]` row of a `subagent` tool update carries `sessionFile` from the first update, when the child has one, so an editor or other host can show the child's transcript as it runs. Before, the path appeared only in the final result, once the child had finished. Thanks to [@zeishr](https://github.com/zeishr) for #3289.
34
+ - From a Pi running inside a Herdr pane, `machine: "local"` now opens the subagent in a new tab of your own Herdr session, with no saved machine or SSH. Before, `local` worked only inside Rex, and placing a child in Herdr on the same machine meant a saved machine and SSH to yourself. When Herdr runs inside a Rex tab, the Herdr session wins, and outside both terminals `local` fails before anything starts. Thanks to [@mystery4f](https://github.com/mystery4f) for #3266.
35
+
36
+ ### Fixed
37
+
38
+ - A child that times out or is stopped in a folder outside Git now gets a one-line note in its recovery summary ("changed tracked files: unavailable (not a Git work tree)"). Before, the summary and the child's output file held git's entire `git diff` option reference. Thanks to [@sternnick](https://github.com/sternnick) for #3287.
39
+ - A child with a `tools` allowlist now fails before its first model request when an extension loaded in the child replaces the tools sent to the model, and the error names the tools that were left out and the ones added in their place. Before, a background child that inherited pi-fabric's code mode started with no usable tool: the model saw only `fabric_exec`, every call to it failed with "Tool fabric_exec not found", and the child spent turns finding that out. Thanks to [@VasantLong](https://github.com/VasantLong) for #3291.
40
+ - The `worktreeSetupHook` docs now say that a new worktree already has a `node_modules` link to the main checkout when the hook runs, and that a hook which installs dependencies must remove the link first. Before, the link was undocumented, so a hook running `pnpm install` wrote into the main checkout's `node_modules` and could break it. Thanks to [@yxlimo](https://github.com/yxlimo) for #3288.
41
+ - `subagent` calls from models that fill every unset optional parameter with the string `"null"` and `workflow` with `"false"`, such as GLM-5.3, now work. Before, those placeholders counted as real values, so every call failed with errors such as "Named workflow resource execution must omit action". Only exact `"null"` values and `workflow: "false"` are ignored; a task that merely contains the word null is unchanged. Thanks to [@AlexKucera](https://github.com/AlexKucera) for #3285.
42
+ - `machine: "local"` in Herdr or Rex now works on hosts whose basic tools are not in `/usr/bin` or `/bin`, such as NixOS. Before, its setup scripts ran with the fixed `PATH` used for remote machines instead of Pi's own, so `rm`, `mkdir`, `mktemp` and `cat` were not found and the child never started. Remote machines keep the fixed `PATH`. Thanks to [@yxlimo](https://github.com/yxlimo) for #3284.
43
+ - The worktree handoff line in a subagent's result now says, when the child changed files, that its work is in the saved patches and was not applied to your checkout, and after a partial cleanup it points at the task entries that say what was left behind. When the handoff file itself can't be written, the error now points at `git worktree list`. Before, the line gave only counts, so a parent reading "1 changed patches" could take the change as already landed. Thanks to [@yxlimo](https://github.com/yxlimo) for #3283.
44
+ - When `worktree: true` refuses to start because the checkout has uncommitted changes, the error now names that checkout and lists the changed files (up to 10). Before, it said only "requires a clean git working tree" and named neither the checkout nor the files. Thanks to [@samclams](https://github.com/samclams) for #3276.
45
+ - A workflow given an `output` file no longer writes its error into that file when it fails, stops, or pauses. The workflow now removes any earlier file at that path when it starts and writes the file only when it completes; the error stays in the tool result, the completion notice, and `status.json`. Before, the file appeared even when the workflow failed within milliseconds of starting, so a script or parent that waited for the file treated the failure as a delivered report. Thanks to [@samclams](https://github.com/samclams) for #3275.
46
+ - When a subagent in a managed worktree commits its work, cleanup now keeps its branch instead of deleting it. Single, chain and parallel runs name the kept branch and its last commit in their result or completion notice; for a workflow child it is recorded in the worktree handoff file listed in the child's `artifactPaths`. Before, cleanup force-deleted the branch, so the commits' messages and authorship survived only as unreachable objects you had to find with `git fsck`. A branch whose commits are already on another branch, a remote branch, or a tag is still deleted. Thanks to [@samclams](https://github.com/samclams) for #3274.
47
+ - A subagent placed in a Herdr or Rex pane no longer loses a large message or crashes when the parent reconnects. Before, a message too big to send to the parent in one piece, such as a screenshot it read or a very large file it wrote, never reached the parent, and the next time the parent reconnected to that pane the subagent's Pi crashed. Now the parent gets the message shortened: images and very long text are replaced by a note saying what was left out, and very long tool arguments are cut. Two large messages sent back to back also no longer break the connection.
48
+ - A subagent with `outputSchema` placed in a Herdr or Rex pane is now refused before any pane opens, with an error naming `outputSchema` among the options a placed Pi can't use yet. Before, it started, could never call `structured_output`, and failed at the end with an error telling it to call a tool it didn't have.
49
+ - A subagent placed in a Herdr or Rex pane no longer fails to start when another extension in that pane opens its own Pi session at startup. Before, the pane was closed with "did not start the pi-subagents bridge" or the launch timed out, because loading pi-subagents a second time in the same Pi cut the connection to the first copy. Thanks to [@mystery4f](https://github.com/mystery4f) for finding and fixing this in #3263.
50
+ - A subagent placed in a Herdr or Rex pane now gets 30 seconds to start. Before, the parent gave up after 100 checks, about 6 seconds for a local Rex pane, so a Pi with many extensions was closed as "did not start the pi-subagents bridge" while it was still loading. Thanks to [@mystery4f](https://github.com/mystery4f) for finding and fixing this in #3263.
51
+ - When a subagent in a Herdr pane fails after its Pi started, for example on a version mismatch or a missing required tool, the error now says why. Before, it could say only "Could not remove the exact owned remote runtime directory", because the closing Pi had already removed that folder. Thanks to [@mystery4f](https://github.com/mystery4f) for finding and fixing this in #3263.
52
+ - Subagents placed in a Herdr or Rex pane now report their tool calls. Status, the fleet view and results show their tool count and current tool, per-tool timeouts apply to them, and time spent waiting on your answer no longer counts against their `timeoutMs`. Before, the parent saw none of a placed subagent's tool calls, so it showed 0 tools, a stuck tool was never stopped, and a wait on your answer used up the subagent's time. Thanks to [@mystery4f](https://github.com/mystery4f) for the report in #3263.
53
+ - A subagent placed in a Herdr or Rex pane (`machine`) no longer ends as failed when it did its job. It now gets the same instructions for reporting its result as other subagents. Before, it never saw them, so it could not write the acceptance report and every run under the default acceptance was rejected. Thanks to [@mystery4f](https://github.com/mystery4f) for the report in #3263.
54
+
5
55
  ## [0.88.1] - 2026-11-12
6
56
 
7
57
  ### Highlights
@@ -258,7 +308,7 @@
258
308
  ### Added
259
309
 
260
310
  - Background workflows cut off by Pi exiting, crashing or reloading now resume on their own when you reopen or reload their session within a day, and steps that already finished are not run again. You can also resume one yourself with `subagent({ action: "resume", id })`, or set `autoResume: false` to resume them only by hand. A stopped workflow is resumed only once, and its notice says how it resumed. If you start a new Pi in the same folder instead, it tells you which session to reopen. See [docs/workflows.md](docs/workflows.md).
261
- - `machine: "local"` runs a native Pi child in a new background tab of your own Rex session, with the same controls as a Herdr-placed Pi child: prompts, steering, follow-ups, abort, `contact_supervisor` and results. The launch fails if the parent Pi is not running inside Rex, and Claude Code, Codex, Cursor and generic `external-cli` agents are rejected. A finished child's tab stays open until you close it; an aborted or stopped child's tab is closed. See [docs/agents.md](docs/agents.md#running-a-pi-child-in-a-rex-pane-on-this-machine).
311
+ - `machine: "local"` runs a native Pi child in a new background tab of your own Rex session, with the same controls as a Herdr-placed Pi child: prompts, steering, follow-ups, abort, `contact_supervisor` and results. The launch fails if the parent Pi is not running inside Rex, and Claude Code, Codex, Cursor and generic `external-cli` agents are rejected. A finished child's tab stays open until you close it; an aborted or stopped child's tab is closed. See [docs/agents.md](docs/agents.md#running-a-pi-child-in-a-new-tab-on-this-machine-rex-or-herdr).
262
312
  - A native Pi child can also run in a Rex tab on another Mac over SSH. Name the Mac in your user settings with `subagents.machines.<name>.rex.ssh`, then pass `machine: "<name>"`. The child opens in that Mac's `subagents` Rex session, which is created the first time it is needed. These machines do not need Herdr, and project settings cannot name a Rex host. See [docs/agents.md](docs/agents.md#running-a-pi-child-in-a-rex-pane-on-another-mac).
263
313
 
264
314
  ### Changed
package/bundle/agents.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  RUNTIME_AGENT_REGISTER_EVENT,
3
3
  RUNTIME_AGENT_REGISTER_VERSION,
4
4
  registerAgentViaEvents
5
- } from "./chunk-L4YY2TOE.js";
5
+ } from "./chunk-5TXWZB73.js";
6
6
  import {
7
7
  registerRuntimeAgent
8
- } from "./chunk-KXW62VBU.js";
9
- import "./chunk-4MVDMA5C.js";
8
+ } from "./chunk-SWGB2P5J.js";
9
+ import "./chunk-LWH7IGI3.js";
10
10
  import "./chunk-JEZOSEWG.js";
11
11
  import "./chunk-YFCK7H2S.js";
12
12
  import "./chunk-QXASAHIA.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  resolvePiLaunchToolPlan
3
- } from "./chunk-D32H53HM.js";
3
+ } from "./chunk-R3NH5XAL.js";
4
4
  import "./chunk-YARY7JWU.js";
5
- import "./chunk-4MVDMA5C.js";
5
+ import "./chunk-LWH7IGI3.js";
6
6
  import "./chunk-JEZOSEWG.js";
7
7
  import "./chunk-YFCK7H2S.js";
8
8
  import "./chunk-QXASAHIA.js";
@@ -1,6 +1,7 @@
1
1
  // src/runs/shared/herdr-pi-protocol.ts
2
2
  var HERDR_PI_PROTOCOL = 1;
3
3
  var HERDR_PI_MAX_FRAME_BYTES = 1024 * 1024;
4
+ var HERDR_PI_MAX_ACCEPTANCE_PROMPT_BYTES = 256 * 1024;
4
5
  var HERDR_PI_MODE_ENV = "PI_SUBAGENTS_HERDR_BRIDGE";
5
6
  var HERDR_PI_RUN_ENV = "PI_SUBAGENTS_HERDR_RUN_ID";
6
7
  var HERDR_PI_RUNTIME_DIR_ENV = "PI_SUBAGENTS_HERDR_RUNTIME_DIR";
@@ -19,10 +20,10 @@ var HerdrPiFrameDecoder = class {
19
20
  #buffer = Buffer.alloc(0);
20
21
  push(chunk) {
21
22
  this.#buffer = Buffer.concat([this.#buffer, chunk]);
22
- if (this.#buffer.byteLength > HERDR_PI_MAX_FRAME_BYTES) throw new Error(`Herdr Pi frame exceeds ${HERDR_PI_MAX_FRAME_BYTES} bytes.`);
23
23
  const frames = [];
24
24
  for (; ; ) {
25
25
  const newline = this.#buffer.indexOf(10);
26
+ if ((newline < 0 ? this.#buffer.byteLength : newline) >= HERDR_PI_MAX_FRAME_BYTES) throw new Error(`Herdr Pi frame exceeds ${HERDR_PI_MAX_FRAME_BYTES} bytes.`);
26
27
  if (newline < 0) break;
27
28
  const line = this.#buffer.subarray(0, newline);
28
29
  this.#buffer = this.#buffer.subarray(newline + 1);
@@ -48,6 +49,7 @@ var HerdrPiFrameDecoder = class {
48
49
  export {
49
50
  HERDR_PI_PROTOCOL,
50
51
  HERDR_PI_MAX_FRAME_BYTES,
52
+ HERDR_PI_MAX_ACCEPTANCE_PROMPT_BYTES,
51
53
  HERDR_PI_MODE_ENV,
52
54
  HERDR_PI_RUN_ENV,
53
55
  HERDR_PI_RUNTIME_DIR_ENV,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildWorkflowChatProgressRows
3
- } from "./chunk-LV3CPYXJ.js";
3
+ } from "./chunk-C22YEYFZ.js";
4
4
  import {
5
5
  aggregateStepStatus,
6
6
  contextModeBadge,
@@ -22,7 +22,7 @@ import {
22
22
  projectAsyncWorkflowRows,
23
23
  projectWorkflowChecklist,
24
24
  workflowGraphStageNodes
25
- } from "./chunk-4ZQBZDF3.js";
25
+ } from "./chunk-SG3NCWZW.js";
26
26
  import {
27
27
  isStaleExtensionContextError,
28
28
  isUnboundExtensionRuntimeError,
@@ -34,7 +34,7 @@ import {
34
34
  formatWorkflowJsonPreview,
35
35
  hostStepReportName,
36
36
  hostStepVerdictLabel
37
- } from "./chunk-CPSUJHZE.js";
37
+ } from "./chunk-KCDPTXHT.js";
38
38
  import {
39
39
  snapshotExternalRuns
40
40
  } from "./chunk-UKG4V45O.js";
@@ -52,7 +52,7 @@ import {
52
52
  getSingleResultOutput,
53
53
  shortenPath,
54
54
  unresolvedChildWatchdogBlockers
55
- } from "./chunk-4MVDMA5C.js";
55
+ } from "./chunk-LWH7IGI3.js";
56
56
  import {
57
57
  MAX_WIDGET_JOBS,
58
58
  WIDGET_ANIMATION_INTERVAL_MS,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-KXW62VBU.js";
3
+ } from "./chunk-SWGB2P5J.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -2,7 +2,7 @@ import {
2
2
  createAtomicJsonWriter,
3
3
  getAgentDir,
4
4
  readStatus
5
- } from "./chunk-4MVDMA5C.js";
5
+ } from "./chunk-LWH7IGI3.js";
6
6
  import {
7
7
  DIRS,
8
8
  TEMP_ARTIFACTS_DIR,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isTrustedRecordedSessionFile,
3
3
  resolveSubagentRunId
4
- } from "./chunk-LV3CPYXJ.js";
4
+ } from "./chunk-C22YEYFZ.js";
5
5
  import {
6
6
  agentStreamOptions,
7
7
  opencodeSessionHeaders,
8
8
  resolveAsyncResumeTarget
9
- } from "./chunk-4ZQBZDF3.js";
9
+ } from "./chunk-SG3NCWZW.js";
10
10
  import {
11
11
  ownsRun
12
12
  } from "./chunk-HXRB42AF.js";
@@ -18,12 +18,12 @@ import {
18
18
  reconcileAsyncRun,
19
19
  resolveAuthorityDecision,
20
20
  resolveMissionStoreLocation
21
- } from "./chunk-CPSUJHZE.js";
21
+ } from "./chunk-KCDPTXHT.js";
22
22
  import {
23
23
  deliverInterruptRequest,
24
24
  queueRevivalBrief,
25
25
  requestAsyncSteer
26
- } from "./chunk-W6HIYD2Z.js";
26
+ } from "./chunk-UUW7P6KJ.js";
27
27
  import {
28
28
  formatShellCommand
29
29
  } from "./chunk-7J4ZXMY7.js";
@@ -34,7 +34,7 @@ import {
34
34
  tryLease,
35
35
  writeAtomicJson,
36
36
  writePrivateAtomicJson
37
- } from "./chunk-4MVDMA5C.js";
37
+ } from "./chunk-LWH7IGI3.js";
38
38
  import {
39
39
  DIRS
40
40
  } from "./chunk-JEZOSEWG.js";
@@ -12,7 +12,7 @@ import {
12
12
  summarizeContextModes,
13
13
  utf8Tail,
14
14
  workflowPreflightLaneForRuntimeKey
15
- } from "./chunk-4ZQBZDF3.js";
15
+ } from "./chunk-SG3NCWZW.js";
16
16
  import {
17
17
  ownsRun
18
18
  } from "./chunk-HXRB42AF.js";
@@ -34,11 +34,11 @@ import {
34
34
  updateActiveRunIndex,
35
35
  validateModelResponseAliases,
36
36
  writeAsyncResultFile
37
- } from "./chunk-CPSUJHZE.js";
37
+ } from "./chunk-KCDPTXHT.js";
38
38
  import {
39
39
  deliverStopRequest,
40
40
  stopInboxClosedPath
41
- } from "./chunk-W6HIYD2Z.js";
41
+ } from "./chunk-UUW7P6KJ.js";
42
42
  import {
43
43
  SUBAGENT_STOPPED_MESSAGE,
44
44
  formatDuration,
@@ -50,7 +50,7 @@ import {
50
50
  waitToolName,
51
51
  writeAtomicJson,
52
52
  writePrivateAtomicJson
53
- } from "./chunk-4MVDMA5C.js";
53
+ } from "./chunk-LWH7IGI3.js";
54
54
  import {
55
55
  DIRS
56
56
  } from "./chunk-JEZOSEWG.js";
@@ -14,20 +14,20 @@ import {
14
14
  resolveCurrentSessionId,
15
15
  resolveWatchdogReviewModel,
16
16
  startWatchdogDiffBaselineCapture
17
- } from "./chunk-IYT7X46U.js";
17
+ } from "./chunk-UNLGCAC4.js";
18
18
  import {
19
19
  agentStreamOptions,
20
20
  opencodeSessionHeaders
21
- } from "./chunk-4ZQBZDF3.js";
21
+ } from "./chunk-SG3NCWZW.js";
22
22
  import {
23
23
  registerNativeSupervisorClient
24
- } from "./chunk-CYKNHFXB.js";
24
+ } from "./chunk-VEEUXJDO.js";
25
25
  import {
26
26
  MODEL_ONLY_TOOL
27
27
  } from "./chunk-HXRB42AF.js";
28
28
  import {
29
29
  inheritedNestedRouteOf
30
- } from "./chunk-CPSUJHZE.js";
30
+ } from "./chunk-KCDPTXHT.js";
31
31
  import {
32
32
  CHILD_WATCHDOG_STATUS_EVENT,
33
33
  DEFAULT_WAIT_TOOL_NAME,
@@ -46,7 +46,7 @@ import {
46
46
  toolBudgetSoftNudge,
47
47
  validateAcceptanceReport,
48
48
  validateStructuredOutputValue
49
- } from "./chunk-4MVDMA5C.js";
49
+ } from "./chunk-LWH7IGI3.js";
50
50
  import {
51
51
  INTERCOM_SESSION_IDENTITY_EVENT
52
52
  } from "./chunk-JEZOSEWG.js";
@@ -84,6 +84,13 @@ function projectRuntimeAcknowledgedExtensions(ids) {
84
84
  // src/runs/shared/tool-availability.ts
85
85
  function formatChildToolDiagnostic(diagnostic, options = {}) {
86
86
  const subject = diagnostic.agent ? `Agent '${diagnostic.agent}'` : "Subagent";
87
+ if (diagnostic.undeclared?.length) {
88
+ const uncallable = diagnostic.uncallable?.length ? ` and added ${diagnostic.uncallable.join(", ")}, which this child cannot call` : "";
89
+ return [
90
+ `${subject} declares tools: ${diagnostic.required.join(", ")}, but an extension loaded in this child replaced the tools sent to the model: it left out ${diagnostic.undeclared.join(", ")}${uncallable}.`,
91
+ "The `tools` field is a strict allowlist. Set `extensions: []` or list only the extensions this child needs, or omit `tools` to use that extension's tool surface."
92
+ ].join("\n");
93
+ }
87
94
  if (options.host === "parent") {
88
95
  return [
89
96
  `${subject} ran as a foreground child, which never loads the parent's ambient extensions, and these child tools were unavailable: ${diagnostic.missing.join(", ")}.`,
@@ -533,7 +540,29 @@ function filterChildPromptOptions(options, inherited) {
533
540
  function rewritesChildPrompt(config) {
534
541
  return config.inheritProjectContext !== void 0 || config.inheritGlobalContext !== void 0 || config.inheritSkills !== void 0 || Boolean(config.fanoutChild);
535
542
  }
543
+ function registerDeclaredToolCheck(pi, config, required) {
544
+ pi.on("context_with_system", (event, ctx) => {
545
+ const declared = new Set(getCurrentTools(event.messages).map((tool) => tool.name));
546
+ if (required.every((name) => declared.has(name))) return void 0;
547
+ const active = new Set(pi.getActiveTools());
548
+ const undeclared = required.filter((name) => active.has(name) && !declared.has(name));
549
+ if (undeclared.length === 0) return void 0;
550
+ const registered = new Set(pi.getAllTools().map((tool) => tool.name));
551
+ const uncallable = config.forkCacheKey ? [] : [...declared].filter((name) => !active.has(name));
552
+ config.toolDiagnostic?.({
553
+ ...config.agent ? { agent: config.agent } : {},
554
+ required: [...required],
555
+ available: [...registered],
556
+ missing: [],
557
+ undeclared,
558
+ ...uncallable.length > 0 ? { uncallable } : {}
559
+ });
560
+ ctx.abort();
561
+ return void 0;
562
+ });
563
+ }
536
564
  function registerSubagentPromptBoundary(pi, config) {
565
+ if (config.requiredTools) registerDeclaredToolCheck(pi, config, config.requiredTools);
537
566
  if (!rewritesChildPrompt(config)) return;
538
567
  if (config.forkCacheKey) return;
539
568
  pi.on("before_agent_start", (event) => {
@@ -11,18 +11,21 @@ import {
11
11
  startWatchdogDiffBaselineCapture,
12
12
  writeUserWatchdogEnabled,
13
13
  writeWatchdogModelSettings
14
- } from "./chunk-IYT7X46U.js";
14
+ } from "./chunk-UNLGCAC4.js";
15
15
  import {
16
16
  resolveGitRepositoryIdentity
17
- } from "./chunk-LV3CPYXJ.js";
17
+ } from "./chunk-C22YEYFZ.js";
18
18
  import {
19
+ formatParallelHandoffLines,
19
20
  listAsyncRuns,
20
21
  parallelHandoffPath,
22
+ parseKeptBranchLines,
21
23
  parseWorkflowChildSummary,
22
24
  readAsyncRecoveryDescriptor,
25
+ readKeptBranches,
23
26
  readWorkflowLaunchRecord,
24
27
  resolveRetainedWorktreeCwd
25
- } from "./chunk-4ZQBZDF3.js";
28
+ } from "./chunk-SG3NCWZW.js";
26
29
  import {
27
30
  ownsRun
28
31
  } from "./chunk-HXRB42AF.js";
@@ -54,24 +57,24 @@ import {
54
57
  resolveMissionStoreLocation,
55
58
  validateMissionId,
56
59
  workflowRunParamsFingerprint
57
- } from "./chunk-CPSUJHZE.js";
60
+ } from "./chunk-KCDPTXHT.js";
58
61
  import {
59
62
  requestAsyncCommand,
60
63
  watchAsyncControlInbox
61
- } from "./chunk-W6HIYD2Z.js";
64
+ } from "./chunk-UUW7P6KJ.js";
62
65
  import {
63
66
  supervisorChannelDir
64
- } from "./chunk-D32H53HM.js";
67
+ } from "./chunk-R3NH5XAL.js";
65
68
  import {
66
69
  createRequiredChildExtensionIdentity
67
70
  } from "./chunk-YARY7JWU.js";
68
71
  import {
69
72
  createHerdrClient,
70
73
  detectHerdr
71
- } from "./chunk-2DIEL4WG.js";
74
+ } from "./chunk-OUM6SEVD.js";
72
75
  import {
73
76
  getProjectSubagentsDir
74
- } from "./chunk-YDZ7BZD5.js";
77
+ } from "./chunk-77VQEATI.js";
75
78
  import {
76
79
  ExternalJobProviderError,
77
80
  getExternalJobProvider,
@@ -81,7 +84,7 @@ import {
81
84
  } from "./chunk-YYREO77V.js";
82
85
  import {
83
86
  mergeRuntimeAgents
84
- } from "./chunk-KXW62VBU.js";
87
+ } from "./chunk-SWGB2P5J.js";
85
88
  import {
86
89
  CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL,
87
90
  EXTERNAL_CLI_ADAPTER_SAFETY,
@@ -142,7 +145,7 @@ import {
142
145
  withFileLease,
143
146
  writeAtomicJson,
144
147
  writePrivateAtomicJson
145
- } from "./chunk-4MVDMA5C.js";
148
+ } from "./chunk-LWH7IGI3.js";
146
149
  import {
147
150
  DIRS,
148
151
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -1263,7 +1266,7 @@ function formatSubagentResultIntercomMessage(input) {
1263
1266
  }
1264
1267
  if (input.asyncId) lines.push(`Async id: ${input.asyncId}`);
1265
1268
  if (input.asyncDir) lines.push(`Async dir: ${input.asyncDir}`);
1266
- if (input.parallelHandoff) lines.push(`Parallel handoff: ${input.parallelHandoff.path}`);
1269
+ if (input.parallelHandoff) lines.push(...formatParallelHandoffLines(input.parallelHandoff.path, input.parallelHandoff.keptBranches));
1267
1270
  const resumeGuidance = asyncResumeGuidance(input);
1268
1271
  if (resumeGuidance) lines.push(resumeGuidance);
1269
1272
  if (input.children.some((child) => child.intercomTarget)) {
@@ -1368,7 +1371,7 @@ function formatSubagentResultReceipt(input) {
1368
1371
  `Run: ${input.runId}`,
1369
1372
  `Children: ${formatStatusCounts(counts)}`
1370
1373
  ];
1371
- if (input.payload.parallelHandoff) lines.push(`Parallel handoff: ${input.payload.parallelHandoff.path}`);
1374
+ if (input.payload.parallelHandoff) lines.push(...formatParallelHandoffLines(input.payload.parallelHandoff.path, input.payload.parallelHandoff.keptBranches));
1372
1375
  const artifacts = input.payload.children.filter((child) => typeof child.artifactPath === "string");
1373
1376
  if (artifacts.length > 0) {
1374
1377
  lines.push("Artifacts:");
@@ -5629,7 +5632,7 @@ function formatSingleCompletion(details) {
5629
5632
  formatResultPreview(details),
5630
5633
  ...watchdogLines.length ? ["", ...watchdogLines] : [],
5631
5634
  details.handoffPath ? "" : void 0,
5632
- details.handoffPath ? `Parallel handoff: ${details.handoffPath}` : void 0,
5635
+ ...details.handoffPath ? formatParallelHandoffLines(details.handoffPath, details.keptBranches) : [],
5633
5636
  correlationLines.length && !details.handoffPath ? "" : void 0,
5634
5637
  ...correlationLines,
5635
5638
  sessionLine ? "" : void 0,
@@ -5691,6 +5694,7 @@ function parseSubagentNotifyContent(content) {
5691
5694
  const resultEnd = firstMetadataIndex > 0 && body[firstMetadataIndex - 1]?.trim() === "" ? firstMetadataIndex - 1 : firstMetadataIndex;
5692
5695
  const resultPreview = body.slice(0, resultEnd).join("\n").trim() || "(no output)";
5693
5696
  const handoffPath = handoffIndex >= 0 ? body[handoffIndex].slice("Parallel handoff: ".length).trim() : void 0;
5697
+ const keptBranches = handoffIndex >= 0 ? parseKeptBranchLines(body.slice(handoffIndex + 1)) : [];
5694
5698
  const workflowRunId = workflowRunIndex >= 0 ? body[workflowRunIndex].slice("Workflow run: ".length).trim() : void 0;
5695
5699
  const childRuns = childRunsIndex >= 0 ? body[childRunsIndex].slice("Child runs: ".length).split(", ").map((part) => {
5696
5700
  const trimmed = part.trim();
@@ -5716,6 +5720,7 @@ function parseSubagentNotifyContent(content) {
5716
5720
  ...workflowReceiptPath2 ? { workflowReceiptPath: workflowReceiptPath2 } : {},
5717
5721
  resultPreview,
5718
5722
  ...handoffPath ? { handoffPath } : {},
5723
+ ...keptBranches.length ? { keptBranches } : {},
5719
5724
  ...workflowRunId ? { workflowRunId } : {},
5720
5725
  ...resumeNotice ? { resumeNotice } : {},
5721
5726
  ...childRuns?.length ? { childRuns } : {},
@@ -5735,7 +5740,7 @@ function formatGroupedCompletion(details) {
5735
5740
  if (detail.workflowReceiptPath) blocks.push(`Workflow receipt: ${detail.workflowReceiptPath}`);
5736
5741
  blocks.push(formatResultPreview(detail));
5737
5742
  blocks.push(...formatWatchdogBlockerLines(detail));
5738
- if (detail.handoffPath) blocks.push(`Parallel handoff: ${detail.handoffPath}`);
5743
+ if (detail.handoffPath) blocks.push(...formatParallelHandoffLines(detail.handoffPath, detail.keptBranches));
5739
5744
  blocks.push(...formatCorrelationLines(detail));
5740
5745
  if (sessionLine) blocks.push(sessionLine);
5741
5746
  blocks.push("");
@@ -5877,6 +5882,7 @@ function buildCompletionDetails(result5) {
5877
5882
  const taskInfo = runningChildren > 0 ? ` (${status === "completed" ? "dispatch complete; " : ""}${runningChildren} ${runningChildren === 1 ? "child" : "children"} running or uncollected)` : result5.taskIndex !== void 0 && result5.totalTasks !== void 0 ? ` (${result5.taskIndex + 1}/${result5.totalTasks})` : void 0;
5878
5883
  const parallelHandoff = result5.parallelHandoff && typeof result5.parallelHandoff === "object" ? result5.parallelHandoff : void 0;
5879
5884
  const handoffPath = typeof parallelHandoff?.path === "string" ? parallelHandoff.path : void 0;
5885
+ const keptBranches = readKeptBranches(parallelHandoff?.keptBranches);
5880
5886
  const receipt = result5.workflowReceipt;
5881
5887
  const receiptPath = receipt && typeof receipt === "object" && !Array.isArray(receipt) ? receipt.path : void 0;
5882
5888
  const workflowReceiptPath2 = typeof receiptPath === "string" && receiptPath ? receiptPath : void 0;
@@ -5975,6 +5981,7 @@ High-importance watchdog concerns:
5975
5981
  ${watchdogConcerns.map((warning) => `- ${warning}`).join("\n")}` : resultPreview,
5976
5982
  ...typeof result5.durationMs === "number" ? { durationMs: result5.durationMs } : {},
5977
5983
  ...handoffPath ? { handoffPath } : {},
5984
+ ...handoffPath && keptBranches.length ? { keptBranches } : {},
5978
5985
  ...rawRunId ? { runId: rawRunId } : {},
5979
5986
  ...workflowRunId ? { workflowRunId } : {},
5980
5987
  ...resumeNotice ? { resumeNotice } : {},
@@ -7881,7 +7888,7 @@ function childSessionFactory() {
7881
7888
  }
7882
7889
  function createLazyPlacementFactory(local) {
7883
7890
  let placed;
7884
- const factory = async () => placed ??= (await import("./chunk-DSHQWGHO.js")).createPlacementAwareChildSessionFactory(local);
7891
+ const factory = async () => placed ??= (await import("./chunk-MIX3MCIF.js")).createPlacementAwareChildSessionFactory(local);
7885
7892
  return {
7886
7893
  async create(launch) {
7887
7894
  return launch.machine ? (await factory()).create(launch) : local.create(launch);
@@ -8111,6 +8118,10 @@ var optionKeys = new Set(SUBAGENT_OPTION_KEYS);
8111
8118
  var ALIAS_HINTS = { runId: "id (top-level)", maxRuntimeMs: "options.timeoutMs", isolation: "worktree (top-level)" };
8112
8119
  var optionsValidator = Compile(SubagentOptionParams);
8113
8120
  function flattenSubagentToolOptions(params, disabled) {
8121
+ params = Object.fromEntries(Object.entries(params).filter(([key, value]) => value !== "null" && !(key === "workflow" && value === "false")));
8122
+ if (params.options && typeof params.options === "object" && !Array.isArray(params.options)) {
8123
+ params.options = Object.fromEntries(Object.entries(params.options).filter(([, value]) => value !== "null"));
8124
+ }
8114
8125
  const removedTopLevel = removedModelWorkflowFieldError(params);
8115
8126
  if (removedTopLevel) throw new Error(removedTopLevel);
8116
8127
  const { options, ...topLevel } = params;
@@ -5,7 +5,7 @@ import {
5
5
  PROJECT_SUBAGENTS_RELATIVE_DIR,
6
6
  canonicalSessionId,
7
7
  inspectSessionLease
8
- } from "./chunk-YDZ7BZD5.js";
8
+ } from "./chunk-77VQEATI.js";
9
9
  import {
10
10
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
11
11
  DEFAULT_GLOBAL_CONCURRENCY_LIMIT,
@@ -27,7 +27,7 @@ import {
27
27
  withFileLease,
28
28
  writeAtomicJson,
29
29
  writePrivateAtomicJson
30
- } from "./chunk-4MVDMA5C.js";
30
+ } from "./chunk-LWH7IGI3.js";
31
31
  import {
32
32
  DIRS,
33
33
  SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
@@ -6451,8 +6451,13 @@ async function probeWorktreeSource(tx, cwd) {
6451
6451
  if (repoCheck.status !== 0 || repoCheck.stdout.trim() !== "true") throw new Error("worktree isolation requires a git repository");
6452
6452
  const toplevel = (await tx.gitChecked(cwd, ["rev-parse", "--show-toplevel"])).trim();
6453
6453
  const status = await tx.gitChecked(toplevel, ["status", "--porcelain", "--", `:!${PROJECT_SUBAGENTS_RELATIVE_DIR}`]);
6454
- if (status.trim().length > 0) {
6455
- throw new Error("worktree isolation requires a clean git working tree. Commit or stash changes first.");
6454
+ const changes = status.split("\n").filter((line) => line.trim().length > 0);
6455
+ if (changes.length > 0) {
6456
+ const shown = changes.slice(0, 10).map((line) => ` ${line}`);
6457
+ if (changes.length > shown.length) shown.push(` \u2026 and ${changes.length - shown.length} more`);
6458
+ throw new Error(`worktree isolation requires a clean git working tree: ${toplevel} has ${changes.length} uncommitted change(s):
6459
+ ${shown.join("\n")}
6460
+ Commit or stash them first.`);
6456
6461
  }
6457
6462
  return toplevel;
6458
6463
  }
@@ -7103,6 +7108,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
7103
7108
  const errors = [];
7104
7109
  let worktreeRemoved = false;
7105
7110
  let branchRemoved = false;
7111
+ let keptBranchTip;
7106
7112
  if (intent.kind === "preserve" && intent.cleanupBlocker) {
7107
7113
  return {
7108
7114
  index: worktree.index,
@@ -7201,11 +7207,29 @@ function cleanupSingleWorktree(setup, worktree, intent) {
7201
7207
  errors.push(`worktree removal failed: ${error instanceof Error ? error.message : String(error)}`);
7202
7208
  }
7203
7209
  if (worktreeRemoved) {
7204
- try {
7205
- runGitChecked(setup.cwd, ["branch", "-D", worktree.branch]);
7206
- branchRemoved = true;
7207
- } catch (error) {
7208
- errors.push(`branch removal failed: ${error instanceof Error ? error.message : String(error)}`);
7210
+ let deleteBranch = true;
7211
+ if (intent.kind === "preserve") {
7212
+ try {
7213
+ const tip = runGitChecked(setup.cwd, ["rev-parse", "--verify", `refs/heads/${worktree.branch}^{commit}`]).trim();
7214
+ if (tip !== setup.baseCommit) {
7215
+ const containing = runGitChecked(setup.cwd, ["for-each-ref", "--contains", tip, "--format=%(refname)", "refs/heads", "refs/remotes", "refs/tags"]);
7216
+ if (!containing.split("\n").some((ref) => ref && ref !== `refs/heads/${worktree.branch}`)) {
7217
+ keptBranchTip = tip;
7218
+ deleteBranch = false;
7219
+ }
7220
+ }
7221
+ } catch (error) {
7222
+ deleteBranch = false;
7223
+ errors.push(`branch check failed: ${error instanceof Error ? error.message : String(error)}`);
7224
+ }
7225
+ }
7226
+ if (deleteBranch) {
7227
+ try {
7228
+ runGitChecked(setup.cwd, ["branch", "-D", worktree.branch]);
7229
+ branchRemoved = true;
7230
+ } catch (error) {
7231
+ errors.push(`branch removal failed: ${error instanceof Error ? error.message : String(error)}`);
7232
+ }
7209
7233
  }
7210
7234
  }
7211
7235
  return {
@@ -7217,6 +7241,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
7217
7241
  ...worktree.recordedBaseDir ? { recordedBaseDir: worktree.recordedBaseDir } : {},
7218
7242
  worktreeRemoved,
7219
7243
  branchRemoved,
7244
+ ...keptBranchTip ? { keptBranchTip } : {},
7220
7245
  ...errors.length ? { errors } : {}
7221
7246
  };
7222
7247
  }
@@ -7417,6 +7442,9 @@ function diffWorktrees(setup, agents, diffsDir) {
7417
7442
  setup.capturedDiffs = diffs;
7418
7443
  return diffs;
7419
7444
  }
7445
+ function isWorktreeCleanupTaskDone(task) {
7446
+ return task.worktreeRemoved && (task.branchRemoved || task.keptBranchTip !== void 0);
7447
+ }
7420
7448
  function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedDiffs ? { capturedDiffs: setup.capturedDiffs } : {} }) {
7421
7449
  assertWorktreeMutationAllowed();
7422
7450
  const tasks = [];
@@ -7432,7 +7460,7 @@ function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedD
7432
7460
  } catch (error) {
7433
7461
  errors.push(`worktree prune failed: ${error instanceof Error ? error.message : String(error)}`);
7434
7462
  }
7435
- const state = tasks.every((task) => task.worktreeRemoved && task.branchRemoved) && pruned ? "complete" : "partial";
7463
+ const state = tasks.every(isWorktreeCleanupTaskDone) && pruned ? "complete" : "partial";
7436
7464
  return {
7437
7465
  state,
7438
7466
  tasks,
@@ -7626,6 +7654,7 @@ export {
7626
7654
  resolveExpectedWorktreeAgentCwd,
7627
7655
  createWorktrees,
7628
7656
  diffWorktrees,
7657
+ isWorktreeCleanupTaskDone,
7629
7658
  cleanupWorktrees,
7630
7659
  formatWorktreeDiffSummary,
7631
7660
  validateModelResponseAliases