@vicary/pi-subagents 0.86.0 → 0.88.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 (122) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/bundle/agents.js +3 -3
  3. package/bundle/child-tool-plan.js +2 -2
  4. package/bundle/{chunk-PYOAIN3V.js → chunk-2DIEL4WG.js} +2 -2
  5. package/bundle/{chunk-GJGTMLPE.js → chunk-3DT5X2QC.js} +483 -477
  6. package/bundle/{chunk-374MZFF4.js → chunk-3MFYKBKI.js} +23 -13
  7. package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
  8. package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
  9. package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
  10. package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
  11. package/bundle/{chunk-DD22RXYJ.js → chunk-AOSILI5R.js} +200 -64
  12. package/bundle/{chunk-WHC2XHGF.js → chunk-BW5JLKIU.js} +174 -56
  13. package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
  14. package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
  15. package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
  16. package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
  17. package/bundle/{chunk-CJHFDQFJ.js → chunk-JYHTDTOZ.js} +10 -6
  18. package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
  19. package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
  20. package/bundle/{chunk-2DITXA3H.js → chunk-NVGQE2H2.js} +12 -12
  21. package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
  22. package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
  23. package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
  24. package/bundle/{chunk-GLVJMI6R.js → chunk-TDJKY2NE.js} +14 -5
  25. package/bundle/{chunk-XOFYXQKZ.js → chunk-V7SZMS6W.js} +2 -2
  26. package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
  27. package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
  28. package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
  29. package/bundle/{chunk-QFLPV64W.js → chunk-XZXYPZUT.js} +46 -32
  30. package/bundle/chunk-YDZ7BZD5.js +523 -0
  31. package/bundle/{chunk-WN2E5XHN.js → chunk-YZPVALSQ.js} +30 -5
  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 +4 -4
  39. package/docs/configuration.md +14 -4
  40. package/docs/extension-api.md +2 -0
  41. package/docs/models.md +6 -2
  42. package/docs/observability.md +2 -0
  43. package/docs/tool-reference.md +5 -1
  44. package/package.json +3 -3
  45. package/skills/pi-subagents/SKILL.md +15 -6
  46. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  47. package/src/agents/agent-management.d.ts +1 -0
  48. package/src/agents/agent-management.js +22 -10
  49. package/src/agents/agent-serializer.d.ts +2 -0
  50. package/src/agents/agent-serializer.js +1 -1
  51. package/src/agents/agents.d.ts +1 -0
  52. package/src/agents/agents.js +39 -14
  53. package/src/api/preflight.d.ts +3 -1
  54. package/src/api/preflight.js +2 -0
  55. package/src/extension/config.d.ts +9 -0
  56. package/src/extension/config.js +13 -0
  57. package/src/extension/index.js +8 -5
  58. package/src/extension/schemas.d.ts +4 -0
  59. package/src/extension/schemas.js +2 -0
  60. package/src/extension/tool-activation.js +20 -3
  61. package/src/runs/background/async-execution.d.ts +2 -1
  62. package/src/runs/background/async-execution.js +4 -2
  63. package/src/runs/background/async-resume.js +2 -1
  64. package/src/runs/background/async-retention.d.ts +0 -2
  65. package/src/runs/background/async-retention.js +11 -5
  66. package/src/runs/background/async-status.d.ts +2 -0
  67. package/src/runs/background/async-status.js +4 -0
  68. package/src/runs/background/run-child-session.d.ts +2 -2
  69. package/src/runs/background/run-child-session.js +4 -7
  70. package/src/runs/background/runner-aliases.js +15 -0
  71. package/src/runs/background/steering.d.ts +2 -11
  72. package/src/runs/background/steering.js +11 -6
  73. package/src/runs/background/subagent-runner.d.ts +0 -2
  74. package/src/runs/background/subagent-runner.js +73 -58
  75. package/src/runs/background/wait-subscriptions.js +124 -12
  76. package/src/runs/foreground/async-steering-action.js +24 -9
  77. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  78. package/src/runs/foreground/async-stop-action.js +9 -1
  79. package/src/runs/foreground/execution.js +33 -15
  80. package/src/runs/foreground/prompt-audit.js +1 -0
  81. package/src/runs/foreground/subagent-executor.d.ts +2 -8
  82. package/src/runs/foreground/subagent-executor.js +57 -23
  83. package/src/runs/shared/async-status-projection.d.ts +2 -0
  84. package/src/runs/shared/async-status-projection.js +10 -0
  85. package/src/runs/shared/child-session.d.ts +5 -4
  86. package/src/runs/shared/child-session.js +64 -36
  87. package/src/runs/shared/herdr-placed-run.js +3 -2
  88. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  89. package/src/runs/shared/mcp-config-sources.js +1 -1
  90. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  91. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  92. package/src/runs/shared/model-resolution.d.ts +19 -4
  93. package/src/runs/shared/model-resolution.js +50 -51
  94. package/src/runs/shared/subagent-prompt-runtime.js +14 -2
  95. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  96. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  97. package/src/shared/artifacts.d.ts +1 -0
  98. package/src/shared/artifacts.js +132 -22
  99. package/src/shared/pruned-fork.js +2 -2
  100. package/src/shared/reported-progress.d.ts +1 -0
  101. package/src/shared/reported-progress.js +12 -0
  102. package/src/shared/status-format.d.ts +1 -0
  103. package/src/shared/status-format.js +1 -1
  104. package/src/shared/types.d.ts +23 -0
  105. package/src/shared/utils.d.ts +3 -1
  106. package/src/shared/utils.js +4 -0
  107. package/src/tui/render.js +33 -2
  108. package/src/watchdog/model-selection.js +2 -2
  109. package/src/watchdog/permission-arbiter.js +1 -0
  110. package/src/watchdog/review.d.ts +0 -5
  111. package/src/watchdog/review.js +4 -3
  112. package/src/workflows/scripted-workflow.d.ts +2 -0
  113. package/src/workflows/scripted-workflow.js +103 -39
  114. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  115. package/src/workflows/structured-workflow-scripts.js +32 -11
  116. package/src/workflows/workflow-resources.js +4 -4
  117. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  118. package/src/workflows/workflow-resume-claim.js +1 -1
  119. package/src/workflows/workflow-resume.d.ts +1 -1
  120. package/src/workflows/workflow-resume.js +3 -1
  121. package/src/workflows/workflow-script-worker.js +3 -1
  122. package/bundle/chunk-GRJHIXYF.js +0 -235
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "pi-subagents",
4
- version: "0.86.0",
4
+ version: "0.88.0",
5
5
  private: true,
