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,200 @@
1
+ // Extract schema helpers — validation, dialect relaxations, unknown-key
2
+ // diagnostics, and the small result/dedup utilities. Pure functions over the
3
+ // schema tree; shared by the `extract` orchestrator and the resolution engine.
4
+ // Split out of extract.ts to keep it (and extract-resolve.ts) under the size
5
+ // budget, and to break the orchestrator↔resolver import cycle. Re-exported
6
+ // through `./extract.js` so callers + tests import unchanged.
7
+ import { estimateTokens } from "../util/tokens.js";
8
+ export function fail(failure) {
9
+ const body = { ok: false, failure };
10
+ return { ...body, tokensEstimate: estimateTokens(JSON.stringify(body)) };
11
+ }
12
+ export function dedupe(arr) {
13
+ return [...new Set(arr)];
14
+ }
15
+ /** Supported `type` values. The list is closed: JSON-Schema's `integer`,
16
+ * `null`, `any`, and union types are NOT supported and will be rejected
17
+ * with a "Did you mean...?" hint when the rejection corresponds to a
18
+ * known alias (e.g. `integer` → `number`). */
19
+ const SUPPORTED_TYPES = ["object", "array", "string", "number", "boolean"];
20
+ /** Known `x-browx-source` keys — used for unknown-key diagnostics. The
21
+ * resolver only reads these; any other key is silently dropped today,
22
+ * which costs adopters debugging time when (say) `attribute` is used
23
+ * instead of `attr`. */
24
+ const KNOWN_HINT_KEYS = [
25
+ "query",
26
+ "selector",
27
+ "attr",
28
+ "prop",
29
+ "text",
30
+ "value",
31
+ "collection",
32
+ ];
33
+ /** Closest known type for a rejected type — used to power "Did you mean?"
34
+ * hints in the validator error. Conservative: only suggests when there's
35
+ * a clear high-confidence alias (e.g. `integer`/`int` → `number`). */
36
+ function suggestType(t) {
37
+ const s = String(t).toLowerCase();
38
+ if (s === "integer" || s === "int" || s === "float" || s === "double" || s === "long")
39
+ return "number";
40
+ if (s === "bool")
41
+ return "boolean";
42
+ if (s === "str" || s === "text")
43
+ return "string";
44
+ if (s === "list" || s === "tuple")
45
+ return "array";
46
+ if (s === "dict" || s === "map" || s === "record")
47
+ return "object";
48
+ return null;
49
+ }
50
+ /** Closest known hint-key for a rejected key — symmetric to `suggestType`.
51
+ * Powers the unknown-hint-key diagnostic ("did you mean `attr`?"). */
52
+ function suggestHintKey(k) {
53
+ const s = k.toLowerCase();
54
+ if (s === "attribute")
55
+ return "attr";
56
+ if (s === "property")
57
+ return "prop";
58
+ if (s === "css" || s === "cssselector" || s === "css_selector")
59
+ return "selector";
60
+ if (s === "label" || s === "name" || s === "search")
61
+ return "query";
62
+ if (s === "container" || s === "items_selector" || s === "rows" || s === "list")
63
+ return "collection";
64
+ // `transform`, `format`, `regex`, `parser` are NOT supported at all.
65
+ return null;
66
+ }
67
+ /** Walk the schema tree and (1) coerce `type:"integer"` → `type:"number"`
68
+ * in place, recording an educational `partialMisses`-bound note per
69
+ * coercion site, and (2) promote `x-browx-source.selector` to
70
+ * `x-browx-source.collection` on array schemas that lack `collection`
71
+ * (the selector key on an array is meaningless today — no leaf-`selector`
72
+ * semantics applies — so the alias is a no-op-overlap promotion).
73
+ *
74
+ * Proposal A (v0.2.3): `integer` is now accepted as a schema-dialect
75
+ * alias for `number`. The leaf coercer already returns JS numbers; a
76
+ * consumer wanting an enforced integer can `Math.trunc()` themselves.
77
+ * The educational note preserves the diagnostic trail for adopters
78
+ * still on the agent-learning curve.
79
+ *
80
+ * Proposal B (v0.2.3): `selector` on an array is treated as an alias
81
+ * for `collection`. If both are present, `collection` wins (the
82
+ * canonical name) — `selector` is dropped from the merged hint so the
83
+ * resolver doesn't see a stale key. We deliberately do NOT emit a
84
+ * partialMisses note for this case: the alias is idiomatic and the
85
+ * resolver already explains `collection` semantics elsewhere, so the
86
+ * extra noise would dilute the diagnostic surface.
87
+ *
88
+ * Pure-additive on the call's outcome — the v0.2.2 `collectUnknownHintKeys`
89
+ * diagnostics still fire (the strict-env opt-in is what changes those
90
+ * into hard rejections), and validateSchema runs AFTER this pass, so a
91
+ * schema that was previously rejected for `integer` now resolves. */
92
+ /** (B) On an array schema, alias `x-browx-source.selector` to `collection`
93
+ * (the canonical key) — `collection` wins if both are present; the redundant
94
+ * `selector` is dropped so the resolver never sees a stale key. */
95
+ function aliasArraySelectorToCollection(schema) {
96
+ const hint = schema["x-browx-source"];
97
+ if (!hint || typeof hint !== "object")
98
+ return;
99
+ const h = hint;
100
+ if (typeof h.selector !== "string")
101
+ return;
102
+ if (!h.collection)
103
+ h.collection = h.selector;
104
+ delete h.selector;
105
+ }
106
+ export function applySchemaRelaxations(schema, path, notes) {
107
+ // (A) integer → number — in place.
108
+ if (schema.type === "integer") {
109
+ schema.type = "number";
110
+ notes.push(`${path || "<root>"}: schema 'integer' coerced to 'number' for forward-compat; use 'number' explicitly in future schemas`);
111
+ }
112
+ // (B) array `selector` aliased to `collection` — in place.
113
+ if (schema.type === "array")
114
+ aliasArraySelectorToCollection(schema);
115
+ // Recurse — into object properties and array items.
116
+ if (schema.type === "object" && schema.properties) {
117
+ for (const [k, v] of Object.entries(schema.properties)) {
118
+ applySchemaRelaxations(v, path ? `${path}.${k}` : k, notes);
119
+ }
120
+ }
121
+ else if (schema.type === "array" && schema.items) {
122
+ applySchemaRelaxations(schema.items, `${path}[]`, notes);
123
+ }
124
+ }
125
+ /** Deep clone the caller-supplied schema before in-place mutation, so we
126
+ * don't surprise an adopter holding a reference. Uses JSON for the
127
+ * round-trip — schemas are plain data (no functions, no Dates). */
128
+ export function cloneSchema(schema) {
129
+ return JSON.parse(JSON.stringify(schema));
130
+ }
131
+ const VALID_TYPES = new Set(["object", "array", "string", "number", "boolean"]);
132
+ /** Validate the `type` field is one of the supported set, with a "did you mean?"
133
+ * hint for known aliases. Returns the violation message or null. */
134
+ function validateType(t, path) {
135
+ if (VALID_TYPES.has(t))
136
+ return null;
137
+ const suggestion = suggestType(t);
138
+ const hint = suggestion ? ` — did you mean "${suggestion}"?` : "";
139
+ return `${path || "<root>"}: unsupported \`type\` ${JSON.stringify(t)} (supported: ${SUPPORTED_TYPES.join(", ")})${hint}`;
140
+ }
141
+ /** Validate an object schema's `properties` map and recurse into each. */
142
+ function validateObjectChildren(schema, path) {
143
+ if (!schema.properties || typeof schema.properties !== "object") {
144
+ return `${path || "<root>"}: object schema requires \`properties\` (a map of property-name → sub-schema)`;
145
+ }
146
+ for (const [k, v] of Object.entries(schema.properties)) {
147
+ const e = validateSchema(v, path ? `${path}.${k}` : k);
148
+ if (e)
149
+ return e;
150
+ }
151
+ return null;
152
+ }
153
+ /** Pure-tree validation. Returns a description of the first invariant
154
+ * violation, or null when the schema is well-formed enough to attempt. */
155
+ export function validateSchema(schema, path) {
156
+ if (!schema || typeof schema !== "object")
157
+ return `${path || "<root>"}: schema must be an object`;
158
+ const typeError = validateType(schema.type, path);
159
+ if (typeError)
160
+ return typeError;
161
+ if (schema.type === "object")
162
+ return validateObjectChildren(schema, path);
163
+ if (schema.type === "array") {
164
+ if (!schema.items) {
165
+ return `${path || "<root>"}: array schema requires \`items\` (the per-row sub-schema)`;
166
+ }
167
+ return validateSchema(schema.items, `${path}[]`);
168
+ }
169
+ return null;
170
+ }
171
+ /** Walk the schema tree and emit one diagnostic per unknown
172
+ * `x-browx-source` key. Pure inspection — does not modify the schema.
173
+ * Adopters who use, e.g., `attribute` instead of `attr` today see the
174
+ * schema "succeed" with silently-wrong leaf values (wrightxai trial-1
175
+ * turn 6: `url` came back as the title text because `attribute:"href"`
176
+ * was silently dropped). The diagnostic surfaces the typo in
177
+ * `evidence.partialMisses` so the agent can self-correct on the next
178
+ * turn without a third "what shape does this take?" probe. */
179
+ export function collectUnknownHintKeys(schema, path, out) {
180
+ const hint = schema["x-browx-source"];
181
+ if (hint && typeof hint === "object") {
182
+ for (const k of Object.keys(hint)) {
183
+ if (!KNOWN_HINT_KEYS.includes(k)) {
184
+ const suggestion = suggestHintKey(k);
185
+ const hintTxt = suggestion
186
+ ? `; did you mean \`${suggestion}\`?`
187
+ : ` (known: ${KNOWN_HINT_KEYS.join(", ")})`;
188
+ out.push(`${path || "<root>"}: unknown \`x-browx-source\` key \`${k}\`${hintTxt}`);
189
+ }
190
+ }
191
+ }
192
+ if (schema.type === "object" && schema.properties) {
193
+ for (const [k, v] of Object.entries(schema.properties)) {
194
+ collectUnknownHintKeys(v, path ? `${path}.${k}` : k, out);
195
+ }
196
+ }
197
+ else if (schema.type === "array" && schema.items) {
198
+ collectUnknownHintKeys(schema.items, `${path}[]`, out);
199
+ }
200
+ }
@@ -0,0 +1,127 @@
1
+ /** Private marker stamped on a hint when the implicit name-as-query lowering ran
2
+ * (so the per-leaf resolver knows the query is internal, not user-supplied — and
3
+ * skips the retirement warning). Module-private symbol; never surfaces in
4
+ * serialised schemas. */
5
+ export declare const IMPLICIT_QUERY: unique symbol;
6
+ export type HintWithMarker = ExtractSourceHint & {
7
+ [IMPLICIT_QUERY]?: true;
8
+ };
9
+ /** Mode toggle. `"deterministic"` is the only supported value. The legacy
10
+ * `"llm-assisted"` literal is retained in the union so that runtime callers
11
+ * passing it (pre-v0.3.2 adopters) still type-check at the page-layer boundary;
12
+ * the SDK type no longer exposes it. At runtime it is tolerated with a
13
+ * `console.warn` and falls through to deterministic. */
14
+ export type ExtractMode = "deterministic" | "llm-assisted";
15
+ /** A JSON-Schema-flavoured shape. We accept the subset that has a clear
16
+ * selector-lowering: object, array, string, number, boolean. `properties`
17
+ * / `items` recurse; the `x-browx-source` extension is the explicit DSL. */
18
+ export interface ExtractSchema {
19
+ type: "object" | "array" | "string" | "number" | "boolean";
20
+ /** Property map for `type:"object"`. Keys are property names; the property
21
+ * name *is* the implicit query unless overridden via x-browx-source. */
22
+ properties?: Record<string, ExtractSchema>;
23
+ /** Item schema for `type:"array"`. Required when `type:"array"`. */
24
+ items?: ExtractSchema;
25
+ /** Per-property explicit source annotation. Overrides the implicit
26
+ * "property name = query" rule. All fields optional; the first present
27
+ * field wins in source-resolution order. */
28
+ "x-browx-source"?: ExtractSourceHint;
29
+ /** Optional fallback default when extraction misses. The result still
30
+ * records the miss in `evidence.partialMisses` — the default keeps the
31
+ * data shape sane without lying about ground truth. */
32
+ default?: unknown;
33
+ /** Whether the field is required. Default false. Required misses surface
34
+ * in `failure.partialMisses`; optional misses only emit `partialMiss`
35
+ * evidence. */
36
+ required?: boolean;
37
+ }
38
+ export interface ExtractSourceHint {
39
+ /** RETIRED in v0.3.3 — the NL tree-scan ranker is unreliable for
40
+ * explicit prose-style per-field queries (uniform null/0 across rows
41
+ * with no partialMiss surfaced; see R-5). The typed SDK no longer
42
+ * exposes this field; passing it at runtime emits a one-shot warn and
43
+ * records a partialMisses entry so the diagnostic surfaces. Use
44
+ * `selector` (raw CSS) instead — the implicit property-name lowering
45
+ * still works for testid-friendly pages. Retained on the page-layer
46
+ * type so the internal implicit-name path keeps compiling. */
47
+ query?: string;
48
+ /** Raw CSS / selectorHint, resolved against the current scope. */
49
+ selector?: string;
50
+ /** When set, read this HTML attribute (e.g. "href", "data-state") from
51
+ * the matched element. Mutually exclusive with `prop` / `text` / `value`. */
52
+ attr?: string;
53
+ /** When set, read this DOM property (e.g. "value", "checked") via the
54
+ * page-side. Mutually exclusive with `attr` / `text` / `value`. */
55
+ prop?: string;
56
+ /** When `true`, read the trimmed visible text. The default behaviour
57
+ * when no read-mode hint is set. */
58
+ text?: boolean;
59
+ /** When `true`, read the form-control value (alias for `prop:"value"`). */
60
+ value?: boolean;
61
+ /** For `type:"array"` only — the collection container selector OR query
62
+ * whose matches each get a per-row scope. */
63
+ collection?: string;
64
+ }
65
+ export interface ExtractOptions {
66
+ /** JSON-schema input. Must be a top-level object or array. Accepts an
67
+ * already-typed `ExtractSchema` (internal callers) or a raw wire object
68
+ * (the MCP `extract` tool passes the untrusted payload straight through);
69
+ * `extract()` validates it via `validateSchema` and returns a structured
70
+ * `invalid-schema` failure when it is malformed. */
71
+ schema: ExtractSchema | Record<string, unknown>;
72
+ /** Scope to a ref's subtree (from a prior snapshot/find). */
73
+ ref?: string;
74
+ /** Scope to a CSS selector match. Mutually exclusive with `ref`. */
75
+ scope?: string;
76
+ /** Default `"deterministic"` (the only supported path). RETIRED in
77
+ * v0.3.2 — `"llm-assisted"` is tolerated at runtime for back-compat
78
+ * (warn + treat as deterministic) but is no longer in the SDK type.
79
+ * Drop the arg from new code. */
80
+ mode?: ExtractMode;
81
+ testAttributes: string[];
82
+ /** When true, v0.2.2's unknown-`x-browx-source`-key diagnostics are
83
+ * promoted from `evidence.partialMisses` entries to hard `ok:false`
84
+ * `invalid-schema` rejections — adopters who want first-class typo
85
+ * detection enable this. Defaults to `process.env.BROWX_EXTRACT_STRICT`
86
+ * being set when undefined. The integer→number coerce and the
87
+ * selector-as-collection alias are NOT promoted by this flag — those
88
+ * are educational signals, not typo-like errors. */
89
+ strictUnknownHintKeys?: boolean;
90
+ }
91
+ export interface ExtractEvidence {
92
+ /** Refs (stable `eN`) the extractor drew from, deduped. Lets the caller
93
+ * pin them via `name_ref` or cache the lookup. */
94
+ refsUsed: string[];
95
+ /** Selectors / queries the extractor actually resolved against — useful
96
+ * for adopters debugging "why did this property come back empty?". */
97
+ selectorsUsed: string[];
98
+ /** Property paths that had no match and (when required) caused the
99
+ * extraction to fail. Each entry is the dotted path through the schema
100
+ * ("rows[3].price"). */
101
+ partialMisses: string[];
102
+ }
103
+ export interface ExtractFailure {
104
+ /** `"app"` when the schema didn't fit the page (missing required fields);
105
+ * `"browxai"` when extract itself couldn't run (invalid scope, invalid
106
+ * schema). */
107
+ source: "app" | "browxai";
108
+ /** Stable kind label. `"llm-assisted-not-implemented"` is retained in the
109
+ * union as a RETIRED kind — v0.3.2 stopped emitting it (the `mode` arg
110
+ * is tolerated with a warn instead). New code should not narrow on it. */
111
+ kind: "invalid-schema" | "scope-not-found" | "required-miss" | "llm-assisted-not-implemented";
112
+ expected: string;
113
+ actual: unknown;
114
+ evidence?: Partial<ExtractEvidence> & Record<string, unknown>;
115
+ /** When `required-miss`: the missing property paths. */
116
+ partialMisses?: string[];
117
+ }
118
+ export type ExtractResult = {
119
+ ok: true;
120
+ data: unknown;
121
+ evidence: ExtractEvidence;
122
+ tokensEstimate: number;
123
+ } | {
124
+ ok: false;
125
+ failure: ExtractFailure;
126
+ tokensEstimate: number;
127
+ };
@@ -0,0 +1,8 @@
1
+ // Extraction type vocabulary — the schema/hint/evidence/result types shared by
2
+ // the `extract` orchestrator and the resolution engine. Split out of extract.ts
3
+ // so neither file carries the other's bulk; re-exported through `./extract.js`.
4
+ /** Private marker stamped on a hint when the implicit name-as-query lowering ran
5
+ * (so the per-leaf resolver knows the query is internal, not user-supplied — and
6
+ * skips the retirement warning). Module-private symbol; never surfaces in
7
+ * serialised schemas. */
8
+ export const IMPLICIT_QUERY = Symbol.for("browxai.extract.implicitQuery");
@@ -0,0 +1,8 @@
1
+ export declare function warnLlmAssistedRetired(): void;
2
+ /** Test-only hook — resets the one-shot guard so the warn-emission can be
3
+ * re-asserted in isolation. Not exported from `index.ts`. */
4
+ export declare function __resetLlmAssistedWarnedForTests(): void;
5
+ export declare function warnExplicitNlQueryRetired(): void;
6
+ /** Test-only hook — resets the one-shot guard so the warn-emission can be
7
+ * re-asserted in isolation. Not exported from `index.ts`. */
8
+ export declare function __resetExplicitNlQueryWarnedForTests(): void;
@@ -0,0 +1,56 @@
1
+ // One-shot deprecation warnings for the retired extract options. Module state so
2
+ // adopters don't spam stderr on every call; the test-only reset hooks let the
3
+ // regression suite re-assert the warn fires. Split out of extract.ts.
4
+ /** One-shot warn for the RETIRED `mode:"llm-assisted"` arg (v0.3.2). Module
5
+ * state so adopters don't spam stderr on every extract call. */
6
+ let __llmAssistedWarned = false;
7
+ export function warnLlmAssistedRetired() {
8
+ if (__llmAssistedWarned)
9
+ return;
10
+ __llmAssistedWarned = true;
11
+ console.warn('browxai: extract({ mode: "llm-assisted" }) is RETIRED as of v0.3.2 — ' +
12
+ "the `mode` arg is no longer part of the SDK type. Treating as " +
13
+ 'mode:"deterministic" (the only supported path). Drop the arg from ' +
14
+ "your call site to silence this warning.");
15
+ }
16
+ /** Test-only hook — resets the one-shot guard so the warn-emission can be
17
+ * re-asserted in isolation. Not exported from `index.ts`. */
18
+ export function __resetLlmAssistedWarnedForTests() {
19
+ __llmAssistedWarned = false;
20
+ }
21
+ /** One-shot warn for the RETIRED `x-browx-source.query` per-field hint
22
+ * (v0.3.3). The natural-language tree-scan ranker is unreliable in
23
+ * production — wrightxai's smoke trial saw the LLM author a prose query
24
+ * for a per-row numeric field on Hacker News, and the resolver returned
25
+ * null for every row (one stale ref re-used across all 30 row scopes,
26
+ * no partialMiss surfaced — the agent burned 14 revisions). Same shape
27
+ * of defect as R-1's `mode:"llm-assisted"`: advertised in the typed SDK,
28
+ * unreliable at runtime. Retired at the typed boundary; tolerated at
29
+ * runtime with a one-shot warn + per-call `partialMisses` entry so the
30
+ * caller sees the actionable diagnostic.
31
+ *
32
+ * Note: this guards the EXPLICIT user-supplied `query`. The implicit
33
+ * "property-name as query" lowering path (`resolveObject` stamps
34
+ * `{ query: name }` for an un-hinted property) is unchanged — the bare
35
+ * property-name case still works on testid-rich pages and is the
36
+ * documented primary path. */
37
+ let __explicitNlQueryWarned = false;
38
+ export function warnExplicitNlQueryRetired() {
39
+ if (__explicitNlQueryWarned)
40
+ return;
41
+ __explicitNlQueryWarned = true;
42
+ console.warn("browxai: extract() — explicit per-field `x-browx-source.query` is " +
43
+ "RETIRED as of v0.3.3. The NL tree-scan ranker is unreliable on " +
44
+ "prose-style queries (uniform null/0 across rows, no partialMiss " +
45
+ "surfaced — see R-5 / wrightxai smoke trial). Use " +
46
+ "`x-browx-source.selector` (raw CSS / selectorHint) for per-field " +
47
+ "targeting; the implicit property-name lowering still works for " +
48
+ "testid-friendly pages. The runtime still attempts resolution and " +
49
+ "records a partialMisses entry so the diagnostic surfaces in " +
50
+ "evidence — drop explicit `query:` to silence this warning.");
51
+ }
52
+ /** Test-only hook — resets the one-shot guard so the warn-emission can be
53
+ * re-asserted in isolation. Not exported from `index.ts`. */
54
+ export function __resetExplicitNlQueryWarnedForTests() {
55
+ __explicitNlQueryWarned = false;
56
+ }
@@ -0,0 +1,9 @@
1
+ import type { Page } from "playwright-core";
2
+ import type { RefRegistry } from "./refs.js";
3
+ import type { SnapshotSubstrate } from "./snapshot-substrate.js";
4
+ import type { ExtractResult, ExtractOptions } from "./extract-types.js";
5
+ export type { ExtractSchema, ExtractSourceHint, ExtractEvidence, ExtractFailure, ExtractResult, ExtractOptions, ExtractMode, } from "./extract-types.js";
6
+ export { __resetLlmAssistedWarnedForTests, __resetExplicitNlQueryWarnedForTests, } from "./extract-warnings.js";
7
+ export { resolveAgainstTree, scanTreeForBestMatch, coerceLeaf } from "./extract-resolve.js";
8
+ export { applySchemaRelaxations, cloneSchema, validateSchema, collectUnknownHintKeys, } from "./extract-schema.js";
9
+ export declare function extract(page: Page, substrate: SnapshotSubstrate, refs: RefRegistry, opts: ExtractOptions): Promise<ExtractResult>;
@@ -0,0 +1,174 @@
1
+ // Structured schema-driven extract primitive.
2
+ //
3
+ // The schema-as-contract primitive every browxai
4
+ // adopter currently rebuilds the same "parse this table into rows" loop on
5
+ // top of `snapshot()`. Stagehand `extract`, Skyvern, browser-use all ship
6
+ // this. browxai's version is **deterministic only** (selector-only —
7
+ // schema fields lower to `find()` / selector queries scoped to a subtree).
8
+ //
9
+ // The `mode` arg is RETIRED as of v0.3.2 — deterministic is the supported
10
+ // path. `mode:"llm-assisted"` is tolerated for back-compat (warn + fall
11
+ // through to deterministic) but is no longer in the typed SDK surface.
12
+ //
13
+ // The schema is the contract: invalid input / partial matches surface in
14
+ // `failure.partialMisses`, never silently coerced into a malformed object.
15
+ //
16
+ // Schema-to-query lowering. Two paths, deliberately layered:
17
+ //
18
+ // 1. **Implicit (the simple rule):** the property *name* is the find()
19
+ // query. `{type:"string"}` property `"price"` → look for a node
20
+ // matching "price" within the current scope and read its visible
21
+ // text. Works on testid-rich pages where the property names line up
22
+ // with `data-testid` tokens / accessible names.
23
+ //
24
+ // 2. **Explicit (the escape hatch):** a property may carry an
25
+ // `x-browx-source` annotation overriding any of {query, selector,
26
+ // attr, prop, text, value}. This is the richer DSL the design
27
+ // called out as a tension — we ship both rules and document the
28
+ // simple one as the primary path. The escape hatch covers the cases
29
+ // where the name doesn't carry enough signal (`"theFirstThing":
30
+ // <selector>`) or where the value isn't innerText (an attribute,
31
+ // a DOM property, a form-control value).
32
+ //
33
+ // Arrays lower to a collection probe: `{type:"array", items:<inner>,
34
+ // "x-browx-source":{collection:<selectorOrQuery>}}` finds the container
35
+ // elements and runs the inner schema scoped to each. Without an explicit
36
+ // collection, an array property is rejected as `partialMiss: "array needs
37
+ // x-browx-source.collection"` — there's no defensible implicit default
38
+ // (the empty list is a lie).
39
+ //
40
+ // Nested objects recurse — each sub-property resolves within the parent's
41
+ // scope, exactly the same lowering rule.
42
+ //
43
+ // Refs used during extraction land in `evidence.refsUsed` so the caller
44
+ // can audit / cache / pin (`name_ref`) the elements the result drew from.
45
+ import { findByRef } from "./snapshot.js";
46
+ import { estimateTokens } from "../util/tokens.js";
47
+ import { warnLlmAssistedRetired } from "./extract-warnings.js";
48
+ import { resolveAgainstTree, locatorForRef } from "./extract-resolve.js";
49
+ import { fail, dedupe, cloneSchema, applySchemaRelaxations, validateSchema, collectUnknownHintKeys, } from "./extract-schema.js";
50
+ export { __resetLlmAssistedWarnedForTests, __resetExplicitNlQueryWarnedForTests, } from "./extract-warnings.js";
51
+ export { resolveAgainstTree, scanTreeForBestMatch, coerceLeaf } from "./extract-resolve.js";
52
+ export { applySchemaRelaxations, cloneSchema, validateSchema, collectUnknownHintKeys, } from "./extract-schema.js";
53
+ /** Clone + relax the schema, then validate it (and, under strict mode, reject
54
+ * unknown `x-browx-source` keys). Returns the relaxed schema + the educational
55
+ * relaxation notes, or a structured `invalid-schema` failure. */
56
+ function prepareSchema(opts) {
57
+ // Clone first so we never mutate the caller-supplied object; relaxation notes
58
+ // ride through to evidence.partialMisses on the successful path.
59
+ const schema = cloneSchema(opts.schema);
60
+ const relaxationNotes = [];
61
+ applySchemaRelaxations(schema, "", relaxationNotes);
62
+ const schemaError = validateSchema(schema, "");
63
+ if (schemaError) {
64
+ return failPrepared("invalid-schema", "a JSON schema whose root is object or array", schemaError);
65
+ }
66
+ // Strict mode: promote unknown-`x-browx-source`-key diagnostics from soft
67
+ // `partialMisses` notes to a hard `invalid-schema` rejection. Default off;
68
+ // opt-in via env or call-arg.
69
+ const strict = opts.strictUnknownHintKeys ?? process.env.BROWX_EXTRACT_STRICT === "1";
70
+ if (strict) {
71
+ const unknown = [];
72
+ collectUnknownHintKeys(schema, "", unknown);
73
+ if (unknown.length > 0) {
74
+ return failPrepared("invalid-schema", "every `x-browx-source` key to be one of the known set (BROWX_EXTRACT_STRICT=1 is on)", unknown.join(" | "));
75
+ }
76
+ }
77
+ return { ok: true, value: { schema, relaxationNotes } };
78
+ }
79
+ function failPrepared(kind, expected, actual) {
80
+ return { ok: false, failure: fail({ source: "browxai", kind, expected, actual }) };
81
+ }
82
+ /** Compose the snapshot and resolve the requested scope (whole tree, a ref
83
+ * subtree, or a CSS-selector scope), validating the empty-scope invariant. */
84
+ async function resolveScope(page, substrate, refs, opts) {
85
+ if (opts.ref && opts.scope) {
86
+ return failPrepared("invalid-schema", "exactly one of `ref` or `scope`", "both provided");
87
+ }
88
+ const tree = (await substrate.compose(refs, opts.testAttributes)).tree;
89
+ if (!tree) {
90
+ return {
91
+ ok: false,
92
+ failure: fail({
93
+ source: "app",
94
+ kind: "scope-not-found",
95
+ expected: "a non-empty accessibility tree",
96
+ actual: "empty",
97
+ }),
98
+ };
99
+ }
100
+ if (opts.ref) {
101
+ const sub = findByRef(tree, opts.ref);
102
+ if (!sub) {
103
+ return failPrepared("scope-not-found", `ref "${opts.ref}" to resolve in the current snapshot`, "no matching ref");
104
+ }
105
+ return {
106
+ ok: true,
107
+ value: { scopeTree: sub, scopeLocator: locatorForRef(page, refs, opts.ref) },
108
+ };
109
+ }
110
+ if (opts.scope) {
111
+ const scopeLocator = page.locator(opts.scope).first();
112
+ const count = await page
113
+ .locator(opts.scope)
114
+ .count()
115
+ .catch(() => 0);
116
+ if (count === 0) {
117
+ return failPrepared("scope-not-found", `scope selector "${opts.scope}" to match ≥1 element`, "0 matches");
118
+ }
119
+ return { ok: true, value: { scopeTree: tree, scopeLocator } };
120
+ }
121
+ return { ok: true, value: { scopeTree: tree } };
122
+ }
123
+ export async function extract(page, substrate, refs, opts) {
124
+ // The `mode` arg is RETIRED as of v0.3.2 — deterministic is the only supported
125
+ // path. Tolerate `mode:"llm-assisted"` at runtime (graceful deprecation): emit
126
+ // a one-shot console.warn and fall through to deterministic.
127
+ if (opts.mode === "llm-assisted")
128
+ warnLlmAssistedRetired();
129
+ const prepared = prepareSchema(opts);
130
+ if (!prepared.ok)
131
+ return prepared.failure;
132
+ const { schema: relaxedSchema, relaxationNotes } = prepared.value;
133
+ const scoped = await resolveScope(page, substrate, refs, opts);
134
+ if (!scoped.ok)
135
+ return scoped.failure;
136
+ const { scopeTree, scopeLocator } = scoped.value;
137
+ const { data, evidence, requiredMisses } = await resolveAgainstTree({
138
+ schema: relaxedSchema,
139
+ page,
140
+ scopeTree,
141
+ scopeLocator,
142
+ });
143
+ // Educational A/B notes ride at the head of partialMisses so the agent
144
+ // sees them on the same observation as the resolved data.
145
+ if (relaxationNotes.length > 0) {
146
+ evidence.partialMisses = [...relaxationNotes, ...evidence.partialMisses];
147
+ }
148
+ if (requiredMisses.length > 0) {
149
+ return fail({
150
+ source: "app",
151
+ kind: "required-miss",
152
+ expected: "all required schema properties to resolve",
153
+ actual: `${requiredMisses.length} required field(s) missing`,
154
+ evidence: {
155
+ refsUsed: dedupe(evidence.refsUsed),
156
+ selectorsUsed: dedupe(evidence.selectorsUsed),
157
+ partialMisses: evidence.partialMisses,
158
+ },
159
+ partialMisses: requiredMisses,
160
+ });
161
+ }
162
+ const out = {
163
+ ok: true,
164
+ data,
165
+ evidence: {
166
+ refsUsed: dedupe(evidence.refsUsed),
167
+ selectorsUsed: dedupe(evidence.selectorsUsed),
168
+ partialMisses: evidence.partialMisses,
169
+ },
170
+ tokensEstimate: 0,
171
+ };
172
+ out.tokensEstimate = estimateTokens(JSON.stringify(out));
173
+ return out;
174
+ }
@@ -0,0 +1,58 @@
1
+ import type { Locator, Page } from "playwright-core";
2
+ import { type ActionContext, type ActionResult, type ActionWindowOptions } from "./actionresult.js";
3
+ import { type ActionTarget } from "./locator.js";
4
+ export interface FillFormField {
5
+ target: ActionTarget;
6
+ value: string;
7
+ }
8
+ export interface FillFormArgs extends ActionWindowOptions {
9
+ fields: FillFormField[];
10
+ /** Optional submit target. Clicked after every field has filled
11
+ * successfully. Skipped when any field fails (atomic submit semantics —
12
+ * we don't submit a partially-filled form). */
13
+ submit?: ActionTarget;
14
+ }
15
+ /** Per-field resolution outcome surfaced when the atomic pre-resolution
16
+ * step fails. `index` lines up with the input `fields[]` order. */
17
+ export interface FieldResolution {
18
+ index: number;
19
+ /** Compact identification of which target shape was passed — for
20
+ * agent-facing error messages. */
21
+ targetSummary: string;
22
+ ok: boolean;
23
+ error?: string;
24
+ }
25
+ /** Per-field dispatch outcome included in the result's `elements` slot is
26
+ * the post-fill `ElementProbe`. When the atomic resolution step rejected
27
+ * the call, `elements` is omitted and `fieldResolution` (on the result
28
+ * envelope as an extension) carries the per-field outcomes. */
29
+ export interface FillFormResult extends ActionResult {
30
+ /** Per-field resolution outcomes — only present when the atomic
31
+ * resolution step rejected the call (`ok:false`, no fills landed). */
32
+ fieldResolution?: FieldResolution[];
33
+ /** When a per-field fill failed mid-loop, the 0-based index of the
34
+ * offending field and a list of skipped indices. Distinguishes
35
+ * "rejected atomically" from "started filling then hit an app error". */
36
+ fillFailure?: {
37
+ atIndex: number;
38
+ skipped: number[];
39
+ };
40
+ }
41
+ /** Pure helper: render a one-line summary of an ActionTarget so the
42
+ * resolution-failure envelope is human-readable. Exported for unit tests. */
43
+ export declare function summariseTarget(t: ActionTarget): string;
44
+ /** Pure helper: validate the args shape before touching the page. Throws
45
+ * on structural problems (empty fields, coord targets for fill — which
46
+ * Playwright can't drive). Exported for unit tests. */
47
+ export declare function validateFillFormArgs(args: FillFormArgs): void;
48
+ export declare function resolveFieldsAtomically(page: Page, refs: ActionContext["refs"], fields: FillFormField[], submit?: ActionTarget): Promise<{
49
+ ok: true;
50
+ locators: Locator[];
51
+ submitLocator?: Locator;
52
+ resolutions: FieldResolution[];
53
+ } | {
54
+ ok: false;
55
+ resolutions: FieldResolution[];
56
+ submitResolution?: FieldResolution;
57
+ }>;
58
+ export declare function fillForm(ctx: ActionContext, args: FillFormArgs): Promise<FillFormResult>;