pi-subagents 0.83.0 → 0.83.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 (63) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/bundle/agents.js +4 -4
  3. package/bundle/capability-ceiling.js +1 -1
  4. package/bundle/child-tool-plan.js +3 -3
  5. package/bundle/{chunk-P2NCCTZP.js → chunk-2D52JFLF.js} +1 -1
  6. package/bundle/{chunk-WG2OTTAK.js → chunk-2DHZTCOL.js} +2 -2
  7. package/bundle/{chunk-MBDOYZ2V.js → chunk-2S4K53MV.js} +1 -1
  8. package/bundle/{chunk-HJJAVHFB.js → chunk-5YIITCPD.js} +23 -23
  9. package/bundle/{chunk-CNLDYEH4.js → chunk-AHIFYGR3.js} +11 -11
  10. package/bundle/{chunk-MHX22USZ.js → chunk-C5P5CHYK.js} +1 -1
  11. package/bundle/{chunk-XXKG3P2W.js → chunk-C7JMPU5F.js} +4 -4
  12. package/bundle/{chunk-VTMNBPCQ.js → chunk-D3JAFGMO.js} +1 -1
  13. package/bundle/{chunk-BKFWQ642.js → chunk-F4ASL6OV.js} +1 -1
  14. package/bundle/{chunk-CDI3GMNV.js → chunk-F5DBXJ2G.js} +15 -15
  15. package/bundle/{chunk-JHZ6DZ5M.js → chunk-G2Z6ZH26.js} +1 -1
  16. package/bundle/{chunk-TJQJ3MEA.js → chunk-IPGZMQXV.js} +10 -10
  17. package/bundle/{chunk-Y3I6H6DV.js → chunk-LFDBD4PW.js} +2 -2
  18. package/bundle/{chunk-7F5SK2U3.js → chunk-LNRJCP2Y.js} +17 -14
  19. package/bundle/{chunk-6B4ITO2W.js → chunk-MABL3FUM.js} +1 -1
  20. package/bundle/{chunk-CGXWSNPA.js → chunk-NPIYWVOD.js} +4 -4
  21. package/bundle/{chunk-RZJN63GU.js → chunk-QP5ZWNIS.js} +2 -2
  22. package/bundle/{chunk-Z7KVHQHL.js → chunk-QXASAHIA.js} +2 -2
  23. package/bundle/{chunk-5ESXK62X.js → chunk-RNIZLSEA.js} +416 -389
  24. package/bundle/{chunk-HLE22FSH.js → chunk-SSG7IEP5.js} +2 -2
  25. package/bundle/{chunk-CZTMUBUI.js → chunk-UFL7IYCW.js} +4 -4
  26. package/bundle/{chunk-LDMXJIA6.js → chunk-UUP372DR.js} +44 -67
  27. package/bundle/{chunk-OOFW75PV.js → chunk-UYK5MZWE.js} +15 -11
  28. package/bundle/{chunk-CSSZRTKY.js → chunk-V2BZYLEP.js} +2 -2
  29. package/bundle/{chunk-4BW55BTL.js → chunk-VLFZIN6D.js} +4 -4
  30. package/bundle/{chunk-527E3D2J.js → chunk-YXFJVCOL.js} +5 -5
  31. package/bundle/{chunk-HXVKGS33.js → chunk-ZVOAMTUQ.js} +4 -4
  32. package/bundle/control-channel.js +3 -3
  33. package/bundle/index.js +1 -1
  34. package/bundle/intercom-bridge.js +3 -3
  35. package/bundle/preflight.js +9 -9
  36. package/bundle/project-panes.js +4 -4
  37. package/docs/configuration.md +12 -1
  38. package/docs/extension-api.md +2 -0
  39. package/docs/missions.md +2 -0
  40. package/docs/tool-reference.md +1 -1
  41. package/package.json +1 -1
  42. package/src/agents/agent-management.d.ts +1 -1
  43. package/src/agents/agent-management.js +2 -2
  44. package/src/agents/agents.js +1 -2
  45. package/src/agents/frontmatter.js +22 -18
  46. package/src/extension/index.js +2 -2
  47. package/src/missions/actions.js +7 -2
  48. package/src/missions/lifecycle.d.ts +11 -0
  49. package/src/missions/lifecycle.js +37 -6
  50. package/src/missions/store.js +1 -0
  51. package/src/missions/types.d.ts +2 -0
  52. package/src/runs/background/async-execution.d.ts +1 -1
  53. package/src/runs/background/async-execution.js +3 -3
  54. package/src/runs/background/async-resume.js +3 -2
  55. package/src/runs/background/retained-children.js +1 -1
  56. package/src/runs/foreground/subagent-executor.js +24 -51
  57. package/src/runs/shared/capability-ceiling.d.ts +2 -1
  58. package/src/runs/shared/capability-ceiling.js +3 -2
  59. package/src/runs/shared/parallel-handoff.d.ts +1 -1
  60. package/src/runs/shared/parallel-handoff.js +10 -6
  61. package/src/shared/types.d.ts +1 -1
  62. package/src/workflows/scripted-workflow.js +4 -1
  63. package/workflow-script-worker.cjs +2 -1
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  appendAgentRefinementOverlay
3
- } from "./chunk-Y3I6H6DV.js";
3
+ } from "./chunk-LFDBD4PW.js";
4
4
  import {
5
5
  buildAgentMemoryInjection,
6
6
  buildSkillInjection
7
- } from "./chunk-7F5SK2U3.js";
7
+ } from "./chunk-LNRJCP2Y.js";
8
8
 
9
9
  // src/runs/shared/effective-system-prompt.ts
