@astralyn/pi 0.84.4 → 0.84.6

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 +57 -0
  2. package/dist/cli/args.d.ts +1 -0
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +11 -0
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/auth-command.d.ts.map +1 -1
  7. package/dist/cli/auth-command.js +5 -4
  8. package/dist/cli/auth-command.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +6 -1
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +11 -6
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/experimental.d.ts +4 -0
  14. package/dist/core/experimental.d.ts.map +1 -1
  15. package/dist/core/experimental.js +4 -0
  16. package/dist/core/experimental.js.map +1 -1
  17. package/dist/core/extensions/index.d.ts +1 -1
  18. package/dist/core/extensions/index.d.ts.map +1 -1
  19. package/dist/core/extensions/index.js.map +1 -1
  20. package/dist/core/extensions/runner.d.ts +1 -0
  21. package/dist/core/extensions/runner.d.ts.map +1 -1
  22. package/dist/core/extensions/runner.js +10 -0
  23. package/dist/core/extensions/runner.js.map +1 -1
  24. package/dist/core/extensions/types.d.ts +19 -1
  25. package/dist/core/extensions/types.d.ts.map +1 -1
  26. package/dist/core/extensions/types.js.map +1 -1
  27. package/dist/core/keybindings.d.ts +29 -0
  28. package/dist/core/keybindings.d.ts.map +1 -1
  29. package/dist/core/keybindings.js +4 -0
  30. package/dist/core/keybindings.js.map +1 -1
  31. package/dist/core/model-config.d.ts +5 -0
  32. package/dist/core/model-config.d.ts.map +1 -1
  33. package/dist/core/model-config.js +1 -0
  34. package/dist/core/model-config.js.map +1 -1
  35. package/dist/core/model-registry.d.ts +2 -0
  36. package/dist/core/model-registry.d.ts.map +1 -1
  37. package/dist/core/model-registry.js +4 -0
  38. package/dist/core/model-registry.js.map +1 -1
  39. package/dist/core/project-trust.js +2 -2
  40. package/dist/core/project-trust.js.map +1 -1
  41. package/dist/core/sdk.d.ts +5 -3
  42. package/dist/core/sdk.d.ts.map +1 -1
  43. package/dist/core/sdk.js +2 -1
  44. package/dist/core/sdk.js.map +1 -1
  45. package/dist/core/session-manager.js +2 -2
  46. package/dist/core/session-manager.js.map +1 -1
  47. package/dist/core/settings-manager.d.ts +6 -0
  48. package/dist/core/settings-manager.d.ts.map +1 -1
  49. package/dist/core/settings-manager.js +12 -0
  50. package/dist/core/settings-manager.js.map +1 -1
  51. package/dist/core/system-prompt.js +1 -1
  52. package/dist/core/system-prompt.js.map +1 -1
  53. package/dist/core/tools/bash.d.ts +7 -1
  54. package/dist/core/tools/bash.d.ts.map +1 -1
  55. package/dist/core/tools/bash.js +4 -2
  56. package/dist/core/tools/bash.js.map +1 -1
  57. package/dist/core/tools/edit.d.ts.map +1 -1
  58. package/dist/core/tools/edit.js +2 -0
  59. package/dist/core/tools/edit.js.map +1 -1
  60. package/dist/core/tools/find.js +1 -1
  61. package/dist/core/tools/find.js.map +1 -1
  62. package/dist/core/tools/grep.js +1 -1
  63. package/dist/core/tools/grep.js.map +1 -1
  64. package/dist/core/tools/read.d.ts.map +1 -1
  65. package/dist/core/tools/read.js +2 -0
  66. package/dist/core/tools/read.js.map +1 -1
  67. package/dist/core/tools/write.d.ts.map +1 -1
  68. package/dist/core/tools/write.js +2 -0
  69. package/dist/core/tools/write.js.map +1 -1
  70. package/dist/extensions/background/index.d.ts +149 -0
  71. package/dist/extensions/background/index.d.ts.map +1 -0
  72. package/dist/extensions/background/index.js +666 -0
  73. package/dist/extensions/background/index.js.map +1 -0
  74. package/dist/extensions/background/manager.d.ts +95 -0
  75. package/dist/extensions/background/manager.d.ts.map +1 -0
  76. package/dist/extensions/background/manager.js +421 -0
  77. package/dist/extensions/background/manager.js.map +1 -0
  78. package/dist/extensions/background/registry.d.ts +220 -0
  79. package/dist/extensions/background/registry.d.ts.map +1 -0
  80. package/dist/extensions/background/registry.js +589 -0
  81. package/dist/extensions/background/registry.js.map +1 -0
  82. package/dist/extensions/background/render.d.ts +50 -0
  83. package/dist/extensions/background/render.d.ts.map +1 -0
  84. package/dist/extensions/background/render.js +260 -0
  85. package/dist/extensions/background/render.js.map +1 -0
  86. package/dist/extensions/index.d.ts.map +1 -1
  87. package/dist/extensions/index.js +2 -0
  88. package/dist/extensions/index.js.map +1 -1
  89. package/dist/extensions/subagent/activity.d.ts +3 -6
  90. package/dist/extensions/subagent/activity.d.ts.map +1 -1
  91. package/dist/extensions/subagent/activity.js +9 -93
  92. package/dist/extensions/subagent/activity.js.map +1 -1
  93. package/dist/extensions/subagent/agents-command.d.ts.map +1 -1
  94. package/dist/extensions/subagent/agents-command.js +270 -169
  95. package/dist/extensions/subagent/agents-command.js.map +1 -1
  96. package/dist/extensions/subagent/agents.d.ts +5 -6
  97. package/dist/extensions/subagent/agents.d.ts.map +1 -1
  98. package/dist/extensions/subagent/agents.js +28 -192
  99. package/dist/extensions/subagent/agents.js.map +1 -1
  100. package/dist/extensions/subagent/budget.d.ts +15 -0
  101. package/dist/extensions/subagent/budget.d.ts.map +1 -0
  102. package/dist/extensions/subagent/budget.js +96 -0
  103. package/dist/extensions/subagent/budget.js.map +1 -0
  104. package/dist/extensions/subagent/cancellation.d.ts +29 -0
  105. package/dist/extensions/subagent/cancellation.d.ts.map +1 -0
  106. package/dist/extensions/subagent/cancellation.js +73 -0
  107. package/dist/extensions/subagent/cancellation.js.map +1 -0
  108. package/dist/extensions/subagent/constants.d.ts +4 -5
  109. package/dist/extensions/subagent/constants.d.ts.map +1 -1
  110. package/dist/extensions/subagent/constants.js +11 -7
  111. package/dist/extensions/subagent/constants.js.map +1 -1
  112. package/dist/extensions/subagent/index.d.ts +0 -3
  113. package/dist/extensions/subagent/index.d.ts.map +1 -1
  114. package/dist/extensions/subagent/index.js +59 -208
  115. package/dist/extensions/subagent/index.js.map +1 -1
  116. package/dist/extensions/subagent/model-selection.d.ts +16 -0
  117. package/dist/extensions/subagent/model-selection.d.ts.map +1 -0
  118. package/dist/extensions/subagent/model-selection.js +51 -0
  119. package/dist/extensions/subagent/model-selection.js.map +1 -0
  120. package/dist/extensions/subagent/render.d.ts +7 -2
  121. package/dist/extensions/subagent/render.d.ts.map +1 -1
  122. package/dist/extensions/subagent/render.js +219 -576
  123. package/dist/extensions/subagent/render.js.map +1 -1
  124. package/dist/extensions/subagent/resolve.d.ts +2 -2
  125. package/dist/extensions/subagent/resolve.d.ts.map +1 -1
  126. package/dist/extensions/subagent/resolve.js +24 -35
  127. package/dist/extensions/subagent/resolve.js.map +1 -1
  128. package/dist/extensions/subagent/runner.d.ts +4 -6
  129. package/dist/extensions/subagent/runner.d.ts.map +1 -1
  130. package/dist/extensions/subagent/runner.js +101 -316
  131. package/dist/extensions/subagent/runner.js.map +1 -1
  132. package/dist/extensions/subagent/schema.d.ts +4 -10
  133. package/dist/extensions/subagent/schema.d.ts.map +1 -1
  134. package/dist/extensions/subagent/schema.js +8 -13
  135. package/dist/extensions/subagent/schema.js.map +1 -1
  136. package/dist/extensions/subagent/sdk-runner.d.ts +13 -11
  137. package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -1
  138. package/dist/extensions/subagent/sdk-runner.js +169 -161
  139. package/dist/extensions/subagent/sdk-runner.js.map +1 -1
  140. package/dist/extensions/subagent/settings.d.ts +2 -2
  141. package/dist/extensions/subagent/settings.d.ts.map +1 -1
  142. package/dist/extensions/subagent/settings.js +27 -14
  143. package/dist/extensions/subagent/settings.js.map +1 -1
  144. package/dist/extensions/subagent/state.d.ts +89 -0
  145. package/dist/extensions/subagent/state.d.ts.map +1 -0
  146. package/dist/extensions/subagent/state.js +294 -0
  147. package/dist/extensions/subagent/state.js.map +1 -0
  148. package/dist/extensions/subagent/text.d.ts +7 -0
  149. package/dist/extensions/subagent/text.d.ts.map +1 -0
  150. package/dist/extensions/subagent/text.js +91 -0
  151. package/dist/extensions/subagent/text.js.map +1 -0
  152. package/dist/extensions/subagent/types.d.ts +16 -43
  153. package/dist/extensions/subagent/types.d.ts.map +1 -1
  154. package/dist/extensions/subagent/types.js.map +1 -1
  155. package/dist/extensions/subagent/ui/choices.d.ts +36 -0
  156. package/dist/extensions/subagent/ui/choices.d.ts.map +1 -0
  157. package/dist/extensions/subagent/ui/choices.js +54 -0
  158. package/dist/extensions/subagent/ui/choices.js.map +1 -0
  159. package/dist/extensions/subagent/ui/model-list.d.ts +4 -3
  160. package/dist/extensions/subagent/ui/model-list.d.ts.map +1 -1
  161. package/dist/extensions/subagent/ui/model-list.js +20 -22
  162. package/dist/extensions/subagent/ui/model-list.js.map +1 -1
  163. package/dist/index.d.ts +2 -2
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js.map +1 -1
  166. package/dist/main.d.ts.map +1 -1
  167. package/dist/main.js +5 -1
  168. package/dist/main.js.map +1 -1
  169. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  170. package/dist/modes/interactive/components/model-selector.js +2 -1
  171. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  172. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  173. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  174. package/dist/modes/interactive/components/settings-selector.js +10 -0
  175. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  176. package/dist/modes/interactive/interactive-mode.d.ts +8 -2
  177. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  178. package/dist/modes/interactive/interactive-mode.js +77 -25
  179. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  180. package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
  181. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
  182. package/dist/modes/interactive/model-catalog-refresh.js +36 -0
  183. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
  184. package/dist/modes/interactive/theme/dark.json +2 -0
  185. package/dist/modes/interactive/theme/light.json +2 -0
  186. package/dist/modes/interactive/theme/theme-controller.d.ts +10 -2
  187. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  188. package/dist/modes/interactive/theme/theme-controller.js +23 -10
  189. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  190. package/dist/modes/interactive/theme/theme-schema.json +9 -1
  191. package/dist/modes/interactive/theme/theme.d.ts +5 -3
  192. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  193. package/dist/modes/interactive/theme/theme.js +12 -2
  194. package/dist/modes/interactive/theme/theme.js.map +1 -1
  195. package/dist/modes/json-event.d.ts +4 -1
  196. package/dist/modes/json-event.d.ts.map +1 -1
  197. package/dist/modes/json-event.js +5 -2
  198. package/dist/modes/json-event.js.map +1 -1
  199. package/dist/package-manager-cli.js +1 -1
  200. package/dist/package-manager-cli.js.map +1 -1
  201. package/dist/server/create-harness.d.ts.map +1 -1
  202. package/dist/server/create-harness.js +2 -0
  203. package/dist/server/create-harness.js.map +1 -1
  204. package/dist/utils/tools-manager.d.ts +10 -1
  205. package/dist/utils/tools-manager.d.ts.map +1 -1
  206. package/dist/utils/tools-manager.js +14 -19
  207. package/dist/utils/tools-manager.js.map +1 -1
  208. package/docs/bundled/README.md +1 -0
  209. package/docs/bundled/extensions/background.md +99 -0
  210. package/docs/bundled/extensions/subagent.md +83 -71
  211. package/docs/compaction.md +6 -6
  212. package/docs/custom-provider.md +1 -1
  213. package/docs/docs.json +4 -0
  214. package/docs/environment-variables.md +8 -2
  215. package/docs/extensions.md +19 -2
  216. package/docs/json.md +6 -4
  217. package/docs/keybindings.md +9 -2
  218. package/docs/rpc.md +15 -4
  219. package/docs/sdk.md +9 -0
  220. package/docs/settings.md +31 -0
  221. package/docs/terminal-setup.md +23 -2
  222. package/docs/themes.md +24 -3
  223. package/docs/tui.md +2 -2
  224. package/docs/usage.md +4 -3
  225. package/examples/README.md +1 -1
  226. package/examples/extensions/README.md +0 -1
  227. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  228. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  229. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  230. package/examples/extensions/gondolin/package-lock.json +2 -2
  231. package/examples/extensions/gondolin/package.json +1 -1
  232. package/examples/extensions/sandbox/package-lock.json +2 -2
  233. package/examples/extensions/sandbox/package.json +1 -1
  234. package/examples/extensions/with-deps/package-lock.json +2 -2
  235. package/examples/extensions/with-deps/package.json +1 -1
  236. package/npm-shrinkwrap.json +170 -221
  237. package/package.json +6 -6
  238. package/dist/extensions/subagent/display-name.d.ts +0 -6
  239. package/dist/extensions/subagent/display-name.d.ts.map +0 -1
  240. package/dist/extensions/subagent/display-name.js +0 -13
  241. package/dist/extensions/subagent/display-name.js.map +0 -1
  242. package/dist/extensions/subagent/retry.d.ts +0 -17
  243. package/dist/extensions/subagent/retry.d.ts.map +0 -1
  244. package/dist/extensions/subagent/retry.js +0 -41
  245. package/dist/extensions/subagent/retry.js.map +0 -1
  246. package/dist/extensions/subagent/ui/profile-editor.d.ts +0 -54
  247. package/dist/extensions/subagent/ui/profile-editor.d.ts.map +0 -1
  248. package/dist/extensions/subagent/ui/profile-editor.js +0 -154
  249. package/dist/extensions/subagent/ui/profile-editor.js.map +0 -1
  250. package/dist/extensions/subagent/ui/profile-picker.d.ts +0 -32
  251. package/dist/extensions/subagent/ui/profile-picker.d.ts.map +0 -1
  252. package/dist/extensions/subagent/ui/profile-picker.js +0 -149
  253. package/dist/extensions/subagent/ui/profile-picker.js.map +0 -1
  254. package/examples/extensions/subagent/README.md +0 -175
  255. package/examples/extensions/subagent/agents/planner.md +0 -37
  256. package/examples/extensions/subagent/agents/reviewer.md +0 -35
  257. package/examples/extensions/subagent/agents/scout.md +0 -50
  258. package/examples/extensions/subagent/agents/worker.md +0 -24
  259. package/examples/extensions/subagent/agents.ts +0 -126
  260. package/examples/extensions/subagent/index.ts +0 -1009
  261. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  262. package/examples/extensions/subagent/prompts/implement.md +0 -10
  263. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
