@diousk/pi-subagents-fast 0.20.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 (183) hide show
  1. package/CHANGELOG.md +808 -0
  2. package/CONTRIBUTING.md +72 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1034 -0
  5. package/SECURITY.md +95 -0
  6. package/dist/abortable.d.ts +12 -0
  7. package/dist/abortable.js +42 -0
  8. package/dist/agent-color.d.ts +35 -0
  9. package/dist/agent-color.js +123 -0
  10. package/dist/agent-file-toggle.d.ts +125 -0
  11. package/dist/agent-file-toggle.js +260 -0
  12. package/dist/agent-manager.d.ts +472 -0
  13. package/dist/agent-manager.js +1338 -0
  14. package/dist/agent-runner.d.ts +312 -0
  15. package/dist/agent-runner.js +1034 -0
  16. package/dist/agent-types.d.ts +119 -0
  17. package/dist/agent-types.js +286 -0
  18. package/dist/child-context.d.ts +2 -0
  19. package/dist/child-context.js +12 -0
  20. package/dist/context.d.ts +12 -0
  21. package/dist/context.js +56 -0
  22. package/dist/cross-extension-rpc.d.ts +66 -0
  23. package/dist/cross-extension-rpc.js +138 -0
  24. package/dist/custom-agents.d.ts +54 -0
  25. package/dist/custom-agents.js +316 -0
  26. package/dist/default-agents.d.ts +7 -0
  27. package/dist/default-agents.js +122 -0
  28. package/dist/enabled-models.d.ts +49 -0
  29. package/dist/enabled-models.js +145 -0
  30. package/dist/env.d.ts +6 -0
  31. package/dist/env.js +28 -0
  32. package/dist/group-join.d.ts +32 -0
  33. package/dist/group-join.js +116 -0
  34. package/dist/index.d.ts +50 -0
  35. package/dist/index.js +3682 -0
  36. package/dist/invocation-config.d.ts +107 -0
  37. package/dist/invocation-config.js +83 -0
  38. package/dist/memory.d.ts +53 -0
  39. package/dist/memory.js +165 -0
  40. package/dist/mention-clone.d.ts +87 -0
  41. package/dist/mention-clone.js +153 -0
  42. package/dist/mention.d.ts +81 -0
  43. package/dist/mention.js +131 -0
  44. package/dist/model-resolver.d.ts +36 -0
  45. package/dist/model-resolver.js +95 -0
  46. package/dist/model-scope.d.ts +49 -0
  47. package/dist/model-scope.js +48 -0
  48. package/dist/nested-tools.d.ts +55 -0
  49. package/dist/nested-tools.js +299 -0
  50. package/dist/output-file.d.ts +43 -0
  51. package/dist/output-file.js +142 -0
  52. package/dist/prompts.d.ts +55 -0
  53. package/dist/prompts.js +91 -0
  54. package/dist/schedule-store.d.ts +38 -0
  55. package/dist/schedule-store.js +155 -0
  56. package/dist/schedule.d.ts +109 -0
  57. package/dist/schedule.js +359 -0
  58. package/dist/settings.d.ts +360 -0
  59. package/dist/settings.js +251 -0
  60. package/dist/skill-loader.d.ts +24 -0
  61. package/dist/skill-loader.js +93 -0
  62. package/dist/status-note.d.ts +61 -0
  63. package/dist/status-note.js +85 -0
  64. package/dist/structured-output.d.ts +61 -0
  65. package/dist/structured-output.js +112 -0
  66. package/dist/types.d.ts +371 -0
  67. package/dist/types.js +5 -0
  68. package/dist/ui/agent-mention.d.ts +82 -0
  69. package/dist/ui/agent-mention.js +187 -0
  70. package/dist/ui/agent-widget.d.ts +219 -0
  71. package/dist/ui/agent-widget.js +592 -0
  72. package/dist/ui/conversation-viewer.d.ts +120 -0
  73. package/dist/ui/conversation-viewer.js +578 -0
  74. package/dist/ui/fleet-list.d.ts +195 -0
  75. package/dist/ui/fleet-list.js +471 -0
  76. package/dist/ui/schedule-menu.d.ts +16 -0
  77. package/dist/ui/schedule-menu.js +94 -0
  78. package/dist/ui/select-item.d.ts +27 -0
  79. package/dist/ui/select-item.js +34 -0
  80. package/dist/ui/viewer-keys.d.ts +20 -0
  81. package/dist/ui/viewer-keys.js +17 -0
  82. package/dist/ui/workflow-card.d.ts +175 -0
  83. package/dist/ui/workflow-card.js +332 -0
  84. package/dist/ui/workflow-dialog.d.ts +305 -0
  85. package/dist/ui/workflow-dialog.js +843 -0
  86. package/dist/ui/workflow-menu.d.ts +60 -0
  87. package/dist/ui/workflow-menu.js +147 -0
  88. package/dist/usage.d.ts +135 -0
  89. package/dist/usage.js +120 -0
  90. package/dist/workflow/collisions.d.ts +95 -0
  91. package/dist/workflow/collisions.js +88 -0
  92. package/dist/workflow/entry.d.ts +32 -0
  93. package/dist/workflow/entry.js +29 -0
  94. package/dist/workflow/host.d.ts +62 -0
  95. package/dist/workflow/host.js +362 -0
  96. package/dist/workflow/journal.d.ts +97 -0
  97. package/dist/workflow/journal.js +120 -0
  98. package/dist/workflow/json-schema.d.ts +51 -0
  99. package/dist/workflow/json-schema.js +111 -0
  100. package/dist/workflow/meta.d.ts +67 -0
  101. package/dist/workflow/meta.js +317 -0
  102. package/dist/workflow/progress.d.ts +224 -0
  103. package/dist/workflow/progress.js +361 -0
  104. package/dist/workflow/runtime.d.ts +334 -0
  105. package/dist/workflow/runtime.js +830 -0
  106. package/dist/workflow/saved.d.ts +90 -0
  107. package/dist/workflow/saved.js +203 -0
  108. package/dist/workflow/task.d.ts +136 -0
  109. package/dist/workflow/task.js +207 -0
  110. package/dist/workflow/tool-description.d.ts +38 -0
  111. package/dist/workflow/tool-description.js +199 -0
  112. package/dist/workflow/worker-source.d.ts +47 -0
  113. package/dist/workflow/worker-source.js +778 -0
  114. package/dist/worktree.d.ts +52 -0
  115. package/dist/worktree.js +164 -0
  116. package/dist/xml.d.ts +10 -0
  117. package/dist/xml.js +12 -0
  118. package/docs/rpc.md +183 -0
  119. package/docs/workflows.md +437 -0
  120. package/examples/agent-tool-description.md +42 -0
  121. package/examples/workflows/compose.js +51 -0
  122. package/examples/workflows/fan-out-audit.js +47 -0
  123. package/examples/workflows/gated-fix.js +60 -0
  124. package/examples/workflows/lib/count-child.js +27 -0
  125. package/examples/workflows/review-panel.js +63 -0
  126. package/examples/workflows/structured-findings.js +78 -0
  127. package/package.json +68 -0
  128. package/src/abortable.ts +43 -0
  129. package/src/agent-color.ts +161 -0
  130. package/src/agent-file-toggle.ts +270 -0
  131. package/src/agent-manager.ts +1581 -0
  132. package/src/agent-runner.ts +1286 -0
  133. package/src/agent-types.ts +346 -0
  134. package/src/child-context.ts +15 -0
  135. package/src/context.ts +58 -0
  136. package/src/cross-extension-rpc.ts +198 -0
  137. package/src/custom-agents.ts +333 -0
  138. package/src/default-agents.ts +126 -0
  139. package/src/enabled-models.ts +180 -0
  140. package/src/env.ts +33 -0
  141. package/src/group-join.ts +141 -0
  142. package/src/index.ts +3991 -0
  143. package/src/invocation-config.ts +155 -0
  144. package/src/memory.ts +179 -0
  145. package/src/mention-clone.ts +196 -0
  146. package/src/mention.ts +141 -0
  147. package/src/model-resolver.ts +118 -0
  148. package/src/model-scope.ts +70 -0
  149. package/src/nested-tools.ts +422 -0
  150. package/src/output-file.ts +155 -0
  151. package/src/prompts.ts +142 -0
  152. package/src/schedule-store.ts +153 -0
  153. package/src/schedule.ts +386 -0
  154. package/src/settings.ts +587 -0
  155. package/src/skill-loader.ts +102 -0
  156. package/src/status-note.ts +90 -0
  157. package/src/structured-output.ts +130 -0
  158. package/src/types.ts +384 -0
  159. package/src/ui/agent-mention.ts +216 -0
  160. package/src/ui/agent-widget.ts +664 -0
  161. package/src/ui/conversation-viewer.ts +589 -0
  162. package/src/ui/fleet-list.ts +543 -0
  163. package/src/ui/schedule-menu.ts +105 -0
  164. package/src/ui/select-item.ts +45 -0
  165. package/src/ui/viewer-keys.ts +39 -0
  166. package/src/ui/workflow-card.ts +470 -0
  167. package/src/ui/workflow-dialog.ts +1115 -0
  168. package/src/ui/workflow-menu.ts +193 -0
  169. package/src/usage.ts +167 -0
  170. package/src/workflow/collisions.ts +123 -0
  171. package/src/workflow/entry.ts +47 -0
  172. package/src/workflow/host.ts +403 -0
  173. package/src/workflow/journal.ts +164 -0
  174. package/src/workflow/json-schema.ts +128 -0
  175. package/src/workflow/meta.ts +325 -0
  176. package/src/workflow/progress.ts +550 -0
  177. package/src/workflow/runtime.ts +1219 -0
  178. package/src/workflow/saved.ts +217 -0
  179. package/src/workflow/task.ts +302 -0
  180. package/src/workflow/tool-description.ts +200 -0
  181. package/src/workflow/worker-source.ts +781 -0
  182. package/src/worktree.ts +205 -0
  183. package/src/xml.ts +13 -0
