@vicary/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-6EUQPQY7.js → chunk-443LPCRI.js} +5 -5
  5. package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
  6. package/bundle/{chunk-CKLZ5FGU.js → chunk-4ALRHKGE.js} +1 -1
  7. package/bundle/{chunk-SVIXQDIV.js → chunk-6JD4XCA4.js} +77 -19
  8. package/bundle/{chunk-XZXYPZUT.js → chunk-7JLNWAMO.js} +54 -36
  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-JYHTDTOZ.js → chunk-CFIYO2IV.js} +5 -5
  12. package/bundle/{chunk-CYKNHFXB.js → chunk-EPMRDKQT.js} +1 -1
  13. package/bundle/{chunk-6PR44R7E.js → chunk-ETDE2VYK.js} +2 -2
  14. package/bundle/{chunk-4MVDMA5C.js → chunk-GHJ6BH5U.js} +13 -7
  15. package/bundle/{chunk-IZEKQEY4.js → chunk-HSHLPYCQ.js} +27 -10
  16. package/bundle/{chunk-3MFYKBKI.js → chunk-HZDLR73C.js} +4 -4
  17. package/bundle/{chunk-2DIEL4WG.js → chunk-JFACGAJT.js} +2 -2
  18. package/bundle/{chunk-L4YY2TOE.js → chunk-JRO2CU4D.js} +1 -1
  19. package/bundle/{chunk-KXW62VBU.js → chunk-KOLLMZ2X.js} +1 -1
  20. package/bundle/{chunk-TDJKY2NE.js → chunk-LEPIY76E.js} +34 -5
  21. package/bundle/{chunk-BW5JLKIU.js → chunk-MJHQIUU7.js} +68 -41
  22. package/bundle/{chunk-47ZN7NKR.js → chunk-NONHDYXE.js} +1 -1
  23. package/bundle/{chunk-PJSOS2Q4.js → chunk-NQ26PJSQ.js} +96 -96
  24. package/bundle/{chunk-AOSILI5R.js → chunk-OVBUEVOT.js} +95 -49
  25. package/bundle/{chunk-NVGQE2H2.js → chunk-PFZZMVD5.js} +75 -32
  26. package/bundle/{chunk-YDZ7BZD5.js → chunk-S77ZKDLS.js} +1 -1
  27. package/bundle/{chunk-3DT5X2QC.js → chunk-SLLZJ5EC.js} +50 -18
  28. package/bundle/{chunk-V7SZMS6W.js → chunk-SWL2EITY.js} +2 -2
  29. package/bundle/{chunk-XIA5GSEU.js → chunk-UQT2EQ4U.js} +2 -2
  30. package/bundle/{chunk-YZPVALSQ.js → chunk-WW6GQBBS.js} +4 -4
  31. package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
  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 +2 -2
  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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,59 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.89.0] - 2026-11-16