@@ -0,0 +1,666 @@
1
+ /**
2
+ * background — run bash commands in the background.
3
+ *
4
+ * Tools: a single `bg` tool with five actions. create starts a task and
5
+ * returns immediately; the result arrives as a <background-task> notification
6
+ * (queued behind the current run while streaming, waking the agent when
7
+ * idle). read returns a bounded slice of a task's output file; wait blocks
8
+ * (bounded) for a task's completion and delivers it inline — the followUp
9
+ * notification is suppressed so the completion is delivered exactly once;
10
+ * kill stops a single task; list enumerates known tasks. /bg opens the
11
+ * interactive task manager. Running counts surface in the footer via
12
+ * ctx.ui.setStatus.
13
+ */
14
+ import { Type } from "typebox";
15
+ import { getAgentDir } from "../../config.js";
16
+ import { SettingsManager } from "../../core/settings-manager.js";
17
+ import { createLocalBashOperations, MAX_TIMEOUT_SECONDS, resolveSpawnContext, } from "../../core/tools/bash.js";
18
+ import { DEFAULT_MAX_BYTES, formatSize } from "../../core/tools/truncate.js";
19
+ import { sanitizeBinaryOutput } from "../../utils/shell.js";
20
+ import { BackgroundTasksMenu } from "./manager.js";
21
+ import { BackgroundTaskRegistry, BG_WAIT_DEFAULT_MS, BG_WAIT_MAX_MS, BG_WAIT_MIN_MS, firstCommandLine, formatDuration, readOutputSince, readOutputSlice, } from "./registry.js";
22
+ import { commandLabel, renderBackgroundNotification, renderBgCall, renderBgResult, } from "./render.js";
23
+ export const BG_NOTIFICATION_TYPE = "background-task";
24
+ const BG_LOGS_DEFAULT_BYTES = 8 * 1024;
25
+ const BG_LOGS_MIN_BYTES = 256;
26
+ const BG_LIST_FINISHED_SHOWN = 5;
27
+ /** Bounded output delta returned by a successful wait. */
28
+ const BG_WAIT_DELTA_BYTES = 32 * 1024;
29
+ /** Tail peek included in a wait timeout result so progress stays visible. */
30
+ const BG_WAIT_PEEK_BYTES = 2 * 1024;
31
+ const bgSchema = Type.Object({
32
+ action: Type.Union([Type.Literal("create"), Type.Literal("read"), Type.Literal("wait"), Type.Literal("kill"), Type.Literal("list")], { description: "Which background-task operation to perform" }),
33
+ // — create —
34
+ command: Type.Optional(Type.String({ description: "Bash command to run in the background (create). Do not append '&'" })),
35
+ description: Type.Optional(Type.String({
36
+ description: "Short label for the task, shown in /bg and notifications, e.g. 'dev server' (create)",
37
+ })),
38
+ timeout: Type.Optional(Type.Number({
39
+ description: "Kill the task after this many seconds; on expiry it is reported as timeout (create)",
40
+ })),
41
+ // — read / wait / kill —
42
+ taskId: Type.Optional(Type.String({ description: "Task id; a unique prefix is accepted, e.g. 'bg-3f' or '3f' (read/wait/kill)" })),
43
+ // — read —
44
+ mode: Type.Optional(Type.Union([Type.Literal("tail"), Type.Literal("head")], {
45
+ description: "Read from the end (default) or the start of the output (read)",
46
+ })),
47
+ bytes: Type.Optional(Type.Number({
48
+ description: `Max bytes to return (read, default ${formatSize(BG_LOGS_DEFAULT_BYTES)}, max ${formatSize(DEFAULT_MAX_BYTES)})`,
49
+ })),
50
+ // — wait —
51
+ waitMs: Type.Optional(Type.Number({
52
+ description: `Max time to wait in ms, default ${BG_WAIT_DEFAULT_MS}, max ${BG_WAIT_MAX_MS} (wait)`,
53
+ })),
54
+ sinceBytes: Type.Optional(Type.Number({
55
+ description: "Only return output written after this byte offset — take it from a previous read/wait result (wait)",
56
+ })),
57
+ });
58
+ export function escapeXml(text) {
59
+ return text
60
+ .replaceAll("&", "&amp;")
61
+ .replaceAll("<", "&lt;")
62
+ .replaceAll(">", "&gt;")
63
+ .replaceAll('"', "&quot;")
64
+ .replaceAll("'", "&apos;");
65
+ }
66
+ /**
67
+ * Strip characters XML 1.0 forbids: C0 controls (except \t \n \r), lone
68
+ * surrogates (U+D800–U+DFFF), and the non-characters U+FFFE/U+FFFF.
69
+ * sanitizeBinaryOutput does not remove the latter two classes, so this filter
70
+ * is the authority for every text field in the notification XML.
71
+ */
72
+ export function filterXmlCharacters(text) {
73
+ let result = "";
74
+ for (const char of text) {
75
+ const code = char.codePointAt(0) ?? 0;
76
+ if (code === 0x09 ||
77
+ code === 0x0a ||
78
+ code === 0x0d ||
79
+ (code >= 0x20 && code <= 0xd7ff) ||
80
+ (code >= 0xe000 && code <= 0xfffd) ||
81
+ code >= 0x10000) {
82
+ result += char;
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+ export function buildNotificationContent(notification) {
88
+ const task = notification.task;
89
+ const runtime = formatDuration((task.endedAt ?? task.startedAt) - task.startedAt);
90
+ const exitCode = task.exitCode === undefined || task.exitCode === null ? "" : ` exitCode="${task.exitCode}"`;
91
+ // filterXmlCharacters keeps \t \n \r and every other XML-legal codepoint,
92
+ // so each field below is valid XML 1.0 after escaping.
93
+ const xmlText = (text) => escapeXml(filterXmlCharacters(text));
94
+ const lines = [
95
+ `<background-task id="${task.id}" status="${task.status}"${exitCode} runtime="${runtime}">`,
96
+ `<command>${xmlText(task.command)}</command>`,
97
+ ];
98
+ if (task.description) {
99
+ lines.push(`<description>${xmlText(task.description)}</description>`);
100
+ }
101
+ lines.push(`<output-file>${xmlText(task.outputPath)}</output-file>`);
102
+ if (task.error) {
103
+ lines.push(`<error>${xmlText(task.error)}</error>`);
104
+ }
105
+ if (notification.tailError) {
106
+ lines.push(`<output-tail unavailable="${xmlText(notification.tailError)}"/>`);
107
+ }
108
+ else {
109
+ const attrs = [
110
+ `bytes="${notification.tailBytes}"`,
111
+ `totalBytes="${notification.totalBytes}"`,
112
+ notification.tailTruncated ? 'truncated="true"' : "",
113
+ notification.tailStartsMidLine ? 'startsMidLine="true"' : "",
114
+ ]
115
+ .filter(Boolean)
116
+ .join(" ");
117
+ const tail = notification.tailText.length > 0 ? xmlText(notification.tailText) : "(no output)";
118
+ lines.push(`<output-tail ${attrs}>`, tail.trimEnd(), "</output-tail>");
119
+ }
120
+ lines.push("</background-task>");
121
+ return lines.join("\n");
122
+ }
123
+ export function formatStatusline(counts) {
124
+ if (counts.total === 0)
125
+ return undefined;
126
+ // Stalled tasks are running tasks: report them separately so the counts add up.
127
+ const waiting = counts.stalled ?? 0;
128
+ const running = counts.running - waiting;
129
+ const ended = counts.total - counts.running;
130
+ const parts = [];
131
+ if (running > 0)
132
+ parts.push(`${running} running`);
133
+ if (waiting > 0)
134
+ parts.push(`${waiting} waiting for input`);
135
+ if (ended > 0)
136
+ parts.push(`${ended} done`);
137
+ return `bg ${parts.join(" · ")}`;
138
+ }
139
+ export function buildStallContent(notification) {
140
+ const task = notification.task;
141
+ const runtime = formatDuration((task.endedAt ?? Date.now()) - task.startedAt);
142
+ const xmlText = (text) => escapeXml(filterXmlCharacters(text));
143
+ const lines = [
144
+ `<background-task id="${task.id}" status="running" waiting-for-input="true" runtime="${runtime}">`,
145
+ `<command>${xmlText(task.command)}</command>`,
146
+ ];
147
+ if (task.description) {
148
+ lines.push(`<description>${xmlText(task.description)}</description>`);
149
+ }
150
+ lines.push(`<output-file>${xmlText(task.outputPath)}</output-file>`);
151
+ if (notification.tailError) {
152
+ lines.push(`<output-tail unavailable="${xmlText(notification.tailError)}"/>`);
153
+ }
154
+ else {
155
+ const attrs = [
156
+ `bytes="${notification.tailBytes}"`,
157
+ `totalBytes="${notification.totalBytes}"`,
158
+ notification.tailTruncated ? 'truncated="true"' : "",
159
+ notification.tailStartsMidLine ? 'startsMidLine="true"' : "",
160
+ ]
161
+ .filter(Boolean)
162
+ .join(" ");
163
+ const tail = notification.tailText.length > 0 ? xmlText(notification.tailText) : "(no output)";
164
+ lines.push(`<output-tail ${attrs}>`, tail.trimEnd(), "</output-tail>");
165
+ }
166
+ lines.push("<advice>The command appears blocked waiting for interactive input. Kill it (bg action kill) and " +
167
+ "re-run with piped input (e.g. echo y | command) or a non-interactive flag if one exists (e.g. --yes). " +
168
+ "The task keeps running until then.</advice>");
169
+ lines.push("</background-task>");
170
+ return lines.join("\n");
171
+ }
172
+ function toStallDetails(notification) {
173
+ const task = notification.task;
174
+ return {
175
+ taskId: task.id,
176
+ command: task.command,
177
+ description: task.description,
178
+ status: "running",
179
+ stalled: true,
180
+ exitCode: undefined,
181
+ runtimeMs: Date.now() - task.startedAt,
182
+ outputPath: task.outputPath,
183
+ totalBytes: notification.totalBytes,
184
+ tailText: notification.tailText,
185
+ tailTruncated: notification.tailTruncated,
186
+ tailError: notification.tailError,
187
+ };
188
+ }
189
+ function describeResolveFailure(input, result) {
190
+ if (result.reason === "ambiguous") {
191
+ const lines = result.candidates.map((task) => ` ${task.id} (${task.status}) ${commandLabel(taskLabel(task), 60)}`);
192
+ return `Task id "${input}" is ambiguous. Candidates:\n${lines.join("\n")}`;
193
+ }
194
+ return `No background task matches "${input}". Check the id returned by bg (action create), or run action list.`;
195
+ }
196
+ /** One row of a bounded task listing: the model-facing list and /bg summaries. */
197
+ function describeTaskLine(task, now) {
198
+ const duration = formatDuration((task.endedAt ?? now) - task.startedAt);
199
+ const exit = task.exitCode !== undefined && task.exitCode !== null ? ` exit ${task.exitCode}` : "";
200
+ return ` ${task.id} ${task.status}${exit} ${duration} ${commandLabel(taskLabel(task), 60)}`;
201
+ }
202
+ /** Label for listings: the model-provided description over the first command line. */
203
+ function taskLabel(task) {
204
+ return task.description ? `${task.description} — ${firstCommandLine(task.command)}` : firstCommandLine(task.command);
205
+ }
206
+ function toNotificationDetails(notification) {
207
+ const task = notification.task;
208
+ return {
209
+ taskId: task.id,
210
+ command: task.command,
211
+ description: task.description,
212
+ status: task.status,
213
+ exitCode: task.exitCode,
214
+ runtimeMs: (task.endedAt ?? task.startedAt) - task.startedAt,
215
+ outputPath: task.outputPath,
216
+ totalBytes: notification.totalBytes,
217
+ tailText: notification.tailText,
218
+ tailTruncated: notification.tailTruncated,
219
+ error: task.error,
220
+ tailError: notification.tailError,
221
+ };
222
+ }
223
+ /**
224
+ * Wrap operations so every executed command carries the prefix, mirroring the
225
+ * built-in bash tool. The prefix never reaches task labels or notifications:
226
+ * `BgTask.command` stays the user's original input.
227
+ */
228
+ export function prependCommandPrefix(operations, prefix) {
229
+ if (!prefix)
230
+ return operations;
231
+ return {
232
+ exec: (command, cwd, options) => operations.exec(`${prefix}\n${command}`, cwd, options),
233
+ };
234
+ }
235
+ /** Shell configuration for one bg session: the session's settings win, disk settings are the fallback. */
236
+ export function resolveSessionShell(ctx, readDiskSettings) {
237
+ return ctx.getShellSettings?.() ?? readDiskSettings?.() ?? {};
238
+ }
239
+ /** Local shell operations honoring the session's shell settings (shellPath, commandPrefix). */
240
+ function createSessionBashOperations(ctx) {
241
+ const shell = resolveSessionShell(ctx, () => {
242
+ // Hosts without getShellSettings (older SDK hosts): fall back to reading
243
+ // settings from disk, matching what the session was configured with.
244
+ const settings = SettingsManager.create(ctx.cwd, getAgentDir(), {
245
+ projectTrusted: ctx.isProjectTrusted(),
246
+ });
247
+ return { shellPath: settings.getShellPath(), commandPrefix: settings.getShellCommandPrefix() };
248
+ });
249
+ return prependCommandPrefix(createLocalBashOperations({ shellPath: shell.shellPath }), shell.commandPrefix);
250
+ }
251
+ /** Validate per-action required fields; every message names the next step. */
252
+ function validateAction(input) {
253
+ switch (input.action) {
254
+ case "create":
255
+ if (!input.command || input.command.trim().length === 0) {
256
+ throw new Error("action 'create' requires 'command' — pass the bash command to run in the background.");
257
+ }
258
+ break;
259
+ case "read":
260
+ case "wait":
261
+ case "kill":
262
+ if (!input.taskId || input.taskId.trim().length === 0) {
263
+ throw new Error(`action '${input.action}' requires 'taskId' — use the id returned by action create, or action list to find it.`);
264
+ }
265
+ break;
266
+ case "list":
267
+ break;
268
+ }
269
+ }
270
+ /** Factory with injectable seams for tests; the default export uses production wiring. */
271
+ export function createBackgroundExtension(overrides) {
272
+ return (pi) => {
273
+ let registry;
274
+ let sessionCtx;
275
+ const requireRegistry = () => {
276
+ if (!registry)
277
+ throw new Error("Background tasks are not available yet (no active session).");
278
+ return registry;
279
+ };
280
+ const resolveTaskOrThrow = (taskId) => {
281
+ const resolved = requireRegistry().resolveTask(taskId);
282
+ if (!resolved.ok)
283
+ throw new Error(describeResolveFailure(taskId, resolved));
284
+ return resolved.task;
285
+ };
286
+ /** Read-only live peek for the pending wait renderer; never throws. */
287
+ const waitLiveProbe = (taskId) => {
288
+ if (!registry)
289
+ return undefined;
290
+ const resolved = registry.resolveTask(taskId);
291
+ return resolved.ok ? { status: resolved.task.status, outputBytes: resolved.task.outputBytes } : undefined;
292
+ };
293
+ const updateStatus = () => {
294
+ if (!registry || registry.isShuttingDown)
295
+ return;
296
+ sessionCtx?.ui.setStatus("background", formatStatusline(registry.counts()));
297
+ };
298
+ pi.on("session_start", (_event, ctx) => {
299
+ sessionCtx = ctx;
300
+ // Defensive: a leftover registry (session_shutdown not seen) must not leak processes.
301
+ if (registry)
302
+ void registry.shutdown();
303
+ registry = new BackgroundTaskRegistry({
304
+ operations: overrides?.operations ?? createSessionBashOperations(ctx),
305
+ outputDir: overrides?.outputDir,
306
+ maxOutputBytes: overrides?.maxOutputBytes,
307
+ stall: overrides?.stall,
308
+ onNotify: (notification) => {
309
+ pi.sendMessage({
310
+ customType: BG_NOTIFICATION_TYPE,
311
+ content: buildNotificationContent(notification),
312
+ display: true,
313
+ details: toNotificationDetails(notification),
314
+ }, { deliverAs: "followUp", triggerTurn: true });
315
+ },
316
+ onStall: (notification) => {
317
+ // Informational one-shot signal: not a terminal state, so it bypasses
318
+ // the claim protocol (a waiting model needs to know it is blocked on
319
+ // input, not merely slow).
320
+ pi.sendMessage({
321
+ customType: BG_NOTIFICATION_TYPE,
322
+ content: buildStallContent(notification),
323
+ display: true,
324
+ details: toStallDetails(notification),
325
+ }, { deliverAs: "followUp", triggerTurn: true });
326
+ },
327
+ onChange: updateStatus,
328
+ });
329
+ updateStatus();
330
+ });
331
+ pi.on("session_shutdown", async (_event, ctx) => {
332
+ ctx.ui.setStatus("background", undefined);
333
+ sessionCtx = undefined;
334
+ const active = registry;
335
+ registry = undefined;
336
+ await active?.shutdown();
337
+ });
338
+ const runCreate = async (params, ctx) => {
339
+ if (params.timeout !== undefined && (!Number.isFinite(params.timeout) || params.timeout <= 0)) {
340
+ throw new Error("Invalid timeout: must be a positive number of seconds.");
341
+ }
342
+ if (params.timeout !== undefined && params.timeout > MAX_TIMEOUT_SECONDS) {
343
+ throw new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);
344
+ }
345
+ // Same PI_* session variables as the built-in bash tool, snapshotted at start.
346
+ const spawnContext = resolveSpawnContext(params.command, ctx.cwd, undefined, true, ctx);
347
+ // Deliberately ignore the turn signal: aborting the current turn must
348
+ // not kill the background task (that is what action kill is for).
349
+ const task = requireRegistry().startTask({
350
+ command: params.command,
351
+ cwd: ctx.cwd,
352
+ description: params.description,
353
+ timeoutSeconds: params.timeout,
354
+ env: spawnContext.env,
355
+ });
356
+ const label = task.description ? ` (${task.description})` : "";
357
+ const text = [
358
+ `Started background task ${task.id}${label}.`,
359
+ `Output file: ${task.outputPath}`,
360
+ "",
361
+ "A <background-task> notification with the result and output tail arrives automatically when the task " +
362
+ "ends — do NOT poll (no sleep loops, no repeated reads). Use action read for an early peek, " +
363
+ "action wait when the next step depends on the result, action kill to stop it.",
364
+ ].join("\n");
365
+ return {
366
+ content: [{ type: "text", text }],
367
+ details: {
368
+ action: "create",
369
+ taskId: task.id,
370
+ outputPath: task.outputPath,
371
+ command: params.command,
372
+ description: params.description,
373
+ },
374
+ };
375
+ };
376
+ const runRead = async (params) => {
377
+ const task = resolveTaskOrThrow(params.taskId);
378
+ const mode = params.mode ?? "tail";
379
+ const maxBytes = Math.min(DEFAULT_MAX_BYTES, Math.max(BG_LOGS_MIN_BYTES, Math.floor(params.bytes ?? BG_LOGS_DEFAULT_BYTES)));
380
+ let slice;
381
+ try {
382
+ slice = await readOutputSlice(task.outputPath, { mode, maxBytes });
383
+ }
384
+ catch (error) {
385
+ const message = error instanceof Error ? error.message : String(error);
386
+ throw new Error(`Could not read output for ${task.id} (${task.status}): ${message}\nOutput file: ${task.outputPath}`);
387
+ }
388
+ const text = sanitizeBinaryOutput(slice.text);
389
+ const running = task.status === "running" ? ["still running"] : [];
390
+ const noticeParts = slice.truncated
391
+ ? [
392
+ `${mode} ${formatSize(slice.sliceBytes)} of ${formatSize(slice.totalBytes)}`,
393
+ `task ${task.id} ${task.status}`,
394
+ ...running,
395
+ ...(slice.startsMidLine ? ["first line may be partial"] : []),
396
+ `full output: ${task.outputPath}`,
397
+ ]
398
+ : [
399
+ `task ${task.id} ${task.status}`,
400
+ ...running,
401
+ `${formatSize(slice.totalBytes)} total`,
402
+ `output: ${task.outputPath}`,
403
+ ];
404
+ const body = text.length > 0 ? text : "(no output yet)";
405
+ return {
406
+ content: [{ type: "text", text: `[${noticeParts.join(" · ")}]\n${body}` }],
407
+ details: {
408
+ action: "read",
409
+ taskId: task.id,
410
+ mode,
411
+ sliceBytes: slice.sliceBytes,
412
+ totalBytes: slice.totalBytes,
413
+ outputPath: task.outputPath,
414
+ },
415
+ };
416
+ };
417
+ const runWait = async (params) => {
418
+ const task = resolveTaskOrThrow(params.taskId);
419
+ const waitMs = Math.min(BG_WAIT_MAX_MS, Math.max(BG_WAIT_MIN_MS, Math.floor(params.waitMs ?? BG_WAIT_DEFAULT_MS)));
420
+ const startedWait = Date.now();
421
+ const result = await requireRegistry().waitForResult(task.id, waitMs);
422
+ const waitedMs = Date.now() - startedWait;
423
+ const finalTask = result.task;
424
+ const exitSuffix = finalTask.exitCode !== undefined && finalTask.exitCode !== null ? ` · exit ${finalTask.exitCode}` : "";
425
+ const ran = formatDuration((finalTask.endedAt ?? Date.now()) - finalTask.startedAt);
426
+ if (result.outcome === "timeout") {
427
+ // Still running: keep progress visible with a bounded tail peek.
428
+ let peekText = "";
429
+ let peekNote = "";
430
+ let totalBytes = finalTask.outputBytes;
431
+ try {
432
+ const peek = await readOutputSlice(finalTask.outputPath, { mode: "tail", maxBytes: BG_WAIT_PEEK_BYTES });
433
+ peekText = sanitizeBinaryOutput(peek.text);
434
+ totalBytes = peek.totalBytes;
435
+ peekNote = peek.truncated ? ` (last ${formatSize(peek.sliceBytes)})` : "";
436
+ }
437
+ catch {
438
+ peekNote = " (output unavailable)";
439
+ }
440
+ const lines = [
441
+ `[${finalTask.id} still running · waited ${formatDuration(waitedMs)} · ${formatSize(totalBytes)} total]`,
442
+ ];
443
+ const trimmed = peekText.trimEnd();
444
+ if (trimmed.length > 0)
445
+ lines.push(`Last output${peekNote}:\n${trimmed}`);
446
+ lines.push("The task keeps running. Wait again (action wait), peek with action read, or stop it with action kill; " +
447
+ "the <background-task> notification still arrives when it ends. Do not sleep-poll.");
448
+ return {
449
+ content: [{ type: "text", text: lines.join("\n\n") }],
450
+ details: {
451
+ action: "wait",
452
+ taskId: finalTask.id,
453
+ timedOut: true,
454
+ status: finalTask.status,
455
+ exitCode: finalTask.exitCode,
456
+ waitedMs,
457
+ deltaBytes: 0,
458
+ totalBytes,
459
+ deltaTruncated: false,
460
+ outputPath: finalTask.outputPath,
461
+ },
462
+ };
463
+ }
464
+ // Terminal: deliver the bounded delta since the requested offset.
465
+ // The followUp notification was suppressed by the claim protocol —
466
+ // this result is the single delivery of the completion.
467
+ const since = params.sinceBytes !== undefined ? Math.max(0, Math.floor(params.sinceBytes)) : undefined;
468
+ let delta;
469
+ let offsetNote;
470
+ try {
471
+ delta = await readOutputSince(finalTask.outputPath, since ?? 0, BG_WAIT_DELTA_BYTES);
472
+ if (since !== undefined && since > delta.totalBytes) {
473
+ // A stale offset past EOF (the output was truncated at the cap, or
474
+ // the model is reusing an id from an earlier read): fall back to
475
+ // the tail and say so. Never an error — the offset is not a bug.
476
+ delta = await readOutputSince(finalTask.outputPath, 0, BG_WAIT_DELTA_BYTES);
477
+ offsetNote = finalTask.outputTruncated
478
+ ? "the given offset is past EOF — output was truncated at the limit; showing the tail"
479
+ : "the given offset is past EOF; showing the tail";
480
+ }
481
+ }
482
+ catch (error) {
483
+ // Deliver the terminal status even when the output file cannot be read.
484
+ const message = error instanceof Error ? error.message : String(error);
485
+ return {
486
+ content: [
487
+ {
488
+ type: "text",
489
+ text: `[${finalTask.id} ${finalTask.status}${exitSuffix} · ran ${ran} · waited ${formatDuration(waitedMs)}]\nerror reading output: ${message}`,
490
+ },
491
+ ],
492
+ details: {
493
+ action: "wait",
494
+ taskId: finalTask.id,
495
+ timedOut: false,
496
+ status: finalTask.status,
497
+ exitCode: finalTask.exitCode,
498
+ waitedMs,
499
+ deltaBytes: 0,
500
+ totalBytes: finalTask.outputBytes,
501
+ deltaTruncated: false,
502
+ outputPath: finalTask.outputPath,
503
+ },
504
+ };
505
+ }
506
+ const lines = [
507
+ `[${finalTask.id} ${finalTask.status}${exitSuffix} · ran ${ran} · waited ${formatDuration(waitedMs)} · +${formatSize(delta.sliceBytes)} new output · total ${formatSize(delta.totalBytes)}]`,
508
+ ];
509
+ if (offsetNote)
510
+ lines.push(`[${offsetNote}]`);
511
+ if (finalTask.error)
512
+ lines.push(`error: ${finalTask.error}`);
513
+ if (delta.truncated) {
514
+ lines.push(`[showing ${formatSize(delta.sliceBytes)} of ${formatSize(delta.totalBytes)}; full output: ${finalTask.outputPath}]`);
515
+ }
516
+ const body = sanitizeBinaryOutput(delta.text).trimEnd();
517
+ lines.push(body.length > 0 ? body : "(no new output)");
518
+ return {
519
+ content: [{ type: "text", text: lines.join("\n") }],
520
+ details: {
521
+ action: "wait",
522
+ taskId: finalTask.id,
523
+ timedOut: false,
524
+ status: finalTask.status,
525
+ exitCode: finalTask.exitCode,
526
+ waitedMs,
527
+ deltaBytes: delta.sliceBytes,
528
+ totalBytes: delta.totalBytes,
529
+ deltaTruncated: delta.truncated,
530
+ outputPath: finalTask.outputPath,
531
+ },
532
+ };
533
+ };
534
+ const runKill = (params) => {
535
+ const task = resolveTaskOrThrow(params.taskId);
536
+ const result = requireRegistry().killTask(task.id);
537
+ if (!result.killed) {
538
+ const exit = task.exitCode !== undefined && task.exitCode !== null ? `, exit ${task.exitCode}` : "";
539
+ throw new Error(`Task ${task.id} is not running (status: ${task.status}${exit}).`);
540
+ }
541
+ return {
542
+ content: [
543
+ {
544
+ type: "text",
545
+ text: `Killed task ${task.id}. If you are waiting on it (action wait) the killed status is delivered there; otherwise a completion notification follows once the process tree is reaped.`,
546
+ },
547
+ ],
548
+ details: { action: "kill", taskId: task.id, command: task.command },
549
+ };
550
+ };
551
+ const runList = () => {
552
+ const tasks = requireRegistry().listTasks();
553
+ if (tasks.length === 0) {
554
+ return {
555
+ content: [{ type: "text", text: "No background tasks this session. Start one with action create." }],
556
+ details: { action: "list", running: 0, finished: 0, shown: 0, hidden: 0 },
557
+ };
558
+ }
559
+ const now = Date.now();
560
+ const running = tasks.filter((task) => task.status === "running");
561
+ const finished = tasks.filter((task) => task.status !== "running");
562
+ const shownFinished = finished.slice(0, BG_LIST_FINISHED_SHOWN);
563
+ const hidden = finished.length - shownFinished.length;
564
+ const lines = [`${running.length} running · ${finished.length} finished`];
565
+ for (const task of [...running, ...shownFinished]) {
566
+ lines.push(describeTaskLine(task, now));
567
+ }
568
+ if (hidden > 0) {
569
+ lines.push(`(+${hidden} more finished, not shown — action read shows any task's output)`);
570
+ }
571
+ return {
572
+ content: [{ type: "text", text: lines.join("\n") }],
573
+ details: {
574
+ action: "list",
575
+ running: running.length,
576
+ finished: finished.length,
577
+ shown: running.length + shownFinished.length,
578
+ hidden,
579
+ },
580
+ };
581
+ };
582
+ pi.registerTool({
583
+ name: "bg",
584
+ label: "bg",
585
+ description: "Run and manage background bash tasks.\n\n" +
586
+ "create: start a command in the background and return immediately with a task id and an " +
587
+ "output file path. Only use this when you don't need the result immediately and are OK being " +
588
+ "notified when the command completes later — a <background-task> notification with status, exit " +
589
+ "code, and output tail arrives automatically when it ends. Do NOT append '&' to the command; bg " +
590
+ "already runs it detached. An optional description labels the task in the UI; an optional timeout " +
591
+ "in seconds kills the task on expiry.\n\n" +
592
+ "read: bounded slice of a task's output (default: last 8KB); works while the task runs. The " +
593
+ "output file is a plain file — the read tool also works on it for line-based paging.\n\n" +
594
+ "wait: block until a task finishes (default 20s, max 60s) and return its status plus output " +
595
+ "written since a given offset. Use when the next step depends on the result; on timeout the task " +
596
+ "is still running and you may wait again. Never emulate waiting with sleep.\n\n" +
597
+ "kill: stop a running task (whole process tree).\n\n" +
598
+ "list: currently known tasks with status.\n\n" +
599
+ "Task ids accept a unique prefix ('3f' for 'bg-3f').",
600
+ promptSnippet: "Manage background shell tasks (bg: create/read/wait/kill/list)",
601
+ promptGuidelines: [
602
+ "Use bg (action create) for long-running commands (dev servers, watch builds, slow tests) instead of regular bash; results arrive as an automatic <background-task> notification, so continue independent work or end the turn.",
603
+ "Never wait on background tasks with sleep loops or repeated reads; use bg action wait (bounded) when a step depends on a task's result, or rely on the completion notification.",
604
+ ],
605
+ parameters: bgSchema,
606
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
607
+ validateAction(params);
608
+ switch (params.action) {
609
+ case "create":
610
+ return runCreate(params, ctx);
611
+ case "read":
612
+ return runRead(params);
613
+ case "wait":
614
+ return runWait(params);
615
+ case "kill":
616
+ return runKill(params);
617
+ case "list":
618
+ return runList();
619
+ }
620
+ },
621
+ renderCall(args, theme, context) {
622
+ return renderBgCall(args, theme, context, waitLiveProbe);
623
+ },
624
+ renderResult(result, options, theme, context) {
625
+ return renderBgResult(result, options, theme, context);
626
+ },
627
+ });
628
+ pi.registerMessageRenderer(BG_NOTIFICATION_TYPE, renderBackgroundNotification);
629
+ pi.registerCommand("bg", {
630
+ description: "View and manage background tasks",
631
+ handler: async (_args, ctx) => {
632
+ const active = registry;
633
+ if (!active || active.counts().total === 0) {
634
+ ctx.ui.notify("No background tasks.", "info");
635
+ return;
636
+ }
637
+ if (ctx.mode !== "tui") {
638
+ // RPC/print: ctx.ui.custom is unavailable — show a bounded summary.
639
+ const lines = active
640
+ .listTasks()
641
+ .slice(0, 10)
642
+ .map((task) => describeTaskLine(task, Date.now()));
643
+ ctx.ui.notify(`Background tasks:\n${lines.join("\n")}\nUse the bg tool (action kill) to stop a task.`, "info");
644
+ return;
645
+ }
646
+ await showBackgroundManager(ctx, active);
647
+ },
648
+ });
649
+ };
650
+ }
651
+ async function showBackgroundManager(ctx, registry) {
652
+ // No overlay options: the component mounts inline in the editor slot, like /model.
653
+ await ctx.ui.custom((tui, theme, keybindings, done) => new BackgroundTasksMenu({
654
+ tui,
655
+ theme,
656
+ keybindings,
657
+ host: {
658
+ listTasks: () => registry.listTasks(),
659
+ killTask: (id) => registry.killTask(id),
660
+ readSlice: (filePath, options) => readOutputSlice(filePath, options),
661
+ },
662
+ onClose: () => done(undefined),
663
+ }));
664
+ }
665
+ export default createBackgroundExtension();
666
+ //# sourceMappingURL=index.js.map