aven-ai 0.0.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 (386) hide show
  1. package/README.md +171 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/libs/config/config-store.d.ts +109 -0
  7. package/dist/libs/config/config-store.d.ts.map +1 -0
  8. package/dist/libs/config/config-store.js +169 -0
  9. package/dist/libs/config/config-store.js.map +1 -0
  10. package/dist/libs/config/index.d.ts +2 -0
  11. package/dist/libs/config/index.d.ts.map +1 -0
  12. package/dist/libs/config/index.js +2 -0
  13. package/dist/libs/config/index.js.map +1 -0
  14. package/dist/libs/provider-clients/index.d.ts +2 -0
  15. package/dist/libs/provider-clients/index.d.ts.map +1 -0
  16. package/dist/libs/provider-clients/index.js +2 -0
  17. package/dist/libs/provider-clients/index.js.map +1 -0
  18. package/dist/libs/provider-clients/provider-client.d.ts +34 -0
  19. package/dist/libs/provider-clients/provider-client.d.ts.map +1 -0
  20. package/dist/libs/provider-clients/provider-client.js +167 -0
  21. package/dist/libs/provider-clients/provider-client.js.map +1 -0
  22. package/dist/libs/provider-definitions/index.d.ts +2 -0
  23. package/dist/libs/provider-definitions/index.d.ts.map +1 -0
  24. package/dist/libs/provider-definitions/index.js +2 -0
  25. package/dist/libs/provider-definitions/index.js.map +1 -0
  26. package/dist/libs/provider-definitions/provider-definitions.d.ts +16 -0
  27. package/dist/libs/provider-definitions/provider-definitions.d.ts.map +1 -0
  28. package/dist/libs/provider-definitions/provider-definitions.js +59 -0
  29. package/dist/libs/provider-definitions/provider-definitions.js.map +1 -0
  30. package/dist/libs/pty/index.d.ts +2 -0
  31. package/dist/libs/pty/index.d.ts.map +1 -0
  32. package/dist/libs/pty/index.js +2 -0
  33. package/dist/libs/pty/index.js.map +1 -0
  34. package/dist/libs/pty/pty-runner.d.ts +26 -0
  35. package/dist/libs/pty/pty-runner.d.ts.map +1 -0
  36. package/dist/libs/pty/pty-runner.js +153 -0
  37. package/dist/libs/pty/pty-runner.js.map +1 -0
  38. package/dist/libs/session-storage/index.d.ts +2 -0
  39. package/dist/libs/session-storage/index.d.ts.map +1 -0
  40. package/dist/libs/session-storage/index.js +2 -0
  41. package/dist/libs/session-storage/index.js.map +1 -0
  42. package/dist/libs/session-storage/session-catalog.d.ts +19 -0
  43. package/dist/libs/session-storage/session-catalog.d.ts.map +1 -0
  44. package/dist/libs/session-storage/session-catalog.js +180 -0
  45. package/dist/libs/session-storage/session-catalog.js.map +1 -0
  46. package/dist/libs/terminal/clipboard.d.ts +3 -0
  47. package/dist/libs/terminal/clipboard.d.ts.map +1 -0
  48. package/dist/libs/terminal/clipboard.js +8 -0
  49. package/dist/libs/terminal/clipboard.js.map +1 -0
  50. package/dist/libs/terminal/index.d.ts +6 -0
  51. package/dist/libs/terminal/index.d.ts.map +1 -0
  52. package/dist/libs/terminal/index.js +6 -0
  53. package/dist/libs/terminal/index.js.map +1 -0
  54. package/dist/libs/terminal/keyboard-protocol.d.ts +3 -0
  55. package/dist/libs/terminal/keyboard-protocol.d.ts.map +1 -0
  56. package/dist/libs/terminal/keyboard-protocol.js +7 -0
  57. package/dist/libs/terminal/keyboard-protocol.js.map +1 -0
  58. package/dist/libs/terminal/mouse-protocol.d.ts +22 -0
  59. package/dist/libs/terminal/mouse-protocol.d.ts.map +1 -0
  60. package/dist/libs/terminal/mouse-protocol.js +51 -0
  61. package/dist/libs/terminal/mouse-protocol.js.map +1 -0
  62. package/dist/libs/terminal/terminal-provider.d.ts +15 -0
  63. package/dist/libs/terminal/terminal-provider.d.ts.map +1 -0
  64. package/dist/libs/terminal/terminal-provider.js +47 -0
  65. package/dist/libs/terminal/terminal-provider.js.map +1 -0
  66. package/dist/libs/terminal/theme.d.ts +24 -0
  67. package/dist/libs/terminal/theme.d.ts.map +1 -0
  68. package/dist/libs/terminal/theme.js +23 -0
  69. package/dist/libs/terminal/theme.js.map +1 -0
  70. package/dist/modules/agent/core.d.ts +41 -0
  71. package/dist/modules/agent/core.d.ts.map +1 -0
  72. package/dist/modules/agent/core.js +149 -0
  73. package/dist/modules/agent/core.js.map +1 -0
  74. package/dist/modules/agent/events/memory-message-adapter.d.ts +4 -0
  75. package/dist/modules/agent/events/memory-message-adapter.d.ts.map +1 -0
  76. package/dist/modules/agent/events/memory-message-adapter.js +48 -0
  77. package/dist/modules/agent/events/memory-message-adapter.js.map +1 -0
  78. package/dist/modules/agent/events/stream-event-adapter.d.ts +17 -0
  79. package/dist/modules/agent/events/stream-event-adapter.d.ts.map +1 -0
  80. package/dist/modules/agent/events/stream-event-adapter.js +82 -0
  81. package/dist/modules/agent/events/stream-event-adapter.js.map +1 -0
  82. package/dist/modules/agent/events/tool-message-adapter.d.ts +21 -0
  83. package/dist/modules/agent/events/tool-message-adapter.d.ts.map +1 -0
  84. package/dist/modules/agent/events/tool-message-adapter.js +123 -0
  85. package/dist/modules/agent/events/tool-message-adapter.js.map +1 -0
  86. package/dist/modules/agent/index.d.ts +5 -0
  87. package/dist/modules/agent/index.d.ts.map +1 -0
  88. package/dist/modules/agent/index.js +5 -0
  89. package/dist/modules/agent/index.js.map +1 -0
  90. package/dist/modules/agent/mock.d.ts +10 -0
  91. package/dist/modules/agent/mock.d.ts.map +1 -0
  92. package/dist/modules/agent/mock.js +60 -0
  93. package/dist/modules/agent/mock.js.map +1 -0
  94. package/dist/modules/agent/prompts/commands.d.ts +2 -0
  95. package/dist/modules/agent/prompts/commands.d.ts.map +1 -0
  96. package/dist/modules/agent/prompts/commands.js +5 -0
  97. package/dist/modules/agent/prompts/commands.js.map +1 -0
  98. package/dist/modules/agent/prompts/file-tools.d.ts +2 -0
  99. package/dist/modules/agent/prompts/file-tools.d.ts.map +1 -0
  100. package/dist/modules/agent/prompts/file-tools.js +7 -0
  101. package/dist/modules/agent/prompts/file-tools.js.map +1 -0
  102. package/dist/modules/agent/prompts/identity.d.ts +2 -0
  103. package/dist/modules/agent/prompts/identity.d.ts.map +1 -0
  104. package/dist/modules/agent/prompts/identity.js +5 -0
  105. package/dist/modules/agent/prompts/identity.js.map +1 -0
  106. package/dist/modules/agent/prompts/system.d.ts +2 -0
  107. package/dist/modules/agent/prompts/system.d.ts.map +1 -0
  108. package/dist/modules/agent/prompts/system.js +5 -0
  109. package/dist/modules/agent/prompts/system.js.map +1 -0
  110. package/dist/modules/agent/services/direct-command-executor.d.ts +10 -0
  111. package/dist/modules/agent/services/direct-command-executor.d.ts.map +1 -0
  112. package/dist/modules/agent/services/direct-command-executor.js +58 -0
  113. package/dist/modules/agent/services/direct-command-executor.js.map +1 -0
  114. package/dist/modules/agent/services/prompt-turn-executor.d.ts +12 -0
  115. package/dist/modules/agent/services/prompt-turn-executor.d.ts.map +1 -0
  116. package/dist/modules/agent/services/prompt-turn-executor.js +79 -0
  117. package/dist/modules/agent/services/prompt-turn-executor.js.map +1 -0
  118. package/dist/modules/agent/tools/exec-command.d.ts +13 -0
  119. package/dist/modules/agent/tools/exec-command.d.ts.map +1 -0
  120. package/dist/modules/agent/tools/exec-command.js +11 -0
  121. package/dist/modules/agent/tools/exec-command.js.map +1 -0
  122. package/dist/modules/agent/tools/files/contracts.d.ts +132 -0
  123. package/dist/modules/agent/tools/files/contracts.d.ts.map +1 -0
  124. package/dist/modules/agent/tools/files/contracts.js +84 -0
  125. package/dist/modules/agent/tools/files/contracts.js.map +1 -0
  126. package/dist/modules/agent/tools/files/create-file-tools.d.ts +61 -0
  127. package/dist/modules/agent/tools/files/create-file-tools.d.ts.map +1 -0
  128. package/dist/modules/agent/tools/files/create-file-tools.js +26 -0
  129. package/dist/modules/agent/tools/files/create-file-tools.js.map +1 -0
  130. package/dist/modules/agent/tools/files/edit-file-operation.d.ts +4 -0
  131. package/dist/modules/agent/tools/files/edit-file-operation.d.ts.map +1 -0
  132. package/dist/modules/agent/tools/files/edit-file-operation.js +98 -0
  133. package/dist/modules/agent/tools/files/edit-file-operation.js.map +1 -0
  134. package/dist/modules/agent/tools/files/file-path-safety.d.ts +2 -0
  135. package/dist/modules/agent/tools/files/file-path-safety.d.ts.map +1 -0
  136. package/dist/modules/agent/tools/files/file-path-safety.js +10 -0
  137. package/dist/modules/agent/tools/files/file-path-safety.js.map +1 -0
  138. package/dist/modules/agent/tools/files/file-state-cache.d.ts +21 -0
  139. package/dist/modules/agent/tools/files/file-state-cache.d.ts.map +1 -0
  140. package/dist/modules/agent/tools/files/file-state-cache.js +54 -0
  141. package/dist/modules/agent/tools/files/file-state-cache.js.map +1 -0
  142. package/dist/modules/agent/tools/files/file-tool-error.d.ts +3 -0
  143. package/dist/modules/agent/tools/files/file-tool-error.d.ts.map +1 -0
  144. package/dist/modules/agent/tools/files/file-tool-error.js +3 -0
  145. package/dist/modules/agent/tools/files/file-tool-error.js.map +1 -0
  146. package/dist/modules/agent/tools/files/file-tool-operations.d.ts +22 -0
  147. package/dist/modules/agent/tools/files/file-tool-operations.d.ts.map +1 -0
  148. package/dist/modules/agent/tools/files/file-tool-operations.js +73 -0
  149. package/dist/modules/agent/tools/files/file-tool-operations.js.map +1 -0
  150. package/dist/modules/agent/tools/files/file-tool-service.d.ts +14 -0
  151. package/dist/modules/agent/tools/files/file-tool-service.d.ts.map +1 -0
  152. package/dist/modules/agent/tools/files/file-tool-service.js +28 -0
  153. package/dist/modules/agent/tools/files/file-tool-service.js.map +1 -0
  154. package/dist/modules/agent/tools/files/mutation-journal.d.ts +12 -0
  155. package/dist/modules/agent/tools/files/mutation-journal.d.ts.map +1 -0
  156. package/dist/modules/agent/tools/files/mutation-journal.js +25 -0
  157. package/dist/modules/agent/tools/files/mutation-journal.js.map +1 -0
  158. package/dist/modules/agent/tools/files/read-file-operation.d.ts +4 -0
  159. package/dist/modules/agent/tools/files/read-file-operation.d.ts.map +1 -0
  160. package/dist/modules/agent/tools/files/read-file-operation.js +92 -0
  161. package/dist/modules/agent/tools/files/read-file-operation.js.map +1 -0
  162. package/dist/modules/agent/tools/files/text-file-codec.d.ts +13 -0
  163. package/dist/modules/agent/tools/files/text-file-codec.d.ts.map +1 -0
  164. package/dist/modules/agent/tools/files/text-file-codec.js +45 -0
  165. package/dist/modules/agent/tools/files/text-file-codec.js.map +1 -0
  166. package/dist/modules/agent/tools/files/write-file-operation.d.ts +4 -0
  167. package/dist/modules/agent/tools/files/write-file-operation.d.ts.map +1 -0
  168. package/dist/modules/agent/tools/files/write-file-operation.js +61 -0
  169. package/dist/modules/agent/tools/files/write-file-operation.js.map +1 -0
  170. package/dist/modules/agent/types.d.ts +65 -0
  171. package/dist/modules/agent/types.d.ts.map +1 -0
  172. package/dist/modules/agent/types.js +21 -0
  173. package/dist/modules/agent/types.js.map +1 -0
  174. package/dist/modules/app/cli.d.ts +2 -0
  175. package/dist/modules/app/cli.d.ts.map +1 -0
  176. package/dist/modules/app/cli.js +23 -0
  177. package/dist/modules/app/cli.js.map +1 -0
  178. package/dist/modules/app/components/app-provider.d.ts +11 -0
  179. package/dist/modules/app/components/app-provider.d.ts.map +1 -0
  180. package/dist/modules/app/components/app-provider.js +18 -0
  181. package/dist/modules/app/components/app-provider.js.map +1 -0
  182. package/dist/modules/app/components/app.d.ts +7 -0
  183. package/dist/modules/app/components/app.d.ts.map +1 -0
  184. package/dist/modules/app/components/app.js +45 -0
  185. package/dist/modules/app/components/app.js.map +1 -0
  186. package/dist/modules/app/index.d.ts +6 -0
  187. package/dist/modules/app/index.d.ts.map +1 -0
  188. package/dist/modules/app/index.js +5 -0
  189. package/dist/modules/app/index.js.map +1 -0
  190. package/dist/modules/app/input/prompt-history.d.ts +3 -0
  191. package/dist/modules/app/input/prompt-history.d.ts.map +1 -0
  192. package/dist/modules/app/input/prompt-history.js +13 -0
  193. package/dist/modules/app/input/prompt-history.js.map +1 -0
  194. package/dist/modules/app/input/use-overlay-controller.d.ts +14 -0
  195. package/dist/modules/app/input/use-overlay-controller.d.ts.map +1 -0
  196. package/dist/modules/app/input/use-overlay-controller.js +168 -0
  197. package/dist/modules/app/input/use-overlay-controller.js.map +1 -0
  198. package/dist/modules/app/services/quit-controller.d.ts +2 -0
  199. package/dist/modules/app/services/quit-controller.d.ts.map +1 -0
  200. package/dist/modules/app/services/quit-controller.js +27 -0
  201. package/dist/modules/app/services/quit-controller.js.map +1 -0
  202. package/dist/modules/app/services/runtime-event-batcher.d.ts +13 -0
  203. package/dist/modules/app/services/runtime-event-batcher.d.ts.map +1 -0
  204. package/dist/modules/app/services/runtime-event-batcher.js +41 -0
  205. package/dist/modules/app/services/runtime-event-batcher.js.map +1 -0
  206. package/dist/modules/app/services/use-app-input.d.ts +14 -0
  207. package/dist/modules/app/services/use-app-input.d.ts.map +1 -0
  208. package/dist/modules/app/services/use-app-input.js +144 -0
  209. package/dist/modules/app/services/use-app-input.js.map +1 -0
  210. package/dist/modules/app/services/use-runtime-connection.d.ts +15 -0
  211. package/dist/modules/app/services/use-runtime-connection.d.ts.map +1 -0
  212. package/dist/modules/app/services/use-runtime-connection.js +128 -0
  213. package/dist/modules/app/services/use-runtime-connection.js.map +1 -0
  214. package/dist/modules/app/services/use-runtime-session.d.ts +8 -0
  215. package/dist/modules/app/services/use-runtime-session.d.ts.map +1 -0
  216. package/dist/modules/app/services/use-runtime-session.js +79 -0
  217. package/dist/modules/app/services/use-runtime-session.js.map +1 -0
  218. package/dist/modules/app/services/use-runtime-workspace.d.ts +16 -0
  219. package/dist/modules/app/services/use-runtime-workspace.d.ts.map +1 -0
  220. package/dist/modules/app/services/use-runtime-workspace.js +134 -0
  221. package/dist/modules/app/services/use-runtime-workspace.js.map +1 -0
  222. package/dist/modules/app/store/app-state.d.ts +39 -0
  223. package/dist/modules/app/store/app-state.d.ts.map +1 -0
  224. package/dist/modules/app/store/app-state.js +2 -0
  225. package/dist/modules/app/store/app-state.js.map +1 -0
  226. package/dist/modules/app/store/apply-runtime-event.d.ts +4 -0
  227. package/dist/modules/app/store/apply-runtime-event.d.ts.map +1 -0
  228. package/dist/modules/app/store/apply-runtime-event.js +72 -0
  229. package/dist/modules/app/store/apply-runtime-event.js.map +1 -0
  230. package/dist/modules/app/store/create-app-store.d.ts +5 -0
  231. package/dist/modules/app/store/create-app-store.d.ts.map +1 -0
  232. package/dist/modules/app/store/create-app-store.js +49 -0
  233. package/dist/modules/app/store/create-app-store.js.map +1 -0
  234. package/dist/modules/app/store/selectors.d.ts +20 -0
  235. package/dist/modules/app/store/selectors.d.ts.map +1 -0
  236. package/dist/modules/app/store/selectors.js +19 -0
  237. package/dist/modules/app/store/selectors.js.map +1 -0
  238. package/dist/modules/commands/index.d.ts +2 -0
  239. package/dist/modules/commands/index.d.ts.map +1 -0
  240. package/dist/modules/commands/index.js +2 -0
  241. package/dist/modules/commands/index.js.map +1 -0
  242. package/dist/modules/commands/registry.d.ts +11 -0
  243. package/dist/modules/commands/registry.d.ts.map +1 -0
  244. package/dist/modules/commands/registry.js +16 -0
  245. package/dist/modules/commands/registry.js.map +1 -0
  246. package/dist/modules/composer/components/composer.d.ts +17 -0
  247. package/dist/modules/composer/components/composer.d.ts.map +1 -0
  248. package/dist/modules/composer/components/composer.js +35 -0
  249. package/dist/modules/composer/components/composer.js.map +1 -0
  250. package/dist/modules/composer/index.d.ts +6 -0
  251. package/dist/modules/composer/index.d.ts.map +1 -0
  252. package/dist/modules/composer/index.js +5 -0
  253. package/dist/modules/composer/index.js.map +1 -0
  254. package/dist/modules/composer/services/editor.d.ts +9 -0
  255. package/dist/modules/composer/services/editor.d.ts.map +1 -0
  256. package/dist/modules/composer/services/editor.js +39 -0
  257. package/dist/modules/composer/services/editor.js.map +1 -0
  258. package/dist/modules/composer/services/input-intent.d.ts +40 -0
  259. package/dist/modules/composer/services/input-intent.d.ts.map +1 -0
  260. package/dist/modules/composer/services/input-intent.js +58 -0
  261. package/dist/modules/composer/services/input-intent.js.map +1 -0
  262. package/dist/modules/composer/services/suggestions.d.ts +9 -0
  263. package/dist/modules/composer/services/suggestions.d.ts.map +1 -0
  264. package/dist/modules/composer/services/suggestions.js +18 -0
  265. package/dist/modules/composer/services/suggestions.js.map +1 -0
  266. package/dist/modules/composer/types.d.ts +9 -0
  267. package/dist/modules/composer/types.d.ts.map +1 -0
  268. package/dist/modules/composer/types.js +2 -0
  269. package/dist/modules/composer/types.js.map +1 -0
  270. package/dist/modules/conversation/components/transcript-row.d.ts +9 -0
  271. package/dist/modules/conversation/components/transcript-row.d.ts.map +1 -0
  272. package/dist/modules/conversation/components/transcript-row.js +13 -0
  273. package/dist/modules/conversation/components/transcript-row.js.map +1 -0
  274. package/dist/modules/conversation/components/virtual-transcript.d.ts +9 -0
  275. package/dist/modules/conversation/components/virtual-transcript.d.ts.map +1 -0
  276. package/dist/modules/conversation/components/virtual-transcript.js +24 -0
  277. package/dist/modules/conversation/components/virtual-transcript.js.map +1 -0
  278. package/dist/modules/conversation/fixtures.d.ts +3 -0
  279. package/dist/modules/conversation/fixtures.d.ts.map +1 -0
  280. package/dist/modules/conversation/fixtures.js +22 -0
  281. package/dist/modules/conversation/fixtures.js.map +1 -0
  282. package/dist/modules/conversation/index.d.ts +5 -0
  283. package/dist/modules/conversation/index.d.ts.map +1 -0
  284. package/dist/modules/conversation/index.js +4 -0
  285. package/dist/modules/conversation/index.js.map +1 -0
  286. package/dist/modules/conversation/services/input-intent.d.ts +18 -0
  287. package/dist/modules/conversation/services/input-intent.d.ts.map +1 -0
  288. package/dist/modules/conversation/services/input-intent.js +18 -0
  289. package/dist/modules/conversation/services/input-intent.js.map +1 -0
  290. package/dist/modules/conversation/services/markdown-rows.d.ts +5 -0
  291. package/dist/modules/conversation/services/markdown-rows.d.ts.map +1 -0
  292. package/dist/modules/conversation/services/markdown-rows.js +96 -0
  293. package/dist/modules/conversation/services/markdown-rows.js.map +1 -0
  294. package/dist/modules/conversation/services/message-rows.d.ts +8 -0
  295. package/dist/modules/conversation/services/message-rows.d.ts.map +1 -0
  296. package/dist/modules/conversation/services/message-rows.js +141 -0
  297. package/dist/modules/conversation/services/message-rows.js.map +1 -0
  298. package/dist/modules/conversation/services/row-model.d.ts +5 -0
  299. package/dist/modules/conversation/services/row-model.d.ts.map +1 -0
  300. package/dist/modules/conversation/services/row-model.js +11 -0
  301. package/dist/modules/conversation/services/row-model.js.map +1 -0
  302. package/dist/modules/conversation/services/selection.d.ts +10 -0
  303. package/dist/modules/conversation/services/selection.d.ts.map +1 -0
  304. package/dist/modules/conversation/services/selection.js +92 -0
  305. package/dist/modules/conversation/services/selection.js.map +1 -0
  306. package/dist/modules/conversation/services/terminal-cells.d.ts +9 -0
  307. package/dist/modules/conversation/services/terminal-cells.d.ts.map +1 -0
  308. package/dist/modules/conversation/services/terminal-cells.js +24 -0
  309. package/dist/modules/conversation/services/terminal-cells.js.map +1 -0
  310. package/dist/modules/conversation/services/transcript-row-cache.d.ts +10 -0
  311. package/dist/modules/conversation/services/transcript-row-cache.d.ts.map +1 -0
  312. package/dist/modules/conversation/services/transcript-row-cache.js +40 -0
  313. package/dist/modules/conversation/services/transcript-row-cache.js.map +1 -0
  314. package/dist/modules/conversation/services/use-transcript-controller.d.ts +17 -0
  315. package/dist/modules/conversation/services/use-transcript-controller.d.ts.map +1 -0
  316. package/dist/modules/conversation/services/use-transcript-controller.js +157 -0
  317. package/dist/modules/conversation/services/use-transcript-controller.js.map +1 -0
  318. package/dist/modules/conversation/services/wrapping.d.ts +3 -0
  319. package/dist/modules/conversation/services/wrapping.d.ts.map +1 -0
  320. package/dist/modules/conversation/services/wrapping.js +46 -0
  321. package/dist/modules/conversation/services/wrapping.js.map +1 -0
  322. package/dist/modules/conversation/types.d.ts +77 -0
  323. package/dist/modules/conversation/types.d.ts.map +1 -0
  324. package/dist/modules/conversation/types.js +2 -0
  325. package/dist/modules/conversation/types.js.map +1 -0
  326. package/dist/modules/overlays/components/overlay.d.ts +10 -0
  327. package/dist/modules/overlays/components/overlay.d.ts.map +1 -0
  328. package/dist/modules/overlays/components/overlay.js +17 -0
  329. package/dist/modules/overlays/components/overlay.js.map +1 -0
  330. package/dist/modules/overlays/index.d.ts +6 -0
  331. package/dist/modules/overlays/index.d.ts.map +1 -0
  332. package/dist/modules/overlays/index.js +5 -0
  333. package/dist/modules/overlays/index.js.map +1 -0
  334. package/dist/modules/overlays/services/overlay-items.d.ts +20 -0
  335. package/dist/modules/overlays/services/overlay-items.d.ts.map +1 -0
  336. package/dist/modules/overlays/services/overlay-items.js +56 -0
  337. package/dist/modules/overlays/services/overlay-items.js.map +1 -0
  338. package/dist/modules/overlays/services/overlay-registry.d.ts +4 -0
  339. package/dist/modules/overlays/services/overlay-registry.d.ts.map +1 -0
  340. package/dist/modules/overlays/services/overlay-registry.js +42 -0
  341. package/dist/modules/overlays/services/overlay-registry.js.map +1 -0
  342. package/dist/modules/overlays/services/overlay-selection.d.ts +23 -0
  343. package/dist/modules/overlays/services/overlay-selection.d.ts.map +1 -0
  344. package/dist/modules/overlays/services/overlay-selection.js +23 -0
  345. package/dist/modules/overlays/services/overlay-selection.js.map +1 -0
  346. package/dist/modules/overlays/types.d.ts +15 -0
  347. package/dist/modules/overlays/types.d.ts.map +1 -0
  348. package/dist/modules/overlays/types.js +2 -0
  349. package/dist/modules/overlays/types.js.map +1 -0
  350. package/dist/modules/providers/catalog.d.ts +2 -0
  351. package/dist/modules/providers/catalog.d.ts.map +1 -0
  352. package/dist/modules/providers/catalog.js +2 -0
  353. package/dist/modules/providers/catalog.js.map +1 -0
  354. package/dist/modules/providers/index.d.ts +5 -0
  355. package/dist/modules/providers/index.d.ts.map +1 -0
  356. package/dist/modules/providers/index.js +3 -0
  357. package/dist/modules/providers/index.js.map +1 -0
  358. package/dist/modules/providers/services/provider-connection-manager.d.ts +22 -0
  359. package/dist/modules/providers/services/provider-connection-manager.d.ts.map +1 -0
  360. package/dist/modules/providers/services/provider-connection-manager.js +147 -0
  361. package/dist/modules/providers/services/provider-connection-manager.js.map +1 -0
  362. package/dist/modules/providers/types.d.ts +20 -0
  363. package/dist/modules/providers/types.d.ts.map +1 -0
  364. package/dist/modules/providers/types.js +2 -0
  365. package/dist/modules/providers/types.js.map +1 -0
  366. package/dist/modules/sessions/index.d.ts +3 -0
  367. package/dist/modules/sessions/index.d.ts.map +1 -0
  368. package/dist/modules/sessions/index.js +3 -0
  369. package/dist/modules/sessions/index.js.map +1 -0
  370. package/dist/modules/sessions/services/project-session-manager.d.ts +28 -0
  371. package/dist/modules/sessions/services/project-session-manager.d.ts.map +1 -0
  372. package/dist/modules/sessions/services/project-session-manager.js +90 -0
  373. package/dist/modules/sessions/services/project-session-manager.js.map +1 -0
  374. package/dist/modules/sessions/types.d.ts +13 -0
  375. package/dist/modules/sessions/types.d.ts.map +1 -0
  376. package/dist/modules/sessions/types.js +12 -0
  377. package/dist/modules/sessions/types.js.map +1 -0
  378. package/dist/utils/safe-error.d.ts +2 -0
  379. package/dist/utils/safe-error.d.ts.map +1 -0
  380. package/dist/utils/safe-error.js +10 -0
  381. package/dist/utils/safe-error.js.map +1 -0
  382. package/dist/utils/text.d.ts +2 -0
  383. package/dist/utils/text.d.ts.map +1 -0
  384. package/dist/utils/text.js +5 -0
  385. package/dist/utils/text.js.map +1 -0
  386. package/package.json +72 -0
