@astralyn/pi 0.99.0 → 1.0.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 (512) hide show
  1. package/CHANGELOG.md +39 -3
  2. package/dist/bundle/chunks/anthropic-messages-CG2BSDQS.js +6 -0
  3. package/dist/bundle/chunks/anthropic.js +2 -2
  4. package/dist/bundle/chunks/{azure-openai-responses-RPBERDXD.js → azure-openai-responses-PBA4QKCM.js} +1 -1
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
  6. package/dist/bundle/chunks/{chunk-ABVRAYXT.js → chunk-6UFFVA7M.js} +2 -2
  7. package/dist/bundle/chunks/chunk-GIG5IHES.js +2 -0
  8. package/dist/bundle/chunks/{chunk-VW2P3X6P.js → chunk-HESRDUKO.js} +414 -666
  9. package/dist/bundle/chunks/{chunk-A576H74Y.js → chunk-PFZKRUMO.js} +1 -1
  10. package/dist/bundle/chunks/chunk-SGLYRVQL.js +2 -0
  11. package/dist/bundle/chunks/chunk-TRHTWM3C.js +2 -0
  12. package/dist/bundle/chunks/{chunk-DEWXBB6W.js → chunk-V66VGGOM.js} +1 -1
  13. package/dist/bundle/chunks/chunk-Z2RKSI3O.js +2 -0
  14. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-ZYSAFXXL.js → cloudflare-workers-ai-system-one-YB7XPPP4.js} +1 -1
  15. package/dist/bundle/chunks/codemode-worker.js +67 -8
  16. package/dist/bundle/chunks/github-copilot.js +1 -1
  17. package/dist/bundle/chunks/{google-generative-ai-SDNQVVXA.js → google-generative-ai-V5ZM5MCL.js} +1 -1
  18. package/dist/bundle/chunks/{google-vertex-LZXOLBIO.js → google-vertex-22THOFP5.js} +1 -1
  19. package/dist/bundle/chunks/{llama-cpp-classify-7IYGGPND.js → llama-cpp-classify-R7DQLTQN.js} +1 -1
  20. package/dist/bundle/chunks/{mistral-conversations-VYKPSSAM.js → mistral-conversations-WHSCJJWP.js} +1 -1
  21. package/dist/bundle/chunks/openai-chatgpt.js +1 -1
  22. package/dist/bundle/chunks/{openai-codex-responses-HZ4VUDXD.js → openai-codex-responses-N7GDPBPP.js} +1 -1
  23. package/dist/bundle/chunks/openai-codex.js +1 -1
  24. package/dist/bundle/chunks/{openai-completions-SKDGF6OE.js → openai-completions-RGGQK5UW.js} +1 -1
  25. package/dist/bundle/chunks/{openai-responses-FPML4SSG.js → openai-responses-3ZLD5JYI.js} +1 -1
  26. package/dist/bundle/chunks/{openrouter-images-5524IQHX.js → openrouter-images-YP3YVB54.js} +1 -1
  27. package/dist/bundle/chunks/openrouter.js +1 -1
  28. package/dist/bundle/chunks/radius.js +1 -1
  29. package/dist/bundle/chunks/{typesafe-system-one-Z2CDLKEY.js → typesafe-system-one-RREJAKWB.js} +1 -1
  30. package/dist/bundle/chunks/virtual-modules-4RQ2L6W4.js +2 -0
  31. package/dist/bundle/cli.js +1 -1
  32. package/dist/bundle/index.js +1 -1
  33. package/dist/bundle/rpc-entry.js +1 -1
  34. package/dist/cli/args.js +1 -1
  35. package/dist/cli/args.js.map +1 -1
  36. package/dist/config.d.ts +5 -8
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +16 -13
  39. package/dist/config.js.map +1 -1
  40. package/dist/core/agent-session.d.ts +21 -1
  41. package/dist/core/agent-session.d.ts.map +1 -1
  42. package/dist/core/agent-session.js +64 -11
  43. package/dist/core/agent-session.js.map +1 -1
  44. package/dist/core/extensions/index.d.ts +1 -1
  45. package/dist/core/extensions/index.d.ts.map +1 -1
  46. package/dist/core/extensions/index.js.map +1 -1
  47. package/dist/core/extensions/loader.d.ts.map +1 -1
  48. package/dist/core/extensions/loader.js +13 -1
  49. package/dist/core/extensions/loader.js.map +1 -1
  50. package/dist/core/extensions/types.d.ts +6 -1
  51. package/dist/core/extensions/types.d.ts.map +1 -1
  52. package/dist/core/extensions/types.js.map +1 -1
  53. package/dist/core/keybindings.d.ts +51 -11
  54. package/dist/core/keybindings.d.ts.map +1 -1
  55. package/dist/core/keybindings.js +11 -3
  56. package/dist/core/keybindings.js.map +1 -1
  57. package/dist/core/mcp-servers.d.ts +34 -7
  58. package/dist/core/mcp-servers.d.ts.map +1 -1
  59. package/dist/core/mcp-servers.js +52 -11
  60. package/dist/core/mcp-servers.js.map +1 -1
  61. package/dist/core/model-registry.d.ts +3 -1
  62. package/dist/core/model-registry.d.ts.map +1 -1
  63. package/dist/core/model-registry.js +4 -0
  64. package/dist/core/model-registry.js.map +1 -1
  65. package/dist/core/model-runtime.d.ts +6 -0
  66. package/dist/core/model-runtime.d.ts.map +1 -1
  67. package/dist/core/model-runtime.js +22 -18
  68. package/dist/core/model-runtime.js.map +1 -1
  69. package/dist/core/radius.d.ts +2 -0
  70. package/dist/core/radius.d.ts.map +1 -1
  71. package/dist/core/radius.js +2 -0
  72. package/dist/core/radius.js.map +1 -1
  73. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  74. package/dist/core/remote-catalog-provider.js +4 -9
  75. package/dist/core/remote-catalog-provider.js.map +1 -1
  76. package/dist/core/sdk.d.ts.map +1 -1
  77. package/dist/core/sdk.js +1 -0
  78. package/dist/core/sdk.js.map +1 -1
  79. package/dist/core/settings-manager.d.ts +7 -5
  80. package/dist/core/settings-manager.d.ts.map +1 -1
  81. package/dist/core/settings-manager.js +2 -1
  82. package/dist/core/settings-manager.js.map +1 -1
  83. package/dist/core/system-prompt.js +1 -1
  84. package/dist/core/system-prompt.js.map +1 -1
  85. package/dist/core/tasks/format.d.ts +7 -0
  86. package/dist/core/tasks/format.d.ts.map +1 -0
  87. package/dist/core/tasks/format.js +14 -0
  88. package/dist/core/tasks/format.js.map +1 -0
  89. package/dist/core/tasks/history.d.ts.map +1 -1
  90. package/dist/core/tasks/history.js +0 -19
  91. package/dist/core/tasks/history.js.map +1 -1
  92. package/dist/core/tasks/output.d.ts +8 -0
  93. package/dist/core/tasks/output.d.ts.map +1 -1
  94. package/dist/core/tasks/output.js +19 -0
  95. package/dist/core/tasks/output.js.map +1 -1
  96. package/dist/core/tasks/presentation.d.ts +1 -3
  97. package/dist/core/tasks/presentation.d.ts.map +1 -1
  98. package/dist/core/tasks/presentation.js +79 -166
  99. package/dist/core/tasks/presentation.js.map +1 -1
  100. package/dist/core/tasks/runtime.d.ts +16 -9
  101. package/dist/core/tasks/runtime.d.ts.map +1 -1
  102. package/dist/core/tasks/runtime.js +89 -106
  103. package/dist/core/tasks/runtime.js.map +1 -1
  104. package/dist/core/tasks/session.d.ts.map +1 -1
  105. package/dist/core/tasks/session.js +13 -4
  106. package/dist/core/tasks/session.js.map +1 -1
  107. package/dist/core/tasks/store.d.ts +20 -6
  108. package/dist/core/tasks/store.d.ts.map +1 -1
  109. package/dist/core/tasks/store.js +45 -18
  110. package/dist/core/tasks/store.js.map +1 -1
  111. package/dist/core/tasks/types.d.ts +14 -54
  112. package/dist/core/tasks/types.d.ts.map +1 -1
  113. package/dist/core/tasks/types.js +1 -5
  114. package/dist/core/tasks/types.js.map +1 -1
  115. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  116. package/dist/core/tools/renderers/bash.js +11 -34
  117. package/dist/core/tools/renderers/bash.js.map +1 -1
  118. package/dist/core/tools/shell-execution.d.ts +0 -1
  119. package/dist/core/tools/shell-execution.d.ts.map +1 -1
  120. package/dist/core/tools/shell-execution.js +3 -10
  121. package/dist/core/tools/shell-execution.js.map +1 -1
  122. package/dist/core/tools/shell-tool.d.ts.map +1 -1
  123. package/dist/core/tools/shell-tool.js +2 -4
  124. package/dist/core/tools/shell-tool.js.map +1 -1
  125. package/dist/core/tools/tasks/actions.d.ts +1 -1
  126. package/dist/core/tools/tasks/actions.d.ts.map +1 -1
  127. package/dist/core/tools/tasks/actions.js +26 -12
  128. package/dist/core/tools/tasks/actions.js.map +1 -1
  129. package/dist/core/tools/tasks/constants.d.ts +2 -6
  130. package/dist/core/tools/tasks/constants.d.ts.map +1 -1
  131. package/dist/core/tools/tasks/constants.js +2 -6
  132. package/dist/core/tools/tasks/constants.js.map +1 -1
  133. package/dist/core/tools/tasks/schema.d.ts +1 -1
  134. package/dist/core/tools/tasks/schema.d.ts.map +1 -1
  135. package/dist/core/tools/tasks/schema.js +8 -7
  136. package/dist/core/tools/tasks/schema.js.map +1 -1
  137. package/dist/core/tools/tasks/types.d.ts +8 -38
  138. package/dist/core/tools/tasks/types.d.ts.map +1 -1
  139. package/dist/core/tools/tasks/types.js +6 -11
  140. package/dist/core/tools/tasks/types.js.map +1 -1
  141. package/dist/core/virtual-models.d.ts +2 -0
  142. package/dist/core/virtual-models.d.ts.map +1 -1
  143. package/dist/core/virtual-models.js +19 -12
  144. package/dist/core/virtual-models.js.map +1 -1
  145. package/dist/extensions/btw/agent.d.ts +17 -8
  146. package/dist/extensions/btw/agent.d.ts.map +1 -1
  147. package/dist/extensions/btw/agent.js +74 -76
  148. package/dist/extensions/btw/agent.js.map +1 -1
  149. package/dist/extensions/btw/controller.d.ts +0 -1
  150. package/dist/extensions/btw/controller.d.ts.map +1 -1
  151. package/dist/extensions/btw/controller.js +26 -33
  152. package/dist/extensions/btw/controller.js.map +1 -1
  153. package/dist/extensions/btw/panel.d.ts +13 -14
  154. package/dist/extensions/btw/panel.d.ts.map +1 -1
  155. package/dist/extensions/btw/panel.js +38 -29
  156. package/dist/extensions/btw/panel.js.map +1 -1
  157. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  158. package/dist/extensions/codemode/execute.js +197 -51
  159. package/dist/extensions/codemode/execute.js.map +1 -1
  160. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  161. package/dist/extensions/codemode/renderer.js +43 -25
  162. package/dist/extensions/codemode/renderer.js.map +1 -1
  163. package/dist/extensions/codemode/tool.d.ts +12 -11
  164. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  165. package/dist/extensions/codemode/tool.js +73 -129
  166. package/dist/extensions/codemode/tool.js.map +1 -1
  167. package/dist/extensions/codemode/worker.d.ts +1 -1
  168. package/dist/extensions/codemode/worker.js +1 -1
  169. package/dist/extensions/codemode/worker.js.map +1 -1
  170. package/dist/extensions/deepwiki/schema.d.ts +1 -1
  171. package/dist/extensions/index.d.ts.map +1 -1
  172. package/dist/extensions/index.js +0 -2
  173. package/dist/extensions/index.js.map +1 -1
  174. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  175. package/dist/extensions/mcp/cli.js +20 -5
  176. package/dist/extensions/mcp/cli.js.map +1 -1
  177. package/dist/extensions/mcp/config.d.ts +4 -2
  178. package/dist/extensions/mcp/config.d.ts.map +1 -1
  179. package/dist/extensions/mcp/config.js +14 -2
  180. package/dist/extensions/mcp/config.js.map +1 -1
  181. package/dist/extensions/mcp/index.d.ts +32 -8
  182. package/dist/extensions/mcp/index.d.ts.map +1 -1
  183. package/dist/extensions/mcp/index.js +235 -61
  184. package/dist/extensions/mcp/index.js.map +1 -1
  185. package/dist/extensions/mcp/oauth.d.ts +10 -7
  186. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  187. package/dist/extensions/mcp/oauth.js +56 -31
  188. package/dist/extensions/mcp/oauth.js.map +1 -1
  189. package/dist/extensions/mcp/runtime.d.ts +2 -0
  190. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  191. package/dist/extensions/mcp/runtime.js +16 -9
  192. package/dist/extensions/mcp/runtime.js.map +1 -1
  193. package/dist/extensions/mcp/tools.d.ts +5 -4
  194. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  195. package/dist/extensions/mcp/tools.js +33 -15
  196. package/dist/extensions/mcp/tools.js.map +1 -1
  197. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  198. package/dist/extensions/mcp/ui.js +4 -2
  199. package/dist/extensions/mcp/ui.js.map +1 -1
  200. package/dist/extensions/provider/catalog.d.ts +8 -1
  201. package/dist/extensions/provider/catalog.d.ts.map +1 -1
  202. package/dist/extensions/provider/catalog.js +31 -0
  203. package/dist/extensions/provider/catalog.js.map +1 -1
  204. package/dist/extensions/provider/connection.d.ts +4 -1
  205. package/dist/extensions/provider/connection.d.ts.map +1 -1
  206. package/dist/extensions/provider/connection.js +1 -5
  207. package/dist/extensions/provider/connection.js.map +1 -1
  208. package/dist/extensions/provider/editing.d.ts +36 -0
  209. package/dist/extensions/provider/editing.d.ts.map +1 -0
  210. package/dist/extensions/provider/editing.js +99 -0
  211. package/dist/extensions/provider/editing.js.map +1 -0
  212. package/dist/extensions/provider/json-fields.d.ts +5 -0
  213. package/dist/extensions/provider/json-fields.d.ts.map +1 -0
  214. package/dist/extensions/provider/json-fields.js +31 -0
  215. package/dist/extensions/provider/json-fields.js.map +1 -0
  216. package/dist/extensions/provider/store.d.ts +1 -4
  217. package/dist/extensions/provider/store.d.ts.map +1 -1
  218. package/dist/extensions/provider/store.js +2 -30
  219. package/dist/extensions/provider/store.js.map +1 -1
  220. package/dist/extensions/provider/ui/builtin-data.d.ts +0 -2
  221. package/dist/extensions/provider/ui/builtin-data.d.ts.map +1 -1
  222. package/dist/extensions/provider/ui/builtin-data.js +14 -79
  223. package/dist/extensions/provider/ui/builtin-data.js.map +1 -1
  224. package/dist/extensions/provider/ui/compat.d.ts.map +1 -1
  225. package/dist/extensions/provider/ui/compat.js +6 -9
  226. package/dist/extensions/provider/ui/compat.js.map +1 -1
  227. package/dist/extensions/provider/ui/controls.d.ts +48 -0
  228. package/dist/extensions/provider/ui/controls.d.ts.map +1 -0
  229. package/dist/extensions/provider/ui/controls.js +108 -0
  230. package/dist/extensions/provider/ui/controls.js.map +1 -0
  231. package/dist/extensions/provider/ui/dictionary.d.ts.map +1 -1
  232. package/dist/extensions/provider/ui/dictionary.js +6 -9
  233. package/dist/extensions/provider/ui/dictionary.js.map +1 -1
  234. package/dist/extensions/provider/ui/editor.d.ts +3 -3
  235. package/dist/extensions/provider/ui/editor.d.ts.map +1 -1
  236. package/dist/extensions/provider/ui/editor.js +35 -140
  237. package/dist/extensions/provider/ui/editor.js.map +1 -1
  238. package/dist/extensions/provider/ui/fetch-models.d.ts +0 -3
  239. package/dist/extensions/provider/ui/fetch-models.d.ts.map +1 -1
  240. package/dist/extensions/provider/ui/fetch-models.js +49 -44
  241. package/dist/extensions/provider/ui/fetch-models.js.map +1 -1
  242. package/dist/extensions/provider/ui/model-fields.d.ts.map +1 -1
  243. package/dist/extensions/provider/ui/model-fields.js +11 -14
  244. package/dist/extensions/provider/ui/model-fields.js.map +1 -1
  245. package/dist/extensions/provider/ui/model-options.d.ts +4 -34
  246. package/dist/extensions/provider/ui/model-options.d.ts.map +1 -1
  247. package/dist/extensions/provider/ui/model-options.js +90 -271
  248. package/dist/extensions/provider/ui/model-options.js.map +1 -1
  249. package/dist/extensions/provider/ui/pane.d.ts +4 -18
  250. package/dist/extensions/provider/ui/pane.d.ts.map +1 -1
  251. package/dist/extensions/provider/ui/pane.js.map +1 -1
  252. package/dist/extensions/provider/ui/provider-fields.d.ts +2 -19
  253. package/dist/extensions/provider/ui/provider-fields.d.ts.map +1 -1
  254. package/dist/extensions/provider/ui/provider-fields.js +58 -171
  255. package/dist/extensions/provider/ui/provider-fields.js.map +1 -1
  256. package/dist/extensions/provider/ui/thinking-map.d.ts.map +1 -1
  257. package/dist/extensions/provider/ui/thinking-map.js +6 -9
  258. package/dist/extensions/provider/ui/thinking-map.js.map +1 -1
  259. package/dist/extensions/question/detail-pane.d.ts +7 -2
  260. package/dist/extensions/question/detail-pane.d.ts.map +1 -1
  261. package/dist/extensions/question/detail-pane.js +16 -5
  262. package/dist/extensions/question/detail-pane.js.map +1 -1
  263. package/dist/extensions/question/dialog-view.d.ts +41 -0
  264. package/dist/extensions/question/dialog-view.d.ts.map +1 -0
  265. package/dist/extensions/question/dialog-view.js +329 -0
  266. package/dist/extensions/question/dialog-view.js.map +1 -0
  267. package/dist/extensions/question/dialog.d.ts +3 -3
  268. package/dist/extensions/question/dialog.d.ts.map +1 -1
  269. package/dist/extensions/question/dialog.js +220 -634
  270. package/dist/extensions/question/dialog.js.map +1 -1
  271. package/dist/extensions/question/index.d.ts.map +1 -1
  272. package/dist/extensions/question/index.js +2 -3
  273. package/dist/extensions/question/index.js.map +1 -1
  274. package/dist/extensions/question/render.d.ts.map +1 -1
  275. package/dist/extensions/question/render.js +22 -32
  276. package/dist/extensions/question/render.js.map +1 -1
  277. package/dist/extensions/question/results.d.ts.map +1 -1
  278. package/dist/extensions/question/results.js +56 -12
  279. package/dist/extensions/question/results.js.map +1 -1
  280. package/dist/extensions/question/schema.d.ts +21 -6
  281. package/dist/extensions/question/schema.d.ts.map +1 -1
  282. package/dist/extensions/question/schema.js.map +1 -1
  283. package/dist/extensions/question/state.d.ts +9 -7
  284. package/dist/extensions/question/state.d.ts.map +1 -1
  285. package/dist/extensions/question/state.js +63 -54
  286. package/dist/extensions/question/state.js.map +1 -1
  287. package/dist/extensions/question/types.d.ts +41 -18
  288. package/dist/extensions/question/types.d.ts.map +1 -1
  289. package/dist/extensions/question/types.js.map +1 -1
  290. package/dist/extensions/statusline/index.d.ts +4 -0
  291. package/dist/extensions/statusline/index.d.ts.map +1 -1
  292. package/dist/extensions/statusline/index.js +18 -355
  293. package/dist/extensions/statusline/index.js.map +1 -1
  294. package/dist/extensions/statusline/render.d.ts +19 -0
  295. package/dist/extensions/statusline/render.d.ts.map +1 -0
  296. package/dist/extensions/statusline/render.js +163 -0
  297. package/dist/extensions/statusline/render.js.map +1 -0
  298. package/dist/extensions/statusline/usage.d.ts +12 -0
  299. package/dist/extensions/statusline/usage.d.ts.map +1 -0
  300. package/dist/extensions/statusline/usage.js +36 -0
  301. package/dist/extensions/statusline/usage.js.map +1 -0
  302. package/dist/extensions/tool-search/tool.d.ts +5 -4
  303. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  304. package/dist/extensions/tool-search/tool.js +7 -28
  305. package/dist/extensions/tool-search/tool.js.map +1 -1
  306. package/dist/extensions/web-search/execute.d.ts +1 -5
  307. package/dist/extensions/web-search/execute.d.ts.map +1 -1
  308. package/dist/extensions/web-search/execute.js +4 -9
  309. package/dist/extensions/web-search/execute.js.map +1 -1
  310. package/dist/extensions/web-search/format.d.ts +12 -3
  311. package/dist/extensions/web-search/format.d.ts.map +1 -1
  312. package/dist/extensions/web-search/format.js +33 -25
  313. package/dist/extensions/web-search/format.js.map +1 -1
  314. package/dist/extensions/web-search/index.d.ts.map +1 -1
  315. package/dist/extensions/web-search/index.js +6 -29
  316. package/dist/extensions/web-search/index.js.map +1 -1
  317. package/dist/extensions/web-search/providers/deepseek.d.ts.map +1 -1
  318. package/dist/extensions/web-search/providers/deepseek.js +0 -1
  319. package/dist/extensions/web-search/providers/deepseek.js.map +1 -1
  320. package/dist/extensions/web-search/providers/http.d.ts +1 -1
  321. package/dist/extensions/web-search/providers/http.d.ts.map +1 -1
  322. package/dist/extensions/web-search/providers/http.js.map +1 -1
  323. package/dist/extensions/web-search/providers/minimax.d.ts.map +1 -1
  324. package/dist/extensions/web-search/providers/minimax.js +0 -1
  325. package/dist/extensions/web-search/providers/minimax.js.map +1 -1
  326. package/dist/extensions/web-search/render.d.ts +7 -2
  327. package/dist/extensions/web-search/render.d.ts.map +1 -1
  328. package/dist/extensions/web-search/render.js +32 -4
  329. package/dist/extensions/web-search/render.js.map +1 -1
  330. package/dist/extensions/web-search/results.d.ts.map +1 -1
  331. package/dist/extensions/web-search/results.js +3 -8
  332. package/dist/extensions/web-search/results.js.map +1 -1
  333. package/dist/extensions/web-search/types.d.ts +4 -2
  334. package/dist/extensions/web-search/types.d.ts.map +1 -1
  335. package/dist/extensions/web-search/types.js.map +1 -1
  336. package/dist/index.d.ts +2 -4
  337. package/dist/index.d.ts.map +1 -1
  338. package/dist/index.js +0 -1
  339. package/dist/index.js.map +1 -1
  340. package/dist/main.d.ts.map +1 -1
  341. package/dist/main.js +6 -0
  342. package/dist/main.js.map +1 -1
  343. package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
  344. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  345. package/dist/modes/interactive/components/oauth-selector.js +24 -21
  346. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  347. package/dist/modes/interactive/components/pi-logo-animation.d.ts +68 -0
  348. package/dist/modes/interactive/components/pi-logo-animation.d.ts.map +1 -0
  349. package/dist/modes/interactive/components/pi-logo-animation.js +1076 -0
  350. package/dist/modes/interactive/components/pi-logo-animation.js.map +1 -0
  351. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts +7 -0
  352. package/dist/modes/interactive/components/pi-logo-animation.lazy.d.ts.map +1 -0
  353. package/dist/modes/interactive/components/pi-logo-animation.lazy.js +12 -0
  354. package/dist/modes/interactive/components/pi-logo-animation.lazy.js.map +1 -0
  355. package/dist/modes/interactive/components/pi-logo.d.ts +7 -0
  356. package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -1
  357. package/dist/modes/interactive/components/pi-logo.js +13 -1
  358. package/dist/modes/interactive/components/pi-logo.js.map +1 -1
  359. package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
  360. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  361. package/dist/modes/interactive/components/radius-login-selector.js +83 -0
  362. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  363. package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
  364. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/settings-selector.js +5 -5
  366. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  367. package/dist/modes/interactive/components/status-marker.d.ts +0 -2
  368. package/dist/modes/interactive/components/status-marker.d.ts.map +1 -1
  369. package/dist/modes/interactive/components/status-marker.js +0 -4
  370. package/dist/modes/interactive/components/status-marker.js.map +1 -1
  371. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  372. package/dist/modes/interactive/components/user-message.js +5 -4
  373. package/dist/modes/interactive/components/user-message.js.map +1 -1
  374. package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
  375. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  376. package/dist/modes/interactive/components/visual-truncate.js +36 -6
  377. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  378. package/dist/modes/interactive/interactive-mode.d.ts +10 -0
  379. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  380. package/dist/modes/interactive/interactive-mode.js +167 -40
  381. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  382. package/dist/modes/interactive/tasks/completion-render.d.ts +1 -1
  383. package/dist/modes/interactive/tasks/completion-render.d.ts.map +1 -1
  384. package/dist/modes/interactive/tasks/completion-render.js +28 -82
  385. package/dist/modes/interactive/tasks/completion-render.js.map +1 -1
  386. package/dist/modes/interactive/tasks/index.d.ts.map +1 -1
  387. package/dist/modes/interactive/tasks/index.js +18 -13
  388. package/dist/modes/interactive/tasks/index.js.map +1 -1
  389. package/dist/modes/interactive/tasks/inspector.d.ts +35 -0
  390. package/dist/modes/interactive/tasks/inspector.d.ts.map +1 -0
  391. package/dist/modes/interactive/tasks/inspector.js +93 -0
  392. package/dist/modes/interactive/tasks/inspector.js.map +1 -0
  393. package/dist/modes/interactive/tasks/layout.d.ts +40 -0
  394. package/dist/modes/interactive/tasks/layout.d.ts.map +1 -0
  395. package/dist/modes/interactive/tasks/layout.js +212 -0
  396. package/dist/modes/interactive/tasks/layout.js.map +1 -0
  397. package/dist/modes/interactive/tasks/list.d.ts +21 -0
  398. package/dist/modes/interactive/tasks/list.d.ts.map +1 -0
  399. package/dist/modes/interactive/tasks/list.js +96 -0
  400. package/dist/modes/interactive/tasks/list.js.map +1 -0
  401. package/dist/modes/interactive/tasks/manager.d.ts +29 -36
  402. package/dist/modes/interactive/tasks/manager.d.ts.map +1 -1
  403. package/dist/modes/interactive/tasks/manager.js +315 -315
  404. package/dist/modes/interactive/tasks/manager.js.map +1 -1
  405. package/dist/modes/interactive/tasks/model.d.ts +21 -0
  406. package/dist/modes/interactive/tasks/model.d.ts.map +1 -0
  407. package/dist/modes/interactive/tasks/model.js +41 -0
  408. package/dist/modes/interactive/tasks/model.js.map +1 -0
  409. package/dist/modes/interactive/tasks/render.d.ts +5 -19
  410. package/dist/modes/interactive/tasks/render.d.ts.map +1 -1
  411. package/dist/modes/interactive/tasks/render.js +18 -102
  412. package/dist/modes/interactive/tasks/render.js.map +1 -1
  413. package/dist/modes/interactive/tasks/task-view.d.ts +8 -48
  414. package/dist/modes/interactive/tasks/task-view.d.ts.map +1 -1
  415. package/dist/modes/interactive/tasks/task-view.js +11 -51
  416. package/dist/modes/interactive/tasks/task-view.js.map +1 -1
  417. package/dist/modes/interactive/tasks/text.d.ts +1 -7
  418. package/dist/modes/interactive/tasks/text.d.ts.map +1 -1
  419. package/dist/modes/interactive/tasks/text.js +6 -29
  420. package/dist/modes/interactive/tasks/text.js.map +1 -1
  421. package/dist/modes/interactive/tasks/viewport.d.ts +2 -0
  422. package/dist/modes/interactive/tasks/viewport.d.ts.map +1 -1
  423. package/dist/modes/interactive/tasks/viewport.js +17 -7
  424. package/dist/modes/interactive/tasks/viewport.js.map +1 -1
  425. package/dist/modes/interactive/tasks/views.d.ts +9 -0
  426. package/dist/modes/interactive/tasks/views.d.ts.map +1 -0
  427. package/dist/modes/interactive/tasks/views.js +42 -0
  428. package/dist/modes/interactive/tasks/views.js.map +1 -0
  429. package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
  430. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  431. package/dist/modes/interactive/theme/system-theme.js +16 -5
  432. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  433. package/docs/bundled/README.md +0 -1
  434. package/docs/bundled/extensions/question.md +2 -2
  435. package/docs/bundled/extensions/statusline.md +24 -15
  436. package/docs/bundled/tasks.md +34 -48
  437. package/docs/codemode.md +207 -0
  438. package/docs/docs.json +4 -4
  439. package/docs/environment-variables.md +1 -1
  440. package/docs/extensions.md +7 -9
  441. package/docs/keybindings.md +13 -6
  442. package/docs/mcp.md +142 -82
  443. package/docs/models.md +21 -0
  444. package/docs/providers.md +8 -0
  445. package/docs/sdk.md +2 -2
  446. package/docs/session-format.md +12 -22
  447. package/docs/settings.md +4 -2
  448. package/docs/tui.md +1 -1
  449. package/docs/usage.md +6 -16
  450. package/examples/README.md +1 -1
  451. package/examples/extensions/README.md +1 -2
  452. package/examples/extensions/built-in-tool-renderer.ts +16 -40
  453. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  454. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  455. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  456. package/examples/extensions/gondolin/package-lock.json +2 -2
  457. package/examples/extensions/gondolin/package.json +1 -1
  458. package/examples/extensions/minimal-mode.ts +24 -96
  459. package/examples/extensions/sandbox/package-lock.json +2 -2
  460. package/examples/extensions/sandbox/package.json +1 -1
  461. package/examples/extensions/with-deps/package-lock.json +2 -2
  462. package/examples/extensions/with-deps/package.json +1 -1
  463. package/examples/sdk/14-codemode-mcp.ts +2 -2
  464. package/npm-shrinkwrap.json +69 -58
  465. package/package.json +11 -10
  466. package/dist/bundle/chunks/anthropic-messages-KIXY7EDT.js +0 -6
  467. package/dist/bundle/chunks/chunk-CLLDCO64.js +0 -2
  468. package/dist/bundle/chunks/chunk-UUSTLCVC.js +0 -2
  469. package/dist/bundle/chunks/chunk-VWCWZD6E.js +0 -2
  470. package/dist/bundle/chunks/virtual-modules-TQRORWJQ.js +0 -2
  471. package/dist/core/tasks/view-data.d.ts +0 -8
  472. package/dist/core/tasks/view-data.d.ts.map +0 -1
  473. package/dist/core/tasks/view-data.js +0 -61
  474. package/dist/core/tasks/view-data.js.map +0 -1
  475. package/dist/core/tasks/view.d.ts +0 -30
  476. package/dist/core/tasks/view.d.ts.map +0 -1
  477. package/dist/core/tasks/view.js +0 -50
  478. package/dist/core/tasks/view.js.map +0 -1
  479. package/dist/core/tools/renderers/shell-task.d.ts +0 -4
  480. package/dist/core/tools/renderers/shell-task.d.ts.map +0 -1
  481. package/dist/core/tools/renderers/shell-task.js +0 -35
  482. package/dist/core/tools/renderers/shell-task.js.map +0 -1
  483. package/dist/extensions/todo/constants.d.ts +0 -16
  484. package/dist/extensions/todo/constants.d.ts.map +0 -1
  485. package/dist/extensions/todo/constants.js +0 -30
  486. package/dist/extensions/todo/constants.js.map +0 -1
  487. package/dist/extensions/todo/index.d.ts +0 -3
  488. package/dist/extensions/todo/index.d.ts.map +0 -1
  489. package/dist/extensions/todo/index.js +0 -98
  490. package/dist/extensions/todo/index.js.map +0 -1
  491. package/dist/extensions/todo/schema.d.ts +0 -60
  492. package/dist/extensions/todo/schema.d.ts.map +0 -1
  493. package/dist/extensions/todo/schema.js +0 -56
  494. package/dist/extensions/todo/schema.js.map +0 -1
  495. package/dist/extensions/todo/state.d.ts +0 -34
  496. package/dist/extensions/todo/state.d.ts.map +0 -1
  497. package/dist/extensions/todo/state.js +0 -425
  498. package/dist/extensions/todo/state.js.map +0 -1
  499. package/dist/extensions/todo/view.d.ts +0 -36
  500. package/dist/extensions/todo/view.d.ts.map +0 -1
  501. package/dist/extensions/todo/view.js +0 -580
  502. package/dist/extensions/todo/view.js.map +0 -1
  503. package/dist/extensions/todo/widget.d.ts +0 -15
  504. package/dist/extensions/todo/widget.d.ts.map +0 -1
  505. package/dist/extensions/todo/widget.js +0 -50
  506. package/dist/extensions/todo/widget.js.map +0 -1
  507. package/dist/modes/interactive/tasks/fallback-view.d.ts +0 -4
  508. package/dist/modes/interactive/tasks/fallback-view.d.ts.map +0 -1
  509. package/dist/modes/interactive/tasks/fallback-view.js +0 -27
  510. package/dist/modes/interactive/tasks/fallback-view.js.map +0 -1
  511. package/docs/bundled/extensions/todo.md +0 -104
  512. package/examples/extensions/todo.ts +0 -297
