@esso0428/pi-subagents 0.17.5 → 0.17.7

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 (263) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/README.md +1 -1
  4. package/dist/abortable.d.ts +13 -0
  5. package/dist/abortable.d.ts.map +1 -0
  6. package/dist/abortable.js +43 -0
  7. package/dist/abortable.js.map +1 -0
  8. package/dist/agent-color.d.ts +36 -0
  9. package/dist/agent-color.d.ts.map +1 -0
  10. package/dist/agent-color.js +124 -0
  11. package/dist/agent-color.js.map +1 -0
  12. package/dist/agent-file-toggle.d.ts +126 -0
  13. package/dist/agent-file-toggle.d.ts.map +1 -0
  14. package/dist/agent-file-toggle.js +259 -0
  15. package/dist/agent-file-toggle.js.map +1 -0
  16. package/dist/agent-history.d.ts +4 -0
  17. package/dist/agent-history.d.ts.map +1 -1
  18. package/dist/agent-history.js +47 -1
  19. package/dist/agent-history.js.map +1 -1
  20. package/dist/agent-manager.d.ts +370 -56
  21. package/dist/agent-manager.d.ts.map +1 -1
  22. package/dist/agent-manager.js +1123 -409
  23. package/dist/agent-manager.js.map +1 -1
  24. package/dist/agent-runner.d.ts +100 -10
  25. package/dist/agent-runner.d.ts.map +1 -1
  26. package/dist/agent-runner.js +166 -21
  27. package/dist/agent-runner.js.map +1 -1
  28. package/dist/agent-types.d.ts +57 -5
  29. package/dist/agent-types.d.ts.map +1 -1
  30. package/dist/agent-types.js +164 -32
  31. package/dist/agent-types.js.map +1 -1
  32. package/dist/child-context.d.ts +3 -0
  33. package/dist/child-context.d.ts.map +1 -0
  34. package/dist/child-context.js +13 -0
  35. package/dist/child-context.js.map +1 -0
  36. package/dist/cross-extension-rpc.d.ts +23 -3
  37. package/dist/cross-extension-rpc.d.ts.map +1 -1
  38. package/dist/cross-extension-rpc.js +79 -17
  39. package/dist/cross-extension-rpc.js.map +1 -1
  40. package/dist/custom-agents.d.ts +38 -1
  41. package/dist/custom-agents.d.ts.map +1 -1
  42. package/dist/custom-agents.js +164 -12
  43. package/dist/custom-agents.js.map +1 -1
  44. package/dist/index.d.ts +34 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1908 -495
  47. package/dist/index.js.map +1 -1
  48. package/dist/invocation-config.d.ts +87 -2
  49. package/dist/invocation-config.d.ts.map +1 -1
  50. package/dist/invocation-config.js +71 -3
  51. package/dist/invocation-config.js.map +1 -1
  52. package/dist/mention-clone.d.ts +88 -0
  53. package/dist/mention-clone.d.ts.map +1 -0
  54. package/dist/mention-clone.js +154 -0
  55. package/dist/mention-clone.js.map +1 -0
  56. package/dist/mention.d.ts +82 -0
  57. package/dist/mention.d.ts.map +1 -0
  58. package/dist/mention.js +132 -0
  59. package/dist/mention.js.map +1 -0
  60. package/dist/model-resolver.d.ts +17 -0
  61. package/dist/model-resolver.d.ts.map +1 -1
  62. package/dist/model-resolver.js +15 -0
  63. package/dist/model-resolver.js.map +1 -1
  64. package/dist/model-scope.d.ts +50 -0
  65. package/dist/model-scope.d.ts.map +1 -0
  66. package/dist/model-scope.js +49 -0
  67. package/dist/model-scope.js.map +1 -0
  68. package/dist/nested-tools.d.ts +57 -0
  69. package/dist/nested-tools.d.ts.map +1 -0
  70. package/dist/nested-tools.js +301 -0
  71. package/dist/nested-tools.js.map +1 -0
  72. package/dist/output-file.d.ts +22 -3
  73. package/dist/output-file.d.ts.map +1 -1
  74. package/dist/output-file.js +58 -7
  75. package/dist/output-file.js.map +1 -1
  76. package/dist/prompts.d.ts +23 -0
  77. package/dist/prompts.d.ts.map +1 -1
  78. package/dist/prompts.js +20 -2
  79. package/dist/prompts.js.map +1 -1
  80. package/dist/schedule.d.ts.map +1 -1
  81. package/dist/schedule.js +36 -15
  82. package/dist/schedule.js.map +1 -1
  83. package/dist/settings.d.ts +228 -2
  84. package/dist/settings.d.ts.map +1 -1
  85. package/dist/settings.js +94 -0
  86. package/dist/settings.js.map +1 -1
  87. package/dist/status-note.d.ts +49 -1
  88. package/dist/status-note.d.ts.map +1 -1
  89. package/dist/status-note.js +62 -1
  90. package/dist/status-note.js.map +1 -1
  91. package/dist/structured-output.d.ts +62 -0
  92. package/dist/structured-output.d.ts.map +1 -0
  93. package/dist/structured-output.js +113 -0
  94. package/dist/structured-output.js.map +1 -0
  95. package/dist/types.d.ts +176 -10
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/ui/agent-mention.d.ts +83 -0
  98. package/dist/ui/agent-mention.d.ts.map +1 -0
  99. package/dist/ui/agent-mention.js +188 -0
  100. package/dist/ui/agent-mention.js.map +1 -0
  101. package/dist/ui/agent-widget.d.ts +96 -75
  102. package/dist/ui/agent-widget.d.ts.map +1 -1
  103. package/dist/ui/agent-widget.js +397 -420
  104. package/dist/ui/agent-widget.js.map +1 -1
  105. package/dist/ui/conversation-blocks.d.ts.map +1 -1
  106. package/dist/ui/conversation-blocks.js +6 -0
  107. package/dist/ui/conversation-blocks.js.map +1 -1
  108. package/dist/ui/conversation-timeline.d.ts +10 -2
  109. package/dist/ui/conversation-timeline.d.ts.map +1 -1
  110. package/dist/ui/conversation-timeline.js +130 -23
  111. package/dist/ui/conversation-timeline.js.map +1 -1
  112. package/dist/ui/conversation-viewer.d.ts +20 -5
  113. package/dist/ui/conversation-viewer.d.ts.map +1 -1
  114. package/dist/ui/conversation-viewer.js +274 -73
  115. package/dist/ui/conversation-viewer.js.map +1 -1
  116. package/dist/ui/fleet-list.d.ts +198 -0
  117. package/dist/ui/fleet-list.d.ts.map +1 -0
  118. package/dist/ui/fleet-list.js +487 -0
  119. package/dist/ui/fleet-list.js.map +1 -0
  120. package/dist/ui/schedule-menu.d.ts.map +1 -1
  121. package/dist/ui/schedule-menu.js +6 -7
  122. package/dist/ui/schedule-menu.js.map +1 -1
  123. package/dist/ui/select-item.d.ts +28 -0
  124. package/dist/ui/select-item.d.ts.map +1 -0
  125. package/dist/ui/select-item.js +35 -0
  126. package/dist/ui/select-item.js.map +1 -0
  127. package/dist/ui/workflow-card.d.ts +176 -0
  128. package/dist/ui/workflow-card.d.ts.map +1 -0
  129. package/dist/ui/workflow-card.js +333 -0
  130. package/dist/ui/workflow-card.js.map +1 -0
  131. package/dist/ui/workflow-dialog.d.ts +306 -0
  132. package/dist/ui/workflow-dialog.d.ts.map +1 -0
  133. package/dist/ui/workflow-dialog.js +844 -0
  134. package/dist/ui/workflow-dialog.js.map +1 -0
  135. package/dist/ui/workflow-menu.d.ts +61 -0
  136. package/dist/ui/workflow-menu.d.ts.map +1 -0
  137. package/dist/ui/workflow-menu.js +148 -0
  138. package/dist/ui/workflow-menu.js.map +1 -0
  139. package/dist/usage.d.ts +86 -1
  140. package/dist/usage.d.ts.map +1 -1
  141. package/dist/usage.js +72 -1
  142. package/dist/usage.js.map +1 -1
  143. package/dist/workflow/collisions.d.ts +96 -0
  144. package/dist/workflow/collisions.d.ts.map +1 -0
  145. package/dist/workflow/collisions.js +89 -0
  146. package/dist/workflow/collisions.js.map +1 -0
  147. package/dist/workflow/entry.d.ts +33 -0
  148. package/dist/workflow/entry.d.ts.map +1 -0
  149. package/dist/workflow/entry.js +30 -0
  150. package/dist/workflow/entry.js.map +1 -0
  151. package/dist/workflow/host.d.ts +63 -0
  152. package/dist/workflow/host.d.ts.map +1 -0
  153. package/dist/workflow/host.js +363 -0
  154. package/dist/workflow/host.js.map +1 -0
  155. package/dist/workflow/journal.d.ts +98 -0
  156. package/dist/workflow/journal.d.ts.map +1 -0
  157. package/dist/workflow/journal.js +121 -0
  158. package/dist/workflow/journal.js.map +1 -0
  159. package/dist/workflow/json-schema.d.ts +52 -0
  160. package/dist/workflow/json-schema.d.ts.map +1 -0
  161. package/dist/workflow/json-schema.js +112 -0
  162. package/dist/workflow/json-schema.js.map +1 -0
  163. package/dist/workflow/meta.d.ts +68 -0
  164. package/dist/workflow/meta.d.ts.map +1 -0
  165. package/dist/workflow/meta.js +318 -0
  166. package/dist/workflow/meta.js.map +1 -0
  167. package/dist/workflow/progress.d.ts +225 -0
  168. package/dist/workflow/progress.d.ts.map +1 -0
  169. package/dist/workflow/progress.js +362 -0
  170. package/dist/workflow/progress.js.map +1 -0
  171. package/dist/workflow/runtime.d.ts +335 -0
  172. package/dist/workflow/runtime.d.ts.map +1 -0
  173. package/dist/workflow/runtime.js +831 -0
  174. package/dist/workflow/runtime.js.map +1 -0
  175. package/dist/workflow/saved.d.ts +91 -0
  176. package/dist/workflow/saved.d.ts.map +1 -0
  177. package/dist/workflow/saved.js +204 -0
  178. package/dist/workflow/saved.js.map +1 -0
  179. package/dist/workflow/task.d.ts +137 -0
  180. package/dist/workflow/task.d.ts.map +1 -0
  181. package/dist/workflow/task.js +208 -0
  182. package/dist/workflow/task.js.map +1 -0
  183. package/dist/workflow/tool-description.d.ts +39 -0
  184. package/dist/workflow/tool-description.d.ts.map +1 -0
  185. package/dist/workflow/tool-description.js +200 -0
  186. package/dist/workflow/tool-description.js.map +1 -0
  187. package/dist/workflow/worker-source.d.ts +48 -0
  188. package/dist/workflow/worker-source.d.ts.map +1 -0
  189. package/dist/workflow/worker-source.js +779 -0
  190. package/dist/workflow/worker-source.js.map +1 -0
  191. package/dist/worktree.d.ts +10 -3
  192. package/dist/worktree.d.ts.map +1 -1
  193. package/dist/worktree.js +58 -54
  194. package/dist/worktree.js.map +1 -1
  195. package/dist/xml.d.ts +11 -0
  196. package/dist/xml.d.ts.map +1 -0
  197. package/dist/xml.js +13 -0
  198. package/dist/xml.js.map +1 -0
  199. package/docs/rpc.md +183 -0
  200. package/docs/superpowers/plans/2026-09-30-conversation-viewer-scrollbar.md +216 -0
  201. package/docs/superpowers/plans/2026-09-30-upstream-event-workflow-partial-history.md +195 -0
  202. package/docs/superpowers/specs/2026-09-30-conversation-viewer-scrollbar-design.md +82 -0
  203. package/docs/superpowers/specs/2026-09-30-upstream-event-workflow-partial-history-design.md +49 -0
  204. package/docs/workflows.md +437 -0
  205. package/examples/agent-tool-description.md +7 -7
  206. package/examples/workflows/compose.js +51 -0
  207. package/examples/workflows/fan-out-audit.js +47 -0
  208. package/examples/workflows/gated-fix.js +60 -0
  209. package/examples/workflows/lib/count-child.js +27 -0
  210. package/examples/workflows/review-panel.js +63 -0
  211. package/examples/workflows/structured-findings.js +78 -0
  212. package/package.json +1 -1
  213. package/src/abortable.ts +43 -0
  214. package/src/agent-color.ts +161 -0
  215. package/src/agent-file-toggle.ts +269 -0
  216. package/src/agent-history.ts +54 -2
  217. package/src/agent-manager.ts +1263 -402
  218. package/src/agent-runner.ts +251 -27
  219. package/src/agent-types.ts +188 -32
  220. package/src/child-context.ts +15 -0
  221. package/src/cross-extension-rpc.ts +96 -20
  222. package/src/custom-agents.ts +170 -13
  223. package/src/index.ts +2024 -537
  224. package/src/invocation-config.ts +118 -3
  225. package/src/mention-clone.ts +196 -0
  226. package/src/mention.ts +141 -0
  227. package/src/model-resolver.ts +18 -0
  228. package/src/model-scope.ts +70 -0
  229. package/src/nested-tools.ts +424 -0
  230. package/src/output-file.ts +61 -6
  231. package/src/prompts.ts +45 -2
  232. package/src/schedule.ts +35 -14
  233. package/src/settings.ts +312 -2
  234. package/src/status-note.ts +66 -1
  235. package/src/structured-output.ts +130 -0
  236. package/src/types.ts +177 -10
  237. package/src/ui/agent-mention.ts +216 -0
  238. package/src/ui/agent-widget.ts +389 -441
  239. package/src/ui/conversation-blocks.ts +6 -0
  240. package/src/ui/conversation-timeline.ts +139 -25
  241. package/src/ui/conversation-viewer.ts +284 -69
  242. package/src/ui/fleet-list.ts +558 -0
  243. package/src/ui/schedule-menu.ts +9 -8
  244. package/src/ui/select-item.ts +45 -0
  245. package/src/ui/workflow-card.ts +470 -0
  246. package/src/ui/workflow-dialog.ts +1115 -0
  247. package/src/ui/workflow-menu.ts +193 -0
  248. package/src/usage.ts +109 -2
  249. package/src/workflow/collisions.ts +123 -0
  250. package/src/workflow/entry.ts +47 -0
  251. package/src/workflow/host.ts +403 -0
  252. package/src/workflow/journal.ts +164 -0
  253. package/src/workflow/json-schema.ts +128 -0
  254. package/src/workflow/meta.ts +325 -0
  255. package/src/workflow/progress.ts +550 -0
  256. package/src/workflow/runtime.ts +1219 -0
  257. package/src/workflow/saved.ts +217 -0
  258. package/src/workflow/task.ts +302 -0
  259. package/src/workflow/tool-description.ts +200 -0
  260. package/src/workflow/worker-source.ts +781 -0
  261. package/src/worktree.ts +69 -55
  262. package/src/xml.ts +13 -0
  263. package/vitest.config.ts +0 -18
