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,145 @@
1
+ import type { Locator } from "playwright-core";
2
+ import type { EngineKind, EngineCapabilities } from "./types.js";
3
+ import { engineCapabilities } from "./capability-registry.js";
4
+ import type { BrowserSession, SessionOptions } from "../session/types.js";
5
+ import type { SessionEntry } from "../session/registry.js";
6
+ import type { ActionSubstrate } from "../page/action-substrate.js";
7
+ import type { CaptureSubstrate } from "../page/capture-substrate.js";
8
+ import type { StorageSubstrate } from "../page/storage-substrate.js";
9
+ import type { ScriptSubstrate } from "../page/script-substrate.js";
10
+ import type { EmulationSubstrate } from "../page/emulation-substrate.js";
11
+ import type { SnapshotSubstrate } from "../page/snapshot-substrate.js";
12
+ import type { NetworkSubstrate } from "../page/network-substrate.js";
13
+ import type { ActionContext } from "../page/actionresult.js";
14
+ import type { RefRegistry } from "../page/refs.js";
15
+ import type { ScreenshotSaveResult } from "../page/screenshot-save.js";
16
+ import type { CapabilityConfig } from "../util/capabilities.js";
17
+ import type { ConfigStore } from "../util/config-store.js";
18
+ import type { Workspace } from "../util/workspace.js";
19
+ /** The per-capability substrate set a session is wired with. The five
20
+ * `host-build.ts` selectors (actionsFor / captureFor / storageFor / scriptFor /
21
+ * emulationFor) collapse into producing one of these, and so do the two
22
+ * standalone `*-substrate-select.ts` files (`snapshotSubstrateFor` /
23
+ * `networkSubstrateFor`) — the engine owns the Safari-vs-Playwright-vs-CDP
24
+ * choice once, expressed here, so no engine-name dispatch survives above the
25
+ * seam. Each field is a `(e) => Substrate` selector: the engine handle is
26
+ * captured per-session from the `SessionEntry`, so the per-call surface carries
27
+ * no engine type. (0004-03 §1.) */
28
+ export interface SubstrateBundle {
29
+ actions: (e: SessionEntry) => ActionSubstrate;
30
+ capture: (e: SessionEntry) => CaptureSubstrate;
31
+ storage: (e: SessionEntry) => StorageSubstrate;
32
+ script: (e: SessionEntry) => ScriptSubstrate;
33
+ emulation: (e: SessionEntry) => EmulationSubstrate;
34
+ snapshot: (e: SessionEntry) => SnapshotSubstrate;
35
+ network: (e: SessionEntry) => NetworkSubstrate;
36
+ }
37
+ /** The per-server host config the `makeSubstrates` factory needs — the exact
38
+ * `ctxFor` + `describeTarget` + screenshot-`save` dependencies host-build supplied
39
+ * inline before the fold. These CLOSE OVER server-scoped security boundaries
40
+ * (`ctxFor` carries the server's originPolicy / config.testAttributes / caps
41
+ * gating; `save` writes under the server's `workspace.root`), so the composition
42
+ * root threads its OWN per-server set at the `makeSubstrates(deps)` call site —
43
+ * never a module-global, which would let a second `createServer()` in the same
44
+ * process overwrite the first server's boundary (the in-process SDK transport
45
+ * composes one server per transport). Threading explicitly keeps each server's
46
+ * substrates bound to ITS deps, so cross-server contamination is impossible. */
47
+ export interface SubstrateDeps {
48
+ /** Build the `ActionContext` for an action dispatch — the verbatim `ctxFor`
49
+ * closure from host-build (it closes over the server's config/originPolicy/caps). */
50
+ ctxFor: (e: SessionEntry) => ActionContext;
51
+ /** The structured one-liner alongside an element screenshot. */
52
+ describeTarget: (loc: Locator, refs: RefRegistry, target: {
53
+ ref: string;
54
+ } | {
55
+ selector: string;
56
+ } | {
57
+ coords: {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ }) => Promise<string>;
62
+ /** Persist a screenshot buffer to the server's workspace-rooted path. */
63
+ save: (buf: Buffer, args: {
64
+ path: string;
65
+ format: "png" | "jpeg";
66
+ fullPage: boolean;
67
+ }) => ScreenshotSaveResult;
68
+ }
69
+ /** The per-server host config the `postWire` step needs — the same locals
70
+ * `buildSessionRegistry` owns. These too are server-scoped (`caps` is the
71
+ * server's capability gate, `workspace.root` its sandbox write-root), so the
72
+ * composition root threads its OWN set at the `postWire(entry, deps)` call site
73
+ * rather than a module-global: a second server with different caps/workspace must
74
+ * never reach across and wire THIS server's sessions. */
75
+ export interface PostWireDeps {
76
+ caps: CapabilityConfig;
77
+ configStore: ConfigStore;
78
+ workspace: Workspace;
79
+ }
80
+ /** Everything the session layer needs from an engine, declared once in the
81
+ * engine's own adapter-registration module. Adding an engine = a new module
82
+ * that calls `registerEngine(record)` once; no edit to any session factory, the
83
+ * session registry, or host-build. This is the single `EngineEntry` shape the
84
+ * whole RFC 0004 suite standardizes on (0004-03 §1) — over the real session
85
+ * types, not placeholders. */
86
+ export interface EngineEntry {
87
+ readonly kind: EngineKind;
88
+ /** The static capability declaration (deep / sub-interfaces) — today this is
89
+ * `capabilitiesFor(kind)`; the registry makes the adapter the owner of its
90
+ * own row, not a central table. */
91
+ readonly capabilities: EngineCapabilities;
92
+ /** Launch + return the lifecycle session for one of the session modes. Subsumes
93
+ * the per-engine launch/attach branching the three session factories carried;
94
+ * the factories keep only their MODE concern (the launch mode is threaded
95
+ * through `opts.launchMode`, defaulting to managed). */
96
+ makeAdapter(opts: SessionOptions): Promise<BrowserSession>;
97
+ /** Build the per-capability substrate selectors for a session of this engine.
98
+ * Subsumes the five host-build.ts selectors + the two standalone selectors —
99
+ * the Safari-vs-Playwright-vs-CDP choice is the engine's own concern. The
100
+ * composition root passes its OWN per-server `SubstrateDeps` (originPolicy /
101
+ * workspace / caps / ctxFor, threaded explicitly — NOT a module-global —
102
+ * precisely to preserve per-server isolation when two servers share a process). */
103
+ makeSubstrates(deps: SubstrateDeps): SubstrateBundle;
104
+ /** Post-creation wiring previously scattered as `sess.engine !== "safari"`
105
+ * guards across session-registry.ts — now owned by the engine that needs it.
106
+ * The four Playwright engines attach the full console/bridge/policy/download/
107
+ * stealth/device-emulation/ws-interactive/workers set; Safari attaches only its
108
+ * BiDi console bridge (and the synthetic in-memory engine attaches nothing).
109
+ *
110
+ * Takes the composition root's OWN per-server `PostWireDeps` (caps / configStore
111
+ * / workspace) — threaded explicitly at the call site, NOT read from a
112
+ * module-global, so a second server in the same process can never wire THIS
113
+ * server's sessions with its capabilities or sandbox root.
114
+ *
115
+ * Returns `void` OR a `Promise<void>`: the four Playwright engines AWAIT their
116
+ * context attaches (so the session is fully wired before the factory returns it,
117
+ * byte-identical to the pre-relocation inline awaits), while the no-op engines
118
+ * return sync `void`. The session factory `await`s the result. */
119
+ postWire(entry: SessionEntry, deps: PostWireDeps): void | Promise<void>;
120
+ }
121
+ /** Add-only registration. Called once per adapter-registration module at module
122
+ * load. A sixth engine is a sixth `registerEngine(...)` call in a new file — no
123
+ * edit here. Re-registering an engine is a programming error, surfaced loudly so
124
+ * a duplicate (e.g. a double-imported barrel) never silently shadows. */
125
+ export declare function registerEngine(def: EngineEntry): void;
126
+ /** The data-driven lookup the factories / selectors / post-wire call. Throws the
127
+ * same structured `EngineNotYetSupportedError` the engine-select path does — a
128
+ * declared-but-unregistered engine is a refusal, never a silent default. The
129
+ * session-mode dispatch stays in the factories; the registry resolves only the
130
+ * ENGINE. */
131
+ export declare function engineEntry(kind: EngineKind): EngineEntry;
132
+ /** Whether an engine has a registered entry. Lets a caller branch on
133
+ * registration presence (e.g. a test) without forcing the throw. */
134
+ export declare function hasEngine(kind: EngineKind): boolean;
135
+ /** Non-throwing capability lookup — re-exported from the decoupled capability
136
+ * side-table (`capability-registry.ts`) so callers can import it from the registry
137
+ * surface. The gate imports it from the side-table directly to avoid a cycle. */
138
+ export { engineCapabilities };
139
+ /** Whether an engine's BYOB/attach lane requires an explicit `BROWX_ATTACH_CDP`
140
+ * endpoint. Android attach is endpoint-DISCOVERED over adb (no endpoint needed);
141
+ * every other engine's CDP-attach lane requires the loopback endpoint. The
142
+ * session registry consults this so its attached-mode precondition stays
143
+ * engine-agnostic (the one android-specific fact lives here, in the engine layer,
144
+ * not as a literal branch in the session registry). */
145
+ export declare function byobAttachNeedsEndpoint(kind: EngineKind): boolean;
@@ -0,0 +1,67 @@
1
+ // The EngineRegistry (RFC 0004 D1) — the one place an engine's name appears as
2
+ // data. Each engine registers a single `EngineEntry` record (in its own
3
+ // adapters/<engine>.engine.ts module); the session factories, the substrate
4
+ // selection, and the post-creation wiring then resolve everything by a
5
+ // data-driven lookup keyed on `session.engine` — no `if (engine === "literal")`
6
+ // branch survives above the seam.
7
+ //
8
+ // This realizes architecture-principles §4 ("new engine = new adapter behind the
9
+ // existing port"): a sixth engine is a sixth `registerEngine(...)` call in a new
10
+ // file, with no edit to managed.ts / incognito.ts / byob.ts / session-registry.ts
11
+ // / host-build.ts. The strangler-fig discipline (RFC 0004 §1.2): the registry is
12
+ // a pure indirection over the SAME adapter instances + the SAME post-wire steps
13
+ // the if-chains drove, so each engine's observable session is byte-identical —
14
+ // only the dispatch MECHANISM changes.
15
+ import { invariant } from "../util/invariant.js";
16
+ import { EngineNotYetSupportedError } from "./select.js";
17
+ import { setEngineCapabilities, engineCapabilities } from "./capability-registry.js";
18
+ const REGISTRY = new Map();
19
+ /** Add-only registration. Called once per adapter-registration module at module
20
+ * load. A sixth engine is a sixth `registerEngine(...)` call in a new file — no
21
+ * edit here. Re-registering an engine is a programming error, surfaced loudly so
22
+ * a duplicate (e.g. a double-imported barrel) never silently shadows. */
23
+ export function registerEngine(def) {
24
+ // L8: the record's own `kind` must match the capability row's `engine` — the
25
+ // registry keys on `def.kind` while the gate reads `def.capabilities.engine`,
26
+ // so a mismatch would silently gate the wrong engine. Each adapter module
27
+ // already wires `{ kind: K, capabilities: capabilitiesFor(K) }`, so this holds
28
+ // on every valid registration; the invariant catches a copy-paste swap at
29
+ // module load, not in production.
30
+ invariant(def.kind === def.capabilities.engine, `engine "${def.kind}" registered with capabilities for "${def.capabilities.engine}"`);
31
+ if (REGISTRY.has(def.kind)) {
32
+ throw new Error(`engine-registry: "${def.kind}" registered twice`);
33
+ }
34
+ REGISTRY.set(def.kind, def);
35
+ // Mirror the capability declaration into the decoupled side-table so the engine
36
+ // gate can read it without importing this module (which would form a cycle).
37
+ setEngineCapabilities(def.kind, def.capabilities);
38
+ }
39
+ /** The data-driven lookup the factories / selectors / post-wire call. Throws the
40
+ * same structured `EngineNotYetSupportedError` the engine-select path does — a
41
+ * declared-but-unregistered engine is a refusal, never a silent default. The
42
+ * session-mode dispatch stays in the factories; the registry resolves only the
43
+ * ENGINE. */
44
+ export function engineEntry(kind) {
45
+ const def = REGISTRY.get(kind);
46
+ if (!def)
47
+ throw new EngineNotYetSupportedError(kind);
48
+ return def;
49
+ }
50
+ /** Whether an engine has a registered entry. Lets a caller branch on
51
+ * registration presence (e.g. a test) without forcing the throw. */
52
+ export function hasEngine(kind) {
53
+ return REGISTRY.has(kind);
54
+ }
55
+ /** Non-throwing capability lookup — re-exported from the decoupled capability
56
+ * side-table (`capability-registry.ts`) so callers can import it from the registry
57
+ * surface. The gate imports it from the side-table directly to avoid a cycle. */
58
+ export { engineCapabilities };
59
+ /** Whether an engine's BYOB/attach lane requires an explicit `BROWX_ATTACH_CDP`
60
+ * endpoint. Android attach is endpoint-DISCOVERED over adb (no endpoint needed);
61
+ * every other engine's CDP-attach lane requires the loopback endpoint. The
62
+ * session registry consults this so its attached-mode precondition stays
63
+ * engine-agnostic (the one android-specific fact lives here, in the engine layer,
64
+ * not as a literal branch in the session registry). */
65
+ export function byobAttachNeedsEndpoint(kind) {
66
+ return kind !== "android";
67
+ }
@@ -0,0 +1,48 @@
1
+ import { type BrowserType } from "playwright-core";
2
+ import type { EngineKind } from "./types.js";
3
+ /** Engines wired today. Chromium + Firefox (Playwright's bundled Juggler build)
4
+ * + WebKit (Playwright's bundled WebKit build — the WebKit-ENGINE correctness
5
+ * lane, NOT Safari) + Android (real Chrome-on-Android attached over adb + CDP —
6
+ * full CDP, `deep: true`) + Safari (REAL Safari.app over safaridriver — the
7
+ * first non-Playwright engine, no Playwright Page, curated subset). All five
8
+ * `EngineKind` members are implemented; the no-silent-no-op selection error
9
+ * remains for any future engine declared before its adapter lands. */
10
+ export declare const IMPLEMENTED_ENGINES: readonly EngineKind[];
11
+ export declare class EngineNotYetSupportedError extends Error {
12
+ readonly engine: EngineKind;
13
+ constructor(engine: EngineKind);
14
+ }
15
+ /** Map an `EngineKind` to the Playwright `BrowserType` that drives it. Throws
16
+ * `EngineNotYetSupportedError` for engines without an adapter yet. The mapping
17
+ * is `playwright[browserType]` — the same surface every Playwright client
18
+ * selects on. */
19
+ export declare function resolveBrowserType(engine: EngineKind): BrowserType;
20
+ /** Raised when the operator names an engine that browxai does not implement —
21
+ * the top-level `BROWX_ENGINE` / `--engine` validation error. Distinct from
22
+ * `EngineNotYetSupportedError` (which guards a *declared-but-unadaptered*
23
+ * `EngineKind` at the launch path): this one fires on an arbitrary operator
24
+ * string (a typo, an unsupported browser, …) that is not even a known engine,
25
+ * BEFORE the server starts. The message lists the implemented engines so the fix
26
+ * is in the error. */
27
+ export declare class UnknownEngineError extends Error {
28
+ readonly value: string;
29
+ constructor(value: string);
30
+ }
31
+ /** Validate an operator-supplied engine string against `IMPLEMENTED_ENGINES`.
32
+ * Returns the value narrowed to `EngineKind` on success; throws
33
+ * `UnknownEngineError` (structured, listing the valid engines) otherwise. The
34
+ * comparison is exact + case-sensitive: engine kinds are lowercase tokens, and
35
+ * silently accepting `Firefox`/`FIREFOX` would mask a misconfiguration. */
36
+ export declare function validateEngine(value: string): EngineKind;
37
+ /** Resolve the operator's engine selection for the MCP server. Precedence:
38
+ * an explicit `--engine <kind>` CLI flag wins over the `BROWX_ENGINE` env var,
39
+ * which wins over the default `chromium`. Both inputs are validated against
40
+ * `IMPLEMENTED_ENGINES`; an unknown value throws `UnknownEngineError`. Returns
41
+ * `undefined` when neither is set, so the caller can omit `browserType` and let
42
+ * `server.ts` apply its own default (byte-identical to never passing the option).
43
+ *
44
+ * Pure over (argv, env) so it unit-tests without a browser. Mirrors the inline
45
+ * env/flag idiom the rest of cli.ts uses (BROWX_HEADLESS, BROWX_ATTACH_CDP),
46
+ * lifted into a function only because it carries validation + precedence worth
47
+ * testing in isolation. */
48
+ export declare function resolveEngineSelection(argv: readonly string[], env?: NodeJS.ProcessEnv): EngineKind | undefined;
@@ -0,0 +1,128 @@
1
+ // Engine selection. The launch path resolves an `EngineKind` to a Playwright
2
+ // browser-type and rejects the not-yet-implemented engines with a structured
3
+ // error — the doctrine's no-silent-no-op rule: an unsupported engine must fail
4
+ // loudly, naming the engines that are available, not quietly fall back to
5
+ // Chromium.
6
+ import { chromium, firefox, webkit } from "playwright-core";
7
+ // `android` resolves to Playwright's `chromium` BrowserType — Chrome-on-Android
8
+ // speaks full CDP, so the adapter attaches with `chromium.connectOverCDP(wsUrl)`
9
+ // over an adb-forwarded socket, reusing the exact Chromium transport.
10
+ // `safari` has NO entry: it is the first non-Playwright engine (driven over
11
+ // safaridriver, not a Playwright BrowserType), so `resolveBrowserType` is never
12
+ // the path for it — the SafaridriverHybridAdapter owns its own transport. The map
13
+ // is `Partial` to make that explicit at the type level.
14
+ const BROWSER_TYPES = {
15
+ chromium,
16
+ firefox,
17
+ webkit,
18
+ android: chromium,
19
+ };
20
+ /** Engines wired today. Chromium + Firefox (Playwright's bundled Juggler build)
21
+ * + WebKit (Playwright's bundled WebKit build — the WebKit-ENGINE correctness
22
+ * lane, NOT Safari) + Android (real Chrome-on-Android attached over adb + CDP —
23
+ * full CDP, `deep: true`) + Safari (REAL Safari.app over safaridriver — the
24
+ * first non-Playwright engine, no Playwright Page, curated subset). All five
25
+ * `EngineKind` members are implemented; the no-silent-no-op selection error
26
+ * remains for any future engine declared before its adapter lands. */
27
+ export const IMPLEMENTED_ENGINES = [
28
+ "chromium",
29
+ "firefox",
30
+ "webkit",
31
+ "android",
32
+ "safari",
33
+ ];
34
+ export class EngineNotYetSupportedError extends Error {
35
+ engine;
36
+ constructor(engine) {
37
+ super(`engine-not-yet-supported: "${engine}" is declared but not yet implemented — ` +
38
+ "chromium, firefox, webkit, android, and safari are wired today. " +
39
+ 'Use browserType:"chromium" (the default), "firefox", "webkit", "android", or "safari".');
40
+ this.name = "EngineNotYetSupportedError";
41
+ this.engine = engine;
42
+ }
43
+ }
44
+ /** Map an `EngineKind` to the Playwright `BrowserType` that drives it. Throws
45
+ * `EngineNotYetSupportedError` for engines without an adapter yet. The mapping
46
+ * is `playwright[browserType]` — the same surface every Playwright client
47
+ * selects on. */
48
+ export function resolveBrowserType(engine) {
49
+ if (!IMPLEMENTED_ENGINES.includes(engine)) {
50
+ throw new EngineNotYetSupportedError(engine);
51
+ }
52
+ // chromium + firefox + webkit + android all reach here today (android maps to
53
+ // the chromium BrowserType — it attaches to real Chrome-on-Android over CDP).
54
+ // safari has no Playwright BrowserType (it is driven over safaridriver), so it
55
+ // is not in BROWSER_TYPES — the guard keeps this total without a fake mapping.
56
+ const browserType = BROWSER_TYPES[engine];
57
+ if (!browserType) {
58
+ throw new EngineNotYetSupportedError(engine);
59
+ }
60
+ return browserType;
61
+ }
62
+ /** Raised when the operator names an engine that browxai does not implement —
63
+ * the top-level `BROWX_ENGINE` / `--engine` validation error. Distinct from
64
+ * `EngineNotYetSupportedError` (which guards a *declared-but-unadaptered*
65
+ * `EngineKind` at the launch path): this one fires on an arbitrary operator
66
+ * string (a typo, an unsupported browser, …) that is not even a known engine,
67
+ * BEFORE the server starts. The message lists the implemented engines so the fix
68
+ * is in the error. */
69
+ export class UnknownEngineError extends Error {
70
+ value;
71
+ constructor(value) {
72
+ super(`engine "${value}" is not available; implemented engines: ${IMPLEMENTED_ENGINES.join(", ")}`);
73
+ this.name = "UnknownEngineError";
74
+ this.value = value;
75
+ }
76
+ }
77
+ /** Validate an operator-supplied engine string against `IMPLEMENTED_ENGINES`.
78
+ * Returns the value narrowed to `EngineKind` on success; throws
79
+ * `UnknownEngineError` (structured, listing the valid engines) otherwise. The
80
+ * comparison is exact + case-sensitive: engine kinds are lowercase tokens, and
81
+ * silently accepting `Firefox`/`FIREFOX` would mask a misconfiguration. */
82
+ export function validateEngine(value) {
83
+ if (IMPLEMENTED_ENGINES.includes(value)) {
84
+ return value;
85
+ }
86
+ throw new UnknownEngineError(value);
87
+ }
88
+ /** Resolve the operator's engine selection for the MCP server. Precedence:
89
+ * an explicit `--engine <kind>` CLI flag wins over the `BROWX_ENGINE` env var,
90
+ * which wins over the default `chromium`. Both inputs are validated against
91
+ * `IMPLEMENTED_ENGINES`; an unknown value throws `UnknownEngineError`. Returns
92
+ * `undefined` when neither is set, so the caller can omit `browserType` and let
93
+ * `server.ts` apply its own default (byte-identical to never passing the option).
94
+ *
95
+ * Pure over (argv, env) so it unit-tests without a browser. Mirrors the inline
96
+ * env/flag idiom the rest of cli.ts uses (BROWX_HEADLESS, BROWX_ATTACH_CDP),
97
+ * lifted into a function only because it carries validation + precedence worth
98
+ * testing in isolation. */
99
+ export function resolveEngineSelection(argv, env = process.env) {
100
+ const flag = readEngineFlag(argv);
101
+ if (flag !== undefined)
102
+ return validateEngine(flag);
103
+ const fromEnv = env.BROWX_ENGINE?.trim();
104
+ if (fromEnv)
105
+ return validateEngine(fromEnv);
106
+ return undefined;
107
+ }
108
+ /** Extract the `--engine <kind>` / `--engine=<kind>` value from an argv slice,
109
+ * or undefined when the flag is absent. A bare trailing `--engine` with no
110
+ * value throws (an obvious operator mistake, not a silent no-op). */
111
+ function readEngineFlag(argv) {
112
+ for (let i = 0; i < argv.length; i++) {
113
+ const arg = argv[i];
114
+ if (arg === undefined)
115
+ continue;
116
+ if (arg === "--engine") {
117
+ const next = argv[i + 1];
118
+ if (next === undefined || next.startsWith("--")) {
119
+ throw new Error("--engine requires a value, e.g. `--engine firefox`. See BROWX_ENGINE.");
120
+ }
121
+ return next;
122
+ }
123
+ if (arg.startsWith("--engine=")) {
124
+ return arg.slice("--engine=".length);
125
+ }
126
+ }
127
+ return undefined;
128
+ }
@@ -0,0 +1,13 @@
1
+ import type { CDPSession } from "playwright-core";
2
+ /** A session shape carrying the optional CDP accessor + its engine tag. The
3
+ * full `BrowserSession` satisfies this; the helper takes the narrow shape so
4
+ * it doesn't pull the whole session interface into the engine module. */
5
+ export interface CdpCapable {
6
+ readonly engine: string;
7
+ cdp?(): CDPSession;
8
+ }
9
+ /** Return the session's raw CDP handle. Throws a structured error naming the
10
+ * engine when the session has no CDP escape hatch. On Chromium `cdp` is always
11
+ * present, so this never throws there — keep it a direct delegate on the hot
12
+ * path. */
13
+ export declare function requireCdp(session: CdpCapable): CDPSession;
@@ -0,0 +1,22 @@
1
+ // CDP-presence assertion for the now-optional `cdp()` member.
2
+ //
3
+ // `BrowserSession.cdp()` used to be mandatory; making it optional is what un-
4
+ // gates multi-engine (the eager `newCDPSession` throws off-Chromium). The ~19
5
+ // CDP-hard tools and the network/a11y substrate still need the raw handle on
6
+ // Chromium — they route through `requireCdp`, which returns the handle on an
7
+ // engine that has it (Chromium: always) and throws a structured, engine-naming
8
+ // error on one that doesn't, rather than letting `undefined.send(...)` blow up
9
+ // opaquely. On the Chromium hot path this is a single truthiness check and a
10
+ // direct delegate — no allocation, no indirection.
11
+ /** Return the session's raw CDP handle. Throws a structured error naming the
12
+ * engine when the session has no CDP escape hatch. On Chromium `cdp` is always
13
+ * present, so this never throws there — keep it a direct delegate on the hot
14
+ * path. */
15
+ export function requireCdp(session) {
16
+ if (!session.cdp) {
17
+ throw new Error(`engine "${session.engine}" has no CDP escape hatch — this operation needs raw CDP ` +
18
+ "(perf / coverage / heap / network tap / a11y substrate) and is only available on " +
19
+ "chromium today.");
20
+ }
21
+ return session.cdp();
22
+ }
@@ -0,0 +1,19 @@
1
+ import type { EngineKind } from "./types.js";
2
+ /** Record that a tool needs the raw-CDP (`deep`) escape hatch, from its colocated
3
+ * `host.register({ deep: true })` metadata (RFC 0004 P2). The only writer of the
4
+ * derived `DEEP_TOOLS` set. Idempotent. */
5
+ export declare function declareDeepTool(tool: string): void;
6
+ export declare function installDeepToolsCollector(collect: () => void): void;
7
+ export declare const DEEP_TOOLS: ReadonlySet<string>;
8
+ /** The structured refusal envelope an engine-gated tool returns. Mirrors
9
+ * `assertPdfSupported`'s `{error, hint} | null` shape so handlers splice it in
10
+ * the same way. */
11
+ export interface EngineRefusal {
12
+ error: string;
13
+ hint: string;
14
+ }
15
+ /** Returns a structured refusal when `tool` cannot run on `engine`, else null.
16
+ * Null is the fast path on chromium (the only engine with `deep`) and on every
17
+ * cross-browser tool regardless of engine — a single Set lookup + a capability
18
+ * read, no allocation on the supported path. */
19
+ export declare function assertEngineSupports(tool: string, engine: EngineKind): EngineRefusal | null;