@@ -1 +1 @@
1
- {"version":3,"file":"shell-tool.js","sourceRoot":"","sources":["../../../src/core/tools/shell-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAA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BACpC,UAAU;gBACV,OAAO;gBACP,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG;gBACpB,UAAU;gBACV,MAAM,EAAE,YAAY;gBACpB,QAAQ,EAAE,cAAc;gBACxB,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC;aAClC,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACrE,OAAO;gBACN,iBAAiB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5E,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,0CAA0C,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa,OAAO,CAAC,IAAI,CAAC,MAAM,wTAAwT,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;qBACne;iBACD;gBACD,OAAO,EAAE;oBACR,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE;oBAC3D,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;iBACvC;aACD,CAAC;QACH,CAAC;QACD,GAAG,oBAAoB,CAAC,MAAM,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellEnv,\n\tkillProcessTree,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { type TaskCompletion, TaskExecutionError } from \"../tasks/types.ts\";\nimport { createShellRenderers } from \"./renderers/bash.ts\";\nimport { type ManagedShellExecution, runShellCommand } from \"./shell-execution.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type TruncationResult } from \"./truncate.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst bashSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n\tbackground: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"true returns a managed task ID immediately and runs the command in the background; omit or false to block until exit\",\n\t\t}),\n\t),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands, foreground or background\",\n\tguidelines: [\"You can inspect PI_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\nconst bashOutputSchema = Type.Union([\n\tType.Object({\n\t\toutput: Type.String({\n\t\t\tdescription: \"Combined stdout and stderr, up to 1 MiB, keeping head and tail when truncated.\",\n\t\t}),\n\t\ttruncated: Type.Boolean(),\n\t\tfull_output_path: Type.Optional(Type.String()),\n\t\texit_code: Type.Number(),\n\t\twall_time_seconds: Type.Number(),\n\t}),\n\tType.Object({ task_id: Type.String(), status: Type.String() }),\n]);\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n\t/** Settled handoff snapshot, not a command completion or exit code. */\n\tbackground?: { kind: \"background\"; taskId: string };\n}\n\n/**\n * Pluggable operations for the bash tool.\n * Override these to delegate command execution to remote systems (for example SSH).\n */\nexport interface BashOperations {\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;\n\t * a null exit code is treated as a failed command.\n\t *\n\t * Error contract: reject with `new Error(\"aborted\")` when aborted via `signal`,\n\t * and `new Error(\"timeout:<seconds>\")` on timeout expiry. The shared shell\n\t * execution pipeline classifies outcomes from these exact markers.\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(\n\tshellName: string,\n\tresolveShellConfig: () => ShellConfig,\n\tnormalizeCommand: (command: string) => string = (command) => command,\n): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, env }) => {\n\t\t\tconst timeoutMs = resolveTimeoutMs(timeout);\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst shellConfig = resolveShellConfig();\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst normalizedCommand = normalizeCommand(command);\n\t\t\tconst child = spawn(\n\t\t\t\tshellConfig.shell,\n\t\t\t\tcommandFromStdin ? shellConfig.args : [...shellConfig.args, normalizedCommand],\n\t\t\t\t{\n\t\t\t\t\tcwd,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tenv: env ?? getShellEnv(),\n\t\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(normalizedCommand);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", onData);\n\t\t\t\tchild.stderr?.on(\"data\", onData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\treturn { exitCode: exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1) };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nexport function resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n): BashSpawnContext {\n\tconst env = { ...getShellEnv() };\n\tdelete env.PI_SESSION_ID;\n\tdelete env.PI_SESSION_FILE;\n\tdelete env.PI_PROVIDER;\n\tdelete env.PI_MODEL;\n\tdelete env.PI_REASONING_LEVEL;\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tenv.PI_SESSION_ID = ctx.sessionManager.getSessionId();\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) env.PI_SESSION_FILE = sessionFile;\n\t\tif (model) {\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) env.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current Pi session metadata as PI_* environment variables. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tdispose?: () => void;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\n/** Translate terminal shell failures to the native foreground tool contract once. */\nfunction shellToolResult(completion: TaskCompletion<BashToolDetails | undefined>, managed: boolean) {\n\tconst status = completion.status;\n\tif (completion.result.structuredContent) return completion.result;\n\tif (status === \"failed\" || status === \"timeout\" || status === \"cancelled\") {\n\t\tconst text = completion.result.content\n\t\t\t.filter((part) => part.type === \"text\")\n\t\t\t.map((part) => part.text)\n\t\t\t.join(\"\\n\");\n\t\tconst message = completion.error ? text || completion.error : `${text ? `${text}\\n\\n` : \"\"}Command ${status}`;\n\t\tthrow managed ? new TaskExecutionError(message, status) : new Error(message);\n\t}\n\treturn completion.result;\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions: BashToolOptions & { operations: BashOperations },\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\tconst ops = options.operations;\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\treturn {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr, truncated to the last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first); the full output is saved to a temp file. Optionally provide a timeout in seconds (no default). Choose the mode per call: foreground (default) blocks until the command exits — use it when your next step needs the output; background: true returns immediately with a task ID — use it for long-running work (builds, servers, watchers, big test suites) or when you have independent work to continue. A handoff is not completion: the result arrives later as an automatic completion notification; meanwhile use tasks read to inspect output, tasks wait to block until it settles, tasks kill to stop it. Background output is limited to 20 MiB; an expired tasks wait window never stops the command.`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\tparameters: bashSchema,\n\t\toutputSchema: bashOutputSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\t{ command, timeout, background }: BashToolInput,\n\t\t\tparentSignal?: AbortSignal,\n\t\t\toriginalUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst host = ctx?.tasks;\n\t\t\tif (host?.closed) throw new Error(\"Background service is closed\");\n\t\t\tconst run = async (managed?: ManagedShellExecution): Promise<TaskCompletion<BashToolDetails | undefined>> => {\n\t\t\t\tconst signal = managed?.control.signal ?? parentSignal;\n\t\t\t\ttry {\n\t\t\t\t\tif (managed) {\n\t\t\t\t\t\tif (signal?.aborted) throw new Error(\"Command aborted\");\n\t\t\t\t\t\tresolveTimeoutMs(timeout);\n\t\t\t\t\t}\n\t\t\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\t\t\tresolvedCommand,\n\t\t\t\t\t\tctx?.cwd || cwd,\n\t\t\t\t\t\tspawnHook,\n\t\t\t\t\t\texposeSessionEnvironment,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t);\n\t\t\t\t\treturn await runShellCommand({\n\t\t\t\t\t\toperations: ops,\n\t\t\t\t\t\tshellName: config.shellName,\n\t\t\t\t\t\tcontext: spawnContext,\n\t\t\t\t\t\ttempFilePrefix: config.tempFilePrefix,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tonUpdate: originalUpdate,\n\t\t\t\t\t\tmanaged,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Setup and cleanup exceptions carry an explicit terminal status.\n\t\t\t\t\tif (!managed) throw error;\n\t\t\t\t\tthrow new TaskExecutionError(\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t\t\tmanaged.control.signal.aborted ? \"cancelled\" : \"failed\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (!host) {\n\t\t\t\tif (background)\n\t\t\t\t\tthrow new Error(\"Background execution is not available in this host. No command was started.\");\n\t\t\t\treturn shellToolResult(await run(), false);\n\t\t\t}\n\t\t\tconst outcome = await host.execute<BashToolDetails | undefined>({\n\t\t\t\tkind: config.name,\n\t\t\t\tformat: \"log\",\n\t\t\t\ttitle: `${config.label}: ${command}`,\n\t\t\t\ttoolCallId,\n\t\t\t\tcommand,\n\t\t\t\tcwd: ctx?.cwd || cwd,\n\t\t\t\tbackground,\n\t\t\t\tsignal: parentSignal,\n\t\t\t\tonUpdate: originalUpdate,\n\t\t\t\trun: (control) => run({ control }),\n\t\t\t});\n\t\t\tif (outcome.kind === \"result\") return shellToolResult(outcome, true);\n\t\t\treturn {\n\t\t\t\tstructuredContent: { task_id: outcome.task.id, status: outcome.task.status },\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Command handed to background. Task ID: ${outcome.task.id}. Status: ${outcome.task.status}. Completion arrives automatically as a notification — do not poll or immediately wait on it; continue with other work or hand back to the user. Use tasks read to inspect output, tasks wait only when your next step is blocked on the result (prefer foreground next time in that case), or tasks kill to stop it.${outcome.task.outputPath ? `\\nFull output: ${outcome.task.outputPath}` : \"\"}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: {\n\t\t\t\t\tbackground: { kind: \"background\", taskId: outcome.task.id },\n\t\t\t\t\tfullOutputPath: outcome.task.outputPath,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\t...createShellRenderers(config),\n\t};\n}\n"]}
1
+ {"version":3,"file":"shell-tool.js","sourceRoot":"","sources":["../../../src/core/tools/shell-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACN,WAAW,EACX,eAAe,EAEf,qBAAqB,EACrB,uBAAuB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAuB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAA8B,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAyB,MAAM,eAAe,CAAC;AAE5F,MAAM,cAAc,GAAG,aAAa,CAAC;AACrC,MAAM,mBAAmB,GAAG,cAAc,GAAG,IAAI,CAAC;AAElD,SAAS,gBAAgB,CAAC,OAA2B;IACpD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5C,IAAI,CAAC,MAAM,CAAC,QA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BACD,OAAO,EAAE;oBACR,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE;oBAC3D,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;iBACvC;aACD,CAAC;QACH,CAAC;QACD,GAAG,oBAAoB,CAAC,MAAM,CAAC;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { access as fsAccess } from \"node:fs/promises\";\nimport { constants as osConstants } from \"node:os\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { waitForChildProcess } from \"../../utils/child-process.ts\";\nimport {\n\tgetShellEnv,\n\tkillProcessTree,\n\ttype ShellConfig,\n\ttrackDetachedChildPid,\n\tuntrackDetachedChildPid,\n} from \"../../utils/shell.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { type TaskCompletion, TaskExecutionError } from \"../tasks/types.ts\";\nimport { createShellRenderers } from \"./renderers/bash.ts\";\nimport { type ManagedShellExecution, runShellCommand } from \"./shell-execution.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type TruncationResult } from \"./truncate.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\n\nfunction resolveTimeoutMs(timeout: number | undefined): number | undefined {\n\tif (timeout === undefined) return undefined;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n\treturn timeoutMs;\n}\n\nconst bashSchema = Type.Object({\n\tcommand: Type.String({ description: \"Shell command to execute\" }),\n\ttimeout: Type.Optional(Type.Number({ description: \"Timeout in seconds (optional, no default timeout)\" })),\n\tbackground: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"true returns a managed task ID immediately and runs the command in the background; omit or false to block until exit\",\n\t\t}),\n\t),\n});\n\nexport const bashToolSystemPromptContribution = {\n\tsnippet: \"Execute bash commands, foreground or background\",\n\tguidelines: [\"You can inspect PI_* environment variables for current model and session details.\"],\n} as const;\n\nexport type BashToolInput = Static<typeof bashSchema>;\n\nconst bashOutputSchema = Type.Union([\n\tType.Object({\n\t\toutput: Type.String({\n\t\t\tdescription: \"Combined stdout and stderr, up to 1 MiB, keeping head and tail when truncated.\",\n\t\t}),\n\t\ttruncated: Type.Boolean(),\n\t\tfull_output_path: Type.Optional(Type.String()),\n\t\texit_code: Type.Number(),\n\t\twall_time_seconds: Type.Number(),\n\t}),\n\tType.Object({ task_id: Type.String(), status: Type.String() }),\n]);\n\nexport interface BashToolDetails {\n\ttruncation?: TruncationResult;\n\tfullOutputPath?: string;\n\t/** Settled handoff snapshot, not a command completion or exit code. */\n\tbackground?: { kind: \"background\"; taskId: string };\n}\n\n/**\n * Pluggable operations for the bash tool.\n * Override these to delegate command execution to remote systems (for example SSH).\n */\nexport interface BashOperations {\n\t/**\n\t * Execute a command and stream output.\n\t * @param command The command to execute\n\t * @param cwd Working directory\n\t * @param options Execution options\n\t * @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;\n\t * a null exit code is treated as a failed command.\n\t *\n\t * Error contract: reject with `new Error(\"aborted\")` when aborted via `signal`,\n\t * and `new Error(\"timeout:<seconds>\")` on timeout expiry. The shared shell\n\t * execution pipeline classifies outcomes from these exact markers.\n\t */\n\texec: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\toptions: {\n\t\t\tonData: (data: Buffer) => void;\n\t\t\tsignal?: AbortSignal;\n\t\t\ttimeout?: number;\n\t\t\tenv?: NodeJS.ProcessEnv;\n\t\t},\n\t) => Promise<{ exitCode: number | null }>;\n}\n\n/** Shared process execution used by the built-in shell tools. */\nexport function createLocalShellOperations(\n\tshellName: string,\n\tresolveShellConfig: () => ShellConfig,\n\tnormalizeCommand: (command: string) => string = (command) => command,\n): BashOperations {\n\treturn {\n\t\texec: async (command, cwd, { onData, signal, timeout, env }) => {\n\t\t\tconst timeoutMs = resolveTimeoutMs(timeout);\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t}\n\t\t\tconst shellConfig = resolveShellConfig();\n\t\t\ttry {\n\t\t\t\tawait fsAccess(cwd, constants.F_OK);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(`Working directory does not exist: ${cwd}\\nCannot execute ${shellName} commands.`);\n\t\t\t}\n\n\t\t\tif (signal?.aborted) throw new Error(\"aborted\");\n\t\t\tconst commandFromStdin = shellConfig.commandTransport === \"stdin\";\n\t\t\tconst normalizedCommand = normalizeCommand(command);\n\t\t\tconst child = spawn(\n\t\t\t\tshellConfig.shell,\n\t\t\t\tcommandFromStdin ? shellConfig.args : [...shellConfig.args, normalizedCommand],\n\t\t\t\t{\n\t\t\t\t\tcwd,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tenv: env ?? getShellEnv(),\n\t\t\t\t\tstdio: [commandFromStdin ? \"pipe\" : \"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (commandFromStdin) {\n\t\t\t\tchild.stdin?.on(\"error\", () => {});\n\t\t\t\tchild.stdin?.end(normalizedCommand);\n\t\t\t}\n\t\t\tif (child.pid) trackDetachedChildPid(child.pid);\n\t\t\tlet timedOut = false;\n\t\t\tlet timeoutHandle: NodeJS.Timeout | undefined;\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\t// Set timeout if provided.\n\t\t\t\tif (timeoutMs !== undefined) {\n\t\t\t\t\ttimeoutHandle = setTimeout(() => {\n\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t\t\t\t}, timeoutMs);\n\t\t\t\t}\n\t\t\t\t// Stream stdout and stderr.\n\t\t\t\tchild.stdout?.on(\"data\", onData);\n\t\t\t\tchild.stderr?.on(\"data\", onData);\n\t\t\t\t// Handle abort signal by killing the entire process tree.\n\t\t\t\tif (signal) {\n\t\t\t\t\tif (signal.aborted) onAbort();\n\t\t\t\t\telse signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t\t// Handle shell spawn errors and wait for the process to terminate without hanging\n\t\t\t\t// on inherited stdio handles held by detached descendants.\n\t\t\t\tconst exitCode = await waitForChildProcess(child);\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"aborted\");\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tthrow new Error(`timeout:${timeout}`);\n\t\t\t\t}\n\t\t\t\t// A signal-killed shell has no exit code. Use the standard shell convention so\n\t\t\t\t// callers do not mistake the termination for a successful command.\n\t\t\t\tconst signalCode = child.signalCode;\n\t\t\t\treturn { exitCode: exitCode ?? (signalCode ? 128 + (osConstants.signals[signalCode] ?? 0) : 1) };\n\t\t\t} finally {\n\t\t\t\tif (child.pid) untrackDetachedChildPid(child.pid);\n\t\t\t\tif (timeoutHandle) clearTimeout(timeoutHandle);\n\t\t\t\tif (signal) signal.removeEventListener(\"abort\", onAbort);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Create bash operations using pi's built-in local shell execution backend.\n *\n * This is useful for extensions that intercept user_bash and still want pi's\n * standard local shell behavior while wrapping or rewriting commands.\n */\n\nexport interface BashSpawnContext {\n\tcommand: string;\n\tcwd: string;\n\tenv: NodeJS.ProcessEnv;\n}\n\nexport type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;\n\nexport function resolveSpawnContext(\n\tcommand: string,\n\tcwd: string,\n\tspawnHook: BashSpawnHook | undefined,\n\texposeSessionEnvironment: boolean,\n\tctx: ExtensionContext | undefined,\n): BashSpawnContext {\n\tconst env = { ...getShellEnv() };\n\tdelete env.PI_SESSION_ID;\n\tdelete env.PI_SESSION_FILE;\n\tdelete env.PI_PROVIDER;\n\tdelete env.PI_MODEL;\n\tdelete env.PI_REASONING_LEVEL;\n\tif (exposeSessionEnvironment && ctx) {\n\t\tconst model = ctx.model;\n\t\tenv.PI_SESSION_ID = ctx.sessionManager.getSessionId();\n\t\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\t\tif (sessionFile) env.PI_SESSION_FILE = sessionFile;\n\t\tif (model) {\n\t\t\tenv.PI_PROVIDER = model.provider;\n\t\t\tenv.PI_MODEL = model.id;\n\t\t}\n\t\tif (ctx.thinkingLevel) env.PI_REASONING_LEVEL = ctx.thinkingLevel;\n\t}\n\tconst baseContext: BashSpawnContext = { command, cwd, env };\n\treturn spawnHook ? spawnHook(baseContext) : baseContext;\n}\n\nexport interface BashToolOptions {\n\t/** Custom operations for command execution. Default: local shell */\n\toperations?: BashOperations;\n\t/** Command prefix prepended to every command (for example shell setup commands) */\n\tcommandPrefix?: string;\n\t/** Optional explicit shell path from settings */\n\tshellPath?: string;\n\t/** Expose current Pi session metadata as PI_* environment variables. Default: true */\n\texposeSessionEnvironment?: boolean;\n\t/** Hook to adjust command, cwd, or env before execution */\n\tspawnHook?: BashSpawnHook;\n}\n\nexport type BashRenderState = {\n\tdispose?: () => void;\n};\n\nexport interface ShellToolConfig {\n\tname: string;\n\tlabel: string;\n\tshellName: string;\n\tprompt: string;\n\tpromptSnippet: string;\n\tpromptGuidelines?: readonly string[];\n\ttempFilePrefix: string;\n}\n\n/** Translate terminal shell failures to the native foreground tool contract once. */\nfunction shellToolResult(completion: TaskCompletion<BashToolDetails | undefined>, managed: boolean) {\n\tconst status = completion.status;\n\tif (completion.result.structuredContent) return completion.result;\n\tif (status === \"failed\" || status === \"timeout\" || status === \"cancelled\") {\n\t\tconst text = completion.result.content\n\t\t\t.filter((part) => part.type === \"text\")\n\t\t\t.map((part) => part.text)\n\t\t\t.join(\"\\n\");\n\t\tconst message = completion.error ? text || completion.error : `${text ? `${text}\\n\\n` : \"\"}Command ${status}`;\n\t\tthrow managed ? new TaskExecutionError(message, status) : new Error(message);\n\t}\n\treturn completion.result;\n}\n\nexport function createShellToolDefinition(\n\tcwd: string,\n\tconfig: ShellToolConfig,\n\toptions: BashToolOptions & { operations: BashOperations },\n): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState> {\n\tconst ops = options.operations;\n\tconst commandPrefix = options?.commandPrefix;\n\tconst exposeSessionEnvironment = options?.exposeSessionEnvironment ?? true;\n\tconst spawnHook = options?.spawnHook;\n\treturn {\n\t\tname: config.name,\n\t\tlabel: config.label,\n\t\tdescription: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr, truncated to the last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first); the full output is saved to a temp file. Optionally provide a timeout in seconds (no default). Choose the mode per call: foreground (default) blocks until the command exits — use it when your next step needs the output; background: true returns immediately with a task ID — use it for long-running work (builds, servers, watchers, big test suites) or when you have independent work to continue. A handoff is not completion: the result arrives later as an automatic completion notification; meanwhile use tasks read to inspect output, tasks wait to block until it settles, tasks kill to stop it. Background output is limited to 20 MiB; an expired tasks wait window never stops the command.`,\n\t\tpromptSnippet: config.promptSnippet,\n\t\tpromptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,\n\t\tparameters: bashSchema,\n\t\toutputSchema: bashOutputSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\t{ command, timeout, background }: BashToolInput,\n\t\t\tparentSignal?: AbortSignal,\n\t\t\toriginalUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst host = ctx?.tasks;\n\t\t\tif (host?.closed) throw new Error(\"Task service is closed\");\n\t\t\tconst run = async (managed?: ManagedShellExecution): Promise<TaskCompletion<BashToolDetails | undefined>> => {\n\t\t\t\tconst signal = managed?.control.signal ?? parentSignal;\n\t\t\t\ttry {\n\t\t\t\t\tif (managed) {\n\t\t\t\t\t\tif (signal?.aborted) throw new Error(\"Command aborted\");\n\t\t\t\t\t\tresolveTimeoutMs(timeout);\n\t\t\t\t\t}\n\t\t\t\t\tconst resolvedCommand = commandPrefix ? `${commandPrefix}\\n${command}` : command;\n\t\t\t\t\tconst spawnContext = resolveSpawnContext(\n\t\t\t\t\t\tresolvedCommand,\n\t\t\t\t\t\tctx?.cwd || cwd,\n\t\t\t\t\t\tspawnHook,\n\t\t\t\t\t\texposeSessionEnvironment,\n\t\t\t\t\t\tctx,\n\t\t\t\t\t);\n\t\t\t\t\treturn await runShellCommand({\n\t\t\t\t\t\toperations: ops,\n\t\t\t\t\t\tcontext: spawnContext,\n\t\t\t\t\t\ttempFilePrefix: config.tempFilePrefix,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tonUpdate: originalUpdate,\n\t\t\t\t\t\tmanaged,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Setup and cleanup exceptions carry an explicit terminal status.\n\t\t\t\t\tif (!managed) throw error;\n\t\t\t\t\tthrow new TaskExecutionError(\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t\t\tmanaged.control.signal.aborted ? \"cancelled\" : \"failed\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (!host) {\n\t\t\t\tif (background)\n\t\t\t\t\tthrow new Error(\"Background execution is not available in this host. No command was started.\");\n\t\t\t\treturn shellToolResult(await run(), false);\n\t\t\t}\n\t\t\tconst outcome = await host.execute<BashToolDetails | undefined>({\n\t\t\t\tkind: config.name,\n\t\t\t\ttitle: command,\n\t\t\t\ttoolCallId,\n\t\t\t\tcommand,\n\t\t\t\tcwd: ctx?.cwd || cwd,\n\t\t\t\tbackground,\n\t\t\t\tsignal: parentSignal,\n\t\t\t\tonUpdate: originalUpdate,\n\t\t\t\trun: (control) => run({ control }),\n\t\t\t});\n\t\t\tif (outcome.kind === \"result\") return shellToolResult(outcome, true);\n\t\t\treturn {\n\t\t\t\tstructuredContent: { task_id: outcome.task.id, status: outcome.task.status },\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Command handed to background. Task ID: ${outcome.task.id}. Status: ${outcome.task.status}. Completion arrives automatically as a notification — do not poll or immediately wait on it; continue with other work or hand back to the user. Use tasks read to inspect output, tasks wait only when your next step is blocked on the result (prefer foreground next time in that case), or tasks kill to stop it.${outcome.task.outputPath ? `\\nFull output: ${outcome.task.outputPath}` : \"\"}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: {\n\t\t\t\t\tbackground: { kind: \"background\", taskId: outcome.task.id },\n\t\t\t\t\tfullOutputPath: outcome.task.outputPath,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\t...createShellRenderers(config),\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- /** Management only: execution and delivery belong to the session Background service. */
1
+ /** Management only: execution and delivery belong to the session task runtime. */
2
2
  import type { AgentToolResult } from "../../extensions/types.ts";
3
3
  import { type TaskSnapshot, type TasksContext } from "../../tasks/types.ts";
4
4
  import { type TasksInput } from "./schema.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/actions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAIxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAIN,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA+D,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,KAAK,EAAgB,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BAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,GAAG,SAAa,GAAG,MAAM,CAE7E;AAwFD,wBAAsB,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAkBrH;AACD,wBAAsB,OAAO,CAC5B,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,UAAU,EACjB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAChC,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAsC5C;AACD,wBAAgB,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAoBtG;AACD,wBAAgB,OAAO,CAAC,UAAU,EAAE,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAmBnF"}
@@ -1,6 +1,6 @@
1
- /** Management only: execution and delivery belong to the session Background service. */
2
- import { runtimeLabel } from "../../../modes/interactive/tasks/task-view.js";
1
+ /** Management only: execution and delivery belong to the session task runtime. */
3
2
  import { sanitizeBinaryOutput } from "../../../utils/shell.js";
3
+ import { runtimeLabel } from "../../tasks/format.js";
4
4
  import { boundText } from "../../tasks/output.js";
5
5
  import { isTaskTerminal, TaskLookupError, } from "../../tasks/types.js";
6
6
  import { truncateHead } from "../truncate.js";
@@ -52,17 +52,33 @@ function lookupFailure(background, id, error) {
52
52
  return error instanceof Error ? error : new Error(String(error));
53
53
  if (error.kind === "ambiguous") {
54
54
  const lines = error.matches.map((task) => describeTaskLine(task)).join("\n");
55
- return new Error(`Ambiguous background task ID "${id}" matches ${error.matches.length} tasks:\n${lines}`);
55
+ return new Error(`Ambiguous task ID "${id}" matches ${error.matches.length} tasks:\n${lines}`);
56
56
  }
57
57
  const { tasks, foregroundOmitted } = listedTasks(background);
58
58
  const active = tasks.filter((task) => !isTaskTerminal(task.status));
59
59
  const finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));
