@subimpact/e 0.99.12 → 0.100.1

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 (930) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +7 -1
  3. package/dist/bundle/chunks/anthropic-messages-BGDBSRR2.js +6 -0
  4. package/dist/bundle/chunks/azure-openai-responses-ZCNWFVTX.js +2 -0
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
  6. package/dist/bundle/chunks/chunk-35AZPBGE.js +11 -0
  7. package/dist/bundle/chunks/{chunk-C47CLQZK.js → chunk-CMZY6PM7.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-XVIZD2L5.js → chunk-DOSAFY5Y.js} +3 -3
  9. package/dist/bundle/chunks/{chunk-KAXC2ESR.js → chunk-GICF34HK.js} +8 -8
  10. package/dist/bundle/chunks/{chunk-GYREDKZT.js → chunk-HKQXO4IQ.js} +1 -1
  11. package/dist/bundle/chunks/chunk-K4O5WZC5.js +11 -0
  12. package/dist/bundle/chunks/{chunk-SVKJCAH2.js → chunk-NBSSK56J.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-XZYVF4BW.js → chunk-RAB4RJZ2.js} +60 -60
  14. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-NHSAQJW5.js → cloudflare-workers-ai-system-one-6FXZDK6A.js} +1 -1
  15. package/dist/bundle/chunks/{easter-egg-3d-DD22MRM3.js → easter-egg-3d-JQPBRQEU.js} +1 -1
  16. package/dist/bundle/chunks/github-copilot.js +1 -1
  17. package/dist/bundle/chunks/{google-generative-ai-ON7RPJHF.js → google-generative-ai-VJA5IOK3.js} +1 -1
  18. package/dist/bundle/chunks/{google-vertex-6YO5GV2H.js → google-vertex-TI6AJXT2.js} +1 -1
  19. package/dist/bundle/chunks/{mistral-conversations-NN33SMJ6.js → mistral-conversations-XTWEX6FG.js} +1 -1
  20. package/dist/bundle/chunks/openai-codex-responses-WGH4GHLE.js +10 -0
  21. package/dist/bundle/chunks/openai-completions-GXGEEHZH.js +7 -0
  22. package/dist/bundle/chunks/openai-responses-NLSL5UY4.js +3 -0
  23. package/dist/bundle/chunks/{typesafe-system-one-PRR5K6CI.js → typesafe-system-one-3OTHQPDL.js} +1 -1
  24. package/dist/bundle/chunks/{virtual-modules-6MDPJKNE.js → virtual-modules-L22CHFWU.js} +1 -1
  25. package/dist/bundle/cli-runtime.js +1 -1
  26. package/dist/bundle/index.js +1 -1
  27. package/dist/bundle/rpc-entry.js +1 -1
  28. package/docs/compaction.md +2 -2
  29. package/docs/extensions.md +4 -10
  30. package/docs/message-types.md +2 -4
  31. package/docs/session-format.md +4 -4
  32. package/docs/settings.md +1 -1
  33. package/docs/tui.md +1 -1
  34. package/examples/extensions/overlay-test.ts +2 -2
  35. package/package.json +31 -31
  36. package/dist/bun/cli.d.ts +0 -5
  37. package/dist/bun/cli.d.ts.map +0 -1
  38. package/dist/bun/cli.js +0 -5
  39. package/dist/bun/cli.js.map +0 -1
  40. package/dist/bun/restore-sandbox-env.d.ts +0 -17
  41. package/dist/bun/restore-sandbox-env.d.ts.map +0 -1
  42. package/dist/bun/restore-sandbox-env.js +0 -36
  43. package/dist/bun/restore-sandbox-env.js.map +0 -1
  44. package/dist/bun/runtime-setup.d.ts +0 -2
  45. package/dist/bun/runtime-setup.d.ts.map +0 -1
  46. package/dist/bun/runtime-setup.js +0 -9
  47. package/dist/bun/runtime-setup.js.map +0 -1
  48. package/dist/bun/sandbox-env-setup.d.ts +0 -2
  49. package/dist/bun/sandbox-env-setup.d.ts.map +0 -1
  50. package/dist/bun/sandbox-env-setup.js +0 -4
  51. package/dist/bun/sandbox-env-setup.js.map +0 -1
  52. package/dist/bundle/chunks/anthropic-messages-EGJT3PY6.js +0 -6
  53. package/dist/bundle/chunks/azure-openai-responses-JEEXH6HK.js +0 -2
  54. package/dist/bundle/chunks/chunk-IOJUMBW3.js +0 -11
  55. package/dist/bundle/chunks/chunk-KJUDFE6Y.js +0 -11
  56. package/dist/bundle/chunks/openai-codex-responses-CPSVXTKM.js +0 -10
  57. package/dist/bundle/chunks/openai-completions-T7GN33JE.js +0 -7
  58. package/dist/bundle/chunks/openai-responses-GPE3ZQ46.js +0 -3
  59. package/dist/cli/args.d.ts +0 -61
  60. package/dist/cli/args.d.ts.map +0 -1
  61. package/dist/cli/args.js +0 -453
  62. package/dist/cli/args.js.map +0 -1
  63. package/dist/cli/auth-check.d.ts +0 -19
  64. package/dist/cli/auth-check.d.ts.map +0 -1
  65. package/dist/cli/auth-check.js +0 -50
  66. package/dist/cli/auth-check.js.map +0 -1
  67. package/dist/cli/auth-command.d.ts +0 -24
  68. package/dist/cli/auth-command.d.ts.map +0 -1
  69. package/dist/cli/auth-command.js +0 -103
  70. package/dist/cli/auth-command.js.map +0 -1
  71. package/dist/cli/config-selector.d.ts +0 -16
  72. package/dist/cli/config-selector.d.ts.map +0 -1
  73. package/dist/cli/config-selector.js +0 -32
  74. package/dist/cli/config-selector.js.map +0 -1
  75. package/dist/cli/credential-print.d.ts +0 -13
  76. package/dist/cli/credential-print.d.ts.map +0 -1
  77. package/dist/cli/credential-print.js +0 -76
  78. package/dist/cli/credential-print.js.map +0 -1
  79. package/dist/cli/file-processor.d.ts +0 -15
  80. package/dist/cli/file-processor.d.ts.map +0 -1
  81. package/dist/cli/file-processor.js +0 -71
  82. package/dist/cli/file-processor.js.map +0 -1
  83. package/dist/cli/initial-message.d.ts +0 -18
  84. package/dist/cli/initial-message.d.ts.map +0 -1
  85. package/dist/cli/initial-message.js +0 -22
  86. package/dist/cli/initial-message.js.map +0 -1
  87. package/dist/cli/list-models.d.ts +0 -9
  88. package/dist/cli/list-models.d.ts.map +0 -1
  89. package/dist/cli/list-models.js +0 -98
  90. package/dist/cli/list-models.js.map +0 -1
  91. package/dist/cli/project-trust.d.ts +0 -10
  92. package/dist/cli/project-trust.d.ts.map +0 -1
  93. package/dist/cli/project-trust.js +0 -48
  94. package/dist/cli/project-trust.js.map +0 -1
  95. package/dist/cli/session-picker.d.ts +0 -10
  96. package/dist/cli/session-picker.d.ts.map +0 -1
  97. package/dist/cli/session-picker.js +0 -36
  98. package/dist/cli/session-picker.js.map +0 -1
  99. package/dist/cli/setup.d.ts +0 -2
  100. package/dist/cli/setup.d.ts.map +0 -1
  101. package/dist/cli/setup.js +0 -12
  102. package/dist/cli/setup.js.map +0 -1
  103. package/dist/cli/startup-ui.d.ts +0 -20
  104. package/dist/cli/startup-ui.d.ts.map +0 -1
  105. package/dist/cli/startup-ui.js +0 -193
  106. package/dist/cli/startup-ui.js.map +0 -1
  107. package/dist/cli.d.ts +0 -3
  108. package/dist/cli.d.ts.map +0 -1
  109. package/dist/cli.js +0 -6
  110. package/dist/cli.js.map +0 -1
  111. package/dist/config.d.ts +0 -107
  112. package/dist/config.d.ts.map +0 -1
  113. package/dist/config.js +0 -486
  114. package/dist/config.js.map +0 -1
  115. package/dist/core/agent-session-runtime.d.ts +0 -119
  116. package/dist/core/agent-session-runtime.d.ts.map +0 -1
  117. package/dist/core/agent-session-runtime.js +0 -317
  118. package/dist/core/agent-session-runtime.js.map +0 -1
  119. package/dist/core/agent-session-services.d.ts +0 -86
  120. package/dist/core/agent-session-services.d.ts.map +0 -1
  121. package/dist/core/agent-session-services.js +0 -147
  122. package/dist/core/agent-session-services.js.map +0 -1
  123. package/dist/core/agent-session.d.ts +0 -881
  124. package/dist/core/agent-session.d.ts.map +0 -1
  125. package/dist/core/agent-session.js +0 -3524
  126. package/dist/core/agent-session.js.map +0 -1
  127. package/dist/core/auth-guidance.d.ts +0 -5
  128. package/dist/core/auth-guidance.d.ts.map +0 -1
  129. package/dist/core/auth-guidance.js +0 -21
  130. package/dist/core/auth-guidance.js.map +0 -1
  131. package/dist/core/auth-storage.d.ts +0 -72
  132. package/dist/core/auth-storage.d.ts.map +0 -1
  133. package/dist/core/auth-storage.js +0 -426
  134. package/dist/core/auth-storage.js.map +0 -1
  135. package/dist/core/bash-executor.d.ts +0 -32
  136. package/dist/core/bash-executor.d.ts.map +0 -1
  137. package/dist/core/bash-executor.js +0 -106
  138. package/dist/core/bash-executor.js.map +0 -1
  139. package/dist/core/bug-report-upload.d.ts +0 -12
  140. package/dist/core/bug-report-upload.d.ts.map +0 -1
  141. package/dist/core/bug-report-upload.js +0 -22
  142. package/dist/core/bug-report-upload.js.map +0 -1
  143. package/dist/core/bug-report.d.ts +0 -176
  144. package/dist/core/bug-report.d.ts.map +0 -1
  145. package/dist/core/bug-report.js +0 -292
  146. package/dist/core/bug-report.js.map +0 -1
  147. package/dist/core/cache-stats.d.ts +0 -49
  148. package/dist/core/cache-stats.d.ts.map +0 -1
  149. package/dist/core/cache-stats.js +0 -112
  150. package/dist/core/cache-stats.js.map +0 -1
  151. package/dist/core/cache-warmer.d.ts +0 -103
  152. package/dist/core/cache-warmer.d.ts.map +0 -1
  153. package/dist/core/cache-warmer.js +0 -359
  154. package/dist/core/cache-warmer.js.map +0 -1
  155. package/dist/core/compaction/branch-summarization.d.ts +0 -98
  156. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  157. package/dist/core/compaction/branch-summarization.js +0 -251
  158. package/dist/core/compaction/branch-summarization.js.map +0 -1
  159. package/dist/core/compaction/compaction.d.ts +0 -145
  160. package/dist/core/compaction/compaction.d.ts.map +0 -1
  161. package/dist/core/compaction/compaction.js +0 -744
  162. package/dist/core/compaction/compaction.js.map +0 -1
  163. package/dist/core/compaction/index.d.ts +0 -7
  164. package/dist/core/compaction/index.d.ts.map +0 -1
  165. package/dist/core/compaction/index.js +0 -7
  166. package/dist/core/compaction/index.js.map +0 -1
  167. package/dist/core/compaction/utils.d.ts +0 -39
  168. package/dist/core/compaction/utils.d.ts.map +0 -1
  169. package/dist/core/compaction/utils.js +0 -149
  170. package/dist/core/compaction/utils.js.map +0 -1
  171. package/dist/core/crash-log.d.ts +0 -27
  172. package/dist/core/crash-log.d.ts.map +0 -1
  173. package/dist/core/crash-log.js +0 -140
  174. package/dist/core/crash-log.js.map +0 -1
  175. package/dist/core/defaults.d.ts +0 -4
  176. package/dist/core/defaults.d.ts.map +0 -1
  177. package/dist/core/defaults.js +0 -11
  178. package/dist/core/defaults.js.map +0 -1
  179. package/dist/core/diagnostics.d.ts +0 -15
  180. package/dist/core/diagnostics.d.ts.map +0 -1
  181. package/dist/core/diagnostics.js +0 -2
  182. package/dist/core/diagnostics.js.map +0 -1
  183. package/dist/core/event-bus.d.ts +0 -9
  184. package/dist/core/event-bus.d.ts.map +0 -1
  185. package/dist/core/event-bus.js +0 -25
  186. package/dist/core/event-bus.js.map +0 -1
  187. package/dist/core/exec.d.ts +0 -29
  188. package/dist/core/exec.d.ts.map +0 -1
  189. package/dist/core/exec.js +0 -75
  190. package/dist/core/exec.js.map +0 -1
  191. package/dist/core/experimental.d.ts +0 -2
  192. package/dist/core/experimental.d.ts.map +0 -1
  193. package/dist/core/experimental.js +0 -6
  194. package/dist/core/experimental.js.map +0 -1
  195. package/dist/core/export-html/ansi-to-html.d.ts +0 -22
  196. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  197. package/dist/core/export-html/ansi-to-html.js +0 -249
  198. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  199. package/dist/core/export-html/index.d.ts +0 -37
  200. package/dist/core/export-html/index.d.ts.map +0 -1
  201. package/dist/core/export-html/index.js +0 -226
  202. package/dist/core/export-html/index.js.map +0 -1
  203. package/dist/core/export-html/tool-renderer.d.ts +0 -34
  204. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  205. package/dist/core/export-html/tool-renderer.js +0 -109
  206. package/dist/core/export-html/tool-renderer.js.map +0 -1
  207. package/dist/core/extensions/index.d.ts +0 -12
  208. package/dist/core/extensions/index.d.ts.map +0 -1
  209. package/dist/core/extensions/index.js +0 -9
  210. package/dist/core/extensions/index.js.map +0 -1
  211. package/dist/core/extensions/jiti-loader.d.ts +0 -2
  212. package/dist/core/extensions/jiti-loader.d.ts.map +0 -1
  213. package/dist/core/extensions/jiti-loader.js +0 -4
  214. package/dist/core/extensions/jiti-loader.js.map +0 -1
  215. package/dist/core/extensions/jiti-static-loader.d.ts +0 -2
  216. package/dist/core/extensions/jiti-static-loader.d.ts.map +0 -1
  217. package/dist/core/extensions/jiti-static-loader.js +0 -4
  218. package/dist/core/extensions/jiti-static-loader.js.map +0 -1
  219. package/dist/core/extensions/loader.d.ts +0 -23
  220. package/dist/core/extensions/loader.d.ts.map +0 -1
  221. package/dist/core/extensions/loader.js +0 -667
  222. package/dist/core/extensions/loader.js.map +0 -1
  223. package/dist/core/extensions/runner.d.ts +0 -204
  224. package/dist/core/extensions/runner.d.ts.map +0 -1
  225. package/dist/core/extensions/runner.js +0 -1207
  226. package/dist/core/extensions/runner.js.map +0 -1
  227. package/dist/core/extensions/types.d.ts +0 -1669
  228. package/dist/core/extensions/types.d.ts.map +0 -1
  229. package/dist/core/extensions/types.js +0 -48
  230. package/dist/core/extensions/types.js.map +0 -1
  231. package/dist/core/extensions/virtual-modules.d.ts +0 -3
  232. package/dist/core/extensions/virtual-modules.d.ts.map +0 -1
  233. package/dist/core/extensions/virtual-modules.js +0 -38
  234. package/dist/core/extensions/virtual-modules.js.map +0 -1
  235. package/dist/core/extensions/wrapper.d.ts +0 -20
  236. package/dist/core/extensions/wrapper.d.ts.map +0 -1
  237. package/dist/core/extensions/wrapper.js +0 -22
  238. package/dist/core/extensions/wrapper.js.map +0 -1
  239. package/dist/core/footer-data-provider.d.ts +0 -64
  240. package/dist/core/footer-data-provider.d.ts.map +0 -1
  241. package/dist/core/footer-data-provider.js +0 -338
  242. package/dist/core/footer-data-provider.js.map +0 -1
  243. package/dist/core/http-dispatcher.d.ts +0 -22
  244. package/dist/core/http-dispatcher.d.ts.map +0 -1
  245. package/dist/core/http-dispatcher.js +0 -98
  246. package/dist/core/http-dispatcher.js.map +0 -1
  247. package/dist/core/index.d.ts +0 -14
  248. package/dist/core/index.d.ts.map +0 -1
  249. package/dist/core/index.js +0 -13
  250. package/dist/core/index.js.map +0 -1
  251. package/dist/core/keybindings.d.ts +0 -428
  252. package/dist/core/keybindings.d.ts.map +0 -1
  253. package/dist/core/keybindings.js +0 -321
  254. package/dist/core/keybindings.js.map +0 -1
  255. package/dist/core/messages.d.ts +0 -77
  256. package/dist/core/messages.d.ts.map +0 -1
  257. package/dist/core/messages.js +0 -124
  258. package/dist/core/messages.js.map +0 -1
  259. package/dist/core/model-config.d.ts +0 -760
  260. package/dist/core/model-config.d.ts.map +0 -1
  261. package/dist/core/model-config.js +0 -294
  262. package/dist/core/model-config.js.map +0 -1
  263. package/dist/core/model-registry.d.ts +0 -61
  264. package/dist/core/model-registry.d.ts.map +0 -1
  265. package/dist/core/model-registry.js +0 -140
  266. package/dist/core/model-registry.js.map +0 -1
  267. package/dist/core/model-resolver.d.ts +0 -124
  268. package/dist/core/model-resolver.d.ts.map +0 -1
  269. package/dist/core/model-resolver.js +0 -590
  270. package/dist/core/model-resolver.js.map +0 -1
  271. package/dist/core/model-runtime.d.ts +0 -145
  272. package/dist/core/model-runtime.d.ts.map +0 -1
  273. package/dist/core/model-runtime.js +0 -758
  274. package/dist/core/model-runtime.js.map +0 -1
  275. package/dist/core/models-store.d.ts +0 -22
  276. package/dist/core/models-store.d.ts.map +0 -1
  277. package/dist/core/models-store.js +0 -115
  278. package/dist/core/models-store.js.map +0 -1
  279. package/dist/core/nested-tool-calls.d.ts +0 -102
  280. package/dist/core/nested-tool-calls.d.ts.map +0 -1
  281. package/dist/core/nested-tool-calls.js +0 -178
  282. package/dist/core/nested-tool-calls.js.map +0 -1
  283. package/dist/core/output-guard.d.ts +0 -7
  284. package/dist/core/output-guard.d.ts.map +0 -1
  285. package/dist/core/output-guard.js +0 -89
  286. package/dist/core/output-guard.js.map +0 -1
  287. package/dist/core/package-manager.d.ts +0 -217
  288. package/dist/core/package-manager.d.ts.map +0 -1
  289. package/dist/core/package-manager.js +0 -2224
  290. package/dist/core/package-manager.js.map +0 -1
  291. package/dist/core/pi-manifest.d.ts +0 -8
  292. package/dist/core/pi-manifest.d.ts.map +0 -1
  293. package/dist/core/pi-manifest.js +0 -26
  294. package/dist/core/pi-manifest.js.map +0 -1
  295. package/dist/core/project-trust.d.ts +0 -15
  296. package/dist/core/project-trust.d.ts.map +0 -1
  297. package/dist/core/project-trust.js +0 -59
  298. package/dist/core/project-trust.js.map +0 -1
  299. package/dist/core/prompt-templates.d.ts +0 -59
  300. package/dist/core/prompt-templates.d.ts.map +0 -1
  301. package/dist/core/prompt-templates.js +0 -262
  302. package/dist/core/prompt-templates.js.map +0 -1
  303. package/dist/core/provider-attribution.d.ts +0 -4
  304. package/dist/core/provider-attribution.d.ts.map +0 -1
  305. package/dist/core/provider-attribution.js +0 -72
  306. package/dist/core/provider-attribution.js.map +0 -1
  307. package/dist/core/provider-composer.d.ts +0 -80
  308. package/dist/core/provider-composer.d.ts.map +0 -1
  309. package/dist/core/provider-composer.js +0 -488
  310. package/dist/core/provider-composer.js.map +0 -1
  311. package/dist/core/radius.d.ts +0 -5
  312. package/dist/core/radius.d.ts.map +0 -1
  313. package/dist/core/radius.js +0 -9
  314. package/dist/core/radius.js.map +0 -1
  315. package/dist/core/remote-catalog-provider.d.ts +0 -12
  316. package/dist/core/remote-catalog-provider.d.ts.map +0 -1
  317. package/dist/core/remote-catalog-provider.js +0 -132
  318. package/dist/core/remote-catalog-provider.js.map +0 -1
  319. package/dist/core/resolve-config-value.d.ts +0 -30
  320. package/dist/core/resolve-config-value.d.ts.map +0 -1
  321. package/dist/core/resolve-config-value.js +0 -247
  322. package/dist/core/resolve-config-value.js.map +0 -1
  323. package/dist/core/resource-loader.d.ts +0 -227
  324. package/dist/core/resource-loader.d.ts.map +0 -1
  325. package/dist/core/resource-loader.js +0 -1008
  326. package/dist/core/resource-loader.js.map +0 -1
  327. package/dist/core/runtime-credentials.d.ts +0 -15
  328. package/dist/core/runtime-credentials.d.ts.map +0 -1
  329. package/dist/core/runtime-credentials.js +0 -39
  330. package/dist/core/runtime-credentials.js.map +0 -1
  331. package/dist/core/sdk.d.ts +0 -108
  332. package/dist/core/sdk.d.ts.map +0 -1
  333. package/dist/core/sdk.js +0 -315
  334. package/dist/core/sdk.js.map +0 -1
  335. package/dist/core/session-cwd.d.ts +0 -19
  336. package/dist/core/session-cwd.d.ts.map +0 -1
  337. package/dist/core/session-cwd.js +0 -38
  338. package/dist/core/session-cwd.js.map +0 -1
  339. package/dist/core/session-export.d.ts +0 -8
  340. package/dist/core/session-export.d.ts.map +0 -1
  341. package/dist/core/session-export.js +0 -33
  342. package/dist/core/session-export.js.map +0 -1
  343. package/dist/core/session-manager.d.ts +0 -416
  344. package/dist/core/session-manager.d.ts.map +0 -1
  345. package/dist/core/session-manager.js +0 -1523
  346. package/dist/core/session-manager.js.map +0 -1
  347. package/dist/core/settings-diagnostics.d.ts +0 -9
  348. package/dist/core/settings-diagnostics.d.ts.map +0 -1
  349. package/dist/core/settings-diagnostics.js +0 -21
  350. package/dist/core/settings-diagnostics.js.map +0 -1
  351. package/dist/core/settings-manager.d.ts +0 -362
  352. package/dist/core/settings-manager.d.ts.map +0 -1
  353. package/dist/core/settings-manager.js +0 -1107
  354. package/dist/core/settings-manager.js.map +0 -1
  355. package/dist/core/skills.d.ts +0 -60
  356. package/dist/core/skills.d.ts.map +0 -1
  357. package/dist/core/skills.js +0 -407
  358. package/dist/core/skills.js.map +0 -1
  359. package/dist/core/slash-commands.d.ts +0 -15
  360. package/dist/core/slash-commands.d.ts.map +0 -1
  361. package/dist/core/slash-commands.js +0 -28
  362. package/dist/core/slash-commands.js.map +0 -1
  363. package/dist/core/source-info.d.ts +0 -26
  364. package/dist/core/source-info.d.ts.map +0 -1
  365. package/dist/core/source-info.js +0 -35
  366. package/dist/core/source-info.js.map +0 -1
  367. package/dist/core/system-prompt.d.ts +0 -71
  368. package/dist/core/system-prompt.d.ts.map +0 -1
  369. package/dist/core/system-prompt.js +0 -147
  370. package/dist/core/system-prompt.js.map +0 -1
  371. package/dist/core/telemetry.d.ts +0 -3
  372. package/dist/core/telemetry.d.ts.map +0 -1
  373. package/dist/core/telemetry.js +0 -10
  374. package/dist/core/telemetry.js.map +0 -1
  375. package/dist/core/timings.d.ts +0 -6
  376. package/dist/core/timings.d.ts.map +0 -1
  377. package/dist/core/timings.js +0 -42
  378. package/dist/core/timings.js.map +0 -1
  379. package/dist/core/tools/bash.d.ts +0 -101
  380. package/dist/core/tools/bash.d.ts.map +0 -1
  381. package/dist/core/tools/bash.js +0 -348
  382. package/dist/core/tools/bash.js.map +0 -1
  383. package/dist/core/tools/edit-diff.d.ts +0 -101
  384. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  385. package/dist/core/tools/edit-diff.js +0 -421
  386. package/dist/core/tools/edit-diff.js.map +0 -1
  387. package/dist/core/tools/edit.d.ts +0 -44
  388. package/dist/core/tools/edit.d.ts.map +0 -1
  389. package/dist/core/tools/edit.js +0 -147
  390. package/dist/core/tools/edit.js.map +0 -1
  391. package/dist/core/tools/file-mutation-queue.d.ts +0 -6
  392. package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
  393. package/dist/core/tools/file-mutation-queue.js +0 -52
  394. package/dist/core/tools/file-mutation-queue.js.map +0 -1
  395. package/dist/core/tools/find.d.ts +0 -42
  396. package/dist/core/tools/find.d.ts.map +0 -1
  397. package/dist/core/tools/find.js +0 -251
  398. package/dist/core/tools/find.js.map +0 -1
  399. package/dist/core/tools/grep.d.ts +0 -41
  400. package/dist/core/tools/grep.d.ts.map +0 -1
  401. package/dist/core/tools/grep.js +0 -252
  402. package/dist/core/tools/grep.js.map +0 -1
  403. package/dist/core/tools/index.d.ts +0 -43
  404. package/dist/core/tools/index.d.ts.map +0 -1
  405. package/dist/core/tools/index.js +0 -129
  406. package/dist/core/tools/index.js.map +0 -1
  407. package/dist/core/tools/ls.d.ts +0 -41
  408. package/dist/core/tools/ls.d.ts.map +0 -1
  409. package/dist/core/tools/ls.js +0 -126
  410. package/dist/core/tools/ls.js.map +0 -1
  411. package/dist/core/tools/output-accumulator.d.ts +0 -63
  412. package/dist/core/tools/output-accumulator.d.ts.map +0 -1
  413. package/dist/core/tools/output-accumulator.js +0 -220
  414. package/dist/core/tools/output-accumulator.js.map +0 -1
  415. package/dist/core/tools/path-utils.d.ts +0 -10
  416. package/dist/core/tools/path-utils.d.ts.map +0 -1
  417. package/dist/core/tools/path-utils.js +0 -99
  418. package/dist/core/tools/path-utils.js.map +0 -1
  419. package/dist/core/tools/powershell.d.ts +0 -16
  420. package/dist/core/tools/powershell.d.ts.map +0 -1
  421. package/dist/core/tools/powershell.js +0 -39
  422. package/dist/core/tools/powershell.js.map +0 -1
  423. package/dist/core/tools/read.d.ts +0 -42
  424. package/dist/core/tools/read.d.ts.map +0 -1
  425. package/dist/core/tools/read.js +0 -169
  426. package/dist/core/tools/read.js.map +0 -1
  427. package/dist/core/tools/render-utils.d.ts +0 -30
  428. package/dist/core/tools/render-utils.d.ts.map +0 -1
  429. package/dist/core/tools/render-utils.js +0 -91
  430. package/dist/core/tools/render-utils.js.map +0 -1
  431. package/dist/core/tools/renderers/bash.d.ts +0 -12
  432. package/dist/core/tools/renderers/bash.d.ts.map +0 -1
  433. package/dist/core/tools/renderers/bash.js +0 -117
  434. package/dist/core/tools/renderers/bash.js.map +0 -1
  435. package/dist/core/tools/renderers/edit.d.ts +0 -23
  436. package/dist/core/tools/renderers/edit.d.ts.map +0 -1
  437. package/dist/core/tools/renderers/edit.js +0 -168
  438. package/dist/core/tools/renderers/edit.js.map +0 -1
  439. package/dist/core/tools/renderers/find.d.ts +0 -10
  440. package/dist/core/tools/renderers/find.d.ts.map +0 -1
  441. package/dist/core/tools/renderers/find.js +0 -64
  442. package/dist/core/tools/renderers/find.js.map +0 -1
  443. package/dist/core/tools/renderers/grep.d.ts +0 -10
  444. package/dist/core/tools/renderers/grep.d.ts.map +0 -1
  445. package/dist/core/tools/renderers/grep.js +0 -69
  446. package/dist/core/tools/renderers/grep.js.map +0 -1
  447. package/dist/core/tools/renderers/index.d.ts +0 -28
  448. package/dist/core/tools/renderers/index.d.ts.map +0 -1
  449. package/dist/core/tools/renderers/index.js +0 -47
  450. package/dist/core/tools/renderers/index.js.map +0 -1
  451. package/dist/core/tools/renderers/ls.d.ts +0 -10
  452. package/dist/core/tools/renderers/ls.d.ts.map +0 -1
  453. package/dist/core/tools/renderers/ls.js +0 -58
  454. package/dist/core/tools/renderers/ls.js.map +0 -1
  455. package/dist/core/tools/renderers/read.d.ts +0 -11
  456. package/dist/core/tools/renderers/read.d.ts.map +0 -1
  457. package/dist/core/tools/renderers/read.js +0 -130
  458. package/dist/core/tools/renderers/read.js.map +0 -1
  459. package/dist/core/tools/renderers/write.d.ts +0 -10
  460. package/dist/core/tools/renderers/write.d.ts.map +0 -1
  461. package/dist/core/tools/renderers/write.js +0 -153
  462. package/dist/core/tools/renderers/write.js.map +0 -1
  463. package/dist/core/tools/tool-definition-wrapper.d.ts +0 -16
  464. package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
  465. package/dist/core/tools/tool-definition-wrapper.js +0 -38
  466. package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
  467. package/dist/core/tools/truncate.d.ts +0 -84
  468. package/dist/core/tools/truncate.d.ts.map +0 -1
  469. package/dist/core/tools/truncate.js +0 -244
  470. package/dist/core/tools/truncate.js.map +0 -1
  471. package/dist/core/tools/write.d.ts +0 -30
  472. package/dist/core/tools/write.d.ts.map +0 -1
  473. package/dist/core/tools/write.js +0 -61
  474. package/dist/core/tools/write.js.map +0 -1
  475. package/dist/core/trust-manager.d.ts +0 -36
  476. package/dist/core/trust-manager.d.ts.map +0 -1
  477. package/dist/core/trust-manager.js +0 -203
  478. package/dist/core/trust-manager.js.map +0 -1
  479. package/dist/core/usage-totals.d.ts +0 -21
  480. package/dist/core/usage-totals.d.ts.map +0 -1
  481. package/dist/core/usage-totals.js +0 -79
  482. package/dist/core/usage-totals.js.map +0 -1
  483. package/dist/core/virtual-models.d.ts +0 -117
  484. package/dist/core/virtual-models.d.ts.map +0 -1
  485. package/dist/core/virtual-models.js +0 -124
  486. package/dist/core/virtual-models.js.map +0 -1
  487. package/dist/extensions/index.d.ts +0 -3
  488. package/dist/extensions/index.d.ts.map +0 -1
  489. package/dist/extensions/index.js +0 -3
  490. package/dist/extensions/index.js.map +0 -1
  491. package/dist/extensions/llama/client.d.ts +0 -69
  492. package/dist/extensions/llama/client.d.ts.map +0 -1
  493. package/dist/extensions/llama/client.js +0 -313
  494. package/dist/extensions/llama/client.js.map +0 -1
  495. package/dist/extensions/llama/huggingface.d.ts +0 -23
  496. package/dist/extensions/llama/huggingface.d.ts.map +0 -1
  497. package/dist/extensions/llama/huggingface.js +0 -141
  498. package/dist/extensions/llama/huggingface.js.map +0 -1
  499. package/dist/extensions/llama/index.d.ts +0 -3
  500. package/dist/extensions/llama/index.d.ts.map +0 -1
  501. package/dist/extensions/llama/index.js +0 -219
  502. package/dist/extensions/llama/index.js.map +0 -1
  503. package/dist/extensions/llama/provider.d.ts +0 -12
  504. package/dist/extensions/llama/provider.d.ts.map +0 -1
  505. package/dist/extensions/llama/provider.js +0 -213
  506. package/dist/extensions/llama/provider.js.map +0 -1
  507. package/dist/extensions/llama/ui.d.ts +0 -42
  508. package/dist/extensions/llama/ui.d.ts.map +0 -1
  509. package/dist/extensions/llama/ui.js +0 -416
  510. package/dist/extensions/llama/ui.js.map +0 -1
  511. package/dist/index.d.ts +0 -38
  512. package/dist/index.d.ts.map +0 -1
  513. package/dist/index.js +0 -49
  514. package/dist/index.js.map +0 -1
  515. package/dist/main.d.ts +0 -16
  516. package/dist/main.d.ts.map +0 -1
  517. package/dist/main.js +0 -819
  518. package/dist/main.js.map +0 -1
  519. package/dist/migrations.d.ts +0 -33
  520. package/dist/migrations.d.ts.map +0 -1
  521. package/dist/migrations.js +0 -282
  522. package/dist/migrations.js.map +0 -1
  523. package/dist/modes/index.d.ts +0 -10
  524. package/dist/modes/index.d.ts.map +0 -1
  525. package/dist/modes/index.js +0 -8
  526. package/dist/modes/index.js.map +0 -1
  527. package/dist/modes/interactive/bug-report.d.ts +0 -16
  528. package/dist/modes/interactive/bug-report.d.ts.map +0 -1
  529. package/dist/modes/interactive/bug-report.js +0 -210
  530. package/dist/modes/interactive/bug-report.js.map +0 -1
  531. package/dist/modes/interactive/chat-viewport.d.ts +0 -20
  532. package/dist/modes/interactive/chat-viewport.d.ts.map +0 -1
  533. package/dist/modes/interactive/chat-viewport.js +0 -28
  534. package/dist/modes/interactive/chat-viewport.js.map +0 -1
  535. package/dist/modes/interactive/components/armin.d.ts +0 -37
  536. package/dist/modes/interactive/components/armin.d.ts.map +0 -1
  537. package/dist/modes/interactive/components/armin.js +0 -335
  538. package/dist/modes/interactive/components/armin.js.map +0 -1
  539. package/dist/modes/interactive/components/assistant-message.d.ts +0 -26
  540. package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
  541. package/dist/modes/interactive/components/assistant-message.js +0 -158
  542. package/dist/modes/interactive/components/assistant-message.js.map +0 -1
  543. package/dist/modes/interactive/components/bash-execution.d.ts +0 -38
  544. package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
  545. package/dist/modes/interactive/components/bash-execution.js +0 -178
  546. package/dist/modes/interactive/components/bash-execution.js.map +0 -1
  547. package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
  548. package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
  549. package/dist/modes/interactive/components/bordered-loader.js +0 -54
  550. package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
  551. package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -17
  552. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
  553. package/dist/modes/interactive/components/branch-summary-message.js +0 -54
  554. package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
  555. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -17
  556. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  557. package/dist/modes/interactive/components/compaction-summary-message.js +0 -55
  558. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
  559. package/dist/modes/interactive/components/config-selector.d.ts +0 -102
  560. package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
  561. package/dist/modes/interactive/components/config-selector.js +0 -771
  562. package/dist/modes/interactive/components/config-selector.js.map +0 -1
  563. package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
  564. package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
  565. package/dist/modes/interactive/components/countdown-timer.js +0 -33
  566. package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
  567. package/dist/modes/interactive/components/custom-editor.d.ts +0 -30
  568. package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
  569. package/dist/modes/interactive/components/custom-editor.js +0 -115
  570. package/dist/modes/interactive/components/custom-editor.js.map +0 -1
  571. package/dist/modes/interactive/components/custom-entry.d.ts +0 -21
  572. package/dist/modes/interactive/components/custom-entry.d.ts.map +0 -1
  573. package/dist/modes/interactive/components/custom-entry.js +0 -58
  574. package/dist/modes/interactive/components/custom-entry.js.map +0 -1
  575. package/dist/modes/interactive/components/custom-message.d.ts +0 -22
  576. package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
  577. package/dist/modes/interactive/components/custom-message.js +0 -88
  578. package/dist/modes/interactive/components/custom-message.js.map +0 -1
  579. package/dist/modes/interactive/components/diff.d.ts +0 -12
  580. package/dist/modes/interactive/components/diff.d.ts.map +0 -1
  581. package/dist/modes/interactive/components/diff.js +0 -133
  582. package/dist/modes/interactive/components/diff.js.map +0 -1
  583. package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
  584. package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
  585. package/dist/modes/interactive/components/dynamic-border.js +0 -21
  586. package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
  587. package/dist/modes/interactive/components/e-logo.d.ts +0 -16
  588. package/dist/modes/interactive/components/e-logo.d.ts.map +0 -1
  589. package/dist/modes/interactive/components/e-logo.js +0 -29
  590. package/dist/modes/interactive/components/e-logo.js.map +0 -1
  591. package/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
  592. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +0 -1
  593. package/dist/modes/interactive/components/earendil-announcement.js +0 -40
  594. package/dist/modes/interactive/components/earendil-announcement.js.map +0 -1
  595. package/dist/modes/interactive/components/easter-egg-3d.d.ts +0 -104
  596. package/dist/modes/interactive/components/easter-egg-3d.d.ts.map +0 -1
  597. package/dist/modes/interactive/components/easter-egg-3d.js +0 -1138
  598. package/dist/modes/interactive/components/easter-egg-3d.js.map +0 -1
  599. package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts +0 -6
  600. package/dist/modes/interactive/components/easter-egg-3d.lazy.d.ts.map +0 -1
  601. package/dist/modes/interactive/components/easter-egg-3d.lazy.js +0 -23
  602. package/dist/modes/interactive/components/easter-egg-3d.lazy.js.map +0 -1
  603. package/dist/modes/interactive/components/extension-editor.d.ts +0 -24
  604. package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
  605. package/dist/modes/interactive/components/extension-editor.js +0 -103
  606. package/dist/modes/interactive/components/extension-editor.js.map +0 -1
  607. package/dist/modes/interactive/components/extension-input.d.ts +0 -25
  608. package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
  609. package/dist/modes/interactive/components/extension-input.js +0 -67
  610. package/dist/modes/interactive/components/extension-input.js.map +0 -1
  611. package/dist/modes/interactive/components/extension-selector.d.ts +0 -27
  612. package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
  613. package/dist/modes/interactive/components/extension-selector.js +0 -87
  614. package/dist/modes/interactive/components/extension-selector.js.map +0 -1
  615. package/dist/modes/interactive/components/first-time-setup.d.ts +0 -25
  616. package/dist/modes/interactive/components/first-time-setup.d.ts.map +0 -1
  617. package/dist/modes/interactive/components/first-time-setup.js +0 -109
  618. package/dist/modes/interactive/components/first-time-setup.js.map +0 -1
  619. package/dist/modes/interactive/components/footer.d.ts +0 -39
  620. package/dist/modes/interactive/components/footer.d.ts.map +0 -1
  621. package/dist/modes/interactive/components/footer.js +0 -265
  622. package/dist/modes/interactive/components/footer.js.map +0 -1
  623. package/dist/modes/interactive/components/index.d.ts +0 -33
  624. package/dist/modes/interactive/components/index.d.ts.map +0 -1
  625. package/dist/modes/interactive/components/index.js +0 -34
  626. package/dist/modes/interactive/components/index.js.map +0 -1
  627. package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -13
  628. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
  629. package/dist/modes/interactive/components/keybinding-hints.js +0 -36
  630. package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
  631. package/dist/modes/interactive/components/login-dialog.d.ts +0 -52
  632. package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
  633. package/dist/modes/interactive/components/login-dialog.js +0 -188
  634. package/dist/modes/interactive/components/login-dialog.js.map +0 -1
  635. package/dist/modes/interactive/components/markdown-transform.d.ts +0 -3
  636. package/dist/modes/interactive/components/markdown-transform.d.ts.map +0 -1
  637. package/dist/modes/interactive/components/markdown-transform.js +0 -19
  638. package/dist/modes/interactive/components/markdown-transform.js.map +0 -1
  639. package/dist/modes/interactive/components/mermaid.d.ts +0 -11
  640. package/dist/modes/interactive/components/mermaid.d.ts.map +0 -1
  641. package/dist/modes/interactive/components/mermaid.js +0 -75
  642. package/dist/modes/interactive/components/mermaid.js.map +0 -1
  643. package/dist/modes/interactive/components/model-selector.d.ts +0 -60
  644. package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
  645. package/dist/modes/interactive/components/model-selector.js +0 -361
  646. package/dist/modes/interactive/components/model-selector.js.map +0 -1
  647. package/dist/modes/interactive/components/oauth-selector.d.ts +0 -33
  648. package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
  649. package/dist/modes/interactive/components/oauth-selector.js +0 -163
  650. package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
  651. package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -46
  652. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
  653. package/dist/modes/interactive/components/scoped-models-selector.js +0 -326
  654. package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
  655. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
  656. package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
  657. package/dist/modes/interactive/components/session-selector-search.js +0 -155
  658. package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
  659. package/dist/modes/interactive/components/session-selector.d.ts +0 -95
  660. package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
  661. package/dist/modes/interactive/components/session-selector.js +0 -893
  662. package/dist/modes/interactive/components/session-selector.js.map +0 -1
  663. package/dist/modes/interactive/components/settings-selector.d.ts +0 -96
  664. package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
  665. package/dist/modes/interactive/components/settings-selector.js +0 -742
  666. package/dist/modes/interactive/components/settings-selector.js.map +0 -1
  667. package/dist/modes/interactive/components/settings-submenu.d.ts +0 -72
  668. package/dist/modes/interactive/components/settings-submenu.d.ts.map +0 -1
  669. package/dist/modes/interactive/components/settings-submenu.js +0 -165
  670. package/dist/modes/interactive/components/settings-submenu.js.map +0 -1
  671. package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
  672. package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
  673. package/dist/modes/interactive/components/show-images-selector.js +0 -39
  674. package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
  675. package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -18
  676. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
  677. package/dist/modes/interactive/components/skill-invocation-message.js +0 -57
  678. package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
  679. package/dist/modes/interactive/components/status-indicator.d.ts +0 -30
  680. package/dist/modes/interactive/components/status-indicator.d.ts.map +0 -1
  681. package/dist/modes/interactive/components/status-indicator.js +0 -67
  682. package/dist/modes/interactive/components/status-indicator.js.map +0 -1
  683. package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
  684. package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
  685. package/dist/modes/interactive/components/theme-selector.js +0 -50
  686. package/dist/modes/interactive/components/theme-selector.js.map +0 -1
  687. package/dist/modes/interactive/components/themed-text.d.ts +0 -17
  688. package/dist/modes/interactive/components/themed-text.d.ts.map +0 -1
  689. package/dist/modes/interactive/components/themed-text.js +0 -29
  690. package/dist/modes/interactive/components/themed-text.js.map +0 -1
  691. package/dist/modes/interactive/components/thinking-selector.d.ts +0 -23
  692. package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
  693. package/dist/modes/interactive/components/thinking-selector.js +0 -109
  694. package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
  695. package/dist/modes/interactive/components/tool-execution.d.ts +0 -83
  696. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  697. package/dist/modes/interactive/components/tool-execution.js +0 -323
  698. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  699. package/dist/modes/interactive/components/tree-selector.d.ts +0 -94
  700. package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
  701. package/dist/modes/interactive/components/tree-selector.js +0 -1254
  702. package/dist/modes/interactive/components/tree-selector.js.map +0 -1
  703. package/dist/modes/interactive/components/trust-selector.d.ts +0 -23
  704. package/dist/modes/interactive/components/trust-selector.d.ts.map +0 -1
  705. package/dist/modes/interactive/components/trust-selector.js +0 -91
  706. package/dist/modes/interactive/components/trust-selector.js.map +0 -1
  707. package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
  708. package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
  709. package/dist/modes/interactive/components/user-message-selector.js +0 -114
  710. package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
  711. package/dist/modes/interactive/components/user-message.d.ts +0 -16
  712. package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
  713. package/dist/modes/interactive/components/user-message.js +0 -50
  714. package/dist/modes/interactive/components/user-message.js.map +0 -1
  715. package/dist/modes/interactive/components/visual-truncate.d.ts +0 -48
  716. package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
  717. package/dist/modes/interactive/components/visual-truncate.js +0 -66
  718. package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
  719. package/dist/modes/interactive/external-editor.d.ts +0 -12
  720. package/dist/modes/interactive/external-editor.d.ts.map +0 -1
  721. package/dist/modes/interactive/external-editor.js +0 -38
  722. package/dist/modes/interactive/external-editor.js.map +0 -1
  723. package/dist/modes/interactive/interactive-mode.d.ts +0 -470
  724. package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
  725. package/dist/modes/interactive/interactive-mode.js +0 -5795
  726. package/dist/modes/interactive/interactive-mode.js.map +0 -1
  727. package/dist/modes/interactive/model-catalog-refresh.d.ts +0 -7
  728. package/dist/modes/interactive/model-catalog-refresh.d.ts.map +0 -1
  729. package/dist/modes/interactive/model-catalog-refresh.js +0 -34
  730. package/dist/modes/interactive/model-catalog-refresh.js.map +0 -1
  731. package/dist/modes/interactive/model-search.d.ts +0 -12
  732. package/dist/modes/interactive/model-search.d.ts.map +0 -1
  733. package/dist/modes/interactive/model-search.js +0 -15
  734. package/dist/modes/interactive/model-search.js.map +0 -1
  735. package/dist/modes/interactive/session-share.d.ts +0 -18
  736. package/dist/modes/interactive/session-share.d.ts.map +0 -1
  737. package/dist/modes/interactive/session-share.js +0 -188
  738. package/dist/modes/interactive/session-share.js.map +0 -1
  739. package/dist/modes/interactive/theme/system-theme.d.ts +0 -55
  740. package/dist/modes/interactive/theme/system-theme.d.ts.map +0 -1
  741. package/dist/modes/interactive/theme/system-theme.js +0 -546
  742. package/dist/modes/interactive/theme/system-theme.js.map +0 -1
  743. package/dist/modes/interactive/theme/theme-controller.d.ts +0 -81
  744. package/dist/modes/interactive/theme/theme-controller.d.ts.map +0 -1
  745. package/dist/modes/interactive/theme/theme-controller.js +0 -210
  746. package/dist/modes/interactive/theme/theme-controller.js.map +0 -1
  747. package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
  748. package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
  749. package/dist/modes/interactive/theme/theme-json.js +0 -132
  750. package/dist/modes/interactive/theme/theme-json.js.map +0 -1
  751. package/dist/modes/interactive/theme/theme.d.ts +0 -158
  752. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  753. package/dist/modes/interactive/theme/theme.js +0 -913
  754. package/dist/modes/interactive/theme/theme.js.map +0 -1
  755. package/dist/modes/interactive/tui-renderer.d.ts +0 -22
  756. package/dist/modes/interactive/tui-renderer.d.ts.map +0 -1
  757. package/dist/modes/interactive/tui-renderer.js +0 -67
  758. package/dist/modes/interactive/tui-renderer.js.map +0 -1
  759. package/dist/modes/json-event.d.ts +0 -34
  760. package/dist/modes/json-event.d.ts.map +0 -1
  761. package/dist/modes/json-event.js +0 -29
  762. package/dist/modes/json-event.js.map +0 -1
  763. package/dist/modes/print-mode.d.ts +0 -28
  764. package/dist/modes/print-mode.d.ts.map +0 -1
  765. package/dist/modes/print-mode.js +0 -142
  766. package/dist/modes/print-mode.js.map +0 -1
  767. package/dist/modes/rpc/jsonl.d.ts +0 -17
  768. package/dist/modes/rpc/jsonl.d.ts.map +0 -1
  769. package/dist/modes/rpc/jsonl.js +0 -49
  770. package/dist/modes/rpc/jsonl.js.map +0 -1
  771. package/dist/modes/rpc/rpc-client.d.ts +0 -254
  772. package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
  773. package/dist/modes/rpc/rpc-client.js +0 -499
  774. package/dist/modes/rpc/rpc-client.js.map +0 -1
  775. package/dist/modes/rpc/rpc-mode.d.ts +0 -20
  776. package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
  777. package/dist/modes/rpc/rpc-mode.js +0 -655
  778. package/dist/modes/rpc/rpc-mode.js.map +0 -1
  779. package/dist/modes/rpc/rpc-types.d.ts +0 -478
  780. package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
  781. package/dist/modes/rpc/rpc-types.js +0 -8
  782. package/dist/modes/rpc/rpc-types.js.map +0 -1
  783. package/dist/package-manager-cli.d.ts +0 -9
  784. package/dist/package-manager-cli.d.ts.map +0 -1
  785. package/dist/package-manager-cli.js +0 -1000
  786. package/dist/package-manager-cli.js.map +0 -1
  787. package/dist/rpc-entry.d.ts +0 -3
  788. package/dist/rpc-entry.d.ts.map +0 -1
  789. package/dist/rpc-entry.js +0 -11
  790. package/dist/rpc-entry.js.map +0 -1
  791. package/dist/utils/abort.d.ts +0 -5
  792. package/dist/utils/abort.d.ts.map +0 -1
  793. package/dist/utils/abort.js +0 -48
  794. package/dist/utils/abort.js.map +0 -1
  795. package/dist/utils/ansi.d.ts +0 -10
  796. package/dist/utils/ansi.d.ts.map +0 -1
  797. package/dist/utils/ansi.js +0 -71
  798. package/dist/utils/ansi.js.map +0 -1
  799. package/dist/utils/changelog.d.ts +0 -22
  800. package/dist/utils/changelog.d.ts.map +0 -1
  801. package/dist/utils/changelog.js +0 -165
  802. package/dist/utils/changelog.js.map +0 -1
  803. package/dist/utils/child-process.d.ts +0 -18
  804. package/dist/utils/child-process.d.ts.map +0 -1
  805. package/dist/utils/child-process.js +0 -106
  806. package/dist/utils/child-process.js.map +0 -1
  807. package/dist/utils/clipboard-command.d.ts +0 -7
  808. package/dist/utils/clipboard-command.d.ts.map +0 -1
  809. package/dist/utils/clipboard-command.js +0 -45
  810. package/dist/utils/clipboard-command.js.map +0 -1
  811. package/dist/utils/clipboard-image.d.ts +0 -11
  812. package/dist/utils/clipboard-image.d.ts.map +0 -1
  813. package/dist/utils/clipboard-image.js +0 -214
  814. package/dist/utils/clipboard-image.js.map +0 -1
  815. package/dist/utils/clipboard.d.ts +0 -6
  816. package/dist/utils/clipboard.d.ts.map +0 -1
  817. package/dist/utils/clipboard.js +0 -157
  818. package/dist/utils/clipboard.js.map +0 -1
  819. package/dist/utils/deprecation.d.ts +0 -4
  820. package/dist/utils/deprecation.d.ts.map +0 -1
  821. package/dist/utils/deprecation.js +0 -13
  822. package/dist/utils/deprecation.js.map +0 -1
  823. package/dist/utils/exif-orientation.d.ts +0 -5
  824. package/dist/utils/exif-orientation.d.ts.map +0 -1
  825. package/dist/utils/exif-orientation.js +0 -157
  826. package/dist/utils/exif-orientation.js.map +0 -1
  827. package/dist/utils/frontmatter.d.ts +0 -8
  828. package/dist/utils/frontmatter.d.ts.map +0 -1
  829. package/dist/utils/frontmatter.js +0 -27
  830. package/dist/utils/frontmatter.js.map +0 -1
  831. package/dist/utils/fs-watch.d.ts +0 -5
  832. package/dist/utils/fs-watch.d.ts.map +0 -1
  833. package/dist/utils/fs-watch.js +0 -25
  834. package/dist/utils/fs-watch.js.map +0 -1
  835. package/dist/utils/git.d.ts +0 -26
  836. package/dist/utils/git.d.ts.map +0 -1
  837. package/dist/utils/git.js +0 -195
  838. package/dist/utils/git.js.map +0 -1
  839. package/dist/utils/html.d.ts +0 -7
  840. package/dist/utils/html.d.ts.map +0 -1
  841. package/dist/utils/html.js +0 -40
  842. package/dist/utils/html.js.map +0 -1
  843. package/dist/utils/image-convert.d.ts +0 -22
  844. package/dist/utils/image-convert.d.ts.map +0 -1
  845. package/dist/utils/image-convert.js +0 -84
  846. package/dist/utils/image-convert.js.map +0 -1
  847. package/dist/utils/image-process.d.ts +0 -18
  848. package/dist/utils/image-process.d.ts.map +0 -1
  849. package/dist/utils/image-process.js +0 -83
  850. package/dist/utils/image-process.js.map +0 -1
  851. package/dist/utils/image-resize-core.d.ts +0 -42
  852. package/dist/utils/image-resize-core.d.ts.map +0 -1
  853. package/dist/utils/image-resize-core.js +0 -129
  854. package/dist/utils/image-resize-core.js.map +0 -1
  855. package/dist/utils/image-resize-worker.d.ts +0 -2
  856. package/dist/utils/image-resize-worker.d.ts.map +0 -1
  857. package/dist/utils/image-resize-worker.js +0 -32
  858. package/dist/utils/image-resize-worker.js.map +0 -1
  859. package/dist/utils/image-resize.d.ts +0 -16
  860. package/dist/utils/image-resize.d.ts.map +0 -1
  861. package/dist/utils/image-resize.js +0 -96
  862. package/dist/utils/image-resize.js.map +0 -1
  863. package/dist/utils/json.d.ts +0 -3
  864. package/dist/utils/json.d.ts.map +0 -1
  865. package/dist/utils/json.js +0 -7
  866. package/dist/utils/json.js.map +0 -1
  867. package/dist/utils/management-http.d.ts +0 -25
  868. package/dist/utils/management-http.d.ts.map +0 -1
  869. package/dist/utils/management-http.js +0 -54
  870. package/dist/utils/management-http.js.map +0 -1
  871. package/dist/utils/mime.d.ts +0 -3
  872. package/dist/utils/mime.d.ts.map +0 -1
  873. package/dist/utils/mime.js +0 -110
  874. package/dist/utils/mime.js.map +0 -1
  875. package/dist/utils/open-browser.d.ts +0 -9
  876. package/dist/utils/open-browser.d.ts.map +0 -1
  877. package/dist/utils/open-browser.js +0 -22
  878. package/dist/utils/open-browser.js.map +0 -1
  879. package/dist/utils/paths.d.ts +0 -34
  880. package/dist/utils/paths.d.ts.map +0 -1
  881. package/dist/utils/paths.js +0 -115
  882. package/dist/utils/paths.js.map +0 -1
  883. package/dist/utils/photon.d.ts +0 -21
  884. package/dist/utils/photon.d.ts.map +0 -1
  885. package/dist/utils/photon.js +0 -121
  886. package/dist/utils/photon.js.map +0 -1
  887. package/dist/utils/pi-user-agent.d.ts +0 -2
  888. package/dist/utils/pi-user-agent.d.ts.map +0 -1
  889. package/dist/utils/pi-user-agent.js +0 -5
  890. package/dist/utils/pi-user-agent.js.map +0 -1
  891. package/dist/utils/shell.d.ts +0 -32
  892. package/dist/utils/shell.d.ts.map +0 -1
  893. package/dist/utils/shell.js +0 -189
  894. package/dist/utils/shell.js.map +0 -1
  895. package/dist/utils/sleep.d.ts +0 -5
  896. package/dist/utils/sleep.d.ts.map +0 -1
  897. package/dist/utils/sleep.js +0 -17
  898. package/dist/utils/sleep.js.map +0 -1
  899. package/dist/utils/syntax-highlight.d.ts +0 -13
  900. package/dist/utils/syntax-highlight.d.ts.map +0 -1
  901. package/dist/utils/syntax-highlight.js +0 -184
  902. package/dist/utils/syntax-highlight.js.map +0 -1
  903. package/dist/utils/text.d.ts +0 -8
  904. package/dist/utils/text.d.ts.map +0 -1
  905. package/dist/utils/text.js +0 -9
  906. package/dist/utils/text.js.map +0 -1
  907. package/dist/utils/tool-result-images.d.ts +0 -21
  908. package/dist/utils/tool-result-images.d.ts.map +0 -1
  909. package/dist/utils/tool-result-images.js +0 -48
  910. package/dist/utils/tool-result-images.js.map +0 -1
  911. package/dist/utils/tools-manager.d.ts +0 -13
  912. package/dist/utils/tools-manager.d.ts.map +0 -1
  913. package/dist/utils/tools-manager.js +0 -343
  914. package/dist/utils/tools-manager.js.map +0 -1
  915. package/dist/utils/version-check.d.ts +0 -19
  916. package/dist/utils/version-check.d.ts.map +0 -1
  917. package/dist/utils/version-check.js +0 -72
  918. package/dist/utils/version-check.js.map +0 -1
  919. package/dist/utils/windows-self-update.d.ts +0 -3
  920. package/dist/utils/windows-self-update.d.ts.map +0 -1
  921. package/dist/utils/windows-self-update.js +0 -77
  922. package/dist/utils/windows-self-update.js.map +0 -1
  923. package/dist/utils/wsl.d.ts +0 -3
  924. package/dist/utils/wsl.d.ts.map +0 -1
  925. package/dist/utils/wsl.js +0 -15
  926. package/dist/utils/wsl.js.map +0 -1
  927. package/dist/utils/zip.d.ts +0 -7
  928. package/dist/utils/zip.d.ts.map +0 -1
  929. package/dist/utils/zip.js +0 -60
  930. package/dist/utils/zip.js.map +0 -1