6
6
  description: "Pi extension for single-agent delegation and scripted multi-agent workflows",
7
7
  author: "Nico Bailon",
@@ -108,7 +108,7 @@ var package_default = {
108
108
  "@js-temporal/polyfill": "0.5.1",
109
109
  acorn: "8.18.0",
110
110
  jiti: "2.7.0",
111
- undici: "8.12.3",
111
+ undici: "8.12.4",
112
112
  yaml: "2.8.3"
113
113
  },
114
114
  devDependencies: {
@@ -11,7 +11,7 @@ import {
11
11
  readStatus,
12
12
  writeAtomicJson,
13
13
  writePrivateAtomicJson
14
- } from "./chunk-QGO6HXHG.js";
14
+ } from "./chunk-4MVDMA5C.js";
15
15
  import {
16
16
  ASYNC_DIR,
17
17
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -4,7 +4,7 @@ import {
4
4
  getAgentDir,
5
5
  getProjectConfigDir,
6
6
  resolveRexLocalPlacement
7
- } from "./chunk-QGO6HXHG.js";
7
+ } from "./chunk-4MVDMA5C.js";
8
8
 
9
9
  // src/runs/shared/herdr-machine.ts
10
10
  import { spawnSync as spawnSync2 } from "node:child_process";
@@ -7,37 +7,37 @@ import {
7
7
  safeTranscriptEvent,
8
8
  steerAsyncRun,
9
9
  steerWorkflowForegroundTarget
10
- } from "./chunk-3RKFH2UZ.js";
10
+ } from "./chunk-6EUQPQY7.js";
11
11
  import {
12
12
  FLEET_STATUS_WIDGET_KEY,
13
13
  runningTone,
14
14
  stepTaskSummary
15
- } from "./chunk-WN2E5XHN.js";
15
+ } from "./chunk-YZPVALSQ.js";
16
16
  import {
17
17
  foregroundChildStateLabel,
18
18
  formatAsyncRunTranscript,
19
19
  stopAsyncRun
20
- } from "./chunk-UR7OW5S7.js";
20
+ } from "./chunk-RHYVKQQL.js";
21
21
  import {
22
22
  contextModeBadge,
23
23
  contextModeLabel,
24
24
  decodeUtf8Tail,
25
25
  listAsyncRuns
26
- } from "./chunk-BGXEAYUM.js";
26
+ } from "./chunk-SVIXQDIV.js";
27
27
  import {
28
28
  reportSessionWarning
29
29
  } from "./chunk-HXRB42AF.js";
30
- import "./chunk-GJGTMLPE.js";
31
- import "./chunk-5H4BICQZ.js";
30
+ import "./chunk-3DT5X2QC.js";
31
+ import "./chunk-W6HIYD2Z.js";
32
32
  import "./chunk-NIXWDZZV.js";
33
- import "./chunk-77ASNIEM.js";
33
+ import "./chunk-47ZN7NKR.js";
34
34
  import "./chunk-7F6RKT6W.js";
35
35
  import "./chunk-CTPAE36Y.js";
36
36
  import "./chunk-7J4ZXMY7.js";
37
37
  import {
38
38
  getArtifactPaths,
39
39
  getArtifactsDir
40
- } from "./chunk-GRJHIXYF.js";
40
+ } from "./chunk-YDZ7BZD5.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-QGO6HXHG.js";
52
+ } from "./chunk-4MVDMA5C.js";
53
53
  import {
54
54
  DIRS
55
55
  } from "./chunk-JEZOSEWG.js";
@@ -8,23 +8,23 @@ import {
8
8
  projectTimeoutRecovery,
9
9
  readAsyncRecoveryDescriptor,
10
10
  utf8Tail
11
- } from "./chunk-BGXEAYUM.js";
11
+ } from "./chunk-SVIXQDIV.js";
12
12
  import {
13
13
  MAX_ARGS_BYTES,
14
14
  MAX_ARGS_DEPTH,
15
15
  MAX_ARGS_FIELDS,
16
16
  MAX_ARGS_ITEMS
17
- } from "./chunk-NF7IEKBH.js";
17
+ } from "./chunk-W2BZS6UC.js";
18
18
  import {
19
19
  fallbackResultPayloadPathForSessionRun,
20
20
  nestedRunScope,
21
21
  resultFilePath,
22
22
  resultPayloadMatchesSessionRun,
23
23
  resultPayloadPathForSessionRun
24
- } from "./chunk-GJGTMLPE.js";
24
+ } from "./chunk-3DT5X2QC.js";
25
25
  import {
26
26
  PROJECT_SUBAGENTS_RELATIVE_DIR
27
- } from "./chunk-GRJHIXYF.js";
27
+ } from "./chunk-YDZ7BZD5.js";
28
28
  import {
29
29
  listBackgroundWorkWakeChannels,
30
30
  snapshotBackgroundWork
@@ -40,6 +40,7 @@ import {
40
40
  formatDuration,
41
41
  getAgentDir,
42
42
  getProjectConfigDir,
43
+ knownModelProviders,
43
44
  resolveEffectiveThinking,
44
45
  resolveModelCandidate,
45
46
  shortenPath,
@@ -49,7 +50,7 @@ import {
49
50
  waitToolName,
50
51
  withSettingsFileLease,
51
52
  writePrivateAtomicJson
52
- } from "./chunk-QGO6HXHG.js";
53
+ } from "./chunk-4MVDMA5C.js";
53
54
  import {
54
55
  DIRS,
55
56
  INTERCOM_DETACH_REQUEST_EVENT,
@@ -819,6 +820,7 @@ var SubagentParamProperties = {
819
820
  description: 'Management/control only; omit for execution. validate accepts workflow: true or a script path. Discover actions with {action:"guide",options:{topic:"tool-reference"}}.'
820
821
  })),
