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,353 @@
1
+ import { requireCdp } from "../engine/index.js";
2
+ import { applyLocaleCdp, applyLocaleNavigator, clearLocaleCdp, applyTimezoneCdp, clearTimezoneCdp, applyUserAgentCdp, clearUserAgentCdp, applyPermissions, clearPermissions, BYOB_EMULATION_WARNING, } from "../session/emulation.js";
3
+ import { setTabVisibility } from "../page/visibility.js";
4
+ import { estimateTokens } from "../util/tokens.js";
5
+ import { SESSION_ARG } from "./schemas.js";
6
+ /**
7
+ * Per-primitive live emulation — the seven sibling mutators that each set ONE
8
+ * live knob on the session (`set_locale` / `set_timezone` / `set_geolocation` /
9
+ * `set_color_scheme` / `set_reduced_motion` / `set_user_agent` /
10
+ * `grant_permissions`) plus `tab_visibility`. State persists on the SessionEntry.
11
+ * Registered through the shared `ToolHost` seam.
12
+ */
13
+ export function registerLiveEmulationTools(host) {
14
+ const { z, register, gateCheck, engineGate, entryFor, emulationFor } = host;
15
+ // ---------- Per-primitive device emulation ----------
16
+ //
17
+ // Seven sibling tools (deliberately NOT a bundled `emulate({…})`) — each
18
+ // mutates ONE Playwright/CDP knob on the live session: `set_locale`,
19
+ // `set_timezone`, `set_geolocation`, `set_color_scheme`, `set_reduced_motion`,
20
+ // `set_user_agent`, `grant_permissions`. State persists on the SessionEntry
21
+ // so new pages within the same context re-apply automatically. CONTEXT-
22
+ // time-only Playwright settings (locale, timezone, UA) are routed through
23
+ // their CDP equivalents (`Emulation.setLocaleOverride`,
24
+ // `Emulation.setTimezoneOverride`, `Network.setUserAgentOverride`) — those
25
+ // DO take effect mid-session. The other four use Playwright's stable
26
+ // mutators. BYOB / attached sessions surface a warning that overrides
27
+ // applied via CDP outlive browxai's detach.
28
+ /** Wrap an emulation-tool result with the standard envelope (`ok`, `applied`,
29
+ * `state` snapshot, `tokensEstimate`, plus BYOB warning when applicable). */
30
+ const emulationResult = (e, applied, extra = {}) => {
31
+ const warnings = [...(extra.warnings ?? [])];
32
+ if (e.mode === "attached")
33
+ warnings.push(BYOB_EMULATION_WARNING);
34
+ const body = {
35
+ ok: true,
36
+ session: e.id,
37
+ applied,
38
+ state: {
39
+ locale: e.deviceEmulation.locale ?? null,
40
+ timezoneId: e.deviceEmulation.timezoneId ?? null,
41
+ geolocation: e.deviceEmulation.geolocation ?? null,
42
+ colorScheme: e.deviceEmulation.colorScheme ?? null,
43
+ reducedMotion: e.deviceEmulation.reducedMotion ?? null,
44
+ userAgent: e.deviceEmulation.userAgent ?? null,
45
+ permissions: Object.fromEntries(e.deviceEmulation.permissions),
46
+ },
47
+ };
48
+ if (warnings.length)
49
+ body.warnings = warnings;
50
+ if (extra.note)
51
+ body.note = extra.note;
52
+ body.tokensEstimate = estimateTokens(JSON.stringify(body));
53
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
54
+ };
55
+ /** Standard emulation failure envelope. */
56
+ const emulationError = (toolName, err) => ({
57
+ content: [
58
+ {
59
+ type: "text",
60
+ text: JSON.stringify({
61
+ ok: false,
62
+ action: { type: toolName },
63
+ error: err instanceof Error ? err.message : String(err),
64
+ tokensEstimate: 0,
65
+ }, null, 2),
66
+ },
67
+ ],
68
+ });
69
+ /** Render an EmulationSubstrate refusal as the standard failure envelope (the
70
+ * Safari adapter has no live surface for the knob). Carries the adapter's
71
+ * `hint` so the agent knows where the override IS available. */
72
+ const emulationRefusal = (toolName, refusal) => ({
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: JSON.stringify({
77
+ ok: false,
78
+ action: { type: toolName },
79
+ error: refusal.error,
80
+ ...(refusal.hint ? { hint: refusal.hint } : {}),
81
+ tokensEstimate: 0,
82
+ }, null, 2),
83
+ },
84
+ ],
85
+ });
86
+ register("set_locale", {
87
+ capability: "action",
88
+ batchable: true,
89
+ deep: true,
90
+ description: "Override the session's browser locale (`navigator.language` / `navigator.languages`, `Intl.*` defaults, `Accept-Language` header). Persists across navigation + new tabs in the same session and takes effect on the current page immediately. Pass `locale: null` to clear the override and restore the browser default. NOTE: Playwright's `BrowserContext.locale` is creation-time-only, so this primitive combines CDP `Emulation.setLocaleOverride` (Accept-Language + Intl) with a context init-script that patches the JS `navigator.language(s)` getters — `setLocaleOverride` alone does not move them. BYOB caveat: both overrides persist on the attached Chrome until it navigates/restarts after detach.",
91
+ inputSchema: {
92
+ locale: z
93
+ .union([z.string(), z.null()])
94
+ .optional()
95
+ .describe('BCP-47 locale tag, e.g. "en-US", "de-DE", "ja-JP". Pass null (or omit) to clear the override and restore the browser default.'),
96
+ ...SESSION_ARG,
97
+ },
98
+ }, async ({ locale, session }) => {
99
+ const g = gateCheck("set_locale");
100
+ if (g)
101
+ return g;
102
+ const e = await entryFor(session);
103
+ const eg = engineGate("set_locale", e);
104
+ if (eg)
105
+ return eg;
106
+ try {
107
+ const localePage = e.session.page();
108
+ if (locale === null || locale === undefined) {
109
+ await clearLocaleCdp(requireCdp(e.session));
110
+ await applyLocaleNavigator(localePage.context(), localePage, "");
111
+ e.deviceEmulation.locale = undefined;
112
+ return emulationResult(e, { locale: null });
113
+ }
114
+ await applyLocaleCdp(requireCdp(e.session), locale);
115
+ await applyLocaleNavigator(localePage.context(), localePage, locale);
116
+ e.deviceEmulation.locale = locale;
117
+ return emulationResult(e, { locale });
118
+ }
119
+ catch (err) {
120
+ return emulationError("set_locale", err);
121
+ }
122
+ });
123
+ register("set_timezone", {
124
+ capability: "action",
125
+ batchable: true,
126
+ deep: true,
127
+ description: "Override the session's IANA timezone for `Date`, `Intl.DateTimeFormat`, etc. Persists across navigation + new tabs. Pass `timezoneId: null` to clear. NOTE: Playwright's `BrowserContext.timezoneId` is creation-time-only, so this primitive uses CDP `Emulation.setTimezoneOverride` (mid-session-capable). BYOB caveat: the CDP override persists on attached Chrome after detach.",
128
+ inputSchema: {
129
+ timezoneId: z
130
+ .union([z.string(), z.null()])
131
+ .optional()
132
+ .describe('IANA timezone, e.g. "America/New_York", "Europe/London", "Asia/Tokyo". Pass null (or omit) to clear.'),
133
+ ...SESSION_ARG,
134
+ },
135
+ }, async ({ timezoneId, session }) => {
136
+ const g = gateCheck("set_timezone");
137
+ if (g)
138
+ return g;
139
+ const e = await entryFor(session);
140
+ const eg = engineGate("set_timezone", e);
141
+ if (eg)
142
+ return eg;
143
+ try {
144
+ if (timezoneId === null || timezoneId === undefined) {
145
+ await clearTimezoneCdp(requireCdp(e.session));
146
+ e.deviceEmulation.timezoneId = undefined;
147
+ return emulationResult(e, { timezoneId: null });
148
+ }
149
+ await applyTimezoneCdp(requireCdp(e.session), timezoneId);
150
+ e.deviceEmulation.timezoneId = timezoneId;
151
+ return emulationResult(e, { timezoneId });
152
+ }
153
+ catch (err) {
154
+ return emulationError("set_timezone", err);
155
+ }
156
+ });
157
+ register("set_geolocation", {
158
+ capability: "action",
159
+ batchable: true,
160
+ description: "Override the session's HTML5 Geolocation reading. The page MUST also be granted the `geolocation` permission via `grant_permissions` for `navigator.geolocation.*` to deliver this value (browsers gate it). Uses Playwright's `context.setGeolocation()` which mutates a live context — no CDP fallback needed. Pass no coords (or `latitude:null`) to clear.",
161
+ inputSchema: {
162
+ latitude: z
163
+ .union([z.number(), z.null()])
164
+ .optional()
165
+ .describe("Latitude in degrees [-90, 90]. Pass null (or omit) to clear the override."),
166
+ longitude: z.number().optional().describe("Longitude in degrees [-180, 180]."),
167
+ accuracy: z
168
+ .number()
169
+ .nonnegative()
170
+ .optional()
171
+ .describe("Accuracy radius in metres. Default 0."),
172
+ ...SESSION_ARG,
173
+ },
174
+ }, async ({ latitude, longitude, accuracy, session }) => {
175
+ const g = gateCheck("set_geolocation");
176
+ if (g)
177
+ return g;
178
+ const e = await entryFor(session);
179
+ try {
180
+ const isClear = latitude === null || latitude === undefined;
181
+ if (isClear) {
182
+ const r = await emulationFor(e).setGeolocation(null);
183
+ if (r.kind === "refusal")
184
+ return emulationRefusal("set_geolocation", r);
185
+ e.deviceEmulation.geolocation = undefined;
186
+ return emulationResult(e, { geolocation: null });
187
+ }
188
+ if (longitude === undefined) {
189
+ return emulationError("set_geolocation", new Error("longitude is required when latitude is set"));
190
+ }
191
+ const coords = { latitude, longitude, accuracy };
192
+ const r = await emulationFor(e).setGeolocation(coords);
193
+ if (r.kind === "refusal")
194
+ return emulationRefusal("set_geolocation", r);
195
+ e.deviceEmulation.geolocation = coords;
196
+ const warnings = [];
197
+ const grantedHere = e.deviceEmulation.permissions.get("") ?? [];
198
+ const grantedAll = [...e.deviceEmulation.permissions.values()].flat();
199
+ if (![...grantedHere, ...grantedAll].includes("geolocation")) {
200
+ warnings.push('set_geolocation: pages need the `geolocation` permission for navigator.geolocation to deliver this — call grant_permissions({ permissions: ["geolocation"] }) for the relevant origin.');
201
+ }
202
+ return emulationResult(e, { geolocation: coords }, { warnings });
203
+ }
204
+ catch (err) {
205
+ return emulationError("set_geolocation", err);
206
+ }
207
+ });
208
+ register("set_color_scheme", {
209
+ capability: "action",
210
+ batchable: true,
211
+ description: "Override the session's `prefers-color-scheme` media query — drives dark-mode rendering. Mutates a live page via Playwright's `page.emulateMedia({colorScheme})`; takes effect immediately (CSS media queries re-evaluate). Pass `\"no-preference\"` to clear the override.",
212
+ inputSchema: {
213
+ scheme: z
214
+ .enum(["light", "dark", "no-preference"])
215
+ .describe("`light` / `dark` force the scheme; `no-preference` clears the override and restores the system default."),
216
+ ...SESSION_ARG,
217
+ },
218
+ }, async ({ scheme, session }) => {
219
+ const g = gateCheck("set_color_scheme");
220
+ if (g)
221
+ return g;
222
+ const e = await entryFor(session);
223
+ try {
224
+ const r = await emulationFor(e).setColorScheme(scheme);
225
+ if (r.kind === "refusal")
226
+ return emulationRefusal("set_color_scheme", r);
227
+ e.deviceEmulation.colorScheme = scheme === "no-preference" ? undefined : scheme;
228
+ return emulationResult(e, { colorScheme: scheme });
229
+ }
230
+ catch (err) {
231
+ return emulationError("set_color_scheme", err);
232
+ }
233
+ });
234
+ register("set_reduced_motion", {
235
+ capability: "action",
236
+ batchable: true,
237
+ description: "Override the session's `prefers-reduced-motion` media query — useful when an animation-heavy page is unstable to drive, or to verify a reduced-motion code path. Mutates a live page via Playwright's `page.emulateMedia({reducedMotion})`. Pass `on:false` to clear.",
238
+ inputSchema: {
239
+ on: z.boolean().describe("true → `reduce`; false → `no-preference` (clears the override)."),
240
+ ...SESSION_ARG,
241
+ },
242
+ }, async ({ on, session }) => {
243
+ const g = gateCheck("set_reduced_motion");
244
+ if (g)
245
+ return g;
246
+ const e = await entryFor(session);
247
+ try {
248
+ const motion = on ? "reduce" : "no-preference";
249
+ const r = await emulationFor(e).setReducedMotion(motion);
250
+ if (r.kind === "refusal")
251
+ return emulationRefusal("set_reduced_motion", r);
252
+ e.deviceEmulation.reducedMotion = on ? "reduce" : undefined;
253
+ return emulationResult(e, { reducedMotion: motion });
254
+ }
255
+ catch (err) {
256
+ return emulationError("set_reduced_motion", err);
257
+ }
258
+ });
259
+ register("set_user_agent", {
260
+ capability: "action",
261
+ batchable: true,
262
+ deep: true,
263
+ description: "Override the session's User-Agent (HTTP header + `navigator.userAgent`). Persists across navigation + new tabs. Pass `userAgent: null` to clear. NOTE: Playwright's `BrowserContext.userAgent` is creation-time-only, so this primitive uses CDP `Network.setUserAgentOverride` (mid-session-capable; updates both the network header and the JS-visible value). BYOB caveat: the CDP override persists on attached Chrome after detach.",
264
+ inputSchema: {
265
+ userAgent: z
266
+ .union([z.string(), z.null()])
267
+ .optional()
268
+ .describe("Full User-Agent string. Pass null (or omit) to clear and restore the browser default."),
269
+ ...SESSION_ARG,
270
+ },
271
+ }, async ({ userAgent, session }) => {
272
+ const g = gateCheck("set_user_agent");
273
+ if (g)
274
+ return g;
275
+ const e = await entryFor(session);
276
+ const eg = engineGate("set_user_agent", e);
277
+ if (eg)
278
+ return eg;
279
+ try {
280
+ if (userAgent === null || userAgent === undefined) {
281
+ await clearUserAgentCdp(requireCdp(e.session));
282
+ e.deviceEmulation.userAgent = undefined;
283
+ return emulationResult(e, { userAgent: null });
284
+ }
285
+ await applyUserAgentCdp(requireCdp(e.session), userAgent);
286
+ e.deviceEmulation.userAgent = userAgent;
287
+ return emulationResult(e, { userAgent });
288
+ }
289
+ catch (err) {
290
+ return emulationError("set_user_agent", err);
291
+ }
292
+ });
293
+ register("grant_permissions", {
294
+ capability: "action",
295
+ batchable: true,
296
+ description: "Grant browser permissions for the session — `geolocation`, `notifications`, `clipboard-read`, `clipboard-write`, `camera`, `microphone`, `midi`, `background-sync`, `accelerometer`, `gyroscope`, `magnetometer`, `ambient-light-sensor`, `payment-handler`, etc. (Chromium permission names). Mutates a live context via Playwright `context.grantPermissions`. Optionally scope to a specific `origin`; otherwise grants for the current page's origin. Pass `permissions: []` (or omit) to clear all grants for the session — Playwright does not expose per-origin revocation, so clearing is context-wide.",
297
+ inputSchema: {
298
+ permissions: z
299
+ .array(z.string())
300
+ .optional()
301
+ .describe("List of Chromium permission names. Pass empty array (or omit) to clear ALL grants (context-wide; per-origin revocation isn't supported by the underlying platform)."),
302
+ origin: z
303
+ .string()
304
+ .optional()
305
+ .describe('Origin to scope the grant to (e.g. "https://example.com"). Omit to use the current page\'s origin.'),
306
+ ...SESSION_ARG,
307
+ },
308
+ }, async ({ permissions, origin, session }) => {
309
+ const g = gateCheck("grant_permissions");
310
+ if (g)
311
+ return g;
312
+ const e = await entryFor(session);
313
+ try {
314
+ if (!permissions || permissions.length === 0) {
315
+ const hadOrigin = origin !== undefined;
316
+ await clearPermissions(e.session.page().context(), e.deviceEmulation, origin);
317
+ const note = hadOrigin
318
+ ? "Per-origin permission revocation isn't supported by Playwright; cleared ALL grants for the session context."
319
+ : "Cleared ALL permission grants for the session context.";
320
+ return emulationResult(e, { permissions: [], origin: origin ?? null }, { note });
321
+ }
322
+ await applyPermissions(e.session.page().context(), e.deviceEmulation, permissions, origin);
323
+ return emulationResult(e, { permissions, origin: origin ?? null });
324
+ }
325
+ catch (err) {
326
+ return emulationError("grant_permissions", err);
327
+ }
328
+ });
329
+ register("tab_visibility", {
330
+ capability: "navigation",
331
+ description: 'Background or foreground the session\'s tab — the only way to reproduce the bug class that only fires when the tab is hidden (throttled setTimeout, paused requestAnimationFrame so framework enter/animation hooks never run, and on-return a visibilitychange/focus handler replays stale state). `state:"background"` overrides document.visibilityState/hidden + dispatches visibilitychange, AND best-effort takes front focus away from the page so real timer/rAF throttling applies (real throttling is best-effort under headless). `state:"background"` with `holdMs` is the headline form: background, hold hidden for holdMs, then auto-foreground — reproducing the background→return transition in one call. `state:"foreground"` restores visibility and re-focuses the tab.',
332
+ inputSchema: {
333
+ state: z
334
+ .enum(["background", "foreground"])
335
+ .describe("background = hide/deprioritise the tab; foreground = restore + re-focus."),
336
+ holdMs: z
337
+ .number()
338
+ .int()
339
+ .positive()
340
+ .max(120_000)
341
+ .optional()
342
+ .describe("background only: hold hidden this long (ms), then auto-foreground. Cap 120000."),
343
+ ...SESSION_ARG,
344
+ },
345
+ }, async ({ state, holdMs, session }) => {
346
+ const g = gateCheck("tab_visibility");
347
+ if (g)
348
+ return g;
349
+ const e = await entryFor(session);
350
+ const result = await setTabVisibility(e.session.page(), e.session.page().context(), state, holdMs);
351
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
352
+ });
353
+ }
@@ -0,0 +1,36 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { PluginRecord } from "../plugin/types.js";
3
+ import type { Capability } from "../util/capabilities.js";
4
+ import type { ToolHost, ToolResponse } from "./host.js";
5
+ /** The createServer-owned pieces the plugin runtime needs that the shared
6
+ * `ToolHost` doesn't surface: the raw MCP server (for plugin-tool
7
+ * registration) and the per-dispatch metrics/diagnostics noters (plugin tools
8
+ * ride the same accounting path as core tools, minus the wedge tracker). */
9
+ export interface PluginRuntimeDeps {
10
+ server: McpServer;
11
+ noteMetrics: (toolName: string, args: unknown, res: ToolResponse, startedAt: number) => void;
12
+ noteDiagnostics: (toolName: string, args: unknown, res: ToolResponse, startedAt: number) => void;
13
+ }
14
+ /** The capability each plugin-info MCP tool gates under (both `read` — they are
15
+ * pure-read introspection over the loaded-plugin set). The SINGLE SOURCE for
16
+ * these two rows: `wirePluginRuntime`'s `register` calls read it (colocated
17
+ * metadata, RFC 0004 P2), and the metadata-collector bootstrap
18
+ * (`tool-metadata.ts`) reads it to derive the rows WITHOUT running the async
19
+ * plugin loader. Keyed by tool name. */
20
+ export declare const PLUGIN_INFO_TOOL_CAPABILITY: Readonly<Record<string, Capability>>;
21
+ /**
22
+ * Plugin runtime wiring — the LAST step of `createServer`, run after every core
23
+ * `register*Tools(host)` call so the `coreToolNames` snapshot below counts the
24
+ * full core surface as "core" and plugins load on top of it.
25
+ *
26
+ * Plugins are loaded ONCE here. Cycle detection is fatal; everything else
27
+ * (capability mismatch, missing dep, malformed manifest, load-time exception)
28
+ * downgrades the affected plugin to a non-`loaded` status and surfaces on
29
+ * `plugins_list`. `set_config({plugins})` persists into the config store but
30
+ * takes effect on NEXT server restart — mirroring the capability lifecycle.
31
+ *
32
+ * Returns the loaded `PluginRecord[]`; `createServer` assigns it to the
33
+ * `pluginRecords` local that `get_config` reports the live enabled-plugin set
34
+ * from (via the host getter).
35
+ */
36
+ export declare function wirePluginRuntime(host: ToolHost, deps: PluginRuntimeDeps): Promise<ReadonlyArray<PluginRecord>>;
@@ -0,0 +1,274 @@
1
+ import { startPluginRuntime } from "../plugin/runtime.js";
2
+ import { RUNTIME_API_VERSION } from "../plugin/manifest.js";
3
+ import { log } from "../util/logging.js";
4
+ /** The capability each plugin-info MCP tool gates under (both `read` — they are
5
+ * pure-read introspection over the loaded-plugin set). The SINGLE SOURCE for
6
+ * these two rows: `wirePluginRuntime`'s `register` calls read it (colocated
7
+ * metadata, RFC 0004 P2), and the metadata-collector bootstrap
8
+ * (`tool-metadata.ts`) reads it to derive the rows WITHOUT running the async
9
+ * plugin loader. Keyed by tool name. */
10
+ export const PLUGIN_INFO_TOOL_CAPABILITY = {
11
+ plugins_list: "read",
12
+ plugins_info: "read",
13
+ };
14
+ /**
15
+ * Plugin runtime wiring — the LAST step of `createServer`, run after every core
16
+ * `register*Tools(host)` call so the `coreToolNames` snapshot below counts the
17
+ * full core surface as "core" and plugins load on top of it.
18
+ *
19
+ * Plugins are loaded ONCE here. Cycle detection is fatal; everything else
20
+ * (capability mismatch, missing dep, malformed manifest, load-time exception)
21
+ * downgrades the affected plugin to a non-`loaded` status and surfaces on
22
+ * `plugins_list`. `set_config({plugins})` persists into the config store but
23
+ * takes effect on NEXT server restart — mirroring the capability lifecycle.
24
+ *
25
+ * Returns the loaded `PluginRecord[]`; `createServer` assigns it to the
26
+ * `pluginRecords` local that `get_config` reports the live enabled-plugin set
27
+ * from (via the host getter).
28
+ */
29
+ export async function wirePluginRuntime(host, deps) {
30
+ const { register, gateCheck, caps, workspace, resolvedConfig, toolHandlers, z } = host;
31
+ const { server, noteMetrics, noteDiagnostics } = deps;
32
+ let pluginRecords = [];
33
+ /** Per-plugin-tool capability map. Populated as the runtime registers
34
+ * tools; `isToolEnabled` consults this first for namespaced tools and
35
+ * falls back to the core map otherwise. */
36
+ const pluginToolCapability = new Map();
37
+ /** Per-plugin-tool ownership map (tool → plugin npm name). Mirrors the
38
+ * runtime's internal liveTools registry so the host-side `ownerOf`
39
+ * hook can answer "who owns tool X" without crossing the runtime
40
+ * boundary. */
41
+ const pluginToolOwner = new Map();
42
+ /** Per-plugin-tool def cache — keeps the description + input schema
43
+ * so `plugins_info` can dump the registered shape. */
44
+ const pluginToolDef = new Map();
45
+ // Snapshot of core tool names at this point — anything registered
46
+ // BEFORE plugin loading is a core tool from the plugin runtime's point
47
+ // of view.
48
+ const coreToolNames = new Set(Object.keys(toolHandlers));
49
+ // Wrap `gateCheck` for plugin tools by patching the active gate
50
+ // check pipeline. We can't reuse the core `gateCheck` directly — it
51
+ // consults `TOOL_CAPABILITY` for the core surface only. The wrapper
52
+ // injected on every plugin tool registration does the check inline.
53
+ const pluginGate = (toolName) => {
54
+ const cap = pluginToolCapability.get(toolName);
55
+ if (cap === undefined)
56
+ return null; // no capability declared → allowed
57
+ if (caps.enabled.has(cap))
58
+ return null;
59
+ return {
60
+ content: [
61
+ {
62
+ type: "text",
63
+ text: JSON.stringify({
64
+ ok: false,
65
+ error: `plugin tool "${toolName}" is disabled — its declared capability is not in the server's ACTIVE set`,
66
+ requiredCapability: cap,
67
+ activeCapabilities: [...caps.enabled],
68
+ hint: "Plugin-declared capabilities are gated the same way as core tools — add the capability to BROWX_CAPABILITIES " +
69
+ "(or set_config({capabilities:[...]})) and RESTART the browxai server.",
70
+ }, null, 2),
71
+ },
72
+ ],
73
+ };
74
+ };
75
+ const registerPluginTool = (name, def, handler, capability, ownerPlugin) => {
76
+ if (capability !== undefined) {
77
+ pluginToolCapability.set(name, capability);
78
+ }
79
+ else {
80
+ pluginToolCapability.set(name, undefined);
81
+ }
82
+ pluginToolOwner.set(name, ownerPlugin);
83
+ pluginToolDef.set(name, def);
84
+ // Plugin tool handler envelope: capability gate → handler → standard
85
+ // metrics + diagnostics wrap. We don't apply the wedge tracker —
86
+ // plugin tools aren't core page-exercising primitives, so the
87
+ // session-wedged stamping path is reserved for browser-touching
88
+ // tools the host owns.
89
+ const wrapped = async (args) => {
90
+ const startedAt = Date.now();
91
+ const gated = pluginGate(name);
92
+ if (gated)
93
+ return gated;
94
+ let inner;
95
+ try {
96
+ inner = await handler(args);
97
+ }
98
+ catch (e) {
99
+ inner = {
100
+ content: [
101
+ {
102
+ type: "text",
103
+ text: JSON.stringify({
104
+ ok: false,
105
+ error: `plugin tool "${name}" threw: ${e instanceof Error ? e.message : String(e)}`,
106
+ }, null, 2),
107
+ },
108
+ ],
109
+ };
110
+ }
111
+ // PluginToolResponse content items match ToolResponse exactly — same
112
+ // shape, kept as parallel types only to draw the API boundary.
113
+ const out = { content: [...inner.content] };
114
+ noteMetrics(name, args, out, startedAt);
115
+ noteDiagnostics(name, args, out, startedAt);
116
+ return out;
117
+ };
118
+ toolHandlers[name] = wrapped;
119
+ // The SDK's `registerTool` generic cannot relate its conditional-typed
120
+ // callback to the plugin def's `Record<string, z.ZodTypeAny>` schema;
121
+ // widening the config's schema to a concrete `z.ZodRawShape` lets that
122
+ // conditional resolve, so `wrapped` (args narrowed to `unknown`, result a
123
+ // `CallToolResult`) matches with no assertion. Mirrors `host-build.ts`.
124
+ const sdkConfig = def;
125
+ server.registerTool(name, sdkConfig, wrapped);
126
+ };
127
+ try {
128
+ const result = await startPluginRuntime({
129
+ workspaceRoot: workspace.root,
130
+ enabledCapabilities: caps.enabled,
131
+ extraDeclared: resolvedConfig.plugins,
132
+ host: {
133
+ isCoreTool: (n) => coreToolNames.has(n),
134
+ dispatch: async (n, args) => {
135
+ const fn = toolHandlers[n];
136
+ if (!fn) {
137
+ return {
138
+ content: [
139
+ {
140
+ type: "text",
141
+ text: JSON.stringify({ ok: false, error: `dispatch: unknown tool "${n}"` }, null, 2),
142
+ },
143
+ ],
144
+ };
145
+ }
146
+ const res = await fn(args);
147
+ return { content: [...res.content] };
148
+ },
149
+ registerTool: registerPluginTool,
150
+ ownerOf: (n) => {
151
+ if (coreToolNames.has(n))
152
+ return undefined;
153
+ return pluginToolOwner.get(n);
154
+ },
155
+ },
156
+ });
157
+ pluginRecords = result.plugins;
158
+ const loaded = pluginRecords.filter((p) => p.status === "loaded");
159
+ log.info("plugin runtime: loaded", {
160
+ apiVersion: RUNTIME_API_VERSION,
161
+ pluginsDeclared: pluginRecords.length,
162
+ pluginsLoaded: loaded.length,
163
+ toolsRegistered: result.toolCount,
164
+ });
165
+ for (const p of pluginRecords) {
166
+ if (p.status !== "loaded") {
167
+ log.warn(`plugin runtime: ${p.manifest.name} status=${p.status} — ${p.statusReason ?? ""}`);
168
+ }
169
+ }
170
+ }
171
+ catch (e) {
172
+ // Cycle errors and only cycle errors abort startup loudly. All other
173
+ // failures get downgraded inside startPluginRuntime to a per-plugin
174
+ // load-error record.
175
+ log.error(`plugin runtime: fatal — ${e instanceof Error ? e.message : String(e)}`);
176
+ throw e;
177
+ }
178
+ // plugins_list / plugins_info MCP tools ( surface).
179
+ register("plugins_list", {
180
+ description: "List every declared browxai plugin and its load status. Each entry carries `{name, namespace, version, trust, capabilities, dependsOn, status, declaredAt, enabledAt?, statusReason?, tools, transitiveDeps}`. `status` is one of `loaded` (live), `disabled-by-capability-mismatch` (plugin declares a capability not in the server's active set), `disabled-by-cycle` (caught at startup — server start would have aborted, so this status only appears in test surfaces), `disabled-by-dep-missing` (a `dependsOn` target isn't installed or fails the version range), `disabled-by-namespace-conflict` (two plugins claimed the same namespace), or `load-error` (manifest invalid, entry module threw, etc.). Read-only — gates under `read`. The plugin runtime is RESOLVED ONCE AT SERVER START; this tool reports the live state, not what `plugins.json` currently declares (use `get_config({scope:'resolved'}).plugins` for that, plus the `pluginsPendingRestart` flag).",
181
+ capability: PLUGIN_INFO_TOOL_CAPABILITY.plugins_list,
182
+ inputSchema: {},
183
+ }, async () => {
184
+ // D3 (RFC 0004 P2): enforce the declared `read` capability at the handler,
185
+ // mirroring the gesture-network per-handler idiom. Without this a direct
186
+ // server dispatch under BROWX_CAPABILITIES=human would EXECUTE this tool
187
+ // despite its derived `read` row (the row alone doesn't gate the handler).
188
+ const g = gateCheck("plugins_list");
189
+ if (g)
190
+ return g;
191
+ const body = {
192
+ ok: true,
193
+ apiVersion: RUNTIME_API_VERSION,
194
+ plugins: pluginRecords.map((p) => ({
195
+ name: p.manifest.name,
196
+ namespace: p.manifest.browxai.namespace || null,
197
+ version: p.manifest.version,
198
+ trust: p.manifest.trust,
199
+ capabilities: p.declaredCapabilities,
200
+ dependsOn: p.manifest.browxai.dependsOn,
201
+ status: p.status,
202
+ declaredAt: p.declaredAt,
203
+ ...(p.enabledAt ? { enabledAt: p.enabledAt } : {}),
204
+ ...(p.statusReason ? { statusReason: p.statusReason } : {}),
205
+ tools: p.tools,
206
+ transitiveDeps: p.transitiveDeps,
207
+ })),
208
+ };
209
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
210
+ });
211
+ register("plugins_info", {
212
+ description: "Full manifest + tool registry dump for ONE plugin. Returns `{name, version, namespace, trust, capabilities, dependsOn, transitiveDeps, status, tools: [{name, description, inputSchema?}]}` so an operator can audit what a plugin contributes to the running surface. Read-only — gates under `read`.",
213
+ capability: PLUGIN_INFO_TOOL_CAPABILITY.plugins_info,
214
+ inputSchema: {
215
+ name: z
216
+ .string()
217
+ .describe('npm package name of the plugin (e.g. "@browxai/plugin-example").'),
218
+ },
219
+ }, async ({ name }) => {
220
+ // D3 (RFC 0004 P2): enforce the declared `read` capability at the handler
221
+ // (see plugins_list above).
222
+ const g = gateCheck("plugins_info");
223
+ if (g)
224
+ return g;
225
+ const p = pluginRecords.find((r) => r.manifest.name === name);
226
+ if (!p) {
227
+ return {
228
+ content: [
229
+ {
230
+ type: "text",
231
+ text: JSON.stringify({
232
+ ok: false,
233
+ error: `plugin "${name}" is not in the declared set`,
234
+ declared: pluginRecords.map((r) => r.manifest.name),
235
+ }, null, 2),
236
+ },
237
+ ],
238
+ };
239
+ }
240
+ const tools = p.tools.map((tName) => {
241
+ const def = pluginToolDef.get(tName);
242
+ return {
243
+ name: tName,
244
+ description: def?.description ?? null,
245
+ // Best-effort schema introspection — Zod schemas are runtime
246
+ // objects, but we can surface the field names so the operator
247
+ // sees the input shape. Full JSON-Schema lowering is deferred.
248
+ inputFields: def?.inputSchema ? Object.keys(def.inputSchema).sort() : [],
249
+ };
250
+ });
251
+ const body = {
252
+ ok: true,
253
+ name: p.manifest.name,
254
+ version: p.manifest.version,
255
+ description: p.manifest.description ?? null,
256
+ path: p.manifest.path,
257
+ entryPath: p.manifest.entryPath,
258
+ namespace: p.manifest.browxai.namespace || null,
259
+ trust: p.manifest.trust,
260
+ capabilities: p.declaredCapabilities,
261
+ dependsOn: p.manifest.browxai.dependsOn,
262
+ transitiveDeps: p.transitiveDeps,
263
+ status: p.status,
264
+ statusReason: p.statusReason ?? null,
265
+ declaredAt: p.declaredAt,
266
+ enabledAt: p.enabledAt ?? null,
267
+ apiVersion: p.manifest.browxai.apiVersion,
268
+ browxaiVersion: p.manifest.browxai.browxaiVersion ?? null,
269
+ tools,
270
+ };
271
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
272
+ });
273
+ return pluginRecords;
274
+ }
@@ -0,0 +1,9 @@
1
+ import type { ToolHost } from "./host.js";
2
+ /**
3
+ * Read / observe — buffer reads + element diagnostics. The session ring-buffer
4
+ * reads (console_read / network_read / ws_read / network_body), the DOM-metric
5
+ * sampler + window watcher, element inspection / locator generation / point
6
+ * probing, and the gated `eval_js` escape hatch. Registered through the shared
7
+ * `ToolHost` seam.
8
+ */
9
+ export declare function registerReadObserveBufferTools(host: ToolHost): void;