pi-subagents 0.83.1 → 0.85.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 (206) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-5YIITCPD.js → chunk-3UZ5FVVJ.js} +322 -110
  5. package/bundle/{chunk-F4ASL6OV.js → chunk-7MAE3DJV.js} +1 -1
  6. package/bundle/{chunk-YXFJVCOL.js → chunk-CS4O36CZ.js} +11 -156
  7. package/bundle/{chunk-AHIFYGR3.js → chunk-DV2NCNPR.js} +22 -11
  8. package/bundle/{chunk-G2Z6ZH26.js → chunk-GCSLVFCX.js} +1 -1
  9. package/bundle/{chunk-2S4K53MV.js → chunk-H2NLFTC5.js} +1 -1
  10. package/bundle/{chunk-MABL3FUM.js → chunk-HFTBF7SG.js} +2 -1
  11. package/bundle/chunk-HXRB42AF.js +108 -0
  12. package/bundle/{chunk-UFL7IYCW.js → chunk-IQIWF2VX.js} +190 -1177
  13. package/bundle/{chunk-NPIYWVOD.js → chunk-JNXT3MPI.js} +15 -6
  14. package/bundle/{chunk-C7JMPU5F.js → chunk-JO67XSKD.js} +59 -27
  15. package/bundle/{chunk-UUP372DR.js → chunk-JWYG26RE.js} +223 -93
  16. package/bundle/{chunk-C5P5CHYK.js → chunk-KDMFBYFM.js} +1 -1
  17. package/bundle/{chunk-V2BZYLEP.js → chunk-KEY3UQMQ.js} +7 -2
  18. package/bundle/{chunk-VLFZIN6D.js → chunk-KZ34KQQH.js} +9 -6
  19. package/bundle/{chunk-ZVOAMTUQ.js → chunk-L2ENOFVZ.js} +76 -58
  20. package/bundle/{chunk-RNIZLSEA.js → chunk-LGMILZNE.js} +323 -18
  21. package/bundle/{chunk-UYK5MZWE.js → chunk-LTPH2DXH.js} +247 -153
  22. package/bundle/{chunk-2D52JFLF.js → chunk-N7B2KD74.js} +41 -117
  23. package/bundle/{chunk-IPGZMQXV.js → chunk-O7CPL6H4.js} +183 -28
  24. package/bundle/{chunk-D3JAFGMO.js → chunk-PHZP3KHB.js} +1 -1
  25. package/bundle/{chunk-2DHZTCOL.js → chunk-PVIVCDG2.js} +2 -2
  26. package/bundle/{chunk-LFDBD4PW.js → chunk-QO75KJBT.js} +2 -2
  27. package/bundle/{chunk-SSG7IEP5.js → chunk-RQAUNAWG.js} +2 -2
  28. package/bundle/{chunk-QP5ZWNIS.js → chunk-RV5OGHLO.js} +6 -3
  29. package/bundle/chunk-T5V5BRCL.js +1067 -0
  30. package/bundle/{chunk-LNRJCP2Y.js → chunk-UX4SCV5N.js} +337 -207
  31. package/bundle/{chunk-F5DBXJ2G.js → chunk-WOVMHDES.js} +234 -182
  32. package/bundle/control-channel.js +2 -2
  33. package/bundle/index.js +1 -1
  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 +17 -2
  38. package/docs/configuration.md +2 -2
  39. package/docs/extension-api.md +16 -1
  40. package/docs/workflows.md +30 -2
  41. package/package.json +1 -1
  42. package/src/agents/agent-management.js +27 -11
  43. package/src/agents/agent-memory.d.ts +1 -4
  44. package/src/agents/agent-memory.js +1 -4
  45. package/src/agents/agents.d.ts +1 -3
  46. package/src/agents/agents.js +7 -6
  47. package/src/agents/frontmatter.js +1 -8
  48. package/src/agents/global-npm-root.d.ts +1 -0
  49. package/src/agents/global-npm-root.js +11 -3
  50. package/src/agents/skills.d.ts +0 -3
  51. package/src/agents/skills.js +0 -3
  52. package/src/extension/config.js +7 -1
  53. package/src/extension/herdr-pi-bridge.js +10 -2
  54. package/src/extension/index.d.ts +0 -13
  55. package/src/extension/index.js +43 -32
  56. package/src/extension/public-execution.d.ts +1 -0
  57. package/src/extension/public-execution.js +4 -0
  58. package/src/extension/reply-workflow-script.js +24 -4
  59. package/src/extension/schemas.d.ts +8 -3
  60. package/src/extension/schemas.js +5 -3
  61. package/src/extension/session-switch.d.ts +25 -0
  62. package/src/extension/session-switch.js +138 -0
  63. package/src/extension/subagent-guide.d.ts +1 -1
  64. package/src/extension/subagent-guide.js +1 -1
  65. package/src/extension/subagent-launch-tool.d.ts +25 -0
  66. package/src/extension/subagent-launch-tool.js +48 -0
  67. package/src/extension/tool-activation.js +25 -11
  68. package/src/extension/tool-description.js +6 -0
  69. package/src/inspectors/herdr/actions.d.ts +0 -1
  70. package/src/inspectors/herdr/actions.js +0 -1
  71. package/src/inspectors/session-roots-codec.d.ts +0 -1
  72. package/src/inspectors/session-roots-codec.js +0 -1
  73. package/src/inspectors/tmux/actions.d.ts +0 -1
  74. package/src/inspectors/tmux/actions.js +0 -1
  75. package/src/integrations/herdr-status.js +3 -8
  76. package/src/intercom/native-supervisor-channel.js +65 -9
  77. package/src/runs/background/async-execution.d.ts +8 -9
  78. package/src/runs/background/async-execution.js +77 -27
  79. package/src/runs/background/async-job-tracker.js +12 -0
  80. package/src/runs/background/async-resume.d.ts +2 -1
  81. package/src/runs/background/async-resume.js +112 -39
  82. package/src/runs/background/async-retention.d.ts +1 -0
  83. package/src/runs/background/async-retention.js +22 -11
  84. package/src/runs/background/auto-drain.js +2 -1
  85. package/src/runs/background/boot-id.d.ts +1 -3
  86. package/src/runs/background/boot-id.js +1 -3
  87. package/src/runs/background/completion-batcher.d.ts +3 -4
  88. package/src/runs/background/completion-batcher.js +2 -3
  89. package/src/runs/background/control-channel.d.ts +0 -6
  90. package/src/runs/background/control-channel.js +0 -6
  91. package/src/runs/background/fleet-view.js +2 -3
  92. package/src/runs/background/notify.d.ts +0 -2
  93. package/src/runs/background/notify.js +0 -2
  94. package/src/runs/background/result-watcher.d.ts +1 -0
  95. package/src/runs/background/result-watcher.js +59 -29
  96. package/src/runs/background/resume-guidance.js +4 -2
  97. package/src/runs/background/retained-children.js +2 -1
  98. package/src/runs/background/run-child-session.d.ts +2 -1
  99. package/src/runs/background/run-child-session.js +10 -2
  100. package/src/runs/background/run-status.js +4 -3
  101. package/src/runs/background/scheduled-runs.d.ts +3 -1
  102. package/src/runs/background/scheduled-runs.js +13 -16
  103. package/src/runs/background/subagent-runner.d.ts +2 -4
  104. package/src/runs/background/subagent-runner.js +10 -6
  105. package/src/runs/background/subagent-wait.js +12 -15
  106. package/src/runs/background/wait-config.d.ts +2 -0
  107. package/src/runs/background/wait-config.js +17 -3
  108. package/src/runs/background/wait-tool.js +4 -2
  109. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  110. package/src/runs/background/workflow-terminal-proof.js +0 -1
  111. package/src/runs/foreground/execution.d.ts +0 -3
  112. package/src/runs/foreground/execution.js +17 -9
  113. package/src/runs/foreground/subagent-executor.d.ts +3 -2
  114. package/src/runs/foreground/subagent-executor.js +112 -26
  115. package/src/runs/shared/child-commands.js +15 -2
  116. package/src/runs/shared/child-hooks.d.ts +1 -7
  117. package/src/runs/shared/child-hooks.js +13 -5
  118. package/src/runs/shared/child-launch.js +6 -2
  119. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  120. package/src/runs/shared/child-session.d.ts +3 -1
  121. package/src/runs/shared/child-session.js +22 -2
  122. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  123. package/src/runs/shared/child-tool-plan.js +0 -1
  124. package/src/runs/shared/claude-code-adapter.js +11 -0
  125. package/src/runs/shared/external-cli-runner.js +26 -6
  126. package/src/runs/shared/herdr-connection.js +2 -1
  127. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  128. package/src/runs/shared/herdr-pane-host.js +17 -1
  129. package/src/runs/shared/herdr-placed-run.js +48 -22
  130. package/src/runs/shared/lane-metadata.d.ts +0 -1
  131. package/src/runs/shared/lane-metadata.js +0 -1
  132. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  133. package/src/runs/shared/model-resolution-diagnostic.d.ts +11 -1
  134. package/src/runs/shared/model-resolution-diagnostic.js +25 -0
  135. package/src/runs/shared/model-resolution.d.ts +2 -2
  136. package/src/runs/shared/model-resolution.js +7 -1
  137. package/src/runs/shared/model-scope.d.ts +1 -5
  138. package/src/runs/shared/model-scope.js +1 -5
  139. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  140. package/src/runs/shared/mutation-evidence.js +52 -7
  141. package/src/runs/shared/nested-events.d.ts +1 -0
  142. package/src/runs/shared/nested-events.js +1 -1
  143. package/src/runs/shared/parallel-utils.d.ts +2 -1
  144. package/src/runs/shared/permissions.js +5 -3
  145. package/src/runs/shared/placement-host.d.ts +5 -1
  146. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  147. package/src/runs/shared/rex-pane-host.js +0 -2
  148. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  149. package/src/runs/shared/run-launch-folder.js +21 -0
  150. package/src/runs/shared/runner-launcher.d.ts +12 -1
  151. package/src/runs/shared/runner-launcher.js +16 -0
  152. package/src/runs/shared/single-output.d.ts +3 -3
  153. package/src/runs/shared/single-output.js +5 -3
  154. package/src/runs/shared/structured-output.d.ts +8 -0
  155. package/src/runs/shared/structured-output.js +30 -2
  156. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  157. package/src/runs/shared/subagent-prompt-runtime.js +4 -2
  158. package/src/runs/shared/tool-timeout.js +2 -1
  159. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  160. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  161. package/src/runs/shared/worktree.d.ts +3 -0
  162. package/src/runs/shared/worktree.js +20 -0
  163. package/src/shared/capacity-resilient-json.d.ts +1 -1
  164. package/src/shared/child-cache-retention.d.ts +1 -2
  165. package/src/shared/child-cache-retention.js +1 -2
  166. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  167. package/src/shared/fleet-transcript-reader.js +333 -0
  168. package/src/shared/formatters.d.ts +0 -18
  169. package/src/shared/formatters.js +0 -18
  170. package/src/shared/session-succession.d.ts +16 -1
  171. package/src/shared/session-succession.js +41 -2
  172. package/src/shared/session-warnings.d.ts +7 -0
  173. package/src/shared/session-warnings.js +26 -0
  174. package/src/shared/settings.d.ts +0 -23
  175. package/src/shared/settings.js +3 -35
  176. package/src/shared/types.d.ts +28 -11
  177. package/src/shared/types.js +0 -12
  178. package/src/shared/utils.d.ts +0 -14
  179. package/src/shared/utils.js +0 -22
  180. package/src/shared/wait-tool-name.d.ts +8 -0
  181. package/src/shared/wait-tool-name.js +13 -0
  182. package/src/slash/slash-commands.js +2 -1
  183. package/src/slash/subagent-cost.d.ts +3 -2
  184. package/src/slash/subagent-cost.js +22 -3
  185. package/src/slash/subagents-admin.js +0 -1
  186. package/src/tui/fleet-status.d.ts +0 -5
  187. package/src/tui/fleet-status.js +4 -24
  188. package/src/tui/fleet-transcript.d.ts +1 -44
  189. package/src/tui/fleet-transcript.js +1 -327
  190. package/src/tui/fleet.js +6 -4
  191. package/src/tui/render.d.ts +0 -9
  192. package/src/tui/render.js +81 -47
  193. package/src/tui/subagent-messages.js +3 -2
  194. package/src/watchdog/register-child.d.ts +2 -3
  195. package/src/watchdog/register-child.js +2 -3
  196. package/src/watchdog/turn-delta.js +2 -1
  197. package/src/workflows/scripted-workflow.js +243 -20
  198. package/src/workflows/workflow-launch-record.d.ts +15 -6
  199. package/src/workflows/workflow-launch-record.js +30 -12
  200. package/src/workflows/workflow-resume-claim.js +2 -2
  201. package/src/workflows/workflow-resume.d.ts +1 -1
  202. package/src/workflows/workflow-resume.js +11 -8
  203. package/src/workflows/workflow-script-worker.d.ts +13 -0
  204. package/src/workflows/workflow-script-worker.js +79 -0
  205. package/workflow-script-process.cjs +36 -0
  206. package/workflow-script-worker.cjs +453 -176
