pi-subagents 0.88.0 → 0.88.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/bundle/child-tool-plan.js +2 -2
  3. package/bundle/{chunk-SVIXQDIV.js → chunk-4ZQBZDF3.js} +2 -2
  4. package/bundle/{chunk-YZPVALSQ.js → chunk-5EMPFFO4.js} +3 -3
  5. package/bundle/{chunk-CKLZ5FGU.js → chunk-6CG2VAG4.js} +1 -1
  6. package/bundle/{chunk-6EUQPQY7.js → chunk-7OX6O7DQ.js} +3 -3
  7. package/bundle/{chunk-3DT5X2QC.js → chunk-CPSUJHZE.js} +11 -8
  8. package/bundle/{chunk-3MFYKBKI.js → chunk-D32H53HM.js} +3 -3
  9. package/bundle/{chunk-PJSOS2Q4.js → chunk-DSHQWGHO.js} +1 -1
  10. package/bundle/{chunk-4PM6RDE5.js → chunk-FLNDHNPE.js} +46 -28
  11. package/bundle/{chunk-RHYVKQQL.js → chunk-LV3CPYXJ.js} +2 -2
  12. package/bundle/{chunk-47GJDBIK.js → chunk-N6TAAIB3.js} +2 -2
  13. package/bundle/{chunk-4UGWHREQ.js → chunk-PCZEQQAQ.js} +75 -40
  14. package/bundle/{chunk-IZEKQEY4.js → chunk-PYKBTBY6.js} +23 -6
  15. package/bundle/{chunk-6PR44R7E.js → chunk-RMZAAXIR.js} +1 -1
  16. package/bundle/{chunk-UVDLJXL6.js → chunk-VTUUOLM4.js} +3 -3
  17. package/bundle/{chunk-CTPAE36Y.js → chunk-YARY7JWU.js} +22 -0
  18. package/bundle/{chunk-MTPICU4A.js → chunk-YQSTGPEU.js} +7 -7
  19. package/bundle/{chunk-XAOHLFJO.js → chunk-ZJ2BT5TI.js} +21 -16
  20. package/bundle/index.js +1 -1
  21. package/bundle/preflight.js +4 -4
  22. package/bundle/required-child-extensions.js +1 -1
  23. package/docs/agents.md +4 -2
  24. package/docs/workflows.md +3 -1
  25. package/package.json +1 -1
  26. package/src/extension/index.d.ts +1 -1
  27. package/src/extension/index.js +43 -20
  28. package/src/extension/subagent-launch-tool.d.ts +6 -2
  29. package/src/extension/subagent-launch-tool.js +13 -9
  30. package/src/runs/background/stale-run-reconciler.js +17 -8
  31. package/src/runs/foreground/subagent-executor.js +11 -6
  32. package/src/runs/shared/child-launch.js +6 -3
  33. package/src/runs/shared/child-session.d.ts +1 -1
  34. package/src/runs/shared/child-session.js +3 -27
  35. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +5 -3
  36. package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -4
  37. package/src/shared/compaction-interruption.d.ts +9 -0
  38. package/src/shared/compaction-interruption.js +47 -0
  39. package/src/shared/parent-wake.d.ts +3 -2
  40. package/src/shared/parent-wake.js +14 -3
  41. package/src/shared/required-child-extensions.d.ts +2 -0
  42. package/src/shared/required-child-extensions.js +27 -0
  43. package/src/tui/fleet.d.ts +7 -2
  44. package/src/tui/fleet.js +22 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.88.1] - 2026-11-12
