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,148 @@
1
+ // The Playwright post-creation wiring (RFC 0004 D1 + D5). The four Playwright
2
+ // engines (chromium / firefox / webkit / android) register `playwrightPostWire`
3
+ // as their `EngineEntry.postWire`; safari registers its own minimal BiDi-console
4
+ // post-wire (safari.engine.ts). This is where the 17 scattered
5
+ // `sess.engine !== "safari"` guards in session-registry.ts collapse into ONE call
6
+ // — the engine that needs the Playwright bookkeeping owns it, the engine that
7
+ // does not (safari, and the synthetic in-memory engine) simply omits it.
8
+ //
9
+ // Every attach below is byte-identical to its pre-relocation form and runs in the
10
+ // EXACT same source order (console → bridge → dialog → permission → notification →
11
+ // fs-picker → downloads → overlay → stealth → device-emulation → ws-interactive →
12
+ // workers). The post-creation attaches are side-effects on the Playwright context;
13
+ // running them once the SessionEntry is assembled (rather than inline during
14
+ // construction) is observably identical because no navigation — and thus no
15
+ // console/network/dialog event — fires during session creation.
16
+ //
17
+ // Host deps (caps / configStore / workspace) are threaded in per server: the
18
+ // composition root (`buildSessionRegistry`) owns them and passes its OWN set as the
19
+ // `deps` argument to `playwrightPostWire(entry, deps)`. They are NOT a module-global
20
+ // — a module-global would let a second `createServer()` in the same process (the
21
+ // in-process SDK transport composes one server per transport) overwrite the first
22
+ // server's caps gate / workspace sandbox-root, so server A could start installing
23
+ // server B's action-gated wrappers + stealth scripts on A's OWN sessions. Threading
24
+ // explicitly keeps each server's post-wire bound to its own boundary. The
25
+ // per-session policy states + bridge are read off the SessionEntry.
26
+ import { log } from "../util/logging.js";
27
+ import { attachDialogPolicy } from "./dialog.js";
28
+ import { attachPermissionPolicy, applyCdpBaseline as applyPermissionCdpBaseline, } from "./permission.js";
29
+ import { attachNotificationPolicy } from "./notification.js";
30
+ import { attachFsPickerPolicy } from "./fs-picker.js";
31
+ import { attachDeviceEmulation } from "./device-emu.js";
32
+ import { reapplyAll as reapplyEmulation } from "./emulation.js";
33
+ import { attachDownloadCapture } from "../page/downloads.js";
34
+ import { applyOverlayHide } from "../helper/overlay-hide.js";
35
+ import { applyStealth } from "../helper/stealth.js";
36
+ /** Attach the full Playwright post-creation bookkeeping to a freshly-built
37
+ * SessionEntry, using the per-server `deps` (caps / configStore / workspace) the
38
+ * composition root threads in. Returns the promise the session factory awaits, so
39
+ * every context attach completes before the session is handed to a tool call —
40
+ * byte-identical to the pre-relocation inline awaits. */
41
+ export async function playwrightPostWire(entry, deps) {
42
+ const { caps, configStore, workspace } = deps;
43
+ const sess = entry.session;
44
+ const ctx = sess.page().context();
45
+ const br = entry.bridge;
46
+ // console — attach to the current + future pages. (Safari's console arrives
47
+ // over BiDi in its own post-wire; every Playwright engine attaches here.)
48
+ entry.console.attach(sess.page());
49
+ // browser bridge — the page-side __browx signalling channel.
50
+ await br.attach(ctx);
51
+ // dialog policy — install per-page on current + future pages.
52
+ attachDialogPolicy(ctx, entry.dialog);
53
+ // permission policy — install per-context binding + init-script wrappers, plus
54
+ // the CDP baseline (Browser.setPermission per supported name). The ask-human
55
+ // handler routes through the bridge — `__browx.confirm(true|false)` from
56
+ // page-side DevTools releases the wait. Best-effort: attach failures still leave
57
+ // the CDP baseline below in place.
58
+ await attachPermissionPolicy(ctx, entry.permission, async (permission, origin) => {
59
+ log.info(`permission ask-human: ${permission}${origin ? ` (${origin})` : ""} → call __browx.confirm(true|false) in DevTools to respond`);
60
+ try {
61
+ const sig = await br.awaitSignal("respond", 300_000);
62
+ const data = sig.data;
63
+ if (data && data.kind === "confirm" && data.value === true)
64
+ return "allow";
65
+ return "deny";
66
+ }
67
+ catch {
68
+ return "deny";
69
+ }
70
+ });
71
+ await applyPermissionCdpBaseline(ctx, entry.permission).catch(() => undefined);
72
+ // notification-construction policy — per-context wrapper + binding around
73
+ // `new Notification(...)`. Default `allow` preserves browser default.
74
+ await attachNotificationPolicy(ctx, entry.notification, async (n) => {
75
+ log.info(`notification ask-human: ${JSON.stringify({ title: n.title, origin: n.origin })} → call __browx.confirm(true|false) in DevTools to respond`);
76
+ try {
77
+ const sig = await br.awaitSignal("respond", 300_000);
78
+ const data = sig.data;
79
+ if (data && data.kind === "confirm" && data.value === true)
80
+ return "allow";
81
+ return "deny";
82
+ }
83
+ catch {
84
+ return "deny";
85
+ }
86
+ });
87
+ // File System Access picker policy — per-context binding + init-script stubs.
88
+ // The server-side write target for `createWritable()` is workspace-rooted and
89
+ // validated against `workspace.root` at `fs_picker_respond` time.
90
+ await attachFsPickerPolicy(ctx, entry.fsPicker, workspace.root, async (api, suggestedName) => {
91
+ log.info(`fs-picker ask-human: ${api}${suggestedName ? ` (${suggestedName})` : ""} → call __browx.respond({files:[…]}) in DevTools (or fs_picker_respond) to answer`);
92
+ try {
93
+ const sig = await br.awaitSignal("respond", 300_000);
94
+ const data = sig.data;
95
+ if (data &&
96
+ data.kind === "fs_picker_respond" &&
97
+ Array.isArray(data.value?.files)) {
98
+ return data.value.files;
99
+ }
100
+ return null;
101
+ }
102
+ catch {
103
+ return null;
104
+ }
105
+ }).catch(() => undefined);
106
+ // Per-session download capture — always attach the context listener; when
107
+ // capture is off it just discards Playwright's temp file.
108
+ attachDownloadCapture(ctx, entry.downloads);
109
+ // resolve overlay selectors fresh per session so a
110
+ // `set_config({hideOverlaySelectors})` applies without a server restart.
111
+ await applyOverlayHide(ctx, configStore.resolve().hideOverlaySelectors);
112
+ // Per-context stealth init-script patches (capability `stealth`). Off by
113
+ // default; when on, overrides navigator.webdriver / plugins / languages /
114
+ // window.chrome on every page before page scripts run.
115
+ if (caps.enabled.has("stealth")) {
116
+ await applyStealth(ctx).catch((err) => {
117
+ log.warn(`stealth: failed to apply init script — ${err instanceof Error ? err.message : String(err)}`);
118
+ });
119
+ }
120
+ // Per-session device-emulation: attach the synthetic Web Bluetooth/USB/HID
121
+ // catalogs + the per-page reapply of locale/timezone/UA overrides.
122
+ await attachDeviceEmulation(ctx, entry.webDeviceEmulation).catch(() => undefined);
123
+ ctx.on("page", (newPage) => {
124
+ // Best-effort: a new tab fires here. Create its own CDP session to route
125
+ // locale/timezone/UA overrides. Errors swallowed — re-apply never breaks a
126
+ // navigation.
127
+ (async () => {
128
+ try {
129
+ const newCdp = await sess.page().context().newCDPSession(newPage);
130
+ await reapplyEmulation(sess.page().context(), newPage, newCdp, entry.deviceEmulation);
131
+ }
132
+ catch {
133
+ /* best-effort */
134
+ }
135
+ })().catch(() => undefined);
136
+ });
137
+ // ws-interactive — install the page-side WS wrapper EAGERLY (capability-gated
138
+ // on `action`) so a page that constructs `new WebSocket(...)` during initial
139
+ // document parse hits the wrapped constructor.
140
+ if (caps.enabled.has("action")) {
141
+ await entry.wsInteractive.install(sess.page()).catch(() => undefined);
142
+ }
143
+ // workers — same eager-install posture (capability-gated on `read`): the
144
+ // page-side Worker-constructor wrapper must be live before any document parse.
145
+ if (caps.enabled.has("read")) {
146
+ await entry.workers.installPageWrapper(sess.page()).catch(() => undefined);
147
+ }
148
+ }
@@ -0,0 +1,21 @@
1
+ /** A bounded, append-only record ring with a per-record timestamp. The single
2
+ * source of the buffer+cap discipline the five policy classes shared.
3
+ *
4
+ * `cap` defaults to 200 (every policy's historical default). `tsOf` extracts the
5
+ * per-record timestamp; it defaults to reading a `ts: number` field, so a record
6
+ * shaped `{ ts }` needs no extractor, and a record shaped `{ timestamp }` passes
7
+ * `(r) => r.timestamp`. */
8
+ export declare class PolicyRecordBuffer<TRecord> {
9
+ private readonly buffer;
10
+ private readonly cap;
11
+ private readonly tsOf;
12
+ constructor(cap?: number, tsOf?: (rec: TRecord) => number);
13
+ /** Append a record; drop the oldest once the ring exceeds `cap`. The one place
14
+ * the bound lives. */
15
+ record(rec: TRecord): void;
16
+ /** Slice records with timestamp `>= since`. Used by the action-window. */
17
+ since(since: number): TRecord[];
18
+ /** True if any record in `[since, now]` satisfies `pred`. Each policy passes
19
+ * its own "raised" test — e.g. `(r) => r.handledAs === "raised"`. */
20
+ matchedSince(since: number, pred: (rec: TRecord) => boolean): boolean;
21
+ }
@@ -0,0 +1,47 @@
1
+ // RFC 0004 P3 / D4 (DRY). The bounded, timestamp-ordered record ring the five
2
+ // page-policy classes (`DialogPolicyState`, `PermissionPolicyState`,
3
+ // `NotificationPolicyState`, `FsPickerPolicyState`, `DeviceEmulationState`) each
4
+ // hand-rolled verbatim — a `buffer: T[]` + a hard `cap` + `record` / `since` /
5
+ // a predicate-windowed `matchedSince`. Five copies of one bound is five places
6
+ // the cap or the timestamp comparison could drift; this is the single home.
7
+ //
8
+ // The bound is load-bearing (L7 — a chatty page must not grow the ring without
9
+ // limit), so collapsing it here makes the cap one tested value instead of five.
10
+ //
11
+ // Timestamp accessor: four of the five records carry `ts`; `NotificationRecord`
12
+ // carries `timestamp`. Rather than rename a field that is exposed on the wire
13
+ // (`ActionResult` / the policy report), the buffer takes a `tsOf` extractor so
14
+ // each policy keeps its own record shape verbatim — byte-identical behaviour,
15
+ // one shared bound.
16
+ /** A bounded, append-only record ring with a per-record timestamp. The single
17
+ * source of the buffer+cap discipline the five policy classes shared.
18
+ *
19
+ * `cap` defaults to 200 (every policy's historical default). `tsOf` extracts the
20
+ * per-record timestamp; it defaults to reading a `ts: number` field, so a record
21
+ * shaped `{ ts }` needs no extractor, and a record shaped `{ timestamp }` passes
22
+ * `(r) => r.timestamp`. */
23
+ export class PolicyRecordBuffer {
24
+ buffer = [];
25
+ cap;
26
+ tsOf;
27
+ constructor(cap = 200, tsOf) {
28
+ this.cap = cap;
29
+ this.tsOf = tsOf ?? ((rec) => rec.ts);
30
+ }
31
+ /** Append a record; drop the oldest once the ring exceeds `cap`. The one place
32
+ * the bound lives. */
33
+ record(rec) {
34
+ this.buffer.push(rec);
35
+ if (this.buffer.length > this.cap)
36
+ this.buffer.shift();
37
+ }
38
+ /** Slice records with timestamp `>= since`. Used by the action-window. */
39
+ since(since) {
40
+ return this.buffer.filter((r) => this.tsOf(r) >= since);
41
+ }
42
+ /** True if any record in `[since, now]` satisfies `pred`. Each policy passes
43
+ * its own "raised" test — e.g. `(r) => r.handledAs === "raised"`. */
44
+ matchedSince(since, pred) {
45
+ return this.buffer.some((r) => this.tsOf(r) >= since && pred(r));
46
+ }
47
+ }
@@ -0,0 +1,11 @@
1
+ export interface ProfileSnapshotResult {
2
+ ok: boolean;
3
+ action: "snapshot" | "restore";
4
+ profile: string;
5
+ snapshot: string;
6
+ }
7
+ /** Copy a profile directory into a named snapshot (overwrites an existing
8
+ * snapshot of the same name). */
9
+ export declare function snapshotProfile(workspaceRoot: string, profile: string | undefined, snapshot: string): ProfileSnapshotResult;
10
+ /** Restore a named snapshot back over a profile directory. */
11
+ export declare function restoreProfile(workspaceRoot: string, profile: string | undefined, snapshot: string): ProfileSnapshotResult;
@@ -0,0 +1,53 @@
1
+ // Profile snapshot / restore — capability `human`.
2
+ //
3
+ // A destructive authenticated-SPA test mutates the persistent profile (an
4
+ // accidental timeline edit, a half-finished form, dirty local state). Repeat
5
+ // runs then start from a polluted baseline. This copies a session's profile
6
+ // directory to/from a named snapshot under the workspace, so a test can
7
+ // checkpoint a clean state and restore it between runs.
8
+ //
9
+ // Copying a profile dir while Chromium has it open yields a corrupt copy
10
+ // (locked SQLite, in-flight writes) — the caller MUST close sessions first;
11
+ // the server tool enforces that guard.
12
+ import { cpSync, existsSync } from "node:fs";
13
+ import { join } from "node:path";
14
+ // mnemonic / profile names — no path separators or traversal.
15
+ const SAFE_NAME = /^[A-Za-z0-9._-]+$/;
16
+ function checkName(kind, name) {
17
+ if (!SAFE_NAME.test(name)) {
18
+ throw new Error(`${kind} "${name}" invalid — use only letters, digits, '.', '_', '-' (no path separators)`);
19
+ }
20
+ }
21
+ /** The on-disk dir for a session profile. `default`/undefined → `<root>/profile`
22
+ * (the legacy single-profile path); a name → `<root>/profiles/<name>`. */
23
+ function profileDir(workspaceRoot, profile) {
24
+ if (!profile || profile === "default")
25
+ return join(workspaceRoot, "profile");
26
+ checkName("profile", profile);
27
+ return join(workspaceRoot, "profiles", profile);
28
+ }
29
+ function snapshotDir(workspaceRoot, snapshot) {
30
+ checkName("snapshot", snapshot);
31
+ return join(workspaceRoot, "profile-snapshots", snapshot);
32
+ }
33
+ /** Copy a profile directory into a named snapshot (overwrites an existing
34
+ * snapshot of the same name). */
35
+ export function snapshotProfile(workspaceRoot, profile, snapshot) {
36
+ const src = profileDir(workspaceRoot, profile);
37
+ const dest = snapshotDir(workspaceRoot, snapshot);
38
+ if (!existsSync(src)) {
39
+ throw new Error(`profile_snapshot: no profile directory at "${src}" — open a persistent session with this profile first`);
40
+ }
41
+ cpSync(src, dest, { recursive: true, force: true });
42
+ return { ok: true, action: "snapshot", profile: profile ?? "default", snapshot };
43
+ }
44
+ /** Restore a named snapshot back over a profile directory. */
45
+ export function restoreProfile(workspaceRoot, profile, snapshot) {
46
+ const src = snapshotDir(workspaceRoot, snapshot);
47
+ const dest = profileDir(workspaceRoot, profile);
48
+ if (!existsSync(src)) {
49
+ throw new Error(`profile_restore: no snapshot "${snapshot}" — take one with profile_snapshot first`);
50
+ }
51
+ cpSync(src, dest, { recursive: true, force: true });
52
+ return { ok: true, action: "restore", profile: profile ?? "default", snapshot };
53
+ }
@@ -0,0 +1,365 @@
1
+ import type { BrowserSession } from "./types.js";
2
+ import type { RefRegistry } from "../page/refs.js";
3
+ import type { SnapshotSubstrate } from "../page/snapshot-substrate.js";
4
+ import type { FrameRegistry } from "../page/frames.js";
5
+ import type { ConsoleBuffer } from "../page/console.js";
6
+ import type { SessionNetworkRing, SessionWsRing } from "../page/network.js";
7
+ import type { NetworkSubstrate } from "../page/network-substrate.js";
8
+ import type { WsInteractiveRegistry } from "../page/ws-interactive.js";
9
+ import type { WorkersRegistry } from "../page/workers.js";
10
+ import type { BrowxBridge } from "../helper/bridge.js";
11
+ import type { Recorder } from "../page/recording.js";
12
+ import type { FeedbackMemory } from "../page/learning.js";
13
+ import type { ClipboardBuffer } from "../page/clipboard.js";
14
+ import type { RouteRegistry } from "../page/routes.js";
15
+ import type { RegionRegistry } from "../page/regions.js";
16
+ import type { EmulationRegistry } from "../page/emulation.js";
17
+ import type { ClockRegistry } from "../page/clock.js";
18
+ import type { SeededRandomRegistry } from "../page/seed-random.js";
19
+ import type { PerfTracingState } from "../page/perf.js";
20
+ import type { CoverageTrackerState } from "../page/coverage.js";
21
+ import type { WedgeTracker } from "./wedge.js";
22
+ import type { SessionMetrics } from "./metrics.js";
23
+ import type { DialogPolicy, DialogPolicyState } from "./dialog.js";
24
+ import type { PermissionPolicy, PermissionPolicyState } from "./permission.js";
25
+ import type { NotificationPolicy, NotificationPolicyState } from "./notification.js";
26
+ import type { FsPickerPolicy, FsPickerPolicyState } from "./fs-picker.js";
27
+ import type { EmulationState as DeviceEmulationState } from "./emulation.js";
28
+ import type { DeviceEmulationState as WebDeviceEmulationState } from "./device-emu.js";
29
+ import type { SecretRegistry } from "../util/secrets.js";
30
+ import type { HarRecorderState, HarStartConfig } from "../page/har.js";
31
+ import type { VideoRecorderState, VideoStartConfig } from "../page/video.js";
32
+ import type { ExtensionRegistry } from "./extensions.js";
33
+ import type { DownloadsRegistry } from "../page/downloads.js";
34
+ import type { ArtifactsRegistry } from "./artifacts.js";
35
+ export type SessionMode = "persistent" | "incognito" | "attached";
36
+ /**
37
+ * RFC 0004 P3 / D3 (ISP). The per-session state is segregated into the role
38
+ * bundles its consumers actually use — engine-core, observation, network, the
39
+ * four page-policy buffers, live + deep emulation, capture/artifact, and the
40
+ * cross-cutting feature concerns — instead of one 40-field record every tool
41
+ * depends on whole. `SessionEntry` stays the composed WHOLE (the intersection of
42
+ * the bundles, declared at the bottom), so no field moves at runtime and the
43
+ * factory keeps building one object; a consumer that reads only `e.refs` /
44
+ * `e.dialog` can depend on `SessionObserveRole` / `SessionPolicyRole` and stop
45
+ * recompiling when an unrelated feature field changes. Per 0004-03 §3.
46
+ */
47
+ /** Engine-core identity + lifecycle. The fields every consumer that touches the
48
+ * live browser handle reads. */
49
+ export interface SessionCore {
50
+ id: string;
51
+ mode: SessionMode;
52
+ session: BrowserSession;
53
+ openedAt: number;
54
+ /** epoch ms of the last `get()` for this id — drives idle-age
55
+ * reaping (`close_sessions({ idleMs })`) at multi-agent scale. */
56
+ lastActivityAt: number;
57
+ /** Profile-name component used at launch (persistent mode only). Recorded
58
+ * so the rebuild path used by `extensions_*` can recompute the same
59
+ * profileDir without re-deriving the spec. Undefined for incognito /
60
+ * attached sessions. */
61
+ launchProfile?: string;
62
+ }
63
+ /** Observation role — the snapshot/find/frames/console reads. */
64
+ export interface SessionObserveRole {
65
+ refs: RefRegistry;
66
+ /** Engine-agnostic snapshot/a11y tree source. Chromium gets the
67
+ * verbatim CDP substrate (Accessibility.getFullAXTree + DOM-walk); firefox /
68
+ * webkit get the page-side Playwright walker. The snapshot / find / extract /
69
+ * text_search / set-of-marks tools and the action-window pre/post deltas mint
70
+ * refs through this seam instead of reaching a raw CDPSession — so they run on
71
+ * any engine, not only chromium. Selected once at session creation
72
+ * (`snapshotSubstrateFor`) so the hot path is a captured-handle delegate. */
73
+ snapshotSubstrate: SnapshotSubstrate;
74
+ /** Engine-agnostic network tap + ActionResult-network-slice source.
75
+ * Chromium gets the verbatim CDP substrate (NetworkBuffer / WsBuffer /
76
+ * NetworkTap / fetchResponseBody); firefox / webkit get the Playwright context-
77
+ * event substrate. The session-wide rings below (`network` / `ws`) ARE this
78
+ * substrate's rings; the action window mints its per-action tap from it and
79
+ * `network_body` fetches through it — so the network tools + the envelope's
80
+ * network slice run on any engine. Selected once at session creation
81
+ * (`networkSubstrateFor`) so the hot path is a captured-handle delegate. */
82
+ networkSubstrate: NetworkSubstrate;
83
+ /** per-session frame ID assignment. `frames_list` mints/looks up
84
+ * stable `fN` IDs from this registry; snapshot/find/action consult it to
85
+ * resolve a `frame` arg back to a Playwright `Frame` handle. */
86
+ frames: FrameRegistry;
87
+ console: ConsoleBuffer;
88
+ }
89
+ /** Network role — the session-wide rings + the engine-selected network substrate
90
+ * and the interactive-WS / workers / route registries. */
91
+ export interface SessionNetworkRole {
92
+ /** session-wide HTTP request ring (`networkSubstrate.http`). */
93
+ network: SessionNetworkRing;
94
+ /** session-wide WebSocket/SSE frame ring (`networkSubstrate.ws`). */
95
+ ws: SessionWsRing;
96
+ /** per-session interactive-WS registry (capability `action`). Lazy:
97
+ * the page-side wrapper is only installed on first `ws_send` /
98
+ * `ws_intercept`. Holds the active interceptor patterns server-side
99
+ * so `unintercept` / `list` answer locally without a page round-trip. */
100
+ wsInteractive: WsInteractiveRegistry;
101
+ /** per-session worker visibility (Web Workers + Service Workers).
102
+ * Holds the page-side `__browxWorkers` wrapper state + the CDP-side SW
103
+ * attachments. Lazy in the same shape as `wsInteractive` — eagerly
104
+ * installed at session creation when `read` is on so workers opened by
105
+ * the initial document are seen; otherwise the wrapper installs on first
106
+ * `workers_list` / `worker_message_send` / `sw_intercept_fetch` call. */
107
+ workers: WorkersRegistry;
108
+ /** per-session network route interceptions (capability `action`). */
109
+ routes: RouteRegistry;
110
+ }
111
+ /** Feature role — the cross-cutting per-session services a handler reaches for
112
+ * one feature at a time (the helper bridge, the recorder, learning feedback,
113
+ * the clipboard model, and the named-region store). */
114
+ export interface SessionFeatureRole {
115
+ bridge: BrowxBridge;
116
+ recorder: Recorder;
117
+ feedback: FeedbackMemory;
118
+ /** per-session clipboard model (capability `clipboard`). Isolated so
119
+ * concurrent sessions don't clobber each other through the shared OS
120
+ * clipboard; the OS clipboard is touched only transactionally. */
121
+ clipboard: ClipboardBuffer;
122
+ /** per-session named visual regions (capability `human`). */
123
+ regions: RegionRegistry;
124
+ }
125
+ /** Live-emulation role — the runtime knobs that re-apply on navigation
126
+ * (network/CPU throttling, virtual clock, seeded randomness). */
127
+ export interface SessionEmulationRole {
128
+ /** per-session network + CPU emulation overrides (capability `action`).
129
+ * Caches active state and re-applies on main-frame navigation. */
130
+ emulation: EmulationRegistry;
131
+ /** per-session virtual-time clock controller (capability `action`).
132
+ * Wraps CDP `Emulation.setVirtualTimePolicy` for deterministic
133
+ * date-sensitive testing; re-applies on main-frame navigation. */
134
+ clock: ClockRegistry;
135
+ /** per-session seeded `Math.random` override (capability `action`). Init
136
+ * script wraps Mulberry32 so date / pick-randomly / id-gen flake repros
137
+ * are deterministic. Per-session; `crypto.randomUUID` /
138
+ * `crypto.getRandomValues` NOT touched in MVP. */
139
+ seededRandom: SeededRandomRegistry;
140
+ }
141
+ /** Deep role — the CDP-deep tracing/coverage state the `perf_*` / `coverage_*`
142
+ * tools drive (Chromium-only). */
143
+ export interface SessionDeepRole {
144
+ /** per-session CDP performance tracing state (capability `action`). One
145
+ * trace lifecycle at a time per session; `perf_start` while a trace is
146
+ * already running cleanly restarts (see src/page/perf.ts). */
147
+ perf: PerfTracingState;
148
+ /** per-session CDP precise-coverage tracker (capability split — `coverage_start`
149
+ * is `action`, `coverage_stop` is `read`). Pairs JS Profiler + CSS rule
150
+ * usage trackers into one lifecycle. Internally used by `perf_audit`. */
151
+ coverage: CoverageTrackerState;
152
+ }
153
+ /** Health role — the per-session anti-wedge + metrics bookkeeping the dispatch
154
+ * wrapper accumulates. */
155
+ export interface SessionHealthRole {
156
+ /** Per-session consecutive anti-wedge-timeout counter; drives the
157
+ * `sessionWedged` signal once the session times out repeatedly. */
158
+ wedge: WedgeTracker;
159
+ /** Per-session cumulative tool-call metrics (counts, latency,
160
+ * tokensEstimate sum, capability denials, errors). Accumulated by the
161
+ * dispatch wrapper in `server.ts`; surfaced via the `session_metrics`
162
+ * tool. Read-only from the agent's side — no per-call disk writes. */
163
+ metrics: SessionMetrics;
164
+ }
165
+ /** Policy role — the four page-policy buffers (dialog / permission / notification
166
+ * / fs-picker) a handler reads or mutates together. */
167
+ export interface SessionPolicyRole {
168
+ /** per-session dialog policy + per-page handler bookkeeping. Survives
169
+ * navigation: the `context.on('page')` install re-attaches the handler on
170
+ * every new page (capability `action` — no separate capability). */
171
+ dialog: DialogPolicyState;
172
+ /** per-session permission policy + per-context binding/init-script
173
+ * bookkeeping. Sibling of `dialog`: governs camera/microphone/geolocation/
174
+ * clipboard/notification/sensor permission requests fired from the page.
175
+ * Default `raise` (deterministic anti-deadlock). Mutable at runtime via
176
+ * `set_permission_policy`; persists across navigation (init-script is
177
+ * re-injected on every new document). Capability `action`. */
178
+ permission: PermissionPolicyState;
179
+ /** per-session notification policy + per-context binding/init-script
180
+ * bookkeeping. Sibling of `permission`: governs `new Notification(...)`
181
+ * *constructor* calls (the page actually attempting to notify the human).
182
+ * Distinct from `permission.notifications` — that gates the W3C permission
183
+ * check (`Notification.requestPermission` + `Notification.permission`),
184
+ * this gates the constructor surface. The two policies compose. Default
185
+ * `allow` (browser default — most apps expect the constructor to succeed).
186
+ * Mutable at runtime via `set_notification_policy`; persists across
187
+ * navigation. Capability `action`. */
188
+ notification: NotificationPolicyState;
189
+ /** per-session File System Access picker policy + per-context binding /
190
+ * init-script bookkeeping. Sibling of `dialog` / `permission`: governs
191
+ * `showOpenFilePicker` / `showSaveFilePicker` / `showDirectoryPicker`
192
+ * calls fired from the page. Default `raise` (deterministic anti-
193
+ * deadlock — without a policy, headless sessions deadlock on the picker
194
+ * dialog that has no driver). Mutable at runtime via
195
+ * `set_fs_picker_policy`; persists across navigation (init-script is
196
+ * re-injected on every new document). Capability `action` for the
197
+ * policy mutators; `file-io` for `fs_picker_respond`. */
198
+ fsPicker: FsPickerPolicyState;
199
+ }
200
+ /** Device-emulation role — the per-primitive live-emulation state + the synthetic
201
+ * Web Bluetooth/USB/HID device catalogs. */
202
+ export interface SessionDeviceRole {
203
+ /** Per-primitive runtime device-emulation state (locale, timezone,
204
+ * geolocation, colour scheme, reduced motion, user-agent, permissions).
205
+ * Mutated by the 7 `set_*` / `grant_permissions` tools and re-applied
206
+ * when a new page opens in the context. Distinct from `emulation`
207
+ * (which holds network/cpu throttling state). */
208
+ deviceEmulation: DeviceEmulationState;
209
+ /** Per-session Web Bluetooth / WebUSB / WebHID device-catalog state. Off
210
+ * by default — empty catalogs until `emulate_bluetooth` / `emulate_usb`
211
+ * / `emulate_hid` populate them. Capability `device-emulation`. When
212
+ * the capability is off, the page-side wrappers still install (so the
213
+ * default user-dismissed-picker shape is delivered without a deadlock
214
+ * on headless), but the check binding short-circuits to `refused`. */
215
+ webDeviceEmulation: WebDeviceEmulationState;
216
+ }
217
+ /** Capture role — the artifact-egress + sensitive-data state: HAR / video
218
+ * recorders, the secrets registry, loaded extensions, and the download /
219
+ * artifact stores. */
220
+ export interface SessionCaptureRole {
221
+ /** Per-session HAR recorder state (HTTP Archive record/replay). Drives the
222
+ * `start_har`/`stop_har` tools and tracks any HAR wired at session creation
223
+ * via `open_session({har})`. Capability `action` (writes a file). The HAR
224
+ * file is finalized by Playwright on `context.close()` — the recorder state
225
+ * carries the reserved path until then. */
226
+ har: HarRecorderState;
227
+ /** Per-session video recorder state. Drives the `stop_video` / `get_video`
228
+ * tools and tracks any video wired at session creation via
229
+ * `open_session({recordVideo})`. Same finalize-on-close caveat as HAR:
230
+ * Playwright writes the .webm only when the context closes; the
231
+ * registry's teardown calls `page.video().saveAs(targetPath)` for a
232
+ * deterministic output filename. Capability `file-io` (writes a file). */
233
+ video: VideoRecorderState;
234
+ /** per-session sensitive-data registry (capability `secrets`). Off by
235
+ * default — empty until `register_secret` is called. When non-empty, every
236
+ * egress sink masks occurrences of the real value back to `<NAME>` before
237
+ * emitting; `fill`/`press` materialise `<NAME>` to the real value at
238
+ * dispatch. The registry is per-session so concurrent sessions don't share
239
+ * an auth-flow's secrets. */
240
+ secrets: SecretRegistry;
241
+ /** per-session loaded Chrome extensions (capability `extensions`). Empty
242
+ * by default; mutated by `extensions_install` / `extensions_reload` /
243
+ * `extensions_uninstall`. The list also drives the launch flags
244
+ * (`--load-extension`, `--disable-extensions-except`) when the underlying
245
+ * browser context is (re)built — extensions are a launch-time concern in
246
+ * Chromium. Persistent (headed) sessions only — `incognito` / `attached`
247
+ * reject the mutators with a structured error. */
248
+ extensions: ExtensionRegistry;
249
+ /** per-session download-capture registry (capability `file-io`). Off by
250
+ * default — every Playwright `download` event is intercepted and discarded
251
+ * until `downloads_capture({on:true})` toggles capture on. When on, the
252
+ * artifact is persisted to `$BROWX_WORKSPACE/.downloads/<sessionId>/` and
253
+ * surfaced on `ActionResult.downloads[]`. Same posture as `upload_file`'s
254
+ * workspace-rooted-paths model — the reverse direction. */
255
+ downloads: DownloadsRegistry;
256
+ /** per-session artifact KV (capabilities `action` for save, `read` for
257
+ * get/list). Workspace-rooted at `$BROWX_WORKSPACE/.artifacts/<sessionId>/`.
258
+ * Capacity-bounded (200 entries / 50 MiB; oldest-write evicted past the
259
+ * cap). The on-disk dir is wiped on session teardown — sessions that
260
+ * never wrote an artifact leave no trace. */
261
+ artifacts: ArtifactsRegistry;
262
+ }
263
+ /** Per-session state. Everything here was a server-singleton pre-multi-session;
264
+ * one of these exists per live session id. Composed (RFC 0004 P3 / D3) as the
265
+ * INTERSECTION of the role bundles above — no field moved at runtime; a consumer
266
+ * may depend on the narrow role it reads (e.g. `SessionPolicyRole`) instead of
267
+ * the whole record. The factory in server.ts still builds one object. */
268
+ export interface SessionEntry extends SessionCore, SessionObserveRole, SessionNetworkRole, SessionFeatureRole, SessionEmulationRole, SessionDeepRole, SessionHealthRole, SessionPolicyRole, SessionDeviceRole, SessionCaptureRole {
269
+ }
270
+ export declare const DEFAULT_SESSION_ID = "default";
271
+ /** Per-session creation spec, supplied by `open_session` (or undefined for the
272
+ * lazily-created default, which falls back to the server's launch mode). */
273
+ export interface OpenSpec {
274
+ mode?: SessionMode;
275
+ /** Persistent mode only: named profile dir under the workspace. */
276
+ profile?: string;
277
+ /** Playwright device-preset name (e.g. "iPhone 14"). */
278
+ device?: string;
279
+ /** explicit viewport; overrides a preset's viewport. */
280
+ viewport?: {
281
+ width: number;
282
+ height: number;
283
+ };
284
+ /** initial dialog policy for this session (default `{mode:"raise"}`).
285
+ * Mutable at runtime via `set_dialog_policy`; see src/session/dialog.ts. */
286
+ dialogPolicy?: DialogPolicy;
287
+ /** initial permission policy for this session (default `{mode:"raise"}`).
288
+ * Mutable at runtime via `set_permission_policy`; see
289
+ * src/session/permission.ts. */
290
+ permissionPolicy?: PermissionPolicy;
291
+ /** initial notification policy for this session (default `{mode:"allow"}`).
292
+ * Governs `new Notification(...)` constructor calls (distinct from the
293
+ * permission check, which lives in `permissionPolicy.notifications`).
294
+ * Mutable at runtime via `set_notification_policy`; see
295
+ * src/session/notification.ts. */
296
+ notificationPolicy?: NotificationPolicy;
297
+ /** initial File System Access picker policy for this session (default
298
+ * `{mode:"raise"}`). Mutable at runtime via `set_fs_picker_policy`;
299
+ * see src/session/fs-picker.ts. */
300
+ fsPickerPolicy?: FsPickerPolicy;
301
+ /** Seed the new context's storage state at creation (bulk layer).
302
+ * Either an inline blob (as returned by `dump_storage_state`) or a
303
+ * workspace-rooted JSON path. Mutually exclusive with `authState`.
304
+ * See `src/session/storage.ts` for the per-mode semantics
305
+ * (incognito: native primitive; managed: post-create + clears profile;
306
+ * attached: ignored). */
307
+ storageState?: import("./storage.js").StorageStateBlob | string;
308
+ /** Seed the new context's storage state at creation from a named slot
309
+ * (`$BROWX_WORKSPACE/.auth-states/<name>.json`, written by `auth_save`).
310
+ * Mutually exclusive with `storageState`. */
311
+ authState?: string;
312
+ /** Enable HAR recording at context creation (native Playwright `recordHar`).
313
+ * The HAR is finalized when the session closes. For mid-session start/stop
314
+ * use the `start_har`/`stop_har` tools instead — they wire HAR via
315
+ * `routeFromHAR(update:true)` on the running context. */
316
+ har?: HarStartConfig;
317
+ /** Enable video recording at context creation via Playwright's native
318
+ * `recordVideo` context option. The .webm is finalized when the session
319
+ * closes. There is no runtime `start_video` tool (Playwright doesn't
320
+ * expose a mid-context start) — wire it here at session creation. The
321
+ * target path is workspace-rooted (default
322
+ * `<workspace>/videos/<session-id>-<ISO>.webm`); on `close_session` the
323
+ * registry calls `page.video().saveAs(targetPath)` for a deterministic
324
+ * filename. Honoured on `persistent` + `incognito`; refused on
325
+ * `attached` (not-owned). */
326
+ recordVideo?: VideoStartConfig;
327
+ /** Workspace-rooted HAR file path(s) to REPLAY against this session. Each
328
+ * file is wired post-create with `context.routeFromHAR(file,
329
+ * {notFound:"fallback"})` — requests in the archive are served from it,
330
+ * anything missing falls through to the live network. */
331
+ hars?: string[];
332
+ }
333
+ export declare class SessionRegistry {
334
+ private factory;
335
+ private teardown;
336
+ private entries;
337
+ /** In-flight creations, so two concurrent first-calls for the same id don't
338
+ * each launch a browser. */
339
+ private creating;
340
+ constructor(factory: (id: string, spec?: OpenSpec) => Promise<SessionEntry>, teardown: (e: SessionEntry) => Promise<void>);
341
+ /** Resolve (or lazily create) the entry for `id`. Concurrency-safe. The
342
+ * `spec` is only consulted on creation — once an entry exists it's returned
343
+ * as-is regardless of spec. */
344
+ get(id?: string, spec?: OpenSpec): Promise<SessionEntry>;
345
+ has(id: string): boolean;
346
+ /** Non-creating peek — returns undefined if not yet open. */
347
+ peek(id: string): SessionEntry | undefined;
348
+ list(): SessionEntry[];
349
+ /** Tear down + remove one session. Returns false if it wasn't open. */
350
+ close(id: string): Promise<boolean>;
351
+ /**
352
+ * bulk teardown. Selects live sessions by `prefix` (id starts-with),
353
+ * `all`, and/or `idleMs` (no `get()` in the last N ms). Filters AND together
354
+ * when multiple are given; at least one selector is required. Returns the
355
+ * closed ids (in selection order). The team-lead reap primitive — at
356
+ * multi-agent scale a wedged/killed agent strands sessions.
357
+ */
358
+ closeMatching(sel: {
359
+ prefix?: string;
360
+ all?: boolean;
361
+ idleMs?: number;
362
+ }): Promise<string[]>;
363
+ /** Tear down everything (server shutdown). */
364
+ closeAll(): Promise<void>;
365
+ }