@astralyn/pi 1.4.6 → 1.4.8

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 (253) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/bundle/chunks/{chunk-EYKC6ESU.js → chunk-5VIOGR76.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-KDO6L76C.js → chunk-FODCTZXW.js} +4 -4
  4. package/dist/bundle/chunks/{chunk-RBTJBQWX.js → chunk-I2COK45I.js} +136 -137
  5. package/dist/bundle/chunks/{chunk-AXFWZIHH.js → chunk-MG5XDTXV.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-ALHAFUHP.js → chunk-PU2IWWXV.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-5M3YJ54Z.js → chunk-RO2VH6UZ.js} +1 -1
  8. package/dist/bundle/chunks/{cli-FH77R7JR.js → cli-MEL7SGJD.js} +1 -1
  9. package/dist/bundle/chunks/{execute-5ZQUS52M.js → execute-4CWRNHPO.js} +1 -1
  10. package/dist/bundle/chunks/{runtime-R5CMHJ5P.js → runtime-R3X67XMR.js} +1 -1
  11. package/dist/bundle/chunks/{virtual-modules-KCQU7LOC.js → virtual-modules-BBLD7YLS.js} +1 -1
  12. package/dist/bundle/cli.js +1 -1
  13. package/dist/bundle/index.js +1 -1
  14. package/dist/bundle/rpc-entry.js +1 -1
  15. package/dist/core/agent-session.d.ts +0 -3
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +0 -4
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/extensions/index.d.ts +1 -1
  20. package/dist/core/extensions/index.d.ts.map +1 -1
  21. package/dist/core/extensions/index.js.map +1 -1
  22. package/dist/core/package-manager.d.ts +3 -1
  23. package/dist/core/package-manager.d.ts.map +1 -1
  24. package/dist/core/package-manager.js +10 -0
  25. package/dist/core/package-manager.js.map +1 -1
  26. package/dist/core/resource-loader.d.ts +2 -0
  27. package/dist/core/resource-loader.d.ts.map +1 -1
  28. package/dist/core/resource-loader.js +17 -4
  29. package/dist/core/resource-loader.js.map +1 -1
  30. package/dist/core/settings-manager.d.ts +4 -2
  31. package/dist/core/settings-manager.d.ts.map +1 -1
  32. package/dist/core/settings-manager.js +11 -0
  33. package/dist/core/settings-manager.js.map +1 -1
  34. package/dist/core/settings-schema.d.ts +7 -0
  35. package/dist/core/settings-schema.d.ts.map +1 -1
  36. package/dist/core/settings-schema.js +6 -0
  37. package/dist/core/settings-schema.js.map +1 -1
  38. package/dist/core/skill-invocation.d.ts +46 -0
  39. package/dist/core/skill-invocation.d.ts.map +1 -0
  40. package/dist/core/skill-invocation.js +128 -0
  41. package/dist/core/skill-invocation.js.map +1 -0
  42. package/dist/core/skills.d.ts +10 -0
  43. package/dist/core/skills.d.ts.map +1 -1
  44. package/dist/core/skills.js +23 -0
  45. package/dist/core/skills.js.map +1 -1
  46. package/dist/core/tasks/delivery.d.ts +11 -4
  47. package/dist/core/tasks/delivery.d.ts.map +1 -1
  48. package/dist/core/tasks/delivery.js +9 -9
  49. package/dist/core/tasks/delivery.js.map +1 -1
  50. package/dist/core/tasks/execution.d.ts +10 -3
  51. package/dist/core/tasks/execution.d.ts.map +1 -1
  52. package/dist/core/tasks/execution.js +72 -52
  53. package/dist/core/tasks/execution.js.map +1 -1
  54. package/dist/core/tasks/format.d.ts +0 -2
  55. package/dist/core/tasks/format.d.ts.map +1 -1
  56. package/dist/core/tasks/format.js +1 -16
  57. package/dist/core/tasks/format.js.map +1 -1
  58. package/dist/core/tasks/limits.d.ts +12 -1
  59. package/dist/core/tasks/limits.d.ts.map +1 -1
  60. package/dist/core/tasks/limits.js +20 -1
  61. package/dist/core/tasks/limits.js.map +1 -1
  62. package/dist/core/tasks/output.d.ts +6 -12
  63. package/dist/core/tasks/output.d.ts.map +1 -1
  64. package/dist/core/tasks/output.js +35 -32
  65. package/dist/core/tasks/output.js.map +1 -1
  66. package/dist/core/tasks/record.d.ts +45 -0
  67. package/dist/core/tasks/record.d.ts.map +1 -0
  68. package/dist/core/tasks/record.js +80 -0
  69. package/dist/core/tasks/record.js.map +1 -0
  70. package/dist/core/tasks/runtime.d.ts +14 -14
  71. package/dist/core/tasks/runtime.d.ts.map +1 -1
  72. package/dist/core/tasks/runtime.js +111 -93
  73. package/dist/core/tasks/runtime.js.map +1 -1
  74. package/dist/core/tasks/session.d.ts +0 -1
  75. package/dist/core/tasks/session.d.ts.map +1 -1
  76. package/dist/core/tasks/session.js +7 -8
  77. package/dist/core/tasks/session.js.map +1 -1
  78. package/dist/core/tasks/store.d.ts +18 -25
  79. package/dist/core/tasks/store.d.ts.map +1 -1
  80. package/dist/core/tasks/store.js +42 -40
  81. package/dist/core/tasks/store.js.map +1 -1
  82. package/dist/core/tasks/types.d.ts +96 -17
  83. package/dist/core/tasks/types.d.ts.map +1 -1
  84. package/dist/core/tasks/types.js.map +1 -1
  85. package/dist/core/tools/shell-execution.d.ts +8 -7
  86. package/dist/core/tools/shell-execution.d.ts.map +1 -1
  87. package/dist/core/tools/shell-execution.js +18 -26
  88. package/dist/core/tools/shell-execution.js.map +1 -1
  89. package/dist/core/tools/shell-tool.d.ts.map +1 -1
  90. package/dist/core/tools/shell-tool.js +31 -29
  91. package/dist/core/tools/shell-tool.js.map +1 -1
  92. package/dist/core/usage-totals.d.ts +3 -0
  93. package/dist/core/usage-totals.d.ts.map +1 -1
  94. package/dist/core/usage-totals.js +15 -0
  95. package/dist/core/usage-totals.js.map +1 -1
  96. package/dist/extensions/agent/progress.d.ts.map +1 -1
  97. package/dist/extensions/agent/progress.js +1 -11
  98. package/dist/extensions/agent/progress.js.map +1 -1
  99. package/dist/extensions/agent/settings-host.d.ts +33 -0
  100. package/dist/extensions/agent/settings-host.d.ts.map +1 -0
  101. package/dist/extensions/agent/settings-host.js +75 -0
  102. package/dist/extensions/agent/settings-host.js.map +1 -0
  103. package/dist/extensions/agent/settings.d.ts.map +1 -1
  104. package/dist/extensions/agent/settings.js +18 -7
  105. package/dist/extensions/agent/settings.js.map +1 -1
  106. package/dist/extensions/agent/tool.d.ts.map +1 -1
  107. package/dist/extensions/agent/tool.js +9 -5
  108. package/dist/extensions/agent/tool.js.map +1 -1
  109. package/dist/extensions/agent/worker.d.ts.map +1 -1
  110. package/dist/extensions/agent/worker.js +3 -5
  111. package/dist/extensions/agent/worker.js.map +1 -1
  112. package/dist/extensions/btw/agent.d.ts +1 -1
  113. package/dist/extensions/btw/agent.d.ts.map +1 -1
  114. package/dist/extensions/btw/agent.js +3 -20
  115. package/dist/extensions/btw/agent.js.map +1 -1
  116. package/dist/extensions/cached-compaction/index.d.ts.map +1 -1
  117. package/dist/extensions/cached-compaction/index.js +3 -22
  118. package/dist/extensions/cached-compaction/index.js.map +1 -1
  119. package/dist/extensions/cached-compaction/render.d.ts +1 -0
  120. package/dist/extensions/cached-compaction/render.d.ts.map +1 -1
  121. package/dist/extensions/cached-compaction/render.js +42 -14
  122. package/dist/extensions/cached-compaction/render.js.map +1 -1
  123. package/dist/extensions/deepwiki/client.d.ts.map +1 -1
  124. package/dist/extensions/deepwiki/client.js +6 -78
  125. package/dist/extensions/deepwiki/client.js.map +1 -1
  126. package/dist/extensions/deepwiki/transport.d.ts +3 -0
  127. package/dist/extensions/deepwiki/transport.d.ts.map +1 -0
  128. package/dist/extensions/deepwiki/transport.js +96 -0
  129. package/dist/extensions/deepwiki/transport.js.map +1 -0
  130. package/dist/extensions/provider/ui/builtin-data.d.ts +3 -3
  131. package/dist/extensions/provider/ui/builtin-data.d.ts.map +1 -1
  132. package/dist/extensions/provider/ui/builtin-data.js.map +1 -1
  133. package/dist/extensions/provider/ui/compat.d.ts +3 -3
  134. package/dist/extensions/provider/ui/compat.d.ts.map +1 -1
  135. package/dist/extensions/provider/ui/compat.js.map +1 -1
  136. package/dist/extensions/provider/ui/controls.d.ts +2 -2
  137. package/dist/extensions/provider/ui/controls.d.ts.map +1 -1
  138. package/dist/extensions/provider/ui/controls.js.map +1 -1
  139. package/dist/extensions/provider/ui/dialogs.d.ts +3 -3
  140. package/dist/extensions/provider/ui/dialogs.d.ts.map +1 -1
  141. package/dist/extensions/provider/ui/dialogs.js.map +1 -1
  142. package/dist/extensions/provider/ui/dictionary.d.ts +2 -2
  143. package/dist/extensions/provider/ui/dictionary.d.ts.map +1 -1
  144. package/dist/extensions/provider/ui/dictionary.js.map +1 -1
  145. package/dist/extensions/provider/ui/editor.d.ts.map +1 -1
  146. package/dist/extensions/provider/ui/editor.js +1 -3
  147. package/dist/extensions/provider/ui/editor.js.map +1 -1
  148. package/dist/extensions/provider/ui/fetch-models.d.ts +2 -2
  149. package/dist/extensions/provider/ui/fetch-models.d.ts.map +1 -1
  150. package/dist/extensions/provider/ui/fetch-models.js.map +1 -1
  151. package/dist/extensions/provider/ui/model-fields.d.ts +2 -2
  152. package/dist/extensions/provider/ui/model-fields.d.ts.map +1 -1
  153. package/dist/extensions/provider/ui/model-fields.js.map +1 -1
  154. package/dist/extensions/provider/ui/model-options.d.ts +6 -6
  155. package/dist/extensions/provider/ui/model-options.d.ts.map +1 -1
  156. package/dist/extensions/provider/ui/model-options.js.map +1 -1
  157. package/dist/extensions/provider/ui/pane.d.ts +21 -12
  158. package/dist/extensions/provider/ui/pane.d.ts.map +1 -1
  159. package/dist/extensions/provider/ui/pane.js.map +1 -1
  160. package/dist/extensions/provider/ui/provider-fields.d.ts +3 -3
  161. package/dist/extensions/provider/ui/provider-fields.d.ts.map +1 -1
  162. package/dist/extensions/provider/ui/provider-fields.js.map +1 -1
  163. package/dist/extensions/provider/ui/thinking-map.d.ts +2 -2
  164. package/dist/extensions/provider/ui/thinking-map.d.ts.map +1 -1
  165. package/dist/extensions/provider/ui/thinking-map.js.map +1 -1
  166. package/dist/extensions/run-summary/format.js +1 -1
  167. package/dist/extensions/run-summary/format.js.map +1 -1
  168. package/dist/extensions/statusline/usage.d.ts.map +1 -1
  169. package/dist/extensions/statusline/usage.js +2 -6
  170. package/dist/extensions/statusline/usage.js.map +1 -1
  171. package/dist/extensions/tasks/tool/actions.d.ts +1 -1
  172. package/dist/extensions/tasks/tool/actions.d.ts.map +1 -1
  173. package/dist/extensions/tasks/tool/actions.js +49 -106
  174. package/dist/extensions/tasks/tool/actions.js.map +1 -1
  175. package/dist/extensions/tasks/tool/constants.d.ts +1 -6
  176. package/dist/extensions/tasks/tool/constants.d.ts.map +1 -1
  177. package/dist/extensions/tasks/tool/constants.js +1 -6
  178. package/dist/extensions/tasks/tool/constants.js.map +1 -1
  179. package/dist/extensions/tasks/tool/schema.d.ts +0 -3
  180. package/dist/extensions/tasks/tool/schema.d.ts.map +1 -1
  181. package/dist/extensions/tasks/tool/schema.js +4 -13
  182. package/dist/extensions/tasks/tool/schema.js.map +1 -1
  183. package/dist/extensions/tasks/tool.d.ts.map +1 -1
  184. package/dist/extensions/tasks/tool.js +2 -2
  185. package/dist/extensions/tasks/tool.js.map +1 -1
  186. package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -1
  187. package/dist/extensions/tasks/ui/completion-render.js +31 -33
  188. package/dist/extensions/tasks/ui/completion-render.js.map +1 -1
  189. package/dist/extensions/tasks/ui/layout.d.ts +7 -7
  190. package/dist/extensions/tasks/ui/layout.d.ts.map +1 -1
  191. package/dist/extensions/tasks/ui/layout.js +17 -19
  192. package/dist/extensions/tasks/ui/layout.js.map +1 -1
  193. package/dist/extensions/tasks/ui/list.d.ts.map +1 -1
  194. package/dist/extensions/tasks/ui/list.js +2 -3
  195. package/dist/extensions/tasks/ui/list.js.map +1 -1
  196. package/dist/extensions/tasks/ui/manager.d.ts +16 -7
  197. package/dist/extensions/tasks/ui/manager.d.ts.map +1 -1
  198. package/dist/extensions/tasks/ui/manager.js +163 -131
  199. package/dist/extensions/tasks/ui/manager.js.map +1 -1
  200. package/dist/extensions/tasks/ui/model.d.ts +25 -0
  201. package/dist/extensions/tasks/ui/model.d.ts.map +1 -1
  202. package/dist/extensions/tasks/ui/model.js +4 -0
  203. package/dist/extensions/tasks/ui/model.js.map +1 -1
  204. package/dist/extensions/tasks/ui/render.d.ts +1 -1
  205. package/dist/extensions/tasks/ui/render.d.ts.map +1 -1
  206. package/dist/extensions/tasks/ui/render.js +11 -7
  207. package/dist/extensions/tasks/ui/render.js.map +1 -1
  208. package/dist/extensions/tasks/ui/status.d.ts +15 -0
  209. package/dist/extensions/tasks/ui/status.d.ts.map +1 -0
  210. package/dist/extensions/tasks/ui/status.js +16 -0
  211. package/dist/extensions/tasks/ui/status.js.map +1 -0
  212. package/dist/index.d.ts +1 -1
  213. package/dist/index.d.ts.map +1 -1
  214. package/dist/index.js.map +1 -1
  215. package/dist/modes/interactive/components/config-selector.d.ts +17 -2
  216. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  217. package/dist/modes/interactive/components/config-selector.js +199 -18
  218. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  219. package/dist/modes/interactive/components/status-marker.d.ts +2 -1
  220. package/dist/modes/interactive/components/status-marker.d.ts.map +1 -1
  221. package/dist/modes/interactive/components/status-marker.js +0 -1
  222. package/dist/modes/interactive/components/status-marker.js.map +1 -1
  223. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  224. package/dist/modes/interactive/interactive-mode.js +7 -1
  225. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  226. package/dist/utils/duration.d.ts +3 -0
  227. package/dist/utils/duration.d.ts.map +1 -0
  228. package/dist/utils/duration.js +17 -0
  229. package/dist/utils/duration.js.map +1 -0
  230. package/dist/utils/number.d.ts +3 -0
  231. package/dist/utils/number.d.ts.map +1 -0
  232. package/dist/utils/number.js +5 -0
  233. package/dist/utils/number.js.map +1 -0
  234. package/docs/bundled/extensions/agent.md +3 -3
  235. package/docs/bundled/extensions/cached-compaction.md +13 -4
  236. package/docs/bundled/extensions/deepwiki.md +3 -1
  237. package/docs/extensions.md +5 -5
  238. package/docs/packages.md +5 -3
  239. package/docs/sdk.md +1 -1
  240. package/docs/session-format.md +1 -1
  241. package/docs/settings.md +11 -0
  242. package/docs/skills.md +23 -0
  243. package/npm-shrinkwrap.json +2 -2
  244. package/package.json +1 -1
  245. package/schemas/settings.schema.json +36 -0
  246. package/dist/extensions/deepwiki/http.d.ts +0 -13
  247. package/dist/extensions/deepwiki/http.d.ts.map +0 -1
  248. package/dist/extensions/deepwiki/http.js +0 -88
  249. package/dist/extensions/deepwiki/http.js.map +0 -1
  250. package/dist/extensions/tasks/ui/task-view.d.ts +0 -8
  251. package/dist/extensions/tasks/ui/task-view.d.ts.map +0 -1
  252. package/dist/extensions/tasks/ui/task-view.js +0 -13
  253. package/dist/extensions/tasks/ui/task-view.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACN,cAAc,EACd,eAAe,GAIf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,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,MAAM,CAAyB,IAAY,EAAE,OAAU;IAC/D,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE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K,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3C,OAAO,MAAM,CACZ,KAAK,CAAC,MAAM;QACX,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,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 type { AgentToolResult } from \"../../../core/extensions/types.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport { boundText } from \"../../../core/tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n} from \"../../../core/tasks/types.ts\";\nimport { truncateHead } from \"../../../core/tools/truncate.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.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}\nfunction activeBackgroundTasks(background: TasksContext): TaskSnapshot[] {\n\treturn background.list().filter((task) => task.mode === \"background\" && !isTaskTerminal(task.status));\n}\n\nfunction stillRunningText(tasks: TaskSnapshot[]): string {\n\treturn tasks.length > 0 ? `\\n\\n[still_running]\\n${tasks.map((task) => describeTaskLine(task)).join(\"\\n\")}` : \"\";\n}\n\nfunction emptyWaitDetails(\n\toutcome: \"interrupted\" | \"timed_out\" | \"no_tasks\",\n\twaitedMs: number,\n\trunning: number,\n): TasksWaitDetails {\n\treturn {\n\t\taction: \"wait\",\n\t\toutcome,\n\t\twaitedMs,\n\t\tdeltaBytes: 0,\n\t\ttotalBytes: 0,\n\t\tdeltaTruncated: false,\n\t\toutputPath: \"\",\n\t\trunning,\n\t};\n}\n\nasync function runWaitAny(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n\tinterruptSignal?: AbortSignal,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst candidates = activeBackgroundTasks(background);\n\tif (candidates.length === 0) {\n\t\treturn result(\n\t\t\t\"No background tasks are running, so there is nothing to wait for. Finished tasks report back via automatic notification.\",\n\t\t\temptyWaitDetails(\"no_tasks\", 0, 0),\n\t\t);\n\t}\n\t// Holds cover the whole initial cohort until the winning result is ready for\n\t// persistence. Other completed tasks resume ordinary notification delivery on release.\n\tconst releases = candidates.map((task) => background.holdDelivery(task.id));\n\tconst start = Date.now();\n\ttry {\n\t\tconst task = await background.waitAny(clampWaitMs(input.waitMs), signal, interruptSignal);\n\t\tconst ids = new Set(candidates.map((candidate) => candidate.id));\n\t\tconst running = activeBackgroundTasks(background).filter((candidate) => ids.has(candidate.id));\n\t\tif (!task) {\n\t\t\tconst interrupted = !background.closed && interruptSignal?.aborted === true;\n\t\t\tconst outcome = interrupted ? \"interrupted\" : \"timed_out\";\n\t\t\tconst note = background.closed\n\t\t\t\t? \"The host closed; execution state is unconfirmed.\"\n\t\t\t\t: interrupted\n\t\t\t\t\t? \"New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped.\"\n\t\t\t\t\t: \"The wait window expired; running tasks continue. Prefer other work over waiting again.\";\n\t\t\treturn result(\n\t\t\t\t`${note}${stillRunningText(running)}`,\n\t\t\t\temptyWaitDetails(outcome, Date.now() - start, running.length),\n\t\t\t);\n\t\t}\n\t\tconst slice = await background.read(task.id, { bytes: TASKS_WAIT_DELTA_BYTES });\n\t\tsignal?.throwIfAborted();\n\t\tonReady?.(task.id);\n\t\treturn result(\n\t\t\t`${readText(`[${describeTaskLine(task)} · waitAny settled · ${rangeText(slice)}]`, slice)}${stillRunningText(running)}`,\n\t\t\t{\n\t\t\t\taction: \"wait\",\n\t\t\t\toutcome: \"settled\",\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\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\trunning: running.length,\n\t\t\t},\n\t\t);\n\t} finally {\n\t\tfor (const release of releases) release();\n\t}\n}\n\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\tonReady?: (taskId: string) => void,\n\tinterruptSignal?: AbortSignal,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tif (!input.taskId?.trim()) {\n\t\tif (input.sinceBytes !== undefined)\n\t\t\tthrow new Error(\"action 'wait' without 'taskId' does not accept 'sinceBytes'; offsets belong to one task.\");\n\t\treturn runWaitAny(background, input, signal, onReady, interruptSignal);\n\t}\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, interruptSignal);\n\t\t\tconst settled = isTaskTerminal(task.status);\n\t\t\tconst interrupted = !settled && !background.closed && interruptSignal?.aborted === true;\n\t\t\tconst timedOut = !settled && !interrupted;\n\t\t\tconst outcome = settled ? \"settled\" : interrupted ? \"interrupted\" : \"timed_out\";\n\t\t\tconst waitedMs = Date.now() - start;\n\t\t\tif (interrupted) {\n\t\t\t\treturn result(\n\t\t\t\t\t`[${describeTaskLine(task)} · interrupted by steering; execution continues]\\nRead the new input before deciding whether to wait again; the task was not stopped.`,\n\t\t\t\t\t{\n\t\t\t\t\t\taction: \"wait\",\n\t\t\t\t\t\toutcome,\n\t\t\t\t\t\ttaskId: task.id,\n\t\t\t\t\t\tstatus: task.status,\n\t\t\t\t\t\tkind: task.kind,\n\t\t\t\t\t\twaitedMs,\n\t\t\t\t\t\tdeltaBytes: 0,\n\t\t\t\t\t\ttotalBytes: 0,\n\t\t\t\t\t\tdeltaTruncated: false,\n\t\t\t\t\t\toutputPath: task.outputPath ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\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 (settled) 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\toutcome,\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\twaitedMs,\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\ttitle: 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/extensions/tasks/tool/actions.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACN,cAAc,EACd,eAAe,GAKf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,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C,EAAE,CAAC;KACvD,CACD,CAAC;AACH,CAAC","sourcesContent":["/** Management only: execution and delivery belong to the session task runtime. */\n\nimport type { AgentToolResult } from \"../../../core/extensions/types.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport { clampReadBytes, clampWaitMs } from \"../../../core/tasks/limits.ts\";\nimport { boundText } from \"../../../core/tasks/output.ts\";\nimport {\n\tisTaskTerminal,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskWaitOutcome,\n} from \"../../../core/tasks/types.ts\";\nimport { truncateHead } from \"../../../core/tools/truncate.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { TASKS_LIST_FINISHED_SHOWN, TASKS_WAIT_DELTA_BYTES } from \"./constants.ts\";\nimport { clampSinceBytes, 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}\nfunction stillRunningText(tasks: readonly TaskSnapshot[]): string {\n\treturn tasks.length > 0 ? `\\n\\n[still_running]\\n${tasks.map((task) => describeTaskLine(task)).join(\"\\n\")}` : \"\";\n}\n\n/** A finished observation of one task, or of the first task in a waitAny cohort to settle. */\ninterface WaitView {\n\tscope: \"task\" | \"any\";\n\toutcome: TaskWaitOutcome | \"no_tasks\";\n\twaitedMs: number;\n\ttask?: TaskSnapshot;\n\tread?: TaskRead;\n\t/** Present for waitAny: cohort members still running. */\n\trunning?: readonly TaskSnapshot[];\n}\n\nfunction waitDetails({ outcome, waitedMs, task, read, running }: WaitView): TasksWaitDetails {\n\treturn {\n\t\taction: \"wait\",\n\t\t// A closed host is told apart in the text; the stored outcome keeps its historical values.\n\t\toutcome: outcome === \"closed\" ? \"timed_out\" : outcome,\n\t\t...(task ? { taskId: task.id, status: task.status, kind: task.kind } : {}),\n\t\twaitedMs,\n\t\tdeltaBytes: read ? Buffer.byteLength(read.text) : 0,\n\t\ttotalBytes: read?.totalBytes ?? 0,\n\t\tdeltaTruncated: read?.truncated ?? false,\n\t\toutputPath: task?.outputPath ?? \"\",\n\t\t...(running ? { running: running.length } : {}),\n\t};\n}\n\nfunction waitText(view: WaitView, sinceBytes?: number): string {\n\tconst { scope, outcome, task, read, running } = view;\n\tconst still = stillRunningText(running ?? []);\n\tif (outcome === \"no_tasks\") {\n\t\treturn \"No background tasks are running, so there is nothing to wait for. Finished tasks report back via automatic notification.\";\n\t}\n\tif (read && task) {\n\t\tconst header =\n\t\t\tscope === \"any\"\n\t\t\t\t? `${describeTaskLine(task)} · waitAny settled`\n\t\t\t\t: `${describeTaskLine(task)}${\n\t\t\t\t\t\toutcome === \"closed\"\n\t\t\t\t\t\t\t? \" · host closed; execution state unconfirmed\"\n\t\t\t\t\t\t\t: outcome === \"timed_out\"\n\t\t\t\t\t\t\t\t? \" · wait window expired; execution continues\"\n\t\t\t\t\t\t\t\t: \"\"\n\t\t\t\t\t}`;\n\t\treturn `${readText(`[${header} · ${rangeText(read, sinceBytes)}]`, read)}${still}`;\n\t}\n\tif (scope === \"task\" && task) {\n\t\treturn `[${describeTaskLine(task)} · interrupted by steering; execution continues]\\nRead the new input before deciding whether to wait again; the task was not stopped.`;\n\t}\n\tconst note =\n\t\toutcome === \"closed\"\n\t\t\t? \"The host closed; execution state is unconfirmed.\"\n\t\t\t: outcome === \"interrupted\"\n\t\t\t\t? \"New steering input ended this wait early. Read the new input before deciding what to do next; no task was stopped.\"\n\t\t\t\t: \"The wait window expired; running tasks continue. Prefer other work over waiting again.\";\n\treturn `${note}${still}`;\n}\n\nfunction waitResult(view: WaitView, sinceBytes?: number): AgentToolResult<TasksWaitDetails> {\n\treturn result(waitText(view, sinceBytes), waitDetails(view));\n}\n\nexport async function runWait(\n\tbackground: TasksContext,\n\tinput: TasksInput,\n\tsignal?: AbortSignal,\n\ttoolCallId?: string,\n): Promise<AgentToolResult<TasksWaitDetails>> {\n\tconst timeoutMs = clampWaitMs(input.waitMs);\n\tif (!input.taskId?.trim()) {\n\t\tif (input.sinceBytes !== undefined)\n\t\t\tthrow new Error(\"action 'wait' without 'taskId' does not accept 'sinceBytes'; offsets belong to one task.\");\n\t\tconst any = await background.waitAny({ timeoutMs, signal, toolCallId, read: { bytes: TASKS_WAIT_DELTA_BYTES } });\n\t\treturn waitResult({ scope: \"any\", ...any });\n\t}\n\tconst id = requireTaskId(input);\n\ttry {\n\t\tconst sinceBytes = clampSinceBytes(input.sinceBytes);\n\t\tconst one = await background.wait(id, {\n\t\t\ttimeoutMs,\n\t\t\tsignal,\n\t\t\ttoolCallId,\n\t\t\tread: { bytes: TASKS_WAIT_DELTA_BYTES, sinceBytes },\n\t\t});\n\t\treturn waitResult({ scope: \"task\", ...one }, sinceBytes);\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\ttitle: 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"]}
