@di-code/coding-agent 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +104 -46
  2. package/compositions/base.yml +54 -0
  3. package/compositions/interactive.yml +14 -0
  4. package/compositions/json.yml +6 -0
  5. package/compositions/print.yml +5 -0
  6. package/compositions/rpc.yml +12 -0
  7. package/compositions/webui.yml +9 -0
  8. package/dist/cli.d.ts +22 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +97 -3
  11. package/dist/cli.js.map +1 -1
  12. package/dist/composition-loader-entry.d.ts +11 -0
  13. package/dist/composition-loader-entry.d.ts.map +1 -0
  14. package/dist/composition-loader-entry.js +12 -0
  15. package/dist/composition-loader-entry.js.map +1 -0
  16. package/dist/compositions.d.ts +32 -0
  17. package/dist/compositions.d.ts.map +1 -0
  18. package/dist/compositions.js +173 -0
  19. package/dist/compositions.js.map +1 -0
  20. package/dist/core/session/session-manager.d.ts +9 -2
  21. package/dist/core/session/session-manager.d.ts.map +1 -1
  22. package/dist/core/session/session-manager.js +28 -0
  23. package/dist/core/session/session-manager.js.map +1 -1
  24. package/dist/core/session/session-storage.d.ts.map +1 -1
  25. package/dist/core/session/session-storage.js +20 -3
  26. package/dist/core/session/session-storage.js.map +1 -1
  27. package/dist/core/session/types.d.ts +11 -2
  28. package/dist/core/session/types.d.ts.map +1 -1
  29. package/dist/core/session/types.js.map +1 -1
  30. package/dist/core/session-tools.d.ts +5 -0
  31. package/dist/core/session-tools.d.ts.map +1 -0
  32. package/dist/core/session-tools.js +17 -0
  33. package/dist/core/session-tools.js.map +1 -0
  34. package/dist/core/session.d.ts +19 -7
  35. package/dist/core/session.d.ts.map +1 -1
  36. package/dist/core/session.js +71 -39
  37. package/dist/core/session.js.map +1 -1
  38. package/dist/core/tools/bash.d.ts +1 -38
  39. package/dist/core/tools/bash.d.ts.map +1 -1
  40. package/dist/core/tools/bash.js +1 -207
  41. package/dist/core/tools/bash.js.map +1 -1
  42. package/dist/core/tools/edit-diff.d.ts +1 -24
  43. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  44. package/dist/core/tools/edit-diff.js +1 -135
  45. package/dist/core/tools/edit-diff.js.map +1 -1
  46. package/dist/core/tools/edit.d.ts +1 -26
  47. package/dist/core/tools/edit.d.ts.map +1 -1
  48. package/dist/core/tools/edit.js +1 -140
  49. package/dist/core/tools/edit.js.map +1 -1
  50. package/dist/core/tools/file-mutation-queue.d.ts +1 -1
  51. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  52. package/dist/core/tools/file-mutation-queue.js +1 -23
  53. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  54. package/dist/core/tools/file-search.d.ts +1 -13
  55. package/dist/core/tools/file-search.d.ts.map +1 -1
  56. package/dist/core/tools/file-search.js +1 -98
  57. package/dist/core/tools/file-search.js.map +1 -1
  58. package/dist/core/tools/glob.d.ts +1 -10
  59. package/dist/core/tools/glob.d.ts.map +1 -1
  60. package/dist/core/tools/glob.js +1 -43
  61. package/dist/core/tools/glob.js.map +1 -1
  62. package/dist/core/tools/grep.d.ts +1 -12
  63. package/dist/core/tools/grep.d.ts.map +1 -1
  64. package/dist/core/tools/grep.js +1 -66
  65. package/dist/core/tools/grep.js.map +1 -1
  66. package/dist/core/tools/load-skill.d.ts +1 -9
  67. package/dist/core/tools/load-skill.d.ts.map +1 -1
  68. package/dist/core/tools/load-skill.js +1 -21
  69. package/dist/core/tools/load-skill.js.map +1 -1
  70. package/dist/core/tools/path-boundary.d.ts +1 -4
  71. package/dist/core/tools/path-boundary.d.ts.map +1 -1
  72. package/dist/core/tools/path-boundary.js +1 -65
  73. package/dist/core/tools/path-boundary.js.map +1 -1
  74. package/dist/core/tools/read.d.ts +1 -16
  75. package/dist/core/tools/read.d.ts.map +1 -1
  76. package/dist/core/tools/read.js +1 -131
  77. package/dist/core/tools/read.js.map +1 -1
  78. package/dist/core/tools/write.d.ts +1 -16
  79. package/dist/core/tools/write.d.ts.map +1 -1
  80. package/dist/core/tools/write.js +1 -44
  81. package/dist/core/tools/write.js.map +1 -1
  82. package/dist/entry.js +30 -28
  83. package/dist/entry.js.map +1 -1
  84. package/dist/index.d.ts +6 -3
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +6 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/interactive/builtin.d.ts +17 -0
  89. package/dist/interactive/builtin.d.ts.map +1 -0
  90. package/dist/interactive/builtin.js +47 -0
  91. package/dist/interactive/builtin.js.map +1 -0
  92. package/dist/interactive/controller.d.ts +85 -0
  93. package/dist/interactive/controller.d.ts.map +1 -0
  94. package/dist/interactive/controller.js +211 -0
  95. package/dist/interactive/controller.js.map +1 -0
  96. package/dist/interactive/index.d.ts +3 -0
  97. package/dist/interactive/index.d.ts.map +1 -0
  98. package/dist/interactive/index.js +3 -0
  99. package/dist/interactive/index.js.map +1 -0
  100. package/dist/interactive-host-entry.d.ts +7 -0
  101. package/dist/interactive-host-entry.d.ts.map +1 -0
  102. package/dist/interactive-host-entry.js +123 -0
  103. package/dist/interactive-host-entry.js.map +1 -0
  104. package/dist/interactive-profile.d.ts +18 -0
  105. package/dist/interactive-profile.d.ts.map +1 -0
  106. package/dist/interactive-profile.js +290 -0
  107. package/dist/interactive-profile.js.map +1 -0
  108. package/dist/interactive-resources-entry.d.ts +7 -0
  109. package/dist/interactive-resources-entry.d.ts.map +1 -0
  110. package/dist/interactive-resources-entry.js +42 -0
  111. package/dist/interactive-resources-entry.js.map +1 -0
  112. package/dist/legacy-main.d.ts +39 -0
  113. package/dist/legacy-main.d.ts.map +1 -0
  114. package/dist/legacy-main.js +611 -0
  115. package/dist/legacy-main.js.map +1 -0
  116. package/dist/main.d.ts +15 -34
  117. package/dist/main.d.ts.map +1 -1
  118. package/dist/main.js +130 -518
  119. package/dist/main.js.map +1 -1
  120. package/dist/mcp/entries.d.ts +42 -0
  121. package/dist/mcp/entries.d.ts.map +1 -0
  122. package/dist/mcp/entries.js +98 -0
  123. package/dist/mcp/entries.js.map +1 -0
  124. package/dist/mcp-client-entry.d.ts +5 -0
  125. package/dist/mcp-client-entry.d.ts.map +1 -0
  126. package/dist/mcp-client-entry.js +6 -0
  127. package/dist/mcp-client-entry.js.map +1 -0
  128. package/dist/mcp-config-entry.d.ts +5 -0
  129. package/dist/mcp-config-entry.d.ts.map +1 -0
  130. package/dist/mcp-config-entry.js +6 -0
  131. package/dist/mcp-config-entry.js.map +1 -0
  132. package/dist/mcp-tools-entry.d.ts +5 -0
  133. package/dist/mcp-tools-entry.d.ts.map +1 -0
  134. package/dist/mcp-tools-entry.js +6 -0
  135. package/dist/mcp-tools-entry.js.map +1 -0
  136. package/dist/mcp-transport-entry.d.ts +5 -0
  137. package/dist/mcp-transport-entry.d.ts.map +1 -0
  138. package/dist/mcp-transport-entry.js +6 -0
  139. package/dist/mcp-transport-entry.js.map +1 -0
  140. package/dist/modes/interactive-entry.d.ts +18 -0
  141. package/dist/modes/interactive-entry.d.ts.map +1 -0
  142. package/dist/modes/interactive-entry.js +21 -0
  143. package/dist/modes/interactive-entry.js.map +1 -0
  144. package/dist/modes/interactive.d.ts +16 -6
  145. package/dist/modes/interactive.d.ts.map +1 -1
  146. package/dist/modes/interactive.js +81 -32
  147. package/dist/modes/interactive.js.map +1 -1
  148. package/dist/modes/json-entry.d.ts +13 -0
  149. package/dist/modes/json-entry.d.ts.map +1 -0
  150. package/dist/modes/json-entry.js +14 -0
  151. package/dist/modes/json-entry.js.map +1 -0
  152. package/dist/modes/json.d.ts +4 -1
  153. package/dist/modes/json.d.ts.map +1 -1
  154. package/dist/modes/json.js +3 -3
  155. package/dist/modes/json.js.map +1 -1
  156. package/dist/modes/print-entry.d.ts +10 -0
  157. package/dist/modes/print-entry.d.ts.map +1 -0
  158. package/dist/modes/print-entry.js +11 -0
  159. package/dist/modes/print-entry.js.map +1 -0
  160. package/dist/modes/tree-selector.d.ts.map +1 -1
  161. package/dist/modes/tree-selector.js +4 -0
  162. package/dist/modes/tree-selector.js.map +1 -1
  163. package/dist/plugin-dump-composition.d.ts +6 -0
  164. package/dist/plugin-dump-composition.d.ts.map +1 -0
  165. package/dist/plugin-dump-composition.js +7 -0
  166. package/dist/plugin-dump-composition.js.map +1 -0
  167. package/dist/plugin-inventory.d.ts +7 -0
  168. package/dist/plugin-inventory.d.ts.map +1 -0
  169. package/dist/plugin-inventory.js +8 -0
  170. package/dist/plugin-inventory.js.map +1 -0
  171. package/dist/plugin-manager.d.ts +6 -0
  172. package/dist/plugin-manager.d.ts.map +1 -0
  173. package/dist/plugin-manager.js +7 -0
  174. package/dist/plugin-manager.js.map +1 -0
  175. package/dist/plugin-trace.d.ts +6 -0
  176. package/dist/plugin-trace.d.ts.map +1 -0
  177. package/dist/plugin-trace.js +7 -0
  178. package/dist/plugin-trace.js.map +1 -0
  179. package/dist/plugins/dynamic-broker.d.ts +76 -0
  180. package/dist/plugins/dynamic-broker.d.ts.map +1 -0
  181. package/dist/plugins/dynamic-broker.js +852 -0
  182. package/dist/plugins/dynamic-broker.js.map +1 -0
  183. package/dist/plugins/profile.d.ts +15 -0
  184. package/dist/plugins/profile.d.ts.map +1 -0
  185. package/dist/plugins/profile.js +34 -0
  186. package/dist/plugins/profile.js.map +1 -0
  187. package/dist/plugins/runtime-host.d.ts +37 -0
  188. package/dist/plugins/runtime-host.d.ts.map +1 -0
  189. package/dist/plugins/runtime-host.js +95 -0
  190. package/dist/plugins/runtime-host.js.map +1 -0
  191. package/dist/plugins/trust.d.ts +8 -0
  192. package/dist/plugins/trust.d.ts.map +1 -0
  193. package/dist/plugins/trust.js +59 -0
  194. package/dist/plugins/trust.js.map +1 -0
  195. package/dist/project-trust-entry.d.ts +15 -0
  196. package/dist/project-trust-entry.d.ts.map +1 -0
  197. package/dist/project-trust-entry.js +15 -0
  198. package/dist/project-trust-entry.js.map +1 -0
  199. package/dist/rpc/client.d.ts +78 -6
  200. package/dist/rpc/client.d.ts.map +1 -1
  201. package/dist/rpc/client.js +172 -4
  202. package/dist/rpc/client.js.map +1 -1
  203. package/dist/rpc/dispatcher.d.ts +121 -0
  204. package/dist/rpc/dispatcher.d.ts.map +1 -0
  205. package/dist/rpc/dispatcher.js +994 -0
  206. package/dist/rpc/dispatcher.js.map +1 -0
  207. package/dist/rpc/index.d.ts +2 -0
  208. package/dist/rpc/index.d.ts.map +1 -1
  209. package/dist/rpc/index.js +2 -0
  210. package/dist/rpc/index.js.map +1 -1
  211. package/dist/rpc/lifecycle.d.ts +6 -0
  212. package/dist/rpc/lifecycle.d.ts.map +1 -0
  213. package/dist/rpc/lifecycle.js +24 -0
  214. package/dist/rpc/lifecycle.js.map +1 -0
  215. package/dist/rpc/protocol.d.ts +112 -31
  216. package/dist/rpc/protocol.d.ts.map +1 -1
  217. package/dist/rpc/protocol.js +569 -117
  218. package/dist/rpc/protocol.js.map +1 -1
  219. package/dist/rpc/server-service.d.ts +7 -0
  220. package/dist/rpc/server-service.d.ts.map +1 -0
  221. package/dist/rpc/server-service.js +3 -0
  222. package/dist/rpc/server-service.js.map +1 -0
  223. package/dist/rpc/server.d.ts +16 -19
  224. package/dist/rpc/server.d.ts.map +1 -1
  225. package/dist/rpc/server.js +59 -115
  226. package/dist/rpc/server.js.map +1 -1
  227. package/dist/rpc-client-sdk-entry.d.ts +12 -0
  228. package/dist/rpc-client-sdk-entry.d.ts.map +1 -0
  229. package/dist/rpc-client-sdk-entry.js +11 -0
  230. package/dist/rpc-client-sdk-entry.js.map +1 -0
  231. package/dist/rpc-entry.js +50 -18
  232. package/dist/rpc-entry.js.map +1 -1
  233. package/dist/rpc-server-entry.d.ts +8 -0
  234. package/dist/rpc-server-entry.d.ts.map +1 -0
  235. package/dist/rpc-server-entry.js +67 -0
  236. package/dist/rpc-server-entry.js.map +1 -0
  237. package/dist/runtime/attachment-store.d.ts +13 -0
  238. package/dist/runtime/attachment-store.d.ts.map +1 -0
  239. package/dist/runtime/attachment-store.js +93 -0
  240. package/dist/runtime/attachment-store.js.map +1 -0
  241. package/dist/runtime/bootstrap.d.ts +14 -0
  242. package/dist/runtime/bootstrap.d.ts.map +1 -0
  243. package/dist/runtime/bootstrap.js +29 -0
  244. package/dist/runtime/bootstrap.js.map +1 -0
  245. package/dist/runtime/interactive-host-service.d.ts +22 -0
  246. package/dist/runtime/interactive-host-service.d.ts.map +1 -0
  247. package/dist/runtime/interactive-host-service.js +2 -0
  248. package/dist/runtime/interactive-host-service.js.map +1 -0
  249. package/dist/runtime/interactive-resource-service.d.ts +11 -0
  250. package/dist/runtime/interactive-resource-service.d.ts.map +1 -0
  251. package/dist/runtime/interactive-resource-service.js +3 -0
  252. package/dist/runtime/interactive-resource-service.js.map +1 -0
  253. package/dist/runtime/plugin-inventory-entry.d.ts +5 -0
  254. package/dist/runtime/plugin-inventory-entry.d.ts.map +1 -0
  255. package/dist/runtime/plugin-inventory-entry.js +18 -0
  256. package/dist/runtime/plugin-inventory-entry.js.map +1 -0
  257. package/dist/runtime/plugin-inventory-service.d.ts +8 -0
  258. package/dist/runtime/plugin-inventory-service.d.ts.map +1 -0
  259. package/dist/runtime/plugin-inventory-service.js +3 -0
  260. package/dist/runtime/plugin-inventory-service.js.map +1 -0
  261. package/dist/runtime/plugin-manager-entry.d.ts +20 -0
  262. package/dist/runtime/plugin-manager-entry.d.ts.map +1 -0
  263. package/dist/runtime/plugin-manager-entry.js +96 -0
  264. package/dist/runtime/plugin-manager-entry.js.map +1 -0
  265. package/dist/runtime/plugin-observability-entry.d.ts +12 -0
  266. package/dist/runtime/plugin-observability-entry.d.ts.map +1 -0
  267. package/dist/runtime/plugin-observability-entry.js +73 -0
  268. package/dist/runtime/plugin-observability-entry.js.map +1 -0
  269. package/dist/runtime/product-host.d.ts +91 -0
  270. package/dist/runtime/product-host.d.ts.map +1 -0
  271. package/dist/runtime/product-host.js +529 -0
  272. package/dist/runtime/product-host.js.map +1 -0
  273. package/dist/runtime/session-factory.d.ts +17 -0
  274. package/dist/runtime/session-factory.d.ts.map +1 -0
  275. package/dist/runtime/session-factory.js +75 -0
  276. package/dist/runtime/session-factory.js.map +1 -0
  277. package/dist/runtime/session-host.d.ts +152 -0
  278. package/dist/runtime/session-host.d.ts.map +1 -0
  279. package/dist/runtime/session-host.js +895 -0
  280. package/dist/runtime/session-host.js.map +1 -0
  281. package/dist/runtime-core-entry.d.ts +11 -0
  282. package/dist/runtime-core-entry.d.ts.map +1 -0
  283. package/dist/runtime-core-entry.js +9 -0
  284. package/dist/runtime-core-entry.js.map +1 -0
  285. package/dist/session-factory-entry.d.ts +7 -0
  286. package/dist/session-factory-entry.d.ts.map +1 -0
  287. package/dist/session-factory-entry.js +9 -0
  288. package/dist/session-factory-entry.js.map +1 -0
  289. package/dist/session-store-jsonl-entry.d.ts +7 -0
  290. package/dist/session-store-jsonl-entry.d.ts.map +1 -0
  291. package/dist/session-store-jsonl-entry.js +33 -0
  292. package/dist/session-store-jsonl-entry.js.map +1 -0
  293. package/dist/startup.d.ts +12 -1
  294. package/dist/startup.d.ts.map +1 -1
  295. package/dist/startup.js +106 -15
  296. package/dist/startup.js.map +1 -1
  297. package/dist/subagents/index.d.ts +2 -0
  298. package/dist/subagents/index.d.ts.map +1 -0
  299. package/dist/subagents/index.js +2 -0
  300. package/dist/subagents/index.js.map +1 -0
  301. package/dist/subagents/service.d.ts +50 -0
  302. package/dist/subagents/service.d.ts.map +1 -0
  303. package/dist/subagents/service.js +521 -0
  304. package/dist/subagents/service.js.map +1 -0
  305. package/dist/ui-host.d.ts +125 -0
  306. package/dist/ui-host.d.ts.map +1 -0
  307. package/dist/ui-host.js +275 -0
  308. package/dist/ui-host.js.map +1 -0
  309. package/dist/web/assets/index-BwfuGMvv.css +1 -0
  310. package/dist/web/assets/index-DPUaJqFJ.js +41 -0
  311. package/dist/web/assets/index-DPUaJqFJ.js.map +1 -0
  312. package/dist/web/index.html +14 -0
  313. package/dist/web-command.d.ts +11 -0
  314. package/dist/web-command.d.ts.map +1 -0
  315. package/dist/web-command.js +114 -0
  316. package/dist/web-command.js.map +1 -0
  317. package/dist/web-frontend.d.ts +73 -0
  318. package/dist/web-frontend.d.ts.map +1 -0
  319. package/dist/web-frontend.js +249 -0
  320. package/dist/web-frontend.js.map +1 -0
  321. package/dist/web.d.ts +254 -0
  322. package/dist/web.d.ts.map +1 -0
  323. package/dist/web.js +740 -0
  324. package/dist/web.js.map +1 -0
  325. package/dist/webui-entry.d.ts +3 -0
  326. package/dist/webui-entry.d.ts.map +1 -0
  327. package/dist/webui-entry.js +73 -0
  328. package/dist/webui-entry.js.map +1 -0
  329. package/dist/webui.d.ts +91 -0
  330. package/dist/webui.d.ts.map +1 -0
  331. package/dist/webui.js +882 -0
  332. package/dist/webui.js.map +1 -0
  333. package/package.json +89 -8
