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,308 @@
1
+ // `plan()` / `execute()` — separate intent capture from dispatch.
2
+ //
3
+ // `plan()` resolves a natural-language query (via the same scoring as `find()`)
4
+ // down to a single bound, serialisable `ActionDescriptor` carrying:
5
+ // - the action `verb` (`click` / `fill` / `hover` / `press` / `select`),
6
+ // - the verb's structured `args` (the `value` for `fill`, `key` for `press`, etc.),
7
+ // - the resolved `ref` (the existing stable-key namespace — NOT a parallel id system),
8
+ // - the `evidence` (selectorHint, stability, score, top-N candidates) the caller
9
+ // can audit before deciding to execute,
10
+ // - an `expiresAt` deadline (epoch-ms).
11
+ //
12
+ // `execute(descriptor)` then re-resolves the ref via `refs.ts` and dispatches the
13
+ // verb's action against the live page. Two structured failure modes:
14
+ //
15
+ // - `error: "descriptor expired"` → past `expiresAt`. Caller should re-`plan`.
16
+ // - `error: "ref no longer resolves"` → the ref is no longer in the registry, or
17
+ // the underlying locator no longer addresses
18
+ // a live element. Caller should re-`plan`.
19
+ //
20
+ // Explicit non-goal — mock dispatch. `execute()` actually runs the action; the
21
+ // value here is *capturing and replaying intent*, not *suppressing effects*.
22
+ // (An action that fakes its effect is a footgun — the agent thinks it ran
23
+ // something it didn't.) For a no-effect-but-want-to-see-the-target dry-run,
24
+ // inspect the returned descriptor's `evidence` block before calling `execute`.
25
+ import { randomUUID } from "node:crypto";
26
+ import { find } from "./find.js";
27
+ import * as actions from "./actions.js";
28
+ /** Action verbs `plan()`/`execute()` understand. Single-target verbs only —
29
+ * page-level / multi-step verbs (`navigate`, `scroll`, `wait_for`, `choose_option`)
30
+ * are out of scope here; they're either trivially planned (`navigate(url)` doesn't
31
+ * need a ranked candidate) or expand into multiple action-window dispatches and
32
+ * belong in their own primitives. */
33
+ export const PLAN_VERBS = ["click", "fill", "hover", "press", "select"];
34
+ const DEFAULT_TTL_MS = 60_000;
35
+ const MIN_TTL_MS = 1_000;
36
+ const MAX_TTL_MS = 30 * 60_000;
37
+ /** Validate per-verb args at plan time so a bad descriptor can never reach
38
+ * `execute()`. Pure; exported for tests. */
39
+ export function validateVerbArgs(verb, args) {
40
+ const a = args ?? {};
41
+ if (verb === "fill") {
42
+ if (typeof a.value !== "string")
43
+ return 'plan: verb "fill" requires verbArgs.value (string)';
44
+ }
45
+ if (verb === "press") {
46
+ if (typeof a.key !== "string" || a.key.length === 0)
47
+ return 'plan: verb "press" requires verbArgs.key (non-empty string)';
48
+ }
49
+ if (verb === "select") {
50
+ if (!Array.isArray(a.values) || a.values.length === 0)
51
+ return 'plan: verb "select" requires verbArgs.values (non-empty string[])';
52
+ }
53
+ if (verb === "click") {
54
+ if (a.button !== undefined && !["left", "right", "middle"].includes(a.button)) {
55
+ return `plan: verb "click" — button must be left/right/middle (got ${JSON.stringify(a.button)})`;
56
+ }
57
+ }
58
+ return null;
59
+ }
60
+ /** Clamp a caller-supplied ttl into the sane range. Pure; exported for tests. */
61
+ export function clampTtl(ttlMs) {
62
+ const v = typeof ttlMs === "number" && Number.isFinite(ttlMs) ? ttlMs : DEFAULT_TTL_MS;
63
+ return Math.min(Math.max(v, MIN_TTL_MS), MAX_TTL_MS);
64
+ }
65
+ /** Project a `find()` candidate into a descriptor's `evidence` block.
66
+ * Pure; exported for tests. */
67
+ export function evidenceFromCandidate(query, picked, alternatives, warnings) {
68
+ const alts = alternatives.slice(0, 4).map((c) => {
69
+ const a = { ref: c.ref, role: c.role, score: c.score };
70
+ if (c.name !== undefined)
71
+ a.name = c.name;
72
+ if (c.testId !== undefined)
73
+ a.testId = c.testId;
74
+ return a;
75
+ });
76
+ const ev = {
77
+ query,
78
+ selectorHint: picked.selectorHint,
79
+ selectorTier: picked.selectorTier,
80
+ stability: picked.stability,
81
+ role: picked.role,
82
+ score: picked.score,
83
+ actionable: picked.actionable,
84
+ warnings,
85
+ alternatives: alts,
86
+ };
87
+ if (picked.name !== undefined)
88
+ ev.name = picked.name;
89
+ if (picked.testId !== undefined)
90
+ ev.testId = picked.testId;
91
+ return ev;
92
+ }
93
+ /** Build a descriptor from a resolved candidate + caller args. Pure; exported
94
+ * for tests. */
95
+ export function buildDescriptor(args) {
96
+ const now = args.now ?? Date.now();
97
+ return {
98
+ id: randomUUID(),
99
+ ref: args.picked.ref,
100
+ verb: args.verb,
101
+ args: { ...args.verbArgs },
102
+ evidence: evidenceFromCandidate(args.query, args.picked, args.alternatives, args.warnings),
103
+ expiresAt: now + args.ttlMs,
104
+ };
105
+ }
106
+ /** rough JSON-byte/4 token estimate for a descriptor — matches the
107
+ * shape `tokensEstimate` uses across other tools. Pure; exported for tests. */
108
+ export function estimateDescriptorTokens(d) {
109
+ return Math.ceil(JSON.stringify(d).length / 4);
110
+ }
111
+ /**
112
+ * `plan()`: rank `query` against the live tree, pick the top candidate,
113
+ * validate the verb's args, return a serialisable descriptor (no dispatch).
114
+ *
115
+ * Returns `{ ok: false }` with structured reasons when:
116
+ * - the verb's required args are missing/wrong-shape (validated up front),
117
+ * - `find()` returned no candidates (or none above `confidenceFloor`).
118
+ *
119
+ * Note: a descriptor IS returned even if the top candidate is non-actionable
120
+ * (off-screen / disabled). The caller can inspect `evidence.actionable` and
121
+ * decide; we don't silently refuse to plan against a hidden modal, because
122
+ * sometimes that's exactly what the caller wants to confirm.
123
+ */
124
+ export async function plan(page, substrate, refs, opts,
125
+ /** CDP handle for find()'s visible-rect bbox fast path — chromium only. */
126
+ cdp) {
127
+ const argError = validateVerbArgs(opts.verb, opts.verbArgs);
128
+ if (argError) {
129
+ return { ok: false, error: argError, warnings: [], tokensEstimate: 0 };
130
+ }
131
+ const ttlMs = clampTtl(opts.ttlMs);
132
+ const result = await find(page, substrate, refs, {
133
+ query: opts.query,
134
+ testAttributes: opts.testAttributes,
135
+ contextRef: opts.contextRef,
136
+ confidenceFloor: opts.confidenceFloor,
137
+ fallbackHints: opts.fallbackHints,
138
+ // bound the candidate list so evidence.alternatives stays small (we
139
+ // only ever return the top + up to 4 alts).
140
+ maxCandidates: 5,
141
+ }, cdp);
142
+ if (result.candidates.length === 0) {
143
+ return {
144
+ ok: false,
145
+ error: `plan: no candidate matched query ${JSON.stringify(opts.query)}`,
146
+ warnings: result.warnings,
147
+ tokensEstimate: 0,
148
+ };
149
+ }
150
+ const [picked, ...rest] = result.candidates;
151
+ if (!picked) {
152
+ return {
153
+ ok: false,
154
+ error: `plan: no candidate matched query ${JSON.stringify(opts.query)}`,
155
+ warnings: result.warnings,
156
+ tokensEstimate: 0,
157
+ };
158
+ }
159
+ const descriptor = buildDescriptor({
160
+ picked,
161
+ alternatives: rest,
162
+ query: opts.query,
163
+ verb: opts.verb,
164
+ verbArgs: opts.verbArgs ?? {},
165
+ warnings: result.warnings,
166
+ ttlMs,
167
+ });
168
+ return {
169
+ ok: true,
170
+ descriptor,
171
+ warnings: result.warnings,
172
+ tokensEstimate: estimateDescriptorTokens(descriptor),
173
+ };
174
+ }
175
+ /** Static descriptor validation (shape only — does not touch the page).
176
+ * Pure; exported for tests. */
177
+ export function validateDescriptor(d) {
178
+ if (!d || typeof d !== "object")
179
+ return { ok: false, error: "execute: descriptor must be an object" };
180
+ const obj = d;
181
+ if (typeof obj.id !== "string")
182
+ return { ok: false, error: "execute: descriptor.id missing or not a string" };
183
+ if (typeof obj.ref !== "string")
184
+ return { ok: false, error: "execute: descriptor.ref missing or not a string" };
185
+ if (typeof obj.verb !== "string" || !PLAN_VERBS.includes(obj.verb)) {
186
+ return { ok: false, error: `execute: descriptor.verb must be one of ${PLAN_VERBS.join("/")}` };
187
+ }
188
+ if (typeof obj.expiresAt !== "number")
189
+ return { ok: false, error: "execute: descriptor.expiresAt missing or not a number" };
190
+ if (typeof obj.args !== "object" || obj.args === null)
191
+ return { ok: false, error: "execute: descriptor.args must be an object" };
192
+ // evidence is informational — present-but-malformed should not block
193
+ // dispatch, but it must be at least an object so callers can rely on
194
+ // `descriptor.evidence.selectorHint` being readable when present.
195
+ if (obj.evidence !== undefined && (typeof obj.evidence !== "object" || obj.evidence === null)) {
196
+ return { ok: false, error: "execute: descriptor.evidence must be an object when present" };
197
+ }
198
+ return { ok: true, descriptor: obj };
199
+ }
200
+ /**
201
+ * `execute(descriptor)`: dispatch a previously-planned descriptor. Re-resolves
202
+ * the ref via `refs.ts` (the same stable-key scheme `find()`/`snapshot()` use),
203
+ * runs the verb's action, and returns the dispatched `ActionResult`.
204
+ *
205
+ * Refusal modes (no dispatch happens):
206
+ * - `reason: "expired"` — past `expiresAt`.
207
+ * - `reason: "ref-gone"` — `refs.has(descriptor.ref)` is false. The agent
208
+ * should re-`plan` against the current snapshot.
209
+ * - `reason: "invalid"` — descriptor failed shape validation (bad verb,
210
+ * missing fields, malformed args).
211
+ *
212
+ * Capability gating: this function does NOT enforce capabilities itself — the
213
+ * MCP `execute` handler runs `gateCheck(verb)` (e.g. `gateCheck("click")`)
214
+ * before calling in, so a descriptor with `verb: "click"` is denied when the
215
+ * `action` capability is disabled, surfacing the *underlying* capability error
216
+ * (not a generic "execute denied").
217
+ */
218
+ /** Pre-flight validation for `execute`: schema, expiry, ref-presence, and
219
+ * re-validated verb args. Returns the validated descriptor or a failure
220
+ * outcome to return verbatim. */
221
+ function validateForExecute(ctx, rawDescriptor, now) {
222
+ const validated = validateDescriptor(rawDescriptor);
223
+ if (!validated.ok) {
224
+ return {
225
+ ok: false,
226
+ outcome: { ok: false, error: validated.error, reason: "invalid", tokensEstimate: 0 },
227
+ };
228
+ }
229
+ const d = validated.descriptor;
230
+ if (now > d.expiresAt) {
231
+ return {
232
+ ok: false,
233
+ outcome: {
234
+ ok: false,
235
+ error: `execute: descriptor expired (${now - d.expiresAt}ms past expiresAt). Re-plan against the current snapshot.`,
236
+ reason: "expired",
237
+ tokensEstimate: 0,
238
+ },
239
+ };
240
+ }
241
+ if (!ctx.refs.has(d.ref)) {
242
+ return {
243
+ ok: false,
244
+ outcome: {
245
+ ok: false,
246
+ error: `execute: ref "${d.ref}" no longer in the session's registry — the page likely re-snapshotted ` +
247
+ `to a tree where the bound element is absent. Re-plan against the current snapshot.`,
248
+ reason: "ref-gone",
249
+ tokensEstimate: 0,
250
+ },
251
+ };
252
+ }
253
+ // Re-validate verb args at execute time too — a hand-edited descriptor could
254
+ // have dropped a required arg between plan and execute.
255
+ const argError = validateVerbArgs(d.verb, d.args);
256
+ if (argError) {
257
+ return {
258
+ ok: false,
259
+ outcome: { ok: false, error: argError, reason: "invalid", tokensEstimate: 0 },
260
+ };
261
+ }
262
+ return { ok: true, descriptor: d };
263
+ }
264
+ export async function execute(ctx, rawDescriptor, opts = {}) {
265
+ const now = opts.now ?? Date.now();
266
+ const pre = validateForExecute(ctx, rawDescriptor, now);
267
+ if (!pre.ok)
268
+ return pre.outcome;
269
+ const d = pre.descriptor;
270
+ const target = { ref: d.ref };
271
+ // Forwarded window options. We don't override the underlying action's
272
+ // recordingHint plumbing here — the server-level handler computes one from
273
+ // the ref (mirroring how `click`/`fill` are registered).
274
+ const windowOpts = {
275
+ ...(opts.mode !== undefined ? { mode: opts.mode } : {}),
276
+ ...(opts.maxResultTokens !== undefined ? { maxResultTokens: opts.maxResultTokens } : {}),
277
+ ...(opts.deadlineMs !== undefined ? { deadlineMs: opts.deadlineMs } : {}),
278
+ ...(opts.deadlineWarning !== undefined ? { deadlineWarning: opts.deadlineWarning } : {}),
279
+ ...(opts.recordingHint !== undefined ? { recordingHint: opts.recordingHint } : {}),
280
+ };
281
+ let result;
282
+ switch (d.verb) {
283
+ case "click":
284
+ result = await actions.click(ctx, {
285
+ target,
286
+ ...(d.args.button ? { button: d.args.button } : {}),
287
+ ...windowOpts,
288
+ });
289
+ break;
290
+ case "fill":
291
+ result = await actions.fill(ctx, { target, value: d.args.value, ...windowOpts });
292
+ break;
293
+ case "hover":
294
+ result = await actions.hover(ctx, { target, ...windowOpts });
295
+ break;
296
+ case "press":
297
+ result = await actions.press(ctx, { target, key: d.args.key, ...windowOpts });
298
+ break;
299
+ case "select":
300
+ result = await actions.select(ctx, { target, values: d.args.values, ...windowOpts });
301
+ break;
302
+ }
303
+ return {
304
+ ok: true,
305
+ result,
306
+ tokensEstimate: result.tokensEstimate,
307
+ };
308
+ }
@@ -0,0 +1,46 @@
1
+ import type { Page } from "playwright-core";
2
+ export interface ProbedElement {
3
+ tag: string;
4
+ id?: string;
5
+ testId?: string;
6
+ role?: string;
7
+ name?: string;
8
+ classes?: string;
9
+ pointerEvents: string;
10
+ visibility: string;
11
+ display: string;
12
+ zIndex: string;
13
+ cursor: string;
14
+ bbox: {
15
+ x: number;
16
+ y: number;
17
+ width: number;
18
+ height: number;
19
+ } | null;
20
+ }
21
+ export interface PointProbeResult {
22
+ ok: boolean;
23
+ point: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ /** `document.elementsFromPoint(x,y)` top-down, capped at 8. The first entry
28
+ * is what a real click at this point would hit. */
29
+ stack: ProbedElement[];
30
+ /** nearest scrollable ancestor of the top element (overflow auto/scroll
31
+ * with overflowing content), or null. */
32
+ scrollContainer: ProbedElement | null;
33
+ /** nearest clickable ancestor of the top element (a/button, role
34
+ * button/link, [onclick], [tabindex]), or null — what a click here would
35
+ * *semantically* activate even if the literal hit is a child glyph. */
36
+ clickableAncestor: ProbedElement | null;
37
+ /** present only when `crop:true` — a small PNG (base64) around the point,
38
+ * bounded; off by default to keep results token-cheap. */
39
+ cropBase64?: string;
40
+ }
41
+ export declare function pointProbe(page: Page, point: {
42
+ x: number;
43
+ y: number;
44
+ }, opts?: {
45
+ crop?: boolean;
46
+ }): Promise<PointProbeResult>;
@@ -0,0 +1,99 @@
1
+ // `point_probe` — read-only coordinate target inspection.
2
+ //
3
+ // In canvas / virtualised-timeline / painted UIs the real target isn't a
4
+ // clean accessible element, so an agent driving by `coords` is trusting a
5
+ // screenshot estimate of "what is actually under this point". point_probe
6
+ // answers it deterministically: the full `elementsFromPoint` stack with each
7
+ // layer's identity + the computed properties that decide hit-testing
8
+ // (pointer-events / visibility / z-index / cursor), plus the nearest scroll
9
+ // container and clickable ancestor. No agent JS (fixed server script).
10
+ const MAX_STACK = 8;
11
+ // `page.evaluate(string)` treats the string as an *expression* — a
12
+ // `function(arg){…}` string is never called and args are ignored. So this is
13
+ // an arg-less IIFE with the (numeric, zod-validated) coords interpolated in.
14
+ function buildProbeScript(x, y, max) {
15
+ return `(() => {
16
+ var x = ${x}, y = ${y}, MAX = ${max};
17
+ function summ(el) {
18
+ if (!el || !el.tagName) return null;
19
+ var cs = (el.ownerDocument && el.ownerDocument.defaultView)
20
+ ? el.ownerDocument.defaultView.getComputedStyle(el) : null;
21
+ var r = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
22
+ var cls = (typeof el.className === 'string' && el.className) ? el.className.slice(0, 120) : undefined;
23
+ return {
24
+ tag: el.tagName.toLowerCase(),
25
+ id: el.id || undefined,
26
+ testId: el.getAttribute ? (el.getAttribute('data-testid') || undefined) : undefined,
27
+ role: el.getAttribute ? (el.getAttribute('role') || undefined) : undefined,
28
+ name: (el.getAttribute && el.getAttribute('aria-label')) ||
29
+ (el.textContent ? el.textContent.trim().slice(0, 40) : undefined) || undefined,
30
+ classes: cls,
31
+ pointerEvents: cs ? cs.pointerEvents : '',
32
+ visibility: cs ? cs.visibility : '',
33
+ display: cs ? cs.display : '',
34
+ zIndex: cs ? cs.zIndex : '',
35
+ cursor: cs ? cs.cursor : '',
36
+ bbox: r ? { x: r.x, y: r.y, width: r.width, height: r.height } : null,
37
+ };
38
+ }
39
+ var els = (document.elementsFromPoint ? document.elementsFromPoint(x, y) : []).slice(0, MAX);
40
+ var top = els[0] || null;
41
+ function scrollAncestor(el) {
42
+ var n = el;
43
+ while (n && n.tagName) {
44
+ var cs = getComputedStyle(n);
45
+ var oy = cs.overflowY, ox = cs.overflowX;
46
+ var scrolly = (oy === 'auto' || oy === 'scroll') && n.scrollHeight > n.clientHeight;
47
+ var scrollx = (ox === 'auto' || ox === 'scroll') && n.scrollWidth > n.clientWidth;
48
+ if (scrolly || scrollx) return n;
49
+ n = n.parentElement;
50
+ }
51
+ return null;
52
+ }
53
+ function clickableAncestor(el) {
54
+ var n = el;
55
+ while (n && n.tagName) {
56
+ var t = n.tagName.toLowerCase();
57
+ var role = n.getAttribute ? n.getAttribute('role') : null;
58
+ if (t === 'a' || t === 'button' || role === 'button' || role === 'link' ||
59
+ (n.hasAttribute && (n.hasAttribute('onclick') || n.hasAttribute('tabindex')))) return n;
60
+ n = n.parentElement;
61
+ }
62
+ return null;
63
+ }
64
+ return {
65
+ stack: els.map(summ),
66
+ scrollContainer: top ? summ(scrollAncestor(top)) : null,
67
+ clickableAncestor: top ? summ(clickableAncestor(top)) : null,
68
+ };
69
+ })()`;
70
+ }
71
+ export async function pointProbe(page, point, opts = {}) {
72
+ const probed = await page.evaluate(buildProbeScript(point.x, point.y, MAX_STACK));
73
+ const result = {
74
+ ok: true,
75
+ point,
76
+ stack: probed.stack ?? [],
77
+ scrollContainer: probed.scrollContainer ?? null,
78
+ clickableAncestor: probed.clickableAncestor ?? null,
79
+ };
80
+ if (opts.crop) {
81
+ try {
82
+ const half = 40;
83
+ const buf = await page.screenshot({
84
+ clip: {
85
+ x: Math.max(0, point.x - half),
86
+ y: Math.max(0, point.y - half),
87
+ width: half * 2,
88
+ height: half * 2,
89
+ },
90
+ type: "png",
91
+ });
92
+ result.cropBase64 = Buffer.from(buf).toString("base64");
93
+ }
94
+ catch {
95
+ /* crop is best-effort — the probe stack is the primary signal */
96
+ }
97
+ }
98
+ return result;
99
+ }
@@ -0,0 +1,67 @@
1
+ import type { DispatchedAction } from "./actionresult.js";
2
+ import type { FindCandidate } from "./find.js";
3
+ export interface RecordedStep {
4
+ id: string;
5
+ action: DispatchedAction;
6
+ url: string;
7
+ selectorHint?: string;
8
+ /** Stability of the locator at calibration time. friend. */
9
+ stability?: FindCandidate["stability"];
10
+ /** Optional agent-supplied annotation for the doc emission. */
11
+ annotation?: {
12
+ copy: string;
13
+ arrow?: string;
14
+ target?: string;
15
+ };
16
+ ts: number;
17
+ }
18
+ export declare class Recorder {
19
+ private steps;
20
+ private name;
21
+ private autoCounter;
22
+ start(flowName: string): {
23
+ ok: true;
24
+ name: string;
25
+ };
26
+ active(): boolean;
27
+ /** Read-only access to the recorded trace + the flow name without ending
28
+ * the recording. Used by trace-export tools (e.g. the Playwright-script
29
+ * exporter) that need to lower the steps to a runnable artefact while the
30
+ * recording is still in progress. Returns null when no recording is
31
+ * active. */
32
+ inspect(): {
33
+ name: string;
34
+ steps: ReadonlyArray<RecordedStep>;
35
+ } | null;
36
+ /** Record an action that just happened. The caller (server.ts action handlers)
37
+ * passes the descriptor + the URL it ended at + whatever selectorHint was
38
+ * used to resolve the target. Best-effort: if no recording is active, this
39
+ * is a no-op. */
40
+ record(descriptor: DispatchedAction, url: string, hint?: {
41
+ selectorHint: string;
42
+ stability?: FindCandidate["stability"];
43
+ }): void;
44
+ /** Attach an annotation to the most-recent step (or by id). */
45
+ annotate(args: {
46
+ stepId?: string;
47
+ copy: string;
48
+ arrow?: string;
49
+ target?: string;
50
+ }): {
51
+ ok: boolean;
52
+ error?: string;
53
+ };
54
+ /** End the recording. Returns the YAML draft + the step count. */
55
+ end(): {
56
+ name: string;
57
+ yaml: string;
58
+ stepCount: number;
59
+ };
60
+ private suggestId;
61
+ /** Render the recording as YAML. Minimal site-docs-flavoured shape; consumers
62
+ * can post-process. We don't pull in a YAML library to keep deps lean — the
63
+ * output is small + predictable. */
64
+ private toYaml;
65
+ private collectLocators;
66
+ private locatorNameFor;
67
+ }