@@ -2,17 +2,12 @@
2
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
- * place; execution and retention limits belong to the core service.
5
+ * place; read and wait limits, execution and retention belong to the core service.
6
6
  */
7
- /** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */
8
- export declare const TASKS_LOGS_DEFAULT_BYTES: number;
9
- export declare const TASKS_LOGS_MIN_BYTES = 256;
10
7
  /** Finished tasks shown by `list` before the rest fold into a count. */
11
8
  export declare const TASKS_LIST_FINISHED_SHOWN = 5;
12
9
  /** Bounded output delta returned by a successful wait. */
13
10
  export declare const TASKS_WAIT_DELTA_BYTES: number;
14
- /** Wait-window bounds shared by execution and the pending-call renderer. */
15
- export { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS, TASKS_WAIT_MIN_MS } from "../../../core/tasks/limits.ts";
16
11
  /** How long a foreground execution runs before the statusline advertises the detach key. */
17
12
  export declare const TASKS_DETACH_HINT_DELAY_MS = 10000;
18
13
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/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,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE5G,4FAA4F;AAC5F,eAAO,MAAM,0BAA0B,QAAS,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,4FAA4F;AAC5F,eAAO,MAAM,0BAA0B,QAAS,CAAC"}
@@ -2,17 +2,12 @@
2
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
- * place; execution and retention limits belong to the core service.
5
+ * place; read and wait limits, execution and retention belong to the core service.
6
6
  */