@@ -10,22 +10,27 @@ import {
10
10
  drainOutstandingWork,
11
11
  evaluateChildToolDiagnostic,
12
12
  formatWatchdogCwdSection,
13
- registerNativeSupervisorClient,
14
13
  registerWaitTool,
15
14
  resolveCurrentSessionId,
16
15
  resolveWatchdogReviewModel,
17
16
  startWatchdogDiffBaselineCapture
18
- } from "./chunk-UFL7IYCW.js";
17
+ } from "./chunk-IQIWF2VX.js";
19
18
  import {
20
- MODEL_ONLY_TOOL,
21
19
  agentStreamOptions,
22
20
  opencodeSessionHeaders
23
- } from "./chunk-UYK5MZWE.js";
21
+ } from "./chunk-LTPH2DXH.js";
22
+ import {
23
+ registerNativeSupervisorClient
24
+ } from "./chunk-T5V5BRCL.js";
25
+ import {
26
+ MODEL_ONLY_TOOL
27
+ } from "./chunk-HXRB42AF.js";
24
28
  import {
25
29
  inheritedNestedRouteOf
26
- } from "./chunk-RNIZLSEA.js";
30
+ } from "./chunk-LGMILZNE.js";
27
31
  import {
28
32
  CHILD_WATCHDOG_STATUS_EVENT,
33
+ DEFAULT_WAIT_TOOL_NAME,
29
34
  MISSING_STRUCTURED_ACCEPTANCE_REPORT_ERROR,
30
35
  SUBAGENT_WATCHDOG_WARNING_TYPE,
31
36
  appendPermissionAudit,
@@ -34,12 +39,14 @@ import {
34
39
  getAgentDir,
35
40
  permissionArgsPreview,
36
41
  permissionDecision,
42
+ prepareStructuredOutputArguments,
43
+ setWaitToolName,
37
44
  shouldBlockToolForBudget,
38
45
  toolBudgetBlockedMessage,
39
46
  toolBudgetSoftNudge,
40
47
  validateAcceptanceReport,
41
48
  validateStructuredOutputValue
42
- } from "./chunk-LNRJCP2Y.js";
49
+ } from "./chunk-UX4SCV5N.js";
43
50
  import {
44
51
  INTERCOM_SESSION_IDENTITY_EVENT
45
52
  } from "./chunk-JEZOSEWG.js";