6
+
7
+ ### Highlights
8
+
9
+ - 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.
10
+ - 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.
11
+ - Editors and other hosts can now show a subagent's transcript while it runs, for foreground subagents and for every child of a workflow.
12
+ - 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.
13
+ - Models such as GLM-5.3 that fill unused options with `"null"` can call `subagent`, and `machine: "local"` works on NixOS.
14
+
15
+ ### Added
16
+
17
+ - 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.
18
+ - 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.
19
+ - 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.
20
+
21
+ ### Fixed
22
+
23
+ - 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.
24
+ - 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.
25
+ - 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.
26
+ - `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.
27
+ - `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.
28
+ - 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.
29
+ - 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.
30
+ - 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.
31
+ - 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.
32
+ - 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.
33
+ - 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.
34
+ - 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.
35
+ - 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.
36
+ - 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.
37
+ - 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.
38
+ - 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.
39
+
40
+ ## [0.88.1] - 2026-11-12
41
+
42
+ ### Highlights
43
+
44
+ - A permission prompt or other dialog that opens while the fleet inspector is up is no longer hidden behind it.
45
+ - Background subagents whose agent has no tool list get your configured MCP tools again, and an extension that registers its own MCP server no longer stops subagents from starting.
46
+ - `status` and `stop` no longer report a cleanly finishing background subagent as having ended without proof.
47
+ - A manual `/compact` no longer wakes an idle parent while background subagents are running.
48
+
49
+ ### Fixed
50
+
51
+ - The fleet inspector no longer covers a dialog that opens while it is up, such as a permission prompt from another extension or a `select`/`confirm`. The inspector steps aside while the dialog is open and comes back, with the same child selected, when it closes. Before, the dialog sat hidden behind the inspector, so `q` seemed to do nothing and Esc answered the hidden prompt. Thanks to [@imLWY](https://github.com/imLWY) for #3254.
52
+ - Background subagents whose agent doesn't list `tools` now get the direct MCP tools you configured in pi-mcp-adapter, as long as no capability ceiling applies. Agents that only set `excludeTools` keep every tool they don't exclude. Before, these subagents lost all direct MCP tools. Thanks to [@acolomba](https://github.com/acolomba) for #3259.
53
+ - A subagent no longer fails to start when one of its required child extensions registers an MCP server with `pi.registerMcpServer()` and the agent selects no `mcp:` tools. Before, the launch stopped with "Required child extension failed during startup". The subagent now runs and shows Pi's message as a warning in its output; any other startup failure of a required extension still stops the launch. With Pi's built-in MCP, foreground subagents can also select `mcp:` tools from servers their required child extensions register; before, every server an extension registered was refused in the foreground. Thanks to [@NicholasSend](https://github.com/NicholasSend) for #3256.
54
+ - `status` and `stop` no longer report a background subagent's exit as `unknown` (`observer-unavailable`) when they are called in the moment between the subagent saving its result and saving its final status. The run now keeps showing `running` until it finishes. Before, a caller waiting for proof that the run ended could see an unverifiable end for a run that exited cleanly. Thanks to [@Ancienttwo](https://github.com/Ancienttwo) for #3258.
55
+ - An extension that changes a workflow child's `task` in its `tool_call` handler for `subagent_launch` now changes what that child is told. Before, the change was dropped and the child got the original text, although Pi applies such changes for every other tool. This covers workflow scripts, `parallel`, `tasks` and `chain`, including steps built from `{previous}`. Other fields and a resumed child's message still can't be changed.
56
+ - With background subagents running, a manual compaction (`/compact`, RPC `compact` or an extension's `ctx.compact()`) no longer starts a turn when the parent was idle or stopped with Esc. Before, every manual compaction resumed the parent, so an extension that compacts on `agent_settled` made it answer "still waiting" each time. A compaction that interrupts a working parent still resumes it. A subagent result that arrives during a compaction now wakes the parent once the compaction ends, instead of starting a run mid-compaction. Thanks to [@IdrisGit](https://github.com/IdrisGit) for #3253 and [@jyshowalter](https://github.com/jyshowalter) for the report. (#3252)
57
+
5
58
  ## [0.88.0] - 2026-11-10
6
59
 
7
60
  ### Highlights
@@ -240,7 +293,7 @@
240
293
  ### Added
241
294
 
242
295
  - 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).
243
- - `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).
296
+ - `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).
244
297
  - 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).
245
298
 
246
299
  ### 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-JRO2CU4D.js";
6
6
  import {
7
7
  registerRuntimeAgent
8
- } from "./chunk-KXW62VBU.js";
9
- import "./chunk-4MVDMA5C.js";
8
+ } from "./chunk-KOLLMZ2X.js";
9
+ import "./chunk-GHJ6BH5U.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-3MFYKBKI.js";
4
- import "./chunk-CTPAE36Y.js";
5
- import "./chunk-4MVDMA5C.js";
3
+ } from "./chunk-HZDLR73C.js";
4
+ import "./chunk-YARY7JWU.js";
5
+ import "./chunk-GHJ6BH5U.js";
6
6
  import "./chunk-JEZOSEWG.js";
7
7
  import "./chunk-YFCK7H2S.js";
8
8
  import "./chunk-QXASAHIA.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isTrustedRecordedSessionFile,
3
3
  resolveSubagentRunId
