@xzzpig/pi-subagents 0.24.2 → 0.25.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 (258) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bundle/agent-management.js +4 -4
  3. package/bundle/agents.js +3 -3
  4. package/bundle/child-tool-plan.js +2 -2
  5. package/bundle/chunk-34TUUBRN.js +1107 -0
  6. package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
  7. package/bundle/{chunk-XWWUDWUW.js → chunk-5YEOWNSD.js} +371 -135
  8. package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
  9. package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
  10. package/bundle/{chunk-4UH4WS4G.js → chunk-6MNRKUHY.js} +23 -12
  11. package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
  12. package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
  13. package/bundle/chunk-HXRB42AF.js +108 -0
  14. package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
  15. package/bundle/{chunk-CYY5UMJU.js → chunk-IJWITCC6.js} +411 -249
  16. package/bundle/{chunk-RU522D5W.js → chunk-IKFKH5EL.js} +369 -50
  17. package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
  18. package/bundle/{chunk-JEA2ZKUA.js → chunk-IUDEI6FJ.js} +35 -200
  19. package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
  20. package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
  21. package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
  22. package/bundle/{chunk-224WMDIV.js → chunk-KCJFGKVK.js} +350 -123
  23. package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
  24. package/bundle/chunk-LYKG4FKH.js +523 -0
  25. package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
  26. package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
  27. package/bundle/{chunk-BQ2OAB4Q.js → chunk-OSVXFWPG.js} +67 -30
  28. package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
  29. package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
  30. package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
  31. package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
  32. package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
  33. package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
  34. package/bundle/{chunk-O4D5PBVI.js → chunk-YWXILP5N.js} +3 -2
  35. package/bundle/control-channel.js +2 -2
  36. package/bundle/index.js +1 -1
  37. package/bundle/intercom-bridge.js +2 -2
  38. package/bundle/preflight.js +12 -10
  39. package/bundle/project-panes.js +3 -3
  40. package/bundle/workflow-resources.js +1 -1
  41. package/docs/agents.md +27 -6
  42. package/docs/configuration.md +20 -8
  43. package/docs/extension-api.md +18 -1
  44. package/docs/models.md +6 -2
  45. package/docs/observability.md +2 -0
  46. package/docs/tool-reference.md +7 -1
  47. package/docs/workflows.md +30 -2
  48. package/package.json +2 -2
  49. package/skills/pi-subagents/SKILL.md +15 -6
  50. package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
  51. package/src/agents/agent-management.d.ts +1 -0
  52. package/src/agents/agent-management.js +46 -18
  53. package/src/agents/agent-memory.d.ts +1 -4
  54. package/src/agents/agent-memory.js +1 -4
  55. package/src/agents/agent-serializer.d.ts +2 -0
  56. package/src/agents/agent-serializer.js +1 -1
  57. package/src/agents/agents.d.ts +2 -3
  58. package/src/agents/agents.js +46 -20
  59. package/src/agents/frontmatter.js +1 -8
  60. package/src/agents/global-npm-root.d.ts +1 -0
  61. package/src/agents/global-npm-root.js +11 -3
  62. package/src/agents/skills.d.ts +0 -3
  63. package/src/agents/skills.js +0 -3
  64. package/src/api/preflight.d.ts +3 -1
  65. package/src/api/preflight.js +2 -0
  66. package/src/extension/config.d.ts +1 -0
  67. package/src/extension/config.js +13 -1
  68. package/src/extension/herdr-pi-bridge.js +10 -2
  69. package/src/extension/index.d.ts +0 -13
  70. package/src/extension/index.js +51 -37
  71. package/src/extension/public-execution.d.ts +1 -0
  72. package/src/extension/public-execution.js +4 -0
  73. package/src/extension/reply-workflow-script.js +24 -4
  74. package/src/extension/schemas.d.ts +12 -3
  75. package/src/extension/schemas.js +7 -3
  76. package/src/extension/session-switch.d.ts +25 -0
  77. package/src/extension/session-switch.js +138 -0
  78. package/src/extension/subagent-guide.d.ts +1 -1
  79. package/src/extension/subagent-guide.js +1 -1
  80. package/src/extension/subagent-launch-tool.d.ts +25 -0
  81. package/src/extension/subagent-launch-tool.js +48 -0
  82. package/src/extension/tool-activation.js +55 -15
  83. package/src/extension/tool-description.d.ts +1 -1
  84. package/src/extension/tool-description.js +14 -8
  85. package/src/inspectors/herdr/actions.d.ts +0 -1
  86. package/src/inspectors/herdr/actions.js +0 -1
  87. package/src/inspectors/session-roots-codec.d.ts +0 -1
  88. package/src/inspectors/session-roots-codec.js +0 -1
  89. package/src/inspectors/tmux/actions.d.ts +0 -1
  90. package/src/inspectors/tmux/actions.js +0 -1
  91. package/src/integrations/herdr-status.js +3 -8
  92. package/src/intercom/native-supervisor-channel.js +65 -9
  93. package/src/runs/background/async-execution.d.ts +7 -10
  94. package/src/runs/background/async-execution.js +66 -29
  95. package/src/runs/background/async-job-tracker.js +12 -0
  96. package/src/runs/background/async-resume.d.ts +2 -1
  97. package/src/runs/background/async-resume.js +114 -40
  98. package/src/runs/background/async-retention.d.ts +0 -2
  99. package/src/runs/background/async-retention.js +17 -6
  100. package/src/runs/background/async-status.d.ts +2 -0
  101. package/src/runs/background/async-status.js +4 -0
  102. package/src/runs/background/auto-drain.js +2 -1
  103. package/src/runs/background/boot-id.d.ts +1 -3
  104. package/src/runs/background/boot-id.js +1 -3
  105. package/src/runs/background/completion-batcher.d.ts +3 -4
  106. package/src/runs/background/completion-batcher.js +2 -3
  107. package/src/runs/background/control-channel.d.ts +0 -6
  108. package/src/runs/background/control-channel.js +0 -6
  109. package/src/runs/background/fleet-view.js +2 -3
  110. package/src/runs/background/notify.d.ts +0 -2
  111. package/src/runs/background/notify.js +0 -2
  112. package/src/runs/background/result-watcher.d.ts +1 -0
  113. package/src/runs/background/result-watcher.js +59 -29
  114. package/src/runs/background/resume-guidance.js +4 -2
  115. package/src/runs/background/retained-children.js +2 -1
  116. package/src/runs/background/run-child-session.d.ts +2 -3
  117. package/src/runs/background/run-child-session.js +5 -8
  118. package/src/runs/background/run-status.js +9 -7
  119. package/src/runs/background/runner-aliases.js +15 -0
  120. package/src/runs/background/scheduled-runs.d.ts +3 -1
  121. package/src/runs/background/scheduled-runs.js +13 -16
  122. package/src/runs/background/steering.d.ts +2 -11
  123. package/src/runs/background/steering.js +11 -6
  124. package/src/runs/background/subagent-runner.d.ts +2 -6
  125. package/src/runs/background/subagent-runner.js +88 -70
  126. package/src/runs/background/subagent-wait.js +12 -15
  127. package/src/runs/background/wait-config.d.ts +2 -0
  128. package/src/runs/background/wait-config.js +17 -3
  129. package/src/runs/background/wait-subscriptions.js +124 -12
  130. package/src/runs/background/wait-tool.js +4 -2
  131. package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
  132. package/src/runs/background/workflow-terminal-proof.js +0 -1
  133. package/src/runs/foreground/async-steering-action.js +24 -9
  134. package/src/runs/foreground/async-stop-action.d.ts +1 -1
  135. package/src/runs/foreground/async-stop-action.js +9 -1
  136. package/src/runs/foreground/execution.d.ts +0 -3
  137. package/src/runs/foreground/execution.js +56 -24
  138. package/src/runs/foreground/prompt-audit.js +1 -0
  139. package/src/runs/foreground/subagent-executor.d.ts +5 -10
  140. package/src/runs/foreground/subagent-executor.js +164 -49
  141. package/src/runs/shared/acceptance.js +69 -26
  142. package/src/runs/shared/async-status-projection.d.ts +2 -0
  143. package/src/runs/shared/async-status-projection.js +10 -0
  144. package/src/runs/shared/child-commands.js +15 -2
  145. package/src/runs/shared/child-hooks.d.ts +1 -7
  146. package/src/runs/shared/child-hooks.js +13 -5
  147. package/src/runs/shared/child-launch.js +6 -2
  148. package/src/runs/shared/child-runtime-config.d.ts +0 -1
  149. package/src/runs/shared/child-session.d.ts +6 -5
  150. package/src/runs/shared/child-session.js +85 -38
  151. package/src/runs/shared/child-tool-plan.d.ts +0 -1
  152. package/src/runs/shared/child-tool-plan.js +0 -1
  153. package/src/runs/shared/claude-code-adapter.js +11 -0
  154. package/src/runs/shared/external-cli-contract.d.ts +49 -0
  155. package/src/runs/shared/external-cli-contract.js +18 -13
  156. package/src/runs/shared/external-cli-runner.js +26 -6
  157. package/src/runs/shared/herdr-connection.js +2 -1
  158. package/src/runs/shared/herdr-pane-host.d.ts +2 -2
  159. package/src/runs/shared/herdr-pane-host.js +17 -1
  160. package/src/runs/shared/herdr-placed-run.js +51 -24
  161. package/src/runs/shared/lane-metadata.d.ts +0 -1
  162. package/src/runs/shared/lane-metadata.js +0 -1
  163. package/src/runs/shared/mcp-config-sources.d.ts +4 -1
  164. package/src/runs/shared/mcp-config-sources.js +1 -1
  165. package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
  166. package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
  167. package/src/runs/shared/mcp-direct-tool-grant.js +8 -1
  168. package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
  169. package/src/runs/shared/model-resolution.d.ts +20 -5
  170. package/src/runs/shared/model-resolution.js +55 -50
  171. package/src/runs/shared/model-scope.d.ts +1 -5
  172. package/src/runs/shared/model-scope.js +1 -5
  173. package/src/runs/shared/mutation-evidence.d.ts +1 -1
  174. package/src/runs/shared/mutation-evidence.js +52 -7
  175. package/src/runs/shared/nested-events.d.ts +1 -0
  176. package/src/runs/shared/nested-events.js +1 -1
  177. package/src/runs/shared/parallel-utils.d.ts +0 -1
  178. package/src/runs/shared/permissions.js +5 -3
  179. package/src/runs/shared/placement-host.d.ts +5 -1
  180. package/src/runs/shared/rex-pane-host.d.ts +0 -1
  181. package/src/runs/shared/rex-pane-host.js +0 -2
  182. package/src/runs/shared/run-launch-folder.d.ts +12 -0
  183. package/src/runs/shared/run-launch-folder.js +21 -0
  184. package/src/runs/shared/runner-launcher.d.ts +12 -1
  185. package/src/runs/shared/runner-launcher.js +16 -0
  186. package/src/runs/shared/single-output.d.ts +3 -3
  187. package/src/runs/shared/single-output.js +5 -3
  188. package/src/runs/shared/structured-output.d.ts +8 -0
  189. package/src/runs/shared/structured-output.js +40 -5
  190. package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
  191. package/src/runs/shared/subagent-prompt-runtime.js +18 -4
  192. package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
  193. package/src/runs/shared/supervisor-wait-timer.js +61 -0
  194. package/src/runs/shared/tool-timeout.js +2 -1
  195. package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
  196. package/src/runs/shared/worktree-cleanup-plan.js +0 -1
  197. package/src/runs/shared/worktree.d.ts +3 -0
  198. package/src/runs/shared/worktree.js +20 -0
  199. package/src/shared/artifacts.d.ts +1 -0
  200. package/src/shared/artifacts.js +132 -22
  201. package/src/shared/capacity-resilient-json.d.ts +1 -1
  202. package/src/shared/child-cache-retention.d.ts +1 -2
  203. package/src/shared/child-cache-retention.js +1 -2
  204. package/src/shared/fleet-transcript-reader.d.ts +51 -0
  205. package/src/shared/fleet-transcript-reader.js +333 -0
  206. package/src/shared/formatters.d.ts +0 -18
  207. package/src/shared/formatters.js +0 -18
  208. package/src/shared/pruned-fork.js +2 -2
  209. package/src/shared/reported-progress.d.ts +1 -0
  210. package/src/shared/reported-progress.js +12 -0
  211. package/src/shared/session-succession.d.ts +16 -1
  212. package/src/shared/session-succession.js +41 -2
  213. package/src/shared/session-warnings.d.ts +7 -0
  214. package/src/shared/session-warnings.js +26 -0
  215. package/src/shared/settings.d.ts +0 -23
  216. package/src/shared/settings.js +3 -35
  217. package/src/shared/status-format.d.ts +1 -0
  218. package/src/shared/status-format.js +1 -1
  219. package/src/shared/types.d.ts +108 -59
  220. package/src/shared/types.js +0 -12
  221. package/src/shared/utils.d.ts +3 -15
  222. package/src/shared/utils.js +4 -22
  223. package/src/shared/wait-tool-name.d.ts +8 -0
  224. package/src/shared/wait-tool-name.js +13 -0
  225. package/src/slash/slash-commands.js +2 -1
  226. package/src/slash/subagent-cost.d.ts +3 -2
  227. package/src/slash/subagent-cost.js +22 -3
  228. package/src/slash/subagents-admin.js +0 -1
  229. package/src/tui/fleet-status.d.ts +0 -5
  230. package/src/tui/fleet-status.js +4 -24
  231. package/src/tui/fleet.js +6 -4
  232. package/src/tui/render.d.ts +0 -9
  233. package/src/tui/render.js +194 -68
  234. package/src/tui/subagent-messages.js +3 -2
  235. package/src/watchdog/model-selection.js +2 -2
  236. package/src/watchdog/permission-arbiter.js +1 -0
  237. package/src/watchdog/register-child.d.ts +2 -3
  238. package/src/watchdog/register-child.js +2 -3
  239. package/src/watchdog/review.d.ts +0 -5
  240. package/src/watchdog/review.js +4 -3
  241. package/src/watchdog/turn-delta.js +2 -1
  242. package/src/workflows/scripted-workflow.d.ts +2 -0
  243. package/src/workflows/scripted-workflow.js +344 -59
  244. package/src/workflows/structured-workflow-scripts.d.ts +4 -3
  245. package/src/workflows/structured-workflow-scripts.js +32 -11
  246. package/src/workflows/workflow-launch-record.d.ts +15 -6
  247. package/src/workflows/workflow-launch-record.js +30 -12
  248. package/src/workflows/workflow-receipt.js +36 -53
  249. package/src/workflows/workflow-resources.js +4 -4
  250. package/src/workflows/workflow-resume-claim.d.ts +2 -0
  251. package/src/workflows/workflow-resume-claim.js +3 -3
  252. package/src/workflows/workflow-resume.d.ts +1 -1
  253. package/src/workflows/workflow-resume.js +13 -8
  254. package/src/workflows/workflow-script-worker.d.ts +13 -0
  255. package/src/workflows/workflow-script-worker.js +81 -0
  256. package/workflow-script-process.cjs +36 -0
  257. package/workflow-script-worker.cjs +4 -1
  258. package/bundle/chunk-U4ODUYAG.js +0 -235