@@ -786,6 +793,7 @@ function registerStructuredOutputTool(pi, structured) {
786
793
  label: "Structured Output",
787
794
  description: "Submit the required final structured output for this subagent step. This terminates the step.",
788
795
  parameters,
796
+ prepareArguments: (args) => prepareStructuredOutputArguments(structured.schema, args),
789
797
  async execute(_id, params) {
790
798
  const validation = await validateStructuredOutputValue(structured.schema, params.value);
791
799
  if (validation.status === "invalid") {
@@ -839,6 +847,7 @@ function registerSubagentPromptRuntime(pi, config, drainObservation) {
839
847
  } }
840
848
  };
841
849
  const nestedRootRunId = inheritedNestedRouteOf(config)?.rootRunId;
850
+ setWaitToolName(config.waitTool.name ?? DEFAULT_WAIT_TOOL_NAME);
842
851
  if (typeof pi.registerTool === "function") registerWaitTool(pi, waitState, config.waitTool.enabled, void 0, config.waitTool.defaultTimeoutMs, { nestedRootRunId }, () => config.hasPendingSupervisorRequest?.() === true);
843
852
  const supervisorMetadata = childSupervisorMetadata(config);
844
853
  let nativeSupervisorClientRegistered = false;
@@ -1,22 +1,18 @@
1
1
  import {
2
2
  PLACED_RESTORE_UNSUPPORTED,
3
- REX_BUNDLE_BIN,
4
- REX_CALL_TIMEOUT_MS,
5
- REX_EXIT_GONE,
6
- REX_EXIT_UNREACHABLE,
7
- REX_MAX_OUTPUT,
8
3
  connectHerdrMachine,
9
- isRexLocalMachine,
10
4
  remoteShellCommand,
11
- resolveRexBinary,
12
- rexCommandEnv,
13
- rexGlobalArgs,
14
5
  runBoundedCommand,
15
6
  sshMachineAccess
16
- } from "./chunk-2D52JFLF.js";
7
+ } from "./chunk-N7B2KD74.js";
17
8
  import {
18
9
  package_default
19
- } from "./chunk-MABL3FUM.js";
10
+ } from "./chunk-HFTBF7SG.js";
11
+ import {
12
+ ensureSupervisorChannelDir
13
+ } from "./chunk-T5V5BRCL.js";
14
+ import "./chunk-HXRB42AF.js";
15
+ import "./chunk-NIXWDZZV.js";
20
16
  import {
21
17
  HERDR_PI_MODE_ENV,
22
18
  HERDR_PI_PROTOCOL,
@@ -27,9 +23,18 @@ import {
27
23
  validateHerdrPiRunId
28
24
  } from "./chunk-4QFZZV3O.js";
29
25
  import {
26
+ REX_BUNDLE_BIN,
27
+ REX_CALL_TIMEOUT_MS,
28
+ REX_EXIT_GONE,
29
+ REX_EXIT_UNREACHABLE,
30
+ REX_MAX_OUTPUT,
30
31
  getAgentDir,
31
- getPiSpawnCommand
32
- } from "./chunk-LNRJCP2Y.js";
32
+ getPiSpawnCommand,
33
+ isRexLocalMachine,
34
+ resolveRexBinary,
35
+ rexCommandEnv,
36
+ rexGlobalArgs
37
+ } from "./chunk-UX4SCV5N.js";
33
38
  import "./chunk-JEZOSEWG.js";
