@bastani/atomic 0.9.21-alpha.1 → 0.9.21-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 (514) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +11 -0
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/subagents/src/extension/index.bundle.mjs +292 -60
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/builtin/workflows/CHANGELOG.md +11 -0
  9. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  10. package/dist/builtin/workflows/builtin/{chunk-cw86srkf.js → chunk-632fxeb8.js} +1 -1
  11. package/dist/builtin/workflows/builtin/{chunk-w18kbz63.js → chunk-94f8zfz1.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-kspvwc24.js → chunk-9cm2ckq2.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-jaj27rqc.js → chunk-a1ar035d.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-wh19f5ee.js → chunk-d3xhj946.js} +5 -4
  15. package/dist/builtin/workflows/builtin/{chunk-crw7q5g1.js → chunk-gyjck9z8.js} +1 -1
  16. package/dist/builtin/workflows/builtin/{chunk-maqv731g.js → chunk-hj8mh07f.js} +10 -6
  17. package/dist/builtin/workflows/builtin/{chunk-0nrgfbag.js → chunk-kb7s3gx2.js} +1 -1
  18. package/dist/builtin/workflows/builtin/{chunk-73c5tayt.js → chunk-kgn5wz1c.js} +19 -1
  19. package/dist/builtin/workflows/builtin/{chunk-2hak3b7g.js → chunk-nkj4qhj6.js} +1 -1
  20. package/dist/builtin/workflows/builtin/{chunk-bzdvx2xr.js → chunk-r97ndfvt.js} +1 -1
  21. package/dist/builtin/workflows/builtin/{chunk-vkmpdat4.js → chunk-wf876n16.js} +1 -1
  22. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  23. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  24. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  25. package/dist/builtin/workflows/builtin/goal.js +4 -4
  26. package/dist/builtin/workflows/builtin/index.js +12 -12
  27. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  28. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  29. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  30. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  31. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  32. package/dist/builtin/workflows/package.json +1 -1
  33. package/dist/builtin/workflows/src/extension/index.bundle.mjs +40 -11
  34. package/dist/builtin/workflows/src/index.js +9 -3
  35. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -1
  36. package/dist/cli/auth-command.js +5 -0
  37. package/dist/cli/auth-command.js.map +1 -1
  38. package/dist/cli/credential-print.js +2 -0
  39. package/dist/cli/credential-print.js.map +1 -1
  40. package/dist/cli/experimental/command.js +5 -2
  41. package/dist/cli/experimental/command.js.map +1 -1
  42. package/dist/cli.js +1 -1
  43. package/dist/cli.js.map +1 -1
  44. package/dist/config.d.ts +4 -4
  45. package/dist/config.js +4 -4
  46. package/dist/config.js.map +1 -1
  47. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  48. package/dist/core/agent-session-extension-bindings.js +9 -4
  49. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  50. package/dist/core/agent-session-methods.d.ts +4 -4
  51. package/dist/core/agent-session-methods.d.ts.map +1 -1
  52. package/dist/core/agent-session-methods.js.map +1 -1
  53. package/dist/core/agent-session-prompt.d.ts +4 -4
  54. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  55. package/dist/core/agent-session-prompt.js +38 -15
  56. package/dist/core/agent-session-prompt.js.map +1 -1
  57. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  58. package/dist/core/agent-session-runtime.js +14 -9
  59. package/dist/core/agent-session-runtime.js.map +1 -1
  60. package/dist/core/agent-session-types.d.ts +4 -1
  61. package/dist/core/agent-session-types.d.ts.map +1 -1
  62. package/dist/core/agent-session-types.js.map +1 -1
  63. package/dist/core/agent-session.d.ts +1 -1
  64. package/dist/core/agent-session.d.ts.map +1 -1
  65. package/dist/core/agent-session.js +140 -95
  66. package/dist/core/agent-session.js.map +1 -1
  67. package/dist/core/auth-storage-backends.js +2 -3
  68. package/dist/core/auth-storage-backends.js.map +1 -1
  69. package/dist/core/auth-storage.js +4 -1
  70. package/dist/core/auth-storage.js.map +1 -1
  71. package/dist/core/builtin-resource-loader.js +9 -0
  72. package/dist/core/builtin-resource-loader.js.map +1 -1
  73. package/dist/core/cache-warmer.js +8 -1
  74. package/dist/core/cache-warmer.js.map +1 -1
  75. package/dist/core/compaction/range-planner.js +6 -0
  76. package/dist/core/compaction/range-planner.js.map +1 -1
  77. package/dist/core/execution-model-router.d.ts +13 -3
  78. package/dist/core/execution-model-router.d.ts.map +1 -1
  79. package/dist/core/execution-model-router.js +227 -131
  80. package/dist/core/execution-model-router.js.map +1 -1
  81. package/dist/core/export-html/template-js/entries-navigation.js +16 -6
  82. package/dist/core/export-html/template-js/initialization.js +34 -11
  83. package/dist/core/export-html/template.css +10 -0
  84. package/dist/core/export-html/template.js +50 -17
  85. package/dist/core/extensions/context-types.d.ts +2 -0
  86. package/dist/core/extensions/context-types.d.ts.map +1 -1
  87. package/dist/core/extensions/context-types.js.map +1 -1
  88. package/dist/core/extensions/host-input.js +8 -4
  89. package/dist/core/extensions/host-input.js.map +1 -1
  90. package/dist/core/extensions/reactive-widget.js +1 -0
  91. package/dist/core/extensions/reactive-widget.js.map +1 -1
  92. package/dist/core/extensions/runner-context.d.ts +1 -0
  93. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  94. package/dist/core/extensions/runner-context.js +4 -0
  95. package/dist/core/extensions/runner-context.js.map +1 -1
  96. package/dist/core/extensions/runner.d.ts +1 -0
  97. package/dist/core/extensions/runner.d.ts.map +1 -1
  98. package/dist/core/extensions/runner.js +48 -30
  99. package/dist/core/extensions/runner.js.map +1 -1
  100. package/dist/core/extensions/runtime-types.d.ts +1 -0
  101. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  102. package/dist/core/extensions/runtime-types.js.map +1 -1
  103. package/dist/core/extensions/workflow-activity-hub.js +9 -7
  104. package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
  105. package/dist/core/footer-data-provider.js +24 -23
  106. package/dist/core/footer-data-provider.js.map +1 -1
  107. package/dist/core/keybindings.js +1 -0
  108. package/dist/core/keybindings.js.map +1 -1
  109. package/dist/core/mandatory-resource-loader.js +4 -1
  110. package/dist/core/mandatory-resource-loader.js.map +1 -1
  111. package/dist/core/model-config.js +2 -0
  112. package/dist/core/model-config.js.map +1 -1
  113. package/dist/core/model-registry.js +1 -0
  114. package/dist/core/model-registry.js.map +1 -1
  115. package/dist/core/{model-routing-task.d.ts → model-routing-bytes.d.ts} +1 -4
  116. package/dist/core/model-routing-bytes.d.ts.map +1 -0
  117. package/dist/core/model-routing-bytes.js +33 -0
  118. package/dist/core/model-routing-bytes.js.map +1 -0
  119. package/dist/core/model-routing-candidates.d.ts +42 -0
  120. package/dist/core/model-routing-candidates.d.ts.map +1 -0
  121. package/dist/core/model-routing-candidates.js +309 -0
  122. package/dist/core/model-routing-candidates.js.map +1 -0
  123. package/dist/core/model-routing-constraints.d.ts +4 -0
  124. package/dist/core/model-routing-constraints.d.ts.map +1 -1
  125. package/dist/core/model-routing-constraints.js +13 -1
  126. package/dist/core/model-routing-constraints.js.map +1 -1
  127. package/dist/core/model-routing-debug.d.ts +9 -0
  128. package/dist/core/model-routing-debug.d.ts.map +1 -0
  129. package/dist/core/model-routing-debug.js +14 -0
  130. package/dist/core/model-routing-debug.js.map +1 -0
  131. package/dist/core/model-routing-evals.d.ts +50 -0
  132. package/dist/core/model-routing-evals.d.ts.map +1 -0
  133. package/dist/core/model-routing-evals.js +190 -0
  134. package/dist/core/model-routing-evals.js.map +1 -0
  135. package/dist/core/model-routing-needs.d.ts +75 -0
  136. package/dist/core/model-routing-needs.d.ts.map +1 -0
  137. package/dist/core/model-routing-needs.js +176 -0
  138. package/dist/core/model-routing-needs.js.map +1 -0
  139. package/dist/core/model-runtime-streaming.js +3 -0
  140. package/dist/core/model-runtime-streaming.js.map +1 -1
  141. package/dist/core/model-runtime.js +26 -14
  142. package/dist/core/model-runtime.js.map +1 -1
  143. package/dist/core/models-store.js +2 -3
  144. package/dist/core/models-store.js.map +1 -1
  145. package/dist/core/output-guard.js +1 -0
  146. package/dist/core/output-guard.js.map +1 -1
  147. package/dist/core/package-manager-paths.d.ts +2 -1
  148. package/dist/core/package-manager-paths.d.ts.map +1 -1
  149. package/dist/core/package-manager-paths.js +4 -3
  150. package/dist/core/package-manager-paths.js.map +1 -1
  151. package/dist/core/package-manager.js +1 -0
  152. package/dist/core/package-manager.js.map +1 -1
  153. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  154. package/dist/core/resource-loader-assets.js +9 -7
  155. package/dist/core/resource-loader-assets.js.map +1 -1
  156. package/dist/core/resource-loader-core.js +49 -0
  157. package/dist/core/resource-loader-core.js.map +1 -1
  158. package/dist/core/runtime-credentials.js +2 -1
  159. package/dist/core/runtime-credentials.js.map +1 -1
  160. package/dist/core/session-cwd.js +1 -0
  161. package/dist/core/session-cwd.js.map +1 -1
  162. package/dist/core/session-manager-archive.d.ts.map +1 -1
  163. package/dist/core/session-manager-archive.js +4 -2
  164. package/dist/core/session-manager-archive.js.map +1 -1
  165. package/dist/core/session-manager-core.js +11 -7
  166. package/dist/core/session-manager-core.js.map +1 -1
  167. package/dist/core/session-manager-storage.d.ts +10 -4
  168. package/dist/core/session-manager-storage.d.ts.map +1 -1
  169. package/dist/core/session-manager-storage.js +12 -6
  170. package/dist/core/session-manager-storage.js.map +1 -1
  171. package/dist/core/settings-manager-basic-accessors.d.ts +2 -1
  172. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  173. package/dist/core/settings-manager-basic-accessors.js +21 -0
  174. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  175. package/dist/core/settings-manager-core.js +13 -7
  176. package/dist/core/settings-manager-core.js.map +1 -1
  177. package/dist/core/settings-manager.d.ts +1 -1
  178. package/dist/core/settings-manager.d.ts.map +1 -1
  179. package/dist/core/settings-manager.js.map +1 -1
  180. package/dist/core/settings-storage.js +6 -0
  181. package/dist/core/settings-storage.js.map +1 -1
  182. package/dist/core/settings-types.d.ts +8 -0
  183. package/dist/core/settings-types.d.ts.map +1 -1
  184. package/dist/core/settings-types.js.map +1 -1
  185. package/dist/core/structured-output/index.d.ts.map +1 -1
  186. package/dist/core/structured-output/index.js +4 -1
  187. package/dist/core/structured-output/index.js.map +1 -1
  188. package/dist/core/structured-output/invalid-output.js +1 -0
  189. package/dist/core/structured-output/invalid-output.js.map +1 -1
  190. package/dist/core/tasks/agent-adapter.js +5 -3
  191. package/dist/core/tasks/agent-adapter.js.map +1 -1
  192. package/dist/core/tasks/child-command-owner.js +3 -7
  193. package/dist/core/tasks/child-command-owner.js.map +1 -1
  194. package/dist/core/tasks/completion.js +5 -1
  195. package/dist/core/tasks/completion.js.map +1 -1
  196. package/dist/core/tasks/owner-store.js +12 -8
  197. package/dist/core/tasks/owner-store.js.map +1 -1
  198. package/dist/core/tasks/supervisor.js +14 -35
  199. package/dist/core/tasks/supervisor.js.map +1 -1
  200. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +13 -4
  201. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  202. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +11 -1
  203. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  204. package/dist/core/tools/ask-user-question/view/components/chat-row-view.js +1 -0
  205. package/dist/core/tools/ask-user-question/view/components/chat-row-view.js.map +1 -1
  206. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +1 -0
  207. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  208. package/dist/core/tools/ask-user-question/view/components/option-list-view.js +1 -0
  209. package/dist/core/tools/ask-user-question/view/components/option-list-view.js.map +1 -1
  210. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js +5 -0
  211. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  212. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +2 -0
  213. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  214. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +13 -8
  215. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  216. package/dist/core/tools/ask-user-question/view/components/submit-picker.js +1 -0
  217. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  218. package/dist/core/tools/ask-user-question/view/components/tab-bar.js +1 -0
  219. package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
  220. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +30 -24
  221. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  222. package/dist/core/tools/ask-user-question/view/dialog-builder.js +5 -0
  223. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  224. package/dist/core/tools/ask-user-question/view/props-adapter.js +8 -0
  225. package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
  226. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +4 -4
  227. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  228. package/dist/core/tools/bash.js +5 -8
  229. package/dist/core/tools/bash.js.map +1 -1
  230. package/dist/core/tools/edit-batch.js +4 -0
  231. package/dist/core/tools/edit-batch.js.map +1 -1
  232. package/dist/core/tools/edit.js +2 -0
  233. package/dist/core/tools/edit.js.map +1 -1
  234. package/dist/core/tools/file-mutation-coordinator.js +9 -0
  235. package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
  236. package/dist/core/tools/find.js +1 -1
  237. package/dist/core/tools/find.js.map +1 -1
  238. package/dist/core/tools/hashline-engine/fs.js +1 -1
  239. package/dist/core/tools/hashline-engine/fs.js.map +1 -1
  240. package/dist/core/tools/hashline-engine/input.js +4 -0
  241. package/dist/core/tools/hashline-engine/input.js.map +1 -1
  242. package/dist/core/tools/hashline-engine/mismatch.js +6 -0
  243. package/dist/core/tools/hashline-engine/mismatch.js.map +1 -1
  244. package/dist/core/tools/hashline-engine/patcher.js +13 -0
  245. package/dist/core/tools/hashline-engine/patcher.js.map +1 -1
  246. package/dist/core/tools/hashline-engine/recovery.js +1 -0
  247. package/dist/core/tools/hashline-engine/recovery.js.map +1 -1
  248. package/dist/core/tools/output-accumulator.js +20 -13
  249. package/dist/core/tools/output-accumulator.js.map +1 -1
  250. package/dist/core/tools/persisted-output-file.js +9 -3
  251. package/dist/core/tools/persisted-output-file.js.map +1 -1
  252. package/dist/core/tools/resource-selectors.js +1 -0
  253. package/dist/core/tools/resource-selectors.js.map +1 -1
  254. package/dist/core/tools/write.js +1 -0
  255. package/dist/core/tools/write.js.map +1 -1
  256. package/dist/core/trust-manager.js +1 -0
  257. package/dist/core/trust-manager.js.map +1 -1
  258. package/dist/core/workflow-stage-admission.js +17 -10
  259. package/dist/core/workflow-stage-admission.js.map +1 -1
  260. package/dist/extensions/llama/client.js +2 -0
  261. package/dist/extensions/llama/client.js.map +1 -1
  262. package/dist/extensions/llama/huggingface-ui.js +17 -9
  263. package/dist/extensions/llama/huggingface-ui.js.map +1 -1
  264. package/dist/extensions/llama/huggingface.js +2 -0
  265. package/dist/extensions/llama/huggingface.js.map +1 -1
  266. package/dist/extensions/llama/ui.js +11 -3
  267. package/dist/extensions/llama/ui.js.map +1 -1
  268. package/dist/index.d.ts +4 -2
  269. package/dist/index.d.ts.map +1 -1
  270. package/dist/index.js +3 -1
  271. package/dist/index.js.map +1 -1
  272. package/dist/modes/interactive/components/armin.js +10 -6
  273. package/dist/modes/interactive/components/armin.js.map +1 -1
  274. package/dist/modes/interactive/components/assistant-message.js +10 -2
  275. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  276. package/dist/modes/interactive/components/atomic-working-status.js +10 -2
  277. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  278. package/dist/modes/interactive/components/bash-execution.js +9 -4
  279. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  280. package/dist/modes/interactive/components/bordered-loader.js +3 -0
  281. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  282. package/dist/modes/interactive/components/branch-summary-message.js +4 -1
  283. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  284. package/dist/modes/interactive/components/chat-message-renderer.js +2 -1
  285. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  286. package/dist/modes/interactive/components/chat-session-host-state.js +63 -31
  287. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  288. package/dist/modes/interactive/components/chat-session-host.js +8 -1
  289. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  290. package/dist/modes/interactive/components/chat-transcript.js +24 -14
  291. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  292. package/dist/modes/interactive/components/compaction-boundary-message.js +2 -1
  293. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  294. package/dist/modes/interactive/components/config-selector-list.js +15 -6
  295. package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
  296. package/dist/modes/interactive/components/config-selector.js +7 -1
  297. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  298. package/dist/modes/interactive/components/countdown-timer.js +2 -0
  299. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  300. package/dist/modes/interactive/components/custom-editor.js +21 -1
  301. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  302. package/dist/modes/interactive/components/custom-entry.js +4 -1
  303. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  304. package/dist/modes/interactive/components/custom-message.js +9 -1
  305. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  306. package/dist/modes/interactive/components/daxnuts.js +8 -6
  307. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  308. package/dist/modes/interactive/components/dynamic-border.js +1 -0
  309. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  310. package/dist/modes/interactive/components/extension-editor.js +7 -1
  311. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  312. package/dist/modes/interactive/components/extension-input.js +8 -2
  313. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  314. package/dist/modes/interactive/components/extension-selector.js +9 -1
  315. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  316. package/dist/modes/interactive/components/first-time-setup.js +4 -2
  317. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  318. package/dist/modes/interactive/components/footer.js +5 -2
  319. package/dist/modes/interactive/components/footer.js.map +1 -1
  320. package/dist/modes/interactive/components/host-input-form.js +13 -2
  321. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  322. package/dist/modes/interactive/components/login-dialog.js +9 -3
  323. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  324. package/dist/modes/interactive/components/model-selector.js +24 -12
  325. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  326. package/dist/modes/interactive/components/oauth-selector.js +12 -3
  327. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  328. package/dist/modes/interactive/components/reserved-bottom-overlay.js +11 -2
  329. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
  330. package/dist/modes/interactive/components/scoped-models-selector.js +13 -8
  331. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  332. package/dist/modes/interactive/components/scroll-widget.js +4 -0
  333. package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
  334. package/dist/modes/interactive/components/session-selector-header.js +11 -7
  335. package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
  336. package/dist/modes/interactive/components/session-selector-list.js +25 -12
  337. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  338. package/dist/modes/interactive/components/session-selector.js +23 -15
  339. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  340. package/dist/modes/interactive/components/settings-selector-submenus.js +19 -1
  341. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  342. package/dist/modes/interactive/components/settings-selector.js +1 -0
  343. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  344. package/dist/modes/interactive/components/show-images-selector.js +1 -0
  345. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  346. package/dist/modes/interactive/components/skill-invocation-message.js +4 -1
  347. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  348. package/dist/modes/interactive/components/startup-identity.js +8 -3
  349. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  350. package/dist/modes/interactive/components/task-completion-message.js +2 -0
  351. package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
  352. package/dist/modes/interactive/components/task-detail.js +2 -0
  353. package/dist/modes/interactive/components/task-detail.js.map +1 -1
  354. package/dist/modes/interactive/components/task-inspector.js +22 -12
  355. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  356. package/dist/modes/interactive/components/task-list.js +2 -0
  357. package/dist/modes/interactive/components/task-list.js.map +1 -1
  358. package/dist/modes/interactive/components/task-live-transcript.js +8 -3
  359. package/dist/modes/interactive/components/task-live-transcript.js.map +1 -1
  360. package/dist/modes/interactive/components/task-navigation.js +5 -2
  361. package/dist/modes/interactive/components/task-navigation.js.map +1 -1
  362. package/dist/modes/interactive/components/task-row.js +2 -0
  363. package/dist/modes/interactive/components/task-row.js.map +1 -1
  364. package/dist/modes/interactive/components/theme-selector.js +2 -0
  365. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  366. package/dist/modes/interactive/components/thinking-selector.js +7 -1
  367. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  368. package/dist/modes/interactive/components/tool-execution.js +25 -10
  369. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  370. package/dist/modes/interactive/components/transcript-follow-indicator.js +1 -0
  371. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
  372. package/dist/modes/interactive/components/tree-selector-component.js +7 -3
  373. package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
  374. package/dist/modes/interactive/components/tree-selector-help.js +1 -0
  375. package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
  376. package/dist/modes/interactive/components/tree-selector-label-input.js +6 -2
  377. package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
  378. package/dist/modes/interactive/components/tree-selector-list.js +4 -0
  379. package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
  380. package/dist/modes/interactive/components/trust-selector.js +6 -0
  381. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  382. package/dist/modes/interactive/components/user-message-selector.js +6 -3
  383. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  384. package/dist/modes/interactive/components/user-message.js +5 -0
  385. package/dist/modes/interactive/components/user-message.js.map +1 -1
  386. package/dist/modes/interactive/components/working-status.js +1 -0
  387. package/dist/modes/interactive/components/working-status.js.map +1 -1
  388. package/dist/modes/interactive/interactive-autocomplete.js +2 -0
  389. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  390. package/dist/modes/interactive/interactive-extension-runtime.js +1 -0
  391. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  392. package/dist/modes/interactive/interactive-mode-base.js +162 -120
  393. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  394. package/dist/modes/interactive/interactive-mode-helpers.js +3 -0
  395. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  396. package/dist/modes/interactive/interactive-mode-surface.d.ts +0 -6
  397. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  398. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  399. package/dist/modes/interactive/interactive-resource-disclosure.js +0 -4
  400. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  401. package/dist/modes/interactive/interactive-resource-rendering.js +0 -12
  402. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  403. package/dist/modes/interactive/interactive-startup-chat-container.js +1 -4
  404. package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
  405. package/dist/modes/interactive/model-catalog-refresh.js +1 -3
  406. package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
  407. package/dist/modes/interactive/theme/color-utils.d.ts +5 -0
  408. package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
  409. package/dist/modes/interactive/theme/color-utils.js +11 -0
  410. package/dist/modes/interactive/theme/color-utils.js.map +1 -1
  411. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  412. package/dist/modes/interactive/theme/global-theme.js +4 -3
  413. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  414. package/dist/modes/interactive/theme/theme-class.js +7 -0
  415. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  416. package/dist/modes/interactive/theme/theme-controller.js +9 -2
  417. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  418. package/dist/modes/interactive-engine/activity-watchdog.js +8 -3
  419. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  420. package/dist/modes/interactive-engine/engine-custom-ui.js +12 -8
  421. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  422. package/dist/modes/interactive-engine/engine-dialog-host.js +7 -3
  423. package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
  424. package/dist/modes/interactive-engine/engine-health.js +23 -13
  425. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  426. package/dist/modes/interactive-engine/engine-input-form.js +3 -2
  427. package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
  428. package/dist/modes/interactive-engine/engine-monitor.js +13 -1
  429. package/dist/modes/interactive-engine/engine-monitor.js.map +1 -1
  430. package/dist/modes/interactive-engine/engine-project-trust.js +2 -1
  431. package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -1
  432. package/dist/modes/interactive-engine/engine-render-service.js +7 -4
  433. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  434. package/dist/modes/interactive-engine/engine-session-picker.js +3 -2
  435. package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
  436. package/dist/modes/interactive-engine/input-form-host.js +5 -1
  437. package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
  438. package/dist/modes/interactive-engine/isolated-runtime.js +37 -23
  439. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  440. package/dist/modes/interactive-engine/remote-command-catalog.js +4 -3
  441. package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
  442. package/dist/modes/interactive-engine/remote-component.js +24 -12
  443. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  444. package/dist/modes/interactive-engine/remote-frame-clamp.js +3 -3
  445. package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -1
  446. package/dist/modes/interactive-engine/remote-model-catalog.js +5 -4
  447. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
  448. package/dist/modes/interactive-engine/remote-queue-pause.js +3 -1
  449. package/dist/modes/interactive-engine/remote-queue-pause.js.map +1 -1
  450. package/dist/modes/interactive-engine/remote-renderer.js +24 -13
  451. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  452. package/dist/modes/interactive-engine/resource-readiness-error.js +1 -0
  453. package/dist/modes/interactive-engine/resource-readiness-error.js.map +1 -1
  454. package/dist/modes/interactive-engine/session-picker-host.js +5 -1
  455. package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
  456. package/dist/modes/interactive-engine/terminal-mode-controller.js +2 -1
  457. package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -1
  458. package/dist/modes/rpc/queued-writer.js +13 -4
  459. package/dist/modes/rpc/queued-writer.js.map +1 -1
  460. package/dist/modes/rpc/rpc-bash-request-owners.js +2 -1
  461. package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
  462. package/dist/modes/rpc/rpc-client-api.d.ts +8 -4
  463. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  464. package/dist/modes/rpc/rpc-client-api.js +10 -3
  465. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  466. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  467. package/dist/modes/rpc/rpc-client.js +35 -22
  468. package/dist/modes/rpc/rpc-client.js.map +1 -1
  469. package/dist/modes/rpc/rpc-command-handler.js +6 -6
  470. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  471. package/dist/modes/rpc/rpc-event-buffer.js +3 -1
  472. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  473. package/dist/modes/rpc/rpc-generation-buffer.js +1 -3
  474. package/dist/modes/rpc/rpc-generation-buffer.js.map +1 -1
  475. package/dist/modes/rpc/rpc-keybindings-reload.js +4 -1
  476. package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
  477. package/dist/modes/rpc/rpc-output-buffer.js +3 -4
  478. package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
  479. package/dist/modes/rpc/rpc-pending-requests.js +1 -3
  480. package/dist/modes/rpc/rpc-pending-requests.js.map +1 -1
  481. package/dist/modes/rpc/rpc-provider-auth.js +3 -1
  482. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  483. package/dist/modes/rpc/rpc-resource-readiness.js +4 -5
  484. package/dist/modes/rpc/rpc-resource-readiness.js.map +1 -1
  485. package/dist/modes/rpc/rpc-session-binding.js +15 -0
  486. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  487. package/dist/modes/rpc/rpc-terminal-drain.js +3 -0
  488. package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
  489. package/dist/modes/rpc/rpc-types.d.ts +10 -1
  490. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  491. package/dist/modes/rpc/rpc-types.js.map +1 -1
  492. package/docs/models/evals.md +883 -39
  493. package/docs/models/model-selection.md +7 -8
  494. package/docs/rpc/examples.md +1 -1
  495. package/docs/rpc/protocol.md +9 -3
  496. package/docs/sdk/structured-decisions.md +1 -1
  497. package/docs/sdk.md +3 -3
  498. package/docs/settings.md +24 -3
  499. package/docs/subagents/reference.md +22 -4
  500. package/docs/subagents.md +2 -0
  501. package/docs/usage.md +3 -3
  502. package/docs/workflows/api-reference.md +1 -1
  503. package/docs/workflows/authoring.md +1 -7
  504. package/docs/workflows/builtins.md +1 -1
  505. package/docs/workflows/reliable-design.md +1 -1
  506. package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
  507. package/examples/extensions/gondolin/package.json +1 -1
  508. package/examples/rpc-client.ts +1 -1
  509. package/examples/rpc-extension-ui.ts +1 -1
  510. package/npm-shrinkwrap.json +70 -33
  511. package/package.json +6 -7
  512. package/dist/core/model-routing-task.d.ts.map +0 -1
  513. package/dist/core/model-routing-task.js +0 -120
  514. package/dist/core/model-routing-task.js.map +0 -1
