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,167 @@
1
+ // Virtual-time clock control — capability `action`.
2
+ //
3
+ // Wraps CDP `Emulation.setVirtualTimePolicy` so date-sensitive flows
4
+ // (renewal dates, "today" filters, scheduling, expiry edges) can be tested
5
+ // deterministically without touching the OS clock. Per-session.
6
+ //
7
+ // Three modes:
8
+ // - freeze → pause virtual time at `atIso` (or "now" if omitted). CDP
9
+ // policy: `pause` (virtual time is truly halted at the anchor, so a
10
+ // rAF/timer loop cannot race Date forward; page resource loading runs on
11
+ // real time and is unaffected).
12
+ // - advance → jump the virtual clock forward by `byMs`, or to absolute
13
+ // `atIso`, then re-freeze. CDP policy: `advance` with a `budget` (ms),
14
+ // then we re-issue a pause so subsequent JS time queries stay pinned.
15
+ // - release → resume real time. CDP no-op-equivalent via `disabled`.
16
+ //
17
+ // CDP's `setVirtualTimePolicy` is per-target. A renderer swap or fresh page
18
+ // drops it — same shape as src/page/emulation.ts, so we cache the active
19
+ // state per session and re-apply on `framenavigated` (main frame only).
20
+ //
21
+ // BYOB note: when applied to an attached Chrome, the virtual-time policy
22
+ // stays in effect on the human's page until they release it, reload, or
23
+ // close the tab — a wall-clock-looking page that has actually frozen time
24
+ // is a debugging trap. Surfaced as a `warning` on the result.
25
+ const MAX_ADVANCE_MS = 365 * 24 * 60 * 60 * 1000; // one year — sanity ceiling
26
+ function parseIso(iso, field) {
27
+ const t = Date.parse(iso);
28
+ if (!Number.isFinite(t)) {
29
+ throw new Error(`clock: ${field} is not a valid ISO-8601 timestamp (got ${JSON.stringify(iso)})`);
30
+ }
31
+ return t;
32
+ }
33
+ function normalizeInput(input, currentMs) {
34
+ if (input.mode === "release") {
35
+ return { mode: "release", targetMs: currentMs, advanceBudgetMs: 0 };
36
+ }
37
+ if (input.mode === "freeze") {
38
+ if (input.byMs !== undefined) {
39
+ throw new Error(`clock: byMs is only valid with mode:"advance" (got mode:"freeze")`);
40
+ }
41
+ const targetMs = input.atIso !== undefined ? parseIso(input.atIso, "atIso") : Date.now();
42
+ return { mode: "freeze", targetMs, advanceBudgetMs: 0 };
43
+ }
44
+ // advance
45
+ if (input.atIso !== undefined && input.byMs !== undefined) {
46
+ throw new Error(`clock: advance requires exactly one of atIso or byMs, not both`);
47
+ }
48
+ if (input.atIso === undefined && input.byMs === undefined) {
49
+ throw new Error(`clock: advance requires either atIso or byMs`);
50
+ }
51
+ let targetMs;
52
+ if (input.atIso !== undefined) {
53
+ targetMs = parseIso(input.atIso, "atIso");
54
+ }
55
+ else {
56
+ if (!Number.isFinite(input.byMs) || input.byMs <= 0) {
57
+ throw new Error(`clock: byMs must be a positive finite number (got ${input.byMs})`);
58
+ }
59
+ if (input.byMs > MAX_ADVANCE_MS) {
60
+ throw new Error(`clock: byMs ${input.byMs} exceeds max ${MAX_ADVANCE_MS} (1 year)`);
61
+ }
62
+ targetMs = currentMs + input.byMs;
63
+ }
64
+ const advanceBudgetMs = Math.max(0, targetMs - currentMs);
65
+ if (advanceBudgetMs > MAX_ADVANCE_MS) {
66
+ throw new Error(`clock: advance distance ${advanceBudgetMs}ms exceeds max ${MAX_ADVANCE_MS}ms (1 year)`);
67
+ }
68
+ return { mode: "advance", targetMs, advanceBudgetMs };
69
+ }
70
+ /** Per-session clock controller. One per SessionEntry. */
71
+ export class ClockRegistry {
72
+ state;
73
+ /** Re-apply hook installed once per page on first use. */
74
+ reattachInstalled = new WeakSet();
75
+ /** Apply the requested mode and remember it. Returns the normalized state. */
76
+ async apply(cdp, page, input) {
77
+ const currentMs = this.state?.nowMs ?? Date.now();
78
+ const norm = normalizeInput(input, currentMs);
79
+ if (norm.mode === "release") {
80
+ await this.sendRelease(cdp);
81
+ this.state = undefined;
82
+ this.installReattach(page);
83
+ return { state: undefined, mode: "release", appliedAtIso: null };
84
+ }
85
+ if (norm.mode === "freeze") {
86
+ await this.sendPauseAt(cdp, norm.targetMs);
87
+ this.state = { nowMs: norm.targetMs, paused: true };
88
+ this.installReattach(page);
89
+ return {
90
+ state: this.state,
91
+ mode: "freeze",
92
+ appliedAtIso: new Date(norm.targetMs).toISOString(),
93
+ };
94
+ }
95
+ // advance: start from currentMs (re-pin), then advance by budget, then re-pause
96
+ await this.sendPauseAt(cdp, currentMs);
97
+ if (norm.advanceBudgetMs > 0) {
98
+ await this.sendAdvance(cdp, norm.advanceBudgetMs);
99
+ }
100
+ // After advance budget elapses CDP returns to whatever follow-up policy was
101
+ // queued — we explicitly re-pause at the new target so subsequent JS time
102
+ // queries see the pinned instant.
103
+ await this.sendPauseAt(cdp, norm.targetMs);
104
+ this.state = { nowMs: norm.targetMs, paused: true };
105
+ this.installReattach(page);
106
+ return {
107
+ state: this.state,
108
+ mode: "advance",
109
+ appliedAtIso: new Date(norm.targetMs).toISOString(),
110
+ };
111
+ }
112
+ /** Reset on close/teardown if a non-default policy is active. */
113
+ async resetAll(cdp) {
114
+ if (this.state) {
115
+ await this.sendRelease(cdp).catch(() => undefined);
116
+ }
117
+ this.state = undefined;
118
+ }
119
+ /** Test introspection. */
120
+ current() {
121
+ return this.state;
122
+ }
123
+ installReattach(page) {
124
+ if (this.reattachInstalled.has(page))
125
+ return;
126
+ this.reattachInstalled.add(page);
127
+ const onNav = async (frame) => {
128
+ if (frame.parentFrame())
129
+ return; // main frame only
130
+ try {
131
+ const cdp = await page
132
+ .context()
133
+ .newCDPSession(page)
134
+ .catch(() => null);
135
+ if (!cdp)
136
+ return;
137
+ if (this.state) {
138
+ await this.sendPauseAt(cdp, this.state.nowMs).catch(() => undefined);
139
+ }
140
+ }
141
+ catch {
142
+ // page may have closed mid-navigation; swallow
143
+ }
144
+ };
145
+ page.on("framenavigated", onNav);
146
+ }
147
+ async sendPauseAt(cdp, atMs) {
148
+ // `pause` truly halts virtual time at `initialVirtualTime`. The earlier
149
+ // `pauseIfNetworkFetchesPending` only held time while a fetch was in flight —
150
+ // once the page went network-idle the scheduler resumed and any rAF/timer
151
+ // loop raced the clock forward (Date jumped days per wall-second), so a
152
+ // "frozen" page was not actually frozen. `pause` pins Date deterministically.
153
+ await cdp.send("Emulation.setVirtualTimePolicy", {
154
+ policy: "pause",
155
+ initialVirtualTime: atMs / 1000, // CDP expects seconds since epoch
156
+ });
157
+ }
158
+ async sendAdvance(cdp, budgetMs) {
159
+ await cdp.send("Emulation.setVirtualTimePolicy", {
160
+ policy: "advance",
161
+ budget: budgetMs,
162
+ });
163
+ }
164
+ async sendRelease(cdp) {
165
+ await cdp.send("Emulation.setVirtualTimePolicy", { policy: "advance" });
166
+ }
167
+ }
@@ -0,0 +1,55 @@
1
+ import type { CDPSession, Frame } from "playwright-core";
2
+ import { type A11yNode } from "./a11y.js";
3
+ import type { RefRegistry } from "./refs.js";
4
+ export interface ComposedSnapshot {
5
+ /** The combined tree. Root is the a11y root; DOM-walk leaves are appended as children. */
6
+ tree: A11yNode | null;
7
+ /** Counts and source mix — useful for the low-content warning + debugging. */
8
+ stats: {
9
+ a11yInteractive: number;
10
+ domWalkEntries: number;
11
+ domWalkNew: number;
12
+ domWalkCombined: number;
13
+ /** count of closed-shadow elements harvested via CDP.
14
+ * Always zero when `pierce !== "closed"` or CDP refused the pierce
15
+ * call. */
16
+ closedShadowEntries?: number;
17
+ };
18
+ /** Non-fatal warnings — low-content a11y tree, closed-shadow CDP
19
+ * unavailable when pierce: "closed" was requested, etc. */
20
+ warnings: string[];
21
+ }
22
+ export interface ComposeOptions {
23
+ /** shadow DOM piercing.
24
+ * - `undefined` (default) — pre-v0.5.0 behaviour. Playwright's a11y tree
25
+ * already includes open shadow content, but the DOM-walk fallback does
26
+ * not recurse into shadow roots.
27
+ * - `"open"` — additionally have the DOM-walk recurse through every open
28
+ * shadow root reachable from the page side.
29
+ * - `"closed"` — open-walk + CDP `pierce:true` pass that surfaces
30
+ * interactive / test-attr-bearing elements inside CLOSED shadow roots.
31
+ * Best-effort: when CDP refuses the pierce call (older Chromium,
32
+ * detached attached-mode session), falls back to the open-only result
33
+ * and emits a warning.
34
+ * - `false` — neither path recurses into shadow content. The DOM-walk
35
+ * sticks to the top document. */
36
+ pierce?: "open" | "closed" | false;
37
+ }
38
+ export declare function composeSnapshot(cdp: CDPSession, refs: RefRegistry, testAttributes: string[], opts?: ComposeOptions): Promise<ComposedSnapshot>;
39
+ /**
40
+ * Frame-scoped snapshot. Composes the snapshot for a child iframe.
41
+ *
42
+ * Cross-origin frames sit in their own renderer (OOPIF) — the top-level CDP
43
+ * session's `Accessibility.getFullAXTree` is rooted at the main target and
44
+ * doesn't reach into them. Same-origin child frames are in the same renderer
45
+ * but CDP's per-frame a11y query path is fragile across Playwright versions.
46
+ * Pragmatic choice: for ANY child frame we skip the CDP a11y pass and use the
47
+ * DOM-walk only via `frame.evaluate(...)`. The DOM walk is what carries find()
48
+ * on heavy SPAs anyway, and `frame.evaluate` is the portable, identical-
49
+ * behaviour-across-origin entry point Playwright exposes.
50
+ *
51
+ * Refs minted here are bound to `frame` on the registry so subsequent
52
+ * `locatorFor` calls route through `frame.locator(...)` rather than
53
+ * `page.locator(...)` — actions land inside the correct OOPIF transparently.
54
+ */
55
+ export declare function composeSnapshotForFrame(frame: Frame, refs: RefRegistry, testAttributes: string[], frameId: string, opts?: ComposeOptions): Promise<ComposedSnapshot>;
@@ -0,0 +1,169 @@
1
+ // Compose the a11y tree + the DOM-walk fallback into a single tree.
2
+ // .
3
+ //
4
+ // Behaviour:
5
+ // - Always get the a11y tree first (it carries roles, accessible names, structure).
6
+ // - Always run the DOM walk (uniform behaviour, predictable cost — one
7
+ // Runtime.evaluate per snapshot is cheap relative to the rest of a CDP roundtrip).
8
+ // - Merge: DOM-walk entries become children of the root tree. Entries whose stable
9
+ // key already matches an a11y node get `source: "both"`; entries new to the
10
+ // registry get `source: "dom"`. The a11y nodes keep `source: "a11y"` (default).
11
+ // - If the a11y tree has fewer than LOW_A11Y_THRESHOLD interactive descendants
12
+ // under the root, emit a warning telling the agent the DOM-walk source carried
13
+ // the load (#11) — most adopters interpret an empty-ish a11y tree as "page is
14
+ // empty" rather than "a11y is sparse on this codebase." This warning closes that
15
+ // ambiguity.
16
+ import { getA11yTree, walk } from "./a11y.js";
17
+ import { runDomWalk, runDomWalkOnFrame, mergeDomWalkIntoTree, } from "./dom-walk.js";
18
+ import { annotateStructuralContext } from "./structural.js";
19
+ import { LOW_A11Y_THRESHOLD } from "../util/config.js";
20
+ import { elementKey } from "./refs.js";
21
+ import { harvestClosedShadowElements } from "./shadow.js";
22
+ const INTERACTIVE_ROLES = new Set([
23
+ "button",
24
+ "link",
25
+ "textbox",
26
+ "searchbox",
27
+ "combobox",
28
+ "checkbox",
29
+ "radio",
30
+ "switch",
31
+ "slider",
32
+ "spinbutton",
33
+ "menuitem",
34
+ "menuitemcheckbox",
35
+ "menuitemradio",
36
+ "option",
37
+ "tab",
38
+ "treeitem",
39
+ ]);
40
+ export async function composeSnapshot(cdp, refs, testAttributes, opts = {}) {
41
+ const a11y = await getA11yTree(cdp, refs, testAttributes).catch(() => null);
42
+ if (a11y)
43
+ markSource(a11y, "a11y");
44
+ const a11yInteractive = a11y ? countInteractive(a11y) : 0;
45
+ const entries = await runDomWalk(cdp, { testAttributes, pierce: opts.pierce });
46
+ // closed-shadow elements come from a separate CDP pass.
47
+ // Same DomWalkEntry shape; merged via the same registry path so the
48
+ // selectorHint tier + `[from-dom]` evidence remain coherent.
49
+ let closedEntries = [];
50
+ let closedShadowWarning;
51
+ let closedShadowCount = 0;
52
+ if (opts.pierce === "closed") {
53
+ const harvested = await harvestClosedShadowElements(cdp, testAttributes, 500);
54
+ closedEntries = harvested.entries.map((e) => ({
55
+ role: e.role,
56
+ name: e.name,
57
+ testId: e.testId,
58
+ testIdAttr: e.testIdAttr,
59
+ tag: e.tag,
60
+ id: e.id,
61
+ structuralPath: e.structuralPath,
62
+ cssPath: e.cssPath,
63
+ }));
64
+ closedShadowCount = closedEntries.length;
65
+ closedShadowWarning = harvested.warning;
66
+ }
67
+ const allEntries = [...entries, ...closedEntries];
68
+ const merge = a11y ? mergeDomWalkIntoTree(a11y, allEntries, refs) : { added: 0, combined: 0 };
69
+ // After merging a11y + DOM-walk, tag descendants of repeated containers
70
+ // with their structural neighbourhood (row/column/rowText). Cheap O(n)
71
+ // pass; callers like `find()` ship these annotations as candidate
72
+ // evidence and 's container-probe references them.
73
+ if (a11y)
74
+ annotateStructuralContext(a11y);
75
+ const warnings = [];
76
+ if (a11yInteractive < LOW_A11Y_THRESHOLD) {
77
+ warnings.push(`low-content a11y tree (${a11yInteractive} interactive descendants under root); ` +
78
+ `the DOM-walk fallback supplied ${merge.added} new node(s) (${allEntries.length} total candidates seen). ` +
79
+ `Heavy SPAs with non-semantic markup often surface useful state through the DOM-walk source — ` +
80
+ `use [from-dom]-marked entries with their [testid=…] hints when present.`);
81
+ }
82
+ if (closedShadowWarning)
83
+ warnings.push(closedShadowWarning);
84
+ if (closedShadowCount > 0) {
85
+ warnings.push(`${closedShadowCount} candidate(s) discovered inside CLOSED shadow root(s) via CDP. ` +
86
+ `Closed-shadow elements are platform-protected — action tools (click/fill/etc) ` +
87
+ `CANNOT reach them through Playwright's locator engine. Use them as evidence ` +
88
+ `("this widget exists at depth N") only.`);
89
+ }
90
+ return {
91
+ tree: a11y,
92
+ stats: {
93
+ a11yInteractive,
94
+ domWalkEntries: allEntries.length,
95
+ domWalkNew: merge.added,
96
+ domWalkCombined: merge.combined,
97
+ ...(opts.pierce === "closed" ? { closedShadowEntries: closedShadowCount } : {}),
98
+ },
99
+ warnings,
100
+ };
101
+ }
102
+ /**
103
+ * Frame-scoped snapshot. Composes the snapshot for a child iframe.
104
+ *
105
+ * Cross-origin frames sit in their own renderer (OOPIF) — the top-level CDP
106
+ * session's `Accessibility.getFullAXTree` is rooted at the main target and
107
+ * doesn't reach into them. Same-origin child frames are in the same renderer
108
+ * but CDP's per-frame a11y query path is fragile across Playwright versions.
109
+ * Pragmatic choice: for ANY child frame we skip the CDP a11y pass and use the
110
+ * DOM-walk only via `frame.evaluate(...)`. The DOM walk is what carries find()
111
+ * on heavy SPAs anyway, and `frame.evaluate` is the portable, identical-
112
+ * behaviour-across-origin entry point Playwright exposes.
113
+ *
114
+ * Refs minted here are bound to `frame` on the registry so subsequent
115
+ * `locatorFor` calls route through `frame.locator(...)` rather than
116
+ * `page.locator(...)` — actions land inside the correct OOPIF transparently.
117
+ */
118
+ export async function composeSnapshotForFrame(frame, refs, testAttributes, frameId, opts = {}) {
119
+ // Synthetic root so the serialiser has a tree to walk; child-frame
120
+ // discovery is leaf-shaped (DOM-walk produces flat entries).
121
+ const rootKey = elementKey({
122
+ role: "WebArea",
123
+ name: undefined,
124
+ path: `__frame__/${frameId}`,
125
+ frameId,
126
+ });
127
+ const rootRef = refs.forKey(rootKey, { role: "WebArea", source: "dom", frameId });
128
+ refs.bindFrame(rootRef, frame);
129
+ const root = {
130
+ ref: rootRef,
131
+ role: "WebArea",
132
+ name: frame.url() || frame.name() || `frame:${frameId}`,
133
+ source: "dom",
134
+ children: [],
135
+ };
136
+ const entries = await runDomWalkOnFrame(frame, { testAttributes, pierce: opts.pierce });
137
+ const merge = mergeDomWalkIntoTree(root, entries, refs, { frameId, frame });
138
+ annotateStructuralContext(root);
139
+ const warnings = [
140
+ `frame "${frameId}": snapshot is DOM-walk-sourced only — CDP accessibility-tree extraction is not run for child frames (OOPIF / cross-origin compatibility). [from-dom] markers reflect the source, not a deficiency.`,
141
+ ];
142
+ if (opts.pierce === "closed") {
143
+ warnings.push(`frame "${frameId}": closed-shadow piercing via CDP is not run inside child frames (the CDP pierce path is rooted at the top target). pierce: "closed" degraded to "open" for this frame.`);
144
+ }
145
+ return {
146
+ tree: root,
147
+ stats: {
148
+ a11yInteractive: 0,
149
+ domWalkEntries: entries.length,
150
+ domWalkNew: merge.added,
151
+ domWalkCombined: merge.combined,
152
+ },
153
+ warnings,
154
+ };
155
+ }
156
+ function markSource(root, source) {
157
+ for (const { node } of walk(root)) {
158
+ if (!node.source)
159
+ node.source = source;
160
+ }
161
+ }
162
+ function countInteractive(root) {
163
+ let n = 0;
164
+ for (const { node } of walk(root)) {
165
+ if (INTERACTIVE_ROLES.has(node.role))
166
+ n++;
167
+ }
168
+ return n;
169
+ }
@@ -0,0 +1,39 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { SecretRegistry } from "../util/secrets.js";
3
+ export interface ConsoleMessage {
4
+ ts: number;
5
+ type: string;
6
+ text: string;
7
+ }
8
+ export declare class ConsoleBuffer {
9
+ private cap;
10
+ private msgs;
11
+ private errs;
12
+ /** Optional per-session secrets registry. Injected by the server after
13
+ * session creation so the egress masking layer applies on every read. */
14
+ private secrets;
15
+ constructor(cap?: number);
16
+ /** Wire a per-session secrets registry. After this, every `recent` /
17
+ * `errorsSince` / `pageErrorsSince` read substitutes registered real-values
18
+ * with their `<NAME>` aliases AFTER the URL sanitiser runs (the
19
+ * query-string secret-stripper that runs first so encoded secrets in URLs
20
+ * don't leak past the name-substitution pass). */
21
+ setSecrets(secrets: SecretRegistry): void;
22
+ attach(page: Page): void;
23
+ /** Ingest a console entry from a NON-Playwright source — the safari engine has
24
+ * no Playwright Page, so its console arrives via the BiDi `log.entryAdded`
25
+ * stream. Mirrors the `page.on("console")` push so
26
+ * `recent()` / `warningCountSince()` / `errorsSince()` work identically. The
27
+ * BiDi level (`debug`/`info`/`warn`/`error`) is mapped to the console `type`
28
+ * vocabulary (`warn` → `warning`) the readers key on. */
29
+ ingest(level: string, text: string): void;
30
+ /** Compose the two egress layers: URL-sanitise first (regex on URL shape),
31
+ * then secrets-mask (literal real-value substitution). They don't fight —
32
+ * the URL sanitiser already redacted `?token=…`; the literal scan still
33
+ * catches a registered secret that landed elsewhere in the text. */
34
+ private sanitiseEgress;
35
+ recent(limit?: number): ConsoleMessage[];
36
+ errorsSince(ts: number): string[];
37
+ pageErrorsSince(ts: number): string[];
38
+ warningCountSince(ts: number): number;
39
+ }
@@ -0,0 +1,73 @@
1
+ // Ring buffer of console messages + page errors, hooked off Playwright Page events.
2
+ // Always-on (cheap); ActionResult slices the "since action started" view; the
3
+ // `console_read` MCP tool exposes the buffer.
4
+ import { sanitizeUrlsInText } from "../util/url-sanitizer.js";
5
+ const DEFAULT_CAP = 200;
6
+ export class ConsoleBuffer {
7
+ cap;
8
+ msgs = [];
9
+ errs = [];
10
+ /** Optional per-session secrets registry. Injected by the server after
11
+ * session creation so the egress masking layer applies on every read. */
12
+ secrets = null;
13
+ constructor(cap = DEFAULT_CAP) {
14
+ this.cap = cap;
15
+ }
16
+ /** Wire a per-session secrets registry. After this, every `recent` /
17
+ * `errorsSince` / `pageErrorsSince` read substitutes registered real-values
18
+ * with their `<NAME>` aliases AFTER the URL sanitiser runs (the
19
+ * query-string secret-stripper that runs first so encoded secrets in URLs
20
+ * don't leak past the name-substitution pass). */
21
+ setSecrets(secrets) {
22
+ this.secrets = secrets;
23
+ }
24
+ attach(page) {
25
+ page.on("console", (m) => {
26
+ this.msgs.push({ ts: Date.now(), type: m.type(), text: m.text() });
27
+ if (this.msgs.length > this.cap)
28
+ this.msgs.shift();
29
+ });
30
+ page.on("pageerror", (err) => {
31
+ this.errs.push({ ts: Date.now(), text: err.message });
32
+ if (this.errs.length > this.cap)
33
+ this.errs.shift();
34
+ });
35
+ }
36
+ /** Ingest a console entry from a NON-Playwright source — the safari engine has
37
+ * no Playwright Page, so its console arrives via the BiDi `log.entryAdded`
38
+ * stream. Mirrors the `page.on("console")` push so
39
+ * `recent()` / `warningCountSince()` / `errorsSince()` work identically. The
40
+ * BiDi level (`debug`/`info`/`warn`/`error`) is mapped to the console `type`
41
+ * vocabulary (`warn` → `warning`) the readers key on. */
42
+ ingest(level, text) {
43
+ const type = level === "warn" ? "warning" : level;
44
+ this.msgs.push({ ts: Date.now(), type, text });
45
+ if (this.msgs.length > this.cap)
46
+ this.msgs.shift();
47
+ }
48
+ /** Compose the two egress layers: URL-sanitise first (regex on URL shape),
49
+ * then secrets-mask (literal real-value substitution). They don't fight —
50
+ * the URL sanitiser already redacted `?token=…`; the literal scan still
51
+ * catches a registered secret that landed elsewhere in the text. */
52
+ sanitiseEgress(text) {
53
+ const afterUrl = sanitizeUrlsInText(text);
54
+ return this.secrets ? this.secrets.applyMaskInText(afterUrl) : afterUrl;
55
+ }
56
+ // URL substrings + registered-secret values in console / page-error text are
57
+ // sanitized at the egress boundary (read time) — the ring keeps raw text;
58
+ // only what leaves the server toward an MCP result is redacted.
59
+ recent(limit = 50) {
60
+ return this.msgs.slice(-limit).map((m) => ({ ...m, text: this.sanitiseEgress(m.text) }));
61
+ }
62
+ errorsSince(ts) {
63
+ return this.msgs
64
+ .filter((m) => m.type === "error" && m.ts >= ts)
65
+ .map((m) => this.sanitiseEgress(m.text));
66
+ }
67
+ pageErrorsSince(ts) {
68
+ return this.errs.filter((e) => e.ts >= ts).map((e) => this.sanitiseEgress(e.text));
69
+ }
70
+ warningCountSince(ts) {
71
+ return this.msgs.filter((m) => m.type === "warning" && m.ts >= ts).length;
72
+ }
73
+ }
@@ -0,0 +1,97 @@
1
+ import type { CDPSession } from "playwright-core";
2
+ /** Per-script JS coverage entry — one per Script URL the profiler observed. */
3
+ export interface JsCoverageEntry {
4
+ url: string;
5
+ totalBytes: number;
6
+ usedBytes: number;
7
+ /** 0-100. `totalBytes:0` is reported as `usagePercent:100` (no code → no
8
+ * dead code). */
9
+ usagePercent: number;
10
+ /** Optional list of dead byte ranges (only emitted when small enough to
11
+ * surface — top 50 ranges per script). */
12
+ deadRanges?: Array<{
13
+ start: number;
14
+ end: number;
15
+ }>;
16
+ }
17
+ /** Per-stylesheet CSS coverage entry — one per <style>/<link rel=stylesheet>
18
+ * the page used. */
19
+ export interface CssCoverageEntry {
20
+ url: string;
21
+ totalBytes: number;
22
+ usedBytes: number;
23
+ /** Approximate count derived from used-rule ranges. */
24
+ usedRules: number;
25
+ /** Same approximation against total ranges. */
26
+ totalRules: number;
27
+ /** 0-100. */
28
+ usagePercent: number;
29
+ /** Dead-rule byte ranges (top 50 per stylesheet). */
30
+ deadRules?: Array<{
31
+ start: number;
32
+ end: number;
33
+ }>;
34
+ }
35
+ /** Result of `coverage_stop` — the parsed report. */
36
+ export interface CoverageStopResult {
37
+ jsCoverage: JsCoverageEntry[];
38
+ cssCoverage: CssCoverageEntry[];
39
+ durationMs: number;
40
+ }
41
+ /** CDP Profiler.takePreciseCoverage response shape (only the fields we touch). */
42
+ interface CdpScriptCoverage {
43
+ url?: string;
44
+ functions?: Array<{
45
+ functionName?: string;
46
+ isBlockCoverage?: boolean;
47
+ ranges?: Array<{
48
+ startOffset: number;
49
+ endOffset: number;
50
+ count: number;
51
+ }>;
52
+ }>;
53
+ }
54
+ /** CDP CSS.takeCoverageDelta response shape. */
55
+ interface CdpRuleUsage {
56
+ styleSheetId: string;
57
+ startOffset: number;
58
+ endOffset: number;
59
+ used: boolean;
60
+ }
61
+ interface CdpStyleSheetHeader {
62
+ styleSheetId: string;
63
+ sourceURL?: string;
64
+ length?: number;
65
+ }
66
+ /** Per-session coverage tracker. One instance per SessionEntry; the
67
+ * underlying CDP coverage is per-target. */
68
+ export declare class CoverageTrackerState {
69
+ private running;
70
+ private startedAt;
71
+ /** Snapshot of `getAllStyleSheets()` taken at `start` so `stop` can map
72
+ * styleSheetId → URL + total length without a second CDP roundtrip. */
73
+ private cssHeaders;
74
+ /** CSS.styleSheetAdded event handler — kept for cleanup. */
75
+ private onStyleSheetAdded;
76
+ isRunning(): boolean;
77
+ /** Start both Profiler + CSS coverage on `cdp`. Returns `{restarted}` —
78
+ * if an instance was already running, it is cleanly stopped (results
79
+ * discarded) and a fresh one begins. */
80
+ start(cdp: CDPSession): Promise<{
81
+ startedAt: number;
82
+ restarted: boolean;
83
+ }>;
84
+ /** Stop both trackers, fetch + parse the results. Safe to call when no
85
+ * coverage is running — returns an empty report with `notRunning:true`. */
86
+ stop(cdp: CDPSession): Promise<CoverageStopResult & {
87
+ notRunning?: true;
88
+ }>;
89
+ /** Force-clean teardown for session close. */
90
+ closeIfRunning(cdp: CDPSession): Promise<void>;
91
+ private stopInternal;
92
+ }
93
+ export declare function parseJsCoverage(scripts: CdpScriptCoverage[]): JsCoverageEntry[];
94
+ /** Parse `CSS.stopRuleUsageTracking` output into per-stylesheet entries.
95
+ * Exported for unit tests against synthetic CDP payloads. */
96
+ export declare function parseCssCoverage(ruleUsage: CdpRuleUsage[], headers: Map<string, CdpStyleSheetHeader>): CssCoverageEntry[];
97
+ export {};