@aria-cli/tools 1.0.19 → 1.0.31

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 (459) hide show
  1. package/dist/.aria-build-stamp.json +1 -1
  2. package/dist/ask-user-interaction.js +23 -0
  3. package/dist/cache/web-cache.js +67 -0
  4. package/dist/definitions/arion.js +105 -0
  5. package/dist/definitions/browser/browser.js +419 -0
  6. package/dist/definitions/browser/index.js +5 -0
  7. package/dist/definitions/browser/pw-downloads.js +115 -0
  8. package/dist/definitions/browser/pw-interactions.js +200 -0
  9. package/dist/definitions/browser/pw-responses.js +77 -0
  10. package/dist/definitions/browser/pw-session.js +311 -0
  11. package/dist/definitions/browser/pw-shared.js +67 -0
  12. package/dist/definitions/browser/pw-snapshot.js +302 -0
  13. package/dist/definitions/browser/pw-state.js +63 -0
  14. package/dist/definitions/browser/types.js +5 -0
  15. package/dist/definitions/code-intelligence.js +471 -0
  16. package/dist/definitions/core.js +110 -0
  17. package/dist/definitions/delegation.js +513 -0
  18. package/dist/definitions/deploy.js +66 -0
  19. package/dist/definitions/filesystem.js +197 -0
  20. package/dist/definitions/frg.js +64 -0
  21. package/{dist-cjs/definitions/index.d.ts → dist/definitions/index.js} +2 -0
  22. package/dist/definitions/memory.js +124 -0
  23. package/dist/definitions/messaging.js +626 -0
  24. package/dist/definitions/meta.js +350 -0
  25. package/dist/definitions/network.js +160 -0
  26. package/dist/definitions/outlook.js +278 -0
  27. package/dist/definitions/patch/apply-patch.js +185 -0
  28. package/dist/definitions/patch/fuzzy-match.js +167 -0
  29. package/{dist-cjs/definitions/patch/index.d.ts → dist/definitions/patch/index.js} +1 -0
  30. package/dist/definitions/patch/patch-parser.js +208 -0
  31. package/dist/definitions/patch/sandbox-paths.js +106 -0
  32. package/dist/definitions/process/index.js +5 -0
  33. package/dist/definitions/process/process-registry.js +214 -0
  34. package/dist/definitions/process/process.js +387 -0
  35. package/dist/definitions/process/pty-keys.js +255 -0
  36. package/dist/definitions/process/session-slug.js +143 -0
  37. package/dist/definitions/quip.js +196 -0
  38. package/dist/definitions/search.js +61 -0
  39. package/dist/definitions/session-history.js +70 -0
  40. package/dist/definitions/shell.js +182 -0
  41. package/dist/definitions/slack.js +181 -0
  42. package/dist/definitions/web.js +110 -0
  43. package/dist/executors/apply-patch.js +902 -0
  44. package/dist/executors/arion.js +120 -0
  45. package/dist/executors/code-intelligence.js +883 -0
  46. package/dist/executors/deploy.js +849 -0
  47. package/dist/executors/filesystem.js +1119 -0
  48. package/dist/executors/frg-freshness.js +577 -0
  49. package/dist/executors/frg.js +299 -0
  50. package/{dist-cjs/executors/index.d.ts → dist/executors/index.js} +22 -19
  51. package/dist/executors/learning-meta.js +1147 -0
  52. package/dist/executors/lsp-client.js +297 -0
  53. package/dist/executors/memory.js +751 -0
  54. package/dist/executors/meta.js +221 -0
  55. package/dist/executors/process-registry.js +466 -0
  56. package/dist/executors/pty-session-store.js +31 -0
  57. package/dist/executors/pty.js +281 -0
  58. package/dist/executors/restart.js +120 -0
  59. package/dist/executors/search-freshness.js +196 -0
  60. package/dist/executors/search-types.js +53 -0
  61. package/dist/executors/search.js +67 -0
  62. package/dist/executors/self-diagnose.js +399 -0
  63. package/dist/executors/session-history.js +284 -0
  64. package/dist/executors/shell-safety.js +474 -0
  65. package/dist/executors/shell.js +955 -0
  66. package/dist/executors/utils.js +34 -0
  67. package/dist/executors/web.js +543 -0
  68. package/dist/extraction/content-extraction.js +248 -0
  69. package/dist/extraction/index.js +5 -0
  70. package/dist/headless-control-contract.js +968 -0
  71. package/dist/{index-v49pd2a0.js → index-45qvfjbf.js} +2 -2
  72. package/dist/index.js +71 -372
  73. package/dist/local-control-http-auth.js +3 -0
  74. package/dist/mcp/client.js +182 -0
  75. package/dist/mcp/connection.js +484 -0
  76. package/dist/mcp/index.js +11 -0
  77. package/dist/mcp/jsonrpc.js +145 -0
  78. package/dist/mcp/types.js +8 -0
  79. package/dist/network-control-adapter.js +73 -0
  80. package/dist/network-runtime/address-types.js +166 -0
  81. package/dist/network-runtime/db-owner-fencing.js +70 -0
  82. package/dist/network-runtime/delivery-receipts.js +270 -0
  83. package/dist/network-runtime/direct-endpoint-authority.js +26 -0
  84. package/dist/network-runtime/index.js +13 -1
  85. package/dist/network-runtime/local-control-contract.js +628 -0
  86. package/dist/network-runtime/node-store-contract.js +35 -0
  87. package/dist/network-runtime/pair-route-contract.js +78 -0
  88. package/dist/network-runtime/peer-capabilities.js +29 -0
  89. package/dist/network-runtime/peer-principal-ref.js +13 -0
  90. package/dist/network-runtime/peer-state-machine.js +122 -0
  91. package/dist/network-runtime/protocol-schemas.js +206 -0
  92. package/dist/network-runtime/runtime-bootstrap-contract.js +61 -0
  93. package/dist/outlook/desktop-session.js +280 -0
  94. package/dist/policy.js +150 -0
  95. package/dist/providers/brave.js +63 -0
  96. package/dist/providers/duckduckgo.js +177 -0
  97. package/dist/providers/exa.js +64 -0
  98. package/dist/providers/firecrawl.js +56 -0
  99. package/{dist-cjs/providers/index.d.ts → dist/providers/index.js} +1 -1
  100. package/dist/providers/jina.js +50 -0
  101. package/dist/providers/router.js +97 -0
  102. package/dist/providers/search-provider.js +33 -0
  103. package/dist/providers/tavily.js +55 -0
  104. package/dist/pty-w5c9dv33.js +1 -0
  105. package/dist/quip/desktop-session.js +318 -0
  106. package/{dist-cjs/registry/index.d.ts → dist/registry/index.js} +1 -0
  107. package/dist/registry/registry.js +757 -0
  108. package/dist/runtime-socket-local-control-client.js +331 -0
  109. package/dist/security/dns-normalization.js +20 -0
  110. package/dist/security/dns-pinning.js +124 -0
  111. package/dist/security/external-content.js +92 -0
  112. package/dist/security/ssrf.js +182 -0
  113. package/dist/slack/desktop-session.js +325 -0
  114. package/dist/tool-factory.js +48 -0
  115. package/dist/types.js +8 -0
  116. package/dist/utils/retry.js +133 -0
  117. package/dist/utils/safe-parse-json.js +161 -0
  118. package/dist/utils/url.js +20 -0
  119. package/dist-cjs/ask-user-interaction.js +28 -0
  120. package/dist-cjs/cache/web-cache.js +71 -0
  121. package/dist-cjs/definitions/arion.js +108 -0
  122. package/dist-cjs/definitions/browser/browser.js +422 -0
  123. package/dist-cjs/definitions/browser/index.js +9 -0
  124. package/dist-cjs/definitions/browser/pw-downloads.js +118 -0
  125. package/dist-cjs/definitions/browser/pw-interactions.js +214 -0
  126. package/dist-cjs/definitions/browser/pw-responses.js +85 -0
  127. package/dist-cjs/definitions/browser/pw-session.js +327 -0
  128. package/dist-cjs/definitions/browser/pw-shared.js +73 -0
  129. package/dist-cjs/definitions/browser/pw-snapshot.js +308 -0
  130. package/dist-cjs/definitions/browser/pw-state.js +71 -0
  131. package/dist-cjs/definitions/browser/types.js +6 -0
  132. package/dist-cjs/definitions/code-intelligence.js +474 -0
  133. package/dist-cjs/definitions/core.js +134 -0
  134. package/dist-cjs/definitions/delegation.js +516 -0
  135. package/dist-cjs/definitions/deploy.js +69 -0
  136. package/dist-cjs/definitions/filesystem.js +200 -0
  137. package/dist-cjs/definitions/frg.js +67 -0
  138. package/dist-cjs/definitions/index.js +44 -0
  139. package/dist-cjs/definitions/memory.js +127 -0
  140. package/dist-cjs/definitions/messaging.js +632 -0
  141. package/dist-cjs/definitions/meta.js +353 -0
  142. package/dist-cjs/definitions/network.js +163 -0
  143. package/dist-cjs/definitions/outlook.js +281 -0
  144. package/dist-cjs/definitions/patch/apply-patch.js +192 -0
  145. package/dist-cjs/definitions/patch/fuzzy-match.js +173 -0
  146. package/dist-cjs/definitions/patch/index.js +6 -0
  147. package/dist-cjs/definitions/patch/patch-parser.js +216 -0
  148. package/dist-cjs/definitions/patch/sandbox-paths.js +114 -0
  149. package/dist-cjs/definitions/process/index.js +9 -0
  150. package/dist-cjs/definitions/process/process-registry.js +232 -0
  151. package/dist-cjs/definitions/process/process.js +390 -0
  152. package/dist-cjs/definitions/process/pty-keys.js +260 -0
  153. package/dist-cjs/definitions/process/session-slug.js +146 -0
  154. package/dist-cjs/definitions/quip.js +199 -0
  155. package/dist-cjs/definitions/search.js +64 -0
  156. package/dist-cjs/definitions/session-history.js +73 -0
  157. package/dist-cjs/definitions/shell.js +185 -0
  158. package/dist-cjs/definitions/slack.js +184 -0
  159. package/dist-cjs/definitions/web.js +113 -0
  160. package/dist-cjs/executors/apply-patch.js +939 -0
  161. package/dist-cjs/executors/arion.js +126 -0
  162. package/dist-cjs/executors/code-intelligence.js +926 -0
  163. package/dist-cjs/executors/deploy.js +870 -0
  164. package/dist-cjs/executors/filesystem.js +1164 -0
  165. package/dist-cjs/executors/frg-freshness.js +628 -0
  166. package/dist-cjs/executors/frg.js +335 -0
  167. package/dist-cjs/executors/index.js +144 -0
  168. package/dist-cjs/executors/learning-meta.js +1166 -0
  169. package/dist-cjs/executors/memory.js +797 -0
  170. package/dist-cjs/executors/meta.js +227 -0
  171. package/dist-cjs/executors/process-registry.js +470 -0
  172. package/dist-cjs/executors/pty-session-store.js +35 -0
  173. package/dist-cjs/executors/pty.js +289 -0
  174. package/dist-cjs/executors/restart.js +156 -0
  175. package/dist-cjs/executors/search-freshness.js +235 -0
  176. package/dist-cjs/executors/search-types.js +57 -0
  177. package/dist-cjs/executors/search.js +103 -0
  178. package/dist-cjs/executors/self-diagnose.js +435 -0
  179. package/dist-cjs/executors/session-history.js +321 -0
  180. package/dist-cjs/executors/shell-safety.js +479 -0
  181. package/dist-cjs/executors/shell.js +1002 -0
  182. package/dist-cjs/executors/utils.js +74 -0
  183. package/dist-cjs/executors/web.js +548 -0
  184. package/dist-cjs/extraction/content-extraction.js +289 -0
  185. package/dist-cjs/extraction/index.js +9 -0
  186. package/dist-cjs/headless-control-contract.js +973 -0
  187. package/dist-cjs/index.js +436 -385
  188. package/dist-cjs/local-control-http-auth.js +6 -0
  189. package/dist-cjs/mcp/client.js +186 -0
  190. package/dist-cjs/mcp/connection.js +488 -0
  191. package/dist-cjs/mcp/index.js +31 -0
  192. package/dist-cjs/mcp/jsonrpc.js +149 -0
  193. package/dist-cjs/mcp/types.js +9 -0
  194. package/dist-cjs/network-control-adapter.js +78 -0
  195. package/dist-cjs/network-runtime/address-types.js +169 -0
  196. package/dist-cjs/network-runtime/db-owner-fencing.js +77 -0
  197. package/dist-cjs/network-runtime/delivery-receipts.js +279 -0
  198. package/dist-cjs/network-runtime/direct-endpoint-authority.js +30 -0
  199. package/dist-cjs/network-runtime/index.js +173 -8
  200. package/dist-cjs/network-runtime/local-control-contract.js +634 -0
  201. package/dist-cjs/network-runtime/node-store-contract.js +39 -0
  202. package/dist-cjs/network-runtime/pair-route-contract.js +81 -0
  203. package/dist-cjs/network-runtime/peer-capabilities.js +38 -0
  204. package/dist-cjs/network-runtime/peer-principal-ref.js +16 -0
  205. package/dist-cjs/network-runtime/peer-state-machine.js +130 -0
  206. package/dist-cjs/network-runtime/protocol-schemas.js +213 -0
  207. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +64 -0
  208. package/dist-cjs/outlook/desktop-session.js +319 -0
  209. package/dist-cjs/policy.js +156 -0
  210. package/dist-cjs/providers/brave.js +67 -0
  211. package/dist-cjs/providers/duckduckgo.js +181 -0
  212. package/dist-cjs/providers/exa.js +68 -0
  213. package/dist-cjs/providers/firecrawl.js +60 -0
  214. package/dist-cjs/providers/index.js +18 -0
  215. package/dist-cjs/providers/jina.js +54 -0
  216. package/dist-cjs/providers/router.js +101 -0
  217. package/dist-cjs/providers/search-provider.js +37 -0
  218. package/dist-cjs/providers/tavily.js +59 -0
  219. package/dist-cjs/quip/desktop-session.js +354 -0
  220. package/dist-cjs/registry/index.js +7 -0
  221. package/dist-cjs/registry/registry.js +762 -0
  222. package/dist-cjs/runtime-socket-local-control-client.js +368 -0
  223. package/dist-cjs/security/dns-normalization.js +23 -0
  224. package/dist-cjs/security/dns-pinning.js +161 -0
  225. package/dist-cjs/security/external-content.js +96 -0
  226. package/dist-cjs/security/ssrf.js +222 -0
  227. package/dist-cjs/slack/desktop-session.js +367 -0
  228. package/dist-cjs/tool-factory.js +51 -0
  229. package/dist-cjs/types.js +9 -0
  230. package/dist-cjs/utils/retry.js +170 -0
  231. package/dist-cjs/utils/safe-parse-json.js +165 -0
  232. package/dist-cjs/utils/url.js +24 -0
  233. package/package.json +11 -10
  234. package/dist/ask-user-interaction.d.ts +0 -10
  235. package/dist/cache/web-cache.d.ts +0 -52
  236. package/dist/definitions/arion.d.ts +0 -8
  237. package/dist/definitions/browser/browser.d.ts +0 -2
  238. package/dist/definitions/browser/index.d.ts +0 -1
  239. package/dist/definitions/browser/pw-downloads.d.ts +0 -13
  240. package/dist/definitions/browser/pw-interactions.d.ts +0 -78
  241. package/dist/definitions/browser/pw-responses.d.ts +0 -28
  242. package/dist/definitions/browser/pw-session.d.ts +0 -65
  243. package/dist/definitions/browser/pw-shared.d.ts +0 -22
  244. package/dist/definitions/browser/pw-snapshot.d.ts +0 -34
  245. package/dist/definitions/browser/pw-state.d.ts +0 -22
  246. package/dist/definitions/browser/types.d.ts +0 -277
  247. package/dist/definitions/code-intelligence.d.ts +0 -8
  248. package/dist/definitions/core.d.ts +0 -47
  249. package/dist/definitions/delegation.d.ts +0 -11
  250. package/dist/definitions/deploy.d.ts +0 -15
  251. package/dist/definitions/filesystem.d.ts +0 -9
  252. package/dist/definitions/frg.d.ts +0 -3
  253. package/dist/definitions/index.d.ts +0 -19
  254. package/dist/definitions/memory.d.ts +0 -8
  255. package/dist/definitions/messaging.d.ts +0 -11
  256. package/dist/definitions/meta.d.ts +0 -11
  257. package/dist/definitions/network.d.ts +0 -11
  258. package/dist/definitions/outlook.d.ts +0 -2
  259. package/dist/definitions/patch/apply-patch.d.ts +0 -11
  260. package/dist/definitions/patch/fuzzy-match.d.ts +0 -10
  261. package/dist/definitions/patch/index.d.ts +0 -1
  262. package/dist/definitions/patch/patch-parser.d.ts +0 -50
  263. package/dist/definitions/patch/sandbox-paths.d.ts +0 -18
  264. package/dist/definitions/process/index.d.ts +0 -1
  265. package/dist/definitions/process/process-registry.d.ts +0 -67
  266. package/dist/definitions/process/process.d.ts +0 -9
  267. package/dist/definitions/process/pty-keys.d.ts +0 -13
  268. package/dist/definitions/process/session-slug.d.ts +0 -1
  269. package/dist/definitions/quip.d.ts +0 -2
  270. package/dist/definitions/search.d.ts +0 -9
  271. package/dist/definitions/session-history.d.ts +0 -11
  272. package/dist/definitions/shell.d.ts +0 -8
  273. package/dist/definitions/slack.d.ts +0 -2
  274. package/dist/definitions/web.d.ts +0 -8
  275. package/dist/executors/apply-patch.d.ts +0 -51
  276. package/dist/executors/arion.d.ts +0 -50
  277. package/dist/executors/code-intelligence.d.ts +0 -138
  278. package/dist/executors/deploy.d.ts +0 -169
  279. package/dist/executors/filesystem.d.ts +0 -150
  280. package/dist/executors/frg-freshness.d.ts +0 -93
  281. package/dist/executors/frg.d.ts +0 -27
  282. package/dist/executors/index.d.ts +0 -44
  283. package/dist/executors/learning-meta.d.ts +0 -87
  284. package/dist/executors/lsp-client.d.ts +0 -38
  285. package/dist/executors/memory.d.ts +0 -203
  286. package/dist/executors/meta.d.ts +0 -73
  287. package/dist/executors/process-registry.d.ts +0 -98
  288. package/dist/executors/pty-session-store.d.ts +0 -14
  289. package/dist/executors/pty.d.ts +0 -133
  290. package/dist/executors/restart.d.ts +0 -13
  291. package/dist/executors/search-freshness.d.ts +0 -50
  292. package/dist/executors/search-types.d.ts +0 -52
  293. package/dist/executors/search.d.ts +0 -11
  294. package/dist/executors/self-diagnose.d.ts +0 -89
  295. package/dist/executors/session-history.d.ts +0 -75
  296. package/dist/executors/shell-safety.d.ts +0 -27
  297. package/dist/executors/shell.d.ts +0 -168
  298. package/dist/executors/utils.d.ts +0 -20
  299. package/dist/executors/web.d.ts +0 -89
  300. package/dist/extraction/content-extraction.d.ts +0 -48
  301. package/dist/extraction/index.d.ts +0 -4
  302. package/dist/headless-control-contract.d.ts +0 -3182
  303. package/dist/index.d.ts +0 -62
  304. package/dist/local-control-http-auth.d.ts +0 -2
  305. package/dist/mcp/client.d.ts +0 -68
  306. package/dist/mcp/connection.d.ts +0 -54
  307. package/dist/mcp/index.d.ts +0 -10
  308. package/dist/mcp/jsonrpc.d.ts +0 -36
  309. package/dist/mcp/types.d.ts +0 -178
  310. package/dist/network-control-adapter.d.ts +0 -4
  311. package/dist/network-runtime/address-types.d.ts +0 -201
  312. package/dist/network-runtime/db-owner-fencing.d.ts +0 -43
  313. package/dist/network-runtime/delivery-receipts.d.ts +0 -117
  314. package/dist/network-runtime/direct-endpoint-authority.d.ts +0 -8
  315. package/dist/network-runtime/index.d.ts +0 -24
  316. package/dist/network-runtime/local-control-contract.d.ts +0 -758
  317. package/dist/network-runtime/node-store-contract.d.ts +0 -49
  318. package/dist/network-runtime/pair-route-contract.d.ts +0 -100
  319. package/dist/network-runtime/peer-capabilities.d.ts +0 -10
  320. package/dist/network-runtime/peer-principal-ref.d.ts +0 -9
  321. package/dist/network-runtime/peer-state-machine.d.ts +0 -70
  322. package/dist/network-runtime/protocol-schemas.d.ts +0 -328
  323. package/dist/network-runtime/runtime-bootstrap-contract.d.ts +0 -81
  324. package/dist/outlook/desktop-session.d.ts +0 -68
  325. package/dist/policy.d.ts +0 -43
  326. package/dist/providers/brave.d.ts +0 -10
  327. package/dist/providers/duckduckgo.d.ts +0 -18
  328. package/dist/providers/exa.d.ts +0 -10
  329. package/dist/providers/firecrawl.d.ts +0 -10
  330. package/dist/providers/index.d.ts +0 -8
  331. package/dist/providers/jina.d.ts +0 -10
  332. package/dist/providers/router.d.ts +0 -21
  333. package/dist/providers/search-provider.d.ts +0 -35
  334. package/dist/providers/tavily.d.ts +0 -10
  335. package/dist/pty-cf6pmvx6.js +0 -1
  336. package/dist/quip/desktop-session.d.ts +0 -69
  337. package/dist/registry/index.d.ts +0 -1
  338. package/dist/registry/registry.d.ts +0 -156
  339. package/dist/runtime-socket-local-control-client.d.ts +0 -10
  340. package/dist/security/dns-normalization.d.ts +0 -6
  341. package/dist/security/dns-pinning.d.ts +0 -27
  342. package/dist/security/external-content.d.ts +0 -40
  343. package/dist/security/ssrf.d.ts +0 -40
  344. package/dist/slack/desktop-session.d.ts +0 -69
  345. package/dist/tool-factory.d.ts +0 -46
  346. package/dist/types.d.ts +0 -1192
  347. package/dist/utils/retry.d.ts +0 -11
  348. package/dist/utils/safe-parse-json.d.ts +0 -26
  349. package/dist/utils/url.d.ts +0 -10
  350. package/dist-cjs/ask-user-interaction.d.ts +0 -10
  351. package/dist-cjs/cache/web-cache.d.ts +0 -52
  352. package/dist-cjs/definitions/arion.d.ts +0 -8
  353. package/dist-cjs/definitions/browser/browser.d.ts +0 -2
  354. package/dist-cjs/definitions/browser/index.d.ts +0 -1
  355. package/dist-cjs/definitions/browser/pw-downloads.d.ts +0 -13
  356. package/dist-cjs/definitions/browser/pw-interactions.d.ts +0 -78
  357. package/dist-cjs/definitions/browser/pw-responses.d.ts +0 -28
  358. package/dist-cjs/definitions/browser/pw-session.d.ts +0 -65
  359. package/dist-cjs/definitions/browser/pw-shared.d.ts +0 -22
  360. package/dist-cjs/definitions/browser/pw-snapshot.d.ts +0 -34
  361. package/dist-cjs/definitions/browser/pw-state.d.ts +0 -22
  362. package/dist-cjs/definitions/browser/types.d.ts +0 -277
  363. package/dist-cjs/definitions/code-intelligence.d.ts +0 -8
  364. package/dist-cjs/definitions/core.d.ts +0 -47
  365. package/dist-cjs/definitions/delegation.d.ts +0 -11
  366. package/dist-cjs/definitions/deploy.d.ts +0 -15
  367. package/dist-cjs/definitions/filesystem.d.ts +0 -9
  368. package/dist-cjs/definitions/frg.d.ts +0 -3
  369. package/dist-cjs/definitions/memory.d.ts +0 -8
  370. package/dist-cjs/definitions/messaging.d.ts +0 -11
  371. package/dist-cjs/definitions/meta.d.ts +0 -11
  372. package/dist-cjs/definitions/network.d.ts +0 -11
  373. package/dist-cjs/definitions/outlook.d.ts +0 -2
  374. package/dist-cjs/definitions/patch/apply-patch.d.ts +0 -11
  375. package/dist-cjs/definitions/patch/fuzzy-match.d.ts +0 -10
  376. package/dist-cjs/definitions/patch/patch-parser.d.ts +0 -50
  377. package/dist-cjs/definitions/patch/sandbox-paths.d.ts +0 -18
  378. package/dist-cjs/definitions/process/index.d.ts +0 -1
  379. package/dist-cjs/definitions/process/process-registry.d.ts +0 -67
  380. package/dist-cjs/definitions/process/process.d.ts +0 -9
  381. package/dist-cjs/definitions/process/pty-keys.d.ts +0 -13
  382. package/dist-cjs/definitions/process/session-slug.d.ts +0 -1
  383. package/dist-cjs/definitions/quip.d.ts +0 -2
  384. package/dist-cjs/definitions/search.d.ts +0 -9
  385. package/dist-cjs/definitions/session-history.d.ts +0 -11
  386. package/dist-cjs/definitions/shell.d.ts +0 -8
  387. package/dist-cjs/definitions/slack.d.ts +0 -2
  388. package/dist-cjs/definitions/web.d.ts +0 -8
  389. package/dist-cjs/executors/apply-patch.d.ts +0 -51
  390. package/dist-cjs/executors/arion.d.ts +0 -50
  391. package/dist-cjs/executors/code-intelligence.d.ts +0 -138
  392. package/dist-cjs/executors/deploy.d.ts +0 -169
  393. package/dist-cjs/executors/filesystem.d.ts +0 -150
  394. package/dist-cjs/executors/frg-freshness.d.ts +0 -93
  395. package/dist-cjs/executors/frg.d.ts +0 -27
  396. package/dist-cjs/executors/learning-meta.d.ts +0 -87
  397. package/dist-cjs/executors/lsp-client.d.ts +0 -38
  398. package/dist-cjs/executors/memory.d.ts +0 -203
  399. package/dist-cjs/executors/meta.d.ts +0 -73
  400. package/dist-cjs/executors/process-registry.d.ts +0 -98
  401. package/dist-cjs/executors/pty-session-store.d.ts +0 -14
  402. package/dist-cjs/executors/pty.d.ts +0 -133
  403. package/dist-cjs/executors/restart.d.ts +0 -13
  404. package/dist-cjs/executors/search-freshness.d.ts +0 -50
  405. package/dist-cjs/executors/search-types.d.ts +0 -52
  406. package/dist-cjs/executors/search.d.ts +0 -11
  407. package/dist-cjs/executors/self-diagnose.d.ts +0 -89
  408. package/dist-cjs/executors/session-history.d.ts +0 -75
  409. package/dist-cjs/executors/shell-safety.d.ts +0 -27
  410. package/dist-cjs/executors/shell.d.ts +0 -168
  411. package/dist-cjs/executors/utils.d.ts +0 -20
  412. package/dist-cjs/executors/web.d.ts +0 -89
  413. package/dist-cjs/extraction/content-extraction.d.ts +0 -48
  414. package/dist-cjs/extraction/index.d.ts +0 -4
  415. package/dist-cjs/headless-control-contract.d.ts +0 -3182
  416. package/dist-cjs/index.d.ts +0 -62
  417. package/dist-cjs/local-control-http-auth.d.ts +0 -2
  418. package/dist-cjs/mcp/client.d.ts +0 -68
  419. package/dist-cjs/mcp/connection.d.ts +0 -54
  420. package/dist-cjs/mcp/index.d.ts +0 -10
  421. package/dist-cjs/mcp/jsonrpc.d.ts +0 -36
  422. package/dist-cjs/mcp/types.d.ts +0 -178
  423. package/dist-cjs/network-control-adapter.d.ts +0 -4
  424. package/dist-cjs/network-runtime/address-types.d.ts +0 -201
  425. package/dist-cjs/network-runtime/db-owner-fencing.d.ts +0 -43
  426. package/dist-cjs/network-runtime/delivery-receipts.d.ts +0 -117
  427. package/dist-cjs/network-runtime/direct-endpoint-authority.d.ts +0 -8
  428. package/dist-cjs/network-runtime/index.d.ts +0 -24
  429. package/dist-cjs/network-runtime/local-control-contract.d.ts +0 -758
  430. package/dist-cjs/network-runtime/node-store-contract.d.ts +0 -49
  431. package/dist-cjs/network-runtime/pair-route-contract.d.ts +0 -100
  432. package/dist-cjs/network-runtime/peer-capabilities.d.ts +0 -10
  433. package/dist-cjs/network-runtime/peer-principal-ref.d.ts +0 -9
  434. package/dist-cjs/network-runtime/peer-state-machine.d.ts +0 -70
  435. package/dist-cjs/network-runtime/protocol-schemas.d.ts +0 -328
  436. package/dist-cjs/network-runtime/runtime-bootstrap-contract.d.ts +0 -81
  437. package/dist-cjs/outlook/desktop-session.d.ts +0 -68
  438. package/dist-cjs/policy.d.ts +0 -43
  439. package/dist-cjs/providers/brave.d.ts +0 -10
  440. package/dist-cjs/providers/duckduckgo.d.ts +0 -18
  441. package/dist-cjs/providers/exa.d.ts +0 -10
  442. package/dist-cjs/providers/firecrawl.d.ts +0 -10
  443. package/dist-cjs/providers/jina.d.ts +0 -10
  444. package/dist-cjs/providers/router.d.ts +0 -21
  445. package/dist-cjs/providers/search-provider.d.ts +0 -35
  446. package/dist-cjs/providers/tavily.d.ts +0 -10
  447. package/dist-cjs/quip/desktop-session.d.ts +0 -69
  448. package/dist-cjs/registry/registry.d.ts +0 -156
  449. package/dist-cjs/runtime-socket-local-control-client.d.ts +0 -10
  450. package/dist-cjs/security/dns-normalization.d.ts +0 -6
  451. package/dist-cjs/security/dns-pinning.d.ts +0 -27
  452. package/dist-cjs/security/external-content.d.ts +0 -40
  453. package/dist-cjs/security/ssrf.d.ts +0 -40
  454. package/dist-cjs/slack/desktop-session.d.ts +0 -69
  455. package/dist-cjs/tool-factory.d.ts +0 -46
  456. package/dist-cjs/types.d.ts +0 -1192
  457. package/dist-cjs/utils/retry.d.ts +0 -11
  458. package/dist-cjs/utils/safe-parse-json.d.ts +0 -26
  459. package/dist-cjs/utils/url.d.ts +0 -10
