pi-subagents 0.85.0 → 0.87.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 (97) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-O7CPL6H4.js → chunk-2D2DQGC2.js} +9 -9
  5. package/bundle/{chunk-KZ34KQQH.js → chunk-2NY5PCKQ.js} +11 -5
  6. package/bundle/{chunk-PVIVCDG2.js → chunk-3CVOAS77.js} +2 -2
  7. package/bundle/{chunk-N7B2KD74.js → chunk-6O7YH2QV.js} +1 -1
  8. package/bundle/{chunk-IQIWF2VX.js → chunk-AIL46SZU.js} +8 -6
  9. package/bundle/{chunk-H2NLFTC5.js → chunk-BFF6YDK6.js} +1 -1
  10. package/bundle/{chunk-UX4SCV5N.js → chunk-C3KWLXDH.js} +159 -98
  11. package/bundle/{chunk-GCSLVFCX.js → chunk-C5QWQSSM.js} +1 -1
  12. package/bundle/{chunk-3UZ5FVVJ.js → chunk-DGTZKYIE.js} +39 -34
  13. package/bundle/{chunk-KDMFBYFM.js → chunk-ESWW6XSX.js} +1 -1
  14. package/bundle/{chunk-WOVMHDES.js → chunk-EYGBK6CE.js} +194 -94
  15. package/bundle/{chunk-CS4O36CZ.js → chunk-HDICKROY.js} +5 -5
  16. package/bundle/{chunk-DV2NCNPR.js → chunk-JLDQ6YUR.js} +12 -12
  17. package/bundle/{chunk-RQAUNAWG.js → chunk-LFKMM3UH.js} +2 -2
  18. package/bundle/{chunk-L2ENOFVZ.js → chunk-LZKVUWIY.js} +66 -26
  19. package/bundle/{chunk-RV5OGHLO.js → chunk-M2VBGET6.js} +2 -2
  20. package/bundle/{chunk-HFTBF7SG.js → chunk-OOE3R7IQ.js} +1 -1
  21. package/bundle/{chunk-JNXT3MPI.js → chunk-OTLDAYEQ.js} +5 -5
  22. package/bundle/{chunk-JWYG26RE.js → chunk-OZCPYJEY.js} +80 -37
  23. package/bundle/{chunk-LGMILZNE.js → chunk-PGU4TZV3.js} +79 -32
  24. package/bundle/{chunk-KEY3UQMQ.js → chunk-SIAQXPJ4.js} +6 -8
  25. package/bundle/{chunk-QO75KJBT.js → chunk-USRX7QXD.js} +2 -2
  26. package/bundle/{chunk-7MAE3DJV.js → chunk-VFUFOZBU.js} +1 -1
  27. package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
  28. package/bundle/{chunk-T5V5BRCL.js → chunk-W52LJANO.js} +1 -1
  29. package/bundle/{chunk-PHZP3KHB.js → chunk-XSDYTXHF.js} +18 -11
  30. package/bundle/{chunk-LTPH2DXH.js → chunk-XV7RTWTS.js} +3 -3
  31. package/bundle/{chunk-JO67XSKD.js → chunk-YEXKJJVS.js} +12 -7
  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 +12 -10
  36. package/bundle/project-panes.js +3 -3
  37. package/bundle/workflow-resources.js +1 -1
  38. package/docs/agents.md +9 -3
  39. package/docs/configuration.md +14 -6
  40. package/docs/extension-api.md +2 -0
  41. package/docs/models.md +6 -2
  42. package/docs/tool-reference.md +3 -0
  43. package/package.json +1 -1
  44. package/skills/pi-subagents/SKILL.md +7 -4
  45. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  46. package/src/agents/agent-management.js +10 -6
  47. package/src/agents/agent-serializer.d.ts +2 -0
  48. package/src/agents/agent-serializer.js +1 -1
  49. package/src/agents/agents.js +37 -12
  50. package/src/api/preflight.d.ts +3 -1
  51. package/src/api/preflight.js +2 -0
  52. package/src/extension/index.js +4 -2
  53. package/src/extension/schemas.d.ts +2 -0
  54. package/src/extension/schemas.js +1 -0
  55. package/src/extension/tool-activation.js +10 -1
  56. package/src/extension/tool-description.d.ts +1 -1
  57. package/src/extension/tool-description.js +8 -8
  58. package/src/runs/background/async-execution.d.ts +2 -1
  59. package/src/runs/background/async-execution.js +4 -2
  60. package/src/runs/background/run-status.js +5 -4
  61. package/src/runs/background/runner-aliases.js +15 -0
  62. package/src/runs/background/subagent-runner.js +6 -6
  63. package/src/runs/background/wait-subscriptions.js +124 -12
  64. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  65. package/src/runs/foreground/async-stop-action.js +9 -1
  66. package/src/runs/foreground/execution.js +1 -0
  67. package/src/runs/foreground/subagent-executor.d.ts +1 -0
  68. package/src/runs/foreground/subagent-executor.js +51 -8
  69. package/src/runs/shared/acceptance.js +69 -26
  70. package/src/runs/shared/child-session.d.ts +5 -4
  71. package/src/runs/shared/child-session.js +43 -33
  72. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  73. package/src/runs/shared/external-cli-contract.js +18 -13
  74. package/src/runs/shared/herdr-placed-run.js +3 -2
  75. package/src/runs/shared/mcp-config-sources.d.ts +2 -1
  76. package/src/runs/shared/mcp-config-sources.js +1 -1
  77. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -1
  78. package/src/runs/shared/mcp-direct-tool-allowlist.js +5 -6
  79. package/src/runs/shared/model-resolution.d.ts +19 -4
  80. package/src/runs/shared/model-resolution.js +50 -51
  81. package/src/runs/shared/structured-output.js +10 -3
  82. package/src/shared/artifacts.js +25 -13
  83. package/src/shared/pruned-fork.js +2 -2
  84. package/src/shared/types.d.ts +71 -48
  85. package/src/tui/render.js +83 -22
  86. package/src/watchdog/model-selection.js +2 -2
  87. package/src/watchdog/review.js +2 -2
  88. package/src/workflows/scripted-workflow.d.ts +2 -0
  89. package/src/workflows/scripted-workflow.js +103 -39
  90. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  91. package/src/workflows/structured-workflow-scripts.js +32 -11
  92. package/src/workflows/workflow-receipt.js +36 -53
  93. package/src/workflows/workflow-resources.js +4 -4
  94. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  95. package/src/workflows/workflow-resume-claim.js +1 -1
  96. package/src/workflows/workflow-resume.d.ts +1 -1
  97. package/src/workflows/workflow-resume.js +3 -1