4
- } from "./chunk-RHYVKQQL.js";
4
+ } from "./chunk-7W2IQFP4.js";
5
5
  import {
6
6
  agentStreamOptions,
7
7
  opencodeSessionHeaders,
8
8
  resolveAsyncResumeTarget
9
- } from "./chunk-SVIXQDIV.js";
9
+ } from "./chunk-6JD4XCA4.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-3DT5X2QC.js";
21
+ } from "./chunk-SLLZJ5EC.js";
22
22
  import {
23
23
  deliverInterruptRequest,
24
24
  queueRevivalBrief,
25
25
  requestAsyncSteer
26
- } from "./chunk-W6HIYD2Z.js";
26
+ } from "./chunk-A3INCQ6Z.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-GHJ6BH5U.js";
38
38
  import {
39
39
  DIRS
40
40
  } from "./chunk-JEZOSEWG.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,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "pi-subagents",
4
- version: "0.88.0",
4
+ version: "0.89.0",
5
5
  private: true,
6
6
  description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
7
7
  author: "Nico Bailon",
@@ -28,6 +28,7 @@ import {
28
28
  hostStepVerdictLabel,
29
29
  isActiveAsyncState,
30
30
  isComparablePathInside,
31
+ isWorktreeCleanupTaskDone,
31
32
  normalizeParallelGroups,
32
33
  normalizeWorktreeBaseRef,
33
34
  parseHostStepNode,
@@ -46,19 +47,19 @@ import {
46
47
  validateModelResponseAliases,
47
48
  withWorkflowChildRunModel,
48
49
  withWorktreeTransaction
49
- } from "./chunk-3DT5X2QC.js";
50
+ } from "./chunk-SLLZJ5EC.js";
50
51
  import {
51
52
  validateIntercomBridgeConfig
52
- } from "./chunk-47ZN7NKR.js";
53
+ } from "./chunk-NONHDYXE.js";
53
54
  import {
54
55
  stableJsonDigest
55
56
  } from "./chunk-7F6RKT6W.js";