package/src/schedule.ts CHANGED
@@ -19,6 +19,8 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
19
19
  import { Cron } from "croner";
20
20
  import { nanoid } from "nanoid";
21
21
  import type { AgentManager } from "./agent-manager.js";
22
+ import { normalizeMaxTurns } from "./agent-runner.js";
23
+ import { resolveSpawnType } from "./agent-types.js";
22
24
  import { resolveModel } from "./model-resolver.js";
23
25
  import type { ScheduleStore } from "./schedule-store.js";
24
26
  import type { IsolationMode, ScheduledSubagent, SubagentType, ThinkingLevel } from "./types.js";
@@ -238,7 +240,15 @@ export class SubagentScheduler {
238
240
 
239
241
  let agentId: string;
240
242
  try {
241
- agentId = manager.spawn(pi, ctx, job.subagent_type, job.prompt, {
243
+ // Re-resolve at fire time against the registry as it stands. This does not
244
+ // reload from disk (the scheduler has no reason to rebuild process-global
245
+ // state from a timer), so it catches changes that went through /agents or
246
+ // an Agent call — not a file deleted directly from a shell. The catch below turns
247
+ // this into lastStatus: "error" plus an error event, like any other
248
+ // fire-time failure.
249
+ const dispatch = resolveSpawnType(job.subagent_type);
250
+ if (!dispatch.ok) throw new Error(dispatch.message);
251
+ agentId = manager.spawn(pi, ctx, dispatch.type, job.prompt, {
242
252
  description: job.description,
243
253
  isBackground: true,
244
254
  bypassQueue: true,
@@ -247,6 +257,20 @@ export class SubagentScheduler {
247
257
  isolated: job.isolated,
248
258
  thinkingLevel: job.thinking,
249
259
  isolation: job.isolation,
260
+ // A scheduled run has no tool call to build this, so without it the
261
+ // conversation viewer shows nothing about how the job was configured.
262
+ // The model is left out on purpose: agent-manager fills in the effective
263
+ // one when the session reports it, and naming the pre-session pick here
264
+ // would only be right until then.
265
+ invocation: {
266
+ thinking: job.thinking,
267
+ // Normalized like the Agent tool's own snapshot: `0` means unlimited,
268
+ // and rendering it as "max turns: 0" would read as a limit of none.
269
+ maxTurns: normalizeMaxTurns(job.max_turns),
270
+ isolated: job.isolated,
271
+ runInBackground: true,
272
+ isolation: job.isolation,
273
+ },
250
274
  });
251
275
  } catch (err) {
252
276
  const error = err instanceof Error ? err.message : String(err);
@@ -257,7 +281,6 @@ export class SubagentScheduler {
257
281
 
258
282
  this.emit({ type: "fired", jobId: id, agentId, name: job.name });
259
283
 
260
- const record = manager.getRecord(agentId);
261
284
  const finalize = (status: "success" | "error") => {
262
285
  const next = this.getNextRun(id);
263
286
  const current = store.get(id);
@@ -272,18 +295,16 @@ export class SubagentScheduler {
272
295
  // AgentManager's promise resolves either way (its .catch returns ""), so we
273
296
  // can't infer success/failure from the promise — read record.status instead.
274
297
  // Terminal states: completed/steered = success; error/aborted/stopped = error.
275
- if (record?.promise) {
276
- record.promise
277
- .then(() => {
278
- const r = manager.getRecord(agentId);
279
- const failed = r?.status === "error" || r?.status === "aborted" || r?.status === "stopped";
280
- finalize(failed ? "error" : "success");
281
- })
282
- .catch(() => finalize("error"));
283
- } else {
284
- // Spawn returned without a promise (defensive — bypassQueue path always sets one).
285
- finalize("success");
286
- }
298
+ // awaitStartup first: with isolation: "worktree" the run promise only exists
299
+ // once the repo copy is made, and a failed copy rejects here.
300
+ manager.awaitStartup(agentId)
301
+ .then(() => manager.getRecord(agentId)?.promise)
302
+ .then(() => {
303
+ const r = manager.getRecord(agentId);
304
+ const failed = r?.status === "error" || r?.status === "aborted" || r?.status === "stopped";
305
+ finalize(failed ? "error" : "success");
306
+ })
307
+ .catch(() => finalize("error"));
287
308
  }
288
309
 
289
310
  private emit(event: ScheduleChangeEvent): void {
package/src/settings.ts CHANGED
@@ -5,10 +5,33 @@
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
7
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
8
- import type { JoinMode, WidgetMode } from "./types.js";
8
+ import { NO_FALLBACK } from "./agent-types.js";
9
+ import type { AgentMentionMode, JoinMode, ViewerMarkdownMode, WidgetMode } from "./types.js";
9
10
 
10
11
  export interface SubagentsSettings {
11
12
  maxConcurrent?: number;
13
+ /**
14
+ * Max concurrent FOREGROUND (blocking) agents — `0` = unlimited, the default,
15
+ * which preserves the behaviour that has always applied: nothing bounded
16
+ * foreground work, and pi dispatches a message's tool calls through
17
+ * `Promise.all`, so an unqualified fan-out of blocking `Agent` calls runs all
18
+ * at once. Set it to bound that (#253 — on local models, parallel agents
19
+ * thrash the prompt cache).
20
+ *
21
+ * Deliberately independent of `maxConcurrent` rather than folded into it: a
22
+ * foreground agent blocks the parent anyway, so charging it to the background
23
+ * pool would let a saturated pool starve the main session of work it could
24
+ * have done itself.
25
+ *
26
+ * Bounds only spawns a caller is blocking on inline. Nested children are
27
+ * exempt — their parent is blocked awaiting them, so queueing a child behind
28
+ * its own parent would deadlock — and so are detached spawns from
29
+ * cross-extension RPC or `@handle` mentions, which block nobody and are
30
+ * documented to start immediately. Foreground `resume` is also outside the
31
+ * pool: it reuses an existing session and never reaches the spawn path, so
32
+ * several blocking resumes in one message can still exceed the limit.
33
+ */
34
+ maxConcurrentForeground?: number;
12
35
  /**
13
36
  * 0 = unlimited — the extension's single source of truth for that convention:
14
37
  * `normalizeMaxTurns()` in agent-runner.ts treats 0 → `undefined`, and the
@@ -17,6 +40,23 @@ export interface SubagentsSettings {
17
40
  defaultMaxTurns?: number;
18
41
  graceTurns?: number;
19
42
  defaultJoinMode?: JoinMode;
43
+ /**
44
+ * Whether a top-level `Agent` spawn that doesn't say runs detached.
45
+ * Defaults to `true`, following Claude Code, where the agent backgrounds
46
+ * unless the caller passes `run_in_background: false`. Set `false` to restore
47
+ * the previous behaviour, where an unqualified spawn blocked the turn and
48
+ * returned its result inline.
49
+ *
50
+ * Top-level only. Nested spawns (a subagent spawning its own) always default
51
+ * to foreground regardless of this setting — see `nested-tools.ts`, where a
52
+ * detached child would be killed by `abortOwnedChildren` when its parent
53
+ * settles, with no notification path to deliver its result.
54
+ *
55
+ * An explicit `run_in_background` on the call, or in the agent file's
56
+ * frontmatter, overrides this in both directions; the setting only decides
57
+ * what "unspecified" means.
58
+ */
59
+ backgroundByDefault?: boolean;
20
60
  /**
21
61
  * Master switch for the schedule subagent feature. Defaults to `true`.
22
62
  * When `false`: the `Agent` tool's `schedule` param + its guideline are
@@ -48,6 +88,18 @@ export interface SubagentsSettings {
48
88
  * against. Defaults to false: subagents may use any model.
49
89
  */
50
90
  scopeModels?: boolean;
91
+ /**
92
+ * When true, an unreadable or unparseable agent `.md` aborts extension load
93
+ * instead of being skipped with a warning — pi exits, naming the file.
94
+ *
95
+ * Startup only, by design. Mid-session reloads (one per `Agent` call) keep
96
+ * warning: a bad edit at 3pm should not kill the session on the next
97
+ * unrelated spawn, where the failure would look disconnected from its cause.
98
+ * For a checked-in `.pi/agents/`, failing at startup is the point — the
99
+ * alternative is running a *different* agent than the file names.
100
+ * Defaults to false.
101
+ */
102
+ strictAgentFiles?: boolean;
51
103
  /**
52
104
  * When true, the three built-in default agents (general-purpose, Explore, Plan)
53
105
  * are not registered at startup. User-defined agents from project/global custom
@@ -66,6 +118,40 @@ export interface SubagentsSettings {
66
118
  * next pi session.
67
119
  */
68
120
  toolDescriptionMode?: ToolDescriptionMode;
121
+ /**
122
+ * Whether the Claude Code-style FleetView (the navigable main+subagents list
123
+ * rendered below the editor) is shown. Defaults to `true`. Pure-UI: when off,
124
+ * the list never registers and the global key handler never captures input.
125
+ */
126
+ fleetView?: boolean;
127
+ /**
128
+ * Whether `@handle message` typed at the prompt is routed to that subagent
129
+ * instead of the main model, and whether `@` offers running agents alongside
130
+ * pi's file completion. Defaults to `model`. Applied live.
131
+ *
132
+ * - `model`: mentioning an agent that is not running asks the main model to
133
+ * spawn it with the `Agent` tool, Claude Code's behaviour. Costs a turn,
134
+ * and the model writes the agent's prompt rather than your text being it.
135
+ * - `direct`: that agent is started here instead, with the typed message as
136
+ * its prompt and no main-model turn spent.
137
+ * - `off`: the input hook falls straight through and the stacked
138
+ * autocomplete provider delegates everything back to pi's built-in one.
139
+ *
140
+ * Messaging a running agent and resuming a finished one are direct in both
141
+ * `model` and `direct`. The legacy booleans are still accepted: `true` reads
142
+ * as `model`, `false` as `off`.
143
+ */
144
+ agentMentions?: AgentMentionMode;
145
+ /**
146
+ * Whether subagents persist their pi session by default, so `@handle` can
147
+ * reopen an agent's conversation long after its in-memory record is gone.
148
+ * Defaults to `true`. Per-agent `persist_session:` frontmatter overrides it
149
+ * in both directions. Turning it off restores the previous behaviour, where
150
+ * a handle stops resolving roughly ten minutes after the agent finishes and
151
+ * mentioning it starts a fresh run instead. Persisted sessions also appear
152
+ * nested under the spawning session in pi's `/resume`.
153
+ */
154
+ rememberAgents?: boolean;
69
155
  /**
70
156
  * Display mode for the persistent above-editor agent widget:
71
157
  * - `all`: show every agent (foreground + background).
@@ -73,7 +159,7 @@ export interface SubagentsSettings {
73
159
  * Agent tool result, so the widget would otherwise double-render them
74
160
  * (#118); everything else (background, queued, scheduled, RPC) stays.
75
161
  * - `off`: hide the widget entirely.
76
- * Defaults to `all`. Pure-UI and applied live (toggling refreshes the
162
+ * Defaults to `background`. Pure-UI and applied live (toggling refreshes the
77
163
  * widget).
78
164
  */
79
165
  widgetMode?: WidgetMode;
@@ -88,6 +174,134 @@ export interface SubagentsSettings {
88
174
  * (`isolation: worktree`), or memory files.
89
175
  */
90
176
  outputTranscript?: boolean;
177
+ /**
178
+ * Whether `isolation: "worktree"` may create a worktree at all. Defaults to
179
+ * `true`. Set `false` on a repo where worktrees are too slow or too large to
180
+ * be worth it (#184): a requested worktree is then dropped and the agent runs
181
+ * in the main checkout.
182
+ *
183
+ * The drop is deliberately silent — there is no per-result note, because the
184
+ * setting exists for projects whose model asks for a worktree on every call,
185
+ * where a note would be noise on every result. What keeps the orchestrator
186
+ * from claiming a `pi-agent-*` branch anyway is that it is never told the
187
+ * capability exists: `isolationParam` (invocation-config.ts) drops the field
188
+ * from both tool schemas, and `isolationGuideline` (index.ts) drops the
189
+ * matching prose from the full and compact descriptions — a custom one opts
190
+ * in via the `{{isolationGuideline}}` placeholder. Anything that
191
+ * reintroduces the prose has to reintroduce a note with it.
192
+ *
193
+ * Deliberately a downgrade rather than an error. The fail-loud rule covers
194
+ * worktrees that *cannot* be created; this is the user declining one, and
195
+ * throwing would reject exactly the calls that the `isolation: "off"` value
196
+ * exists to tolerate. Enforced below the tool boundary, so it also covers the
197
+ * scheduler and the unvalidated cross-extension RPC path.
198
+ */
199
+ worktreeIsolation?: boolean;
200
+ /**
201
+ * Master switch for scripted workflows. Defaults to `true`.
202
+ *
203
+ * Off is not a soft hide: the `SubagentWorkflow` tool is never registered, so
204
+ * the model is not told it exists and cannot call it, the `/agents`
205
+ * Workflows entry is hidden, and `--subagents-workflow-file` is refused.
206
+ *
207
+ * Absent is not the same as `true`. Unset means *auto*: on, but yielding to
208
+ * another extension that already offers a workflow tool, because two
209
+ * orchestrators in one tool spec is a worse default than none — the model
210
+ * has to guess which to call, and pays for both descriptions to find out.
211
+ * Setting it explicitly pins the answer in both directions: `true` keeps
212
+ * ours whatever else is loaded, `false` is off regardless. See
213
+ * `resolveWorkflowCollisions` in index.ts.
214
+ *
215
+ * Read once at extension init, before registration, so flipping it in
216
+ * `/agents → Settings` takes effect on the next pi session — the same
217
+ * contract `schedulingEnabled` has, and for the same reason: a tool spec is
218
+ * fixed once pi has it.
219
+ */
220
+ workflowsEnabled?: boolean;
221
+ /**
222
+ * Hard ceiling on nested subagent delegation, counted from the main session:
223
+ * main = 0, its subagents = 1, their children = 2. Defaults to `2`; `0` or `1`
224
+ * disables nesting project-wide. Read when a subagent session is built, so a
225
+ * change applies to agents started after it.
226
+ */
227
+ maxSubagentDepth?: number;
228
+ /**
229
+ * Agent type substituted when a caller-supplied `subagent_type` doesn't
230
+ * resolve to exactly one enabled agent (unknown, disabled, or ambiguous by
231
+ * case). Omitted keeps the historical `general-purpose` fallback; a type name
232
+ * routes those calls to that agent instead; `"none"` disables the fallback so
233
+ * dispatch fails closed with an error naming the available types.
234
+ *
235
+ * The boolean `false` is accepted as a spelling of `"none"`, because a boolean
236
+ * would otherwise be dropped as the wrong type and silently leave the
237
+ * PERMISSIVE default in place while the author believes strict dispatch is on
238
+ * — the wrong direction to fail for this setting. Every other value is an
239
+ * agent name, so a mistaken `"off"` fails loudly at dispatch rather than
240
+ * meaning one thing here and another in the resolver.
241
+ */
242
+ fallbackSubagent?: string;
243
+ /**
244
+ * Whether this extension's tool results carry a `usage` field, so subagent
245
+ * spend reaches the parent session's own accounting. Defaults to `false`.
246
+ *
247
+ * Subagents run in their own pi sessions, so by default the parent's footer,
248
+ * statusline and `/cost` show only what the main model spent — a session that
249
+ * delegated most of its work reads as nearly free. Pi folds
250
+ * `toolResult.usage` into `getSessionStats()`, so attaching it makes those
251
+ * surfaces count subagents too, under `/cost`'s "Tools/summaries" bucket.
252
+ *
253
+ * Off by default because it changes numbers the user may already be tracking
254
+ * (a statusline reading session cost will step up), not because the numbers
255
+ * are wrong.
256
+ *
257
+ * Three properties of what gets reported:
258
+ * - Tokens exclude `cacheRead`, for the reason in `usage.ts` — the parent's
259
+ * token total therefore rises by billed tokens only.
260
+ * - Cost is pi's own per-message `usage.cost.total`; we price nothing, and
261
+ * a model pi has no rates for contributes 0.
262
+ * - The context-window percentage is untouched. Pi derives it from assistant
263
+ * messages alone (`getContextUsage`), so a delegating session's context
264
+ * does not appear to fill up faster.
265
+ */
266
+ reportUsage?: boolean;
267
+ /**
268
+ * Whether the subagent surfaces show an estimated dollar cost next to their
269
+ * token counts (widget, FleetView, conversation viewer, foreground results,
270
+ * completion notifications). Defaults to `false`. Applied live.
271
+ *
272
+ * Rendered as `~$0.0042` — the tilde marks it as pi's reported estimate
273
+ * rather than a billed figure, and it is omitted entirely when the model has
274
+ * no pricing data, so a local model shows tokens and no dollars.
275
+ *
276
+ * Independent of `reportUsage`: this one is what a human reads, that one is
277
+ * what the parent session counts.
278
+ */
279
+ showCost?: boolean;
280
+
281
+ /**
282
+ * Whether the widget's running rows name the model driving each agent and the
283
+ * thinking level it is running at.
284
+ *
285
+ * Off by default, unlike the tool result and the conversation viewer, which
286
+ * show the pair unconditionally: those have a line to themselves, while the
287
+ * widget row already carries the description, turns, tool uses, tokens and
288
+ * elapsed time, and every character it gains is one the description loses on a
289
+ * narrow terminal.
290
+ */
291
+ showModel?: boolean;
292
+ /**
293
+ * How much of the conversation viewer's transcript renders as Markdown.
294
+ * Defaults to `assistant`. Applied live — the viewer's `m` key cycles this
295
+ * same setting, so a choice made in the overlay persists like one made in
296
+ * `/agents → Settings`.
297
+ *
298
+ * Scoped rather than all-or-nothing because the two kinds of content have
299
+ * different contracts: assistant text is authored as Markdown, while a tool
300
+ * result is whatever bytes the tool produced. Rendering the latter as
301
+ * Markdown is lossy in ways that look like the tool misbehaved — see
302
+ * `ViewerMarkdownMode` for the specific rewrites — so `all` is opt-in.
303
+ */
304
+ viewerMarkdown?: ViewerMarkdownMode;
91
305
  }
92
306
 
93
307
  export type ToolDescriptionMode = "full" | "compact" | "custom";
@@ -95,15 +309,29 @@ export type ToolDescriptionMode = "full" | "compact" | "custom";
95
309
  /** Setter hooks used by applySettings to wire persisted values into in-memory state. */
96
310
  export interface SettingsAppliers {
97
311
  setMaxConcurrent: (n: number) => void;
312
+ setMaxConcurrentForeground: (n: number) => void;
98
313
  setDefaultMaxTurns: (n: number) => void;
99
314
  setGraceTurns: (n: number) => void;
100
315
  setDefaultJoinMode: (mode: JoinMode) => void;
316
+ setBackgroundByDefault: (b: boolean) => void;
101
317
  setSchedulingEnabled: (b: boolean) => void;
102
318
  setScopeModels: (enabled: boolean) => void;
319
+ setStrictAgentFiles: (b: boolean) => void;
103
320
  setDisableDefaultAgents: (b: boolean) => void;
104
321
  setToolDescriptionMode: (mode: ToolDescriptionMode) => void;
322
+ setFleetView: (b: boolean) => void;
323
+ setAgentMentions: (mode: AgentMentionMode) => void;
324
+ setRememberAgents: (b: boolean) => void;
105
325
  setWidgetMode: (mode: WidgetMode) => void;
106
326
  setOutputTranscript: (b: boolean) => void;
327
+ setWorktreeIsolation: (b: boolean) => void;
328
+ setWorkflowsEnabled: (b: boolean) => void;
329
+ setMaxSubagentDepth: (n: number) => void;
330
+ setFallbackSubagent: (v: string | undefined) => void;
331
+ setReportUsage: (b: boolean) => void;
332
+ setShowCost: (b: boolean) => void;
333
+ setShowModel: (b: boolean) => void;
334
+ setViewerMarkdown: (mode: ViewerMarkdownMode) => void;
107
335
  }
108
336
 
109
337
  /** Emit callback — a subset of `pi.events.emit` to keep helpers testable. */
@@ -112,6 +340,8 @@ export type SettingsEmit = (event: string, payload: unknown) => void;
112
340
  const VALID_JOIN_MODES: ReadonlySet<string> = new Set<JoinMode>(["async", "group", "smart"]);
113
341
  const VALID_TOOL_DESCRIPTION_MODES: ReadonlySet<string> = new Set<ToolDescriptionMode>(["full", "compact", "custom"]);
114
342
  const VALID_WIDGET_MODES: ReadonlySet<string> = new Set<WidgetMode>(["all", "background", "off"]);
343
+ const VALID_VIEWER_MARKDOWN_MODES: ReadonlySet<string> = new Set<ViewerMarkdownMode>(["off", "assistant", "all"]);
344
+ const VALID_AGENT_MENTION_MODES: ReadonlySet<string> = new Set<AgentMentionMode>(["model", "direct", "off"]);
115
345
 
116
346
  // Sanity ceilings — prevent hand-edited configs from asking for values that
117
347
  // make no operational sense (e.g. 1e6 concurrent subagents). Permissive enough
@@ -119,6 +349,7 @@ const VALID_WIDGET_MODES: ReadonlySet<string> = new Set<WidgetMode>(["all", "bac
119
349
  const MAX_CONCURRENT_CEILING = 1024;
120
350
  const MAX_TURNS_CEILING = 10_000;
121
351
  const GRACE_TURNS_CEILING = 1_000;
352
+ const SUBAGENT_DEPTH_CEILING = 16;
122
353
 
123
354
  /** Drop fields that don't match the expected shape. Silent — garbage becomes absent. */
124
355
  function sanitize(raw: unknown): SubagentsSettings {
@@ -132,6 +363,15 @@ function sanitize(raw: unknown): SubagentsSettings {
132
363
  ) {
133
364
  out.maxConcurrent = r.maxConcurrent as number;
134
365
  }
366
+ // Floor 0, not 1 like maxConcurrent above: 0 is the documented "unlimited"
367
+ // value and the default, so dropping it would silently be unrepresentable.
368
+ if (
369
+ Number.isInteger(r.maxConcurrentForeground) &&
370
+ (r.maxConcurrentForeground as number) >= 0 &&
371
+ (r.maxConcurrentForeground as number) <= MAX_CONCURRENT_CEILING
372
+ ) {
373
+ out.maxConcurrentForeground = r.maxConcurrentForeground as number;
374
+ }
135
375
  if (
136
376
  Number.isInteger(r.defaultMaxTurns) &&
137
377
  (r.defaultMaxTurns as number) >= 0 &&
@@ -146,27 +386,81 @@ function sanitize(raw: unknown): SubagentsSettings {
146
386
  ) {
147
387
  out.graceTurns = r.graceTurns as number;
148
388
  }
389
+ if (
390
+ Number.isInteger(r.maxSubagentDepth) &&
391
+ (r.maxSubagentDepth as number) >= 0 &&
392
+ (r.maxSubagentDepth as number) <= SUBAGENT_DEPTH_CEILING
393
+ ) {
394
+ out.maxSubagentDepth = r.maxSubagentDepth as number;
395
+ }
149
396
  if (typeof r.defaultJoinMode === "string" && VALID_JOIN_MODES.has(r.defaultJoinMode)) {
150
397
  out.defaultJoinMode = r.defaultJoinMode as JoinMode;
151
398
  }
399
+ if (typeof r.backgroundByDefault === "boolean") {
400
+ out.backgroundByDefault = r.backgroundByDefault;
401
+ }
152
402
  if (typeof r.schedulingEnabled === "boolean") {
153
403
  out.schedulingEnabled = r.schedulingEnabled;
154
404
  }
155
405
  if (typeof r.scopeModels === "boolean") {
156
406
  out.scopeModels = r.scopeModels;
157
407
  }
408
+ if (typeof r.strictAgentFiles === "boolean") {
409
+ out.strictAgentFiles = r.strictAgentFiles;
410
+ }
158
411
  if (typeof r.disableDefaultAgents === "boolean") {
159
412
  out.disableDefaultAgents = r.disableDefaultAgents;
160
413
  }
161
414
  if (typeof r.toolDescriptionMode === "string" && VALID_TOOL_DESCRIPTION_MODES.has(r.toolDescriptionMode)) {
162
415
  out.toolDescriptionMode = r.toolDescriptionMode as ToolDescriptionMode;
163
416
  }
417
+ if (typeof r.fleetView === "boolean") {
418
+ out.fleetView = r.fleetView;
419
+ }
420
+ // Was a boolean before the `model` mode existed. A hand-written or
421
+ // previously-written `true` means "on", which is now the default `model`.
422
+ if (typeof r.agentMentions === "boolean") {
423
+ out.agentMentions = r.agentMentions ? "model" : "off";
424
+ } else if (typeof r.agentMentions === "string" && VALID_AGENT_MENTION_MODES.has(r.agentMentions)) {
425
+ out.agentMentions = r.agentMentions as AgentMentionMode;
426
+ }
427
+ if (typeof r.rememberAgents === "boolean") {
428
+ out.rememberAgents = r.rememberAgents;
429
+ }
164
430
  if (typeof r.widgetMode === "string" && VALID_WIDGET_MODES.has(r.widgetMode)) {
165
431
  out.widgetMode = r.widgetMode as WidgetMode;
166
432
  }
167
433
  if (typeof r.outputTranscript === "boolean") {
168
434
  out.outputTranscript = r.outputTranscript;
169
435
  }
436
+ if (typeof r.worktreeIsolation === "boolean") {
437
+ out.worktreeIsolation = r.worktreeIsolation;
438
+ }
439
+ if (typeof r.reportUsage === "boolean") {
440
+ out.reportUsage = r.reportUsage;
441
+ }
442
+ if (typeof r.showCost === "boolean") {
443
+ out.showCost = r.showCost;
444
+ }
445
+ if (typeof r.showModel === "boolean") {
446
+ out.showModel = r.showModel;
447
+ }
448
+ if (typeof r.viewerMarkdown === "string" && VALID_VIEWER_MARKDOWN_MODES.has(r.viewerMarkdown)) {
449
+ out.viewerMarkdown = r.viewerMarkdown as ViewerMarkdownMode;
450
+ }
451
+ if (typeof r.workflowsEnabled === "boolean") {
452
+ out.workflowsEnabled = r.workflowsEnabled;
453
+ }
454
+ if (r.fallbackSubagent === false) {
455
+ // The only non-string spelling worth accepting: a boolean would otherwise be
456
+ // dropped, silently leaving the PERMISSIVE default in place. Every string is
457
+ // an agent name except the `none` sentinel, which the resolver recognizes —
458
+ // so a mistaken "off" fails loudly at dispatch instead of meaning something
459
+ // different here than it does there.
460
+ out.fallbackSubagent = NO_FALLBACK;
461
+ } else if (typeof r.fallbackSubagent === "string" && r.fallbackSubagent.trim()) {
462
+ out.fallbackSubagent = r.fallbackSubagent.trim();
463
+ }
170
464
  return out;
171
465
  }
172
466
 
@@ -218,15 +512,31 @@ export function saveSettings(s: SubagentsSettings, cwd: string = process.cwd()):
218
512
  /** Apply persisted settings to the in-memory state via caller-supplied setters. */
219
513
  export function applySettings(s: SubagentsSettings, appliers: SettingsAppliers): void {
220
514
  if (typeof s.maxConcurrent === "number") appliers.setMaxConcurrent(s.maxConcurrent);
515
+ if (typeof s.maxConcurrentForeground === "number") {
516
+ appliers.setMaxConcurrentForeground(s.maxConcurrentForeground);
517
+ }
221
518
  if (typeof s.defaultMaxTurns === "number") appliers.setDefaultMaxTurns(s.defaultMaxTurns);
222
519
  if (typeof s.graceTurns === "number") appliers.setGraceTurns(s.graceTurns);
520
+ if (typeof s.maxSubagentDepth === "number") appliers.setMaxSubagentDepth(s.maxSubagentDepth);
521
+ if (typeof s.fallbackSubagent === "string") appliers.setFallbackSubagent(s.fallbackSubagent);
223
522
  if (s.defaultJoinMode) appliers.setDefaultJoinMode(s.defaultJoinMode);
523
+ if (typeof s.backgroundByDefault === "boolean") appliers.setBackgroundByDefault(s.backgroundByDefault);
224
524
  if (typeof s.schedulingEnabled === "boolean") appliers.setSchedulingEnabled(s.schedulingEnabled);
225
525
  if (typeof s.scopeModels === "boolean") appliers.setScopeModels(s.scopeModels);
526
+ if (typeof s.strictAgentFiles === "boolean") appliers.setStrictAgentFiles(s.strictAgentFiles);
226
527
  if (typeof s.disableDefaultAgents === "boolean") appliers.setDisableDefaultAgents(s.disableDefaultAgents);
227
528
  if (s.toolDescriptionMode) appliers.setToolDescriptionMode(s.toolDescriptionMode);
529
+ if (typeof s.fleetView === "boolean") appliers.setFleetView(s.fleetView);
530
+ if (s.agentMentions) appliers.setAgentMentions(s.agentMentions);
531
+ if (typeof s.rememberAgents === "boolean") appliers.setRememberAgents(s.rememberAgents);
228
532
  if (s.widgetMode) appliers.setWidgetMode(s.widgetMode);
229
533
  if (typeof s.outputTranscript === "boolean") appliers.setOutputTranscript(s.outputTranscript);
534
+ if (typeof s.worktreeIsolation === "boolean") appliers.setWorktreeIsolation(s.worktreeIsolation);
535
+ if (typeof s.reportUsage === "boolean") appliers.setReportUsage(s.reportUsage);
536
+ if (typeof s.showCost === "boolean") appliers.setShowCost(s.showCost);
537
+ if (typeof s.showModel === "boolean") appliers.setShowModel(s.showModel);
538
+ if (s.viewerMarkdown) appliers.setViewerMarkdown(s.viewerMarkdown);
539
+ if (typeof s.workflowsEnabled === "boolean") appliers.setWorkflowsEnabled(s.workflowsEnabled);
230
540
  }
231
541
 
232
542
  /**
@@ -1,7 +1,15 @@
1
1
  /**
2
- * status-note.ts — Parenthetical status note appended to agent result text.
2
+ * status-note.ts — Honest framing for an agent result: the parenthetical status
3
+ * note for a non-normal outcome, and the salvaged partial output of a failure.
4
+ *
5
+ * Lives here rather than in an index.ts closure because both entry points need
6
+ * it — the top-level tools and the nested delegation tools, which can't import
7
+ * from index.ts (that is the extension entry, and it already reaches these tools
8
+ * through agent-runner).
3
9
  */
4
10
 
11
+ import type { AgentRecord } from "./types.js";
12
+
5
13
  /**
6
14
  * Explicit parenthetical note for a non-normal terminal outcome, so the parent
7
15
  * agent can't mistake partial output for a completed result. Empty string for a
@@ -23,3 +31,60 @@ export function getStatusNote(status: string): string {
23
31
  return "";
24
32
  }
25
33
  }
34
+
35
+ /**
36
+ * Foreground variant of `getStatusNote`. A foreground caller is in a different
37
+ * position from a background one, so it needs different text:
38
+ *
39
+ * - It already holds the agent's ENTIRE output inline, whereas the background
40
+ * notification carries a 500-char preview. So only here can we truthfully
41
+ * say there is nothing more to fetch — which is the whole point, because
42
+ * - it has no agent id. The id travels in the tool result's renderer
43
+ * `details`, which is never serialized to the model. A parent that reads
44
+ * "output may be partial" as "truncated, go retrieve the rest" therefore
45
+ * has nothing valid to call `get_subagent_result` with, and will invent an
46
+ * id (#174).
47
+ *
48
+ * Only the lead clause varies between the three, and each variation carries
49
+ * information: `wrapped up` vs `aborted` tells the parent whether the output is
50
+ * a considered final answer or a fragment, and `stopped` shouts because a human
51
+ * intervening outranks everything else in the string. Only `steered` hedges on
52
+ * completion — it was told to wrap up and did, so it may well have finished at
53
+ * the limit; an aborted run blew through its grace turns while still working,
54
+ * and `stopped` can only fire on a running agent, so neither ever delivered a
55
+ * final answer. Identical confidence gets identical wording: phrasing one fact
56
+ * two ways invites a hunt for a distinction that isn't there.
57
+ *
58
+ * Every clause is a statement about state, never an instruction to act, and
59
+ * `get_subagent_result` is never named — naming the tool we steer away from only
60
+ * raises its salience. Two instructions were tried here and cut: "re-spawn with
61
+ * a higher max_turns" (pushes a fresh multi-minute run to save one wasted tool
62
+ * call) and, on `stopped`, "ask before restarting it" (restates the lead, and
63
+ * presumes someone is present to ask — false under `pi -p`, in scheduled jobs,
64
+ * and in any background-driven run). Nothing here can measure whether wording
65
+ * improves parent behavior, so removing a false cue (which cannot induce new
66
+ * behavior) and adding an instruction (which can) are not equally safe bets.
67
+ * Don't add either back without a way to measure it.
68
+ */
69
+ export function getForegroundOutcomeNote(status: string): string {
70
+ switch (status) {
71
+ case "stopped":
72
+ return " (STOPPED BY THE USER — everything the agent produced is above; the task is unfinished)";
73
+ case "aborted":
74
+ return " (aborted at the turn limit — everything the agent produced is above; the task is unfinished)";
75
+ case "steered":
76
+ return " (wrapped up at the turn limit — everything the agent produced is above; the task may be unfinished)";
77
+ default:
78
+ return "";
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Salvaged partial output of a failed run, as a labeled suffix for the error
84
+ * surfaces (or "" if the run produced nothing). `record.result` is bounded to
85
+ * the run's own turns, so this is never a stale earlier answer (#144).
86
+ */
87
+ export function partialOutputSuffix(record: AgentRecord): string {
88
+ const partial = record.result?.trim();
89
+ return partial ? `\n\nPartial output before the failure:\n${partial}` : "";
90
+ }