7
- /** Default and floor for a `read` slice; the ceiling is the core's TASK_RESULT_BYTES. */
8
- export const TASKS_LOGS_DEFAULT_BYTES = 8 * 1024;
9
- export const TASKS_LOGS_MIN_BYTES = 256;
10
7
  /** Finished tasks shown by `list` before the rest fold into a count. */
11
8
  export const TASKS_LIST_FINISHED_SHOWN = 5;
12
9
  /** Bounded output delta returned by a successful wait. */
13
10
  export const TASKS_WAIT_DELTA_BYTES = 32 * 1024;
14
- /** Wait-window bounds shared by execution and the pending-call renderer. */
15
- export { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS, TASKS_WAIT_MIN_MS } from "../../../core/tasks/limits.js";
16
11
  /** How long a foreground execution runs before the statusline advertises the detach key. */
17
12
  export const TASKS_DETACH_HINT_DELAY_MS = 10_000;
18
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/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,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE5G,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 { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS, TASKS_WAIT_MIN_MS } from \"../../../core/tasks/limits.ts\";\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/extensions/tasks/tool/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,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; read and wait limits, execution and retention belong to the core service.\n */\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/** How long a foreground execution runs before the statusline advertises the detach key. */\nexport const TASKS_DETACH_HINT_DELAY_MS = 10_000;\n"]}
@@ -18,9 +18,6 @@ export declare const tasksSchema: Type.TObject<{
18
18
  /** Raw tool arguments. Every per-action field is optional here; actions.ts narrows. */
19
19
  export type TasksInput = Static<typeof tasksSchema>;
20
20
  export declare function requireTaskId(input: TasksInput): string;
21
- export declare function clampReadBytes(bytes: number | undefined): number;
22
- /** Shared with the pending-call renderer so the window it shows is the one that runs. */
23
- export declare function clampWaitMs(waitMs: number | undefined): number;
24
21
  export declare function clampSinceBytes(sinceBytes: number | undefined): number | undefined;
25
22
  export declare const TASKS_TOOL_DESCRIPTION: string;
26
23
  export declare const TASKS_PROMPT_SNIPPET = "Manage background tasks; wait for a specific task or any running task";
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAY5C,eAAO,MAAM,WAAW;;;;;;;EAiCtB,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,QAOmS,CAAC;AACvU,eAAO,MAAM,oBAAoB,0EAA0E,CAAC;AAC5G,eAAO,MAAM,uBAAuB,UAInC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAM5C,eAAO,MAAM,WAAW;;;;;;;EAiCtB,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,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAElF;AAED,eAAO,MAAM,sBAAsB,QAOmS,CAAC;AACvU,eAAO,MAAM,oBAAoB,0EAA0E,CAAC;AAC5G,eAAO,MAAM,uBAAuB,UAInC,CAAC"}
@@ -8,10 +8,10 @@
8
8
  */
9
9
  import { StringEnum } from "@earendil-works/pi-ai";
10
10
  import { Type } from "typebox";
11
- import { formatDuration } from "../../../core/tasks/format.js";
12
- import { TASK_RESULT_BYTES } from "../../../core/tasks/output.js";
11
+ import { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS } from "../../../core/tasks/limits.js";
12
+ import { TASK_READ_BYTES, TASK_RESULT_BYTES } from "../../../core/tasks/output.js";
13
13
  import { formatSize } from "../../../core/tools/truncate.js";
14
- import { TASKS_LOGS_DEFAULT_BYTES, TASKS_LOGS_MIN_BYTES, TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS, TASKS_WAIT_MIN_MS, } from "./constants.js";
14
+ import { formatDuration } from "../../../utils/duration.js";
15
15
  export const tasksSchema = Type.Object({
16
16
  action: StringEnum(["read", "wait", "kill", "list"], {
17
17
  description: "Which task operation to perform",
@@ -25,7 +25,7 @@ export const tasksSchema = Type.Object({
25
25
  description: "Read from the end (default) or the start of the output (read)",
26
26
  })),
27
27
  bytes: Type.Optional(Type.Number({
28
- description: `Max bytes to return (read, default ${formatSize(TASKS_LOGS_DEFAULT_BYTES)}, max ${formatSize(TASK_RESULT_BYTES)})`,
28
+ description: `Max bytes to return (read, default ${formatSize(TASK_READ_BYTES)}, max ${formatSize(TASK_RESULT_BYTES)})`,
29
29
  })),
30
30
  // — wait —
31
31
  waitMs: Type.Optional(Type.Number({
@@ -46,15 +46,6 @@ export function requireTaskId(input) {
46
46
  }
47
47
  return taskId;
48
48
  }
49
- export function clampReadBytes(bytes) {
50
- const value = bytes !== undefined && Number.isFinite(bytes) ? bytes : TASKS_LOGS_DEFAULT_BYTES;
51
- return Math.min(TASK_RESULT_BYTES, Math.max(TASKS_LOGS_MIN_BYTES, Math.floor(value)));
52
- }
53
- /** Shared with the pending-call renderer so the window it shows is the one that runs. */
54
- export function clampWaitMs(waitMs) {
55
- const value = waitMs !== undefined && Number.isFinite(waitMs) ? waitMs : TASKS_WAIT_DEFAULT_MS;
56
- return Math.min(TASKS_WAIT_MAX_MS, Math.max(TASKS_WAIT_MIN_MS, Math.floor(value)));
57
- }
58
49
  export function clampSinceBytes(sinceBytes) {
59
50
  return sinceBytes === undefined || !Number.isFinite(sinceBytes) ? undefined : Math.max(0, Math.floor(sinceBytes));
60
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/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,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,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,CAA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C,CAAC,wBAAwB,CAAC;IAC/F,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,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,uGAAuG;IACvG,6MAA6M;IAC7M,8CAA8C;IAC9C,qUAAqU,CAAC;AACvU,MAAM,CAAC,MAAM,oBAAoB,GAAG,uEAAuE,CAAC;AAC5G,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,+GAA+G;IAC/G,qPAAqP;IACrP,gKAAgK;CAChK,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 { formatDuration } from \"../../../core/tasks/format.ts\";\nimport { TASK_RESULT_BYTES } from \"../../../core/tasks/output.ts\";\nimport { formatSize } from \"../../../core/tools/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(\n\t\tType.String({\n\t\t\tdescription: \"Task execution id (read/wait/kill). Omit for wait to wait for any task running at call time.\",\n\t\t}),\n\t),\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: `Maximum wait window in ms (default ${formatDuration(TASKS_WAIT_DEFAULT_MS)}, max ${formatDuration(TASKS_WAIT_MAX_MS)}). Only the wait ends on timeout; execution continues.`,\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 with taskId only)\",\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 model-readable output or report slice (head/tail); tool-call activity stays in /tasks. \" +\n\t\"wait: observe one task, or any task running at call time, for up to waitMs; no running tasks returns immediately. New steering input ends only the wait with outcome interrupted; it never stops the task. \" +\n\t\"kill: request cancellation of a whole task. \" +\n\t\"tasks cannot start work; submit background work through its owning tool. A wait ends as settled, interrupted, timed_out, or no_tasks. Timeout or cancellation ends only the wait, never execution. Reads and settled waits report byte ranges; use next sinceBytes only with that task's ID. Output is capped at 50KB per response.\";\nexport const TASKS_PROMPT_SNIPPET = \"Manage background tasks; wait for a specific task or any running task\";\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: provide taskId for one task or omit it for any task running at call time; never sleep-poll with repeated reads.\",\n\t\"A new steering message interrupts only an active tasks wait so you can read the new input; it does not cancel execution. A wait timeout is not a task failure.\",\n];\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/tool/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,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,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,CACpB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,8FAA8F;KAC3G,CAAC,CACF;IACD,WAAW;IACX,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,CAAU,EAAE;QACrC,WAAW,EAAE,+DAA+D;KAC5E,CAAC,CACF;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,sC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MAAM,uBAAuB,GAAG;IACtC,+GAA+G;IAC/G,qPAAqP;IACrP,gKAAgK;CAChK,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 { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS } from \"../../../core/tasks/limits.ts\";\nimport { TASK_READ_BYTES, TASK_RESULT_BYTES } from \"../../../core/tasks/output.ts\";\nimport { formatSize } from \"../../../core/tools/truncate.ts\";\nimport { formatDuration } from \"../../../utils/duration.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(\n\t\tType.String({\n\t\t\tdescription: \"Task execution id (read/wait/kill). Omit for wait to wait for any task running at call time.\",\n\t\t}),\n\t),\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(TASK_READ_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: `Maximum wait window in ms (default ${formatDuration(TASKS_WAIT_DEFAULT_MS)}, max ${formatDuration(TASKS_WAIT_MAX_MS)}). Only the wait ends on timeout; execution continues.`,\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 with taskId only)\",\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 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 model-readable output or report slice (head/tail); tool-call activity stays in /tasks. \" +\n\t\"wait: observe one task, or any task running at call time, for up to waitMs; no running tasks returns immediately. New steering input ends only the wait with outcome interrupted; it never stops the task. \" +\n\t\"kill: request cancellation of a whole task. \" +\n\t\"tasks cannot start work; submit background work through its owning tool. A wait ends as settled, interrupted, timed_out, or no_tasks. Timeout or cancellation ends only the wait, never execution. Reads and settled waits report byte ranges; use next sinceBytes only with that task's ID. Output is capped at 50KB per response.\";\nexport const TASKS_PROMPT_SNIPPET = \"Manage background tasks; wait for a specific task or any running task\";\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: provide taskId for one task or omit it for any task running at call time; never sleep-poll with repeated reads.\",\n\t\"A new steering message interrupts only an active tasks wait so you can read the new input; it does not cancel execution. A wait timeout is not a task failure.\",\n];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/tasks/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAyE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACtH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,wBAAgB,yBAAyB,IAAI,cAAc,CAAC,OAAO,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAoC9G"}
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/tasks/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAyE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACtH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE3F,wBAAgB,yBAAyB,IAAI,cAAc,CAAC,OAAO,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC,CA8B9G"}
@@ -10,13 +10,13 @@ export function createTasksToolDefinition() {
10
10
  promptGuidelines: TASKS_PROMPT_GUIDELINES,
11
11
  parameters: tasksSchema,
12
12
  constrainedSampling: { type: "json_schema", strict: "prefer" },
13
- async execute(_id, params, signal, _onUpdate, ctx) {
13
+ async execute(toolCallId, params, signal, _onUpdate, ctx) {
14
14
  try {
15
15
  switch (params.action) {
16
16
  case "read":
17
17
  return await runRead(ctx.tasks, params);
18
18
  case "wait":
19
- return await runWait(ctx.tasks, params, signal, (taskId) => ctx.tasks.session?.prepareWait(_id, taskId), ctx.tasks.session?.waitInterruptSignal);
19
+ return await runWait(ctx.tasks, params, signal, toolCallId);
20
20
  case "kill":
21
21
  return runKill(ctx.tasks, params);
22
22
  case "list":
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/tasks/tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAyB,MAAM,gBAAgB,CAAC;AAE3F,MAAM,UAAU,yBAAyB;IACxC,OAAO;QACN,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,sBAAsB;QACnC,aAAa,EAAE,oBAAoB;QACnC,gBAAgB,EAAE,uBAAuB;QACzC,UAAU,EAAE,WAAW;QACvB,mBAAmB,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9D,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;YAChD,IAAI,CAAC;gBACJ,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;oBACvB,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACzC,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CACnB,GAAG,CAAC,KAAK,EACT,MAAM,EACN,MAAM,EACN,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EACvD,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,mBAAmB,CACtC,CAAC;oBACH,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACnC,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,uEAAuE;gBACvE,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;QACD,UAAU,EAAE,eAAe;QAC3B,YAAY,EAAE,iBAAiB;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import type { ToolDefinition } from \"../../core/extensions/types.ts\";\nimport { boundedText, runKill, runList, runRead, runWait } from \"./tool/actions.ts\";\nimport { TASKS_PROMPT_GUIDELINES, TASKS_PROMPT_SNIPPET, TASKS_TOOL_DESCRIPTION, tasksSchema } from \"./tool/schema.ts\";\nimport type { TasksDetails } from \"./tool/types.ts\";\nimport { renderTasksCall, renderTasksResult, type TasksRenderState } from \"./ui/render.ts\";\n\nexport function createTasksToolDefinition(): ToolDefinition<typeof tasksSchema, TasksDetails, TasksRenderState> {\n\treturn {\n\t\tname: \"tasks\",\n\t\tlabel: \"tasks\",\n\t\tdescription: TASKS_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TASKS_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TASKS_PROMPT_GUIDELINES,\n\t\tparameters: tasksSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(_id, params, signal, _onUpdate, ctx) {\n\t\t\ttry {\n\t\t\t\tswitch (params.action) {\n\t\t\t\t\tcase \"read\":\n\t\t\t\t\t\treturn await runRead(ctx.tasks, params);\n\t\t\t\t\tcase \"wait\":\n\t\t\t\t\t\treturn await runWait(\n\t\t\t\t\t\t\tctx.tasks,\n\t\t\t\t\t\t\tparams,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t(taskId) => ctx.tasks.session?.prepareWait(_id, taskId),\n\t\t\t\t\t\t\tctx.tasks.session?.waitInterruptSignal,\n\t\t\t\t\t\t);\n\t\t\t\t\tcase \"kill\":\n\t\t\t\t\t\treturn runKill(ctx.tasks, params);\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\treturn runList(ctx.tasks);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Lookup failures already carry the current task list from actions.ts.\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(boundedText(message));\n\t\t\t}\n\t\t},\n\t\trenderCall: renderTasksCall,\n\t\trenderResult: renderTasksResult,\n\t};\n}\n"]}
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/tasks/tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAyB,MAAM,gBAAgB,CAAC;AAE3F,MAAM,UAAU,yBAAyB;IACxC,OAAO;QACN,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,sBAAsB;QACnC,aAAa,EAAE,oBAAoB;QACnC,gBAAgB,EAAE,uBAAuB;QACzC,UAAU,EAAE,WAAW;QACvB,mBAAmB,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE;QAC9D,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;YACvD,IAAI,CAAC;gBACJ,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;oBACvB,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACzC,KAAK,MAAM;wBACV,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;oBAC7D,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBACnC,KAAK,MAAM;wBACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,uEAAuE;gBACvE,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;QACD,UAAU,EAAE,eAAe;QAC3B,YAAY,EAAE,iBAAiB;KAC/B,CAAC;AACH,CAAC","sourcesContent":["import type { ToolDefinition } from \"../../core/extensions/types.ts\";\nimport { boundedText, runKill, runList, runRead, runWait } from \"./tool/actions.ts\";\nimport { TASKS_PROMPT_GUIDELINES, TASKS_PROMPT_SNIPPET, TASKS_TOOL_DESCRIPTION, tasksSchema } from \"./tool/schema.ts\";\nimport type { TasksDetails } from \"./tool/types.ts\";\nimport { renderTasksCall, renderTasksResult, type TasksRenderState } from \"./ui/render.ts\";\n\nexport function createTasksToolDefinition(): ToolDefinition<typeof tasksSchema, TasksDetails, TasksRenderState> {\n\treturn {\n\t\tname: \"tasks\",\n\t\tlabel: \"tasks\",\n\t\tdescription: TASKS_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TASKS_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TASKS_PROMPT_GUIDELINES,\n\t\tparameters: tasksSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tasync execute(toolCallId, params, signal, _onUpdate, ctx) {\n\t\t\ttry {\n\t\t\t\tswitch (params.action) {\n\t\t\t\t\tcase \"read\":\n\t\t\t\t\t\treturn await runRead(ctx.tasks, params);\n\t\t\t\t\tcase \"wait\":\n\t\t\t\t\t\treturn await runWait(ctx.tasks, params, signal, toolCallId);\n\t\t\t\t\tcase \"kill\":\n\t\t\t\t\t\treturn runKill(ctx.tasks, params);\n\t\t\t\t\tcase \"list\":\n\t\t\t\t\t\treturn runList(ctx.tasks);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Lookup failures already carry the current task list from actions.ts.\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(boundedText(message));\n\t\t\t}\n\t\t},\n\t\trenderCall: renderTasksCall,\n\t\trenderResult: renderTasksResult,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"completion-render.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/ui/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAE,KAAK,SAAS,EAA6D,MAAM,wBAAwB,CAAC;AACnH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAoLvE,gGAAgG;AAChG,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,KAAK,GACV,SAAS,CAYX"}
1
+ {"version":3,"file":"completion-render.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/ui/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAoLvE,gGAAgG;AAChG,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,KAAK,GACV,SAAS,CAYX"}
@@ -1,17 +1,13 @@
1
1
  /** Human-facing completion cards. The persisted context message remains untouched. */
2
- import { stripTerminalSequences, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
+ import { truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
3
3
  import { readVersionedTask } from "../../../core/tasks/codec.js";
4
4
  import { runtimeLabel } from "../../../core/tasks/format.js";
5
- import { statusMarker } from "../../../modes/interactive/components/status-marker.js";
6
5
  import { FramedComponent } from "../../../modes/interactive/tool-view/style.js";
7
- import { sanitizeBinaryOutput } from "../../../utils/shell.js";
8
- import { statusName } from "./task-view.js";
6
+ import { statusName, statusView } from "./status.js";
7
+ import { cleanTaskText } from "./text.js";
9
8
  const SOURCE_LIMIT = 64 * 1024;
10
9
  const CARD_ROWS = 128;
11
10
  const OUTPUT_ROWS = 20;
12
- function clean(text) {
13
- return sanitizeBinaryOutput(stripTerminalSequences(text)).replace(/\r\n?/g, "\n");
14
- }
15
11
  function savedText(message) {
16
12
  // 64K is a UTF-16 code-unit display budget, not a UTF-8 byte promise; the block
17
13
  // cap bounds iteration itself so many empty/non-text blocks cannot spin here.
@@ -41,33 +37,30 @@ function savedText(message) {
41
37
  }
42
38
  }
43
39
  }
44
- return { text: clean(text), clipped };
40
+ return { text: cleanTaskText(text), clipped };
45
41
  }
46
42
  function completionView(message) {
47
43
  const task = readVersionedTask(message.details);
48
44
  if (!task) {
49
45
  const { text, clipped } = savedText(message);
50
- return { body: text, truncated: clipped, facts: [] };
46
+ return { kind: "saved", body: text, truncated: clipped };
51
47
  }
52
48
  return {
53
- label: clean(task.label),
54
- title: clean(task.title),
49
+ kind: "task",
50
+ label: cleanTaskText(task.label),
51
+ title: cleanTaskText(task.title),
55
52
  duration: runtimeLabel(task),
56
53
  status: task.status,
57
- id: clean(task.id),
58
- input: task.input && { label: clean(task.input.label), text: clean(task.input.text) },
59
- facts: (task.facts ?? []).map(([label, value]) => [clean(label), clean(value)]),
60
- path: task.outputPath === undefined ? undefined : clean(task.outputPath),
61
- diagnostic: task.error === undefined ? undefined : clean(task.error),
62
- output: clean(task.result?.text ?? ""),
54
+ id: cleanTaskText(task.id),
55
+ input: task.input && { label: cleanTaskText(task.input.label), text: cleanTaskText(task.input.text) },
56
+ facts: (task.facts ?? []).map(([label, value]) => [cleanTaskText(label), cleanTaskText(value)]),
57
+ path: task.outputPath === undefined ? undefined : cleanTaskText(task.outputPath),
58
+ diagnostic: task.error === undefined ? undefined : cleanTaskText(task.error),
59
+ output: cleanTaskText(task.result?.text ?? ""),
63
60
  report: task.output === "report",
64
- body: "",
65
61
  truncated: task.result?.truncated === true || task.input?.truncated === true,
66
62
  };
67
63
  }
68
- function color(status) {
69
- return status === undefined ? "muted" : statusMarker(status).color;
70
- }
71
64
  function shortId(id) {
72
65
  return id.replace(/^(.+)-([0-9a-f]{8})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "$1-$2");
73
66
  }
@@ -81,7 +74,7 @@ class CompletionCard {
81
74
  render(width) {
82
75
  if (width < 1)
83
76
  return [];
84
- const chrome = new FramedComponent({ render: (contentWidth) => this.renderContent(contentWidth), invalidate() { } }, "header", () => color(this.view.status));
77
+ const chrome = new FramedComponent({ render: (contentWidth) => this.renderContent(contentWidth), invalidate() { } }, "header", () => (this.view.kind === "task" ? statusView(this.view.status).color : "muted"));
85
78
  // The gutter reserves its own cells; clip defensively for one-cell terminals.
86
79
  return chrome.render(width).map((line) => truncateToWidth(line, width, ""));
87
80
  }
@@ -99,14 +92,19 @@ class CompletionCard {
99
92
  const indent = inner >= 3 ? " " : "";
100
93
  const bodyWidth = Math.max(1, inner - indent.length);
101
94
  const lines = [];
102
- const status = view.status ? statusName(view.status) : "Result received";
103
- lines.push(`${theme.fg("toolTitle", theme.bold(view.label ?? "Notification"))}${theme.fg("muted", ` · Background ${status.toLowerCase()}${view.duration ? ` · ${view.duration}` : ""}`)}${view.id ? theme.fg("dim", ` · ${shortId(view.id)}`) : ""}`);
104
- const summary = view.title?.split("\n").find((line) => line.trim()) ?? view.title;
95
+ const status = view.kind === "task" ? statusName(view.status) : "Result received";
96
+ const label = view.kind === "task" ? view.label : "Notification";
97
+ const duration = view.kind === "task" && view.duration ? ` · ${view.duration}` : "";
98
+ const id = view.kind === "task" ? view.id : "";
99
+ lines.push(`${theme.fg("toolTitle", theme.bold(label))}${theme.fg("muted", ` · Background ${status.toLowerCase()}${duration}`)}${id ? theme.fg("dim", ` · ${shortId(id)}`) : ""}`);
105
100
  if (!options.expanded) {
106
- if (summary)
107
- lines.push(theme.fg("toolOutput", summary));
108
- if (view.diagnostic)
109
- lines.push(theme.fg(color(view.status), view.diagnostic));
101
+ if (view.kind === "task") {
102
+ const summary = view.title.split("\n").find((line) => line.trim()) ?? view.title;
103
+ if (summary)
104
+ lines.push(theme.fg("toolOutput", summary));
105
+ if (view.diagnostic)
106
+ lines.push(theme.fg(statusView(view.status).color, view.diagnostic));
107
+ }
110
108
  }
111
109
  else {
112
110
  if (view.truncated) {
@@ -124,7 +122,7 @@ class CompletionCard {
124
122
  if (!tail && omitted)
125
123
  lines.push(theme.fg("dim", `${indent}… ${omitted} more display lines omitted`));
126
124
  };
127
- if (view.output === undefined)
125
+ if (view.kind === "saved")
128
126
  section("Details", view.body || "No text result.", 36);
129
127
  else {
130
128
  if (view.input)
@@ -140,8 +138,8 @@ class CompletionCard {
140
138
  if (view.path)
141
139
  section("Log", view.path, 4);
142
140
  }
143
- if (view.id) {
144
- lines.push("", ...wrapTextWithAnsi(`Task ID: ${view.id}`, inner).map((line) => theme.fg("dim", line)));
141
+ if (id) {
142
+ lines.push("", ...wrapTextWithAnsi(`Task ID: ${id}`, inner).map((line) => theme.fg("dim", line)));
145
143
  }
146
144
  lines.push(theme.fg("dim", "Preview of the saved result."));
147
145
  }
@@ -162,9 +160,9 @@ export function renderTaskCompletion(message, options, theme) {
162
160
  }
163
161
  catch {
164
162
  view = {
163
+ kind: "saved",
165
164
  body: "The saved notification could not be interpreted. Its original message remains in session history.",
166
165
  truncated: false,
167
- facts: [],
168
166
  };
169
167
  }
170
168
  return new CompletionCard(view, options, theme);
@@ -1 +1 @@
1
- {"version":3,"file":"completion-render.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/ui/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAkB,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGnH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAA0B,YAAY,EAAE,MAAM,wDAAwD,CAAC;AAE9G,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/B,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,EAAE,CAAC;AAmBvB,SAAS,KAAK,CAAC,IAAY;IAC1B,OAAO,oBAAoB,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC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C;AACjD,CAAC","sourcesContent":["/** Human-facing completion cards. The persisted context message remains untouched. */\nimport { type Component, stripTerminalSequences, truncateToWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { MessageRenderOptions } from \"../../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../../core/messages.ts\";\nimport { readVersionedTask } from \"../../../core/tasks/codec.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport type { TaskFact, TaskStatus } from \"../../../core/tasks/types.ts\";\nimport { type StatusMarkerColor, statusMarker } from \"../../../modes/interactive/components/status-marker.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport { FramedComponent } from \"../../../modes/interactive/tool-view/style.ts\";\nimport { sanitizeBinaryOutput } from \"../../../utils/shell.ts\";\nimport { statusName } from \"./task-view.ts\";\n\nconst SOURCE_LIMIT = 64 * 1024;\nconst CARD_ROWS = 128;\nconst OUTPUT_ROWS = 20;\ninterface CompletionView {\n\tlabel?: string;\n\ttitle?: string;\n\tduration?: string;\n\tstatus?: TaskStatus;\n\tid?: string;\n\tinput?: { label: string; text: string };\n\tfacts: TaskFact[];\n\tpath?: string;\n\tdiagnostic?: string;\n\t/** Undefined for an unreadable message, whose saved content is shown instead. */\n\toutput?: string;\n\t/** A report previews its beginning; a log previews its end. */\n\treport?: boolean;\n\tbody: string;\n\ttruncated: boolean;\n}\n\nfunction clean(text: string): string {\n\treturn sanitizeBinaryOutput(stripTerminalSequences(text)).replace(/\\r\\n?/g, \"\\n\");\n}\n\nfunction savedText(message: CustomMessage<unknown>): { text: string; clipped: boolean } {\n\t// 64K is a UTF-16 code-unit display budget, not a UTF-8 byte promise; the block\n\t// cap bounds iteration itself so many empty/non-text blocks cannot spin here.\n\tconst MAX_SOURCE_BLOCKS = 256;\n\tconst content = message.content;\n\tlet text = \"\";\n\tlet clipped = false;\n\tif (typeof content === \"string\") {\n\t\ttext = content.slice(0, SOURCE_LIMIT);\n\t\tclipped = content.length > SOURCE_LIMIT;\n\t} else if (Array.isArray(content)) {\n\t\tlet visited = 0;\n\t\tfor (const block of content) {\n\t\t\tif (++visited > MAX_SOURCE_BLOCKS) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!block || block.type !== \"text\" || typeof block.text !== \"string\") continue;\n\t\t\tconst next = `${text ? \"\\n\" : \"\"}${block.text.slice(0, SOURCE_LIMIT + 1)}`;\n\t\t\tconst remaining = SOURCE_LIMIT - text.length;\n\t\t\ttext += next.slice(0, remaining);\n\t\t\tif (next.length > remaining || block.text.length > SOURCE_LIMIT) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn { text: clean(text), clipped };\n}\n\nfunction completionView(message: CustomMessage<unknown>): CompletionView {\n\tconst task = readVersionedTask(message.details);\n\tif (!task) {\n\t\tconst { text, clipped } = savedText(message);\n\t\treturn { body: text, truncated: clipped, facts: [] };\n\t}\n\treturn {\n\t\tlabel: clean(task.label),\n\t\ttitle: clean(task.title),\n\t\tduration: runtimeLabel(task),\n\t\tstatus: task.status,\n\t\tid: clean(task.id),\n\t\tinput: task.input && { label: clean(task.input.label), text: clean(task.input.text) },\n\t\tfacts: (task.facts ?? []).map(([label, value]) => [clean(label), clean(value)]),\n\t\tpath: task.outputPath === undefined ? undefined : clean(task.outputPath),\n\t\tdiagnostic: task.error === undefined ? undefined : clean(task.error),\n\t\toutput: clean(task.result?.text ?? \"\"),\n\t\treport: task.output === \"report\",\n\t\tbody: \"\",\n\t\ttruncated: task.result?.truncated === true || task.input?.truncated === true,\n\t};\n}\n\nfunction color(status: string | undefined): StatusMarkerColor {\n\treturn status === undefined ? \"muted\" : statusMarker(status).color;\n}\nfunction shortId(id: string): string {\n\treturn id.replace(/^(.+)-([0-9a-f]{8})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, \"$1-$2\");\n}\n\nclass CompletionCard implements Component {\n\tprivate readonly view: CompletionView;\n\tprivate readonly options: MessageRenderOptions;\n\tprivate readonly theme: Theme;\n\tconstructor(view: CompletionView, options: MessageRenderOptions, theme: Theme) {\n\t\tthis.view = view;\n\t\tthis.options = options;\n\t\tthis.theme = theme;\n\t}\n\tinvalidate(): void {}\n\trender(width: number): string[] {\n\t\tif (width < 1) return [];\n\t\tconst chrome = new FramedComponent(\n\t\t\t{ render: (contentWidth) => this.renderContent(contentWidth), invalidate() {} },\n\t\t\t\"header\",\n\t\t\t() => color(this.view.status),\n\t\t);\n\t\t// The gutter reserves its own cells; clip defensively for one-cell terminals.\n\t\treturn chrome.render(width).map((line) => truncateToWidth(line, width, \"\"));\n\t}\n\tprivate renderContent(width: number): string[] {\n\t\t// The chrome clamps to ≥1 already; keep the padding arithmetic safe regardless.\n\t\tif (!Number.isFinite(width) || width < 1) return [];\n\t\tconst view = this.view;\n\t\tconst theme = this.theme;\n\t\tconst options = this.options;\n\t\t// The native dot/rail replaces the default one-cell custom-message inset.\n\t\t// Additional configured padding stays inside the chrome, never shifting the dot.\n\t\tconst padding = Math.min(Math.max(0, Math.floor(options.outputPad || 0) - 1), Math.floor((width - 1) / 2));\n\t\tconst inner = width - padding * 2;\n\t\tconst indent = inner >= 3 ? \" \" : \"\";\n\t\tconst bodyWidth = Math.max(1, inner - indent.length);\n\t\tconst lines: string[] = [];\n\t\tconst status = view.status ? statusName(view.status) : \"Result received\";\n\t\tlines.push(\n\t\t\t`${theme.fg(\"toolTitle\", theme.bold(view.label ?? \"Notification\"))}${theme.fg(\"muted\", ` · Background ${status.toLowerCase()}${view.duration ? ` · ${view.duration}` : \"\"}`)}${view.id ? theme.fg(\"dim\", ` · ${shortId(view.id)}`) : \"\"}`,\n\t\t);\n\t\tconst summary = view.title?.split(\"\\n\").find((line) => line.trim()) ?? view.title;\n\t\tif (!options.expanded) {\n\t\t\tif (summary) lines.push(theme.fg(\"toolOutput\", summary));\n\t\t\tif (view.diagnostic) lines.push(theme.fg(color(view.status), view.diagnostic));\n\t\t} else {\n\t\t\tif (view.truncated) {\n\t\t\t\tlines.push(theme.fg(\"warning\", \"The saved result is truncated; this is not the complete original output.\"));\n\t\t\t}\n\t\t\tconst section = (title: string, text: string, limit: number, tail = false, error = false) => {\n\t\t\t\tlines.push(\"\", theme.fg(\"muted\", theme.bold(title)));\n\t\t\t\tconst rendered = wrapTextWithAnsi(text, bodyWidth).map((line) =>\n\t\t\t\t\ttheme.fg(error ? \"error\" : \"toolOutput\", line),\n\t\t\t\t);\n\t\t\t\tconst omitted = Math.max(0, rendered.length - limit);\n\t\t\t\tconst selected = tail ? rendered.slice(-limit) : rendered.slice(0, limit);\n\t\t\t\tif (tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} earlier display lines omitted`));\n\t\t\t\tfor (const line of selected) lines.push(indent + line);\n\t\t\t\tif (!tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} more display lines omitted`));\n\t\t\t};\n\t\t\tif (view.output === undefined) section(\"Details\", view.body || \"No text result.\", 36);\n\t\t\telse {\n\t\t\t\tif (view.input) section(view.input.label, view.input.text, 8);\n\t\t\t\telse if (view.title) section(\"Task\", view.title, 4);\n\t\t\t\tif (view.facts.length) {\n\t\t\t\t\tconst width = Math.max(...view.facts.map(([label]) => label.length)) + 1;\n\t\t\t\t\tsection(\"Details\", view.facts.map(([label, value]) => `${label.padEnd(width)}${value}`).join(\"\\n\"), 8);\n\t\t\t\t}\n\t\t\t\tsection(\n\t\t\t\t\tview.status === \"failed\" || view.status === \"timeout\" ? \"Error\" : \"Result\",\n\t\t\t\t\tview.diagnostic ?? status,\n\t\t\t\t\t4,\n\t\t\t\t\tfalse,\n\t\t\t\t\tview.status === \"failed\",\n\t\t\t\t);\n\t\t\t\tsection(\"Output\", !view.output.trim() ? \"No output.\" : view.output, OUTPUT_ROWS, !view.report);\n\t\t\t\tif (view.path) section(\"Log\", view.path, 4);\n\t\t\t}\n\t\t\tif (view.id) {\n\t\t\t\tlines.push(\"\", ...wrapTextWithAnsi(`Task ID: ${view.id}`, inner).map((line) => theme.fg(\"dim\", line)));\n\t\t\t}\n\t\t\tlines.push(theme.fg(\"dim\", \"Preview of the saved result.\"));\n\t\t}\n\t\tconst bounded =\n\t\t\tlines.length > CARD_ROWS\n\t\t\t\t? [\n\t\t\t\t\t\t...lines.slice(0, CARD_ROWS - 1),\n\t\t\t\t\t\ttheme.fg(\"dim\", \"… card shortened; use tasks read for retained output\"),\n\t\t\t\t\t]\n\t\t\t\t: lines;\n\t\treturn bounded.map((line) => \" \".repeat(padding) + truncateToWidth(line, inner, \"…\") + \" \".repeat(padding));\n\t}\n}\n\n/** Always return a compact, replay-safe component, including for unknown historical formats. */\nexport function renderTaskCompletion(\n\tmessage: CustomMessage<unknown>,\n\toptions: MessageRenderOptions,\n\ttheme: Theme,\n): Component {\n\tlet view: CompletionView;\n\ttry {\n\t\tview = completionView(message);\n\t} catch {\n\t\tview = {\n\t\t\tbody: \"The saved notification could not be interpreted. Its original message remains in session history.\",\n\t\t\ttruncated: false,\n\t\t\tfacts: [],\n\t\t};\n\t}\n\treturn new CompletionCard(view, options, theme);\n}\n"]}
1
+ {"version":3,"file":"completion-render.js","sourceRoot":"","sources":["../../../../src/extensions/tasks/ui/completion-render.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAAkB,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/B,MAAM,SAAS,GAAG,GAAG,CAAC;A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/B,OAA6B,EAC7B,KAAY;IAEZ,IAAI,IAAoB,CAAC;IACzB,IAAI,CAAC;QACJ,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,IAAI,GAAG;YACN,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,mGAAmG;YACzG,SAAS,EAAE,KAAK;SAChB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/** Human-facing completion cards. The persisted context message remains untouched. */\nimport { type Component, truncateToWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { MessageRenderOptions } from \"../../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../../core/messages.ts\";\nimport { readVersionedTask } from \"../../../core/tasks/codec.ts\";\nimport { runtimeLabel } from \"../../../core/tasks/format.ts\";\nimport type { TaskFact, TaskStatus } from \"../../../core/tasks/types.ts\";\nimport type { Theme } from \"../../../modes/interactive/theme/theme.ts\";\nimport { FramedComponent } from \"../../../modes/interactive/tool-view/style.ts\";\nimport { statusName, statusView } from \"./status.ts\";\nimport { cleanTaskText } from \"./text.ts\";\n\nconst SOURCE_LIMIT = 64 * 1024;\nconst CARD_ROWS = 128;\nconst OUTPUT_ROWS = 20;\n/** A persisted task completion, or the saved text of a message that is unreadable or from an older format. */\ntype CompletionView =\n\t| {\n\t\t\tkind: \"task\";\n\t\t\tlabel: string;\n\t\t\ttitle: string;\n\t\t\tduration: string;\n\t\t\tstatus: TaskStatus;\n\t\t\tid: string;\n\t\t\tinput?: { label: string; text: string };\n\t\t\tfacts: TaskFact[];\n\t\t\tpath?: string;\n\t\t\tdiagnostic?: string;\n\t\t\toutput: string;\n\t\t\t/** A report previews its beginning; a log previews its end. */\n\t\t\treport: boolean;\n\t\t\ttruncated: boolean;\n\t }\n\t| { kind: \"saved\"; body: string; truncated: boolean };\n\nfunction savedText(message: CustomMessage<unknown>): { text: string; clipped: boolean } {\n\t// 64K is a UTF-16 code-unit display budget, not a UTF-8 byte promise; the block\n\t// cap bounds iteration itself so many empty/non-text blocks cannot spin here.\n\tconst MAX_SOURCE_BLOCKS = 256;\n\tconst content = message.content;\n\tlet text = \"\";\n\tlet clipped = false;\n\tif (typeof content === \"string\") {\n\t\ttext = content.slice(0, SOURCE_LIMIT);\n\t\tclipped = content.length > SOURCE_LIMIT;\n\t} else if (Array.isArray(content)) {\n\t\tlet visited = 0;\n\t\tfor (const block of content) {\n\t\t\tif (++visited > MAX_SOURCE_BLOCKS) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!block || block.type !== \"text\" || typeof block.text !== \"string\") continue;\n\t\t\tconst next = `${text ? \"\\n\" : \"\"}${block.text.slice(0, SOURCE_LIMIT + 1)}`;\n\t\t\tconst remaining = SOURCE_LIMIT - text.length;\n\t\t\ttext += next.slice(0, remaining);\n\t\t\tif (next.length > remaining || block.text.length > SOURCE_LIMIT) {\n\t\t\t\tclipped = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn { text: cleanTaskText(text), clipped };\n}\n\nfunction completionView(message: CustomMessage<unknown>): CompletionView {\n\tconst task = readVersionedTask(message.details);\n\tif (!task) {\n\t\tconst { text, clipped } = savedText(message);\n\t\treturn { kind: \"saved\", body: text, truncated: clipped };\n\t}\n\treturn {\n\t\tkind: \"task\",\n\t\tlabel: cleanTaskText(task.label),\n\t\ttitle: cleanTaskText(task.title),\n\t\tduration: runtimeLabel(task),\n\t\tstatus: task.status,\n\t\tid: cleanTaskText(task.id),\n\t\tinput: task.input && { label: cleanTaskText(task.input.label), text: cleanTaskText(task.input.text) },\n\t\tfacts: (task.facts ?? []).map(([label, value]) => [cleanTaskText(label), cleanTaskText(value)]),\n\t\tpath: task.outputPath === undefined ? undefined : cleanTaskText(task.outputPath),\n\t\tdiagnostic: task.error === undefined ? undefined : cleanTaskText(task.error),\n\t\toutput: cleanTaskText(task.result?.text ?? \"\"),\n\t\treport: task.output === \"report\",\n\t\ttruncated: task.result?.truncated === true || task.input?.truncated === true,\n\t};\n}\n\nfunction shortId(id: string): string {\n\treturn id.replace(/^(.+)-([0-9a-f]{8})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, \"$1-$2\");\n}\n\nclass CompletionCard implements Component {\n\tprivate readonly view: CompletionView;\n\tprivate readonly options: MessageRenderOptions;\n\tprivate readonly theme: Theme;\n\tconstructor(view: CompletionView, options: MessageRenderOptions, theme: Theme) {\n\t\tthis.view = view;\n\t\tthis.options = options;\n\t\tthis.theme = theme;\n\t}\n\tinvalidate(): void {}\n\trender(width: number): string[] {\n\t\tif (width < 1) return [];\n\t\tconst chrome = new FramedComponent(\n\t\t\t{ render: (contentWidth) => this.renderContent(contentWidth), invalidate() {} },\n\t\t\t\"header\",\n\t\t\t() => (this.view.kind === \"task\" ? statusView(this.view.status).color : \"muted\"),\n\t\t);\n\t\t// The gutter reserves its own cells; clip defensively for one-cell terminals.\n\t\treturn chrome.render(width).map((line) => truncateToWidth(line, width, \"\"));\n\t}\n\tprivate renderContent(width: number): string[] {\n\t\t// The chrome clamps to ≥1 already; keep the padding arithmetic safe regardless.\n\t\tif (!Number.isFinite(width) || width < 1) return [];\n\t\tconst view = this.view;\n\t\tconst theme = this.theme;\n\t\tconst options = this.options;\n\t\t// The native dot/rail replaces the default one-cell custom-message inset.\n\t\t// Additional configured padding stays inside the chrome, never shifting the dot.\n\t\tconst padding = Math.min(Math.max(0, Math.floor(options.outputPad || 0) - 1), Math.floor((width - 1) / 2));\n\t\tconst inner = width - padding * 2;\n\t\tconst indent = inner >= 3 ? \" \" : \"\";\n\t\tconst bodyWidth = Math.max(1, inner - indent.length);\n\t\tconst lines: string[] = [];\n\t\tconst status = view.kind === \"task\" ? statusName(view.status) : \"Result received\";\n\t\tconst label = view.kind === \"task\" ? view.label : \"Notification\";\n\t\tconst duration = view.kind === \"task\" && view.duration ? ` · ${view.duration}` : \"\";\n\t\tconst id = view.kind === \"task\" ? view.id : \"\";\n\t\tlines.push(\n\t\t\t`${theme.fg(\"toolTitle\", theme.bold(label))}${theme.fg(\"muted\", ` · Background ${status.toLowerCase()}${duration}`)}${id ? theme.fg(\"dim\", ` · ${shortId(id)}`) : \"\"}`,\n\t\t);\n\t\tif (!options.expanded) {\n\t\t\tif (view.kind === \"task\") {\n\t\t\t\tconst summary = view.title.split(\"\\n\").find((line) => line.trim()) ?? view.title;\n\t\t\t\tif (summary) lines.push(theme.fg(\"toolOutput\", summary));\n\t\t\t\tif (view.diagnostic) lines.push(theme.fg(statusView(view.status).color, view.diagnostic));\n\t\t\t}\n\t\t} else {\n\t\t\tif (view.truncated) {\n\t\t\t\tlines.push(theme.fg(\"warning\", \"The saved result is truncated; this is not the complete original output.\"));\n\t\t\t}\n\t\t\tconst section = (title: string, text: string, limit: number, tail = false, error = false) => {\n\t\t\t\tlines.push(\"\", theme.fg(\"muted\", theme.bold(title)));\n\t\t\t\tconst rendered = wrapTextWithAnsi(text, bodyWidth).map((line) =>\n\t\t\t\t\ttheme.fg(error ? \"error\" : \"toolOutput\", line),\n\t\t\t\t);\n\t\t\t\tconst omitted = Math.max(0, rendered.length - limit);\n\t\t\t\tconst selected = tail ? rendered.slice(-limit) : rendered.slice(0, limit);\n\t\t\t\tif (tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} earlier display lines omitted`));\n\t\t\t\tfor (const line of selected) lines.push(indent + line);\n\t\t\t\tif (!tail && omitted) lines.push(theme.fg(\"dim\", `${indent}… ${omitted} more display lines omitted`));\n\t\t\t};\n\t\t\tif (view.kind === \"saved\") section(\"Details\", view.body || \"No text result.\", 36);\n\t\t\telse {\n\t\t\t\tif (view.input) section(view.input.label, view.input.text, 8);\n\t\t\t\telse if (view.title) section(\"Task\", view.title, 4);\n\t\t\t\tif (view.facts.length) {\n\t\t\t\t\tconst width = Math.max(...view.facts.map(([label]) => label.length)) + 1;\n\t\t\t\t\tsection(\"Details\", view.facts.map(([label, value]) => `${label.padEnd(width)}${value}`).join(\"\\n\"), 8);\n\t\t\t\t}\n\t\t\t\tsection(\n\t\t\t\t\tview.status === \"failed\" || view.status === \"timeout\" ? \"Error\" : \"Result\",\n\t\t\t\t\tview.diagnostic ?? status,\n\t\t\t\t\t4,\n\t\t\t\t\tfalse,\n\t\t\t\t\tview.status === \"failed\",\n\t\t\t\t);\n\t\t\t\tsection(\"Output\", !view.output.trim() ? \"No output.\" : view.output, OUTPUT_ROWS, !view.report);\n\t\t\t\tif (view.path) section(\"Log\", view.path, 4);\n\t\t\t}\n\t\t\tif (id) {\n\t\t\t\tlines.push(\"\", ...wrapTextWithAnsi(`Task ID: ${id}`, inner).map((line) => theme.fg(\"dim\", line)));\n\t\t\t}\n\t\t\tlines.push(theme.fg(\"dim\", \"Preview of the saved result.\"));\n\t\t}\n\t\tconst bounded =\n\t\t\tlines.length > CARD_ROWS\n\t\t\t\t? [\n\t\t\t\t\t\t...lines.slice(0, CARD_ROWS - 1),\n\t\t\t\t\t\ttheme.fg(\"dim\", \"… card shortened; use tasks read for retained output\"),\n\t\t\t\t\t]\n\t\t\t\t: lines;\n\t\treturn bounded.map((line) => \" \".repeat(padding) + truncateToWidth(line, inner, \"…\") + \" \".repeat(padding));\n\t}\n}\n\n/** Always return a compact, replay-safe component, including for unknown historical formats. */\nexport function renderTaskCompletion(\n\tmessage: CustomMessage<unknown>,\n\toptions: MessageRenderOptions,\n\ttheme: Theme,\n): Component {\n\tlet view: CompletionView;\n\ttry {\n\t\tview = completionView(message);\n\t} catch {\n\t\tview = {\n\t\t\tkind: \"saved\",\n\t\t\tbody: \"The saved notification could not be interpreted. Its original message remains in session history.\",\n\t\t\ttruncated: false,\n\t\t};\n\t}\n\treturn new CompletionCard(view, options, theme);\n}\n"]}
@@ -2,8 +2,7 @@ import type { AppKeybinding, KeybindingsManager } from "../../../core/keybinding
2
2
  import type { Theme } from "../../../modes/interactive/theme/theme.ts";
3
3
  import type { TaskInspector } from "./inspector.ts";
4
4
  import type { TaskList } from "./list.ts";
5
- import type { TaskSelection, TasksTab } from "./model.ts";
6
- import type { TaskViewport } from "./viewport.ts";
5
+ import { type PanelFocus, type PanelMode, type TaskSelection, type TasksTab } from "./model.ts";
7
6
  export interface TaskHit {
8
7
  x: number;
9
8
  y: number;
@@ -29,12 +28,13 @@ interface LayoutOptions {
29
28
  selection: TaskSelection;
30
29
  inspector: TaskInspector;
31
30
  list: TaskList;
32
- focus: "list" | "inspector";
33
- searchLine?: (width: number) => string;
34
- pendingKill?: string;
31
+ focus: PanelFocus;
32
+ mode: PanelMode;
33
+ /** Renders the search input line; shown only in search mode. */
34
+ searchLine: (width: number) => string;
35
35
  feedback?: string;
36
- help?: TaskViewport;
37
- canDetach: boolean;
36
+ /** Whether the host would move this task to the background now. */
37
+ canDetach: (id: string) => boolean;
38
38
  }
39
39
  /** Cell geometry and mouse targets are produced together, so resize cannot separate them. */
40
40
  export declare function renderTasksLayout(options: LayoutOptions): TasksLayout;
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/extensions/tasks/ui/layout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAc,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAMlG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,WAAW,OAAO;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MA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