821
822
  capabilities: Type2.Optional(Type2.Boolean({ description: "list: compact capability rows/details without system prompts." })),
823
+ search: Type2.Optional(Type2.String({ minLength: 1, description: "list: case-insensitive match on agent name, alias, or description." })),
822
824
  name: Type2.Optional(Type2.String({ description: "schedule.create name." })),
823
825
  id: Type2.Optional(Type2.String({
824
826
  description: "Run id/prefix for status/control."
@@ -837,6 +839,7 @@ var SubagentParamProperties = {
837
839
  supersession: Type2.Optional(Type2.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordSupersession evidence; read guide tool-reference." })),
838
840
  index: Type2.Optional(Type2.Integer({ minimum: 0, description: "Zero-based child/transcript index." })),
839
841
  childId: Type2.Optional(Type2.String({ minLength: 1, maxLength: 256, description: "Child-scoped stop identity." })),
842
+ drain: Type2.Optional(Type2.Boolean({ description: "stop: a live async workflow starts no new children; started ones finish." })),
840
843
  toolCallId: Type2.Optional(Type2.String({ description: "Command tool-call id." })),
841
844
  view: Type2.Optional(Type2.String({
842
845
  enum: ["fleet", "transcript"],
@@ -4189,7 +4192,7 @@ function resolveReviewThinking(input) {
4189
4192
  function resolveConfiguredModel(ctx, rawModel) {
4190
4193
  const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
4191
4194
  const preferredProvider = typeof ctx.model?.provider === "string" ? ctx.model.provider : void 0;
4192
- const resolved = resolveModelCandidate(rawModel, availableModels, preferredProvider);
4195
+ const resolved = resolveModelCandidate(rawModel, availableModels, preferredProvider, knownModelProviders(ctx.modelRegistry));
4193
4196
  if (!resolved) {
4194
4197
  throw new Error(`Configured watchdog model '${rawModel}' did not match exactly one authenticated available model. Use provider/model or configure credentials for the intended provider.`);
4195
4198
  }
@@ -4399,6 +4402,7 @@ async function runWatchdogAttempt(ctx, request, options) {
4399
4402
  hasDiff: diffBaseline !== void 0
4400
4403
  });
4401
4404
  const agent2 = new Agent({
4405
+ sessionId,
4402
4406
  initialState: {
4403
4407
  systemPrompt,
4404
4408
  model: selection.model,
@@ -8,7 +8,7 @@ import {
8
8
  validateCodeOwnedProfileRunner,
9
9
  validatePermissionRules,
10
10
  validateToolBudgetConfig
11
- } from "./chunk-QGO6HXHG.js";
11
+ } from "./chunk-4MVDMA5C.js";
12
12
 
13
13
  // src/agents/runtime-agent-registry.ts
14
14
  var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  registerRuntimeAgent
3
- } from "./chunk-NAFLUJ26.js";
3
+ } from "./chunk-KXW62VBU.js";
4
4
 
5
5
  // src/agents/runtime-agent-events.ts
6
6
  var RUNTIME_AGENT_REGISTER_EVENT = "pi-subagents:runtime-agent-register:v1";
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  rewriteSubagentPrompt
3
- } from "./chunk-GLVJMI6R.js";
3
+ } from "./chunk-TDJKY2NE.js";
4
4
  import {
5
5
  package_default
6
- } from "./chunk-7ZUFN6ME.js";
6
+ } from "./chunk-CKLZ5FGU.js";
7
7
  import {
8
8
  WATCHDOG_DIFF_TOOL_NAME,
9
9
  captureWatchdogDiffBaseline,
10
10
  createWatchdogDiffTool
11
- } from "./chunk-CJHFDQFJ.js";
12
- import "./chunk-BGXEAYUM.js";
13
- import "./chunk-ZPY5QZCS.js";
11
+ } from "./chunk-JYHTDTOZ.js";
12
+ import "./chunk-SVIXQDIV.js";
13
+ import "./chunk-CYKNHFXB.js";
14
14
  import {
15
15
  MODEL_ONLY_TOOL
16
16
  } from "./chunk-HXRB42AF.js";
17
- import "./chunk-NF7IEKBH.js";
17
+ import "./chunk-W2BZS6UC.js";
18
18
  import {
19
19
  appendAgentRefinementOverlay
20
- } from "./chunk-LGINOOY5.js";
21
- import "./chunk-GJGTMLPE.js";
20
+ } from "./chunk-XIA5GSEU.js";
21
+ import "./chunk-3DT5X2QC.js";
22
22
  import "./chunk-NIXWDZZV.js";
23
- import "./chunk-77ASNIEM.js";
23
+ import "./chunk-47ZN7NKR.js";
24
24
  import "./chunk-7F6RKT6W.js";
25
25
  import {
26
26
  assertNoToolModifierEntries
27
- } from "./chunk-374MZFF4.js";
27
+ } from "./chunk-3MFYKBKI.js";
28
28
  import "./chunk-CTPAE36Y.js";
29
- import "./chunk-GRJHIXYF.js";
29
+ import "./chunk-YDZ7BZD5.js";
30
30
  import {
31
31
  HERDR_PI_MAX_FRAME_BYTES,
32
32
  HERDR_PI_PROTOCOL,
@@ -43,7 +43,7 @@ import {
43
43
  discoverAgents,
44
44
  resolveExistingReadPaths,
45
45
  resolveSkills
46
- } from "./chunk-QGO6HXHG.js";
46
+ } from "./chunk-4MVDMA5C.js";
47
47
  import "./chunk-JEZOSEWG.js";
48
48
  import "./chunk-YFCK7H2S.js";
49
49
  import "./chunk-QXASAHIA.js";
@@ -4,13 +4,13 @@ import {
4
4
  remoteShellCommand,
5
5
  runBoundedCommand,
6
6
  sshMachineAccess
7
- } from "./chunk-YK3QYNLE.js";
7
+ } from "./chunk-GDR2ILWY.js";
8
8
  import {
9
9
  package_default
10
- } from "./chunk-7ZUFN6ME.js";
10
+ } from "./chunk-CKLZ5FGU.js";
11
11
  import {
12
12
  ensureSupervisorChannelDir
13
- } from "./chunk-ZPY5QZCS.js";
13
+ } from "./chunk-CYKNHFXB.js";
14
14
  import "./chunk-HXRB42AF.js";
