@aria-cli/tools 1.0.8 → 1.0.10

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 (588) hide show
  1. package/package.json +9 -6
  2. package/dist-cjs/.tsbuildinfo +0 -1
  3. package/dist-cjs/ask-user-interaction.d.ts +0 -10
  4. package/dist-cjs/ask-user-interaction.js +0 -28
  5. package/dist-cjs/ask-user-interaction.js.map +0 -1
  6. package/dist-cjs/cache/web-cache.d.ts +0 -52
  7. package/dist-cjs/cache/web-cache.js +0 -71
  8. package/dist-cjs/cache/web-cache.js.map +0 -1
  9. package/dist-cjs/definitions/arion.d.ts +0 -8
  10. package/dist-cjs/definitions/arion.js +0 -108
  11. package/dist-cjs/definitions/arion.js.map +0 -1
  12. package/dist-cjs/definitions/browser/browser.d.ts +0 -2
  13. package/dist-cjs/definitions/browser/browser.js +0 -422
  14. package/dist-cjs/definitions/browser/browser.js.map +0 -1
  15. package/dist-cjs/definitions/browser/index.d.ts +0 -1
  16. package/dist-cjs/definitions/browser/index.js +0 -9
  17. package/dist-cjs/definitions/browser/index.js.map +0 -1
  18. package/dist-cjs/definitions/browser/pw-downloads.d.ts +0 -13
  19. package/dist-cjs/definitions/browser/pw-downloads.js +0 -118
  20. package/dist-cjs/definitions/browser/pw-downloads.js.map +0 -1
  21. package/dist-cjs/definitions/browser/pw-interactions.d.ts +0 -78
  22. package/dist-cjs/definitions/browser/pw-interactions.js +0 -214
  23. package/dist-cjs/definitions/browser/pw-interactions.js.map +0 -1
  24. package/dist-cjs/definitions/browser/pw-responses.d.ts +0 -28
  25. package/dist-cjs/definitions/browser/pw-responses.js +0 -85
  26. package/dist-cjs/definitions/browser/pw-responses.js.map +0 -1
  27. package/dist-cjs/definitions/browser/pw-session.d.ts +0 -65
  28. package/dist-cjs/definitions/browser/pw-session.js +0 -327
  29. package/dist-cjs/definitions/browser/pw-session.js.map +0 -1
  30. package/dist-cjs/definitions/browser/pw-shared.d.ts +0 -22
  31. package/dist-cjs/definitions/browser/pw-shared.js +0 -73
  32. package/dist-cjs/definitions/browser/pw-shared.js.map +0 -1
  33. package/dist-cjs/definitions/browser/pw-snapshot.d.ts +0 -34
  34. package/dist-cjs/definitions/browser/pw-snapshot.js +0 -308
  35. package/dist-cjs/definitions/browser/pw-snapshot.js.map +0 -1
  36. package/dist-cjs/definitions/browser/pw-state.d.ts +0 -22
  37. package/dist-cjs/definitions/browser/pw-state.js +0 -71
  38. package/dist-cjs/definitions/browser/pw-state.js.map +0 -1
  39. package/dist-cjs/definitions/browser/types.d.ts +0 -277
  40. package/dist-cjs/definitions/browser/types.js +0 -6
  41. package/dist-cjs/definitions/browser/types.js.map +0 -1
  42. package/dist-cjs/definitions/code-intelligence.d.ts +0 -8
  43. package/dist-cjs/definitions/code-intelligence.js +0 -474
  44. package/dist-cjs/definitions/code-intelligence.js.map +0 -1
  45. package/dist-cjs/definitions/core.d.ts +0 -47
  46. package/dist-cjs/definitions/core.js +0 -134
  47. package/dist-cjs/definitions/core.js.map +0 -1
  48. package/dist-cjs/definitions/delegation.d.ts +0 -11
  49. package/dist-cjs/definitions/delegation.js +0 -516
  50. package/dist-cjs/definitions/delegation.js.map +0 -1
  51. package/dist-cjs/definitions/deploy.d.ts +0 -15
  52. package/dist-cjs/definitions/deploy.js +0 -69
  53. package/dist-cjs/definitions/deploy.js.map +0 -1
  54. package/dist-cjs/definitions/filesystem.d.ts +0 -9
  55. package/dist-cjs/definitions/filesystem.js +0 -200
  56. package/dist-cjs/definitions/filesystem.js.map +0 -1
  57. package/dist-cjs/definitions/frg.d.ts +0 -3
  58. package/dist-cjs/definitions/frg.js +0 -67
  59. package/dist-cjs/definitions/frg.js.map +0 -1
  60. package/dist-cjs/definitions/index.d.ts +0 -19
  61. package/dist-cjs/definitions/index.js +0 -44
  62. package/dist-cjs/definitions/index.js.map +0 -1
  63. package/dist-cjs/definitions/memory.d.ts +0 -8
  64. package/dist-cjs/definitions/memory.js +0 -127
  65. package/dist-cjs/definitions/memory.js.map +0 -1
  66. package/dist-cjs/definitions/messaging.d.ts +0 -11
  67. package/dist-cjs/definitions/messaging.js +0 -632
  68. package/dist-cjs/definitions/messaging.js.map +0 -1
  69. package/dist-cjs/definitions/meta.d.ts +0 -11
  70. package/dist-cjs/definitions/meta.js +0 -353
  71. package/dist-cjs/definitions/meta.js.map +0 -1
  72. package/dist-cjs/definitions/network.d.ts +0 -11
  73. package/dist-cjs/definitions/network.js +0 -163
  74. package/dist-cjs/definitions/network.js.map +0 -1
  75. package/dist-cjs/definitions/outlook.d.ts +0 -2
  76. package/dist-cjs/definitions/outlook.js +0 -281
  77. package/dist-cjs/definitions/outlook.js.map +0 -1
  78. package/dist-cjs/definitions/patch/apply-patch.d.ts +0 -11
  79. package/dist-cjs/definitions/patch/apply-patch.js +0 -192
  80. package/dist-cjs/definitions/patch/apply-patch.js.map +0 -1
  81. package/dist-cjs/definitions/patch/fuzzy-match.d.ts +0 -10
  82. package/dist-cjs/definitions/patch/fuzzy-match.js +0 -173
  83. package/dist-cjs/definitions/patch/fuzzy-match.js.map +0 -1
  84. package/dist-cjs/definitions/patch/index.d.ts +0 -1
  85. package/dist-cjs/definitions/patch/index.js +0 -6
  86. package/dist-cjs/definitions/patch/index.js.map +0 -1
  87. package/dist-cjs/definitions/patch/patch-parser.d.ts +0 -50
  88. package/dist-cjs/definitions/patch/patch-parser.js +0 -216
  89. package/dist-cjs/definitions/patch/patch-parser.js.map +0 -1
  90. package/dist-cjs/definitions/patch/sandbox-paths.d.ts +0 -18
  91. package/dist-cjs/definitions/patch/sandbox-paths.js +0 -114
  92. package/dist-cjs/definitions/patch/sandbox-paths.js.map +0 -1
  93. package/dist-cjs/definitions/process/index.d.ts +0 -1
  94. package/dist-cjs/definitions/process/index.js +0 -9
  95. package/dist-cjs/definitions/process/index.js.map +0 -1
  96. package/dist-cjs/definitions/process/process-registry.d.ts +0 -67
  97. package/dist-cjs/definitions/process/process-registry.js +0 -232
  98. package/dist-cjs/definitions/process/process-registry.js.map +0 -1
  99. package/dist-cjs/definitions/process/process.d.ts +0 -9
  100. package/dist-cjs/definitions/process/process.js +0 -390
  101. package/dist-cjs/definitions/process/process.js.map +0 -1
  102. package/dist-cjs/definitions/process/pty-keys.d.ts +0 -13
  103. package/dist-cjs/definitions/process/pty-keys.js +0 -260
  104. package/dist-cjs/definitions/process/pty-keys.js.map +0 -1
  105. package/dist-cjs/definitions/process/session-slug.d.ts +0 -1
  106. package/dist-cjs/definitions/process/session-slug.js +0 -146
  107. package/dist-cjs/definitions/process/session-slug.js.map +0 -1
  108. package/dist-cjs/definitions/quip.d.ts +0 -2
  109. package/dist-cjs/definitions/quip.js +0 -199
  110. package/dist-cjs/definitions/quip.js.map +0 -1
  111. package/dist-cjs/definitions/search.d.ts +0 -9
  112. package/dist-cjs/definitions/search.js +0 -64
  113. package/dist-cjs/definitions/search.js.map +0 -1
  114. package/dist-cjs/definitions/session-history.d.ts +0 -11
  115. package/dist-cjs/definitions/session-history.js +0 -73
  116. package/dist-cjs/definitions/session-history.js.map +0 -1
  117. package/dist-cjs/definitions/shell.d.ts +0 -8
  118. package/dist-cjs/definitions/shell.js +0 -185
  119. package/dist-cjs/definitions/shell.js.map +0 -1
  120. package/dist-cjs/definitions/slack.d.ts +0 -2
  121. package/dist-cjs/definitions/slack.js +0 -184
  122. package/dist-cjs/definitions/slack.js.map +0 -1
  123. package/dist-cjs/definitions/web.d.ts +0 -8
  124. package/dist-cjs/definitions/web.js +0 -113
  125. package/dist-cjs/definitions/web.js.map +0 -1
  126. package/dist-cjs/executors/apply-patch.d.ts +0 -51
  127. package/dist-cjs/executors/apply-patch.js +0 -939
  128. package/dist-cjs/executors/apply-patch.js.map +0 -1
  129. package/dist-cjs/executors/arion.d.ts +0 -50
  130. package/dist-cjs/executors/arion.js +0 -126
  131. package/dist-cjs/executors/arion.js.map +0 -1
  132. package/dist-cjs/executors/code-intelligence.d.ts +0 -138
  133. package/dist-cjs/executors/code-intelligence.js +0 -926
  134. package/dist-cjs/executors/code-intelligence.js.map +0 -1
  135. package/dist-cjs/executors/deploy.d.ts +0 -169
  136. package/dist-cjs/executors/deploy.js +0 -870
  137. package/dist-cjs/executors/deploy.js.map +0 -1
  138. package/dist-cjs/executors/filesystem.d.ts +0 -150
  139. package/dist-cjs/executors/filesystem.js +0 -1168
  140. package/dist-cjs/executors/filesystem.js.map +0 -1
  141. package/dist-cjs/executors/frg-freshness.d.ts +0 -93
  142. package/dist-cjs/executors/frg-freshness.js +0 -628
  143. package/dist-cjs/executors/frg-freshness.js.map +0 -1
  144. package/dist-cjs/executors/frg.d.ts +0 -27
  145. package/dist-cjs/executors/frg.js +0 -335
  146. package/dist-cjs/executors/frg.js.map +0 -1
  147. package/dist-cjs/executors/index.d.ts +0 -44
  148. package/dist-cjs/executors/index.js +0 -144
  149. package/dist-cjs/executors/index.js.map +0 -1
  150. package/dist-cjs/executors/learning-meta.d.ts +0 -87
  151. package/dist-cjs/executors/learning-meta.js +0 -1166
  152. package/dist-cjs/executors/learning-meta.js.map +0 -1
  153. package/dist-cjs/executors/lsp-client.d.ts +0 -38
  154. package/dist-cjs/executors/lsp-client.js +0 -311
  155. package/dist-cjs/executors/lsp-client.js.map +0 -1
  156. package/dist-cjs/executors/memory.d.ts +0 -203
  157. package/dist-cjs/executors/memory.js +0 -797
  158. package/dist-cjs/executors/memory.js.map +0 -1
  159. package/dist-cjs/executors/meta.d.ts +0 -73
  160. package/dist-cjs/executors/meta.js +0 -227
  161. package/dist-cjs/executors/meta.js.map +0 -1
  162. package/dist-cjs/executors/process-registry.d.ts +0 -98
  163. package/dist-cjs/executors/process-registry.js +0 -470
  164. package/dist-cjs/executors/process-registry.js.map +0 -1
  165. package/dist-cjs/executors/pty-session-store.d.ts +0 -14
  166. package/dist-cjs/executors/pty-session-store.js +0 -35
  167. package/dist-cjs/executors/pty-session-store.js.map +0 -1
  168. package/dist-cjs/executors/pty.d.ts +0 -133
  169. package/dist-cjs/executors/pty.js +0 -313
  170. package/dist-cjs/executors/pty.js.map +0 -1
  171. package/dist-cjs/executors/restart.d.ts +0 -13
  172. package/dist-cjs/executors/restart.js +0 -156
  173. package/dist-cjs/executors/restart.js.map +0 -1
  174. package/dist-cjs/executors/search-freshness.d.ts +0 -50
  175. package/dist-cjs/executors/search-freshness.js +0 -235
  176. package/dist-cjs/executors/search-freshness.js.map +0 -1
  177. package/dist-cjs/executors/search-types.d.ts +0 -52
  178. package/dist-cjs/executors/search-types.js +0 -57
  179. package/dist-cjs/executors/search-types.js.map +0 -1
  180. package/dist-cjs/executors/search.d.ts +0 -11
  181. package/dist-cjs/executors/search.js +0 -103
  182. package/dist-cjs/executors/search.js.map +0 -1
  183. package/dist-cjs/executors/self-diagnose.d.ts +0 -89
  184. package/dist-cjs/executors/self-diagnose.js +0 -435
  185. package/dist-cjs/executors/self-diagnose.js.map +0 -1
  186. package/dist-cjs/executors/session-history.d.ts +0 -75
  187. package/dist-cjs/executors/session-history.js +0 -321
  188. package/dist-cjs/executors/session-history.js.map +0 -1
  189. package/dist-cjs/executors/shell-safety.d.ts +0 -27
  190. package/dist-cjs/executors/shell-safety.js +0 -479
  191. package/dist-cjs/executors/shell-safety.js.map +0 -1
  192. package/dist-cjs/executors/shell.d.ts +0 -168
  193. package/dist-cjs/executors/shell.js +0 -1002
  194. package/dist-cjs/executors/shell.js.map +0 -1
  195. package/dist-cjs/executors/utils.d.ts +0 -20
  196. package/dist-cjs/executors/utils.js +0 -74
  197. package/dist-cjs/executors/utils.js.map +0 -1
  198. package/dist-cjs/executors/web.d.ts +0 -89
  199. package/dist-cjs/executors/web.js +0 -548
  200. package/dist-cjs/executors/web.js.map +0 -1
  201. package/dist-cjs/extraction/content-extraction.d.ts +0 -48
  202. package/dist-cjs/extraction/content-extraction.js +0 -244
  203. package/dist-cjs/extraction/content-extraction.js.map +0 -1
  204. package/dist-cjs/extraction/index.d.ts +0 -4
  205. package/dist-cjs/extraction/index.js +0 -9
  206. package/dist-cjs/extraction/index.js.map +0 -1
  207. package/dist-cjs/headless-control-contract.d.ts +0 -3182
  208. package/dist-cjs/headless-control-contract.js +0 -973
  209. package/dist-cjs/headless-control-contract.js.map +0 -1
  210. package/dist-cjs/index.d.ts +0 -62
  211. package/dist-cjs/index.js +0 -438
  212. package/dist-cjs/index.js.map +0 -1
  213. package/dist-cjs/local-control-http-auth.d.ts +0 -2
  214. package/dist-cjs/local-control-http-auth.js +0 -6
  215. package/dist-cjs/local-control-http-auth.js.map +0 -1
  216. package/dist-cjs/mcp/client.d.ts +0 -68
  217. package/dist-cjs/mcp/client.js +0 -186
  218. package/dist-cjs/mcp/client.js.map +0 -1
  219. package/dist-cjs/mcp/connection.d.ts +0 -54
  220. package/dist-cjs/mcp/connection.js +0 -485
  221. package/dist-cjs/mcp/connection.js.map +0 -1
  222. package/dist-cjs/mcp/index.d.ts +0 -10
  223. package/dist-cjs/mcp/index.js +0 -31
  224. package/dist-cjs/mcp/index.js.map +0 -1
  225. package/dist-cjs/mcp/jsonrpc.d.ts +0 -36
  226. package/dist-cjs/mcp/jsonrpc.js +0 -149
  227. package/dist-cjs/mcp/jsonrpc.js.map +0 -1
  228. package/dist-cjs/mcp/types.d.ts +0 -178
  229. package/dist-cjs/mcp/types.js +0 -9
  230. package/dist-cjs/mcp/types.js.map +0 -1
  231. package/dist-cjs/network-control-adapter.d.ts +0 -4
  232. package/dist-cjs/network-control-adapter.js +0 -78
  233. package/dist-cjs/network-control-adapter.js.map +0 -1
  234. package/dist-cjs/network-runtime/address-types.d.ts +0 -201
  235. package/dist-cjs/network-runtime/address-types.js +0 -169
  236. package/dist-cjs/network-runtime/address-types.js.map +0 -1
  237. package/dist-cjs/network-runtime/db-owner-fencing.d.ts +0 -43
  238. package/dist-cjs/network-runtime/db-owner-fencing.js +0 -77
  239. package/dist-cjs/network-runtime/db-owner-fencing.js.map +0 -1
  240. package/dist-cjs/network-runtime/delivery-receipts.d.ts +0 -117
  241. package/dist-cjs/network-runtime/delivery-receipts.js +0 -277
  242. package/dist-cjs/network-runtime/delivery-receipts.js.map +0 -1
  243. package/dist-cjs/network-runtime/direct-endpoint-authority.d.ts +0 -8
  244. package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -30
  245. package/dist-cjs/network-runtime/direct-endpoint-authority.js.map +0 -1
  246. package/dist-cjs/network-runtime/index.d.ts +0 -24
  247. package/dist-cjs/network-runtime/index.js +0 -173
  248. package/dist-cjs/network-runtime/index.js.map +0 -1
  249. package/dist-cjs/network-runtime/local-control-contract.d.ts +0 -758
  250. package/dist-cjs/network-runtime/local-control-contract.js +0 -634
  251. package/dist-cjs/network-runtime/local-control-contract.js.map +0 -1
  252. package/dist-cjs/network-runtime/node-store-contract.d.ts +0 -49
  253. package/dist-cjs/network-runtime/node-store-contract.js +0 -39
  254. package/dist-cjs/network-runtime/node-store-contract.js.map +0 -1
  255. package/dist-cjs/network-runtime/pair-route-contract.d.ts +0 -100
  256. package/dist-cjs/network-runtime/pair-route-contract.js +0 -81
  257. package/dist-cjs/network-runtime/pair-route-contract.js.map +0 -1
  258. package/dist-cjs/network-runtime/peer-capabilities.d.ts +0 -10
  259. package/dist-cjs/network-runtime/peer-capabilities.js +0 -38
  260. package/dist-cjs/network-runtime/peer-capabilities.js.map +0 -1
  261. package/dist-cjs/network-runtime/peer-principal-ref.d.ts +0 -9
  262. package/dist-cjs/network-runtime/peer-principal-ref.js +0 -16
  263. package/dist-cjs/network-runtime/peer-principal-ref.js.map +0 -1
  264. package/dist-cjs/network-runtime/peer-state-machine.d.ts +0 -70
  265. package/dist-cjs/network-runtime/peer-state-machine.js +0 -130
  266. package/dist-cjs/network-runtime/peer-state-machine.js.map +0 -1
  267. package/dist-cjs/network-runtime/protocol-schemas.d.ts +0 -328
  268. package/dist-cjs/network-runtime/protocol-schemas.js +0 -213
  269. package/dist-cjs/network-runtime/protocol-schemas.js.map +0 -1
  270. package/dist-cjs/network-runtime/runtime-bootstrap-contract.d.ts +0 -81
  271. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -64
  272. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js.map +0 -1
  273. package/dist-cjs/outlook/desktop-session.d.ts +0 -68
  274. package/dist-cjs/outlook/desktop-session.js +0 -319
  275. package/dist-cjs/outlook/desktop-session.js.map +0 -1
  276. package/dist-cjs/package.json +0 -3
  277. package/dist-cjs/policy.d.ts +0 -43
  278. package/dist-cjs/policy.js +0 -156
  279. package/dist-cjs/policy.js.map +0 -1
  280. package/dist-cjs/providers/brave.d.ts +0 -10
  281. package/dist-cjs/providers/brave.js +0 -67
  282. package/dist-cjs/providers/brave.js.map +0 -1
  283. package/dist-cjs/providers/duckduckgo.d.ts +0 -18
  284. package/dist-cjs/providers/duckduckgo.js +0 -181
  285. package/dist-cjs/providers/duckduckgo.js.map +0 -1
  286. package/dist-cjs/providers/exa.d.ts +0 -10
  287. package/dist-cjs/providers/exa.js +0 -68
  288. package/dist-cjs/providers/exa.js.map +0 -1
  289. package/dist-cjs/providers/firecrawl.d.ts +0 -10
  290. package/dist-cjs/providers/firecrawl.js +0 -60
  291. package/dist-cjs/providers/firecrawl.js.map +0 -1
  292. package/dist-cjs/providers/index.d.ts +0 -8
  293. package/dist-cjs/providers/index.js +0 -18
  294. package/dist-cjs/providers/index.js.map +0 -1
  295. package/dist-cjs/providers/jina.d.ts +0 -10
  296. package/dist-cjs/providers/jina.js +0 -54
  297. package/dist-cjs/providers/jina.js.map +0 -1
  298. package/dist-cjs/providers/router.d.ts +0 -21
  299. package/dist-cjs/providers/router.js +0 -101
  300. package/dist-cjs/providers/router.js.map +0 -1
  301. package/dist-cjs/providers/search-provider.d.ts +0 -35
  302. package/dist-cjs/providers/search-provider.js +0 -37
  303. package/dist-cjs/providers/search-provider.js.map +0 -1
  304. package/dist-cjs/providers/tavily.d.ts +0 -10
  305. package/dist-cjs/providers/tavily.js +0 -59
  306. package/dist-cjs/providers/tavily.js.map +0 -1
  307. package/dist-cjs/quip/desktop-session.d.ts +0 -69
  308. package/dist-cjs/quip/desktop-session.js +0 -354
  309. package/dist-cjs/quip/desktop-session.js.map +0 -1
  310. package/dist-cjs/registry/index.d.ts +0 -1
  311. package/dist-cjs/registry/index.js +0 -7
  312. package/dist-cjs/registry/index.js.map +0 -1
  313. package/dist-cjs/registry/registry.d.ts +0 -156
  314. package/dist-cjs/registry/registry.js +0 -762
  315. package/dist-cjs/registry/registry.js.map +0 -1
  316. package/dist-cjs/runtime-socket-local-control-client.d.ts +0 -10
  317. package/dist-cjs/runtime-socket-local-control-client.js +0 -368
  318. package/dist-cjs/runtime-socket-local-control-client.js.map +0 -1
  319. package/dist-cjs/security/dns-normalization.d.ts +0 -6
  320. package/dist-cjs/security/dns-normalization.js +0 -23
  321. package/dist-cjs/security/dns-normalization.js.map +0 -1
  322. package/dist-cjs/security/dns-pinning.d.ts +0 -27
  323. package/dist-cjs/security/dns-pinning.js +0 -161
  324. package/dist-cjs/security/dns-pinning.js.map +0 -1
  325. package/dist-cjs/security/external-content.d.ts +0 -40
  326. package/dist-cjs/security/external-content.js +0 -96
  327. package/dist-cjs/security/external-content.js.map +0 -1
  328. package/dist-cjs/security/ssrf.d.ts +0 -40
  329. package/dist-cjs/security/ssrf.js +0 -222
  330. package/dist-cjs/security/ssrf.js.map +0 -1
  331. package/dist-cjs/slack/desktop-session.d.ts +0 -69
  332. package/dist-cjs/slack/desktop-session.js +0 -367
  333. package/dist-cjs/slack/desktop-session.js.map +0 -1
  334. package/dist-cjs/tool-factory.d.ts +0 -46
  335. package/dist-cjs/tool-factory.js +0 -51
  336. package/dist-cjs/tool-factory.js.map +0 -1
  337. package/dist-cjs/types.d.ts +0 -1192
  338. package/dist-cjs/types.js +0 -9
  339. package/dist-cjs/types.js.map +0 -1
  340. package/dist-cjs/utils/retry.d.ts +0 -11
  341. package/dist-cjs/utils/retry.js +0 -170
  342. package/dist-cjs/utils/retry.js.map +0 -1
  343. package/dist-cjs/utils/safe-parse-json.d.ts +0 -26
  344. package/dist-cjs/utils/safe-parse-json.js +0 -165
  345. package/dist-cjs/utils/safe-parse-json.js.map +0 -1
  346. package/dist-cjs/utils/url.d.ts +0 -10
  347. package/dist-cjs/utils/url.js +0 -24
  348. package/dist-cjs/utils/url.js.map +0 -1
  349. package/src/__tests__/web-fetch-download.test.ts +0 -433
  350. package/src/__tests__/web-tools.test.ts +0 -619
  351. package/src/ask-user-interaction.ts +0 -33
  352. package/src/cache/web-cache.ts +0 -110
  353. package/src/definitions/arion.ts +0 -118
  354. package/src/definitions/browser/browser.ts +0 -502
  355. package/src/definitions/browser/index.ts +0 -5
  356. package/src/definitions/browser/pw-downloads.ts +0 -142
  357. package/src/definitions/browser/pw-interactions.ts +0 -282
  358. package/src/definitions/browser/pw-responses.ts +0 -98
  359. package/src/definitions/browser/pw-session.ts +0 -405
  360. package/src/definitions/browser/pw-shared.ts +0 -85
  361. package/src/definitions/browser/pw-snapshot.ts +0 -383
  362. package/src/definitions/browser/pw-state.ts +0 -101
  363. package/src/definitions/browser/types.ts +0 -203
  364. package/src/definitions/code-intelligence.ts +0 -526
  365. package/src/definitions/core.ts +0 -118
  366. package/src/definitions/delegation.ts +0 -567
  367. package/src/definitions/deploy.ts +0 -73
  368. package/src/definitions/filesystem.ts +0 -217
  369. package/src/definitions/frg.ts +0 -67
  370. package/src/definitions/index.ts +0 -28
  371. package/src/definitions/memory.ts +0 -150
  372. package/src/definitions/messaging.ts +0 -734
  373. package/src/definitions/meta.ts +0 -392
  374. package/src/definitions/network.ts +0 -179
  375. package/src/definitions/outlook.ts +0 -318
  376. package/src/definitions/patch/apply-patch.ts +0 -235
  377. package/src/definitions/patch/fuzzy-match.ts +0 -217
  378. package/src/definitions/patch/index.ts +0 -1
  379. package/src/definitions/patch/patch-parser.ts +0 -297
  380. package/src/definitions/patch/sandbox-paths.ts +0 -129
  381. package/src/definitions/process/index.ts +0 -5
  382. package/src/definitions/process/process-registry.ts +0 -303
  383. package/src/definitions/process/process.ts +0 -456
  384. package/src/definitions/process/pty-keys.ts +0 -298
  385. package/src/definitions/process/session-slug.ts +0 -147
  386. package/src/definitions/quip.ts +0 -225
  387. package/src/definitions/search.ts +0 -67
  388. package/src/definitions/session-history.ts +0 -79
  389. package/src/definitions/shell.ts +0 -202
  390. package/src/definitions/slack.ts +0 -211
  391. package/src/definitions/web.ts +0 -119
  392. package/src/executors/apply-patch.ts +0 -1035
  393. package/src/executors/arion.ts +0 -199
  394. package/src/executors/code-intelligence.ts +0 -1179
  395. package/src/executors/deploy.ts +0 -1066
  396. package/src/executors/filesystem.ts +0 -1428
  397. package/src/executors/frg-freshness.ts +0 -743
  398. package/src/executors/frg.ts +0 -394
  399. package/src/executors/index.ts +0 -280
  400. package/src/executors/learning-meta.ts +0 -1367
  401. package/src/executors/lsp-client.ts +0 -355
  402. package/src/executors/memory.ts +0 -978
  403. package/src/executors/meta.ts +0 -293
  404. package/src/executors/process-registry.ts +0 -570
  405. package/src/executors/pty-session-store.ts +0 -43
  406. package/src/executors/pty.ts +0 -342
  407. package/src/executors/restart.ts +0 -133
  408. package/src/executors/search-freshness.ts +0 -249
  409. package/src/executors/search-types.ts +0 -98
  410. package/src/executors/search.ts +0 -89
  411. package/src/executors/self-diagnose.ts +0 -552
  412. package/src/executors/session-history.ts +0 -435
  413. package/src/executors/shell-safety.ts +0 -519
  414. package/src/executors/shell.ts +0 -1243
  415. package/src/executors/utils.ts +0 -40
  416. package/src/executors/web.ts +0 -786
  417. package/src/extraction/content-extraction.ts +0 -281
  418. package/src/extraction/index.ts +0 -5
  419. package/src/headless-control-contract.ts +0 -1149
  420. package/src/index.ts +0 -788
  421. package/src/local-control-http-auth.ts +0 -2
  422. package/src/mcp/client.ts +0 -218
  423. package/src/mcp/connection.ts +0 -568
  424. package/src/mcp/index.ts +0 -11
  425. package/src/mcp/jsonrpc.ts +0 -195
  426. package/src/mcp/types.ts +0 -199
  427. package/src/network-control-adapter.ts +0 -88
  428. package/src/network-runtime/address-types.ts +0 -218
  429. package/src/network-runtime/db-owner-fencing.ts +0 -91
  430. package/src/network-runtime/delivery-receipts.ts +0 -372
  431. package/src/network-runtime/direct-endpoint-authority.ts +0 -35
  432. package/src/network-runtime/index.ts +0 -316
  433. package/src/network-runtime/local-control-contract.ts +0 -784
  434. package/src/network-runtime/node-store-contract.ts +0 -46
  435. package/src/network-runtime/pair-route-contract.ts +0 -97
  436. package/src/network-runtime/peer-capabilities.ts +0 -48
  437. package/src/network-runtime/peer-principal-ref.ts +0 -20
  438. package/src/network-runtime/peer-state-machine.ts +0 -160
  439. package/src/network-runtime/protocol-schemas.ts +0 -265
  440. package/src/network-runtime/runtime-bootstrap-contract.ts +0 -83
  441. package/src/outlook/desktop-session.ts +0 -409
  442. package/src/policy.ts +0 -171
  443. package/src/providers/brave.ts +0 -80
  444. package/src/providers/duckduckgo.ts +0 -199
  445. package/src/providers/exa.ts +0 -85
  446. package/src/providers/firecrawl.ts +0 -77
  447. package/src/providers/index.ts +0 -8
  448. package/src/providers/jina.ts +0 -70
  449. package/src/providers/router.ts +0 -121
  450. package/src/providers/search-provider.ts +0 -74
  451. package/src/providers/tavily.ts +0 -74
  452. package/src/quip/desktop-session.ts +0 -435
  453. package/src/registry/index.ts +0 -1
  454. package/src/registry/registry.ts +0 -905
  455. package/src/runtime-socket-local-control-client.ts +0 -632
  456. package/src/security/dns-normalization.ts +0 -34
  457. package/src/security/dns-pinning.ts +0 -138
  458. package/src/security/external-content.ts +0 -129
  459. package/src/security/ssrf.ts +0 -207
  460. package/src/slack/desktop-session.ts +0 -493
  461. package/src/tool-factory.ts +0 -91
  462. package/src/types.ts +0 -1341
  463. package/src/utils/retry.ts +0 -163
  464. package/src/utils/safe-parse-json.ts +0 -176
  465. package/src/utils/url.ts +0 -20
  466. package/tests/benchmarks/registry.bench.ts +0 -57
  467. package/tests/cache/web-cache.test.ts +0 -147
  468. package/tests/critical-integration.test.ts +0 -1465
  469. package/tests/definitions/apply-patch.test.ts +0 -586
  470. package/tests/definitions/browser.test.ts +0 -495
  471. package/tests/definitions/delegation-pause-resume.test.ts +0 -758
  472. package/tests/definitions/execution.test.ts +0 -671
  473. package/tests/definitions/messaging-inbox-scope.test.ts +0 -229
  474. package/tests/definitions/messaging.test.ts +0 -1468
  475. package/tests/definitions/outlook.test.ts +0 -30
  476. package/tests/definitions/process.test.ts +0 -469
  477. package/tests/definitions/slack.test.ts +0 -28
  478. package/tests/definitions/tool-inventory.test.ts +0 -218
  479. package/tests/e2e/delegation-quest-orchestration.e2e.test.ts +0 -433
  480. package/tests/e2e/memory-tool-discovery-contract.e2e.test.ts +0 -81
  481. package/tests/executors/apply-patch.test.ts +0 -538
  482. package/tests/executors/arion.test.ts +0 -309
  483. package/tests/executors/conversation-primitives.test.ts +0 -250
  484. package/tests/executors/deploy.test.ts +0 -746
  485. package/tests/executors/filesystem-tools.test.ts +0 -357
  486. package/tests/executors/filesystem.test.ts +0 -959
  487. package/tests/executors/frg-freshness.test.ts +0 -136
  488. package/tests/executors/frg-merge.test.ts +0 -70
  489. package/tests/executors/frg-session-content.test.ts +0 -40
  490. package/tests/executors/frg.test.ts +0 -56
  491. package/tests/executors/memory-bugfixes.test.ts +0 -257
  492. package/tests/executors/memory-real-memoria.integration.test.ts +0 -316
  493. package/tests/executors/memory.test.ts +0 -853
  494. package/tests/executors/meta-tools.test.ts +0 -411
  495. package/tests/executors/meta.test.ts +0 -683
  496. package/tests/executors/path-containment.test.ts +0 -51
  497. package/tests/executors/process-registry.test.ts +0 -505
  498. package/tests/executors/pty.test.ts +0 -664
  499. package/tests/executors/quest-security.test.ts +0 -249
  500. package/tests/executors/read-file-media.test.ts +0 -230
  501. package/tests/executors/recall-knowledge-schema.test.ts +0 -209
  502. package/tests/executors/recall-tags.test.ts +0 -278
  503. package/tests/executors/remember-null-safety.contract.test.ts +0 -41
  504. package/tests/executors/restart.test.ts +0 -67
  505. package/tests/executors/search-unified.test.ts +0 -381
  506. package/tests/executors/session-history.test.ts +0 -340
  507. package/tests/executors/session-transcript.test.ts +0 -561
  508. package/tests/executors/shell-abort.test.ts +0 -416
  509. package/tests/executors/shell-env-blocklist.test.ts +0 -648
  510. package/tests/executors/shell-env-process.test.ts +0 -245
  511. package/tests/executors/shell-process-registry.test.ts +0 -334
  512. package/tests/executors/shell-tools.test.ts +0 -393
  513. package/tests/executors/shell.test.ts +0 -690
  514. package/tests/executors/web-abort-vs-timeout.test.ts +0 -213
  515. package/tests/executors/web-integration.test.ts +0 -633
  516. package/tests/executors/web-symlink.test.ts +0 -18
  517. package/tests/executors/web.test.ts +0 -1400
  518. package/tests/executors/write-stdin.test.ts +0 -145
  519. package/tests/extraction/content-extraction.test.ts +0 -153
  520. package/tests/guards/tools-default-test-lane.integration.test.ts +0 -21
  521. package/tests/guards/tools-package-test-commands.e2e.test.ts +0 -43
  522. package/tests/guards/tools-test-lane-manifest.contract.test.ts +0 -76
  523. package/tests/guards/tools-vitest-workspace-alias.contract.test.ts +0 -63
  524. package/tests/helpers/async-waits.ts +0 -53
  525. package/tests/integration/headless-control-contract.integration.test.ts +0 -153
  526. package/tests/integration/memory-tool-schema-parity.integration.test.ts +0 -67
  527. package/tests/integration/meta-tools-round-trip.integration.test.ts +0 -506
  528. package/tests/integration/quest-round-trip.test.ts +0 -303
  529. package/tests/integration/registry-executor-flow.test.ts +0 -85
  530. package/tests/integration.test.ts +0 -177
  531. package/tests/loading-tier.test.ts +0 -126
  532. package/tests/mcp/client-reconnect.test.ts +0 -267
  533. package/tests/mcp/connection.test.ts +0 -846
  534. package/tests/mcp/injectable-logger.test.ts +0 -83
  535. package/tests/mcp/jsonrpc.test.ts +0 -109
  536. package/tests/mcp/lifecycle.test.ts +0 -879
  537. package/tests/network-runtime/address-types.contract.test.ts +0 -143
  538. package/tests/network-runtime/continuity-bind-schema.contract.test.ts +0 -203
  539. package/tests/network-runtime/local-control-contract.test.ts +0 -869
  540. package/tests/network-runtime/local-control-invite-token.contract.test.ts +0 -146
  541. package/tests/network-runtime/node-store-contract.test.ts +0 -11
  542. package/tests/network-runtime/pair-protocol-nodeid.contract.test.ts +0 -15
  543. package/tests/network-runtime/peer-state-machine.contract.test.ts +0 -148
  544. package/tests/network-runtime/protocol-schemas.contract.test.ts +0 -512
  545. package/tests/network-runtime/relay-pending-nodeid.contract.test.ts +0 -62
  546. package/tests/network-runtime/runtime-bootstrap-contract.test.ts +0 -227
  547. package/tests/network-runtime/runtime-socket-local-control-client.test.ts +0 -621
  548. package/tests/network-runtime/wait-for-message-script.test.ts +0 -288
  549. package/tests/parallel.test.ts +0 -71
  550. package/tests/policy.test.ts +0 -184
  551. package/tests/print-default-test-lane.ts +0 -14
  552. package/tests/print-test-lane-manifest.ts +0 -22
  553. package/tests/providers/brave.test.ts +0 -159
  554. package/tests/providers/duckduckgo.test.ts +0 -207
  555. package/tests/providers/exa.test.ts +0 -175
  556. package/tests/providers/firecrawl.test.ts +0 -168
  557. package/tests/providers/jina.test.ts +0 -144
  558. package/tests/providers/router.test.ts +0 -328
  559. package/tests/providers/tavily.test.ts +0 -165
  560. package/tests/registry/discovery.test.ts +0 -154
  561. package/tests/registry/injectable-logger.test.ts +0 -230
  562. package/tests/registry/input-validation.test.ts +0 -361
  563. package/tests/registry/interface-completeness.test.ts +0 -85
  564. package/tests/registry/mcp-integration.test.ts +0 -103
  565. package/tests/registry/mcp-read-only-hint.test.ts +0 -60
  566. package/tests/registry/memoria-discovery.test.ts +0 -390
  567. package/tests/registry/nested-validation.test.ts +0 -283
  568. package/tests/registry/pseudo-tool-filtering.test.ts +0 -258
  569. package/tests/registry/registration-lifecycle.test.ts +0 -133
  570. package/tests/registry-validation.test.ts +0 -424
  571. package/tests/registry.test.ts +0 -460
  572. package/tests/security/dns-pinning.test.ts +0 -162
  573. package/tests/security/external-content.test.ts +0 -144
  574. package/tests/security/ssrf.test.ts +0 -118
  575. package/tests/shell-safety-integration.test.ts +0 -32
  576. package/tests/shell-safety.test.ts +0 -365
  577. package/tests/slack/desktop-session.test.ts +0 -50
  578. package/tests/test-lane-manifest.ts +0 -440
  579. package/tests/test-utils.ts +0 -27
  580. package/tests/tool-factory.test.ts +0 -188
  581. package/tests/utils/retry.test.ts +0 -231
  582. package/tests/utils/url.test.ts +0 -63
  583. package/tsconfig.cjs.json +0 -24
  584. package/tsconfig.json +0 -12
  585. package/vitest.config.ts +0 -55
  586. package/vitest.e2e.config.ts +0 -24
  587. package/vitest.integration.config.ts +0 -24
  588. package/vitest.native.config.ts +0 -24
@@ -1,1168 +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
- }
1168
- //# sourceMappingURL=filesystem.js.map