@@ -10,10 +10,10 @@ import {
10
10
  setInlineWorkflowCoverage,
11
11
  setMainThinkingLevelSource,
12
12
  widgetRenderKey
13
- } from "./chunk-L2ENOFVZ.js";
13
+ } from "./chunk-LZKVUWIY.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-HFTBF7SG.js";
16
+ } from "./chunk-OOE3R7IQ.js";
17
17
  import {
18
18
  EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
19
19
  REVIVAL_ORIGIN_FILE,
@@ -29,7 +29,7 @@ import {
29
29
  createWaitSubscriptionManager,
30
30
  deliverSubagentResultIntercomEvent,
31
31
  deriveChildSessionName,
32
- disposeChildSessions,
32
+ disposeChildSessionsForParent,
33
33
  editableAgentConfig,
34
34
  externalJobBridgeEligibility,
35
35
  flattenSubagentToolOptions,
@@ -62,7 +62,7 @@ import {
62
62
  snapshotProviderDiagnostics,
63
63
  workflowResumeClaimState,
64
64
  workflowResumeRefusal
65
- } from "./chunk-WOVMHDES.js";
65
+ } from "./chunk-EYGBK6CE.js";
66
66
  import {
67
67
  SUBAGENT_CHILD_ENV,
68
68
  SUBAGENT_PARENT_SESSION_ENV,
@@ -82,14 +82,14 @@ import {
82
82
  resolvePiSessionId,
83
83
  resolveWaitToolConfig,
84
84
  setDeclarationPinning
85
- } from "./chunk-IQIWF2VX.js";
85
+ } from "./chunk-AIL46SZU.js";
86
86
  import {
87
87
  deliverAsyncRunStop,
88
88
  ownerConfirmedDead,
89
89
  readSessionMessagesTail,
90
90
  resolveSubagentRunId,
91
91
  restoreForegroundRunHistory
92
- } from "./chunk-KZ34KQQH.js";
92
+ } from "./chunk-2NY5PCKQ.js";
93
93
  import {
94
94
  ASYNC_STATUS_SNAPSHOT_KIND,
95
95
  ASYNC_STATUS_SNAPSHOT_VERSION,
@@ -105,7 +105,7 @@ import {
105
105
  resolveAsyncStatusChild,
106
106
  runLaunchDir,
107
107
  stopStoppableAsyncStatusChildren
108
- } from "./chunk-LTPH2DXH.js";
108
+ } from "./chunk-XV7RTWTS.js";
109
109
  import {
110
110
  CONTACT_SUPERVISOR_TOOL_NAME,
111
111
  NATIVE_SUPERVISOR_TOOL_NAME,
@@ -115,7 +115,7 @@ import {
115
115
  parseSupervisorReplyData,
116
116
  parseSupervisorRequestDetails,
117
117
  topLevelSupervisorTool
118
- } from "./chunk-T5V5BRCL.js";
118
+ } from "./chunk-W52LJANO.js";
119
119
  import {
120
120
  MODEL_ONLY_TOOL,
121
121
  canRenderComponents,
@@ -130,7 +130,7 @@ import {
130
130
  reportSessionWarning,
131
131
  withCachedUiContext
132
132
  } from "./chunk-HXRB42AF.js";
133
- import "./chunk-NF7IEKBH.js";
133
+ import "./chunk-W2BZS6UC.js";
134
134
  import {
135
135
  disabledFeatureUseError,
136
136
  getActiveAsyncCapacitySnapshot,
@@ -140,7 +140,7 @@ import {
140
140
  resolveDisabledFeatureSurface,
141
141
  resolveMaxActiveAsyncRunsPerSession,
142
142
  resolveScheduledStoreRoot
143
- } from "./chunk-RV5OGHLO.js";
143
+ } from "./chunk-M2VBGET6.js";
144
144
  import {
145
145
  ACTIVE_RUN_INDEX_DIR,
146
146
  MissionNotFoundError,
@@ -191,28 +191,28 @@ import {
191
191
  withWorkflowChildRunModel,
192
192
  writeAsyncResultFile,
193
193
  writeResultIndexForData
194
- } from "./chunk-LGMILZNE.js";
195
- import "./chunk-7MAE3DJV.js";
194
+ } from "./chunk-PGU4TZV3.js";
195
+ import "./chunk-VFUFOZBU.js";
196
196
  import {
197
197
  shouldUseNativeFsWatch
198
198
  } from "./chunk-NIXWDZZV.js";
199
199
  import {
200
200
  validateIntercomBridgeConfig
201
- } from "./chunk-KDMFBYFM.js";
201
+ } from "./chunk-ESWW6XSX.js";
202
202
  import "./chunk-7F6RKT6W.js";