15
15
  import "./chunk-NIXWDZZV.js";
16
16
  import {
@@ -34,7 +34,7 @@ import {
34
34
  resolveRexBinary,
35
35
  rexCommandEnv,
36
36
  rexGlobalArgs
37
- } from "./chunk-QGO6HXHG.js";
37
+ } from "./chunk-4MVDMA5C.js";
38
38
  import "./chunk-JEZOSEWG.js";
39
39
  import "./chunk-YFCK7H2S.js";
40
40
  import "./chunk-QXASAHIA.js";
@@ -1305,17 +1305,22 @@ function createPlacedPiSession(launch) {
1305
1305
  return launch.machine?.provider === "rex" ? createRexPiSession(launch) : createHerdrPiSession(launch);
1306
1306
  }
1307
1307
  function createPlacementAwareChildSessionFactory(local, createRemote = createPlacedPiSession) {
1308
- const remote = /* @__PURE__ */ new Set();
1308
+ const remote = /* @__PURE__ */ new Map();
1309
1309
  return { async create(launch) {
1310
1310
  if (!launch.machine) return local.create(launch);
1311
1311
  serializeHerdrPiLaunch(launch);
1312
1312
  const child = await createRemote(launch);
1313
- remote.add(child);
1313
+ remote.set(child, launch.parentSessionFile);
1314
1314
  return child;
1315
1315
  }, async dispose() {
1316
- await Promise.allSettled([...remote].map((child) => child.dispose()));
1316
+ await Promise.allSettled([...remote.keys()].map((child) => child.dispose()));
1317
1317
  remote.clear();
1318
1318
  await local.dispose();
1319
+ }, async disposeForParent(parentSessionFile) {
1320
+ const matching = [...remote].filter(([, parent]) => parent === parentSessionFile).map(([child]) => child);
1321
+ await Promise.allSettled(matching.map((child) => child.dispose()));
1322
+ for (const child of matching) remote.delete(child);
1323
+ await local.disposeForParent(parentSessionFile);
1319
1324
  } };
1320
1325
  }
1321
1326
  export {
@@ -12,7 +12,7 @@ import {
12
12
  summarizeContextModes,
13
13
  utf8Tail,
14
14
  workflowPreflightLaneForRuntimeKey
15
- } from "./chunk-BGXEAYUM.js";
15
+ } from "./chunk-SVIXQDIV.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-GJGTMLPE.js";
37
+ } from "./chunk-3DT5X2QC.js";
38
38
  import {
39
39
  deliverStopRequest,
40
40
  stopInboxClosedPath
41
- } from "./chunk-5H4BICQZ.js";
41
+ } from "./chunk-W6HIYD2Z.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-QGO6HXHG.js";
53
+ } from "./chunk-4MVDMA5C.js";
54
54
  import {
55
55
  DIRS
56
56
  } from "./chunk-JEZOSEWG.js";
@@ -937,13 +937,19 @@ function deliverAsyncRunStop(input) {
937
937
  if (!(pausedWholeRun && fs5.existsSync(stopInboxClosedPath(delivery.asyncDir)))) deliverStopRequest(delivery);
938
938
  if (pausedWholeRun) return sealPausedRun(delivery.asyncDir, status, resultsDir);
939
939
  }
