@aria-cli/tools 1.0.13 → 1.0.15

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 (478) hide show
  1. package/dist/.aria-build-stamp.json +1 -1
  2. package/dist/ask-user-interaction.d.ts +0 -1
  3. package/dist/cache/web-cache.d.ts +0 -1
  4. package/dist/definitions/arion.d.ts +0 -1
  5. package/dist/definitions/browser/browser.d.ts +0 -1
  6. package/dist/definitions/browser/index.d.ts +0 -1
  7. package/dist/definitions/browser/pw-downloads.d.ts +0 -1
  8. package/dist/definitions/browser/pw-interactions.d.ts +0 -1
  9. package/dist/definitions/browser/pw-responses.d.ts +0 -1
  10. package/dist/definitions/browser/pw-session.d.ts +0 -1
  11. package/dist/definitions/browser/pw-shared.d.ts +0 -1
  12. package/dist/definitions/browser/pw-snapshot.d.ts +0 -1
  13. package/dist/definitions/browser/pw-state.d.ts +0 -1
  14. package/dist/definitions/browser/types.d.ts +0 -1
  15. package/dist/definitions/code-intelligence.d.ts +0 -1
  16. package/dist/definitions/core.d.ts +0 -1
  17. package/dist/definitions/delegation.d.ts +0 -1
  18. package/dist/definitions/deploy.d.ts +0 -1
  19. package/dist/definitions/filesystem.d.ts +0 -1
  20. package/dist/definitions/frg.d.ts +0 -1
  21. package/dist/definitions/index.d.ts +0 -1
  22. package/dist/definitions/memory.d.ts +0 -1
  23. package/dist/definitions/messaging.d.ts +0 -1
  24. package/dist/definitions/meta.d.ts +0 -1
  25. package/dist/definitions/network.d.ts +0 -1
  26. package/dist/definitions/outlook.d.ts +0 -1
  27. package/dist/definitions/patch/apply-patch.d.ts +0 -1
  28. package/dist/definitions/patch/fuzzy-match.d.ts +0 -1
  29. package/dist/definitions/patch/index.d.ts +0 -1
  30. package/dist/definitions/patch/patch-parser.d.ts +0 -1
  31. package/dist/definitions/patch/sandbox-paths.d.ts +0 -1
  32. package/dist/definitions/process/index.d.ts +0 -1
  33. package/dist/definitions/process/process-registry.d.ts +0 -1
  34. package/dist/definitions/process/process.d.ts +0 -1
  35. package/dist/definitions/process/pty-keys.d.ts +0 -1
  36. package/dist/definitions/process/session-slug.d.ts +0 -1
  37. package/dist/definitions/quip.d.ts +0 -1
  38. package/dist/definitions/search.d.ts +0 -1
  39. package/dist/definitions/session-history.d.ts +0 -1
  40. package/dist/definitions/shell.d.ts +0 -1
  41. package/dist/definitions/slack.d.ts +0 -1
  42. package/dist/definitions/web.d.ts +0 -1
  43. package/dist/dns-pinning-vc0r0vpx.js +1 -0
  44. package/dist/executors/apply-patch.d.ts +0 -1
  45. package/dist/executors/arion.d.ts +0 -1
  46. package/dist/executors/code-intelligence.d.ts +0 -1
  47. package/dist/executors/deploy.d.ts +0 -1
  48. package/dist/executors/filesystem.d.ts +0 -1
  49. package/dist/executors/frg-freshness.d.ts +0 -1
  50. package/dist/executors/frg.d.ts +0 -1
  51. package/dist/executors/index.d.ts +0 -1
  52. package/dist/executors/learning-meta.d.ts +0 -1
  53. package/dist/executors/lsp-client.d.ts +0 -1
  54. package/dist/executors/memory.d.ts +0 -1
  55. package/dist/executors/meta.d.ts +0 -1
  56. package/dist/executors/process-registry.d.ts +0 -1
  57. package/dist/executors/pty-session-store.d.ts +0 -1
  58. package/dist/executors/pty.d.ts +0 -1
  59. package/dist/executors/restart.d.ts +0 -1
  60. package/dist/executors/search-freshness.d.ts +0 -1
  61. package/dist/executors/search-types.d.ts +0 -1
  62. package/dist/executors/search.d.ts +0 -1
  63. package/dist/executors/self-diagnose.d.ts +0 -1
  64. package/dist/executors/session-history.d.ts +0 -1
  65. package/dist/executors/shell-safety.d.ts +0 -1
  66. package/dist/executors/shell.d.ts +0 -1
  67. package/dist/executors/utils.d.ts +0 -1
  68. package/dist/executors/web.d.ts +0 -1
  69. package/dist/extraction/content-extraction.d.ts +0 -1
  70. package/dist/extraction/index.d.ts +0 -1
  71. package/dist/headless-control-contract.d.ts +0 -1
  72. package/dist/index-6qew5tp1.js +2 -0
  73. package/dist/index-8xap0se3.js +6 -0
  74. package/dist/index-a2fr1b3x.js +2 -0
  75. package/dist/index-e1r4t0h0.js +8 -0
  76. package/dist/index-syg9gyvy.js +2 -0
  77. package/dist/index-x52t2mbj.js +4 -0
  78. package/dist/index.d.ts +0 -1
  79. package/dist/index.js +372 -71
  80. package/dist/local-control-http-auth.d.ts +0 -1
  81. package/dist/lsp-client-msnj763y.js +1 -0
  82. package/dist/mcp/client.d.ts +0 -1
  83. package/dist/mcp/connection.d.ts +0 -1
  84. package/dist/mcp/index.d.ts +0 -1
  85. package/dist/mcp/jsonrpc.d.ts +0 -1
  86. package/dist/mcp/types.d.ts +0 -1
  87. package/dist/network-control-adapter.d.ts +0 -1
  88. package/dist/network-runtime/address-types.d.ts +0 -1
  89. package/dist/network-runtime/db-owner-fencing.d.ts +0 -1
  90. package/dist/network-runtime/delivery-receipts.d.ts +0 -1
  91. package/dist/network-runtime/direct-endpoint-authority.d.ts +0 -1
  92. package/dist/network-runtime/index.d.ts +0 -1
  93. package/dist/network-runtime/index.js +1 -13
  94. package/dist/network-runtime/local-control-contract.d.ts +0 -1
  95. package/dist/network-runtime/node-store-contract.d.ts +0 -1
  96. package/dist/network-runtime/pair-route-contract.d.ts +0 -1
  97. package/dist/network-runtime/peer-capabilities.d.ts +0 -1
  98. package/dist/network-runtime/peer-principal-ref.d.ts +0 -1
  99. package/dist/network-runtime/peer-state-machine.d.ts +0 -1
  100. package/dist/network-runtime/protocol-schemas.d.ts +0 -1
  101. package/dist/network-runtime/runtime-bootstrap-contract.d.ts +0 -1
  102. package/dist/outlook/desktop-session.d.ts +0 -1
  103. package/dist/policy.d.ts +0 -1
  104. package/dist/providers/brave.d.ts +0 -1
  105. package/dist/providers/duckduckgo.d.ts +0 -1
  106. package/dist/providers/exa.d.ts +0 -1
  107. package/dist/providers/firecrawl.d.ts +0 -1
  108. package/dist/providers/index.d.ts +0 -1
  109. package/dist/providers/jina.d.ts +0 -1
  110. package/dist/providers/router.d.ts +0 -1
  111. package/dist/providers/search-provider.d.ts +0 -1
  112. package/dist/providers/tavily.d.ts +0 -1
  113. package/dist/pty-ff59hy75.js +1 -0
  114. package/dist/quip/desktop-session.d.ts +0 -1
  115. package/dist/registry/index.d.ts +0 -1
  116. package/dist/registry/registry.d.ts +0 -1
  117. package/dist/runtime-socket-local-control-client.d.ts +0 -1
  118. package/dist/security/dns-normalization.d.ts +0 -1
  119. package/dist/security/dns-pinning.d.ts +0 -1
  120. package/dist/security/external-content.d.ts +0 -1
  121. package/dist/security/ssrf.d.ts +0 -1
  122. package/dist/session-history-6gn52xhp.js +1 -0
  123. package/dist/slack/desktop-session.d.ts +0 -1
  124. package/dist/tool-factory.d.ts +0 -1
  125. package/dist/types.d.ts +0 -1
  126. package/dist/utils/retry.d.ts +0 -1
  127. package/dist/utils/safe-parse-json.d.ts +0 -1
  128. package/dist/utils/url.d.ts +0 -1
  129. package/dist-cjs/headless-control-contract.d.ts +35 -35
  130. package/dist-cjs/index.js +171 -186
  131. package/dist-cjs/network-runtime/index.js +3 -3
  132. package/dist-cjs/network-runtime/local-control-contract.d.ts +12 -12
  133. package/package.json +8 -6
  134. package/dist/.tsbuildinfo +0 -1
  135. package/dist/ask-user-interaction.d.ts.map +0 -1
  136. package/dist/ask-user-interaction.js +0 -23
  137. package/dist/ask-user-interaction.js.map +0 -1
  138. package/dist/cache/web-cache.d.ts.map +0 -1
  139. package/dist/cache/web-cache.js +0 -67
  140. package/dist/cache/web-cache.js.map +0 -1
  141. package/dist/definitions/arion.d.ts.map +0 -1
  142. package/dist/definitions/arion.js +0 -105
  143. package/dist/definitions/arion.js.map +0 -1
  144. package/dist/definitions/browser/browser.d.ts.map +0 -1
  145. package/dist/definitions/browser/browser.js +0 -419
  146. package/dist/definitions/browser/browser.js.map +0 -1
  147. package/dist/definitions/browser/index.d.ts.map +0 -1
  148. package/dist/definitions/browser/index.js +0 -5
  149. package/dist/definitions/browser/index.js.map +0 -1
  150. package/dist/definitions/browser/pw-downloads.d.ts.map +0 -1
  151. package/dist/definitions/browser/pw-downloads.js +0 -115
  152. package/dist/definitions/browser/pw-downloads.js.map +0 -1
  153. package/dist/definitions/browser/pw-interactions.d.ts.map +0 -1
  154. package/dist/definitions/browser/pw-interactions.js +0 -200
  155. package/dist/definitions/browser/pw-interactions.js.map +0 -1
  156. package/dist/definitions/browser/pw-responses.d.ts.map +0 -1
  157. package/dist/definitions/browser/pw-responses.js +0 -77
  158. package/dist/definitions/browser/pw-responses.js.map +0 -1
  159. package/dist/definitions/browser/pw-session.d.ts.map +0 -1
  160. package/dist/definitions/browser/pw-session.js +0 -311
  161. package/dist/definitions/browser/pw-session.js.map +0 -1
  162. package/dist/definitions/browser/pw-shared.d.ts.map +0 -1
  163. package/dist/definitions/browser/pw-shared.js +0 -67
  164. package/dist/definitions/browser/pw-shared.js.map +0 -1
  165. package/dist/definitions/browser/pw-snapshot.d.ts.map +0 -1
  166. package/dist/definitions/browser/pw-snapshot.js +0 -302
  167. package/dist/definitions/browser/pw-snapshot.js.map +0 -1
  168. package/dist/definitions/browser/pw-state.d.ts.map +0 -1
  169. package/dist/definitions/browser/pw-state.js +0 -63
  170. package/dist/definitions/browser/pw-state.js.map +0 -1
  171. package/dist/definitions/browser/types.d.ts.map +0 -1
  172. package/dist/definitions/browser/types.js +0 -5
  173. package/dist/definitions/browser/types.js.map +0 -1
  174. package/dist/definitions/code-intelligence.d.ts.map +0 -1
  175. package/dist/definitions/code-intelligence.js +0 -471
  176. package/dist/definitions/code-intelligence.js.map +0 -1
  177. package/dist/definitions/core.d.ts.map +0 -1
  178. package/dist/definitions/core.js +0 -110
  179. package/dist/definitions/core.js.map +0 -1
  180. package/dist/definitions/delegation.d.ts.map +0 -1
  181. package/dist/definitions/delegation.js +0 -513
  182. package/dist/definitions/delegation.js.map +0 -1
  183. package/dist/definitions/deploy.d.ts.map +0 -1
  184. package/dist/definitions/deploy.js +0 -66
  185. package/dist/definitions/deploy.js.map +0 -1
  186. package/dist/definitions/filesystem.d.ts.map +0 -1
  187. package/dist/definitions/filesystem.js +0 -197
  188. package/dist/definitions/filesystem.js.map +0 -1
  189. package/dist/definitions/frg.d.ts.map +0 -1
  190. package/dist/definitions/frg.js +0 -64
  191. package/dist/definitions/frg.js.map +0 -1
  192. package/dist/definitions/index.d.ts.map +0 -1
  193. package/dist/definitions/index.js +0 -21
  194. package/dist/definitions/index.js.map +0 -1
  195. package/dist/definitions/memory.d.ts.map +0 -1
  196. package/dist/definitions/memory.js +0 -124
  197. package/dist/definitions/memory.js.map +0 -1
  198. package/dist/definitions/messaging.d.ts.map +0 -1
  199. package/dist/definitions/messaging.js +0 -626
  200. package/dist/definitions/messaging.js.map +0 -1
  201. package/dist/definitions/meta.d.ts.map +0 -1
  202. package/dist/definitions/meta.js +0 -350
  203. package/dist/definitions/meta.js.map +0 -1
  204. package/dist/definitions/network.d.ts.map +0 -1
  205. package/dist/definitions/network.js +0 -160
  206. package/dist/definitions/network.js.map +0 -1
  207. package/dist/definitions/outlook.d.ts.map +0 -1
  208. package/dist/definitions/outlook.js +0 -278
  209. package/dist/definitions/outlook.js.map +0 -1
  210. package/dist/definitions/patch/apply-patch.d.ts.map +0 -1
  211. package/dist/definitions/patch/apply-patch.js +0 -185
  212. package/dist/definitions/patch/apply-patch.js.map +0 -1
  213. package/dist/definitions/patch/fuzzy-match.d.ts.map +0 -1
  214. package/dist/definitions/patch/fuzzy-match.js +0 -167
  215. package/dist/definitions/patch/fuzzy-match.js.map +0 -1
  216. package/dist/definitions/patch/index.d.ts.map +0 -1
  217. package/dist/definitions/patch/index.js +0 -2
  218. package/dist/definitions/patch/index.js.map +0 -1
  219. package/dist/definitions/patch/patch-parser.d.ts.map +0 -1
  220. package/dist/definitions/patch/patch-parser.js +0 -208
  221. package/dist/definitions/patch/patch-parser.js.map +0 -1
  222. package/dist/definitions/patch/sandbox-paths.d.ts.map +0 -1
  223. package/dist/definitions/patch/sandbox-paths.js +0 -106
  224. package/dist/definitions/patch/sandbox-paths.js.map +0 -1
  225. package/dist/definitions/process/index.d.ts.map +0 -1
  226. package/dist/definitions/process/index.js +0 -5
  227. package/dist/definitions/process/index.js.map +0 -1
  228. package/dist/definitions/process/process-registry.d.ts.map +0 -1
  229. package/dist/definitions/process/process-registry.js +0 -214
  230. package/dist/definitions/process/process-registry.js.map +0 -1
  231. package/dist/definitions/process/process.d.ts.map +0 -1
  232. package/dist/definitions/process/process.js +0 -387
  233. package/dist/definitions/process/process.js.map +0 -1
  234. package/dist/definitions/process/pty-keys.d.ts.map +0 -1
  235. package/dist/definitions/process/pty-keys.js +0 -255
  236. package/dist/definitions/process/pty-keys.js.map +0 -1
  237. package/dist/definitions/process/session-slug.d.ts.map +0 -1
  238. package/dist/definitions/process/session-slug.js +0 -143
  239. package/dist/definitions/process/session-slug.js.map +0 -1
  240. package/dist/definitions/quip.d.ts.map +0 -1
  241. package/dist/definitions/quip.js +0 -196
  242. package/dist/definitions/quip.js.map +0 -1
  243. package/dist/definitions/search.d.ts.map +0 -1
  244. package/dist/definitions/search.js +0 -61
  245. package/dist/definitions/search.js.map +0 -1
  246. package/dist/definitions/session-history.d.ts.map +0 -1
  247. package/dist/definitions/session-history.js +0 -70
  248. package/dist/definitions/session-history.js.map +0 -1
  249. package/dist/definitions/shell.d.ts.map +0 -1
  250. package/dist/definitions/shell.js +0 -182
  251. package/dist/definitions/shell.js.map +0 -1
  252. package/dist/definitions/slack.d.ts.map +0 -1
  253. package/dist/definitions/slack.js +0 -181
  254. package/dist/definitions/slack.js.map +0 -1
  255. package/dist/definitions/web.d.ts.map +0 -1
  256. package/dist/definitions/web.js +0 -110
  257. package/dist/definitions/web.js.map +0 -1
  258. package/dist/executors/apply-patch.d.ts.map +0 -1
  259. package/dist/executors/apply-patch.js +0 -902
  260. package/dist/executors/apply-patch.js.map +0 -1
  261. package/dist/executors/arion.d.ts.map +0 -1
  262. package/dist/executors/arion.js +0 -120
  263. package/dist/executors/arion.js.map +0 -1
  264. package/dist/executors/code-intelligence.d.ts.map +0 -1
  265. package/dist/executors/code-intelligence.js +0 -883
  266. package/dist/executors/code-intelligence.js.map +0 -1
  267. package/dist/executors/deploy.d.ts.map +0 -1
  268. package/dist/executors/deploy.js +0 -849
  269. package/dist/executors/deploy.js.map +0 -1
  270. package/dist/executors/filesystem.d.ts.map +0 -1
  271. package/dist/executors/filesystem.js +0 -1123
  272. package/dist/executors/filesystem.js.map +0 -1
  273. package/dist/executors/frg-freshness.d.ts.map +0 -1
  274. package/dist/executors/frg-freshness.js +0 -577
  275. package/dist/executors/frg-freshness.js.map +0 -1
  276. package/dist/executors/frg.d.ts.map +0 -1
  277. package/dist/executors/frg.js +0 -299
  278. package/dist/executors/frg.js.map +0 -1
  279. package/dist/executors/index.d.ts.map +0 -1
  280. package/dist/executors/index.js +0 -47
  281. package/dist/executors/index.js.map +0 -1
  282. package/dist/executors/learning-meta.d.ts.map +0 -1
  283. package/dist/executors/learning-meta.js +0 -1147
  284. package/dist/executors/learning-meta.js.map +0 -1
  285. package/dist/executors/lsp-client.d.ts.map +0 -1
  286. package/dist/executors/lsp-client.js +0 -297
  287. package/dist/executors/lsp-client.js.map +0 -1
  288. package/dist/executors/memory.d.ts.map +0 -1
  289. package/dist/executors/memory.js +0 -751
  290. package/dist/executors/memory.js.map +0 -1
  291. package/dist/executors/meta.d.ts.map +0 -1
  292. package/dist/executors/meta.js +0 -221
  293. package/dist/executors/meta.js.map +0 -1
  294. package/dist/executors/process-registry.d.ts.map +0 -1
  295. package/dist/executors/process-registry.js +0 -466
  296. package/dist/executors/process-registry.js.map +0 -1
  297. package/dist/executors/pty-session-store.d.ts.map +0 -1
  298. package/dist/executors/pty-session-store.js +0 -31
  299. package/dist/executors/pty-session-store.js.map +0 -1
  300. package/dist/executors/pty.d.ts.map +0 -1
  301. package/dist/executors/pty.js +0 -272
  302. package/dist/executors/pty.js.map +0 -1
  303. package/dist/executors/restart.d.ts.map +0 -1
  304. package/dist/executors/restart.js +0 -120
  305. package/dist/executors/restart.js.map +0 -1
  306. package/dist/executors/search-freshness.d.ts.map +0 -1
  307. package/dist/executors/search-freshness.js +0 -196
  308. package/dist/executors/search-freshness.js.map +0 -1
  309. package/dist/executors/search-types.d.ts.map +0 -1
  310. package/dist/executors/search-types.js +0 -53
  311. package/dist/executors/search-types.js.map +0 -1
  312. package/dist/executors/search.d.ts.map +0 -1
  313. package/dist/executors/search.js +0 -67
  314. package/dist/executors/search.js.map +0 -1
  315. package/dist/executors/self-diagnose.d.ts.map +0 -1
  316. package/dist/executors/self-diagnose.js +0 -399
  317. package/dist/executors/self-diagnose.js.map +0 -1
  318. package/dist/executors/session-history.d.ts.map +0 -1
  319. package/dist/executors/session-history.js +0 -284
  320. package/dist/executors/session-history.js.map +0 -1
  321. package/dist/executors/shell-safety.d.ts.map +0 -1
  322. package/dist/executors/shell-safety.js +0 -474
  323. package/dist/executors/shell-safety.js.map +0 -1
  324. package/dist/executors/shell.d.ts.map +0 -1
  325. package/dist/executors/shell.js +0 -955
  326. package/dist/executors/shell.js.map +0 -1
  327. package/dist/executors/utils.d.ts.map +0 -1
  328. package/dist/executors/utils.js +0 -34
  329. package/dist/executors/utils.js.map +0 -1
  330. package/dist/executors/web.d.ts.map +0 -1
  331. package/dist/executors/web.js +0 -543
  332. package/dist/executors/web.js.map +0 -1
  333. package/dist/extraction/content-extraction.d.ts.map +0 -1
  334. package/dist/extraction/content-extraction.js +0 -236
  335. package/dist/extraction/content-extraction.js.map +0 -1
  336. package/dist/extraction/index.d.ts.map +0 -1
  337. package/dist/extraction/index.js +0 -5
  338. package/dist/extraction/index.js.map +0 -1
  339. package/dist/headless-control-contract.d.ts.map +0 -1
  340. package/dist/headless-control-contract.js +0 -968
  341. package/dist/headless-control-contract.js.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/index.js.map +0 -1
  344. package/dist/local-control-http-auth.d.ts.map +0 -1
  345. package/dist/local-control-http-auth.js +0 -3
  346. package/dist/local-control-http-auth.js.map +0 -1
  347. package/dist/mcp/client.d.ts.map +0 -1
  348. package/dist/mcp/client.js +0 -182
  349. package/dist/mcp/client.js.map +0 -1
  350. package/dist/mcp/connection.d.ts.map +0 -1
  351. package/dist/mcp/connection.js +0 -481
  352. package/dist/mcp/connection.js.map +0 -1
  353. package/dist/mcp/index.d.ts.map +0 -1
  354. package/dist/mcp/index.js +0 -11
  355. package/dist/mcp/index.js.map +0 -1
  356. package/dist/mcp/jsonrpc.d.ts.map +0 -1
  357. package/dist/mcp/jsonrpc.js +0 -145
  358. package/dist/mcp/jsonrpc.js.map +0 -1
  359. package/dist/mcp/types.d.ts.map +0 -1
  360. package/dist/mcp/types.js +0 -8
  361. package/dist/mcp/types.js.map +0 -1
  362. package/dist/network-control-adapter.d.ts.map +0 -1
  363. package/dist/network-control-adapter.js +0 -73
  364. package/dist/network-control-adapter.js.map +0 -1
  365. package/dist/network-runtime/address-types.d.ts.map +0 -1
  366. package/dist/network-runtime/address-types.js +0 -166
  367. package/dist/network-runtime/address-types.js.map +0 -1
  368. package/dist/network-runtime/db-owner-fencing.d.ts.map +0 -1
  369. package/dist/network-runtime/db-owner-fencing.js +0 -70
  370. package/dist/network-runtime/db-owner-fencing.js.map +0 -1
  371. package/dist/network-runtime/delivery-receipts.d.ts.map +0 -1
  372. package/dist/network-runtime/delivery-receipts.js +0 -268
  373. package/dist/network-runtime/delivery-receipts.js.map +0 -1
  374. package/dist/network-runtime/direct-endpoint-authority.d.ts.map +0 -1
  375. package/dist/network-runtime/direct-endpoint-authority.js +0 -26
  376. package/dist/network-runtime/direct-endpoint-authority.js.map +0 -1
  377. package/dist/network-runtime/index.d.ts.map +0 -1
  378. package/dist/network-runtime/index.js.map +0 -1
  379. package/dist/network-runtime/local-control-contract.d.ts.map +0 -1
  380. package/dist/network-runtime/local-control-contract.js +0 -628
  381. package/dist/network-runtime/local-control-contract.js.map +0 -1
  382. package/dist/network-runtime/node-store-contract.d.ts.map +0 -1
  383. package/dist/network-runtime/node-store-contract.js +0 -35
  384. package/dist/network-runtime/node-store-contract.js.map +0 -1
  385. package/dist/network-runtime/pair-route-contract.d.ts.map +0 -1
  386. package/dist/network-runtime/pair-route-contract.js +0 -78
  387. package/dist/network-runtime/pair-route-contract.js.map +0 -1
  388. package/dist/network-runtime/peer-capabilities.d.ts.map +0 -1
  389. package/dist/network-runtime/peer-capabilities.js +0 -29
  390. package/dist/network-runtime/peer-capabilities.js.map +0 -1
  391. package/dist/network-runtime/peer-principal-ref.d.ts.map +0 -1
  392. package/dist/network-runtime/peer-principal-ref.js +0 -13
  393. package/dist/network-runtime/peer-principal-ref.js.map +0 -1
  394. package/dist/network-runtime/peer-state-machine.d.ts.map +0 -1
  395. package/dist/network-runtime/peer-state-machine.js +0 -122
  396. package/dist/network-runtime/peer-state-machine.js.map +0 -1
  397. package/dist/network-runtime/protocol-schemas.d.ts.map +0 -1
  398. package/dist/network-runtime/protocol-schemas.js +0 -206
  399. package/dist/network-runtime/protocol-schemas.js.map +0 -1
  400. package/dist/network-runtime/runtime-bootstrap-contract.d.ts.map +0 -1
  401. package/dist/network-runtime/runtime-bootstrap-contract.js +0 -61
  402. package/dist/network-runtime/runtime-bootstrap-contract.js.map +0 -1
  403. package/dist/outlook/desktop-session.d.ts.map +0 -1
  404. package/dist/outlook/desktop-session.js +0 -280
  405. package/dist/outlook/desktop-session.js.map +0 -1
  406. package/dist/policy.d.ts.map +0 -1
  407. package/dist/policy.js +0 -150
  408. package/dist/policy.js.map +0 -1
  409. package/dist/providers/brave.d.ts.map +0 -1
  410. package/dist/providers/brave.js +0 -63
  411. package/dist/providers/brave.js.map +0 -1
  412. package/dist/providers/duckduckgo.d.ts.map +0 -1
  413. package/dist/providers/duckduckgo.js +0 -177
  414. package/dist/providers/duckduckgo.js.map +0 -1
  415. package/dist/providers/exa.d.ts.map +0 -1
  416. package/dist/providers/exa.js +0 -64
  417. package/dist/providers/exa.js.map +0 -1
  418. package/dist/providers/firecrawl.d.ts.map +0 -1
  419. package/dist/providers/firecrawl.js +0 -56
  420. package/dist/providers/firecrawl.js.map +0 -1
  421. package/dist/providers/index.d.ts.map +0 -1
  422. package/dist/providers/index.js +0 -8
  423. package/dist/providers/index.js.map +0 -1
  424. package/dist/providers/jina.d.ts.map +0 -1
  425. package/dist/providers/jina.js +0 -50
  426. package/dist/providers/jina.js.map +0 -1
  427. package/dist/providers/router.d.ts.map +0 -1
  428. package/dist/providers/router.js +0 -97
  429. package/dist/providers/router.js.map +0 -1
  430. package/dist/providers/search-provider.d.ts.map +0 -1
  431. package/dist/providers/search-provider.js +0 -33
  432. package/dist/providers/search-provider.js.map +0 -1
  433. package/dist/providers/tavily.d.ts.map +0 -1
  434. package/dist/providers/tavily.js +0 -55
  435. package/dist/providers/tavily.js.map +0 -1
  436. package/dist/quip/desktop-session.d.ts.map +0 -1
  437. package/dist/quip/desktop-session.js +0 -318
  438. package/dist/quip/desktop-session.js.map +0 -1
  439. package/dist/registry/index.d.ts.map +0 -1
  440. package/dist/registry/index.js +0 -2
  441. package/dist/registry/index.js.map +0 -1
  442. package/dist/registry/registry.d.ts.map +0 -1
  443. package/dist/registry/registry.js +0 -757
  444. package/dist/registry/registry.js.map +0 -1
  445. package/dist/runtime-socket-local-control-client.d.ts.map +0 -1
  446. package/dist/runtime-socket-local-control-client.js +0 -331
  447. package/dist/runtime-socket-local-control-client.js.map +0 -1
  448. package/dist/security/dns-normalization.d.ts.map +0 -1
  449. package/dist/security/dns-normalization.js +0 -20
  450. package/dist/security/dns-normalization.js.map +0 -1
  451. package/dist/security/dns-pinning.d.ts.map +0 -1
  452. package/dist/security/dns-pinning.js +0 -124
  453. package/dist/security/dns-pinning.js.map +0 -1
  454. package/dist/security/external-content.d.ts.map +0 -1
  455. package/dist/security/external-content.js +0 -92
  456. package/dist/security/external-content.js.map +0 -1
  457. package/dist/security/ssrf.d.ts.map +0 -1
  458. package/dist/security/ssrf.js +0 -182
  459. package/dist/security/ssrf.js.map +0 -1
  460. package/dist/slack/desktop-session.d.ts.map +0 -1
  461. package/dist/slack/desktop-session.js +0 -325
  462. package/dist/slack/desktop-session.js.map +0 -1
  463. package/dist/tool-factory.d.ts.map +0 -1
  464. package/dist/tool-factory.js +0 -48
  465. package/dist/tool-factory.js.map +0 -1
  466. package/dist/types.d.ts.map +0 -1
  467. package/dist/types.js +0 -8
  468. package/dist/types.js.map +0 -1
  469. package/dist/utils/retry.d.ts.map +0 -1
  470. package/dist/utils/retry.js +0 -133
  471. package/dist/utils/retry.js.map +0 -1
  472. package/dist/utils/safe-parse-json.d.ts.map +0 -1
  473. package/dist/utils/safe-parse-json.js +0 -161
  474. package/dist/utils/safe-parse-json.js.map +0 -1
  475. package/dist/utils/url.d.ts.map +0 -1
  476. package/dist/utils/url.js +0 -20
  477. package/dist/utils/url.js.map +0 -1
  478. package/dist-cjs/.tsbuildinfo +0 -1
