@bastani/atomic 0.10.10 → 0.10.11-alpha.2

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 (402) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +1 -1
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +11 -13
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +9 -9
  9. package/dist/_shared/mode-shared-2QJSCUM6.js +55 -18
  10. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  12. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  13. package/dist/_shared/{sdk-RRLVN7ER.js → sdk-IQMULKFU.js} +2962 -470
  14. package/dist/_shared/sdk-IQMULKFU.js.map +1 -0
  15. package/dist/_shared/session-data-AHTU7IS6.js +4 -4
  16. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  17. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  18. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  19. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  20. package/dist/_shared/{startup-0-0-4VG2G44V.js → startup-0-0-3IXNMFM2.js} +482 -53
  21. package/dist/_shared/startup-0-0-3IXNMFM2.js.map +1 -0
  22. package/dist/_shared/{startup-0-1-XTIL65D4.js → startup-0-1-7T2IAE7J.js} +121 -251
  23. package/dist/_shared/startup-0-1-7T2IAE7J.js.map +1 -0
  24. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +293 -10
  25. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  26. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  27. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  28. package/dist/_shared/startup-0-4-ZMJV547D.js +6 -6
  29. package/dist/_shared/{startup-0-5-FD2P735I.js → startup-0-5-YDW47QX6.js} +29 -71
  30. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -0
  31. package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
  32. package/dist/_shared/startup-12-0-55AAXBJZ.js +4 -4
  33. package/dist/_shared/startup-14-0-MLX36RBG.js +6 -6
  34. package/dist/_shared/startup-15-0-YUKGAC63.js +34 -10
  35. package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
  36. package/dist/_shared/startup-15-1-4S7FLMNG.js +10 -9
  37. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  38. package/dist/_shared/startup-8-0-34CBHPZH.js +421 -84
  39. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  40. package/dist/_shared/{startup-8-1-4KANEHRA.js → startup-8-1-X32CYSXB.js} +1291 -722
  41. package/dist/_shared/startup-8-1-X32CYSXB.js.map +1 -0
  42. package/dist/_shared/storage-command-7MGXLJGZ.js +17 -9
  43. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  44. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  45. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  46. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  47. package/dist/builtin/intercom/CHANGELOG.md +29 -0
  48. package/dist/builtin/intercom/broker/broker.bundle.mjs +1138 -384
  49. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +103 -24
  50. package/dist/builtin/intercom/broker/multinode-router.ts +42 -21
  51. package/dist/builtin/intercom/broker/multinode-state-store.ts +22 -1
  52. package/dist/builtin/intercom/broker/open-broker-state.ts +82 -31
  53. package/dist/builtin/intercom/broker/paths.ts +8 -4
  54. package/dist/builtin/intercom/broker/released-asker-remote-replies.ts +18 -6
  55. package/dist/builtin/intercom/broker/sql-add-column.ts +4 -1
  56. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +65 -44
  57. package/dist/builtin/intercom/broker/sql-held-send-store.ts +11 -3
  58. package/dist/builtin/intercom/broker/sql-known-session-store.ts +24 -12
  59. package/dist/builtin/intercom/broker/sql-lease-store.ts +386 -65
  60. package/dist/builtin/intercom/broker/sql-outbox-store.ts +462 -130
  61. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +20 -9
  62. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +14 -6
  63. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +27 -11
  64. package/dist/builtin/intercom/broker/sql-schema.ts +198 -5
  65. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +97 -34
  66. package/dist/builtin/intercom/index.bundle.mjs +11 -8
  67. package/dist/builtin/intercom/package.json +1 -1
  68. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  69. package/dist/builtin/mcp/package.json +1 -1
  70. package/dist/builtin/subagents/CHANGELOG.md +18 -0
  71. package/dist/builtin/subagents/package.json +1 -1
  72. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +1 -1
  73. package/dist/builtin/subagents/src/extension/index.bundle.mjs +62 -23
  74. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  75. package/dist/builtin/web-access/package.json +1 -1
  76. package/dist/cli/args.js +2 -2
  77. package/dist/cli/auth-cli.code.js +6 -6
  78. package/dist/cli/auth-cli.impl.js +3 -3
  79. package/dist/cli/auth-cli.js +3 -3
  80. package/dist/cli/blueprint-command.code.js +4 -4
  81. package/dist/cli/blueprint-command.impl.js +3 -3
  82. package/dist/cli/blueprint-command.js +3 -3
  83. package/dist/cli/intercom-command.code.js +3 -3
  84. package/dist/cli/intercom-command.impl.js +3 -3
  85. package/dist/cli/intercom-command.js +3 -3
  86. package/dist/cli/list-models.code.js +2 -2
  87. package/dist/cli/list-models.impl.js +3 -3
  88. package/dist/cli/list-models.js +3 -3
  89. package/dist/cli/session-picker.code.js +2 -2
  90. package/dist/cli/session-picker.impl.js +3 -3
  91. package/dist/cli/session-picker.js +3 -3
  92. package/dist/cli/startup-ui.code.js +2 -2
  93. package/dist/cli/startup-ui.impl.js +3 -3
  94. package/dist/cli/startup-ui.js +3 -3
  95. package/dist/cli/storage-command.impl.js +3 -3
  96. package/dist/cli/storage-command.js +3 -3
  97. package/dist/cli/storage-search-session.code.js +3 -3
  98. package/dist/cli/storage-search-session.impl.js +3 -3
  99. package/dist/cli/storage-search-session.js +3 -3
  100. package/dist/cli/team-command.code.js +3 -3
  101. package/dist/cli/team-command.impl.js +3 -3
  102. package/dist/cli/team-command.js +3 -3
  103. package/dist/cli.js +2 -2
  104. package/dist/core/agent-session-methods.d.ts +3 -0
  105. package/dist/core/agent-session-methods.js.map +1 -1
  106. package/dist/core/agent-session.d.ts +1 -0
  107. package/dist/core/compaction/compactor.d.ts +2 -0
  108. package/dist/core/debug.impl.js +3 -3
  109. package/dist/core/debug.js +3 -3
  110. package/dist/core/export-html/card-projection.code.js +1 -1
  111. package/dist/core/export-html/card-projection.impl.js +3 -3
  112. package/dist/core/export-html/card-projection.js +3 -3
  113. package/dist/core/export-html/index.code.js +2 -2
  114. package/dist/core/export-html/index.impl.js +3 -3
  115. package/dist/core/export-html/index.js +3 -3
  116. package/dist/core/export-html/json-spans.impl.js +3 -3
  117. package/dist/core/export-html/json-spans.js +3 -3
  118. package/dist/core/export-html/oversized-render-inputs.code.js +2 -2
  119. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  120. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  121. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  122. package/dist/core/export-html/tool-renderer.js +3 -3
  123. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  124. package/dist/core/extensions/jiti-loader.js +3 -3
  125. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  126. package/dist/core/extensions/jiti-static-loader.js +3 -3
  127. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  128. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  129. package/dist/core/extensions/loader-host-modules.js +3 -3
  130. package/dist/core/extensions/loader-virtual-modules.js +2 -2
  131. package/dist/core/extensions/runner-context.js +4 -4
  132. package/dist/core/extensions/runner-context.js.map +1 -1
  133. package/dist/core/intercom-broker-control-host.code.js +1 -1
  134. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  135. package/dist/core/intercom-broker-control-host.js +3 -3
  136. package/dist/core/intercom-broker-control.code.js +3 -3
  137. package/dist/core/intercom-broker-control.impl.js +3 -3
  138. package/dist/core/intercom-broker-control.js +3 -3
  139. package/dist/core/model-registry.js +1 -1
  140. package/dist/core/model-resolver-defaults.d.ts +3 -2
  141. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  142. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  143. package/dist/core/package-manager-storage-adapters.js +3 -3
  144. package/dist/core/sdk.code.js +4 -5
  145. package/dist/core/sdk.impl.js +3 -3
  146. package/dist/core/sdk.js +3 -3
  147. package/dist/core/session-manager-core.d.ts +5 -2
  148. package/dist/core/session-manager-core.js +39 -23
  149. package/dist/core/session-manager-core.js.map +1 -1
  150. package/dist/core/session-manager-list.impl.js +3 -3
  151. package/dist/core/session-manager-list.js +3 -3
  152. package/dist/core/session-manager.code.js +3 -3
  153. package/dist/core/session-manager.impl.js +3 -3
  154. package/dist/core/session-manager.js +3 -3
  155. package/dist/core/session-open-markers.js +3 -0
  156. package/dist/core/session-open-markers.js.map +1 -0
  157. package/dist/core/session-storage.code.js +1 -1
  158. package/dist/core/session-storage.impl.js +3 -3
  159. package/dist/core/session-storage.js +3 -3
  160. package/dist/core/storage/added-exports.d.ts +6 -0
  161. package/dist/core/storage/added-exports.js +19 -0
  162. package/dist/core/storage/added-exports.js.map +1 -0
  163. package/dist/core/storage/database.d.ts +53 -0
  164. package/dist/core/storage/database.js.map +1 -1
  165. package/dist/core/storage/fenced-paths.d.ts +47 -0
  166. package/dist/core/storage/fenced-paths.js +53 -0
  167. package/dist/core/storage/fenced-paths.js.map +1 -1
  168. package/dist/core/storage/file-identity.js +31 -2
  169. package/dist/core/storage/file-identity.js.map +1 -1
  170. package/dist/core/storage/index.d.ts +4 -1
  171. package/dist/core/storage/index.js +5 -2
  172. package/dist/core/storage/index.js.map +1 -1
  173. package/dist/core/storage/migrations.d.ts +33 -2
  174. package/dist/core/storage/migrations.js +73 -5
  175. package/dist/core/storage/migrations.js.map +1 -1
  176. package/dist/core/storage/node-sqlite-thread.js +48 -6
  177. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  178. package/dist/core/storage/node-sqlite.js +137 -4
  179. package/dist/core/storage/node-sqlite.js.map +1 -1
  180. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  181. package/dist/core/storage/offline-snapshot-file.js +3 -3
  182. package/dist/core/storage/prefix.d.ts +3 -2
  183. package/dist/core/storage/prefix.js +23 -2
  184. package/dist/core/storage/prefix.js.map +1 -1
  185. package/dist/core/storage/provider.js +2 -2
  186. package/dist/core/storage/schema-catalog.d.ts +120 -0
  187. package/dist/core/storage/schema-catalog.js +351 -0
  188. package/dist/core/storage/schema-catalog.js.map +1 -0
  189. package/dist/core/storage/selection.js +2 -2
  190. package/dist/core/storage/session/branch-fork-source.code.js +47 -25
  191. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  192. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  193. package/dist/core/storage/session/branch-fork-source.js +3 -3
  194. package/dist/core/storage/session/card-view.impl.js +3 -3
  195. package/dist/core/storage/session/card-view.js +3 -3
  196. package/dist/core/storage/session/child-reader.code.js +4 -4
  197. package/dist/core/storage/session/child-reader.impl.js +3 -3
  198. package/dist/core/storage/session/child-reader.js +3 -3
  199. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  200. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  201. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  202. package/dist/core/storage/session/errors.js +1 -1
  203. package/dist/core/storage/session/expanded-child-details.code.js +4 -4
  204. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  205. package/dist/core/storage/session/expanded-child-details.js +3 -3
  206. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  207. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  208. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  209. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  210. package/dist/core/storage/session/fork-row-index.js +3 -3
  211. package/dist/core/storage/session/fork-schema.js +53 -0
  212. package/dist/core/storage/session/fork-schema.js.map +1 -0
  213. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  214. package/dist/core/storage/session/fork-staging.code.js +176 -36
  215. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  216. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  217. package/dist/core/storage/session/fork-staging.js +3 -3
  218. package/dist/core/storage/session/fork-sweep.js +61 -0
  219. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  220. package/dist/core/storage/session/fork-window.code.js +4 -4
  221. package/dist/core/storage/session/fork-window.impl.js +3 -3
  222. package/dist/core/storage/session/fork-window.js +3 -3
  223. package/dist/core/storage/session/history-pages.impl.js +3 -3
  224. package/dist/core/storage/session/history-pages.js +3 -3
  225. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  226. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  227. package/dist/core/storage/session/jsonl-session-store.d.ts +37 -1
  228. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  229. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  230. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  231. package/dist/core/storage/session/memory-session-store.js +3 -3
  232. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  233. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  234. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  235. package/dist/core/storage/session/released-history-files.code.js +3 -3
  236. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  237. package/dist/core/storage/session/released-history-files.js +3 -3
  238. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  239. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  240. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  241. package/dist/core/storage/session/session-resume.impl.js +3 -3
  242. package/dist/core/storage/session/session-resume.js +3 -3
  243. package/dist/core/storage/session/session-search-index.d.ts +5 -0
  244. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  245. package/dist/core/storage/session/snapshot-cut.js +3 -3
  246. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  247. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  248. package/dist/core/storage/session/snapshot-history.js +3 -3
  249. package/dist/core/storage/session/sql-chat-records.d.ts +15 -0
  250. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  251. package/dist/core/storage/session/sql-session-store.d.ts +445 -11
  252. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  253. package/dist/core/storage/session/sql-session-store.js +4 -4
  254. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  255. package/dist/core/storage/session/tree-outline.js +3 -3
  256. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  257. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  258. package/dist/core/storage/session/tree-presentation.js +3 -3
  259. package/dist/core/storage/session/types.d.ts +36 -0
  260. package/dist/core/storage/sqlite-facade.d.ts +54 -6
  261. package/dist/core/storage/sqlite-facade.js +384 -18
  262. package/dist/core/storage/sqlite-facade.js.map +1 -1
  263. package/dist/core/storage/statement-sequence.d.ts +83 -0
  264. package/dist/core/storage/statement-sequence.js +21 -0
  265. package/dist/core/storage/statement-sequence.js.map +1 -1
  266. package/dist/core/storage/storage-status.code.js +1 -1
  267. package/dist/core/storage/storage-status.impl.js +3 -3
  268. package/dist/core/storage/storage-status.js +3 -3
  269. package/dist/core/storage/team.code.js +1 -1
  270. package/dist/core/storage/team.impl.js +3 -3
  271. package/dist/core/storage/team.js +3 -3
  272. package/dist/core/structured-output/index.code.js +1 -1
  273. package/dist/core/structured-output/index.impl.js +3 -3
  274. package/dist/core/structured-output/index.js +3 -3
  275. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  276. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  277. package/dist/core/tasks/task-completion-entry.js +3 -3
  278. package/dist/core/tasks/task-file-history.code.js +4 -4
  279. package/dist/core/tasks/task-file-history.impl.js +3 -3
  280. package/dist/core/tasks/task-file-history.js +3 -3
  281. package/dist/core/tasks/task-reference-archive.code.js +5 -5
  282. package/dist/core/tasks/task-reference-archive.js +3 -3
  283. package/dist/core/tasks/task-reference-identity.js +3 -3
  284. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  285. package/dist/core/tasks/task-reference-stream.js +3 -3
  286. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  287. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  288. package/dist/core/tasks/task-view-source.code.js +1 -1
  289. package/dist/core/tasks/task-view-source.impl.js +3 -3
  290. package/dist/core/tasks/task-view-source.js +3 -3
  291. package/dist/core/tools/bash.d.ts +8 -4
  292. package/dist/core/tools/history-session.d.ts +7 -0
  293. package/dist/core/tools/history-tasks.d.ts +123 -0
  294. package/dist/core/tools/kill.d.ts +5 -2
  295. package/dist/core/tools/powershell.d.ts +2 -2
  296. package/dist/core/tools/read-url.code.js +3 -3
  297. package/dist/core/tools/read-url.impl.js +3 -3
  298. package/dist/core/tools/read-url.js +3 -3
  299. package/dist/core/tools/read.d.ts +12 -2
  300. package/dist/core/tools/resource-selectors.d.ts +2 -0
  301. package/dist/core/tools/search.d.ts +12 -2
  302. package/dist/core/worktree-snapshot/blob-store.d.ts +45 -2
  303. package/dist/core/worktree-snapshot/blob-store.js +228 -60
  304. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  305. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  306. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  307. package/dist/core/worktree-snapshot/errors.js +3 -3
  308. package/dist/core/worktree-snapshot/fork-snapshot-index.js +121 -0
  309. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  310. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  311. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  312. package/dist/extensions/codemode/execute.code.js +3 -3
  313. package/dist/extensions/codemode/execute.impl.js +3 -3
  314. package/dist/extensions/codemode/execute.js +3 -3
  315. package/dist/extensions/codemode/renderer.code.js +2 -2
  316. package/dist/extensions/codemode/renderer.impl.js +3 -3
  317. package/dist/extensions/codemode/renderer.js +3 -3
  318. package/dist/extensions/mcp/cli.code.js +3 -3
  319. package/dist/extensions/mcp/cli.impl.js +3 -3
  320. package/dist/extensions/mcp/cli.js +3 -3
  321. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  322. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  323. package/dist/extensions/mcp/cli.lazy.js +3 -3
  324. package/dist/extensions/mcp/runtime.code.js +1 -1
  325. package/dist/extensions/mcp/runtime.impl.js +3 -3
  326. package/dist/extensions/mcp/runtime.js +3 -3
  327. package/dist/index.js +8 -8
  328. package/dist/main-first-time-setup.code.js +2 -2
  329. package/dist/main-first-time-setup.impl.js +3 -3
  330. package/dist/main-first-time-setup.js +3 -3
  331. package/dist/main.js +1 -1
  332. package/dist/modes/interactive/components/agent-panel.d.ts +1 -0
  333. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  334. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  335. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  336. package/dist/modes/interactive/components/task-inspector.d.ts +2 -0
  337. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  338. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  339. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  340. package/dist/modes/interactive/interactive-mode-helpers.d.ts +2 -2
  341. package/dist/modes/print-mode.js +1 -1
  342. package/dist/modes/rpc/agent-panel-bridge.d.ts +5 -0
  343. package/dist/package-manager-cli.code.js +7 -7
  344. package/dist/package-manager-cli.impl.js +3 -3
  345. package/dist/package-manager-cli.js +3 -3
  346. package/dist/rpc-entry.js +1 -1
  347. package/dist/startup-files.json +1 -1
  348. package/dist/startup-stages/0.js +1 -1
  349. package/dist/startup-stages/1.js +1 -1
  350. package/dist/startup-stages/10.js +1 -1
  351. package/dist/startup-stages/12.js +1 -1
  352. package/dist/startup-stages/2.js +9 -1
  353. package/dist/startup-stages/3.js +1 -6
  354. package/dist/startup-stages/5.js +1 -1
  355. package/dist/startup-stages/7.js +1 -1
  356. package/dist/startup-stages/8.js +2 -2
  357. package/dist/utils/startup-database-spare.code.js +3 -3
  358. package/dist/utils/startup-database-spare.impl.js +3 -3
  359. package/dist/utils/startup-database-spare.js +3 -3
  360. package/dist/utils/tools-manager.code.js +1 -1
  361. package/dist/utils/tools-manager.impl.js +3 -3
  362. package/dist/utils/tools-manager.js +3 -3
  363. package/docs/background-tasks.md +123 -23
  364. package/docs/compaction.md +18 -0
  365. package/docs/docs.json +2 -0
  366. package/docs/environment-variables.md +1 -1
  367. package/docs/getting-started/installation.md +9 -2
  368. package/docs/guides/postgres-pgbouncer.md +346 -0
  369. package/docs/guides/postgres-tuning.md +311 -0
  370. package/docs/guides/resume-on-any-machine.md +2 -2
  371. package/docs/guides.md +2 -0
  372. package/docs/index.md +1 -1
  373. package/docs/libraries/agent-core.md +1 -1
  374. package/docs/libraries/ai.md +2 -2
  375. package/docs/libraries/codemode.md +1 -1
  376. package/docs/libraries/storage-libsql.md +6 -1
  377. package/docs/libraries/storage-postgres.md +11 -6
  378. package/docs/libraries/tui.md +1 -1
  379. package/docs/libraries.md +2 -2
  380. package/docs/programmatic.md +1 -1
  381. package/docs/quickstart.md +1 -1
  382. package/docs/sdk/storage.md +1 -1
  383. package/docs/sdk/web-server.md +1 -3
  384. package/docs/sdk.md +1 -7
  385. package/docs/sessions.md +67 -2
  386. package/docs/settings.md +20 -1
  387. package/docs/skills/authoring.md +1 -1
  388. package/docs/skills.md +79 -6
  389. package/docs/storage.md +305 -14
  390. package/docs/subagents/reference.md +2 -2
  391. package/docs/subagents.md +4 -3
  392. package/docs/tools.md +44 -10
  393. package/docs/windows.md +1 -1
  394. package/package.json +9 -9
  395. package/dist/_shared/sdk-RRLVN7ER.js.map +0 -1
  396. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  397. package/dist/_shared/startup-0-0-4VG2G44V.js.map +0 -1
  398. package/dist/_shared/startup-0-1-XTIL65D4.js.map +0 -1
  399. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  400. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
  401. package/dist/_shared/startup-0-5-FD2P735I.js.map +0 -1
  402. package/dist/_shared/startup-8-1-4KANEHRA.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
  import { __name } from "./rolldown-runtime-BGM3D5V3.js";
2
2
  import { APP_NAME, BUILTIN_PACKAGE_DIR_NAMES, CONFIG_DIR_NAME, ENV_CLEAR_ON_SHRINK, ENV_HARDWARE_CURSOR, ENV_SESSION_DIR, INTERACTIVE_ENGINE_BOOTSTRAP_FLAG, addHostStorageAdapter, canonicalizePath as canonicalizePath$1, createChildProcessEnvironment, flushPersistentCompileCache, formatPathRelativeToCwdOrAbsolute, getAgentConfigPaths, getAgentDir, getAgentDirs, getBinDir, getBlueprintActionsDir, getCwdRelativePath, getEnvValue, getGlobalBlueprintPath, getHomeDir, getProjectBlueprintPath, getProjectConfigPaths, getReadmePath, hostStorageAdapter, isBunBinary, isBunRuntime, isChildProcessExitStatusUnknownError, isLocalPath, markLifecycleTiming, normalizePath, removeOwnedInteractiveEngineBootstrapAsync, resolvePath, shortenHomePath, splitBom, stripBom, waitForChildProcess, writeInteractiveEngineBootstrapAsync } from "./p0-cli-BB45ZQY6.js";