34
39
  import "./chunk-YFCK7H2S.js";
35
40
  import "./chunk-QXASAHIA.js";
@@ -459,8 +464,18 @@ var herdrPaneHost = {
459
464
  const { terminalId } = await startHerdrAgent(connection, owned, request.kind, request.name, request.args, options);
460
465
  return { owned, terminalId };
461
466
  },
462
- async prompt(connection, identity, text) {
463
- await connection.client.call("agent.prompt", { target: identity.agentName, text });
467
+ async prompt(connection, identity, text, options = {}) {
468
+ const clock = options.clock ?? { now: () => Date.now(), wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) }, deadline = clock.now() + (options.timeoutMs ?? 5e3), pollMs = options.pollMs ?? 100;
469
+ for (; ; ) {
470
+ try {
471
+ await connection.client.call("agent.prompt", { target: identity.agentName, text });
472
+ return;
473
+ } catch (error) {
474
+ if (!(error instanceof Error) || !error.message.includes("is not an active named agent") || clock.now() >= deadline) throw error;
475
+ await clock.wait(Math.min(pollMs, deadline - clock.now()));
476
+ if (options.stopped?.()) throw new Error("Remote Pi prompt was not sent because the run was stopped.", { cause: error });
477
+ }
478
+ }
464
479
  },