10
10
  function appendSection(prompt, section) {
@@ -11,7 +11,7 @@ import {
11
11
  projectTimeoutRecovery,
12
12
  readAsyncRecoveryDescriptor,
13
13
  utf8Tail
14
- } from "./chunk-OOFW75PV.js";
14
+ } from "./chunk-UYK5MZWE.js";
15
15
  import {
16
16
  MAX_ARGS_BYTES,
17
17
  MAX_ARGS_DEPTH,
@@ -24,13 +24,13 @@ import {
24
24
  resultFilePath,
25
25
  resultPayloadMatchesSessionRun,
26
26
  resultPayloadPathForSessionRun
27
- } from "./chunk-5ESXK62X.js";
27
+ } from "./chunk-RNIZLSEA.js";
28
28
  import {
29
29
  shouldUseNativeFsWatch
30
30
  } from "./chunk-NIXWDZZV.js";
31
31
  import {
32
32
  PROJECT_SUBAGENTS_RELATIVE_DIR
33
- } from "./chunk-VTMNBPCQ.js";
33
+ } from "./chunk-D3JAFGMO.js";
34
34
  import {
35
35
  listBackgroundWorkWakeChannels,
36
36
  snapshotBackgroundWork
@@ -55,7 +55,7 @@ import {
55
55
  withSettingsFileLease,
56
56
  writeAtomicJson,
57
57
  writePrivateAtomicJson
58
- } from "./chunk-7F5SK2U3.js";
58
+ } from "./chunk-LNRJCP2Y.js";
59
59
  import {
60
60
  ASYNC_DIR,
61
61
  DIRS,
@@ -3,7 +3,7 @@ import {
3
3
  projectRuntimeAcknowledgedExtensions,
4
4
  registerSubagentPromptBoundary,
5
5
  registerSubagentPromptRuntime
6
- } from "./chunk-CGXWSNPA.js";
6
+ } from "./chunk-NPIYWVOD.js";
7
7
  import {
8
8
  INSPECTOR_ACTIONS,
9
9
  canQueueRetainedAsyncFollowUp,
@@ -25,13 +25,13 @@ import {
25
25
  updateSteeringTarget,
26
26
  waitForSteeringAction,
27
27
  workflowAsyncChildSteeringGuidance
28
- } from "./chunk-527E3D2J.js";
28
+ } from "./chunk-YXFJVCOL.js";
29
29
  import {
30
30
  PLACED_RESTORE_UNSUPPORTED,
31
31
  formatHerdrMachineRunnerUnsupported,
32
32
  isRexLocalMachine,
33
33
  resolveMachinePlacement
34
- } from "./chunk-P2NCCTZP.js";
34
+ } from "./chunk-2D52JFLF.js";
35
35
  import {
36
36
  COMPLETION_ACTION,
37
37
  DEFAULT_CONTROL_CONFIG,
@@ -120,7 +120,7 @@ import {
120
120
  workflowStopCause,
121
121
  writeWorkflowLaunchRecord,
122
122
  writeWorkflowReceipt
123
- } from "./chunk-CDI3GMNV.js";
123
+ } from "./chunk-F5DBXJ2G.js";
124
124
  import {
125
125
  NATIVE_SUPERVISOR_TOOL_NAME,
126
126
  SUBAGENT_PARENT_SESSION_ENV,
@@ -136,7 +136,7 @@ import {
136
136
  resolveWatchdogConfig,
137
137
  sendRuleViolationWarning,
138
138
  writeWatchdogModelSettings
139
- } from "./chunk-CZTMUBUI.js";
139
+ } from "./chunk-UFL7IYCW.js";
140
140
  import {
141
141
  MAX_REMEMBERED_FOREGROUND_RUNS,
142
142
  discardRunningForegroundRun,
@@ -149,7 +149,7 @@ import {
149
149
  resolveSubagentRunId,
150
150
  resolveWorkflowChatProgress,
151
151
  stopAsyncRun
152
- } from "./chunk-4BW55BTL.js";
152
+ } from "./chunk-VLFZIN6D.js";
153
153
  import {
154
154
  MODEL_ONLY_TOOL,
155
155
  RunFanoutLimitError,
@@ -211,7 +211,7 @@ import {
211
211
  writeParallelHandoffGroup,
212
212
  writeRunFanoutBudgetDescriptor,
213
213
  writeWorktreeSetupHandoff
214
- } from "./chunk-OOFW75PV.js";
214
+ } from "./chunk-UYK5MZWE.js";
215
215
  import {
216
216
  authorizeWorkflowResourceHost,
217
217
  claimWorkflowChildPermit,
@@ -228,10 +228,10 @@ import {
228
228
  canPreferFork,
229
229
  createForkContextResolver,
230
230
  resolveSubagentLaunchContext
231
- } from "./chunk-HLE22FSH.js";
231
+ } from "./chunk-SSG7IEP5.js";
232
232
  import {
233
233
  handleRefinementAction
234
- } from "./chunk-Y3I6H6DV.js";
234
+ } from "./chunk-LFDBD4PW.js";
235
235
  import {
236
236
  ActiveAsyncCapacityError,
237
237
  acquireActiveAsyncCapacity,
@@ -246,7 +246,7 @@ import {
246
246
  resolveDisabledFeatureSurface,
247
247
  resolveMaxActiveAsyncRunsPerSession,
248
248
  transferActiveAsyncCapacity
249
- } from "./chunk-RZJN63GU.js";
249
+ } from "./chunk-QP5ZWNIS.js";
250
250
  import {
251
251
  DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS,
252
252
  MACHINE_DIFF_OPTIONS,
@@ -280,6 +280,7 @@ import {
280
280
  inheritedNestedParentAddressOf,
281
281
  inheritedNestedRouteOf,
282
282
  initializeProcessTerminal,
283
+ missionAcceptanceStatus,
283
284
  nestedResultsPath,
284
285
  nestedRunNotActiveMessage,
285
286
  nestedRunScope,
@@ -325,7 +326,7 @@ import {
325
326
  writeNestedControlRequest,
326
327
  writeNestedControlResult,
327
328
  writeNestedEvent
328
- } from "./chunk-5ESXK62X.js";
329
+ } from "./chunk-RNIZLSEA.js";
329
330
  import {
330
331
  closeSteerInbox,
331
332
  consumeSteerRequests,
@@ -333,7 +334,7 @@ import {
333
334
  readRevivalBriefs,
334
335
  requestAsyncSteer,
335
336
  watchAsyncControlInbox
336
- } from "./chunk-BKFWQ642.js";
337
+ } from "./chunk-F4ASL6OV.js";
337
338
  import "./chunk-NIXWDZZV.js";
338
339
  import {
339
340
  INTERCOM_BRIDGE_MARKER,
@@ -342,7 +343,7 @@ import {
342
343
  resolveIntercomBridge,
343
344
  resolveIntercomSessionTarget,
344
345
  resolveSubagentIntercomTarget
345
- } from "./chunk-MHX22USZ.js";
346
+ } from "./chunk-C5P5CHYK.js";
346
347
  import {
347
348
  resolveLaunchBinding,
348
349
  stableJsonDigest
@@ -356,7 +357,7 @@ import {
356
357
  resolvePiLaunchToolPlan,
357
358
  resolveRuntimeModulePath,
358
359
  supervisorChannelDir
359
- } from "./chunk-CSSZRTKY.js";
360
+ } from "./chunk-V2BZYLEP.js";
360
361
  import {
361
362
  assertRequiredChildExtensionsAdmitted,
362
363
  hasMandatoryRequiredChildExtensions,
@@ -367,7 +368,7 @@ import {
367
368
  import {
368
369
  HERDR_PROJECT_PANE_ACTIONS,
369
370
  handleHerdrProjectPaneAction
370
- } from "./chunk-WG2OTTAK.js";
371
+ } from "./chunk-2DHZTCOL.js";
371
372
  import "./chunk-7J4ZXMY7.js";
372
373
  import {
373
374
  PROJECT_SUBAGENTS_RELATIVE_DIR,
@@ -380,12 +381,12 @@ import {
380
381
  getProjectSubagentsDir,
381
382
  writeArtifact,
382
383
  writeMetadata
383
- } from "./chunk-VTMNBPCQ.js";
384
+ } from "./chunk-D3JAFGMO.js";
384
385
  import "./chunk-XA3DY6UG.js";
385
386
  import {
386
387
  getExternalJobProvider
387
388
  } from "./chunk-YYREO77V.js";
388
- import "./chunk-JHZ6DZ5M.js";
389
+ import "./chunk-G2Z6ZH26.js";
389
390
  import {
390
391
  ChainOutputValidationError,
391
392
  MAX_STREAMED_RECENT_TOOLS,
@@ -531,7 +532,7 @@ import {
531
532
  writeAtomicJson,
532
533
  writeInitialProgressFile,
533
534
  writePrivateAtomicJson
534
- } from "./chunk-7F5SK2U3.js";
535
+ } from "./chunk-LNRJCP2Y.js";
535
536
  import {
536
537
  CHAIN_RUNS_DIR,
537
538
  DEFAULT_ARTIFACT_CONFIG,
@@ -569,7 +570,7 @@ import {
569
570
  assertAgentAllowedByCapabilityCeiling,
570
571
  intersectSubagentCapabilityCeilings,
571
572
  resolveCurrentSubagentCapabilityCeiling
572
- } from "./chunk-Z7KVHQHL.js";
573
+ } from "./chunk-QXASAHIA.js";
573
574
 
574
575
  // src/runs/foreground/subagent-executor.ts
575
576
  import { randomUUID as randomUUID5 } from "node:crypto";
@@ -2621,7 +2622,8 @@ function executeAsyncChain(id, params) {
2621
2622
  if (acceptanceErrors.length > 0) return formatAsyncStartError(resultMode, acceptanceErrors.join(" "));
2622
2623
  const undefinedLauncher = chain.flatMap(getStepAgents).map((name) => agents.find((agent) => agent.name === name)?.launcher).find((name) => name !== void 0 && !lookupRunnerLauncher(ctx.runnerLaunchers, name));
2623
2624
  if (undefinedLauncher !== void 0) return formatAsyncStartError(resultMode, `Launcher '${undefinedLauncher}' used by this ${resultMode} is not defined in runnerLaunchers in the user subagent config.`);
2624
- const capabilityCeiling = params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(ctx.currentSessionId);
2625
+ const launchParentSessionId = ctx.parentSessionId ?? ctx.currentSessionId;
2626
+ const capabilityCeiling = params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(launchParentSessionId);
2625
2627
  const inheritedNestedRoute2 = inheritedNestedRouteOf(ctx.childRuntime);
2626
2628
  const nestedAddress = inheritedNestedRoute2 ? inheritedNestedParentAddressOf(ctx.childRuntime) : void 0;
2627
2629
  const asyncDir = inheritedNestedRoute2 ? path5.join(TEMP_ROOT_DIR, "nested-subagent-runs", inheritedNestedRoute2.rootRunId, id) : path5.join(DIRS.async, id);
@@ -2713,7 +2715,6 @@ function executeAsyncChain(id, params) {
2713
2715
  const initialStatusAt = Date.now();
2714
2716
  const initialCompletionOwnerId = ctx.completionOwnerId ?? currentCompletionOwnerId();
2715
2717
  const completionOwnerProcess = currentRecordedPid();
2716
- const launchParentSessionId = ctx.parentSessionId ?? ctx.currentSessionId;
2717
2718
  try {
2718
2719
  writeRetainedRequiredChildExtensions(asyncDir, params.requiredExtensions ?? ctx.childRuntime?.requiredExtensions ?? resolveRequiredChildExtensions(launchParentSessionId ?? void 0));
2719
2720
  } catch (error) {
@@ -2973,7 +2974,7 @@ function executeAsyncSingle(id, params) {
2973
2974
  if (extensionBindings !== void 0) unsupported.push("extension bindings");
2974
2975
  if (unsupported.length > 0) return formatAsyncStartError("single", `Agent '${agentConfig.name}' uses runner.type='${externalRunnerType}' and does not support: ${unsupported.join(", ")}.`);
2975
2976
  }
2976
- const capabilityCeiling = intersectSubagentCapabilityCeilings(params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(ctx.currentSessionId), ctx.childRuntime?.capabilityCeiling);
2977
+ const capabilityCeiling = intersectSubagentCapabilityCeilings(params.capabilityCeiling ?? resolveCurrentSubagentCapabilityCeiling(ctx.parentSessionId ?? ctx.currentSessionId), ctx.childRuntime?.capabilityCeiling);
2977
2978
  try {
2978
2979
  assertAgentAllowedByCapabilityCeiling(agentConfig.name, capabilityCeiling);
2979
2980
  } catch (error) {
@@ -10251,9 +10252,6 @@ function resolveForegroundResumeTarget(params, state, options = {}) {
10251
10252
  ...child.capabilityCeiling ? { capabilityCeiling: child.capabilityCeiling } : {}
10252
10253
  };
10253
10254
  }
10254
- function isAsyncRunNotFound(error) {
10255
- return error instanceof Error && error.message.startsWith("Async run not found.");
10256
- }
10257
10255
  function isMissingExactAsyncStatusFile(error, requested) {
10258
10256
  return error instanceof Error && error.message === `Status file not found for async run '${requested}'.`;
10259
10257
  }
@@ -10311,32 +10309,10 @@ function resolveResumeTarget(params, state, options = {}) {
10311
10309
  if (isResumeAmbiguity(foregroundError) && !resumeTargetExact(asyncTarget, requested)) throw foregroundError;
10312
10310
  return asyncTarget;
10313
10311
  }
10314
- if (foregroundError && !isAsyncRunNotFound(asyncError)) throw foregroundError;
10315
10312
  if (foregroundError) throw foregroundError;
10316
10313
  if (asyncError) throw asyncError;
10317
10314
  throw new Error("Run not found. Provide id or runId.");
10318
10315
  }
10319
- function getAsyncInterruptTarget(state, runId, location, options = {}) {
10320
- if (location?.asyncDir) {
10321
- return {
10322
- asyncId: location.resolvedId ?? runId ?? path18.basename(location.asyncDir),
10323
- asyncDir: location.asyncDir
10324
- };
10325
- }
10326
- if (runId) {
10327
- const direct = state.asyncJobs.get(runId);
10328
- if (direct) return { asyncId: direct.asyncId, asyncDir: direct.asyncDir };
10329
- if (options.fallbackToNewest === false) return void 0;
10330
- }
10331
- let newest;
10332
- for (const job of state.asyncJobs.values()) {
10333
- if (job.status !== "running") continue;
10334
- if (!newest || (job.updatedAt ?? 0) > newest.updatedAt) {
10335
- newest = { asyncId: job.asyncId, asyncDir: job.asyncDir, updatedAt: job.updatedAt ?? 0 };
10336
- }
10337
- }
10338
- return newest ? { asyncId: newest.asyncId, asyncDir: newest.asyncDir } : void 0;
10339
- }
10340
10316
  function isStaleExtensionContextError2(error) {
10341
10317
  if (!(error instanceof Error)) return false;
10342
10318
  return /extension ctx is stale|stale after session replacement or reload/i.test(error.message);
@@ -10396,12 +10372,12 @@ function emitControlNotification(input) {
10396
10372
  }
10397
10373
  }
10398
10374
  function interruptAsyncRun(state, runId, kill, location) {
10399
- const target = getAsyncInterruptTarget(state, runId, location, { fallbackToNewest: runId === void 0 });
10375
+ const target = location?.asyncDir ? { asyncId: location.resolvedId ?? runId, asyncDir: location.asyncDir } : state.asyncJobs.get(runId);
10400
10376
  if (!target) return null;
10401
10377
  const status = reconcileAsyncRun(target.asyncDir, omitUndefinedProperties({ kill })).status;
10402
10378
  if (!status || status.state !== "running" || typeof status.pid !== "number") {
10403
10379
  return {
10404
- content: [{ type: "text", text: `No running async run with an interrupt-capable pid was found for '${runId ?? "current"}'.` }],
10380
+ content: [{ type: "text", text: `No running async run with an interrupt-capable pid was found for '${runId}'.` }],
10405
10381
  isError: true,
10406
10382
  details: { mode: "management", results: [] }
10407
10383
  };
@@ -10618,7 +10594,7 @@ function appendStepToAsyncChain(input) {
10618
10594
  worktreeBranchPrefix: input.deps.config.worktreeBranchPrefix,
10619
10595
  asyncDir: resolved.location.asyncDir,
10620
10596
  validateOutputBindings: false,
10621
- capabilityCeiling: intersectSubagentCapabilityCeilings(status.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(asyncCtx.currentSessionId)),
10597
+ capabilityCeiling: intersectSubagentCapabilityCeilings(status.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(asyncCtx.parentSessionId)),
10622
10598
  requiredExtensions: retainedRequiredExtensions
10623
10599
  }));
10624
10600
  if ("error" in built) {
@@ -11011,7 +10987,7 @@ async function resumeExternalJobFollowUp(input) {
11011
10987
  availableModels: input.ctx.modelRegistry.getAvailable().map(toModelInfo),
11012
10988
  outputBaseDir: resolveSingleRunOutputBaseDir(input.deps, artifactsDir, runId),
11013
10989
  ...input.absoluteDeadlineAt !== void 0 ? { absoluteDeadlineAt: input.absoluteDeadlineAt } : {},
11014
- capabilityCeiling: resolveCurrentSubagentCapabilityCeiling(currentSessionId),
10990
+ capabilityCeiling: resolveCurrentSubagentCapabilityCeiling(input.ctx.sessionManager.getSessionId() ?? void 0),
11015
10991
  runFanoutBudget: createRunFanoutBudget(runId, resolveMaxSubagentSpawnsPerRun(input.deps.config.maxSubagentSpawnsPerRun)),
11016
10992
  activeAsyncCapacity,
11017
10993
  externalJobFollowUp: { sourceRunId: input.target.runId, sourceStepIndex: input.target.index, parentProviderJobId: externalJob.providerJobId, requestId, requestDigest }
@@ -11288,7 +11264,7 @@ async function resumeAsyncRun(input) {
11288
11264
  childIntercomTarget: intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(runId2, agent, index) : void 0,
11289
11265
  globalConcurrencyLimit: input.deps.config.globalConcurrencyLimit,
11290
11266
  runFanoutBudget: createRunFanoutBudget(runId2, resolveMaxSubagentSpawnsPerRun(input.deps.config.maxSubagentSpawnsPerRun)),
11291
- capabilityCeiling: intersectSubagentCapabilityCeilings("capabilityCeiling" in target ? target.capabilityCeiling : void 0, resolveCurrentSubagentCapabilityCeiling(input.deps.state.currentSessionId)),
11267
+ capabilityCeiling: intersectSubagentCapabilityCeilings("capabilityCeiling" in target ? target.capabilityCeiling : void 0, resolveCurrentSubagentCapabilityCeiling(input.ctx.sessionManager.getSessionId() ?? void 0)),
11292
11268
  thinkingCeiling: target.thinkingCeiling,
11293
11269
  activeAsyncCapacity: activeAsyncCapacity2
11294
11270
  }));
@@ -11440,7 +11416,7 @@ async function resumeAsyncRun(input) {
11440
11416
  ...input.params.toolBudget !== void 0 ? { toolBudget: input.params.toolBudget } : {},
11441
11417
  // Recovery descriptors, remembered foreground runs, and current workflow roots
11442
11418
  // preserve parent authority before the selected agent's descendant ceiling.
11443
- capabilityCeiling: intersectSubagentCapabilityCeilings(recoveryDescriptor?.capabilityCeiling ?? (target.source === "foreground" || target.source === "async" && target.mode === "workflow" ? target.capabilityCeiling : void 0), resolveCurrentSubagentCapabilityCeiling(input.deps.state.currentSessionId)),
11419
+ capabilityCeiling: intersectSubagentCapabilityCeilings(recoveryDescriptor?.capabilityCeiling ?? (target.source === "foreground" || target.source === "async" && target.mode === "workflow" ? target.capabilityCeiling : void 0), resolveCurrentSubagentCapabilityCeiling(input.ctx.sessionManager.getSessionId() ?? void 0)),
11444
11420
  runFanoutBudget: input.params.runFanoutBudget ?? recoveryDescriptor?.runFanoutBudget ?? createRunFanoutBudget(runId, resolveMaxSubagentSpawnsPerRun(input.deps.config.maxSubagentSpawnsPerRun)),
11445
11421
  parentWorkflowRunId: input.params.workflowParentRunId,
11446
11422
  workflowKey: input.params.workflowKey,
@@ -14175,7 +14151,7 @@ function createSubagentExecutor(deps) {
14175
14151
  const eventsPath = path18.join(asyncDir, "events.jsonl");
14176
14152
  const startedAt = Date.now();
14177
14153
  const currentSessionId = resolveCurrentSessionId(ctx.sessionManager);
14178
- const workflowCapabilityCeiling2 = intersectSubagentCapabilityCeilings(requestParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(currentSessionId));
14154
+ const workflowCapabilityCeiling2 = intersectSubagentCapabilityCeilings(requestParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(ctx.sessionManager.getSessionId() ?? void 0));
14179
14155
  const completionOwnerId = deps2.state.completionOwnerId ?? currentCompletionOwnerId();
14180
14156
  deps2.state.completionOwnerId = completionOwnerId;
14181
14157
  const workflowScriptSourceDigest = workflowScriptDigest(requestParams.workflowScript);
@@ -14919,6 +14895,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
14919
14895
  ...result2.details.results[0]?.sessionFile ? { sessionPath: result2.details.results[0].sessionFile } : {},
14920
14896
  artifactPaths: child.artifactPaths,
14921
14897
  ...["completed", "failed"].includes(childStatus) ? { completedAt: (/* @__PURE__ */ new Date()).toISOString() } : {},
14898
+ acceptanceStatus: missionAcceptanceStatus(result2.details.results),
14922
14899
  heartbeat: { status: childStatus, ...childPhase ? { phase: childPhase } : {} }
14923
14900
  });
14924
14901
  if (result2.details.asyncId) {
@@ -15063,7 +15040,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
15063
15040
  let lastProgressAt = 0;
15064
15041
  let workflowProgressClosed = false;
15065
15042
  const workflowDeadlineAt = timeout === void 0 ? void 0 : Date.now() + timeout;
15066
- const workflowCapabilityCeiling = intersectSubagentCapabilityCeilings(requestParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(resolveCurrentSessionId(ctx.sessionManager)));
15043
+ const workflowCapabilityCeiling = intersectSubagentCapabilityCeilings(requestParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(ctx.sessionManager.getSessionId() ?? void 0));
15067
15044
  const sendWorkflowProgress = () => {
15068
15045
  if (workflowProgressClosed) return;
15069
15046
  if (activityTimer) clearTimeout(activityTimer);
@@ -15196,6 +15173,7 @@ Parent action: ${COMPLETION_ACTION}` : content,
15196
15173
  ...result2.details.results[0]?.sessionFile ? { sessionPath: result2.details.results[0].sessionFile } : {},
15197
15174
  artifactPaths: child.artifactPaths,
15198
15175
  ...["completed", "failed"].includes(childStatus) ? { completedAt: (/* @__PURE__ */ new Date()).toISOString() } : {},
15176
+ acceptanceStatus: missionAcceptanceStatus(result2.details.results),
15199
15177
  heartbeat: { status: childStatus, ...childPhase ? { phase: childPhase } : {} }
15200
15178
  });
15201
15179
  return child;
@@ -15902,21 +15880,20 @@ ${item.text}` } : item)
15902
15880
  );
15903
15881
  if (stopResult) return stopResult;
15904
15882
  return {
15905
- content: [{ type: "text", text: "No stoppable async run found in this session." }],
15883
+ content: [{ type: "text", text: `No stoppable async run found for '${targetRunId}'.` }],
15906
15884
  isError: true,
15907
15885
  details: { mode: "management", results: [] }
15908
15886
  };
15909
15887
  }
15910
15888
  if (action === "interrupt") {
15911
15889
  const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
15890
+ if (!targetRunId) return { content: [{ type: "text", text: "action='interrupt' requires id." }], isError: true, details: { mode: "management", results: [] } };
15912
15891
  let resolved;
15913
- if (targetRunId) {
15914
- try {
15915
- resolved = resolveSubagentRunId(targetRunId, omitUndefinedProperties({ state: deps2.state, nested: nestedResolutionScopeForExecutor(deps2) }));
15916
- } catch (error) {
15917
- const message = error instanceof Error ? error.message : String(error);
15918
- return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
15919
- }
15892
+ try {
15893
+ resolved = resolveSubagentRunId(targetRunId, omitUndefinedProperties({ state: deps2.state, nested: nestedResolutionScopeForExecutor(deps2) }));
15894
+ } catch (error) {
15895
+ const message = error instanceof Error ? error.message : String(error);
15896
+ return { content: [{ type: "text", text: message }], isError: true, details: { mode: "management", results: [] } };
15920
15897
  }
15921
15898
  if (resolved?.kind === "nested") return interruptNestedRun(resolved);
15922
15899
  const foreground = getForegroundControl(deps2.state, resolved?.kind === "foreground" ? resolved.id : targetRunId);
@@ -15944,7 +15921,7 @@ ${item.text}` } : item)
15944
15921
  );
15945
15922
  if (asyncInterruptResult) return asyncInterruptResult;
15946
15923
  return {
15947
- content: [{ type: "text", text: "No interrupt-capable run found in this session." }],
15924
+ content: [{ type: "text", text: `No interrupt-capable run found for '${targetRunId}'.` }],
15948
15925
  isError: true,
15949
15926
  details: { mode: "management", results: [] }
15950
15927
  };
@@ -15960,7 +15937,7 @@ ${item.text}` } : item)
15960
15937
  ...ctx,
15961
15938
  cwd: requestCwd,
15962
15939
  config: deps2.config,
15963
- currentSessionId: deps2.state.currentSessionId ?? ctx.sessionManager.getSessionId() ?? void 0,
15940
+ piSessionId: ctx.sessionManager.getSessionId() ?? void 0,
15964
15941
  discoverAgentsAll: deps2.discoverAgentsAll,
15965
15942
  runtimeAgentOwner: deps2.pi,
15966
15943
  onAgentsChanged: deps2.onAgentsChanged
@@ -16062,7 +16039,7 @@ ${item.text}` } : item)
16062
16039
  let prepareForkSessionForIndex = async () => {
16063
16040
  };
16064
16041
  const launchCapabilityCeiling = () => intersectSubagentCapabilityCeilings(
16065
- intersectSubagentCapabilityCeilings(effectiveParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(requestSessionId)),
16042
+ intersectSubagentCapabilityCeilings(effectiveParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(requestPiSessionId)),
16066
16043
  deps2.childRuntime?.capabilityCeiling
16067
16044
  );
16068
16045
  const assertLaunchableAgentsAllowedBeforeFork = () => {
@@ -16308,7 +16285,7 @@ ${item.text}` } : item)
16308
16285
  scopedModelIds: scopedModelIdsFromContext(ctx),