940
- function stopAsyncRun(state, runId, kill, location, childId) {
940
+ function stopAsyncRun(state, runId, kill, location, childId, drain) {
941
941
  const target = getAsyncStopTarget(state, runId, location);
942
942
  const workflowRunId = target?.asyncId ?? runId;
943
943
  const workflowController = childId === void 0 && workflowRunId ? state.workflowControllers?.get(workflowRunId) : void 0;
944
944
  const workflowAsyncDir = workflowController && workflowRunId ? target?.asyncDir ?? state.asyncJobs.get(workflowRunId)?.asyncDir : void 0;
945
945
  const workflowStatus = workflowAsyncDir ? readStatus(workflowAsyncDir) : void 0;
946
946
  const foreignWorkflow = Boolean(state.currentSessionId && workflowStatus && workflowStatus.sessionId !== state.currentSessionId);
947
+ if (drain) {
948
+ const drained = workflowController && workflowRunId && !foreignWorkflow && !workflowController.signal.aborted ? state.workflowDrains?.get(workflowRunId)?.() : void 0;
949
+ if (!drained) return { content: [{ type: "text", text: `drain applies only to live async workflows in this session; '${runId ?? "current"}' is not one.` }], isError: true, details: { mode: "management", results: [] } };
950
+ if (!drained.ok) return { content: [{ type: "text", text: `Could not save the drain request for '${workflowRunId}'; nothing was stopped. Retry, or use stop without drain.` }], isError: true, details: { mode: "management", results: [] } };
951
+ return { content: [{ type: "text", text: `Drain requested for async workflow ${workflowRunId}: no new children will start; ${drained.started} started child(ren) will finish.` }], details: { mode: "management", results: [] } };
952
+ }
947
953
  if (workflowController && workflowRunId && !foreignWorkflow) {
948
954
  if (workflowStatus) stopStoppableAsyncStatusChildren(workflowStatus, state.workflowChildStops?.get(workflowRunId), "Workflow stopped.");
949
955
  workflowController.abort(new Error("Workflow stopped."));
@@ -46,16 +46,19 @@ import {
46
46
  validateModelResponseAliases,
47
47
  withWorkflowChildRunModel,
48
48
  withWorktreeTransaction
49
- } from "./chunk-GJGTMLPE.js";
49
+ } from "./chunk-3DT5X2QC.js";
50
50
  import {
51
51
  validateIntercomBridgeConfig
52
- } from "./chunk-77ASNIEM.js";
52
+ } from "./chunk-47ZN7NKR.js";
53
53
  import {
54
54
  stableJsonDigest
55
55
  } from "./chunk-7F6RKT6W.js";
56
56
  import {
57
57
  snapshotRequiredChildExtensions
58
58
  } from "./chunk-CTPAE36Y.js";
59
+ import {
60
+ missingForkCopyNote
61
+ } from "./chunk-YDZ7BZD5.js";
59
62
  import {
60
63
  DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
61
64
  assertWorkflowLaneKey,
@@ -80,7 +83,7 @@ import {
80
83
  validateToolBudgetConfig,
81
84
  waitForFileSystemRetry,
82
85
  writeAtomicJson
83
- } from "./chunk-QGO6HXHG.js";
86
+ } from "./chunk-4MVDMA5C.js";
84
87
  import {
85
88
  DIRS,
86
89
  RUNNER_LAUNCHER_NAME_PATTERN,
@@ -1241,6 +1244,8 @@ function projectStep(step, index, depth, ctx) {
1241
1244
  const activity = activityFor(step, ctx);
1242
1245
  const { id, label } = stepIdentity(step, index, ctx);
1243
1246
  const agent = publicOptionalText(step.agent, ctx.caps.maxStringLength);
1247
+ const progressText = publicOptionalText(step.progressText, ctx.caps.maxStringLength);
1248
+ const progressUpdatedAt = publicTime(step.progressUpdatedAt);
1244
1249
  const node = {
1245
1250
  id,
1246
1251
  kind: "step",
@@ -1249,7 +1254,9 @@ function projectStep(step, index, depth, ctx) {
1249
1254
  ...startedAt !== void 0 ? { startedAt } : {},
1250
1255
  ...updatedAt !== void 0 ? { updatedAt } : {},
1251
1256
  ...terminalState(state) && endedAt !== void 0 ? { endedAt } : {},
1252
- ...activity ? { activity } : {}
1257
+ ...activity ? { activity } : {},
1258
+ ...progressText ? { progressText } : {},
1259
+ ...progressUpdatedAt !== void 0 ? { progressUpdatedAt } : {}
1253
1260
  };
1254
1261
  if (agent) node.agent = agent;
1255
1262
  setStepModel(node, ctx, step);
@@ -1392,6 +1399,10 @@ function projectMaterializedStep(step, index, child, depth, ctx, childrenByParen
1392
1399
  const selfActivity = selfStep ? activityFor(selfStep, ctx) : void 0;
1393
1400
  const activity = laneActivity || selfActivity || live.activity ? { ...laneActivity, ...selfActivity, ...live.activity } : void 0;
1394
1401
  const node = { ...live, id, kind: "step", label };
1402
+ const progressText = publicOptionalText(selfStep?.progressText ?? step.progressText, ctx.caps.maxStringLength);
1403
+ const progressUpdatedAt = publicTime(selfStep?.progressUpdatedAt ?? step.progressUpdatedAt);
1404
+ if (progressText) node.progressText = progressText;
1405
+ if (progressUpdatedAt !== void 0) node.progressUpdatedAt = progressUpdatedAt;
1395
1406
  const agent = publicOptionalText(selfStep?.agent || step.agent, ctx.caps.maxStringLength);
1396
1407
  if (agent) node.agent = agent;
1397
1408
  if (activity) node.activity = activity;
@@ -2291,6 +2302,8 @@ function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
2291
2302
  ...step.currentPath ? { currentPath: step.currentPath } : {},
2292
2303
  ...step.recentTools ? { recentTools: step.recentTools.map((tool) => ({ ...tool })) } : {},
2293
2304
  ...step.recentOutput ? { recentOutput: [...step.recentOutput] } : {},
2305
+ ...step.progressText ? { progressText: step.progressText } : {},
2306
+ ...step.progressUpdatedAt !== void 0 ? { progressUpdatedAt: step.progressUpdatedAt } : {},
2294
2307
  ...step.turnCount !== void 0 ? { turnCount: step.turnCount } : {},
2295
2308
  ...step.toolCount !== void 0 ? { toolCount: step.toolCount } : {},
2296
2309
  ...step.steering ? { steering: step.steering } : {},
@@ -2556,6 +2569,7 @@ function formatStepLine(step) {
2556
2569
  const modelThinking = formatModelThinking(step.model, step.thinking);
2557
2570
  if (modelThinking) parts.push(modelThinking);
2558
2571
  if (step.durationMs !== void 0) parts.push(formatDuration(step.durationMs));
2572
+ if (step.progressText && step.status === "running") parts.push(`progress: ${step.progressText}`);
2559
2573
  if (step.tokens) parts.push(`${formatTokens(step.tokens.total)} tok`);
2560
2574
  if (step.lane) parts.push(`lane ${step.lane.key}`);
2561
2575
  if (step.worktreePath) parts.push(`worktree ${shortenPath(step.worktreePath)} \xB7 branch ${step.branch ?? "unknown"}${step.provider ? ` \xB7 provider ${step.provider}` : ""}`);
@@ -3883,7 +3897,7 @@ function launchedWorktreeCwdWithoutHandoff(runId, launchCwd, launched) {
3883
3897
  function validateResumeSessionFile(runId, sessionFile) {
3884
3898
  if (path8.extname(sessionFile) !== ".jsonl") throw new Error(`Async run '${runId}' session file must be a .jsonl file: ${sessionFile}`);
3885
3899
  const resolved = path8.resolve(sessionFile);
3886
- if (!fs7.existsSync(resolved)) throw new Error(`Async run '${runId}' session file does not exist: ${sessionFile}`);
3900
+ if (!fs7.existsSync(resolved)) throw new Error(`Async run '${runId}' session file does not exist: ${sessionFile}${missingForkCopyNote(resolved)}`);
3887
3901
  return resolved;
3888
3902
  }
3889
3903
  function validateResumeCwd(runId, cwd) {
@@ -4109,6 +4123,7 @@ function opencodeSessionHeaders(model, sessionId) {
4109
4123
  export {
4110
4124
  agentStreamOptions,
4111
4125
  opencodeSessionHeaders,
4126
+ formatActivityAge,
4112
4127
  formatActivityLabel,
4113
4128
  aggregateStepStatus,
4114
4129
  formatAgentRunningLabel,
@@ -14,20 +14,20 @@ import {
14
14
  resolveCurrentSessionId,
15
15
  resolveWatchdogReviewModel,
16
16
  startWatchdogDiffBaselineCapture
17
- } from "./chunk-CJHFDQFJ.js";
17
+ } from "./chunk-JYHTDTOZ.js";
18
18
  import {
19
19
  agentStreamOptions,
20
20
  opencodeSessionHeaders
21
- } from "./chunk-BGXEAYUM.js";
21
+ } from "./chunk-SVIXQDIV.js";
22
22
  import {
23
23
  registerNativeSupervisorClient
24
- } from "./chunk-ZPY5QZCS.js";
24
+ } from "./chunk-CYKNHFXB.js";
25
25
  import {
26
26
  MODEL_ONLY_TOOL
27
27
  } from "./chunk-HXRB42AF.js";
28
28
  import {
29
29
  inheritedNestedRouteOf
30
- } from "./chunk-GJGTMLPE.js";
30
+ } from "./chunk-3DT5X2QC.js";
31
31
  import {
32
32
  CHILD_WATCHDOG_STATUS_EVENT,
33
33
  DEFAULT_WAIT_TOOL_NAME,
@@ -46,7 +46,7 @@ import {
46
46
  toolBudgetSoftNudge,
47
47
  validateAcceptanceReport,
48
48
  validateStructuredOutputValue
49
- } from "./chunk-QGO6HXHG.js";
49
+ } from "./chunk-4MVDMA5C.js";
50
50
  import {
51
51
  INTERCOM_SESSION_IDENTITY_EVENT
52
52
  } from "./chunk-JEZOSEWG.js";
@@ -295,6 +295,7 @@ function createWatchdogPermissionArbiter(options = {}) {
295
295
  ].join("\n");
296
296
  const tools = [tool];
297
297
  agent = new Agent({
298
+ sessionId,
298
299
  initialState: {
299
300
  systemPrompt,
300
301
  model: selection.model,
@@ -584,6 +585,11 @@ function modelBefore(messages, forkedAt) {
584
585
  return void 0;
585
586
  }
586
587
  var LOADOUT_SECTIONS = /* @__PURE__ */ new Set(["tools", "rules", "docs", "skills", "advertised_subagents", "mcp_servers", "project_context"]);
588
+ function projectInstructionBlocks(section) {
589
+ const blocks = /* @__PURE__ */ new Map();
590
+ for (const match of (section ?? "").matchAll(/<project_instructions\s+path=(["'])(.*?)\1\s*>[\s\S]*?<\/project_instructions>/gi)) blocks.set(match[2], match[0]);
591
+ return blocks;
592
+ }
587
593
  function forkInstructions(input) {
588
594
  const parent = getCurrentSystemMessage(input.parent);
589
595
  const child = getCurrentSystemMessage(input.child);
@@ -596,6 +602,9 @@ function forkInstructions(input) {
596
602
  for (const [name, value] of Object.entries(child?.sections ?? {})) {
597
603
  if (!LOADOUT_SECTIONS.has(name) && value && parent?.sections?.[name] !== value) parts.push(value);
598
604
  }
605
+ const parentFiles = projectInstructionBlocks(parent?.sections?.project_context);
606
+ const missingFiles = [...projectInstructionBlocks(child?.sections?.project_context)].filter(([filePath]) => !parentFiles.has(filePath)).map(([, block]) => block);
607
+ if (missingFiles.length > 0) parts.push(["Project instructions for your working folder, which the parent's prompt does not include:", ...missingFiles].join("\n\n"));
599
608
  if (input.boundary) parts.push(input.boundary);
600
609
  return `<subagent_instructions>
601
610
  ${parts.join("\n\n")}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  appendAgentRefinementOverlay
3
- } from "./chunk-LGINOOY5.js";
3
+ } from "./chunk-XIA5GSEU.js";
4
4
  import {
5
5
  buildAgentMemoryInjection,
6
6
  buildSkillInjection
7
- } from "./chunk-QGO6HXHG.js";
7
+ } from "./chunk-4MVDMA5C.js";
8
8
 
9
9
  // src/runs/shared/effective-system-prompt.ts
10
10
  function appendSection(prompt, section) {
@@ -112,7 +112,21 @@ import { randomUUID } from "node:crypto";
112
112
  var OUTPUT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
113
113
  var PLACEHOLDER_PATTERN = /\{(?:task|previous|outputs\.([A-Za-z_][A-Za-z0-9_]*))\}/g;
114
114
  var CHILD_FIELDS = ["cwd", "model"];
115
- var TOP_LEVEL_CONTROLS_HINT = " Put worktree and other child controls on the subagent call itself; they apply to every child.";
115
+ var SHARED_CHILD_CONTROLS = /* @__PURE__ */ new Set(["worktree", "baseRef", "context", "skill", "fast", "agentScope", "outputMode", "outputSchema", "agentContract", "acceptance", "gate", "toolBudget", "toolTimeoutMs", "control"]);
116
+ var SCRIPT_CHILD_FIELDS = /* @__PURE__ */ new Set(["key", "label", "phase", "resume", "async", "timeoutMs"]);
117
+ function unsupportedChildFieldAdvice(fields, scripts) {
118
+ const perChild = scripts ? "use workflow: true with runs.all items" : "you need workflow scripts, which disabledFeatures has turned off";
119
+ const advice = [];
120
+ const itemFields = fields.filter((field) => CHILD_FIELDS.includes(field));
121
+ if (itemFields.length > 0) advice.push(`Set ${itemFields.join(", ")} on each item, or on the subagent call itself to give every child the same value.`);
122
+ if (fields.includes("output")) advice.push(`For one shared output, set output on the subagent call itself: the workflow result is written there and each child gets its own file beside it. For exact or different per-child paths, ${perChild}. Do not drop output if you need durable child files.`);
123
+ const shared = fields.filter((field) => SHARED_CHILD_CONTROLS.has(field));
124
+ if (shared.length > 0) advice.push(`Set ${shared.join(", ")} on the subagent call itself to give every child the same value; for different values per child, ${perChild}.`);
125
+ const scriptOnly = fields.filter((field) => SCRIPT_CHILD_FIELDS.has(field));
126
+ if (scriptOnly.length > 0) advice.push(`For per-child ${scriptOnly.join(", ")}, ${perChild}.`);
127
+ advice.push("No child was launched.");
128
+ return advice.join(" ");
129
+ }
116
130
  function isPlainRecord(value) {
117
131
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
118
132
  const prototype = Object.getPrototypeOf(value);
@@ -122,10 +136,10 @@ function nonEmptyString(value, path) {
122
136
  if (typeof value !== "string" || !value.trim()) throw new Error(`${path} must be a non-empty string.`);
123
137
  return value;
124
138
  }
125
- function exactFields(value, path, allowed, hint) {
139
+ function exactFields(value, path, allowed, hint, scripts) {
126
140
  if (!isPlainRecord(value)) throw new Error(`${path} must be an object.`);
127
141
  const unsupported = Object.keys(value).filter((key) => !allowed.includes(key));
128
- if (unsupported.length > 0) throw new Error(`${path} contains unsupported fields: ${unsupported.join(", ")}. ${hint}`);
142
+ if (unsupported.length > 0) throw new Error(`${path} contains unsupported fields: ${unsupported.join(", ")}. ${hint} ${unsupportedChildFieldAdvice(unsupported, scripts)}`);
129
143
  return value;
130
144
  }
131
145
  function compileTemplate(template, scope) {
@@ -184,11 +198,11 @@ var SETTLE_HELPER = [
184
198
  ' return new Error(label + ": " + children.filter(function (child) { return !child.ok; }).map(function (child) { return child.key + " (" + child.agent + ") failed" + (child.error ? ": " + child.error : ""); }).join("; "));',
185
199
  "}"
186
200
  ].join("\n");
187
- function buildTasksScript(steps, originalTask) {
201
+ function buildTasksScript(steps, originalTask, scripts) {
188
202
  if (!Array.isArray(steps) || steps.length === 0) throw new Error("tasks must be a non-empty array of { agent, task } items.");
189
203
  const children = steps.map((item, index) => {
190
204
  const path = `tasks[${index}]`;
191
- const record = exactFields(item, path, ["agent", "task", ...CHILD_FIELDS], `Each tasks item accepts agent and task, plus optional cwd and model.${TOP_LEVEL_CONTROLS_HINT}`);
205
+ const record = exactFields(item, path, ["agent", "task", ...CHILD_FIELDS], "Each tasks item accepts agent and task, plus optional cwd and model.", scripts);
192
206
  const agent = nonEmptyString(record.agent, `${path}.agent`);
193
207
  const task = nonEmptyString(record.task, `${path}.task`);
194
208
  const taskExpression = compileTemplate(task, {
@@ -219,18 +233,18 @@ function buildChainScript(steps, originalTask) {
219
233
  let stepChildren;
220
234
  let outputName;
221
235
  if (isPlainRecord(step) && Object.hasOwn(step, "parallel")) {
222
- const record = exactFields(step, path, ["parallel"], `A parallel step accepts only parallel; as is supported on sequential steps only.${TOP_LEVEL_CONTROLS_HINT}`);
236
+ const record = exactFields(step, path, ["parallel"], "A parallel step accepts only parallel; as is supported on sequential steps only.", false);
223
237
  const items = record.parallel;
224
238
  if (!Array.isArray(items) || items.length === 0) throw new Error(`${path}.parallel must be a non-empty array of { agent, task } items.`);
225
239
  stepChildren = items.map((item, itemIndex) => {
226
240
  const itemPath = `${path}.parallel[${itemIndex}]`;
227
- const itemRecord = exactFields(item, itemPath, ["agent", "task", ...CHILD_FIELDS], `Each parallel item accepts agent and task, plus optional cwd and model.${TOP_LEVEL_CONTROLS_HINT}`);
241
+ const itemRecord = exactFields(item, itemPath, ["agent", "task", ...CHILD_FIELDS], "Each parallel item accepts agent and task, plus optional cwd and model.", false);
228
242
  const agent = nonEmptyString(itemRecord.agent, `${itemPath}.agent`);
229
243
  const task = nonEmptyString(itemRecord.task, `${itemPath}.task`);
230
244
  return { key: `step-${number}-${itemIndex + 1}`, agent, fields: childFields(itemRecord, itemPath), taskExpression: compileTemplate(task, { path: `${itemPath}.task`, hasOriginalTask, previous, outputs }) };
231
245
  });
232
246
  } else {
233
- const record = exactFields(step, path, ["agent", "task", "as", ...CHILD_FIELDS], `A sequential step accepts agent, task, as, cwd and model; a parallel step accepts only parallel.${TOP_LEVEL_CONTROLS_HINT}`);
247
+ const record = exactFields(step, path, ["agent", "task", "as", ...CHILD_FIELDS], "A sequential step accepts agent, task, as, cwd and model; a parallel step accepts only parallel.", false);
234
248
  const agent = nonEmptyString(record.agent, `${path}.agent`);
235
249
  let task;
236
250
  if (record.task === void 0) {
@@ -256,8 +270,8 @@ function buildChainScript(steps, originalTask) {
256
270
  lines.push("return { ok: true, children };");
257
271
  return lines.join("\n");
258
272
  }
259
- function buildStructuredWorkflowScript(kind, steps, originalTask) {
260
- return kind === "tasks" ? buildTasksScript(steps, originalTask) : buildChainScript(steps, originalTask);
273
+ function buildStructuredWorkflowScript(kind, steps, originalTask, scripts) {
274
+ return kind === "tasks" ? buildTasksScript(steps, originalTask, scripts) : buildChainScript(steps, originalTask);
261
275
  }
262
276
 
263
277
  // src/workflows/workflow-resources.ts
@@ -375,9 +389,9 @@ function resolveRunCi(args) {
375
389
  }
376
390
  function resolveParallel(args) {
377
391
  const unsupported = Object.keys(args).filter((key) => key !== "tasks");
378
- if (unsupported.length > 0) return { error: `workflow 'parallel' args contain unsupported fields: ${unsupported.join(", ")}. Pass args.tasks: [{ agent, task, cwd?, model? }, ...].${TOP_LEVEL_CONTROLS_HINT}` };
392
+ if (unsupported.length > 0) return { error: `workflow 'parallel' args contain unsupported fields: ${unsupported.join(", ")}. Pass args.tasks: [{ agent, task, cwd?, model? }, ...]. ${unsupportedChildFieldAdvice(unsupported, true)}` };
379
393
  try {
380
- return { script: buildStructuredWorkflowScript("tasks", args.tasks, void 0) };
394
+ return { script: buildStructuredWorkflowScript("tasks", args.tasks, void 0, true) };
381
395
  } catch (error) {
382
396
  return { error: `workflow 'parallel' args.${error instanceof Error ? error.message : String(error)}` };
383
397
  }
@@ -415,7 +429,7 @@ function resolveStructuredWorkflowResource(input) {
415
429
  validatePlainJson(task, "task");
416
430
  }
417
431
  if (jsonByteLength({ [kind]: steps, task }) > MAX_ARGS_BYTES) return { ok: false, error: `${kind} input exceeds ${MAX_ARGS_BYTES} bytes.` };
418
- const script = buildStructuredWorkflowScript(kind, JSON.parse(JSON.stringify(steps)), task);
432
+ const script = buildStructuredWorkflowScript(kind, JSON.parse(JSON.stringify(steps)), task, false);
419
433
  return { ok: true, resource: issueWorkflowResource(kind, STRUCTURED_WORKFLOW_RESOURCE_VERSION, script) };
420
434
  } catch (error) {
421
435
  return { ok: false, error: error instanceof Error ? error.message.slice(0, 4096) : "Structured workflow resolution failed." };
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  resolveWatchPath,
6
6
  writeAtomicJson
7
- } from "./chunk-QGO6HXHG.js";
7
+ } from "./chunk-4MVDMA5C.js";
8
8
  import {
9
9
  POLL_INTERVAL_MS
10
10
  } from "./chunk-JEZOSEWG.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getProjectSubagentsDir
3
- } from "./chunk-GRJHIXYF.js";
3
+ } from "./chunk-YDZ7BZD5.js";
4
4
  import {
5
5
  discoverAgents,
6
6
  formatUnknownAgentError,
7
7
  resolveAgentName,
8
8
  unknownAgentDiagnosticContext
9
- } from "./chunk-QGO6HXHG.js";
9
+ } from "./chunk-4MVDMA5C.js";
10
10
 
11
11
  // src/agents/agent-refinements.ts
12
12
  import { createHash, randomUUID } from "node:crypto";