@@ -0,0 +1,311 @@
1
+ // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
+ // https://github.com/openclaw/openclaw
3
+ // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
+ import { MAX_CONSOLE_MESSAGES, MAX_NETWORK_REQUESTS, MAX_PAGE_ERRORS } from "./pw-responses.js";
5
+ // ── Module-level state (singleton per Node process) ───────────────────
6
+ let currentSession = null;
7
+ let currentRefs = {};
8
+ const consoleMessages = [];
9
+ const networkRequests = [];
10
+ const pageErrors = [];
11
+ let nextRequestId = 0;
12
+ const DEFAULT_NAVIGATION_OPTIONS = {
13
+ timeout: 20_000,
14
+ waitUntil: "domcontentloaded",
15
+ };
16
+ // ── Accessors ─────────────────────────────────────────────────────────
17
+ export function getSession() {
18
+ return currentSession;
19
+ }
20
+ export function getRefs() {
21
+ return currentRefs;
22
+ }
23
+ export function setRefs(refs) {
24
+ currentRefs = refs;
25
+ }
26
+ export function getConsoleMessages() {
27
+ return consoleMessages;
28
+ }
29
+ export function getNetworkRequests() {
30
+ return networkRequests;
31
+ }
32
+ export function getPageErrors() {
33
+ return pageErrors;
34
+ }
35
+ const defaultPlaywrightLoader = () => Function('return import("playwright")')();
36
+ let playwrightLoader = defaultPlaywrightLoader;
37
+ /**
38
+ * Test seam for injecting a mocked playwright loader.
39
+ * Passing null restores the production loader.
40
+ */
41
+ export function setPlaywrightLoaderForTest(loader) {
42
+ playwrightLoader = loader ?? defaultPlaywrightLoader;
43
+ }
44
+ // ── Page listener wiring ──────────────────────────────────────────────
45
+ const observedPages = new WeakSet();
46
+ function wirePageListeners(page) {
47
+ if (observedPages.has(page)) {
48
+ return;
49
+ }
50
+ observedPages.add(page);
51
+ page.on("console", (...args) => {
52
+ const msg = args[0];
53
+ if (!msg)
54
+ return;
55
+ const entry = {
56
+ type: typeof msg.type === "function" ? msg.type() : "log",
57
+ text: typeof msg.text === "function" ? msg.text() : String(msg),
58
+ timestamp: new Date().toISOString(),
59
+ };
60
+ consoleMessages.push(entry);
61
+ if (consoleMessages.length > MAX_CONSOLE_MESSAGES) {
62
+ consoleMessages.shift();
63
+ }
64
+ });
65
+ page.on("pageerror", (...args) => {
66
+ const err = args[0];
67
+ pageErrors.push({
68
+ message: err?.message ? String(err.message) : String(err),
69
+ name: err?.name ? String(err.name) : undefined,
70
+ timestamp: new Date().toISOString(),
71
+ });
72
+ if (pageErrors.length > MAX_PAGE_ERRORS) {
73
+ pageErrors.shift();
74
+ }
75
+ });
76
+ page.on("request", (...args) => {
77
+ const req = args[0];
78
+ if (!req)
79
+ return;
80
+ nextRequestId += 1;
81
+ const entry = {
82
+ id: `r${nextRequestId}`,
83
+ timestamp: new Date().toISOString(),
84
+ method: typeof req.method === "function" ? req.method() : "GET",
85
+ url: typeof req.url === "function" ? req.url() : "",
86
+ resourceType: typeof req.resourceType === "function" ? req.resourceType() : undefined,
87
+ };
88
+ networkRequests.push(entry);
89
+ if (networkRequests.length > MAX_NETWORK_REQUESTS) {
90
+ networkRequests.shift();
91
+ }
92
+ });
93
+ page.on("response", (...args) => {
94
+ const resp = args[0];
95
+ if (!resp)
96
+ return;
97
+ const respUrl = typeof resp.url === "function" ? resp.url() : "";
98
+ // Match by URL (find most recent matching request)
99
+ for (let i = networkRequests.length - 1; i >= 0; i -= 1) {
100
+ const rec = networkRequests[i];
101
+ if (rec && rec.url === respUrl && rec.status === undefined) {
102
+ rec.status = typeof resp.status === "function" ? resp.status() : undefined;
103
+ rec.ok = typeof resp.ok === "function" ? resp.ok() : undefined;
104
+ break;
105
+ }
106
+ }
107
+ });
108
+ page.on("requestfailed", (...args) => {
109
+ const req = args[0];
110
+ if (!req)
111
+ return;
112
+ const failUrl = typeof req.url === "function" ? req.url() : "";
113
+ for (let i = networkRequests.length - 1; i >= 0; i -= 1) {
114
+ const rec = networkRequests[i];
115
+ if (rec && rec.url === failUrl && rec.ok === undefined) {
116
+ rec.ok = false;
117
+ rec.failureText = typeof req.failure === "function" ? req.failure()?.errorText : undefined;
118
+ break;
119
+ }
120
+ }
121
+ });
122
+ }
123
+ function isChromiumLike(value) {
124
+ return (typeof value === "object" &&
125
+ value !== null &&
126
+ typeof value.launch === "function");
127
+ }
128
+ /**
129
+ * Resolve Playwright's chromium launcher across module interop shapes.
130
+ * Some runtimes expose `{ chromium }`, others only `{ default: { chromium } }`.
131
+ */
132
+ export function resolveChromiumLauncher(moduleValue) {
133
+ const pw = moduleValue;
134
+ const chromium = pw?.chromium ?? pw?.default?.chromium;
135
+ if (isChromiumLike(chromium)) {
136
+ return chromium;
137
+ }
138
+ const keys = pw && typeof pw === "object"
139
+ ? Object.keys(pw)
140
+ .sort()
141
+ .join(", ")
142
+ : String(pw);
143
+ throw new Error(`Invalid playwright module shape: missing chromium.launch (module keys: ${keys || "(none)"}).`);
144
+ }
145
+ /**
146
+ * Launch a new Playwright browser session.
147
+ * Uses dynamic import so the tool module loads even without playwright installed.
148
+ */
149
+ export async function launchBrowser(options) {
150
+ if (currentSession) {
151
+ // Already have a session — navigate if URL given, otherwise return existing
152
+ if (options?.url) {
153
+ try {
154
+ await currentSession.page.goto(options.url, DEFAULT_NAVIGATION_OPTIONS);
155
+ }
156
+ catch (error) {
157
+ const message = error instanceof Error ? error.message : String(error);
158
+ throw new Error(`Navigation to ${options.url} failed: ${message}. Session remains active; use 'snapshot' or retry 'navigate'.`);
159
+ }
160
+ }
161
+ return currentSession;
162
+ }
163
+ // Dynamic import: playwright is an optional peer dependency.
164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
+ let pw;
166
+ try {
167
+ pw = await playwrightLoader();
168
+ }
169
+ catch {
170
+ throw new Error("playwright is not installed. Run: npx playwright install chromium\n" +
171
+ "Or: npm install playwright && npx playwright install chromium");
172
+ }
173
+ const chromium = resolveChromiumLauncher(pw);
174
+ const browser = await chromium.launch({
175
+ headless: options?.headless !== false, // default headless
176
+ });
177
+ const context = browser.newContext
178
+ ? await browser.newContext({
179
+ viewport: { width: 1280, height: 720 },
180
+ userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
181
+ })
182
+ : (browser.contexts()[0] ??
183
+ (() => {
184
+ throw new Error("No browser context available");
185
+ })());
186
+ const page = context.pages?.().length
187
+ ? context.pages()[0]
188
+ : await context.newPage();
189
+ wirePageListeners(page);
190
+ // Persist session state before first navigation so launch+goto timeout
191
+ // cannot leave the tool in a "no session" state.
192
+ currentSession = { browser, context, page };
193
+ currentRefs = {};
194
+ consoleMessages.length = 0;
195
+ networkRequests.length = 0;
196
+ pageErrors.length = 0;
197
+ nextRequestId = 0;
198
+ if (options?.url) {
199
+ try {
200
+ await page.goto(options.url, DEFAULT_NAVIGATION_OPTIONS);
201
+ }
202
+ catch (error) {
203
+ const message = error instanceof Error ? error.message : String(error);
204
+ throw new Error(`Browser launched, but initial navigation to ${options.url} failed: ${message}. Session remains active; use 'snapshot' or retry 'navigate'.`);
205
+ }
206
+ }
207
+ return currentSession;
208
+ }
209
+ /**
210
+ * Close the current browser session and clean up all state.
211
+ */
212
+ export async function closeBrowser() {
213
+ const session = currentSession;
214
+ currentSession = null;
215
+ currentRefs = {};
216
+ consoleMessages.length = 0;
217
+ networkRequests.length = 0;
218
+ pageErrors.length = 0;
219
+ nextRequestId = 0;
220
+ if (session) {
221
+ try {
222
+ await session.browser.close();
223
+ }
224
+ catch {
225
+ // Best-effort close.
226
+ }
227
+ }
228
+ }
229
+ // ── Tab management ────────────────────────────────────────────────────
230
+ /**
231
+ * List all open tabs (pages) in the current context.
232
+ */
233
+ export function listTabs() {
234
+ if (!currentSession) {
235
+ return [];
236
+ }
237
+ const pages = currentSession.context.pages();
238
+ return pages.map((p, i) => ({
239
+ index: i,
240
+ url: p.url(),
241
+ active: p === currentSession.page,
242
+ }));
243
+ }
244
+ /**
245
+ * Open a new tab, optionally navigating to a URL.
246
+ */
247
+ export async function newTab(url) {
248
+ if (!currentSession) {
249
+ const launched = await launchBrowser({ url });
250
+ return { index: 0, url: launched.page.url() };
251
+ }
252
+ const page = await currentSession.context.newPage();
253
+ wirePageListeners(page);
254
+ currentSession.page = page;
255
+ currentRefs = {};
256
+ if (url) {
257
+ await page.goto(url, DEFAULT_NAVIGATION_OPTIONS);
258
+ }
259
+ const pages = currentSession.context.pages();
260
+ return { index: pages.length - 1, url: page.url() };
261
+ }
262
+ /**
263
+ * Switch to a tab by index.
264
+ */
265
+ export async function selectTab(index) {
266
+ if (!currentSession) {
267
+ await launchBrowser();
268
+ }
269
+ if (!currentSession) {
270
+ throw new Error("No tabs open.");
271
+ }
272
+ const pages = currentSession.context.pages();
273
+ if (index < 0 || index >= pages.length) {
274
+ throw new Error(`Tab index ${index} out of range (0..${pages.length - 1})`);
275
+ }
276
+ const page = pages[index];
277
+ currentSession.page = page;
278
+ wirePageListeners(page);
279
+ currentRefs = {};
280
+ return { url: page.url() };
281
+ }
282
+ /**
283
+ * Close a tab by index (defaults to current tab).
284
+ */
285
+ export async function closeTab(index) {
286
+ if (!currentSession) {
287
+ throw new Error("No tabs open.");
288
+ }
289
+ const pages = currentSession.context.pages();
290
+ const targetIndex = index ?? pages.indexOf(currentSession.page);
291
+ if (targetIndex < 0 || targetIndex >= pages.length) {
292
+ throw new Error(`Tab index ${targetIndex} out of range`);
293
+ }
294
+ const targetPage = pages[targetIndex];
295
+ await targetPage.close();
296
+ // Update current page if we closed the active one
297
+ const remaining = currentSession.context.pages();
298
+ if (!remaining.length) {
299
+ // All tabs closed — create a fresh one
300
+ const page = await currentSession.context.newPage();
301
+ currentSession.page = page;
302
+ wirePageListeners(page);
303
+ }
304
+ else if (targetPage === currentSession.page) {
305
+ const newIndex = Math.min(targetIndex, remaining.length - 1);
306
+ currentSession.page = remaining[newIndex];
307
+ wirePageListeners(currentSession.page);
308
+ }
309
+ currentRefs = {};
310
+ }
311
+ //# sourceMappingURL=pw-session.js.map
@@ -0,0 +1,67 @@
1
+ // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
+ // https://github.com/openclaw/openclaw
3
+ // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
+ /**
5
+ * Shared utilities for Playwright-based browser tool functions.
6
+ * Ported from OpenClaw's pw-tools-core.shared.ts.
7
+ */
8
+ /**
9
+ * Parse a raw ref string into its canonical "eN" form.
10
+ * Accepts: "e1", "@e1", "ref=e1" -> "e1". Returns null if invalid.
11
+ */
12
+ export function parseRoleRef(raw) {
13
+ const trimmed = raw.trim();
14
+ if (!trimmed) {
15
+ return null;
16
+ }
17
+ const normalized = trimmed.startsWith("@")
18
+ ? trimmed.slice(1)
19
+ : trimmed.startsWith("ref=")
20
+ ? trimmed.slice(4)
21
+ : trimmed;
22
+ return /^e\d+$/.test(normalized) ? normalized : null;
23
+ }
24
+ /**
25
+ * Validate and normalize a ref string. Throws if the ref is empty/invalid.
26
+ */
27
+ export function requireRef(value) {
28
+ const raw = typeof value === "string" ? value.trim() : "";
29
+ const roleRef = raw ? parseRoleRef(raw) : null;
30
+ const ref = roleRef ?? (raw.startsWith("@") ? raw.slice(1) : raw);
31
+ if (!ref) {
32
+ throw new Error("ref is required");
33
+ }
34
+ return ref;
35
+ }
36
+ /**
37
+ * Clamp a timeout value to a safe range (500ms .. 120s).
38
+ */
39
+ export function normalizeTimeoutMs(timeoutMs, fallback) {
40
+ return Math.max(500, Math.min(120_000, timeoutMs ?? fallback));
41
+ }
42
+ /**
43
+ * Rewrite Playwright errors into messages that guide the LLM to take
44
+ * corrective action (re-snapshot, scroll, etc.).
45
+ */
46
+ export function toAIFriendlyError(error, selector) {
47
+ const message = error instanceof Error ? error.message : String(error);
48
+ if (message.includes("strict mode violation")) {
49
+ const countMatch = message.match(/resolved to (\d+) elements/);
50
+ const count = countMatch ? countMatch[1] : "multiple";
51
+ return new Error(`Selector "${selector}" matched ${count} elements. ` +
52
+ `Run a new snapshot to get updated refs, or use a different ref.`);
53
+ }
54
+ if ((message.includes("Timeout") || message.includes("waiting for")) &&
55
+ (message.includes("to be visible") || message.includes("not visible"))) {
56
+ return new Error(`Element "${selector}" not found or not visible. ` +
57
+ `Run a new snapshot to see current page elements.`);
58
+ }
59
+ if (message.includes("intercepts pointer events") ||
60
+ message.includes("not visible") ||
61
+ message.includes("not receive pointer events")) {
62
+ return new Error(`Element "${selector}" is not interactable (hidden or covered). ` +
63
+ `Try scrolling it into view, closing overlays, or re-snapshotting.`);
64
+ }
65
+ return error instanceof Error ? error : new Error(message);
66
+ }
67
+ //# sourceMappingURL=pw-shared.js.map
@@ -0,0 +1,302 @@
1
+ // Originally from OpenClaw (MIT License, Copyright 2025 Peter Steinberger)
2
+ // https://github.com/openclaw/openclaw
3
+ // Modified for ARIA — stripped OpenClaw runtime, rewired to ARIA Tool interface
4
+ // ── Role classification sets ──────────────────────────────────────────
5
+ const INTERACTIVE_ROLES = new Set([
6
+ "button",
7
+ "link",
8
+ "textbox",
9
+ "checkbox",
10
+ "radio",
11
+ "combobox",
12
+ "listbox",
13
+ "menuitem",
14
+ "menuitemcheckbox",
15
+ "menuitemradio",
16
+ "option",
17
+ "searchbox",
18
+ "slider",
19
+ "spinbutton",
20
+ "switch",
21
+ "tab",
22
+ "treeitem",
23
+ ]);
24
+ const CONTENT_ROLES = new Set([
25
+ "heading",
26
+ "cell",
27
+ "gridcell",
28
+ "columnheader",
29
+ "rowheader",
30
+ "listitem",
31
+ "article",
32
+ "region",
33
+ "main",
34
+ "navigation",
35
+ ]);
36
+ const STRUCTURAL_ROLES = new Set([
37
+ "generic",
38
+ "group",
39
+ "list",
40
+ "table",
41
+ "row",
42
+ "rowgroup",
43
+ "grid",
44
+ "treegrid",
45
+ "menu",
46
+ "menubar",
47
+ "toolbar",
48
+ "tablist",
49
+ "tree",
50
+ "directory",
51
+ "document",
52
+ "application",
53
+ "presentation",
54
+ "none",
55
+ ]);
56
+ // ── Stats ─────────────────────────────────────────────────────────────
57
+ export function getRoleSnapshotStats(snapshot, refs) {
58
+ const interactive = Object.values(refs).filter((r) => INTERACTIVE_ROLES.has(r.role)).length;
59
+ return {
60
+ lines: snapshot.split("\n").length,
61
+ chars: snapshot.length,
62
+ refs: Object.keys(refs).length,
63
+ interactive,
64
+ };
65
+ }
66
+ // ── Internal helpers ──────────────────────────────────────────────────
67
+ function getIndentLevel(line) {
68
+ const match = line.match(/^(\s*)/);
69
+ return match ? Math.floor(match[1].length / 2) : 0;
70
+ }
71
+ function createRoleNameTracker() {
72
+ const counts = new Map();
73
+ const refsByKey = new Map();
74
+ return {
75
+ counts,
76
+ refsByKey,
77
+ getKey(role, name) {
78
+ return `${role}:${name ?? ""}`;
79
+ },
80
+ getNextIndex(role, name) {
81
+ const key = this.getKey(role, name);
82
+ const current = counts.get(key) ?? 0;
83
+ counts.set(key, current + 1);
84
+ return current;
85
+ },
86
+ trackRef(role, name, ref) {
87
+ const key = this.getKey(role, name);
88
+ const list = refsByKey.get(key) ?? [];
89
+ list.push(ref);
90
+ refsByKey.set(key, list);
91
+ },
92
+ getDuplicateKeys() {
93
+ const out = new Set();
94
+ for (const [key, refs] of refsByKey) {
95
+ if (refs.length > 1) {
96
+ out.add(key);
97
+ }
98
+ }
99
+ return out;
100
+ },
101
+ };
102
+ }
103
+ function removeNthFromNonDuplicates(refs, tracker) {
104
+ const duplicates = tracker.getDuplicateKeys();
105
+ for (const [ref, data] of Object.entries(refs)) {
106
+ const key = tracker.getKey(data.role, data.name);
107
+ if (!duplicates.has(key)) {
108
+ delete refs[ref]?.nth;
109
+ }
110
+ }
111
+ }
112
+ function compactTree(tree) {
113
+ const lines = tree.split("\n");
114
+ const result = [];
115
+ for (let i = 0; i < lines.length; i += 1) {
116
+ const line = lines[i];
117
+ if (line.includes("[ref=")) {
118
+ result.push(line);
119
+ continue;
120
+ }
121
+ if (line.includes(":") && !line.trimEnd().endsWith(":")) {
122
+ result.push(line);
123
+ continue;
124
+ }
125
+ const currentIndent = getIndentLevel(line);
126
+ let hasRelevantChildren = false;
127
+ for (let j = i + 1; j < lines.length; j += 1) {
128
+ const childIndent = getIndentLevel(lines[j]);
129
+ if (childIndent <= currentIndent) {
130
+ break;
131
+ }
132
+ if (lines[j]?.includes("[ref=")) {
133
+ hasRelevantChildren = true;
134
+ break;
135
+ }
136
+ }
137
+ if (hasRelevantChildren) {
138
+ result.push(line);
139
+ }
140
+ }
141
+ return result.join("\n");
142
+ }
143
+ function matchInteractiveSnapshotLine(line, options) {
144
+ const depth = getIndentLevel(line);
145
+ if (options.maxDepth !== undefined && depth > options.maxDepth) {
146
+ return null;
147
+ }
148
+ const match = line.match(/^(\s*-\s*)(\w+)(?:\s+"([^"]*)")?(.*)$/);
149
+ if (!match) {
150
+ return null;
151
+ }
152
+ const [, , roleRaw, name, suffix] = match;
153
+ if (roleRaw.startsWith("/")) {
154
+ return null;
155
+ }
156
+ const role = roleRaw.toLowerCase();
157
+ return {
158
+ roleRaw: roleRaw,
159
+ role,
160
+ ...(name ? { name } : {}),
161
+ suffix: suffix,
162
+ };
163
+ }
164
+ function processLine(line, refs, options, tracker, nextRef) {
165
+ const depth = getIndentLevel(line);
166
+ if (options.maxDepth !== undefined && depth > options.maxDepth) {
167
+ return null;
168
+ }
169
+ const match = line.match(/^(\s*-\s*)(\w+)(?:\s+"([^"]*)")?(.*)$/);
170
+ if (!match) {
171
+ return options.interactive ? null : line;
172
+ }
173
+ const [, prefix, roleRaw, name, suffix] = match;
174
+ if (roleRaw.startsWith("/")) {
175
+ return options.interactive ? null : line;
176
+ }
177
+ const role = roleRaw.toLowerCase();
178
+ const isInteractive = INTERACTIVE_ROLES.has(role);
179
+ const isContent = CONTENT_ROLES.has(role);
180
+ const isStructural = STRUCTURAL_ROLES.has(role);
181
+ if (options.interactive && !isInteractive) {
182
+ return null;
183
+ }
184
+ if (options.compact && isStructural && !name) {
185
+ return null;
186
+ }
187
+ const shouldHaveRef = isInteractive || (isContent && !!name);
188
+ if (!shouldHaveRef) {
189
+ return line;
190
+ }
191
+ const ref = nextRef();
192
+ const nth = tracker.getNextIndex(role, name);
193
+ tracker.trackRef(role, name, ref);
194
+ refs[ref] = { role, name, nth };
195
+ let enhanced = `${prefix}${roleRaw}`;
196
+ if (name) {
197
+ enhanced += ` "${name}"`;
198
+ }
199
+ enhanced += ` [ref=${ref}]`;
200
+ if (nth > 0) {
201
+ enhanced += ` [nth=${nth}]`;
202
+ }
203
+ if (suffix) {
204
+ enhanced += suffix;
205
+ }
206
+ return enhanced;
207
+ }
208
+ // ── Public API ────────────────────────────────────────────────────────
209
+ /**
210
+ * Build a role-ref snapshot from Playwright's ariaSnapshot() output.
211
+ * This is the core transform: raw ARIA tree text -> annotated tree + ref map.
212
+ */
213
+ export function buildRoleSnapshotFromAriaSnapshot(ariaSnapshot, options = {}) {
214
+ const lines = ariaSnapshot.split("\n");
215
+ const refs = {};
216
+ const tracker = createRoleNameTracker();
217
+ let counter = 0;
218
+ const nextRef = () => {
219
+ counter += 1;
220
+ return `e${counter}`;
221
+ };
222
+ if (options.interactive) {
223
+ const result = [];
224
+ for (const line of lines) {
225
+ const parsed = matchInteractiveSnapshotLine(line, options);
226
+ if (!parsed) {
227
+ continue;
228
+ }
229
+ const { roleRaw, role, name, suffix } = parsed;
230
+ if (!INTERACTIVE_ROLES.has(role)) {
231
+ continue;
232
+ }
233
+ const ref = nextRef();
234
+ const nth = tracker.getNextIndex(role, name);
235
+ tracker.trackRef(role, name, ref);
236
+ refs[ref] = { role, name, nth };
237
+ let enhanced = `- ${roleRaw}`;
238
+ if (name) {
239
+ enhanced += ` "${name}"`;
240
+ }
241
+ enhanced += ` [ref=${ref}]`;
242
+ if (nth > 0) {
243
+ enhanced += ` [nth=${nth}]`;
244
+ }
245
+ if (suffix.includes("[")) {
246
+ enhanced += suffix;
247
+ }
248
+ result.push(enhanced);
249
+ }
250
+ removeNthFromNonDuplicates(refs, tracker);
251
+ return {
252
+ snapshot: result.join("\n") || "(no interactive elements)",
253
+ refs,
254
+ };
255
+ }
256
+ const result = [];
257
+ for (const line of lines) {
258
+ const processed = processLine(line, refs, options, tracker, nextRef);
259
+ if (processed !== null) {
260
+ result.push(processed);
261
+ }
262
+ }
263
+ removeNthFromNonDuplicates(refs, tracker);
264
+ const tree = result.join("\n") || "(empty)";
265
+ return {
266
+ snapshot: options.compact ? compactTree(tree) : tree,
267
+ refs,
268
+ };
269
+ }
270
+ /**
271
+ * Take a role-based accessibility snapshot of a page.
272
+ * Uses Playwright's built-in ariaSnapshot() on the :root locator,
273
+ * then annotates elements with [ref=eN] markers.
274
+ */
275
+ export async function snapshotPage(page, options) {
276
+ const locator = page.locator(":root");
277
+ const ariaSnapshot = await locator.ariaSnapshot();
278
+ const built = buildRoleSnapshotFromAriaSnapshot(String(ariaSnapshot ?? ""), options);
279
+ const stats = getRoleSnapshotStats(built.snapshot, built.refs);
280
+ return {
281
+ snapshot: built.snapshot,
282
+ refs: built.refs,
283
+ stats,
284
+ url: page.url(),
285
+ title: await page.title(),
286
+ };
287
+ }
288
+ /**
289
+ * Navigate a page to a URL.
290
+ */
291
+ export async function navigatePage(page, url, timeoutMs) {
292
+ const target = String(url ?? "").trim();
293
+ if (!target) {
294
+ throw new Error("url is required");
295
+ }
296
+ await page.goto(target, {
297
+ timeout: Math.max(1000, Math.min(120_000, timeoutMs ?? 20_000)),
298
+ waitUntil: "domcontentloaded",
299
+ });
300
+ return { url: page.url() };
301
+ }
302
+ //# sourceMappingURL=pw-snapshot.js.map