@@ -1,12 +1,8 @@
1
- /**
2
- * Chain behavior, template resolution, and directory management
3
- */
4
1
  import { type AgentConfig, type AgentScope, type UnknownAgentDiagnosticContext } from "../agents/agents.ts";
5
2
  import { type OutputOverrideInput, type ResolvedStepBehavior } from "../runs/shared/child-launch-plan.ts";
6
3
  import { type AcceptanceInput, type AgentContract, type ChainGateLayer, type JsonSchemaObject, type OutputMode, type ToolBudgetConfig } from "./types.ts";
7
4
  export { planChildLaunch, resolveStepBehavior, resolveTaskTextForFileUpdatePolicy, suppressProgressForReadOnlyTask, taskDisallowsFileUpdates, } from "../runs/shared/child-launch-plan.ts";
8
5
  export type { ChildLaunchPlan, ChildLaunchPlanInput, OutputOverrideInput, ResolvedStepBehavior, StepOverrides } from "../runs/shared/child-launch-plan.ts";
9
- /** Sequential step: single agent execution */
10
6
  export interface SequentialStep {
11
7
  agent: string;
12
8
  task?: string;
@@ -30,7 +26,6 @@ export interface SequentialStep {
30
26
  /** Internal workflow child isolation; public workflow scripts supply this on runs.run. */
31
27
  worktree?: boolean;
32
28
  }
33
- /** Parallel task item within a parallel step */
34
29
  export interface ParallelTaskItem {
35
30
  agent: string;
36
31
  task?: string;
@@ -80,7 +75,6 @@ export interface DynamicParallelStep {
80
75
  agentContract?: AgentContract;
81
76
  gateOn?: ChainGateLayer;
82
77
  }
83
- /** Parallel step: multiple agents running concurrently */
84
78
  export interface ParallelStep {
85
79
  parallel: ParallelTaskItem[];
86
80
  concurrency?: number;
@@ -91,21 +85,15 @@ export interface ParallelStep {
91
85
  agentContract?: AgentContract;
92
86
  gateOn?: ChainGateLayer;
93
87
  }
94
- /** Union type for chain steps */
95
88
  export type ChainStep = SequentialStep | ParallelStep | DynamicParallelStep;
96
89
  export declare function isParallelStep(step: ChainStep): step is ParallelStep;
97
90
  export declare function isDynamicParallelStep(step: ChainStep): step is DynamicParallelStep;
98
- /** Get all agent names in a step (single for sequential, multiple for parallel) */
99
91
  export declare function getStepAgents(step: ChainStep): string[];
100
92
  export declare function createChainDir(runId: string, baseDir?: string): string;
101
93
  export declare function removeChainDir(chainDir: string): void;
102
94
  export declare function cleanupOldChainDirs(): void;
103
95
  /** Resolved templates for a chain - string for sequential, string[] for parallel */
104
96
  export type ResolvedTemplates = (string | string[])[];
105
- /**
106
- * Resolve templates for a chain with parallel step support.
107
- * Returns string for sequential steps, string[] for parallel steps.
108
- */
109
97
  export declare function resolveChainTemplates(steps: ChainStep[]): ResolvedTemplates;
110
98
  /**
111
99
  * Expand a leading `~`/`~/` to the user's home directory. Other forms (relative,
@@ -119,28 +107,17 @@ export declare function expandHomePath(filePath: string): string;
119
107
  export declare function resolveChainPath(filePath: string, chainDir: string): string;
120
108
  export declare function resolveExistingReadInstructionPaths(reads: readonly string[], instructionCwd: string, existenceCwd?: string): string[];
121
109
  export declare function resolveExistingReadPaths(reads: readonly string[], cwd: string): string[];
122
- /**
123
- * Build chain instructions from resolved behavior.
124
- * These are appended to the task to tell the agent what to read/write.
125
- */
126
110
  export declare function writeInitialProgressFile(progressDir: string): void;
127
111
  export declare function buildChainInstructions(behavior: ResolvedStepBehavior, chainDir: string, isFirstProgressAgent: boolean, previousSummary?: string, readExistenceDir?: string): {
128
112
  prefix: string;
129
113
  suffix: string;
130
114
  };
131
- /**
132
- * Resolve behaviors for all tasks in a parallel step.
133
- * Creates namespaced output paths to avoid collisions.
134
- */
135
115
  /** Exact discovery context, or explicit input for defensive fallback discovery. */
136
116
  export type ParallelBehaviorDiagnostics = UnknownAgentDiagnosticContext | {
137
117
  cwd: string;
138
118
  scope?: AgentScope;
139
119
  };
140
120
  export declare function resolveParallelBehaviors(tasks: ParallelTaskItem[], agentConfigs: AgentConfig[], stepIndex: number, chainSkills?: string[], diagnostics?: ParallelBehaviorDiagnostics): ResolvedStepBehavior[];
141
- /**
142
- * Create subdirectories for parallel step outputs
143
- */
144
121
  export declare function createParallelDirs(chainDir: string, stepIndex: number, taskCount: number, agentNames: string[]): void;
145
122
  export type { ParallelTaskResult } from "../runs/shared/parallel-utils.ts";
146
123
  export { aggregateParallelOutputs } from "../runs/shared/parallel-utils.ts";
@@ -1,6 +1,3 @@
1
- /**
2
- * Chain behavior, template resolution, and directory management
3
- */
4
1
  import * as fs from "node:fs";
5
2
  import * as os from "node:os";
6
3
  import * as path from "node:path";
@@ -8,19 +5,15 @@ import { discoverAgents, formatUnknownAgentError, unknownAgentDiagnosticContext
8
5
  import { normalizeSkillInput } from "../agents/skills.js";
9
6
  import { normalizeOutputOverride } from "../runs/shared/child-launch-plan.js";
10
7
  import { CHAIN_RUNS_DIR } from "./types.js";
11
- const CHAIN_DIR_MAX_AGE_MS = 24 * 60 * 60 * 1000; // 24 hours
8
+ const CHAIN_DIR_MAX_AGE_MS = 24 * 60 * 60 * 1000;
12
9
  const INITIAL_PROGRESS_CONTENT = "# Progress\n\n## Status\nIn Progress\n\n## Tasks\n\n## Files Changed\n\n## Notes\n";
13
10
  export { planChildLaunch, resolveStepBehavior, resolveTaskTextForFileUpdatePolicy, suppressProgressForReadOnlyTask, taskDisallowsFileUpdates, } from "../runs/shared/child-launch-plan.js";
14
- // =============================================================================
15
- // Type Guards
16
- // =============================================================================
17
11
  export function isParallelStep(step) {
18
12
  return "parallel" in step && Array.isArray(step.parallel);
19
13
  }
20
14
  export function isDynamicParallelStep(step) {
21
15
  return "expand" in step && "collect" in step && "parallel" in step && !Array.isArray(step.parallel);
22
16
  }
23
- /** Get all agent names in a step (single for sequential, multiple for parallel) */
24
17
  export function getStepAgents(step) {
25
18
  if (isParallelStep(step)) {
26
19
  return step.parallel.map((t) => t.agent);
@@ -30,9 +23,6 @@ export function getStepAgents(step) {
30
23
  }
31
24
  return [step.agent];
32
25
  }
33
- // =============================================================================
34
- // Chain Directory Management
35
- // =============================================================================
36
26
  export function createChainDir(runId, baseDir) {
37
27
  const chainDir = path.join(baseDir ? path.resolve(baseDir) : CHAIN_RUNS_DIR, runId);
38
28
  fs.mkdirSync(chainDir, { recursive: true });
@@ -72,35 +62,24 @@ export function cleanupOldChainDirs() {
72
62
  }
73
63
  }
74
64
  }
75
- /**
76
- * Resolve templates for a chain with parallel step support.
77
- * Returns string for sequential steps, string[] for parallel steps.
78
- */
79
65
  export function resolveChainTemplates(steps) {
80
66
  return steps.map((step, i) => {
81
67
  if (isParallelStep(step)) {
82
- // Parallel step: resolve each task's template
83
68
  return step.parallel.map((task) => {
84
69
  if (task.task)
85
70
  return task.task;
86
- // Default for parallel tasks is {previous}
87
71
  return "{previous}";
88
72
  });
89
73
  }
90
74
  if (isDynamicParallelStep(step)) {
91
75
  return step.parallel.task ?? "{previous}";
92
76
  }
93
- // Sequential step: existing logic
94
77
  const seq = step;
95
78
  if (seq.task)
96
79
  return seq.task;
97
- // Default: first step uses {task}, others use {previous}
98
80
  return i === 0 ? "{task}" : "{previous}";
99
81
  });
100
82
  }
101
- // =============================================================================
102
- // Chain Instruction Injection
103
- // =============================================================================
104
83
  /**
105
84
  * Expand a leading `~`/`~/` to the user's home directory. Other forms (relative,
106
85
  * absolute, `~user/`) pass through unchanged.
@@ -130,10 +109,6 @@ export function resolveExistingReadInstructionPaths(reads, instructionCwd, exist
130
109
  export function resolveExistingReadPaths(reads, cwd) {
131
110
  return resolveExistingReadInstructionPaths(reads, cwd);
132
111
  }
133
- /**
134
- * Build chain instructions from resolved behavior.
135
- * These are appended to the task to tell the agent what to read/write.
136
- */
137
112
  export function writeInitialProgressFile(progressDir) {
138
113
  fs.mkdirSync(progressDir, { recursive: true });
139
114
  fs.writeFileSync(path.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
@@ -162,7 +137,6 @@ export function buildChainInstructions(behavior, chainDir, isFirstProgressAgent,
162
137
  suffixParts.push(`Update progress at: ${progressPath}`);
163
138
  }
164
139
  }
165
- // Include previous step's summary in suffix if available
166
140
  if (previousSummary && previousSummary.trim()) {
167
141
  suffixParts.push(`Previous step output:\n${previousSummary.trim()}`);
168
142
  }
@@ -185,7 +159,6 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
185
159
  : unknownAgentDiagnosticContext(discoverAgents(path.resolve(diagnostics.cwd), diagnostics.scope ?? "both"));
186
160
  throw new Error(formatUnknownAgentError(task.agent, context));
187
161
  }
188
- // Build subdirectory path for this parallel task
189
162
  const subdir = path.join(`parallel-${stepIndex}`, `${taskIndex}-${task.agent}`);
190
163
  // Output: task override > agent default (namespaced) > false
191
164
  // Absolute paths pass through unchanged; relative paths get namespaced under subdir
@@ -197,19 +170,17 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
197
170
  output = false;
198
171
  }
199
172
  else if (path.isAbsolute(taskOutput)) {
200
- output = taskOutput; // Absolute path: use as-is
173
+ output = taskOutput;
201
174
  }
202
175
  else {
203
- output = path.join(subdir, taskOutput); // Relative: namespace under subdir
176
+ output = path.join(subdir, taskOutput);
204
177
  }
205
178
  }
206
179
  else if (configOutput) {
207
180
  // Agent defaults are always relative, so namespace them
208
181
  output = path.join(subdir, configOutput);
209
182
  }
210
- // Reads: task override > agent default > false
211
183
  const reads = task.reads !== undefined ? task.reads : config.defaultReads ?? false;
212
- // Progress: task override > agent default > false
213
184
  const progress = task.progress !== undefined
214
185
  ? task.progress
215
186
  : config.defaultProgress ?? false;
@@ -235,9 +206,6 @@ export function resolveParallelBehaviors(tasks, agentConfigs, stepIndex, chainSk
235
206
  return { output, outputMode, reads, progress, skills, model };
236
207
  });
237
208
  }