@@ -1 +1 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EAAuC,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAa,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CA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,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { readFile as fsReadFile, writeFile as fsWriteFile } from \"node:fs/promises\";\nimport type { AgentTool, ToolExecutionResult } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport { applyEditsToContent, type Edit, generateDiffString, generateUnifiedPatch } from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveAllowedFilePath } from \"./path-boundary.ts\";\n\nconst editItemParameters = Type.Object({\n\toldText: Type.String(),\n\tnewText: Type.String(),\n});\n\nexport const editParameters = Type.Object({\n\tpath: Type.String({ minLength: 1 }),\n\tedits: Type.Optional(Type.Array(editItemParameters, { minItems: 1 })),\n\t// Compatibility with the original di-code single-edit contract.\n\toldText: Type.Optional(Type.String()),\n\tnewText: Type.Optional(Type.String()),\n});\n\nexport type EditParameters = Static<typeof editParameters>;\n\nexport interface EditOperations {\n\treadFile(filePath: string): Promise<Buffer>;\n\twriteFile(filePath: string, content: string): Promise<void>;\n}\n\nexport interface EditToolOptions {\n\treadonly operations?: EditOperations;\n}\n\nexport interface EditToolDetails {\n\treadonly diff: string;\n\treadonly patch: string;\n\treadonly firstChangedLine?: number;\n}\n\nexport type EditTool = AgentTool<typeof editParameters, ToolExecutionResult<EditToolDetails>>;\n\nconst defaultEditOperations: EditOperations = {\n\tasync readFile(filePath) {\n\t\treturn fsReadFile(filePath);\n\t},\n\tasync writeFile(filePath, content) {\n\t\tawait fsWriteFile(filePath, content, \"utf8\");\n\t},\n};\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nfunction normalizeLineEndings(text: string): string {\n\treturn text.replaceAll(\"\\r\\n\", \"\\n\").replaceAll(\"\\r\", \"\\n\");\n}\n\nfunction restoreLineEndings(text: string, ending: \"\\n\" | \"\\r\\n\"): string {\n\treturn ending === \"\\n\" ? text : text.replaceAll(\"\\n\", \"\\r\\n\");\n}\n\nfunction detectLineEnding(text: string): \"\\n\" | \"\\r\\n\" {\n\treturn text.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n}\n\nfunction hasUtf8Bom(bytes: Buffer): boolean {\n\treturn bytes.length >= 3 && bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;\n}\n\nfunction containsNulByte(bytes: Buffer): boolean {\n\tconst sampleLength = Math.min(bytes.length, 8 * 1024);\n\tfor (let index = 0; index < sampleLength; index++) {\n\t\tif (bytes[index] === 0) return true;\n\t}\n\treturn false;\n}\n\nfunction decodeUtf8(bytes: Buffer, path: string): string {\n\tconst text = bytes.toString(\"utf8\");\n\tif (!Buffer.from(text, \"utf8\").equals(bytes)) throw new Error(`File is not valid UTF-8: ${path}`);\n\treturn text;\n}\n\nfunction normalizeEdits(parameters: EditParameters, path: string): Edit[] {\n\tif (parameters.edits) {\n\t\treturn parameters.edits.map((edit) => ({ oldText: edit.oldText, newText: edit.newText }));\n\t}\n\tif (typeof parameters.oldText === \"string\" && typeof parameters.newText === \"string\") {\n\t\treturn [{ oldText: parameters.oldText, newText: parameters.newText }];\n\t}\n\tthrow new Error(`edit requires edits[] or oldText/newText in ${path}`);\n}\n\nfunction legacyError(cause: unknown, path: string, legacy: boolean): never {\n\tif (!legacy || !(cause instanceof Error)) throw cause;\n\tif (cause.message.includes(\"oldText must not be empty\")) throw cause;\n\tif (cause.message.includes(\"Could not find edits[0]\")) {\n\t\tthrow new Error(`Text to replace was not found in ${path}`);\n\t}\n\tif (cause.message.includes(\"Found \") && cause.message.includes(\"occurrences of edits[0]\")) {\n\t\tthrow new Error(`Text to replace is ambiguous in ${path}`);\n\t}\n\tthrow cause;\n}\n\nexport function createEditTool(allowedRoot: string, options: EditToolOptions = {}): EditTool {\n\tconst operations = options.operations ?? defaultEditOperations;\n\n\treturn {\n\t\tname: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit one UTF-8 text file using one or more unique exact replacements in edits[]. Legacy oldText/newText is also accepted.\",\n\t\tparameters: editParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolExecutionResult<EditToolDetails>> {\n\t\t\tthrowIfAborted(signal);\n\t\t\tif (parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tif (parameters.edits === undefined && parameters.oldText === \"\") throw new Error(\"oldText must not be empty\");\n\t\t\tconst edits = normalizeEdits(parameters, parameters.path);\n\t\t\tconst legacy = parameters.edits === undefined;\n\t\t\tconst absolutePath = await resolveAllowedFilePath(parameters.path, allowedRoot);\n\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tconst originalBytes = await operations.readFile(absolutePath);\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tif (containsNulByte(originalBytes)) throw new Error(\"Binary files are not supported by edit\");\n\t\t\t\tconst hasBom = hasUtf8Bom(originalBytes);\n\t\t\t\tconst originalText = decodeUtf8(originalBytes, parameters.path).replace(/^\\uFEFF/, \"\");\n\t\t\t\tconst ending = detectLineEnding(originalText);\n\t\t\t\tconst baseContent = normalizeLineEndings(originalText);\n\t\t\t\tconst normalizedEdits = edits.map((edit) => ({\n\t\t\t\t\toldText: normalizeLineEndings(edit.oldText),\n\t\t\t\t\tnewText: normalizeLineEndings(edit.newText),\n\t\t\t\t}));\n\t\t\t\tlet newContent: string;\n\t\t\t\ttry {\n\t\t\t\t\tnewContent = applyEditsToContent(baseContent, normalizedEdits, parameters.path).newContent;\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tlegacyError(cause, parameters.path, legacy);\n\t\t\t\t}\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tconst currentBytes = await operations.readFile(absolutePath);\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tif (!currentBytes.equals(originalBytes)) {\n\t\t\t\t\tthrow new Error(`File changed during edit: ${parameters.path}`);\n\t\t\t\t}\n\t\t\t\tawait operations.writeFile(absolutePath, `${hasBom ? \"\\uFEFF\" : \"\"}${restoreLineEndings(newContent, ending)}`);\n\t\t\t\tthrowIfAborted(signal);\n\t\t\t\tconst display = generateDiffString(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: legacy\n\t\t\t\t\t\t\t\t? `Successfully replaced text in ${parameters.path}`\n\t\t\t\t\t\t\t\t: `Successfully replaced ${normalizedEdits.length} block(s) in ${parameters.path}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t] satisfies ToolResultContent[],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tdiff: display.diff,\n\t\t\t\t\t\tpatch: generateUnifiedPatch(parameters.path, baseContent, newContent),\n\t\t\t\t\t\t...(display.firstChangedLine === undefined ? {} : { firstChangedLine: display.firstChangedLine }),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,2 +1,2 @@
1
- export declare function withFileMutationQueue<T>(filePath: string, operation: () => Promise<T>): Promise<T>;
1
+ export * from "@di-code/builtins";
2
2
  //# sourceMappingURL=file-mutation-queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAIA,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBxG"}