@@ -0,0 +1,312 @@
1
+ /**
2
+ * agent-runner.ts — Core execution engine: creates sessions, runs agents, collects results.
3
+ */
4
+ import type { Model } from "@earendil-works/pi-ai";
5
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
6
+ import { type AgentSession, DefaultResourceLoader, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
7
+ import { type NestedAgentManager } from "./nested-tools.js";
8
+ import type { ServiceTier, SubagentType, ThinkingLevel } from "./types.js";
9
+ import type { LifetimeUsage } from "./usage.js";
10
+ import type { CompiledSchema } from "./workflow/json-schema.js";
11
+ /**
12
+ * Tool names registered by THIS extension. Single source of truth so the
13
+ * registration sites (index.ts) and the subagent exclusion list below can't
14
+ * drift apart. These are our own tools, not pi built-ins, so they can't be
15
+ * derived from pi — but they only need defining once.
16
+ */
17
+ export declare const SUBAGENT_TOOL_NAMES: {
18
+ readonly AGENT: "Agent";
19
+ readonly WORKFLOW: "SubagentWorkflow";
20
+ readonly GET_RESULT: "get_subagent_result";
21
+ readonly STEER: "steer_subagent";
22
+ };
23
+ /** Whether an API accepts the OpenAI `service_tier` request field. */
24
+ export declare function isServiceTierApi(api: string | undefined): boolean;
25
+ /**
26
+ * Add a custom agent's service tier to compatible provider requests.
27
+ *
28
+ * The existing payload hook belongs to pi's extension lifecycle, so it must be
29
+ * called first and its replacement preserved. An undefined replacement means
30
+ * "keep the original payload" in pi-ai's callback contract.
31
+ */
32
+ export declare function installServiceTierPayload(session: Pick<AgentSession, "agent">, serviceTier: ServiceTier | undefined): void;
33
+ /**
34
+ * Canonical name of an extension for `extensions: [...]` allowlist matching.
35
+ * Lowercased — extension names match case-insensitively so `extensions: [Mcp]`
36
+ * resolves the same as `[mcp]`. Tool names within `ext:foo/bar` are not affected.
37
+ * Directory extensions (`foo/index.ts`) resolve to the parent directory name;
38
+ * single-file extensions to the basename minus `.ts`/`.js`.
39
+ */
40
+ export declare function extensionCanonicalName(extPath: string): string;
41
+ /**
42
+ * All names an extension answers to for allowlist matching (lowercased): its
43
+ * path-derived {@link extensionCanonicalName} plus, when a pi package manifest
44
+ * declares this entry, that package's unscoped short name (`@scope/foo` → `foo`).
45
+ * #143: an extension installed via `pi.extensions: ["./src/index.ts"]` would
46
+ * otherwise only ever match as `src` (the source directory), never by its
47
+ * package name. The path-derived name is preserved, so it keeps matching too.
48
+ */
49
+ export declare function extensionCanonicalNames(extPath: string): string[];
50
+ /**
51
+ * Classify `extensions: string[]` frontmatter entries for the loader-level filter.
52
+ *
53
+ * An entry is a PATH iff it contains a path separator or starts with `~`; otherwise
54
+ * it is a NAME. `"*"` sets the wildcard flag (keep all default-discovered extensions).
55
+ *
56
+ * Path entries are resolved (`~` expanded, made absolute against `cwd`) into `paths`
57
+ * — and their canonical name is also added to `names`. The loader override matches
58
+ * everything by canonical name, so path-loaded extensions are matched via their name
59
+ * rather than their post-staging `Extension.path`.
60
+ */
61
+ export declare function parseExtensionsSpec(entries: string[], cwd: string): {
62
+ names: Set<string>;
63
+ paths: string[];
64
+ wildcard: boolean;
65
+ };
66
+ /**
67
+ * Parse raw `ext:` selector strings (from the `tools:` CSV) into the set of
68
+ * extension names to keep loaded and a per-extension tool-narrowing map.
69
+ *
70
+ * `ext:foo` → `extNames` has `foo`, no narrowing entry (all of foo's tools).
71
+ * `ext:foo/bar` → `extNames` has `foo`, `narrowing.foo` has `bar` (only `bar`).
72
+ * A name lands in `narrowing` only when a `/tool` form is seen, so a bare
73
+ * `ext:foo` alongside `ext:foo/bar` leaves narrowing in effect (narrowing wins).
74
+ * The split is on the first `/`; extension canonical names never contain `/`.
75
+ */
76
+ export declare function parseExtSelectors(entries: string[]): {
77
+ extNames: Set<string>;
78
+ narrowing: Map<string, Set<string>>;
79
+ };
80
+ /**
81
+ * Keep a subagent's tool scope correct as extensions register tools over time.
82
+ *
83
+ * Extensions may call `registerTool` long after load — pi-mcp from `session_start`,
84
+ * context-mode from `before_agent_start` — so scope has to be re-derived rather than
85
+ * snapshotted. `registerTool` writes into the very `extension.tools` maps this reads,
86
+ * so `inScope()` sees late arrivals on the next call.
87
+ *
88
+ * Two enforcement points, because neither covers the whole picture:
89
+ *
90
+ * - `turn_end` re-narrows the ACTIVE set. pi emits `turn_end` immediately before
91
+ * `prepareNextTurn` re-snapshots `agent.state.tools`, and session listeners run
92
+ * synchronously, so the narrow lands in time for turns 2..N.
93
+ * - `beforeToolCall` blocks out-of-scope calls. Turn 1 cannot be narrowed at all:
94
+ * `before_agent_start` fires INSIDE `prompt()` and may widen the tool set, but
95
+ * `createContextSnapshot()` freezes that turn's tools immediately after — there
96
+ * is no hook in between. A call-time check is the only correct guard there.
97
+ *
98
+ * Both are installed on the session and deliberately NOT unsubscribed: they must
99
+ * outlive the `runAgent` call so resumed/steered turns stay scoped. pi's `dispose()`
100
+ * clears `_eventListeners`, so they die with the session rather than leaking.
101
+ *
102
+ * Only meaningful when extensions are loaded — under `noExtensions`/`isolated` the
103
+ * static `allowedToolNames` allowlist already gates the registry itself.
104
+ */
105
+ export declare function installExtensionToolScope(session: AgentSession, ctx: {
106
+ loader: DefaultResourceLoader;
107
+ toolNames: string[];
108
+ disallowedSet: Set<string> | undefined;
109
+ extNames: Set<string>;
110
+ narrowing: Map<string, Set<string>>;
111
+ /**
112
+ * Injected `customTools` to keep active regardless of the built-in list.
113
+ *
114
+ * Two kinds arrive here and they are blocked for different reasons: opt-in
115
+ * nested-delegation tools share EXCLUDED_TOOL_NAMES' names, and
116
+ * StructuredOutput is simply not a built-in, so neither survives a `keep`
117
+ * seeded from `toolNames`.
118
+ */
119
+ readmitToolNames: Set<string>;
120
+ }): void;
121
+ /** Normalize max turns. undefined or 0 = unlimited, otherwise minimum 1. */
122
+ export declare function normalizeMaxTurns(n: number | undefined): number | undefined;
123
+ /** Get the default max turns value. undefined = unlimited. */
124
+ export declare function getDefaultMaxTurns(): number | undefined;
125
+ /** Set the default max turns value. undefined or 0 = unlimited, otherwise minimum 1. */
126
+ export declare function setDefaultMaxTurns(n: number | undefined): void;
127
+ /**
128
+ * The turn limit a run of `type` will actually enforce: an explicit value if the
129
+ * caller supplied one, else the agent's own `max_turns`, else the project
130
+ * default. `undefined` = unlimited.
131
+ *
132
+ * Exported because the widget's turn counter (`↻3≤20`) has to predict this
133
+ * before the run starts, and a second copy of the expression would drift from
134
+ * the one below that enforces it.
135
+ */
136
+ export declare function resolveEffectiveMaxTurns(type: string, explicit?: number): number | undefined;
137
+ /** Whether subagent sessions are persisted by default. */
138
+ export declare function getRememberAgents(): boolean;
139
+ /** Set whether subagent sessions are persisted by default. */
140
+ export declare function setRememberAgents(b: boolean): void;
141
+ /** Get the grace turns value. */
142
+ export declare function getGraceTurns(): number;
143
+ /** Set the grace turns value (minimum 1). */
144
+ export declare function setGraceTurns(n: number): void;
145
+ /**
146
+ * Try to find the right model for an agent type.
147
+ * Priority: explicit option > config.model > parent model.
148
+ */
149
+ export declare function resolveDefaultModel(parentModel: Model<any> | undefined, registry: {
150
+ find(provider: string, modelId: string): Model<any> | undefined;
151
+ getAvailable?(): Model<any>[];
152
+ }, configModel?: string): Model<any> | undefined;
153
+ /** Info about a tool event in the subagent. */
154
+ export interface ToolActivity {
155
+ type: "start" | "end";
156
+ toolName: string;
157
+ }
158
+ export interface RunOptions {
159
+ /** ExtensionAPI instance — used for pi.exec() instead of execSync. */
160
+ pi: ExtensionAPI;
161
+ /** Manager-assigned id; suffixes session name to disambiguate parallel spawns (e.g. `Explore#a1b2c3d4`). */
162
+ agentId?: string;
163
+ model?: Model<any>;
164
+ maxTurns?: number;
165
+ signal?: AbortSignal;
166
+ isolated?: boolean;
167
+ inheritContext?: boolean;
168
+ thinkingLevel?: ThinkingLevel;
169
+ /**
170
+ * Reopen this pi session file rather than starting an empty conversation.
171
+ * `createAgentSession` seeds itself from whatever its SessionManager holds,
172
+ * so pointing it at an existing file rehydrates that agent's history and the
173
+ * prompt continues it. Everything else — tools, model, system prompt, turn
174
+ * caps — is still resolved from the agent type, so the continuation runs
175
+ * under the type's *current* definition, not the one the original run used.
176
+ */
177
+ resumeSessionFile?: string;
178
+ /**
179
+ * True when another agent spawned this one. Only top-level agents get a
180
+ * handle, so only they can be reopened by name — which is the whole reason
181
+ * `rememberAgents` persists a session at all. A nested run's transcript would
182
+ * be unreachable by anything, so it stays in memory unless its own
183
+ * frontmatter asks otherwise.
184
+ */
185
+ nested?: boolean;
186
+ /**
187
+ * True when a workflow run spawned this agent. Its final text is the value
188
+ * `agent()` resolves to rather than a report a person reads, and the prompt
189
+ * says so — but only when `structuredOutput` is unset, since that child
190
+ * already has a `StructuredOutput` tool to answer through and two competing
191
+ * "this is how you return your answer" instructions is worse than one.
192
+ */
193
+ workflow?: boolean;
194
+ /** Override working directory (e.g. for worktree isolation). */
195
+ cwd?: string;
196
+ /**
197
+ * Directory the worktree copy was created from. Set only when `cwd` points
198
+ * into a worktree — the prompt then tells the agent to stay in the copy
199
+ * instead of following the inherited parent prompt back to the main tree.
200
+ */
201
+ worktreeBase?: string;
202
+ /**
203
+ * Where .pi config is discovered (project extensions, skills, pi settings,
204
+ * agent memory). Default: same as the working directory. The manager sets
205
+ * this to the parent session's cwd when `SpawnOptions.cwd` points the
206
+ * working directory elsewhere — the agent works *there* but carries the
207
+ * parent project's config (the target's `.pi` extensions never execute).
208
+ *
209
+ * WARNING for future callers: if you pass `cwd` pointing at a directory the
210
+ * user didn't open, you almost certainly must pass `configCwd` too —
211
+ * omitting it makes the target's `.pi` extensions execute in this process.
212
+ * (Worktree isolation is the one intentional exception: its copy IS the
213
+ * parent's repo, so config resolving inside it is correct.)
214
+ */
215
+ configCwd?: string;
216
+ /** Called on tool start/end with activity info. */
217
+ onToolActivity?: (activity: ToolActivity) => void;
218
+ /** Called on streaming text deltas from the assistant response. */
219
+ onTextDelta?: (delta: string, fullText: string) => void;
220
+ onSessionCreated?: (session: AgentSession) => void;
221
+ /** Called at the end of each agentic turn with the cumulative count. */
222
+ onTurnEnd?: (turnCount: number) => void;
223
+ /**
224
+ * Called once per assistant message_end with that message's usage delta.
225
+ * Lets callers maintain a lifetime accumulator that survives compaction
226
+ * (which replaces session.state.messages and resets stats-derived sums).
227
+ *
228
+ * `cost` is pi's own `usage.cost.total` for that message — priced from the
229
+ * model's rates, so it is 0 (not missing) for a model pi has no pricing for.
230
+ * We never price anything ourselves; every dollar figure this extension shows
231
+ * or reports traces back to this field.
232
+ */
233
+ onAssistantUsage?: (usage: LifetimeUsage) => void;
234
+ /**
235
+ * Called when the session successfully compacts. `tokensBefore` is upstream's
236
+ * pre-compaction context size estimate. Aborted compactions don't fire.
237
+ */
238
+ onCompaction?: (info: {
239
+ reason: "manual" | "threshold" | "overflow";
240
+ tokensBefore: number;
241
+ }) => void;
242
+ /**
243
+ * Make this child report through a `StructuredOutput` tool built from this
244
+ * schema, and put the validated payload on {@link RunResult.structuredJson}.
245
+ *
246
+ * Already compiled by the caller, so a schema this runtime cannot validate
247
+ * fails at the call that wrote it rather than inside the child.
248
+ */
249
+ structuredOutput?: CompiledSchema;
250
+ /** Runtime bridge for opt-in child-safe nested delegation. */
251
+ nestedRuntime?: {
252
+ manager: NestedAgentManager;
253
+ parentAgentId: string;
254
+ depth: number;
255
+ maxSubagentDepth?: number;
256
+ };
257
+ }
258
+ export interface RunResult {
259
+ responseText: string;
260
+ session: AgentSession;
261
+ /** True if the agent was hard-aborted (max_turns + grace exceeded). */
262
+ aborted: boolean;
263
+ /** True if the agent was steered to wrap up (hit soft turn limit) but finished in time. */
264
+ steered: boolean;
265
+ /**
266
+ * A failure message for the run's FINAL assistant turn, when that turn failed:
267
+ * a provider error (stopReason "error"), or a "length" stop that produced no
268
+ * text (a silent max-token death). pi resolves an exhausted-retries failure
269
+ * normally instead of rejecting, so without this the manager would report such
270
+ * a run as completed — with an empty result, or worse, an earlier turn's text
271
+ * presented as the answer (#144). Undefined for a clean stop, or a "length"
272
+ * stop that produced text (a legitimate truncated answer).
273
+ */
274
+ failure?: string;
275
+ /**
276
+ * The validated `StructuredOutput` payload as canonical JSON, when the caller
277
+ * asked for a schema and the child produced one.
278
+ *
279
+ * Deliberately not folded into {@link responseText}: `record.result` picks up
280
+ * a worktree branch note on the way out, which would leave the caller with
281
+ * unparseable JSON, and merging the two would make "produced structured
282
+ * output" indistinguishable from "happened to answer in JSON".
283
+ */
284
+ structuredJson?: string;
285
+ /** Whether the extra structured-output prompt had to be sent. */
286
+ structuredRetried?: boolean;
287
+ }
288
+ export declare function runAgent(ctx: ExtensionContext, type: SubagentType, prompt: string, options: RunOptions): Promise<RunResult>;
289
+ /**
290
+ * Send a new prompt to an existing session (resume).
291
+ */
292
+ export declare function resumeAgent(session: AgentSession, prompt: string, options?: {
293
+ onToolActivity?: (activity: ToolActivity) => void;
294
+ onAssistantUsage?: (usage: LifetimeUsage) => void;
295
+ onCompaction?: (info: {
296
+ reason: "manual" | "threshold" | "overflow";
297
+ tokensBefore: number;
298
+ }) => void;
299
+ signal?: AbortSignal;
300
+ }): Promise<{
301
+ text: string;
302
+ failure?: string;
303
+ }>;
304
+ /**
305
+ * Send a steering message to a running subagent.
306
+ * The message will interrupt the agent after its current tool execution.
307
+ */
308
+ export declare function steerAgent(session: AgentSession, message: string): Promise<void>;
309
+ /**
310
+ * Get the subagent's conversation messages as formatted text.
311
+ */
312
+ export declare function getAgentConversation(session: AgentSession): string;