56
57
  import {
57
58
  snapshotRequiredChildExtensions
58
- } from "./chunk-CTPAE36Y.js";
59
+ } from "./chunk-YARY7JWU.js";
59
60
  import {
60
61
  missingForkCopyNote
61
- } from "./chunk-YDZ7BZD5.js";
62
+ } from "./chunk-S77ZKDLS.js";
62
63
  import {
63
64
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
64
65
  assertWorkflowLaneKey,
@@ -83,7 +84,7 @@ import {
83
84
  validateToolBudgetConfig,
84
85
  waitForFileSystemRetry,
85
86
  writeAtomicJson
86
- } from "./chunk-4MVDMA5C.js";
87
+ } from "./chunk-GHJ6BH5U.js";
87
88
  import {
88
89
  DIRS,
89
90
  RUNNER_LAUNCHER_NAME_PATTERN,
@@ -545,6 +546,7 @@ function stopStoppableAsyncStatusChildren(status, stopChild, message) {
545
546
  var KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
546
547
  var TERMINAL_STATES = /* @__PURE__ */ new Set(["completed", "failed", "paused", "stopped", "rejected", "detached"]);
547
548
  var MAX_REQUIRED_ID_BYTES = 4096;
549
+ var MAX_SESSION_FILE_BYTES = 4096;
548
550
  var ACTIVITY_COUNTERS = ["currentToolStartedAt", "lastActivityAt", "durationMs", "toolCount", "turnCount", "tokens", "inputTokens", "outputTokens"];
549
551
  function workflowChildProgress(progress) {
550
552
  return {
@@ -599,6 +601,7 @@ function workflowChildSummary(input) {
599
601
  ...bounded(entry.runId, 256) ? { runId: bounded(entry.runId, 256) } : {},
600
602
  ...previous?.agent ? { agent: previous.agent } : {},
601
603
  ...previous?.sessionName ? { sessionName: previous.sessionName } : {},
604
+ ...previous?.sessionFile ? { sessionFile: previous.sessionFile } : {},
602
605
  ...previous?.model ? { model: previous.model } : {},
603
606
  ...previous?.thinking ? { thinking: previous.thinking } : {}
604
607
  });
@@ -615,6 +618,7 @@ function workflowChildSummary(input) {
615
618
  ...bounded(step.runId, 256) ? { runId: bounded(step.runId, 256) } : {},
616
619
  ...launchResolved && bounded(step.agent, 256) ? { agent: bounded(step.agent, 256) } : {},
617
620
  ...bounded(step.sessionName, 256) ? { sessionName: bounded(step.sessionName, 256) } : {},
621
+ ...bounded(step.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: step.sessionFile } : {},
618
622
  ...bounded(step.model, 256) ? { model: bounded(step.model, 256) } : {},
619
623
  ...bounded(step.thinking, 32) ? { thinking: bounded(step.thinking, 32) } : {}
620
624
  });
@@ -629,6 +633,7 @@ function workflowChildSummary(input) {
629
633
  ...bounded(child.runId, 256) ? { runId: bounded(child.runId, 256) } : {},
630
634
  ...bounded(child.agent, 256) ? { agent: bounded(child.agent, 256) } : {},
631
635
  ...bounded(result?.sessionName, 256) ? { sessionName: bounded(result?.sessionName, 256) } : {},
636
+ ...bounded(result?.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: result?.sessionFile } : {},
632
637
  ...bounded(result?.model, 256) ? { model: bounded(result?.model, 256) } : {},
633
638
  ...bounded(result?.thinking, 32) ? { thinking: bounded(result?.thinking, 32) } : {}
634
639
  });
@@ -640,11 +645,14 @@ function workflowChildSummary(input) {
640
645
  }
641
646
  for (const [key, launch] of input.launches ?? []) {
642
647
  const row = rows.get(key);
643
- if (!row || row.state !== "running") continue;
648
+ if (!row) continue;
649
+ const running = row.state === "running";
644
650
  rows.set(key, {
645
651
  ...row,
646
- ...!row.runId && bounded(launch.runId, 256) ? { runId: launch.runId } : {},
647
- ...!row.agent && bounded(launch.agent, 256) ? { agent: launch.agent } : {}
652
+ ...running && !row.runId && bounded(launch.runId, 256) ? { runId: launch.runId } : {},
653
+ ...running && !row.agent && bounded(launch.agent, 256) ? { agent: launch.agent } : {},
654
+ // Finished rows keep it too: live updates carry no child results, so this is a settled child's only transcript link until the workflow returns.
655
+ ...!row.sessionFile && bounded(launch.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: launch.sessionFile } : {}
648
656
  });
649
657
  }
650
658
  for (const [key, progress] of input.progress ?? []) {
@@ -680,16 +688,16 @@ function parseWorkflowChildSummary(value) {
680
688
  const children = input.children.map((row) => {
681
689
  if (!row || typeof row !== "object" || Array.isArray(row)) throw new Error("workflowChildren child row is invalid.");
682
690
  const child = row;
683
- if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "model", "thinking", "state", "activity"].includes(key))) throw new Error("workflowChildren child row has unsupported fields.");
691
+ if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "sessionFile", "model", "thinking", "state", "activity"].includes(key))) throw new Error("workflowChildren child row has unsupported fields.");
684
692
  if (typeof child.childId !== "string" || !KEY_PATTERN.test(child.childId)) throw new Error("workflowChildren childId is invalid.");
685
693
  const state = child.state;
686
694
  if (state !== "pending" && state !== "running" && state !== "completed" && state !== "failed" && state !== "paused" && state !== "stopped" && state !== "rejected" && state !== "detached") throw new Error("workflowChildren child state is invalid.");
687
- for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["model", 256], ["thinking", 32]]) {
695
+ for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["sessionFile", MAX_SESSION_FILE_BYTES], ["model", 256], ["thinking", 32]]) {
688
696
  if (child[field] !== void 0 && bounded(child[field], maxBytes) === void 0) throw new Error(`workflowChildren child ${field} is invalid.`);
689
697
  }
690
698
  const activity = parseActivity(child.activity);
691
699
  if (activity && state !== "running") throw new Error("workflowChildren child activity requires running state.");
692
- return { childId: child.childId, state, ...activity ? { activity } : {}, ...child.runId ? { runId: child.runId } : {}, ...child.agent ? { agent: child.agent } : {}, ...child.sessionName ? { sessionName: child.sessionName } : {}, ...child.model ? { model: child.model } : {}, ...child.thinking ? { thinking: child.thinking } : {} };
700
+ return { childId: child.childId, state, ...activity ? { activity } : {}, ...child.runId ? { runId: child.runId } : {}, ...child.agent ? { agent: child.agent } : {}, ...child.sessionName ? { sessionName: child.sessionName } : {}, ...child.sessionFile ? { sessionFile: child.sessionFile } : {}, ...child.model ? { model: child.model } : {}, ...child.thinking ? { thinking: child.thinking } : {} };
693
701
  });