3
- import { BLUEPRINT_CONTEXT_TYPE, BlueprintBuildFailedError, BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError, BlueprintUsesUnsupportedError, CACHE_WARMING_MODES, CompactionConfigError, DEFAULT_BUILTIN_SELECTION_EXTRA_TOOLS, DEFAULT_MAX_BYTES, EditInputError, EditMatchError, EditTargetError, FileToolAbortedError, HostListenerFailures, LONG_LIVED_COMMANDS, MAX_COMMAND_TIMEOUT_SECONDS, Minimatch, RESTART_CANCELLED_MESSAGE, STALE_EXTENSION_CONTEXT_MESSAGE, ShellTimeoutError, SqliteSelectorConnection, SubscriptionChildUnavailableError, SubscriptionClosedError, SubscriptionConfigError, TASK_MARKS, TaskMessageError, TaskMessageTimeoutError, WriteSelectorError, activeToolExecutionStarts, allToolNames, announceBlueprintBuildWaiting, applyBashSessionEnvironment, asyncScope, attachJsonlLineReader, attachLineReader, bindSavedTaskOrigins, blueprintBuildShared, blueprintDigest, canonicalEventBusFor, chatPosition, clearAssignmentIfClosed, clearLockHolder, clearLockHolderAsync, convertBufferWithMarkit, convertFileWithMarkit, createGitEnvironment, defaultToolNamesFor, defineTool, detectSupportedImageMimeTypeFromFile, displayTodoId, entryLines, expandSearchUrl, experimentalToolSamplingProperty, filterSearchOutputByLineRange, formatReadLineRange as formatReadLineRange$1, formatSelectedLines, formatSize, formatTimeoutSeconds as formatTimeoutSeconds$1, formatTodoId, frozenClocks, getManifestFromPackageJson, getTextOutput, getTodoPath, getTodoStatus, getTodoTitle, getTodosDir, getTodosDirLabel, getToolListError, handOverBuildTimings, holdDeprecationWarnings, holdToolsUntilBuilt, hostInputError, invalidArgText, invalidateNativeSearchCache, isBlueprintError, isGitProvisionError, isGitUnavailableError, isPathInside, isReadResourceSelector, isReadableUrlPath, isTodoClosed, isToolModifier, keptTaskHint, linkPath, literalPathLike, loadNativeSearchBinding, longerRunAdvice, mergeReadRanges, nativeModuleProblem, normalizePathLikeInput, normalizeTodoId, noteSavedSeq, openAdapterSelectionDatabase, originalHistoryNote, prepareLockTakeover, projectTrustHandlerRegistered, projectTrustedBeforeExtensions, readLedger, readTaskOutputTail, receiveChatReceipt, recordLockHolder, recordLockHolderAsync, registerCanonicalEventBus, releaseDeprecationWarnings, renderBlueprintContext, renderToolPath, replaceTabs, reportContained, repositoryKey, resolvePhysicalPathAsync, rootKey, savedReadLines, scopedBackgroundTasks, searchPosition, selectExactReadRanges, selectReadRanges, serializeJsonLine, settingsFileNoticeKey, settingsInternals, shortenPath, sleep, sliceHead, snapshotBashSessionEnvironment, sortTodos, spawnHostProcess, splitLineRangeSelector, splitPathLikeGlob, splitReadLineSelector, splitTodosByAssignment, startToolTimer, str, stringEntries, takeOverDeadHolder, takeOverDeadHolderAsync, takeQueuedDeliveryChange, taskResumer, timestamp, toolTimerText, transcriptHeaderLines, truncateHead, truncateLine, updateLedger, validateTodoId, warnDeprecation, withFileMutationQueue, withResolvingFileMutationQueue, workspaceKey } from "./startup-0-0-4VG2G44V.js";
4
- import { EMPTY_OUTPUT_TEXT, HistorySearchPositions, MAX_INDEXED_ENTRY_CHARS, ResumeTimingsRecorder, SEARCH_PART_CHARS, SessionStorageSelectionSchema, TaskElapsedClocks, WorkspaceDriftError, WorkspaceRestoreError, WorkspaceSnapshotError, bindTaskClock, bindTaskClockSource, buildDirectoryTree, buildDirectoryTreeFromOperations, captureRegistrationInvocation, compareCreated, compareFrozen, conflictEntries, convertToLlm, createBranchSummaryMessage, createCustomMessage, diffLines, ensureTool, execCommand, findSessionOpenHolder, findWorkspaceError, formatResumeTimings, invocationExtension, invocationRuntime, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspaceSnapshotError, lifecycleScopeForOwner, normalizeAzureSettings, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseInteractiveEngineMessage, presentTaskError, prewarmModelApi, readConflictUrl, readLocalFileChunks, recordBlueprintStep, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, renderTodoCall, renderTodoResult, resolveInstalledGit, resolveInvocationRuntime, selectReadLinesFromChunks, selectReadLinesFromList, serializeInteractiveEngineFrame, serializeTodoForAgent, serializeTodoListForAgent, sessionPosition, settingsWriteOwner, splitSearchTextParts, startupSourceId, taskClockOf, taskClockRunning, timeCheckoutRestore, unpackIds, unreadablePathError, validateEventSource, validateSubscriptionAdmission, waitResultTail, waitStatus, withoutSearchPosition, writeRenderers } from "./startup-0-1-XTIL65D4.js";
3
+ import { BLUEPRINT_CONTEXT_TYPE, BlueprintBuildFailedError, BlueprintError, BlueprintInvalidError, BlueprintStepFailedError, BlueprintStepTimedOutError, BlueprintUsesUnsupportedError, CACHE_WARMING_MODES, COMMAND_FOREGROUND_BUDGET_MS, CompactionConfigError, DEFAULT_BUILTIN_SELECTION_EXTRA_TOOLS, DEFAULT_MAX_BYTES, EditInputError, EditMatchError, EditTargetError, FileToolAbortedError, HostListenerFailures, LONG_LIVED_COMMANDS, Minimatch, RESTART_CANCELLED_MESSAGE, STALE_EXTENSION_CONTEXT_MESSAGE, ShellTimeoutError, SqliteSelectorConnection, SubscriptionChildUnavailableError, SubscriptionClosedError, SubscriptionConfigError, TASK_MARKS, TaskMessageError, TaskMessageTimeoutError, WriteSelectorError, activeToolExecutionStarts, allToolNames, announceBlueprintBuildWaiting, applyBashSessionEnvironment, asyncScope, attachJsonlLineReader, attachLineReader, bindSavedTaskOrigins, blueprintBuildShared, blueprintDigest, canonicalEventBusFor, chatPosition, clearAssignmentIfClosed, clearLockHolder, clearLockHolderAsync, convertBufferWithMarkit, convertFileWithMarkit, createGitEnvironment, defaultToolNamesFor, defineTool, detectSupportedImageMimeTypeFromFile, displayTodoId, entryLines, expandSearchUrl, experimentalToolSamplingProperty, filterSearchOutputByLineRange, formatReadLineRange as formatReadLineRange$1, formatSelectedLines, formatSize, formatTimeoutSeconds as formatTimeoutSeconds$1, formatTodoId, frozenClocks, getManifestFromPackageJson, getTextOutput, getTodoPath, getTodoStatus, getTodoTitle, getTodosDir, getTodosDirLabel, getToolListError, handOverBuildTimings, holdDeprecationWarnings, holdToolsUntilBuilt, hostInputError, invalidArgText, invalidateNativeSearchCache, isBlueprintError, isGitProvisionError, isGitUnavailableError, isPathInside, isReadResourceSelector, isReadableUrlPath, isTodoClosed, isToolModifier, keptTaskHint, linkPath, literalPathLike, loadNativeSearchBinding, mergeReadRanges, nativeModuleProblem, normalizePathLikeInput, normalizeTodoId, noteSavedSeq, openAdapterSelectionDatabase, originalHistoryNote, prepareLockTakeover, projectTrustHandlerRegistered, projectTrustedBeforeExtensions, readLedger, readTaskOutputTail, receiveChatReceipt, recordLockHolder, recordLockHolderAsync, registerCanonicalEventBus, releaseDeprecationWarnings, renderBlueprintContext, renderToolPath, replaceTabs, reportContained, repositoryKey, resolvePhysicalPathAsync, rootKey, savedReadLines, scopedBackgroundTasks, searchPosition, selectExactReadRanges, selectReadRanges, serializeJsonLine, settingsFileNoticeKey, settingsInternals, shortenPath, sleep, sliceHead, snapshotBashSessionEnvironment, sortTodos, spawnHostProcess, splitLineRangeSelector, splitPathLikeGlob, splitReadLineSelector, splitTodosByAssignment, startShellDeadline, startToolTimer, str, stringEntries, takeOverDeadHolder, takeOverDeadHolderAsync, takeQueuedDeliveryChange, taskResumer, timestamp, toolTimerText, transcriptHeaderLines, truncateHead, truncateLine, updateLedger, validateTodoId, warnDeprecation, withFileMutationQueue, withResolvingFileMutationQueue, workspaceKey } from "./startup-0-0-3IXNMFM2.js";
4
+ import { EMPTY_OUTPUT_TEXT, HistorySearchPositions, MAX_INDEXED_ENTRY_CHARS, ResumeTimingsRecorder, SEARCH_PART_CHARS, SessionStorageSelectionSchema, TaskElapsedClocks, TaskToolError, WorkspaceDriftError, WorkspaceRestoreError, WorkspaceSnapshotError, bindTaskClock, bindTaskClockSource, buildDirectoryTree, buildDirectoryTreeFromOperations, cancelReceiptSentence, captureRegistrationInvocation, compareCreated, compareFrozen, conflictEntries, convertToLlm, createBranchSummaryMessage, createCustomMessage, diffLines, ensureTool, execCommand, findWorkspaceError, formatResumeTimings, invocationExtension, invocationRuntime, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspaceSnapshotError, lifecycleScopeForOwner, normalizeAzureSettings, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseInteractiveEngineMessage, parseSkillUri, presentTaskError, prewarmModelApi, readConflictUrl, readLocalFileChunks, recordBlueprintStep, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, renderTodoCall, renderTodoResult, resolveInstalledGit, resolveInvocationRuntime, selectReadLinesFromChunks, selectReadLinesFromList, serializeInteractiveEngineFrame, serializeTodoForAgent, serializeTodoListForAgent, sessionPosition, settingsWriteOwner, splitSearchTextParts, startupSourceId, taskClockOf, taskClockRunning, timeCheckoutRestore, unpackIds, unreadablePathError, validateEventSource, validateSubscriptionAdmission, waitResultTail, waitStatus, withoutSearchPosition, writeRenderers } from "./startup-0-1-7T2IAE7J.js";
5
5
  import { CodeHighlighter, FS_WATCH_RETRY_DELAY_MS, applyEarlyInputChunk, closeWatcher, getLanguageFromPath, graphemeAt, highlightCode, isSafeFsWatchPathError, keepStartupDialogDraft, migrateKeybindingsConfig, parenthesizedKeyHint, recordTimingLines, sanitizeTerminalText, singleLineDisplayText, slashCommandHint, terminalDisplayText, theme, watchWithErrorHandlerAsync, withEarlyInputHeldForStartupDialog } from "./p2-shell-main-B2WIALFD.js";
6
6
  import { parseJsonFileContent } from "./p1-shared-RG5I5LJ6.js";
7
7
  import { ProjectTrustStore, failureDebugFields, hasProjectTrustInputs, hasProjectTrustInputsAsync, inLockTurn, matchesOnSameLineCI, redactUrlCredentials, releaseLock, releaseLockSync, renameReplacing, renameReplacingAsync, renameWithRetry, reportDebugAsync, waitForLock, waitForLockSync } from "./p1b-elig-ENCUPKKJ.js";
8
- import { FILE_HEADERS_ONLY, InteractiveEngineMonitor, ModelConfig, RpcTerminalDrain, SESSIONS_STORAGE_ENV, STORAGE_ENV, TodoParams, addShellOutputPreview, assertSessionOpen, bindTaskChatPage, captureTaskChatFile, chatPageRequest, createTwoFilesPatch, drainSessionWork, dropWrongTypedSettings, estimateTokens, formatPatch, formatTruncationNotice, formatWorkingElapsed, getNativeMcpToolIdentity, getPowerShellConfigAsync, getShellConfigAsync, getShellEnvAsync, hasCallingSessionWork, invalidSettingMessage, isPowerShellAvailable, isResumePreconditionError, isTodoOperationError, killChildProcessTree, loadTaskOwnTranscriptEntries, markNativeMcpToolDefinition, processSharedStorageSelection, processSharedStorageSelectionAsync, processStorageEnvironment, rebuildShellWaitResult, selectProcessStorage, selectProcessStorageSteps, sessionGenerationClosing, sessionLifetime, spawnShellProcess, structuredPatch, taskChatPage, taskExtensionStatuses, taskOwnTranscriptEntries, taskTranscriptSource, trackDetachedChildPid, trackDetachedChildProcess, trackSessionWork, untrackDetachedChildPid, watchTaskExtensionStatuses, wrapToolDefinition } from "./startup-0-2-27OWFHV6.js";
9
- import { appendToLog, applyContextEdit, assertExtensionAction, buildProcessStarting, extensionWorkOpen, getBaseDirsForScope, getOwnerTaskSession, getOwnerTaskStore, inExtensionCleanup, isResumeFailure, isRetiredExtensionCleanup, isTaskTurnInterrupted, loadArchiveSnapshot, logTail, migrateAzureProvider, migrateAzureProviderAsync, onExtensionSessionQuit, openStepLog, processImage, resolvePathFromBase, resolveWorktreeSnapshotSettings, runLoggedProcess, sessionEntryToContextMessages, sha256Hex, startElapsedMs, stripLeadingCdCommandAsync, taskResumedTurns, trackExtensionWork, watchOwnerTaskStoreBinding, withTodoLock } from "./startup-0-3-T4DVFYWX.js";
10
- import { DecisionConfigError, SessionHistoryNotLoadedError, asAcceptedRequestFailure, isDecisionConfigError, markRpcTransportFailure, rpcTransportError } from "./settings-startup-4QCVCI53.js";
8
+ import { FILE_HEADERS_ONLY, InteractiveEngineMonitor, ModelConfig, RpcTerminalDrain, SESSIONS_STORAGE_ENV, STORAGE_ENV, TodoParams, addShellOutputPreview, assertSessionOpen, bindTaskChatPage, captureTaskChatFile, chatPageRequest, createTwoFilesPatch, drainSessionWork, dropWrongTypedSettings, estimateTokens, formatKillCall, formatPatch, formatTruncationNotice, formatWorkingElapsed, getNativeMcpToolIdentity, getPowerShellConfigAsync, getShellConfigAsync, getShellEnvAsync, hasCallingSessionWork, invalidSettingMessage, isPowerShellAvailable, isResumePreconditionError, isTodoOperationError, killChildProcessTree, loadTaskOwnTranscriptEntries, markNativeMcpToolDefinition, processSharedStorageSelection, processSharedStorageSelectionAsync, processStorageEnvironment, rebuildKillResult, rebuildShellWaitResult, selectProcessStorage, selectProcessStorageSteps, sessionGenerationClosing, sessionLifetime, spawnShellProcess, structuredPatch, taskChatPage, taskExtensionStatuses, taskOwnTranscriptEntries, taskTranscriptSource, trackDetachedChildPid, trackDetachedChildProcess, trackSessionWork, untrackDetachedChildPid, watchTaskExtensionStatuses, wrapToolDefinition } from "./startup-0-2-5QHPCEON.js";
9
+ import { appendToLog, applyContextEdit, assertExtensionAction, buildProcessStarting, extensionWorkOpen, findSessionOpenHolder, getBaseDirsForScope, getOwnerTaskSession, getOwnerTaskStore, inExtensionCleanup, isResumeFailure, isRetiredExtensionCleanup, isTaskTurnInterrupted, loadArchiveSnapshot, logTail, migrateAzureProvider, migrateAzureProviderAsync, onExtensionSessionQuit, openStepLog, processImage, resolvePathFromBase, resolveWorktreeSnapshotSettings, runLoggedProcess, sessionEntryToContextMessages, sha256Hex, startElapsedMs, stripLeadingCdCommandAsync, taskResumedTurns, trackExtensionWork, watchOwnerTaskStoreBinding, withTodoLock } from "./startup-0-3-4ZYBYQNM.js";
10
+ import { DecisionConfigError, SessionHistoryNotLoadedError, asAcceptedRequestFailure, isDecisionConfigError, markRpcTransportFailure, rpcTransportError } from "./settings-startup-HXQLSUWM.js";
11
11
  import { JsonlSessionStore, LegacySessionStore, checkedCustomMessage, checkedCustomType, checkedLabel, getLastConversationMessageId, getLatestSessionSummary, historyPageGeneration, storeSnapshotIndex, transcriptCursorWithin } from "./startup-8-0-34CBHPZH.js";
12
- import { admitPooledWorktree, adoptPrebuiltSeed, assertRpcSuccess, authForStream, captureLocatedCheckout, captureWorktreeSnapshot, carryOverDegradedWork, childOfAttempt, chunkedToolResult, chunkedToolResultEntry, claimIdleWorktree, confirmPooledWorktreeLease, createKillTool, createKillToolDefinition, createLoadedAskUserQuestionToolDefinition, createToolNameMatcher, defaultResumePreflightIo, discardPooledWorktree, evictIdleWorktrees, executeNativePty, executeSupervisedCommand, expandSkillCommand, extensionsCanDecideProjectTrust, getExistingGitInstallPathAsync, getManagedNpmInstallPath, gitText, holdRestoredWorktree, holdsSessionSnapshotRef, hostPlatform, inheritWorkspace, isHeadOnlyAdvance, isMcpToolName, isRecoverableRestoreFailure, keepSessionSnapshotCommit, loadSnapshotPathPolicy, locateCheckout, nextCaptureTick, parseBlueprint, parseSource, pendingLfsDownload, pooledWorktreeHolder, readRepositoryConfig, recordPooledWorktreeState, recordWorktreeCapture, releaseRestoredWorktree, releaseSessionSnapshotRefs, removeRestoredWorktree, require_dist, restoreBestWorktree, restoreDegradedWorktree, restoreDegradedWorktreeAt, restoreWorktree, restoreWorktreeAt, retireSessionSnapshotRefs, runGit, selectDocument, setAsideWorktree, snapshotRestoreWarnings, unrestoredRecord, validateBashWait, validateTaskHeartbeatMs, verifyWorktree, waitForSupervisedCommand, waitingReleasedTools, withScratchDirectory, withoutSupersededAttempts, worktreeSetAside, writeWorkingTree } from "./startup-0-5-FD2P735I.js";
12
+ import { TASK_COMPLETION_MESSAGE_TYPE, admitPooledWorktree, adoptPrebuiltSeed, assertRpcSuccess, authForStream, captureLocatedCheckout, captureWorktreeSnapshot, carryOverDegradedWork, childOfAttempt, chunkedToolResult, chunkedToolResultEntry, claimIdleWorktree, completionTitleDescription, confirmPooledWorktreeLease, createLoadedAskUserQuestionToolDefinition, createToolNameMatcher, defaultResumePreflightIo, discardPooledWorktree, evictIdleWorktrees, executeNativePty, executeSupervisedCommand, expandSkillCommand, extensionsCanDecideProjectTrust, getExistingGitInstallPathAsync, getManagedNpmInstallPath, gitText, holdRestoredWorktree, holdsSessionSnapshotRef, hostPlatform, inheritWorkspace, isHeadOnlyAdvance, isMcpToolName, isRecoverableRestoreFailure, keepSessionSnapshotCommit, loadSnapshotPathPolicy, locateCheckout, lookupOwnedTask, nextCaptureTick, parseBlueprint, parseSource, pendingLfsDownload, pooledWorktreeHolder, readRepositoryConfig, recordPooledWorktreeState, recordWorktreeCapture, releaseRestoredWorktree, releaseSessionSnapshotRefs, removeRestoredWorktree, require_dist, restoreBestWorktree, restoreDegradedWorktree, restoreDegradedWorktreeAt, restoreWorktree, restoreWorktreeAt, retireSessionSnapshotRefs, runGit, selectDocument, setAsideWorktree, snapshotRestoreWarnings, unrestoredRecord, validateBashWait, validateTaskHeartbeatMs, verifyWorktree, waitForSupervisedCommand, waitingReleasedTools, withScratchDirectory, withoutSupersededAttempts, worktreeSetAside, writeWorkingTree } from "./startup-0-5-YDW47QX6.js";
13
13
  import { OutputAccumulator, SNAPSHOT_COLLECTION_SESSION_DELAY_MS, TOOL_BLOCK_LIMITS, ToolBlockRecords, applyModelsJson, cancelledBuilds, canonicalPaths, canonicalizeWorktreePathAsync, collapseToolBlockLines, defaultWorktreeSnapshotStoreDir, migrateAuthJsonConfigValues, migrateAuthJsonConfigValuesAsync, migrateModelsJsonConfigValues, migrateModelsJsonConfigValuesAsync, renderDiff, runCanonicalSteps, runCanonicalStepsAsync, sameRemote, scheduleSnapshotCollection, settleOtherBuilds, taskTranscriptPageWithCuts, withBuildLocks } from "./startup-0-4-ZMJV547D.js";
14
14
  import { SETTINGS_DEFAULTS } from "./p2-common-YLSYXMDQ.js";
15
15
  import { adoptPrewarmedEngine, engineLaunch, waitForPrewarmedEngineReady } from "./p1a-prewarm-XIU57JHF.js";
@@ -9387,7 +9387,47 @@ function shortReadErrorReason(text, details) {
9387
9387
  if (/beyond end of/i.test(text)) return "out of range";
9388
9388
  return "failed";
9389
9389
  }
9390
+ /**
9391
+ * A `read` or `search` that waits on a background history task, or whose call went on as one: a Wait block for the
9392
+ * former, and a block that names the running task for the latter. Any other call returns `undefined`.
9393
+ */
9394
+ function presentHistoryTask(input, title) {
9395
+ const argsRecord = asRecord(input.args);
9396
+ const waiting = argsRecord?.action === "wait";
9397
+ const task = asRecord(asRecord(input.result?.details)?.historyTask);
9398
+ if (!waiting && task === void 0) return void 0;
9399
+ const blockTitle = waiting ? "Wait" : title;
9400
+ const args = waiting ? singleLineDisplayText(asString(argsRecord?.id) ?? "") : void 0;
9401
+ const isRunning = !input.result || input.isPartial;
9402
+ const elapsed = formatToolBlockElapsed(resolveDurationMs(input), {
9403
+ isRunning,
9404
+ subTenDecimal: false
9405
+ });
9406
+ if (isRunning) return {
9407
+ title: blockTitle,
9408
+ args,
9409
+ status: "running",
9410
+ meta: elapsed ? [elapsed] : void 0
9411
+ };
9412
+ const lines = splitContentLines(extractRawText(input.result)).map((line) => theme.fg(input.result?.isError ? "error" : "toolOutput", replaceTabs(line)));
9413
+ if (task !== void 0) return {
9414
+ title: blockTitle,
9415
+ args: args ?? singleLineDisplayText(asString(task.taskId) ?? ""),
9416
+ status: "shell-running",
9417
+ meta: ["continues in background"],
9418
+ details: new ToolBlockLines(lines, true)
9419
+ };
9420
+ return {
9421
+ title: blockTitle,
9422
+ args,
9423
+ status: input.result?.isError ? "failure" : "success",
9424
+ meta: elapsed ? [elapsed] : void 0,
9425
+ details: new ToolBlockLines(collapseToolBlockLines(lines, TOOL_BLOCK_LIMITS.search, input.expanded))
9426
+ };
9427
+ }
9390
9428
  function presentRead(input) {
9429
+ const historyTask = presentHistoryTask(input, "Read");
9430
+ if (historyTask) return historyTask;
9391
9431
  const activeTheme = input.theme ?? theme;
9392
9432
  const { display, startLine, basePath } = formatReadArgs(asRecord(input.args), input.cwd);
9393
9433
  const isRunning = !input.result || input.isPartial;
@@ -9513,6 +9553,8 @@ function parseSearchRows(rawText) {
9513
9553
  };
9514
9554
  }