203
- import "./chunk-KEY3UQMQ.js";
203
+ import "./chunk-SIAQXPJ4.js";
204
204
  import "./chunk-CTPAE36Y.js";
205
205
  import {
206
206
  listHerdrProjectPaneRoots,
207
207
  restoreHerdrProjectPaneSnapshots
208
- } from "./chunk-PVIVCDG2.js";
208
+ } from "./chunk-3CVOAS77.js";
209
209
  import "./chunk-7J4ZXMY7.js";
210
210
  import {
211
211
  cleanupAllArtifactDirs,
212
212
  cleanupOldArtifacts,
213
213
  getArtifactPaths,
214
214
  getArtifactsDir
215
- } from "./chunk-PHZP3KHB.js";
215
+ } from "./chunk-XSDYTXHF.js";
216
216
  import {
217
217
  listBackgroundWorkProviders
218
218
  } from "./chunk-XA3DY6UG.js";
@@ -220,12 +220,12 @@ import "./chunk-YYREO77V.js";
220
220
  import "./chunk-UKG4V45O.js";
221
221
  import {
222
222
  registerRuntimeAgentEventListener
223
- } from "./chunk-H2NLFTC5.js";
223
+ } from "./chunk-BFF6YDK6.js";
224
224
  import {
225
225
  clearRuntimeAgentsForPi,
226
226
  listRuntimeAgentConfigs,
227
227
  mergeRuntimeAgents
228
- } from "./chunk-GCSLVFCX.js";
228
+ } from "./chunk-C5QWQSSM.js";
229
229
  import {
230
230
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
231
231
  DEFAULT_WAIT_TOOL_NAME,
@@ -268,7 +268,7 @@ import {
268
268
  waitToolName,
269
269
  withSettingsFileLease,
270
270
  writeAtomicJson
271
- } from "./chunk-UX4SCV5N.js";
271
+ } from "./chunk-C3KWLXDH.js";
272
272
  import {
273
273
  DEFAULT_ARTIFACT_CONFIG,
274
274
  DIRS,
@@ -5360,7 +5360,7 @@ function registerSlashCommands(pi, state, options = {}) {
5360
5360
  }
5361
5361
  fleetOpen = true;
5362
5362
  try {
5363
- const { openSubagentFleet } = await import("./chunk-O7CPL6H4.js");
5363
+ const { openSubagentFleet } = await import("./chunk-2D2DQGC2.js");
5364
5364
  await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
5365
5365
  } finally {
5366
5366
  fleetOpen = false;
@@ -7990,7 +7990,12 @@ function applyRecordedSelection(pi, ctx, mode, replyOwed) {
7990
7990
  const available = pi.getAllTools();
7991
7991
  if (!Array.isArray(available) || !Array.isArray(pi.getActiveTools())) return true;
7992
7992
  if (!available.some((tool) => tool.name === LOADER_NAME)) return true;
7993
- const messages = ctx.sessionManager.buildSessionContext().messages;
7993
+ let messages = ctx.sessionManager.buildSessionContext().messages;
7994
+ if (messages[0]?.role === "system" && messages[1]?.role === "compactionSummary") {
7995
+ const branch = ctx.sessionManager.getBranch();
7996
+ const history = branch.slice(0, branch.findLastIndex((entry) => entry.type === "compaction")).flatMap((entry) => entry.type === "message" && entry.message.role === "system" ? [entry.message] : []);
7997
+ messages = [...history, ...messages.slice(1)];
7998
+ }
7994
7999
  const lost = messages.find((message2) => message2.role === "system" || message2.role === "compactionSummary")?.role === "compactionSummary";
7995
8000
  if (lost || hasNativeToolSelection(messages)) {
7996
8001
  const recorded = /* @__PURE__ */ new Set();
@@ -8164,7 +8169,6 @@ var allEnabled = featureText(resolveDisabledFeatureSurface({}));
8164
8169
  var DEFAULT_SUBAGENT_TOOL_DESCRIPTION = essentials(allEnabled);
8165
8170
  var SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate focused work to child agents; compose multi-child work in one workflow call.";
8166
8171
  var STRUCTURED_SUBAGENT_TOOL_PROMPT_SNIPPET = "Delegate focused work to child agents; compose multi-child work in one chain or tasks call.";
8167
- var COMPACT_SUBAGENT_TOOL_DESCRIPTION = DEFAULT_SUBAGENT_TOOL_DESCRIPTION;
8168
8172
  var FULL_SUBAGENT_TOOL_DESCRIPTION = fullDescription(allEnabled);
8169
8173
  function isToolDescriptionMode(value) {
8170
8174
  return value === "full" || value === "compact" || value === "custom";
@@ -8191,15 +8195,15 @@ function customDescriptionPaths(options) {
8191
8195
  path12.join(agentDir, CUSTOM_TOOL_DESCRIPTION_FILE)
8192
8196
  ];
8193
8197
  }
8194
- function renderCustomTemplate(template, options) {
8198
+ function renderCustomTemplate(template, on, options) {
8195
8199
  const cwd = options?.cwd ?? process.cwd();
8196
8200
  const agentDir = options?.agentDir ?? getAgentDir();
8197
8201
  const projectConfigDir = getProjectConfigDir(cwd);
8198
8202
  const variables = {
8199
- fullDescription: () => FULL_SUBAGENT_TOOL_DESCRIPTION,
8200
- full: () => FULL_SUBAGENT_TOOL_DESCRIPTION,
8201
- compactDescription: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,
8202
- compact: () => COMPACT_SUBAGENT_TOOL_DESCRIPTION,
8203
+ fullDescription: () => fullDescription(on),
8204
+ full: () => fullDescription(on),
8205
+ compactDescription: () => essentials(on),
8206
+ compact: () => essentials(on),
8203
8207
  safetyGuidance: () => SUBAGENT_SAFETY_GUIDANCE,
8204
8208
  safety: () => SUBAGENT_SAFETY_GUIDANCE,
8205
8209
  agentDir: () => agentDir,
@@ -8212,7 +8216,7 @@ function renderCustomTemplate(template, options) {
8212
8216
  return raw;
8213
8217
  });
8214
8218
  }
8215
- function loadCustomToolDescription(options) {
8219
+ function loadCustomToolDescription(on, options) {
8216
8220
  for (const filePath of customDescriptionPaths(options)) {
8217
8221
  let stat;
8218
8222
  try {
@@ -8236,7 +8240,7 @@ function loadCustomToolDescription(options) {
8236
8240
  warn(options, `Ignoring empty custom tool description '${filePath}'.`);
8237
8241
  continue;
8238
8242
  }
8239
- const rendered = renderCustomTemplate(template, options).trim();
8243
+ const rendered = renderCustomTemplate(template, on, options).trim();
8240
8244
  if (!rendered) {
8241
8245
  warn(options, `Ignoring custom tool description '${filePath}' because it rendered empty.`);
8242
8246
  continue;
@@ -8265,7 +8269,7 @@ function describeSubagentTool(config, options) {
8265
8269
  const mode = resolveToolDescriptionMode(config, options);
8266
8270
  if (mode === "compact") return essentials(on);
8267
8271
  if (mode === "custom") {
8268
- const custom = loadCustomToolDescription(options);
8272
+ const custom = loadCustomToolDescription(on, options);
8269
8273
  if (custom) return withMandatorySafetyGuidance(custom);
8270
8274
  warn(options, `${CUSTOM_TOOL_DESCRIPTION_FILE} was not found or valid for toolDescriptionMode "custom"; using full description.`);
8271
8275
  }
@@ -8761,7 +8765,7 @@ function registerSubagentExtension(pi) {
8761
8765
  const ctx = withLastUiContext((current) => current);
8762
8766
  if (!ctx) return;
8763
8767
  try {
8764
- const { openSubagentFleet } = await import("./chunk-O7CPL6H4.js");
8768
+ const { openSubagentFleet } = await import("./chunk-2D2DQGC2.js");
8765
8769
  await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
8766
8770
  } catch (error) {
8767
8771
  if (isStaleExtensionContextError(error)) {
@@ -8970,7 +8974,7 @@ function registerSubagentExtension(pi) {
8970
8974
  let executor;
8971
8975
  let executorPromise;
8972
8976
  let executorModulePromise;
8973
- const loadExecutorModule = () => executorModulePromise ??= import("./chunk-JWYG26RE.js");
8977
+ const loadExecutorModule = () => executorModulePromise ??= import("./chunk-OZCPYJEY.js");
8974
8978
  const getExecutor = () => {
8975
8979
  executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
8976
8980
  executor = createSubagentExecutor(executorDeps);
@@ -8984,7 +8988,7 @@ function registerSubagentExtension(pi) {
8984
8988
  modulePreloadTimer = setTimeout(() => {
8985
8989
  loadExecutorModule().catch(() => {
8986
8990
  });
8987
- if (fleetViewEnabled) import("./chunk-O7CPL6H4.js").catch(() => {
8991
+ if (fleetViewEnabled) import("./chunk-2D2DQGC2.js").catch(() => {
8988
8992
  });
8989
8993
  }, MODULE_PRELOAD_DELAY_MS);
8990
8994
  modulePreloadTimer.unref?.();
@@ -9553,13 +9557,14 @@ ${close}` }]
9553
9557
  supervisorChannel.activateTransport();
9554
9558
  });
9555
9559
  pi.on("session_shutdown", async (event) => {
9560
+ const parentSessionFile = state.parentSessionFile ?? void 0;
9556
9561
  sessionSwitchGuard.sessionShutdown(event);
9557
9562
  cancelCompactionResume();
9558
9563
  completionNotifier.sessionShutdown(event?.reason);
9559
9564
  parentWake.sessionShutdown(event?.reason);
9560
9565
  runtimeEntry.cleanup(event?.reason);
9561
9566
  try {
9562
- await disposeChildSessions();
9567
+ await disposeChildSessionsForParent(parentSessionFile);
9563
9568
  } catch (error) {
9564
9569
  console.error("Failed to dispose in-process child sessions:", error);
9565
9570
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-7F6RKT6W.js";
4
4
  import {
5
5
  getAgentDir
6
- } from "./chunk-UX4SCV5N.js";
6
+ } from "./chunk-C3KWLXDH.js";
7
7
 
8
8
  // src/intercom/intercom-bridge.ts
9
9
  import * as fs from "node:fs";