694
702
  if (new Set(children.map((child) => child.childId)).size !== children.length) throw new Error("workflowChildren has duplicate childId values.");
695
703
  if (typeof input.parentToolCallId !== "string") throw new Error("workflowChildren.parentToolCallId is invalid.");
@@ -1683,6 +1691,12 @@ async function hashFileAsync(diffPath) {
1683
1691
  function splitNul(output) {
1684
1692
  return output.split("\0").filter((part) => part.length > 0);
1685
1693
  }
1694
+ function gitFailureReason(error) {
1695
+ const stderr = error && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "") : "";
1696
+ if (/not a git repository/i.test(stderr)) return "not a Git work tree";
1697
+ const firstLine = (stderr || (error instanceof Error ? error.message : String(error))).split("\n").find((line) => line.trim().length > 0);
1698
+ return firstLine?.trim() ?? "git failed";
1699
+ }
1686
1700
  function hashLargeDiff(cwd, relativePath) {
1687
1701
  const tempDir = fs2.mkdtempSync(path2.join(os.tmpdir(), "pi-subagents-tracked-diff-"));
1688
1702
  const diffPath = path2.join(tempDir, "diff.patch");
@@ -1729,7 +1743,7 @@ function snapshotTrackedMutations(cwd) {
1729
1743
  for (const file of changed.paths) fingerprints[file] = fingerprintPath(cwd, file);
1730
1744
  return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: changed.paths, fingerprints, truncated: changed.truncated };
1731
1745
  } catch (error) {
1732
- return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable: error instanceof Error ? error.message : String(error) };
1746
+ return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable: gitFailureReason(error) };
1733
1747
  }
1734
1748
  }
1735
1749
  async function fingerprintPathAsync(cwd, relativePath) {
@@ -1747,6 +1761,13 @@ async function fingerprintPathAsync(cwd, relativePath) {
1747
1761
  }
1748
1762
  }
1749
1763
  }
1764
+ function remoteMutationSnapshot(cwd) {
1765
+ return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable: "Local Git evidence is not authoritative for a pane-native remote run." };
1766
+ }
1767
+ function remoteMutationEvidence(machine) {
1768
+ const changed = machine.initialGit && machine.finalGit ? machine.initialGit.head !== machine.finalGit.head || machine.initialGit.dirty !== machine.finalGit.dirty : void 0;
1769
+ return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: changed === true, ...changed === void 0 ? { unavailable: "Remote Git before/after evidence was incomplete." } : {} };
1770
+ }
1750
1771
  async function collectTrackedMutationEvidence(snapshot, cwd = snapshot.cwd) {
1751
1772
  if (snapshot.unavailable) {
1752
1773
  return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable: snapshot.unavailable };
@@ -1772,7 +1793,7 @@ async function collectTrackedMutationEvidence(snapshot, cwd = snapshot.cwd) {
1772
1793
  truncated: snapshot.truncated || current.truncated || void 0
1773
1794
  };
1774
1795
  } catch (error) {
1775
- return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable: error instanceof Error ? error.message : String(error) };
1796
+ return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable: gitFailureReason(error) };
1776
1797
  }
1777
1798
  }