60
60
  const shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);
61
61
  if (shown.length === 0) {
62
- return new Error(`No background task "${id}" in this session. No background tasks in this session.`);
62
+ return new Error(`No task "${id}" in this session. No background tasks in this session.`);
63
63
  }
64
64
  const lines = shown.map((task) => describeTaskLine(task)).join("\n");
65
- return new Error(`No background task "${id}" in this session. IDs from other sessions are not valid here.\nCurrent tasks:\n${lines}${foregroundOmissionNote(foregroundOmitted)}`);
65
+ return new Error(`No task "${id}" in this session. IDs from other sessions are not valid here.\nCurrent background tasks:\n${lines}${foregroundOmissionNote(foregroundOmitted)}`);
66
+ }
67
+ /**
68
+ * Where this slice sits in the output, so the next wait can continue from it.
69
+ * A wait whose new output exceeds its budget returns the newest bytes and says what it skipped.
70
+ */
71
+ function rangeText(slice, sinceBytes) {
72
+ const from = slice.fromByte ?? 0;
73
+ const to = from + Buffer.byteLength(slice.text);
74
+ const floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;
75
+ return [
76
+ `bytes ${from}–${to} of ${slice.totalBytes}`,
77
+ sinceBytes !== undefined && from > floor ? `skipped ${from - floor} bytes after sinceBytes ${floor}` : "",
78
+ `next sinceBytes ${to}`,
79
+ ]
80
+ .filter(Boolean)
81
+ .join(" · ");
66
82
  }