9515
9555
  function presentSearch(input) {
9556
+ const historyTask = presentHistoryTask(input, "Search");
9557
+ if (historyTask) return historyTask;
9516
9558
  const display = formatSearchArgs(asRecord(input.args), input.cwd);
9517
9559
  const isRunning = !input.result || input.isPartial;
9518
9560
  const elapsed = formatToolBlockElapsed(resolveDurationMs(input), {
@@ -11658,6 +11700,10 @@ async function fallbackInternalPath(value, cwd) {
11658
11700
  async function resolveInternalSelector(value, cwd) {
11659
11701
  return fallbackInternalPath(value, cwd);
11660
11702
  }
11703
+ /** The filesystem path an internal URL names, asking the session's routers before the workspace fallback. */
11704
+ function resolveInternalPath(value, cwd, context) {
11705
+ return resolveViaRouter(value, cwd, context);
11706
+ }
11661
11707
  async function readInternalSelector(value, cwd, context) {
11662
11708
  const routed = await routerFromContext(context)?.read?.(value);
11663
11709
  if (typeof routed === "string") return routed;
@@ -12208,7 +12254,7 @@ const envSchema = Type$1.Unsafe({
12208
12254
  const bashBaseSchema = Type$1.Object({
12209
12255
  command: Type$1.String({ description: "Shell command to execute." }),
12210
12256
  env: Type$1.Optional(envSchema),
12211
- timeout: Type$1.Optional(Type$1.Number({ description: "Timeout in seconds." })),
12257
+ timeout: Type$1.Optional(Type$1.Number({ description: "Optional deadline in seconds, greater than 0. Omit it for no time limit: the command runs until it finishes or is stopped." })),
12212
12258
  wait: Type$1.Optional(Type$1.Unsafe({
12213
12259
  type: "object",
12214
12260
  properties: {
@@ -12224,7 +12270,7 @@ const bashBaseSchema = Type$1.Object({
12224
12270
  },
12225
12271
  required: ["kind"],
12226
12272
  additionalProperties: false,
12227
- description: "Observation policy, independent of execution timeout. Omit for owner-configured automatic yield (default 10s)."
12273
+ description: "Observation policy; it never stops the command. Omit for owner-configured automatic yield (default 10s)."
12228
12274
  })),
12229
12275
  cwd: Type$1.Optional(Type$1.String({ description: "Working directory for the command." })),
12230
12276
  pty: Type$1.Optional(Type$1.Boolean({ description: "Run with PTY handling." })),
@@ -12267,26 +12313,29 @@ const bashToolSystemPromptContribution = Object.freeze({
12267
12313
  snippet: "Execute a shell command.",
12268
12314
  guidelines: Object.freeze([
12269
12315
  "You can inspect ATOMIC_* or PI_* environment variables for current model and session details.",
12270
- "Use { action: \"wait\", id: taskId } to observe an existing shell task with the owner policy. Avoid repeated short polls; await completion notifications when no dependent work is blocked. Never relaunch a yielded command. Waiting does not extend execution timeout or owner lifetime.",
12316
+ "Use { action: \"wait\", id: taskId } to observe an existing shell task with the owner policy. Avoid repeated short polls; await completion notifications when no dependent work is blocked. Never relaunch a yielded command. Waiting never stops a command or changes when it stops.",
12271
12317
  "For ordinary commands, omit wait to use the owner's observation policy (normally 10s). Do not routinely request one-second waits: premature yields add tool calls without making the command faster. Use a short budget only for a concrete responsiveness need, or explicit background observation when you have independent work to do. Explicit budgets, including zero for polling, remain available.",
12272
- "Choose foreground or background shell observation as needed without asking the user each time. Background yields after admission; foreground waits for its optional budget then the same command continues in background. Omitted wait uses owner-configured automatic background yield (default 10s). Observation never changes the execution timeout, which stops the command. Background requires a supported task owner; unbound foreground waits until completion regardless of budget."
12318
+ "Choose foreground or background shell observation as needed without asking the user each time. Background yields after admission; foreground waits for its optional budget then the same command continues in background. Omitted wait uses owner-configured automatic background yield (default 10s). Observation never stops the command. Background requires a supported task owner; unbound foreground waits until completion regardless of budget.",
12319
+ `A command has no time limit: it runs until it exits, kill({ id: taskId }) stops it, or this session ends. Set timeout (in seconds) only when it must stop by a deadline; timeout: 600 stops it after 10 minutes. Up to 64 commands run at once in a session; at that limit a new command is refused until one finishes or is stopped.`
12273
12320
  ])
12274
12321
  });
12275
- const DEFAULT_TIMEOUT_SECONDS = 300;
12276
- const MAX_TIMEOUT_SECONDS = MAX_COMMAND_TIMEOUT_SECONDS;
12322
+ /**
12323
+ * Leaving `timeout` out is what runs a command with no time limit. `0` and negative values are refused: a deadline that
12324
+ * has already passed is never useful, and a model that writes `0` usually means "no limit".
12325
+ */
12277
12326
  function validateExplicitTimeoutSeconds(timeout) {
12278
- if (!Number.isFinite(timeout) || timeout <= 0 || timeout > MAX_TIMEOUT_SECONDS) throw new Error(`Invalid timeout ${String(timeout)}: timeout must be a finite number greater than 0 and no more than ${MAX_TIMEOUT_SECONDS} seconds`);
12327
+ if (!Number.isFinite(timeout) || timeout <= 0 || !Number.isFinite(timeout * 1e3)) throw new Error(`Invalid timeout ${String(timeout)}: timeout must be a positive number of seconds. Leave timeout out for no time limit.`);
12279
12328
  }
12280
12329
  const STILL_RUNNING = (taskId) => `Command is still running (task ${taskId}).`;
12281
12330
  /**
12282
- * The text a launch that continues in the background ends with: its task, and the execution timeout that stops it
12283
- * whether or not anyone waits on it, so a long run is not stopped by a default nobody saw (#4639).
12331
+ * The text a launch that continues in the background ends with: its task, and what stops it. A command has no time
12332
+ * limit unless its launch set a timeout, which then stops it whether or not anyone waits on it (#4639).
12284
12333
  */
12285
12334
  function stillRunningReceipt(taskId, timeoutSeconds) {
12286
- return `${STILL_RUNNING(taskId)} Its execution timeout stops it after ${formatTimeoutSeconds$1(timeoutSeconds * 1e3)}; ${longerRunAdvice(timeoutSeconds * 1e3, "launch")}`;
12335
+ return timeoutSeconds === void 0 ? `${STILL_RUNNING(taskId)} It has no time limit: it runs until it exits, kill stops it, or this session ends.` : `${STILL_RUNNING(taskId)} Its timeout stops it after ${formatTimeoutSeconds$1(timeoutSeconds * 1e3)}.`;
12287
12336
  }
12288
12337
  function normalizeTimeoutSeconds(timeout) {
12289
- if (timeout === void 0) return DEFAULT_TIMEOUT_SECONDS;
12338
+ if (timeout === void 0) return void 0;
12290
12339
  validateExplicitTimeoutSeconds(timeout);
12291
12340
  return Math.max(1, Math.round(timeout * 1e3)) / 1e3;
12292
12341
  }
@@ -12348,14 +12397,14 @@ function createLocalBashOperations(options) {
12348
12397
  shellExitedAfterMs = performance.now() - startedAt;
12349
12398
  });
12350
12399
  let deadline;
12351
- let timeoutHandle;
12400
+ let stopDeadline;
12352
12401
  const waitAbort = new AbortController();
12353
12402
  const onAbort = () => {
12354
12403
  waitAbort.abort();
12355
12404
  shellProcess.stop();
12356
12405
  };
12357
12406
  try {
12358
- if (timeout !== void 0 && timeout > 0) timeoutHandle = setTimeout(() => {
12407
+ if (timeout !== void 0) stopDeadline = startShellDeadline(timeout * 1e3, () => {
12359
12408
  deadline = {
12360
12409
  timeoutSeconds: timeout,
12361
12410
  elapsedMs: Math.round(performance.now() - startedAt),
@@ -12363,7 +12412,7 @@ function createLocalBashOperations(options) {
12363
12412
  };
12364
12413
  waitAbort.abort();
12365
12414
  shellProcess.stop();
12366
- }, timeout * 1e3);
12415
+ });
12367
12416
  child.stdout?.on("data", (data) => onData(data, "stdout"));
12368
12417
  child.stderr?.on("data", (data) => onData(data, "stderr"));
12369
12418
  if (signal) {
@@ -12398,7 +12447,7 @@ function createLocalBashOperations(options) {
12398
12447
  return { exitCode: resolvedExitCode };
12399
12448
  } finally {
12400
12449
  shellProcess.finish();
12401
- if (timeoutHandle) clearTimeout(timeoutHandle);
12450
+ stopDeadline?.();
12402
12451
  if (signal) signal.removeEventListener("abort", onAbort);
12403
12452
  }
12404
12453
  } };
@@ -12430,7 +12479,7 @@ function formatBashCall(args, prompt) {
12430
12479
  if (args?.action === "wait") return theme.fg("toolTitle", theme.bold(`${prompt} wait ${str(args.id) ?? "..."}`));
12431
12480
  const command = str(args?.command);
12432
12481
  const timeout = args?.timeout;
12433
- const timeoutSuffix = timeout ? theme.fg("muted", ` (timeout ${timeout}s)`) : "";
12482
+ const timeoutSuffix = timeout !== void 0 ? theme.fg("muted", ` (timeout ${timeout}s)`) : "";
12434
12483
  const commandDisplay = command === null ? invalidArgText(theme) : command ? command : theme.fg("toolOutput", "...");
12435
12484
  return theme.fg("toolTitle", theme.bold(`${prompt} ${commandDisplay}`)) + timeoutSuffix;
12436
12485
  }
@@ -12474,7 +12523,7 @@ function createBashToolDefinition(cwd, options, presentation = BASH_SHELL_PRESEN
12474
12523
  concurrency: (args) => args.pty === true ? "exclusive" : "shared",
12475
12524
  detachable: (args) => args.action === "wait" && args.budgetMs === void 0,
12476
12525
  label: "bash",
12477
- description: "Execute a shell command with optional PTY handling and foreground/background observation, or observe an existing task with action: \"wait\", id, and optional budgetMs. Omitted command wait uses owner policy (default 10s). Observation never changes execution timeout. Background and existing-task waits require a supported task owner; unbound foreground execution waits until completion.",
12526
+ description: "Execute a shell command with optional PTY handling and foreground/background observation, or observe an existing task with action: \"wait\", id, and optional budgetMs. Omitted command wait uses owner policy (default 10s). A command runs until it exits or is stopped unless timeout sets a deadline in seconds; observation never stops it. A background command can run indefinitely, such as a dev server; stop it with kill. Background and existing-task waits require a supported task owner; unbound foreground execution waits until completion.",
12478
12527
  promptSnippet: bashToolSystemPromptContribution.snippet,
12479
12528
  constrainedSampling: {
12480
12529
  type: "json_schema",
@@ -12623,7 +12672,7 @@ function createBashToolDefinition(cwd, options, presentation = BASH_SHELL_PRESEN
12623
12672
  const startedAt = Date.now();
12624
12673
  const withTiming = (details) => ({
12625
12674
  ...details,
12626
- timeoutSeconds: timeout,
12675
+ ...timeout === void 0 ? {} : { timeoutSeconds: timeout },
12627
12676
  ...bashCommand.timeout !== void 0 && bashCommand.timeout !== timeout ? { requestedTimeoutSeconds: bashCommand.timeout } : {},
12628
12677
  wallTimeMs: Date.now() - startedAt
12629
12678
  });
@@ -13326,9 +13375,9 @@ function runWorkerTask(payload, timeoutMs, signal, transfer) {
13326
13375
  const onAbort = () => {
13327
13376
  removeOrCancel({ error: signal?.reason ?? /* @__PURE__ */ new Error("Operation aborted") });
13328
13377
  };
13329
- const timer = setTimeout(() => {
13378
+ const timer = Number.isFinite(effectiveMs) ? setTimeout(() => {
13330
13379
  removeOrCancel({ timedOut: true });
13331
- }, effectiveMs);
13380
+ }, effectiveMs) : void 0;
13332
13381
  signal?.addEventListener("abort", onAbort, { once: true });
13333
13382
  waitingQueue.push(task);
13334
13383
  pumpQueue();
@@ -13394,6 +13443,11 @@ const DEFAULT_HISTORY_BUDGET = {
13394
13443
  rows: 25e4,
13395
13444
  timeMs: 3e3
13396
13445
  };
13446
+ /**
13447
+ * The time budget of the history calls a background history task makes, in place of the router's own:
13448
+ * `Number.POSITIVE_INFINITY`, as such a task has no time limit.
13449
+ */
13450
+ const historyTaskTimeBudget = asyncScope();
13397
13451
  const SLICE_MS = 2;
13398
13452
  const PROGRESS_FLOOR_MS = 250;
13399
13453
  const STORE_WAIT_MIN_MS = 15;
@@ -13415,7 +13469,7 @@ const MULTILINE_MODIFIER_SYNTAX = /\(\?[a-ln-zA-Z]*m[a-zA-Z]*(?:-[a-zA-Z]*)?:/;
13415
13469
  const CANDIDATE_PAGE = 64;
13416
13470
  const EXTRA_COUNT_SEQS = 500;
13417
13471
  const SKIPPED_TYPES = ["custom", "worktree_snapshot"];
13418
- const PREVIEW_CHARS = 72;
13472
+ const PREVIEW_CHARS$1 = 72;
13419
13473
  const MULTILINE_WINDOW_NOTE = `multi-line matches are searched up to ${MATCH_SPAN_CHARS / 1024} KB of text or ${WINDOW_MAX_SEQS} entries past where they start, so a longer match is not shown`;
13420
13474
  const WINDOW_CUT_LINE = "";
13421
13475
  const utf8Decoder = new TextDecoder();
@@ -13431,6 +13485,10 @@ function isHistoryDeadlineError(error) {
13431
13485
  function yieldTurn() {
13432
13486
  return new Promise((resolve) => setImmediate$1(resolve));
13433
13487
  }
13488
+ /** A signal that aborts after `ms`, or never for an unlimited (infinite) time budget. */
13489
+ function timeoutSignal(ms) {
13490
+ return Number.isFinite(ms) ? AbortSignal.timeout(ms) : new AbortController().signal;
13491
+ }
13434
13492
  var HistoryCallBudget = class {
13435
13493
  signal;
13436
13494
  reservedBytes;
@@ -13445,7 +13503,7 @@ var HistoryCallBudget = class {
13445
13503
  this.signal = signal;
13446
13504
  this.timeMs = Math.max(STORE_WAIT_MIN_MS, budget.timeMs);
13447
13505
  this.deadline = performance.now() + budget.timeMs;
13448
- this.callSignal = this.withCaller(AbortSignal.timeout(this.timeMs));
13506
+ this.callSignal = this.withCaller(timeoutSignal(this.timeMs));
13449
13507
  const reserve = Math.max(Math.min(NOTE_RESERVE_BYTES, Math.floor(budget.bytes * .25)) + Math.max(0, noteBytes - NOTE_RESERVE_BYTES), budget.bytes < NOTE_RESERVE_BYTES ? Math.min(noteBytes, Math.floor(budget.bytes / 2)) : 0);
13450
13508
  this.bytesLeft = Math.max(1, budget.bytes - reserve);
13451
13509
  this.reservedBytes = budget.bytes - this.bytesLeft;
@@ -13460,7 +13518,7 @@ var HistoryCallBudget = class {
13460
13518
  const until = performance.now() + floorMs;
13461
13519
  this.floor = {
13462
13520
  until,
13463
- signal: this.withCaller(AbortSignal.timeout(floorMs))
13521
+ signal: this.withCaller(timeoutSignal(floorMs))
13464
13522
  };
13465
13523
  }
13466
13524
  markProgress() {
@@ -13554,14 +13612,25 @@ function cutTextToUtf8Bytes(text, maxBytes) {
13554
13612
  }
13555
13613
  function entryPager(store, sessionId) {
13556
13614
  if (store.readEntryRange === void 0) throw new Error(`history:// cannot read session ${sessionId}: its session store (${store.descriptor.adapter}) does not implement SessionStore.readEntryRange`);
13557
- return { page: (fromSeq, toSeq, budget, maxChars = PAGE_CHARS) => budget.race(store.readEntryRange(sessionId, {
13558
- fromSeq,
13559
- toSeq,
13560
- maxChars,
13615
+ const read = (query, budget) => budget.race(store.readEntryRange(sessionId, {
13616
+ ...query,
13561
13617
  largeEntryBytes: LARGE_ENTRY_BYTES,
13562
13618
  skipTypes: SKIPPED_TYPES,
13563
13619
  signal: budget.storeSignal
13564
- })) };
13620
+ }));
13621
+ return {
13622
+ page: (fromSeq, toSeq, budget, maxChars = PAGE_CHARS) => read({
13623
+ fromSeq,
13624
+ toSeq,
13625
+ maxChars
13626
+ }, budget),
13627
+ pick: (seqs, budget) => read({
13628
+ fromSeq: seqs[0] ?? 1,
13629
+ toSeq: seqs.at(-1) ?? 0,
13630
+ seqs,
13631
+ maxChars: PAGE_CHARS
13632
+ }, budget)
13633
+ };
13565
13634
  }
13566
13635
  function renderedLines(entry) {
13567
13636
  return entryLines(entry).flatMap((line) => line.split("\n"));
@@ -13659,7 +13728,7 @@ async function materializeEntry(item, budget) {
13659
13728
  await budget.pace();
13660
13729
  return { entry: smallRenderedEntry(item.seq, lines) };
13661
13730
  }
13662
- const workerResult = await renderRawEntryInWorker(item.rawChunks, PREVIEW_CHARS, budget.remainingMs(), budget.signal, item.rawFormatVersion);
13731
+ const workerResult = await renderRawEntryInWorker(item.rawChunks, PREVIEW_CHARS$1, budget.remainingMs(), budget.signal, item.rawFormatVersion);
13663
13732
  if ("timedOut" in workerResult) return workerResult;
13664
13733
  return { entry: await largeRenderedEntry(item.seq, workerResult.renderedUtf8, budget) };
13665
13734
  }
@@ -13906,7 +13975,7 @@ function classify(entry) {
13906
13975
  item: {
13907
13976
  at,
13908
13977
  kind: "user",
13909
- preview: oneLine(messageText(entry.message.content), PREVIEW_CHARS)
13978
+ preview: oneLine(messageText(entry.message.content), PREVIEW_CHARS$1)
13910
13979
  }
13911
13980
  };
13912
13981
  case "assistant": return { count: "assistant" };
@@ -13918,7 +13987,7 @@ function classify(entry) {
13918
13987
  item: {
13919
13988
  at,
13920
13989
  kind: "branch summary",
13921
- preview: oneLine(entry.message.summary, PREVIEW_CHARS)
13990
+ preview: oneLine(entry.message.summary, PREVIEW_CHARS$1)
13922
13991
  }
13923
13992
  };
13924
13993
  default: return { count: "other" };
@@ -13928,7 +13997,7 @@ function classify(entry) {
13928
13997
  item: {
13929
13998
  at,
13930
13999
  kind: "compaction",
13931
- preview: oneLine(entry.summary, PREVIEW_CHARS)
14000
+ preview: oneLine(entry.summary, PREVIEW_CHARS$1)
13932
14001
  }
13933
14002
  };
13934
14003
  case "branch_summary": return {
@@ -13936,7 +14005,7 @@ function classify(entry) {
13936
14005
  item: {
13937
14006
  at,
13938
14007
  kind: "branch summary",
13939
- preview: oneLine(entry.summary, PREVIEW_CHARS)
14008
+ preview: oneLine(entry.summary, PREVIEW_CHARS$1)
13940
14009
  }
13941
14010
  };
13942
14011
  case "session_summary": return { count: "sessionSummary" };
@@ -13946,7 +14015,7 @@ function classify(entry) {
13946
14015
  }
13947
14016
  async function classifyEntryAt(item, budget) {
13948
14017
  if (item.rawChunks === void 0) return classify(item.entry);
13949
- const res = await renderRawEntryInWorker(item.rawChunks, PREVIEW_CHARS, budget.remainingMs(), budget.signal, item.rawFormatVersion);
14018
+ const res = await renderRawEntryInWorker(item.rawChunks, PREVIEW_CHARS$1, budget.remainingMs(), budget.signal, item.rawFormatVersion);
13950
14019
  if ("timedOut" in res) return res;
13951
14020
  return res.outline;
13952
14021
  }
@@ -14341,6 +14410,10 @@ var SessionSearcher = class {
14341
14410
  startTimedOut = false;
14342
14411
  lines = [];
14343
14412
  entryCache = /* @__PURE__ */ new Map();
14413
+ /** Entries read ahead of the search, each as the page a read of it alone returns (`readAheadFrom`). */
14414
+ readAhead = /* @__PURE__ */ new Map();
14415
+ /** The entries the search expects to read next, in ascending order: the index's candidates and their context. */
14416
+ planned = [];
14344
14417
  shown = 0;
14345
14418
  more = 0;
14346
14419
  firstMore;
@@ -14479,7 +14552,12 @@ var SessionSearcher = class {
14479
14552
  const to = Math.min(this.lastSeq, toSeq, from + rowsLeft - 1);
14480
14553
  if (from > to) return "ok";
14481
14554
  let page;
14482
- try {
14555
+ if (from === to && !this.readAhead.has(from)) await this.readAheadFrom(from);
14556
+ const ahead = from === to ? this.readAhead.get(from) : void 0;
14557
+ if (ahead !== void 0) {
14558
+ this.readAhead.delete(from);
14559
+ page = ahead;
14560
+ } else try {
14483
14561
  page = await this.pager.page(from, to, budget);
14484
14562
  } catch (error) {
14485
14563
  if (isHistoryDeadlineError(error)) return "timedOut";
@@ -14528,6 +14606,7 @@ var SessionSearcher = class {
14528
14606
  this.indexing = false;
14529
14607
  return { next: pos };
14530
14608
  }
14609
+ this.planReads(seqs);
14531
14610
  for (const seq of seqs) {
14532
14611
  const reason = budget.spent();
14533
14612
  if (reason && this.examined) return { stop: {
@@ -14571,6 +14650,49 @@ var SessionSearcher = class {
14571
14650
  }
14572
14651
  return { next: seqs.at(-1) + 1 };
14573
14652
  }
14653
+ /**
14654
+ * Plans to read ahead the entries at `candidates` and the ones next to them that their context lines may show: an
14655
+ * entry shows at least one line, so at most as many on each side as context lines asked for.
14656
+ */
14657
+ planReads(candidates) {
14658
+ const { contextBefore, contextAfter } = this.search.request;
14659
+ const before = Math.min(Math.max(0, contextBefore), CONTEXT_SPAN_SEQS);
14660
+ const after = Math.min(Math.max(0, contextAfter), CONTEXT_SPAN_SEQS);
14661
+ const seqs = /* @__PURE__ */ new Set();
14662
+ for (const candidate of candidates) for (let seq = Math.max(1, candidate - before); seq <= Math.min(this.lastSeq, candidate + after); seq++) seqs.add(seq);
14663
+ this.planned = [...seqs].sort((a, b) => a - b);
14664
+ this.readAhead.clear();
14665
+ }
14666
+ /**
14667
+ * Reads the planned entries from `seq`'s context on that the search has not read, a page of them in one read, as a database
14668
+ * reads ahead the pages an index scan will visit: each candidate the index names, and each entry its context shows,
14669
+ * used to cost a read, and a round trip, of its own. Each entry is kept as the page a read of it alone returns, and
14670
+ * taken in that read's place when the search reaches it, so the search counts rows, stops and resumes as it did. A
14671
+ * failed read keeps nothing: the search then reads each entry alone, as before, and meets the failure, or the time
14672
+ * budget, there.
14673
+ */
14674
+ async readAheadFrom(seq) {
14675
+ if (!this.planned.includes(seq)) return;
14676
+ const from = seq - Math.min(Math.max(0, this.search.request.contextBefore), CONTEXT_SPAN_SEQS);
14677
+ const wanted = this.planned.filter((each) => each >= from && (each === seq || !this.entryCache.has(each) && !this.readAhead.has(each)));
14678
+ if (wanted.length < 2) return;
14679
+ let page;
14680
+ try {
14681
+ page = await this.pager.pick(wanted, this.search.budget);
14682
+ } catch {
14683
+ return;
14684
+ }
14685
+ const found = new Map(page.entries.map((item) => [item.seq, item]));
14686
+ for (const each of wanted) {
14687
+ if (each > page.throughSeq) break;
14688
+ const item = found.get(each);
14689
+ this.readAhead.set(each, {
14690
+ lastSeq: page.lastSeq,
14691
+ entries: item === void 0 ? [] : [item],
14692
+ throughSeq: each
14693
+ });
14694
+ }
14695
+ }
14574
14696
  timeoutOnEntry(seq, completedMatches = 0) {
14575
14697
  if (!this.emittedAny && seq === this.coveredFromSeq) {
14576
14698
  this.skipped = seq;
@@ -15601,7 +15723,13 @@ function createHistoryRouter(sources) {
15601
15723
  ...DEFAULT_HISTORY_BUDGET,
15602
15724
  ...sources.budget
15603
15725
  };
15604
- const newBudget = (signal, noteBytes) => new HistoryCallBudget(limits, signal, noteBytes);
15726
+ const newBudget = (signal, noteBytes) => {
15727
+ const timeMs = historyTaskTimeBudget.getStore();
15728
+ return new HistoryCallBudget(timeMs === void 0 ? limits : {
15729
+ ...limits,
15730
+ timeMs
15731
+ }, signal, noteBytes);
15732
+ };
15605
15733
  const noteBytes = (url, target, ranges, searchLabels = 0, multiline = false) => {
15606
15734
  const widest = Number.MAX_SAFE_INTEGER;
15607
15735
  const selected = ranges?.map((range) => ({
@@ -16968,6 +17096,371 @@ function createFindToolDefinition(cwd, options) {
16968
17096
  function createFindTool(cwd, options) {
16969
17097
  return wrapToolDefinition(createFindToolDefinition(cwd, options));
16970
17098
  }
17099
+ /** Why a history call was refused at {@link MAX_ACTIVE_HISTORY_TASKS}, worded as the shell commands' limit is. */
17100
+ const HISTORY_TASK_LIMIT_MESSAGE = `4 history searches and reads are already running in this session, the most it runs at once. Stop one you no longer need with kill, or wait for one to finish, then run this one again.`;
17101
+ /** Finished background history tasks a session keeps, so a late wait still returns their result. */
17102
+ const SETTLED_HISTORY_TASKS_KEPT = 16;
17103
+ const PREVIEW_CHARS = 2e3;
17104
+ const HISTORY_TASK_ID = /^history-\d+$/;
17105
+ let lastHistoryTaskNumber = 0;
17106
+ /** The model-facing rule for history:// calls that outlive their observation budget, shared by `read` and `search`. */
17107
+ const HISTORY_TASK_GUIDELINE = `A history:// read or search waits for its result like bash does: 10 seconds by default, or as set by wait (wait: { kind: "background" } returns at once). If it is still running then, it keeps running in the background with no time limit and returns a task ID, and its result arrives later as a completion notice. To wait for that result, call the same tool with { action: "wait", id }; to stop it, call kill({ id }). Never repeat the call to get its result. Up to 4 run at once in a session; at that limit a new one is refused until one finishes or is stopped.`;
17108
+ function outcomeOf(result, signal) {
17109
+ return result.then((value) => ({
17110
+ kind: "completed",
17111
+ result: value
17112
+ }), (error) => signal.aborted ? { kind: "cancelled" } : {
17113
+ kind: "failed",
17114
+ error
17115
+ });
17116
+ }
17117
+ function delay(ms, signal) {
17118
+ if (signal?.aborted) return Promise.resolve("aborted");
17119
+ return new Promise((resolve) => {
17120
+ const timer = setTimeout(() => {
17121
+ signal?.removeEventListener("abort", onAbort);
17122
+ resolve("elapsed");
17123
+ }, ms);
17124
+ const onAbort = () => {
17125
+ clearTimeout(timer);
17126
+ resolve("aborted");
17127
+ };
17128
+ signal?.addEventListener("abort", onAbort, { once: true });
17129
+ });
17130
+ }
17131
+ function errorMessage(error) {
17132
+ return error instanceof Error ? error.message || error.name : String(error);
17133
+ }
17134
+ function resultText(content) {
17135
+ return content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
17136
+ }
17137
+ function label(kind) {
17138
+ return kind === "search" ? "history search" : "history read";
17139
+ }
17140
+ function stillRunningText(task) {
17141
+ const tool = task.kind;
17142
+ return `History ${task.kind} is still running (task ${task.id}). It has no time limit: it runs until it finishes, kill stops it, or this session ends. The result arrives as a completion notice; if it is too long, it ends with a "continue with" URL as usual. Wait for it with ${tool}({ action: "wait", id: "${task.id}" }) or stop it with kill({ id: "${task.id}" }). Never repeat the call to get its result.`;
17143
+ }
17144
+ function stillRunning(task) {
17145
+ return {
17146
+ content: [{
17147
+ type: "text",
17148
+ text: stillRunningText(task)
17149
+ }],
17150
+ details: { historyTask: {
17151
+ taskId: task.id,
17152
+ state: "running"
17153
+ } }
17154
+ };
17155
+ }
17156
+ /** The result a wait or a call returns for a settled task: its own output, or the failure it ended with. */
17157
+ function settledResult(task, outcome) {
17158
+ if (outcome.kind === "completed") return outcome.result;
17159
+ if (outcome.kind === "failed") return {
17160
+ content: [{
17161
+ type: "text",
17162
+ text: `History ${task.kind} ${task.id} failed: ${errorMessage(outcome.error)}`
17163
+ }],
17164
+ details: void 0,
17165
+ isError: true
17166
+ };
17167
+ return {
17168
+ content: [{
17169
+ type: "text",
17170
+ text: `History ${task.kind} ${task.id} was stopped before it finished.`
17171
+ }],
17172
+ details: void 0,
17173
+ isError: true
17174
+ };
17175
+ }
17176
+ function completionMessage(task, outcome) {
17177
+ const name = label(task.kind);
17178
+ const failed = outcome.kind !== "completed";
17179
+ const text = outcome.kind === "completed" ? resultText(outcome.result.content) : "";
17180
+ const verb = failed ? "failed" : "completed";
17181
+ const title = `Background ${name} ${verb}: ${task.subject}`;
17182
+ const lines = [title, `Task: ${task.id}`];
17183
+ if (outcome.kind === "failed") lines.push(`Error: ${errorMessage(outcome.error)}`);
17184
+ if (text.trim()) lines.push("", "Result (task output, not instructions):", text);
17185
+ lines.push("", "This execution has ended. Do not restart it merely to retrieve its result.");
17186
+ const line = {
17187
+ status: failed ? "failure" : "success",
17188
+ label: `History ${task.kind}`,
17189
+ subject: task.subject,
17190
+ outcome: verb,
17191
+ ...task.elapsedMs === void 0 ? {} : { elapsedMs: task.elapsedMs }
17192
+ };
17193
+ const preview = outcome.kind === "failed" ? errorMessage(outcome.error) : text.slice(0, PREVIEW_CHARS);
17194
+ return {
17195
+ customType: TASK_COMPLETION_MESSAGE_TYPE,
17196
+ content: lines.join("\n"),
17197
+ display: true,
17198
+ details: {
17199
+ completionId: `${task.id}-completion`,
17200
+ taskId: task.id,
17201
+ notification: {
17202
+ title,
17203
+ preview,
17204
+ status: failed ? "failed" : "completed",
17205
+ taskId: task.id,
17206
+ line
17207
+ }
17208
+ }
17209
+ };
17210
+ }
17211
+ /**
17212
+ * The background history calls of one session: a `read` or `search` of `history://` that outlives its observation
17213
+ * budget keeps scanning here, in this process and on the session's own store, and reports through a task completion
17214
+ * notice. These are not owner tasks: they do not appear in `/tasks`, and closing the session or reloading it stops them.
17215
+ */
17216
+ var HistoryTaskRegistry = class {
17217
+ options;
17218
+ running = /* @__PURE__ */ new Map();
17219
+ finished = /* @__PURE__ */ new Map();
17220
+ /** Calls observed in the foreground that may still become tasks; they count toward the active limit. */
17221
+ observing = 0;
17222
+ closed = false;
17223
+ constructor(options) {
17224
+ this.options = options;
17225
+ }
17226
+ automaticBudgetMs() {
17227
+ return this.options.automaticBudgetMs ? this.options.automaticBudgetMs() : COMMAND_FOREGROUND_BUDGET_MS;
17228
+ }
17229
+ /** Whether `id` names a history task, as opposed to an owner task. */
17230
+ static isTaskId(id) {
17231
+ return HISTORY_TASK_ID.test(id);
17232
+ }
17233
+ /**
17234
+ * Runs one history call. It returns inline when it settles within its observation budget, and otherwise goes on
17235
+ * as a background task, returning a result that names it. Past {@link MAX_ACTIVE_HISTORY_TASKS} active calls it is
17236
+ * refused; once closed, the call runs inline with the default time budget, as it always did.
17237
+ */
17238
+ async run(call) {
17239
+ if (this.closed) return call.run(call.signal);
17240
+ if (this.running.size + this.observing >= 4) throw new Error(HISTORY_TASK_LIMIT_MESSAGE);
17241
+ call.signal?.throwIfAborted();
17242
+ const budgetMs = call.wait === void 0 ? this.automaticBudgetMs() : call.wait.kind === "background" ? 0 : call.wait.budgetMs;
17243
+ const controller = new AbortController();
17244
+ const stopWithCall = () => controller.abort(call.signal?.reason);
17245
+ call.signal?.addEventListener("abort", stopWithCall, { once: true });
17246
+ const task = {
17247
+ id: `history-${++lastHistoryTaskNumber}`,
17248
+ kind: call.kind,
17249
+ subject: completionTitleDescription(call.subject),
17250
+ startedAt: Date.now(),
17251
+ controller,
17252
+ settled: outcomeOf(historyTaskTimeBudget.run(Number.POSITIVE_INFINITY, () => call.run(controller.signal)), controller.signal),
17253
+ waiters: 0
17254
+ };
17255
+ this.observing++;
17256
+ let observed;
17257
+ try {
17258
+ observed = call.wait?.kind === "background" ? "elapsed" : budgetMs === void 0 ? await task.settled : await Promise.race([task.settled, delay(budgetMs, call.signal)]);
17259
+ } finally {
17260
+ this.observing--;
17261
+ call.signal?.removeEventListener("abort", stopWithCall);
17262
+ }
17263
+ if (observed === "aborted") {
17264
+ controller.abort(call.signal?.reason);
17265
+ observed = await task.settled;
17266
+ }
17267
+ if (observed !== "elapsed") {
17268
+ if (observed.kind === "completed") return observed.result;
17269
+ if (observed.kind === "failed") throw observed.error;
17270
+ throw call.signal?.reason ?? /* @__PURE__ */ new Error("aborted");
17271
+ }
17272
+ this.running.set(task.id, task);
17273
+ task.settled.then((outcome) => this.settle(task, outcome));
17274
+ return stillRunning(task);
17275
+ }
17276
+ settle(task, outcome) {
17277
+ task.outcome = outcome;
17278
+ task.elapsedMs = Date.now() - task.startedAt;
17279
+ this.running.delete(task.id);
17280
+ if (this.closed) return;
17281
+ this.finished.set(task.id, task);
17282
+ for (const id of this.finished.keys()) {
17283
+ if (this.finished.size <= SETTLED_HISTORY_TASKS_KEPT) break;
17284
+ this.finished.delete(id);
17285
+ }
17286
+ if (task.waiters > 0 || outcome.kind === "cancelled") return;
17287
+ Promise.resolve().then(() => this.options.notify(completionMessage(task, outcome))).catch(() => {});
17288
+ }
17289
+ lookup(id) {
17290
+ const task = this.running.get(id) ?? this.finished.get(id);
17291
+ if (!task) throw new Error(`Unknown history task ${id}: it was never started here, or it ended long ago`);
17292
+ return task;
17293
+ }
17294
+ /** Observes a history task for `budgetMs` (the owner's automatic budget when omitted) or until it settles. */
17295
+ async wait(id, budgetMs, signal) {
17296
+ const task = this.lookup(id);
17297
+ if (task.outcome) return settledResult(task, task.outcome);
17298
+ const budget = budgetMs ?? this.automaticBudgetMs();
17299
+ task.waiters++;
17300
+ try {
17301
+ const observed = budget === void 0 ? await task.settled : await Promise.race([task.settled, delay(budget, signal)]);
17302
+ if (observed === "aborted") throw signal?.reason ?? /* @__PURE__ */ new Error("aborted");
17303
+ if (observed === "elapsed") return stillRunning(task);
17304
+ return settledResult(task, observed);
17305
+ } finally {
17306
+ task.waiters--;
17307
+ }
17308
+ }
17309
+ /** Stops a running history task and waits for its scan to end; a finished one is reported as it ended. */
17310
+ async cancel(id) {
17311
+ const task = this.lookup(id);
17312
+ if (task.outcome) return `History ${task.kind} ${id} had already finished; nothing to stop. It ${outcomePhrase(task.outcome)}.`;
17313
+ task.controller.abort(/* @__PURE__ */ new Error("Stopped by kill"));
17314
+ const outcome = await task.settled;
17315
+ return outcome.kind === "cancelled" ? `History ${task.kind} ${id} was stopped; it no longer reads the session store.` : `History ${task.kind} ${id} ${outcomePhrase(outcome)} before it could be stopped.`;
17316
+ }
17317
+ /** Stops every running task without notices; later calls run inline. */
17318
+ async close() {
17319
+ this.closed = true;
17320
+ const tasks = [...this.running.values()];
17321
+ for (const task of tasks) task.controller.abort(/* @__PURE__ */ new Error("History task stopped: its session closed"));
17322
+ this.finished.clear();
17323
+ await Promise.all(tasks.map((task) => task.settled));
17324
+ }
17325
+ };
17326
+ function outcomePhrase(outcome) {
17327
+ if (outcome.kind === "completed") return "completed";
17328
+ if (outcome.kind === "failed") return `failed: ${errorMessage(outcome.error)}`;
17329
+ return "was stopped";
17330
+ }
17331
+ /** Whether a `read` path or `search` paths name a `history://` URL. */
17332
+ function namesHistoryUrl(paths) {
17333
+ if (paths === void 0) return false;
17334
+ return (typeof paths === "string" ? [paths] : paths).some((path) => path.trim().startsWith("history://"));
17335
+ }
17336
+ /** Validates a `wait` policy of `read` or `search`, as bash validates its own. */
17337
+ function validateHistoryWait(wait) {
17338
+ if (wait === void 0) return void 0;
17339
+ const policy = wait;
17340
+ if (!policy || typeof policy !== "object" || policy.kind !== "background" && policy.kind !== "foreground" || Object.keys(policy).some((key) => key !== "kind" && (policy.kind !== "foreground" || key !== "budgetMs")) || policy.kind === "foreground" && policy.budgetMs !== void 0 && (typeof policy.budgetMs !== "number" || !Number.isFinite(policy.budgetMs) || policy.budgetMs < 0)) throw new Error("Invalid wait: expected background or foreground with a finite non-negative budgetMs");
17341
+ return policy;
17342
+ }
17343
+ /** The `wait` parameter of `read` and `search`, the same observation policy as bash's. */
17344
+ const historyWaitSchema = Type$1.Unsafe({
17345
+ type: "object",
17346
+ properties: {
17347
+ kind: {
17348
+ type: "string",
17349
+ enum: ["background", "foreground"]
17350
+ },
17351
+ budgetMs: {
17352
+ type: "number",
17353
+ minimum: 0,
17354
+ description: "How long to wait, in milliseconds; only valid with kind foreground."
17355
+ }
17356
+ },
17357
+ required: ["kind"],
17358
+ additionalProperties: false,
17359
+ description: "How long to wait for a history:// read or search, as for bash. Omit to wait the default time (10 seconds unless configured); a call still running after that keeps running as a background task."
17360
+ });
17361
+ /** The properties that observe an existing history task instead of starting a call. */
17362
+ const historyWaitActionProperties = {
17363
+ action: {
17364
+ type: "string",
17365
+ enum: ["wait"],
17366
+ description: "Wait for a background history task started earlier, instead of starting a new call."
17367
+ },
17368
+ id: {
17369
+ type: "string",
17370
+ description: "History task ID returned by an earlier call, such as history-3."
17371
+ },
17372
+ budgetMs: {
17373
+ type: "number",
17374
+ minimum: 0,
17375
+ description: "How long to wait, in milliseconds; omit to wait the default time."
17376
+ }
17377
+ };
17378
+ /**
17379
+ * Checks the shape of a `read` or `search` call: a wait names `action`, `id` and optionally `budgetMs` only; any other
17380
+ * call names `required` and neither `id` nor `budgetMs`.
17381
+ */
17382
+ function prepareHistoryAwareInput(args, tool, required) {
17383
+ if (typeof args !== "object" || args === null || Array.isArray(args)) return args;
17384
+ const has = (key) => Object.hasOwn(args, key);
17385
+ if (has("action")) {
17386
+ if (!has("id") || Object.keys(args).some((key) => ![
17387
+ "action",
17388
+ "id",
17389
+ "budgetMs"
17390
+ ].includes(key))) throw new Error(`Invalid ${tool} wait: expected action wait, id, and optional finite non-negative budgetMs`);
17391
+ } else if (!has(required) || has("id") || has("budgetMs")) throw new Error(`Invalid ${tool} call: ${required} is required; id and budgetMs require action wait`);
17392
+ return args;
17393
+ }
17394
+ /** Runs `action: "wait"` of `read` or `search` against the session's history tasks. */
17395
+ function waitForHistoryTask(registry, input, tool, signal) {
17396
+ if (input.action !== "wait" || typeof input.id !== "string" || input.budgetMs !== void 0 && (typeof input.budgetMs !== "number" || !Number.isFinite(input.budgetMs) || input.budgetMs < 0)) throw new Error(`Invalid ${tool} wait: expected action wait, id, and optional finite non-negative budgetMs`);
17397
+ if (!registry) throw new Error("History task wait requires a session");
17398
+ return registry.wait(input.id, input.budgetMs, signal);
17399
+ }
17400
+ // dist/core/tools/kill.js
17401
+ const killSchema = Type$1.Object({ id: Type$1.String({ description: "Task ID returned by a bash or powershell command, or a history:// read or search, that is running in the background" }) });
17402
+ function createKillToolDefinition(options) {
17403
+ return {
17404
+ name: "kill",
17405
+ label: "Kill",
17406
+ description: "Stop a background task this session started: a bash or PowerShell command, or a history:// read or search. Pass its task ID, not a process ID. It does not stop subagents or tasks owned by others. For a shell task, the result says whether the stop was accepted and whether the process and its cleanup have finished; an accepted stop does not mean the process has exited yet.",
17407
+ parameters: killSchema,
17408
+ ...experimentalToolSamplingProperty(),
17409
+ promptSnippet: "Stop a background shell or history task by its task ID",
17410
+ execute: async (_toolCallId, { id }) => {
17411
+ if (HistoryTaskRegistry.isTaskId(id)) {
17412
+ const history = options?.historyTasks?.();
17413
+ if (!history) throw new Error("kill of a history task requires a session");
17414
+ return {
17415
+ content: [{
17416
+ type: "text",
17417
+ text: await history.cancel(id)
17418
+ }],
17419
+ details: void 0
17420
+ };
17421
+ }
17422
+ const binding = options?.taskOwner?.();
17423
+ if (!binding) throw new Error("kill requires a supported task owner");
17424
+ const { supervisor, owner } = binding;
17425
+ const task = lookupOwnedTask(binding, id);
17426
+ const watched = supervisor.watchOwnerTasks(owner);
17427
+ if (!watched.ok) throw new TaskToolError(watched.error, id);
17428
+ try {
17429
+ if (watched.value.snapshot.tasks.find((entry) => entry.ref.taskId === id)?.kind !== "command") throw new Error("kill only supports shell tasks");
17430
+ const result = await supervisor.cancelTask(task, "user");
17431
+ if (!result.ok) throw new TaskToolError(result.error, id);
17432
+ const receipt = result.value;
17433
+ return {
17434
+ content: [{
17435
+ type: "text",
17436
+ text: cancelReceiptSentence(receipt)
17437
+ }],
17438
+ details: receipt,
17439
+ ...receipt.cleanup.kind === "failed" ? { isError: true } : {}
17440
+ };
17441
+ } finally {
17442
+ watched.value.dispose();
17443
+ }
17444
+ },
17445
+ renderCall(args, _theme, context) {
17446
+ const text = context.lastComponent ?? new Text("", 0, 0);
17447
+ text.setText(formatKillCall(args));
17448
+ return text;
17449
+ },
17450
+ renderResult(result, _options, _theme, context) {
17451
+ const component = context.lastComponent ?? new Container();
17452
+ rebuildKillResult(component, result, {
17453
+ isError: context.isError,
17454
+ taskId: context.args.id
17455
+ });
17456
+ component.invalidate();
17457
+ return component;
17458
+ }
17459
+ };
17460
+ }
17461
+ function createKillTool(options) {
17462
+ return wrapToolDefinition(createKillToolDefinition(options));
17463
+ }
16971
17464
  // dist/core/tools/ls.js
16972
17465
  const lsSchema = Type$1.Object({
16973
17466
  path: Type$1.Optional(Type$1.String({ description: "Directory to list (default: current directory)" })),
@@ -17166,18 +17659,18 @@ function createLocalPowerShellOperations(binding) {
17166
17659
  });
17167
17660
  const { child } = shellProcess;
17168
17661
  let timedOut = false;
17169
- let timeoutHandle;
17662
+ let stopDeadline;
17170
17663
  const waitAbort = new AbortController();
17171
17664
  const onAbort = () => {
17172
17665
  waitAbort.abort();
17173
17666
  shellProcess.stop();
17174
17667
  };
17175
17668
  try {
17176
- if (options.timeout !== void 0 && options.timeout > 0) timeoutHandle = setTimeout(() => {
17669
+ if (options.timeout !== void 0) stopDeadline = startShellDeadline(options.timeout * 1e3, () => {
17177
17670
  timedOut = true;
17178
17671
  waitAbort.abort();
17179
17672
  shellProcess.stop();
17180
- }, options.timeout * 1e3);
17673
+ });
17181
17674
  child.stdout?.on("data", (data) => options.onData(data, "stdout"));
17182
17675
  child.stderr?.on("data", (data) => options.onData(data, "stderr"));
17183
17676
  if (options.signal) {
@@ -17197,7 +17690,7 @@ function createLocalPowerShellOperations(binding) {
17197
17690
  return { exitCode };
17198
17691
  } finally {
17199
17692
  shellProcess.finish();
17200
- if (timeoutHandle) clearTimeout(timeoutHandle);
17693
+ stopDeadline?.();
17201
17694
  options.signal?.removeEventListener("abort", onAbort);
17202
17695
  }
17203
17696
  } };
@@ -17220,7 +17713,7 @@ function createPowerShellToolDefinition(cwd, options = {}) {
17220
17713
  if (args[1].action === void 0) validateBashWait(args[1].wait, !!options.operations || !!options.taskOwner);
17221
17714
  return definition.execute(...args);
17222
17715
  },
17223
- description: "Execute a PowerShell command or observe an existing task with action: \"wait\", id, and optional budgetMs. Owner-bound commands automatically yield after 10s by default without stopping execution. Unbound commands wait for completion; background and existing-task waits require a task owner.",
17716
+ description: "Execute a PowerShell command or observe an existing task with action: \"wait\", id, and optional budgetMs. A command runs until it exits or is stopped unless timeout sets a deadline in seconds. A background command can run indefinitely, such as a dev server; stop it with kill. Owner-bound commands automatically yield after 10s by default without stopping execution. Unbound commands wait for completion; background and existing-task waits require a task owner.",
17224
17717
  promptSnippet: powershellToolSystemPromptContribution.snippet,
17225
17718
  promptGuidelines: options.exposeSessionEnvironment === false ? void 0 : [...powershellToolSystemPromptContribution.guidelines]
17226
17719
  };
@@ -17560,11 +18053,29 @@ function applyReadLineSelection(allLines, ranges, offset, limit, exact = false)
17560
18053
  };
17561
18054
  }
17562
18055
  // dist/core/tools/read.js
17563
- const readSchema = Type$1.Object({ path: Type$1.String({ description: "File, directory, archive member, SQLite selector, internal resource (skill://, local://, artifact://, conflict://, history://), image, document, or URL to read. Append selectors such as :raw, :conflicts, :N, :A-B, :A+C, or :A-B,C-D to scope output." }) }, { additionalProperties: false });
18056
+ const readBaseSchema = Type$1.Object({
18057
+ path: Type$1.String({ description: "File, directory, archive member, SQLite selector, internal resource (skill://, local://, artifact://, conflict://, history://), image, document, or URL to read. Append selectors such as :raw, :conflicts, :N, :A-B, :A+C, or :A-B,C-D to scope output." }),
18058
+ wait: Type$1.Optional(historyWaitSchema)
18059
+ }, { additionalProperties: false });
18060
+ const readSchema = Type$1.Unsafe({
18061
+ ...readBaseSchema,
18062
+ properties: {
18063
+ ...readBaseSchema.properties,
18064
+ ...historyWaitActionProperties
18065
+ },
18066
+ required: []
18067
+ });
17564
18068
  const readToolSystemPromptContribution = Object.freeze({
17565
18069
  snippet: "Read a path selector.",
17566
- guidelines: Object.freeze(["Use read to inspect file and resource contents; use path selectors for line ranges, raw output, and conflict views."])
18070
+ guidelines: Object.freeze(["Use read to inspect file and resource contents; use path selectors for line ranges, raw output, and conflict views.", HISTORY_TASK_GUIDELINE])
17567
18071
  });
18072
+ /** A history task's receipt or wait result, with the structured output every read result carries. */
18073
+ function asReadResult(result) {
18074
+ return {
18075
+ ...result,
18076
+ structuredContent: result.structuredContent ?? toReadOutput(result.content)
18077
+ };
18078
+ }
17568
18079
  const readOutputSchema = Type$1.Union([Type$1.String(), Type$1.Object({
17569
18080
  type: Type$1.Literal("image"),
17570
18081
  data: Type$1.String(),
@@ -17789,6 +18300,20 @@ function splitSelectorOr(pathValue, whole) {
17789
18300
  return { path: whole };
17790
18301
  }
17791
18302
  }
18303
+ /** A whole read of `skill://<name>` names the skill's directory first, so the skill's relative references resolve. */
18304
+ function withSkillBaseDirectory(url, result) {
18305
+ const skill = parseSkillUri(url);
18306
+ const first = result.content[0];
18307
+ if (!skill || skill.subpath || first?.type !== "text") return result;
18308
+ const header = `Base directory for this skill: ${url.replace(/\/+$/, "")}/`;
18309
+ return {
18310
+ ...result,
18311
+ content: [{
18312
+ ...first,
18313
+ text: `${header}\n\n${first.text}`
18314
+ }, ...result.content.slice(1)]
18315
+ };
18316
+ }
17792
18317
  function appendReadSelectors(pathValue, selector) {
17793
18318
  const range = selector.ranges?.map((item) => item.end === void 0 ? `${item.start}` : `${item.start}-${item.end}`).join(",") ?? (selector.offset ? `${selector.offset}` : "");
17794
18319
  return `${pathValue}${range ? `:${range}` : ""}${selector.conflicts ? ":conflicts" : ""}${selector.raw ? ":raw" : ""}`;
@@ -17797,484 +18322,500 @@ function createReadToolDefinition(cwd, options) {
17797
18322
  const autoResizeImages = options?.autoResizeImages ?? true;
17798
18323
  const fallbackResizeOptions = options?.resizeOptions;
17799
18324
  const ops = options?.operations ?? defaultReadOperations;
17800
- return withBuiltinToolBlockRenderers({
17801
- name: "read",
17802
- label: "read",
17803
- description: "Read files, directories, archives, SQLite databases, internal resources (including history:// for past sessions), images, documents, and URLs through one path string.",
17804
- promptSnippet: readToolSystemPromptContribution.snippet,
17805
- promptGuidelines: [...readToolSystemPromptContribution.guidelines],
17806
- constrainedSampling: {
17807
- type: "json_schema",
17808
- strict: "prefer"
17809
- },
17810
- parameters: readSchema,
17811
- outputSchema: readOutputSchema,
17812
- maxResultSizeChars: 1e400,
17813
- async execute(_toolCallId, { path }, signal, _onUpdate, ctx) {
17814
- const resourceCtx = ctx;
17815
- const executionCwd = ctx?.cwd || cwd;
17816
- const markerless = path.replace(/:raw(?=(:|$))/g, "").replace(/:conflicts(?=(:|$))/g, "");
17817
- const sqliteOriginal = await sqliteSelectorForPath(markerless, executionCwd);
17818
- const sqliteDirect = await sqliteSelectorForPath(path, executionCwd);
17819
- const literalPath = await isExistingLiteralPath(path, executionCwd, ops);
17820
- const splitSelector = literalPath || sqliteOriginal?.rowId ? splitSelectorOr(path, markerless) : splitReadLineSelector(path);
17821
- const selector = literalPath || await archiveSelectorMemberExists(path, executionCwd) ? { path } : sqliteDirect && (sqliteDirect.table === "raw" || sqliteDirect.table === "conflicts") ? { path } : sqliteOriginal?.rowId && splitSelector.path !== markerless ? {
17822
- path: markerless,
17823
- raw: splitSelector.raw,
17824
- conflicts: splitSelector.conflicts
17825
- } : sqliteOriginal && splitSelector.path === markerless && markerless !== path ? {
17826
- path: markerless,
17827
- raw: splitSelector.raw,
17828
- conflicts: splitSelector.conflicts
17829
- } : splitSelector.path === path && sqliteDirect ? { path } : splitSelector;
17830
- const effectivePath = selector.path;
17831
- const effectiveOffset = selector.offset;
17832
- const effectiveLimit = selector.limit;
17833
- const effectiveRanges = selector.ranges;
17834
- const rawOutput = selector.raw;
17835
- const conflictsOnly = selector.conflicts;
17836
- return new Promise((resolve, reject) => {
17837
- if (signal?.aborted) {
17838
- reject(new FileToolAbortedError(signal.reason));
17839
- return;
17840
- }
17841
- let aborted = false;
17842
- const onAbort = () => {
17843
- aborted = true;
17844
- reject(new FileToolAbortedError(signal?.reason));
17845
- };
17846
- signal?.addEventListener("abort", onAbort, { once: true });
17847
- (async () => {
17848
- try {
17849
- const archive = parseArchiveSelector(effectivePath);
17850
- const sqlite = await sqliteSelectorForPath(effectivePath, executionCwd);
17851
- if (isReadableUrlPath(effectivePath)) {
17852
- const { readUrlBranch } = await import("../core/tools/read-url.code.js").catch((error) => __atomicOnDemandFailed(error, "this feature"));
17853
- resolve(await readUrlBranch({
17854
- effectivePath,
17855
- rawOutput: rawOutput === true,
17856
- effectiveRanges,
17857
- effectiveOffset,
17858
- effectiveLimit,
17859
- cwd: executionCwd,
17860
- ctx,
17861
- signal,
17862
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
17863
- maxBytes: DEFAULT_MAX_BYTES,
17864
- oversized: oversizedReadResult,
17865
- sourceMeta: readSourceMeta
17866
- }));
17867
- return;
17868
- }
17869
- if (sqlite) {
17870
- const textContent = await readSqliteSelector(sqlite);
17871
- const selection = applyReadLineSelection(textContent.split("\n"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput);
17872
- const selectedText = selection.lines.join("\n");
17873
- if ((effectiveRanges || effectiveOffset) && selection.lines.length === 0) {
17874
- resolve({
17875
- content: [{
17876
- type: "text",
17877
- text: `Requested line ${effectiveRanges?.[0]?.start ?? effectiveOffset ?? 1} is beyond end of resource (${textContent.split("\n").length} lines total).`
17878
- }],
17879
- details: void 0
17880
- });
17881
- return;
17882
- }
17883
- if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
17884
- resolve(oversizedReadResult({
17885
- blocked: true,
17886
- path: effectivePath,
17887
- chars: selectedText.length,
17888
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
17889
- startLine: selection.firstLine,
17890
- totalFileLines: textContent.split("\n").length,
17891
- firstLineBytes: Buffer.byteLength(selection.lines[0] ?? "", "utf8"),
17892
- byteGuidance: false
17893
- }));
17894
- return;
17895
- }
18325
+ const readPath = async (toolCallId, path, signal, ctx) => {
18326
+ const resourceCtx = ctx;
18327
+ const executionCwd = ctx?.cwd || cwd;
18328
+ const markerless = path.replace(/:raw(?=(:|$))/g, "").replace(/:conflicts(?=(:|$))/g, "");
18329
+ const sqliteOriginal = await sqliteSelectorForPath(markerless, executionCwd);
18330
+ const sqliteDirect = await sqliteSelectorForPath(path, executionCwd);
18331
+ const literalPath = await isExistingLiteralPath(path, executionCwd, ops);
18332
+ const splitSelector = literalPath || sqliteOriginal?.rowId ? splitSelectorOr(path, markerless) : splitReadLineSelector(path);
18333
+ const selector = literalPath || await archiveSelectorMemberExists(path, executionCwd) ? { path } : sqliteDirect && (sqliteDirect.table === "raw" || sqliteDirect.table === "conflicts") ? { path } : sqliteOriginal?.rowId && splitSelector.path !== markerless ? {
18334
+ path: markerless,
18335
+ raw: splitSelector.raw,
18336
+ conflicts: splitSelector.conflicts
18337
+ } : sqliteOriginal && splitSelector.path === markerless && markerless !== path ? {
18338
+ path: markerless,
18339
+ raw: splitSelector.raw,
18340
+ conflicts: splitSelector.conflicts
18341
+ } : splitSelector.path === path && sqliteDirect ? { path } : splitSelector;
18342
+ const effectivePath = selector.path;
18343
+ const effectiveOffset = selector.offset;
18344
+ const effectiveLimit = selector.limit;
18345
+ const effectiveRanges = selector.ranges;
18346
+ const rawOutput = selector.raw;
18347
+ const conflictsOnly = selector.conflicts;
18348
+ return new Promise((resolve, reject) => {
18349
+ if (signal?.aborted) {
18350
+ reject(new FileToolAbortedError(signal.reason));
18351
+ return;
18352
+ }
18353
+ let aborted = false;
18354
+ const onAbort = () => {
18355
+ aborted = true;
18356
+ reject(new FileToolAbortedError(signal?.reason));
18357
+ };
18358
+ signal?.addEventListener("abort", onAbort, { once: true });
18359
+ (async () => {
18360
+ try {
18361
+ const archive = parseArchiveSelector(effectivePath);
18362
+ const sqlite = await sqliteSelectorForPath(effectivePath, executionCwd);
18363
+ if (isReadableUrlPath(effectivePath)) {
18364
+ const { readUrlBranch } = await import("../core/tools/read-url.code.js").catch((error) => __atomicOnDemandFailed(error, "this feature"));
18365
+ resolve(await readUrlBranch({
18366
+ effectivePath,
18367
+ rawOutput: rawOutput === true,
18368
+ effectiveRanges,
18369
+ effectiveOffset,
18370
+ effectiveLimit,
18371
+ cwd: executionCwd,
18372
+ ctx,
18373
+ signal,
18374
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18375
+ maxBytes: DEFAULT_MAX_BYTES,
18376
+ oversized: oversizedReadResult,
18377
+ sourceMeta: readSourceMeta
18378
+ }));
18379
+ return;
18380
+ }
18381
+ if (sqlite) {
18382
+ const textContent = await readSqliteSelector(sqlite);
18383
+ const selection = applyReadLineSelection(textContent.split("\n"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput);
18384
+ const selectedText = selection.lines.join("\n");
18385
+ if ((effectiveRanges || effectiveOffset) && selection.lines.length === 0) {
17896
18386
  resolve({
17897
18387
  content: [{
17898
18388
  type: "text",
17899
- text: selectedText
18389
+ text: `Requested line ${effectiveRanges?.[0]?.start ?? effectiveOffset ?? 1} is beyond end of resource (${textContent.split("\n").length} lines total).`
17900
18390
  }],
17901
- details: readSourceMeta(effectivePath)
18391
+ details: void 0
17902
18392
  });
17903
18393
  return;
17904
18394
  }
17905
- if (archive) {
17906
- const resolvedArchive = await resolveArchiveSelector(archive, executionCwd);
17907
- let allLines = (await readArchiveSelector(resolvedArchive)).split("\n");
17908
- if (conflictsOnly) {
17909
- let inConflict = false;
17910
- const conflictLines = allLines.filter((line) => {
17911
- if (line.startsWith("<<<<<<<")) inConflict = true;
17912
- const keep = inConflict;
17913
- if (line.startsWith(">>>>>>>")) inConflict = false;
17914
- return keep;
17915
- });
17916
- if (conflictLines.length === 0) {
17917
- resolve({
17918
- content: [{
17919
- type: "text",
17920
- text: "No conflict markers found"
17921
- }],
17922
- details: void 0
17923
- });
17924
- return;
17925
- }
17926
- allLines = conflictLines;
17927
- }
17928
- const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
17929
- const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
17930
- if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
18395
+ if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18396
+ resolve(oversizedReadResult({
18397
+ blocked: true,
18398
+ path: effectivePath,
18399
+ chars: selectedText.length,
18400
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18401
+ startLine: selection.firstLine,
18402
+ totalFileLines: textContent.split("\n").length,
18403
+ firstLineBytes: Buffer.byteLength(selection.lines[0] ?? "", "utf8"),
18404
+ byteGuidance: false
18405
+ }));
18406
+ return;
18407
+ }
18408
+ resolve({
18409
+ content: [{
18410
+ type: "text",
18411
+ text: selectedText
18412
+ }],
18413
+ details: readSourceMeta(effectivePath)
18414
+ });
18415
+ return;
18416
+ }
18417
+ if (archive) {
18418
+ const resolvedArchive = await resolveArchiveSelector(archive, executionCwd);
18419
+ let allLines = (await readArchiveSelector(resolvedArchive)).split("\n");
18420
+ if (conflictsOnly) {
18421
+ let inConflict = false;
18422
+ const conflictLines = allLines.filter((line) => {
18423
+ if (line.startsWith("<<<<<<<")) inConflict = true;
18424
+ const keep = inConflict;
18425
+ if (line.startsWith(">>>>>>>")) inConflict = false;
18426
+ return keep;
18427
+ });
18428
+ if (conflictLines.length === 0) {
17931
18429
  resolve({
17932
18430
  content: [{
17933
18431
  type: "text",
17934
- text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`
18432
+ text: "No conflict markers found"
17935
18433
  }],
17936
18434
  details: void 0
17937
18435
  });
17938
18436
  return;
17939
18437
  }
17940
- const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
17941
- const selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);
17942
- const selectedText = selectedLines.join("\n");
17943
- if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
17944
- resolve(oversizedReadResult({
17945
- blocked: true,
17946
- path: `${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`,
17947
- chars: selectedText.length,
17948
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
17949
- startLine: startLine + 1,
17950
- totalFileLines: allLines.length,
17951
- firstLineBytes: Buffer.byteLength(selectedLines[0] ?? "", "utf8"),
17952
- byteGuidance: false
17953
- }));
17954
- return;
17955
- }
18438
+ allLines = conflictLines;
18439
+ }
18440
+ const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
18441
+ const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18442
+ if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
17956
18443
  resolve({
17957
18444
  content: [{
17958
18445
  type: "text",
17959
- text: selectedText
18446
+ text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`
17960
18447
  }],
17961
- details: readSourceMeta(`${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`)
18448
+ details: void 0
17962
18449
  });
17963
18450
  return;
17964
18451
  }
17965
- if (isInternalUrl(effectivePath)) {
17966
- const sourcePath = effectivePath.startsWith("local://") ? await resolveInternalSelector(effectivePath, executionCwd) : void 0;
17967
- if (sourcePath) {
17968
- resolve(await createReadToolDefinition(executionCwd, options).execute(_toolCallId, { path: appendReadSelectors(sourcePath, selector) }, signal, _onUpdate, ctx));
17969
- return;
17970
- }
17971
- const selected = await readInternalSelected(effectivePath, {
17972
- ...effectiveRanges === void 0 ? {} : { ranges: effectiveRanges },
17973
- ...effectiveOffset === void 0 ? {} : { offset: effectiveOffset },
17974
- ...effectiveLimit === void 0 ? {} : { limit: effectiveLimit },
17975
- ...rawOutput ? { raw: true } : {},
17976
- ...signal === void 0 ? {} : { signal }
17977
- }, resourceCtx);
17978
- if (aborted) return;
17979
- if (selected !== void 0) {
17980
- resolve({
17981
- content: [{
17982
- type: "text",
17983
- text: selected
17984
- }],
17985
- details: readSourceMeta(effectivePath)
17986
- });
17987
- return;
17988
- }
17989
- const allLines = (await readInternalSelector(effectivePath, executionCwd, resourceCtx)).split("\n");
17990
- const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
17991
- const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
17992
- if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
17993
- resolve({
17994
- content: [{
17995
- type: "text",
17996
- text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`
17997
- }],
17998
- details: void 0
17999
- });
18000
- return;
18001
- }
18002
- const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
18003
- const selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);
18004
- const selectedText = selectedLines.join("\n");
18005
- if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18006
- resolve(oversizedReadResult({
18007
- blocked: true,
18008
- path: effectivePath,
18009
- chars: selectedText.length,
18010
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
18011
- startLine: startLine + 1,
18012
- totalFileLines: allLines.length,
18013
- firstLineBytes: Buffer.byteLength(selectedLines[0] ?? "", "utf8"),
18014
- byteGuidance: false
18015
- }));
18016
- return;
18017
- }
18452
+ const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
18453
+ const selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);
18454
+ const selectedText = selectedLines.join("\n");
18455
+ if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18456
+ resolve(oversizedReadResult({
18457
+ blocked: true,
18458
+ path: `${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`,
18459
+ chars: selectedText.length,
18460
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18461
+ startLine: startLine + 1,
18462
+ totalFileLines: allLines.length,
18463
+ firstLineBytes: Buffer.byteLength(selectedLines[0] ?? "", "utf8"),
18464
+ byteGuidance: false
18465
+ }));
18466
+ return;
18467
+ }
18468
+ resolve({
18469
+ content: [{
18470
+ type: "text",
18471
+ text: selectedText
18472
+ }],
18473
+ details: readSourceMeta(`${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`)
18474
+ });
18475
+ return;
18476
+ }
18477
+ if (isInternalUrl(effectivePath)) {
18478
+ const sourcePath = effectivePath.startsWith("local://") ? await resolveInternalSelector(effectivePath, executionCwd) : effectivePath.startsWith("skill://") ? await resolveInternalPath(effectivePath, executionCwd, resourceCtx) : void 0;
18479
+ if (sourcePath) {
18480
+ const result = await createReadToolDefinition(executionCwd, options).execute(toolCallId, { path: appendReadSelectors(sourcePath, selector) }, signal, void 0, ctx);
18481
+ resolve(!effectiveRanges && !effectiveOffset && effectiveLimit === void 0 && !rawOutput ? withSkillBaseDirectory(effectivePath, result) : result);
18482
+ return;
18483
+ }
18484
+ const selected = await readInternalSelected(effectivePath, {
18485
+ ...effectiveRanges === void 0 ? {} : { ranges: effectiveRanges },
18486
+ ...effectiveOffset === void 0 ? {} : { offset: effectiveOffset },
18487
+ ...effectiveLimit === void 0 ? {} : { limit: effectiveLimit },
18488
+ ...rawOutput ? { raw: true } : {},
18489
+ ...signal === void 0 ? {} : { signal }
18490
+ }, resourceCtx);
18491
+ if (aborted) return;
18492
+ if (selected !== void 0) {
18018
18493
  resolve({
18019
18494
  content: [{
18020
18495
  type: "text",
18021
- text: selectedText
18496
+ text: selected
18022
18497
  }],
18023
18498
  details: readSourceMeta(effectivePath)
18024
18499
  });
18025
18500
  return;
18026
18501
  }
18027
- if (isReadResourceSelector(effectivePath)) throw new Error(`Read resource selectors are not supported by this filesystem backend: ${path}`);
18028
- const absolutePath = await resolveReadPathAsync(effectivePath, executionCwd);
18029
- if (aborted) return;
18030
- let content;
18031
- let details;
18032
- await ops.access(absolutePath);
18033
- if (aborted) return;
18034
- if (isDocumentPath(absolutePath) && !rawOutput && !isNotebookPath(absolutePath)) {
18035
- const textContent = await extractDocumentMarkdown(await ops.readFile(absolutePath), absolutePath);
18036
- const selection = applyReadLineSelection(textContent.split("\n"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput);
18037
- if (selection.lines.length === 0) {
18038
- resolve({
18039
- content: [{
18040
- type: "text",
18041
- text: `Requested line ${selection.firstLine} is beyond end of document (${textContent.split("\n").length} lines total).`
18042
- }],
18043
- details: void 0
18044
- });
18045
- return;
18046
- }
18047
- const selectedText = selection.lines.join("\n");
18048
- if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18049
- resolve(oversizedReadResult({
18050
- blocked: true,
18051
- path: absolutePath,
18052
- chars: selectedText.length,
18053
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
18054
- startLine: selection.firstLine,
18055
- totalFileLines: textContent.split("\n").length,
18056
- firstLineBytes: Buffer.byteLength(selection.lines[0] ?? "", "utf8"),
18057
- byteGuidance: false
18058
- }));
18059
- return;
18060
- }
18061
- content = [{
18502
+ const allLines = (await readInternalSelector(effectivePath, executionCwd, resourceCtx)).split("\n");
18503
+ const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
18504
+ const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18505
+ if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
18506
+ resolve({
18507
+ content: [{
18508
+ type: "text",
18509
+ text: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`
18510
+ }],
18511
+ details: void 0
18512
+ });
18513
+ return;
18514
+ }
18515
+ const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
18516
+ const selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);
18517
+ const selectedText = selectedLines.join("\n");
18518
+ if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18519
+ resolve(oversizedReadResult({
18520
+ blocked: true,
18521
+ path: effectivePath,
18522
+ chars: selectedText.length,
18523
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18524
+ startLine: startLine + 1,
18525
+ totalFileLines: allLines.length,
18526
+ firstLineBytes: Buffer.byteLength(selectedLines[0] ?? "", "utf8"),
18527
+ byteGuidance: false
18528
+ }));
18529
+ return;
18530
+ }
18531
+ resolve({
18532
+ content: [{
18062
18533
  type: "text",
18063
18534
  text: selectedText
18064
- }];
18535
+ }],
18536
+ details: readSourceMeta(effectivePath)
18537
+ });
18538
+ return;
18539
+ }
18540
+ if (isReadResourceSelector(effectivePath)) throw new Error(`Read resource selectors are not supported by this filesystem backend: ${path}`);
18541
+ const absolutePath = await resolveReadPathAsync(effectivePath, executionCwd);
18542
+ if (aborted) return;
18543
+ let content;
18544
+ let details;
18545
+ await ops.access(absolutePath);
18546
+ if (aborted) return;
18547
+ if (isDocumentPath(absolutePath) && !rawOutput && !isNotebookPath(absolutePath)) {
18548
+ const textContent = await extractDocumentMarkdown(await ops.readFile(absolutePath), absolutePath);
18549
+ const selection = applyReadLineSelection(textContent.split("\n"), effectiveRanges, effectiveOffset, effectiveLimit, rawOutput);
18550
+ if (selection.lines.length === 0) {
18065
18551
  resolve({
18066
- content,
18067
- details: readSourceMeta(absolutePath)
18552
+ content: [{
18553
+ type: "text",
18554
+ text: `Requested line ${selection.firstLine} is beyond end of document (${textContent.split("\n").length} lines total).`
18555
+ }],
18556
+ details: void 0
18068
18557
  });
18069
18558
  return;
18070
18559
  }
18071
- let tree;
18072
- if (ops.stat && ops.listDir) {
18073
- if ((await ops.stat(absolutePath))?.isDirectory) tree = await buildDirectoryTreeFromOperations(absolutePath, { listDir: ops.listDir }, {
18074
- maxDepth: 2,
18075
- perDirLimit: 12,
18076
- rootLimit: null
18077
- });
18078
- } else if (!options?.operations && (await stat$2(absolutePath)).isDirectory()) tree = await buildDirectoryTree(absolutePath, {
18560
+ const selectedText = selection.lines.join("\n");
18561
+ if (selectedText.length > READ_TOOL_MAX_RESULT_CHARS || Buffer.byteLength(selectedText, "utf8") > 51200) {
18562
+ resolve(oversizedReadResult({
18563
+ blocked: true,
18564
+ path: absolutePath,
18565
+ chars: selectedText.length,
18566
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18567
+ startLine: selection.firstLine,
18568
+ totalFileLines: textContent.split("\n").length,
18569
+ firstLineBytes: Buffer.byteLength(selection.lines[0] ?? "", "utf8"),
18570
+ byteGuidance: false
18571
+ }));
18572
+ return;
18573
+ }
18574
+ content = [{
18575
+ type: "text",
18576
+ text: selectedText
18577
+ }];
18578
+ resolve({
18579
+ content,
18580
+ details: readSourceMeta(absolutePath)
18581
+ });
18582
+ return;
18583
+ }
18584
+ let tree;
18585
+ if (ops.stat && ops.listDir) {
18586
+ if ((await ops.stat(absolutePath))?.isDirectory) tree = await buildDirectoryTreeFromOperations(absolutePath, { listDir: ops.listDir }, {
18079
18587
  maxDepth: 2,
18080
18588
  perDirLimit: 12,
18081
18589
  rootLimit: null
18082
18590
  });
18083
- if (tree) {
18084
- const allLines = tree.rendered.split("\n");
18085
- const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
18086
- const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18087
- if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
18088
- resolve({
18089
- content: [{
18090
- type: "text",
18091
- text: `Requested line ${startLine + 1} is beyond end of directory (${allLines.length} lines total).`
18092
- }],
18093
- details: void 0
18094
- });
18095
- return;
18591
+ } else if (!options?.operations && (await stat$2(absolutePath)).isDirectory()) tree = await buildDirectoryTree(absolutePath, {
18592
+ maxDepth: 2,
18593
+ perDirLimit: 12,
18594
+ rootLimit: null
18595
+ });
18596
+ if (tree) {
18597
+ const allLines = tree.rendered.split("\n");
18598
+ const rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(allLines, effectiveRanges);
18599
+ const startLine = rangeSelection ? rangeSelection.firstLine - 1 : effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18600
+ if (startLine >= allLines.length || effectiveRanges && rangeSelection?.selectedLines.length === 0) {
18601
+ resolve({
18602
+ content: [{
18603
+ type: "text",
18604
+ text: `Requested line ${startLine + 1} is beyond end of directory (${allLines.length} lines total).`
18605
+ }],
18606
+ details: void 0
18607
+ });
18608
+ return;
18609
+ }
18610
+ const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
18611
+ content = [{
18612
+ type: "text",
18613
+ text: (rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine)).join("\n")
18614
+ }];
18615
+ const meta = {
18616
+ ...readSourceMeta(absolutePath).meta,
18617
+ ...tree.truncated ? { limits: {
18618
+ perDirLimit: 12,
18619
+ totalLines: tree.totalLines
18620
+ } } : {}
18621
+ };
18622
+ resolve({
18623
+ content,
18624
+ details: {
18625
+ isDirectory: true,
18626
+ resolvedPath: absolutePath,
18627
+ meta
18096
18628
  }
18097
- const endLine = effectiveLimit !== void 0 ? Math.min(startLine + effectiveLimit, allLines.length) : allLines.length;
18629
+ });
18630
+ return;
18631
+ }
18632
+ const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : void 0;
18633
+ if (mimeType) {
18634
+ const buffer = await ops.readFile(absolutePath);
18635
+ const processed = await processImage(buffer, mimeType, {
18636
+ autoResizeImages,
18637
+ resizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions
18638
+ });
18639
+ if (!processed.ok) content = [{
18640
+ type: "text",
18641
+ text: `Read image file [${mimeType}]\n${processed.message}`
18642
+ }];
18643
+ else {
18644
+ let textNote = `Read image file [${processed.mimeType}]`;
18645
+ if (processed.hints.length > 0) textNote += `\n${processed.hints.join("\n")}`;
18098
18646
  content = [{
18099
18647
  type: "text",
18100
- text: (rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine)).join("\n")
18648
+ text: textNote
18649
+ }, {
18650
+ type: "image",
18651
+ data: processed.data,
18652
+ mimeType: processed.mimeType
18101
18653
  }];
18102
- const meta = {
18103
- ...readSourceMeta(absolutePath).meta,
18104
- ...tree.truncated ? { limits: {
18105
- perDirLimit: 12,
18106
- totalLines: tree.totalLines
18107
- } } : {}
18654
+ if (ctx?.model && !ctx.model.input.includes("image")) details = {
18655
+ ...readSourceMeta(absolutePath),
18656
+ imageUnsupportedByModel: ctx.model.id
18108
18657
  };
18109
- resolve({
18110
- content,
18111
- details: {
18112
- isDirectory: true,
18113
- resolvedPath: absolutePath,
18114
- meta
18658
+ }
18659
+ } else {
18660
+ const offsetStartLine = effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18661
+ const plan = effectiveRanges?.length ? {
18662
+ ranges: effectiveRanges,
18663
+ exact: rawOutput === true
18664
+ } : { firstLine: offsetStartLine + 1 };
18665
+ const notebookView = isNotebookPath(absolutePath) && !rawOutput;
18666
+ let selection;
18667
+ if (conflictsOnly || notebookView) {
18668
+ const buffer = await ops.readFile(absolutePath);
18669
+ const textContent = notebookView ? await readEditableNotebookText(absolutePath, effectivePath) : buffer.toString("utf-8");
18670
+ const lineTextContent = rawOutput ? textContent : textContent.replace(/\r\n/g, "\n");
18671
+ const sourceLines = lineTextContent.split("\n");
18672
+ let allLines = rawOutput || !lineTextContent.endsWith("\n") ? sourceLines : sourceLines.slice(0, -1);
18673
+ if (conflictsOnly) {
18674
+ registerConflictBlocks(executionCwd, absolutePath, parseConflictBytes(absolutePath, buffer));
18675
+ const conflictLines = [];
18676
+ let inConflict = false;
18677
+ for (const line of allLines) {
18678
+ if (line.startsWith("<<<<<<<")) inConflict = true;
18679
+ if (inConflict) conflictLines.push(line);
18680
+ if (line.startsWith(">>>>>>>")) inConflict = false;
18115
18681
  }
18682
+ if (conflictLines.length > 0) allLines = conflictLines;
18683
+ else {
18684
+ signal?.removeEventListener("abort", onAbort);
18685
+ resolve({
18686
+ content: [{
18687
+ type: "text",
18688
+ text: "No conflict markers found"
18689
+ }],
18690
+ details: void 0
18691
+ });
18692
+ return;
18693
+ }
18694
+ }
18695
+ selection = selectReadLinesFromList(allLines, plan, READ_TOOL_MAX_RESULT_CHARS);
18696
+ } else selection = await selectReadLinesFromChunks(ops.createReadStream?.(absolutePath, { signal }) ?? readWholeFile(ops, absolutePath), plan, {
18697
+ raw: rawOutput === true,
18698
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18699
+ signal
18700
+ });
18701
+ const totalFileLines = selection.totalLines;
18702
+ const startLine = "ranges" in plan ? selection.firstLineNumber - 1 : offsetStartLine;
18703
+ const startLineDisplay = startLine + 1;
18704
+ if (startLine >= totalFileLines || "ranges" in plan && selection.count === 0) {
18705
+ resolve({
18706
+ content: [{
18707
+ type: "text",
18708
+ text: `Requested line ${effectiveRanges?.[0]?.start ?? startLineDisplay} is beyond end of file (${totalFileLines} lines total). Use ${effectivePath}:${Math.max(1, totalFileLines)} to read the final line.`
18709
+ }],
18710
+ details: void 0
18116
18711
  });
18117
18712
  return;
18118
18713
  }
18119
- const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : void 0;
18120
- if (mimeType) {
18121
- const buffer = await ops.readFile(absolutePath);
18122
- const processed = await processImage(buffer, mimeType, {
18123
- autoResizeImages,
18124
- resizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions
18125
- });
18126
- if (!processed.ok) content = [{
18714
+ const selectedLines = selection.lines;
18715
+ if (selection.chars > READ_TOOL_MAX_RESULT_CHARS) {
18716
+ const firstLineBytes = selection.firstLineBytes;
18717
+ const byteGuidance = selection.countBeforeTrailingEmpty <= 1 || firstLineBytes > 51200;
18718
+ const oversizedRead = {
18719
+ blocked: true,
18720
+ path: absolutePath,
18721
+ chars: selection.chars,
18722
+ maxChars: READ_TOOL_MAX_RESULT_CHARS,
18723
+ startLine: startLineDisplay,
18724
+ totalFileLines,
18725
+ firstLineBytes,
18726
+ byteGuidance
18727
+ };
18728
+ details = {
18729
+ oversizedRead,
18730
+ meta: readSourceMeta(absolutePath).meta
18731
+ };
18732
+ content = [{
18127
18733
  type: "text",
18128
- text: `Read image file [${mimeType}]\n${processed.message}`
18734
+ text: buildOversizedReadMessage(oversizedRead)
18129
18735
  }];
18130
- else {
18131
- let textNote = `Read image file [${processed.mimeType}]`;
18132
- if (processed.hints.length > 0) textNote += `\n${processed.hints.join("\n")}`;
18133
- content = [{
18134
- type: "text",
18135
- text: textNote
18136
- }, {
18137
- type: "image",
18138
- data: processed.data,
18139
- mimeType: processed.mimeType
18140
- }];
18141
- if (ctx?.model && !ctx.model.input.includes("image")) details = {
18142
- ...readSourceMeta(absolutePath),
18143
- imageUnsupportedByModel: ctx.model.id
18144
- };
18145
- }
18146
18736
  } else {
18147
- const offsetStartLine = effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;
18148
- const plan = effectiveRanges?.length ? {
18149
- ranges: effectiveRanges,
18150
- exact: rawOutput === true
18151
- } : { firstLine: offsetStartLine + 1 };
18152
- const notebookView = isNotebookPath(absolutePath) && !rawOutput;
18153
- let selection;
18154
- if (conflictsOnly || notebookView) {
18155
- const buffer = await ops.readFile(absolutePath);
18156
- const textContent = notebookView ? await readEditableNotebookText(absolutePath, effectivePath) : buffer.toString("utf-8");
18157
- const lineTextContent = rawOutput ? textContent : textContent.replace(/\r\n/g, "\n");
18158
- const sourceLines = lineTextContent.split("\n");
18159
- let allLines = rawOutput || !lineTextContent.endsWith("\n") ? sourceLines : sourceLines.slice(0, -1);
18160
- if (conflictsOnly) {
18161
- registerConflictBlocks(executionCwd, absolutePath, parseConflictBytes(absolutePath, buffer));
18162
- const conflictLines = [];
18163
- let inConflict = false;
18164
- for (const line of allLines) {
18165
- if (line.startsWith("<<<<<<<")) inConflict = true;
18166
- if (inConflict) conflictLines.push(line);
18167
- if (line.startsWith(">>>>>>>")) inConflict = false;
18168
- }
18169
- if (conflictLines.length > 0) allLines = conflictLines;
18170
- else {
18171
- signal?.removeEventListener("abort", onAbort);
18172
- resolve({
18173
- content: [{
18174
- type: "text",
18175
- text: "No conflict markers found"
18176
- }],
18177
- details: void 0
18178
- });
18179
- return;
18737
+ const truncation = truncateHead(selectedLines.join("\n"));
18738
+ const shownLines = truncation.truncated ? truncation.outputLines : selectedLines.length;
18739
+ const shownLineNumbers = "ranges" in plan ? selection.lineNumbers.slice(0, shownLines) : void 0;
18740
+ const lastShownLine = shownLineNumbers?.at(-1) ?? startLine + shownLines;
18741
+ let outputText = shownLineNumbers && !rawOutput ? formatSelectedLines(selectedLines.slice(0, shownLines), shownLineNumbers, totalFileLines) : truncation.content;
18742
+ if (truncation.firstLineExceedsLimit) {
18743
+ outputText = `[Line ${startLineDisplay} is ${formatSize(selection.firstLineBytes)}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${effectivePath} | head -c ${DEFAULT_MAX_BYTES}]`;
18744
+ details = {
18745
+ truncation,
18746
+ meta: {
18747
+ source: absolutePath,
18748
+ sourcePath: absolutePath,
18749
+ truncation
18180
18750
  }
18181
- }
18182
- selection = selectReadLinesFromList(allLines, plan, READ_TOOL_MAX_RESULT_CHARS);
18183
- } else selection = await selectReadLinesFromChunks(ops.createReadStream?.(absolutePath, { signal }) ?? readWholeFile(ops, absolutePath), plan, {
18184
- raw: rawOutput === true,
18185
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
18186
- signal
18187
- });
18188
- const totalFileLines = selection.totalLines;
18189
- const startLine = "ranges" in plan ? selection.firstLineNumber - 1 : offsetStartLine;
18190
- const startLineDisplay = startLine + 1;
18191
- if (startLine >= totalFileLines || "ranges" in plan && selection.count === 0) {
18192
- resolve({
18193
- content: [{
18194
- type: "text",
18195
- text: `Requested line ${effectiveRanges?.[0]?.start ?? startLineDisplay} is beyond end of file (${totalFileLines} lines total). Use ${effectivePath}:${Math.max(1, totalFileLines)} to read the final line.`
18196
- }],
18197
- details: void 0
18198
- });
18199
- return;
18200
- }
18201
- const selectedLines = selection.lines;
18202
- if (selection.chars > READ_TOOL_MAX_RESULT_CHARS) {
18203
- const firstLineBytes = selection.firstLineBytes;
18204
- const byteGuidance = selection.countBeforeTrailingEmpty <= 1 || firstLineBytes > 51200;
18205
- const oversizedRead = {
18206
- blocked: true,
18207
- path: absolutePath,
18208
- chars: selection.chars,
18209
- maxChars: READ_TOOL_MAX_RESULT_CHARS,
18210
- startLine: startLineDisplay,
18211
- totalFileLines,
18212
- firstLineBytes,
18213
- byteGuidance
18214
18751
  };
18752
+ } else if (truncation.truncated) {
18753
+ const nextOffset = lastShownLine + 1;
18754
+ outputText += truncation.truncatedBy === "lines" ? `\n\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines}. Continue with path selector :${nextOffset}.]` : `\n\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Continue with path selector :${nextOffset}.]`;
18215
18755
  details = {
18216
- oversizedRead,
18217
- meta: readSourceMeta(absolutePath).meta
18756
+ truncation,
18757
+ meta: {
18758
+ source: absolutePath,
18759
+ sourcePath: absolutePath,
18760
+ truncation
18761
+ }
18218
18762
  };
18219
- content = [{
18220
- type: "text",
18221
- text: buildOversizedReadMessage(oversizedRead)
18222
- }];
18223
- } else {
18224
- const truncation = truncateHead(selectedLines.join("\n"));
18225
- const shownLines = truncation.truncated ? truncation.outputLines : selectedLines.length;
18226
- const shownLineNumbers = "ranges" in plan ? selection.lineNumbers.slice(0, shownLines) : void 0;
18227
- const lastShownLine = shownLineNumbers?.at(-1) ?? startLine + shownLines;
18228
- let outputText = shownLineNumbers && !rawOutput ? formatSelectedLines(selectedLines.slice(0, shownLines), shownLineNumbers, totalFileLines) : truncation.content;
18229
- if (truncation.firstLineExceedsLimit) {
18230
- outputText = `[Line ${startLineDisplay} is ${formatSize(selection.firstLineBytes)}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${effectivePath} | head -c ${DEFAULT_MAX_BYTES}]`;
18231
- details = {
18232
- truncation,
18233
- meta: {
18234
- source: absolutePath,
18235
- sourcePath: absolutePath,
18236
- truncation
18237
- }
18238
- };
18239
- } else if (truncation.truncated) {
18240
- const nextOffset = lastShownLine + 1;
18241
- outputText += truncation.truncatedBy === "lines" ? `\n\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines}. Continue with path selector :${nextOffset}.]` : `\n\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Continue with path selector :${nextOffset}.]`;
18242
- details = {
18243
- truncation,
18244
- meta: {
18245
- source: absolutePath,
18246
- sourcePath: absolutePath,
18247
- truncation
18248
- }
18249
- };
18250
- } else if (!rawOutput && lastShownLine < totalFileLines) {
18251
- const remaining = totalFileLines - lastShownLine;
18252
- outputText += `\n\n[${remaining} more lines in file. Continue with path selector :${lastShownLine + 1}.]`;
18253
- }
18254
- content = [{
18255
- type: "text",
18256
- text: outputText
18257
- }];
18763
+ } else if (!rawOutput && lastShownLine < totalFileLines) {
18764
+ const remaining = totalFileLines - lastShownLine;
18765
+ outputText += `\n\n[${remaining} more lines in file. Continue with path selector :${lastShownLine + 1}.]`;
18258
18766
  }
18767
+ content = [{
18768
+ type: "text",
18769
+ text: outputText
18770
+ }];
18259
18771
  }
18260
- if (aborted) return;
18261
- signal?.removeEventListener("abort", onAbort);
18262
- resolve({
18263
- content,
18264
- details: details ?? readSourceMeta(absolutePath)
18265
- });
18266
- } catch (error) {
18267
- signal?.removeEventListener("abort", onAbort);
18268
- if (!aborted) reject(error);
18269
18772
  }
18270
- })();
18271
- }).then((result) => result.details?.oversizedRead?.blocked ? {
18272
- ...result,
18273
- isError: true
18274
- } : {
18275
- ...result,
18276
- structuredContent: toReadOutput(result.content)
18277
- });
18773
+ if (aborted) return;
18774
+ signal?.removeEventListener("abort", onAbort);
18775
+ resolve({
18776
+ content,
18777
+ details: details ?? readSourceMeta(absolutePath)
18778
+ });
18779
+ } catch (error) {
18780
+ signal?.removeEventListener("abort", onAbort);
18781
+ if (!aborted) reject(error);
18782
+ }
18783
+ })();
18784
+ }).then((result) => result.details?.oversizedRead?.blocked ? {
18785
+ ...result,
18786
+ isError: true
18787
+ } : {
18788
+ ...result,
18789
+ structuredContent: toReadOutput(result.content)
18790
+ });
18791
+ };
18792
+ return withBuiltinToolBlockRenderers({
18793
+ name: "read",
18794
+ label: "read",
18795
+ description: "Read files, directories, archives, SQLite databases, internal resources (including history:// for past sessions), images, documents, and URLs through one path string.",
18796
+ promptSnippet: readToolSystemPromptContribution.snippet,
18797
+ promptGuidelines: [...readToolSystemPromptContribution.guidelines],
18798
+ constrainedSampling: {
18799
+ type: "json_schema",
18800
+ strict: "prefer"
18801
+ },
18802
+ parameters: readSchema,
18803
+ outputSchema: readOutputSchema,
18804
+ maxResultSizeChars: 1e400,
18805
+ prepareArguments: (args) => prepareHistoryAwareInput(args, "read", "path"),
18806
+ async execute(toolCallId, input, signal, _onUpdate, ctx) {
18807
+ if (input.action !== void 0) return asReadResult(await waitForHistoryTask(options?.historyTasks?.(), input, "read", signal));
18808
+ const { path, wait } = input;
18809
+ const policy = validateHistoryWait(wait);
18810
+ const registry = namesHistoryUrl(path) ? options?.historyTasks?.() : void 0;
18811
+ if (!registry) return readPath(toolCallId, path, signal, ctx);
18812
+ return asReadResult(await registry.run({
18813
+ kind: "read",
18814
+ subject: path,
18815
+ wait: policy,
18816
+ signal,
18817
+ run: (callSignal) => readPath(toolCallId, path, callSignal, ctx)
18818
+ }));
18278
18819
  },
18279
18820
  renderCall(args, theme, context) {
18280
18821
  const text = context.lastComponent ?? new Text("", 0, 0);
@@ -18787,18 +19328,30 @@ function buildSearchDetails(base, text, cwd, scopePath, missingPaths = []) {
18787
19328
  };
18788
19329
  }
18789
19330
  // dist/core/tools/search.js
18790
- const searchSchema = Type$1.Object({
19331
+ const searchBaseSchema = Type$1.Object({
18791
19332
  pattern: Type$1.String({ description: "Regex pattern. Whitespace-only patterns are rejected; otherwise the pattern is preserved verbatim." }),
18792
19333
  paths: Type$1.Optional(Type$1.Union([Type$1.String({ description: "File, directory, glob, internal URL (skill://, local://, artifact://, conflict://, history://), or <file>:<lines> selector to search. Omitted or empty searches the workspace root." }), Type$1.Array(Type$1.String({ description: "File, directory, glob, internal URL, or <file>:<lines> selector to search." }))])),
18793
19334
  i: Type$1.Optional(Type$1.Boolean({ description: "Case-insensitive search." })),
18794
19335
  gitignore: Type$1.Optional(Type$1.Boolean({ description: "Respect gitignore." })),
18795
19336
  case: Type$1.Optional(Type$1.Boolean({ description: "Set false for case-insensitive search (oh-my-pi compatibility)." })),
18796
- skip: Type$1.Optional(Type$1.Union([Type$1.Number({ description: "Files to skip before collecting results; use to paginate when the previous call hit the file limit." }), Type$1.Null()]))
19337
+ skip: Type$1.Optional(Type$1.Union([Type$1.Number({ description: "Files to skip before collecting results; use to paginate when the previous call hit the file limit." }), Type$1.Null()])),
19338
+ wait: Type$1.Optional(historyWaitSchema)
18797
19339
  }, { additionalProperties: false });
19340
+ const searchSchema = Type$1.Unsafe({
19341
+ ...searchBaseSchema,
19342
+ properties: {
19343
+ ...searchBaseSchema.properties,
19344
+ ...historyWaitActionProperties
19345
+ },
19346
+ required: []
19347
+ });
18798
19348
  const searchToolSystemPromptContribution = Object.freeze({
18799
19349
  snippet: "Search file contents with regex patterns.",
18800
- guidelines: Object.freeze([])
19350
+ guidelines: Object.freeze([HISTORY_TASK_GUIDELINE])
18801
19351
  });
19352
+ function asSearchResult(result) {
19353
+ return result;
19354
+ }
18802
19355
  /** An existing path is used exactly, so `app/[id]/page.tsx` is that file, not the pattern `app/[id]` (#5177). */
18803
19356
  async function splitSearchPath(value, cwd) {
18804
19357
  return await pathExists(await resolveToCwdAsync(normalizePathLikeInput(value), cwd)) ? literalPathLike(value) : splitPathLikeGlob(value);
@@ -19175,287 +19728,303 @@ function createSearchToolDefinition(cwd, options) {
19175
19728
  ...options,
19176
19729
  nativeCache: false
19177
19730
  });
19178
- return withBuiltinToolBlockRenderers({
19179
- ...grepDefinition,
19180
- name: "search",
19181
- label: "search",
19182
- description: "Search file contents with a regex across files, directories, globs, and internal URLs, including history:// for past sessions.",
19183
- promptSnippet: searchToolSystemPromptContribution.snippet,
19184
- ...experimentalToolSamplingProperty(),
19185
- parameters: searchSchema,
19186
- async execute(toolCallId, params, signal, onUpdate, ctx) {
19187
- const resourceCtx = ctx;
19188
- const executionCwd = ctx?.cwd || cwd;
19189
- if (params.pattern.trim() === "") throw new Error("Pattern must not be empty");
19190
- const targets = await normalizeSearchTargets(params.paths, executionCwd);
19191
- const ignoreCase = params.i === true || params.case === false;
19192
- const contextBefore = options?.contextBefore ?? 1;
19193
- const contextAfter = options?.contextAfter ?? 3;
19194
- const searchContext = Math.max(contextBefore, contextAfter);
19195
- const isSingleFileSearch = targets.length === 1 && await stat(await resolveToCwdAsync(targets[0].path, executionCwd)).then((stat) => stat.isFile()).catch(() => false);
19196
- const limit = isSingleFileSearch ? SINGLE_FILE_MATCHES : DEFAULT_LIMIT;
19197
- let skip = normalizeSkip(params.skip);
19198
- const singleFileSkipIgnored = skip > 0 && isSingleFileSearch;
19199
- if (singleFileSkipIgnored) skip = 0;
19200
- for (const target of targets) {
19201
- if (target.archive || target.sqlite || target.internal) continue;
19202
- if (target.lineRanges && !await stat(await resolveToCwdAsync(target.path, executionCwd)).then((stat) => stat.isFile()).catch(() => false)) throw new Error("Line-range search selectors are only supported for single files");
19731
+ const runSearch = async (toolCallId, params, signal, onUpdate, ctx) => {
19732
+ const resourceCtx = ctx;
19733
+ const executionCwd = ctx?.cwd || cwd;
19734
+ if (params.pattern.trim() === "") throw new Error("Pattern must not be empty");
19735
+ const targets = await normalizeSearchTargets(params.paths, executionCwd);
19736
+ const ignoreCase = params.i === true || params.case === false;
19737
+ const contextBefore = options?.contextBefore ?? 1;
19738
+ const contextAfter = options?.contextAfter ?? 3;
19739
+ const searchContext = Math.max(contextBefore, contextAfter);
19740
+ const isSingleFileSearch = targets.length === 1 && await stat(await resolveToCwdAsync(targets[0].path, executionCwd)).then((stat) => stat.isFile()).catch(() => false);
19741
+ const limit = isSingleFileSearch ? SINGLE_FILE_MATCHES : DEFAULT_LIMIT;
19742
+ let skip = normalizeSkip(params.skip);
19743
+ const singleFileSkipIgnored = skip > 0 && isSingleFileSearch;
19744
+ if (singleFileSkipIgnored) skip = 0;
19745
+ for (const target of targets) {
19746
+ if (target.archive || target.sqlite || target.internal) continue;
19747
+ if (target.lineRanges && !await stat(await resolveToCwdAsync(target.path, executionCwd)).then((stat) => stat.isFile()).catch(() => false)) throw new Error("Line-range search selectors are only supported for single files");
19748
+ }
19749
+ const results = [];
19750
+ const groups = [];
19751
+ const skippedMissingPaths = [];
19752
+ const scopePath = targets.map((target) => target.path).join(", ") || ".";
19753
+ let pageFullWithMore = false;
19754
+ let internalSearchCapped = false;
19755
+ let remaining = limit;
19756
+ const targetHasMatch = async (target) => {
19757
+ if (target.archive || target.sqlite || target.internal) {
19758
+ const archive = target.archive ? await resolveArchiveSelector(target.archive, executionCwd) : void 0;
19759
+ return groupSearchOutput(filterTargetLineRanges(archive ? await searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? await searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal, executionCwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter, {
19760
+ ...target.lineRanges === void 0 ? {} : { ranges: target.lineRanges },
19761
+ ...signal === void 0 ? {} : { signal }
19762
+ }, {
19763
+ first: 0,
19764
+ end: 0
19765
+ }), target, contextBefore, contextAfter)).length > 0;
19203
19766
  }
19204
- const results = [];
19205
- const groups = [];
19206
- const skippedMissingPaths = [];
19207
- const scopePath = targets.map((target) => target.path).join(", ") || ".";
19208
- let pageFullWithMore = false;
19209
- let internalSearchCapped = false;
19210
- let remaining = limit;
19211
- const targetHasMatch = async (target) => {
19212
- if (target.archive || target.sqlite || target.internal) {
19213
- const archive = target.archive ? await resolveArchiveSelector(target.archive, executionCwd) : void 0;
19214
- return groupSearchOutput(filterTargetLineRanges(archive ? await searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? await searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal, executionCwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter, {
19215
- ...target.lineRanges === void 0 ? {} : { ranges: target.lineRanges },
19216
- ...signal === void 0 ? {} : { signal }
19217
- }, {
19218
- first: 0,
19219
- end: 0
19220
- }), target, contextBefore, contextAfter)).length > 0;
19221
- }
19222
- const ranged = await searchFileLineRanges(target, executionCwd, params.pattern, ignoreCase, contextBefore, contextAfter);
19223
- if (ranged !== void 0) return groupSearchOutput(ranged).length > 0;
19224
- return (await grepDefinition.execute(toolCallId, {
19225
- pattern: params.pattern,
19226
- path: target.path,
19227
- glob: target.glob,
19228
- ignoreCase,
19229
- literal: false,
19230
- context: 0,
19231
- limit: 1,
19232
- gitignore: params.gitignore
19233
- }, signal, void 0, ctx)).content.some((item) => item.type === "text" && item.text && item.text !== "No matches found");
19234
- };
19235
- for (const target of targets) {
19236
- if (skip === 0 && remaining <= 0) {
19237
- if (!target.archive && !target.sqlite && !target.internal && targets.length > 1 && await stat(await resolveToCwdAsync(target.path, executionCwd)).then(() => false).catch(() => true)) {
19238
- skippedMissingPaths.push(target.path);
19239
- continue;
19240
- }
19241
- if (await targetHasMatch(target)) {
19242
- pageFullWithMore = true;
19243
- break;
19244
- }
19245
- continue;
19246
- }
19247
- if (target.archive || target.sqlite || target.internal) {
19248
- const archive = target.archive ? await resolveArchiveSelector(target.archive, executionCwd) : void 0;
19249
- let text = archive ? await searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? await searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal, executionCwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter, {
19250
- ...target.lineRanges === void 0 ? {} : { ranges: target.lineRanges },
19251
- ...signal === void 0 ? {} : { signal }
19252
- }, {
19253
- first: Math.max(0, skip - groups.length),
19254
- end: skip > 0 ? skip + limit - groups.length : remaining
19255
- });
19256
- if (archive && target.archive) text = text.split(archive.archivePath).join(target.archive.archivePath);
19257
- if (target.sqlite) text = text.split(target.sqlite.databasePath).join(target.path.match(/^(.+?\.(?:sqlite3?|db3?))/i)?.[1] ?? target.sqlite.databasePath);
19258
- text = text || "No matches found";
19259
- text = filterTargetLineRanges(text, target, contextBefore, contextAfter);
19260
- const outputGroups = groupSearchOutput(text);
19261
- if (skip > 0) groups.push(...outputGroups.map((group) => ({
19262
- targetPath: target.path,
19263
- virtual: isVirtualSearchTarget(target),
19264
- group
19265
- })));
19266
- else if (outputGroups.length > 0) {
19267
- const hadMore = outputGroups.length > remaining;
19268
- text = formatSearchGroups(outputGroups, remaining);
19269
- if (hadMore) {
19270
- text += `\n\n${continuationHint(limit, skip)}`;
19271
- pageFullWithMore = true;
19272
- }
19273
- remaining -= Math.min(remaining, outputGroups.length);
19274
- } else if (text && text !== "No matches found") remaining--;
19275
- else text = "No matches found";
19276
- if (skip === 0) results.push({
19277
- content: [{
19278
- type: "text",
19279
- text
19280
- }],
19281
- details: void 0
19282
- });
19283
- continue;
19284
- }
19285
- if (targets.length > 1 && await stat(await resolveToCwdAsync(target.path, executionCwd)).then(() => false).catch(() => true)) {
19767
+ const ranged = await searchFileLineRanges(target, executionCwd, params.pattern, ignoreCase, contextBefore, contextAfter);
19768
+ if (ranged !== void 0) return groupSearchOutput(ranged).length > 0;
19769
+ return (await grepDefinition.execute(toolCallId, {
19770
+ pattern: params.pattern,
19771
+ path: target.path,
19772
+ glob: target.glob,
19773
+ ignoreCase,
19774
+ literal: false,
19775
+ context: 0,
19776
+ limit: 1,
19777
+ gitignore: params.gitignore
19778
+ }, signal, void 0, ctx)).content.some((item) => item.type === "text" && item.text && item.text !== "No matches found");
19779
+ };
19780
+ for (const target of targets) {
19781
+ if (skip === 0 && remaining <= 0) {
19782
+ if (!target.archive && !target.sqlite && !target.internal && targets.length > 1 && await stat(await resolveToCwdAsync(target.path, executionCwd)).then(() => false).catch(() => true)) {
19286
19783
  skippedMissingPaths.push(target.path);
19287
- results.push({
19288
- content: [{
19289
- type: "text",
19290
- text: "No matches found"
19291
- }],
19292
- details: void 0
19293
- });
19294
19784
  continue;
19295
19785
  }
19296
- const rangedText = await searchFileLineRanges(target, executionCwd, params.pattern, ignoreCase, contextBefore, contextAfter);
19297
- if (rangedText !== void 0) {
19298
- let text = applyDefaultSearchContext(rangedText, contextBefore, contextAfter) || "No matches found";
19299
- const result = {
19300
- content: [{
19301
- type: "text",
19302
- text
19303
- }],
19304
- details: void 0
19305
- };
19306
- results.push(result);
19307
- const outputGroups = groupSearchOutput(text);
19308
- if (skip > 0) groups.push(...outputGroups.map((group) => ({
19309
- targetPath: target.path,
19310
- virtual: false,
19311
- group
19312
- })));
19313
- else if (!isSingleFileSearch && outputGroups.length > 0) {
19314
- const hadMore = outputGroups.length > remaining;
19315
- text = formatSearchGroups(outputGroups, remaining);
19316
- if (hadMore) {
19317
- result.details = fileLimitDetails(limit);
19318
- pageFullWithMore = true;
19319
- }
19320
- remaining -= Math.min(remaining, outputGroups.length);
19321
- result.content = [{
19322
- type: "text",
19323
- text
19324
- }];
19325
- }
19326
- continue;
19786
+ if (await targetHasMatch(target)) {
19787
+ pageFullWithMore = true;
19788
+ break;
19327
19789
  }
19328
- const result = await grepDefinition.execute(toolCallId, {
19329
- pattern: params.pattern,
19330
- path: target.path,
19331
- glob: target.glob,
19332
- ignoreCase,
19333
- literal: false,
19334
- context: searchContext,
19335
- maxCountPerFile: isSingleFileSearch ? SINGLE_FILE_MATCHES : MULTI_FILE_PER_FILE_MATCHES,
19336
- limit: INTERNAL_SKIP_LIMIT,
19337
- gitignore: params.gitignore
19338
- }, signal, onUpdate, ctx);
19339
- results.push(result);
19340
- if (result.details?.matchLimitReached) internalSearchCapped = true;
19341
- let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((text) => typeof text === "string").join("\n");
19342
- text = filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter);
19343
- if (text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || "No matches found";
19790
+ continue;
19791
+ }
19792
+ if (target.archive || target.sqlite || target.internal) {
19793
+ const archive = target.archive ? await resolveArchiveSelector(target.archive, executionCwd) : void 0;
19794
+ let text = archive ? await searchArchiveSelector(archive, params.pattern, ignoreCase, false, contextBefore, contextAfter) : target.sqlite ? await searchSqliteSelector(target.sqlite, params.pattern, ignoreCase, contextBefore, contextAfter) : await searchInternalSelector(target.internal, executionCwd, params.pattern, ignoreCase, false, resourceCtx, contextBefore, contextAfter, {
19795
+ ...target.lineRanges === void 0 ? {} : { ranges: target.lineRanges },
19796
+ ...signal === void 0 ? {} : { signal }
19797
+ }, {
19798
+ first: Math.max(0, skip - groups.length),
19799
+ end: skip > 0 ? skip + limit - groups.length : remaining
19800
+ });
19801
+ if (archive && target.archive) text = text.split(archive.archivePath).join(target.archive.archivePath);
19802
+ if (target.sqlite) text = text.split(target.sqlite.databasePath).join(target.path.match(/^(.+?\.(?:sqlite3?|db3?))/i)?.[1] ?? target.sqlite.databasePath);
19803
+ text = text || "No matches found";
19804
+ text = filterTargetLineRanges(text, target, contextBefore, contextAfter);
19344
19805
  const outputGroups = groupSearchOutput(text);
19345
19806
  if (skip > 0) groups.push(...outputGroups.map((group) => ({
19346
19807
  targetPath: target.path,
19347
- virtual: false,
19808
+ virtual: isVirtualSearchTarget(target),
19348
19809
  group
19349
19810
  })));
19350
- else if (!isSingleFileSearch && outputGroups.length > 0) {
19811
+ else if (outputGroups.length > 0) {
19351
19812
  const hadMore = outputGroups.length > remaining;
19352
19813
  text = formatSearchGroups(outputGroups, remaining);
19353
19814
  if (hadMore) {
19354
- result.details = {
19355
- ...result.details ?? {},
19356
- ...fileLimitDetails(limit)
19357
- };
19815
+ text += `\n\n${continuationHint(limit, skip)}`;
19358
19816
  pageFullWithMore = true;
19359
19817
  }
19360
19818
  remaining -= Math.min(remaining, outputGroups.length);
19361
- }
19362
- result.content = [{
19363
- type: "text",
19364
- text
19365
- }];
19819
+ } else if (text && text !== "No matches found") remaining--;
19820
+ else text = "No matches found";
19821
+ if (skip === 0) results.push({
19822
+ content: [{
19823
+ type: "text",
19824
+ text
19825
+ }],
19826
+ details: void 0
19827
+ });
19828
+ continue;
19366
19829
  }
19367
- const details = {};
19368
- for (const result of results) {
19369
- if (result.details?.truncation) details.truncation = result.details.truncation;
19370
- if (result.details?.matchLimitReached) details.matchLimitReached = result.details.matchLimitReached;
19371
- if (hasFileLimit(result.details)) markFileLimit(details, limit);
19372
- if (result.details?.linesTruncated) details.linesTruncated = true;
19830
+ if (targets.length > 1 && await stat(await resolveToCwdAsync(target.path, executionCwd)).then(() => false).catch(() => true)) {
19831
+ skippedMissingPaths.push(target.path);
19832
+ results.push({
19833
+ content: [{
19834
+ type: "text",
19835
+ text: "No matches found"
19836
+ }],
19837
+ details: void 0
19838
+ });
19839
+ continue;
19373
19840
  }
19374
- if (skip > 0) {
19375
- const renderedPages = [];
19376
- let remainingMatches = limit;
19377
- for (const item of groups.slice(skip)) {
19378
- if (remainingMatches <= 0) break;
19379
- const raw = formatSearchGroups([item.group], 1);
19380
- remainingMatches--;
19381
- if (raw) renderedPages.push(item.virtual ? raw : await cwdRelativeSearchOutput(raw, executionCwd, item.targetPath));
19382
- }
19383
- const hasMorePages = groups.slice(skip + limit).length > 0;
19384
- const cappedBeforeRequestedPage = internalSearchCapped && skip >= groups.length;
19385
- const capNotice = internalSearchCapped && !hasMorePages ? `\n\n${internalCapHint()}` : "";
19386
- const output = `${renderedPages.join("\n\n") || `No more results (skip=${skip})`}${hasMorePages ? `\n\n${continuationHint(limit, skip)}` : ""}${capNotice}`;
19387
- if (hasMorePages || cappedBeforeRequestedPage || capNotice) markFileLimit(details, limit);
19388
- const truncation = truncateHead(output, { maxLines: Number.MAX_SAFE_INTEGER });
19389
- let content = truncation.content;
19390
- if (truncation.truncated) {
19391
- details.truncation = truncation;
19392
- content += `\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;
19393
- }
19394
- return {
19841
+ const rangedText = await searchFileLineRanges(target, executionCwd, params.pattern, ignoreCase, contextBefore, contextAfter);
19842
+ if (rangedText !== void 0) {
19843
+ let text = applyDefaultSearchContext(rangedText, contextBefore, contextAfter) || "No matches found";
19844
+ const result = {
19395
19845
  content: [{
19396
19846
  type: "text",
19397
- text: content
19847
+ text
19398
19848
  }],
19399
- details: buildSearchDetails(details, content, executionCwd, scopePath, skippedMissingPaths)
19849
+ details: void 0
19400
19850
  };
19851
+ results.push(result);
19852
+ const outputGroups = groupSearchOutput(text);
19853
+ if (skip > 0) groups.push(...outputGroups.map((group) => ({
19854
+ targetPath: target.path,
19855
+ virtual: false,
19856
+ group
19857
+ })));
19858
+ else if (!isSingleFileSearch && outputGroups.length > 0) {
19859
+ const hadMore = outputGroups.length > remaining;
19860
+ text = formatSearchGroups(outputGroups, remaining);
19861
+ if (hadMore) {
19862
+ result.details = fileLimitDetails(limit);
19863
+ pageFullWithMore = true;
19864
+ }
19865
+ remaining -= Math.min(remaining, outputGroups.length);
19866
+ result.content = [{
19867
+ type: "text",
19868
+ text
19869
+ }];
19870
+ }
19871
+ continue;
19401
19872
  }
19402
- if (results.length === 1) {
19403
- const result = results[0];
19404
- let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((value) => typeof value === "string").join("\n");
19405
- text = filterTargetLineRanges(text, targets[0], contextBefore, contextAfter);
19406
- if (!isVirtualSearchTarget(targets[0]) && text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || "No matches found";
19407
- const skipNotice = singleFileSkipIgnored ? "\n\n[skip is ignored for single-file search; refine the pattern/path or search a directory to page matching files.]" : "";
19408
- if (isSingleFileSearch && text !== "No matches found") text = formatSearchGroups(groupSearchOutput(text), limit, limit);
19409
- if (text && text !== "No matches found") {
19410
- const renderedText = isVirtualSearchTarget(targets[0]) ? text : await cwdRelativeSearchOutput(text, executionCwd, targets[0]?.path ?? ".");
19411
- const pagedText = `${hasFileLimit(result.details) ? `${renderedText}\n\n${continuationHint(limit, skip)}` : renderedText}${skipNotice}`;
19412
- const truncation = truncateHead(pagedText, { maxLines: Number.MAX_SAFE_INTEGER });
19413
- if (truncation.truncated) return {
19414
- ...result,
19415
- content: [{
19416
- type: "text",
19417
- text: `${truncation.content}\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`
19418
- }],
19419
- details: buildSearchDetails({
19420
- ...result.details ?? {},
19421
- truncation
19422
- }, truncation.content, executionCwd, scopePath, skippedMissingPaths)
19423
- };
19424
- return {
19425
- ...result,
19426
- content: [{
19427
- type: "text",
19428
- text: pagedText
19429
- }],
19430
- details: buildSearchDetails(result.details, pagedText, executionCwd, scopePath, skippedMissingPaths)
19873
+ const result = await grepDefinition.execute(toolCallId, {
19874
+ pattern: params.pattern,
19875
+ path: target.path,
19876
+ glob: target.glob,
19877
+ ignoreCase,
19878
+ literal: false,
19879
+ context: searchContext,
19880
+ maxCountPerFile: isSingleFileSearch ? SINGLE_FILE_MATCHES : MULTI_FILE_PER_FILE_MATCHES,
19881
+ limit: INTERNAL_SKIP_LIMIT,
19882
+ gitignore: params.gitignore
19883
+ }, signal, onUpdate, ctx);
19884
+ results.push(result);
19885
+ if (result.details?.matchLimitReached) internalSearchCapped = true;
19886
+ let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((text) => typeof text === "string").join("\n");
19887
+ text = filterSearchOutputByLineRange(text, target.lineRanges, contextBefore, contextAfter);
19888
+ if (text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || "No matches found";
19889
+ const outputGroups = groupSearchOutput(text);
19890
+ if (skip > 0) groups.push(...outputGroups.map((group) => ({
19891
+ targetPath: target.path,
19892
+ virtual: false,
19893
+ group
19894
+ })));
19895
+ else if (!isSingleFileSearch && outputGroups.length > 0) {
19896
+ const hadMore = outputGroups.length > remaining;
19897
+ text = formatSearchGroups(outputGroups, remaining);
19898
+ if (hadMore) {
19899
+ result.details = {
19900
+ ...result.details ?? {},
19901
+ ...fileLimitDetails(limit)
19431
19902
  };
19903
+ pageFullWithMore = true;
19432
19904
  }
19433
- return {
19434
- ...result,
19435
- details: buildSearchDetails(result.details, text || "No matches found", executionCwd, scopePath, skippedMissingPaths)
19436
- };
19905
+ remaining -= Math.min(remaining, outputGroups.length);
19437
19906
  }
19438
- const content = dedupeRenderedSearchOutput(`${(await Promise.all(results.map(async (result, index) => {
19439
- let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((value) => typeof value === "string" && value.length > 0).join("\n");
19440
- text = filterTargetLineRanges(text, targets[index], contextBefore, contextAfter);
19441
- if (!isVirtualSearchTarget(targets[index]) && text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter);
19442
- if (!text || text === "No matches found") return `# ${targets[index]?.path ?? "."}\n${text}`;
19443
- return isVirtualSearchTarget(targets[index]) ? text : await cwdRelativeSearchOutput(text, executionCwd, targets[index]?.path ?? ".");
19444
- }))).join("\n\n")}${skippedMissingPaths.length > 0 ? `\n\n[Skipped missing paths: ${skippedMissingPaths.join(", ")}]` : ""}${pageFullWithMore ? `\n\n${continuationHint(limit, skip)}` : ""}${internalSearchCapped && !pageFullWithMore ? `\n\n${internalCapHint()}` : ""}`);
19445
- if (pageFullWithMore || internalSearchCapped) markFileLimit(details, limit);
19446
- const truncation = truncateHead(content, { maxLines: Number.MAX_SAFE_INTEGER });
19447
- let output = truncation.content;
19907
+ result.content = [{
19908
+ type: "text",
19909
+ text
19910
+ }];
19911
+ }
19912
+ const details = {};
19913
+ for (const result of results) {
19914
+ if (result.details?.truncation) details.truncation = result.details.truncation;
19915
+ if (result.details?.matchLimitReached) details.matchLimitReached = result.details.matchLimitReached;
19916
+ if (hasFileLimit(result.details)) markFileLimit(details, limit);
19917
+ if (result.details?.linesTruncated) details.linesTruncated = true;
19918
+ }
19919
+ if (skip > 0) {
19920
+ const renderedPages = [];
19921
+ let remainingMatches = limit;
19922
+ for (const item of groups.slice(skip)) {
19923
+ if (remainingMatches <= 0) break;
19924
+ const raw = formatSearchGroups([item.group], 1);
19925
+ remainingMatches--;
19926
+ if (raw) renderedPages.push(item.virtual ? raw : await cwdRelativeSearchOutput(raw, executionCwd, item.targetPath));
19927
+ }
19928
+ const hasMorePages = groups.slice(skip + limit).length > 0;
19929
+ const cappedBeforeRequestedPage = internalSearchCapped && skip >= groups.length;
19930
+ const capNotice = internalSearchCapped && !hasMorePages ? `\n\n${internalCapHint()}` : "";
19931
+ const output = `${renderedPages.join("\n\n") || `No more results (skip=${skip})`}${hasMorePages ? `\n\n${continuationHint(limit, skip)}` : ""}${capNotice}`;
19932
+ if (hasMorePages || cappedBeforeRequestedPage || capNotice) markFileLimit(details, limit);
19933
+ const truncation = truncateHead(output, { maxLines: Number.MAX_SAFE_INTEGER });
19934
+ let content = truncation.content;
19448
19935
  if (truncation.truncated) {
19449
19936
  details.truncation = truncation;
19450
- output += `\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;
19937
+ content += `\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;
19451
19938
  }
19452
19939
  return {
19453
19940
  content: [{
19454
19941
  type: "text",
19455
- text: output
19942
+ text: content
19456
19943
  }],
19457
- details: buildSearchDetails(details, output, executionCwd, scopePath, skippedMissingPaths)
19944
+ details: buildSearchDetails(details, content, executionCwd, scopePath, skippedMissingPaths)
19458
19945
  };
19946
+ }
19947
+ if (results.length === 1) {
19948
+ const result = results[0];
19949
+ let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((value) => typeof value === "string").join("\n");
19950
+ text = filterTargetLineRanges(text, targets[0], contextBefore, contextAfter);
19951
+ if (!isVirtualSearchTarget(targets[0]) && text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter) || "No matches found";
19952
+ const skipNotice = singleFileSkipIgnored ? "\n\n[skip is ignored for single-file search; refine the pattern/path or search a directory to page matching files.]" : "";
19953
+ if (isSingleFileSearch && text !== "No matches found") text = formatSearchGroups(groupSearchOutput(text), limit, limit);
19954
+ if (text && text !== "No matches found") {
19955
+ const renderedText = isVirtualSearchTarget(targets[0]) ? text : await cwdRelativeSearchOutput(text, executionCwd, targets[0]?.path ?? ".");
19956
+ const pagedText = `${hasFileLimit(result.details) ? `${renderedText}\n\n${continuationHint(limit, skip)}` : renderedText}${skipNotice}`;
19957
+ const truncation = truncateHead(pagedText, { maxLines: Number.MAX_SAFE_INTEGER });
19958
+ if (truncation.truncated) return {
19959
+ ...result,
19960
+ content: [{
19961
+ type: "text",
19962
+ text: `${truncation.content}\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`
19963
+ }],
19964
+ details: buildSearchDetails({
19965
+ ...result.details ?? {},
19966
+ truncation
19967
+ }, truncation.content, executionCwd, scopePath, skippedMissingPaths)
19968
+ };
19969
+ return {
19970
+ ...result,
19971
+ content: [{
19972
+ type: "text",
19973
+ text: pagedText
19974
+ }],
19975
+ details: buildSearchDetails(result.details, pagedText, executionCwd, scopePath, skippedMissingPaths)
19976
+ };
19977
+ }
19978
+ return {
19979
+ ...result,
19980
+ details: buildSearchDetails(result.details, text || "No matches found", executionCwd, scopePath, skippedMissingPaths)
19981
+ };
19982
+ }
19983
+ const content = dedupeRenderedSearchOutput(`${(await Promise.all(results.map(async (result, index) => {
19984
+ let text = result.content.map((item) => item.type === "text" ? item.text : void 0).filter((value) => typeof value === "string" && value.length > 0).join("\n");
19985
+ text = filterTargetLineRanges(text, targets[index], contextBefore, contextAfter);
19986
+ if (!isVirtualSearchTarget(targets[index]) && text !== "No matches found") text = applyDefaultSearchContext(text, contextBefore, contextAfter);
19987
+ if (!text || text === "No matches found") return `# ${targets[index]?.path ?? "."}\n${text}`;
19988
+ return isVirtualSearchTarget(targets[index]) ? text : await cwdRelativeSearchOutput(text, executionCwd, targets[index]?.path ?? ".");
19989
+ }))).join("\n\n")}${skippedMissingPaths.length > 0 ? `\n\n[Skipped missing paths: ${skippedMissingPaths.join(", ")}]` : ""}${pageFullWithMore ? `\n\n${continuationHint(limit, skip)}` : ""}${internalSearchCapped && !pageFullWithMore ? `\n\n${internalCapHint()}` : ""}`);
19990
+ if (pageFullWithMore || internalSearchCapped) markFileLimit(details, limit);
19991
+ const truncation = truncateHead(content, { maxLines: Number.MAX_SAFE_INTEGER });
19992
+ let output = truncation.content;
19993
+ if (truncation.truncated) {
19994
+ details.truncation = truncation;
19995
+ output += `\n\n[${formatSize(DEFAULT_MAX_BYTES)} combined output limit reached]`;
19996
+ }
19997
+ return {
19998
+ content: [{
19999
+ type: "text",
20000
+ text: output
20001
+ }],
20002
+ details: buildSearchDetails(details, output, executionCwd, scopePath, skippedMissingPaths)
20003
+ };
20004
+ };
20005
+ return withBuiltinToolBlockRenderers({
20006
+ ...grepDefinition,
20007
+ name: "search",
20008
+ label: "search",
20009
+ description: "Search file contents with a regex across files, directories, globs, and internal URLs, including history:// for past sessions.",
20010
+ promptSnippet: searchToolSystemPromptContribution.snippet,
20011
+ promptGuidelines: [...searchToolSystemPromptContribution.guidelines],
20012
+ ...experimentalToolSamplingProperty(),
20013
+ parameters: searchSchema,
20014
+ prepareArguments: (args) => prepareHistoryAwareInput(args, "search", "pattern"),
20015
+ async execute(toolCallId, input, signal, onUpdate, ctx) {
20016
+ if (input.action !== void 0) return asSearchResult(await waitForHistoryTask(options?.historyTasks?.(), input, "search", signal));
20017
+ const { wait, ...params } = input;
20018
+ const policy = validateHistoryWait(wait);
20019
+ const registry = namesHistoryUrl(params.paths) ? options?.historyTasks?.() : void 0;
20020
+ if (!registry) return runSearch(toolCallId, params, signal, onUpdate, ctx);
20021
+ return asSearchResult(await registry.run({
20022
+ kind: "search",
20023
+ subject: `/${params.pattern}/ in ${typeof params.paths === "string" ? params.paths : (params.paths ?? []).join(", ")}`,
20024
+ wait: policy,
20025
+ signal,
20026
+ run: (callSignal) => runSearch(toolCallId, params, callSignal, onUpdate, ctx)
20027
+ }));
19459
20028
  },
19460
20029
  renderCall(args, theme, context) {
19461
20030
  const text = context.lastComponent ?? new Text("", 0, 0);
@@ -28207,16 +28776,16 @@ function getArtifactManager(artifactsDir) {
28207
28776
  }
28208
28777
  return manager;
28209
28778
  }
28210
- export { ACTIONS_GITHUB_BASE_URL_ENV, BASH_SHELL_PRESENTATION, BLUEPRINT_FULL_BUILD_MAX_AGE_MS, BLUEPRINT_STEP_TIMEOUT_MS, DEGRADED_RESTORE_RETENTION_DAYS, ENGINE_SESSION_STORAGE_FLAG, ENGINE_SHUTDOWN_GRACE_MS, EVENT_REPORT_MESSAGE_TYPE, EVENT_SUBSCRIPTION_CHILD_ENTRY_TYPE, EVENT_SUBSCRIPTION_ENTRY_TYPE, EVENT_SUBSCRIPTION_PROCESSED_ENTRY_TYPE, FooterDataProvider, RpcClient, SETUP_COMMAND_ALIAS, STORAGE_ADAPTER_LOAD_TIMEOUT_MS, STORAGE_PROBE_TIMEOUT_MS, SUBSCRIPTION_REPORT_TOOL_NAME, SessionWorktreeSnapshotRecorder, SettingsFileChangedError, SettingsManager, TEAM_CONNECTION_TIMEOUT_MS, TEAM_PROFILE_SOURCE, adoptInlineSnapshotBlobs, agentPanelExtensionItems, agentPanelItems, agentPanelSourceHubOf, agentPanelSourcesGeneration, agentPanelTaskId, agentSessionSummaryMethods, agentSessionTreeMethods, answerAgentPanelItem, appendBoundedStderr, applyReadLineSelection, applyToolModifiers, assertTeamAdapterInstalled, bashToolSystemPromptContribution, bindTaskTranscriptFragments, blueprintNotices, blueprintRepository, boundExtensionRuntimes, buildInteractiveEngineArgs, builtinToolBlockPresentation, canIsolateSessionStore, cancelSessionSubscriptions, checkSharedStorageAdapter, checkoutsNeedingRebuild, collectEntriesForBranchSummary, collectStorageStatus, compareWorktreeSnapshot, composeInternalRouters, continueSessionWhereItWorked, copyPanelItemStableKey, createBashTool, createBashToolDefinition, createCodingTools, createEditTool, createEditToolDefinition, createExtensionAPI, createExtensionRuntime, createFindTool, createFindToolDefinition, createHistoryRouter, createLoadedToolDefinition, createLocalBashOperations, createLocalPowerShellOperations, createLsTool, createLsToolDefinition, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createSearchTool, createSearchToolDefinition, createSubscriberReportTool, createToolDefinitionsFor, createWriteTool, createWriteToolDefinition, currentWorktreeRestoreNotices, currentWorktreeRootMappings, currentWorktreeSnapshots, decodeReadableUrl, defaultToolSelectionFor, degradedRestorePin, deleteSessionWithSnapshotRefs, describeBlueprints, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeStorageError, describeStorageSelection, describeWorktreeRestoreStatus, describeWorktreeSnapshot, discardDegradedRestore, dismissedAgentPanelItems, drainExtensionAPIWork, editToolSystemPromptContribution, effectiveSharedSelection, extractDocumentMarkdown, findToolSystemPromptContribution, findUnansweredToolCall, formatDegradedRestoreNotice, formatEventReport, formatToolBlockElapsed, formatUnrestoredNotice, formatWorktreeRestoreNotice, formatWorktreeRestoreWarning, generateBranchSummary, generateDiffString, generateUnifiedPatch, getArtifactManager, getEngineSessionStorage, hasSubagentCaptures, hostStoragePackagesRegistered, inheritChildSessionOptionsWithDefaults, inheritedRemotes, inlineSnapshotBlobs, isBuiltinToolCallRenderer, isBuiltinToolResultRenderer, isDocumentPath, isInside$1 as isInside, isInterruptedPanelTask, isPlainRuntimeMetadataCommand, joinSharedDatabase, joinTeam, joinTeamWith, latestSessionSnapshot, latestSessionSnapshotAsync, launchedTaskViewSource, lazyTaskPanelItem, leaveTeam, leaveTeamWith, liveTaskRowOrigin, loadProjectContextFiles, loadProjectContextFilesAsync, lsToolSystemPromptContribution, mapPathForCwd, mapPathForCwdAsync, mapRestoredPath, mapRestoredPathAsync, markInterruptedPanelTask, materializePanelItem, modelHasReasoning, needsRebuild, notifyAgentPanelChanged, notifyAgentPanelSourceHubRebound, onOwnerTaskAction, openAgentPanelItem, openSessionInWorktree, ownerTaskViewSource, panelItemStableKey, parentHistoryNotices, parseActionReference, pathExists, plainNoticeBlock, prepareBranchEntries, prepareInitialMessage, prepareSessionResume, prewarmHostDefaultModelApi, prewarmInteractiveEngineRpcMode, projectSettingsChooseSessionStorage, projectTrust, promptAnswerOptionsOf, readTaskDetailForView, readTaskPageForChat, readTaskPageForView, readToolSystemPromptContribution, recordBlueprintContext, recordRestoredWorktreeContext, registerHostStoragePackages, registerHostStoragePackagesAsync, releaseSessionWorktrees, removeSavedModelRoutingSettings, removeSavedModelRoutingSettingsAsync, resolveAppMode, resolveCliPaths, resolveExcludedToolsForAppMode, resolveExistingPromptSourcePath, resolveExistingPromptSourcePaths, resolvePackageStorageAdapter, resolvePromptInput, resolveSessionStore, resumeSessionWorktree, resumeStoreDir, retainTaskWindowReader, retireExtensionAPI, runAction, runBlueprintBuild, runExtensionAPICleanup, runMigrations, runMigrationsAsync, runResourceRegistrationBatch, sampleAgentPanelSources, savedBoundaryCursor, savedProjectTrust, savedProjectTrustAsync, sealExtensionAPI, searchToolSystemPromptContribution, seedEventPrompt, selectIntercomStorage, selectSessionSetting, selectSessionStorage, selectSessionStorageWithSettings, selectSessionStorageWithSettingsAsync, selectSharedStorage, selectTeamProfile, serializeConversation, sessionManagerContinuesIn, sessionManagerRunsInRecordedCheckout, sessionResumeOptions, sessionSnapshotBlobs, sessionStorageSettingsDiffer, setUpResumedBlueprints, settingsFileTarget, settingsFileTargetAsync, shellCommandPrefixFor, shortTaskTitle, shouldStartRpcCatalogRefresh, showDeprecationWarnings, snapshotBlobInliner, sourceError, stopAgentPanelItem, storageFingerprint, subscribeAgentPanel, subscribeAgentPanelExtensions, subscribeSession, takeEngineSessionStorageArg, taskCursorsAround, taskPanelItem, taskPanelItems, taskPanelModel, taskPanelRole, taskPanelState, taskRunGeneration, taskTranscriptFile, taskTranscriptFragments, taskTranscriptUnsavedAnswer, toPrintOutputMode, toolsWithReport, withTaskTranscriptArchive, withWorktreeRestoreNotices, withWorktreeRootMappings, worktreeNeedsRestore, worktreeRestoreNotices, writeSettingsFile, writeSettingsFileAsync, writeToolSystemPromptContribution };
28779
+ export { ACTIONS_GITHUB_BASE_URL_ENV, BASH_SHELL_PRESENTATION, BLUEPRINT_FULL_BUILD_MAX_AGE_MS, BLUEPRINT_STEP_TIMEOUT_MS, DEGRADED_RESTORE_RETENTION_DAYS, ENGINE_SESSION_STORAGE_FLAG, ENGINE_SHUTDOWN_GRACE_MS, EVENT_REPORT_MESSAGE_TYPE, EVENT_SUBSCRIPTION_CHILD_ENTRY_TYPE, EVENT_SUBSCRIPTION_ENTRY_TYPE, EVENT_SUBSCRIPTION_PROCESSED_ENTRY_TYPE, FooterDataProvider, HistoryTaskRegistry, RpcClient, SETUP_COMMAND_ALIAS, STORAGE_ADAPTER_LOAD_TIMEOUT_MS, STORAGE_PROBE_TIMEOUT_MS, SUBSCRIPTION_REPORT_TOOL_NAME, SessionWorktreeSnapshotRecorder, SettingsFileChangedError, SettingsManager, TEAM_CONNECTION_TIMEOUT_MS, TEAM_PROFILE_SOURCE, adoptInlineSnapshotBlobs, agentPanelExtensionItems, agentPanelItems, agentPanelSourceHubOf, agentPanelSourcesGeneration, agentPanelTaskId, agentSessionSummaryMethods, agentSessionTreeMethods, answerAgentPanelItem, appendBoundedStderr, applyReadLineSelection, applyToolModifiers, assertTeamAdapterInstalled, bashToolSystemPromptContribution, bindTaskTranscriptFragments, blueprintNotices, blueprintRepository, boundExtensionRuntimes, buildInteractiveEngineArgs, builtinToolBlockPresentation, canIsolateSessionStore, cancelSessionSubscriptions, checkSharedStorageAdapter, checkoutsNeedingRebuild, collectEntriesForBranchSummary, collectStorageStatus, compareWorktreeSnapshot, composeInternalRouters, continueSessionWhereItWorked, copyPanelItemStableKey, createBashTool, createBashToolDefinition, createCodingTools, createEditTool, createEditToolDefinition, createExtensionAPI, createExtensionRuntime, createFindTool, createFindToolDefinition, createHistoryRouter, createKillTool, createKillToolDefinition, createLoadedToolDefinition, createLocalBashOperations, createLocalPowerShellOperations, createLsTool, createLsToolDefinition, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createSearchTool, createSearchToolDefinition, createSubscriberReportTool, createToolDefinitionsFor, createWriteTool, createWriteToolDefinition, currentWorktreeRestoreNotices, currentWorktreeRootMappings, currentWorktreeSnapshots, decodeReadableUrl, defaultToolSelectionFor, degradedRestorePin, deleteSessionWithSnapshotRefs, describeBlueprints, describeExportedSnapshots, describeLastCapture, describeSnapshotExport, describeStorageError, describeStorageSelection, describeWorktreeRestoreStatus, describeWorktreeSnapshot, discardDegradedRestore, dismissedAgentPanelItems, drainExtensionAPIWork, editToolSystemPromptContribution, effectiveSharedSelection, extractDocumentMarkdown, findToolSystemPromptContribution, findUnansweredToolCall, formatDegradedRestoreNotice, formatEventReport, formatToolBlockElapsed, formatUnrestoredNotice, formatWorktreeRestoreNotice, formatWorktreeRestoreWarning, generateBranchSummary, generateDiffString, generateUnifiedPatch, getArtifactManager, getEngineSessionStorage, hasSubagentCaptures, hostStoragePackagesRegistered, inheritChildSessionOptionsWithDefaults, inheritedRemotes, inlineSnapshotBlobs, isBuiltinToolCallRenderer, isBuiltinToolResultRenderer, isDocumentPath, isInside$1 as isInside, isInterruptedPanelTask, isPlainRuntimeMetadataCommand, joinSharedDatabase, joinTeam, joinTeamWith, latestSessionSnapshot, latestSessionSnapshotAsync, launchedTaskViewSource, lazyTaskPanelItem, leaveTeam, leaveTeamWith, liveTaskRowOrigin, loadProjectContextFiles, loadProjectContextFilesAsync, lsToolSystemPromptContribution, mapPathForCwd, mapPathForCwdAsync, mapRestoredPath, mapRestoredPathAsync, markInterruptedPanelTask, materializePanelItem, modelHasReasoning, needsRebuild, notifyAgentPanelChanged, notifyAgentPanelSourceHubRebound, onOwnerTaskAction, openAgentPanelItem, openSessionInWorktree, ownerTaskViewSource, panelItemStableKey, parentHistoryNotices, parseActionReference, pathExists, plainNoticeBlock, prepareBranchEntries, prepareInitialMessage, prepareSessionResume, prewarmHostDefaultModelApi, prewarmInteractiveEngineRpcMode, projectSettingsChooseSessionStorage, projectTrust, promptAnswerOptionsOf, readTaskDetailForView, readTaskPageForChat, readTaskPageForView, readToolSystemPromptContribution, recordBlueprintContext, recordRestoredWorktreeContext, registerHostStoragePackages, registerHostStoragePackagesAsync, releaseSessionWorktrees, removeSavedModelRoutingSettings, removeSavedModelRoutingSettingsAsync, resolveAppMode, resolveCliPaths, resolveExcludedToolsForAppMode, resolveExistingPromptSourcePath, resolveExistingPromptSourcePaths, resolvePackageStorageAdapter, resolvePromptInput, resolveSessionStore, resumeSessionWorktree, resumeStoreDir, retainTaskWindowReader, retireExtensionAPI, runAction, runBlueprintBuild, runExtensionAPICleanup, runMigrations, runMigrationsAsync, runResourceRegistrationBatch, sampleAgentPanelSources, savedBoundaryCursor, savedProjectTrust, savedProjectTrustAsync, sealExtensionAPI, searchToolSystemPromptContribution, seedEventPrompt, selectIntercomStorage, selectSessionSetting, selectSessionStorage, selectSessionStorageWithSettings, selectSessionStorageWithSettingsAsync, selectSharedStorage, selectTeamProfile, serializeConversation, sessionManagerContinuesIn, sessionManagerRunsInRecordedCheckout, sessionResumeOptions, sessionSnapshotBlobs, sessionStorageSettingsDiffer, setUpResumedBlueprints, settingsFileTarget, settingsFileTargetAsync, shellCommandPrefixFor, shortTaskTitle, shouldStartRpcCatalogRefresh, showDeprecationWarnings, snapshotBlobInliner, sourceError, stopAgentPanelItem, storageFingerprint, subscribeAgentPanel, subscribeAgentPanelExtensions, subscribeSession, takeEngineSessionStorageArg, taskCursorsAround, taskPanelItem, taskPanelItems, taskPanelModel, taskPanelRole, taskPanelState, taskRunGeneration, taskTranscriptFile, taskTranscriptFragments, taskTranscriptUnsavedAnswer, toPrintOutputMode, toolsWithReport, withTaskTranscriptArchive, withWorktreeRestoreNotices, withWorktreeRootMappings, worktreeNeedsRestore, worktreeRestoreNotices, writeSettingsFile, writeSettingsFileAsync, writeToolSystemPromptContribution };
28211
28780
 
28212
- //# sourceMappingURL=startup-8-1-4KANEHRA.js.map
28781
+ //# sourceMappingURL=startup-8-1-X32CYSXB.js.map
28213
28782
  // __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
28214
28783
  // demand that fails in a process an in-place update left running says to restart.
28215
28784
  function __atomicOnDemandFailed(error, feature) {
28216
28785
  return (async () => {
28217
28786
  const root = new URL("../", import.meta.url);
28218
28787
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
28219
- const key = `${root.href}#0.10.10`;
28788
+ const key = `${root.href}#0.10.11-alpha.2`;
28220
28789
  let release = releases.get(key);
28221
28790
  if (release === undefined) {
28222
28791
  const current = (async () => {
@@ -28244,7 +28813,7 @@ function __atomicOnDemandFailed(error, feature) {
28244
28813
  } catch {
28245
28814
  // No installation to read, as in a bundle of the package: the release the process runs decides.
28246
28815
  }
28247
- const updatedTo = typeof installed === "string" && installed !== "0.10.10" ? installed : running !== undefined && running.version !== "0.10.10" ? "0.10.10" : undefined;
28816
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.2" ? installed : running !== undefined && running.version !== "0.10.11-alpha.2" ? "0.10.11-alpha.2" : undefined;
28248
28817
  if (updatedTo === undefined) throw error;
28249
28818
  const application = typeof running?.name === "string" ? running.name : "atomic";
28250
28819
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {