browxai 0.7.0

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 (520) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/THIRD_PARTY_NOTICES.md +45 -0
  4. package/dist/cli/chrome.d.ts +1 -0
  5. package/dist/cli/chrome.js +130 -0
  6. package/dist/cli/command-registry.d.ts +15 -0
  7. package/dist/cli/command-registry.js +35 -0
  8. package/dist/cli/doctor-plugins.d.ts +18 -0
  9. package/dist/cli/doctor-plugins.js +338 -0
  10. package/dist/cli/doctor.d.ts +9 -0
  11. package/dist/cli/doctor.js +407 -0
  12. package/dist/cli/init.d.ts +1 -0
  13. package/dist/cli/init.js +200 -0
  14. package/dist/cli/register-commands.d.ts +1 -0
  15. package/dist/cli/register-commands.js +22 -0
  16. package/dist/cli/serve.d.ts +14 -0
  17. package/dist/cli/serve.js +151 -0
  18. package/dist/cli.d.ts +3 -0
  19. package/dist/cli.js +129 -0
  20. package/dist/engine/adapters/adb.d.ts +72 -0
  21. package/dist/engine/adapters/adb.js +200 -0
  22. package/dist/engine/adapters/android-cdp.d.ts +54 -0
  23. package/dist/engine/adapters/android-cdp.js +110 -0
  24. package/dist/engine/adapters/android.engine.d.ts +1 -0
  25. package/dist/engine/adapters/android.engine.js +31 -0
  26. package/dist/engine/adapters/chromium.engine.d.ts +1 -0
  27. package/dist/engine/adapters/chromium.engine.js +44 -0
  28. package/dist/engine/adapters/firefox.engine.d.ts +1 -0
  29. package/dist/engine/adapters/firefox.engine.js +43 -0
  30. package/dist/engine/adapters/playwright-chromium.d.ts +43 -0
  31. package/dist/engine/adapters/playwright-chromium.js +56 -0
  32. package/dist/engine/adapters/playwright-firefox.d.ts +52 -0
  33. package/dist/engine/adapters/playwright-firefox.js +97 -0
  34. package/dist/engine/adapters/playwright-webkit.d.ts +40 -0
  35. package/dist/engine/adapters/playwright-webkit.js +79 -0
  36. package/dist/engine/adapters/safari/bidi-client.d.ts +46 -0
  37. package/dist/engine/adapters/safari/bidi-client.js +130 -0
  38. package/dist/engine/adapters/safari/launch.d.ts +56 -0
  39. package/dist/engine/adapters/safari/launch.js +104 -0
  40. package/dist/engine/adapters/safari/webdriver-client.d.ts +102 -0
  41. package/dist/engine/adapters/safari/webdriver-client.js +175 -0
  42. package/dist/engine/adapters/safari.engine.d.ts +1 -0
  43. package/dist/engine/adapters/safari.engine.js +52 -0
  44. package/dist/engine/adapters/safaridriver-hybrid.d.ts +56 -0
  45. package/dist/engine/adapters/safaridriver-hybrid.js +127 -0
  46. package/dist/engine/adapters/webkit.engine.d.ts +1 -0
  47. package/dist/engine/adapters/webkit.engine.js +47 -0
  48. package/dist/engine/capabilities.d.ts +53 -0
  49. package/dist/engine/capabilities.js +122 -0
  50. package/dist/engine/capability-registry.d.ts +9 -0
  51. package/dist/engine/capability-registry.js +20 -0
  52. package/dist/engine/index.d.ts +18 -0
  53. package/dist/engine/index.js +14 -0
  54. package/dist/engine/register-engines.d.ts +5 -0
  55. package/dist/engine/register-engines.js +16 -0
  56. package/dist/engine/registry.d.ts +145 -0
  57. package/dist/engine/registry.js +67 -0
  58. package/dist/engine/select.d.ts +48 -0
  59. package/dist/engine/select.js +128 -0
  60. package/dist/engine/session-cdp.d.ts +13 -0
  61. package/dist/engine/session-cdp.js +22 -0
  62. package/dist/engine/tool-gate.d.ts +19 -0
  63. package/dist/engine/tool-gate.js +226 -0
  64. package/dist/engine/types.d.ts +71 -0
  65. package/dist/engine/types.js +16 -0
  66. package/dist/helper/bridge.d.ts +48 -0
  67. package/dist/helper/bridge.js +200 -0
  68. package/dist/helper/browx-page.d.ts +1 -0
  69. package/dist/helper/browx-page.js +47 -0
  70. package/dist/helper/overlay-hide.d.ts +9 -0
  71. package/dist/helper/overlay-hide.js +49 -0
  72. package/dist/helper/stealth.d.ts +10 -0
  73. package/dist/helper/stealth.js +88 -0
  74. package/dist/index.d.ts +7 -0
  75. package/dist/index.js +15 -0
  76. package/dist/page/a11y.d.ts +81 -0
  77. package/dist/page/a11y.js +219 -0
  78. package/dist/page/action-substrate.d.ts +64 -0
  79. package/dist/page/action-substrate.js +118 -0
  80. package/dist/page/actionresult-blocks.d.ts +99 -0
  81. package/dist/page/actionresult-blocks.js +144 -0
  82. package/dist/page/actionresult-shape.d.ts +48 -0
  83. package/dist/page/actionresult-shape.js +155 -0
  84. package/dist/page/actionresult-types.d.ts +368 -0
  85. package/dist/page/actionresult-types.js +4 -0
  86. package/dist/page/actionresult.d.ts +4 -0
  87. package/dist/page/actionresult.js +299 -0
  88. package/dist/page/actions-probe.d.ts +32 -0
  89. package/dist/page/actions-probe.js +294 -0
  90. package/dist/page/actions-scroll.d.ts +40 -0
  91. package/dist/page/actions-scroll.js +53 -0
  92. package/dist/page/actions.d.ts +132 -0
  93. package/dist/page/actions.js +453 -0
  94. package/dist/page/archive-assets.d.ts +39 -0
  95. package/dist/page/archive-assets.js +187 -0
  96. package/dist/page/archive.d.ts +47 -0
  97. package/dist/page/archive.js +349 -0
  98. package/dist/page/asset-export.d.ts +122 -0
  99. package/dist/page/asset-export.js +376 -0
  100. package/dist/page/await_network.d.ts +16 -0
  101. package/dist/page/await_network.js +23 -0
  102. package/dist/page/bbox.d.ts +37 -0
  103. package/dist/page/bbox.js +115 -0
  104. package/dist/page/canvas-capture.d.ts +82 -0
  105. package/dist/page/canvas-capture.js +257 -0
  106. package/dist/page/canvas-diff.d.ts +51 -0
  107. package/dist/page/canvas-diff.js +131 -0
  108. package/dist/page/canvas-gesture.d.ts +53 -0
  109. package/dist/page/canvas-gesture.js +167 -0
  110. package/dist/page/canvas-transform.d.ts +96 -0
  111. package/dist/page/canvas-transform.js +150 -0
  112. package/dist/page/canvas.d.ts +8 -0
  113. package/dist/page/canvas.js +50 -0
  114. package/dist/page/capture-substrate.d.ts +111 -0
  115. package/dist/page/capture-substrate.js +139 -0
  116. package/dist/page/clipboard.d.ts +25 -0
  117. package/dist/page/clipboard.js +50 -0
  118. package/dist/page/clock.d.ts +36 -0
  119. package/dist/page/clock.js +167 -0
  120. package/dist/page/compose.d.ts +55 -0
  121. package/dist/page/compose.js +169 -0
  122. package/dist/page/console.d.ts +39 -0
  123. package/dist/page/console.js +73 -0
  124. package/dist/page/coverage.d.ts +97 -0
  125. package/dist/page/coverage.js +280 -0
  126. package/dist/page/dom-export.d.ts +41 -0
  127. package/dist/page/dom-export.js +193 -0
  128. package/dist/page/dom-walk.d.ts +91 -0
  129. package/dist/page/dom-walk.js +267 -0
  130. package/dist/page/dom_diff.d.ts +48 -0
  131. package/dist/page/dom_diff.js +121 -0
  132. package/dist/page/downloads.d.ts +80 -0
  133. package/dist/page/downloads.js +244 -0
  134. package/dist/page/drop-files.d.ts +78 -0
  135. package/dist/page/drop-files.js +310 -0
  136. package/dist/page/element-export-discovery.d.ts +64 -0
  137. package/dist/page/element-export-discovery.js +346 -0
  138. package/dist/page/element-export.d.ts +46 -0
  139. package/dist/page/element-export.js +251 -0
  140. package/dist/page/emulation-substrate.d.ts +53 -0
  141. package/dist/page/emulation-substrate.js +87 -0
  142. package/dist/page/emulation.d.ts +60 -0
  143. package/dist/page/emulation.js +162 -0
  144. package/dist/page/export-playwright-script.d.ts +47 -0
  145. package/dist/page/export-playwright-script.js +304 -0
  146. package/dist/page/extract-resolve.d.ts +22 -0
  147. package/dist/page/extract-resolve.js +341 -0
  148. package/dist/page/extract-schema.d.ts +20 -0
  149. package/dist/page/extract-schema.js +200 -0
  150. package/dist/page/extract-types.d.ts +127 -0
  151. package/dist/page/extract-types.js +8 -0
  152. package/dist/page/extract-warnings.d.ts +8 -0
  153. package/dist/page/extract-warnings.js +56 -0
  154. package/dist/page/extract.d.ts +9 -0
  155. package/dist/page/extract.js +174 -0
  156. package/dist/page/fill-form.d.ts +58 -0
  157. package/dist/page/fill-form.js +261 -0
  158. package/dist/page/find.d.ts +158 -0
  159. package/dist/page/find.js +470 -0
  160. package/dist/page/frames.d.ts +45 -0
  161. package/dist/page/frames.js +133 -0
  162. package/dist/page/generate-locator.d.ts +57 -0
  163. package/dist/page/generate-locator.js +136 -0
  164. package/dist/page/gestures.d.ts +128 -0
  165. package/dist/page/gestures.js +198 -0
  166. package/dist/page/har.d.ts +91 -0
  167. package/dist/page/har.js +174 -0
  168. package/dist/page/heap.d.ts +97 -0
  169. package/dist/page/heap.js +285 -0
  170. package/dist/page/inspect.d.ts +34 -0
  171. package/dist/page/inspect.js +75 -0
  172. package/dist/page/layout-thrash.d.ts +34 -0
  173. package/dist/page/layout-thrash.js +232 -0
  174. package/dist/page/learning.d.ts +21 -0
  175. package/dist/page/learning.js +84 -0
  176. package/dist/page/locator.d.ts +54 -0
  177. package/dist/page/locator.js +142 -0
  178. package/dist/page/memory-diff.d.ts +48 -0
  179. package/dist/page/memory-diff.js +105 -0
  180. package/dist/page/network-mask.d.ts +8 -0
  181. package/dist/page/network-mask.js +18 -0
  182. package/dist/page/network-playwright.d.ts +96 -0
  183. package/dist/page/network-playwright.js +353 -0
  184. package/dist/page/network-substrate-select.d.ts +18 -0
  185. package/dist/page/network-substrate-select.js +32 -0
  186. package/dist/page/network-substrate.d.ts +109 -0
  187. package/dist/page/network-substrate.js +161 -0
  188. package/dist/page/network-ws.d.ts +46 -0
  189. package/dist/page/network-ws.js +113 -0
  190. package/dist/page/network.d.ts +194 -0
  191. package/dist/page/network.js +415 -0
  192. package/dist/page/overflow-detect.d.ts +102 -0
  193. package/dist/page/overflow-detect.js +449 -0
  194. package/dist/page/pdf.d.ts +69 -0
  195. package/dist/page/pdf.js +109 -0
  196. package/dist/page/perf-audit-analysers.d.ts +40 -0
  197. package/dist/page/perf-audit-analysers.js +369 -0
  198. package/dist/page/perf-audit-runner.d.ts +20 -0
  199. package/dist/page/perf-audit-runner.js +195 -0
  200. package/dist/page/perf-audit-types.d.ts +41 -0
  201. package/dist/page/perf-audit-types.js +5 -0
  202. package/dist/page/perf-audit.d.ts +37 -0
  203. package/dist/page/perf-audit.js +377 -0
  204. package/dist/page/perf.d.ts +127 -0
  205. package/dist/page/perf.js +373 -0
  206. package/dist/page/plan.d.ts +192 -0
  207. package/dist/page/plan.js +308 -0
  208. package/dist/page/point_probe.d.ts +46 -0
  209. package/dist/page/point_probe.js +99 -0
  210. package/dist/page/recording.d.ts +67 -0
  211. package/dist/page/recording.js +172 -0
  212. package/dist/page/refs.d.ts +92 -0
  213. package/dist/page/refs.js +134 -0
  214. package/dist/page/regions.d.ts +23 -0
  215. package/dist/page/regions.js +32 -0
  216. package/dist/page/routes.d.ts +40 -0
  217. package/dist/page/routes.js +87 -0
  218. package/dist/page/safari-actions.d.ts +12 -0
  219. package/dist/page/safari-actions.js +144 -0
  220. package/dist/page/sample.d.ts +64 -0
  221. package/dist/page/sample.js +216 -0
  222. package/dist/page/screenshot-on.d.ts +51 -0
  223. package/dist/page/screenshot-on.js +150 -0
  224. package/dist/page/screenshot-save.d.ts +36 -0
  225. package/dist/page/screenshot-save.js +53 -0
  226. package/dist/page/screenshot-schedule.d.ts +50 -0
  227. package/dist/page/screenshot-schedule.js +155 -0
  228. package/dist/page/script-substrate.d.ts +32 -0
  229. package/dist/page/script-substrate.js +47 -0
  230. package/dist/page/seed-random.d.ts +45 -0
  231. package/dist/page/seed-random.js +144 -0
  232. package/dist/page/set-of-marks.d.ts +96 -0
  233. package/dist/page/set-of-marks.js +245 -0
  234. package/dist/page/shadow.d.ts +136 -0
  235. package/dist/page/shadow.js +400 -0
  236. package/dist/page/shortcut.d.ts +50 -0
  237. package/dist/page/shortcut.js +147 -0
  238. package/dist/page/snapshot-substrate-safari.d.ts +30 -0
  239. package/dist/page/snapshot-substrate-safari.js +84 -0
  240. package/dist/page/snapshot-substrate-select.d.ts +24 -0
  241. package/dist/page/snapshot-substrate-select.js +34 -0
  242. package/dist/page/snapshot-substrate.d.ts +58 -0
  243. package/dist/page/snapshot-substrate.js +135 -0
  244. package/dist/page/snapshot.d.ts +24 -0
  245. package/dist/page/snapshot.js +162 -0
  246. package/dist/page/solve-captcha.d.ts +76 -0
  247. package/dist/page/solve-captcha.js +286 -0
  248. package/dist/page/storage-substrate-types.d.ts +221 -0
  249. package/dist/page/storage-substrate-types.js +6 -0
  250. package/dist/page/storage-substrate.d.ts +215 -0
  251. package/dist/page/storage-substrate.js +280 -0
  252. package/dist/page/structural.d.ts +9 -0
  253. package/dist/page/structural.js +152 -0
  254. package/dist/page/substrate-bundle-safari.d.ts +8 -0
  255. package/dist/page/substrate-bundle-safari.js +42 -0
  256. package/dist/page/substrate-bundle.d.ts +6 -0
  257. package/dist/page/substrate-bundle.js +53 -0
  258. package/dist/page/text_search.d.ts +44 -0
  259. package/dist/page/text_search.js +90 -0
  260. package/dist/page/upload.d.ts +28 -0
  261. package/dist/page/upload.js +62 -0
  262. package/dist/page/verify.d.ts +63 -0
  263. package/dist/page/verify.js +451 -0
  264. package/dist/page/video.d.ts +115 -0
  265. package/dist/page/video.js +169 -0
  266. package/dist/page/visibility.d.ts +22 -0
  267. package/dist/page/visibility.js +94 -0
  268. package/dist/page/watch.d.ts +29 -0
  269. package/dist/page/watch.js +99 -0
  270. package/dist/page/workers.d.ts +126 -0
  271. package/dist/page/workers.js +490 -0
  272. package/dist/page/ws-interactive.d.ts +82 -0
  273. package/dist/page/ws-interactive.js +318 -0
  274. package/dist/plugin/cli.d.ts +45 -0
  275. package/dist/plugin/cli.js +496 -0
  276. package/dist/plugin/command-registry.d.ts +9 -0
  277. package/dist/plugin/command-registry.js +23 -0
  278. package/dist/plugin/depgraph.d.ts +37 -0
  279. package/dist/plugin/depgraph.js +186 -0
  280. package/dist/plugin/manifest.d.ts +182 -0
  281. package/dist/plugin/manifest.js +219 -0
  282. package/dist/plugin/package-manager.d.ts +22 -0
  283. package/dist/plugin/package-manager.js +40 -0
  284. package/dist/plugin/resolver.d.ts +85 -0
  285. package/dist/plugin/resolver.js +166 -0
  286. package/dist/plugin/runtime.d.ts +77 -0
  287. package/dist/plugin/runtime.js +402 -0
  288. package/dist/plugin/types.d.ts +113 -0
  289. package/dist/plugin/types.js +4 -0
  290. package/dist/policy/confirm.d.ts +76 -0
  291. package/dist/policy/confirm.js +162 -0
  292. package/dist/policy/origin.d.ts +17 -0
  293. package/dist/policy/origin.js +79 -0
  294. package/dist/sdk/client.d.ts +21 -0
  295. package/dist/sdk/client.js +174 -0
  296. package/dist/sdk/index.d.ts +32 -0
  297. package/dist/sdk/index.js +61 -0
  298. package/dist/sdk/plugin-types.d.ts +33 -0
  299. package/dist/sdk/plugin-types.js +22 -0
  300. package/dist/sdk/registry.d.ts +17 -0
  301. package/dist/sdk/registry.js +94 -0
  302. package/dist/sdk/socket-transport.d.ts +20 -0
  303. package/dist/sdk/socket-transport.js +90 -0
  304. package/dist/sdk/tool-types.d.ts +634 -0
  305. package/dist/sdk/tool-types.js +28 -0
  306. package/dist/sdk/transport-in-process.d.ts +21 -0
  307. package/dist/sdk/transport-in-process.js +44 -0
  308. package/dist/sdk/transport-registry.d.ts +19 -0
  309. package/dist/sdk/transport-registry.js +31 -0
  310. package/dist/sdk/transport-socket.d.ts +12 -0
  311. package/dist/sdk/transport-socket.js +77 -0
  312. package/dist/sdk/transport-stdio-child.d.ts +10 -0
  313. package/dist/sdk/transport-stdio-child.js +47 -0
  314. package/dist/sdk/transport.d.ts +10 -0
  315. package/dist/sdk/transport.js +35 -0
  316. package/dist/sdk/types.d.ts +176 -0
  317. package/dist/sdk/types.js +10 -0
  318. package/dist/server.d.ts +33 -0
  319. package/dist/server.js +327 -0
  320. package/dist/session/artifacts.d.ts +52 -0
  321. package/dist/session/artifacts.js +177 -0
  322. package/dist/session/byob-attach.d.ts +26 -0
  323. package/dist/session/byob-attach.js +187 -0
  324. package/dist/session/byob.d.ts +8 -0
  325. package/dist/session/byob.js +20 -0
  326. package/dist/session/cache-storage.d.ts +100 -0
  327. package/dist/session/cache-storage.js +166 -0
  328. package/dist/session/device-emu.d.ts +149 -0
  329. package/dist/session/device-emu.js +545 -0
  330. package/dist/session/device.d.ts +14 -0
  331. package/dist/session/device.js +44 -0
  332. package/dist/session/dialog.d.ts +62 -0
  333. package/dist/session/dialog.js +164 -0
  334. package/dist/session/emulation.d.ts +69 -0
  335. package/dist/session/emulation.js +168 -0
  336. package/dist/session/extensions.d.ts +113 -0
  337. package/dist/session/extensions.js +237 -0
  338. package/dist/session/fs-picker.d.ts +144 -0
  339. package/dist/session/fs-picker.js +666 -0
  340. package/dist/session/idb-storage.d.ts +86 -0
  341. package/dist/session/idb-storage.js +229 -0
  342. package/dist/session/incognito.d.ts +3 -0
  343. package/dist/session/incognito.js +20 -0
  344. package/dist/session/launch-options.d.ts +41 -0
  345. package/dist/session/launch-options.js +200 -0
  346. package/dist/session/managed.d.ts +3 -0
  347. package/dist/session/managed.js +16 -0
  348. package/dist/session/metrics.d.ts +45 -0
  349. package/dist/session/metrics.js +75 -0
  350. package/dist/session/notification.d.ts +122 -0
  351. package/dist/session/notification.js +426 -0
  352. package/dist/session/permission.d.ts +144 -0
  353. package/dist/session/permission.js +600 -0
  354. package/dist/session/playwright-post-wire.d.ts +8 -0
  355. package/dist/session/playwright-post-wire.js +148 -0
  356. package/dist/session/policy-buffer.d.ts +21 -0
  357. package/dist/session/policy-buffer.js +47 -0
  358. package/dist/session/profile-snapshot.d.ts +11 -0
  359. package/dist/session/profile-snapshot.js +53 -0
  360. package/dist/session/registry.d.ts +365 -0
  361. package/dist/session/registry.js +98 -0
  362. package/dist/session/safari-post-wire.d.ts +8 -0
  363. package/dist/session/safari-post-wire.js +28 -0
  364. package/dist/session/safari-session.d.ts +10 -0
  365. package/dist/session/safari-session.js +39 -0
  366. package/dist/session/storage.d.ts +148 -0
  367. package/dist/session/storage.js +350 -0
  368. package/dist/session/types.d.ts +113 -0
  369. package/dist/session/types.js +5 -0
  370. package/dist/session/wedge.d.ts +15 -0
  371. package/dist/session/wedge.js +41 -0
  372. package/dist/tools/action-core-tools.d.ts +13 -0
  373. package/dist/tools/action-core-tools.js +156 -0
  374. package/dist/tools/action-form-tools.d.ts +12 -0
  375. package/dist/tools/action-form-tools.js +179 -0
  376. package/dist/tools/action-gesture-tools.d.ts +9 -0
  377. package/dist/tools/action-gesture-tools.js +115 -0
  378. package/dist/tools/action-history-tools.d.ts +8 -0
  379. package/dist/tools/action-history-tools.js +67 -0
  380. package/dist/tools/action-tool.d.ts +42 -0
  381. package/dist/tools/action-tool.js +58 -0
  382. package/dist/tools/action-tools.d.ts +20 -0
  383. package/dist/tools/action-tools.js +28 -0
  384. package/dist/tools/batch-act-tools.d.ts +10 -0
  385. package/dist/tools/batch-act-tools.js +276 -0
  386. package/dist/tools/batch-human-tools.d.ts +8 -0
  387. package/dist/tools/batch-human-tools.js +148 -0
  388. package/dist/tools/canvas-tools.d.ts +40 -0
  389. package/dist/tools/canvas-tools.js +368 -0
  390. package/dist/tools/capture-report-diagnostics-tools.d.ts +7 -0
  391. package/dist/tools/capture-report-diagnostics-tools.js +318 -0
  392. package/dist/tools/capture-report-element-export-tools.d.ts +8 -0
  393. package/dist/tools/capture-report-element-export-tools.js +197 -0
  394. package/dist/tools/capture-report-export-tools.d.ts +8 -0
  395. package/dist/tools/capture-report-export-tools.js +246 -0
  396. package/dist/tools/capture-report-marks-tools.d.ts +9 -0
  397. package/dist/tools/capture-report-marks-tools.js +221 -0
  398. package/dist/tools/capture-report-upload-tools.d.ts +8 -0
  399. package/dist/tools/capture-report-upload-tools.js +277 -0
  400. package/dist/tools/config-approval-tools.d.ts +8 -0
  401. package/dist/tools/config-approval-tools.js +166 -0
  402. package/dist/tools/deep-coverage-tools.d.ts +8 -0
  403. package/dist/tools/deep-coverage-tools.js +325 -0
  404. package/dist/tools/deep-determinism-tools.d.ts +8 -0
  405. package/dist/tools/deep-determinism-tools.js +276 -0
  406. package/dist/tools/deep-perf-tools.d.ts +19 -0
  407. package/dist/tools/deep-perf-tools.js +324 -0
  408. package/dist/tools/device-emulation-tools.d.ts +9 -0
  409. package/dist/tools/device-emulation-tools.js +137 -0
  410. package/dist/tools/extensions-batch-tools.d.ts +18 -0
  411. package/dist/tools/extensions-batch-tools.js +24 -0
  412. package/dist/tools/extensions-rebuild.d.ts +22 -0
  413. package/dist/tools/extensions-rebuild.js +208 -0
  414. package/dist/tools/extensions-tools.d.ts +2 -0
  415. package/dist/tools/extensions-tools.js +331 -0
  416. package/dist/tools/forms-fill-tools.d.ts +8 -0
  417. package/dist/tools/forms-fill-tools.js +109 -0
  418. package/dist/tools/forms-plan-tools.d.ts +7 -0
  419. package/dist/tools/forms-plan-tools.js +159 -0
  420. package/dist/tools/forms-recording-mode-tools.d.ts +8 -0
  421. package/dist/tools/forms-recording-mode-tools.js +71 -0
  422. package/dist/tools/forms-recording-tools.d.ts +14 -0
  423. package/dist/tools/forms-recording-tools.js +22 -0
  424. package/dist/tools/forms-refs-tools.d.ts +8 -0
  425. package/dist/tools/forms-refs-tools.js +90 -0
  426. package/dist/tools/gesture-coord-tools.d.ts +8 -0
  427. package/dist/tools/gesture-coord-tools.js +168 -0
  428. package/dist/tools/gesture-emulation-tools.d.ts +8 -0
  429. package/dist/tools/gesture-emulation-tools.js +135 -0
  430. package/dist/tools/gesture-network-tools.d.ts +17 -0
  431. package/dist/tools/gesture-network-tools.js +27 -0
  432. package/dist/tools/gesture-route-tools.d.ts +8 -0
  433. package/dist/tools/gesture-route-tools.js +142 -0
  434. package/dist/tools/gesture-websocket-tools.d.ts +8 -0
  435. package/dist/tools/gesture-websocket-tools.js +122 -0
  436. package/dist/tools/gesture-worker-tools.d.ts +9 -0
  437. package/dist/tools/gesture-worker-tools.js +200 -0
  438. package/dist/tools/host-build.d.ts +76 -0
  439. package/dist/tools/host-build.js +516 -0
  440. package/dist/tools/host.d.ts +287 -0
  441. package/dist/tools/host.js +1 -0
  442. package/dist/tools/input-tools.d.ts +10 -0
  443. package/dist/tools/input-tools.js +176 -0
  444. package/dist/tools/live-emulation-tools.d.ts +9 -0
  445. package/dist/tools/live-emulation-tools.js +353 -0
  446. package/dist/tools/plugin-runtime.d.ts +36 -0
  447. package/dist/tools/plugin-runtime.js +274 -0
  448. package/dist/tools/read-observe-buffer-tools.d.ts +9 -0
  449. package/dist/tools/read-observe-buffer-tools.js +385 -0
  450. package/dist/tools/read-observe-capture-tools.d.ts +12 -0
  451. package/dist/tools/read-observe-capture-tools.js +376 -0
  452. package/dist/tools/read-observe-dom-tools.d.ts +8 -0
  453. package/dist/tools/read-observe-dom-tools.js +308 -0
  454. package/dist/tools/read-observe-extract-tools.d.ts +8 -0
  455. package/dist/tools/read-observe-extract-tools.js +232 -0
  456. package/dist/tools/read-observe-verify-tools.d.ts +8 -0
  457. package/dist/tools/read-observe-verify-tools.js +316 -0
  458. package/dist/tools/schemas.d.ts +29 -0
  459. package/dist/tools/schemas.js +58 -0
  460. package/dist/tools/secrets-captcha-tools.d.ts +9 -0
  461. package/dist/tools/secrets-captcha-tools.js +231 -0
  462. package/dist/tools/session-dialog-permission-tools.d.ts +9 -0
  463. package/dist/tools/session-dialog-permission-tools.js +287 -0
  464. package/dist/tools/session-lifecycle-tools.d.ts +8 -0
  465. package/dist/tools/session-lifecycle-tools.js +314 -0
  466. package/dist/tools/session-notification-device-tools.d.ts +9 -0
  467. package/dist/tools/session-notification-device-tools.js +156 -0
  468. package/dist/tools/session-policy-tools.d.ts +16 -0
  469. package/dist/tools/session-policy-tools.js +22 -0
  470. package/dist/tools/session-registry.d.ts +28 -0
  471. package/dist/tools/session-registry.js +427 -0
  472. package/dist/tools/storage-artifact-har-video-tools.d.ts +8 -0
  473. package/dist/tools/storage-artifact-har-video-tools.js +311 -0
  474. package/dist/tools/storage-cache-idb-tools.d.ts +8 -0
  475. package/dist/tools/storage-cache-idb-tools.js +347 -0
  476. package/dist/tools/storage-state-cookies-tools.d.ts +8 -0
  477. package/dist/tools/storage-state-cookies-tools.js +223 -0
  478. package/dist/tools/storage-tools.d.ts +17 -0
  479. package/dist/tools/storage-tools.js +25 -0
  480. package/dist/tools/storage-web-auth-tools.d.ts +10 -0
  481. package/dist/tools/storage-web-auth-tools.js +230 -0
  482. package/dist/tools/tool-metadata.d.ts +8 -0
  483. package/dist/tools/tool-metadata.js +185 -0
  484. package/dist/util/batch.d.ts +83 -0
  485. package/dist/util/batch.js +191 -0
  486. package/dist/util/capabilities.d.ts +504 -0
  487. package/dist/util/capabilities.js +254 -0
  488. package/dist/util/config-store.d.ts +103 -0
  489. package/dist/util/config-store.js +206 -0
  490. package/dist/util/config.d.ts +11 -0
  491. package/dist/util/config.js +28 -0
  492. package/dist/util/credentials.d.ts +136 -0
  493. package/dist/util/credentials.js +622 -0
  494. package/dist/util/deadline.d.ts +22 -0
  495. package/dist/util/deadline.js +62 -0
  496. package/dist/util/diagnostics.d.ts +161 -0
  497. package/dist/util/diagnostics.js +579 -0
  498. package/dist/util/egress-sanitiser.d.ts +29 -0
  499. package/dist/util/egress-sanitiser.js +52 -0
  500. package/dist/util/failure.d.ts +8 -0
  501. package/dist/util/failure.js +50 -0
  502. package/dist/util/flake-check.d.ts +109 -0
  503. package/dist/util/flake-check.js +342 -0
  504. package/dist/util/invariant.d.ts +25 -0
  505. package/dist/util/invariant.js +66 -0
  506. package/dist/util/logging.d.ts +6 -0
  507. package/dist/util/logging.js +12 -0
  508. package/dist/util/predicates.d.ts +62 -0
  509. package/dist/util/predicates.js +340 -0
  510. package/dist/util/secrets.d.ts +104 -0
  511. package/dist/util/secrets.js +219 -0
  512. package/dist/util/tokens.d.ts +6 -0
  513. package/dist/util/tokens.js +24 -0
  514. package/dist/util/url-sanitizer.d.ts +19 -0
  515. package/dist/util/url-sanitizer.js +70 -0
  516. package/dist/util/version.d.ts +2 -0
  517. package/dist/util/version.js +21 -0
  518. package/dist/util/workspace.d.ts +7 -0
  519. package/dist/util/workspace.js +22 -0
  520. package/package.json +120 -0
@@ -0,0 +1,84 @@
1
+ // SafariClassicSnapshotSubstrate — the SnapshotSubstrate implementation for the
2
+ // real-Safari engine. Safari has neither CDP (the Chromium/Android
3
+ // substrate) nor a Playwright Page/Frame (the firefox/webkit walker), so it gets
4
+ // a THIRD substrate: the SAME page-side DOM-walk PAGE_SCRIPT, shipped through
5
+ // WebDriver Classic `execute/sync` instead of CDP `Runtime.evaluate` or
6
+ // Playwright `frame.evaluate`. The page-side DOM-walk script
7
+ // returns the identical `DomWalkEntry` shape under
8
+ // `execute/sync`, so this substrate mints the SAME content-hashed refs and emits
9
+ // the SAME tree shape as PlaywrightSnapshotSubstrate — refs are stable across
10
+ // substrates exactly like firefox/webkit.
11
+ //
12
+ // It depends only on a tiny IO seam (`SafariSnapshotIO`: run a script + read the
13
+ // current URL), not on the safaridriver client directly, so the page layer stays
14
+ // decoupled from the engine adapter (the adapter supplies a thin bridge).
15
+ import { elementKey } from "./refs.js";
16
+ import { runDomWalkViaExecute, mergeDomWalkIntoTree } from "./dom-walk.js";
17
+ import { annotateStructuralContext } from "./structural.js";
18
+ /** Safari substrate — the page-side DOM-walk over WebDriver Classic
19
+ * `execute/sync`. No CDP, no Playwright Frame. Mirrors PlaywrightSnapshotSubstrate
20
+ * (synthetic `WebArea` root + DOM-walk leaves), with the same documented
21
+ * fidelity tradeoff: refs + find-ranking signal (role/name/[testid]) are present;
22
+ * the deep CDP a11y nesting and closed-shadow piercing are not (no off-Chromium
23
+ * protocol reaches them). */
24
+ export class SafariClassicSnapshotSubstrate {
25
+ io;
26
+ engine = "safari";
27
+ constructor(io) {
28
+ this.io = io;
29
+ }
30
+ async compose(refs, testAttributes, opts = {}) {
31
+ const url = await this.io.currentUrl().catch(() => "");
32
+ const root = this.makeRoot(refs, url);
33
+ const entries = await runDomWalkViaExecute((script, args) => this.io.exec(script, args), {
34
+ testAttributes,
35
+ pierce: opts.pierce,
36
+ });
37
+ const merge = mergeDomWalkIntoTree(root, entries, refs);
38
+ annotateStructuralContext(root);
39
+ const warnings = [
40
+ `snapshot on the "safari" engine is DOM-walk-sourced over WebDriver Classic execute/sync ` +
41
+ `(Safari has no CDP accessibility tree and no Playwright frame). Refs are stable and the ` +
42
+ `find-ranking signal (role/name/[testid]) is present; the deep a11y structural nesting ` +
43
+ `chromium emits is not. [from-dom] markers reflect the source, not a deficiency.`,
44
+ ];
45
+ if (opts.pierce === "closed") {
46
+ warnings.push(`closed-shadow piercing is chromium-only (it needs CDP DOM.getDocument({pierce:true})); ` +
47
+ `safari has no protocol equivalent, so pierce: "closed" degraded to "open".`);
48
+ }
49
+ return {
50
+ tree: root,
51
+ stats: {
52
+ a11yInteractive: 0,
53
+ domWalkEntries: entries.length,
54
+ domWalkNew: merge.added,
55
+ domWalkCombined: merge.combined,
56
+ ...(opts.pierce === "closed" ? { closedShadowEntries: 0 } : {}),
57
+ },
58
+ warnings,
59
+ };
60
+ }
61
+ async a11yTree(refs, testAttributes) {
62
+ const url = await this.io.currentUrl().catch(() => "");
63
+ const root = this.makeRoot(refs, url);
64
+ const entries = await runDomWalkViaExecute((script, args) => this.io.exec(script, args), {
65
+ testAttributes,
66
+ });
67
+ mergeDomWalkIntoTree(root, entries, refs);
68
+ annotateStructuralContext(root);
69
+ return root;
70
+ }
71
+ /** The synthetic main-frame root — keyed/stable so its ref persists across
72
+ * snapshots, identical to the Playwright substrate's root. */
73
+ makeRoot(refs, url) {
74
+ const rootKey = elementKey({ role: "WebArea", path: "__main__" });
75
+ const rootRef = refs.forKey(rootKey, { role: "WebArea", source: "dom" });
76
+ return {
77
+ ref: rootRef,
78
+ role: "WebArea",
79
+ name: url || "WebArea",
80
+ source: "dom",
81
+ children: [],
82
+ };
83
+ }
84
+ }
@@ -0,0 +1,24 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { SafariSessionHandle } from "../engine/index.js";
3
+ import { type SnapshotSubstrate } from "./snapshot-substrate.js";
4
+ /** The minimal session shape this selector needs — the optional CDP accessor
5
+ * (present only on chromium) + the engine tag + the page handle + the optional
6
+ * Safari-native handle (present only on the `safari` engine, which has no
7
+ * Playwright Page). The full BrowserSession satisfies it; the narrow shape keeps
8
+ * the engine/session interfaces out of this page-layer module. */
9
+ export interface SubstrateCapableSession {
10
+ readonly engine: string;
11
+ page(): Page;
12
+ cdp?(): import("playwright-core").CDPSession;
13
+ safari?(): SafariSessionHandle;
14
+ }
15
+ /** Build the SnapshotSubstrate for a session. Selection is by capability, never a
16
+ * scattered engine-name check:
17
+ * - Safari (no Playwright Page, no CDP) → the WebDriver-Classic DOM-walk
18
+ * substrate, fed by the Safari handle's `execute/sync`.
19
+ * - Chromium / Android (CDP present) → the byte-identical CDP substrate.
20
+ * - Firefox / WebKit (Playwright Page, no CDP) → the page-side walker.
21
+ * A future CDP-bearing engine routes to the CDP substrate automatically; a
22
+ * non-CDP Playwright one to the walker — no edit here. Safari is the one engine
23
+ * whose `page()` throws, so it MUST be handled before the Playwright branch. */
24
+ export declare function snapshotSubstrateFor(session: SubstrateCapableSession): SnapshotSubstrate;
@@ -0,0 +1,34 @@
1
+ // Substrate selection — maps a live session to its SnapshotSubstrate. This is
2
+ // the seam where the engine's snapshot strategy is chosen: chromium (CDP) gets
3
+ // the verbatim CDP substrate; an engine with no CDP escape hatch (firefox /
4
+ // webkit) gets the page-side Playwright walker. The choice is the engine's,
5
+ // declared by whether it exposes the raw-CDP handle — not an engine-name check
6
+ // scattered through the tools.
7
+ //
8
+ // The session layer wires one substrate per entry at creation (server.ts) so the
9
+ // per-call path is a captured-handle delegate with no per-call allocation (the
10
+ // snapshot/find path is hot — architecture doctrine §3). Tools select via this
11
+ // substrate, never via `requireCdp` + an engine branch.
12
+ import { CdpSnapshotSubstrate, PlaywrightSnapshotSubstrate, } from "./snapshot-substrate.js";
13
+ import { SafariClassicSnapshotSubstrate } from "./snapshot-substrate-safari.js";
14
+ /** Build the SnapshotSubstrate for a session. Selection is by capability, never a
15
+ * scattered engine-name check:
16
+ * - Safari (no Playwright Page, no CDP) → the WebDriver-Classic DOM-walk
17
+ * substrate, fed by the Safari handle's `execute/sync`.
18
+ * - Chromium / Android (CDP present) → the byte-identical CDP substrate.
19
+ * - Firefox / WebKit (Playwright Page, no CDP) → the page-side walker.
20
+ * A future CDP-bearing engine routes to the CDP substrate automatically; a
21
+ * non-CDP Playwright one to the walker — no edit here. Safari is the one engine
22
+ * whose `page()` throws, so it MUST be handled before the Playwright branch. */
23
+ export function snapshotSubstrateFor(session) {
24
+ if (session.engine === "safari" && session.safari) {
25
+ const handle = session.safari();
26
+ return new SafariClassicSnapshotSubstrate({
27
+ exec: (scriptBody, args) => handle.webDriver.executeScript(handle.sessionId, scriptBody, args),
28
+ currentUrl: () => handle.webDriver.currentUrl(handle.sessionId),
29
+ });
30
+ }
31
+ if (session.cdp)
32
+ return new CdpSnapshotSubstrate(session.cdp());
33
+ return new PlaywrightSnapshotSubstrate(session.page(), session.engine);
34
+ }
@@ -0,0 +1,58 @@
1
+ import type { CDPSession, Page } from "playwright-core";
2
+ import type { A11yNode } from "./a11y.js";
3
+ import type { RefRegistry } from "./refs.js";
4
+ import { type ComposedSnapshot, type ComposeOptions } from "./compose.js";
5
+ /** The a11y+DOM tree source the snapshot/find tools mint refs from. One
6
+ * instance wraps one session's engine handle; the methods carry no engine
7
+ * type, so the tools above this seam are engine-agnostic. */
8
+ export interface SnapshotSubstrate {
9
+ /** Engine tag — for diagnostics + the per-engine keystone matrix. */
10
+ readonly engine: string;
11
+ /** The composed snapshot (a11y tree + DOM-walk fallback merged) for the
12
+ * main frame. The read core (snapshot/find/extract/text_search/set-of-marks)
13
+ * consumes this. `opts.pierce` reaches the DOM-walk + (chromium only) the
14
+ * closed-shadow CDP pass. */
15
+ compose(refs: RefRegistry, testAttributes: string[], opts?: ComposeOptions): Promise<ComposedSnapshot>;
16
+ /** The raw a11y tree only (no DOM-walk merge). The action window's pre/post
17
+ * snapshotDelta and `watch`'s region sampling consume this — they need the
18
+ * structural a11y tree, not the find-ranking-augmented composed tree. */
19
+ a11yTree(refs: RefRegistry, testAttributes: string[]): Promise<A11yNode | null>;
20
+ }
21
+ /** Chromium substrate — the existing CDP path, moved behind the interface
22
+ * VERBATIM. `compose` / `a11yTree` delegate to the exact functions the tools
23
+ * called inline before this seam (composeSnapshot / getA11yTree over the raw
24
+ * CDPSession), so the output is byte-identical and the chromium keystones are
25
+ * unchanged. The CDP handle is captured here once; callers never see it. */
26
+ export declare class CdpSnapshotSubstrate implements SnapshotSubstrate {
27
+ private readonly cdp;
28
+ readonly engine = "chromium";
29
+ constructor(cdp: CDPSession);
30
+ compose(refs: RefRegistry, testAttributes: string[], opts?: ComposeOptions): Promise<ComposedSnapshot>;
31
+ a11yTree(refs: RefRegistry, testAttributes: string[]): Promise<A11yNode | null>;
32
+ }
33
+ /** Firefox / WebKit substrate — the page-side ARIA/DOM walker over
34
+ * `frame.evaluate`. No CDP. It runs the SAME PAGE_SCRIPT as the (already
35
+ * portable, OOPIF-safe) composeSnapshotForFrame, rooted at the main frame, and
36
+ * mints refs through the SAME RefRegistry / elementKey path, so a ref minted
37
+ * here is the same shape (and stable across snapshots) as a chromium DOM-walk
38
+ * ref.
39
+ *
40
+ * Tree shape: a synthetic `WebArea` root with the walker's interactive /
41
+ * test-attribute-bearing elements as leaf children — identical to the
42
+ * composeSnapshotForFrame shape. The CDP a11y tree's deep structural nesting is
43
+ * not available off-Chromium (Firefox has no `Accessibility.getFullAXTree`),
44
+ * but find()/text_search()/extract() walk the tree flat anyway, and the ref
45
+ * inputs (role/name/testId/cssPath) — the find-ranking + ref-minting signal —
46
+ * are all present. This is the documented, benchmarked fidelity tradeoff of
47
+ * the hybrid approach: chromium keeps the deep AX tree; firefox gets the
48
+ * walker-grade tree that carries the agentic signal. */
49
+ export declare class PlaywrightSnapshotSubstrate implements SnapshotSubstrate {
50
+ private readonly page;
51
+ readonly engine: string;
52
+ constructor(page: Page, engine?: string);
53
+ compose(refs: RefRegistry, testAttributes: string[], opts?: ComposeOptions): Promise<ComposedSnapshot>;
54
+ a11yTree(refs: RefRegistry, testAttributes: string[]): Promise<A11yNode | null>;
55
+ /** The synthetic main-frame root. Keyed/stable so its ref persists across
56
+ * snapshots exactly like the composeSnapshotForFrame root. */
57
+ private makeRoot;
58
+ }
@@ -0,0 +1,135 @@
1
+ // The SnapshotSubstrate interface — the engine-agnostic seam beneath the
2
+ // snapshot / find / extract / text_search / set-of-marks / watch tools and the
3
+ // pre/post ActionResult a11y deltas. It is the substrate side of the hybrid
4
+ // snapshot/a11y design: the tools ask a substrate for "the a11y+DOM
5
+ // tree to mint refs from"; an engine-specific implementation answers.
6
+ //
7
+ // Dependency direction (architecture doctrine §1): tools → SnapshotSubstrate
8
+ // (this interface) → implementation → CDP / Playwright. A tool never reaches a
9
+ // CDPSession or a raw Page through this seam; the engine handle is captured at
10
+ // substrate construction, so the per-call surface carries no engine type. That
11
+ // is what un-couples snapshot/find from CDP and lets them run on Firefox.
12
+ //
13
+ // Two implementations behind it (hybrid):
14
+ // - CdpSnapshotSubstrate (chromium): delegates to composeSnapshot /
15
+ // getA11yTree VERBATIM — the existing CDP `Accessibility.getFullAXTree` +
16
+ // `Runtime.evaluate` DOM-walk path, byte-identical output, so the 67+
17
+ // chromium keystones stay green unchanged.
18
+ // - PlaywrightSnapshotSubstrate (firefox / webkit): the page-side ARIA/DOM
19
+ // walker over `frame.evaluate` (main world) — the SAME PAGE_SCRIPT the
20
+ // already-portable composeSnapshotForFrame uses, generalized to the main
21
+ // frame. It mints the SAME content-hashed ref shape (role/name/testId/
22
+ // cssPath via elementKey), so refs are stable across substrates.
23
+ //
24
+ // Why the walker, not ariaSnapshot() (benchmarked):
25
+ // `locator.ariaSnapshot()` carries NO test attributes (data-testid/…), so it
26
+ // produces 0 testId-bearing nodes on a testid-tagged page — find() scores +5 on
27
+ // a testId hit and elementKey hashes testId into the ref, so an ariaSnapshot
28
+ // substrate degrades both ranking and ref stability. On the representative
29
+ // fixture the walker hit 4/5 find targets vs ariaSnapshot's 0/5, carried testId
30
+ // on 9 nodes vs 0, and ran ~10x faster (10 ms vs 104 ms). The walker also emits
31
+ // exactly the DomWalkEntry shape the existing merge path already consumes, so
32
+ // the firefox tree is byte-shape-identical to the chromium DOM-walk leaves.
33
+ import { getA11yTree } from "./a11y.js";
34
+ import { composeSnapshot } from "./compose.js";
35
+ import { runDomWalkOnFrame, mergeDomWalkIntoTree } from "./dom-walk.js";
36
+ import { annotateStructuralContext } from "./structural.js";
37
+ import { elementKey } from "./refs.js";
38
+ /** Chromium substrate — the existing CDP path, moved behind the interface
39
+ * VERBATIM. `compose` / `a11yTree` delegate to the exact functions the tools
40
+ * called inline before this seam (composeSnapshot / getA11yTree over the raw
41
+ * CDPSession), so the output is byte-identical and the chromium keystones are
42
+ * unchanged. The CDP handle is captured here once; callers never see it. */
43
+ export class CdpSnapshotSubstrate {
44
+ cdp;
45
+ engine = "chromium";
46
+ constructor(cdp) {
47
+ this.cdp = cdp;
48
+ }
49
+ compose(refs, testAttributes, opts = {}) {
50
+ return composeSnapshot(this.cdp, refs, testAttributes, opts);
51
+ }
52
+ a11yTree(refs, testAttributes) {
53
+ return getA11yTree(this.cdp, refs, testAttributes);
54
+ }
55
+ }
56
+ /** Firefox / WebKit substrate — the page-side ARIA/DOM walker over
57
+ * `frame.evaluate`. No CDP. It runs the SAME PAGE_SCRIPT as the (already
58
+ * portable, OOPIF-safe) composeSnapshotForFrame, rooted at the main frame, and
59
+ * mints refs through the SAME RefRegistry / elementKey path, so a ref minted
60
+ * here is the same shape (and stable across snapshots) as a chromium DOM-walk
61
+ * ref.
62
+ *
63
+ * Tree shape: a synthetic `WebArea` root with the walker's interactive /
64
+ * test-attribute-bearing elements as leaf children — identical to the
65
+ * composeSnapshotForFrame shape. The CDP a11y tree's deep structural nesting is
66
+ * not available off-Chromium (Firefox has no `Accessibility.getFullAXTree`),
67
+ * but find()/text_search()/extract() walk the tree flat anyway, and the ref
68
+ * inputs (role/name/testId/cssPath) — the find-ranking + ref-minting signal —
69
+ * are all present. This is the documented, benchmarked fidelity tradeoff of
70
+ * the hybrid approach: chromium keeps the deep AX tree; firefox gets the
71
+ * walker-grade tree that carries the agentic signal. */
72
+ export class PlaywrightSnapshotSubstrate {
73
+ page;
74
+ engine;
75
+ constructor(page, engine = "firefox") {
76
+ this.page = page;
77
+ this.engine = engine;
78
+ }
79
+ async compose(refs, testAttributes, opts = {}) {
80
+ const root = this.makeRoot(refs);
81
+ // The main frame's walk — same PAGE_SCRIPT, same `frame.evaluate` entry as
82
+ // the child-frame path. `pierce` recurses open shadow roots; closed-shadow
83
+ // CDP piercing is chromium-only (no off-Chromium protocol reaches closed
84
+ // roots), so we degrade to open and warn.
85
+ const entries = await runDomWalkOnFrame(this.page.mainFrame(), {
86
+ testAttributes,
87
+ pierce: opts.pierce,
88
+ });
89
+ const merge = mergeDomWalkIntoTree(root, entries, refs);
90
+ annotateStructuralContext(root);
91
+ const warnings = [
92
+ `snapshot on the "${this.engine}" engine is DOM-walk-sourced (no CDP accessibility tree off Chromium). ` +
93
+ `Refs are stable and find-ranking signal (role/name/[testid]) is present; the deep a11y structural ` +
94
+ `nesting chromium emits is not. [from-dom] markers reflect the source, not a deficiency.`,
95
+ ];
96
+ if (opts.pierce === "closed") {
97
+ warnings.push(`closed-shadow piercing is chromium-only (it needs CDP DOM.getDocument({pierce:true}), which ` +
98
+ `${this.engine} has no protocol equivalent for). pierce: "closed" degraded to "open".`);
99
+ }
100
+ return {
101
+ tree: root,
102
+ stats: {
103
+ a11yInteractive: 0,
104
+ domWalkEntries: entries.length,
105
+ domWalkNew: merge.added,
106
+ domWalkCombined: merge.combined,
107
+ ...(opts.pierce === "closed" ? { closedShadowEntries: 0 } : {}),
108
+ },
109
+ warnings,
110
+ };
111
+ }
112
+ async a11yTree(refs, testAttributes) {
113
+ // The pre/post action delta + watch sampling want the structural tree; off
114
+ // Chromium that is the same walker-sourced tree compose() builds (without
115
+ // the find-ranking warnings, which the delta path doesn't surface).
116
+ const root = this.makeRoot(refs);
117
+ const entries = await runDomWalkOnFrame(this.page.mainFrame(), { testAttributes });
118
+ mergeDomWalkIntoTree(root, entries, refs);
119
+ annotateStructuralContext(root);
120
+ return root;
121
+ }
122
+ /** The synthetic main-frame root. Keyed/stable so its ref persists across
123
+ * snapshots exactly like the composeSnapshotForFrame root. */
124
+ makeRoot(refs) {
125
+ const rootKey = elementKey({ role: "WebArea", path: "__main__" });
126
+ const rootRef = refs.forKey(rootKey, { role: "WebArea", source: "dom" });
127
+ return {
128
+ ref: rootRef,
129
+ role: "WebArea",
130
+ name: this.page.url() || "WebArea",
131
+ source: "dom",
132
+ children: [],
133
+ };
134
+ }
135
+ }
@@ -0,0 +1,24 @@
1
+ import { type A11yNode } from "./a11y.js";
2
+ export interface SerialiseOptions {
3
+ /** Indent string per depth level. Default `" "`. */
4
+ indent?: string;
5
+ /** Maximum characters of `name` to keep per node. Default 80. */
6
+ maxNameLen?: number;
7
+ /** If true, drop generic / presentational nodes that contribute nothing. */
8
+ pruneGeneric?: boolean;
9
+ /** cap on emitted lines. When exceeded, the serialisation cuts
10
+ * off and appends `... [+N more nodes elided]`. */
11
+ maxNodes?: number;
12
+ /** case-insensitive substring patterns matched against each node's
13
+ * `role`, `name`, or `testId`. A matching node *and its entire subtree* is skipped.
14
+ * Useful for omitting known-noisy regions (long lists, virtualised tables). */
15
+ omit?: string[];
16
+ }
17
+ /** Render an A11yNode tree to the compact `role "name" [ref=eN] [state]` form. */
18
+ export declare function serialise(root: A11yNode, opts?: SerialiseOptions): string;
19
+ /**
20
+ * Find a subtree by ref. Returns the matching node (or null) so callers can
21
+ * `serialise(findByRef(tree, "e42"), { … })` for scoped snapshots.
22
+ */
23
+ export declare function findByRef(root: A11yNode, ref: string): A11yNode | null;
24
+ export declare function fmtState(n: A11yNode): string;
@@ -0,0 +1,162 @@
1
+ // Compact, token-efficient text serialisation of the a11y tree. Same grammar used
2
+ // everywhere browxai emits a tree (snapshot(), find() context, ActionResult.snapshotDelta) —
3
+ // that's the coherence constraint.
4
+ import { walk } from "./a11y.js";
5
+ /** Render an A11yNode tree to the compact `role "name" [ref=eN] [state]` form. */
6
+ export function serialise(root, opts = {}) {
7
+ const indent = opts.indent ?? " ";
8
+ const maxNameLen = opts.maxNameLen ?? 80;
9
+ const pruneGeneric = opts.pruneGeneric ?? true;
10
+ const maxNodes = opts.maxNodes ?? Infinity;
11
+ const omitPatterns = (opts.omit ?? []).map((p) => p.toLowerCase());
12
+ const lines = [];
13
+ let emitted = 0;
14
+ let truncated = false;
15
+ let elided = 0;
16
+ let elidedBranches = 0;
17
+ // Manual walk so we can prune subtrees on `omit` matches (the generator yields
18
+ // depth-first; pruning needs to skip descendants explicitly). `visitForSerialise`
19
+ // decides this node's disposition (skip-subtree / emit / silent-skip); the loop
20
+ // only owns stack management.
21
+ const stack = [{ node: root, depth: 0 }];
22
+ while (stack.length) {
23
+ const { node, depth } = stack.pop();
24
+ const v = visitForSerialise(node, depth, {
25
+ omitPatterns,
26
+ pruneGeneric,
27
+ maxNameLen,
28
+ indent,
29
+ emitted,
30
+ maxNodes,
31
+ });
32
+ elidedBranches += v.elidedBranches;
33
+ elided += v.elided;
34
+ if (v.truncated)
35
+ truncated = true;
36
+ if (v.line !== null) {
37
+ lines.push(v.line);
38
+ emitted++;
39
+ }
40
+ if (v.skipSubtree)
41
+ continue;
42
+ for (let i = node.children.length - 1; i >= 0; i--) {
43
+ stack.push({ node: node.children[i], depth: depth + 1 });
44
+ }
45
+ }
46
+ if (truncated)
47
+ lines.push(`... [+${elided} more nodes elided; raise maxNodes or pass scope=<ref> to drill in]`);
48
+ if (elidedBranches > 0 && !truncated) {
49
+ lines.push(`... [omit matched ${elidedBranches} subtree(s), ${elided} nodes total]`);
50
+ }
51
+ return lines.join("\n");
52
+ }
53
+ /** Decide one node's disposition during `serialise`: an `omit` match prunes the
54
+ * whole subtree, the maxNodes cap truncates, generic noise is silently dropped,
55
+ * otherwise the node is formatted. Pure — the loop applies the result. */
56
+ function visitForSerialise(node, depth, o) {
57
+ if (matchesOmit(node, o.omitPatterns)) {
58
+ return {
59
+ line: null,
60
+ skipSubtree: true,
61
+ elided: countSubtree(node),
62
+ elidedBranches: 1,
63
+ truncated: false,
64
+ };
65
+ }
66
+ if (o.pruneGeneric && isGenericNoise(node)) {
67
+ return { line: null, skipSubtree: false, elided: 0, elidedBranches: 0, truncated: false };
68
+ }
69
+ if (o.emitted >= o.maxNodes) {
70
+ // this node + its descendants we'd have emitted.
71
+ return {
72
+ line: null,
73
+ skipSubtree: true,
74
+ elided: countSubtree(node),
75
+ elidedBranches: 0,
76
+ truncated: true,
77
+ };
78
+ }
79
+ return {
80
+ line: formatNode(node, depth, o.indent, o.maxNameLen),
81
+ skipSubtree: false,
82
+ elided: 0,
83
+ elidedBranches: 0,
84
+ truncated: false,
85
+ };
86
+ }
87
+ function matchesOmit(node, patterns) {
88
+ if (patterns.length === 0)
89
+ return false;
90
+ const hay = `${node.role}|${node.name ?? ""}|${node.testId ?? ""}`.toLowerCase();
91
+ return patterns.some((p) => hay.includes(p));
92
+ }
93
+ function countSubtree(node) {
94
+ let n = 1;
95
+ for (const c of node.children)
96
+ n += countSubtree(c);
97
+ return n;
98
+ }
99
+ /**
100
+ * Find a subtree by ref. Returns the matching node (or null) so callers can
101
+ * `serialise(findByRef(tree, "e42"), { … })` for scoped snapshots.
102
+ */
103
+ export function findByRef(root, ref) {
104
+ for (const { node } of walk(root)) {
105
+ if (node.ref === ref)
106
+ return node;
107
+ }
108
+ return null;
109
+ }
110
+ function formatNode(node, depth, indent, maxNameLen) {
111
+ const pad = indent.repeat(depth);
112
+ const nm = node.name ? ` "${truncate(node.name, maxNameLen)}"` : "";
113
+ // Emit the actual attribute name (e.g. `[data-testid="…"]` or `[data-type="…"]`) so
114
+ // the agent can transcribe it directly. Falls back to `data-testid` when the source
115
+ // didn't tell us which attr matched.
116
+ const tid = node.testId
117
+ ? ` [${node.testIdAttr ?? "data-testid"}=${JSON.stringify(node.testId)}]`
118
+ : "";
119
+ const src = node.source === "dom" ? " [from-dom]" : node.source === "both" ? " [from-both]" : "";
120
+ return `${pad}${node.role}${nm} [ref=${node.ref}]${tid}${src}${fmtState(node)}`;
121
+ }
122
+ export function fmtState(n) {
123
+ const bits = [];
124
+ if (n.disabled)
125
+ bits.push("disabled");
126
+ if (n.checked !== undefined)
127
+ bits.push(`checked=${n.checked}`);
128
+ if (n.pressed !== undefined)
129
+ bits.push(`pressed=${n.pressed}`);
130
+ if (n.selected)
131
+ bits.push("selected");
132
+ if (n.expanded !== undefined)
133
+ bits.push(`expanded=${n.expanded}`);
134
+ if (n.focused)
135
+ bits.push("focused");
136
+ if (n.value !== undefined && n.value !== "") {
137
+ bits.push(`value=${JSON.stringify(String(n.value).slice(0, 60))}`);
138
+ }
139
+ return bits.length ? ` [${bits.join(", ")}]` : "";
140
+ }
141
+ function truncate(s, n) {
142
+ return s.length <= n ? s : s.slice(0, n - 1) + "…";
143
+ }
144
+ /**
145
+ * Drop generic / presentational nodes that carry no agent signal:
146
+ * - role "generic" / "presentation" with no name and no testId
147
+ * - role "none"
148
+ * - "text" leaves with no name (i.e. empty)
149
+ * These nodes still let their *children* through (caller walks the tree); we
150
+ * just skip emitting a line for them.
151
+ */
152
+ function isGenericNoise(n) {
153
+ if (n.testId)
154
+ return false;
155
+ if (n.role === "none")
156
+ return true;
157
+ if ((n.role === "generic" || n.role === "presentation") && !n.name)
158
+ return true;
159
+ if (n.role === "StaticText" && !n.name)
160
+ return true;
161
+ return false;
162
+ }
@@ -0,0 +1,76 @@
1
+ /** Provider names this version of the module knows how to talk to. Other
2
+ * providers can be added without breaking the env-config surface — new
3
+ * names just append. */
4
+ export declare const KNOWN_PROVIDERS: readonly ["2captcha", "capmonster"];
5
+ export type CaptchaProvider = (typeof KNOWN_PROVIDERS)[number];
6
+ /** Captcha types this tool surfaces in its input schema. The string is
7
+ * forwarded to the provider — providers themselves accept the same shape
8
+ * (`recaptcha2`, `hcaptcha`, `image`, etc.) so we keep the vocabulary thin. */
9
+ export type CaptchaType = "recaptcha2" | "recaptcha3" | "hcaptcha" | "image" | "turnstile";
10
+ /** Resolved provider config (from env). `apiKey` is sensitive — NEVER log it,
11
+ * NEVER include it on the tool result. */
12
+ export interface CaptchaProviderConfig {
13
+ provider: CaptchaProvider;
14
+ apiKey: string;
15
+ /** Override the provider's base URL. Default is the canonical endpoint for
16
+ * the chosen provider. Useful for self-hosted CapMonster-compatible
17
+ * proxies or for testing. */
18
+ apiBase: string;
19
+ /** Per-attempt polling deadline in milliseconds. Default 120_000
20
+ * (2 minutes) — most providers take 10–60s for image/recaptcha. */
21
+ timeoutMs: number;
22
+ /** Poll interval between `getTaskResult` calls. Default 5000 ms. */
23
+ pollMs: number;
24
+ }
25
+ /** Read provider config from env. Returns `null` when nothing is configured —
26
+ * the caller surfaces a structured `ok:false` with a "no provider
27
+ * configured" hint rather than throwing (the capability is on but the
28
+ * deployment hasn't wired a solver — recoverable, not a server-startup
29
+ * error). Returns an `error` object on partial config (provider set without
30
+ * api-key, unknown provider name) so the agent sees a clear pointer. */
31
+ export declare function resolveCaptchaProvider(env?: NodeJS.ProcessEnv): {
32
+ ok: true;
33
+ config: CaptchaProviderConfig;
34
+ } | {
35
+ ok: false;
36
+ reason: "unconfigured" | "partial";
37
+ error?: string;
38
+ };
39
+ /** A challenge ready to submit. The shape mirrors the 2Captcha `in.php` form:
40
+ * `googlekey` + `pageurl` for recaptcha2/3, `sitekey` + `pageurl` for
41
+ * hcaptcha / turnstile, `body` (base64) for image. The tool layer extracts
42
+ * these from the page given `type` + `selector` + the current page URL. */
43
+ export interface CaptchaChallenge {
44
+ type: CaptchaType;
45
+ pageUrl: string;
46
+ /** For recaptcha/hcaptcha/turnstile: the site-key as published on the page. */
47
+ siteKey?: string;
48
+ /** For image captchas: base64-encoded image bytes (without the data URL prefix). */
49
+ imageBase64?: string;
50
+ }
51
+ /** Solver result envelope. `solution` is the provider-returned token / text
52
+ * the agent then types into a hidden form field or invokes a JS callback
53
+ * with. We do NOT auto-submit — the agent is in the driver's seat for
54
+ * what to do with the solution (different sites wire reCAPTCHA differently). */
55
+ export interface CaptchaSolution {
56
+ ok: true;
57
+ provider: CaptchaProvider;
58
+ solution: string;
59
+ /** Provider-specific task id (for logs / cost reconciliation, never sensitive). */
60
+ taskId: string;
61
+ elapsedMs: number;
62
+ }
63
+ export interface CaptchaFailure {
64
+ ok: false;
65
+ provider: CaptchaProvider | null;
66
+ error: string;
67
+ hint: string;
68
+ /** Best-effort: when the provider returned a structured error, surface its
69
+ * code so the agent can decide whether to retry. */
70
+ providerCode?: string;
71
+ }
72
+ export declare function submitToProvider(challenge: CaptchaChallenge, config: CaptchaProviderConfig, fetchImpl?: typeof fetch, nowFn?: () => number, sleepFn?: (ms: number) => Promise<void>): Promise<CaptchaSolution | CaptchaFailure>;
73
+ /** Build the structured "no provider configured" failure — used when the
74
+ * capability is on but env vars are unset. Hints at exactly what to set and
75
+ * names the per-deployment / no-bundled-solver / no-auto-purchase posture. */
76
+ export declare function unconfiguredFailure(): CaptchaFailure;