@@ -1,1123 +0,0 @@
1
- /**
2
- * @aria/tools - Filesystem tool executors
3
- *
4
- * Implementation of filesystem operations for ARIA tool system.
5
- */
6
- import * as fs from "node:fs/promises";
7
- import * as fsSync from "node:fs";
8
- import * as nodePath from "node:path";
9
- import * as crypto from "node:crypto";
10
- import * as readline from "node:readline";
11
- import { structuredPatch as computePatch } from "diff";
12
- import fastGlob from "fast-glob";
13
- import { success, fail, getErrorMessage, isPathWithinBase } from "./utils.js";
14
- import { recordFrgMutation } from "./frg-freshness.js";
15
- import { recordSearchMutation } from "./search-freshness.js";
16
- /** Media file extensions for binary reading */
17
- const MEDIA_EXTENSIONS = new Set([
18
- ".png",
19
- ".jpg",
20
- ".jpeg",
21
- ".gif",
22
- ".webp",
23
- ".svg",
24
- ".bmp",
25
- ".ico",
26
- ".mp3",
27
- ".wav",
28
- ".ogg",
29
- ".flac",
30
- ".aac",
31
- ".mp4",
32
- ".webm",
33
- ".mov",
34
- ".pdf",
35
- ]);
36
- /** MIME type lookup */
37
- const MIME_TYPES = {
38
- ".png": "image/png",
39
- ".jpg": "image/jpeg",
40
- ".jpeg": "image/jpeg",
41
- ".gif": "image/gif",
42
- ".webp": "image/webp",
43
- ".svg": "image/svg+xml",
44
- ".bmp": "image/bmp",
45
- ".ico": "image/x-icon",
46
- ".mp3": "audio/mpeg",
47
- ".wav": "audio/wav",
48
- ".ogg": "audio/ogg",
49
- ".flac": "audio/flac",
50
- ".aac": "audio/aac",
51
- ".mp4": "video/mp4",
52
- ".webm": "video/webm",
53
- ".mov": "video/quicktime",
54
- ".pdf": "application/pdf",
55
- };
56
- const MAX_MEDIA_SIZE_BYTES = 10 * 1024 * 1024; // 10MB
57
- const DEFAULT_READ_LIMIT = 2000;
58
- const MAX_READ_BYTES = 200 * 1024; // 200KB
59
- /**
60
- * Hard output caps to avoid overwhelming tool responses.
61
- * read_file already has media-size capping and line slicing support.
62
- */
63
- export const FILESYSTEM_OUTPUT_LIMITS = {
64
- MAX_GLOB_RESULTS: 2000,
65
- MAX_GREP_MATCHES: 2000,
66
- MAX_GREP_ERRORS: 200,
67
- MAX_GREP_FILE_BYTES: 2 * 1024 * 1024,
68
- MAX_GREP_LINE_BYTES: 16 * 1024,
69
- };
70
- /**
71
- * Normalize common aliases before passing encodings to Node fs APIs.
72
- */
73
- const SUPPORTED_ENCODINGS = new Set([
74
- "utf8",
75
- "utf16le",
76
- "latin1",
77
- "ascii",
78
- "base64",
79
- "base64url",
80
- "hex",
81
- "ucs2",
82
- "binary",
83
- ]);
84
- function normalizeEncoding(inputEncoding) {
85
- if (!inputEncoding)
86
- return "utf8";
87
- const normalized = inputEncoding.toLowerCase();
88
- const canonical = normalized === "utf-8" ? "utf8" : normalized;
89
- if (!SUPPORTED_ENCODINGS.has(canonical)) {
90
- throw new Error(`Unsupported encoding: ${inputEncoding}`);
91
- }
92
- return canonical;
93
- }
94
- /**
95
- * Sensitive dot-directories under $HOME that must never be accessed by tools.
96
- * These contain credentials, keys, and tokens that have no legitimate use in
97
- * ARIA's filesystem operations.
98
- */
99
- const BLOCKED_HOME_DIRS = new Set([
100
- ".ssh",
101
- ".gnupg",
102
- ".gpg",
103
- ".aws",
104
- ".azure",
105
- ".config/gcloud",
106
- ".docker",
107
- ".kube",
108
- ".npmrc",
109
- ".pypirc",
110
- ".netrc",
111
- ".git-credentials",
112
- ".password-store",
113
- ]);
114
- /**
115
- * Returns true if `resolved` falls inside a blocked sensitive directory under home.
116
- * Paths are compared after normalisation so symlink tricks don't bypass.
117
- */
118
- function isBlockedHomePath(resolved, realHome) {
119
- // Strip home prefix to get the relative tail, e.g. ".ssh/id_rsa"
120
- const homePrefix = realHome.endsWith(nodePath.sep) ? realHome : realHome + nodePath.sep;
121
- if (!resolved.startsWith(homePrefix))
122
- return false;
123
- const tail = resolved.slice(homePrefix.length);
124
- for (const blocked of BLOCKED_HOME_DIRS) {
125
- if (tail === blocked || tail.startsWith(blocked + nodePath.sep)) {
126
- return true;
127
- }
128
- }
129
- return false;
130
- }
131
- /**
132
- * Resolves a path relative to the working directory if not absolute.
133
- * Resolves symlinks to prevent bypassing path restrictions.
134
- * Throws if the resolved path is outside the working directory (path traversal protection).
135
- */
136
- function resolvePath(inputPath, ctx) {
137
- let resolved = nodePath.isAbsolute(inputPath)
138
- ? nodePath.resolve(inputPath)
139
- : nodePath.resolve(ctx.workingDir, inputPath);
140
- // Resolve symlinks on both the path and the base to prevent bypass
141
- // and to handle platforms where /tmp → /private/tmp (macOS)
142
- let realBase = ctx.workingDir;
143
- try {
144
- realBase = fsSync.realpathSync(ctx.workingDir);
145
- }
146
- catch {
147
- // Base dir should exist, but fall back to original if not
148
- }
149
- try {
150
- resolved = fsSync.realpathSync(resolved);
151
- }
152
- catch {
153
- // Path may not exist yet (write to new file / mkdir).
154
- // Walk up to find the nearest existing ancestor and resolve from there,
155
- // to handle symlinked temp dirs (e.g., /tmp → /private/tmp on macOS).
156
- let current = resolved;
157
- let suffix = "";
158
- while (current !== nodePath.dirname(current)) {
159
- const parent = nodePath.dirname(current);
160
- suffix = suffix
161
- ? nodePath.join(nodePath.basename(current), suffix)
162
- : nodePath.basename(current);
163
- try {
164
- const realAncestor = fsSync.realpathSync(parent);
165
- resolved = nodePath.join(realAncestor, suffix);
166
- break;
167
- }
168
- catch {
169
- current = parent;
170
- }
171
- }
172
- }
173
- // 1. Check working directory containment (standard sandbox)
174
- if (isPathWithinBase(resolved, realBase)) {
175
- return resolved;
176
- }
177
- // 2. Check home directory containment (allows access to ~/.aria/, ~/projects, etc.)
178
- // Sensitive dot-directories are blocklisted unless autonomy is "full".
179
- const home = process.env.HOME;
180
- if (home) {
181
- try {
182
- const realHome = fsSync.realpathSync(home);
183
- if (isPathWithinBase(resolved, realHome)) {
184
- if (ctx.autonomy !== "full" && isBlockedHomePath(resolved, realHome)) {
185
- throw new Error(`Path not allowed: access to sensitive home directory is blocked (set autonomy to "full" to override)`);
186
- }
187
- return resolved;
188
- }
189
- }
190
- catch (err) {
191
- if (err instanceof Error && err.message.includes("sensitive home directory")) {
192
- throw err;
193
- }
194
- // Home not accessible/exists — fall through to final guard
195
- }
196
- }
197
- // Always enforce containment. This closes bypasses where
198
- // absolute paths could escape the workspace if outer sandboxing is misconfigured.
199
- throw new Error(`Path traversal not allowed: resolved path is outside working directory and home directory`);
200
- }
201
- function normalizeLineEndings(text) {
202
- return text.replace(/\r\n/g, "\n");
203
- }
204
- function hashSha256(text) {
205
- return crypto.createHash("sha256").update(text, "utf8").digest("hex");
206
- }
207
- function splitLinesWithoutTrailingEmpty(content) {
208
- const lines = content.split("\n");
209
- if (content.endsWith("\n") && lines.length > 0 && lines[lines.length - 1] === "") {
210
- lines.pop();
211
- }
212
- return lines;
213
- }
214
- function getReadWindow(content, offset, limit) {
215
- const lines = splitLinesWithoutTrailingEmpty(content);
216
- const startLine = Math.max(0, offset);
217
- const maxLines = Math.max(1, limit);
218
- const sliced = lines.slice(startLine, startLine + maxLines);
219
- const visible = [];
220
- let bytes = 0;
221
- let truncatedByBytes = false;
222
- for (const line of sliced) {
223
- const lineBytes = Buffer.byteLength(line, "utf8");
224
- const separatorBytes = visible.length > 0 ? 1 : 0; // "\n"
225
- if (bytes + lineBytes + separatorBytes > MAX_READ_BYTES) {
226
- truncatedByBytes = true;
227
- break;
228
- }
229
- visible.push(line);
230
- bytes += lineBytes + separatorBytes;
231
- }
232
- const endExclusive = startLine + visible.length;
233
- const truncatedByLines = endExclusive < lines.length;
234
- const truncated = truncatedByBytes || truncatedByLines;
235
- const nextOffset = truncated ? endExclusive : undefined;
236
- return {
237
- content: visible.join("\n"),
238
- startLine,
239
- endLine: endExclusive,
240
- totalLines: lines.length,
241
- truncated,
242
- nextOffset,
243
- bytes,
244
- };
245
- }
246
- async function getReadWindowFromFile(filePath, encoding, offset, limit) {
247
- const startLine = Math.max(0, offset);
248
- const maxLines = Math.max(1, limit);
249
- const visible = [];
250
- let bytes = 0;
251
- let totalLines = 0;
252
- let truncatedByBytes = false;
253
- let hasExtraLines = false;
254
- const input = fsSync.createReadStream(filePath, { encoding });
255
- const lines = readline.createInterface({ input, crlfDelay: Infinity });
256
- try {
257
- for await (const line of lines) {
258
- totalLines++;
259
- if (totalLines <= startLine) {
260
- continue;
261
- }
262
- if (visible.length >= maxLines) {
263
- hasExtraLines = true;
264
- continue;
265
- }
266
- const lineBytes = Buffer.byteLength(line, encoding);
267
- const separatorBytes = visible.length > 0 ? 1 : 0;
268
- if (bytes + lineBytes + separatorBytes > MAX_READ_BYTES) {
269
- truncatedByBytes = true;
270
- hasExtraLines = true;
271
- continue;
272
- }
273
- visible.push(line);
274
- bytes += lineBytes + separatorBytes;
275
- }
276
- }
277
- finally {
278
- lines.close();
279
- input.destroy();
280
- }
281
- const endExclusive = startLine + visible.length;
282
- const truncatedByLines = hasExtraLines;
283
- const truncated = truncatedByBytes || truncatedByLines;
284
- const nextOffset = truncated ? endExclusive : undefined;
285
- return {
286
- content: visible.join("\n"),
287
- startLine,
288
- endLine: endExclusive,
289
- totalLines,
290
- truncated,
291
- nextOffset,
292
- bytes,
293
- };
294
- }
295
- function dedupeRanges(ranges) {
296
- const seen = new Set();
297
- const result = [];
298
- for (const range of ranges) {
299
- const key = `${range.start}:${range.end}`;
300
- if (seen.has(key))
301
- continue;
302
- seen.add(key);
303
- result.push(range);
304
- }
305
- return result.sort((a, b) => a.start - b.start || a.end - b.end);
306
- }
307
- function countLeadingWhitespace(line) {
308
- const match = line.match(/^[\t ]*/);
309
- return match ? match[0].length : 0;
310
- }
311
- function stripCommonIndent(lines) {
312
- let min = Number.POSITIVE_INFINITY;
313
- for (const line of lines) {
314
- if (line.trim().length === 0)
315
- continue;
316
- min = Math.min(min, countLeadingWhitespace(line));
317
- }
318
- if (!Number.isFinite(min) || min <= 0)
319
- return [...lines];
320
- return lines.map((line) => (line.trim().length === 0 ? line : line.slice(min)));
321
- }
322
- function lineStartOffsets(content) {
323
- const starts = [0];
324
- for (let i = 0; i < content.length; i++) {
325
- if (content[i] === "\n") {
326
- starts.push(i + 1);
327
- }
328
- }
329
- return starts;
330
- }
331
- function normalizeSearchLines(raw) {
332
- const lines = [...raw];
333
- if (lines.length > 0 && lines[lines.length - 1] === "") {
334
- lines.pop();
335
- }
336
- return lines;
337
- }
338
- function getLineWindowRanges(content, oldText, predicate) {
339
- if (!oldText.includes("\n"))
340
- return [];
341
- const contentLines = content.split("\n");
342
- const searchLines = normalizeSearchLines(oldText.split("\n"));
343
- if (searchLines.length === 0 || searchLines.length > contentLines.length) {
344
- return [];
345
- }
346
- const starts = lineStartOffsets(content);
347
- const ranges = [];
348
- for (let i = 0; i <= contentLines.length - searchLines.length; i++) {
349
- const window = contentLines.slice(i, i + searchLines.length);
350
- if (!predicate(window, searchLines))
351
- continue;
352
- const start = starts[i] ?? 0;
353
- const lastLineIdx = i + searchLines.length - 1;
354
- const lineStart = starts[lastLineIdx] ?? 0;
355
- const line = contentLines[lastLineIdx] ?? "";
356
- const end = lineStart + line.length;
357
- ranges.push({ start, end });
358
- }
359
- return dedupeRanges(ranges);
360
- }
361
- function findExactRanges(content, oldText) {
362
- if (oldText.length === 0)
363
- return [];
364
- const ranges = [];
365
- let cursor = 0;
366
- while (cursor <= content.length) {
367
- const idx = content.indexOf(oldText, cursor);
368
- if (idx === -1)
369
- break;
370
- ranges.push({ start: idx, end: idx + oldText.length });
371
- cursor = idx + Math.max(oldText.length, 1);
372
- }
373
- return dedupeRanges(ranges);
374
- }
375
- function findTrimmedLineBlockRanges(content, oldText) {
376
- const trimmedNeedle = oldText.trim();
377
- if (trimmedNeedle.length === 0)
378
- return [];
379
- if (!oldText.includes("\n")) {
380
- const lines = content.split("\n");
381
- const starts = lineStartOffsets(content);
382
- const ranges = [];
383
- for (let i = 0; i < lines.length; i++) {
384
- if ((lines[i] ?? "").trim() !== trimmedNeedle)
385
- continue;
386
- const start = starts[i] ?? 0;
387
- const line = lines[i] ?? "";
388
- ranges.push({ start, end: start + line.length });
389
- }
390
- return dedupeRanges(ranges);
391
- }
392
- return getLineWindowRanges(content, oldText, (window, search) => window.every((line, idx) => line.trim() === (search[idx] ?? "").trim()));
393
- }
394
- function findIndentFlexibleRanges(content, oldText) {
395
- return getLineWindowRanges(content, oldText, (window, search) => {
396
- const normalizedWindow = stripCommonIndent(window);
397
- const normalizedSearch = stripCommonIndent(search);
398
- if (normalizedWindow.length !== normalizedSearch.length)
399
- return false;
400
- for (let i = 0; i < normalizedWindow.length; i++) {
401
- if ((normalizedWindow[i] ?? "") !== (normalizedSearch[i] ?? ""))
402
- return false;
403
- }
404
- return true;
405
- });
406
- }
407
- function normalizeWhitespace(line) {
408
- return line.trim().replace(/\s+/g, " ");
409
- }
410
- function findWhitespaceNormalizedRanges(content, oldText) {
411
- if (!oldText.includes("\n")) {
412
- const needle = normalizeWhitespace(oldText);
413
- if (!needle)
414
- return [];
415
- const lines = content.split("\n");
416
- const starts = lineStartOffsets(content);
417
- const ranges = [];
418
- for (let i = 0; i < lines.length; i++) {
419
- const line = lines[i] ?? "";
420
- if (normalizeWhitespace(line) !== needle)
421
- continue;
422
- const start = starts[i] ?? 0;
423
- ranges.push({ start, end: start + line.length });
424
- }
425
- return dedupeRanges(ranges);
426
- }
427
- return getLineWindowRanges(content, oldText, (window, search) => window.every((line, idx) => normalizeWhitespace(line) === normalizeWhitespace(search[idx] ?? "")));
428
- }
429
- function applyRanges(content, ranges, replacement) {
430
- const sorted = [...ranges].sort((a, b) => b.start - a.start || b.end - a.end);
431
- let next = content;
432
- for (const range of sorted) {
433
- next = next.slice(0, range.start) + replacement + next.slice(range.end);
434
- }
435
- return next;
436
- }
437
- /**
438
- * Reads a file's contents.
439
- */
440
- export async function executeReadFile(input, ctx) {
441
- if (ctx.abortSignal?.aborted)
442
- return fail("Operation cancelled");
443
- try {
444
- if (input.offset !== undefined && (!Number.isInteger(input.offset) || input.offset < 0)) {
445
- return fail("offset must be a non-negative integer");
446
- }
447
- if (input.limit !== undefined && (!Number.isInteger(input.limit) || input.limit <= 0)) {
448
- return fail("limit must be a positive integer");
449
- }
450
- const filePath = resolvePath(input.path, ctx);
451
- const stat = await fs.stat(filePath);
452
- const encoding = normalizeEncoding(input.encoding);
453
- if (stat.isDirectory()) {
454
- return fail(`Path is a directory: ${filePath}`);
455
- }
456
- // Detect media files by extension — return base64 object unless caller explicitly requested
457
- // a non-UTF8 text/binary encoding.
458
- const ext = nodePath.extname(filePath).toLowerCase();
459
- const isMediaFile = MEDIA_EXTENSIONS.has(ext);
460
- if (isMediaFile && stat.size > MAX_MEDIA_SIZE_BYTES) {
461
- return fail(`File too large for media reading: ${(stat.size / 1024 / 1024).toFixed(1)}MB (max 10MB)`);
462
- }
463
- const useMediaEncoding = !input.encoding || encoding === "utf8";
464
- if (isMediaFile && useMediaEncoding) {
465
- const buffer = await fs.readFile(filePath);
466
- const base64 = buffer.toString("base64");
467
- const mimeType = MIME_TYPES[ext] ?? "application/octet-stream";
468
- return success(`Read media file: ${nodePath.basename(filePath)} (${mimeType}, ${(stat.size / 1024).toFixed(1)}KB)`, {
469
- type: "media",
470
- mimeType,
471
- base64,
472
- size: stat.size,
473
- path: filePath,
474
- });
475
- }
476
- const explicitWindow = input.offset !== undefined || input.limit !== undefined;
477
- let window;
478
- let returnedContent;
479
- if (!explicitWindow && stat.size <= MAX_READ_BYTES) {
480
- const content = normalizeLineEndings(await fs.readFile(filePath, { encoding }));
481
- window = getReadWindow(content, 0, DEFAULT_READ_LIMIT);
482
- returnedContent = window.truncated ? window.content : content;
483
- }
484
- else {
485
- window = await getReadWindowFromFile(filePath, encoding, input.offset ?? 0, input.limit ?? DEFAULT_READ_LIMIT);
486
- returnedContent = window.content;
487
- }
488
- const returnedBytes = Buffer.byteLength(returnedContent, encoding);
489
- const lineSummary = `lines ${window.startLine + 1}-${window.endLine} of ${window.totalLines}`;
490
- const truncationSummary = window.truncated
491
- ? ` (truncated; use offset=${window.nextOffset ?? window.endLine} to continue)`
492
- : "";
493
- return success(`Read ${returnedContent.length} characters (${lineSummary}, ${returnedBytes} bytes) from ${filePath}${truncationSummary}`, returnedContent);
494
- }
495
- catch (err) {
496
- return fail(getErrorMessage(err));
497
- }
498
- }
499
- /**
500
- * Writes content to a file.
501
- */
502
- export async function executeWriteFile(input, ctx) {
503
- if (ctx.abortSignal?.aborted)
504
- return fail("Operation cancelled");
505
- try {
506
- const filePath = resolvePath(input.path, ctx);
507
- const encoding = normalizeEncoding(input.encoding);
508
- const expectedHash = input.expectedHash?.trim().toLowerCase();
509
- if (expectedHash && !/^[a-f0-9]{64}$/.test(expectedHash)) {
510
- return fail("expectedHash must be a 64-character lowercase/uppercase SHA-256 hex digest");
511
- }
512
- let existed = false;
513
- let previousContent = "";
514
- try {
515
- previousContent = await fs.readFile(filePath, { encoding });
516
- existed = true;
517
- }
518
- catch (err) {
519
- const code = err?.code;
520
- if (code !== "ENOENT") {
521
- throw err;
522
- }
523
- }
524
- const previousHash = existed ? hashSha256(normalizeLineEndings(previousContent)) : undefined;
525
- if (expectedHash) {
526
- if (!existed) {
527
- return fail("expectedHash was provided but the file does not exist");
528
- }
529
- if (previousHash !== expectedHash) {
530
- return fail(`Hash mismatch for ${filePath}: file changed since last read`, {
531
- expectedHash,
532
- actualHash: previousHash,
533
- path: filePath,
534
- });
535
- }
536
- }
537
- // Ensure parent directory exists
538
- const parentDir = nodePath.dirname(filePath);
539
- await fs.mkdir(parentDir, { recursive: true });
540
- if (input.append) {
541
- await fs.appendFile(filePath, input.content, { encoding });
542
- }
543
- else {
544
- await fs.writeFile(filePath, input.content, { encoding });
545
- }
546
- const currentContent = input.append ? previousContent + input.content : input.content;
547
- const currentHash = hashSha256(normalizeLineEndings(currentContent));
548
- const bytesWritten = Buffer.byteLength(input.content, encoding);
549
- const action = input.append ? "appended" : existed ? "overwritten" : "created";
550
- // Compute structured diff for overwrites and appends (not new files)
551
- let structuredPatchData;
552
- if (existed) {
553
- const patch = computePatch(filePath, filePath, previousContent, currentContent, "", "", {
554
- context: 3,
555
- });
556
- structuredPatchData = patch.hunks;
557
- }
558
- recordFrgMutation(filePath, "write", currentContent);
559
- recordSearchMutation(filePath, "write", currentContent);
560
- return success(`Successfully ${action} ${filePath} (${bytesWritten} bytes written)`, {
561
- filePath,
562
- action,
563
- existed,
564
- bytesWritten,
565
- previousHash,
566
- currentHash,
567
- ...(structuredPatchData ? { structuredPatch: structuredPatchData } : {}),
568
- });
569
- }
570
- catch (err) {
571
- return fail(getErrorMessage(err));
572
- }
573
- }
574
- /**
575
- * Edits a file by replacing text.
576
- */
577
- export async function executeEditFile(input, ctx) {
578
- if (ctx.abortSignal?.aborted)
579
- return fail("Operation cancelled");
580
- try {
581
- // Validate oldText is not empty to prevent matching everywhere
582
- if (input.oldText === "") {
583
- return fail("oldText cannot be empty");
584
- }
585
- if (input.expectedReplacements !== undefined &&
586
- (!Number.isInteger(input.expectedReplacements) || input.expectedReplacements <= 0)) {
587
- return fail("expectedReplacements must be a positive integer");
588
- }
589
- const expectedHash = input.expectedHash?.trim().toLowerCase();
590
- if (expectedHash && !/^[a-f0-9]{64}$/.test(expectedHash)) {
591
- return fail("expectedHash must be a 64-character lowercase/uppercase SHA-256 hex digest");
592
- }
593
- if (!input.replaceAll && (input.expectedReplacements ?? 1) > 1) {
594
- return fail("expectedReplacements > 1 requires replaceAll=true");
595
- }
596
- const filePath = resolvePath(input.path, ctx);
597
- const originalContent = await fs.readFile(filePath, "utf-8");
598
- const originalNormalized = normalizeLineEndings(originalContent);
599
- const currentHash = hashSha256(originalNormalized);
600
- if (expectedHash && currentHash !== expectedHash) {
601
- return fail(`Hash mismatch for ${filePath}: file changed since last read`, {
602
- path: filePath,
603
- expectedHash,
604
- actualHash: currentHash,
605
- });
606
- }
607
- const hadCRLF = originalContent.includes("\r\n");
608
- const content = originalNormalized;
609
- const oldText = normalizeLineEndings(input.oldText);
610
- const newText = normalizeLineEndings(input.newText);
611
- const strategies = [
612
- { name: "exact", ranges: findExactRanges(content, oldText) },
613
- { name: "trimmed_line_block", ranges: findTrimmedLineBlockRanges(content, oldText) },
614
- { name: "indentation_flexible", ranges: findIndentFlexibleRanges(content, oldText) },
615
- { name: "whitespace_normalized", ranges: findWhitespaceNormalizedRanges(content, oldText) },
616
- ];
617
- const selected = strategies.find((entry) => entry.ranges.length > 0);
618
- if (!selected) {
619
- return fail(`Text not found in file after trying all strategies: "${input.oldText}"`);
620
- }
621
- const ranges = selected.ranges;
622
- const selectedRanges = input.replaceAll ? ranges : [ranges[0]];
623
- const replacements = selectedRanges.length;
624
- const expectedReplacements = input.expectedReplacements;
625
- if (expectedReplacements !== undefined && replacements !== expectedReplacements) {
626
- return fail(`Replacement count mismatch: expected ${expectedReplacements}, would apply ${replacements}`, {
627
- path: filePath,
628
- strategy: selected.name,
629
- matchesFound: ranges.length,
630
- replacements,
631
- expectedReplacements,
632
- });
633
- }
634
- let updated = applyRanges(content, selectedRanges, newText);
635
- // Compute structured diff before CRLF restoration (both sides are LF-normalized)
636
- const patch = computePatch(filePath, filePath, content, updated, "", "", { context: 3 });
637
- if (hadCRLF) {
638
- updated = updated.replace(/\n/g, "\r\n");
639
- }
640
- await fs.writeFile(filePath, updated, "utf-8");
641
- recordFrgMutation(filePath, "write", updated);
642
- recordSearchMutation(filePath, "write", updated);
643
- return success(`Edited ${filePath} using strategy=${selected.name} (${replacements} replacement(s))`, {
644
- filePath,
645
- strategy: selected.name,
646
- matchesFound: ranges.length,
647
- replacements,
648
- expectedReplacements,
649
- replaceAll: input.replaceAll === true,
650
- previousHash: currentHash,
651
- currentHash: hashSha256(normalizeLineEndings(updated)),
652
- structuredPatch: patch.hunks,
653
- });
654
- }
655
- catch (err) {
656
- return fail(getErrorMessage(err));
657
- }
658
- }
659
- function getStatType(stat) {
660
- if (stat.isFile())
661
- return "file";
662
- if (stat.isDirectory())
663
- return "directory";
664
- if (stat.isSymbolicLink())
665
- return "symlink";
666
- return "other";
667
- }
668
- function getErrorCode(err) {
669
- if (typeof err !== "object" || err === null)
670
- return undefined;
671
- const withCode = err;
672
- return typeof withCode.code === "string" ? withCode.code : undefined;
673
- }
674
- export const LS_INTERNALS = {
675
- async readType(entryPath) {
676
- const stat = await fs.lstat(entryPath);
677
- return getStatType(stat);
678
- },
679
- async readMetadata(entryPath) {
680
- const stat = await fs.lstat(entryPath);
681
- return {
682
- size: stat.size,
683
- mode: (stat.mode & 0o777).toString(8).padStart(3, "0"),
684
- mtimeMs: Math.trunc(stat.mtimeMs),
685
- modifiedAt: stat.mtime.toISOString(),
686
- };
687
- },
688
- };
689
- function normalizeNonNegativeInteger(value, fallback) {
690
- if (value === undefined)
691
- return fallback;
692
- if (!Number.isFinite(value))
693
- return fallback;
694
- if (value <= 0)
695
- return 0;
696
- return Math.floor(value);
697
- }
698
- function getEntryDepth(relativePath) {
699
- return relativePath.split("/").filter(Boolean).length;
700
- }
701
- function insertRetainedPath(retained, candidate, maxEntries) {
702
- if (maxEntries <= 0)
703
- return;
704
- if (retained.length < maxEntries) {
705
- retained.push(candidate);
706
- return;
707
- }
708
- let maxIndex = 0;
709
- for (let i = 1; i < retained.length; i++) {
710
- if (retained[i].localeCompare(retained[maxIndex]) > 0) {
711
- maxIndex = i;
712
- }
713
- }
714
- if (candidate.localeCompare(retained[maxIndex]) < 0) {
715
- retained[maxIndex] = candidate;
716
- }
717
- }
718
- /**
719
- * List files and directories with structured metadata.
720
- */
721
- export async function executeLs(input, ctx) {
722
- if (ctx.abortSignal?.aborted)
723
- return fail("Operation cancelled");
724
- try {
725
- const dirPath = resolvePath(input.path ?? ".", ctx);
726
- const dirStat = await fs.stat(dirPath);
727
- if (!dirStat.isDirectory()) {
728
- return fail(`Path is not a directory: ${dirPath}`);
729
- }
730
- const includeAll = input.all === true;
731
- const includeLong = input.long === true;
732
- const depth = normalizeNonNegativeInteger(input.depth, 1);
733
- const offset = normalizeNonNegativeInteger(input.offset, 0);
734
- const ignore = (input.ignore ?? []).filter((pattern) => pattern.trim() !== "");
735
- const requestedLimit = input.limit !== undefined ? normalizeNonNegativeInteger(input.limit, 0) : null;
736
- const retainedRelativePaths = [];
737
- let total = 0;
738
- for (const relativePath of await fastGlob.glob("**/*", {
739
- cwd: dirPath,
740
- onlyFiles: false,
741
- absolute: false,
742
- dot: includeAll,
743
- deep: depth,
744
- ignore: ignore.length > 0 ? ignore : undefined,
745
- })) {
746
- total++;
747
- if (requestedLimit === null) {
748
- retainedRelativePaths.push(relativePath);
749
- continue;
750
- }
751
- insertRetainedPath(retainedRelativePaths, relativePath, offset + requestedLimit);
752
- }
753
- retainedRelativePaths.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
754
- const limit = requestedLimit === null ? Math.max(total - offset, 0) : requestedLimit;
755
- const pageRelativePaths = retainedRelativePaths.slice(offset, offset + limit);
756
- const truncated = offset + limit < total;
757
- const pageEntries = [];
758
- for (const relativePath of pageRelativePaths) {
759
- const entryPath = nodePath.join(dirPath, relativePath);
760
- const name = nodePath.basename(relativePath);
761
- const entryDepth = getEntryDepth(relativePath);
762
- try {
763
- const type = await LS_INTERNALS.readType(entryPath);
764
- pageEntries.push({
765
- name,
766
- path: relativePath,
767
- depth: entryDepth,
768
- type,
769
- });
770
- }
771
- catch (err) {
772
- const code = getErrorCode(err);
773
- // Entry may disappear between glob traversal and metadata reads.
774
- if (code === "ENOENT" || code === "ENOTDIR") {
775
- continue;
776
- }
777
- // Keep listing useful even if one entry cannot be typed.
778
- pageEntries.push({
779
- name,
780
- path: relativePath,
781
- depth: entryDepth,
782
- type: "other",
783
- });
784
- }
785
- }
786
- let entries;
787
- if (includeLong) {
788
- // Use sequential metadata reads to avoid EMFILE in large directories.
789
- // Any per-entry metadata failure should not fail the whole listing.
790
- entries = [];
791
- for (const entry of pageEntries) {
792
- const entryPath = nodePath.join(dirPath, entry.path);
793
- try {
794
- const metadata = await LS_INTERNALS.readMetadata(entryPath);
795
- entries.push({
796
- ...entry,
797
- ...metadata,
798
- });
799
- }
800
- catch (err) {
801
- const code = getErrorCode(err);
802
- // File may disappear between readdir and lstat; skip stale entries.
803
- if (code === "ENOENT" || code === "ENOTDIR") {
804
- continue;
805
- }
806
- // Keep listing useful even if one entry's metadata cannot be read.
807
- entries.push(entry);
808
- }
809
- }
810
- }
811
- else {
812
- entries = pageEntries;
813
- }
814
- const output = {
815
- path: dirPath,
816
- depth,
817
- limit,
818
- offset,
819
- ignore,
820
- truncated,
821
- total,
822
- entries,
823
- };
824
- const truncationNote = truncated ? " (truncated)" : "";
825
- return success(`Listed ${entries.length} entries in ${dirPath}${truncationNote}`, output);
826
- }
827
- catch (err) {
828
- return fail(getErrorMessage(err));
829
- }
830
- }
831
- /**
832
- * Finds files matching a glob pattern.
833
- */
834
- export async function executeGlob(input, ctx) {
835
- if (ctx.abortSignal?.aborted)
836
- return fail("Operation cancelled");
837
- try {
838
- const cwd = input.cwd ? resolvePath(input.cwd, ctx) : ctx.workingDir;
839
- const files = await fastGlob.glob(input.pattern, {
840
- cwd,
841
- onlyFiles: true,
842
- absolute: false,
843
- ignore: input.ignore,
844
- });
845
- const truncated = files.length > FILESYSTEM_OUTPUT_LIMITS.MAX_GLOB_RESULTS;
846
- const cappedFiles = truncated
847
- ? files.slice(0, FILESYSTEM_OUTPUT_LIMITS.MAX_GLOB_RESULTS)
848
- : files;
849
- const suffix = truncated ? ` (truncated to ${cappedFiles.length})` : "";
850
- return success(`Found ${files.length} files matching ${input.pattern}${suffix}`, cappedFiles);
851
- }
852
- catch (err) {
853
- return fail(getErrorMessage(err));
854
- }
855
- }
856
- const MAX_GREP_PATTERN_LENGTH = 512;
857
- const MAX_GREP_QUANTIFIERS = 64;
858
- const BACKREFERENCE_RE = /\\[1-9][0-9]*/;
859
- const NESTED_QUANTIFIER_RE = /\((?:\?:)?(?:[^()\\]|\\.)*(?:\+|\*|\{\d+(?:,\d*)?\})(?:[^()\\]|\\.)*\)(?:\+|\*|\{\d+(?:,\d*)?\})/;
860
- const NESTED_WILDCARD_RE = /\((?:\?:)?(?:[^()\\]|\\.)*\.(?:\+|\*|\{\d+(?:,\d*)?\})(?:[^()\\]|\\.)*\)(?:\+|\*|\{\d+(?:,\d*)?\})/;
861
- const LOOKAROUND_RE = /\(\?(?:=|!|<=|<!)/;
862
- const REPEATED_SIMPLE_GROUP_RE = /\((?:\?:)?((?:[^()\\]|\\.)+)\)(?:\+|\*|\{\d+(?:,\d*)?\})/g;
863
- const UNESCAPED_QUANTIFIER_TOKEN_RE = /(^|[^\\])(?:\*|\+|\?|\{\d+(?:,\d*)?\})/;
864
- function splitTopLevelAlternatives(groupSource) {
865
- const parts = [];
866
- let current = "";
867
- let escaped = false;
868
- let inClass = false;
869
- let depth = 0;
870
- for (let i = 0; i < groupSource.length; i++) {
871
- const ch = groupSource[i];
872
- if (escaped) {
873
- current += ch;
874
- escaped = false;
875
- continue;
876
- }
877
- if (ch === "\\") {
878
- current += ch;
879
- escaped = true;
880
- continue;
881
- }
882
- if (inClass) {
883
- current += ch;
884
- if (ch === "]") {
885
- inClass = false;
886
- }
887
- continue;
888
- }
889
- if (ch === "[") {
890
- inClass = true;
891
- current += ch;
892
- continue;
893
- }
894
- if (ch === "(") {
895
- depth++;
896
- current += ch;
897
- continue;
898
- }
899
- if (ch === ")" && depth > 0) {
900
- depth--;
901
- current += ch;
902
- continue;
903
- }
904
- if (ch === "|" && depth === 0) {
905
- parts.push(current);
906
- current = "";
907
- continue;
908
- }
909
- current += ch;
910
- }
911
- parts.push(current);
912
- return parts;
913
- }
914
- function normalizeAlternative(raw) {
915
- return raw
916
- .replace(/\\./g, "x")
917
- .replace(/\[[^\]]*\]/g, "x")
918
- .replace(/[\^\$]/g, "")
919
- .replace(/(^|[^\\])(?:\*|\+|\?|\{\d+(?:,\d*)?\})/g, "$1");
920
- }
921
- function hasAmbiguousRepeatedAlternation(pattern) {
922
- for (const match of pattern.matchAll(new RegExp(REPEATED_SIMPLE_GROUP_RE.source, "g"))) {
923
- const groupSource = match[1];
924
- if (!groupSource || !groupSource.includes("|"))
925
- continue;
926
- const alternatives = splitTopLevelAlternatives(groupSource);
927
- if (alternatives.length < 2)
928
- continue;
929
- if (alternatives.some((alt) => alt.length === 0)) {
930
- return true;
931
- }
932
- // Quantified alternatives inside an already repeated group are common
933
- // catastrophic-backtracking shapes ((a+|aa)+, (a?|aa)+, etc.).
934
- if (alternatives.some((alt) => UNESCAPED_QUANTIFIER_TOKEN_RE.test(alt))) {
935
- return true;
936
- }
937
- const normalized = alternatives.map(normalizeAlternative);
938
- for (let i = 0; i < normalized.length; i++) {
939
- for (let j = i + 1; j < normalized.length; j++) {
940
- const left = normalized[i];
941
- const right = normalized[j];
942
- if (!left || !right) {
943
- return true;
944
- }
945
- if (left.startsWith(right) || right.startsWith(left)) {
946
- return true;
947
- }
948
- }
949
- }
950
- }
951
- return false;
952
- }
953
- function countUnescapedQuantifiers(pattern) {
954
- return [...pattern.matchAll(/(^|[^\\])(?:\*|\+|\?|\{\d+(?:,\d*)?\})/g)].length;
955
- }
956
- function getUnsafeRegexReason(pattern) {
957
- if (pattern.length > MAX_GREP_PATTERN_LENGTH) {
958
- return `pattern length exceeds ${MAX_GREP_PATTERN_LENGTH} characters`;
959
- }
960
- if (LOOKAROUND_RE.test(pattern)) {
961
- return "lookaround assertions are not allowed";
962
- }
963
- if (BACKREFERENCE_RE.test(pattern)) {
964
- return "backreferences are not allowed";
965
- }
966
- if (countUnescapedQuantifiers(pattern) > MAX_GREP_QUANTIFIERS) {
967
- return `pattern uses too many quantifiers (max ${MAX_GREP_QUANTIFIERS})`;
968
- }
969
- if (NESTED_QUANTIFIER_RE.test(pattern) || NESTED_WILDCARD_RE.test(pattern)) {
970
- return "nested quantifiers are not allowed";
971
- }
972
- if (hasAmbiguousRepeatedAlternation(pattern)) {
973
- return "ambiguous alternation inside repeated groups is not allowed";
974
- }
975
- return null;
976
- }
977
- /**
978
- * Searches for a pattern in files.
979
- */
980
- export async function executeGrep(input, ctx) {
981
- if (ctx.abortSignal?.aborted)
982
- return fail("Operation cancelled");
983
- try {
984
- const unsafeReason = getUnsafeRegexReason(input.pattern);
985
- if (unsafeReason) {
986
- return fail(`Unsafe regular expression rejected: ${unsafeReason}`);
987
- }
988
- // Validate regex
989
- let regex;
990
- try {
991
- regex = new RegExp(input.pattern, input.ignoreCase ? "gi" : "g");
992
- }
993
- catch {
994
- return fail(`Invalid regular expression: ${input.pattern}`);
995
- }
996
- const targetPath = resolvePath(input.path ?? ".", ctx);
997
- const stat = await fs.stat(targetPath);
998
- const matches = [];
999
- const errors = [];
1000
- let truncated = false;
1001
- if (stat.isDirectory()) {
1002
- // Search in directory
1003
- const globPattern = input.glob ?? "**/*";
1004
- const files = await fastGlob.glob(globPattern, {
1005
- cwd: targetPath,
1006
- onlyFiles: true,
1007
- absolute: true,
1008
- });
1009
- for (const file of files) {
1010
- if (matches.length >= FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_MATCHES) {
1011
- truncated = true;
1012
- break;
1013
- }
1014
- const remaining = FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_MATCHES - matches.length;
1015
- const result = await searchInFile(file, regex, remaining);
1016
- matches.push(...result.matches);
1017
- if (result.truncated) {
1018
- truncated = true;
1019
- }
1020
- if (result.error) {
1021
- if (errors.length < FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_ERRORS) {
1022
- errors.push(result.error);
1023
- }
1024
- }
1025
- if (truncated) {
1026
- break;
1027
- }
1028
- }
1029
- }
1030
- else {
1031
- // Search in single file
1032
- const result = await searchInFile(targetPath, regex, FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_MATCHES);
1033
- matches.push(...result.matches);
1034
- if (result.truncated) {
1035
- truncated = true;
1036
- }
1037
- if (result.error) {
1038
- if (errors.length < FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_ERRORS) {
1039
- errors.push(result.error);
1040
- }
1041
- }
1042
- }
1043
- // Return matches with optional errors array for visibility
1044
- // Note: errors are logged but don't fail the overall search
1045
- const suffix = truncated ? ` (truncated to ${matches.length})` : "";
1046
- return success(`Found ${matches.length} matches for pattern "${input.pattern}"${suffix}`, {
1047
- matches,
1048
- errors: errors.length > 0 ? errors : undefined,
1049
- truncated,
1050
- });
1051
- }
1052
- catch (err) {
1053
- return fail(getErrorMessage(err));
1054
- }
1055
- }
1056
- /**
1057
- * Searches for a regex pattern in a single file.
1058
- * Uses string.match() instead of regex.test() to avoid global regex lastIndex issues.
1059
- */
1060
- async function searchInFile(filePath, regex, maxMatches) {
1061
- const matches = [];
1062
- let skippedLongLine = false;
1063
- if (maxMatches <= 0) {
1064
- return { matches, truncated: true };
1065
- }
1066
- try {
1067
- const stat = await fs.stat(filePath);
1068
- if (stat.size > FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_FILE_BYTES) {
1069
- return {
1070
- matches: [],
1071
- error: `Skipped file ${filePath}: exceeds ${FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_FILE_BYTES} bytes`,
1072
- };
1073
- }
1074
- // Create a non-global version for testing to avoid lastIndex issues
1075
- const testRegex = new RegExp(regex.source, regex.flags.replace("g", ""));
1076
- const input = fsSync.createReadStream(filePath, { encoding: "utf8" });
1077
- const lines = readline.createInterface({ input, crlfDelay: Infinity });
1078
- let lineNumber = 0;
1079
- try {
1080
- for await (const line of lines) {
1081
- lineNumber++;
1082
- const lineBytes = Buffer.byteLength(line, "utf8");
1083
- if (lineBytes > FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_LINE_BYTES) {
1084
- skippedLongLine = true;
1085
- continue;
1086
- }
1087
- if (!testRegex.test(line)) {
1088
- continue;
1089
- }
1090
- matches.push({
1091
- file: filePath,
1092
- line: lineNumber,
1093
- content: line,
1094
- });
1095
- if (matches.length >= maxMatches) {
1096
- lines.close();
1097
- input.destroy();
1098
- return { matches, truncated: true };
1099
- }
1100
- }
1101
- if (skippedLongLine) {
1102
- return {
1103
- matches,
1104
- error: `Skipped lines longer than ${FILESYSTEM_OUTPUT_LIMITS.MAX_GREP_LINE_BYTES} bytes in ${filePath}`,
1105
- };
1106
- }
1107
- return { matches };
1108
- }
1109
- finally {
1110
- lines.close();
1111
- input.destroy();
1112
- }
1113
- }
1114
- catch (err) {
1115
- // Return error info for files that can't be read (binary, permissions, etc.)
1116
- // This allows callers to decide whether to log or surface these errors
1117
- return {
1118
- matches: [],
1119
- error: `Could not read file ${filePath}: ${getErrorMessage(err)}`,
1120
- };
1121
- }
1122
- }
1123
- //# sourceMappingURL=filesystem.js.map