@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
@@ -10,10 +10,10 @@ import {
10
10
  setInlineWorkflowCoverage,
11
11
  setMainThinkingLevelSource,
12
12
  widgetRenderKey
13
- } from "./chunk-YZPVALSQ.js";
13
+ } from "./chunk-WW6GQBBS.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-CKLZ5FGU.js";
16
+ } from "./chunk-4ALRHKGE.js";
17
17
  import {
18
18
  EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
19
19
  REVIVAL_ORIGIN_FILE,
@@ -23,6 +23,8 @@ import {
23
23
  buildSubagentResultIntercomPayload,
24
24
  clearProviderRetry,
25
25
  compactNestedResultChildren,
26
+ compactionInProgress,
27
+ compactionInterruptedRun,
26
28
  controlNotificationKey,
27
29
  createParentWake,
28
30
  createScheduledRunManager,
@@ -37,6 +39,7 @@ import {
37
39
  getInspectorPlugins,
38
40
  hasLiveSubagentWork,
39
41
  hasWorkflowResumeRefusal,
42
+ installCompactionInterruptionCapture,
40
43
  listRetainedChildren,
41
44
  listScheduledRunSummaries,
42
45
  markSeenWithTtl,
@@ -60,9 +63,10 @@ import {
60
63
  sameProviderDiagnostics,
61
64
  serviceExternalJobBridgeRequests,
62
65
  snapshotProviderDiagnostics,
66
+ takeCompactionAbort,
63
67
  workflowResumeClaimState,
64
68
  workflowResumeRefusal
65
- } from "./chunk-AOSILI5R.js";
69
+ } from "./chunk-OVBUEVOT.js";
66
70
  import {
67
71
  SUBAGENT_CHILD_ENV,
68
72
  SUBAGENT_PARENT_SESSION_ENV,
@@ -82,14 +86,14 @@ import {
82
86
  resolvePiSessionId,
83
87
  resolveWaitToolConfig,
84
88
  setDeclarationPinning
85
- } from "./chunk-JYHTDTOZ.js";
89
+ } from "./chunk-CFIYO2IV.js";
86
90
  import {
87
91
  deliverAsyncRunStop,
88
92
  ownerConfirmedDead,
89
93
  readSessionMessagesTail,
90
94
  resolveSubagentRunId,
91
95
  restoreForegroundRunHistory
92
- } from "./chunk-RHYVKQQL.js";
96
+ } from "./chunk-7W2IQFP4.js";
93
97
  import {
94
98
  ASYNC_STATUS_SNAPSHOT_KIND,
95
99
  ASYNC_STATUS_SNAPSHOT_VERSION,
@@ -105,7 +109,7 @@ import {
105
109
  resolveAsyncStatusChild,
106
110
  runLaunchDir,
107
111
  stopStoppableAsyncStatusChildren
108
- } from "./chunk-SVIXQDIV.js";
112
+ } from "./chunk-6JD4XCA4.js";
109
113
  import {
110
114
  CONTACT_SUPERVISOR_TOOL_NAME,
111
115
  NATIVE_SUPERVISOR_TOOL_NAME,
@@ -115,7 +119,7 @@ import {
115
119
  parseSupervisorReplyData,
116
120
  parseSupervisorRequestDetails,
117
121
  topLevelSupervisorTool
118
- } from "./chunk-CYKNHFXB.js";
122
+ } from "./chunk-EPMRDKQT.js";
119
123
  import {
120
124
  MODEL_ONLY_TOOL,
121
125
  canRenderComponents,
@@ -141,7 +145,7 @@ import {
141
145
  resolveDisabledFeatureSurface,
142
146
  resolveMaxActiveAsyncRunsPerSession,
143
147
  resolveScheduledStoreRoot
144
- } from "./chunk-6PR44R7E.js";
148
+ } from "./chunk-ETDE2VYK.js";
145
149
  import {
146
150
  ACTIVE_RUN_INDEX_DIR,
147
151
  MissionNotFoundError,
@@ -192,28 +196,28 @@ import {
192
196
  withWorkflowChildRunModel,
193
197
  writeAsyncResultFile,
194
198
  writeResultIndexForData
195
- } from "./chunk-3DT5X2QC.js";
196
- import "./chunk-W6HIYD2Z.js";
199
+ } from "./chunk-SLLZJ5EC.js";
200
+ import "./chunk-A3INCQ6Z.js";
197
201
  import {
198
202
  shouldUseNativeFsWatch
199
203
  } from "./chunk-NIXWDZZV.js";
200
204
  import {
201
205
  validateIntercomBridgeConfig
202
- } from "./chunk-47ZN7NKR.js";
206
+ } from "./chunk-NONHDYXE.js";
203
207
  import "./chunk-7F6RKT6W.js";