@@ -1,147 +0,0 @@
1
- import { constants } from "fs";
2
- import { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
3
- import { Type } from "typebox";
4
- import { splitBom } from "../../utils/text.js";
5
- import { applyEditsToNormalizedContent, detectLineEnding, generateDiffString, generateUnifiedPatch, normalizeToLF, restoreLineEndings, } from "./edit-diff.js";
6
- import { withFileMutationQueue } from "./file-mutation-queue.js";
7
- import { resolveToCwd } from "./path-utils.js";
8
- import { editRenderers } from "./renderers/edit.js";
9
- import { wrapToolDefinition } from "./tool-definition-wrapper.js";
10
- const replaceEditSchema = Type.Object({
11
- oldText: Type.String({
12
- description: "Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.",
13
- }),
14
- newText: Type.String({ description: "Replacement text for this targeted edit." }),
15
- }, {});
16
- const editSchema = Type.Object({
17
- path: Type.String({ description: "Path to the file to edit (relative or absolute)" }),
18
- edits: Type.Array(replaceEditSchema, {
19
- description: "One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.",
20
- }),
21
- }, {});
22
- export const editToolSystemPromptContribution = {
23
- snippet: "Make precise file edits with exact text replacement, including multiple disjoint edits in one call",
24
- guidelines: [
25
- "Use edit for precise changes (edits[].oldText must match exactly)",
26
- "When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls",
27
- "Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit.",
28
- "Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions.",
29
- ],
30
- };
31
- function isSingleEditInput(value) {
32
- if (!value || typeof value !== "object" || Array.isArray(value)) {
33
- return false;
34
- }
35
- const edit = value;
36
- return typeof edit.oldText === "string" && typeof edit.newText === "string";
37
- }
38
- const defaultEditOperations = {
39
- readFile: (path) => fsReadFile(path),
40
- writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
41
- access: (path) => fsAccess(path, constants.R_OK | constants.W_OK),
42
- };
43
- function prepareEditArguments(input) {
44
- if (!input || typeof input !== "object") {
45
- return input;
46
- }
47
- const args = input;
48
- // Some models (Opus 4.6, GLM-5.1) send edits as a JSON string instead of an array.
49
- // Others send a single edit object instead of a one-element edits array.
50
- if (typeof args.edits === "string") {
51
- try {
52
- const parsed = JSON.parse(args.edits);
53
- if (Array.isArray(parsed)) {
54
- args.edits = parsed;
55
- }
56
- else if (isSingleEditInput(parsed)) {
57
- args.edits = [parsed];
58
- }
59
- }
60
- catch { }
61
- }
62
- else if (isSingleEditInput(args.edits)) {
63
- args.edits = [args.edits];
64
- }
65
- const legacy = args;
66
- if (typeof legacy.oldText !== "string" || typeof legacy.newText !== "string") {
67
- return args;
68
- }
69
- const edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];
70
- edits.push({ oldText: legacy.oldText, newText: legacy.newText });
71
- const { oldText: _oldText, newText: _newText, ...rest } = legacy;
72
- return { ...rest, edits };
73
- }
74
- function validateEditInput(input) {
75
- if (!Array.isArray(input.edits) || input.edits.length === 0) {
76
- throw new Error("Edit tool input is invalid. edits must contain at least one replacement.");
77
- }
78
- return { path: input.path, edits: input.edits };
79
- }
80
- export function createEditToolDefinition(cwd, options) {
81
- const ops = options?.operations ?? defaultEditOperations;
82
- return {
83
- name: "edit",
84
- label: "edit",
85
- description: "Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.",
86
- promptSnippet: editToolSystemPromptContribution.snippet,
87
- promptGuidelines: [...editToolSystemPromptContribution.guidelines],
88
- parameters: editSchema,
89
- constrainedSampling: { type: "json_schema", strict: "prefer" },
90
- renderShell: "self",
91
- prepareArguments: prepareEditArguments,
92
- async execute(_toolCallId, input, signal, _onUpdate, ctx) {
93
- const { path, edits } = validateEditInput(input);
94
- const absolutePath = resolveToCwd(path, ctx?.cwd || cwd);
95
- return withFileMutationQueue(absolutePath, async () => {
96
- // Do not reject from an abort event listener here: that would release the
97
- // mutation queue while an in-flight filesystem operation may still finish.
98
- // Checking signal.aborted after each await observes the same aborts while
99
- // keeping the queue locked until the current operation has settled.
100
- const throwIfAborted = () => {
101
- if (signal?.aborted)
102
- throw new Error("Operation aborted");
103
- };
104
- throwIfAborted();
105
- // Check if file exists.
106
- try {
107
- await ops.access(absolutePath);
108
- }
109
- catch (error) {
110
- throwIfAborted();
111
- const errorMessage = error instanceof Error && "code" in error ? `Error code: ${error.code}` : String(error);
112
- throw new Error(`Could not edit file: ${path}. ${errorMessage}.`);
113
- }
114
- throwIfAborted();
115
- // Read the file.
116
- const buffer = await ops.readFile(absolutePath);
117
- const rawContent = buffer.toString("utf-8");
118
- throwIfAborted();
119
- // Strip BOM before matching. The model will not include an invisible BOM in oldText.
120
- const { bom, text: content } = splitBom(rawContent);
121
- const originalEnding = detectLineEnding(content);
122
- const normalizedContent = normalizeToLF(content);
123
- const { baseContent, newContent } = applyEditsToNormalizedContent(normalizedContent, edits, path);
124
- throwIfAborted();
125
- const finalContent = bom + restoreLineEndings(newContent, originalEnding);
126
- await ops.writeFile(absolutePath, finalContent);
127
- throwIfAborted();
128
- const diffResult = generateDiffString(baseContent, newContent);
129
- const patch = generateUnifiedPatch(path, baseContent, newContent);
130
- return {
131
- content: [
132
- {
133
- type: "text",
134
- text: `Successfully replaced ${edits.length} block(s) in ${path}.`,
135
- },
136
- ],
137
- details: { diff: diffResult.diff, patch, firstChangedLine: diffResult.firstChangedLine },
138
- };
139
- });
140
- },
141
- ...editRenderers,
142
- };
143
- }
144
- export function createEditTool(cwd, options) {
145
- return wrapToolDefinition(createEditToolDefinition(cwd, options));
146
- }
147
- //# sourceMappingURL=edit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EACN,6BAA6B,EAC7B,gBAAgB,EAEhB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,YAAY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AAU,CAAC,CAAC;gBACpD,MAAM,cAAc,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBACjD,MAAM,iBAAiB,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;gBACjD,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,6BAA6B,CAAC,iBAAiB,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;gBAClG,cAAc,EAAE,CAAC;gBAEjB,MAAM,YAAY,GAAG,GAAG,GAAG,kBAAkB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;gBAC1E,MAAM,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;gBAChD,cAAc,EAAE,CAAC;gBAEjB,MAAM,UAAU,GAAG,kBAAkB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;gBAC/D,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;gBAClE,OAAO;oBACN,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,yBAAyB,KAAK,CAAC,MAAM,gBAAgB,IAAI,GAAG;yBAClE;qBACD;oBACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE;iBACxF,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,aAAa;KAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { splitBom } from \"../../utils/text.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport {\n\tapplyEditsToNormalizedContent,\n\tdetectLineEnding,\n\ttype Edit,\n\tgenerateDiffString,\n\tgenerateUnifiedPatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n} from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { type EditRenderState, editRenderers } from \"./renderers/edit.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst replaceEditSchema = Type.Object(\n\t{\n\t\toldText: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.\",\n\t\t}),\n\t\tnewText: Type.String({ description: \"Replacement text for this targeted edit.\" }),\n\t},\n\t{},\n);\n\nconst editSchema = Type.Object(\n\t{\n\t\tpath: Type.String({ description: \"Path to the file to edit (relative or absolute)\" }),\n\t\tedits: Type.Array(replaceEditSchema, {\n\t\t\tdescription:\n\t\t\t\t\"One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.\",\n\t\t}),\n\t},\n\t{},\n);\n\nexport const editToolSystemPromptContribution = {\n\tsnippet: \"Make precise file edits with exact text replacement, including multiple disjoint edits in one call\",\n\tguidelines: [\n\t\t\"Use edit for precise changes (edits[].oldText must match exactly)\",\n\t\t\"When changing multiple separate locations in one file, use one edit call with multiple entries in edits[] instead of multiple edit calls\",\n\t\t\"Each edits[].oldText is matched against the original file, not after earlier edits are applied. Do not emit overlapping or nested edits. Merge nearby changes into one edit.\",\n\t\t\"Keep edits[].oldText as small as possible while still being unique in the file. Do not pad with large unchanged regions.\",\n\t],\n} as const;\n\nexport type EditToolInput = Static<typeof editSchema>;\ntype LegacyEditToolInput = EditToolInput & {\n\toldText?: unknown;\n\tnewText?: unknown;\n};\n\ntype SingleEditInput = { oldText: string; newText: string };\n\nfunction isSingleEditInput(value: unknown): value is SingleEditInput {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\treturn false;\n\t}\n\n\tconst edit = value as Record<string, unknown>;\n\treturn typeof edit.oldText === \"string\" && typeof edit.newText === \"string\";\n}\n\nexport interface EditToolDetails {\n\t/** Display-oriented diff of the changes made */\n\tdiff: string;\n\t/** Standard unified patch of the changes made */\n\tpatch: string;\n\t/** Line number of the first change in the new file (for editor navigation) */\n\tfirstChangedLine?: number;\n}\n\n/**\n * Pluggable operations for the edit tool.\n * Override these to delegate file editing to remote systems (for example SSH).\n */\nexport interface EditOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\t/** Check if file is readable and writable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\t/** Custom operations for file editing. Default: local filesystem */\n\toperations?: EditOperations;\n}\n\nfunction prepareEditArguments(input: unknown): EditToolInput {\n\tif (!input || typeof input !== \"object\") {\n\t\treturn input as EditToolInput;\n\t}\n\n\tconst args = input as Record<string, unknown>;\n\n\t// Some models (Opus 4.6, GLM-5.1) send edits as a JSON string instead of an array.\n\t// Others send a single edit object instead of a one-element edits array.\n\tif (typeof args.edits === \"string\") {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(args.edits);\n\t\t\tif (Array.isArray(parsed)) {\n\t\t\t\targs.edits = parsed;\n\t\t\t} else if (isSingleEditInput(parsed)) {\n\t\t\t\targs.edits = [parsed];\n\t\t\t}\n\t\t} catch {}\n\t} else if (isSingleEditInput(args.edits)) {\n\t\targs.edits = [args.edits];\n\t}\n\n\tconst legacy = args as LegacyEditToolInput;\n\tif (typeof legacy.oldText !== \"string\" || typeof legacy.newText !== \"string\") {\n\t\treturn args as EditToolInput;\n\t}\n\n\tconst edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];\n\tedits.push({ oldText: legacy.oldText, newText: legacy.newText });\n\tconst { oldText: _oldText, newText: _newText, ...rest } = legacy;\n\treturn { ...rest, edits } as EditToolInput;\n}\n\nfunction validateEditInput(input: EditToolInput): { path: string; edits: Edit[] } {\n\tif (!Array.isArray(input.edits) || input.edits.length === 0) {\n\t\tthrow new Error(\"Edit tool input is invalid. edits must contain at least one replacement.\");\n\t}\n\treturn { path: input.path, edits: input.edits };\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined, EditRenderState> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.\",\n\t\tpromptSnippet: editToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...editToolSystemPromptContribution.guidelines],\n\t\tparameters: editSchema,\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\trenderShell: \"self\",\n\t\tprepareArguments: prepareEditArguments,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tconst { path, edits } = validateEditInput(input);\n\t\t\tconst absolutePath = resolveToCwd(path, ctx?.cwd || cwd);\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Check if file exists.\n\t\t\t\ttry {\n\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tthrowIfAborted();\n\t\t\t\t\tconst errorMessage =\n\t\t\t\t\t\terror instanceof Error && \"code\" in error ? `Error code: ${error.code}` : String(error);\n\t\t\t\t\tthrow new Error(`Could not edit file: ${path}. ${errorMessage}.`);\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Read the file.\n\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\tconst rawContent = buffer.toString(\"utf-8\");\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\t// Strip BOM before matching. The model will not include an invisible BOM in oldText.\n\t\t\t\tconst { bom, text: content } = splitBom(rawContent);\n\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\tconst { baseContent, newContent } = applyEditsToNormalizedContent(normalizedContent, edits, path);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\tawait ops.writeFile(absolutePath, finalContent);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst diffResult = generateDiffString(baseContent, newContent);\n\t\t\t\tconst patch = generateUnifiedPatch(path, baseContent, newContent);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully replaced ${edits.length} block(s) in ${path}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { diff: diffResult.diff, patch, firstChangedLine: diffResult.firstChangedLine },\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t...editRenderers,\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
@@ -1,6 +0,0 @@
1
- /**
2
- * Serialize file mutation operations targeting the same file.
3
- * Operations for different files still run in parallel.
4
- */
5
- export declare function withFileMutationQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T>;
6
- //# sourceMappingURL=file-mutation-queue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BjG"}
@@ -1,52 +0,0 @@
1
- import { realpath } from "node:fs/promises";
2
- import { resolve } from "node:path";
3
- const fileMutationQueues = new Map();
4
- let registrationQueue = Promise.resolve();
5
- function isMissingPathError(error) {
6
- return (typeof error === "object" &&
7
- error !== null &&
8
- "code" in error &&
9
- (error.code === "ENOENT" || error.code === "ENOTDIR"));
10
- }
11
- async function getMutationQueueKey(filePath) {
12
- const resolvedPath = resolve(filePath);
13
- try {
14
- return await realpath(resolvedPath);
15
- }
16
- catch (error) {
17
- if (isMissingPathError(error)) {
18
- return resolvedPath;
19
- }
20
- throw error;
21
- }
22
- }
23
- /**
24
- * Serialize file mutation operations targeting the same file.
25
- * Operations for different files still run in parallel.
26
- */
27
- export async function withFileMutationQueue(filePath, fn) {
28
- const registration = registrationQueue.then(async () => {
29
- const key = await getMutationQueueKey(filePath);
30
- const currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();
31
- let releaseNext;
32
- const nextQueue = new Promise((resolveQueue) => {
33
- releaseNext = resolveQueue;
34
- });
35
- const chainedQueue = currentQueue.then(() => nextQueue);
36
- fileMutationQueues.set(key, chainedQueue);
37
- return { key, currentQueue, chainedQueue, releaseNext };
38
- });
39
- registrationQueue = registration.then(() => undefined, () => undefined);
40
- const { key, currentQueue, chainedQueue, releaseNext } = await registration;
41
- await currentQueue;
42
- try {
43
- return await fn();
44
- }
45
- finally {
46
- releaseNext();
47
- if (fileMutationQueues.get(key) === chainedQueue) {
48
- fileMutationQueues.delete(key);
49
- }
50
- }
51
- }
52
- //# sourceMappingURL=file-mutation-queue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-mutation-queue.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAC5D,IAAI,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAE1C,SAAS,kBAAkB,CAAC,KAAc;IACzC,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CACrD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,YAAY,CAAC;QACrB,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAED;;;GAGG;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ationQueues = new Map<string, Promise<void>>();\nlet registrationQueue = Promise.resolve();\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t\"code\" in error &&\n\t\t(error.code === \"ENOENT\" || error.code === \"ENOTDIR\")\n\t);\n}\n\nasync function getMutationQueueKey(filePath: string): Promise<string> {\n\tconst resolvedPath = resolve(filePath);\n\ttry {\n\t\treturn await realpath(resolvedPath);\n\t} catch (error) {\n\t\tif (isMissingPathError(error)) {\n\t\t\treturn resolvedPath;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\n/**\n * Serialize file mutation operations targeting the same file.\n * Operations for different files still run in parallel.\n */\nexport async function withFileMutationQueue<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n\tconst registration = registrationQueue.then(async () => {\n\t\tconst key = await getMutationQueueKey(filePath);\n\t\tconst currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();\n\n\t\tlet releaseNext!: () => void;\n\t\tconst nextQueue = new Promise<void>((resolveQueue) => {\n\t\t\treleaseNext = resolveQueue;\n\t\t});\n\t\tconst chainedQueue = currentQueue.then(() => nextQueue);\n\t\tfileMutationQueues.set(key, chainedQueue);\n\n\t\treturn { key, currentQueue, chainedQueue, releaseNext };\n\t});\n\tregistrationQueue = registration.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\n\tconst { key, currentQueue, chainedQueue, releaseNext } = await registration;\n\tawait currentQueue;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\treleaseNext();\n\t\tif (fileMutationQueues.get(key) === chainedQueue) {\n\t\t\tfileMutationQueues.delete(key);\n\t\t}\n\t}\n}\n"]}
@@ -1,42 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import path from "path";
3
- import { type Static, Type } from "typebox";
4
- import type { ToolDefinition } from "../extensions/types.ts";
5
- import { type TruncationResult } from "./truncate.ts";
6
- /** Relativize a find result against the search root and normalize it to posix separators. */
7
- export declare function relativizeFindResultPath(resultPath: string, searchPath: string, pathModule?: path.PlatformPath): string;
8
- declare const findSchema: Type.TObject<{
9
- pattern: Type.TString;
10
- path: Type.TOptional<Type.TString>;
11
- limit: Type.TOptional<Type.TNumber>;
12
- }>;
13
- export declare const findToolSystemPromptContribution: {
14
- readonly snippet: "Find files by glob pattern (respects .gitignore)";
15
- readonly guidelines: readonly [];
16
- };
17
- export type FindToolInput = Static<typeof findSchema>;
18
- export interface FindToolDetails {
19
- truncation?: TruncationResult;
20
- resultLimitReached?: number;
21
- }
22
- /**
23
- * Pluggable operations for the find tool.
24
- * Override these to delegate file search to remote systems (for example SSH).
25
- */
26
- export interface FindOperations {
27
- /** Check if path exists */
28
- exists: (absolutePath: string) => Promise<boolean> | boolean;
29
- /** Find files matching glob pattern. Returns relative or absolute paths. */
30
- glob: (pattern: string, cwd: string, options: {
31
- ignore: string[];
32
- limit: number;
33
- }) => Promise<string[]> | string[];
34
- }
35
- export interface FindToolOptions {
36
- /** Custom operations for find. Default: local filesystem plus fd */
37
- operations?: FindOperations;
38
- }
39
- export declare function createFindToolDefinition(cwd: string, options?: FindToolOptions): ToolDefinition<typeof findSchema, FindToolDetails | undefined>;
40
- export declare function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema>;
41
- export {};
42
- //# sourceMappingURL=find.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI/E,OAAO,EAAiC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEnG,6FAA6F;AAC7F,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,IAAI,CAAC,YAAmB,GAClC,MAAM,CAMR;AAED,QAAA,MAAM,UAAU;;;;EAMd,CAAC;AAEH,eAAO,MAAM,gCAAgC;aAC5C,OAAO,EAAE,kDAAkD;aAC3D,UAAU;CACD,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAItD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,2BAA2B;IAC3B,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC7D,4EAA4E;IAC5E,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CACnH;AAQD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CAiPhE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -1,251 +0,0 @@
1
- import { createInterface } from "node:readline";
2
- import { spawn } from "child_process";
3
- import path from "path";
4
- import { Type } from "typebox";
5
- import { ensureTool } from "../../utils/tools-manager.js";
6
- import { pathExists, resolveToCwd } from "./path-utils.js";
7
- import { findRenderers } from "./renderers/find.js";
8
- import { wrapToolDefinition } from "./tool-definition-wrapper.js";
9
- import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
10
- /** Relativize a find result against the search root and normalize it to posix separators. */
11
- export function relativizeFindResultPath(resultPath, searchPath, pathModule = path) {
12
- const hadTrailingSeparator = resultPath.endsWith(pathModule.sep) || (pathModule.sep === "\\" && resultPath.endsWith("/"));
13
- const relativePath = pathModule.isAbsolute(resultPath) ? pathModule.relative(searchPath, resultPath) : resultPath;
14
- const posixPath = relativePath.split(pathModule.sep).join("/");
15
- return hadTrailingSeparator && !posixPath.endsWith("/") ? `${posixPath}/` : posixPath;
16
- }
17
- const findSchema = Type.Object({
18
- pattern: Type.String({
19
- description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'",
20
- }),
21
- path: Type.Optional(Type.String({ description: "Directory to search in (default: current directory)" })),
22
- limit: Type.Optional(Type.Number({ description: "Maximum number of results (default: 1000)" })),
23
- });
24
- export const findToolSystemPromptContribution = {
25
- snippet: "Find files by glob pattern (respects .gitignore)",
26
- guidelines: [],
27
- };
28
- const DEFAULT_LIMIT = 1000;
29
- const defaultFindOperations = {
30
- exists: pathExists,
31
- // This is a placeholder. Actual fd execution happens in execute() when no custom glob is provided.
32
- glob: () => [],
33
- };
34
- export function createFindToolDefinition(cwd, options) {
35
- const customOps = options?.operations;
36
- return {
37
- name: "find",
38
- label: "find",
39
- description: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,
40
- promptSnippet: findToolSystemPromptContribution.snippet,
41
- parameters: findSchema,
42
- async execute(_toolCallId, { pattern, path: searchDir, limit }, signal, _onUpdate, ctx) {
43
- return new Promise((resolve, reject) => {
44
- if (signal?.aborted) {
45
- reject(new Error("Operation aborted"));
46
- return;
47
- }
48
- let settled = false;
49
- let stopChild;
50
- const settle = (fn) => {
51
- if (settled)
52
- return;
53
- settled = true;
54
- signal?.removeEventListener("abort", onAbort);
55
- stopChild = undefined;
56
- fn();
57
- };
58
- const onAbort = () => {
59
- stopChild?.();
60
- settle(() => reject(new Error("Operation aborted")));
61
- };
62
- signal?.addEventListener("abort", onAbort, { once: true });
63
- (async () => {
64
- try {
65
- const searchPath = resolveToCwd(searchDir || ".", ctx?.cwd || cwd);
66
- const effectiveLimit = limit ?? DEFAULT_LIMIT;
67
- const ops = customOps ?? defaultFindOperations;
68
- // If custom operations provide glob(), use that instead of fd.
69
- if (customOps?.glob) {
70
- if (!(await ops.exists(searchPath))) {
71
- settle(() => reject(new Error(`Path not found: ${searchPath}`)));
72
- return;
73
- }
74
- if (signal?.aborted) {
75
- settle(() => reject(new Error("Operation aborted")));
76
- return;
77
- }
78
- const results = await ops.glob(pattern, searchPath, {
79
- ignore: ["**/node_modules/**", "**/.git/**"],
80
- limit: effectiveLimit,
81
- });
82
- if (signal?.aborted) {
83
- settle(() => reject(new Error("Operation aborted")));
84
- return;
85
- }
86
- if (results.length === 0) {
87
- settle(() => resolve({
88
- content: [{ type: "text", text: "No files found matching pattern" }],
89
- details: undefined,
90
- }));
91
- return;
92
- }
93
- // Relativize paths against the search root for stable output.
94
- const relativized = results.map((p) => relativizeFindResultPath(p, searchPath));
95
- const resultLimitReached = relativized.length >= effectiveLimit;
96
- const rawOutput = relativized.join("\n");
97
- const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
98
- let resultOutput = truncation.content;
99
- const details = {};
100
- const notices = [];
101
- if (resultLimitReached) {
102
- notices.push(`${effectiveLimit} results limit reached`);
103
- details.resultLimitReached = effectiveLimit;
104
- }
105
- if (truncation.truncated) {
106
- notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
107
- details.truncation = truncation;
108
- }
109
- if (notices.length > 0) {
110
- resultOutput += `\n\n[${notices.join(". ")}]`;
111
- }
112
- settle(() => resolve({
113
- content: [{ type: "text", text: resultOutput }],
114
- details: Object.keys(details).length > 0 ? details : undefined,
115
- }));
116
- return;
117
- }
118
- // Default implementation uses fd.
119
- const fdPath = await ensureTool("fd");
120
- if (signal?.aborted) {
121
- settle(() => reject(new Error("Operation aborted")));
122
- return;
123
- }
124
- if (!fdPath) {
125
- settle(() => reject(new Error("fd is not available and could not be downloaded")));
126
- return;
127
- }
128
- const args = ["--glob", "--color=never", "--hidden"];
129
- // fd normally ignores .gitignore outside git repos, so keep --no-require-git
130
- // there. Inside repos, use fd's default git-aware behavior so parent
131
- // .gitignore rules stop at nested repo boundaries:
132
- // https://github.com/earendil-works/pi/issues/5960
133
- let insideGitRepo = false;
134
- for (let current = searchPath;;) {
135
- if (await pathExists(path.join(current, ".git"))) {
136
- insideGitRepo = true;
137
- break;
138
- }
139
- const parent = path.dirname(current);
140
- if (parent === current)
141
- break;
142
- current = parent;
143
- }
144
- if (!insideGitRepo)
145
- args.push("--no-require-git");
146
- args.push("--max-results", String(effectiveLimit));
147
- // fd --glob matches against the basename unless --full-path is set; in --full-path
148
- // mode it matches against the absolute candidate path, so a path-containing
149
- // pattern like 'src/**/*.spec.ts' needs a leading '**/' to match anything.
150
- let effectivePattern = pattern;
151
- if (pattern.includes("/")) {
152
- args.push("--full-path");
153
- if (!pattern.startsWith("/") && !pattern.startsWith("**/") && pattern !== "**") {
154
- effectivePattern = `**/${pattern}`;
155
- }
156
- // fd matches full paths using native separators on Windows.
157
- if (process.platform === "win32")
158
- effectivePattern = effectivePattern.replaceAll("/", String.raw `[/\\]`);
159
- }
160
- args.push("--", effectivePattern, searchPath);
161
- const child = spawn(fdPath, args, { stdio: ["ignore", "pipe", "pipe"] });
162
- const rl = createInterface({ input: child.stdout });
163
- let stderr = "";
164
- const lines = [];
165
- stopChild = () => {
166
- if (!child.killed) {
167
- child.kill();
168
- }
169
- };
170
- const cleanup = () => {
171
- rl.close();
172
- };
173
- child.stderr?.on("data", (chunk) => {
174
- stderr += chunk.toString();
175
- });
176
- rl.on("line", (line) => {
177
- lines.push(line);
178
- });
179
- child.on("error", (error) => {
180
- cleanup();
181
- settle(() => reject(new Error(`Failed to run fd: ${error.message}`)));
182
- });
183
- child.on("close", (code) => {
184
- cleanup();
185
- if (signal?.aborted) {
186
- settle(() => reject(new Error("Operation aborted")));
187
- return;
188
- }
189
- const output = lines.join("\n");
190
- if (code !== 0) {
191
- const errorMsg = stderr.trim() || `fd exited with code ${code}`;
192
- if (!output) {
193
- settle(() => reject(new Error(errorMsg)));
194
- return;
195
- }
196
- }
197
- if (!output) {
198
- settle(() => resolve({
199
- content: [{ type: "text", text: "No files found matching pattern" }],
200
- details: undefined,
201
- }));
202
- return;
203
- }
204
- const relativized = [];
205
- for (const rawLine of lines) {
206
- const line = rawLine.replace(/\r$/, "").trim();
207
- if (!line)
208
- continue;
209
- relativized.push(relativizeFindResultPath(line, searchPath));
210
- }
211
- const resultLimitReached = relativized.length >= effectiveLimit;
212
- const rawOutput = relativized.join("\n");
213
- const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
214
- let resultOutput = truncation.content;
215
- const details = {};
216
- const notices = [];
217
- if (resultLimitReached) {
218
- notices.push(`${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
219
- details.resultLimitReached = effectiveLimit;
220
- }
221
- if (truncation.truncated) {
222
- notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
223
- details.truncation = truncation;
224
- }
225
- if (notices.length > 0) {
226
- resultOutput += `\n\n[${notices.join(". ")}]`;
227
- }
228
- settle(() => resolve({
229
- content: [{ type: "text", text: resultOutput }],
230
- details: Object.keys(details).length > 0 ? details : undefined,
231
- }));
232
- });
233
- }
234
- catch (e) {
235
- if (signal?.aborted) {
236
- settle(() => reject(new Error("Operation aborted")));
237
- return;
238
- }
239
- const error = e instanceof Error ? e : new Error(String(e));
240
- settle(() => reject(error));
241
- }
242
- })();
243
- });
244
- },
245
- ...findRenderers,
246
- };
247
- }
248
- export function createFindTool(cwd, options) {
249
- return wrapToolDefinition(createFindToolDefinition(cwd, options));
250
- }
251
- //# sourceMappingURL=find.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/core/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAyB,YAAY,EAAE,MAAM,eAAe,CAAC;AAEnG,6FAA6F;AAC7F,MAAM,UAAU,wBAAwB,CACvC,UAAkB,EAClB,UAAkB,EAClB,UAAU,GAAsB,IAAI;IAEpC,MAAM,oBAAoB,GACzB,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9F,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAClH,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,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ACJ,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACZ,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;4BACrB,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;4BACrD,OAAO;wBACR,CAAC;wBACD,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC5D,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;oBAC7B,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,GAAG,aAAa;KAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { pathExists, resolveToCwd } from \"./path-utils.ts\";\nimport { findRenderers } from \"./renderers/find.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\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: path.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}\n\nconst findSchema = Type.Object({\n\tpattern: Type.String({\n\t\tdescription: \"Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'\",\n\t}),\n\tpath: Type.Optional(Type.String({ description: \"Directory to search in (default: current directory)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of results (default: 1000)\" })),\n});\n\nexport const findToolSystemPromptContribution = {\n\tsnippet: \"Find files by glob pattern (respects .gitignore)\",\n\tguidelines: [],\n} as const;\n\nexport type FindToolInput = Static<typeof findSchema>;\n\nconst DEFAULT_LIMIT = 1000;\n\nexport interface FindToolDetails {\n\ttruncation?: TruncationResult;\n\tresultLimitReached?: number;\n}\n\n/**\n * Pluggable operations for the find tool.\n * Override these to delegate file search to remote systems (for example SSH).\n */\nexport interface FindOperations {\n\t/** Check if path exists */\n\texists: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Find files matching glob pattern. Returns relative or absolute paths. */\n\tglob: (pattern: string, cwd: string, options: { ignore: string[]; limit: number }) => Promise<string[]> | string[];\n}\n\nconst defaultFindOperations: FindOperations = {\n\texists: pathExists,\n\t// This is a placeholder. Actual fd execution happens in execute() when no custom glob is provided.\n\tglob: () => [],\n};\n\nexport interface FindToolOptions {\n\t/** Custom operations for find. Default: local filesystem plus fd */\n\toperations?: FindOperations;\n}\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: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first).`,\n\t\tpromptSnippet: findToolSystemPromptContribution.snippet,\n\t\tparameters: findSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ pattern, path: searchDir, limit }: { pattern: string; path?: string; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\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\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\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", ctx?.cwd || cwd);\n\t\t\t\t\t\tconst effectiveLimit = limit ?? DEFAULT_LIMIT;\n\t\t\t\t\t\tconst ops = customOps ?? defaultFindOperations;\n\n\t\t\t\t\t\t// If custom operations provide glob(), use that instead of fd.\n\t\t\t\t\t\tif (customOps?.glob) {\n\t\t\t\t\t\t\tif (!(await ops.exists(searchPath))) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst results = await ops.glob(pattern, searchPath, {\n\t\t\t\t\t\t\t\tignore: [\"**/node_modules/**\", \"**/.git/**\"],\n\t\t\t\t\t\t\t\tlimit: effectiveLimit,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\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\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Relativize paths against the search root for stable output.\n\t\t\t\t\t\t\tconst relativized = results.map((p) => relativizeFindResultPath(p, searchPath));\n\t\t\t\t\t\t\tconst resultLimitReached = relativized.length >= effectiveLimit;\n\t\t\t\t\t\t\tconst rawOutput = relativized.join(\"\\n\");\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet resultOutput = truncation.content;\n\t\t\t\t\t\t\tconst details: FindToolDetails = {};\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (resultLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(`${effectiveLimit} results limit reached`);\n\t\t\t\t\t\t\t\tdetails.resultLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\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\tcontent: [{ type: \"text\", text: resultOutput }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\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\n\t\t\t\t\t\t// Default implementation uses fd.\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\n\t\t\t\t\t\tconst args: string[] = [\"--glob\", \"--color=never\", \"--hidden\"];\n\n\t\t\t\t\t\t// fd normally ignores .gitignore outside git repos, so keep --no-require-git\n\t\t\t\t\t\t// there. Inside repos, use fd's default git-aware behavior so parent\n\t\t\t\t\t\t// .gitignore rules stop at nested repo boundaries:\n\t\t\t\t\t\t// https://github.com/earendil-works/pi/issues/5960\n\t\t\t\t\t\tlet insideGitRepo = false;\n\t\t\t\t\t\tfor (let current = searchPath; ; ) {\n\t\t\t\t\t\t\tif (await pathExists(path.join(current, \".git\"))) {\n\t\t\t\t\t\t\t\tinsideGitRepo = 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\tconst parent = path.dirname(current);\n\t\t\t\t\t\t\tif (parent === current) break;\n\t\t\t\t\t\t\tcurrent = parent;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!insideGitRepo) args.push(\"--no-require-git\");\n\t\t\t\t\t\targs.push(\"--max-results\", String(effectiveLimit));\n\n\t\t\t\t\t\t// fd --glob matches against the basename unless --full-path is set; in --full-path\n\t\t\t\t\t\t// mode it matches against the absolute candidate path, so a path-containing\n\t\t\t\t\t\t// pattern like 'src/**/*.spec.ts' needs a leading '**/' to match anything.\n\t\t\t\t\t\tlet effectivePattern = pattern;\n\t\t\t\t\t\tif (pattern.includes(\"/\")) {\n\t\t\t\t\t\t\targs.push(\"--full-path\");\n\t\t\t\t\t\t\tif (!pattern.startsWith(\"/\") && !pattern.startsWith(\"**/\") && pattern !== \"**\") {\n\t\t\t\t\t\t\t\teffectivePattern = `**/${pattern}`;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// fd matches full paths using native separators on Windows.\n\t\t\t\t\t\t\tif (process.platform === \"win32\")\n\t\t\t\t\t\t\t\teffectivePattern = effectivePattern.replaceAll(\"/\", String.raw`[/\\\\]`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\targs.push(\"--\", effectivePattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(fdPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tconst lines: string[] = [];\n\n\t\t\t\t\t\tstopChild = () => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tlines.push(line);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run fd: ${error.message}`)));\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"close\", (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst output = lines.join(\"\\n\");\n\t\t\t\t\t\t\tif (code !== 0) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `fd exited with code ${code}`;\n\t\t\t\t\t\t\t\tif (!output) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\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}\n\t\t\t\t\t\t\tif (!output) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No files found matching pattern\" }],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\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\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst relativized: string[] = [];\n\t\t\t\t\t\t\tfor (const rawLine of lines) {\n\t\t\t\t\t\t\t\tconst line = rawLine.replace(/\\r$/, \"\").trim();\n\t\t\t\t\t\t\t\tif (!line) continue;\n\t\t\t\t\t\t\t\trelativized.push(relativizeFindResultPath(line, searchPath));\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst resultLimitReached = relativized.length >= effectiveLimit;\n\t\t\t\t\t\t\tconst rawOutput = relativized.join(\"\\n\");\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet resultOutput = truncation.content;\n\t\t\t\t\t\t\tconst details: FindToolDetails = {};\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (resultLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.resultLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) {\n\t\t\t\t\t\t\t\tresultOutput += `\\n\\n[${notices.join(\". \")}]`;\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\tcontent: [{ type: \"text\", text: resultOutput }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\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\t...findRenderers,\n\t};\n}\n\nexport function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema> {\n\treturn wrapToolDefinition(createFindToolDefinition(cwd, options));\n}\n"]}