6
+
7
+ ### Highlights
8
+
9
+ - A permission prompt or other dialog that opens while the fleet inspector is up is no longer hidden behind it.
10
+ - 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.
11
+ - `status` and `stop` no longer report a cleanly finishing background subagent as having ended without proof.
12
+ - A manual `/compact` no longer wakes an idle parent while background subagents are running.
13
+
14
+ ### Fixed
15
+
16
+ - 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.
17
+ - 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.
18
+ - 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.
19
+ - `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.
20
+ - 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.
21
+ - 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)
22
+
5
23
  ## [0.88.0] - 2026-11-10
6
24
 
7
25
  ### Highlights
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  resolvePiLaunchToolPlan
3
- } from "./chunk-3MFYKBKI.js";
4
- import "./chunk-CTPAE36Y.js";
3
+ } from "./chunk-D32H53HM.js";
4
+ import "./chunk-YARY7JWU.js";
5
5
  import "./chunk-4MVDMA5C.js";
6
6
  import "./chunk-JEZOSEWG.js";
7
7
  import "./chunk-YFCK7H2S.js";
@@ -46,7 +46,7 @@ import {
46
46
  validateModelResponseAliases,
47
47
  withWorkflowChildRunModel,
48
48
  withWorktreeTransaction
49
- } from "./chunk-3DT5X2QC.js";
49
+ } from "./chunk-CPSUJHZE.js";
50
50
  import {
51
51
  validateIntercomBridgeConfig
52
52
  } from "./chunk-47ZN7NKR.js";
@@ -55,7 +55,7 @@ import {
55
55
  } from "./chunk-7F6RKT6W.js";
56
56
  import {
57
57
  snapshotRequiredChildExtensions
58
- } from "./chunk-CTPAE36Y.js";
58
+ } from "./chunk-YARY7JWU.js";
59
59
  import {
60
60
  missingForkCopyNote
61
61
  } from "./chunk-YDZ7BZD5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildWorkflowChatProgressRows
3
- } from "./chunk-RHYVKQQL.js";
3
+ } from "./chunk-LV3CPYXJ.js";
4
4
  import {
5
5
  aggregateStepStatus,
6
6
  contextModeBadge,
@@ -22,7 +22,7 @@ import {
22
22
  projectAsyncWorkflowRows,
23
23
  projectWorkflowChecklist,
24
24
  workflowGraphStageNodes
25
- } from "./chunk-SVIXQDIV.js";
25
+ } from "./chunk-4ZQBZDF3.js";
26
26
  import {
27
27
  isStaleExtensionContextError,
28
28
  isUnboundExtensionRuntimeError,
@@ -34,7 +34,7 @@ import {
34
34
  formatWorkflowJsonPreview,
35
35
  hostStepReportName,
36
36
  hostStepVerdictLabel
37
- } from "./chunk-3DT5X2QC.js";
37
+ } from "./chunk-CPSUJHZE.js";
38
38
  import {
39
39
  snapshotExternalRuns
40
40
  } from "./chunk-UKG4V45O.js";
@@ -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.88.1",
5
5
  private: true,
6
6
  description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
7
7
  author: "Nico Bailon",
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isTrustedRecordedSessionFile,
3
3
  resolveSubagentRunId
4
- } from "./chunk-RHYVKQQL.js";
4
+ } from "./chunk-LV3CPYXJ.js";
5
5
  import {
6
6
  agentStreamOptions,
7
7
  opencodeSessionHeaders,
8
8
  resolveAsyncResumeTarget
9
- } from "./chunk-SVIXQDIV.js";
9
+ } from "./chunk-4ZQBZDF3.js";
10
10
  import {
11
11
  ownsRun
12
12
  } from "./chunk-HXRB42AF.js";
@@ -18,7 +18,7 @@ import {
18
18
  reconcileAsyncRun,
19
19
  resolveAuthorityDecision,
20
20
  resolveMissionStoreLocation
21
- } from "./chunk-3DT5X2QC.js";
21
+ } from "./chunk-CPSUJHZE.js";
22
22
  import {
23
23
  deliverInterruptRequest,
24
24
  queueRevivalBrief,
@@ -5978,8 +5978,17 @@ function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
5978
5978
  const resultsDir = options.resultsDir ?? DIRS.results;
5979
5979
  const resultPath = resultFilePath(resultsDir, runId);
5980
5980
  const existingResultPath = effectiveStatus.sessionId ? resultPayloadPathForSessionRun(resultsDir, effectiveStatus.sessionId, runId) ?? (regularFileExists(resultPath) ? resultPath : void 0) : regularFileExists(resultPath) ? resultPath : void 0;
5981
+ const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1e3;
5982
+ const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
5983
+ const observedScope = options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope();
5984
+ const runnerLiveness = (pid) => checkRecordedPidLiveness({ pid, pidNamespaceScope: effectiveStatus.pidNamespaceScope, bootId: effectiveStatus.bootId }, {
5985
+ kill: options.kill,
5986
+ observedScope,
5987
+ observedBootId: options.bootId ? options.bootId() : currentBootId()
5988
+ });
5981
5989
  if (existingResultPath) {
5982
- const terminalStatus = effectiveStatus.state === "running" || effectiveStatus.state === "queued" ? terminalStatusFromResult(effectiveStatus, existingResultPath, now) : void 0;
5990
+ const runnerStillFinishing = effectiveStatus.state === "running" && effectiveStatus.mode !== "workflow" && typeof effectiveStatus.pid === "number" && effectiveStatus.pidNamespaceScope === observedScope && now - lastUpdate <= staleAfterMs && runnerLiveness(effectiveStatus.pid) === "alive";
5991
+ const terminalStatus = (effectiveStatus.state === "running" || effectiveStatus.state === "queued") && !runnerStillFinishing ? terminalStatusFromResult(effectiveStatus, existingResultPath, now) : void 0;
5983
5992
  if (terminalStatus) {
5984
5993
  const currentStatus = readStatus(asyncDir);
5985
5994
  const currentRootError = failureDiagnostic(currentStatus?.error);
@@ -6012,14 +6021,8 @@ function reconcileAsyncRun(asyncDir, options = {}, observeStatus) {
6012
6021
  return { status: null, repaired: false, resultPath };
6013
6022
  }
6014
6023
  }
6015
- const liveness = checkRecordedPidLiveness({ pid: effectiveStatus.pid, pidNamespaceScope: effectiveStatus.pidNamespaceScope, bootId: effectiveStatus.bootId }, {
6016
- kill: options.kill,
6017
- observedScope: options.pidNamespaceScope ? options.pidNamespaceScope() : currentPidNamespaceScope(),
6018
- observedBootId: options.bootId ? options.bootId() : currentBootId()
6019
- });
6024
+ const liveness = runnerLiveness(effectiveStatus.pid);
6020
6025
  if (liveness !== "dead") {
6021
- const staleAfterMs = options.staleAlivePidMs ?? 24 * 60 * 60 * 1e3;
6022
- const lastUpdate = effectiveStatus.lastUpdate ?? effectiveStatus.startedAt;
6023
6026
  if (now - lastUpdate <= staleAfterMs) return { status: status ?? null, repaired: false, resultPath };
6024
6027
  const probe = liveness === "alive" ? "is still live" : "cannot be probed from this process";
6025
6028
  const message = `Async runner PID ${effectiveStatus.pid} ${probe}; status has not updated for ${now - lastUpdate}ms, so stale-run reconciliation marked the run failed because PID ownership is unverified.`;
@@ -1,6 +1,6 @@
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,
@@ -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")] : []];
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-GDR2ILWY.js";
8
8
  import {
9
9
  package_default
10
- } from "./chunk-CKLZ5FGU.js";
10
+ } from "./chunk-6CG2VAG4.js";
11
11
  import {
12
12
  ensureSupervisorChannelDir
13
13
  } from "./chunk-CYKNHFXB.js";
@@ -10,10 +10,10 @@ import {
10
10
  setInlineWorkflowCoverage,
11
11
  setMainThinkingLevelSource,
12
12
  widgetRenderKey
13
- } from "./chunk-YZPVALSQ.js";
13
+ } from "./chunk-5EMPFFO4.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-CKLZ5FGU.js";
16
+ } from "./chunk-6CG2VAG4.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-4UGWHREQ.js";
69
+ } from "./chunk-PCZEQQAQ.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-47GJDBIK.js";
89
+ } from "./chunk-N6TAAIB3.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-LV3CPYXJ.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-4ZQBZDF3.js";
109
113
  import {
110
114
  CONTACT_SUPERVISOR_TOOL_NAME,
111
115
  NATIVE_SUPERVISOR_TOOL_NAME,
@@ -141,7 +145,7 @@ import {
141
145
  resolveDisabledFeatureSurface,
142
146
  resolveMaxActiveAsyncRunsPerSession,
143
147
  resolveScheduledStoreRoot
144
- } from "./chunk-6PR44R7E.js";
148
+ } from "./chunk-RMZAAXIR.js";
145
149
  import {
146
150
  ACTIVE_RUN_INDEX_DIR,
147
151
  MissionNotFoundError,
@@ -192,7 +196,7 @@ import {
192
196
  withWorkflowChildRunModel,
193
197
  writeAsyncResultFile,
194
198
  writeResultIndexForData
195
- } from "./chunk-3DT5X2QC.js";
199
+ } from "./chunk-CPSUJHZE.js";
196
200
  import "./chunk-W6HIYD2Z.js";
197
201
  import {
198
202
  shouldUseNativeFsWatch
@@ -201,8 +205,8 @@ import {
201
205
  validateIntercomBridgeConfig
202
206
  } from "./chunk-47ZN7NKR.js";
203
207
  import "./chunk-7F6RKT6W.js";
204
- import "./chunk-3MFYKBKI.js";
205
- import "./chunk-CTPAE36Y.js";
208
+ import "./chunk-D32H53HM.js";
209
+ import "./chunk-YARY7JWU.js";
206
210
  import {
207
211
  listHerdrProjectPaneRoots,
208
212
  restoreHerdrProjectPaneSnapshots
@@ -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-PYKBTBY6.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-PYKBTBY6.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-XAOHLFJO.js");
8996
+ const loadExecutorModule = () => executorModulePromise ??= import("./chunk-ZJ2BT5TI.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-PYKBTBY6.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-4ZQBZDF3.js";
16
16
  import {
17
17
  ownsRun
18
18
  } from "./chunk-HXRB42AF.js";
@@ -34,7 +34,7 @@ import {
34
34
  updateActiveRunIndex,
35
35
  validateModelResponseAliases,
36
36
  writeAsyncResultFile
37
- } from "./chunk-3DT5X2QC.js";
37
+ } from "./chunk-CPSUJHZE.js";
38
38
  import {
39
39
  deliverStopRequest,
40
40
  stopInboxClosedPath
@@ -8,7 +8,7 @@ import {
8
8
  projectTimeoutRecovery,
9
9
  readAsyncRecoveryDescriptor,
10
10
  utf8Tail
11
- } from "./chunk-SVIXQDIV.js";
11
+ } from "./chunk-4ZQBZDF3.js";
12
12
  import {
13
13
  MAX_ARGS_BYTES,
14
14
  MAX_ARGS_DEPTH,
@@ -21,7 +21,7 @@ import {
21
21
  resultFilePath,
22
22
  resultPayloadMatchesSessionRun,
23
23
  resultPayloadPathForSessionRun
24
- } from "./chunk-3DT5X2QC.js";
24
+ } from "./chunk-CPSUJHZE.js";
25
25
  import {
26
26
  PROJECT_SUBAGENTS_RELATIVE_DIR
27
27
  } from "./chunk-YDZ7BZD5.js";
@@ -11,10 +11,10 @@ import {
11
11
  startWatchdogDiffBaselineCapture,
12
12
  writeUserWatchdogEnabled,
13
13
  writeWatchdogModelSettings
14
- } from "./chunk-47GJDBIK.js";
14
+ } from "./chunk-N6TAAIB3.js";
15
15
  import {
16
16
  resolveGitRepositoryIdentity
17
- } from "./chunk-RHYVKQQL.js";
17
+ } from "./chunk-LV3CPYXJ.js";
18
18
  import {
19
19
  listAsyncRuns,
20
20
  parallelHandoffPath,
@@ -22,7 +22,7 @@ import {
22
22
  readAsyncRecoveryDescriptor,
23
23
  readWorkflowLaunchRecord,
24
24
  resolveRetainedWorktreeCwd
25
- } from "./chunk-SVIXQDIV.js";
25
+ } from "./chunk-4ZQBZDF3.js";
26
26
  import {
27
27
  ownsRun
28
28
  } from "./chunk-HXRB42AF.js";
@@ -54,14 +54,17 @@ import {
54
54
  resolveMissionStoreLocation,
55
55
  validateMissionId,
56
56
  workflowRunParamsFingerprint
57
- } from "./chunk-3DT5X2QC.js";
57
+ } from "./chunk-CPSUJHZE.js";
58
58
  import {
59
59
  requestAsyncCommand,
60
60
  watchAsyncControlInbox
61
61
  } from "./chunk-W6HIYD2Z.js";
62
62
  import {
63
63
  supervisorChannelDir
64
- } from "./chunk-3MFYKBKI.js";
64
+ } from "./chunk-D32H53HM.js";
65
+ import {
66
+ createRequiredChildExtensionIdentity
67
+ } from "./chunk-YARY7JWU.js";
65
68
  import {
66
69
  createHerdrClient,
67
70
  detectHerdr
@@ -167,6 +170,43 @@ import {
167
170
  resolveCurrentSubagentCapabilityCeiling
168
171
  } from "./chunk-QXASAHIA.js";
169
172
 
173
+ // src/shared/compaction-interruption.ts
174
+ var stateSymbol = /* @__PURE__ */ Symbol.for("pi-subagents.compaction-interruption.v1");
175
+ var wrappedSymbol = /* @__PURE__ */ Symbol.for("pi-subagents.compaction-interruption.v1.wrapped");
176
+ var globalStore = globalThis;
177
+ var compactions = globalStore[stateSymbol] ??= /* @__PURE__ */ new WeakMap();
178
+ function installCompactionInterruptionCapture(sessionClass) {
179
+ const prototype = sessionClass.prototype;
180
+ const original = prototype.compact;
181
+ if (original[wrappedSymbol]) return;
182
+ const compact = async function(...args) {
183
+ const manager = this.sessionManager;
184
+ const compaction = compactions.get(manager) ?? { calls: 0, interrupted: false, abortPending: false };
185
+ compactions.set(manager, compaction);
186
+ compaction.calls += 1;
187
+ if (this.isStreaming) compaction.interrupted = compaction.abortPending = true;
188
+ try {
189
+ return await original.apply(this, args);
190
+ } finally {
191
+ if (--compaction.calls === 0) compactions.delete(manager);
192
+ }
193
+ };
194
+ compact[wrappedSymbol] = true;
195
+ prototype.compact = compact;
196
+ }
197
+ function compactionInProgress(sessionManager) {
198
+ return compactions.has(sessionManager);
199
+ }
200
+ function compactionInterruptedRun(sessionManager) {
201
+ return compactions.get(sessionManager)?.interrupted === true;
202
+ }
203
+ function takeCompactionAbort(sessionManager) {
204
+ const compaction = compactions.get(sessionManager);
205
+ if (!compaction?.abortPending) return false;
206
+ compaction.abortPending = false;
207
+ return true;
208
+ }
209
+
170
210
  // src/inspectors/herdr/actions.ts
171
211
  import * as fs from "node:fs";
172
212
  import * as path from "node:path";
@@ -5054,6 +5094,7 @@ function createParentWake(pi, now = Date.now) {
5054
5094
  let ctx;
5055
5095
  let session;
5056
5096
  let held = false;
5097
+ let deferred = false;
5057
5098
  const reservation = () => {
5058
5099
  if (!session) return { sessionId: "" };
5059
5100
  const current = reservations.get(session.manager);
@@ -5076,6 +5117,11 @@ function createParentWake(pi, now = Date.now) {
5076
5117
  pi.sendMessage(message, { triggerTurn: false });
5077
5118
  return true;
5078
5119
  }
5120
+ if (session && compactionInProgress(session.manager)) {
5121
+ deferred = true;
5122
+ pi.sendMessage(message, { triggerTurn: false });
5123
+ return true;
5124
+ }
5079
5125
  if (ctx.isIdle()) reservation().sentAt = now();
5080
5126
  pi.sendMessage(message, options);
5081
5127
  return false;
@@ -5084,19 +5130,21 @@ function createParentWake(pi, now = Date.now) {
5084
5130
  bindSession(context) {
5085
5131
  ctx = context;
5086
5132
  session = { manager: context.sessionManager, id: context.sessionManager.getSessionId() };
5087
- held = false;
5133
+ held = deferred = false;
5088
5134
  },
5089
5135
  agentStarted() {
5090
5136
  reservation().sentAt = void 0;
5091
- held = false;
5137
+ held = deferred = false;
5092
5138
  },
5093
5139
  userAborted: () => {
5094
5140
  held = true;
5095
5141
  },
5096
- releaseHold: () => {
5097
- held = false;
5098
- },
5099
5142
  isHeld: () => held,
5143
+ takeDeferredWake() {
5144
+ const wasDeferred = deferred;
5145
+ deferred = false;
5146
+ return wasDeferred;
5147
+ },
5100
5148
  sessionShutdown(reason) {
5101
5149
  if (reason !== "reload") reservation().sentAt = void 0;
5102
5150
  }
@@ -7335,27 +7383,6 @@ function inheritParentProviders(modelRuntime, parentProviders, claimedProviderId
7335
7383
  var CHILD_PROMPT_RUNTIME_EXTENSION_PATH = "<inline:pi-subagents:prompt-runtime>";
7336
7384
  var CHILD_PROMPT_BOUNDARY_EXTENSION_PATH = "<inline:pi-subagents:prompt-boundary>";
7337
7385
  var PI_UNICODE_SPACES = new RegExp("[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]", "g");
7338
- function childExtensionFileIdentity(extensionPath) {
7339
- if (!path12.isAbsolute(extensionPath)) return void 0;
7340
- try {
7341
- const stat = fs13.statSync(extensionPath, { bigint: true });
7342
- return stat.isFile() ? `${stat.dev}:${stat.ino}` : void 0;
7343
- } catch {
7344
- return void 0;
7345
- }
7346
- }
7347
- function createRequiredChildExtensionIdentity(requiredPaths) {
7348
- const aliases = new Map([...requiredPaths].map((extensionPath) => [extensionPath, childExtensionFileIdentity(extensionPath) ?? extensionPath]));
7349
- const identities = new Set(aliases.values());
7350
- return (extensionPath) => {
7351
- const known = aliases.get(extensionPath);
7352
- if (known !== void 0) return known;
7353
- const identity = childExtensionFileIdentity(extensionPath);
7354
- if (identity === void 0 || !identities.has(identity)) return void 0;
7355
- aliases.set(extensionPath, identity);
7356
- return identity;
7357
- };
7358
- }
7359
7386
  function orderChildPromptHooks(result5) {
7360
7387
  const runtime = result5.extensions.filter(({ path: path17 }) => path17 === CHILD_PROMPT_RUNTIME_EXTENSION_PATH);
7361
7388
  const boundary = result5.extensions.filter(({ path: path17 }) => path17 === CHILD_PROMPT_BOUNDARY_EXTENSION_PATH);
@@ -7710,7 +7737,7 @@ function createDefaultChildSessionFactory(options = {}) {
7710
7737
  await session2.bindExtensions({
7711
7738
  mode: "print",
7712
7739
  onError: (error2) => {
7713
- if (binding && isRequiredSource(error2.extensionPath)) requiredStartupErrors.push(`${error2.extensionPath} (${error2.event}): ${error2.error}`);
7740
+ if (binding && error2.event !== "register_mcp_server" && isRequiredSource(error2.extensionPath)) requiredStartupErrors.push(`${error2.extensionPath} (${error2.event}): ${error2.error}`);
7714
7741
  launch.onExtensionError?.({ extensionPath: error2.extensionPath, event: error2.event, error: error2.error });
7715
7742
  }
7716
7743
  });
@@ -7854,7 +7881,7 @@ function childSessionFactory() {
7854
7881
  }
7855
7882
  function createLazyPlacementFactory(local) {
7856
7883
  let placed;
7857
- const factory = async () => placed ??= (await import("./chunk-PJSOS2Q4.js")).createPlacementAwareChildSessionFactory(local);
7884
+ const factory = async () => placed ??= (await import("./chunk-DSHQWGHO.js")).createPlacementAwareChildSessionFactory(local);
7858
7885
  return {
7859
7886
  async create(launch) {
7860
7887
  return launch.machine ? (await factory()).create(launch) : local.create(launch);
@@ -8249,23 +8276,27 @@ function registerSubagentLaunchTool(pi) {
8249
8276
  pi.registerTool({
8250
8277
  name: SUBAGENT_LAUNCH_TOOL,
8251
8278
  label: "Subagent launch",
8252
- description: "A workflow is about to start this subagent. Blocking this call stops that child from starting.",
8279
+ description: "A workflow is about to start this subagent. Blocking this call stops that child from starting; changing its task changes what the child is told.",
8253
8280
  parameters,
8254
8281
  exposure: "deferred",
8255
- async execute() {
8256
- return { content: [{ type: "text", text: "Records approval for a workflow child launch; it starts nothing itself." }], details: {} };
8282
+ // Pi hands execute the input after every tool_call handler ran, so a handler's change to task arrives here.
8283
+ async execute(_toolCallId, params) {
8284
+ return { content: [{ type: "text", text: "Records approval for a workflow child launch; it starts nothing itself." }], details: { task: params.task } };
8257
8285
  }
8258
8286
  });
8259
8287
  }
8260
8288
  async function approveWorkflowChildLaunch(ctx, describe, signal) {
8261
- if (!("executeTool" in ctx)) return void 0;
8289
+ if (!("executeTool" in ctx)) return {};
8262
8290
  const toolCtx = ctx;
8263
- if (!toolCtx.tools.some((tool) => tool.name === SUBAGENT_LAUNCH_TOOL)) return void 0;
8291
+ if (!toolCtx.tools.some((tool) => tool.name === SUBAGENT_LAUNCH_TOOL)) return {};
8264
8292
  const args = describe();
8265
8293
  const outcome = await toolCtx.executeTool(SUBAGENT_LAUNCH_TOOL, args, { signal });
8266
- if (!outcome.isError) return void 0;
8294
+ if (!outcome.isError) {
8295
+ const task = outcome.result.details?.task;
8296
+ return { task: typeof task === "string" ? task : void 0 };
8297
+ }
8267
8298
  const reason = outcome.result.content.flatMap((block) => block.type === "text" ? [block.text] : []).join("\n").trim();
8268
- return `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}`;
8299
+ return { refusal: `Workflow child '${args.key}' was not started: the ${SUBAGENT_LAUNCH_TOOL} call was refused${reason ? `: ${reason}` : "."}` };
8269
8300
  }
8270
8301
 
8271
8302
  // src/runs/shared/external-job-bridge.ts
@@ -8692,6 +8723,10 @@ function sameProviderDiagnostics(left, right) {
8692
8723
  }
8693
8724
 
8694
8725
  export {
8726
+ installCompactionInterruptionCapture,
8727
+ compactionInProgress,
8728
+ compactionInterruptedRun,
8729
+ takeCompactionAbort,
8695
8730
  getInspectorPlugins,
8696
8731
  registerInspectorEventListener,
8697
8732
  effectiveToolTimeoutMs,