16309
16286
  parentSessionId: requestSessionId,
16310
16287
  parentPiSessionId: requestPiSessionId,
16311
- capabilityCeiling: intersectSubagentCapabilityCeilings(effectiveParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(requestSessionId)),
16288
+ capabilityCeiling: intersectSubagentCapabilityCeilings(effectiveParams.capabilityCeiling, resolveCurrentSubagentCapabilityCeiling(requestPiSessionId)),
16312
16289
  runFanoutBudget,
16313
16290
  topLevelAsyncCapacityEligible,
16314
16291
  activeAsyncCapacity,
@@ -39,10 +39,10 @@ import {
39
39
  validateModelResponseAliases,
40
40
  withWorkflowChildRunModel,
41
41
  withWorktreeTransaction
42
- } from "./chunk-5ESXK62X.js";
42
+ } from "./chunk-RNIZLSEA.js";
43
43
  import {
44
44
  validateIntercomBridgeConfig
45
- } from "./chunk-MHX22USZ.js";
45
+ } from "./chunk-C5P5CHYK.js";
46
46
  import {
47
47
  stableJsonDigest
48
48
  } from "./chunk-7F6RKT6W.js";
@@ -73,7 +73,7 @@ import {
73
73
  validateToolBudgetConfig,
74
74
  waitForFileSystemRetry,
75
75
  writeAtomicJson
76
- } from "./chunk-7F5SK2U3.js";
76
+ } from "./chunk-LNRJCP2Y.js";
77
77
  import {
78
78
  DIRS,
79
79
  RUNNER_LAUNCHER_NAME_PATTERN,
@@ -88,7 +88,7 @@ import {
88
88
  intersectSubagentCapabilityCeilings,
89
89
  normalizeCapabilityCeilingAllowedAgents,
90
90
  parseSubagentCapabilityCeiling
91
- } from "./chunk-Z7KVHQHL.js";
91
+ } from "./chunk-QXASAHIA.js";
92
92
 