1778
1799
  function formatPathList(paths) {
@@ -2745,6 +2766,30 @@ async function withRepositoryWorktreeLock(repo, action, options = {}) {
2745
2766
  // src/runs/shared/parallel-handoff.ts
2746
2767
  import * as fs5 from "node:fs";
2747
2768
  import * as path5 from "node:path";
2769
+
2770
+ // src/runs/shared/kept-branch-text.ts
2771
+ var KEPT_BRANCH_LINE = /^Kept branch (\S+) at ([0-9a-f]+): its commits are on no other branch\.$/;
2772
+ function readKeptBranches(value) {
2773
+ if (!Array.isArray(value)) return [];
2774
+ return value.filter((entry) => typeof entry?.branch === "string" && typeof entry?.tip === "string");
2775
+ }
2776
+ function formatKeptBranchLines(keptBranches) {
2777
+ return keptBranches.map(({ branch, tip }) => `Kept branch ${branch} at ${tip.slice(0, 12)}: its commits are on no other branch.`);
2778
+ }
2779
+ function formatParallelHandoffLines(handoffPath, keptBranches) {
2780
+ return [`Parallel handoff: ${handoffPath}`, ...formatKeptBranchLines(readKeptBranches(keptBranches))];
2781
+ }
2782
+ function parseKeptBranchLines(lines) {
2783
+ const kept = [];
2784
+ for (const line of lines) {
2785
+ const match = line.match(KEPT_BRANCH_LINE);
2786
+ if (!match) break;
2787
+ kept.push({ branch: match[1], tip: match[2] });
2788
+ }
2789
+ return kept;
2790
+ }
2791
+
2792
+ // src/runs/shared/parallel-handoff.ts
2748
2793
  function optionalIdentity(value, label) {
2749
2794
  if (value === void 0) return void 0;
2750
2795
  if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a non-empty string.`);
@@ -2890,6 +2935,7 @@ function resolveRetainedWorktreeCwd(manifestPath, runId, childIndex, recordedWor
2890
2935
  }
2891
2936
  function referenceFor(manifestPath, manifest) {
2892
2937
  const children = manifest.groups.flatMap((group) => group.children);
2938
+ const keptBranches = manifest.groups.flatMap((group) => group.cleanup.tasks.flatMap((task) => task.keptBranchTip ? [{ branch: task.branch, tip: task.keptBranchTip }] : []));
2893
2939
  return {
2894
2940
  version: 1,
2895
2941
  path: manifestPath,
@@ -2897,6 +2943,7 @@ function referenceFor(manifestPath, manifest) {
2897
2943
  childCount: children.length,
2898
2944
  changedPatches: children.filter((child) => child.patch.changed).length,
2899
2945
  cleanupState: manifest.groups.every((group) => group.cleanup.state === "complete") ? "complete" : "partial",
2946
+ ...keptBranches.length ? { keptBranches } : {},
2900
2947
  ...Object.prototype.hasOwnProperty.call(manifest, "cleanupEligibility") ? { cleanupEligibility: trustedStoredCleanupEligibility(manifest) } : {}
2901
2948
  };
2902
2949
  }
@@ -3242,6 +3289,7 @@ function writeParallelHandoffGroupUnlocked(input) {
3242
3289
  const previous = existing?.groups.flatMap((item) => item.cleanup.tasks).find((item) => item.path === task.path && item.branch === task.branch);
3243
3290
  if (previous?.worktreeRemoved) task.worktreeRemoved = true;
3244
3291
  if (previous?.branchRemoved) task.branchRemoved = true;
3292
+ if (previous?.keptBranchTip) task.keptBranchTip = previous.keptBranchTip;
3245
3293
  if (!task.worktreeRemoved && previous?.reason?.includes("retained child resume")) {
3246
3294
  task.preserved = true;
3247
3295
  task.reason = previous.reason;
@@ -3349,10 +3397,15 @@ function writeWorktreeSetupHandoff(input) {
3349
3397
  });
3350
3398
  }
3351
3399
  function formatParallelHandoffReference(reference) {
3352
- return `Worktree handoff: ${reference.path} (${reference.childCount} children, ${reference.changedPatches} changed patches, cleanup ${reference.cleanupState})`;
3400
+ const patches = reference.changedPatches > 0 ? "; the work is in groups[].children[].patch, not applied to this checkout" : "";
3401
+ const kept = reference.cleanupState === "complete" ? "" : "; groups[].cleanup.tasks[] (reason, errors) says what stayed behind";
3402
+ return [
3403
+ `Worktree handoff: ${reference.path} (${reference.childCount} children, ${reference.changedPatches} changed patches, cleanup ${reference.cleanupState})${patches}${kept}`,
3404
+ ...formatKeptBranchLines(reference.keptBranches ?? [])
3405
+ ].join("\n");
3353
3406
  }
3354
3407
  function formatParallelHandoffError(error) {
3355
- return `Worktree handoff unavailable: ${error instanceof Error ? error.message : String(error)}`;
3408
+ return `Worktree handoff unavailable: ${error instanceof Error ? error.message : String(error)}; check \`git worktree list\` for worktrees left behind`;
3356
3409
  }
3357
3410
  function discardPreservedWorktrees(...args) {
3358
3411
  return withHandoffWriteLock(args[0], () => discardPreservedWorktreesUnlocked(...args));
@@ -3363,7 +3416,7 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
3363
3416
  if (!manifest) throw new Error(`Parallel handoff manifest not found: ${resolvedPath}`);
3364
3417
  let attempted = 0;
3365
3418
  for (const group of manifest.groups) {
3366
- const pending = group.cleanup.tasks.filter((task) => task.preserved && (!task.worktreeRemoved || !task.branchRemoved));
3419
+ const pending = group.cleanup.tasks.filter((task) => task.preserved && !isWorktreeCleanupTaskDone(task));
3367
3420
  if (pending.length === 0) continue;
3368
3421
  attempted += pending.length;
3369
3422
  const report = cleanupWorktrees({
@@ -3381,11 +3434,11 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
3381
3434
  syntheticPaths: []
3382
3435
  }))
3383
3436
  }, { kind: "discard", authorization });
3384
- const updates = new Map(report.tasks.map((task) => [task.index, task.worktreeRemoved && task.branchRemoved ? task : { ...task, preserved: true, reason: task.reason ?? "discard cleanup remains incomplete" }]));
3437
+ const updates = new Map(report.tasks.map((task) => [task.index, isWorktreeCleanupTaskDone(task) ? task : { ...task, preserved: true, reason: task.reason ?? "discard cleanup remains incomplete" }]));
3385
3438
  group.cleanup = {
3386
3439
  state: group.cleanup.tasks.every((task) => {
3387
3440
  const next = updates.get(task.index) ?? task;
3388
- return next.worktreeRemoved && next.branchRemoved;
3441
+ return isWorktreeCleanupTaskDone(next);
3389
3442
  }) && report.pruned ? "complete" : "partial",
3390
3443
  tasks: group.cleanup.tasks.map((task) => updates.get(task.index) ?? task),
3391
3444
  pruned: report.pruned,
@@ -3394,7 +3447,7 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
3394
3447
  }
3395
3448
  manifest.updatedAt = Date.now();
3396
3449
  writeAtomicJson(resolvedPath, manifest);
3397
- const remaining = manifest.groups.flatMap((group) => group.cleanup.tasks.map((task) => ({ group, task }))).filter(({ task }) => task.preserved && (!task.worktreeRemoved || !task.branchRemoved));
3450
+ const remaining = manifest.groups.flatMap((group) => group.cleanup.tasks.map((task) => ({ group, task }))).filter(({ task }) => task.preserved && !isWorktreeCleanupTaskDone(task));
3398
3451
  const lines = attempted === 0 ? [`No preserved worktrees remain in ${resolvedPath}.`] : [`Discard processed ${attempted} preserved worktree${attempted === 1 ? "" : "s"}.`, `Manifest: ${resolvedPath}`];
3399
3452
  if (remaining.length > 0) {
3400
3453
  lines.push("", "Some worktrees remain. Inspect and remove them manually if appropriate:");
@@ -4164,6 +4217,8 @@ export {
4164
4217
  projectAsyncWorkflowRows,
4165
4218
  projectAsyncStatusSnapshot,
4166
4219
  snapshotTrackedMutations,
4220
+ remoteMutationSnapshot,
4221
+ remoteMutationEvidence,
4167
4222
  collectTrackedMutationEvidence,
4168
4223
  projectTimeoutRecovery,
4169
4224
  formatTimeoutRecoveryLines,
@@ -4182,6 +4237,9 @@ export {
4182
4237
  utf8Tail,
4183
4238
  withHandoffWriteLock,
4184
4239
  withRepositoryWorktreeLock,
4240
+ readKeptBranches,
4241
+ formatParallelHandoffLines,
4242
+ parseKeptBranchLines,
4185
4243
  readParallelHandoffManifest,
4186
4244
  protectRetainedWorktreeForResume,
4187
4245
  resolveRetainedWorktreeCwd,