1
+ {"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,24 +1,2 @@
1
- import { resolve } from "node:path";
2
- const fileMutationQueues = new Map();
3
- export async function withFileMutationQueue(filePath, operation) {
4
- const resolvedPath = resolve(filePath);
5
- const key = process.platform === "win32" ? resolvedPath.toLowerCase() : resolvedPath;
6
- const currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();
7
- let releaseNext;
8
- const nextQueue = new Promise((resolveQueue) => {
9
- releaseNext = resolveQueue;
10
- });
11
- const chainedQueue = currentQueue.then(() => nextQueue);
12
- fileMutationQueues.set(key, chainedQueue);
13
- await currentQueue;
14
- try {
15
- return await operation();
16
- }
17
- finally {
18
- releaseNext();
19
- if (fileMutationQueues.get(key) === chainedQueue) {
20
- fileMutationQueues.delete(key);
21
- }
22
- }
23
- }
1
+ export * from "@di-code/builtins";
24
2
  //# sourceMappingURL=file-mutation-queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-mutation-queue.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAI,QAAgB,EAAE,SAA2B;IAC3F,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;IACrF,MAAM,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtE,IAAI,WAAwB,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,OAAO,CAAO,CAAC,YAAY,EAAE,EAAE;QACpD,WAAW,GAAG,YAAY,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACxD,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAE1C,MAAM,YAAY,CAAC;IACnB,IAAI,CAAC;QACJ,OAAO,MAAM,SAAS,EAAE,CAAC;IAC1B,CAAC;YAAS,CAAC;QACV,WAAW,EAAE,CAAC;QACd,IAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,YAAY,EAAE,CAAC;YAClD,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import { resolve } from \"node:path\";\n\nconst fileMutationQueues = new Map<string, Promise<void>>();\n\nexport async function withFileMutationQueue<T>(filePath: string, operation: () => Promise<T>): Promise<T> {\n\tconst resolvedPath = resolve(filePath);\n\tconst key = process.platform === \"win32\" ? resolvedPath.toLowerCase() : resolvedPath;\n\tconst currentQueue = fileMutationQueues.get(key) ?? Promise.resolve();\n\n\tlet releaseNext!: () => void;\n\tconst nextQueue = new Promise<void>((resolveQueue) => {\n\t\treleaseNext = resolveQueue;\n\t});\n\tconst chainedQueue = currentQueue.then(() => nextQueue);\n\tfileMutationQueues.set(key, chainedQueue);\n\n\tawait currentQueue;\n\ttry {\n\t\treturn await operation();\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
+ {"version":3,"file":"file-mutation-queue.js","sourceRoot":"","sources":["../../../src/core/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,14 +1,2 @@
1
- export declare const DEFAULT_SEARCH_MAX_RESULTS = 200;
2
- export declare const DEFAULT_SEARCH_MAX_OUTPUT_BYTES: number;
3
- export declare const MAX_SEARCH_FILE_BYTES: number;
4
- export interface SearchFile {
5
- readonly relativePath: string;
6
- readonly searchPath: string;
7
- }
8
- export declare function assertSearchLimit(name: string, value: number): void;
9
- export declare function normalizeSearchPattern(pattern: string): string;
10
- export declare function resolveSearchRoot(inputPath: string | undefined, allowedRoot: string): Promise<string>;
11
- export declare function walkSearchFiles(rootPath: string, signal?: AbortSignal, displayRootPath?: string): AsyncGenerator<SearchFile, void, undefined>;
12
- export declare function readSearchText(file: SearchFile, allowedRoot: string, signal?: AbortSignal): Promise<string | undefined>;
13
- export declare function appendBoundedLine(lines: string[], line: string, maxOutputBytes: number): boolean;
1
+ export * from "@di-code/builtins";
14
2
  //# sourceMappingURL=file-search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-search.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-search.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,+BAA+B,QAAY,CAAC;AACzD,eAAO,MAAM,qBAAqB,QAAkB,CAAC;AAErD,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEnE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAU9D;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3G;AAED,wBAAuB,eAAe,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,EACpB,eAAe,SAAW,GACxB,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAuC7C;AAQD,wBAAsB,cAAc,CACnC,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY7B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAOhG"}
1
+ {"version":3,"file":"file-search.d.ts","sourceRoot":"","sources":["../../../src/core/tools/file-search.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,99 +1,2 @@
1
- import { readdir, readFile, realpath, stat } from "node:fs/promises";
2
- import { basename, matchesGlob, relative, resolve, sep } from "node:path";
3
- import { resolveAllowedExistingPath } from "./path-boundary.js";
4
- export const DEFAULT_SEARCH_MAX_RESULTS = 200;
5
- export const DEFAULT_SEARCH_MAX_OUTPUT_BYTES = 50 * 1024;
6
- export const MAX_SEARCH_FILE_BYTES = 2 * 1024 * 1024;
7
- export function assertSearchLimit(name, value) {
8
- if (!Number.isInteger(value) || value < 1)
9
- throw new Error(`${name} must be a positive integer`);
10
- }
11
- export function normalizeSearchPattern(pattern) {
12
- const normalized = pattern.replaceAll("\\", "/").trim();
13
- if (normalized.length === 0)
14
- throw new Error("pattern must not be empty");
15
- if (normalized.startsWith("/"))
16
- throw new Error("pattern must be relative to the allowed root");
17
- try {
18
- matchesGlob("placeholder", normalized);
19
- }
20
- catch (cause) {
21
- throw new Error(`Invalid glob pattern: ${cause instanceof Error ? cause.message : String(cause)}`);
22
- }
23
- return normalized;
24
- }
25
- export async function resolveSearchRoot(inputPath, allowedRoot) {
26
- return resolveAllowedExistingPath(inputPath ?? ".", allowedRoot);
27
- }
28
- export async function* walkSearchFiles(rootPath, signal, displayRootPath = rootPath) {
29
- const traversalRoot = await realpath(rootPath);
30
- const displayRoot = await realpath(displayRootPath);
31
- const rootMetadata = await stat(traversalRoot);
32
- if (rootMetadata.isFile()) {
33
- yield {
34
- relativePath: relative(displayRoot, traversalRoot).split(sep).join("/"),
35
- searchPath: basename(traversalRoot),
36
- };
37
- return;
38
- }
39
- if (!rootMetadata.isDirectory())
40
- throw new Error("Search path must be a file or directory");
41
- const initialEntries = await readDirectoryEntries(traversalRoot);
42
- const pending = [{ directory: traversalRoot, entries: initialEntries, index: 0 }];
43
- while (pending.length > 0) {
44
- if (signal?.aborted)
45
- throw new Error("Operation aborted");
46
- const frame = pending[pending.length - 1];
47
- if (!frame)
48
- continue;
49
- const entry = frame.entries[frame.index++];
50
- if (!entry) {
51
- pending.pop();
52
- continue;
53
- }
54
- if (entry.isSymbolicLink())
55
- continue;
56
- const absolutePath = resolve(frame.directory, entry.name);
57
- if (entry.isDirectory()) {
58
- pending.push({ directory: absolutePath, entries: await readDirectoryEntries(absolutePath), index: 0 });
59
- continue;
60
- }
61
- if (!entry.isFile())
62
- continue;
63
- const relativePath = relative(displayRoot, absolutePath).split(sep).join("/");
64
- const searchPath = relative(traversalRoot, absolutePath).split(sep).join("/");
65
- yield { relativePath, searchPath };
66
- }
67
- }
68
- async function readDirectoryEntries(directory) {
69
- const entries = await readdir(directory, { withFileTypes: true });
70
- entries.sort((left, right) => left.name.localeCompare(right.name));
71
- return entries;
72
- }
73
- export async function readSearchText(file, allowedRoot, signal) {
74
- if (signal?.aborted)
75
- throw new Error("Operation aborted");
76
- const safePath = await resolveAllowedExistingPath(file.relativePath, allowedRoot);
77
- const metadata = await stat(safePath);
78
- if (!metadata.isFile() || metadata.size > MAX_SEARCH_FILE_BYTES)
79
- return undefined;
80
- const buffer = await readFile(safePath);
81
- if (signal?.aborted)
82
- throw new Error("Operation aborted");
83
- const sampleLength = Math.min(buffer.length, 8 * 1024);
84
- for (let index = 0; index < sampleLength; index++) {
85
- if (buffer[index] === 0)
86
- return undefined;
87
- }
88
- return buffer.toString("utf8");
89
- }
90
- export function appendBoundedLine(lines, line, maxOutputBytes) {
91
- const separatorBytes = lines.length === 0 ? 0 : 1;
92
- const nextBytes = Buffer.byteLength(line, "utf8") + separatorBytes;
93
- const currentBytes = lines.reduce((total, item) => total + Buffer.byteLength(item, "utf8"), 0);
94
- if (currentBytes + nextBytes > maxOutputBytes)
95
- return false;
96
- lines.push(line);
97
- return true;
98
- }
1
+ export * from "@di-code/builtins";
99
2
  //# sourceMappingURL=file-search.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-search.js","sourceRoot":"","sources":["../../../src/core/tools/file-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,GAAG,IAAI,CAAC;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAOrD,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAAa;IAC5D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,CAAC,CAAC;AAClG,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACrD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC1E,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,C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AAC;AAChC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAe,EAAE,IAAY,EAAE,cAAsB;IACtF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC;IACnE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/F,IAAI,YAAY,GAAG,SAAS,GAAG,cAAc;QAAE,OAAO,KAAK,CAAC;IAC5D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { readdir, readFile, realpath, stat } from \"node:fs/promises\";\nimport { basename, matchesGlob, relative, resolve, sep } from \"node:path\";\nimport { resolveAllowedExistingPath } from \"./path-boundary.ts\";\n\nexport const DEFAULT_SEARCH_MAX_RESULTS = 200;\nexport const DEFAULT_SEARCH_MAX_OUTPUT_BYTES = 50 * 1024;\nexport const MAX_SEARCH_FILE_BYTES = 2 * 1024 * 1024;\n\nexport interface SearchFile {\n\treadonly relativePath: string;\n\treadonly searchPath: string;\n}\n\nexport function assertSearchLimit(name: string, value: number): void {\n\tif (!Number.isInteger(value) || value < 1) throw new Error(`${name} must be a positive integer`);\n}\n\nexport function normalizeSearchPattern(pattern: string): string {\n\tconst normalized = pattern.replaceAll(\"\\\\\", \"/\").trim();\n\tif (normalized.length === 0) throw new Error(\"pattern must not be empty\");\n\tif (normalized.startsWith(\"/\")) throw new Error(\"pattern must be relative to the allowed root\");\n\ttry {\n\t\tmatchesGlob(\"placeholder\", normalized);\n\t} catch (cause) {\n\t\tthrow new Error(`Invalid glob pattern: ${cause instanceof Error ? cause.message : String(cause)}`);\n\t}\n\treturn normalized;\n}\n\nexport async function resolveSearchRoot(inputPath: string | undefined, allowedRoot: string): Promise<string> {\n\treturn resolveAllowedExistingPath(inputPath ?? \".\", allowedRoot);\n}\n\nexport async function* walkSearchFiles(\n\trootPath: string,\n\tsignal?: AbortSignal,\n\tdisplayRootPath = rootPath,\n): AsyncGenerator<SearchFile, void, undefined> {\n\tconst traversalRoot = await realpath(rootPath);\n\tconst displayRoot = await realpath(displayRootPath);\n\tconst rootMetadata = await stat(traversalRoot);\n\tif (rootMetadata.isFile()) {\n\t\tyield {\n\t\t\trelativePath: relative(displayRoot, traversalRoot).split(sep).join(\"/\"),\n\t\t\tsearchPath: basename(traversalRoot),\n\t\t};\n\t\treturn;\n\t}\n\tif (!rootMetadata.isDirectory()) throw new Error(\"Search path must be a file or directory\");\n\tconst initialEntries = await readDirectoryEntries(traversalRoot);\n\tconst pending: Array<{\n\t\tdirectory: string;\n\t\tentries: Awaited<ReturnType<typeof readDirectoryEntries>>;\n\t\tindex: number;\n\t}> = [{ directory: traversalRoot, entries: initialEntries, index: 0 }];\n\n\twhile (pending.length > 0) {\n\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\tconst frame = pending[pending.length - 1];\n\t\tif (!frame) continue;\n\t\tconst entry = frame.entries[frame.index++];\n\t\tif (!entry) {\n\t\t\tpending.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.isSymbolicLink()) continue;\n\t\tconst absolutePath = resolve(frame.directory, entry.name);\n\t\tif (entry.isDirectory()) {\n\t\t\tpending.push({ directory: absolutePath, entries: await readDirectoryEntries(absolutePath), index: 0 });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!entry.isFile()) continue;\n\t\tconst relativePath = relative(displayRoot, absolutePath).split(sep).join(\"/\");\n\t\tconst searchPath = relative(traversalRoot, absolutePath).split(sep).join(\"/\");\n\t\tyield { relativePath, searchPath };\n\t}\n}\n\nasync function readDirectoryEntries(directory: string) {\n\tconst entries = await readdir(directory, { withFileTypes: true });\n\tentries.sort((left, right) => left.name.localeCompare(right.name));\n\treturn entries;\n}\n\nexport async function readSearchText(\n\tfile: SearchFile,\n\tallowedRoot: string,\n\tsignal?: AbortSignal,\n): Promise<string | undefined> {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\tconst safePath = await resolveAllowedExistingPath(file.relativePath, allowedRoot);\n\tconst metadata = await stat(safePath);\n\tif (!metadata.isFile() || metadata.size > MAX_SEARCH_FILE_BYTES) return undefined;\n\tconst buffer = await readFile(safePath);\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\tconst sampleLength = Math.min(buffer.length, 8 * 1024);\n\tfor (let index = 0; index < sampleLength; index++) {\n\t\tif (buffer[index] === 0) return undefined;\n\t}\n\treturn buffer.toString(\"utf8\");\n}\n\nexport function appendBoundedLine(lines: string[], line: string, maxOutputBytes: number): boolean {\n\tconst separatorBytes = lines.length === 0 ? 0 : 1;\n\tconst nextBytes = Buffer.byteLength(line, \"utf8\") + separatorBytes;\n\tconst currentBytes = lines.reduce((total, item) => total + Buffer.byteLength(item, \"utf8\"), 0);\n\tif (currentBytes + nextBytes > maxOutputBytes) return false;\n\tlines.push(line);\n\treturn true;\n}\n"]}
1
+ {"version":3,"file":"file-search.js","sourceRoot":"","sources":["../../../src/core/tools/file-search.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,11 +1,2 @@
1
- import type { AgentTool } from "@di-code/agent";
2
- import { type Static, type ToolResultContent, Type } from "@di-code/ai";
3
- export declare const globParameters: Type.TObject<{
4
- pattern: Type.TString;
5
- path: Type.TOptional<Type.TString>;
6
- maxResults: Type.TOptional<Type.TInteger>;
7
- }>;
8
- export type GlobParameters = Static<typeof globParameters>;
9
- export type GlobTool = AgentTool<typeof globParameters, ToolResultContent[]>;
10
- export declare function createGlobTool(allowedRoot: string): GlobTool;
1
+ export * from "@di-code/builtins";
11
2
  //# sourceMappingURL=glob.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAWxE,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAC3D,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,cAAc,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAE7E,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CA8B5D"}
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,44 +1,2 @@
1
- import { matchesGlob } from "node:path";
2
- import { Type } from "@di-code/ai";
3
- import { appendBoundedLine, assertSearchLimit, DEFAULT_SEARCH_MAX_OUTPUT_BYTES, DEFAULT_SEARCH_MAX_RESULTS, normalizeSearchPattern, resolveSearchRoot, walkSearchFiles, } from "./file-search.js";
4
- export const globParameters = Type.Object({
5
- pattern: Type.String({ minLength: 1 }),
6
- path: Type.Optional(Type.String({ minLength: 1 })),
7
- maxResults: Type.Optional(Type.Integer({ minimum: 1 })),
8
- });
9
- export function createGlobTool(allowedRoot) {
10
- return {
11
- name: "glob",
12
- description: "Find files inside the allowed root using a glob pattern such as **/*.ts. Returns sorted relative paths; symlinks are skipped.",
13
- parameters: globParameters,
14
- async execute(_toolCallId, parameters, signal) {
15
- if (signal?.aborted)
16
- throw new Error("Operation aborted");
17
- if (parameters.path !== undefined && parameters.path.length === 0)
18
- throw new Error("path must not be empty");
19
- const pattern = normalizeSearchPattern(parameters.pattern);
20
- const maxResults = parameters.maxResults ?? DEFAULT_SEARCH_MAX_RESULTS;
21
- assertSearchLimit("maxResults", maxResults);
22
- const root = await resolveSearchRoot(parameters.path, allowedRoot);
23
- const displayRoot = await resolveSearchRoot(undefined, allowedRoot);
24
- const lines = [];
25
- let matched = 0;
26
- let truncated = false;
27
- for await (const file of walkSearchFiles(root, signal, displayRoot)) {
28
- if (!matchesGlob(file.searchPath, pattern))
29
- continue;
30
- matched++;
31
- if (matched > maxResults || !appendBoundedLine(lines, file.relativePath, DEFAULT_SEARCH_MAX_OUTPUT_BYTES)) {
32
- truncated = true;
33
- break;
34
- }
35
- }
36
- if (lines.length === 0)
37
- return [{ type: "text", text: "No files matched." }];
38
- if (truncated)
39
- lines.push(`[Results truncated at ${maxResults} matches or 50 KiB.]`);
40
- return [{ type: "text", text: lines.join("\n") }];
41
- },
42
- };
43
- }
1
+ export * from "@di-code/builtins";
44
2
  //# sourceMappingURL=glob.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAuC,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,+BAA+B,EAC/B,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,GACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACtC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;IAClD,UAAU,EAAE,IAAI,CAAC,QA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AAE,IAAI,CAAC,YAAY,EAAE,+BAA+B,CAAC,EAAE,CAAC;oBAC3G,SAAS,GAAG,IAAI,CAAC;oBACjB,MAAM;gBACP,CAAC;YACF,CAAC;YACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC;YAC7E,IAAI,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,yBAAyB,UAAU,sBAAsB,CAAC,CAAC;YACrF,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { matchesGlob } from \"node:path\";\nimport type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport {\n\tappendBoundedLine,\n\tassertSearchLimit,\n\tDEFAULT_SEARCH_MAX_OUTPUT_BYTES,\n\tDEFAULT_SEARCH_MAX_RESULTS,\n\tnormalizeSearchPattern,\n\tresolveSearchRoot,\n\twalkSearchFiles,\n} from \"./file-search.ts\";\n\nexport const globParameters = Type.Object({\n\tpattern: Type.String({ minLength: 1 }),\n\tpath: Type.Optional(Type.String({ minLength: 1 })),\n\tmaxResults: Type.Optional(Type.Integer({ minimum: 1 })),\n});\n\nexport type GlobParameters = Static<typeof globParameters>;\nexport type GlobTool = AgentTool<typeof globParameters, ToolResultContent[]>;\n\nexport function createGlobTool(allowedRoot: string): GlobTool {\n\treturn {\n\t\tname: \"glob\",\n\t\tdescription:\n\t\t\t\"Find files inside the allowed root using a glob pattern such as **/*.ts. Returns sorted relative paths; symlinks are skipped.\",\n\t\tparameters: globParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (parameters.path !== undefined && parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tconst pattern = normalizeSearchPattern(parameters.pattern);\n\t\t\tconst maxResults = parameters.maxResults ?? DEFAULT_SEARCH_MAX_RESULTS;\n\t\t\tassertSearchLimit(\"maxResults\", maxResults);\n\t\t\tconst root = await resolveSearchRoot(parameters.path, allowedRoot);\n\t\t\tconst displayRoot = await resolveSearchRoot(undefined, allowedRoot);\n\t\t\tconst lines: string[] = [];\n\t\t\tlet matched = 0;\n\t\t\tlet truncated = false;\n\t\t\tfor await (const file of walkSearchFiles(root, signal, displayRoot)) {\n\t\t\t\tif (!matchesGlob(file.searchPath, pattern)) continue;\n\t\t\t\tmatched++;\n\t\t\t\tif (matched > maxResults || !appendBoundedLine(lines, file.relativePath, DEFAULT_SEARCH_MAX_OUTPUT_BYTES)) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (lines.length === 0) return [{ type: \"text\", text: \"No files matched.\" }];\n\t\t\tif (truncated) lines.push(`[Results truncated at ${maxResults} matches or 50 KiB.]`);\n\t\t\treturn [{ type: \"text\", text: lines.join(\"\\n\") }];\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/core/tools/glob.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,13 +1,2 @@
1
- import type { AgentTool } from "@di-code/agent";
2
- import { type Static, type ToolResultContent, Type } from "@di-code/ai";
3
- export declare const grepParameters: Type.TObject<{
4
- pattern: Type.TString;
5
- path: Type.TOptional<Type.TString>;
6
- include: Type.TOptional<Type.TString>;
7
- caseSensitive: Type.TOptional<Type.TBoolean>;
8
- maxResults: Type.TOptional<Type.TInteger>;
9
- }>;
10
- export type GrepParameters = Static<typeof grepParameters>;
11
- export type GrepTool = AgentTool<typeof grepParameters, ToolResultContent[]>;
12
- export declare function createGrepTool(allowedRoot: string): GrepTool;
1
+ export * from "@di-code/builtins";
13
2
  //# sourceMappingURL=grep.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAYxE,eAAO,MAAM,cAAc;;;;;;EAMzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAC3D,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,cAAc,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAE7E,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CA6C5D"}
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,67 +1,2 @@
1
- import { matchesGlob } from "node:path";
2
- import { Type } from "@di-code/ai";
3
- import { appendBoundedLine, assertSearchLimit, DEFAULT_SEARCH_MAX_OUTPUT_BYTES, DEFAULT_SEARCH_MAX_RESULTS, normalizeSearchPattern, readSearchText, resolveSearchRoot, walkSearchFiles, } from "./file-search.js";
4
- export const grepParameters = Type.Object({
5
- pattern: Type.String({ minLength: 1, maxLength: 1_000 }),
6
- path: Type.Optional(Type.String({ minLength: 1 })),
7
- include: Type.Optional(Type.String({ minLength: 1 })),
8
- caseSensitive: Type.Optional(Type.Boolean()),
9
- maxResults: Type.Optional(Type.Integer({ minimum: 1 })),
10
- });
11
- export function createGrepTool(allowedRoot) {
12
- return {
13
- name: "grep",
14
- description: "Search UTF-8 text files inside the allowed root for a literal string. Returns sorted path:line matches; binary files and symlinks are skipped.",
15
- parameters: grepParameters,
16
- async execute(_toolCallId, parameters, signal) {
17
- if (signal?.aborted)
18
- throw new Error("Operation aborted");
19
- if (parameters.pattern.length === 0)
20
- throw new Error("pattern must not be empty");
21
- if (parameters.pattern.length > 1_000)
22
- throw new Error("pattern must not exceed 1000 characters");
23
- if (parameters.path !== undefined && parameters.path.length === 0)
24
- throw new Error("path must not be empty");
25
- const include = parameters.include === undefined ? undefined : normalizeSearchPattern(parameters.include);
26
- const maxResults = parameters.maxResults ?? DEFAULT_SEARCH_MAX_RESULTS;
27
- assertSearchLimit("maxResults", maxResults);
28
- const root = await resolveSearchRoot(parameters.path, allowedRoot);
29
- const displayRoot = await resolveSearchRoot(undefined, allowedRoot);
30
- const needle = parameters.caseSensitive === false ? parameters.pattern.toLocaleLowerCase() : parameters.pattern;
31
- const lines = [];
32
- let matched = 0;
33
- let truncated = false;
34
- for await (const file of walkSearchFiles(root, signal, displayRoot)) {
35
- if (include !== undefined && !matchesInclude(file.searchPath, include))
36
- continue;
37
- const text = await readSearchText(file, allowedRoot, signal);
38
- if (text === undefined)
39
- continue;
40
- const fileLines = text.split("\n");
41
- for (let index = 0; index < fileLines.length; index++) {
42
- const line = fileLines[index] ?? "";
43
- const haystack = parameters.caseSensitive === false ? line.toLocaleLowerCase() : line;
44
- if (!haystack.includes(needle))
45
- continue;
46
- matched++;
47
- if (matched > maxResults ||
48
- !appendBoundedLine(lines, `${file.relativePath}:${index + 1}: ${line}`, DEFAULT_SEARCH_MAX_OUTPUT_BYTES)) {
49
- truncated = true;
50
- break;
51
- }
52
- }
53
- if (truncated)
54
- break;
55
- }
56
- if (lines.length === 0)
57
- return [{ type: "text", text: "No matches found." }];
58
- if (truncated)
59
- lines.push(`[Results truncated at ${maxResults} matches or 50 KiB.]`);
60
- return [{ type: "text", text: lines.join("\n") }];
61
- },
62
- };
63
- }
64
- function matchesInclude(relativePath, pattern) {
65
- return matchesGlob(relativePath, pattern);
66
- }
1
+ export * from "@di-code/builtins";
67
2
  //# sourceMappingURL=grep.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B,EAAE,OAAe;IAC5D,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { matchesGlob } from \"node:path\";\nimport type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport {\n\tappendBoundedLine,\n\tassertSearchLimit,\n\tDEFAULT_SEARCH_MAX_OUTPUT_BYTES,\n\tDEFAULT_SEARCH_MAX_RESULTS,\n\tnormalizeSearchPattern,\n\treadSearchText,\n\tresolveSearchRoot,\n\twalkSearchFiles,\n} from \"./file-search.ts\";\n\nexport const grepParameters = Type.Object({\n\tpattern: Type.String({ minLength: 1, maxLength: 1_000 }),\n\tpath: Type.Optional(Type.String({ minLength: 1 })),\n\tinclude: Type.Optional(Type.String({ minLength: 1 })),\n\tcaseSensitive: Type.Optional(Type.Boolean()),\n\tmaxResults: Type.Optional(Type.Integer({ minimum: 1 })),\n});\n\nexport type GrepParameters = Static<typeof grepParameters>;\nexport type GrepTool = AgentTool<typeof grepParameters, ToolResultContent[]>;\n\nexport function createGrepTool(allowedRoot: string): GrepTool {\n\treturn {\n\t\tname: \"grep\",\n\t\tdescription:\n\t\t\t\"Search UTF-8 text files inside the allowed root for a literal string. Returns sorted path:line matches; binary files and symlinks are skipped.\",\n\t\tparameters: grepParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tif (parameters.pattern.length === 0) throw new Error(\"pattern must not be empty\");\n\t\t\tif (parameters.pattern.length > 1_000) throw new Error(\"pattern must not exceed 1000 characters\");\n\t\t\tif (parameters.path !== undefined && parameters.path.length === 0) throw new Error(\"path must not be empty\");\n\t\t\tconst include = parameters.include === undefined ? undefined : normalizeSearchPattern(parameters.include);\n\t\t\tconst maxResults = parameters.maxResults ?? DEFAULT_SEARCH_MAX_RESULTS;\n\t\t\tassertSearchLimit(\"maxResults\", maxResults);\n\t\t\tconst root = await resolveSearchRoot(parameters.path, allowedRoot);\n\t\t\tconst displayRoot = await resolveSearchRoot(undefined, allowedRoot);\n\t\t\tconst needle = parameters.caseSensitive === false ? parameters.pattern.toLocaleLowerCase() : parameters.pattern;\n\t\t\tconst lines: string[] = [];\n\t\t\tlet matched = 0;\n\t\t\tlet truncated = false;\n\t\t\tfor await (const file of walkSearchFiles(root, signal, displayRoot)) {\n\t\t\t\tif (include !== undefined && !matchesInclude(file.searchPath, include)) continue;\n\t\t\t\tconst text = await readSearchText(file, allowedRoot, signal);\n\t\t\t\tif (text === undefined) continue;\n\t\t\t\tconst fileLines = text.split(\"\\n\");\n\t\t\t\tfor (let index = 0; index < fileLines.length; index++) {\n\t\t\t\t\tconst line = fileLines[index] ?? \"\";\n\t\t\t\t\tconst haystack = parameters.caseSensitive === false ? line.toLocaleLowerCase() : line;\n\t\t\t\t\tif (!haystack.includes(needle)) continue;\n\t\t\t\t\tmatched++;\n\t\t\t\t\tif (\n\t\t\t\t\t\tmatched > maxResults ||\n\t\t\t\t\t\t!appendBoundedLine(lines, `${file.relativePath}:${index + 1}: ${line}`, DEFAULT_SEARCH_MAX_OUTPUT_BYTES)\n\t\t\t\t\t) {\n\t\t\t\t\t\ttruncated = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (truncated) break;\n\t\t\t}\n\t\t\tif (lines.length === 0) return [{ type: \"text\", text: \"No matches found.\" }];\n\t\t\tif (truncated) lines.push(`[Results truncated at ${maxResults} matches or 50 KiB.]`);\n\t\t\treturn [{ type: \"text\", text: lines.join(\"\\n\") }];\n\t\t},\n\t};\n}\n\nfunction matchesInclude(relativePath: string, pattern: string): boolean {\n\treturn matchesGlob(relativePath, pattern);\n}\n"]}
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,10 +1,2 @@
1
- import type { AgentTool } from "@di-code/agent";
2
- import { type Static, type ToolResultContent, Type } from "@di-code/ai";
3
- import type { SkillCatalog } from "@di-code/skills";
4
- export declare const loadSkillParameters: Type.TObject<{
5
- name: Type.TString;
6
- }>;
7
- export type LoadSkillParameters = Static<typeof loadSkillParameters>;
8
- export type LoadSkillTool = AgentTool<typeof loadSkillParameters, ToolResultContent[]>;
9
- export declare function createLoadSkillTool(catalog: SkillCatalog): LoadSkillTool;
1
+ export * from "@di-code/builtins";
10
2
  //# sourceMappingURL=load-skill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-skill.d.ts","sourceRoot":"","sources":["../../../src/core/tools/load-skill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,eAAO,MAAM,mBAAmB;;EAE9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACrE,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,mBAAmB,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAEvF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAaxE"}
1
+ {"version":3,"file":"load-skill.d.ts","sourceRoot":"","sources":["../../../src/core/tools/load-skill.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,22 +1,2 @@
1
- import { Type } from "@di-code/ai";
2
- import { readSkillContent } from "@di-code/skills";
3
- export const loadSkillParameters = Type.Object({
4
- name: Type.String({ minLength: 1 }),
5
- });
6
- export function createLoadSkillTool(catalog) {
7
- return {
8
- name: "load_skill",
9
- description: "Load the untrusted instructions for a registered skill by name.",
10
- parameters: loadSkillParameters,
11
- async execute(_toolCallId, parameters, signal) {
12
- if (signal?.aborted)
13
- throw new Error("Operation aborted");
14
- const skill = catalog.resolve(parameters.name);
15
- if (!skill || skill.disableModelInvocation)
16
- throw new Error(`Unknown or unavailable skill "${parameters.name}".`);
17
- const content = await readSkillContent(skill, signal);
18
- return [{ type: "text", text: `<skill name="${skill.name}" source="${skill.source}">\n${content}\n</skill>` }];
19
- },
20
- };
21
- }
1
+ export * from "@di-code/builtins";
22
2
  //# sourceMappingURL=load-skill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-skill.js","sourceRoot":"","sources":["../../../src/core/tools/load-skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,IAAI,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;CACnC,CAAC,CAAC;AAKH,MAAM,UAAU,mBAAmB,CAAC,OAAqB;IACxD,OAAO;QACN,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,iEAAiE;QAC9E,UAAU,EAAE,mBAAmB;QAC/B,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,MAAM;YAC5C,IAAI,MAAM,EAAE,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,sBAAsB;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,CAAC,IAAI,IAAI,CAAC,CAAC;YAClH,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACtD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,KAAK,CAAC,IAAI,aAAa,KAAK,CAAC,MAAM,OAAO,OAAO,YAAY,EAAE,CAAC,CAAC;QAChH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool } from \"@di-code/agent\";\nimport { type Static, type ToolResultContent, Type } from \"@di-code/ai\";\nimport type { SkillCatalog } from \"@di-code/skills\";\nimport { readSkillContent } from \"@di-code/skills\";\n\nexport const loadSkillParameters = Type.Object({\n\tname: Type.String({ minLength: 1 }),\n});\n\nexport type LoadSkillParameters = Static<typeof loadSkillParameters>;\nexport type LoadSkillTool = AgentTool<typeof loadSkillParameters, ToolResultContent[]>;\n\nexport function createLoadSkillTool(catalog: SkillCatalog): LoadSkillTool {\n\treturn {\n\t\tname: \"load_skill\",\n\t\tdescription: \"Load the untrusted instructions for a registered skill by name.\",\n\t\tparameters: loadSkillParameters,\n\t\tasync execute(_toolCallId, parameters, signal): Promise<ToolResultContent[]> {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst skill = catalog.resolve(parameters.name);\n\t\t\tif (!skill || skill.disableModelInvocation) throw new Error(`Unknown or unavailable skill \"${parameters.name}\".`);\n\t\t\tconst content = await readSkillContent(skill, signal);\n\t\t\treturn [{ type: \"text\", text: `<skill name=\"${skill.name}\" source=\"${skill.source}\">\\n${content}\\n</skill>` }];\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"load-skill.js","sourceRoot":"","sources":["../../../src/core/tools/load-skill.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,5 +1,2 @@
1
- export declare function resolveAllowedMutationPath(inputPath: string, allowedRoot: string): Promise<string>;
2
- export declare function resolveAllowedFilePath(inputPath: string, allowedRoot: string): Promise<string>;
3
- /** Resolve an existing file or directory while enforcing the realpath root boundary. */
4
- export declare function resolveAllowedExistingPath(inputPath: string, allowedRoot: string): Promise<string>;
1
+ export * from "@di-code/builtins";
5
2
  //# sourceMappingURL=path-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-boundary.d.ts","sourceRoot":"","sources":["../../../src/core/tools/path-boundary.ts"],"names":[],"mappings":"AAoBA,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgCxG;AAED,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEpG;AAED,wFAAwF;AACxF,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOxG"}
1
+ {"version":3,"file":"path-boundary.d.ts","sourceRoot":"","sources":["../../../src/core/tools/path-boundary.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,66 +1,2 @@
1
- import { lstat, realpath } from "node:fs/promises";
2
- import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
3
- function assertInsideRoot(root, target) {
4
- const fromRoot = relative(root, target);
5
- if (fromRoot === "" || (fromRoot !== ".." && !fromRoot.startsWith(`..${sep}`) && !isAbsolute(fromRoot))) {
6
- return;
7
- }
8
- throw new Error("Path is outside the allowed root");
9
- }
10
- function isMissingPathError(error) {
11
- return (typeof error === "object" &&
12
- error !== null &&
13
- "code" in error &&
14
- (error.code === "ENOENT" || error.code === "ENOTDIR"));
15
- }
16
- export async function resolveAllowedMutationPath(inputPath, allowedRoot) {
17
- const rootReal = await realpath(allowedRoot);
18
- const candidate = resolve(rootReal, inputPath);
19
- assertInsideRoot(rootReal, candidate);
20
- const missingSegments = [];
21
- let current = candidate;
22
- while (true) {
23
- try {
24
- const currentReal = await realpath(current);
25
- assertInsideRoot(rootReal, currentReal);
26
- const target = resolve(currentReal, ...missingSegments.reverse());
27
- assertInsideRoot(rootReal, target);
28
- return target;
29
- }
30
- catch (error) {
31
- if (!isMissingPathError(error))
32
- throw error;
33
- let entryExists = false;
34
- try {
35
- const entry = await lstat(current);
36
- if (entry.isSymbolicLink())
37
- throw new Error("Path is outside the allowed root");
38
- entryExists = true;
39
- }
40
- catch (entryError) {
41
- if (!isMissingPathError(entryError))
42
- throw entryError;
43
- }
44
- if (entryExists)
45
- continue;
46
- const parent = dirname(current);
47
- if (parent === current)
48
- throw error;
49
- missingSegments.push(basename(current));
50
- current = parent;
51
- }
52
- }
53
- }
54
- export async function resolveAllowedFilePath(inputPath, allowedRoot) {
55
- return resolveAllowedExistingPath(inputPath, allowedRoot);
56
- }
57
- /** Resolve an existing file or directory while enforcing the realpath root boundary. */
58
- export async function resolveAllowedExistingPath(inputPath, allowedRoot) {
59
- const rootReal = await realpath(allowedRoot);
60
- const candidate = resolve(rootReal, inputPath);
61
- assertInsideRoot(rootReal, candidate);
62
- const targetReal = await realpath(candidate);
63
- assertInsideRoot(rootReal, targetReal);
64
- return targetReal;
65
- }
1
+ export * from "@di-code/builtins";
66
2
  //# sourceMappingURL=path-boundary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-boundary.js","sourceRoot":"","sources":["../../../src/core/tools/path-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAElF,SAAS,gBAAgB,CAAC,IAAY,EAAE,MAAc;IACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,IAAI,QAAQ,KAAK,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,QAAQ,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AAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;gBACnC,IAAI,KAAK,CAAC,cAAc,EAAE;oBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;gBAChF,WAAW,GAAG,IAAI,CAAC;YACpB,CAAC;YAAC,OAAO,UAAU,EAAE,CAAC;gBACrB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC;oBAAE,MAAM,UAAU,CAAC;YACvD,CAAC;YACD,IAAI,WAAW;gBAAE,SAAS;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;YAChC,IAAI,MAAM,KAAK,OAAO;gBAAE,MAAM,KAAK,CAAC;YACpC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YACxC,OAAO,GAAG,MAAM,CAAC;QAClB,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,SAAiB,EAAE,WAAmB;IAClF,OAAO,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,SAAiB,EAAE,WAAmB;IACtF,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC/C,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7C,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import { lstat, realpath } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, relative, resolve, sep } from \"node:path\";\n\nfunction assertInsideRoot(root: string, target: string): void {\n\tconst fromRoot = relative(root, target);\n\tif (fromRoot === \"\" || (fromRoot !== \"..\" && !fromRoot.startsWith(`..${sep}`) && !isAbsolute(fromRoot))) {\n\t\treturn;\n\t}\n\tthrow new Error(\"Path is outside the allowed root\");\n}\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\nexport async function resolveAllowedMutationPath(inputPath: string, allowedRoot: string): Promise<string> {\n\tconst rootReal = await realpath(allowedRoot);\n\tconst candidate = resolve(rootReal, inputPath);\n\tassertInsideRoot(rootReal, candidate);\n\n\tconst missingSegments: string[] = [];\n\tlet current = candidate;\n\n\twhile (true) {\n\t\ttry {\n\t\t\tconst currentReal = await realpath(current);\n\t\t\tassertInsideRoot(rootReal, currentReal);\n\t\t\tconst target = resolve(currentReal, ...missingSegments.reverse());\n\t\t\tassertInsideRoot(rootReal, target);\n\t\t\treturn target;\n\t\t} catch (error) {\n\t\t\tif (!isMissingPathError(error)) throw error;\n\t\t\tlet entryExists = false;\n\t\t\ttry {\n\t\t\t\tconst entry = await lstat(current);\n\t\t\t\tif (entry.isSymbolicLink()) throw new Error(\"Path is outside the allowed root\");\n\t\t\t\tentryExists = true;\n\t\t\t} catch (entryError) {\n\t\t\t\tif (!isMissingPathError(entryError)) throw entryError;\n\t\t\t}\n\t\t\tif (entryExists) continue;\n\t\t\tconst parent = dirname(current);\n\t\t\tif (parent === current) throw error;\n\t\t\tmissingSegments.push(basename(current));\n\t\t\tcurrent = parent;\n\t\t}\n\t}\n}\n\nexport async function resolveAllowedFilePath(inputPath: string, allowedRoot: string): Promise<string> {\n\treturn resolveAllowedExistingPath(inputPath, allowedRoot);\n}\n\n/** Resolve an existing file or directory while enforcing the realpath root boundary. */\nexport async function resolveAllowedExistingPath(inputPath: string, allowedRoot: string): Promise<string> {\n\tconst rootReal = await realpath(allowedRoot);\n\tconst candidate = resolve(rootReal, inputPath);\n\tassertInsideRoot(rootReal, candidate);\n\tconst targetReal = await realpath(candidate);\n\tassertInsideRoot(rootReal, targetReal);\n\treturn targetReal;\n}\n"]}
1
+ {"version":3,"file":"path-boundary.js","sourceRoot":"","sources":["../../../src/core/tools/path-boundary.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"@di-code/builtins\";\n"]}
@@ -1,17 +1,2 @@
1
- import type { AgentTool } from "@di-code/agent";
2
- import { type Static, type ToolResultContent, Type } from "@di-code/ai";
3
- export declare const DEFAULT_READ_MAX_LINES = 2000;
4
- export declare const DEFAULT_READ_MAX_BYTES: number;
5
- export declare const readParameters: Type.TObject<{
6
- path: Type.TString;
7
- offset: Type.TOptional<Type.TInteger>;
8
- limit: Type.TOptional<Type.TInteger>;
9
- }>;
10
- export type ReadParameters = Static<typeof readParameters>;
11
- export interface ReadToolOptions {
12
- readonly maxLines?: number;
13
- readonly maxBytes?: number;
14
- }
15
- export type ReadTool = AgentTool<typeof readParameters, ToolResultContent[]>;
16
- export declare function createReadTool(allowedRoot: string, options?: ReadToolOptions): ReadTool;
1
+ export * from "@di-code/builtins";
17
2
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGxE,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAC5C,eAAO,MAAM,sBAAsB,QAAY,CAAC;AAEhD,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,cAAc,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAuG7E,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CA8B3F"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}