93
93
  // src/shared/session-succession.ts
94
94
  var SUCCESSION_KEY = /* @__PURE__ */ Symbol.for("pi-subagents.session-succession");
@@ -2850,18 +2850,21 @@ async function protectRetainedWorktreeForResume(manifestPath, runId, childIndex,
2850
2850
  return cwd;
2851
2851
  }), { signal }));
2852
2852
  }
2853
- function resolveRetainedWorktreeCwd(manifestPath, runId, childIndex) {
2853
+ function resolveRetainedWorktreeCwd(manifestPath, runId, childIndex, recordedWorktreePath) {
2854
2854
  const manifest = readParallelHandoffManifest(manifestPath);
2855
- if (!manifest) return void 0;
2856
- if (manifest.runId !== runId) throw new Error(`Managed worktree handoff belongs to run '${manifest.runId}', not '${runId}'.`);
2857
- const match = manifest.groups.flatMap((group) => group.children.map((child) => ({ group, child }))).find(({ child }) => child.index === childIndex);
2858
- if (!match) return void 0;
2855
+ if (manifest && manifest.runId !== runId) throw new Error(`Managed worktree handoff belongs to run '${manifest.runId}', not '${runId}'.`);
2856
+ const match = manifest?.groups.flatMap((group) => group.children.map((child) => ({ group, child }))).find(({ child }) => child.index === childIndex);
2857
+ if (!manifest || !match) {
2858
+ if (recordedWorktreePath) throw new Error(`Async run '${runId}' child ${childIndex} ran in managed worktree ${recordedWorktreePath}, but its handoff has no resumable record yet. Retry after the run settles; if it already ended, inspect ${manifestPath}.`);
2859
+ return void 0;
2860
+ }
2859
2861
  const cleanup = match.group.cleanup.tasks.find((task) => task.index === match.child.taskIndex);
2860
2862
  if (!cleanup) throw new Error(`Async run '${runId}' child ${childIndex} has no managed worktree cleanup record.`);
2861
2863
  const relativeCwd = path5.relative(resolveExistingPath(match.group.repoRoot), resolveExistingPath(manifest.cwd));
2862
2864
  if (path5.isAbsolute(relativeCwd) || relativeCwd === ".." || relativeCwd.startsWith(`..${path5.sep}`)) throw new Error(`Async run '${runId}' has an invalid managed worktree cwd.`);
2863
2865
  const requiredCwd = path5.join(cleanup.path, relativeCwd);
2864
2866
  if (cleanup.worktreeRemoved || cleanup.branchRemoved) throw new Error(`Async run '${runId}' required managed worktree was removed: ${requiredCwd}`);
2867
+ if (cleanup.reason?.includes("pending durable handoff capture")) throw new Error(`Async run '${runId}' child ${childIndex} is still finalizing its managed worktree: ${requiredCwd}. Retry after the run settles; if it already ended, inspect ${manifestPath}.`);
2865
2868
  let worktreeRoot = "";
2866
2869
  let resolvedRequiredCwd = "";
2867
2870
  try {
@@ -3813,7 +3816,8 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
3813
3816
  const requireSessionFile = options.requireSessionFile ?? true;
3814
3817
  const location = resolveAsyncRunLocation(params, asyncDirRoot, resultsDir);
3815
3818
  if (!location.asyncDir && !location.resultPath) {
3816
- throw new Error("Async run not found. Provide id or dir.");
3819
+ const requested = params.id ?? params.runId;
3820
+ throw new Error(requested ? `Async run not found for '${requested}'.` : "Async run not found. Provide id or dir.");
3817
3821
  }
3818
3822
  const reconciliation = location.asyncDir ? reconcileAsyncRun(location.asyncDir, { resultsDir, kill: deps.kill, now: deps.now }) : void 0;
3819
3823
  const status = reconciliation?.status ?? null;
@@ -3913,7 +3917,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
3913
3917
  const stepThinking = statusSteps[index]?.thinking ?? resultSteps[index]?.thinking ?? (stepCount === 1 ? result?.thinking : void 0);
3914
3918
  const thinkingCeiling = statusSteps[index]?.thinkingCeiling ?? (stepCount === 1 ? recoveryDescriptor?.thinkingCeiling : void 0);
3915
3919
  const capabilityCeiling = mode === "workflow" ? intersectSubagentCapabilityCeilings(status?.admissionCapabilityCeiling, result?.admissionCapabilityCeiling) : intersectSubagentCapabilityCeilings(status?.capabilityCeiling, statusSteps[index]?.capabilityCeiling, result?.capabilityCeiling, resultSteps[index]?.capabilityCeiling);
3916
- const managedWorktreeCwd = location.asyncDir ? resolveRetainedWorktreeCwd(parallelHandoffPath(location.asyncDir), runId, index) : void 0;
3920
+ const managedWorktreeCwd = location.asyncDir ? resolveRetainedWorktreeCwd(parallelHandoffPath(location.asyncDir), runId, index, statusSteps[index]?.worktreePath) : void 0;
3917
3921
  const resumeCwd = validateResumeCwd(runId, managedWorktreeCwd ?? status?.cwd ?? result?.cwd ?? recoveryDescriptor?.cwd);
3918
3922
  return {
3919
3923
  kind: "revive",
@@ -7,7 +7,7 @@ import {
7
7
  getAgentDir,
8
8
  getConfigDirName,
9
9
  getProjectConfigDir
10
- } from "./chunk-7F5SK2U3.js";
10
+ } from "./chunk-LNRJCP2Y.js";
11
11
  import {
12
12
  TEMP_ROOT_DIR
13
13
  } from "./chunk-JEZOSEWG.js";
@@ -15,7 +15,7 @@ import {
15
15
  capabilityCeilingAgentRestrictionSources,
16
16
  intersectSubagentCapabilityCeilings,
17
17
  isAgentAllowedByCapabilityCeiling
18
- } from "./chunk-Z7KVHQHL.js";
18
+ } from "./chunk-QXASAHIA.js";
19
19
 
20
20
  // src/runs/shared/child-tool-plan.ts
21
21
  import { createHash as createHash2 } from "node:crypto";
@@ -13,7 +13,7 @@ import {
13
13
  summarizeContextModes,
14
14
  utf8Tail,
15
15
  workflowPreflightLaneForRuntimeKey
16
- } from "./chunk-OOFW75PV.js";
16
+ } from "./chunk-UYK5MZWE.js";
17
17
  import {
18
18
  assertSafeNestedId,
19
19
  checkRecordedPidLiveness,
@@ -32,11 +32,11 @@ import {
32
32
  updateActiveRunIndex,
33
33
  validateModelResponseAliases,
34
34
  writeAsyncResultFile
35
- } from "./chunk-5ESXK62X.js";
35
+ } from "./chunk-RNIZLSEA.js";
36
36
  import {
37
37
  deliverStopRequest,
38
38
  stopInboxClosedPath
39
- } from "./chunk-BKFWQ642.js";
39
+ } from "./chunk-F4ASL6OV.js";
40
40
  import {
41
41
  SUBAGENT_STOPPED_MESSAGE,
42
42
  formatDuration,
@@ -47,7 +47,7 @@ import {
47
47
  validateAcceptanceInput,
48
48
  writeAtomicJson,
49
49
  writePrivateAtomicJson
50
- } from "./chunk-7F5SK2U3.js";
50
+ } from "./chunk-LNRJCP2Y.js";
51
51
  import {
52
52
  DIRS
53
53
  } from "./chunk-JEZOSEWG.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  isTrustedRecordedSessionFile,