465
480
  subscribe(connection, paneId, listener, onDisconnect) {
466
481
  return connection.client.subscribe(herdrStatusSubscriptions(paneId), listener, onDisconnect);
@@ -964,6 +979,7 @@ var HerdrPiSession = class {
964
979
  #reconnectFactory;
965
980
  #reconnectFailure;
966
981
  #replyTimer;
982
+ #repliesInFlight = /* @__PURE__ */ new Set();
967
983
  supervisorDir;
968
984
  runtime;
969
985
  owner;
@@ -978,20 +994,35 @@ var HerdrPiSession = class {
978
994
  this.#initialGit = initialGit;
979
995
  bridge.adopt((frame) => this.#frame(frame));
980
996
  if (this.supervisorDir) {
981
- this.#replyTimer = setInterval(() => {
982
- const replies = path5.join(this.supervisorDir, "replies");
983
- for (const name of fs3.existsSync(replies) ? fs3.readdirSync(replies) : []) {
984
- const file = path5.join(replies, name);
985
- try {
986
- const value = JSON.parse(fs3.readFileSync(file, "utf8"));
987
- if (typeof value.message === "string" && typeof value.requestId === "string") void this.#operation("supervisor-reply", value.message, value.requestId, typeof value.error === "string" ? value.error : void 0).then(() => fs3.rmSync(file, { force: true }));
988
- } catch {
989
- }
990
- }
991
- }, 50);
997
+ this.#replyTimer = setInterval(() => this.#deliverSupervisorReplies(this.supervisorDir), 50);
992
998
  this.#replyTimer.unref?.();
993
999
  }
994
1000
  }
1001
+ // Runs on a timer, where a throw or an unhandled rejection exits Pi. A reply that can't be read or delivered stays
1002
+ // on disk for the next tick, once its earlier delivery has settled; a lost transport reaches the session through the
1003
+ // bridge failure.
1004
+ #deliverSupervisorReplies(supervisorDir) {
1005
+ const replies = path5.join(supervisorDir, "replies");
1006
+ let names;
1007
+ try {
1008
+ names = fs3.existsSync(replies) ? fs3.readdirSync(replies) : [];
1009
+ } catch {
1010
+ return;
1011
+ }
1012
+ for (const name of names) {
1013
+ const file = path5.join(replies, name);
1014
+ if (this.#repliesInFlight.has(file)) continue;
1015
+ try {
1016
+ const value = JSON.parse(fs3.readFileSync(file, "utf8"));
1017
+ if (typeof value.message === "string" && typeof value.requestId === "string") {
1018
+ this.#repliesInFlight.add(file);
1019
+ void this.#operation("supervisor-reply", value.message, value.requestId, typeof value.error === "string" ? value.error : void 0).then(() => fs3.rmSync(file, { force: true })).catch(() => {
1020
+ }).finally(() => this.#repliesInFlight.delete(file));
1021
+ }
1022
+ } catch {
1023
+ }
1024
+ }
1025
+ }
995
1026
  get host() {
996
1027
  return this.owner.host;
997
1028
  }
