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,164 @@
1
+ // Per-session dialog policy. `alert` / `confirm` / `prompt` block every
2
+ // subsequent browser event until handled — without a server-side listener, the
3
+ // session deadlocks. This module installs `page.on('dialog')` per page on every
4
+ // navigation/new-target and routes each fired dialog through a per-session
5
+ // `DialogPolicyState`.
6
+ //
7
+ // Policy modes:
8
+ // - "accept" — accept every dialog (confirm/prompt → OK)
9
+ // - "dismiss" — dismiss every dialog (confirm/prompt → Cancel)
10
+ // - "accept-prompt-with:<text>" — accept with the given text answer for
11
+ // prompts; accept for alert/confirm
12
+ // - "raise" (DEFAULT) — DISMISS the dialog server-side (so the
13
+ // page unblocks) but mark the action as
14
+ // failed with a structured failure hint,
15
+ // so a dialog never silently changes app
16
+ // state under an unaware caller.
17
+ //
18
+ // Per-action capture: every fired dialog is appended to a buffer with a
19
+ // timestamp. `dialogsSince(ts)` slices the buffer for the action-window —
20
+ // mirrors the ConsoleBuffer pattern. The `raise`-mode flag (`raisedSince(ts)`)
21
+ // lets the action layer convert the action to `ok:false` without re-parsing
22
+ // the dialog records.
23
+ import { log } from "../util/logging.js";
24
+ import { PolicyRecordBuffer } from "./policy-buffer.js";
25
+ /** Hint emitted on `ActionResult.failure.hint` when `raise` mode fired.
26
+ * Stable, agent-facing string — referenced in docs/tool-reference.md. */
27
+ export const UNHANDLED_DIALOG_HINT = "unhandled dialog — set dialogPolicy (open_session/set_dialog_policy) to " +
28
+ '"accept", "dismiss", or "accept-prompt-with:<text>" before driving ' +
29
+ "an action that may trigger one. The dialog was dismissed server-side so " +
30
+ "the page is not deadlocked, but its app effect is the cancel branch.";
31
+ /** Mutable per-session state. The handler reads `current()` on every fire,
32
+ * so a `set_dialog_policy` call takes effect on the very next dialog. */
33
+ export class DialogPolicyState {
34
+ policy;
35
+ /** Bounded record ring (shared `PolicyRecordBuffer` — the hard cap so a chatty
36
+ * page can't grow this without bound; the per-action slice is the only
37
+ * consumer, older records are noise). */
38
+ records;
39
+ /** Pages we've already installed the handler on. Lets the
40
+ * `context.on('page')` wiring be idempotent — re-attaching to an existing
41
+ * page (BYOB reconnect, profile-restore) doesn't double-fire. */
42
+ wired = new WeakSet();
43
+ constructor(initial = { mode: "raise" }, cap = 200) {
44
+ this.policy = normalise(initial);
45
+ this.records = new PolicyRecordBuffer(cap);
46
+ }
47
+ current() {
48
+ return { ...this.policy };
49
+ }
50
+ set(next) {
51
+ this.policy = normalise(next);
52
+ return this.current();
53
+ }
54
+ /** Append a dialog record. Caps the buffer at `cap`. */
55
+ record(rec) {
56
+ this.records.record(rec);
57
+ }
58
+ /** Slice records with `ts >= since`. Used by the action-window. */
59
+ since(since) {
60
+ return this.records.since(since);
61
+ }
62
+ /** True if any record in `[since, now]` was handled in `raise` mode.
63
+ * When true, the action-window flips the result to `ok:false`. */
64
+ raisedSince(since) {
65
+ return this.records.matchedSince(since, (r) => r.handledAs === "raised");
66
+ }
67
+ /** Has this page already been wired? Idempotent install guard. */
68
+ hasPage(p) {
69
+ return this.wired.has(p);
70
+ }
71
+ /** Mark a page as wired. */
72
+ markPage(p) {
73
+ this.wired.add(p);
74
+ }
75
+ }
76
+ /** Parse the spec's compact string form (`"accept-prompt-with:<text>"`) into
77
+ * the runtime `DialogPolicy` shape. Idempotent — also accepts the object form. */
78
+ export function parseDialogPolicyArg(v) {
79
+ if (!v)
80
+ return { mode: "raise" };
81
+ if (typeof v === "object")
82
+ return normalise(v);
83
+ if (v === "accept" || v === "dismiss" || v === "raise")
84
+ return { mode: v };
85
+ if (v.startsWith("accept-prompt-with:")) {
86
+ const text = v.slice("accept-prompt-with:".length);
87
+ return { mode: "accept-prompt-with", text };
88
+ }
89
+ throw new Error(`dialogPolicy: invalid value "${v}" — expected "accept" | "dismiss" | "raise" | "accept-prompt-with:<text>"`);
90
+ }
91
+ function normalise(p) {
92
+ if (p.mode === "accept-prompt-with" && (p.text === undefined || p.text === null)) {
93
+ throw new Error('dialogPolicy: mode "accept-prompt-with" requires `text`');
94
+ }
95
+ return p.mode === "accept-prompt-with" ? { mode: p.mode, text: p.text } : { mode: p.mode };
96
+ }
97
+ /** Install the `page.on('dialog')` handler on a single page if not already
98
+ * wired. Safe to call repeatedly; no-op when the page is already known. */
99
+ export function installDialogHandler(page, state) {
100
+ if (state.hasPage(page))
101
+ return;
102
+ state.markPage(page);
103
+ page.on("dialog", (d) => {
104
+ handleDialog(d, state).catch((err) => {
105
+ // never throw out of an event handler — a dispatch error must not crash
106
+ // the page or the server. Log and move on; the next dialog reuses the
107
+ // same handler.
108
+ log.warn("session.dialog: handler error", {
109
+ error: err instanceof Error ? err.message : String(err),
110
+ });
111
+ });
112
+ });
113
+ }
114
+ /** Wire the dialog handler into every page in a context, plus a `context.on(
115
+ * 'page')` listener that wires future pages. Call once per session-creation;
116
+ * the `context.on('page')` install is idempotent because `installDialogHandler`
117
+ * short-circuits already-wired pages. */
118
+ export function attachDialogPolicy(context, state) {
119
+ for (const page of context.pages())
120
+ installDialogHandler(page, state);
121
+ context.on("page", (page) => installDialogHandler(page, state));
122
+ }
123
+ async function handleDialog(d, state) {
124
+ const policy = state.current();
125
+ const kind = d.type();
126
+ const message = d.message();
127
+ const defaultValue = d.defaultValue() || undefined;
128
+ const ts = Date.now();
129
+ switch (policy.mode) {
130
+ case "accept": {
131
+ // For alert: accept (no-op). For confirm: OK. For prompt: empty answer.
132
+ // Callers who want a specific prompt answer set "accept-prompt-with".
133
+ await d.accept().catch(() => undefined);
134
+ state.record({ kind, message, defaultValue, handledAs: "accepted", ts });
135
+ return;
136
+ }
137
+ case "dismiss": {
138
+ await d.dismiss().catch(() => undefined);
139
+ state.record({ kind, message, defaultValue, handledAs: "dismissed", ts });
140
+ return;
141
+ }
142
+ case "accept-prompt-with": {
143
+ // Only prompts read the text answer; alert/confirm ignore the second arg
144
+ // — Playwright accepts either with or without the prompt text.
145
+ const text = policy.text ?? "";
146
+ if (kind === "prompt") {
147
+ await d.accept(text).catch(() => undefined);
148
+ }
149
+ else {
150
+ await d.accept().catch(() => undefined);
151
+ }
152
+ state.record({ kind, message, defaultValue, handledAs: "accepted", ts });
153
+ return;
154
+ }
155
+ case "raise":
156
+ default: {
157
+ // Dismiss server-side so the page unblocks (the spec's anti-deadlock
158
+ // guarantee) AND mark the action as failed via the buffer flag.
159
+ await d.dismiss().catch(() => undefined);
160
+ state.record({ kind, message, defaultValue, handledAs: "raised", ts });
161
+ return;
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,69 @@
1
+ import type { BrowserContext, CDPSession, Page } from "playwright-core";
2
+ export type ColorScheme = "light" | "dark" | "no-preference";
3
+ export type ReducedMotion = "reduce" | "no-preference";
4
+ export interface GeolocationCoords {
5
+ latitude: number;
6
+ longitude: number;
7
+ /** metres; Playwright default 0. */
8
+ accuracy?: number;
9
+ }
10
+ /** Per-origin permission grant. `origin` empty/undefined → applies to the
11
+ * current page's origin at apply time. */
12
+ export interface PermissionGrant {
13
+ permissions: string[];
14
+ origin?: string;
15
+ }
16
+ /** Mutable bag of resolved emulation state. Stored per `SessionEntry`. Any
17
+ * field that is `undefined` means "no override — use the browser default". */
18
+ export interface EmulationState {
19
+ locale?: string;
20
+ timezoneId?: string;
21
+ geolocation?: GeolocationCoords;
22
+ colorScheme?: ColorScheme;
23
+ reducedMotion?: ReducedMotion;
24
+ userAgent?: string;
25
+ /** Per-origin permission grants, keyed by origin (empty string = "current
26
+ * page origin at apply time"). Each grant REPLACES the prior set for that
27
+ * origin — Playwright's `context.grantPermissions` is itself replace-not-
28
+ * merge per call, so we mirror its semantics. */
29
+ permissions: Map<string, string[]>;
30
+ }
31
+ export declare function newEmulationState(): EmulationState;
32
+ /** Re-apply every set knob to a freshly attached page/context. Used on
33
+ * `BrowserContext.on("page")` and on session re-attach. Best-effort: each
34
+ * applier swallows its own error and the next still runs.
35
+ *
36
+ * `cdpFor(page)` returns the CDP session for the page — owned by the caller
37
+ * (the registry creates one CDP session per primary page). For secondary
38
+ * pages opened via `on("page")`, the caller passes a freshly-created CDP. */
39
+ export declare function reapplyAll(context: BrowserContext, page: Page, cdp: CDPSession, state: EmulationState): Promise<void>;
40
+ /** `Emulation.setLocaleOverride` — moves the `Accept-Language` header AND the
41
+ * ICU/`Intl` default locale. It does NOT change `navigator.language` /
42
+ * `navigator.languages` (those are JS getters fixed at document creation), so a
43
+ * full locale emulation pairs this with `applyLocaleNavigator`. Passing empty
44
+ * string clears the override (CDP semantics). */
45
+ export declare function applyLocaleCdp(cdp: CDPSession, locale: string): Promise<void>;
46
+ export declare function clearLocaleCdp(cdp: CDPSession): Promise<void>;
47
+ /** Companion to `applyLocaleCdp`: patch the JS `navigator.language(s)` signal.
48
+ * Registers a context-level init script (future documents + new tabs inherit
49
+ * it) AND re-runs it in the current document for immediate effect. Pass an empty
50
+ * locale to restore the captured originals. */
51
+ export declare function applyLocaleNavigator(context: BrowserContext, page: Page, locale: string): Promise<void>;
52
+ export declare function applyTimezoneCdp(cdp: CDPSession, timezoneId: string): Promise<void>;
53
+ export declare function clearTimezoneCdp(cdp: CDPSession): Promise<void>;
54
+ export declare function applyGeolocation(context: BrowserContext, coords: GeolocationCoords): Promise<void>;
55
+ export declare function clearGeolocation(context: BrowserContext): Promise<void>;
56
+ export declare function applyColorScheme(page: Page, scheme: ColorScheme): Promise<void>;
57
+ export declare function applyReducedMotion(page: Page, motion: ReducedMotion): Promise<void>;
58
+ export declare function applyUserAgentCdp(cdp: CDPSession, userAgent: string): Promise<void>;
59
+ export declare function clearUserAgentCdp(cdp: CDPSession): Promise<void>;
60
+ /** Replace the grant for a single origin (or "" = current page origin).
61
+ * Updates the state bag, then issues the Playwright call. */
62
+ export declare function applyPermissions(context: BrowserContext, state: EmulationState, permissions: string[], origin?: string): Promise<void>;
63
+ export declare function clearPermissions(context: BrowserContext, state: EmulationState, origin?: string): Promise<void>;
64
+ /** Distinct-warning helper. BYOB / attached sessions push CDP overrides into
65
+ * Chrome that browxai does NOT own and CANNOT undo on detach in every case
66
+ * (the human's browser keeps the override until they navigate / restart).
67
+ * Tools surface this string in their result `warnings` whenever an emulation
68
+ * override is applied to an attached session. */
69
+ export declare const BYOB_EMULATION_WARNING: string;
@@ -0,0 +1,168 @@
1
+ // Per-primitive device-emulation state + appliers.
2
+ //
3
+ // Sits alongside `device.ts` (which resolves a Playwright preset at *context-
4
+ // creation* time). The primitives here are the runtime-mutable surface: 7 MCP
5
+ // tools that each set ONE Playwright/CDP emulation knob on a live session, so
6
+ // agents don't have to over-specify a bundled `emulate({...})` payload on
7
+ // every call.
8
+ //
9
+ // Persistence model. Each setting's resolved value is stored on the
10
+ // `SessionEntry.deviceEmulation` bag for the session's lifetime. One re-apply
11
+ // path: new page in the same context — a `BrowserContext.on("page")` hook
12
+ // re-runs the applier so a tab opened mid-session inherits the overrides.
13
+ //
14
+ // Runtime-vs-context-time. Playwright's `BrowserContext` bakes some options
15
+ // (`locale`, `timezoneId`, `userAgent`) at creation; there is no public mutator
16
+ // for them on an existing context. CDP `Emulation.setLocaleOverride`,
17
+ // `Emulation.setTimezoneOverride`, and `Network.setUserAgentOverride` DO take
18
+ // effect post-creation, so this module routes those three through the
19
+ // per-page CDP session. The remaining four — geolocation, colour scheme,
20
+ // reduced motion, permissions — have stable Playwright mid-session mutators
21
+ // and use those. See per-applier comments for the exact mechanism.
22
+ export function newEmulationState() {
23
+ return { permissions: new Map() };
24
+ }
25
+ /** Re-apply every set knob to a freshly attached page/context. Used on
26
+ * `BrowserContext.on("page")` and on session re-attach. Best-effort: each
27
+ * applier swallows its own error and the next still runs.
28
+ *
29
+ * `cdpFor(page)` returns the CDP session for the page — owned by the caller
30
+ * (the registry creates one CDP session per primary page). For secondary
31
+ * pages opened via `on("page")`, the caller passes a freshly-created CDP. */
32
+ export async function reapplyAll(context, page, cdp, state) {
33
+ if (state.locale !== undefined)
34
+ await applyLocaleCdp(cdp, state.locale).catch(() => undefined);
35
+ if (state.timezoneId !== undefined)
36
+ await applyTimezoneCdp(cdp, state.timezoneId).catch(() => undefined);
37
+ if (state.userAgent !== undefined)
38
+ await applyUserAgentCdp(cdp, state.userAgent).catch(() => undefined);
39
+ if (state.geolocation !== undefined)
40
+ await applyGeolocation(context, state.geolocation).catch(() => undefined);
41
+ if (state.colorScheme !== undefined)
42
+ await applyColorScheme(page, state.colorScheme).catch(() => undefined);
43
+ if (state.reducedMotion !== undefined)
44
+ await applyReducedMotion(page, state.reducedMotion).catch(() => undefined);
45
+ for (const [origin, perms] of state.permissions) {
46
+ const opts = origin ? { origin } : undefined;
47
+ await context.grantPermissions(perms, opts).catch(() => undefined);
48
+ }
49
+ }
50
+ // ---------------- locale (CDP override + navigator patch) ----------------
51
+ /** `Emulation.setLocaleOverride` — moves the `Accept-Language` header AND the
52
+ * ICU/`Intl` default locale. It does NOT change `navigator.language` /
53
+ * `navigator.languages` (those are JS getters fixed at document creation), so a
54
+ * full locale emulation pairs this with `applyLocaleNavigator`. Passing empty
55
+ * string clears the override (CDP semantics). */
56
+ export async function applyLocaleCdp(cdp, locale) {
57
+ await cdp.send("Emulation.setLocaleOverride", { locale });
58
+ }
59
+ export async function clearLocaleCdp(cdp) {
60
+ // Per CDP, omitting `locale` clears the override. Playwright's send() is
61
+ // strict-typed so we pass empty-string which the protocol treats as clear.
62
+ await cdp.send("Emulation.setLocaleOverride", { locale: "" });
63
+ }
64
+ /** BCP-47 tag → a `navigator.languages` chain: "fr-FR" → ["fr-FR","fr"]. */
65
+ function localeChain(locale) {
66
+ const base = locale.split("-")[0];
67
+ return base && base !== locale ? [locale, base] : [locale];
68
+ }
69
+ /** The page-side patch that makes `navigator.language` / `navigator.languages`
70
+ * report the emulated locale — the JS signal `setLocaleOverride` leaves alone.
71
+ * Idempotent via a window flag: the first run captures the originals and
72
+ * installs configurable getters; every run only updates the value, so repeated
73
+ * `set_locale` calls (and the context re-running the script on new documents)
74
+ * never stack property redefinitions. An empty locale restores the original. */
75
+ function localeNavigatorScript(locale) {
76
+ const value = locale ? JSON.stringify(locale) : "null";
77
+ const list = locale ? JSON.stringify(localeChain(locale)) : "null";
78
+ return `(() => {
79
+ const w = window;
80
+ if (!w.__browxLocale) {
81
+ w.__browxLocale = {
82
+ lang: navigator.language,
83
+ langs: Array.prototype.slice.call(navigator.languages),
84
+ };
85
+ Object.defineProperty(navigator, "language", {
86
+ configurable: true,
87
+ get: () => (w.__browxLocale.override === undefined ? w.__browxLocale.lang : w.__browxLocale.override),
88
+ });
89
+ Object.defineProperty(navigator, "languages", {
90
+ configurable: true,
91
+ get: () => (w.__browxLocale.overrideList === undefined ? w.__browxLocale.langs : w.__browxLocale.overrideList),
92
+ });
93
+ }
94
+ w.__browxLocale.override = ${value} === null ? undefined : ${value};
95
+ w.__browxLocale.overrideList = ${list} === null ? undefined : ${list};
96
+ })();`;
97
+ }
98
+ /** Companion to `applyLocaleCdp`: patch the JS `navigator.language(s)` signal.
99
+ * Registers a context-level init script (future documents + new tabs inherit
100
+ * it) AND re-runs it in the current document for immediate effect. Pass an empty
101
+ * locale to restore the captured originals. */
102
+ export async function applyLocaleNavigator(context, page, locale) {
103
+ const script = localeNavigatorScript(locale);
104
+ await context.addInitScript({ content: script });
105
+ await page.evaluate(script).catch(() => undefined);
106
+ }
107
+ // ---------------- timezone (CDP-only mid-session) ----------------
108
+ export async function applyTimezoneCdp(cdp, timezoneId) {
109
+ await cdp.send("Emulation.setTimezoneOverride", { timezoneId });
110
+ }
111
+ export async function clearTimezoneCdp(cdp) {
112
+ await cdp.send("Emulation.setTimezoneOverride", { timezoneId: "" });
113
+ }
114
+ // ---------------- geolocation (Playwright context mutator) ----------------
115
+ export async function applyGeolocation(context, coords) {
116
+ await context.setGeolocation({
117
+ latitude: coords.latitude,
118
+ longitude: coords.longitude,
119
+ accuracy: coords.accuracy ?? 0,
120
+ });
121
+ }
122
+ export async function clearGeolocation(context) {
123
+ await context.setGeolocation(null);
124
+ }
125
+ // ---------------- colour scheme (Playwright page mutator) ----------------
126
+ export async function applyColorScheme(page, scheme) {
127
+ await page.emulateMedia({ colorScheme: scheme });
128
+ }
129
+ // ---------------- reduced motion (Playwright page mutator) ----------------
130
+ export async function applyReducedMotion(page, motion) {
131
+ await page.emulateMedia({ reducedMotion: motion });
132
+ }
133
+ // ---------------- user agent (CDP-only mid-session) ----------------
134
+ export async function applyUserAgentCdp(cdp, userAgent) {
135
+ await cdp.send("Network.setUserAgentOverride", { userAgent });
136
+ }
137
+ export async function clearUserAgentCdp(cdp) {
138
+ // Empty-string clears the override per CDP.
139
+ await cdp.send("Network.setUserAgentOverride", { userAgent: "" });
140
+ }
141
+ // ---------------- permissions ----------------
142
+ /** Replace the grant for a single origin (or "" = current page origin).
143
+ * Updates the state bag, then issues the Playwright call. */
144
+ export async function applyPermissions(context, state, permissions, origin) {
145
+ const key = origin ?? "";
146
+ state.permissions.set(key, [...permissions]);
147
+ const opts = origin ? { origin } : undefined;
148
+ await context.grantPermissions(permissions, opts);
149
+ }
150
+ export async function clearPermissions(context, state, origin) {
151
+ // Playwright doesn't expose per-origin permission revocation — only the
152
+ // context-wide `clearPermissions`. We mirror that semantics: clearing wipes
153
+ // every grant in the state bag and the context.
154
+ state.permissions.clear();
155
+ if (origin !== undefined) {
156
+ // Caller asked to clear ONE origin; we issued a full clear because the
157
+ // platform doesn't support partial — surface as a warning at the tool layer.
158
+ }
159
+ await context.clearPermissions();
160
+ }
161
+ /** Distinct-warning helper. BYOB / attached sessions push CDP overrides into
162
+ * Chrome that browxai does NOT own and CANNOT undo on detach in every case
163
+ * (the human's browser keeps the override until they navigate / restart).
164
+ * Tools surface this string in their result `warnings` whenever an emulation
165
+ * override is applied to an attached session. */
166
+ export const BYOB_EMULATION_WARNING = "BYOB caveat: this emulation override is applied via CDP to an attached " +
167
+ "(not-owned) Chrome and will PERSIST on that browser after browxai " +
168
+ "detaches. The human's Chrome must navigate / restart to fully clear it.";
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Loaded-extension record. `id` is the Chrome-computed extension id (a 32-char
3
+ * lowercase alpha string derived from the unpacked path; deterministic given
4
+ * the same path). `path` is the resolved absolute path on disk. `enabled` is
5
+ * a registry-level flag — disabling without uninstall is currently a no-op
6
+ * because Chrome won't honour a partial extension list mid-launch; reserved
7
+ * for a future contract.
8
+ */
9
+ export interface LoadedExtension {
10
+ id: string;
11
+ name: string;
12
+ version: string;
13
+ path: string;
14
+ enabled: boolean;
15
+ }
16
+ /** Per-session extension state. Lives on `SessionEntry.extensions`. */
17
+ export interface ExtensionRegistry {
18
+ /** Currently-loaded extensions for this session. Empty by default. */
19
+ loaded: LoadedExtension[];
20
+ }
21
+ export declare function newExtensionRegistry(): ExtensionRegistry;
22
+ /** Result envelope for install / reload / uninstall — the standard ok/error
23
+ * shape the tool layer wraps with `tokensEstimate`. */
24
+ export interface ExtensionMutationResult {
25
+ ok: true;
26
+ loaded: LoadedExtension[];
27
+ /** Optional note surfaced to the agent (rebuild warning, etc.). */
28
+ note?: string;
29
+ }
30
+ /**
31
+ * Resolve a caller-supplied `path` to an absolute workspace-rooted directory
32
+ * containing an MV3 (or MV2) manifest. Rejects:
33
+ * - empty / whitespace
34
+ * - traversal segments (`..`) that escape the workspace
35
+ * - absolute paths pointing outside the workspace
36
+ * - non-existent paths
37
+ * - paths that are files (not a directory)
38
+ * - directories missing `manifest.json`
39
+ *
40
+ * Returns the resolved absolute path. Throws `Error` with a structured message
41
+ * on any rejection — the tool handler converts that to the `ok:false` envelope.
42
+ */
43
+ export declare function resolveExtensionPath(workspaceRoot: string, p: string, tool: string): string;
44
+ /** Parsed extension manifest — the minimal subset we surface to the agent. */
45
+ export interface ParsedManifest {
46
+ name: string;
47
+ version: string;
48
+ manifestVersion: number;
49
+ }
50
+ export declare function readManifest(extPath: string, tool: string): ParsedManifest;
51
+ /**
52
+ * Compute a deterministic, stable id for an unpacked extension keyed off its
53
+ * absolute path. Chrome's real algorithm hashes the path with SHA-256 and
54
+ * maps the first 16 bytes onto the alphabet `a-p` (32 chars). We approximate
55
+ * with a 32-char alpha hash that's deterministic across runs given the same
56
+ * path; the *exact* Chrome id is not required for our use cases (list /
57
+ * reload / uninstall / trigger all key off the path or our own id mapping).
58
+ *
59
+ * The hash uses Node's built-in `node:crypto` — no extra dep.
60
+ */
61
+ export declare function extensionIdFromPath(absPath: string): string;
62
+ /** Build the Chromium launch arguments for a given set of enabled extensions.
63
+ * Empty list → empty args (no extension flags). Returns a frozen array. */
64
+ export declare function buildLaunchArgs(loaded: ReadonlyArray<LoadedExtension>): string[];
65
+ /** Sentinel returned by the refuse predicates so the tool layer surfaces a
66
+ * uniform error envelope. */
67
+ export interface RefuseResult {
68
+ ok: false;
69
+ error: string;
70
+ hint: string;
71
+ }
72
+ /**
73
+ * Pure refusal predicate — returns null when the session can host extensions,
74
+ * else a structured rejection. Mirrors the gate pattern in server.ts but is
75
+ * pure (testable without launching Chrome).
76
+ */
77
+ export declare function refuseIfUnsupported(input: {
78
+ mode: "persistent" | "incognito" | "attached";
79
+ headless: boolean;
80
+ tool: string;
81
+ }): RefuseResult | null;
82
+ /**
83
+ * In-place mutation helper for the install operation. Pure — given the
84
+ * current registry and a resolved + parsed install request, returns the new
85
+ * registry. Throws on duplicate path. The tool layer is responsible for the
86
+ * rebuild step that materialises the change.
87
+ */
88
+ export declare function applyInstall(reg: ExtensionRegistry, install: {
89
+ path: string;
90
+ name: string;
91
+ version: string;
92
+ }, tool: string): {
93
+ id: string;
94
+ loaded: LoadedExtension[];
95
+ };
96
+ /**
97
+ * Pure helper for uninstall — returns the next loaded list, throws when the
98
+ * id isn't loaded.
99
+ */
100
+ export declare function applyUninstall(reg: ExtensionRegistry, id: string, tool: string): {
101
+ loaded: LoadedExtension[];
102
+ removed: LoadedExtension;
103
+ };
104
+ /**
105
+ * Pure helper for reload — re-parses the manifest at the loaded path and
106
+ * returns the next loaded list with updated name/version. The browser-context
107
+ * rebuild is what actually re-injects content scripts; this helper just keeps
108
+ * the registry consistent.
109
+ */
110
+ export declare function applyReload(reg: ExtensionRegistry, id: string, parsed: ParsedManifest, tool: string): {
111
+ loaded: LoadedExtension[];
112
+ entry: LoadedExtension;
113
+ };