204
- import "./chunk-3MFYKBKI.js";
205
- import "./chunk-CTPAE36Y.js";
208
+ import "./chunk-HZDLR73C.js";
209
+ import "./chunk-YARY7JWU.js";
206
210
  import {
207
211
  listHerdrProjectPaneRoots,
208
212
  restoreHerdrProjectPaneSnapshots
209
- } from "./chunk-2DIEL4WG.js";
213
+ } from "./chunk-JFACGAJT.js";
210
214
  import "./chunk-7J4ZXMY7.js";
211
215
  import {
212
216
  cleanupAllArtifactDirs,
213
217
  cleanupOldArtifacts,
214
218
  getArtifactPaths,
215
219
  getArtifactsDir
216
- } from "./chunk-YDZ7BZD5.js";
220
+ } from "./chunk-S77ZKDLS.js";
217
221
  import {
218
222
  listBackgroundWorkProviders
219
223
  } from "./chunk-XA3DY6UG.js";
@@ -221,12 +225,12 @@ import "./chunk-YYREO77V.js";
221
225
  import "./chunk-UKG4V45O.js";
222
226
  import {
223
227
  registerRuntimeAgentEventListener
224
- } from "./chunk-L4YY2TOE.js";
228
+ } from "./chunk-JRO2CU4D.js";
225
229
  import {
226
230
  clearRuntimeAgentsForPi,
227
231
  listRuntimeAgentConfigs,
228
232
  mergeRuntimeAgents
229
- } from "./chunk-KXW62VBU.js";
233
+ } from "./chunk-KOLLMZ2X.js";
230
234
  import {
231
235
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
232
236
  DEFAULT_WAIT_TOOL_NAME,
@@ -269,7 +273,7 @@ import {
269
273
  waitToolName,
270
274
  withSettingsFileLease,
271
275
  writeAtomicJson
272
- } from "./chunk-4MVDMA5C.js";
276
+ } from "./chunk-GHJ6BH5U.js";
273
277
  import {
274
278
  DEFAULT_ARTIFACT_CONFIG,
275
279
  DIRS,
@@ -317,6 +321,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
317
321
  import * as fs16 from "node:fs";
318
322
  import * as os3 from "node:os";
319
323
  import * as path16 from "node:path";
324
+ import { AgentSession } from "@earendil-works/pi-coding-agent";
320
325
  import { Box as Box2, Container as Container3, Spacer as Spacer3, Text as Text2 } from "@earendil-works/pi-tui";
321
326
 
322
327
  // src/agents/global-npm-root.ts
@@ -5365,7 +5370,7 @@ function registerSlashCommands(pi, state, options = {}) {
5365
5370
  }
5366
5371
  fleetOpen = true;
5367
5372
  try {
5368
- const { openSubagentFleet } = await import("./chunk-IZEKQEY4.js");
5373
+ const { openSubagentFleet } = await import("./chunk-HSHLPYCQ.js");
5369
5374
  await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
5370
5375
  } finally {
5371
5376
  fleetOpen = false;
@@ -8691,6 +8696,7 @@ function registerSubagentExtension(pi) {
8691
8696
  if (process.env[SUBAGENT_CHILD_ENV] === "1") {
8692
8697
  return;
8693
8698
  }
8699
+ installCompactionInterruptionCapture(AgentSession);
8694
8700
  const runtimeRegistry = getRuntimeRegistry();
8695
8701
  setMainThinkingLevelSource(() => readMainThinkingLevel(() => pi.getThinkingLevel()));
8696
8702
  DIRS.results = ensureAccessibleDir(DIRS.results);
@@ -8778,7 +8784,7 @@ function registerSubagentExtension(pi) {
8778
8784
  const ctx = withLastUiContext((current) => current);
8779
8785
  if (!ctx) return;
8780
8786
  try {
8781
- const { openSubagentFleet } = await import("./chunk-IZEKQEY4.js");
8787
+ const { openSubagentFleet } = await import("./chunk-HSHLPYCQ.js");
8782
8788
  await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
8783
8789
  } catch (error) {
8784
8790
  if (isStaleExtensionContextError(error)) {
@@ -8987,7 +8993,7 @@ function registerSubagentExtension(pi) {
8987
8993
  let executor;
8988
8994
  let executorPromise;
8989
8995
  let executorModulePromise;
8990
- const loadExecutorModule = () => executorModulePromise ??= import("./chunk-BW5JLKIU.js");
8996
+ const loadExecutorModule = () => executorModulePromise ??= import("./chunk-MJHQIUU7.js");
8991
8997
  const getExecutor = () => {
8992
8998
  executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
8993
8999
  executor = createSubagentExecutor(executorDeps);
@@ -9001,7 +9007,7 @@ function registerSubagentExtension(pi) {
9001
9007
  modulePreloadTimer = setTimeout(() => {
9002
9008
  loadExecutorModule().catch(() => {
9003
9009
  });
9004
- if (fleetViewEnabled) import("./chunk-IZEKQEY4.js").catch(() => {
9010
+ if (fleetViewEnabled) import("./chunk-HSHLPYCQ.js").catch(() => {
9005
9011
  });
9006
9012
  }, MODULE_PRELOAD_DELAY_MS);
9007
9013
  modulePreloadTimer.unref?.();
@@ -9174,7 +9180,7 @@ ${close}` }]
9174
9180
  registerWaitTool(pi, state, waitToolConfig.enabled, waitSubscriptionManager, waitToolConfig.defaultTimeoutMs, void 0, supervisorChannel.hasPendingRequests);
9175
9181
  pi.on("agent_end", async (_event, ctx) => {
9176
9182
  try {
9177
- if (ctx.hasUI && ctx.signal?.aborted) {
9183
+ if (ctx.hasUI && ctx.signal?.aborted && !takeCompactionAbort(ctx.sessionManager)) {
9178
9184
  parentWake.userAborted();
9179
9185
  const active = activeAsyncJobCount();
9180
9186
  if (active > 0) ctx.ui.notify(`${active} background subagent run${active === 1 ? " is" : "s are"} still active${slashCommandsEnabled ? " \xB7 /subagents-stop" : ""}`, "info");
@@ -9490,9 +9496,11 @@ ${close}` }]
9490
9496
  }
9491
9497
  };
9492
9498
  let compactionResumeTimer;
9499
+ let compactionInterruptedParent = false;
9493
9500
  const cancelCompactionResume = () => {
9494
9501
  clearTimeout(compactionResumeTimer);
9495
9502
  compactionResumeTimer = void 0;
9503
+ compactionInterruptedParent = false;
9496
9504
  };
9497
9505
  pi.on("agent_start", () => {
9498
9506
  cancelCompactionResume();
@@ -9512,32 +9520,42 @@ ${close}` }]
9512
9520
  pi.on("session_before_compact", (event) => {
9513
9521
  if (event.reason !== "manual") suspendWidgetsForCompaction();
9514
9522
  });
9515
- pi.on("session_compact", (event) => {
9523
+ const wakeAfterCompaction = (completed) => (event, ctx) => {
9516
9524
  if (event.reason !== "manual") return;
9517
- if (activeAsyncJobCount() === 0 || !withLastUiContext(() => true)) return;
9518
- cancelCompactionResume();
9525
+ const sessionManager = ctx.sessionManager;
9526
+ if (completed && compactionInterruptedRun(sessionManager)) compactionInterruptedParent = true;
9527
+ if (compactionResumeTimer) return;
9519
9528
  const sessionId = state.currentSessionId;
9520
9529
  const deadline = Date.now() + COMPACTION_RESUME_DEADLINE_MS;
9521
- const resumeWhenIdle = () => {
9522
- if (state.currentSessionId !== sessionId || activeAsyncJobCount() === 0) return;
9523
- const idle = withLastUiContext((ctx) => ctx.isIdle());
9524
- if (idle === void 0) return;
9525
- if (!idle) {
9526
- if (Date.now() < deadline) compactionResumeTimer = setTimeout(resumeWhenIdle, COMPACTION_RESUME_POLL_MS);
9530
+ const wakeWhenIdle = () => {
9531
+ compactionResumeTimer = void 0;
9532
+ if (state.currentSessionId !== sessionId) return;
9533
+ let idle;
9534
+ try {
9535
+ idle = ctx.isIdle();
9536
+ } catch {
9527
9537
  return;
9528
9538
  }
9529
- parentWake.releaseHold();
9539
+ if (!idle || compactionInProgress(sessionManager)) {
9540
+ if (Date.now() < deadline) compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
9541
+ return;
9542
+ }
9543
+ const interrupted = compactionInterruptedParent && activeAsyncJobCount() > 0 && withLastUiContext(() => true) === true;
9544
+ compactionInterruptedParent = false;
9545
+ if (!parentWake.takeDeferredWake() && !interrupted) return;
9530
9546
  parentWake.sendMessage(
9531
9547
  {
9532
9548
  customType: "subagent-compaction-resume",
9533
- content: "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready.",
9549
+ content: interrupted ? "Compaction is complete. Resume the parent task now; background subagent results will arrive separately when ready." : "Compaction is complete. Act on the background subagent notices above.",
9534
9550
  display: false
9535
9551
  },
9536
9552
  { triggerTurn: true }
9537
9553
  );
9538
9554
  };
9539
- compactionResumeTimer = setTimeout(resumeWhenIdle, COMPACTION_RESUME_POLL_MS);
9540
- });
9555
+ compactionResumeTimer = setTimeout(wakeWhenIdle, COMPACTION_RESUME_POLL_MS);
9556
+ };
9557
+ pi.on("session_compact", wakeAfterCompaction(true));
9558
+ pi.on("session_compact_failed", wakeAfterCompaction(false));
9541
9559
  pi.on("session_start", (event, ctx) => {
9542
9560
  parentWake.bindSession(ctx);
9543
9561
  completionNotifier.bindSession(ctx.sessionManager);
@@ -12,7 +12,7 @@ import {
12
12
  summarizeContextModes,
13
13
  utf8Tail,
14
14
  workflowPreflightLaneForRuntimeKey
15
- } from "./chunk-SVIXQDIV.js";
15
+ } from "./chunk-6JD4XCA4.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-3DT5X2QC.js";
37
+ } from "./chunk-SLLZJ5EC.js";
38
38
  import {
39
39
  deliverStopRequest,
40
40
  stopInboxClosedPath
41
- } from "./chunk-W6HIYD2Z.js";
41
+ } from "./chunk-A3INCQ6Z.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-GHJ6BH5U.js";
54
54
  import {
55
55
  DIRS
56
56
  } from "./chunk-JEZOSEWG.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  resolveWatchPath,
6
6
  writeAtomicJson
7
- } from "./chunk-4MVDMA5C.js";
7
+ } from "./chunk-GHJ6BH5U.js";
8
8
  import {
9
9
  POLL_INTERVAL_MS
10
10
  } from "./chunk-JEZOSEWG.js";
@@ -8,7 +8,7 @@ import {
8
8
  projectTimeoutRecovery,
9
9
  readAsyncRecoveryDescriptor,
10
10
  utf8Tail
11
- } from "./chunk-SVIXQDIV.js";
11
+ } from "./chunk-6JD4XCA4.js";
12
12
  import {
13
13
  MAX_ARGS_BYTES,
14
14
  MAX_ARGS_DEPTH,
@@ -21,10 +21,10 @@ import {
21
21
  resultFilePath,
22
22
  resultPayloadMatchesSessionRun,
23
23
  resultPayloadPathForSessionRun
24
- } from "./chunk-3DT5X2QC.js";
24
+ } from "./chunk-SLLZJ5EC.js";
25
25
  import {
26
26
  PROJECT_SUBAGENTS_RELATIVE_DIR
27
- } from "./chunk-YDZ7BZD5.js";
27
+ } from "./chunk-S77ZKDLS.js";
28
28
  import {
29
29
  listBackgroundWorkWakeChannels,
30
30
  snapshotBackgroundWork
@@ -50,7 +50,7 @@ import {
50
50
  waitToolName,
51
51
  withSettingsFileLease,
52
52
  writePrivateAtomicJson
53
- } from "./chunk-4MVDMA5C.js";
53
+ } from "./chunk-GHJ6BH5U.js";
54
54
  import {
55
55
  DIRS,
56
56
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -906,7 +906,7 @@ var SubagentParamProperties = {
906
906
  usageBudget: Type2.Optional(UsageBudgetOverride),
907
907
  agentScope: Type2.Optional(Type2.String({ description: "user/project/both (default); project wins collisions." })),
908
908
  cwd: Type2.Optional(Type2.String({ description: "Execution/project-pane directory." })),
909
- machine: Type2.Optional(Type2.String({ minLength: 1, maxLength: 128, description: 'Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or "local" (a Pi child in a Rex pane here). On another machine, cwd is a directory there.' })),
909
+ machine: Type2.Optional(Type2.String({ minLength: 1, maxLength: 128, description: 'Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or "local" (a Pi child in a new tab of the Herdr or Rex session this Pi runs in). On another machine, cwd is a directory there.' })),
910
910
  requireLauncher: Type2.Optional(Type2.Object({
911
911
  name: Type2.String({ pattern: RUNNER_LAUNCHER_NAME_PATTERN.source }),
912
912
  definitionDigest: Type2.String({ pattern: "^[0-9a-f]{64}$" })
@@ -11,7 +11,7 @@ import {
11
11
  readStatus,
12
12
  writeAtomicJson,
13
13
  writePrivateAtomicJson
14
- } from "./chunk-4MVDMA5C.js";
14
+ } from "./chunk-GHJ6BH5U.js";
15
15
  import {
16
16
  ASYNC_DIR,
17
17
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -11,13 +11,13 @@ import {
11
11
  validateAuthorityPolicy,
12
12
  validateMissionStoreConfig,
13
13
  validateModelResponseAliases
14
- } from "./chunk-3DT5X2QC.js";
14
+ } from "./chunk-SLLZJ5EC.js";
15
15
  import {
16
16
  getAgentDir,
17
17
  readStatus,
18
18
  validatePermissionConfig,
19
19
  writePrivateAtomicJson
20
- } from "./chunk-4MVDMA5C.js";
20
+ } from "./chunk-GHJ6BH5U.js";
21
21
  import {
22
22
  FLEET_KEYBINDING_ACTIONS,
23
23
  RUNNER_LAUNCHER_NAME_PATTERN,
@@ -6561,6 +6561,9 @@ var REX_EXIT_UNREACHABLE = 4;
6561
6561
  function isRexLocalMachine(machine) {
6562
6562
  return machine?.provider === "rex" && !("target" in machine);
6563
6563
  }
6564
+ function editsLocalDisk(machine) {
6565
+ return machine !== void 0 && !("target" in machine);
6566
+ }
6564
6567
  var REX_BUNDLE_BIN = "Library/Application Support/com.superlogical.rex/RexServer/Versions/Current/Rex Server.app/Contents/MacOS/rex";
6565
6568
  var REX_CALL_TIMEOUT_MS = 15e3;
6566
6569
  var REX_MAX_OUTPUT = 1024 * 1024;
@@ -6604,9 +6607,12 @@ function resolveRexLocalPlacement(input) {
6604
6607
  if (result.status === REX_EXIT_UNREACHABLE) throw new Error("Machine 'local' needs the Rex server, but it is unreachable.");
6605
6608
  if (result.status !== 0) throw new Error(`rex session inspect exited with code ${result.status}: ${(result.stderr || result.stdout).trim().slice(0, 512)}`);
6606
6609
  if (!sessionConfirmed(result.stdout, session)) throw new Error(`The Rex server did not confirm session ${session}.`);
6607
- const stepCwd = input.stepCwd?.trim();
6608
- const home = stepCwd === "~" || stepCwd?.startsWith("~/") ? path12.join(os4.homedir(), stepCwd.slice(1)) : void 0;
6609
- const requested = home ?? (stepCwd ? path12.resolve(input.cwd, stepCwd) : input.cwd);
6610
+ return { provider: "rex", id: REX_LOCAL_MACHINE, session, cwd: resolveLocalLaunchCwd(input.cwd, input.stepCwd), ...server ? { server } : {} };
6611
+ }
6612
+ function resolveLocalLaunchCwd(parentCwd, stepCwd) {
6613
+ const step = stepCwd?.trim();
6614
+ const home = step === "~" || step?.startsWith("~/") ? path12.join(os4.homedir(), step.slice(1)) : void 0;
6615
+ const requested = home ?? (step ? path12.resolve(parentCwd, step) : parentCwd);
6610
6616
  let cwd;
6611
6617
  try {
6612
6618
  cwd = fs12.realpathSync(requested);
@@ -6614,9 +6620,7 @@ function resolveRexLocalPlacement(input) {
6614
6620
  throw new Error(`Machine 'local' cwd does not exist: ${requested}.`, { cause: error });
6615
6621
  }
6616
6622
  if (!fs12.statSync(cwd).isDirectory()) throw new Error(`Machine 'local' cwd is not a directory: ${requested}.`);
6617
- const machine = { provider: "rex", id: REX_LOCAL_MACHINE, session, cwd };
6618
- if (server) machine.server = server;
6619
- return machine;
6623
+ return cwd;
6620
6624
  }
6621
6625
 
6622
6626
  // src/runs/shared/single-output.ts
@@ -6701,7 +6705,7 @@ function outputPathMappingFromTask(task, savedPath) {
6701
6705
  }
6702
6706
  function injectSingleOutputInstruction(task, outputPath, capabilities, machine) {
6703
6707
  if (!outputPath) return task;
6704
- const remote = machine !== void 0 && !isRexLocalMachine(machine);
6708
+ const remote = machine !== void 0 && !editsLocalDisk(machine);
6705
6709
  const delivery = !remote && (!capabilities || hasOutputWriteCapability(capabilities.tools, capabilities.mcpDirectTools)) ? `Write your findings to exactly this path: ${outputPath}` : [
6706
6710
  "Return the complete artifact in your final response.",
6707
6711
  `The runtime will persist it to exactly this path: ${outputPath}`,
@@ -8629,6 +8633,7 @@ export {
8629
8633
  REX_EXIT_GONE,
8630
8634
  REX_EXIT_UNREACHABLE,
8631
8635
  isRexLocalMachine,
8636
+ editsLocalDisk,
8632
8637
  REX_BUNDLE_BIN,
8633
8638
  REX_CALL_TIMEOUT_MS,
8634
8639
  REX_MAX_OUTPUT,
@@ -8636,6 +8641,7 @@ export {
8636
8641
  resolveRexBinary,
8637
8642
  rexCommandEnv,
8638
8643
  resolveRexLocalPlacement,
8644
+ resolveLocalLaunchCwd,
8639
8645
  extractChildWrittenOutput,
8640
8646
  normalizeSingleOutputOverride,
8641
8647
  resolveSingleOutputPath,
@@ -7,37 +7,37 @@ import {
7
7
  safeTranscriptEvent,
8
8
  steerAsyncRun,
9
9
  steerWorkflowForegroundTarget
10
- } from "./chunk-6EUQPQY7.js";
10
+ } from "./chunk-443LPCRI.js";
11
11
  import {
12
12
  FLEET_STATUS_WIDGET_KEY,
13
13
  runningTone,
14
14
  stepTaskSummary
15
- } from "./chunk-YZPVALSQ.js";
15
+ } from "./chunk-WW6GQBBS.js";
16
16
  import {
17
17
  foregroundChildStateLabel,
18
18
  formatAsyncRunTranscript,
19
19
  stopAsyncRun
20
- } from "./chunk-RHYVKQQL.js";
20
+ } from "./chunk-7W2IQFP4.js";
21
21
  import {
22
22
  contextModeBadge,
23
23
  contextModeLabel,
24
24
  decodeUtf8Tail,
25
25
  listAsyncRuns
26
- } from "./chunk-SVIXQDIV.js";
26
+ } from "./chunk-6JD4XCA4.js";
27
27
  import {
28
28
  reportSessionWarning
29
29
  } from "./chunk-HXRB42AF.js";
30
- import "./chunk-3DT5X2QC.js";
31
- import "./chunk-W6HIYD2Z.js";
30
+ import "./chunk-SLLZJ5EC.js";
31
+ import "./chunk-A3INCQ6Z.js";
32
32
  import "./chunk-NIXWDZZV.js";
33
- import "./chunk-47ZN7NKR.js";
33
+ import "./chunk-NONHDYXE.js";
34
34
  import "./chunk-7F6RKT6W.js";
35
- import "./chunk-CTPAE36Y.js";
35
+ import "./chunk-YARY7JWU.js";
36
36
  import "./chunk-7J4ZXMY7.js";
37
37
  import {
38
38
  getArtifactPaths,
39
39
  getArtifactsDir
40
- } from "./chunk-YDZ7BZD5.js";
40
+ } from "./chunk-S77ZKDLS.js";
41
41
  import {
42
42
  snapshotExternalRuns
43
43
  } from "./chunk-UKG4V45O.js";
@@ -49,7 +49,7 @@ import {
49
49
  formatTokens,
50
50
  readStatus,
51
51
  shortenPath
52
- } from "./chunk-4MVDMA5C.js";
52
+ } from "./chunk-GHJ6BH5U.js";
53
53
  import {
54
54
  DIRS
55
55
  } from "./chunk-JEZOSEWG.js";
@@ -940,6 +940,10 @@ var SubagentFleetComponent = class {
940
940
  actionBusy = false;
941
941
  transcriptCache;
942
942
  disposed = false;
943
+ // Undefined until a TUI first focuses the overlay, so a fleet rendered outside one still draws.
944
+ hasFocus;
945
+ // The component focused when the fleet opened (the overlay's preFocus).
946
+ openedOver;
943
947
  refreshTimer;
944
948
  refreshMs;
945
949
  tui;
@@ -951,6 +955,7 @@ var SubagentFleetComponent = class {
951
955
  keybindings;
952
956
  constructor(tui, theme, state, done, options = {}) {
953
957
  this.tui = tui;
958
+ this.openedOver = tui.getFocusedComponent?.();
954
959
  this.viewport = new FleetViewport(() => this.tui.requestRender());
955
960
  this.theme = theme;
956
961
  this.markdownTheme = options.markdownTheme ?? getMarkdownTheme();
@@ -1120,6 +1125,14 @@ var SubagentFleetComponent = class {
1120
1125
  scrollDetail(delta) {
1121
1126
  this.viewport.scroll.scrollBy(delta);
1122
1127
  }
1128
+ get focused() {
1129
+ return this.hasFocus === true;
1130
+ }
1131
+ set focused(value) {
1132
+ if (value === this.hasFocus) return;
1133
+ this.hasFocus = value;
1134
+ this.tui.requestRender();
1135
+ }
1123
1136
  handleMouse(event) {
1124
1137
  if (this.steerDraft !== void 0 || this.redoGuidanceDraft !== void 0 || this.stopConfirming || this.actionBusy) {
1125
1138
  return { handled: true, render: false };
@@ -1417,6 +1430,10 @@ var SubagentFleetComponent = class {
1417
1430
  return { header: [], body: this.withActionLines(lines) };
1418
1431
  }
1419
1432
  render(width) {
1433
+ if (this.hasFocus === false && this.tui.getFocusedComponent?.() !== this.openedOver) {
1434
+ this.renderedLayout = void 0;
1435
+ return [];
1436
+ }
1420
1437
  const layout = fleetLayout(width, this.tui.terminal?.rows ?? 32, this.selected, this.snapshot.items);
1421
1438
  this.renderedLayout = layout;
1422
1439
  if (!layout) return [truncateToWidth2("Subagent fleet needs at least 36 columns. Esc closes.", width)];
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  snapshotRequiredChildExtensions
3
- } from "./chunk-CTPAE36Y.js";
3
+ } from "./chunk-YARY7JWU.js";
4
4
  import {
5
5
  THINKING_LEVELS,
6
6
  findConfiguredProjectRoot,
7
7
  getAgentDir,
8
8
  getConfigDirName,
9
9
  getProjectConfigDir
10
- } from "./chunk-4MVDMA5C.js";
10
+ } from "./chunk-GHJ6BH5U.js";
11
11
  import {
12
12
  TEMP_ROOT_DIR
13
13
  } from "./chunk-JEZOSEWG.js";
@@ -563,8 +563,8 @@ function formatUnresolvedBuiltinMcpSelectors(agentName, selectors) {
563
563
  const subject = agentName ? `Agent '${agentName}'` : "Subagent";
564
564
  return `${subject} selects MCP tools that Pi's built-in MCP does not offer: ${selectors.map((selector) => `mcp:${selector}`).join(", ")}. The server may be missing, disconnected, still connecting, or its tools hidden; check /mcp.`;
565
565
  }
566
- function extensionOnlyMcpServers(selections, host, cwd, projectTrusted) {
567
- const registered = new Set(host.getMcpServers?.().map(({ name }) => name));
566
+ function extensionOnlyMcpServers(selections, host, cwd, projectTrusted, loadedByChild) {
567
+ const registered = new Set(host.getMcpServers?.().filter(({ extensionPath }) => !loadedByChild(extensionPath)).map(({ name }) => name));
568
568
  const servers = [...new Set(selections.map(({ selector }) => selector.split("/")[0]))].filter((server) => registered.has(server));
569
569
  if (servers.length === 0) return [];
570
570
  const files = [path2.join(getAgentDir(), "mcp.json"), ...projectTrusted ? [path2.join(cwd, ".pi", "mcp.json")] : []];
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-7J4ZXMY7.js";
4
4
  import {
5
5
  getProjectSubagentsDir
6
- } from "./chunk-YDZ7BZD5.js";
6
+ } from "./chunk-S77ZKDLS.js";
7
7
  import {
8
8
  getPiSpawnCommand,
9
9
  writeAtomicJson
10
- } from "./chunk-4MVDMA5C.js";
10
+ } from "./chunk-GHJ6BH5U.js";
11
11
 
12
12
  // src/inspectors/herdr/project-panes.ts
13
13
  import * as fs from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-KXW62VBU.js";
3
+ } from "./chunk-KOLLMZ2X.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -8,7 +8,7 @@ import {
8
8
  validateCodeOwnedProfileRunner,
9
9
  validatePermissionRules,
10
10
  validateToolBudgetConfig
11
- } from "./chunk-4MVDMA5C.js";
11
+ } from "./chunk-GHJ6BH5U.js";
12
12
 
13
13
  // src/agents/runtime-agent-registry.ts
14
14
  var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";