3
3
  resolveSubagentRunId
4
- } from "./chunk-4BW55BTL.js";
4
+ } from "./chunk-VLFZIN6D.js";
5
5
  import {
6
6
  agentStreamOptions,
7
7
  opencodeSessionHeaders,
8
8
  ownsRun,
9
9
  resolveAsyncResumeTarget
10
- } from "./chunk-OOFW75PV.js";
10
+ } from "./chunk-UYK5MZWE.js";
11
11
  import {
12
12
  currentCompletionOwnerId,
13
13
  listMissions,
@@ -16,12 +16,12 @@ import {
16
16
  reconcileAsyncRun,
17
17
  resolveAuthorityDecision,
18
18
  resolveMissionStoreLocation
19
- } from "./chunk-5ESXK62X.js";
19
+ } from "./chunk-RNIZLSEA.js";
20
20
  import {
21
21
  deliverInterruptRequest,
22
22
  queueRevivalBrief,
23
23
  requestAsyncSteer
24
- } from "./chunk-BKFWQ642.js";
24
+ } from "./chunk-F4ASL6OV.js";
25
25
  import {
26
26
  formatShellCommand
27
27
  } from "./chunk-7J4ZXMY7.js";
@@ -32,7 +32,7 @@ import {
32
32
  tryLease,
33
33
  writeAtomicJson,
34
34
  writePrivateAtomicJson
35
- } from "./chunk-7F5SK2U3.js";
35
+ } from "./chunk-LNRJCP2Y.js";
36
36
  import {
37
37
  DIRS
38
38
  } from "./chunk-JEZOSEWG.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildWorkflowChatProgressRows
3
- } from "./chunk-4BW55BTL.js";
3
+ } from "./chunk-VLFZIN6D.js";
4
4
  import {
5
5
  aggregateStepStatus,
6
6
  contextModeBadge,
@@ -25,13 +25,13 @@ import {
25
25
  projectWorkflowChecklist,
26
26
  withCachedUiContext,
27
27
  workflowGraphStageNodes
28
- } from "./chunk-OOFW75PV.js";
28
+ } from "./chunk-UYK5MZWE.js";
29
29
  import {
30
30
  flatToLogicalStepIndex,
31
31
  formatWorkflowJsonPreview,
32
32
  hostStepReportName,
33
33
  hostStepVerdictLabel
34
- } from "./chunk-5ESXK62X.js";
34
+ } from "./chunk-RNIZLSEA.js";
35
35
  import {
36
36
  snapshotExternalRuns
37
37
  } from "./chunk-UKG4V45O.js";
@@ -49,7 +49,7 @@ import {
49
49
  getSingleResultOutput,
50
50
  shortenPath,
51
51
  unresolvedChildWatchdogBlockers
52
- } from "./chunk-7F5SK2U3.js";
52
+ } from "./chunk-LNRJCP2Y.js";
53
53
  import {
54
54
  MAX_WIDGET_JOBS,
55
55
  WIDGET_ANIMATION_INTERVAL_MS,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  requestAsyncStop
3
- } from "./chunk-BKFWQ642.js";
3
+ } from "./chunk-F4ASL6OV.js";
4
4
  import "./chunk-NIXWDZZV.js";
5
- import "./chunk-7F5SK2U3.js";
5
+ import "./chunk-LNRJCP2Y.js";
6
6
  import "./chunk-JEZOSEWG.js";
7
7
  import "./chunk-YFCK7H2S.js";
8
- import "./chunk-Z7KVHQHL.js";
8
+ import "./chunk-QXASAHIA.js";
9
9
  export {
10
10
  requestAsyncStop
11
11
  };
package/bundle/index.js CHANGED
@@ -17,7 +17,7 @@ function readInstalledPackageVersion() {
17
17
  var loadedPackageVersion = readInstalledPackageVersion();
18
18
 
19
19
  // index.ts
20
- var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-CNLDYEH4.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-HJJAVHFB.js")).default;
20
+ var registerExtension = process.env[HERDR_PI_MODE_ENV] === "1" ? (await import("./chunk-AHIFYGR3.js")).default : process.env.PI_SUBAGENT_CHILD === "1" ? void 0 : (await import("./chunk-5YIITCPD.js")).default;
21
21
  function registerSubagentExtension(pi) {
22
22
  const installedVersion = readInstalledPackageVersion();
23
23
  if (installedVersion !== loadedPackageVersion) {