67
83
  /** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */
68
84
  function readText(header, slice) {
@@ -82,7 +98,7 @@ export async function runRead(background, input) {
82
98
  try {
83
99
  const mode = input.mode ?? "tail";
84
100
  const slice = await background.read(id, { mode, bytes: clampReadBytes(input.bytes) });
85
- return result(readText(`[${describeTaskLine(slice.task)} · ${slice.totalBytes} bytes${slice.truncated ? " · truncated" : ""}]`, slice), {
101
+ return result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {
86
102
  action: "read",
87
103
  taskId: slice.task.id,
88
104
  mode,
@@ -112,20 +128,18 @@ export async function runWait(background, input, signal, onReady) {
112
128
  : timedOut
113
129
  ? " · wait window expired; execution continues"
114
130
  : "";
115
- const slice = await background.read(id, {
116
- bytes: TASKS_WAIT_DELTA_BYTES,
117
- sinceBytes: clampSinceBytes(input.sinceBytes),
118
- });
131
+ const sinceBytes = clampSinceBytes(input.sinceBytes);
132
+ const slice = await background.read(id, { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes });
119
133
  signal?.throwIfAborted();
120
134
  if (!timedOut)
121
135
  onReady?.(task.id);
122
- return result(readText(`[${describeTaskLine(task)}${windowNote}]`, slice), {
136
+ return result(readText(`[${describeTaskLine(task)}${windowNote} · ${rangeText(slice, sinceBytes)}]`, slice), {
123
137
  action: "wait",
124
138
  taskId: task.id,
125
139
  status: task.status,
126
140
  kind: task.kind,
127
141
  timedOut,
128
- exitCode: undefined,
142
+ exitCode: task.exitCode,
129
143
  waitedMs: Date.now() - start,
130
144
  deltaBytes: Buffer.byteLength(slice.text),
131
145
  totalBytes: slice.totalBytes,
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/actions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACN,cAAc,EACd,eAAe,GAIf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAG3G,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,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AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session Background service. */\n\nimport { runtimeLabel } from \"../../../modes/interactive/tasks/task-view.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport type { AgentToolResult } from \"../../extensions/types.ts\";\nimport { boundText } from \"../../tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n} from \"../../tasks/types.ts\";\nimport { truncateHead } from \"../truncate.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampReadBytes, clampSinceBytes, clampWaitMs, requireTaskId, type TasksInput } from \"./schema.ts\";\nimport type { TasksDetails, TasksKillDetails, TasksListDetails, TasksReadDetails, TasksWaitDetails } from \"./types.ts\";\n\nexport function boundedText(text: string): string {\n\treturn truncateHead(sanitizeBinaryOutput(text), { maxBytes: 50 * 1024, maxLines: 2000 }).content;\n}\nfunction result<T extends TasksDetails>(text: string, details: T): AgentToolResult<T> {\n\treturn { content: [{ type: \"text\", text: boundedText(text) }], details };\n}\nexport function describeTaskLine(task: TaskSnapshot, now = Date.now()): string {\n\treturn `${task.id} ${task.kind} ${task.status} (${task.mode}) ${runtimeLabel(task, now)} ${task.title.slice(0, 200)}`;\n}\n\nconst LOOKUP_LIST_LIMIT = 10;\n\n/**\n * Finished rows sort most-recent first. list() is creation-ordered, so an\n * unsorted slice would surface the oldest completions rather than the recent\n * finishes a caller is most likely looking for.\n */\nfunction recentFinishedFirst(tasks: TaskSnapshot[]): TaskSnapshot[] {\n\treturn tasks.sort((left, right) => (right.endedAt ?? 0) - (left.endedAt ?? 0));\n}\n\n/**\n * Listings cover backgrounded work only; foreground executions deliver inline\n * in the transcript, so they are counted rather than shown. Every listing\n * (tasks list output and lookup-failure messages) shares this scope.\n */\nfunction listedTasks(background: TasksContext): { tasks: TaskSnapshot[]; foregroundOmitted: number } {\n\tconst all = background.list();\n\tconst tasks = all.filter((task) => task.mode === \"background\");\n\treturn { tasks, foregroundOmitted: all.length - tasks.length };\n}\n\nfunction foregroundOmissionNote(omitted: number): string {\n\treturn omitted > 0\n\t\t? `\\n${omitted} foreground ${omitted === 1 ? \"execution\" : \"executions\"} omitted — foreground work is delivered inline in the transcript.`\n\t\t: \"\";\n}\n\n/**\n * Rewrite the service's bare lookup failure into an actionable one: an\n * unknown id gets the session's current tasks (active first, then recent\n * finishes) so the next call can use a real id without a separate list call,\n * and an ambiguous prefix gets exactly the tasks it matched — including\n * records outside the current branch, which listings hide but the prefix\n * still collides with.\n */\nfunction lookupFailure(background: TasksContext, id: string, error: unknown): Error {\n\tif (!(error instanceof TaskLookupError)) return error instanceof Error ? error : new Error(String(error));\n\tif (error.kind === \"ambiguous\") {\n\t\tconst lines = error.matches.map((task) => describeTaskLine(task)).join(\"\\n\");\n\t\treturn new Error(`Ambiguous background task ID \"${id}\" matches ${error.matches.length} tasks:\\n${lines}`);\n\t}\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);\n\tif (shown.length === 0) {\n\t\treturn new Error(`No background task \"${id}\" in this session. No background tasks in this session.`);\n\t}\n\tconst lines = shown.map((task) => describeTaskLine(task)).join(\"\\n\");\n\treturn new Error(\n\t\t`No background task \"${id}\" in this session. IDs from other sessions are not valid here.\\nCurrent tasks:\\n${lines}${foregroundOmissionNote(foregroundOmitted)}`,\n\t);\n}\n/** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */\nfunction readText(header: string, slice: TaskRead): string {\n\tconst boundedField = (text: string, maxBytes: number) =>\n\t\ttruncateHead(boundText(sanitizeBinaryOutput(text), maxBytes), { maxBytes, maxLines: 100 }).content;\n\treturn [\n\t\tboundedField(header, 4096),\n\t\tslice.task.error ? `Task error: ${boundedField(slice.task.error, 4096)}` : \"\",\n\t\tslice.readError ? `Output read error: ${boundedField(slice.readError, 4096)}` : \"\",\n\t\tboundedField(slice.task.outputPath ?? \"\", 8192),\n\t\tslice.text || \"(no output yet)\",\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\nexport async function runRead(background: TasksContext, input: TasksInput): Promise<AgentToolResult<TasksReadDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst mode = input.mode ?? \"tail\";\n\t\tconst slice = await background.read(id, { mode, bytes: clampReadBytes(input.bytes) });\n\t\treturn result(\n\t\t\treadText(\n\t\t\t\t`[${describeTaskLine(slice.task)} · ${slice.totalBytes} bytes${slice.truncated ? \" · truncated\" : \"\"}]`,\n\t\t\t\tslice,\n\t\t\t),\n\t\t\t{\n\t\t\t\taction: \"read\",\n\t\t\t\ttaskId: slice.task.id,\n\t\t\t\tmode,\n\t\t\t\tsliceBytes: Buffer.byteLength(slice.text),\n\t\t\t\ttotalBytes: slice.totalBytes,\n\t\t\t\toutputPath: slice.task.outputPath ?? \"\",\n\t\t\t\tkind: slice.task.kind,\n\t\t\t\tstatus: slice.task.status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst release = background.holdDelivery(id);\n\t\ttry {\n\t\t\tconst start = Date.now();\n\t\t\tconst task = await background.wait(id, clampWaitMs(input.waitMs), signal);\n\t\t\tconst timedOut = !isTaskTerminal(task.status);\n\t\t\t// A closed host resolves waits early without settling anything; do not claim\n\t\t\t// the execution merely outlived the wait window.\n\t\t\tconst windowNote = background.closed\n\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t: timedOut\n\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t: \"\";\n\t\t\tconst slice = await background.read(id, {\n\t\t\t\tbytes: TASKS_WAIT_DELTA_BYTES,\n\t\t\t\tsinceBytes: clampSinceBytes(input.sinceBytes),\n\t\t\t});\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (!timedOut) onReady?.(task.id);\n\t\t\treturn result(readText(`[${describeTaskLine(task)}${windowNote}]`, slice), {\n\t\t\t\taction: \"wait\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tstatus: task.status,\n\t\t\t\tkind: task.kind,\n\t\t\t\ttimedOut,\n\t\t\t\texitCode: undefined,\n\t\t\t\twaitedMs: Date.now() - start,\n\t\t\t\tdeltaBytes: Buffer.byteLength(slice.text),\n\t\t\t\ttotalBytes: slice.totalBytes,\n\t\t\t\tdeltaTruncated: slice.truncated,\n\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t});\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runKill(background: TasksContext, input: TasksInput): AgentToolResult<TasksKillDetails> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst task = background.get(id);\n\t\tconst requested = background.kill(task.id);\n\t\treturn result(\n\t\t\trequested\n\t\t\t\t? `Cancellation requested for ${task.id}. The task or whole group is stopping; cleanup may still be in progress.`\n\t\t\t\t: `No new cancellation requested for ${task.id} (${background.get(task.id).status}).`,\n\t\t\t{\n\t\t\t\taction: \"kill\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tcommand: task.command ?? task.title,\n\t\t\t\trequested,\n\t\t\t\tstatus: background.get(task.id).status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runList(background: TasksContext): AgentToolResult<TasksListDetails> {\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished.slice(0, TASKS_LIST_FINISHED_SHOWN)].slice(0, 100);\n\tconst hidden = tasks.length - shown.length;\n\treturn result(\n\t\tshown.length\n\t\t\t? `${shown.map((task) => describeTaskLine(task)).join(\"\\n\")}${hidden > 0 ? `\\n${hidden} more records not shown.` : \"\"}${foregroundOmissionNote(foregroundOmitted)}`\n\t\t\t: `No background tasks. Start work through its owning tool with background: true.${foregroundOmissionNote(foregroundOmitted)}`,\n\t\t{\n\t\t\taction: \"list\",\n\t\t\trunning: active.length,\n\t\t\tfinished: finished.length,\n\t\t\tshown: shown.length,\n\t\t\thidden,\n\t\t\t...(foregroundOmitted > 0 ? { foregroundOmitted } : {}),\n\t\t},\n\t);\n}\n"]}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACN,cAAc,EACd,eAAe,GAIf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAG3G,MAAM,UAAU,WAAW,CAAC,IAAY;IACvC,OAAO,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;AAClG,CAAC;AACD,SAAS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,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,0BAA0B,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,EAAE;QACnK,CAAC,CAAC,iFAAiF,sBAAsB,CAAC,iBAAiB,CAAC,EAAE,EAC/H;QACC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,GAAG,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CACD,CAAC;AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session task runtime. */\n\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport type { AgentToolResult } from \"../../extensions/types.ts\";\nimport { runtimeLabel } from \"../../tasks/format.ts\";\nimport { boundText } from \"../../tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n} from \"../../tasks/types.ts\";\nimport { truncateHead } from \"../truncate.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampReadBytes, clampSinceBytes, clampWaitMs, requireTaskId, type TasksInput } from \"./schema.ts\";\nimport type { TasksDetails, TasksKillDetails, TasksListDetails, TasksReadDetails, TasksWaitDetails } from \"./types.ts\";\n\nexport function boundedText(text: string): string {\n\treturn truncateHead(sanitizeBinaryOutput(text), { maxBytes: 50 * 1024, maxLines: 2000 }).content;\n}\nfunction result<T extends TasksDetails>(text: string, details: T): AgentToolResult<T> {\n\treturn { content: [{ type: \"text\", text: boundedText(text) }], details };\n}\nexport function describeTaskLine(task: TaskSnapshot, now = Date.now()): string {\n\treturn `${task.id} ${task.kind} ${task.status} (${task.mode}) ${runtimeLabel(task, now)} ${task.title.slice(0, 200)}`;\n}\n\nconst LOOKUP_LIST_LIMIT = 10;\n\n/**\n * Finished rows sort most-recent first. list() is creation-ordered, so an\n * unsorted slice would surface the oldest completions rather than the recent\n * finishes a caller is most likely looking for.\n */\nfunction recentFinishedFirst(tasks: TaskSnapshot[]): TaskSnapshot[] {\n\treturn tasks.sort((left, right) => (right.endedAt ?? 0) - (left.endedAt ?? 0));\n}\n\n/**\n * Listings cover backgrounded work only; foreground executions deliver inline\n * in the transcript, so they are counted rather than shown. Every listing\n * (tasks list output and lookup-failure messages) shares this scope.\n */\nfunction listedTasks(background: TasksContext): { tasks: TaskSnapshot[]; foregroundOmitted: number } {\n\tconst all = background.list();\n\tconst tasks = all.filter((task) => task.mode === \"background\");\n\treturn { tasks, foregroundOmitted: all.length - tasks.length };\n}\n\nfunction foregroundOmissionNote(omitted: number): string {\n\treturn omitted > 0\n\t\t? `\\n${omitted} foreground ${omitted === 1 ? \"execution\" : \"executions\"} omitted — foreground work is delivered inline in the transcript.`\n\t\t: \"\";\n}\n\n/**\n * Rewrite the service's bare lookup failure into an actionable one: an\n * unknown id gets the session's current tasks (active first, then recent\n * finishes) so the next call can use a real id without a separate list call,\n * and an ambiguous prefix gets exactly the tasks it matched — including\n * records outside the current branch, which listings hide but the prefix\n * still collides with.\n */\nfunction lookupFailure(background: TasksContext, id: string, error: unknown): Error {\n\tif (!(error instanceof TaskLookupError)) return error instanceof Error ? error : new Error(String(error));\n\tif (error.kind === \"ambiguous\") {\n\t\tconst lines = error.matches.map((task) => describeTaskLine(task)).join(\"\\n\");\n\t\treturn new Error(`Ambiguous task ID \"${id}\" matches ${error.matches.length} tasks:\\n${lines}`);\n\t}\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished].slice(0, LOOKUP_LIST_LIMIT);\n\tif (shown.length === 0) {\n\t\treturn new Error(`No task \"${id}\" in this session. No background tasks in this session.`);\n\t}\n\tconst lines = shown.map((task) => describeTaskLine(task)).join(\"\\n\");\n\treturn new Error(\n\t\t`No task \"${id}\" in this session. IDs from other sessions are not valid here.\\nCurrent background tasks:\\n${lines}${foregroundOmissionNote(foregroundOmitted)}`,\n\t);\n}\n\n/**\n * Where this slice sits in the output, so the next wait can continue from it.\n * A wait whose new output exceeds its budget returns the newest bytes and says what it skipped.\n */\nfunction rangeText(slice: TaskRead, sinceBytes?: number): string {\n\tconst from = slice.fromByte ?? 0;\n\tconst to = from + Buffer.byteLength(slice.text);\n\tconst floor = sinceBytes === undefined || sinceBytes > slice.totalBytes ? 0 : sinceBytes;\n\treturn [\n\t\t`bytes ${from}–${to} of ${slice.totalBytes}`,\n\t\tsinceBytes !== undefined && from > floor ? `skipped ${from - floor} bytes after sinceBytes ${floor}` : \"\",\n\t\t`next sinceBytes ${to}`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\" · \");\n}\n\n/** Reserve space for each independent diagnostic before allowing raw output to fill the budget. */\nfunction readText(header: string, slice: TaskRead): string {\n\tconst boundedField = (text: string, maxBytes: number) =>\n\t\ttruncateHead(boundText(sanitizeBinaryOutput(text), maxBytes), { maxBytes, maxLines: 100 }).content;\n\treturn [\n\t\tboundedField(header, 4096),\n\t\tslice.task.error ? `Task error: ${boundedField(slice.task.error, 4096)}` : \"\",\n\t\tslice.readError ? `Output read error: ${boundedField(slice.readError, 4096)}` : \"\",\n\t\tboundedField(slice.task.outputPath ?? \"\", 8192),\n\t\tslice.text || \"(no output yet)\",\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n}\nexport async function runRead(background: TasksContext, input: TasksInput): Promise<AgentToolResult<TasksReadDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst mode = input.mode ?? \"tail\";\n\t\tconst slice = await background.read(id, { mode, bytes: clampReadBytes(input.bytes) });\n\t\treturn result(readText(`[${describeTaskLine(slice.task)} · ${rangeText(slice)}]`, slice), {\n\t\t\taction: \"read\",\n\t\t\ttaskId: slice.task.id,\n\t\t\tmode,\n\t\t\tsliceBytes: Buffer.byteLength(slice.text),\n\t\t\ttotalBytes: slice.totalBytes,\n\t\t\toutputPath: slice.task.outputPath ?? \"\",\n\t\t\tkind: slice.task.kind,\n\t\t\tstatus: slice.task.status,\n\t\t});\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst release = background.holdDelivery(id);\n\t\ttry {\n\t\t\tconst start = Date.now();\n\t\t\tconst task = await background.wait(id, clampWaitMs(input.waitMs), signal);\n\t\t\tconst timedOut = !isTaskTerminal(task.status);\n\t\t\t// A closed host resolves waits early without settling anything; do not claim\n\t\t\t// the execution merely outlived the wait window.\n\t\t\tconst windowNote = background.closed\n\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t: timedOut\n\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t: \"\";\n\t\t\tconst sinceBytes = clampSinceBytes(input.sinceBytes);\n\t\t\tconst slice = await background.read(id, { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes });\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (!timedOut) onReady?.(task.id);\n\t\t\treturn result(readText(`[${describeTaskLine(task)}${windowNote} · ${rangeText(slice, sinceBytes)}]`, slice), {\n\t\t\t\taction: \"wait\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tstatus: task.status,\n\t\t\t\tkind: task.kind,\n\t\t\t\ttimedOut,\n\t\t\t\texitCode: task.exitCode,\n\t\t\t\twaitedMs: Date.now() - start,\n\t\t\t\tdeltaBytes: Buffer.byteLength(slice.text),\n\t\t\t\ttotalBytes: slice.totalBytes,\n\t\t\t\tdeltaTruncated: slice.truncated,\n\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t});\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runKill(background: TasksContext, input: TasksInput): AgentToolResult<TasksKillDetails> {\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst task = background.get(id);\n\t\tconst requested = background.kill(task.id);\n\t\treturn result(\n\t\t\trequested\n\t\t\t\t? `Cancellation requested for ${task.id}. The task or whole group is stopping; cleanup may still be in progress.`\n\t\t\t\t: `No new cancellation requested for ${task.id} (${background.get(task.id).status}).`,\n\t\t\t{\n\t\t\t\taction: \"kill\",\n\t\t\t\ttaskId: task.id,\n\t\t\t\tcommand: task.command ?? task.title,\n\t\t\t\trequested,\n\t\t\t\tstatus: background.get(task.id).status,\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tthrow lookupFailure(background, id, error);\n\t}\n}\nexport function runList(background: TasksContext): AgentToolResult<TasksListDetails> {\n\tconst { tasks, foregroundOmitted } = listedTasks(background);\n\tconst active = tasks.filter((task) => !isTaskTerminal(task.status));\n\tconst finished = recentFinishedFirst(tasks.filter((task) => isTaskTerminal(task.status)));\n\tconst shown = [...active, ...finished.slice(0, TASKS_LIST_FINISHED_SHOWN)].slice(0, 100);\n\tconst hidden = tasks.length - shown.length;\n\treturn result(\n\t\tshown.length\n\t\t\t? `${shown.map((task) => describeTaskLine(task)).join(\"\\n\")}${hidden > 0 ? `\\n${hidden} more records not shown.` : \"\"}${foregroundOmissionNote(foregroundOmitted)}`\n\t\t\t: `No background tasks. Start work through its owning tool with background: true.${foregroundOmissionNote(foregroundOmitted)}`,\n\t\t{\n\t\t\taction: \"list\",\n\t\t\trunning: active.length,\n\t\t\tfinished: finished.length,\n\t\t\tshown: shown.length,\n\t\t\thidden,\n\t\t\t...(foregroundOmitted > 0 ? { foregroundOmitted } : {}),\n\t\t},\n\t);\n}\n"]}
@@ -1,14 +1,10 @@
1
1
  /**
2
- * background — shared limits and identity.
2
+ * Shared limits of the `tasks` tool.
3
3
  *
4
4
  * Numbers that more than one module needs live here so a change lands in one
5
5
  * place; execution and retention limits belong to the core service.
6
6
  */
7
- /** Historical extension-owned completion/stall messages. */
8
- export declare const TASKS_NOTIFICATION_TYPE = "background-task";
9
- /** Session-owned completions; model content and delivery are unchanged by rendering. */
10
- export declare const TASKS_COMPLETION_TYPE = "task-completion";
11
- /** Default and floor for a `read` slice; the ceiling is truncate.ts's DEFAULT_MAX_BYTES. */
7
+ /** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */
12
8
  export declare const TASKS_LOGS_DEFAULT_BYTES: number;
13
9
  export declare const TASKS_LOGS_MIN_BYTES = 256;
14
10
  /** Finished tasks shown by `list` before the rest fold into a count. */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,uBAAuB,oBAAoB,CAAC;AACzD,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB,QAAW,CAAC;AACjD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AACvC,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,0BAA0B,QAAS,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,eAAO,MAAM,wBAAwB,QAAW,CAAC;AACjD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AACvC,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,0BAA0B,QAAS,CAAC"}
@@ -1,14 +1,10 @@
1
1
  /**
2
- * background — shared limits and identity.
2
+ * Shared limits of the `tasks` tool.
3
3
  *
4
4
  * Numbers that more than one module needs live here so a change lands in one
5
5
  * place; execution and retention limits belong to the core service.
6
6
  */
7
- /** Historical extension-owned completion/stall messages. */
8
- export const TASKS_NOTIFICATION_TYPE = "background-task";
9
- /** Session-owned completions; model content and delivery are unchanged by rendering. */
10
- export const TASKS_COMPLETION_TYPE = "task-completion";
11
- /** Default and floor for a `read` slice; the ceiling is truncate.ts's DEFAULT_MAX_BYTES. */
7
+ /** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */
12
8
  export const TASKS_LOGS_DEFAULT_BYTES = 8 * 1024;
13
9
  export const TASKS_LOGS_MIN_BYTES = 256;
14
10
  /** Finished tasks shown by `list` before the rest fold into a count. */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AACzD,wFAAwF;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC","sourcesContent":["/**\n * background — shared limits and identity.\n *\n * Numbers that more than one module needs live here so a change lands in one\n * place; execution and retention limits belong to the core service.\n */\n\n/** Historical extension-owned completion/stall messages. */\nexport const TASKS_NOTIFICATION_TYPE = \"background-task\";\n/** Session-owned completions; model content and delivery are unchanged by rendering. */\nexport const TASKS_COMPLETION_TYPE = \"task-completion\";\n\n/** Default and floor for a `read` slice; the ceiling is truncate.ts's DEFAULT_MAX_BYTES. */\nexport const TASKS_LOGS_DEFAULT_BYTES = 8 * 1024;\nexport const TASKS_LOGS_MIN_BYTES = 256;\n\n/** Finished tasks shown by `list` before the rest fold into a count. */\nexport const TASKS_LIST_FINISHED_SHOWN = 5;\n\n/** Bounded output delta returned by a successful wait. */\nexport const TASKS_WAIT_DELTA_BYTES = 32 * 1024;\n\n/** Wait-window bounds shared by execution and the pending-call renderer. */\nexport const TASKS_WAIT_DEFAULT_MS = 20_000;\nexport const TASKS_WAIT_MIN_MS = 1_000;\nexport const TASKS_WAIT_MAX_MS = 60_000;\n\n/** How long a foreground execution runs before the statusline advertises the detach key. */\nexport const TASKS_DETACH_HINT_DELAY_MS = 10_000;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC","sourcesContent":["/**\n * Shared limits of the `tasks` tool.\n *\n * Numbers that more than one module needs live here so a change lands in one\n * place; execution and retention limits belong to the core service.\n */\n\n/** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */\nexport const TASKS_LOGS_DEFAULT_BYTES = 8 * 1024;\nexport const TASKS_LOGS_MIN_BYTES = 256;\n\n/** Finished tasks shown by `list` before the rest fold into a count. */\nexport const TASKS_LIST_FINISHED_SHOWN = 5;\n\n/** Bounded output delta returned by a successful wait. */\nexport const TASKS_WAIT_DELTA_BYTES = 32 * 1024;\n\n/** Wait-window bounds shared by execution and the pending-call renderer. */\nexport const TASKS_WAIT_DEFAULT_MS = 20_000;\nexport const TASKS_WAIT_MIN_MS = 1_000;\nexport const TASKS_WAIT_MAX_MS = 60_000;\n\n/** How long a foreground execution runs before the statusline advertises the detach key. */\nexport const TASKS_DETACH_HINT_DELAY_MS = 10_000;\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * background — the `bg` tool's wire contract: one flat schema whose `action`
2
+ * The `tasks` tool's wire contract: one flat schema whose `action`
3
3
  * selects which of the remaining fields apply, plus the model-facing copy.
4
4
  *
5
5
  * The schema stays flat deliberately: a single tool keeps the model's tool list
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAU5C,eAAO,MAAM,WAAW;;;;;;;EA6BtB,CAAC;AAEH,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAOpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGhE;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG9D;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAElF;AAED,eAAO,MAAM,sBAAsB,QAO+E,CAAC;AACnH,eAAO,MAAM,oBAAoB,qDAAqD,CAAC;AACvF,eAAO,MAAM,uBAAuB,UAGnC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/tasks/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAW5C,eAAO,MAAM,WAAW;;;;;;;EA6BtB,CAAC;AAEH,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAOpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGhE;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG9D;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAElF;AAED,eAAO,MAAM,sBAAsB,QAOiJ,CAAC;AACrL,eAAO,MAAM,oBAAoB,qDAAqD,CAAC;AACvF,eAAO,MAAM,uBAAuB,UAGnC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * background — the `bg` tool's wire contract: one flat schema whose `action`
2
+ * The `tasks` tool's wire contract: one flat schema whose `action`
3
3
  * selects which of the remaining fields apply, plus the model-facing copy.
4
4
  *
5
5
  * The schema stays flat deliberately: a single tool keeps the model's tool list
@@ -8,11 +8,12 @@
8
8
  */
9
9
  import { StringEnum } from "@earendil-works/pi-ai";
10
10
  import { Type } from "typebox";
11
- import { DEFAULT_MAX_BYTES, formatSize } from "../truncate.js";
11
+ import { TASK_RESULT_BYTES } from "../../tasks/output.js";
12
+ import { formatSize } from "../truncate.js";
12
13
  import { TASKS_LOGS_DEFAULT_BYTES, TASKS_LOGS_MIN_BYTES, TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS, TASKS_WAIT_MIN_MS, } from "./constants.js";
13
14
  export const tasksSchema = Type.Object({
14
15
  action: StringEnum(["read", "wait", "kill", "list"], {
15
- description: "Which background-task operation to perform",
16
+ description: "Which task operation to perform",
16
17
  }),
17
18
  // — read / wait / kill —
18
19
  taskId: Type.Optional(Type.String({ description: "Task execution id (read/wait/kill)" })),
@@ -21,14 +22,14 @@ export const tasksSchema = Type.Object({
21
22
  description: "Read from the end (default) or the start of the output (read)",
22
23
  })),
23
24
  bytes: Type.Optional(Type.Number({
24
- description: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(DEFAULT_MAX_BYTES)})`,
25
+ description: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(TASK_RESULT_BYTES)})`,
25
26
  })),
26
27
  // — wait —
27
28
  waitMs: Type.Optional(Type.Number({
28
29
  description: `Max time to wait in ms, default ${TASKS_WAIT_DEFAULT_MS}, max ${TASKS_WAIT_MAX_MS} (wait)`,
29
30
  })),
30
31
  sinceBytes: Type.Optional(Type.Number({
31
- description: "Only return output written after this byte offset — take it from a previous read/wait result (wait)",
32
+ description: "Only return output written after this byte offset — use the 'next sinceBytes' value from a previous read or wait (wait)",
32
33
  })),
33
34
  });
34
35
  // ── reading the contract ──────────────────────────────────────────────────
@@ -44,7 +45,7 @@ export function requireTaskId(input) {
44
45
  }
45
46
  export function clampReadBytes(bytes) {
46
47
  const value = bytes !== undefined && Number.isFinite(bytes) ? bytes : TASKS_LOGS_DEFAULT_BYTES;
47
- return Math.min(DEFAULT_MAX_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));
48
+ return Math.min(TASK_RESULT_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));
48
49
  }
49
50
  /** Shared with the pending-call renderer so the window it shows is the one that runs. */
50
51
  export function clampWaitMs(waitMs) {
@@ -60,7 +61,7 @@ export const TASKS_TOOL_DESCRIPTION = "Inspect and control background tasks star
60
61
  "read: bounded output or report slice (head/tail). " +
61
62
  "wait: block up to waitMs for a task to settle; cancelling the wait ends only the wait, never the task. " +
62
63
  "kill: request cancellation of a whole task. " +
63
- "tasks cannot start work; submit background work through its owning tool. Output is capped at 50KB per response.";
64
+ "tasks cannot start work; submit background work through its owning tool. Each read or wait reports its byte range and the next sinceBytes. Output is capped at 50KB per response.";
64
65
  export const TASKS_PROMPT_SNIPPET = "Manage background tasks (list, read, wait, kill)";
65
66
  export const TASKS_PROMPT_GUIDELINES = [
66
67
  "Start background work through its owning tool with background: true; continue independent work while it runs.",
@@ -1 +1 @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AS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAClC,8EAA8E;IAC9E,+EAA+E;IAC/E,8DAA8D;IAC9D,oDAAoD;IACpD,yGAAyG;IACzG,8CAA8C;IAC9C,iHAAiH,CAAC;AACnH,MAAM,CAAC,MAAM,oBAAoB,GAAG,kDAAkD,CAAC;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,+GAA+G;IAC/G,qLAAqL;CACrL,CAAC","sourcesContent":["/**\n * background — the `bg` tool's wire contract: one flat schema whose `action`\n * selects which of the remaining fields apply, plus the model-facing copy.\n *\n * The schema stays flat deliberately: a single tool keeps the model's tool list\n * short. Execution creation belongs to the native tools. Narrowing happens\n * inside actions.ts, not here.\n */\n\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { DEFAULT_MAX_BYTES, formatSize } from \"../truncate.ts\";\nimport {\n\tTASKS_LOGS_DEFAULT_BYTES,\n\tTASKS_LOGS_MIN_BYTES,\n\tTASKS_WAIT_DEFAULT_MS,\n\tTASKS_WAIT_MAX_MS,\n\tTASKS_WAIT_MIN_MS,\n} from \"./constants.ts\";\n\nexport const tasksSchema = Type.Object({\n\taction: StringEnum([\"read\", \"wait\", \"kill\", \"list\"] as const, {\n\t\tdescription: \"Which background-task operation to perform\",\n\t}),\n\t// — read / wait / kill —\n\ttaskId: Type.Optional(Type.String({ description: \"Task execution id (read/wait/kill)\" })),\n\t// — read —\n\tmode: Type.Optional(\n\t\tStringEnum([\"tail\", \"head\"] as const, {\n\t\t\tdescription: \"Read from the end (default) or the start of the output (read)\",\n\t\t}),\n\t),\n\tbytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(DEFAULT_MAX_BYTES)})`,\n\t\t}),\n\t),\n\t// — wait —\n\twaitMs: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max time to wait in ms, default ${TASKS_WAIT_DEFAULT_MS}, max ${TASKS_WAIT_MAX_MS} (wait)`,\n\t\t}),\n\t),\n\tsinceBytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription:\n\t\t\t\t\"Only return output written after this byte offset — take it from a previous read/wait result (wait)\",\n\t\t}),\n\t),\n});\n\n/** Raw tool arguments. Every per-action field is optional here; actions.ts narrows. */\nexport type TasksInput = Static<typeof tasksSchema>;\n\n// ── reading the contract ──────────────────────────────────────────────────\n// One place per field: required fields throw a message that names the next\n// step, optional ones clamp to their documented range. Callers get plain\n// values, so no action handler needs a cast.\n\nexport function requireTaskId(input: TasksInput): string {\n\tconst taskId = input.taskId;\n\tif (!taskId || taskId.trim().length === 0) {\n\t\tthrow new Error(`action '${input.action}' requires 'taskId' — use action list to find the execution id.`);\n\t}\n\treturn taskId;\n}\n\nexport function clampReadBytes(bytes: number | undefined): number {\n\tconst value = bytes !== undefined && Number.isFinite(bytes) ? bytes : TASKS_LOGS_DEFAULT_BYTES;\n\treturn Math.min(DEFAULT_MAX_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));\n}\n\n/** Shared with the pending-call renderer so the window it shows is the one that runs. */\nexport function clampWaitMs(waitMs: number | undefined): number {\n\tconst value = waitMs !== undefined && Number.isFinite(waitMs) ? waitMs : TASKS_WAIT_DEFAULT_MS;\n\treturn Math.min(TASKS_WAIT_MAX_MS, Math.max(TASKS_WAIT_MIN_MS, Math.floor(value)));\n}\n\nexport function clampSinceBytes(sinceBytes: number | undefined): number | undefined {\n\treturn sinceBytes === undefined || !Number.isFinite(sinceBytes) ? undefined : Math.max(0, Math.floor(sinceBytes));\n}\n\nexport const TASKS_TOOL_DESCRIPTION =\n\t\"Inspect and control background tasks started by native tools or extensions. \" +\n\t\"Completion is delivered to you automatically as a notification — never poll. \" +\n\t\"list: bounded activity/history listing; find task IDs here. \" +\n\t\"read: bounded output or report slice (head/tail). \" +\n\t\"wait: block up to waitMs for a task to settle; cancelling the wait ends only the wait, never the task. \" +\n\t\"kill: request cancellation of a whole task. \" +\n\t\"tasks cannot start work; submit background work through its owning tool. Output is capped at 50KB per response.\";\nexport const TASKS_PROMPT_SNIPPET = \"Manage background tasks (list, read, wait, kill)\";\nexport const TASKS_PROMPT_GUIDELINES = [\n\t\"Start background work through its owning tool with background: true; continue independent work while it runs.\",\n\t\"A finished background task delivers its result automatically as a notification; use tasks wait only when your next step is blocked on it, and never sleep-poll with repeated reads.\",\n];\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,EAAE;QAC7D,WAAW,EAAE,iCAAiC;KAC9C,CAAC;IACF,yBAAyB;IACzB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC,CAAC;IACzF,WAAW;IACX,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,CAAU,EAAE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MAA0B;IACrD,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAC/F,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAA8B;IAC7D,OAAO,UAAU,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAClC,8EAA8E;IAC9E,+EAA+E;IAC/E,8DAA8D;IAC9D,oDAAoD;IACpD,yGAAyG;IACzG,8CAA8C;IAC9C,mLAAmL,CAAC;AACrL,MAAM,CAAC,MAAM,oBAAoB,GAAG,kDAAkD,CAAC;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,+GAA+G;IAC/G,qLAAqL;CACrL,CAAC","sourcesContent":["/**\n * The `tasks` tool's wire contract: one flat schema whose `action`\n * selects which of the remaining fields apply, plus the model-facing copy.\n *\n * The schema stays flat deliberately: a single tool keeps the model's tool list\n * short. Execution creation belongs to the native tools. Narrowing happens\n * inside actions.ts, not here.\n */\n\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { TASK_RESULT_BYTES } from \"../../tasks/output.ts\";\nimport { formatSize } from \"../truncate.ts\";\nimport {\n\tTASKS_LOGS_DEFAULT_BYTES,\n\tTASKS_LOGS_MIN_BYTES,\n\tTASKS_WAIT_DEFAULT_MS,\n\tTASKS_WAIT_MAX_MS,\n\tTASKS_WAIT_MIN_MS,\n} from \"./constants.ts\";\n\nexport const tasksSchema = Type.Object({\n\taction: StringEnum([\"read\", \"wait\", \"kill\", \"list\"] as const, {\n\t\tdescription: \"Which task operation to perform\",\n\t}),\n\t// — read / wait / kill —\n\ttaskId: Type.Optional(Type.String({ description: \"Task execution id (read/wait/kill)\" })),\n\t// — read —\n\tmode: Type.Optional(\n\t\tStringEnum([\"tail\", \"head\"] as const, {\n\t\t\tdescription: \"Read from the end (default) or the start of the output (read)\",\n\t\t}),\n\t),\n\tbytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(TASK_RESULT_BYTES)})`,\n\t\t}),\n\t),\n\t// — wait —\n\twaitMs: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription: `Max time to wait in ms, default ${TASKS_WAIT_DEFAULT_MS}, max ${TASKS_WAIT_MAX_MS} (wait)`,\n\t\t}),\n\t),\n\tsinceBytes: Type.Optional(\n\t\tType.Number({\n\t\t\tdescription:\n\t\t\t\t\"Only return output written after this byte offset — use the 'next sinceBytes' value from a previous read or wait (wait)\",\n\t\t}),\n\t),\n});\n\n/** Raw tool arguments. Every per-action field is optional here; actions.ts narrows. */\nexport type TasksInput = Static<typeof tasksSchema>;\n\n// ── reading the contract ──────────────────────────────────────────────────\n// One place per field: required fields throw a message that names the next\n// step, optional ones clamp to their documented range. Callers get plain\n// values, so no action handler needs a cast.\n\nexport function requireTaskId(input: TasksInput): string {\n\tconst taskId = input.taskId;\n\tif (!taskId || taskId.trim().length === 0) {\n\t\tthrow new Error(`action '${input.action}' requires 'taskId' — use action list to find the execution id.`);\n\t}\n\treturn taskId;\n}\n\nexport function clampReadBytes(bytes: number | undefined): number {\n\tconst value = bytes !== undefined && Number.isFinite(bytes) ? bytes : TASKS_LOGS_DEFAULT_BYTES;\n\treturn Math.min(TASK_RESULT_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));\n}\n\n/** Shared with the pending-call renderer so the window it shows is the one that runs. */\nexport function clampWaitMs(waitMs: number | undefined): number {\n\tconst value = waitMs !== undefined && Number.isFinite(waitMs) ? waitMs : TASKS_WAIT_DEFAULT_MS;\n\treturn Math.min(TASKS_WAIT_MAX_MS, Math.max(TASKS_WAIT_MIN_MS, Math.floor(value)));\n}\n\nexport function clampSinceBytes(sinceBytes: number | undefined): number | undefined {\n\treturn sinceBytes === undefined || !Number.isFinite(sinceBytes) ? undefined : Math.max(0, Math.floor(sinceBytes));\n}\n\nexport const TASKS_TOOL_DESCRIPTION =\n\t\"Inspect and control background tasks started by native tools or extensions. \" +\n\t\"Completion is delivered to you automatically as a notification — never poll. \" +\n\t\"list: bounded activity/history listing; find task IDs here. \" +\n\t\"read: bounded output or report slice (head/tail). \" +\n\t\"wait: block up to waitMs for a task to settle; cancelling the wait ends only the wait, never the task. \" +\n\t\"kill: request cancellation of a whole task. \" +\n\t\"tasks cannot start work; submit background work through its owning tool. Each read or wait reports its byte range and the next sinceBytes. Output is capped at 50KB per response.\";\nexport const TASKS_PROMPT_SNIPPET = \"Manage background tasks (list, read, wait, kill)\";\nexport const TASKS_PROMPT_GUIDELINES = [\n\t\"Start background work through its owning tool with background: true; continue independent work while it runs.\",\n\t\"A finished background task delivers its result automatically as a notification; use tasks wait only when your next step is blocked on it, and never sleep-poll with repeated reads.\",\n];\n"]}
@@ -1,28 +1,14 @@
1
1
  /**
2
- * background — the structured `details` payloads.
2
+ * The `tasks` tool's structured `details` payloads.
3
3
  *
4
- * PERSISTENCE CONTRACT: every shape here is JSON-serialized verbatim into the
5
- * session file (agent-session.ts -> session-manager.ts) and read back by this
6
- * extension's renderers on `/reload`, `/tree`, and session resume — so a
7
- * renderer always has to cope with details written by an older build. Adding an
8
- * optional field is free; renaming or repurposing an existing one silently
9
- * degrades historical transcripts, because components/custom-message.ts catches
10
- * renderer failures and falls back to an unstyled box with no diagnostic.
4
+ * Every shape here is JSON-serialized verbatim into the session file and read back
5
+ * by the renderers on `/reload`, `/tree`, and session resume. Adding an optional
6
+ * field is free; renaming or repurposing an existing one degrades historical
7
+ * transcripts.
11
8
  *
12
- * Keep `exitCode` three-state for the same reason: historical entries hold
13
- * `null` for signal-reaped tasks. task-view.ts's `exitSuffix` is the one place
14
- * that has to know.
9
+ * `exitCode` is three-state: `null` for signal-reaped tasks.
15
10
  */
16
11
  import type { TaskKind, TaskStatus } from "../../tasks/types.ts";
17
- /** Historical transcripts used killed rather than cancelled. */
18
- export type TasksTaskStatus = TaskStatus | "killed";
19
- export interface TasksCreateDetails {
20
- action: "create";
21
- taskId: string;
22
- outputPath: string;
23
- command: string;
24
- description?: string;
25
- }
26
12
  export interface TasksReadDetails {
27
13
  kind?: TaskKind;
28
14
  status?: TaskStatus;
@@ -39,7 +25,7 @@ export interface TasksWaitDetails {
39
25
  taskId: string;
40
26
  /** True when the wait window expired and the task is still running. */
41
27
  timedOut: boolean;
42
- status: TasksTaskStatus;
28
+ status: TaskStatus;
43
29
  exitCode: number | null | undefined;
44
30
  waitedMs: number;
45
31
  deltaBytes: number;
@@ -63,21 +49,5 @@ export interface TasksListDetails {
63
49
  /** Foreground executions omitted from the listing; they deliver inline in the transcript. */
64
50
  foregroundOmitted?: number;
65
51
  }
66
- export type TasksDetails = TasksCreateDetails | TasksReadDetails | TasksKillDetails | TasksListDetails | TasksWaitDetails;
67
- export interface TasksNotificationDetails {
68
- taskId: string;
69
- command: string;
70
- description?: string;
71
- status: TasksTaskStatus;
72
- /** True for the one-shot "waiting for interactive input" signal; the task keeps running. */
73
- stalled?: true;
74
- exitCode: number | null | undefined;
75
- runtimeMs: number;
76
- outputPath: string;
77
- totalBytes: number;
78
- tailText: string;
79
- tailTruncated: boolean;
80
- error?: string;
81
- tailError?: string;
82
- }
52
+ export type TasksDetails = TasksReadDetails | TasksKillDetails | TasksListDetails | TasksWaitDetails;
83
53
  //# sourceMappingURL=types.d.ts.map
@@ -1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C;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC"}
@@ -1,17 +1,12 @@
1
1
  /**
2
- * background — the structured `details` payloads.
2
+ * The `tasks` tool's structured `details` payloads.
3
3
  *
4
- * PERSISTENCE CONTRACT: every shape here is JSON-serialized verbatim into the
5
- * session file (agent-session.ts -> session-manager.ts) and read back by this
6
- * extension's renderers on `/reload`, `/tree`, and session resume — so a
7
- * renderer always has to cope with details written by an older build. Adding an
8
- * optional field is free; renaming or repurposing an existing one silently
9
- * degrades historical transcripts, because components/custom-message.ts catches
10
- * renderer failures and falls back to an unstyled box with no diagnostic.
4
+ * Every shape here is JSON-serialized verbatim into the session file and read back
5
+ * by the renderers on `/reload`, `/tree`, and session resume. Adding an optional
6
+ * field is free; renaming or repurposing an existing one degrades historical
7
+ * transcripts.
11
8
  *
12
- * Keep `exitCode` three-state for the same reason: historical entries hold
13
- * `null` for signal-reaped tasks. task-view.ts's `exitSuffix` is the one place
14
- * that has to know.
9
+ * `exitCode` is three-state: `null` for signal-reaped tasks.
15
10
  */
16
11
  export {};
17
12
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/**\n * background — the structured `details` payloads.\n *\n * PERSISTENCE CONTRACT: every shape here is JSON-serialized verbatim into the\n * session file (agent-session.ts -> session-manager.ts) and read back by this\n * extension's renderers on `/reload`, `/tree`, and session resume — so a\n * renderer always has to cope with details written by an older build. Adding an\n * optional field is free; renaming or repurposing an existing one silently\n * degrades historical transcripts, because components/custom-message.ts catches\n * renderer failures and falls back to an unstyled box with no diagnostic.\n *\n * Keep `exitCode` three-state for the same reason: historical entries hold\n * `null` for signal-reaped tasks. task-view.ts's `exitSuffix` is the one place\n * that has to know.\n */\n\nimport type { TaskKind, TaskStatus } from \"../../tasks/types.ts\";\n\n/** Historical transcripts used killed rather than cancelled. */\nexport type TasksTaskStatus = TaskStatus | \"killed\";\n\nexport interface TasksCreateDetails {\n\taction: \"create\";\n\ttaskId: string;\n\toutputPath: string;\n\tcommand: string;\n\tdescription?: string;\n}\n\nexport interface TasksReadDetails {\n\tkind?: TaskKind;\n\tstatus?: TaskStatus;\n\taction: \"read\";\n\ttaskId: string;\n\tmode: \"head\" | \"tail\";\n\tsliceBytes: number;\n\ttotalBytes: number;\n\toutputPath: string;\n}\n\nexport interface TasksWaitDetails {\n\tkind?: TaskKind;\n\taction: \"wait\";\n\ttaskId: string;\n\t/** True when the wait window expired and the task is still running. */\n\ttimedOut: boolean;\n\tstatus: TasksTaskStatus;\n\texitCode: number | null | undefined;\n\twaitedMs: number;\n\tdeltaBytes: number;\n\ttotalBytes: number;\n\tdeltaTruncated: boolean;\n\toutputPath: string;\n}\n\nexport interface TasksKillDetails {\n\trequested?: boolean;\n\tstatus?: TaskStatus;\n\taction: \"kill\";\n\ttaskId: string;\n\tcommand: string;\n}\n\nexport interface TasksListDetails {\n\taction: \"list\";\n\trunning: number;\n\tfinished: number;\n\tshown: number;\n\thidden: number;\n\t/** Foreground executions omitted from the listing; they deliver inline in the transcript. */\n\tforegroundOmitted?: number;\n}\n\nexport type TasksDetails =\n\t| TasksCreateDetails\n\t| TasksReadDetails\n\t| TasksKillDetails\n\t| TasksListDetails\n\t| TasksWaitDetails;\n\nexport interface TasksNotificationDetails {\n\ttaskId: string;\n\tcommand: string;\n\tdescription?: string;\n\tstatus: TasksTaskStatus;\n\t/** True for the one-shot \"waiting for interactive input\" signal; the task keeps running. */\n\tstalled?: true;\n\texitCode: number | null | undefined;\n\truntimeMs: number;\n\toutputPath: string;\n\ttotalBytes: number;\n\ttailText: string;\n\ttailTruncated: boolean;\n\terror?: string;\n\ttailError?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/tools/tasks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG","sourcesContent":["/**\n * The `tasks` tool's structured `details` payloads.\n *\n * Every shape here is JSON-serialized verbatim into the session file and read back\n * by the renderers on `/reload`, `/tree`, and session resume. Adding an optional\n * field is free; renaming or repurposing an existing one degrades historical\n * transcripts.\n *\n * `exitCode` is three-state: `null` for signal-reaped tasks.\n */\n\nimport type { TaskKind, TaskStatus } from \"../../tasks/types.ts\";\n\nexport interface TasksReadDetails {\n\tkind?: TaskKind;\n\tstatus?: TaskStatus;\n\taction: \"read\";\n\ttaskId: string;\n\tmode: \"head\" | \"tail\";\n\tsliceBytes: number;\n\ttotalBytes: number;\n\toutputPath: string;\n}\n\nexport interface TasksWaitDetails {\n\tkind?: TaskKind;\n\taction: \"wait\";\n\ttaskId: string;\n\t/** True when the wait window expired and the task is still running. */\n\ttimedOut: boolean;\n\tstatus: TaskStatus;\n\texitCode: number | null | undefined;\n\twaitedMs: number;\n\tdeltaBytes: number;\n\ttotalBytes: number;\n\tdeltaTruncated: boolean;\n\toutputPath: string;\n}\n\nexport interface TasksKillDetails {\n\trequested?: boolean;\n\tstatus?: TaskStatus;\n\taction: \"kill\";\n\ttaskId: string;\n\tcommand: string;\n}\n\nexport interface TasksListDetails {\n\taction: \"list\";\n\trunning: number;\n\tfinished: number;\n\tshown: number;\n\thidden: number;\n\t/** Foreground executions omitted from the listing; they deliver inline in the transcript. */\n\tforegroundOmitted?: number;\n}\n\nexport type TasksDetails = TasksReadDetails | TasksKillDetails | TasksListDetails | TasksWaitDetails;\n"]}
@@ -97,6 +97,8 @@ export declare function findLatestResponse(messages: readonly AgentMessage[]): A
97
97
  * `model_change`, because responses name the physical models it routed to. Otherwise the latest
98
98
  * physical response wins, as in sessions without virtual models. A virtual model that is no longer
99
99
  * registered does not hold, so the selection falls back to the physical model that answered last.
100
+ *
101
+ * Only the last `model_change` can hold, so this looks up at most one model in the catalog.
100
102
  */
101
103
  export declare function getBranchSelection(branch: readonly SessionEntry[], getModel: (provider: string, modelId: string) => Model<Api> | undefined): {
102
104
  provider: string;