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,316 @@
1
+ import { requireCdp } from "../engine/index.js";
2
+ import { verifyVisible, verifyText, verifyValue, verifyCount, verifyAttribute, verifyPredicate, } from "../page/verify.js";
3
+ import { withDeadline } from "../util/deadline.js";
4
+ import { estimateTokens } from "../util/tokens.js";
5
+ import { REF_OR_SELECTOR, SESSION_ARG } from "./schemas.js";
6
+ /**
7
+ * Read / observe — the assertive verify_* family. Fail-emitting siblings of
8
+ * `wait_for`: each asserts a page condition NOW and returns `ok:false` with a
9
+ * structured `failure` on a miss. Read-only; registered through the shared
10
+ * `ToolHost` seam.
11
+ */
12
+ export function registerReadObserveVerifyTools(host) {
13
+ const { z, register, gateCheck, entryFor, asTarget, cfgActionTimeout, caps, config } = host;
14
+ // ---------- verify-family — assertive read primitives ----------
15
+ // Shared inputs for the element-targeted verify_* tools. Same target shape
16
+ // as the action surface (ref / selector / named — coords not allowed; a
17
+ // verify needs a structural identity, not a pixel).
18
+ const VERIFY_TARGET = {
19
+ ref: REF_OR_SELECTOR.ref,
20
+ selector: REF_OR_SELECTOR.selector,
21
+ named: REF_OR_SELECTOR.named,
22
+ contextRef: REF_OR_SELECTOR.contextRef,
23
+ ...SESSION_ARG,
24
+ };
25
+ /** Wrap a `VerifyResult` in the standard JSON envelope with `tokensEstimate`.
26
+ * Same `{ok, failure}` shape across the whole family.
27
+ *
28
+ * Secrets-masking: when `e` is supplied and the `secrets` capability is on,
29
+ * the body is run through `applyMaskDeep` BEFORE token-counting and
30
+ * envelope construction. The load-bearing path is `failure.actual` for
31
+ * `verify_text` / `verify_value` / `verify_attribute` — these echo the
32
+ * element's real innerText / value / attribute on a miss, which is a
33
+ * direct value-disclosure of any registered secret. Callers that don't
34
+ * thread a session entry (no page-derived strings) pass `undefined`. */
35
+ const verifyResultText = (res, e) => {
36
+ const rawBody = res.ok ? { ok: true } : { ok: false, failure: res.failure };
37
+ const body = e && caps.enabled.has("secrets") ? e.secrets.applyMaskDeep(rawBody) : rawBody;
38
+ const tokensEstimate = estimateTokens(JSON.stringify(body));
39
+ return {
40
+ content: [
41
+ { type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
42
+ ],
43
+ };
44
+ };
45
+ register("verify_visible", {
46
+ capability: "read",
47
+ batchable: true,
48
+ description: 'Assertive sibling of `wait_for`: fail-emitting (`ok:false` + `failure:{source,kind,expected,actual}`) instead of permissive (`wait_for` returns ok:false on deadline expiry as a normal outcome). Use to terminate retry loops deterministically: "this element MUST be visible right now, else fail loudly." Read-only. `source:"app"` when the element isn\'t visible (the assertion failed against the page); `source:"browxai"` when verify itself couldn\'t run (ref no longer in the snapshot, etc).',
49
+ inputSchema: VERIFY_TARGET,
50
+ }, async (args) => {
51
+ const g = gateCheck("verify_visible");
52
+ if (g)
53
+ return g;
54
+ const e = await entryFor(args.session);
55
+ const target = asTarget(args, "verify_visible", e.refs);
56
+ if ("coords" in target) {
57
+ return verifyResultText({
58
+ ok: false,
59
+ failure: {
60
+ source: "browxai",
61
+ kind: "visible",
62
+ expected: "ref/selector/named target",
63
+ actual: "coords target",
64
+ },
65
+ }, e);
66
+ }
67
+ try {
68
+ const res = await withDeadline(verifyVisible(e.session.page(), e.refs, target), cfgActionTimeout(), "verify_visible");
69
+ return verifyResultText(res, e);
70
+ }
71
+ catch (err) {
72
+ return verifyResultText({
73
+ ok: false,
74
+ failure: {
75
+ source: "browxai",
76
+ kind: "visible",
77
+ expected: "verify_visible to complete",
78
+ actual: err instanceof Error ? err.message : String(err),
79
+ },
80
+ }, e);
81
+ }
82
+ });
83
+ register("verify_text", {
84
+ capability: "read",
85
+ batchable: true,
86
+ description: "Assert the targeted element's visible text matches. Fail-emitting (`ok:false` + structured `failure`) — distinct from `text_search` (which counts matches over the whole page) and `wait_for` (permissive). Default substring + case-insensitive; pass `exact:true` for case-sensitive equality on the trimmed text. Read-only.",
87
+ inputSchema: {
88
+ ...VERIFY_TARGET,
89
+ text: z.string().describe("Text to assert against the element's visible text."),
90
+ exact: z
91
+ .boolean()
92
+ .optional()
93
+ .describe("Default false (case-insensitive substring). When true, case-sensitive equality on trimmed innerText."),
94
+ },
95
+ }, async (args) => {
96
+ const g = gateCheck("verify_text");
97
+ if (g)
98
+ return g;
99
+ const e = await entryFor(args.session);
100
+ const target = asTarget(args, "verify_text", e.refs);
101
+ if ("coords" in target) {
102
+ return verifyResultText({
103
+ ok: false,
104
+ failure: {
105
+ source: "browxai",
106
+ kind: "text",
107
+ expected: "ref/selector/named target",
108
+ actual: "coords target",
109
+ },
110
+ }, e);
111
+ }
112
+ try {
113
+ const res = await withDeadline(verifyText(e.session.page(), e.refs, target, args.text, args.exact === true), cfgActionTimeout(), "verify_text");
114
+ return verifyResultText(res, e);
115
+ }
116
+ catch (err) {
117
+ return verifyResultText({
118
+ ok: false,
119
+ failure: {
120
+ source: "browxai",
121
+ kind: "text",
122
+ expected: "verify_text to complete",
123
+ actual: err instanceof Error ? err.message : String(err),
124
+ },
125
+ }, e);
126
+ }
127
+ });
128
+ register("verify_value", {
129
+ capability: "read",
130
+ batchable: true,
131
+ description: "Assert the targeted form-control's current value (input/textarea/select/contenteditable). Fail-emitting (`ok:false` + structured `failure`). Use to confirm a controlled-component fill landed without an extra round-trip — pairs with `ActionResult.element.value` from `fill`. Read-only.",
132
+ inputSchema: {
133
+ ...VERIFY_TARGET,
134
+ value: z
135
+ .string()
136
+ .describe("Expected value (strict equality after String() of the DOM-side `value`)."),
137
+ },
138
+ }, async (args) => {
139
+ const g = gateCheck("verify_value");
140
+ if (g)
141
+ return g;
142
+ const e = await entryFor(args.session);
143
+ const target = asTarget(args, "verify_value", e.refs);
144
+ if ("coords" in target) {
145
+ return verifyResultText({
146
+ ok: false,
147
+ failure: {
148
+ source: "browxai",
149
+ kind: "value",
150
+ expected: "ref/selector/named target",
151
+ actual: "coords target",
152
+ },
153
+ }, e);
154
+ }
155
+ try {
156
+ const res = await withDeadline(verifyValue(e.session.page(), e.refs, target, args.value), cfgActionTimeout(), "verify_value");
157
+ return verifyResultText(res, e);
158
+ }
159
+ catch (err) {
160
+ return verifyResultText({
161
+ ok: false,
162
+ failure: {
163
+ source: "browxai",
164
+ kind: "value",
165
+ expected: "verify_value to complete",
166
+ actual: err instanceof Error ? err.message : String(err),
167
+ },
168
+ }, e);
169
+ }
170
+ });
171
+ register("verify_count", {
172
+ capability: "read",
173
+ batchable: true,
174
+ description: 'Assert exactly `n` elements match. Pass one of `selector` (raw CSS / Playwright locator) or `text` (case-insensitive visible-text search over the composed a11y tree, same shape as `text_search`). Fail-emitting (`ok:false` + structured `failure`). Use for grid/list invariants — "there are 5 rows after the delete", "no \'Wrong Type\' values left in the table". Read-only.',
175
+ inputSchema: {
176
+ selector: z
177
+ .string()
178
+ .optional()
179
+ .describe("CSS / selectorHint to count. Mutually exclusive with `text`."),
180
+ text: z
181
+ .string()
182
+ .optional()
183
+ .describe("Visible text to count (case-insensitive substring across the a11y tree)."),
184
+ n: z.number().int().nonnegative().describe("Exact expected count."),
185
+ ...SESSION_ARG,
186
+ },
187
+ }, async (args) => {
188
+ const g = gateCheck("verify_count");
189
+ if (g)
190
+ return g;
191
+ const e = await entryFor(args.session);
192
+ try {
193
+ const res = await withDeadline(verifyCount(e.session.page(), requireCdp(e.session), e.refs, {
194
+ selector: args.selector,
195
+ text: args.text,
196
+ n: args.n,
197
+ testAttributes: config.testAttributes,
198
+ }), cfgActionTimeout(), "verify_count");
199
+ return verifyResultText(res, e);
200
+ }
201
+ catch (err) {
202
+ return verifyResultText({
203
+ ok: false,
204
+ failure: {
205
+ source: "browxai",
206
+ kind: "count",
207
+ expected: "verify_count to complete",
208
+ actual: err instanceof Error ? err.message : String(err),
209
+ },
210
+ }, e);
211
+ }
212
+ });
213
+ register("verify_attribute", {
214
+ capability: "read",
215
+ batchable: true,
216
+ description: "Assert the targeted element's HTML attribute matches. Pass `value` to require equality; omit `value` to require presence (any value). Fail-emitting (`ok:false` + structured `failure`). Use for `aria-*` / `data-*` / `disabled` / role state that doesn't surface as visible text. Read-only.",
217
+ inputSchema: {
218
+ ...VERIFY_TARGET,
219
+ attr: z
220
+ .string()
221
+ .describe('Attribute name to read (e.g. "aria-pressed", "data-state", "disabled").'),
222
+ value: z
223
+ .string()
224
+ .optional()
225
+ .describe("Expected attribute value (strict string equality). Omit to assert the attribute is merely present."),
226
+ },
227
+ }, async (args) => {
228
+ const g = gateCheck("verify_attribute");
229
+ if (g)
230
+ return g;
231
+ const e = await entryFor(args.session);
232
+ const target = asTarget(args, "verify_attribute", e.refs);
233
+ if ("coords" in target) {
234
+ return verifyResultText({
235
+ ok: false,
236
+ failure: {
237
+ source: "browxai",
238
+ kind: "attribute",
239
+ expected: "ref/selector/named target",
240
+ actual: "coords target",
241
+ },
242
+ }, e);
243
+ }
244
+ try {
245
+ const res = await withDeadline(verifyAttribute(e.session.page(), e.refs, target, args.attr, args.value), cfgActionTimeout(), "verify_attribute");
246
+ return verifyResultText(res, e);
247
+ }
248
+ catch (err) {
249
+ return verifyResultText({
250
+ ok: false,
251
+ failure: {
252
+ source: "browxai",
253
+ kind: "attribute",
254
+ expected: "verify_attribute to complete",
255
+ actual: err instanceof Error ? err.message : String(err),
256
+ },
257
+ }, e);
258
+ }
259
+ });
260
+ // Recursive predicate shape — z.lazy lets the schema reference itself for
261
+ // the and/or/not combinators. NOT an arbitrary-JS path: the `kind` enum and
262
+ // `key` accessor list are fixed server-side (see src/util/predicates.ts).
263
+ const PREDICATE_SCHEMA = z.lazy(() => z.union([
264
+ z.object({
265
+ kind: z.enum([
266
+ "equals",
267
+ "notEquals",
268
+ "contains",
269
+ "notContains",
270
+ "gt",
271
+ "lt",
272
+ "gte",
273
+ "lte",
274
+ "matches",
275
+ "exists",
276
+ ]),
277
+ key: z
278
+ .string()
279
+ .describe('Dotted accessor into `data` (e.g. "actionResult.element.value"). Must start with an allow-listed root (actionResult, snapshot, element, value, expect).'),
280
+ value: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),
281
+ }),
282
+ z.object({
283
+ kind: z.literal("between"),
284
+ key: z.string(),
285
+ lo: z.number(),
286
+ hi: z.number(),
287
+ }),
288
+ z.object({
289
+ kind: z.enum(["and", "or", "not"]),
290
+ predicates: z.array(PREDICATE_SCHEMA).min(1),
291
+ }),
292
+ ]));
293
+ register("verify_predicate", {
294
+ capability: "read",
295
+ batchable: true,
296
+ description: 'Composed predicate check over a caller-supplied `data` bag — fixed vocabulary, NOT arbitrary JS. The predicate `kind` is a fixed enum (`equals`/`notEquals`/`contains`/`notContains`/`gt`/`lt`/`gte`/`lte`/`between`/`matches`/`exists`, plus `and`/`or`/`not` combinators). The accessor `key` must start with an allow-listed root: `actionResult`, `snapshot`, `element`, `value`, `expect`. The model supplies *data* (which key, which expected value); the *vocabulary* is server-owned. Use as a deterministic gate on an already-captured ActionResult / snapshot / metric (the screenshot-judge analogue when chained behind a `screenshot`). Fail-emitting: `source:"app"` when the predicate didn\'t hold; `source:"browxai"` when the predicate shape itself is malformed. `eval_js` (gated behind `eval`) remains the only arbitrary-JS path — verify_predicate does NOT add a second.',
297
+ inputSchema: {
298
+ predicate: PREDICATE_SCHEMA.describe("The predicate to evaluate. Recursive shape — and/or/not nest leaf predicates."),
299
+ data: z
300
+ .record(z.unknown())
301
+ .describe("Bag the predicate reads from. Typically `{ actionResult: <prior result>, snapshot?: <prior snapshot output>, element?: {...} }`. Accessor keys are resolved against this object; only allow-listed root segments are honoured."),
302
+ ...SESSION_ARG,
303
+ },
304
+ }, async (args) => {
305
+ const g = gateCheck("verify_predicate");
306
+ if (g)
307
+ return g;
308
+ // Resolve the session entry so `failure.actual` (which may echo a
309
+ // string lifted from the caller-supplied `data` bag — e.g. a prior
310
+ // ActionResult.element.value that pre-dated masking) gets re-masked
311
+ // through the same egress chokepoint as the other verify_* tools.
312
+ const e = await entryFor(args.session);
313
+ const res = verifyPredicate(args.predicate, args.data);
314
+ return verifyResultText(res, e);
315
+ });
316
+ }
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ export declare const SESSION_ARG: {
3
+ session: z.ZodOptional<z.ZodString>;
4
+ };
5
+ export declare const TIMEOUT_ARG: {
6
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
7
+ };
8
+ export declare const ACTION_OPTS: {
9
+ session: z.ZodOptional<z.ZodString>;
10
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
11
+ mode: z.ZodOptional<z.ZodEnum<["scoped_snapshot", "tree_diff", "full", "none"]>>;
12
+ maxResultTokens: z.ZodOptional<z.ZodNumber>;
13
+ };
14
+ export declare const REF_OR_SELECTOR: {
15
+ ref: z.ZodOptional<z.ZodString>;
16
+ selector: z.ZodOptional<z.ZodString>;
17
+ named: z.ZodOptional<z.ZodString>;
18
+ contextRef: z.ZodOptional<z.ZodString>;
19
+ coords: z.ZodOptional<z.ZodObject<{
20
+ x: z.ZodNumber;
21
+ y: z.ZodNumber;
22
+ }, "strip", z.ZodTypeAny, {
23
+ y: number;
24
+ x: number;
25
+ }, {
26
+ y: number;
27
+ x: number;
28
+ }>>;
29
+ };
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+ // Shared input-schema fragments for the MCP tool surface. These live in a leaf
3
+ // module — depended on by both the composition root (`createServer`) and the
4
+ // per-family tool modules under `src/tools/` — so neither side has to import the
5
+ // other. Keeping them here is what lets `action-tools.ts` depend on the host
6
+ // seam alone instead of reaching back into `../server.js` (which would close an
7
+ // import cycle).
8
+ const SNAPSHOT_MODE = z.enum(["scoped_snapshot", "tree_diff", "full", "none"]).optional();
9
+ // every browser-touching tool accepts an optional `session` id.
10
+ // Omitting it resolves to the lazily-created "default" session — byte-identical
11
+ // to pre-2.5 single-session behaviour. Distinct ids get fully isolated state
12
+ // (own RefRegistry, own BrowserContext / cookie jar, own buffers).
13
+ export const SESSION_ARG = {
14
+ session: z
15
+ .string()
16
+ .optional()
17
+ .describe('Session id (default "default"). Each id is an isolated browser context (own cookie jar, own refs). Open non-default sessions with open_session; list with list_sessions.'),
18
+ };
19
+ // per-call anti-wedge override. Default comes from config
20
+ // `actionTimeoutMs` (5000). The wording deliberately deters large values.
21
+ export const TIMEOUT_ARG = {
22
+ timeoutMs: z
23
+ .number()
24
+ .int()
25
+ .positive()
26
+ .max(3_600_000)
27
+ .optional()
28
+ .describe("Anti-wedge hard deadline for this call (ms). Default 5000 (config `actionTimeoutMs`). " +
29
+ "An action needing >5s is almost always a no-op or a wedged page op. When a call " +
30
+ "times out, the fix is to retry it ONCE or — if timeouts keep recurring — discard " +
31
+ "the session (`close_session` then `open_session`), NOT a bigger timeout: raising " +
32
+ "this never recovers a wedged session. Raise it ONLY for one specific known-slow " +
33
+ "call, never as a blanket. Values approaching the 3600000 (1h) ceiling are " +
34
+ "essentially always a mistake; over-ceiling is clamped + warned."),
35
+ };
36
+ export const ACTION_OPTS = {
37
+ mode: SNAPSHOT_MODE,
38
+ maxResultTokens: z.number().int().positive().max(20_000).optional(),
39
+ ...TIMEOUT_ARG,
40
+ ...SESSION_ARG,
41
+ };
42
+ // `target` accepts ref *or* selector *or* named *or* coords. Validated at
43
+ // handler time. `contextRef` optionally scopes a `selector` to a prior ref's
44
+ // subtree. `coords` is the escape hatch for visually-located targets (canvas,
45
+ // custom-painted UIs, dismiss-empty-space) — only click/hover honour it.
46
+ export const REF_OR_SELECTOR = {
47
+ ref: z.string().optional().describe("Stable [eN] ref from snapshot()/find()"),
48
+ selector: z.string().optional().describe("CSS / selectorHint fallback"),
49
+ named: z.string().optional().describe("Mnemonic name previously bound with name_ref"),
50
+ contextRef: z
51
+ .string()
52
+ .optional()
53
+ .describe("Resolve `selector` within the subtree of this ref (from a prior snapshot/find). Lets you say 'the X *inside* this row/card/panel' without baking positional :nth chains into the selector. Ignored when `ref` or `named` is used."),
54
+ coords: z
55
+ .object({ x: z.number(), y: z.number() })
56
+ .optional()
57
+ .describe("Page-coordinate target {x,y} (CSS pixels, viewport-relative). Escape hatch for canvas / custom-painted UIs / dismiss-empty-space cases that ref/selector resolution can't address. Honoured by `click` and `hover` only; ignored elsewhere."),
58
+ };
@@ -0,0 +1,9 @@
1
+ import type { ToolHost } from "./host.js";
2
+ /**
3
+ * Secrets / captcha / credentials tools — the off-by-default egress-sensitive
4
+ * seams: `register_secret` (the per-session secrets registry that backs egress
5
+ * masking), `solve_captcha` (the provider-bridge), and `get_totp` /
6
+ * `get_credential` (the credentials provider). Registered through the shared
7
+ * `ToolHost` seam.
8
+ */
9
+ export declare function registerSecretsCaptchaTools(host: ToolHost): void;
@@ -0,0 +1,231 @@
1
+ import { resolveCaptchaProvider, submitToProvider, unconfiguredFailure, } from "../page/solve-captcha.js";
2
+ import { applyCredentialToRegistry } from "../util/credentials.js";
3
+ import { estimateTokens } from "../util/tokens.js";
4
+ import { SESSION_ARG } from "./schemas.js";
5
+ /** Stamp a captcha result body with its token estimate and wrap it as a tool
6
+ * text response — the shared shape every solve_captcha envelope uses. */
7
+ function captchaJsonResult(body) {
8
+ const withTokens = { ...body, tokensEstimate: estimateTokens(JSON.stringify(body)) };
9
+ return { content: [{ type: "text", text: JSON.stringify(withTokens, null, 2) }] };
10
+ }
11
+ /** Read the widget site-key from a selector — `data-sitekey` (the
12
+ * reCAPTCHA/hCaptcha/Turnstile convention) first, then common alternatives.
13
+ * Returns undefined when the selector misses or carries no key. */
14
+ async function readSiteKeyFromSelector(page, selector) {
15
+ try {
16
+ const handle = await page.$(selector);
17
+ if (!handle)
18
+ return undefined;
19
+ const key = (await handle.getAttribute("data-sitekey")) ??
20
+ (await handle.getAttribute("data-site-key")) ??
21
+ (await handle.getAttribute("sitekey")) ??
22
+ undefined;
23
+ await handle.dispose().catch(() => undefined);
24
+ return key;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
30
+ /**
31
+ * Secrets / captcha / credentials tools — the off-by-default egress-sensitive
32
+ * seams: `register_secret` (the per-session secrets registry that backs egress
33
+ * masking), `solve_captcha` (the provider-bridge), and `get_totp` /
34
+ * `get_credential` (the credentials provider). Registered through the shared
35
+ * `ToolHost` seam.
36
+ */
37
+ export function registerSecretsCaptchaTools(host) {
38
+ const { z, register, gateCheck, entryFor, caps, credentialsResolved } = host;
39
+ // ---------- secrets registry (capability `secrets`) ----------
40
+ register("register_secret", {
41
+ capability: "secrets",
42
+ description: 'Register a sensitive value the agent will use without ever seeing the real string in any tool result. **Gated behind the off-by-default `secrets` capability** — same posture class as `eval` / `network-body` / `disableWebSecurity`. Pair: the agent calls `fill({value:"<NAME>"})` / `press({key:"<NAME>"})` and the runtime substitutes the registered real value AT dispatch (so the page receives the actual string), while EVERY egress sink — `ActionResult.network`, `network_read`, `network_body`, `ws_read`, `console_read`, `snapshot`, `find` evidence — strips occurrences of the real value back to `<NAME>` before returning to the agent. `name` must match `/^[A-Z][A-Z0-9_]*$/` (uppercase identifier — the `<NAME>` mask is the stable contract). Optional `scope` (URL substring, case-insensitive) narrows the *dispatch* side: a scoped secret won\'t be substituted into a `fill` whose page URL doesn\'t contain the scope (refuses with a clear error). Per-session registry, capped at 32 entries. `screenshot` is a PARTIAL sink: when the page\'s text content contains a registered value, a warning is appended; pixel-level redaction (region-blur) is deferred — call snapshot/find for verified-clean evidence instead. NEVER re-emits or logs the real value.',
43
+ inputSchema: {
44
+ name: z
45
+ .string()
46
+ .describe('Agent-facing alias, e.g. "PASSWORD" / "OTP" / "SESSION_TOKEN". Uppercase identifier — `<NAME>` mask format.'),
47
+ value: z
48
+ .string()
49
+ .describe("The real secret value. Stored per-session in memory only; never persisted, never logged."),
50
+ scope: z
51
+ .string()
52
+ .optional()
53
+ .describe("Optional URL substring (case-insensitive). When set, dispatch-side substitution refuses if the current page URL doesn't contain the scope (prevents cross-origin leak). Egress masking is global regardless."),
54
+ ...SESSION_ARG,
55
+ },
56
+ }, async ({ name, value, scope, session, }) => {
57
+ const g = gateCheck("register_secret");
58
+ if (g)
59
+ return g;
60
+ const e = await entryFor(session);
61
+ try {
62
+ e.secrets.register({ name, value, ...(scope ? { scope } : {}) });
63
+ }
64
+ catch (err) {
65
+ return {
66
+ content: [
67
+ {
68
+ type: "text",
69
+ text: JSON.stringify({ ok: false, error: err instanceof Error ? err.message : String(err) }, null, 2),
70
+ },
71
+ ],
72
+ };
73
+ }
74
+ const body = {
75
+ ok: true,
76
+ registered: name,
77
+ scope: scope ?? null,
78
+ // never echo the value back. Echo only the registered names — useful
79
+ // for the agent to confirm what aliases are live without leaking.
80
+ names: e.secrets.names(),
81
+ tokensEstimate: estimateTokens(JSON.stringify({ ok: true, registered: name, scope, names: e.secrets.names() })),
82
+ };
83
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
84
+ });
85
+ // ---------- captcha solver delegation (capability `captcha`) ----------
86
+ //
87
+ // `solve_captcha` is a delegation seam — it POSTs the captcha challenge to a
88
+ // provider configured per-deployment via environment variables
89
+ // (BROWX_CAPTCHA_PROVIDER + BROWX_CAPTCHA_API_KEY, optional
90
+ // BROWX_CAPTCHA_API_BASE / BROWX_CAPTCHA_TIMEOUT_MS / BROWX_CAPTCHA_POLL_MS).
91
+ // browxai does NOT bundle a solver and does NOT auto-purchase credits — when
92
+ // the capability is on but no provider is configured the tool returns a
93
+ // structured failure with a clear "no provider configured" hint. Loud-warned
94
+ // at boot (see the `captcha` warning above). Targets the 2Captcha-
95
+ // compatible HTTP API for v0.2.0 (`/in.php` submit + `/res.php` poll);
96
+ // CapMonster Cloud mirrors the same shape. Other providers can be added by
97
+ // extending src/page/solve-captcha.ts.
98
+ register("solve_captcha", {
99
+ capability: "captcha",
100
+ description: "Delegate a captcha challenge to a configured external provider (2Captcha / CapMonster / etc — provider speaks the 2Captcha-compatible REST API). **Gated behind the off-by-default `captcha` capability** — same posture class as `eval` / `network-body` / `secrets` / `extensions` / `stealth`. SOLVING CAPTCHAS MAY VIOLATE THE TARGET SITE'S TERMS OF SERVICE; the operator carries the legal exposure. " +
101
+ "Provider config is per-deployment via environment variables: BROWX_CAPTCHA_PROVIDER (`2captcha` or `capmonster`) + BROWX_CAPTCHA_API_KEY; optional BROWX_CAPTCHA_API_BASE / BROWX_CAPTCHA_TIMEOUT_MS / BROWX_CAPTCHA_POLL_MS. **browxai does NOT bundle a solver and does NOT auto-purchase credits** — when the capability is on but no provider is configured the tool returns a structured `ok:false` with a clear `no provider configured` hint. " +
102
+ "For widget captchas (`recaptcha2`, `recaptcha3`, `hcaptcha`, `turnstile`), supply the page's site-key via `siteKey` OR `selector` (when given, the server reads `data-sitekey` from the selected element on the current page). For `image`, supply `imageBase64` (raw base64, no data URL prefix). Returns `{ok, provider, solution, taskId, elapsedMs}` on success — the agent then types `solution` into the hidden form field / invokes the page's recaptcha callback. We do NOT auto-submit the solution; how to wire it into the page is per-site.",
103
+ inputSchema: {
104
+ type: z
105
+ .enum(["recaptcha2", "recaptcha3", "hcaptcha", "turnstile", "image"])
106
+ .describe("Captcha kind. `recaptcha2` = checkbox or invisible v2; `recaptcha3` = score-based v3; `hcaptcha` = hCaptcha widget; `turnstile` = Cloudflare Turnstile; `image` = base64 image upload (caller provides `imageBase64`)."),
107
+ selector: z
108
+ .string()
109
+ .optional()
110
+ .describe("CSS selector for the captcha widget element on the current page. When given, the server reads `data-sitekey` (or equivalent) from the element to populate `siteKey`. Either `selector` or `siteKey` is required for widget captchas."),
111
+ siteKey: z
112
+ .string()
113
+ .optional()
114
+ .describe("Explicit site-key for the captcha widget (alternative to `selector`). Required for widget captchas when `selector` is not given."),
115
+ imageBase64: z
116
+ .string()
117
+ .optional()
118
+ .describe("Raw base64-encoded image bytes (no `data:image/...;base64,` prefix). Required for `image` type; ignored for widget types."),
119
+ ...SESSION_ARG,
120
+ },
121
+ }, async ({ type, selector, siteKey, imageBase64, session, }) => {
122
+ const g = gateCheck("solve_captcha");
123
+ if (g)
124
+ return g;
125
+ // Resolve provider config fresh per call so an operator can rotate creds
126
+ // via env without restarting (env is the source of truth).
127
+ const cfg = resolveCaptchaProvider(process.env);
128
+ if (!cfg.ok) {
129
+ if (cfg.reason === "unconfigured")
130
+ return captchaJsonResult(unconfiguredFailure());
131
+ return captchaJsonResult({
132
+ ok: false,
133
+ provider: null,
134
+ error: cfg.error ?? "captcha provider config is incomplete",
135
+ hint: "Set BROWX_CAPTCHA_PROVIDER and BROWX_CAPTCHA_API_KEY together. browxai does NOT bundle a solver and does NOT auto-purchase credits.",
136
+ });
137
+ }
138
+ const e = await entryFor(session);
139
+ let pageUrl;
140
+ try {
141
+ pageUrl = e.session.page().url();
142
+ }
143
+ catch {
144
+ return captchaJsonResult({
145
+ ok: false,
146
+ provider: cfg.config.provider,
147
+ error: "session has no active page",
148
+ hint: "Call open_session + navigate first.",
149
+ });
150
+ }
151
+ // Resolve siteKey: explicit > selector-derived. For `image` neither is
152
+ // needed (imageBase64 is the payload).
153
+ let resolvedSiteKey = siteKey;
154
+ if (!resolvedSiteKey && selector && type !== "image") {
155
+ resolvedSiteKey = await readSiteKeyFromSelector(e.session.page(), selector);
156
+ if (!resolvedSiteKey) {
157
+ return captchaJsonResult({
158
+ ok: false,
159
+ provider: cfg.config.provider,
160
+ error: `solve_captcha: could not read a site-key attribute from selector "${selector}"`,
161
+ hint: "Pass `siteKey` explicitly, or pass a `selector` that points at an element carrying `data-sitekey` (the standard reCAPTCHA / hCaptcha / Turnstile widget attribute).",
162
+ });
163
+ }
164
+ }
165
+ const result = await submitToProvider({
166
+ type,
167
+ pageUrl,
168
+ ...(resolvedSiteKey ? { siteKey: resolvedSiteKey } : {}),
169
+ ...(imageBase64 ? { imageBase64 } : {}),
170
+ }, cfg.config);
171
+ // Mask the solution through the per-session secrets registry so a
172
+ // solver-issued token containing a registered value (unlikely but
173
+ // defensible) doesn't bypass the egress layer.
174
+ const masked = e.secrets.applyMaskDeep(result);
175
+ const body = { ...masked, tokensEstimate: estimateTokens(JSON.stringify(masked)) };
176
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
177
+ });
178
+ // ---------- credentials hook (capability `credentials`) ----------
179
+ //
180
+ // Pluggable TOTP / username+password lookup against an operator-configured
181
+ // vault. Off-by-default; loud-warned at boot. Provider is per-deployment,
182
+ // NEVER bundled. `get_credential` ADDITIONALLY requires the `secrets`
183
+ // capability (auto-registers the looked-up password into the secrets-mask
184
+ // registry under `<PASSWORD_<account>>` — without `secrets`, the lookup
185
+ // refuses rather than leak cleartext into the result).
186
+ register("get_totp", {
187
+ capability: "credentials",
188
+ description: "Look up a one-time TOTP code from the deployment's configured credentials vault. **Gated behind the off-by-default `credentials` capability** — same posture class as `eval` / `network-body` / `secrets`. Provider is selected per-deployment via `BROWX_CREDENTIALS_PROVIDER` (`oathtool` default — no paid dependency, seeds via env or file; or `1password` / `bitwarden` / `lastpass` via their respective CLIs the operator installs out-of-band). Returns `{ok, code, provider}` on success; `{ok:false, error, hint, provider}` on failure (missing seed / CLI not on PATH / CLI not logged in — actionable hint included). TOTP codes are NOT masked through the secrets registry: a TOTP is single-use and short-lived, so masking buys little while complicating verify-step flows — the code is returned in plaintext so the agent can pass it to `fill({value: code})` or compare against on-page text. `account` semantics depend on the provider (oathtool: a key from `BROWX_OATHTOOL_SEEDS`; 1password/bitwarden/lastpass: an item name / id the CLI accepts).",
189
+ inputSchema: {
190
+ account: z
191
+ .string()
192
+ .describe("Provider-specific account identifier (oathtool seed key / 1password item name / bitwarden item id / lastpass item name)."),
193
+ },
194
+ }, async ({ account }) => {
195
+ const g = gateCheck("get_totp");
196
+ if (g)
197
+ return g;
198
+ const result = await credentialsResolved.provider.getTotp(account);
199
+ const body = {
200
+ ...result,
201
+ tokensEstimate: estimateTokens(JSON.stringify(result)),
202
+ };
203
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
204
+ });
205
+ register("get_credential", {
206
+ capability: "credentials",
207
+ description: 'Look up a `{username, password}` pair from the deployment\'s configured credentials vault. **Gated behind the off-by-default `credentials` capability** AND additionally requires the `secrets` capability (without it the lookup refuses — returning a password in cleartext would leak it into the transcript on first reference). On success, the password is AUTO-REGISTERED into the per-session secrets registry under `<PASSWORD_<account>>` (account name sanitised to `/^[A-Z][A-Z0-9_]*$/`); the agent then passes `fill({value: "<PASSWORD_acct>"})` and the runtime materialises the real value AT Playwright dispatch. The returned object carries `{ok, username, aliasName, provider}` — **never the cleartext password**. Pair with `get_totp` for the 2FA half. `oathtool` provider does NOT support `get_credential` (TOTP-only) — pair with a credential-bearing provider. `account` semantics are provider-specific (1password: item name; bitwarden: item id; lastpass: item name).',
208
+ inputSchema: {
209
+ account: z
210
+ .string()
211
+ .describe("Provider-specific account identifier — see the per-provider notes in docs/tool-reference.md."),
212
+ ...SESSION_ARG,
213
+ },
214
+ }, async ({ account, session }) => {
215
+ const g = gateCheck("get_credential");
216
+ if (g)
217
+ return g;
218
+ const e = await entryFor(session);
219
+ const raw = (await credentialsResolved.provider.getCredential(account));
220
+ // `applyCredentialToRegistry` enforces the `secrets`-capability
221
+ // pairing rule and strips `_password` before the result leaves this
222
+ // module — so the response we serialise never contains cleartext.
223
+ const registry = caps.enabled.has("secrets") ? e.secrets : null;
224
+ const result = applyCredentialToRegistry(raw, registry, account);
225
+ const body = {
226
+ ...result,
227
+ tokensEstimate: estimateTokens(JSON.stringify(result)),
228
+ };
229
+ return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
230
+ });
231
+ }
@@ -0,0 +1,9 @@
1
+ import type { RegisterHost, GateHost, SessionHost, ConfigHost, ServerServicesHost } from "./host.js";
2
+ /**
3
+ * Dialog / permission / file-system-picker policy tools: set_dialog_policy /
4
+ * set_permission_policy / set_fs_picker_policy / fs_picker_respond. Split out of
5
+ * `session-policy-tools` by cohesive family (RFC 0004 P3 / D3 SRP); registered
6
+ * through the shared `ToolHost` seam in the same source order. The host owns the
7
+ * closures (register / gate / entry / workspace).
8
+ */
9
+ export declare function registerSessionDialogPermissionTools(host: RegisterHost & GateHost & SessionHost & ConfigHost & ServerServicesHost): void;