238
- /**
239
- * Create subdirectories for parallel step outputs
240
- */
241
209
  export function createParallelDirs(chainDir, stepIndex, taskCount, agentNames) {
242
210
  for (let i = 0; i < taskCount; i++) {
243
211
  const subdir = path.join(chainDir, `parallel-${stepIndex}`, `${i}-${agentNames[i]}`);
@@ -1,5 +1,6 @@
1
1
  import type { ActivityState, AsyncJobStep } from "./types.ts";
2
2
  type StepStatusLike = Pick<AsyncJobStep, "status">;
3
+ export declare function formatActivityAge(ms: number): string;
3
4
  export declare function formatActivityLabel(lastActivityAt: number | undefined, activityState?: ActivityState, now?: number): string | undefined;
4
5
  export declare function aggregateStepStatus(steps: StepStatusLike[]): AsyncJobStep["status"];
5
6
  export declare function formatAgentRunningLabel(count: number): string;
@@ -1,4 +1,4 @@
1
- function formatActivityAge(ms) {
1
+ export function formatActivityAge(ms) {
2
2
  if (ms < 1000)
3
3
  return "now";
4
4
  if (ms < 60000)
@@ -1,6 +1,3 @@
1
- /**
2
- * Type definitions for the subagent extension
3
- */
4
1
  import type { Message } from "@earendil-works/pi-ai";
5
2
  import type { SubagentDelegationProviderDiagnostics } from "../api/delegation.ts";
6
3
  import type { AgentConfig } from "../agents/agents.ts";
@@ -340,6 +337,8 @@ export interface WaitToolConfigObject {
340
337
  enabled?: boolean;
341
338
  /** Default blocking window for bg_wait calls that omit timeoutMs. */
342
339
  defaultTimeoutMs?: number;
340
+ /** Registers the wait tool under this name instead of bg_wait, e.g. when another extension uses bg_wait. */
341
+ name?: string;
343
342
  }
344
343
  export type WaitToolConfig = boolean | WaitToolConfigObject;
345
344
  export interface ControlEvent {
@@ -669,6 +668,7 @@ export interface ScheduleOrigin {
669
668
  }
670
669
  export type SteeringActionState = "delivered" | "scheduled" | "pending" | "partial" | "recovered" | "failed";
671
670
  export type SteeringTargetState = "scheduled" | "pending" | "routed" | "queued" | "delivered" | "late" | "failed" | "recovered";
671
+ export type SteeringFailureKind = "rejected" | "unconsumed";
672
672
  export interface SteeringTargetStatus {
673
673
  index: number;
674
674
  state: SteeringTargetState;
@@ -677,6 +677,7 @@ export interface SteeringTargetStatus {
677
677
  lateDeliveredAt?: number;
678
678
  failedAt?: number;
679
679
  recoveredAt?: number;
680
+ failureKind?: SteeringFailureKind;
680
681
  reason?: string;
681
682
  replacementRunId?: string;
682
683
  }
@@ -701,6 +702,7 @@ export interface SteeringStatus {
701
702
  export interface SteerActionTarget {
702
703
  index: number;
703
704
  state: SteeringTargetState;
705
+ failureKind?: SteeringFailureKind;
704
706
  deliveredAt?: number;
705
707
  lateDeliveredAt?: number;
706
708
  reason?: string;
@@ -749,15 +751,31 @@ export interface SteeringRecoveryDescriptor {
749
751
  requiredExtensions?: RequiredChildExtensionSnapshot;
750
752
  runFanoutBudget: RunFanoutBudgetDescriptor;
751
753
  sourceRunId: string;
754
+ /** The session that launched the run; only it, or a session that replaced it, may resume the run. */
755
+ sessionId?: string;
752
756
  agentContract?: AgentContract;
753
757
  agent: string;
754
758
  sandbox?: string;
755
759
  permissionProfile?: string;
756
760
  sessionFile?: string;
761
+ /**
762
+ * The managed worktree the launch chose, so a resume never takes its cwd from the run's own
763
+ * handoff.json alone: the native cwd the parent computed, or the Worktrunk branch it requested.
764
+ */
765
+ managedWorktree?: {
766
+ provider: "native";
767
+ cwd: string;
768
+ } | {
769
+ provider: "worktrunk";
770
+ branch: string;
771
+ };
757
772
  /** Git ref used to allocate managed worktrees for this run. */
758
773
  baseRef?: string;
759
- /** Launcher name the run was wrapped with; resume re-reads its argv from current user config. Absence means unwrapped. */
760
- launcher?: string;
774
+ /** Launcher name the run was wrapped with, or null when it ran unwrapped; resume re-reads its argv from current user config.
775
+ * Absence (descriptors written before null was recorded) means unknown: resume uses the agent file's current launcher. */
776
+ launcher?: string | null;
777
+ /** The launcher and agent definition digest the launch required; a resume refuses unless both still hold. */
778
+ requiredLauncher?: RequiredRunnerLauncher;
761
779
  cwd: string;
762
780
  model?: string;
763
781
  modelProvider?: string;
@@ -791,7 +809,6 @@ export interface SteeringRecoveryDescriptor {
791
809
  structuredOutputSchema?: JsonSchemaObject;
792
810
  acceptance?: AcceptanceInput;
793
811
  controlConfig?: ResolvedControlConfig;
794
- /** Resolved launch context for this async child. */
795
812
  context?: "fresh" | "fork";
796
813
  /** Raw per-run bridge override. Omitted descriptors continue to use global config. */
797
814
  intercomBridge?: IntercomBridgeConfig;
@@ -875,6 +892,8 @@ export interface AgentProgress {
875
892
  /** Human-readable display name for the child's session, when derived at launch. */
876
893
  sessionName?: string;
877
894
  status: "pending" | "running" | "completed" | "failed" | "detached";
895
+ progressText?: string;
896
+ progressUpdatedAt?: number;
878
897
  activityState?: ActivityState;
879
898
  task: string;
880
899
  skills?: string[];
@@ -1149,7 +1168,6 @@ export interface SingleResult {
1149
1168
  /** Human-readable display name for the child's own session (agent + task
1150
1169
  * excerpt), when the launcher derived one. Display metadata only. */
1151
1170
  sessionName?: string;
1152
- /** Resolved launch context for this child. */
1153
1171
  context?: "fresh" | "fork";
1154
1172
  exitCode: number;
1155
1173
  processSignal?: string | null;
@@ -1258,7 +1276,6 @@ export interface WaitCompletionChild {
1258
1276
  runId?: string;
1259
1277
  /** Bounded accounting projection used by /subagent-cost after async completion. */
1260
1278
  usage?: Usage;
1261
- /** Persisted Pi child session when available. */
1262
1279
  sessionFile?: string;
1263
1280
  success?: boolean;
1264
1281
  outputState?: SubagentOutputState;
@@ -1326,6 +1343,7 @@ export interface AgentCapabilityRow {
1326
1343
  model?: {
1327
1344
  value?: string;
1328
1345
  thinking?: string | false;
1346
+ unavailable?: true;
1329
1347
  };
1330
1348
  execution?: {
1331
1349
  defaultAsync?: boolean;
@@ -1455,6 +1473,8 @@ export interface Details {
1455
1473
  sourceRunId: string;
1456
1474
  attempt: number;
1457
1475
  };
1476
+ /** When `stop` with `drain` was requested (epoch ms). A drained run is never resumed. */
1477
+ drainRequestedAt?: number;
1458
1478
  resource?: WorkflowResourceProvenance;
1459
1479
  preflightWarnings?: string[];
1460
1480
  trace: Array<{
@@ -1539,6 +1559,8 @@ export interface NestedStepSummary {
1539
1559
  /** Human-readable display name for the child session, when derived at launch. */
1540
1560
  sessionName?: string;
1541
1561
  status: "pending" | "running" | "complete" | "completed" | "failed" | "partial" | "paused" | "stopped" | "rejected";
1562
+ progressText?: string;
1563
+ progressUpdatedAt?: number;
1542
1564
  model?: string;
1543
1565
  thinking?: string;
1544
1566
  sessionFile?: string;
@@ -1739,54 +1761,9 @@ export interface ExternalCliReceiptMetadata {
1739
1761
  };
1740
1762
  capabilities: ExternalCliCapabilities;
1741
1763
  machine?: ExternalCliMachineStatus;
1742
- safety?: {
1743
- sandbox: "read-only";
1744
- approvalPolicy: "never";
1745
- ephemeral: true;
1746
- } | {
1747
- access: "workspace-write";
1748
- sandbox: "workspace-write";
1749
- approvalPolicy: "never";
1750
- ephemeral: true;
1751
- } | {
1752
- permissionMode: "plan";
1753
- tools: "none";
1754
- mcp: "empty-strict";
1755
- settingSources: "none";
1756
- sessionPersistence: false;
1757
- } | {
1758
- access: "read-only";
1759
- authentication: "existing-cli-required";
1760
- permissionMode: "plan";
1761
- tools: "none";
1762
- mcp: "empty-strict";
1763
- settingSources: "user";
1764
- userSettingsTrust: "required";
1765
- sessionPersistence: false;
1766
- } | {
1767
- access: "workspace-write";
1768
- authentication: "existing-cli-required";
1769
- permissionMode: "acceptEdits";
1770
- tools: "Read,Write,Edit,Glob,Grep";
1771
- mcp: "empty-strict";
1772
- settingSources: "user";
1773
- userSettingsTrust: "required";
1774
- sessionPersistence: false;
1775
- } | {
1776
- access: "read-only";
1777
- authentication: "cursor-api-key-or-existing-login";
1778
- mode: "ask";
1779
- sandbox: "enabled";
1780
- workspaceTrust: "existing-required";
1781
- sessionReuse: false;
1782
- } | {
1783
- access: "workspace-write";
1784
- authentication: "cursor-api-key-or-existing-login";
1785
- mode: "print";
1786
- sandbox: "enabled";
1787
- workspaceTrust: "existing-required";
1788
- sessionReuse: false;
1789
- };
1764
+ safety?: ExternalCliProfileSafety;
1765
+ /** Where `safety` came from. Nothing in it is measured from the launched process. */
1766
+ safetySource?: ExternalCliSafetySource;
1790
1767
  outputArtifacts?: {
1791
1768
  stdoutPath?: string;
1792
1769
  stderrPath?: string;
@@ -1801,6 +1778,59 @@ export interface ExternalCliReceiptMetadata {
1801
1778
  };
1802
1779
  nonResumableReason: string;
1803
1780
  }
1781
+ export type ExternalCliProfileSafety = {
1782
+ sandbox: "read-only";
1783
+ approvalPolicy: "never";
1784
+ ephemeral: true;
1785
+ } | {
1786
+ access: "workspace-write";
1787
+ sandbox: "workspace-write";
1788
+ approvalPolicy: "never";
1789
+ ephemeral: true;
1790
+ } | {
1791
+ permissionMode: "plan";
1792
+ tools: "none";
1793
+ mcp: "empty-strict";
1794
+ settingSources: "none";
1795
+ sessionPersistence: false;
1796
+ } | {
1797
+ access: "read-only";
1798
+ authentication: "existing-cli-required";
1799
+ permissionMode: "plan";
1800
+ tools: "none";
1801
+ mcp: "empty-strict";
1802
+ settingSources: "user";
1803
+ userSettingsTrust: "required";
1804
+ sessionPersistence: false;
1805
+ } | {
1806
+ access: "workspace-write";
1807
+ authentication: "existing-cli-required";
1808
+ permissionMode: "acceptEdits";
1809
+ tools: "Read,Write,Edit,Glob,Grep";
1810
+ mcp: "empty-strict";
1811
+ settingSources: "user";
1812
+ userSettingsTrust: "required";
1813
+ sessionPersistence: false;
1814
+ } | {
1815
+ access: "read-only";
1816
+ authentication: "cursor-api-key-or-existing-login";
1817
+ mode: "ask";
1818
+ sandbox: "enabled";
1819
+ workspaceTrust: "existing-required";
1820
+ sessionReuse: false;
1821
+ } | {
1822
+ access: "workspace-write";
1823
+ authentication: "cursor-api-key-or-existing-login";
1824
+ mode: "print";
1825
+ sandbox: "enabled";
1826
+ workspaceTrust: "existing-required";
1827
+ sessionReuse: false;
1828
+ };
1829
+ export interface ExternalCliSafetySource {
1830
+ measured: false;
1831
+ /** The launch command, absent on a Herdr saved machine. A wrapper script here can grant more or less than the adapter profile. */
1832
+ command?: string;
1833
+ }
1804
1834
  export interface ExternalCliRunnerStatus {
1805
1835
  type: "external-cli";
1806
1836
  command: string;
@@ -1808,6 +1838,7 @@ export interface ExternalCliRunnerStatus {
1808
1838
  promptDelivery: "stdin" | "prompt-file";
1809
1839
  adapter: ExternalCliReceiptMetadata["adapter"];
1810
1840
  safety?: ExternalCliReceiptMetadata["safety"];
1841
+ safetySource?: ExternalCliSafetySource;
1811
1842
  capabilities: ExternalCliCapabilities;
1812
1843
  unsupportedReasons: Record<Exclude<keyof ExternalCliCapabilities, "stop">, string>;
1813
1844
  nonResumableReason: string;
@@ -1948,7 +1979,6 @@ export interface AsyncStatus {
1948
1979
  runner?: ExternalCliRunnerStatus | ExternalJobRunnerStatus;
1949
1980
  externalProcess?: ExternalProcessStatus;
1950
1981
  externalJob?: ExternalJobStatus;
1951
- /** Resolved launch context for this child step. */
1952
1982
  context?: "fresh" | "fork";
1953
1983
  /** Short caller-facing task/goal shown in fleet surfaces when available. */
1954
1984
  description?: string;
@@ -1992,6 +2022,8 @@ export interface AsyncStatus {
1992
2022
  endMs: number;
1993
2023
  }>;
1994
2024
  recentOutput?: string[];
2025
+ progressText?: string;
2026
+ progressUpdatedAt?: number;
1995
2027
  turnCount?: number;
1996
2028
  toolCount?: number;
1997
2029
  startedAt?: number;
@@ -2289,6 +2321,10 @@ export interface WaitSubscriptionRecord {
2289
2321
  version: 1;
2290
2322
  token: string;
2291
2323
  sessionId: string;
2324
+ /** Completion owner of the process that armed the record. A record without it stays scoped to the session. */
2325
+ completionOwnerId?: string;
2326
+ /** The Pi process behind `completionOwnerId`. Once it is dead, the next process on the session takes the wake. */
2327
+ completionOwnerProcess?: RecordedPid;
2292
2328
  targetKind: "async" | "foreground";
2293
2329
  runId: string;
2294
2330
  requestedId: string;
@@ -2382,6 +2418,13 @@ export interface SubagentState {
2382
2418
  contextInjectionBlock?: string;
2383
2419
  /** `subagents.injectAgents` entries that matched no discovered agent at snapshot time. */
2384
2420
  contextInjectionUnknownNames?: string[];
2421
+ /** Live in-process workflow drains keyed by workflow run id; `ok: false` means the drain request could not be saved and nothing was stopped. */
2422
+ workflowDrains?: Map<string, () => {
2423
+ ok: true;
2424
+ started: number;
2425
+ } | {
2426
+ ok: false;
2427
+ }>;
2385
2428
  /** Background children awaited by a blocking workflow call: their parent cannot answer supervisor asks. */
2386
2429
  blockingWorkflowChildren?: Set<string>;
2387
2430
  }
@@ -2432,6 +2475,11 @@ export interface RunnerLauncher {
2432
2475
  name: string;
2433
2476
  argv: string[];
2434
2477
  }
2478
+ /** A call's requirement that its agent runs under this launcher with this agent definition digest. */
2479
+ export interface RequiredRunnerLauncher {
2480
+ name: string;
2481
+ definitionDigest: string;
2482
+ }
2435
2483
  export declare const SUBAGENT_ASYNC_COMPLETE_EVENT = "subagent:async-complete";
2436
2484
  export declare const SUBAGENT_PROCESS_TERMINAL_EVENT = "subagent:process-terminal";
2437
2485
  export declare const SUBAGENT_FOREGROUND_COMPLETE_EVENT = "subagent:foreground-complete";
@@ -2484,7 +2532,6 @@ export interface RunSyncOptions {
2484
2532
  parentSessionId?: string;
2485
2533
  /** The parent session's file, recorded as a new child session's `parentSession` header. */
2486
2534
  parentSessionFile?: string;
2487
- /** Resolved launch context for this child. */
2488
2535
  context?: "fresh" | "fork";
2489
2536
  cwd?: string;
2490
2537
  /** Resolved pane-native saved-machine placement. */
@@ -2516,6 +2563,8 @@ export interface RunSyncOptions {
2516
2563
  /** Internal structured-delegation transport optimization: skip unchanged live snapshots. */
2517
2564
  suppressUnchangedDelegationUpdates?: boolean;
2518
2565
  onControlEvent?: (event: ControlEvent) => void;
2566
+ /** Reports a problem found by a timer callback, with a stable key to de-duplicate it; without it the message goes to stderr. */
2567
+ onWarning?: (message: string, key: string) => void;
2519
2568
  /** Exposes a non-terminating detach callback while the child is active. */
2520
2569
  onDetachReady?: (detach: (reason?: string) => boolean) => void;
2521
2570
  /** Internal foreground receipt proposal; returns true only when the outer waiter accepted it. */
@@ -2570,12 +2619,12 @@ export interface RunSyncOptions {
2570
2619
  fullId: string;
2571
2620
  contextWindow?: number;
2572
2621
  }>;
2622
+ knownProviders?: import("../runs/shared/model-resolution.ts").KnownProviders;
2573
2623
  modelResponseAliases?: Record<string, string[]>;
2574
2624
  /** Current parent-session provider to prefer for ambiguous bare model ids */
2575
2625
  preferredModelProvider?: string;
2576
2626
  /** Parent Pi event host used to snapshot runtime-registered MCP servers before child launch. */
2577
2627
  runtimeSnapshotHost?: import("../runs/shared/mcp-direct-tool-allowlist.ts").McpRuntimeSnapshotHost;
2578
- /** Optional subagent model-scope enforcement. */
2579
2628
  modelScope?: ModelScopeRule | ModelScopeRule[];
2580
2629
  /** Skills to make available (overrides agent default if provided) */
2581
2630
  skills?: string[];
@@ -1,6 +1,3 @@
1
- /**
2
- * Type definitions for the subagent extension
3
- */
4
1
  import * as os from "node:os";
5
2
  import * as path from "node:path";
6
3
  export const SUBAGENT_LIFECYCLE_ARTIFACT_VERSION = 3;
@@ -41,9 +38,6 @@ export const FLEET_KEYBINDING_ACTIONS = [
41
38
  "toggleThinking",
42
39
  "toggleRenderer",
43
40
  ];
44
- // ============================================================================
45
- // Constants
46
- // ============================================================================
47
41
  export const DEFAULT_MAX_OUTPUT = {
48
42
  bytes: 200 * 1024,
49
43
  lines: 5000,
@@ -167,9 +161,6 @@ export function wrapForkTask(task, preamble) {
167
161
  return task;
168
162
  return `${wrappedPrefix}${task}`;
169
163
  }
170
- // ============================================================================
171
- // Recursion Depth Guard
172
- // ============================================================================
173
164
  function normalizeNonNegativeInteger(value) {
174
165
  const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
175
166
  if (!Number.isInteger(parsed) || parsed < 0)
@@ -229,9 +220,6 @@ export function resolveMaxSubagentSpawnsPerRun(configMaxSpawns) {
229
220
  ?? normalizeMaxSubagentSpawnsPerRun(configMaxSpawns)
230
221
  ?? DEFAULT_MAX_SUBAGENT_SPAWNS_PER_RUN;
231
222
  }
232
- // ============================================================================
233
- // Utility Functions
234
- // ============================================================================
235
223
  function formatBytes(bytes) {
236
224
  if (bytes < 1024)
237
225
  return `${bytes}B`;
@@ -1,4 +1,4 @@
1
- import type { Message, Usage as PiUsage } from "@earendil-works/pi-ai";
1
+ import type { Message, StopReason, Usage as PiUsage } from "@earendil-works/pi-ai";
2
2
  import type { AgentProgress, AsyncStatus, Details, DisplayItem, ErrorInfo, SingleResult, ToolCallSummary, Usage } from "./types.ts";
3
3
  export declare const PI_CODING_AGENT_PACKAGE_ROOT_ENV = "PI_SUBAGENTS_PI_CODING_AGENT_PACKAGE_ROOT";
4
4
  export declare const PROMPT_REDACTED = "[prompt redacted]";
@@ -11,9 +11,6 @@ export declare function getProjectConfigDir(projectRoot: string): string;
11
11
  export declare function getAgentDir(): string;
12
12
  export declare function pruneStatusCacheForAsyncRoot(asyncDirRoot: string, runIds: Iterable<string>): number;
13
13
  export declare function resolveChildCwd(baseCwd: string, childCwd: string | undefined): string;
14
- /**
15
- * Read async job status from disk (with mtime-based caching)
16
- */
17
14
  export declare function readStatus(asyncDir: string): AsyncStatus | null;
18
15
  export declare function getLastActivity(outputFile: string | undefined): string;
19
16
  export declare function findLatestSessionFile(sessionDir: string): string | null;
@@ -30,13 +27,11 @@ export declare function assistantMessageError(message: {
30
27
  }): string | undefined;
31
28
  export declare function getFinalOutput(messages: Message[]): string;
32
29
  export declare function getSingleResultOutput(result: Pick<SingleResult, "finalOutput" | "messages">): string;
33
- /**
34
- * Extract display items (text and tool calls) from messages
35
- */
30
+ export declare const TRUNCATED_RESPONSE_ERROR = "Response was truncated: the model reached its maximum output length.";
31
+ export declare function getTerminalAssistantStopReason(messages: Message[]): StopReason | undefined;
36
32
  export declare function getDisplayItems(messages: Message[] | undefined): DisplayItem[];
37
33
  export declare function sumResultsUsage(results: SingleResult[]): Usage;
38
34
  export declare function toAgentToolUsage(usage: Usage): PiUsage;
39
- /** Sum input tokens, output tokens, and cost across a set of SingleResults. */
40
35
  export declare function sumResultsCost(results: SingleResult[]): NonNullable<Details["totalCost"]>;
41
36
  export declare function compactForegroundResult(result: SingleResult): SingleResult;
42
37
  export declare function compactForegroundDetails(details: Details): Details;
@@ -56,7 +51,6 @@ export declare function compactForegroundDetails(details: Details): Details;
56
51
  export declare const MAX_STREAMED_RECENT_TOOLS = 32;
57
52
  export declare const MAX_STREAMED_TOOL_CALLS = 64;
58
53
  export declare const MAX_STREAMED_OUTPUT_LINE_CHARS = 2000;
59
- /** Keep only the most recent tool-history entries in a streamed snapshot. */
60
54
  export declare function boundStreamedRecentTools(recentTools: AgentProgress["recentTools"]): AgentProgress["recentTools"];
61
55
  /** Cap per-line length of recent output so one long line can't inflate a snapshot. */
62
56
  export declare function boundStreamedRecentOutput(recentOutput: string[]): string[];
@@ -72,12 +66,6 @@ export declare function formatEmptyTerminalAssistantResponseError(messages: Mess
72
66
  * Detect errors in subagent execution from messages (only errors with no subsequent success)
73
67
  */
74
68
  export declare function detectSubagentError(messages: Message[]): ErrorInfo;
75
- /**
76
- * Extract a preview of tool arguments for display
77
- */
78
69
  export declare function extractToolArgsPreview(args: Record<string, unknown>): string;
79
- /**
80
- * Extract text content from various message content formats
81
- */
82
70
  export declare function extractTextFromContent(content: unknown): string;
83
71
  export { mapConcurrent } from "../runs/shared/parallel-utils.ts";