@@ -0,0 +1,98 @@
1
+ import { dirname } from 'node:path';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { FileToolValidationError } from './file-tool-error.js';
4
+ import { validatedPath } from './file-path-safety.js';
5
+ import { assertFreshRead, assertMutableFile, assertMutationSize, displayPath, fileToolError, MAX_MUTATION_BYTES, occurrences, pathExists, rememberFullFile, throwIfAborted, } from './file-tool-operations.js';
6
+ import { decodeText, encodeText, normalizedContent, withLineEnding } from './text-file-codec.js';
7
+ export const editFileOperation = async (context, input, signal) => {
8
+ let path = input.file_path;
9
+ try {
10
+ path = validatedPath(input.file_path);
11
+ if (path.toLowerCase().endsWith('.ipynb')) {
12
+ throw new FileToolValidationError('Notebook files are not supported by Edit.');
13
+ }
14
+ if (input.old_string === input.new_string) {
15
+ throw new FileToolValidationError('old_string and new_string must be different.');
16
+ }
17
+ throwIfAborted(signal);
18
+ const exists = await pathExists(path);
19
+ if (!exists)
20
+ return await createWithEdit(context, path, input, signal);
21
+ const cached = context.cache.get(path);
22
+ if (!cached)
23
+ throw new FileToolValidationError('Read the existing file before editing it.');
24
+ await assertMutableFile(path);
25
+ const buffer = await readFile(path, { signal });
26
+ if (buffer.length > MAX_MUTATION_BYTES)
27
+ throw new FileToolValidationError('The file is too large to edit safely.');
28
+ const decoded = decodeText(buffer);
29
+ const before = normalizedContent(decoded.content);
30
+ await assertFreshRead(path, before, cached);
31
+ const oldString = normalizedContent(input.old_string);
32
+ const newString = normalizedContent(input.new_string);
33
+ if (oldString === newString) {
34
+ throw new FileToolValidationError('old_string and new_string must be different after line-ending normalization.');
35
+ }
36
+ const matchCount = before === '' && oldString === '' ? 1 : occurrences(before, oldString);
37
+ if (matchCount === 0)
38
+ throw new FileToolValidationError('old_string was not found in the file.');
39
+ if (!input.replace_all && matchCount > 1) {
40
+ throw new FileToolValidationError('old_string is not unique. Provide more context or set replace_all to true.');
41
+ }
42
+ const after = oldString === ''
43
+ ? newString
44
+ : input.replace_all
45
+ ? before.split(oldString).join(newString)
46
+ : before.replace(oldString, newString);
47
+ throwIfAborted(signal);
48
+ const encoded = encodeText(withLineEnding(after, decoded.lineEnding), decoded.encoding, decoded.bom);
49
+ assertMutationSize(encoded);
50
+ await writeFile(path, encoded, { signal });
51
+ await rememberFullFile(context, path, after);
52
+ const operationId = context.mutations.record({ file: path, before, after });
53
+ const replacements = input.replace_all ? matchCount : 1;
54
+ return {
55
+ status: 'success',
56
+ tool: 'Edit',
57
+ file_path: displayPath(path),
58
+ replacements,
59
+ operation_id: operationId,
60
+ message: `Replaced ${replacements} occurrence${replacements === 1 ? '' : 's'}.`,
61
+ };
62
+ }
63
+ catch (error) {
64
+ if (signal.aborted)
65
+ throw signal.reason ?? error;
66
+ return fileToolError('Edit', path, error);
67
+ }
68
+ };
69
+ const createWithEdit = async (context, path, input, signal) => {
70
+ if (input.old_string !== '') {
71
+ throw new FileToolValidationError('The file does not exist. Use an empty old_string to create it.');
72
+ }
73
+ await mkdir(dirname(path), { recursive: true });
74
+ throwIfAborted(signal);
75
+ const encoded = Buffer.from(input.new_string, 'utf8');
76
+ assertMutationSize(encoded);
77
+ try {
78
+ await writeFile(path, encoded, { flag: 'wx', signal });
79
+ }
80
+ catch (error) {
81
+ if (error.code === 'EEXIST') {
82
+ throw new FileToolValidationError('The file changed before Edit could create it. Read it and retry.');
83
+ }
84
+ throw error;
85
+ }
86
+ const after = normalizedContent(input.new_string);
87
+ await rememberFullFile(context, path, after);
88
+ const operationId = context.mutations.record({ file: path, before: '', after });
89
+ return {
90
+ status: 'success',
91
+ tool: 'Edit',
92
+ file_path: displayPath(path),
93
+ replacements: 1,
94
+ operation_id: operationId,
95
+ message: 'Created file with Edit.',
96
+ };
97
+ };
98
+ //# sourceMappingURL=edit-file-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-file-operation.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/edit-file-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,aAAa,EAEb,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,cAAc,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAE/F,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACrC,OAAwB,EACxB,KAAgB,EAChB,MAAmB,EACG,EAAE;IACxB,IAAI,IAAI,G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AC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxD,MAAM,IAAI,uBAAuB,CAAC,kEAAkE,CAAC,CAAC;QACvG,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAC,CAAC,CAAC;IAC9E,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,WAAW;QACzB,OAAO,EAAE,yBAAyB;KAClC,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const validatedPath: (value: string) => string;
2
+ //# sourceMappingURL=file-path-safety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-path-safety.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-path-safety.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,MAI7C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { isAbsolute, normalize } from 'node:path';
2
+ import { FileToolValidationError } from './file-tool-error.js';
3
+ export const validatedPath = (value) => {
4
+ if (/^(?:\\\\|\/\/)/u.test(value))
5
+ throw new FileToolValidationError('UNC paths are not supported.');
6
+ if (!isAbsolute(value))
7
+ throw new FileToolValidationError('file_path must be absolute.');
8
+ return normalize(value);
9
+ };
10
+ //# sourceMappingURL=file-path-safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-path-safety.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-path-safety.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAE7D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAU,EAAE;IACtD,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,uBAAuB,CAAC,8BAA8B,CAAC,CAAC;IACrG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,uBAAuB,CAAC,6BAA6B,CAAC,CAAC;IACzF,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export type FileReadState = {
2
+ content: string;
3
+ fingerprint: string;
4
+ timestamp: number;
5
+ offset?: number;
6
+ limit?: number;
7
+ isPartialView?: boolean;
8
+ totalLines: number;
9
+ readLines: number;
10
+ };
11
+ export declare class FileStateCache {
12
+ #private;
13
+ constructor(maxEntries?: number, maxBytes?: number);
14
+ get(path: string): FileReadState | undefined;
15
+ peek(path: string): FileReadState | undefined;
16
+ set(path: string, state: FileReadState): void;
17
+ clear(): void;
18
+ get size(): number;
19
+ get byteSize(): number;
20
+ }
21
+ //# sourceMappingURL=file-state-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-state-cache.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-state-cache.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAOF,qBAAa,cAAc;;IAM1B,YAAY,UAAU,SAAM,EAAE,QAAQ,SAAmB,EAGxD;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAM3C;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE5C;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI,CAW5C;IAED,KAAK,IAAI,IAAI,CAGZ;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;CAUD"}
@@ -0,0 +1,54 @@
1
+ export class FileStateCache {
2
+ #maxEntries;
3
+ #maxBytes;
4
+ #entries = new Map();
5
+ #bytes = 0;
6
+ constructor(maxEntries = 100, maxBytes = 25 * 1024 * 1024) {
7
+ this.#maxEntries = maxEntries;
8
+ this.#maxBytes = maxBytes;
9
+ }
10
+ get(path) {
11
+ const entry = this.#entries.get(path);
12
+ if (!entry)
13
+ return undefined;
14
+ this.#entries.delete(path);
15
+ this.#entries.set(path, entry);
16
+ return entry.state;
17
+ }
18
+ peek(path) {
19
+ return this.#entries.get(path)?.state;
20
+ }
21
+ set(path, state) {
22
+ const existing = this.#entries.get(path);
23
+ if (existing) {
24
+ this.#bytes -= existing.bytes;
25
+ this.#entries.delete(path);
26
+ }
27
+ const bytes = Buffer.byteLength(state.content);
28
+ if (bytes > this.#maxBytes || this.#maxEntries === 0)
29
+ return;
30
+ this.#entries.set(path, { state, bytes });
31
+ this.#bytes += bytes;
32
+ this.#evict();
33
+ }
34
+ clear() {
35
+ this.#entries.clear();
36
+ this.#bytes = 0;
37
+ }
38
+ get size() {
39
+ return this.#entries.size;
40
+ }
41
+ get byteSize() {
42
+ return this.#bytes;
43
+ }
44
+ #evict() {
45
+ while (this.#entries.size > this.#maxEntries || this.#bytes > this.#maxBytes) {
46
+ const oldest = this.#entries.entries().next().value;
47
+ if (!oldest)
48
+ return;
49
+ this.#entries.delete(oldest[0]);
50
+ this.#bytes -= oldest[1].bytes;
51
+ }
52
+ }
53
+ }
54
+ //# sourceMappingURL=file-state-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-state-cache.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-state-cache.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,cAAc;IACjB,WAAW,CAAS;IACpB,SAAS,CAAS;IAClB,QAAQ,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,GAAG,CAAC,CAAC;IAEX,YAAY,UAAU,GAAG,GAAG,EAAE,QAAQ,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;QACxD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,GAAG,CAAC,IAAY;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,IAAY,EAAE,KAAoB;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,QAAQ,EAAE,CAAC;YACd,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Error extends Error {
2
+ }
3
+ //# sourceMappingURL=file-tool-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tool-error.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-tool-error.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;CAAG"}
@@ -0,0 +1,3 @@
1
+ export class FileToolValidationError extends Error {
2
+ }
3
+ //# sourceMappingURL=file-tool-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tool-error.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-tool-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;CAAG"}
@@ -0,0 +1,22 @@
1
+ import type { EditResult, ReadResult, WriteResult } from './contracts.js';
2
+ import type { FileReadState, FileStateCache } from './file-state-cache.js';
3
+ import type { MutationJournal } from './mutation-journal.js';
4
+ export declare const DEFAULT_READ_LIMIT = 2000;
5
+ export declare const MAX_READ_BYTES: number;
6
+ export declare const MAX_MODEL_CONTENT = 100000;
7
+ export declare const MAX_MUTATION_BYTES: number;
8
+ export type FileToolContext = {
9
+ cache: FileStateCache;
10
+ mutations: MutationJournal;
11
+ };
12
+ export declare const contentFingerprint: (content: string) => string;
13
+ export declare const displayPath: (path: string) => string;
14
+ export declare const throwIfAborted: (signal: AbortSignal) => void;
15
+ export declare const fileToolError: (tool: 'Read' | 'Edit' | 'Write', path: string, error: unknown) => ReadResult | EditResult | WriteResult;
16
+ export declare const pathExists: (path: string) => Promise<boolean>;
17
+ export declare const assertMutableFile: (path: string) => Promise<void>;
18
+ export declare const assertFreshRead: (path: string, currentContent: string, cached: FileReadState) => Promise<void>;
19
+ export declare const rememberFullFile: (context: FileToolContext, path: string, content: string) => Promise<void>;
20
+ export declare const assertMutationSize: (buffer: Buffer) => void;
21
+ export declare const occurrences: (content: string, search: string) => number;
22
+ //# sourceMappingURL=file-tool-operations.d.ts.map
@@ -0,0 +1 @@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AM,kBAAkB,WAAY,MAAM,KAAG,IAMnD,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,MAAM,UAAU,MAAM,KAAG,MAS7D,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstat, stat } from 'node:fs/promises';
3
+ import { FileToolValidationError } from './file-tool-error.js';
4
+ export const DEFAULT_READ_LIMIT = 2_000;
5
+ export const MAX_READ_BYTES = 256 * 1024;
6
+ export const MAX_MODEL_CONTENT = 100_000;
7
+ export const MAX_MUTATION_BYTES = 16 * 1024 * 1024;
8
+ export const contentFingerprint = (content) => createHash('sha256').update(content).digest('hex');
9
+ export const displayPath = (path) => path;
10
+ export const throwIfAborted = (signal) => {
11
+ if (signal.aborted)
12
+ throw signal.reason ?? new Error('Aborted');
13
+ };
14
+ export const fileToolError = (tool, path, error) => ({
15
+ status: 'error',
16
+ tool,
17
+ file_path: displayPath(path),
18
+ error: error instanceof Error ? error.message : String(error),
19
+ });
20
+ export const pathExists = async (path) => {
21
+ try {
22
+ await lstat(path);
23
+ return true;
24
+ }
25
+ catch (error) {
26
+ if (error.code === 'ENOENT')
27
+ return false;
28
+ throw error;
29
+ }
30
+ };
31
+ export const assertMutableFile = async (path) => {
32
+ const metadata = await lstat(path);
33
+ if (!metadata.isFile() && !metadata.isSymbolicLink()) {
34
+ throw new FileToolValidationError('The path must point to a regular file.');
35
+ }
36
+ };
37
+ export const assertFreshRead = async (path, currentContent, cached) => {
38
+ const timestamp = Math.floor((await stat(path)).mtimeMs);
39
+ if (contentFingerprint(currentContent) !== cached.fingerprint) {
40
+ throw new FileToolValidationError('The file changed since it was read. Read it again before editing or writing.');
41
+ }
42
+ if (timestamp > cached.timestamp && cached.isPartialView) {
43
+ throw new FileToolValidationError('The file changed since it was read. Read it again before editing or writing.');
44
+ }
45
+ };
46
+ export const rememberFullFile = async (context, path, content) => {
47
+ const metadata = await stat(path);
48
+ const lineCount = content.split('\n').length;
49
+ context.cache.set(path, {
50
+ content,
51
+ fingerprint: contentFingerprint(content),
52
+ timestamp: Math.floor(metadata.mtimeMs),
53
+ totalLines: lineCount,
54
+ readLines: lineCount,
55
+ });
56
+ };
57
+ export const assertMutationSize = (buffer) => {
58
+ if (buffer.length > MAX_MUTATION_BYTES) {
59
+ throw new FileToolValidationError(`The resulting file exceeds the ${MAX_MUTATION_BYTES / 1024 / 1024} MiB mutation limit.`);
60
+ }
61
+ };
62
+ export const occurrences = (content, search) => {
63
+ if (search === '')
64
+ return 0;
65
+ let count = 0;
66
+ let index = 0;
67
+ while ((index = content.indexOf(search, index)) !== -1) {
68
+ count += 1;
69
+ index += search.length;
70
+ }
71
+ return count;
72
+ };
73
+ //# sourceMappingURL=file-tool-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tool-operations.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-tool-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAI7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAOnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAElH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC;AAE1D,MAAM,CAAC,MAAM,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AAC;IAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACxD,KAAK,IAAI,CAAC,CAAC;QACX,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { EditInput, EditResult, ReadInput, ReadResult, WriteInput, WriteResult } from './contracts.js';
2
+ import { FileStateCache } from './file-state-cache.js';
3
+ import { MutationJournal, type FileMutation } from './mutation-journal.js';
4
+ export type { FileMutation } from './mutation-journal.js';
5
+ export declare class FileToolService {
6
+ #private;
7
+ constructor(cache?: FileStateCache, mutations?: MutationJournal);
8
+ read(input: ReadInput, signal: AbortSignal): Promise<ReadResult>;
9
+ edit(input: EditInput, signal: AbortSignal): Promise<EditResult>;
10
+ write(input: WriteInput, signal: AbortSignal): Promise<WriteResult>;
11
+ takeMutation(operationId: string): FileMutation | undefined;
12
+ clear(): void;
13
+ }
14
+ //# sourceMappingURL=file-tool-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tool-service.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-tool-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE1G,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAC,eAAe,EAAE,KAAK,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAIzE,YAAY,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAExD,qBAAa,eAAe;;IAG3B,YAAY,KAAK,iBAAuB,EAAE,SAAS,kBAAwB,EAE1E;IAED,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/D;IAED,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/D;IAED,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAElE;IAED,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE1D;IAED,KAAK,IAAI,IAAI,CAGZ;CACD"}
@@ -0,0 +1,28 @@
1
+ import { editFileOperation } from './edit-file-operation.js';
2
+ import { FileStateCache } from './file-state-cache.js';
3
+ import { MutationJournal } from './mutation-journal.js';
4
+ import { readFileOperation } from './read-file-operation.js';
5
+ import { writeFileOperation } from './write-file-operation.js';
6
+ export class FileToolService {
7
+ #context;
8
+ constructor(cache = new FileStateCache(), mutations = new MutationJournal()) {
9
+ this.#context = { cache, mutations };
10
+ }
11
+ read(input, signal) {
12
+ return readFileOperation(this.#context, input, signal);
13
+ }
14
+ edit(input, signal) {
15
+ return editFileOperation(this.#context, input, signal);
16
+ }
17
+ write(input, signal) {
18
+ return writeFileOperation(this.#context, input, signal);
19
+ }
20
+ takeMutation(operationId) {
21
+ return this.#context.mutations.take(operationId);
22
+ }
23
+ clear() {
24
+ this.#context.cache.clear();
25
+ this.#context.mutations.clear();
26
+ }
27
+ }
28
+ //# sourceMappingURL=file-tool-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-tool-service.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/file-tool-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAC,eAAe,EAAoB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAI7D,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAkB;IAEnC,YAAY,KAAK,GAAG,IAAI,cAAc,EAAE,EAAE,SAAS,GAAG,IAAI,eAAe,EAAE;QAC1E,IAAI,CAAC,QAAQ,GAAG,EAAC,KAAK,EAAE,SAAS,EAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,KAAgB,EAAE,MAAmB;QACzC,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,KAAgB,EAAE,MAAmB;QACzC,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,KAAiB,EAAE,MAAmB;QAC3C,OAAO,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,YAAY,CAAC,WAAmB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACD"}
@@ -0,0 +1,12 @@
1
+ export type FileMutation = {
2
+ file: string;
3
+ before: string;
4
+ after: string;
5
+ };
6
+ export declare class MutationJournal {
7
+ #private;
8
+ record(mutation: FileMutation): string;
9
+ take(operationId: string): FileMutation | undefined;
10
+ clear(): void;
11
+ }
12
+ //# sourceMappingURL=mutation-journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutation-journal.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/mutation-journal.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,eAAe;;IAG3B,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CASrC;IAED,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAIlD;IAED,KAAK,IAAI,IAAI,CAEZ;CACD"}
@@ -0,0 +1,25 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ const MAX_MUTATIONS = 100;
3
+ export class MutationJournal {
4
+ #mutations = new Map();
5
+ record(mutation) {
6
+ const operationId = randomUUID();
7
+ this.#mutations.set(operationId, mutation);
8
+ while (this.#mutations.size > MAX_MUTATIONS) {
9
+ const oldest = this.#mutations.keys().next().value;
10
+ if (!oldest)
11
+ break;
12
+ this.#mutations.delete(oldest);
13
+ }
14
+ return operationId;
15
+ }
16
+ take(operationId) {
17
+ const mutation = this.#mutations.get(operationId);
18
+ this.#mutations.delete(operationId);
19
+ return mutation;
20
+ }
21
+ clear() {
22
+ this.#mutations.clear();
23
+ }
24
+ }
25
+ //# sourceMappingURL=mutation-journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutation-journal.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/mutation-journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAEvC,MAAM,aAAa,GAAG,GAAG,CAAC;AAQ1B,MAAM,OAAO,eAAe;IAClB,UAAU,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEtD,MAAM,CAAC,QAAsB;QAC5B,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,aAAa,EAAE,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAA2B,CAAC;YACzE,IAAI,CAAC,MAAM;gBAAE,MAAM;YACnB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,WAAW,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,WAAmB;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACD"}
@@ -0,0 +1,4 @@
1
+ import type { ReadInput, ReadResult } from './contracts.js';
2
+ import { type FileToolContext } from './file-tool-operations.js';
3
+ export declare const readFileOperation: (context: FileToolContext, input: ReadInput, signal: AbortSignal) => Promise<ReadResult>;
4
+ //# sourceMappingURL=read-file-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file-operation.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/read-file-operation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAKN,KAAK,eAAe,EAIpB,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,iBAAiB,YACpB,eAAe,SACjB,SAAS,UACR,WAAW,KACjB,OAAO,CAAC,UAAU,CAoFpB,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { readFile, stat } from 'node:fs/promises';
2
+ import { decodeText, normalizedContent } from './text-file-codec.js';
3
+ import { FileToolValidationError } from './file-tool-error.js';
4
+ import { validatedPath } from './file-path-safety.js';
5
+ import { contentFingerprint, DEFAULT_READ_LIMIT, displayPath, fileToolError, MAX_MODEL_CONTENT, MAX_READ_BYTES, throwIfAborted, } from './file-tool-operations.js';
6
+ export const readFileOperation = async (context, input, signal) => {
7
+ let path = input.file_path;
8
+ try {
9
+ path = validatedPath(input.file_path);
10
+ throwIfAborted(signal);
11
+ const metadata = await stat(path);
12
+ if (!metadata.isFile())
13
+ throw new FileToolValidationError('The path must point to a regular file.');
14
+ if (metadata.size > MAX_READ_BYTES) {
15
+ throw new FileToolValidationError(`The file exceeds the ${MAX_READ_BYTES / 1024} KiB Read limit.`);
16
+ }
17
+ const decoded = decodeText(await readFile(path, { signal }));
18
+ throwIfAborted(signal);
19
+ const normalized = normalizedContent(decoded.content);
20
+ const fingerprint = contentFingerprint(normalized);
21
+ const startLine = input.offset ?? 1;
22
+ const limit = input.limit ?? DEFAULT_READ_LIMIT;
23
+ const timestamp = Math.floor((await stat(path)).mtimeMs);
24
+ const cached = context.cache.peek(path);
25
+ if (cached &&
26
+ cached.timestamp === timestamp &&
27
+ cached.fingerprint === fingerprint &&
28
+ cached.offset === input.offset &&
29
+ cached.limit === input.limit) {
30
+ return {
31
+ status: 'unchanged',
32
+ tool: 'Read',
33
+ file_path: displayPath(path),
34
+ start_line: startLine,
35
+ num_lines: cached.readLines,
36
+ total_lines: cached.totalLines,
37
+ message: 'File contents are unchanged since the previous read of this range.',
38
+ };
39
+ }
40
+ const lines = normalized.split('\n');
41
+ const selected = lines.slice(startLine - 1, startLine - 1 + limit);
42
+ const formatted = [];
43
+ const cachedLines = [];
44
+ let characters = 0;
45
+ let outputCapped = false;
46
+ for (const [index, line] of selected.entries()) {
47
+ const outputLine = `${startLine + index}\t${line}`;
48
+ const addition = outputLine.length + (formatted.length === 0 ? 0 : 1);
49
+ if (characters + addition > MAX_MODEL_CONTENT) {
50
+ outputCapped = true;
51
+ break;
52
+ }
53
+ formatted.push(outputLine);
54
+ cachedLines.push(line);
55
+ characters += addition;
56
+ }
57
+ if (selected.length > 0 && formatted.length === 0) {
58
+ const prefix = `${startLine}\t`;
59
+ const visible = selected[0]?.slice(0, Math.max(0, MAX_MODEL_CONTENT - prefix.length)) ?? '';
60
+ formatted.push(prefix + visible);
61
+ cachedLines.push(visible);
62
+ outputCapped = visible.length < (selected[0]?.length ?? 0);
63
+ }
64
+ const isPartialView = outputCapped || startLine !== 1 || cachedLines.length < lines.length;
65
+ context.cache.set(path, {
66
+ content: isPartialView ? cachedLines.join('\n') : normalized,
67
+ fingerprint,
68
+ timestamp,
69
+ ...(input.offset === undefined ? {} : { offset: input.offset }),
70
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
71
+ ...(isPartialView ? { isPartialView: true } : {}),
72
+ totalLines: lines.length,
73
+ readLines: cachedLines.length,
74
+ });
75
+ return {
76
+ status: 'success',
77
+ tool: 'Read',
78
+ file_path: displayPath(path),
79
+ content: formatted.join('\n'),
80
+ start_line: startLine,
81
+ num_lines: cachedLines.length,
82
+ total_lines: lines.length,
83
+ truncated: outputCapped,
84
+ };
85
+ }
86
+ catch (error) {
87
+ if (signal.aborted)
88
+ throw signal.reason ?? error;
89
+ return fileToolError('Read', path, error);
90
+ }
91
+ };
92
+ //# sourceMappingURL=read-file-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file-operation.js","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/read-file-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,aAAa,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AAC,CAAC,CAAC,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/C,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,SAAS,EAAE,WAAW,CAAC,MAAM;SAC7B,CAAC,CAAC;QACH,OAAO;YACN,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC;YAC5B,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7B,UAAU,EAAE,SAAS;YACrB,SAAS,EAAE,WAAW,CAAC,MAAM;YAC7B,WAAW,EAAE,KAAK,CAAC,MAAM;YACzB,SAAS,EAAE,YAAY;SACvB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,MAAM,CAAC,OAAO;YAAE,MAAM,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC;QACjD,OAAO,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAe,CAAC;IACzD,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type TextEncoding = 'utf8' | 'utf16le';
2
+ export type LineEnding = '\n' | '\r\n' | '\r';
3
+ export type DecodedFile = {
4
+ content: string;
5
+ encoding: TextEncoding;
6
+ bom: boolean;
7
+ lineEnding: LineEnding;
8
+ };
9
+ export declare const normalizedContent: (content: string) => string;
10
+ export declare const decodeText: (buffer: Buffer) => DecodedFile;
11
+ export declare const encodeText: (content: string, encoding: TextEncoding, bom: boolean) => Buffer;
12
+ export declare const withLineEnding: (content: string, lineEnding: LineEnding) => string;
13
+ //# sourceMappingURL=text-file-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-file-codec.d.ts","sourceRoot":"","sources":["../../../../../src/modules/agent/tools/files/text-file-codec.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,MAA0C,CAAC;AAQ/F,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,WAuB3C,CAAC;AAEF,eAAO,MAAM,UAAU,YAAa,MAAM,YAAY,YAAY,OAAO,OAAO,KAAG,MAKlF,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,MAAM,cAAc,UAAU,KAAG,MACL,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { FileToolValidationError } from './file-tool-error.js';
2
+ export const normalizedContent = (content) => content.replace(/\r\n?/gu, '\n');
3
+ const lineEndingOf = (content) => {
4
+ if (content.includes('\r\n'))
5
+ return '\r\n';
6
+ if (content.includes('\r'))
7
+ return '\r';
8
+ return '\n';
9
+ };
10
+ export const decodeText = (buffer) => {
11
+ let encoding = 'utf8';
12
+ let bom = false;
13
+ let body = buffer;
14
+ if (buffer.length >= 2 && buffer[0] === 0xff && buffer[1] === 0xfe) {
15
+ encoding = 'utf16le';
16
+ bom = true;
17
+ body = buffer.subarray(2);
18
+ if (body.length % 2 !== 0)
19
+ throw new FileToolValidationError('The file is not valid UTF-16LE text.');
20
+ }
21
+ else if (buffer.length >= 3 && buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf) {
22
+ bom = true;
23
+ body = buffer.subarray(3);
24
+ }
25
+ if (encoding === 'utf8' && body.includes(0)) {
26
+ throw new FileToolValidationError('Binary files are not supported.');
27
+ }
28
+ let content;
29
+ try {
30
+ content = new TextDecoder(encoding === 'utf8' ? 'utf-8' : 'utf-16le', { fatal: true }).decode(body);
31
+ }
32
+ catch {
33
+ throw new FileToolValidationError(`The file is not valid ${encoding === 'utf8' ? 'UTF-8' : 'UTF-16LE'} text.`);
34
+ }
35
+ return { content, encoding, bom, lineEnding: lineEndingOf(content) };
36
+ };
37
+ export const encodeText = (content, encoding, bom) => {
38
+ const body = Buffer.from(content, encoding);
39
+ if (!bom)
40
+ return body;
41
+ const marker = encoding === 'utf16le' ? Buffer.from([0xff, 0xfe]) : Buffer.from([0xef, 0xbb, 0xbf]);
42
+ return Buffer.concat([marker, body]);
43
+ };
44
+ export const withLineEnding = (content, lineEnding) => lineEnding === '\n' ? content : content.replace(/\n/gu, lineEnding);
45
+ //# sourceMappingURL=text-file-codec.js.map