@@ -1102,6 +1133,7 @@ var HerdrPiSession = class {
1102
1133
  const createdAt = Date.now();
1103
1134
  const file = path5.join(this.supervisorDir, "requests", `${path5.basename(frame.requestId)}.json`);
1104
1135
  const request = { type: "subagent.supervisor.request", id: frame.requestId, createdAt, ...reason !== "progress_update" ? { expiresAt: createdAt + 10 * 6e4 } : {}, reason, message: typeof frame.message === "string" ? frame.message : "", ...frame.interview && typeof frame.interview === "object" ? { interview: frame.interview } : {}, expectsReply: reason !== "progress_update", runId: this.runtime.runId ?? this.identity.runId, agent: this.runtime.agent ?? "remote", childIndex: this.runtime.childIndex ?? 0, orchestratorSessionId: this.runtime.orchestratorSessionId };
1136
+ ensureSupervisorChannelDir(this.supervisorDir);
1105
1137
  try {
1106
1138
  fs3.writeFileSync(file, JSON.stringify(request), { mode: 384, flag: "wx" });
1107
1139
  } catch (error) {
@@ -1117,7 +1149,7 @@ var HerdrPiSession = class {
1117
1149
  if (operation === "prompt") completion = new Promise((resolve, reject) => this.#operations.set(requestId, { resolve, reject, accepted: false, settled: false }));
1118
1150
  try {
1119
1151
  await Promise.race([this.bridge.prepare(requestId, operation, text, supervisorId, supervisorError), this.bridge.failure]);
1120
- await this.host.prompt(this.connection, this.identity, `/pi-subagents-bridge ${requestId}`);
1152
+ await this.host.prompt(this.connection, this.identity, `/pi-subagents-bridge ${requestId}`, operation === "abort" ? {} : { stopped: () => this.#aborted || this.#disposed });
1121
1153
  await completion;
1122
1154
  } catch (error) {
1123
1155
  if (operation === "prompt" && this.bridge.failed) {