@@ -165,6 +165,15 @@ function describeLiveState(state) {
165
165
  * The message is the wire format; see {@link FILE_MUTATION_CONFLICT_CODE}.
166
166
  */
167
167
  export class FileMutationConflict extends Error {
168
+ reason;
169
+ path;
170
+ canonicalKey;
171
+ requester;
172
+ presentedTag;
173
+ /** Structured alongside the message so a ledger can record it without re-parsing text. */
174
+ evidence;
175
+ liveState;
176
+ causeCode;
168
177
  constructor(details) {
169
178
  super(FileMutationConflict.formatMessage(details));
170
179
  // Sub-classing Error does not set this, and consumers match on it.
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-coordinator.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,4BAA4B,CAAC;AAEjF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CAAC;AAqGpE;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,SAAS,SAAS,CAAC,IAAY;IAC9B,O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CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,mFAAmF;QACnF,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACH,CAAC","sourcesContent":["import { computeFileHash, type SnapshotStore } from \"./hashline-engine/index.ts\";\n\n/**\n * Stable token carried inside every conflict message.\n *\n * It lives in the message text, not only on the class, because nothing typed survives the\n * trip from a tool to a workflow: a subagent result reports `cause`/`error` as strings, a\n * workflow task result has no error field at all, and a workflow runner reduces a failure to\n * `err.message`. Matching this token is how a consumer downstream of that flattening tells a\n * mutation conflict apart from an ordinary tool error.\n *\n * It is placed at the start of the message so it survives truncation of the tail as the\n * message is relayed. Never change it without updating every consumer that matches on it.\n */\nexport const FILE_MUTATION_CONFLICT_CODE = \"FILE_MUTATION_CONFLICT\";\n\n/**\n * Reasons report a {@link FileMutationLiveState} wherever the live target can be described,\n * which is everywhere except `target_unreadable`: that one exists precisely because the target\n * could not be read, so claiming a size or a tag for it would be invention.\n *\n * Only the reasons that have something to compare against also report a\n * {@link FileMutationConflictEvidence} diff: `no_prior_observation` never read the file, and\n * `foreign_snapshot` presented a tag naming content this session has never seen, so in both\n * cases there is no prior side to diff.\n */\nexport type FileMutationConflictReason =\n\t/** Live content moved between the mutation being prepared and the write being attempted. */\n\t| \"changed_before_write\"\n\t/** Overwrite attempted with no prior read of this file in this session. */\n\t| \"no_prior_observation\"\n\t/** Overwrite attempted, but what this session observed is no longer the live content. */\n\t| \"changed_since_observation\"\n\t/** Exclusive create lost: the target already exists. */\n\t| \"target_exists\"\n\t/** The target no longer exists: removed between preparing the mutation and writing it. */\n\t| \"target_missing\"\n\t/**\n\t * The target still exists but can no longer be read: replaced by a directory, made\n\t * unreadable, locked, or rewritten as content this reader cannot parse. Distinct from a\n\t * content change because there is nothing to diff, and from a deletion because the path is\n\t * still occupied.\n\t */\n\t| \"target_unreadable\"\n\t/** The presented tag was never minted in this session's snapshot store. */\n\t| \"foreign_snapshot\";\n\n/**\n * Correlation only.\n *\n * Flora, 2026-08-13: identity \"must never grant permission or identify a current owner or\n * culprit\". So this describes the writer being *rejected*, never a winner, and nothing in\n * this module reads it to decide whether a mutation is admitted. A record of the last Atomic\n * writer could not prove ownership anyway, because shell commands, external programs, other\n * Atomic processes and symlink changes all bypass this coordinator.\n */\nexport interface MutationRequester {\n\treadonly sessionId: string;\n\t/** Session that spawned this one, from the child's `supervisor.supervisorSessionId`. */\n\treadonly parentSessionId?: string;\n\treadonly workflowRunId?: string;\n\treadonly workflowStageId?: string;\n\treadonly workflowStageName?: string;\n\treadonly subagentRunId?: string;\n\treadonly subagentAgent?: string;\n\t/**\n\t * Position within a fan-out. Needed to tell siblings apart: a child's intercom address is\n\t * `agent + runId + index` (`resolveSubagentIntercomTarget`), so a stage that spawns several\n\t * children of one agent onto one file yields identical identity without it.\n\t */\n\treadonly subagentIndex?: number;\n\t/** Opaque per-attempt UUID. Diagnostic only; never an authority. */\n\treadonly attemptId?: string;\n\t/** The specific tool call rejected. Narrower than the attempt, which makes many calls. */\n\treadonly toolCallId?: string;\n}\n\n/**\n * Resolved per execution rather than captured once.\n *\n * Mirrors `sessionTempDir` in the session tool registry, which is a thunk \"so bash spill\n * files follow the live transcript session across fork/branch/resume\". A requester captured\n * at tool-construction time would keep a stale session id through exactly those transitions,\n * which is the relaunch case this feature exists to make legible.\n *\n * Takes the tool call id rather than leaving callers to merge it in, because it has a\n * different lifetime from the rest: session identity belongs to the session, the call id is\n * an argument of the single `execute` being rejected.\n */\nexport type MutationRequesterResolver = (toolCallId: string) => MutationRequester | undefined;\n\n/**\n * What actually diverged, so a conflict can be acted on without a second round trip.\n *\n * A reason and a path are not evidence; they say a race happened, not what it did. Whatever acts\n * on the rejection, a workflow applying its own control behavior or a human reading the error,\n * needs the divergence itself before it can decide anything.\n *\n * The span is computed by trimming the common prefix and suffix rather than comparing line by\n * line positionally, so inserting one line at the top reports one changed region and not every\n * following line.\n */\nexport interface FileMutationConflictEvidence {\n\t/** 1-based line of the first divergence. */\n\treadonly line: number;\n\t/** Lines the rejected mutation assumed occupied the divergent span. */\n\treadonly assumedLines: number;\n\t/** Lines actually occupying it now. */\n\treadonly foundLines: number;\n\t/** First assumed line, clamped. Absent when the span is pure insertion. */\n\treadonly assumed?: string;\n\t/** First live line, clamped. Absent when the span is pure deletion. */\n\treadonly found?: string;\n}\n\n/**\n * Excerpts are clamped because a conflict travels as message text through channels that\n * truncate, and because file content copied into an error outlives the turn in ledger records.\n * One line per side is enough to tell the model whether its plan still holds.\n */\nconst EVIDENCE_LINE_CHARS = 120;\n\nfunction clampLine(line: string): string {\n\treturn line.length <= EVIDENCE_LINE_CHARS ? line : `${line.slice(0, EVIDENCE_LINE_CHARS)}...`;\n}\n\n/**\n * The target as it stood at the moment of refusal, independent of any comparison.\n *\n * Kept separate from {@link FileMutationConflictEvidence} because the two answer different\n * questions and only one of them can be unanswerable. A conflict may have nothing to diff\n * against, as when the session never read the file, but there is still always something worth\n * reporting about what the mutation was aimed at. Size in particular is the difference between\n * clobbering an empty placeholder and clobbering four hundred lines of production code.\n */\nexport interface FileMutationLiveState {\n\t/** Lines currently in the file. Zero when it is empty or does not exist. */\n\treadonly lines: number;\n\t/** Tag of the live content, so a rejected tag can be told apart from the real one. */\n\treadonly tag?: string;\n\t/** First line, clamped. Absent when the file is missing, empty, or starts with a blank line. */\n\treadonly firstLine?: string;\n}\n\n/** Describe live content, or a missing target when `live` is `undefined`. */\nexport function computeLiveState(live: string | undefined): FileMutationLiveState {\n\tif (live === undefined) return { lines: 0 };\n\t// Trailing newline terminates the last line rather than starting an empty one.\n\tconst lines = live === \"\" ? [] : live.replace(/\\n$/, \"\").split(\"\\n\");\n\tconst first = lines[0];\n\treturn {\n\t\tlines: lines.length,\n\t\ttag: computeFileHash(live),\n\t\t...(first ? { firstLine: clampLine(first) } : {}),\n\t};\n}\n\n/**\n * Compare what a mutation assumed against what is live, returning `undefined` when they agree.\n *\n * Both sides must already share a line-ending convention. `Snapshot.text` is normalized to LF,\n * so a caller passing raw live bytes on Windows would report every line as divergent.\n */\nexport function computeConflictEvidence(assumed: string, found: string): FileMutationConflictEvidence | undefined {\n\tif (assumed === found) return undefined;\n\tconst assumedLines = assumed.split(\"\\n\");\n\tconst foundLines = found.split(\"\\n\");\n\tlet start = 0;\n\twhile (start < assumedLines.length && start < foundLines.length && assumedLines[start] === foundLines[start]) {\n\t\tstart++;\n\t}\n\tlet endAssumed = assumedLines.length;\n\tlet endFound = foundLines.length;\n\twhile (endAssumed > start && endFound > start && assumedLines[endAssumed - 1] === foundLines[endFound - 1]) {\n\t\tendAssumed--;\n\t\tendFound--;\n\t}\n\treturn {\n\t\tline: start + 1,\n\t\tassumedLines: endAssumed - start,\n\t\tfoundLines: endFound - start,\n\t\t...(start < endAssumed ? { assumed: clampLine(assumedLines[start] ?? \"\") } : {}),\n\t\t...(start < endFound ? { found: clampLine(foundLines[start] ?? \"\") } : {}),\n\t};\n}\n\nexport interface FileMutationConflictDetails {\n\treadonly reason: FileMutationConflictReason;\n\t/** Display path, as the model referred to it. */\n\treadonly path: string;\n\t/** Symlink-resolved key, from `canonicalMutationKey`. */\n\treadonly canonicalKey: string;\n\treadonly requester?: MutationRequester;\n\t/** The tag the rejected mutation presented, when it had one. */\n\treadonly presentedTag?: string;\n\t/** Absent when the reason carries no comparison, as with `no_prior_observation`. */\n\treadonly evidence?: FileMutationConflictEvidence;\n\t/** What the mutation was aimed at. Absent only when it could not be read at all. */\n\treadonly liveState?: FileMutationLiveState;\n\t/**\n\t * Filesystem error code that classified the conflict, such as `EISDIR` or `EACCES`. For a\n\t * target that became unreadable this is the whole diagnosis, since nothing else about the\n\t * file can be reported once the read fails.\n\t */\n\treadonly causeCode?: string;\n}\n\ninterface ReasonCopy {\n\t/** Why the mutation was refused, as a full sentence. */\n\treadonly diagnosis: string;\n\t/** What to do about it, addressed to the model and naming the path it acts on. */\n\treadonly instruction: (path: string) => string;\n}\n\nconst SHELL_OUTPUT_IS_NOT_A_READ =\n\t\"Shell output (cat, sed, head) and tags quoted in error messages do not count as reads.\";\n\n/**\n * Paired so the instruction cannot contradict the diagnosis it follows.\n *\n * A single shared instruction cannot be true of all seven reasons. \"Read the file again\" is\n * false for the ones that fail precisely because the file was never read, and impossible for\n * `target_missing`, where there is nothing left to read.\n */\nconst REASON_COPY: Record<FileMutationConflictReason, ReasonCopy> = {\n\tchanged_before_write: {\n\t\tdiagnosis: \"The file changed after this edit was prepared.\",\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} again and rebuild the edit from its current content and tag. Do not resend the same edit.`,\n\t},\n\tno_prior_observation: {\n\t\tdiagnosis: `This session has not read the file it is overwriting. ${SHELL_OUTPUT_IS_NOT_A_READ}`,\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} with the read tool, then decide whether this overwrite is still the change you want.`,\n\t},\n\tchanged_since_observation: {\n\t\tdiagnosis: \"The file changed since this session last read it.\",\n\t\tinstruction: (path) => `Read ${path} again and reconcile this change with its current content.`,\n\t},\n\ttarget_exists: {\n\t\tdiagnosis: \"The file already exists.\",\n\t\tinstruction: (path) => `Read ${path} and edit it in place, or write to a different path.`,\n\t},\n\ttarget_missing: {\n\t\tdiagnosis: \"The file no longer exists.\",\n\t\tinstruction: () =>\n\t\t\t\"Do not read it. Confirm the removal was intended, then recreate the file or drop this change.\",\n\t},\n\ttarget_unreadable: {\n\t\tdiagnosis: \"The file still exists but can no longer be read.\",\n\t\tinstruction: (path) =>\n\t\t\t`Something replaced or locked ${path} rather than editing it. Inspect what is there before retrying; an identical edit will fail the same way.`,\n\t},\n\tforeign_snapshot: {\n\t\tdiagnosis: `The presented tag was not issued to this session. Only read, search, write, and edit results issue tags. ${SHELL_OUTPUT_IS_NOT_A_READ}`,\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} with the read tool (a line range such as ${path}:10-40 is enough), then retry with the tag and line numbers from that result. Nothing was written.`,\n\t},\n};\n\nfunction describeRequester(requester: MutationRequester): string {\n\tconst parts = [`session=${requester.sessionId}`];\n\tif (requester.parentSessionId) parts.push(`parent=${requester.parentSessionId}`);\n\tif (requester.workflowRunId) parts.push(`run=${requester.workflowRunId}`);\n\tif (requester.workflowStageId) parts.push(`stage=${requester.workflowStageId}`);\n\t// Quoted: a stage name is free text and the field separator here is a space.\n\tif (requester.workflowStageName) parts.push(`stageName=\"${requester.workflowStageName}\"`);\n\tif (requester.subagentRunId) parts.push(`child=${requester.subagentRunId}`);\n\tif (requester.subagentAgent) parts.push(`agent=${requester.subagentAgent}`);\n\t// Presence, not truthiness: the first child of a fan-out is index 0.\n\tif (requester.subagentIndex !== undefined) parts.push(`index=${requester.subagentIndex}`);\n\tif (requester.attemptId) parts.push(`attempt=${requester.attemptId}`);\n\tif (requester.toolCallId) parts.push(`call=${requester.toolCallId}`);\n\treturn parts.join(\" \");\n}\n\n/**\n * Quote an excerpt of file content so it stays on its own line of the message.\n *\n * `JSON.stringify` rather than wrapping in backticks or quotes of our own: source lines\n * routinely contain both, and a template literal in a TypeScript file would otherwise close\n * the delimiter early and leave the excerpt unreadable. It also escapes control characters,\n * so a stray CR from a file this module was handed unnormalized shows up as `\\r` rather than\n * silently rearranging the message.\n */\nfunction quoteExcerpt(text: string): string {\n\treturn JSON.stringify(text);\n}\n\nfunction describeEvidence(evidence: FileMutationConflictEvidence): string {\n\tconst span =\n\t\tevidence.assumedLines === 1 && evidence.foundLines === 1\n\t\t\t? \"\"\n\t\t\t: ` (${evidence.assumedLines} lines replaced by ${evidence.foundLines})`;\n\tconst at = `line ${evidence.line}`;\n\tif (evidence.assumed !== undefined && evidence.found !== undefined) {\n\t\treturn `${at}: assumed ${quoteExcerpt(evidence.assumed)}, found ${quoteExcerpt(evidence.found)}${span}.`;\n\t}\n\tif (evidence.found !== undefined) {\n\t\treturn `${at}: found ${quoteExcerpt(evidence.found)} where this mutation expected nothing${span}.`;\n\t}\n\treturn `${at}: assumed ${quoteExcerpt(evidence.assumed ?? \"\")}, which is no longer present${span}.`;\n}\n\n/**\n * The live tag is labeled as unusable because it is not minted by the refusal: an agent that\n * copies it into a retry is rejected again with the same conflict.\n */\nfunction describeLiveState(state: FileMutationLiveState): string {\n\tif (!state.tag) return \"does not exist.\";\n\tconst first = state.firstLine ? `, first line ${quoteExcerpt(state.firstLine)}` : \"\";\n\treturn `${state.lines} lines${first}. Current tag #${state.tag} is for comparison only; edits need a tag from your own read.`;\n}\n\n/**\n * Raised instead of a bare `Error` so a conflict is countable rather than merely readable.\n * The message is the wire format; see {@link FILE_MUTATION_CONFLICT_CODE}.\n */\nexport class FileMutationConflict extends Error {\n\treadonly reason: FileMutationConflictReason;\n\treadonly path: string;\n\treadonly canonicalKey: string;\n\treadonly requester: MutationRequester | undefined;\n\treadonly presentedTag: string | undefined;\n\t/** Structured alongside the message so a ledger can record it without re-parsing text. */\n\treadonly evidence: FileMutationConflictEvidence | undefined;\n\treadonly liveState: FileMutationLiveState | undefined;\n\treadonly causeCode: string | undefined;\n\n\tconstructor(details: FileMutationConflictDetails) {\n\t\tsuper(FileMutationConflict.formatMessage(details));\n\t\t// Sub-classing Error does not set this, and consumers match on it.\n\t\tthis.name = \"FileMutationConflict\";\n\t\tthis.reason = details.reason;\n\t\tthis.path = details.path;\n\t\tthis.canonicalKey = details.canonicalKey;\n\t\tthis.requester = details.requester;\n\t\tthis.presentedTag = details.presentedTag;\n\t\tthis.evidence = details.evidence;\n\t\tthis.liveState = details.liveState;\n\t\tthis.causeCode = details.causeCode;\n\t}\n\n\t/**\n\t * One labeled line per concern, ordered by what must survive truncation: the code, reason,\n\t * and path first, then why and what to do, then the divergence and live state, and the\n\t * requester identity last. Identity is correlation for logs, never guidance, so it is the\n\t * most expendable part of the message for the model reading it.\n\t */\n\tstatic formatMessage(details: FileMutationConflictDetails): string {\n\t\tconst copy = REASON_COPY[details.reason];\n\t\tconst presented = details.presentedTag ? ` (presented #${details.presentedTag})` : \"\";\n\t\tconst cause = details.causeCode ? ` Filesystem error: ${details.causeCode}.` : \"\";\n\t\tconst lines = [\n\t\t\t`${FILE_MUTATION_CONFLICT_CODE}:${details.reason} ${details.path}${presented}`,\n\t\t\t`Why: ${copy.diagnosis}${cause}`,\n\t\t\t`Next: ${copy.instruction(details.path)}`,\n\t\t];\n\t\tif (details.evidence) lines.push(`First divergence: ${describeEvidence(details.evidence)}`);\n\t\tif (details.liveState) lines.push(`Live file: ${describeLiveState(details.liveState)}`);\n\t\tif (details.requester) lines.push(`Requester: ${describeRequester(details.requester)}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/** Whether a thrown value is an exclusive-create collision reported by the filesystem. */\nexport function isExclusiveCreateCollision(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\";\n}\n\n/**\n * Whether a thrown value says the target is gone. `ENOTDIR` counts because a parent directory\n * replaced by a file makes the path unreachable for the same reason a deletion does.\n */\nexport function isMissingTargetError(error: unknown): boolean {\n\tconst code = filesystemErrorCode(error);\n\treturn code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\n/** The `code` a filesystem rejection carries, when it carries one. */\nexport function filesystemErrorCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null || !(\"code\" in error)) return undefined;\n\tconst code = (error as { code?: unknown }).code;\n\treturn typeof code === \"string\" ? code : undefined;\n}\n\n/**\n * Guard for the window between preparing a mutation and committing it, called under the\n * mutation queue.\n *\n * `prepared` is the content the mutation was computed against, which for a hashline edit is\n * the file as `prepare` read it, NOT what the session originally observed, since `prepare`\n * re-reads and may have recovered onto drifted content. Naming that honestly matters: this\n * closes a time-of-check window, it does not prove the session read the file.\n *\n * Full text rather than tags: a hashline tag is 16 bits and the engine documents that it can\n * collide, so it is a label for the model to recognize, never proof of identity.\n */\nexport function assertLiveMatchesPrepared(args: {\n\treadonly canonicalKey: string;\n\treadonly path: string;\n\treadonly prepared: string;\n\treadonly live: string;\n\treadonly requester?: MutationRequester;\n\treadonly presentedTag?: string;\n}): void {\n\tif (args.live === args.prepared) return;\n\tconst evidence = computeConflictEvidence(args.prepared, args.live);\n\tthrow new FileMutationConflict({\n\t\treason: \"changed_before_write\",\n\t\tpath: args.path,\n\t\tcanonicalKey: args.canonicalKey,\n\t\trequester: args.requester,\n\t\tpresentedTag: args.presentedTag,\n\t\tliveState: computeLiveState(args.live),\n\t\t...(evidence ? { evidence } : {}),\n\t});\n}\n\n/**\n * Guard for `write` overwriting an existing file: this session must already have observed the\n * exact content it is about to replace.\n *\n * Asks the session's own store and never another session's, which is what keeps cross-session\n * rejection strict. `byHashAndText` answers both halves of the requirement at once, since a\n * hit means this session recorded exactly this content for this path.\n *\n * `storeKey` is the snapshot store's own key convention, the normalized absolute path, which\n * is NOT symlink-resolved unlike `canonicalKey`. Passing the wrong one makes a symlinked path\n * miss and report a false `no_prior_observation`.\n *\n * The tag is derived here rather than accepted. Unlike the engine's own use of\n * `byHashAndText`, where the hash is the independent claim a section presented, `write` has no\n * presented tag: it replaces the whole file. Any tag is therefore just `live` hashed, and\n * taking it as a parameter only creates a way for the two to disagree silently.\n */\nexport function assertPriorSessionObservation(args: {\n\treadonly canonicalKey: string;\n\treadonly storeKey: string;\n\treadonly path: string;\n\treadonly store: SnapshotStore;\n\treadonly live: string;\n\treadonly requester?: MutationRequester;\n}): void {\n\tif (args.store.byHashAndText(args.storeKey, computeFileHash(args.live), args.live)) return;\n\t// The last version this session recorded is what it believed it was overwriting, so the\n\t// divergence from live is the evidence. Without one there is nothing to diff, but the live\n\t// state still reports what was about to be clobbered sight unseen, which is the part\n\t// whoever reviews the rejection actually needs.\n\tconst head = args.store.head(args.storeKey);\n\tconst evidence = head ? computeConflictEvidence(head.text, args.live) : undefined;\n\tthrow new FileMutationConflict({\n\t\treason: head ? \"changed_since_observation\" : \"no_prior_observation\",\n\t\tpath: args.path,\n\t\tcanonicalKey: args.canonicalKey,\n\t\trequester: args.requester,\n\t\tliveState: computeLiveState(args.live),\n\t\t...(evidence ? { evidence } : {}),\n\t});\n}\n\n/**\n * Build a requester from parts already present on a session. Kept pure so it is testable\n * without constructing an `AgentSession`, and so this module never imports one.\n */\nexport function buildMutationRequester(parts: {\n\treadonly sessionId: string;\n\treadonly orchestration?: {\n\t\treadonly kind: string;\n\t\treadonly workflowRunId: string;\n\t\treadonly workflowStageId: string;\n\t\treadonly workflowStageName: string;\n\t};\n\treadonly intercom?: {\n\t\treadonly runId: string;\n\t\treadonly agent: string;\n\t\treadonly index?: number;\n\t\treadonly supervisor?: { readonly supervisorSessionId: string };\n\t};\n\treadonly attemptId?: string;\n\treadonly toolCallId?: string;\n}): MutationRequester {\n\tconst workflow = parts.orchestration?.kind === \"workflow-stage\" ? parts.orchestration : undefined;\n\tconst supervisorSessionId = parts.intercom?.supervisor?.supervisorSessionId;\n\tconst subagentIndex = parts.intercom?.index;\n\treturn {\n\t\tsessionId: parts.sessionId,\n\t\t...(supervisorSessionId ? { parentSessionId: supervisorSessionId } : {}),\n\t\t...(workflow ? { workflowRunId: workflow.workflowRunId } : {}),\n\t\t...(workflow ? { workflowStageId: workflow.workflowStageId } : {}),\n\t\t...(workflow ? { workflowStageName: workflow.workflowStageName } : {}),\n\t\t...(parts.intercom ? { subagentRunId: parts.intercom.runId } : {}),\n\t\t...(parts.intercom ? { subagentAgent: parts.intercom.agent } : {}),\n\t\t// Presence, not truthiness: index 0 is the first child, and `0 ? … : {}` drops it.\n\t\t...(subagentIndex !== undefined ? { subagentIndex } : {}),\n\t\t...(parts.attemptId ? { attemptId: parts.attemptId } : {}),\n\t\t...(parts.toolCallId ? { toolCallId: parts.toolCallId } : {}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"file-mutation-coordinator.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,MAAM,4BAA4B,CAAC;AAEjF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CAAC;AAqGpE;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,SAAS,SAAS,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,MAAM,IAAI,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC;AAC/F,CAAC;AAoBD,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB,CAAC,IAAwB;IACxD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC5C,+EAA+E;IAC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,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,mFAAmF;QACnF,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC;AACH,CAAC","sourcesContent":["import { computeFileHash, type SnapshotStore } from \"./hashline-engine/index.ts\";\n\n/**\n * Stable token carried inside every conflict message.\n *\n * It lives in the message text, not only on the class, because nothing typed survives the\n * trip from a tool to a workflow: a subagent result reports `cause`/`error` as strings, a\n * workflow task result has no error field at all, and a workflow runner reduces a failure to\n * `err.message`. Matching this token is how a consumer downstream of that flattening tells a\n * mutation conflict apart from an ordinary tool error.\n *\n * It is placed at the start of the message so it survives truncation of the tail as the\n * message is relayed. Never change it without updating every consumer that matches on it.\n */\nexport const FILE_MUTATION_CONFLICT_CODE = \"FILE_MUTATION_CONFLICT\";\n\n/**\n * Reasons report a {@link FileMutationLiveState} wherever the live target can be described,\n * which is everywhere except `target_unreadable`: that one exists precisely because the target\n * could not be read, so claiming a size or a tag for it would be invention.\n *\n * Only the reasons that have something to compare against also report a\n * {@link FileMutationConflictEvidence} diff: `no_prior_observation` never read the file, and\n * `foreign_snapshot` presented a tag naming content this session has never seen, so in both\n * cases there is no prior side to diff.\n */\nexport type FileMutationConflictReason =\n\t/** Live content moved between the mutation being prepared and the write being attempted. */\n\t| \"changed_before_write\"\n\t/** Overwrite attempted with no prior read of this file in this session. */\n\t| \"no_prior_observation\"\n\t/** Overwrite attempted, but what this session observed is no longer the live content. */\n\t| \"changed_since_observation\"\n\t/** Exclusive create lost: the target already exists. */\n\t| \"target_exists\"\n\t/** The target no longer exists: removed between preparing the mutation and writing it. */\n\t| \"target_missing\"\n\t/**\n\t * The target still exists but can no longer be read: replaced by a directory, made\n\t * unreadable, locked, or rewritten as content this reader cannot parse. Distinct from a\n\t * content change because there is nothing to diff, and from a deletion because the path is\n\t * still occupied.\n\t */\n\t| \"target_unreadable\"\n\t/** The presented tag was never minted in this session's snapshot store. */\n\t| \"foreign_snapshot\";\n\n/**\n * Correlation only.\n *\n * Flora, 2026-08-13: identity \"must never grant permission or identify a current owner or\n * culprit\". So this describes the writer being *rejected*, never a winner, and nothing in\n * this module reads it to decide whether a mutation is admitted. A record of the last Atomic\n * writer could not prove ownership anyway, because shell commands, external programs, other\n * Atomic processes and symlink changes all bypass this coordinator.\n */\nexport interface MutationRequester {\n\treadonly sessionId: string;\n\t/** Session that spawned this one, from the child's `supervisor.supervisorSessionId`. */\n\treadonly parentSessionId?: string;\n\treadonly workflowRunId?: string;\n\treadonly workflowStageId?: string;\n\treadonly workflowStageName?: string;\n\treadonly subagentRunId?: string;\n\treadonly subagentAgent?: string;\n\t/**\n\t * Position within a fan-out. Needed to tell siblings apart: a child's intercom address is\n\t * `agent + runId + index` (`resolveSubagentIntercomTarget`), so a stage that spawns several\n\t * children of one agent onto one file yields identical identity without it.\n\t */\n\treadonly subagentIndex?: number;\n\t/** Opaque per-attempt UUID. Diagnostic only; never an authority. */\n\treadonly attemptId?: string;\n\t/** The specific tool call rejected. Narrower than the attempt, which makes many calls. */\n\treadonly toolCallId?: string;\n}\n\n/**\n * Resolved per execution rather than captured once.\n *\n * Mirrors `sessionTempDir` in the session tool registry, which is a thunk \"so bash spill\n * files follow the live transcript session across fork/branch/resume\". A requester captured\n * at tool-construction time would keep a stale session id through exactly those transitions,\n * which is the relaunch case this feature exists to make legible.\n *\n * Takes the tool call id rather than leaving callers to merge it in, because it has a\n * different lifetime from the rest: session identity belongs to the session, the call id is\n * an argument of the single `execute` being rejected.\n */\nexport type MutationRequesterResolver = (toolCallId: string) => MutationRequester | undefined;\n\n/**\n * What actually diverged, so a conflict can be acted on without a second round trip.\n *\n * A reason and a path are not evidence; they say a race happened, not what it did. Whatever acts\n * on the rejection, a workflow applying its own control behavior or a human reading the error,\n * needs the divergence itself before it can decide anything.\n *\n * The span is computed by trimming the common prefix and suffix rather than comparing line by\n * line positionally, so inserting one line at the top reports one changed region and not every\n * following line.\n */\nexport interface FileMutationConflictEvidence {\n\t/** 1-based line of the first divergence. */\n\treadonly line: number;\n\t/** Lines the rejected mutation assumed occupied the divergent span. */\n\treadonly assumedLines: number;\n\t/** Lines actually occupying it now. */\n\treadonly foundLines: number;\n\t/** First assumed line, clamped. Absent when the span is pure insertion. */\n\treadonly assumed?: string;\n\t/** First live line, clamped. Absent when the span is pure deletion. */\n\treadonly found?: string;\n}\n\n/**\n * Excerpts are clamped because a conflict travels as message text through channels that\n * truncate, and because file content copied into an error outlives the turn in ledger records.\n * One line per side is enough to tell the model whether its plan still holds.\n */\nconst EVIDENCE_LINE_CHARS = 120;\n\nfunction clampLine(line: string): string {\n\treturn line.length <= EVIDENCE_LINE_CHARS ? line : `${line.slice(0, EVIDENCE_LINE_CHARS)}...`;\n}\n\n/**\n * The target as it stood at the moment of refusal, independent of any comparison.\n *\n * Kept separate from {@link FileMutationConflictEvidence} because the two answer different\n * questions and only one of them can be unanswerable. A conflict may have nothing to diff\n * against, as when the session never read the file, but there is still always something worth\n * reporting about what the mutation was aimed at. Size in particular is the difference between\n * clobbering an empty placeholder and clobbering four hundred lines of production code.\n */\nexport interface FileMutationLiveState {\n\t/** Lines currently in the file. Zero when it is empty or does not exist. */\n\treadonly lines: number;\n\t/** Tag of the live content, so a rejected tag can be told apart from the real one. */\n\treadonly tag?: string;\n\t/** First line, clamped. Absent when the file is missing, empty, or starts with a blank line. */\n\treadonly firstLine?: string;\n}\n\n/** Describe live content, or a missing target when `live` is `undefined`. */\nexport function computeLiveState(live: string | undefined): FileMutationLiveState {\n\tif (live === undefined) return { lines: 0 };\n\t// Trailing newline terminates the last line rather than starting an empty one.\n\tconst lines = live === \"\" ? [] : live.replace(/\\n$/, \"\").split(\"\\n\");\n\tconst first = lines[0];\n\treturn {\n\t\tlines: lines.length,\n\t\ttag: computeFileHash(live),\n\t\t...(first ? { firstLine: clampLine(first) } : {}),\n\t};\n}\n\n/**\n * Compare what a mutation assumed against what is live, returning `undefined` when they agree.\n *\n * Both sides must already share a line-ending convention. `Snapshot.text` is normalized to LF,\n * so a caller passing raw live bytes on Windows would report every line as divergent.\n */\nexport function computeConflictEvidence(assumed: string, found: string): FileMutationConflictEvidence | undefined {\n\tif (assumed === found) return undefined;\n\tconst assumedLines = assumed.split(\"\\n\");\n\tconst foundLines = found.split(\"\\n\");\n\tlet start = 0;\n\twhile (start < assumedLines.length && start < foundLines.length && assumedLines[start] === foundLines[start]) {\n\t\tstart++;\n\t}\n\tlet endAssumed = assumedLines.length;\n\tlet endFound = foundLines.length;\n\twhile (endAssumed > start && endFound > start && assumedLines[endAssumed - 1] === foundLines[endFound - 1]) {\n\t\tendAssumed--;\n\t\tendFound--;\n\t}\n\treturn {\n\t\tline: start + 1,\n\t\tassumedLines: endAssumed - start,\n\t\tfoundLines: endFound - start,\n\t\t...(start < endAssumed ? { assumed: clampLine(assumedLines[start] ?? \"\") } : {}),\n\t\t...(start < endFound ? { found: clampLine(foundLines[start] ?? \"\") } : {}),\n\t};\n}\n\nexport interface FileMutationConflictDetails {\n\treadonly reason: FileMutationConflictReason;\n\t/** Display path, as the model referred to it. */\n\treadonly path: string;\n\t/** Symlink-resolved key, from `canonicalMutationKey`. */\n\treadonly canonicalKey: string;\n\treadonly requester?: MutationRequester;\n\t/** The tag the rejected mutation presented, when it had one. */\n\treadonly presentedTag?: string;\n\t/** Absent when the reason carries no comparison, as with `no_prior_observation`. */\n\treadonly evidence?: FileMutationConflictEvidence;\n\t/** What the mutation was aimed at. Absent only when it could not be read at all. */\n\treadonly liveState?: FileMutationLiveState;\n\t/**\n\t * Filesystem error code that classified the conflict, such as `EISDIR` or `EACCES`. For a\n\t * target that became unreadable this is the whole diagnosis, since nothing else about the\n\t * file can be reported once the read fails.\n\t */\n\treadonly causeCode?: string;\n}\n\ninterface ReasonCopy {\n\t/** Why the mutation was refused, as a full sentence. */\n\treadonly diagnosis: string;\n\t/** What to do about it, addressed to the model and naming the path it acts on. */\n\treadonly instruction: (path: string) => string;\n}\n\nconst SHELL_OUTPUT_IS_NOT_A_READ =\n\t\"Shell output (cat, sed, head) and tags quoted in error messages do not count as reads.\";\n\n/**\n * Paired so the instruction cannot contradict the diagnosis it follows.\n *\n * A single shared instruction cannot be true of all seven reasons. \"Read the file again\" is\n * false for the ones that fail precisely because the file was never read, and impossible for\n * `target_missing`, where there is nothing left to read.\n */\nconst REASON_COPY: Record<FileMutationConflictReason, ReasonCopy> = {\n\tchanged_before_write: {\n\t\tdiagnosis: \"The file changed after this edit was prepared.\",\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} again and rebuild the edit from its current content and tag. Do not resend the same edit.`,\n\t},\n\tno_prior_observation: {\n\t\tdiagnosis: `This session has not read the file it is overwriting. ${SHELL_OUTPUT_IS_NOT_A_READ}`,\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} with the read tool, then decide whether this overwrite is still the change you want.`,\n\t},\n\tchanged_since_observation: {\n\t\tdiagnosis: \"The file changed since this session last read it.\",\n\t\tinstruction: (path) => `Read ${path} again and reconcile this change with its current content.`,\n\t},\n\ttarget_exists: {\n\t\tdiagnosis: \"The file already exists.\",\n\t\tinstruction: (path) => `Read ${path} and edit it in place, or write to a different path.`,\n\t},\n\ttarget_missing: {\n\t\tdiagnosis: \"The file no longer exists.\",\n\t\tinstruction: () =>\n\t\t\t\"Do not read it. Confirm the removal was intended, then recreate the file or drop this change.\",\n\t},\n\ttarget_unreadable: {\n\t\tdiagnosis: \"The file still exists but can no longer be read.\",\n\t\tinstruction: (path) =>\n\t\t\t`Something replaced or locked ${path} rather than editing it. Inspect what is there before retrying; an identical edit will fail the same way.`,\n\t},\n\tforeign_snapshot: {\n\t\tdiagnosis: `The presented tag was not issued to this session. Only read, search, write, and edit results issue tags. ${SHELL_OUTPUT_IS_NOT_A_READ}`,\n\t\tinstruction: (path) =>\n\t\t\t`Read ${path} with the read tool (a line range such as ${path}:10-40 is enough), then retry with the tag and line numbers from that result. Nothing was written.`,\n\t},\n};\n\nfunction describeRequester(requester: MutationRequester): string {\n\tconst parts = [`session=${requester.sessionId}`];\n\tif (requester.parentSessionId) parts.push(`parent=${requester.parentSessionId}`);\n\tif (requester.workflowRunId) parts.push(`run=${requester.workflowRunId}`);\n\tif (requester.workflowStageId) parts.push(`stage=${requester.workflowStageId}`);\n\t// Quoted: a stage name is free text and the field separator here is a space.\n\tif (requester.workflowStageName) parts.push(`stageName=\"${requester.workflowStageName}\"`);\n\tif (requester.subagentRunId) parts.push(`child=${requester.subagentRunId}`);\n\tif (requester.subagentAgent) parts.push(`agent=${requester.subagentAgent}`);\n\t// Presence, not truthiness: the first child of a fan-out is index 0.\n\tif (requester.subagentIndex !== undefined) parts.push(`index=${requester.subagentIndex}`);\n\tif (requester.attemptId) parts.push(`attempt=${requester.attemptId}`);\n\tif (requester.toolCallId) parts.push(`call=${requester.toolCallId}`);\n\treturn parts.join(\" \");\n}\n\n/**\n * Quote an excerpt of file content so it stays on its own line of the message.\n *\n * `JSON.stringify` rather than wrapping in backticks or quotes of our own: source lines\n * routinely contain both, and a template literal in a TypeScript file would otherwise close\n * the delimiter early and leave the excerpt unreadable. It also escapes control characters,\n * so a stray CR from a file this module was handed unnormalized shows up as `\\r` rather than\n * silently rearranging the message.\n */\nfunction quoteExcerpt(text: string): string {\n\treturn JSON.stringify(text);\n}\n\nfunction describeEvidence(evidence: FileMutationConflictEvidence): string {\n\tconst span =\n\t\tevidence.assumedLines === 1 && evidence.foundLines === 1\n\t\t\t? \"\"\n\t\t\t: ` (${evidence.assumedLines} lines replaced by ${evidence.foundLines})`;\n\tconst at = `line ${evidence.line}`;\n\tif (evidence.assumed !== undefined && evidence.found !== undefined) {\n\t\treturn `${at}: assumed ${quoteExcerpt(evidence.assumed)}, found ${quoteExcerpt(evidence.found)}${span}.`;\n\t}\n\tif (evidence.found !== undefined) {\n\t\treturn `${at}: found ${quoteExcerpt(evidence.found)} where this mutation expected nothing${span}.`;\n\t}\n\treturn `${at}: assumed ${quoteExcerpt(evidence.assumed ?? \"\")}, which is no longer present${span}.`;\n}\n\n/**\n * The live tag is labeled as unusable because it is not minted by the refusal: an agent that\n * copies it into a retry is rejected again with the same conflict.\n */\nfunction describeLiveState(state: FileMutationLiveState): string {\n\tif (!state.tag) return \"does not exist.\";\n\tconst first = state.firstLine ? `, first line ${quoteExcerpt(state.firstLine)}` : \"\";\n\treturn `${state.lines} lines${first}. Current tag #${state.tag} is for comparison only; edits need a tag from your own read.`;\n}\n\n/**\n * Raised instead of a bare `Error` so a conflict is countable rather than merely readable.\n * The message is the wire format; see {@link FILE_MUTATION_CONFLICT_CODE}.\n */\nexport class FileMutationConflict extends Error {\n\treadonly reason: FileMutationConflictReason;\n\treadonly path: string;\n\treadonly canonicalKey: string;\n\treadonly requester: MutationRequester | undefined;\n\treadonly presentedTag: string | undefined;\n\t/** Structured alongside the message so a ledger can record it without re-parsing text. */\n\treadonly evidence: FileMutationConflictEvidence | undefined;\n\treadonly liveState: FileMutationLiveState | undefined;\n\treadonly causeCode: string | undefined;\n\n\tconstructor(details: FileMutationConflictDetails) {\n\t\tsuper(FileMutationConflict.formatMessage(details));\n\t\t// Sub-classing Error does not set this, and consumers match on it.\n\t\tthis.name = \"FileMutationConflict\";\n\t\tthis.reason = details.reason;\n\t\tthis.path = details.path;\n\t\tthis.canonicalKey = details.canonicalKey;\n\t\tthis.requester = details.requester;\n\t\tthis.presentedTag = details.presentedTag;\n\t\tthis.evidence = details.evidence;\n\t\tthis.liveState = details.liveState;\n\t\tthis.causeCode = details.causeCode;\n\t}\n\n\t/**\n\t * One labeled line per concern, ordered by what must survive truncation: the code, reason,\n\t * and path first, then why and what to do, then the divergence and live state, and the\n\t * requester identity last. Identity is correlation for logs, never guidance, so it is the\n\t * most expendable part of the message for the model reading it.\n\t */\n\tstatic formatMessage(details: FileMutationConflictDetails): string {\n\t\tconst copy = REASON_COPY[details.reason];\n\t\tconst presented = details.presentedTag ? ` (presented #${details.presentedTag})` : \"\";\n\t\tconst cause = details.causeCode ? ` Filesystem error: ${details.causeCode}.` : \"\";\n\t\tconst lines = [\n\t\t\t`${FILE_MUTATION_CONFLICT_CODE}:${details.reason} ${details.path}${presented}`,\n\t\t\t`Why: ${copy.diagnosis}${cause}`,\n\t\t\t`Next: ${copy.instruction(details.path)}`,\n\t\t];\n\t\tif (details.evidence) lines.push(`First divergence: ${describeEvidence(details.evidence)}`);\n\t\tif (details.liveState) lines.push(`Live file: ${describeLiveState(details.liveState)}`);\n\t\tif (details.requester) lines.push(`Requester: ${describeRequester(details.requester)}`);\n\t\treturn lines.join(\"\\n\");\n\t}\n}\n\n/** Whether a thrown value is an exclusive-create collision reported by the filesystem. */\nexport function isExclusiveCreateCollision(error: unknown): boolean {\n\treturn typeof error === \"object\" && error !== null && \"code\" in error && error.code === \"EEXIST\";\n}\n\n/**\n * Whether a thrown value says the target is gone. `ENOTDIR` counts because a parent directory\n * replaced by a file makes the path unreachable for the same reason a deletion does.\n */\nexport function isMissingTargetError(error: unknown): boolean {\n\tconst code = filesystemErrorCode(error);\n\treturn code === \"ENOENT\" || code === \"ENOTDIR\";\n}\n\n/** The `code` a filesystem rejection carries, when it carries one. */\nexport function filesystemErrorCode(error: unknown): string | undefined {\n\tif (typeof error !== \"object\" || error === null || !(\"code\" in error)) return undefined;\n\tconst code = (error as { code?: unknown }).code;\n\treturn typeof code === \"string\" ? code : undefined;\n}\n\n/**\n * Guard for the window between preparing a mutation and committing it, called under the\n * mutation queue.\n *\n * `prepared` is the content the mutation was computed against, which for a hashline edit is\n * the file as `prepare` read it, NOT what the session originally observed, since `prepare`\n * re-reads and may have recovered onto drifted content. Naming that honestly matters: this\n * closes a time-of-check window, it does not prove the session read the file.\n *\n * Full text rather than tags: a hashline tag is 16 bits and the engine documents that it can\n * collide, so it is a label for the model to recognize, never proof of identity.\n */\nexport function assertLiveMatchesPrepared(args: {\n\treadonly canonicalKey: string;\n\treadonly path: string;\n\treadonly prepared: string;\n\treadonly live: string;\n\treadonly requester?: MutationRequester;\n\treadonly presentedTag?: string;\n}): void {\n\tif (args.live === args.prepared) return;\n\tconst evidence = computeConflictEvidence(args.prepared, args.live);\n\tthrow new FileMutationConflict({\n\t\treason: \"changed_before_write\",\n\t\tpath: args.path,\n\t\tcanonicalKey: args.canonicalKey,\n\t\trequester: args.requester,\n\t\tpresentedTag: args.presentedTag,\n\t\tliveState: computeLiveState(args.live),\n\t\t...(evidence ? { evidence } : {}),\n\t});\n}\n\n/**\n * Guard for `write` overwriting an existing file: this session must already have observed the\n * exact content it is about to replace.\n *\n * Asks the session's own store and never another session's, which is what keeps cross-session\n * rejection strict. `byHashAndText` answers both halves of the requirement at once, since a\n * hit means this session recorded exactly this content for this path.\n *\n * `storeKey` is the snapshot store's own key convention, the normalized absolute path, which\n * is NOT symlink-resolved unlike `canonicalKey`. Passing the wrong one makes a symlinked path\n * miss and report a false `no_prior_observation`.\n *\n * The tag is derived here rather than accepted. Unlike the engine's own use of\n * `byHashAndText`, where the hash is the independent claim a section presented, `write` has no\n * presented tag: it replaces the whole file. Any tag is therefore just `live` hashed, and\n * taking it as a parameter only creates a way for the two to disagree silently.\n */\nexport function assertPriorSessionObservation(args: {\n\treadonly canonicalKey: string;\n\treadonly storeKey: string;\n\treadonly path: string;\n\treadonly store: SnapshotStore;\n\treadonly live: string;\n\treadonly requester?: MutationRequester;\n}): void {\n\tif (args.store.byHashAndText(args.storeKey, computeFileHash(args.live), args.live)) return;\n\t// The last version this session recorded is what it believed it was overwriting, so the\n\t// divergence from live is the evidence. Without one there is nothing to diff, but the live\n\t// state still reports what was about to be clobbered sight unseen, which is the part\n\t// whoever reviews the rejection actually needs.\n\tconst head = args.store.head(args.storeKey);\n\tconst evidence = head ? computeConflictEvidence(head.text, args.live) : undefined;\n\tthrow new FileMutationConflict({\n\t\treason: head ? \"changed_since_observation\" : \"no_prior_observation\",\n\t\tpath: args.path,\n\t\tcanonicalKey: args.canonicalKey,\n\t\trequester: args.requester,\n\t\tliveState: computeLiveState(args.live),\n\t\t...(evidence ? { evidence } : {}),\n\t});\n}\n\n/**\n * Build a requester from parts already present on a session. Kept pure so it is testable\n * without constructing an `AgentSession`, and so this module never imports one.\n */\nexport function buildMutationRequester(parts: {\n\treadonly sessionId: string;\n\treadonly orchestration?: {\n\t\treadonly kind: string;\n\t\treadonly workflowRunId: string;\n\t\treadonly workflowStageId: string;\n\t\treadonly workflowStageName: string;\n\t};\n\treadonly intercom?: {\n\t\treadonly runId: string;\n\t\treadonly agent: string;\n\t\treadonly index?: number;\n\t\treadonly supervisor?: { readonly supervisorSessionId: string };\n\t};\n\treadonly attemptId?: string;\n\treadonly toolCallId?: string;\n}): MutationRequester {\n\tconst workflow = parts.orchestration?.kind === \"workflow-stage\" ? parts.orchestration : undefined;\n\tconst supervisorSessionId = parts.intercom?.supervisor?.supervisorSessionId;\n\tconst subagentIndex = parts.intercom?.index;\n\treturn {\n\t\tsessionId: parts.sessionId,\n\t\t...(supervisorSessionId ? { parentSessionId: supervisorSessionId } : {}),\n\t\t...(workflow ? { workflowRunId: workflow.workflowRunId } : {}),\n\t\t...(workflow ? { workflowStageId: workflow.workflowStageId } : {}),\n\t\t...(workflow ? { workflowStageName: workflow.workflowStageName } : {}),\n\t\t...(parts.intercom ? { subagentRunId: parts.intercom.runId } : {}),\n\t\t...(parts.intercom ? { subagentAgent: parts.intercom.agent } : {}),\n\t\t// Presence, not truthiness: index 0 is the first child, and `0 ? … : {}` drops it.\n\t\t...(subagentIndex !== undefined ? { subagentIndex } : {}),\n\t\t...(parts.attemptId ? { attemptId: parts.attemptId } : {}),\n\t\t...(parts.toolCallId ? { toolCallId: parts.toolCallId } : {}),\n\t};\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
2
  import { stat as fsStat } from "node:fs/promises";
3
- import path from "node:path";
3
+ import path, {} from "node:path";
4
4
  import { createInterface } from "node:readline";
5
5
  import { Text } from "@earendil-works/pi-tui";
6
6
  import { spawn } from "child_process";
@@ -1 +1 @@
1
- {"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAA2B,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC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AI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAC3E,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { statSync } from \"node:fs\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport path, { type PlatformPath } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { normalizePathLikeInput, splitPathLikeGlob } from \"./glob-path-utils.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput } from \"./render-utils.ts\";\nimport { type InternalResourceContext, resolveInternalSelector } from \"./resource-selectors.ts\";\nimport { loadNativeSearchBinding } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst toPosixPath = (value: string): string => value.split(path.sep).join(\"/\");\nconst findSchema = Type.Object(\n\t{\n\t\tpaths: Type.Array(Type.String({ description: \"File, directory, or glob path to find.\" }), {\n\t\t\tdescription: \"Paths or glob paths to find.\",\n\t\t\tminItems: 1,\n\t\t}),\n\t\thidden: Type.Optional(Type.Boolean({ description: \"Include hidden files. Defaults to true.\" })),\n\t\tgitignore: Type.Optional(Type.Boolean({ description: \"Respect gitignore. Defaults to true.\" })),\n\t\tlimit: Type.Optional(\n\t\t\tType.Number({ description: \"Maximum number of results, clamped to 1-200.\", minimum: 1, maximum: 200 }),\n\t\t),\n\t\ttimeout: Type.Optional(\n\t\t\tType.Number({ description: \"Timeout in seconds; default 5, clamped to 0.5..60.\", minimum: 0.5, maximum: 60 }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\nexport const findToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Find filesystem paths by glob.\",\n\tguidelines: Object.freeze([] as const),\n} as const);\nexport type FindToolInput = Static<typeof findSchema>;\nconst DEFAULT_LIMIT = 200;\nconst MAX_LIMIT = 200;\nconst DEFAULT_TIMEOUT_MS = 5000;\nconst MIN_TIMEOUT_MS = 500;\nconst MAX_TIMEOUT_MS = 60_000;\ninterface FindTarget {\n\tsearchPath: string;\n\tpattern: string;\n\texactPathInput: boolean;\n\tinputPath: string;\n}\nfunction normalizeLimit(limit: number | undefined): number {\n\treturn limit === undefined || !Number.isFinite(limit)\n\t\t? DEFAULT_LIMIT\n\t\t: Math.max(1, Math.min(MAX_LIMIT, Math.floor(limit)));\n}\nfunction normalizeTimeoutMs(timeout: number | undefined): number {\n\treturn timeout === undefined || !Number.isFinite(timeout)\n\t\t? DEFAULT_TIMEOUT_MS\n\t\t: Math.max(MIN_TIMEOUT_MS, Math.min(MAX_TIMEOUT_MS, Math.floor(timeout * 1000)));\n}\nfunction formatTimeoutSeconds(timeoutMs: number): string {\n\tconst seconds = timeoutMs / 1000;\n\treturn Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(1);\n}\nasync function resolveFindInternal(input: string, cwd: string, ctx?: InternalResourceContext): Promise<string> {\n\tconst parsed = splitPathLikeGlob(input);\n\tif (!/^[a-z]+:\\/\\//i.test(parsed.basePath)) return input;\n\tfor (const resolve of [\n\t\tctx?.internalRouter?.resolve,\n\t\tctx?.internalResourceRouter?.resolve,\n\t\tctx?.resolveInternalUrl,\n\t]) {\n\t\tconst resolved = await resolve?.(parsed.basePath);\n\t\tif (typeof resolved === \"string\") return parsed.glob ? `${resolved}/${parsed.glob}` : resolved;\n\t}\n\tconst fallback = resolveInternalSelector(parsed.basePath, cwd);\n\treturn fallback ? (parsed.glob ? `${fallback}/${parsed.glob}` : fallback) : input;\n}\nfunction isWindowsAbsolutePath(value: string): boolean {\n\treturn /^[A-Za-z]:[\\\\/]/.test(value) || value.startsWith(\"\\\\\\\\\");\n}\nfunction resolveFindBackendPath(input: string, cwd: string, customBackend: boolean): string {\n\tif (!customBackend) return resolveToCwd(input, cwd);\n\tif (input === \".\" || input === \"\") return cwd;\n\tif (input.startsWith(\"/\") || isWindowsAbsolutePath(input)) return input;\n\tif (cwd.includes(\"\\\\\") || isWindowsAbsolutePath(cwd)) return path.resolve(cwd, input);\n\treturn `${cwd.replace(/\\/+$/, \"\")}/${input}`;\n}\nasync function delimiterInExistingGlobRoot(\n\tvalue: string,\n\tcwd: string,\n\tops: FindOperations,\n\tcustomBackend: boolean,\n): Promise<boolean> {\n\tconst parsed = splitPathLikeGlob(value);\n\treturn (\n\t\t!!parsed.glob &&\n\t\t/[;,\\s]/.test(parsed.basePath) &&\n\t\t(await ops.exists(resolveFindBackendPath(parsed.basePath, cwd, customBackend)))\n\t);\n}\nasync function expandDelimitedFindPaths(\n\tpathsValue: string[] | undefined,\n\tcwd: string,\n\tops: FindOperations,\n\tctx?: InternalResourceContext,\n\tcustomBackend = false,\n): Promise<string[]> {\n\tif (!pathsValue?.length) throw new Error(\"find.paths must include at least one path or glob.\");\n\tconst expanded: string[] = [];\n\tfor (const input of pathsValue) {\n\t\tconst raw = normalizePathLikeInput(input);\n\t\tif (raw === \"\") throw new Error(\"find.paths entries must not be empty.\");\n\t\tconst resolvedRaw = await resolveFindInternal(raw, cwd, ctx);\n\t\tconst rawParsed = splitPathLikeGlob(resolvedRaw);\n\t\tif (\n\t\t\t(rawParsed.glob === undefined &&\n\t\t\t\t(await ops.exists(resolveFindBackendPath(rawParsed.basePath, cwd, customBackend)))) ||\n\t\t\t(await delimiterInExistingGlobRoot(resolvedRaw, cwd, ops, customBackend))\n\t\t) {\n\t\t\texpanded.push(resolvedRaw);\n\t\t\tcontinue;\n\t\t}\n\t\tconst parts = await Promise.all(\n\t\t\traw\n\t\t\t\t.split(/[;,\\s]+/)\n\t\t\t\t.map(normalizePathLikeInput)\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.map((part) => resolveFindInternal(part, cwd, ctx)),\n\t\t);\n\t\tconst delimiterCanSplit = /[;,]/.test(raw)\n\t\t\t? (\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tparts.map((part) =>\n\t\t\t\t\t\t\tops.exists(resolveFindBackendPath(splitPathLikeGlob(part).basePath, cwd, customBackend)),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t).some(Boolean)\n\t\t\t: (\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tparts.map((part) =>\n\t\t\t\t\t\t\tops.exists(resolveFindBackendPath(splitPathLikeGlob(part).basePath, cwd, customBackend)),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t).every(Boolean);\n\t\tif (parts.length > 1 && delimiterCanSplit) expanded.push(...parts);\n\t\telse expanded.push(resolvedRaw);\n\t}\n\treturn expanded;\n}\nfunction normalizeFindTargets(cwd: string, pathsValue: string[] | undefined, customBackend = false): FindTarget[] {\n\tif (!pathsValue || pathsValue.length === 0) throw new Error(\"find.paths must include at least one path or glob.\");\n\treturn pathsValue.map((searchPath) => {\n\t\tconst parsed = splitPathLikeGlob(searchPath);\n\t\tconst target = {\n\t\t\tsearchPath: resolveFindBackendPath(parsed.basePath, cwd, customBackend),\n\t\t\tpattern: parsed.glob ?? \"**/*\",\n\t\t\texactPathInput: parsed.glob === undefined,\n\t\t\tinputPath: searchPath,\n\t\t};\n\t\treturn target;\n\t});\n}\n/** Relativize a find result against the search root and normalize it to POSIX separators. */\nexport function relativizeFindResultPath(\n\tresultPath: string,\n\tsearchPath: string,\n\tpathModule: PlatformPath = path,\n): string {\n\tconst hadTrailingSeparator =\n\t\tresultPath.endsWith(pathModule.sep) || (pathModule.sep === \"\\\\\" && resultPath.endsWith(\"/\"));\n\tconst relativePath = pathModule.isAbsolute(resultPath) ? pathModule.relative(searchPath, resultPath) : resultPath;\n\tconst posixPath = relativePath.split(pathModule.sep).join(\"/\");\n\treturn hadTrailingSeparator && !posixPath.endsWith(\"/\") ? `${posixPath}/` : posixPath;\n}\nfunction formatExactFoundPath(foundPath: string, cwd: string): string {\n\treturn toPosixPath(path.relative(cwd, foundPath) || path.basename(foundPath));\n}\nfunction containsHiddenSegment(value: string): boolean {\n\treturn toPosixPath(value)\n\t\t.split(\"/\")\n\t\t.some((part) => part.startsWith(\".\") && part.length > 1);\n}\nfunction findTargetMentionsNodeModules(target: FindTarget): boolean {\n\treturn target.pattern.includes(\"node_modules\") || toPosixPath(target.searchPath).split(\"/\").includes(\"node_modules\");\n}\nfunction formatFoundPath(foundPath: string, searchPath: string, searchPaths: string[], cwd: string): string {\n\tconst relative = relativizeFindResultPath(foundPath, searchPath);\n\tif (searchPaths.length <= 1) return relative;\n\tconst rootLabel = toPosixPath(path.relative(cwd, searchPath) || path.basename(searchPath) || \".\");\n\treturn `${rootLabel}/${relative}`;\n}\ninterface FindTreeNode {\n\tfiles: Set<string>;\n\tdirs: Map<string, FindTreeNode>;\n}\nfunction createFindTreeNode(): FindTreeNode {\n\treturn { files: new Set(), dirs: new Map() };\n}\nfunction formatFindTree(relativized: string[]): string {\n\tconst root = createFindTreeNode();\n\tfor (const item of relativized) {\n\t\tconst isDir = item.endsWith(\"/\");\n\t\tconst parts = item.replace(/\\/+$/g, \"\").split(\"/\").filter(Boolean);\n\t\tif (parts.length === 0) continue;\n\t\tlet node = root;\n\t\tconst dirParts = isDir ? parts : parts.slice(0, -1);\n\t\tfor (const dir of dirParts) {\n\t\t\tlet child = node.dirs.get(dir);\n\t\t\tif (!child) {\n\t\t\t\tchild = createFindTreeNode();\n\t\t\t\tnode.dirs.set(dir, child);\n\t\t\t}\n\t\t\tnode = child;\n\t\t}\n\t\tif (!isDir) node.files.add(parts[parts.length - 1]!);\n\t}\n\tconst lines: string[] = [];\n\tconst collapse = (dir: string, node: FindTreeNode): { label: string; node: FindTreeNode } => {\n\t\tconst parts = [dir];\n\t\tlet current = node;\n\t\twhile (current.files.size === 0 && current.dirs.size === 1) {\n\t\t\tconst [[nextDir, nextNode]] = [...current.dirs.entries()];\n\t\t\tparts.push(nextDir!);\n\t\t\tcurrent = nextNode!;\n\t\t}\n\t\treturn { label: parts.join(\"/\"), node: current };\n\t};\n\tconst render = (node: FindTreeNode, depth: number): void => {\n\t\tfor (const file of [...node.files].sort()) lines.push(file);\n\t\tfor (const [dir, child] of [...node.dirs.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n\t\t\tconst folded = collapse(dir, child);\n\t\t\tlines.push(`${\"#\".repeat(depth + 1)} ${folded.label}/`);\n\t\t\trender(folded.node, depth + 1);\n\t\t}\n\t};\n\trender(root, 0);\n\treturn lines.join(\"\\n\");\n}\nexport interface FindToolDetails {\n\ttruncation?: TruncationResult;\n\tresultLimitReached?: number;\n\ttimedOut?: boolean;\n\ttruncated?: boolean;\n\tskippedMissingPaths?: string[];\n\tmissingPaths?: string[];\n\tscopePath?: string;\n\tfileCount?: number;\n\tfiles?: string[];\n\tmeta?: { limits?: { resultLimit?: number }; truncation?: TruncationResult };\n}\nfunction buildFindResult(\n\trelativized: string[],\n\teffectiveLimit: number,\n\ttimedOut: boolean,\n\ttimeoutMs: number,\n\tskippedMissingPaths: string[] = [],\n\tresultLimitReached = false,\n): {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: FindToolDetails | undefined;\n} {\n\tconst rawOutput = relativized.length > 0 ? formatFindTree(relativized) : \"No files found matching pattern\";\n\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\tlet resultOutput = truncation.content;\n\tconst details: FindToolDetails = {\n\t\tscopePath: \".\",\n\t\tfileCount: relativized.length,\n\t\tfiles: relativized,\n\t\tmeta: { limits: { resultLimit: effectiveLimit } },\n\t};\n\tconst notices: string[] = [];\n\tif (resultLimitReached) {\n\t\tnotices.push(`${effectiveLimit} results limit reached. Refine pattern or path to narrow results`);\n\t\tdetails.resultLimitReached = effectiveLimit;\n\t}\n\tif (timedOut) {\n\t\tnotices.push(\n\t\t\t`find timed out after ${formatTimeoutSeconds(timeoutMs)}s; returning ${relativized.length} partial matches — increase timeout or narrow pattern`,\n\t\t);\n\t\tdetails.timedOut = true;\n\t\tdetails.truncated = true;\n\t}\n\tif (skippedMissingPaths.length > 0) {\n\t\tnotices.push(`Skipped missing paths: ${skippedMissingPaths.join(\", \")}`);\n\t\tdetails.skippedMissingPaths = skippedMissingPaths;\n\t\tdetails.missingPaths = skippedMissingPaths;\n\t}\n\tif (truncation.truncated) {\n\t\tnotices.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit reached`);\n\t\tdetails.truncation = truncation;\n\t\tdetails.meta = { ...(details.meta ?? {}), truncation };\n\t\tdetails.truncated = true;\n\t}\n\tif (notices.length > 0) {\n\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\n\t}\n\treturn { content: [{ type: \"text\", text: resultOutput }], details };\n}\n/** Pluggable operations for remote/container find backends. */\nexport interface FindOperations {\n\tstat?: (\n\t\tpath: string,\n\t) =>\n\t\t| Promise<{ isFile: boolean; isDirectory: boolean } | undefined>\n\t\t| { isFile: boolean; isDirectory: boolean }\n\t\t| undefined;\n\texists: (path: string) => Promise<boolean> | boolean;\n\tglob: (\n\t\tpattern: string,\n\t\tcwd: string,\n\t\toptions: { ignore: string[]; limit: number; hidden: boolean },\n\t) => Promise<string[]> | string[];\n}\nconst defaultFindOperations: FindOperations = {\n\texists: pathExists,\n\tglob: () => [],\n};\nexport interface FindToolOptions {\n\t/** Custom operations for find. Default: local filesystem plus fd */\n\toperations?: FindOperations;\n}\nfunction stripTrailingForwardSlashes(value: string): string {\n\tlet end = value.length;\n\twhile (end > 0 && value[end - 1] === \"/\") end--;\n\treturn value.slice(0, end);\n}\n\nfunction formatFindCall(\n\targs: { paths?: string[]; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string {\n\tconst paths = Array.isArray(args?.paths)\n\t\t? args.paths\n\t\t\t\t.map((item) => (splitPathLikeGlob(item).glob ? item : `${stripTrailingForwardSlashes(item)}/**/*`))\n\t\t\t\t.join(\", \")\n\t\t: \"<paths>\";\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"find\"))} ${theme.fg(\"accent\", paths)}`;\n\tif (args?.limit !== undefined) text += theme.fg(\"toolOutput\", ` (limit ${args.limit})`);\n\treturn text;\n}\nfunction formatFindResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: FindToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 20;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t\t}\n\t}\n\tconst resultLimit = result.details?.resultLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst timedOut = result.details?.timedOut;\n\tif (resultLimit || truncation?.truncated || timedOut) {\n\t\tconst warnings: string[] = [];\n\t\tif (resultLimit) warnings.push(`${resultLimit} results limit`);\n\t\tif (timedOut) warnings.push(\"timeout\");\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\nexport function createFindToolDefinition(\n\tcwd: string,\n\toptions?: FindToolOptions,\n): ToolDefinition<typeof findSchema, FindToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"find\",\n\t\tlabel: \"find\",\n\t\tdescription: \"Find filesystem paths by glob; use search when you need content matches instead of path matches.\",\n\t\tpromptSnippet: findToolSystemPromptContribution.snippet,\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: findSchema,\n\t\tasync execute(_toolCallId, params: FindToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tlet stopChild: (() => void) | undefined;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tstopChild = undefined;\n\t\t\t\t\tfn();\n\t\t\t\t};\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tstopChild?.();\n\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t};\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tconst { limit, hidden, gitignore, timeout } = params;\n\t\t\t\tconst paths = params.paths;\n\t\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ops = customOps ?? defaultFindOperations;\n\t\t\t\t\t\tconst targets = normalizeFindTargets(\n\t\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\t\tawait expandDelimitedFindPaths(paths, executionCwd, ops, resourceCtx, !!customOps),\n\t\t\t\t\t\t\t!!customOps,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst searchPaths = targets.map((target) => target.searchPath);\n\t\t\t\t\t\tconst effectiveLimit = normalizeLimit(limit);\n\t\t\t\t\t\tconst timeoutMs = normalizeTimeoutMs(timeout);\n\t\t\t\t\t\tconst emitUpdate = (files: string[]) =>\n\t\t\t\t\t\t\t_onUpdate?.({\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: files.join(\"\\n\") || \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\tdetails: { scopePath: \".\", files, fileCount: files.length, truncated: false },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tconst exactFileResults: string[] = [];\n\t\t\t\t\t\tconst searchableTargets: FindTarget[] = [];\n\t\t\t\t\t\tconst skippedMissingPaths: string[] = [];\n\t\t\t\t\t\tfor (const target of targets) {\n\t\t\t\t\t\t\tconst stat = customOps\n\t\t\t\t\t\t\t\t? await customOps.stat?.(target.searchPath)\n\t\t\t\t\t\t\t\t: await fsStat(target.searchPath).catch(() => undefined);\n\t\t\t\t\t\t\tif (!stat && targets.length > 1 && !customOps) {\n\t\t\t\t\t\t\t\tskippedMissingPaths.push(target.inputPath);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!stat && targets.length === 1 && !customOps) {\n\t\t\t\t\t\t\t\tthrow new Error(`ENOENT: Path not found: ${target.searchPath}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (target.exactPathInput) {\n\t\t\t\t\t\t\t\tconst isFile = typeof stat?.isFile === \"function\" ? stat.isFile() : stat?.isFile;\n\t\t\t\t\t\t\t\tif (isFile) {\n\t\t\t\t\t\t\t\t\texactFileResults.push(formatExactFoundPath(target.searchPath, executionCwd));\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsearchableTargets.push(target);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (exactFileResults.length > effectiveLimit || searchableTargets.length === 0) {\n\t\t\t\t\t\t\tconst resultLimitReached = exactFileResults.length > effectiveLimit;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\texactFileResults.slice(0, effectiveLimit),\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\temitUpdate(exactFileResults.slice(0, effectiveLimit));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (customOps?.glob) {\n\t\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\t\tconst relativized: string[] = [...exactFileResults];\n\t\t\t\t\t\t\tlet customLimitReached = false;\n\t\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\t\tif (!(await ops.exists(target.searchPath))) {\n\t\t\t\t\t\t\t\t\tif (targets.length > 1) {\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths.push(target.inputPath);\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${target.searchPath}`)));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst remaining = effectiveLimit - relativized.length;\n\t\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\t\tif (remaining <= 0) {\n\t\t\t\t\t\t\t\t\tconst ignore = findTargetMentionsNodeModules(target)\n\t\t\t\t\t\t\t\t\t\t? [\"**/.git/**\"]\n\t\t\t\t\t\t\t\t\t\t: [\"**/node_modules/**\", \"**/.git/**\"];\n\t\t\t\t\t\t\t\t\tconst probe = await Promise.resolve(\n\t\t\t\t\t\t\t\t\t\tops.glob(target.pattern, target.searchPath, {\n\t\t\t\t\t\t\t\t\t\t\tignore,\n\t\t\t\t\t\t\t\t\t\t\tlimit: 1,\n\t\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tif (probe.some((p) => hidden !== false || !containsHiddenSegment(p)))\n\t\t\t\t\t\t\t\t\t\tcustomLimitReached = true;\n\t\t\t\t\t\t\t\t\tif (customLimitReached) break;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst timeoutResult = Symbol(\"find-timeout\");\n\t\t\t\t\t\t\t\tlet raceTimer: ReturnType<typeof setTimeout> | undefined;\n\t\t\t\t\t\t\t\tconst ignore = findTargetMentionsNodeModules(target)\n\t\t\t\t\t\t\t\t\t? [\"**/.git/**\"]\n\t\t\t\t\t\t\t\t\t: [\"**/node_modules/**\", \"**/.git/**\"];\n\t\t\t\t\t\t\t\tconst results = await Promise.race<string[] | symbol>([\n\t\t\t\t\t\t\t\t\tPromise.resolve(\n\t\t\t\t\t\t\t\t\t\tops.glob(target.pattern, target.searchPath, {\n\t\t\t\t\t\t\t\t\t\t\tignore,\n\t\t\t\t\t\t\t\t\t\t\tlimit: remaining + 1,\n\t\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tnew Promise<typeof timeoutResult>((resolveTimeout) => {\n\t\t\t\t\t\t\t\t\t\traceTimer = setTimeout(() => resolveTimeout(timeoutResult), remainingMs);\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tif (raceTimer) clearTimeout(raceTimer);\n\t\t\t\t\t\t\t\tif (!Array.isArray(results)) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (target.exactPathInput && results.length === 0) {\n\t\t\t\t\t\t\t\t\tconst stat = await customOps.stat?.(target.searchPath);\n\t\t\t\t\t\t\t\t\tif (!stat?.isDirectory)\n\t\t\t\t\t\t\t\t\t\trelativized.push(formatExactFoundPath(target.searchPath, executionCwd));\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst visible = results.filter((p) => hidden !== false || !containsHiddenSegment(p));\n\t\t\t\t\t\t\t\tif (visible.length > remaining) customLimitReached = true;\n\t\t\t\t\t\t\t\trelativized.push(\n\t\t\t\t\t\t\t\t\t...visible\n\t\t\t\t\t\t\t\t\t\t.slice(0, remaining)\n\t\t\t\t\t\t\t\t\t\t.map((p) => formatFoundPath(p, target.searchPath, searchPaths, executionCwd)),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\temitUpdate(relativized);\n\t\t\t\t\t\t\t\tif (customLimitReached) break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\trelativized,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tcustomLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst nativeBinding = loadNativeSearchBinding();\n\t\t\t\t\t\tif (nativeBinding) {\n\t\t\t\t\t\t\tconst matches: { path: string; mtime: number }[] = exactFileResults.map((path) => ({\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\tmtime: Number.POSITIVE_INFINITY,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst result = await nativeBinding.glob({\n\t\t\t\t\t\t\t\t\t\tpattern: target.pattern,\n\t\t\t\t\t\t\t\t\t\tpath: target.searchPath,\n\t\t\t\t\t\t\t\t\t\trecursive: false,\n\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\tgitignore: gitignore !== false,\n\t\t\t\t\t\t\t\t\t\tincludeNodeModules: findTargetMentionsNodeModules(target),\n\t\t\t\t\t\t\t\t\t\tmaxResults: effectiveLimit + 1,\n\t\t\t\t\t\t\t\t\t\tcache: false,\n\t\t\t\t\t\t\t\t\t\tsortByMtime: true,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs: remainingMs,\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tmatches.push(\n\t\t\t\t\t\t\t\t\t\t...result.matches.map((match) => {\n\t\t\t\t\t\t\t\t\t\t\tconst fileType = match.fileType ?? (match as { file_type?: number }).file_type;\n\t\t\t\t\t\t\t\t\t\t\tconst isDir =\n\t\t\t\t\t\t\t\t\t\t\t\t(fileType === 2 ||\n\t\t\t\t\t\t\t\t\t\t\t\t\tfileType === \"Dir\" ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t(fileType === undefined &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatSync(path.resolve(target.searchPath, match.path), {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthrowIfNoEntry: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t})?.isDirectory())) &&\n\t\t\t\t\t\t\t\t\t\t\t\t!match.path.endsWith(\"/\");\n\t\t\t\t\t\t\t\t\t\t\tconst matchPath = isDir ? `${match.path}/` : match.path;\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: formatFoundPath(matchPath, target.searchPath, searchPaths, executionCwd),\n\t\t\t\t\t\t\t\t\t\t\t\tmtime: match.mtime ?? 0,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\temitUpdate(matches.map((match) => match.path));\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (String(error).toLowerCase().includes(\"timed out\")) {\n\t\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst uniqueMatches = [\n\t\t\t\t\t\t\t\t...matches\n\t\t\t\t\t\t\t\t\t.reduce((map, match) => {\n\t\t\t\t\t\t\t\t\t\tconst previous = map.get(match.path);\n\t\t\t\t\t\t\t\t\t\tif (!previous || match.mtime > previous.mtime) map.set(match.path, match);\n\t\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t\t}, new Map<string, { path: string; mtime: number }>())\n\t\t\t\t\t\t\t\t\t.values(),\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tuniqueMatches.sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));\n\t\t\t\t\t\t\tconst resultLimitReached = uniqueMatches.length > effectiveLimit;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\tuniqueMatches.slice(0, effectiveLimit).map((match) => match.path),\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst fdPath = await ensureTool(\"fd\");\n\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!fdPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"fd is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\tconst relativized: string[] = [...exactFileResults];\n\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\tconst runFdForTarget = async (target: FindTarget, remaining: number): Promise<boolean> => {\n\t\t\t\t\t\t\tconst args: string[] = [\n\t\t\t\t\t\t\t\t\"--glob\",\n\t\t\t\t\t\t\t\t\"--color=never\",\n\t\t\t\t\t\t\t\t\"--no-require-git\",\n\t\t\t\t\t\t\t\t\"--max-results\",\n\t\t\t\t\t\t\t\tString(remaining + 1),\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tif (hidden !== false) args.push(\"--hidden\");\n\t\t\t\t\t\t\tif (gitignore === false) args.push(\"--no-ignore\");\n\t\t\t\t\t\t\tif (!findTargetMentionsNodeModules(target)) args.push(\"--exclude\", \"node_modules\");\n\t\t\t\t\t\t\tlet fdPattern = target.pattern;\n\t\t\t\t\t\t\tif (target.pattern.includes(\"/\")) {\n\t\t\t\t\t\t\t\targs.push(\"--full-path\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!target.pattern.startsWith(\"/\") &&\n\t\t\t\t\t\t\t\t\t!target.pattern.startsWith(\"**/\") &&\n\t\t\t\t\t\t\t\t\ttarget.pattern !== \"**\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tfdPattern = `**/${target.pattern}`;\n\t\t\t\t\t\t\t\t// fd matches full paths with native separators on Windows.\n\t\t\t\t\t\t\t\tif (process.platform === \"win32\") fdPattern = fdPattern.replaceAll(\"/\", String.raw`[/\\\\]`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\targs.push(\"--\", fdPattern, target.searchPath);\n\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn await new Promise<boolean>((resolveTarget, rejectTarget) => {\n\t\t\t\t\t\t\t\tconst child = spawn(fdPath, args, {\n\t\t\t\t\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\t\t\tconst lines: string[] = [];\n\t\t\t\t\t\t\t\tstopChild = () => {\n\t\t\t\t\t\t\t\t\tif (!child.killed) child.kill();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst targetTimer = setTimeout(() => {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tstopChild?.();\n\t\t\t\t\t\t\t\t}, remainingMs);\n\t\t\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\t\t\tclearTimeout(targetTimer);\n\t\t\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\trl.on(\"line\", (line) => lines.push(line));\n\t\t\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\t\t\trejectTarget(new Error(`Failed to run fd: ${error.message}`));\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tchild.on(\"close\", (code) => {\n\t\t\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\t\trejectTarget(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (!timedOut && code !== 0 && lines.length === 0) {\n\t\t\t\t\t\t\t\t\t\trejectTarget(new Error(stderr.trim() || `fd exited with code ${code}`));\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfor (const rawLine of lines.slice(0, remaining)) {\n\t\t\t\t\t\t\t\t\t\tconst line = rawLine.replace(/\\r$/, \"\").trim();\n\t\t\t\t\t\t\t\t\t\tif (line) {\n\t\t\t\t\t\t\t\t\t\t\tconst found =\n\t\t\t\t\t\t\t\t\t\t\t\tstatSync(path.resolve(target.searchPath, line), {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrowIfNoEntry: false,\n\t\t\t\t\t\t\t\t\t\t\t\t})?.isDirectory() && !line.endsWith(\"/\")\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${line}/`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: line;\n\t\t\t\t\t\t\t\t\t\t\trelativized.push(formatFoundPath(found, target.searchPath, searchPaths, executionCwd));\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\temitUpdate(relativized);\n\t\t\t\t\t\t\t\t\tresolveTarget(lines.length > Math.max(0, remaining));\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\t\t\t\t\t\tlet resultLimitReached = false;\n\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\tconst remaining = effectiveLimit - relativized.length;\n\t\t\t\t\t\t\tif (timedOut) break;\n\t\t\t\t\t\t\tif (remaining <= 0) {\n\t\t\t\t\t\t\t\tif (await runFdForTarget(target, 0)) {\n\t\t\t\t\t\t\t\t\tresultLimitReached = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst targetLimitReached = await runFdForTarget(target, remaining);\n\t\t\t\t\t\t\tif (targetLimitReached) {\n\t\t\t\t\t\t\t\tresultLimitReached = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\trelativized.slice(0, effectiveLimit),\n\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst error = e instanceof Error ? e : new Error(String(e));\n\t\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatFindCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatFindResult(result, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\nexport function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema> {\n\treturn wrapToolDefinition(createFindToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAAI,EAAE,EAAqB,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAgC,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,k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AC","sourcesContent":["import { statSync } from \"node:fs\";\nimport { stat as fsStat } from \"node:fs/promises\";\nimport path, { type PlatformPath } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { normalizePathLikeInput, splitPathLikeGlob } from \"./glob-path-utils.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput } from \"./render-utils.ts\";\nimport { type InternalResourceContext, resolveInternalSelector } from \"./resource-selectors.ts\";\nimport { loadNativeSearchBinding } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst toPosixPath = (value: string): string => value.split(path.sep).join(\"/\");\nconst findSchema = Type.Object(\n\t{\n\t\tpaths: Type.Array(Type.String({ description: \"File, directory, or glob path to find.\" }), {\n\t\t\tdescription: \"Paths or glob paths to find.\",\n\t\t\tminItems: 1,\n\t\t}),\n\t\thidden: Type.Optional(Type.Boolean({ description: \"Include hidden files. Defaults to true.\" })),\n\t\tgitignore: Type.Optional(Type.Boolean({ description: \"Respect gitignore. Defaults to true.\" })),\n\t\tlimit: Type.Optional(\n\t\t\tType.Number({ description: \"Maximum number of results, clamped to 1-200.\", minimum: 1, maximum: 200 }),\n\t\t),\n\t\ttimeout: Type.Optional(\n\t\t\tType.Number({ description: \"Timeout in seconds; default 5, clamped to 0.5..60.\", minimum: 0.5, maximum: 60 }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\nexport const findToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Find filesystem paths by glob.\",\n\tguidelines: Object.freeze([] as const),\n} as const);\nexport type FindToolInput = Static<typeof findSchema>;\nconst DEFAULT_LIMIT = 200;\nconst MAX_LIMIT = 200;\nconst DEFAULT_TIMEOUT_MS = 5000;\nconst MIN_TIMEOUT_MS = 500;\nconst MAX_TIMEOUT_MS = 60_000;\ninterface FindTarget {\n\tsearchPath: string;\n\tpattern: string;\n\texactPathInput: boolean;\n\tinputPath: string;\n}\nfunction normalizeLimit(limit: number | undefined): number {\n\treturn limit === undefined || !Number.isFinite(limit)\n\t\t? DEFAULT_LIMIT\n\t\t: Math.max(1, Math.min(MAX_LIMIT, Math.floor(limit)));\n}\nfunction normalizeTimeoutMs(timeout: number | undefined): number {\n\treturn timeout === undefined || !Number.isFinite(timeout)\n\t\t? DEFAULT_TIMEOUT_MS\n\t\t: Math.max(MIN_TIMEOUT_MS, Math.min(MAX_TIMEOUT_MS, Math.floor(timeout * 1000)));\n}\nfunction formatTimeoutSeconds(timeoutMs: number): string {\n\tconst seconds = timeoutMs / 1000;\n\treturn Number.isInteger(seconds) ? String(seconds) : seconds.toFixed(1);\n}\nasync function resolveFindInternal(input: string, cwd: string, ctx?: InternalResourceContext): Promise<string> {\n\tconst parsed = splitPathLikeGlob(input);\n\tif (!/^[a-z]+:\\/\\//i.test(parsed.basePath)) return input;\n\tfor (const resolve of [\n\t\tctx?.internalRouter?.resolve,\n\t\tctx?.internalResourceRouter?.resolve,\n\t\tctx?.resolveInternalUrl,\n\t]) {\n\t\tconst resolved = await resolve?.(parsed.basePath);\n\t\tif (typeof resolved === \"string\") return parsed.glob ? `${resolved}/${parsed.glob}` : resolved;\n\t}\n\tconst fallback = resolveInternalSelector(parsed.basePath, cwd);\n\treturn fallback ? (parsed.glob ? `${fallback}/${parsed.glob}` : fallback) : input;\n}\nfunction isWindowsAbsolutePath(value: string): boolean {\n\treturn /^[A-Za-z]:[\\\\/]/.test(value) || value.startsWith(\"\\\\\\\\\");\n}\nfunction resolveFindBackendPath(input: string, cwd: string, customBackend: boolean): string {\n\tif (!customBackend) return resolveToCwd(input, cwd);\n\tif (input === \".\" || input === \"\") return cwd;\n\tif (input.startsWith(\"/\") || isWindowsAbsolutePath(input)) return input;\n\tif (cwd.includes(\"\\\\\") || isWindowsAbsolutePath(cwd)) return path.resolve(cwd, input);\n\treturn `${cwd.replace(/\\/+$/, \"\")}/${input}`;\n}\nasync function delimiterInExistingGlobRoot(\n\tvalue: string,\n\tcwd: string,\n\tops: FindOperations,\n\tcustomBackend: boolean,\n): Promise<boolean> {\n\tconst parsed = splitPathLikeGlob(value);\n\treturn (\n\t\t!!parsed.glob &&\n\t\t/[;,\\s]/.test(parsed.basePath) &&\n\t\t(await ops.exists(resolveFindBackendPath(parsed.basePath, cwd, customBackend)))\n\t);\n}\nasync function expandDelimitedFindPaths(\n\tpathsValue: string[] | undefined,\n\tcwd: string,\n\tops: FindOperations,\n\tctx?: InternalResourceContext,\n\tcustomBackend = false,\n): Promise<string[]> {\n\tif (!pathsValue?.length) throw new Error(\"find.paths must include at least one path or glob.\");\n\tconst expanded: string[] = [];\n\tfor (const input of pathsValue) {\n\t\tconst raw = normalizePathLikeInput(input);\n\t\tif (raw === \"\") throw new Error(\"find.paths entries must not be empty.\");\n\t\tconst resolvedRaw = await resolveFindInternal(raw, cwd, ctx);\n\t\tconst rawParsed = splitPathLikeGlob(resolvedRaw);\n\t\tif (\n\t\t\t(rawParsed.glob === undefined &&\n\t\t\t\t(await ops.exists(resolveFindBackendPath(rawParsed.basePath, cwd, customBackend)))) ||\n\t\t\t(await delimiterInExistingGlobRoot(resolvedRaw, cwd, ops, customBackend))\n\t\t) {\n\t\t\texpanded.push(resolvedRaw);\n\t\t\tcontinue;\n\t\t}\n\t\tconst parts = await Promise.all(\n\t\t\traw\n\t\t\t\t.split(/[;,\\s]+/)\n\t\t\t\t.map(normalizePathLikeInput)\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.map((part) => resolveFindInternal(part, cwd, ctx)),\n\t\t);\n\t\tconst delimiterCanSplit = /[;,]/.test(raw)\n\t\t\t? (\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tparts.map((part) =>\n\t\t\t\t\t\t\tops.exists(resolveFindBackendPath(splitPathLikeGlob(part).basePath, cwd, customBackend)),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t).some(Boolean)\n\t\t\t: (\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tparts.map((part) =>\n\t\t\t\t\t\t\tops.exists(resolveFindBackendPath(splitPathLikeGlob(part).basePath, cwd, customBackend)),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t).every(Boolean);\n\t\tif (parts.length > 1 && delimiterCanSplit) expanded.push(...parts);\n\t\telse expanded.push(resolvedRaw);\n\t}\n\treturn expanded;\n}\nfunction normalizeFindTargets(cwd: string, pathsValue: string[] | undefined, customBackend = false): FindTarget[] {\n\tif (!pathsValue || pathsValue.length === 0) throw new Error(\"find.paths must include at least one path or glob.\");\n\treturn pathsValue.map((searchPath) => {\n\t\tconst parsed = splitPathLikeGlob(searchPath);\n\t\tconst target = {\n\t\t\tsearchPath: resolveFindBackendPath(parsed.basePath, cwd, customBackend),\n\t\t\tpattern: parsed.glob ?? \"**/*\",\n\t\t\texactPathInput: parsed.glob === undefined,\n\t\t\tinputPath: searchPath,\n\t\t};\n\t\treturn target;\n\t});\n}\n/** Relativize a find result against the search root and normalize it to POSIX separators. */\nexport function relativizeFindResultPath(\n\tresultPath: string,\n\tsearchPath: string,\n\tpathModule: PlatformPath = path,\n): string {\n\tconst hadTrailingSeparator =\n\t\tresultPath.endsWith(pathModule.sep) || (pathModule.sep === \"\\\\\" && resultPath.endsWith(\"/\"));\n\tconst relativePath = pathModule.isAbsolute(resultPath) ? pathModule.relative(searchPath, resultPath) : resultPath;\n\tconst posixPath = relativePath.split(pathModule.sep).join(\"/\");\n\treturn hadTrailingSeparator && !posixPath.endsWith(\"/\") ? `${posixPath}/` : posixPath;\n}\nfunction formatExactFoundPath(foundPath: string, cwd: string): string {\n\treturn toPosixPath(path.relative(cwd, foundPath) || path.basename(foundPath));\n}\nfunction containsHiddenSegment(value: string): boolean {\n\treturn toPosixPath(value)\n\t\t.split(\"/\")\n\t\t.some((part) => part.startsWith(\".\") && part.length > 1);\n}\nfunction findTargetMentionsNodeModules(target: FindTarget): boolean {\n\treturn target.pattern.includes(\"node_modules\") || toPosixPath(target.searchPath).split(\"/\").includes(\"node_modules\");\n}\nfunction formatFoundPath(foundPath: string, searchPath: string, searchPaths: string[], cwd: string): string {\n\tconst relative = relativizeFindResultPath(foundPath, searchPath);\n\tif (searchPaths.length <= 1) return relative;\n\tconst rootLabel = toPosixPath(path.relative(cwd, searchPath) || path.basename(searchPath) || \".\");\n\treturn `${rootLabel}/${relative}`;\n}\ninterface FindTreeNode {\n\tfiles: Set<string>;\n\tdirs: Map<string, FindTreeNode>;\n}\nfunction createFindTreeNode(): FindTreeNode {\n\treturn { files: new Set(), dirs: new Map() };\n}\nfunction formatFindTree(relativized: string[]): string {\n\tconst root = createFindTreeNode();\n\tfor (const item of relativized) {\n\t\tconst isDir = item.endsWith(\"/\");\n\t\tconst parts = item.replace(/\\/+$/g, \"\").split(\"/\").filter(Boolean);\n\t\tif (parts.length === 0) continue;\n\t\tlet node = root;\n\t\tconst dirParts = isDir ? parts : parts.slice(0, -1);\n\t\tfor (const dir of dirParts) {\n\t\t\tlet child = node.dirs.get(dir);\n\t\t\tif (!child) {\n\t\t\t\tchild = createFindTreeNode();\n\t\t\t\tnode.dirs.set(dir, child);\n\t\t\t}\n\t\t\tnode = child;\n\t\t}\n\t\tif (!isDir) node.files.add(parts[parts.length - 1]!);\n\t}\n\tconst lines: string[] = [];\n\tconst collapse = (dir: string, node: FindTreeNode): { label: string; node: FindTreeNode } => {\n\t\tconst parts = [dir];\n\t\tlet current = node;\n\t\twhile (current.files.size === 0 && current.dirs.size === 1) {\n\t\t\tconst [[nextDir, nextNode]] = [...current.dirs.entries()];\n\t\t\tparts.push(nextDir!);\n\t\t\tcurrent = nextNode!;\n\t\t}\n\t\treturn { label: parts.join(\"/\"), node: current };\n\t};\n\tconst render = (node: FindTreeNode, depth: number): void => {\n\t\tfor (const file of [...node.files].sort()) lines.push(file);\n\t\tfor (const [dir, child] of [...node.dirs.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n\t\t\tconst folded = collapse(dir, child);\n\t\t\tlines.push(`${\"#\".repeat(depth + 1)} ${folded.label}/`);\n\t\t\trender(folded.node, depth + 1);\n\t\t}\n\t};\n\trender(root, 0);\n\treturn lines.join(\"\\n\");\n}\nexport interface FindToolDetails {\n\ttruncation?: TruncationResult;\n\tresultLimitReached?: number;\n\ttimedOut?: boolean;\n\ttruncated?: boolean;\n\tskippedMissingPaths?: string[];\n\tmissingPaths?: string[];\n\tscopePath?: string;\n\tfileCount?: number;\n\tfiles?: string[];\n\tmeta?: { limits?: { resultLimit?: number }; truncation?: TruncationResult };\n}\nfunction buildFindResult(\n\trelativized: string[],\n\teffectiveLimit: number,\n\ttimedOut: boolean,\n\ttimeoutMs: number,\n\tskippedMissingPaths: string[] = [],\n\tresultLimitReached = false,\n): {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: FindToolDetails | undefined;\n} {\n\tconst rawOutput = relativized.length > 0 ? formatFindTree(relativized) : \"No files found matching pattern\";\n\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\tlet resultOutput = truncation.content;\n\tconst details: FindToolDetails = {\n\t\tscopePath: \".\",\n\t\tfileCount: relativized.length,\n\t\tfiles: relativized,\n\t\tmeta: { limits: { resultLimit: effectiveLimit } },\n\t};\n\tconst notices: string[] = [];\n\tif (resultLimitReached) {\n\t\tnotices.push(`${effectiveLimit} results limit reached. Refine pattern or path to narrow results`);\n\t\tdetails.resultLimitReached = effectiveLimit;\n\t}\n\tif (timedOut) {\n\t\tnotices.push(\n\t\t\t`find timed out after ${formatTimeoutSeconds(timeoutMs)}s; returning ${relativized.length} partial matches — increase timeout or narrow pattern`,\n\t\t);\n\t\tdetails.timedOut = true;\n\t\tdetails.truncated = true;\n\t}\n\tif (skippedMissingPaths.length > 0) {\n\t\tnotices.push(`Skipped missing paths: ${skippedMissingPaths.join(\", \")}`);\n\t\tdetails.skippedMissingPaths = skippedMissingPaths;\n\t\tdetails.missingPaths = skippedMissingPaths;\n\t}\n\tif (truncation.truncated) {\n\t\tnotices.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit reached`);\n\t\tdetails.truncation = truncation;\n\t\tdetails.meta = { ...(details.meta ?? {}), truncation };\n\t\tdetails.truncated = true;\n\t}\n\tif (notices.length > 0) {\n\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\n\t}\n\treturn { content: [{ type: \"text\", text: resultOutput }], details };\n}\n/** Pluggable operations for remote/container find backends. */\nexport interface FindOperations {\n\tstat?: (\n\t\tpath: string,\n\t) =>\n\t\t| Promise<{ isFile: boolean; isDirectory: boolean } | undefined>\n\t\t| { isFile: boolean; isDirectory: boolean }\n\t\t| undefined;\n\texists: (path: string) => Promise<boolean> | boolean;\n\tglob: (\n\t\tpattern: string,\n\t\tcwd: string,\n\t\toptions: { ignore: string[]; limit: number; hidden: boolean },\n\t) => Promise<string[]> | string[];\n}\nconst defaultFindOperations: FindOperations = {\n\texists: pathExists,\n\tglob: () => [],\n};\nexport interface FindToolOptions {\n\t/** Custom operations for find. Default: local filesystem plus fd */\n\toperations?: FindOperations;\n}\nfunction stripTrailingForwardSlashes(value: string): string {\n\tlet end = value.length;\n\twhile (end > 0 && value[end - 1] === \"/\") end--;\n\treturn value.slice(0, end);\n}\n\nfunction formatFindCall(\n\targs: { paths?: string[]; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string {\n\tconst paths = Array.isArray(args?.paths)\n\t\t? args.paths\n\t\t\t\t.map((item) => (splitPathLikeGlob(item).glob ? item : `${stripTrailingForwardSlashes(item)}/**/*`))\n\t\t\t\t.join(\", \")\n\t\t: \"<paths>\";\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"find\"))} ${theme.fg(\"accent\", paths)}`;\n\tif (args?.limit !== undefined) text += theme.fg(\"toolOutput\", ` (limit ${args.limit})`);\n\treturn text;\n}\nfunction formatFindResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: FindToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 20;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t\t}\n\t}\n\tconst resultLimit = result.details?.resultLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst timedOut = result.details?.timedOut;\n\tif (resultLimit || truncation?.truncated || timedOut) {\n\t\tconst warnings: string[] = [];\n\t\tif (resultLimit) warnings.push(`${resultLimit} results limit`);\n\t\tif (timedOut) warnings.push(\"timeout\");\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\nexport function createFindToolDefinition(\n\tcwd: string,\n\toptions?: FindToolOptions,\n): ToolDefinition<typeof findSchema, FindToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"find\",\n\t\tlabel: \"find\",\n\t\tdescription: \"Find filesystem paths by glob; use search when you need content matches instead of path matches.\",\n\t\tpromptSnippet: findToolSystemPromptContribution.snippet,\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: findSchema,\n\t\tasync execute(_toolCallId, params: FindToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tlet stopChild: (() => void) | undefined;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\tstopChild = undefined;\n\t\t\t\t\tfn();\n\t\t\t\t};\n\t\t\t\tconst onAbort = () => {\n\t\t\t\t\tstopChild?.();\n\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t};\n\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\tconst { limit, hidden, gitignore, timeout } = params;\n\t\t\t\tconst paths = params.paths;\n\t\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst ops = customOps ?? defaultFindOperations;\n\t\t\t\t\t\tconst targets = normalizeFindTargets(\n\t\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\t\tawait expandDelimitedFindPaths(paths, executionCwd, ops, resourceCtx, !!customOps),\n\t\t\t\t\t\t\t!!customOps,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst searchPaths = targets.map((target) => target.searchPath);\n\t\t\t\t\t\tconst effectiveLimit = normalizeLimit(limit);\n\t\t\t\t\t\tconst timeoutMs = normalizeTimeoutMs(timeout);\n\t\t\t\t\t\tconst emitUpdate = (files: string[]) =>\n\t\t\t\t\t\t\t_onUpdate?.({\n\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: files.join(\"\\n\") || \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\tdetails: { scopePath: \".\", files, fileCount: files.length, truncated: false },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tconst exactFileResults: string[] = [];\n\t\t\t\t\t\tconst searchableTargets: FindTarget[] = [];\n\t\t\t\t\t\tconst skippedMissingPaths: string[] = [];\n\t\t\t\t\t\tfor (const target of targets) {\n\t\t\t\t\t\t\tconst stat = customOps\n\t\t\t\t\t\t\t\t? await customOps.stat?.(target.searchPath)\n\t\t\t\t\t\t\t\t: await fsStat(target.searchPath).catch(() => undefined);\n\t\t\t\t\t\t\tif (!stat && targets.length > 1 && !customOps) {\n\t\t\t\t\t\t\t\tskippedMissingPaths.push(target.inputPath);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!stat && targets.length === 1 && !customOps) {\n\t\t\t\t\t\t\t\tthrow new Error(`ENOENT: Path not found: ${target.searchPath}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (target.exactPathInput) {\n\t\t\t\t\t\t\t\tconst isFile = typeof stat?.isFile === \"function\" ? stat.isFile() : stat?.isFile;\n\t\t\t\t\t\t\t\tif (isFile) {\n\t\t\t\t\t\t\t\t\texactFileResults.push(formatExactFoundPath(target.searchPath, executionCwd));\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsearchableTargets.push(target);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (exactFileResults.length > effectiveLimit || searchableTargets.length === 0) {\n\t\t\t\t\t\t\tconst resultLimitReached = exactFileResults.length > effectiveLimit;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\texactFileResults.slice(0, effectiveLimit),\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\temitUpdate(exactFileResults.slice(0, effectiveLimit));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (customOps?.glob) {\n\t\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\t\tconst relativized: string[] = [...exactFileResults];\n\t\t\t\t\t\t\tlet customLimitReached = false;\n\t\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\t\tif (!(await ops.exists(target.searchPath))) {\n\t\t\t\t\t\t\t\t\tif (targets.length > 1) {\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths.push(target.inputPath);\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${target.searchPath}`)));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst remaining = effectiveLimit - relativized.length;\n\t\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\t\tif (remaining <= 0) {\n\t\t\t\t\t\t\t\t\tconst ignore = findTargetMentionsNodeModules(target)\n\t\t\t\t\t\t\t\t\t\t? [\"**/.git/**\"]\n\t\t\t\t\t\t\t\t\t\t: [\"**/node_modules/**\", \"**/.git/**\"];\n\t\t\t\t\t\t\t\t\tconst probe = await Promise.resolve(\n\t\t\t\t\t\t\t\t\t\tops.glob(target.pattern, target.searchPath, {\n\t\t\t\t\t\t\t\t\t\t\tignore,\n\t\t\t\t\t\t\t\t\t\t\tlimit: 1,\n\t\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tif (probe.some((p) => hidden !== false || !containsHiddenSegment(p)))\n\t\t\t\t\t\t\t\t\t\tcustomLimitReached = true;\n\t\t\t\t\t\t\t\t\tif (customLimitReached) break;\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst timeoutResult = Symbol(\"find-timeout\");\n\t\t\t\t\t\t\t\tlet raceTimer: ReturnType<typeof setTimeout> | undefined;\n\t\t\t\t\t\t\t\tconst ignore = findTargetMentionsNodeModules(target)\n\t\t\t\t\t\t\t\t\t? [\"**/.git/**\"]\n\t\t\t\t\t\t\t\t\t: [\"**/node_modules/**\", \"**/.git/**\"];\n\t\t\t\t\t\t\t\tconst results = await Promise.race<string[] | symbol>([\n\t\t\t\t\t\t\t\t\tPromise.resolve(\n\t\t\t\t\t\t\t\t\t\tops.glob(target.pattern, target.searchPath, {\n\t\t\t\t\t\t\t\t\t\t\tignore,\n\t\t\t\t\t\t\t\t\t\t\tlimit: remaining + 1,\n\t\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tnew Promise<typeof timeoutResult>((resolveTimeout) => {\n\t\t\t\t\t\t\t\t\t\traceTimer = setTimeout(() => resolveTimeout(timeoutResult), remainingMs);\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tif (raceTimer) clearTimeout(raceTimer);\n\t\t\t\t\t\t\t\tif (!Array.isArray(results)) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (target.exactPathInput && results.length === 0) {\n\t\t\t\t\t\t\t\t\tconst stat = await customOps.stat?.(target.searchPath);\n\t\t\t\t\t\t\t\t\tif (!stat?.isDirectory)\n\t\t\t\t\t\t\t\t\t\trelativized.push(formatExactFoundPath(target.searchPath, executionCwd));\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst visible = results.filter((p) => hidden !== false || !containsHiddenSegment(p));\n\t\t\t\t\t\t\t\tif (visible.length > remaining) customLimitReached = true;\n\t\t\t\t\t\t\t\trelativized.push(\n\t\t\t\t\t\t\t\t\t...visible\n\t\t\t\t\t\t\t\t\t\t.slice(0, remaining)\n\t\t\t\t\t\t\t\t\t\t.map((p) => formatFoundPath(p, target.searchPath, searchPaths, executionCwd)),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\temitUpdate(relativized);\n\t\t\t\t\t\t\t\tif (customLimitReached) break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\trelativized,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tcustomLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst nativeBinding = loadNativeSearchBinding();\n\t\t\t\t\t\tif (nativeBinding) {\n\t\t\t\t\t\t\tconst matches: { path: string; mtime: number }[] = exactFileResults.map((path) => ({\n\t\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\t\tmtime: Number.POSITIVE_INFINITY,\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst result = await nativeBinding.glob({\n\t\t\t\t\t\t\t\t\t\tpattern: target.pattern,\n\t\t\t\t\t\t\t\t\t\tpath: target.searchPath,\n\t\t\t\t\t\t\t\t\t\trecursive: false,\n\t\t\t\t\t\t\t\t\t\thidden: hidden !== false,\n\t\t\t\t\t\t\t\t\t\tgitignore: gitignore !== false,\n\t\t\t\t\t\t\t\t\t\tincludeNodeModules: findTargetMentionsNodeModules(target),\n\t\t\t\t\t\t\t\t\t\tmaxResults: effectiveLimit + 1,\n\t\t\t\t\t\t\t\t\t\tcache: false,\n\t\t\t\t\t\t\t\t\t\tsortByMtime: true,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs: remainingMs,\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tmatches.push(\n\t\t\t\t\t\t\t\t\t\t...result.matches.map((match) => {\n\t\t\t\t\t\t\t\t\t\t\tconst fileType = match.fileType ?? (match as { file_type?: number }).file_type;\n\t\t\t\t\t\t\t\t\t\t\tconst isDir =\n\t\t\t\t\t\t\t\t\t\t\t\t(fileType === 2 ||\n\t\t\t\t\t\t\t\t\t\t\t\t\tfileType === \"Dir\" ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t(fileType === undefined &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstatSync(path.resolve(target.searchPath, match.path), {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthrowIfNoEntry: false,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t})?.isDirectory())) &&\n\t\t\t\t\t\t\t\t\t\t\t\t!match.path.endsWith(\"/\");\n\t\t\t\t\t\t\t\t\t\t\tconst matchPath = isDir ? `${match.path}/` : match.path;\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: formatFoundPath(matchPath, target.searchPath, searchPaths, executionCwd),\n\t\t\t\t\t\t\t\t\t\t\t\tmtime: match.mtime ?? 0,\n\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\temitUpdate(matches.map((match) => match.path));\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (String(error).toLowerCase().includes(\"timed out\")) {\n\t\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst uniqueMatches = [\n\t\t\t\t\t\t\t\t...matches\n\t\t\t\t\t\t\t\t\t.reduce((map, match) => {\n\t\t\t\t\t\t\t\t\t\tconst previous = map.get(match.path);\n\t\t\t\t\t\t\t\t\t\tif (!previous || match.mtime > previous.mtime) map.set(match.path, match);\n\t\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t\t}, new Map<string, { path: string; mtime: number }>())\n\t\t\t\t\t\t\t\t\t.values(),\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tuniqueMatches.sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));\n\t\t\t\t\t\t\tconst resultLimitReached = uniqueMatches.length > effectiveLimit;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\t\tuniqueMatches.slice(0, effectiveLimit).map((match) => match.path),\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst fdPath = await ensureTool(\"fd\");\n\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!fdPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"fd is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet timedOut = false;\n\t\t\t\t\t\tconst relativized: string[] = [...exactFileResults];\n\t\t\t\t\t\tconst deadline = Date.now() + timeoutMs;\n\t\t\t\t\t\tconst runFdForTarget = async (target: FindTarget, remaining: number): Promise<boolean> => {\n\t\t\t\t\t\t\tconst args: string[] = [\n\t\t\t\t\t\t\t\t\"--glob\",\n\t\t\t\t\t\t\t\t\"--color=never\",\n\t\t\t\t\t\t\t\t\"--no-require-git\",\n\t\t\t\t\t\t\t\t\"--max-results\",\n\t\t\t\t\t\t\t\tString(remaining + 1),\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\tif (hidden !== false) args.push(\"--hidden\");\n\t\t\t\t\t\t\tif (gitignore === false) args.push(\"--no-ignore\");\n\t\t\t\t\t\t\tif (!findTargetMentionsNodeModules(target)) args.push(\"--exclude\", \"node_modules\");\n\t\t\t\t\t\t\tlet fdPattern = target.pattern;\n\t\t\t\t\t\t\tif (target.pattern.includes(\"/\")) {\n\t\t\t\t\t\t\t\targs.push(\"--full-path\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!target.pattern.startsWith(\"/\") &&\n\t\t\t\t\t\t\t\t\t!target.pattern.startsWith(\"**/\") &&\n\t\t\t\t\t\t\t\t\ttarget.pattern !== \"**\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tfdPattern = `**/${target.pattern}`;\n\t\t\t\t\t\t\t\t// fd matches full paths with native separators on Windows.\n\t\t\t\t\t\t\t\tif (process.platform === \"win32\") fdPattern = fdPattern.replaceAll(\"/\", String.raw`[/\\\\]`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\targs.push(\"--\", fdPattern, target.searchPath);\n\t\t\t\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\t\t\t\tif (remainingMs <= 0) {\n\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn await new Promise<boolean>((resolveTarget, rejectTarget) => {\n\t\t\t\t\t\t\t\tconst child = spawn(fdPath, args, {\n\t\t\t\t\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\t\t\tconst lines: string[] = [];\n\t\t\t\t\t\t\t\tstopChild = () => {\n\t\t\t\t\t\t\t\t\tif (!child.killed) child.kill();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst targetTimer = setTimeout(() => {\n\t\t\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\t\t\tstopChild?.();\n\t\t\t\t\t\t\t\t}, remainingMs);\n\t\t\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\t\t\tclearTimeout(targetTimer);\n\t\t\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\trl.on(\"line\", (line) => lines.push(line));\n\t\t\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\t\t\trejectTarget(new Error(`Failed to run fd: ${error.message}`));\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tchild.on(\"close\", (code) => {\n\t\t\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\t\t\trejectTarget(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (!timedOut && code !== 0 && lines.length === 0) {\n\t\t\t\t\t\t\t\t\t\trejectTarget(new Error(stderr.trim() || `fd exited with code ${code}`));\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfor (const rawLine of lines.slice(0, remaining)) {\n\t\t\t\t\t\t\t\t\t\tconst line = rawLine.replace(/\\r$/, \"\").trim();\n\t\t\t\t\t\t\t\t\t\tif (line) {\n\t\t\t\t\t\t\t\t\t\t\tconst found =\n\t\t\t\t\t\t\t\t\t\t\t\tstatSync(path.resolve(target.searchPath, line), {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthrowIfNoEntry: false,\n\t\t\t\t\t\t\t\t\t\t\t\t})?.isDirectory() && !line.endsWith(\"/\")\n\t\t\t\t\t\t\t\t\t\t\t\t\t? `${line}/`\n\t\t\t\t\t\t\t\t\t\t\t\t\t: line;\n\t\t\t\t\t\t\t\t\t\t\trelativized.push(formatFoundPath(found, target.searchPath, searchPaths, executionCwd));\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\temitUpdate(relativized);\n\t\t\t\t\t\t\t\t\tresolveTarget(lines.length > Math.max(0, remaining));\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\t\t\t\t\t\tlet resultLimitReached = false;\n\t\t\t\t\t\tfor (const target of searchableTargets) {\n\t\t\t\t\t\t\tconst remaining = effectiveLimit - relativized.length;\n\t\t\t\t\t\t\tif (timedOut) break;\n\t\t\t\t\t\t\tif (remaining <= 0) {\n\t\t\t\t\t\t\t\tif (await runFdForTarget(target, 0)) {\n\t\t\t\t\t\t\t\t\tresultLimitReached = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst targetLimitReached = await runFdForTarget(target, remaining);\n\t\t\t\t\t\t\tif (targetLimitReached) {\n\t\t\t\t\t\t\t\tresultLimitReached = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\tbuildFindResult(\n\t\t\t\t\t\t\t\t\trelativized.slice(0, effectiveLimit),\n\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\ttimedOut,\n\t\t\t\t\t\t\t\t\ttimeoutMs,\n\t\t\t\t\t\t\t\t\tskippedMissingPaths,\n\t\t\t\t\t\t\t\t\tresultLimitReached,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst error = e instanceof Error ? e : new Error(String(e));\n\t\t\t\t\t\tsettle(() => reject(error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatFindCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatFindResult(result, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\nexport function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema> {\n\treturn wrapToolDefinition(createFindToolDefinition(cwd, options));\n}\n"]}
@@ -19,9 +19,9 @@ import * as pathModule from "node:path";
19
19
  * `node:fs` callers that already check `err.code === "ENOENT"`.
20
20
  */
21
21
  export class NotFoundError extends Error {
22
+ code = "ENOENT";
22
23
  constructor(path, cause) {
23
24
  super(`File not found: ${path}`);
24
- this.code = "ENOENT";
25
25
  this.name = "NotFoundError";
26
26
  if (cause !== undefined)
27
27
  this.cause = cause;
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/fs.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD;;;;;;;;;GASG;AACH,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAYxC;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGvC,YAAY,IAAY,EAAE,KAAe;QACxC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QAHzB,SAAI,GAAG,QAAQ,CAAC;QAIxB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS;YAAG,IAAoC,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9E,CAAC;CACD;AAED,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,aAAa;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,KAAK,YAAY,KAAK,IAAK,KAAmC,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAClG,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,OAAgB,UAAU;IAI/B,kFAAkF;IAClF,KAAK,CAAC,cAAc,CAAC,KAAa,IAAkB,CAAC;IAKrD,6FAA6F;IAC7F,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YA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IAED,gEAAgE;IAChE,GAAG,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,sEAAsE;IACtE,MAAM,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,wBAAwB;IACxB,KAAK;QACJ,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,uCAAuC;IACvC,OAAO;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC7C,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,OAAe;QAC5C,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,IAAY;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\nimport { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\n/**\n * Storage seam for the hashline patcher. {@link Filesystem} is intentionally\n * minimal — `readText`, `writeText`, `exists` — so any backing store can be\n * adapted: disk, memory, S3, an LSP text-document protocol, a Git tree, a\n * VFS, etc.\n *\n * The patcher does its own BOM stripping and LF normalization between\n * {@link Filesystem.readText} and {@link Filesystem.writeText}; the FS deals\n * only in raw text strings.\n */\nimport * as pathModule from \"node:path\";\n\n/**\n * Result returned by {@link Filesystem.writeText}. The patcher echoes back\n * `text` so adapters that transform on serialization (e.g. notebooks) can\n * report what actually landed on disk.\n */\nexport interface WriteResult {\n\t/** Final text that was persisted. May differ from the input if the FS transformed it. */\n\ttext: string;\n}\n\n/**\n * ENOENT-like error thrown by {@link Filesystem.readText} when a path is\n * missing. Carrying a `code` property keeps the contract compatible with\n * `node:fs` callers that already check `err.code === \"ENOENT\"`.\n */\nexport class NotFoundError extends Error {\n\treadonly code = \"ENOENT\";\n\n\tconstructor(path: string, cause?: unknown) {\n\t\tsuper(`File not found: ${path}`);\n\t\tthis.name = \"NotFoundError\";\n\t\tif (cause !== undefined) (this as Error & { cause?: unknown }).cause = cause;\n\t}\n}\n\n/** Type guard for {@link NotFoundError} and structurally-compatible errors. */\nexport function isNotFound(error: unknown): boolean {\n\tif (error instanceof NotFoundError) return true;\n\tif (error instanceof Error && (error as Error & { code?: string }).code === \"ENOENT\") return true;\n\treturn false;\n}\n\n/**\n * Abstract storage backend the {@link Patcher} reads from and writes to.\n * Subclass for new backends; the package ships {@link InMemoryFilesystem} and\n * {@link NodeFilesystem} for the most common cases.\n *\n * Implementations work with raw text — the patcher handles BOM stripping and\n * line-ending normalization itself. `readText` MUST throw {@link\n * NotFoundError} (or any error for which {@link isNotFound} returns true)\n * when the path doesn't exist; that's how the patcher detects a create-vs-\n * update.\n */\nexport abstract class Filesystem {\n\t/** Read the file's full text content. Throw on missing file. */\n\tabstract readText(path: string): Promise<string>;\n\n\t/** Validate that `path` is writable before a prepared batch starts committing. */\n\tasync preflightWrite(_path: string): Promise<void> {}\n\n\t/** Persist `content` at `path`. Returns the actual final text that was written. */\n\tabstract writeText(path: string, content: string): Promise<WriteResult>;\n\n\t/** Return true when the path exists and can be read. Default: probe via {@link readText}. */\n\tasync exists(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.readText(path);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (isNotFound(error)) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Canonical path used as a key by external caches (e.g. snapshot\n\t * stores). The default is identity; override to return an absolute or\n\t * otherwise canonicalised path so producers and consumers of cached\n\t * snapshots agree on the key without each having to redo the resolution.\n\t */\n\tcanonicalPath(path: string): string {\n\t\treturn path;\n\t}\n}\n\n/**\n * In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as\n * a building block for stacked adapters (e.g. an LRU layer on top).\n */\nexport class InMemoryFilesystem extends Filesystem {\n\t#files = new Map<string, string>();\n\n\tconstructor(initial?: Iterable<readonly [string, string]>) {\n\t\tsuper();\n\t\tif (initial) {\n\t\t\tfor (const [path, content] of initial) this.#files.set(path, content);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst text = this.#files.get(path);\n\t\tif (text === undefined) throw new NotFoundError(path);\n\t\treturn text;\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tthis.#files.set(path, content);\n\t\treturn { text: content };\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn this.#files.has(path);\n\t}\n\n\t/** Synchronous helper for setting up fixtures without awaiting. */\n\tset(path: string, content: string): void {\n\t\tthis.#files.set(path, content);\n\t}\n\n\t/** Synchronous helper for inspecting state without awaiting. */\n\tget(path: string): string | undefined {\n\t\treturn this.#files.get(path);\n\t}\n\n\t/** Remove a single entry. Returns true when something was removed. */\n\tdelete(path: string): boolean {\n\t\treturn this.#files.delete(path);\n\t}\n\n\t/** Wipe all entries. */\n\tclear(): void {\n\t\tthis.#files.clear();\n\t}\n\n\t/** Iterate `[path, content]` pairs. */\n\tentries(): IterableIterator<[string, string]> {\n\t\treturn this.#files.entries();\n\t}\n}\n\n/**\n * Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI\n * use. Paths are accepted as-is; callers responsible for any cwd or\n * jail/sandbox resolution should wrap this with their own subclass.\n */\nexport class NodeFilesystem extends Filesystem {\n\tasync readText(path: string): Promise<string> {\n\t\tif (!existsSync(path)) throw new NotFoundError(path);\n\t\treturn readFile(path, \"utf8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tawait writeFile(path, content, \"utf8\");\n\t\treturn { text: content };\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn pathModule.resolve(path);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn existsSync(path);\n\t}\n}\n"]}
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/fs.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD;;;;;;;;;GASG;AACH,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AAYxC;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC9B,IAAI,GAAG,QAAQ,CAAC;IAEzB,YAAY,IAAY,EAAE,KAAe;QACxC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS;YAAG,IAAoC,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9E,CAAC;CACD;AAED,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,aAAa;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,KAAK,YAAY,KAAK,IAA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AI,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\nimport { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\n/**\n * Storage seam for the hashline patcher. {@link Filesystem} is intentionally\n * minimal — `readText`, `writeText`, `exists` — so any backing store can be\n * adapted: disk, memory, S3, an LSP text-document protocol, a Git tree, a\n * VFS, etc.\n *\n * The patcher does its own BOM stripping and LF normalization between\n * {@link Filesystem.readText} and {@link Filesystem.writeText}; the FS deals\n * only in raw text strings.\n */\nimport * as pathModule from \"node:path\";\n\n/**\n * Result returned by {@link Filesystem.writeText}. The patcher echoes back\n * `text` so adapters that transform on serialization (e.g. notebooks) can\n * report what actually landed on disk.\n */\nexport interface WriteResult {\n\t/** Final text that was persisted. May differ from the input if the FS transformed it. */\n\ttext: string;\n}\n\n/**\n * ENOENT-like error thrown by {@link Filesystem.readText} when a path is\n * missing. Carrying a `code` property keeps the contract compatible with\n * `node:fs` callers that already check `err.code === \"ENOENT\"`.\n */\nexport class NotFoundError extends Error {\n\treadonly code = \"ENOENT\";\n\n\tconstructor(path: string, cause?: unknown) {\n\t\tsuper(`File not found: ${path}`);\n\t\tthis.name = \"NotFoundError\";\n\t\tif (cause !== undefined) (this as Error & { cause?: unknown }).cause = cause;\n\t}\n}\n\n/** Type guard for {@link NotFoundError} and structurally-compatible errors. */\nexport function isNotFound(error: unknown): boolean {\n\tif (error instanceof NotFoundError) return true;\n\tif (error instanceof Error && (error as Error & { code?: string }).code === \"ENOENT\") return true;\n\treturn false;\n}\n\n/**\n * Abstract storage backend the {@link Patcher} reads from and writes to.\n * Subclass for new backends; the package ships {@link InMemoryFilesystem} and\n * {@link NodeFilesystem} for the most common cases.\n *\n * Implementations work with raw text — the patcher handles BOM stripping and\n * line-ending normalization itself. `readText` MUST throw {@link\n * NotFoundError} (or any error for which {@link isNotFound} returns true)\n * when the path doesn't exist; that's how the patcher detects a create-vs-\n * update.\n */\nexport abstract class Filesystem {\n\t/** Read the file's full text content. Throw on missing file. */\n\tabstract readText(path: string): Promise<string>;\n\n\t/** Validate that `path` is writable before a prepared batch starts committing. */\n\tasync preflightWrite(_path: string): Promise<void> {}\n\n\t/** Persist `content` at `path`. Returns the actual final text that was written. */\n\tabstract writeText(path: string, content: string): Promise<WriteResult>;\n\n\t/** Return true when the path exists and can be read. Default: probe via {@link readText}. */\n\tasync exists(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.readText(path);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (isNotFound(error)) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Canonical path used as a key by external caches (e.g. snapshot\n\t * stores). The default is identity; override to return an absolute or\n\t * otherwise canonicalised path so producers and consumers of cached\n\t * snapshots agree on the key without each having to redo the resolution.\n\t */\n\tcanonicalPath(path: string): string {\n\t\treturn path;\n\t}\n}\n\n/**\n * In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as\n * a building block for stacked adapters (e.g. an LRU layer on top).\n */\nexport class InMemoryFilesystem extends Filesystem {\n\t#files = new Map<string, string>();\n\n\tconstructor(initial?: Iterable<readonly [string, string]>) {\n\t\tsuper();\n\t\tif (initial) {\n\t\t\tfor (const [path, content] of initial) this.#files.set(path, content);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst text = this.#files.get(path);\n\t\tif (text === undefined) throw new NotFoundError(path);\n\t\treturn text;\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tthis.#files.set(path, content);\n\t\treturn { text: content };\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn this.#files.has(path);\n\t}\n\n\t/** Synchronous helper for setting up fixtures without awaiting. */\n\tset(path: string, content: string): void {\n\t\tthis.#files.set(path, content);\n\t}\n\n\t/** Synchronous helper for inspecting state without awaiting. */\n\tget(path: string): string | undefined {\n\t\treturn this.#files.get(path);\n\t}\n\n\t/** Remove a single entry. Returns true when something was removed. */\n\tdelete(path: string): boolean {\n\t\treturn this.#files.delete(path);\n\t}\n\n\t/** Wipe all entries. */\n\tclear(): void {\n\t\tthis.#files.clear();\n\t}\n\n\t/** Iterate `[path, content]` pairs. */\n\tentries(): IterableIterator<[string, string]> {\n\t\treturn this.#files.entries();\n\t}\n}\n\n/**\n * Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI\n * use. Paths are accepted as-is; callers responsible for any cwd or\n * jail/sandbox resolution should wrap this with their own subclass.\n */\nexport class NodeFilesystem extends Filesystem {\n\tasync readText(path: string): Promise<string> {\n\t\tif (!existsSync(path)) throw new NotFoundError(path);\n\t\treturn readFile(path, \"utf8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tawait writeFile(path, content, \"utf8\");\n\t\treturn { text: content };\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn pathModule.resolve(path);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn existsSync(path);\n\t}\n}\n"]}
@@ -216,6 +216,9 @@ function splitRawSections(input, options = {}) {
216
216
  * than build these directly.
217
217
  */
218
218
  export class PatchSection {
219
+ path;
220
+ fileHash;
221
+ diff;
219
222
  #parsed;
220
223
  constructor(raw) {
221
224
  this.path = raw.path;
@@ -330,6 +333,7 @@ export class PatchSection {
330
333
  * filesystem. To apply a patch, hand it to {@link Patcher.apply}.
331
334
  */
332
335
  export class Patch {
336
+ sections;
333
337
  constructor(sections) {
334
338
  this.sections = sections;
335
339
  }