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,172 @@
1
+ // Calibration-walk → flow-file scaffold — .
2
+ //
3
+ // Records action-tool calls during a session and emits a draft `flow-file.yaml`
4
+ // the agent can hand to site-docs (or any consumer with a similar YAML shape).
5
+ //
6
+ // The recording captures: the action's type/target, the resolved selectorHint
7
+ // (so flow-files transcribe mechanically), the URL, and an optional human-readable
8
+ // note. Annotations are agent-supplied via `record_annotate({ copy, arrow })`.
9
+ //
10
+ // Format: minimal site-docs-flavoured YAML (the canonical shape lives in the
11
+ // site-docs repo; consumers can post-process if they need a different dialect).
12
+ export class Recorder {
13
+ steps = [];
14
+ name = null;
15
+ autoCounter = 0;
16
+ start(flowName) {
17
+ if (this.name) {
18
+ // Replace silently — calibration restarts are common.
19
+ }
20
+ this.name = flowName;
21
+ this.steps = [];
22
+ this.autoCounter = 0;
23
+ return { ok: true, name: flowName };
24
+ }
25
+ active() {
26
+ return this.name !== null;
27
+ }
28
+ /** Read-only access to the recorded trace + the flow name without ending
29
+ * the recording. Used by trace-export tools (e.g. the Playwright-script
30
+ * exporter) that need to lower the steps to a runnable artefact while the
31
+ * recording is still in progress. Returns null when no recording is
32
+ * active. */
33
+ inspect() {
34
+ if (!this.name)
35
+ return null;
36
+ return { name: this.name, steps: this.steps.slice() };
37
+ }
38
+ /** Record an action that just happened. The caller (server.ts action handlers)
39
+ * passes the descriptor + the URL it ended at + whatever selectorHint was
40
+ * used to resolve the target. Best-effort: if no recording is active, this
41
+ * is a no-op. */
42
+ record(descriptor, url, hint) {
43
+ if (!this.name)
44
+ return;
45
+ const id = this.suggestId(descriptor);
46
+ this.steps.push({
47
+ id,
48
+ action: descriptor,
49
+ url,
50
+ selectorHint: hint?.selectorHint,
51
+ stability: hint?.stability,
52
+ ts: Date.now(),
53
+ });
54
+ }
55
+ /** Attach an annotation to the most-recent step (or by id). */
56
+ annotate(args) {
57
+ if (!this.name)
58
+ return { ok: false, error: "no active recording" };
59
+ if (this.steps.length === 0)
60
+ return { ok: false, error: "no steps recorded yet" };
61
+ const step = args.stepId
62
+ ? this.steps.find((s) => s.id === args.stepId)
63
+ : this.steps[this.steps.length - 1];
64
+ if (!step)
65
+ return { ok: false, error: `no step with id "${args.stepId}"` };
66
+ step.annotation = { copy: args.copy, arrow: args.arrow, target: args.target };
67
+ return { ok: true };
68
+ }
69
+ /** End the recording. Returns the YAML draft + the step count. */
70
+ end() {
71
+ if (!this.name)
72
+ throw new Error("end_recording: no active recording");
73
+ const name = this.name;
74
+ const yaml = this.toYaml();
75
+ const stepCount = this.steps.length;
76
+ this.name = null;
77
+ this.steps = [];
78
+ return { name, yaml, stepCount };
79
+ }
80
+ suggestId(d) {
81
+ const base = d.type === "navigate"
82
+ ? "open"
83
+ : d.type === "click"
84
+ ? "click"
85
+ : d.type === "fill"
86
+ ? "fill"
87
+ : d.type === "press"
88
+ ? "press"
89
+ : d.type === "hover"
90
+ ? "hover"
91
+ : d.type === "select"
92
+ ? "select"
93
+ : d.type === "waitFor"
94
+ ? "wait"
95
+ : d.type;
96
+ return `${base}-${++this.autoCounter}`;
97
+ }
98
+ /** Render the recording as YAML. Minimal site-docs-flavoured shape; consumers
99
+ * can post-process. We don't pull in a YAML library to keep deps lean — the
100
+ * output is small + predictable. */
101
+ toYaml() {
102
+ const lines = [];
103
+ lines.push(`name: ${this.name}`);
104
+ lines.push(`# Drafted via browxai recording — review locator stability + add prerequisites/assertions before committing.`);
105
+ // Locators block — pulled from steps that have a selectorHint.
106
+ const locatorEntries = this.collectLocators();
107
+ if (locatorEntries.length > 0) {
108
+ lines.push("locators:");
109
+ for (const { name, hint, stability } of locatorEntries) {
110
+ const stabilityTag = stability && stability !== "high" ? ` # stability: ${stability} — review` : "";
111
+ lines.push(` ${name}: ${quote(hint)}${stabilityTag}`);
112
+ }
113
+ }
114
+ lines.push("steps:");
115
+ for (const step of this.steps) {
116
+ lines.push(` - id: ${step.id}`);
117
+ lines.push(` action: ${step.action.type}`);
118
+ const valueOrUrl = step.action.url ?? step.action.value;
119
+ if (valueOrUrl !== undefined)
120
+ lines.push(` value: ${quote(valueOrUrl)}`);
121
+ if (step.selectorHint && step.action.type !== "navigate") {
122
+ const locName = this.locatorNameFor(step);
123
+ lines.push(` target: $${locName}`);
124
+ }
125
+ if (step.annotation) {
126
+ lines.push(` annotation:`);
127
+ lines.push(` copy: ${quote(step.annotation.copy)}`);
128
+ if (step.annotation.arrow)
129
+ lines.push(` arrow: ${step.annotation.arrow}`);
130
+ if (step.annotation.target)
131
+ lines.push(` target: ${step.annotation.target}`);
132
+ }
133
+ }
134
+ return lines.join("\n") + "\n";
135
+ }
136
+ collectLocators() {
137
+ const seen = new Map();
138
+ for (const step of this.steps) {
139
+ if (!step.selectorHint || step.action.type === "navigate")
140
+ continue;
141
+ const name = this.locatorNameFor(step);
142
+ if (!seen.has(name))
143
+ seen.set(name, { name, hint: step.selectorHint, stability: step.stability });
144
+ }
145
+ return [...seen.values()];
146
+ }
147
+ locatorNameFor(step) {
148
+ // Derive a stable locator name from the selectorHint: extract the testId/
149
+ // role+name if obvious, else mash the step id.
150
+ const hint = step.selectorHint ?? "";
151
+ // Tier-1 attribute selector: require `data-*` prefix so we don't match
152
+ // e.g. `[name="Submit"]` inside a role=… hint.
153
+ const testId = hint.match(/\[(data-[a-z-]+)="([^"]+)"\]/);
154
+ if (testId)
155
+ return slugify(testId[2]);
156
+ const roleName = hint.match(/role=([a-z]+)\[name="([^"]+)"\]/i);
157
+ if (roleName)
158
+ return slugify(`${roleName[1]}_${roleName[2]}`);
159
+ return slugify(step.id);
160
+ }
161
+ }
162
+ function slugify(s) {
163
+ return (s
164
+ .replace(/[^a-z0-9]+/gi, "_")
165
+ .replace(/^_+|_+$/g, "")
166
+ .toLowerCase() || "step");
167
+ }
168
+ function quote(s) {
169
+ // Minimal YAML scalar quoting — wrap in double quotes if contains spaces /
170
+ // special chars; otherwise leave bare. Always quote for predictability.
171
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
172
+ }
@@ -0,0 +1,92 @@
1
+ import type { Frame } from "playwright-core";
2
+ export interface KeyInputs {
3
+ role: string;
4
+ name?: string;
5
+ /** A structural path through the a11y tree, e.g. "WebArea/main/list/listitem[2]/button". */
6
+ path: string;
7
+ /** Optional test-id-ish attribute value to disambiguate identical roles. */
8
+ testId?: string;
9
+ /** stable frame ID this node lives in. Namespaces the key so two
10
+ * iframes with the same internal markup don't collide on the same ref.
11
+ * Absent / empty means the main frame, preserving the pre-v0.5.0 hash. */
12
+ frameId?: string;
13
+ }
14
+ export declare function elementKey(inputs: KeyInputs): string;
15
+ /** What we remember about a ref so an action can rebuild a Playwright Locator for it. */
16
+ export interface RefLocatorInputs {
17
+ role: string;
18
+ name?: string;
19
+ testId?: string;
20
+ /** Attribute *name* that yielded `testId` (e.g. "data-testid", "data-type").
21
+ * Locator-resolution uses it to build `[<attr>=...]` so non-standard test attributes
22
+ * Just Work. */
23
+ testIdAttr?: string;
24
+ /** Ref provenance. Drives locator routing: a11y refs use role/name locators
25
+ * (auto-wait + strict semantics); dom refs use the structural CSS path that
26
+ * built the ref (refs whose role is a bare tag like `td`/`div`/`generic`
27
+ * produce ambiguous role-locators that don't actually find anything). `both`
28
+ * means the same element was discovered by both passes — a11y-tier locators
29
+ * win, with cssPath available as fallback. */
30
+ source?: "a11y" | "dom" | "both";
31
+ /** Structural CSS path captured at DOM-walk time, e.g.
32
+ * `body > div:nth-child(2) > table > tbody > tr:nth-child(4) > td:nth-child(3)`.
33
+ * Used when role/name locators would be ambiguous. Only populated for refs
34
+ * whose `source` includes `dom`. */
35
+ cssPath?: string;
36
+ /** stable frame ID the ref was minted in. Absent / `f0` means the
37
+ * main frame (existing behaviour). Anything else: a child iframe — locator
38
+ * resolution routes through `frame.locator(...)` instead of `page.locator(...)`
39
+ * so subsequent actions land inside the correct frame. Same-origin and
40
+ * cross-origin frames work transparently through Playwright's frame API. */
41
+ frameId?: string;
42
+ }
43
+ export declare class RefRegistry {
44
+ private refByKey;
45
+ private keyByRef;
46
+ private locatorByRef;
47
+ /** persistent named refs. Maps an agent-chosen mnemonic (e.g.
48
+ * "play_btn") to the underlying ref. Refs themselves are stable across
49
+ * snapshots (see elementKey()) so the name effectively pins an element
50
+ * identity for the whole session. */
51
+ private refByName;
52
+ /** Frame handle owning each child-frame ref. Main-frame refs
53
+ * omit the entry — the page-level locator resolution handles them
54
+ * unchanged. When a child-frame ref is acted on, `locatorFor` uses
55
+ * this Frame handle (instead of `page.locator(...)`) so the action
56
+ * lands inside the right OOPIF / same-origin iframe. */
57
+ private frameByRef;
58
+ private counter;
59
+ /** Resolve (or mint) the ref for a node's stable key. */
60
+ forKey(key: string, locator?: RefLocatorInputs): string;
61
+ has(ref: string): boolean;
62
+ hasKey(key: string): boolean;
63
+ keyOf(ref: string): string | undefined;
64
+ locatorOf(ref: string): RefLocatorInputs | undefined;
65
+ updateLocator(ref: string, locator: RefLocatorInputs): void;
66
+ /**
67
+ * Merge new locator inputs into an existing ref's record. Existing richness
68
+ * wins (a11y-discovered `name` survives); missing fields fill in from the
69
+ * partial; `source` combines (`a11y` + `dom` → `both`). When the ref has
70
+ * no prior locator inputs, the partial is installed wholesale provided
71
+ * `role` is present.
72
+ */
73
+ augmentLocator(ref: string, partial: Partial<RefLocatorInputs>): void;
74
+ /** Bind a Playwright Frame handle to a ref. Call when minting a ref in a
75
+ * child-frame snapshot/find so action-time `locatorFor` can route through
76
+ * the frame instead of the page. Main-frame refs don't need to call this;
77
+ * absence of a binding means "resolve through the page". */
78
+ bindFrame(ref: string, frame: Frame): void;
79
+ /** Resolve a ref to its bound Frame, or undefined for main-frame refs. */
80
+ frameOf(ref: string): Frame | undefined;
81
+ /** Bind a mnemonic name to a ref. Overwrites any prior binding for that name. */
82
+ nameRef(name: string, ref: string): void;
83
+ /** Resolve a name back to a ref. */
84
+ refByNameLookup(name: string): string | undefined;
85
+ /** List all current name → ref bindings. */
86
+ listNames(): Array<{
87
+ name: string;
88
+ ref: string;
89
+ }>;
90
+ /** Useful for tests / introspection only. */
91
+ size(): number;
92
+ }
@@ -0,0 +1,134 @@
1
+ // Stable `eN` ref scheme — the cross-snapshot coherence constraint.
2
+ //
3
+ // A ref is assigned by a *stable element key* (a hash of role + accessible name +
4
+ // structural path + testid-if-any), NOT by enumeration order. When a node persists
5
+ // across snapshots it keeps its eN; new nodes get fresh ones. This is what makes
6
+ // `tree_diff` line-stable and what lets refs from a `find()` candidate survive
7
+ // the next `snapshot()`.
8
+ import { createHash } from "node:crypto";
9
+ export function elementKey(inputs) {
10
+ const raw = [
11
+ inputs.role,
12
+ inputs.name ?? "",
13
+ inputs.path,
14
+ inputs.testId ?? "",
15
+ inputs.frameId ?? "",
16
+ ].join("");
17
+ // Short hash — collision-resistant within a single page session.
18
+ return createHash("sha256").update(raw).digest("hex").slice(0, 16);
19
+ }
20
+ export class RefRegistry {
21
+ refByKey = new Map();
22
+ keyByRef = new Map();
23
+ locatorByRef = new Map();
24
+ /** persistent named refs. Maps an agent-chosen mnemonic (e.g.
25
+ * "play_btn") to the underlying ref. Refs themselves are stable across
26
+ * snapshots (see elementKey()) so the name effectively pins an element
27
+ * identity for the whole session. */
28
+ refByName = new Map();
29
+ /** Frame handle owning each child-frame ref. Main-frame refs
30
+ * omit the entry — the page-level locator resolution handles them
31
+ * unchanged. When a child-frame ref is acted on, `locatorFor` uses
32
+ * this Frame handle (instead of `page.locator(...)`) so the action
33
+ * lands inside the right OOPIF / same-origin iframe. */
34
+ frameByRef = new Map();
35
+ counter = 0;
36
+ /** Resolve (or mint) the ref for a node's stable key. */
37
+ forKey(key, locator) {
38
+ let ref = this.refByKey.get(key);
39
+ if (!ref) {
40
+ ref = `e${++this.counter}`;
41
+ this.refByKey.set(key, ref);
42
+ this.keyByRef.set(ref, key);
43
+ }
44
+ if (locator)
45
+ this.locatorByRef.set(ref, locator);
46
+ return ref;
47
+ }
48
+ has(ref) {
49
+ return this.keyByRef.has(ref);
50
+ }
51
+ hasKey(key) {
52
+ return this.refByKey.has(key);
53
+ }
54
+ keyOf(ref) {
55
+ return this.keyByRef.get(ref);
56
+ }
57
+ locatorOf(ref) {
58
+ return this.locatorByRef.get(ref);
59
+ }
60
+ updateLocator(ref, locator) {
61
+ if (this.keyByRef.has(ref))
62
+ this.locatorByRef.set(ref, locator);
63
+ }
64
+ /**
65
+ * Merge new locator inputs into an existing ref's record. Existing richness
66
+ * wins (a11y-discovered `name` survives); missing fields fill in from the
67
+ * partial; `source` combines (`a11y` + `dom` → `both`). When the ref has
68
+ * no prior locator inputs, the partial is installed wholesale provided
69
+ * `role` is present.
70
+ */
71
+ augmentLocator(ref, partial) {
72
+ if (!this.keyByRef.has(ref))
73
+ return;
74
+ const existing = this.locatorByRef.get(ref);
75
+ if (!existing) {
76
+ if (partial.role !== undefined)
77
+ this.locatorByRef.set(ref, partial);
78
+ return;
79
+ }
80
+ const merged = {
81
+ role: existing.role,
82
+ name: existing.name ?? partial.name,
83
+ testId: existing.testId ?? partial.testId,
84
+ testIdAttr: existing.testIdAttr ?? partial.testIdAttr,
85
+ cssPath: existing.cssPath ?? partial.cssPath,
86
+ source: combineSource(existing.source, partial.source),
87
+ frameId: existing.frameId ?? partial.frameId,
88
+ };
89
+ this.locatorByRef.set(ref, merged);
90
+ }
91
+ // --- frame binding ---
92
+ /** Bind a Playwright Frame handle to a ref. Call when minting a ref in a
93
+ * child-frame snapshot/find so action-time `locatorFor` can route through
94
+ * the frame instead of the page. Main-frame refs don't need to call this;
95
+ * absence of a binding means "resolve through the page". */
96
+ bindFrame(ref, frame) {
97
+ if (!this.keyByRef.has(ref))
98
+ return;
99
+ this.frameByRef.set(ref, frame);
100
+ }
101
+ /** Resolve a ref to its bound Frame, or undefined for main-frame refs. */
102
+ frameOf(ref) {
103
+ return this.frameByRef.get(ref);
104
+ }
105
+ // --- named refs ---
106
+ /** Bind a mnemonic name to a ref. Overwrites any prior binding for that name. */
107
+ nameRef(name, ref) {
108
+ if (!this.keyByRef.has(ref))
109
+ throw new Error(`name_ref: ref "${ref}" not in registry`);
110
+ this.refByName.set(name, ref);
111
+ }
112
+ /** Resolve a name back to a ref. */
113
+ refByNameLookup(name) {
114
+ return this.refByName.get(name);
115
+ }
116
+ /** List all current name → ref bindings. */
117
+ listNames() {
118
+ return [...this.refByName.entries()].map(([name, ref]) => ({ name, ref }));
119
+ }
120
+ /** Useful for tests / introspection only. */
121
+ size() {
122
+ return this.refByKey.size;
123
+ }
124
+ }
125
+ function combineSource(a, b) {
126
+ if (!a)
127
+ return b;
128
+ if (!b)
129
+ return a;
130
+ if (a === b)
131
+ return a;
132
+ // Any mix of a11y + dom (or already-both) ⇒ both.
133
+ return "both";
134
+ }
@@ -0,0 +1,23 @@
1
+ export interface Box {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface NamedRegion {
8
+ name: string;
9
+ box: Box;
10
+ /** box centre — the point to hand to a coords-based action. */
11
+ center: {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ }
16
+ /** One per SessionEntry. In-memory; nothing persisted. */
17
+ export declare class RegionRegistry {
18
+ private regions;
19
+ set(name: string, box: Box): NamedRegion;
20
+ get(name: string): NamedRegion | undefined;
21
+ list(): NamedRegion[];
22
+ private view;
23
+ }
@@ -0,0 +1,32 @@
1
+ // Named visual regions — capability `human`.
2
+ //
3
+ // In virtualised timelines / canvas / unlabelled positioned divs the target
4
+ // is "the third row segment at x=…", not an element ref. `name_region` binds
5
+ // a box to a mnemonic so a sub-agent can re-select, copy, and re-check the
6
+ // same media segment without re-deriving coordinates each time (coordinate
7
+ // drift). `region` resolves the name back to its box + centre point, which
8
+ // the caller passes to `click({coords})` etc.
9
+ /** One per SessionEntry. In-memory; nothing persisted. */
10
+ export class RegionRegistry {
11
+ regions = new Map();
12
+ set(name, box) {
13
+ this.regions.set(name, box);
14
+ return this.view(name);
15
+ }
16
+ get(name) {
17
+ return this.view(name);
18
+ }
19
+ list() {
20
+ return [...this.regions.keys()].map((n) => this.view(n));
21
+ }
22
+ view(name) {
23
+ const box = this.regions.get(name);
24
+ if (!box)
25
+ return undefined;
26
+ return {
27
+ name,
28
+ box,
29
+ center: { x: box.x + box.width / 2, y: box.y + box.height / 2 },
30
+ };
31
+ }
32
+ }
@@ -0,0 +1,40 @@
1
+ import type { Page } from "playwright-core";
2
+ export interface RouteResponse {
3
+ status?: number;
4
+ body?: string;
5
+ contentType?: string;
6
+ delayMs?: number;
7
+ }
8
+ export interface RouteSpec extends RouteResponse {
9
+ urlPattern: string;
10
+ method?: string;
11
+ }
12
+ export interface RouteQueueSpec {
13
+ urlPattern: string;
14
+ method?: string;
15
+ responses: RouteResponse[];
16
+ }
17
+ /** Per-session registry of active route interceptions. Routes are also
18
+ * discarded when the session's browser context closes; this exists for
19
+ * `unroute` (mid-session clearing) and audit. */
20
+ export declare class RouteRegistry {
21
+ private routes;
22
+ /** Single canned response for every matching request. */
23
+ add(page: Page, spec: RouteSpec): Promise<{
24
+ key: string;
25
+ }>;
26
+ /** Successive matches consume successive responses; once the list is
27
+ * exhausted, matches fall through to the real network. */
28
+ addQueue(page: Page, spec: RouteQueueSpec): Promise<{
29
+ key: string;
30
+ queued: number;
31
+ }>;
32
+ private removeByKey;
33
+ /** Remove one route (by urlPattern[+method]) or, when no pattern is given,
34
+ * every route this session registered. Returns the removed keys. */
35
+ remove(page: Page, sel: {
36
+ urlPattern?: string;
37
+ method?: string;
38
+ }): Promise<string[]>;
39
+ list(): string[];
40
+ }
@@ -0,0 +1,87 @@
1
+ // Scoped network route mocking — capability `action`.
2
+ //
3
+ // Race-condition QA needs to make backend responses arrive in a controlled
4
+ // (often out-of-request) order, or substitute a canned response. Rather than
5
+ // app-specific `eval_js` monkey-patching, this drives Playwright's own
6
+ // `page.route` interception, per-session and torn down with the session.
7
+ //
8
+ // `route` fulfils every match with one canned response (optional delay).
9
+ // `route_queue` fulfils successive matches from a list — each entry with its
10
+ // own delay, so e.g. response #2 (delay 0) can land before response #1
11
+ // (delay 400) — the exact "responses out of request order" failure class.
12
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
13
+ const MAX_DELAY_MS = 60_000;
14
+ function keyOf(urlPattern, method) {
15
+ return `${(method ?? "*").toUpperCase()} ${urlPattern}`;
16
+ }
17
+ async function fulfil(route, r) {
18
+ if (r.delayMs && r.delayMs > 0)
19
+ await sleep(Math.min(r.delayMs, MAX_DELAY_MS));
20
+ await route.fulfill({
21
+ status: r.status ?? 200,
22
+ contentType: r.contentType ?? "application/json",
23
+ body: r.body ?? "",
24
+ });
25
+ }
26
+ /** Per-session registry of active route interceptions. Routes are also
27
+ * discarded when the session's browser context closes; this exists for
28
+ * `unroute` (mid-session clearing) and audit. */
29
+ export class RouteRegistry {
30
+ routes = new Map();
31
+ /** Single canned response for every matching request. */
32
+ async add(page, spec) {
33
+ const key = keyOf(spec.urlPattern, spec.method);
34
+ await this.removeByKey(page, key); // replace any prior route on the same key
35
+ const handler = async (route) => {
36
+ if (spec.method && route.request().method().toUpperCase() !== spec.method.toUpperCase()) {
37
+ return route.fallback();
38
+ }
39
+ await fulfil(route, spec);
40
+ };
41
+ await page.route(spec.urlPattern, handler);
42
+ this.routes.set(key, { url: spec.urlPattern, handler });
43
+ return { key };
44
+ }
45
+ /** Successive matches consume successive responses; once the list is
46
+ * exhausted, matches fall through to the real network. */
47
+ async addQueue(page, spec) {
48
+ const key = keyOf(spec.urlPattern, spec.method);
49
+ await this.removeByKey(page, key);
50
+ let i = 0;
51
+ const handler = async (route) => {
52
+ if (spec.method && route.request().method().toUpperCase() !== spec.method.toUpperCase()) {
53
+ return route.fallback();
54
+ }
55
+ const r = spec.responses[i++];
56
+ if (!r)
57
+ return route.fallback();
58
+ await fulfil(route, r);
59
+ };
60
+ await page.route(spec.urlPattern, handler);
61
+ this.routes.set(key, { url: spec.urlPattern, handler });
62
+ return { key, queued: spec.responses.length };
63
+ }
64
+ async removeByKey(page, key) {
65
+ const e = this.routes.get(key);
66
+ if (!e)
67
+ return false;
68
+ await page.unroute(e.url, e.handler).catch(() => undefined);
69
+ this.routes.delete(key);
70
+ return true;
71
+ }
72
+ /** Remove one route (by urlPattern[+method]) or, when no pattern is given,
73
+ * every route this session registered. Returns the removed keys. */
74
+ async remove(page, sel) {
75
+ if (!sel.urlPattern) {
76
+ const all = [...this.routes.keys()];
77
+ for (const k of all)
78
+ await this.removeByKey(page, k);
79
+ return all;
80
+ }
81
+ const key = keyOf(sel.urlPattern, sel.method);
82
+ return (await this.removeByKey(page, key)) ? [key] : [];
83
+ }
84
+ list() {
85
+ return [...this.routes.keys()];
86
+ }
87
+ }
@@ -0,0 +1,12 @@
1
+ import type { SafariSessionHandle } from "../engine/index.js";
2
+ import type { RefRegistry } from "./refs.js";
3
+ import type { ActionResult, DispatchedAction } from "./actionresult.js";
4
+ import type { ActionTarget } from "./locator.js";
5
+ /** A clean refusal for an action family outside Safari's curated subset (hover,
6
+ * select, scroll, …). Keeps the gating in the adapter rather than the handler,
7
+ * so the tool surface stays engine-blind. */
8
+ export declare function safariUnsupportedAction(type: DispatchedAction["type"]): ActionResult;
9
+ export declare function safariNavigate(handle: SafariSessionHandle, url: string): Promise<ActionResult>;
10
+ export declare function safariClick(handle: SafariSessionHandle, refs: RefRegistry, target: ActionTarget): Promise<ActionResult>;
11
+ export declare function safariFill(handle: SafariSessionHandle, refs: RefRegistry, target: ActionTarget, value: string): Promise<ActionResult>;
12
+ export declare function safariPress(handle: SafariSessionHandle, refs: RefRegistry, target: ActionTarget, key: string): Promise<ActionResult>;