@aria-cli/tools 1.0.12 → 1.0.13

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