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,257 @@
1
+ /// <reference lib="dom" />
2
+ // canvas_capture — framebuffer / 2D ImageData / PNG bytes of a `<canvas>`.
3
+ // App-agnostic pixel source for the BYO-vision loop (see canvas.ts header).
4
+ //
5
+ // Bounded: refuses canvases larger than 16384×16384 (CANVAS_MAX_DIMENSION) —
6
+ // a multi-megapixel buffer round-tripped through base64 is genuinely a problem.
7
+ /** Max canvas dimensions accepted by `canvas_capture`. Larger canvases
8
+ * refuse with a structured error rather than allocating a giant byte
9
+ * payload. 16384 matches Chromium's `max_texture_size` for most
10
+ * hardware — a `<canvas>` larger than this would not paint correctly
11
+ * anyway. */
12
+ export const CANVAS_MAX_DIMENSION = 16384;
13
+ // The page-side capture is decomposed into per-format helpers so the
14
+ // top-level `PAGE_CAPTURE_FN` stays a small dispatcher. EVERY helper is a
15
+ // nested declaration of PAGE_CAPTURE_FN — the whole thing must serialize as
16
+ // one self-contained function literal across `page.evaluate`, so the helpers
17
+ // cannot live at module scope (they would be lost on serialization). The split
18
+ // is therefore internal to the one function literal.
19
+ /** Page-side capture function — REAL function literal (NOT stringified).
20
+ * Playwright's `page.evaluate(fn, arg)` serializes the source + invokes
21
+ * in-page with the arg. Mirror of the pattern used in `dom_export` /
22
+ * `element_export` / `overflow_detect` — a stringified arrow function
23
+ * evaluates to the function value uncalled, which CDP can't serialize.
24
+ *
25
+ * Returns a structured discriminated union (mirror of CanvasCaptureResult)
26
+ * so the host side can pass it straight back. */
27
+ export const PAGE_CAPTURE_FN = (args) => {
28
+ // --- locate ---
29
+ function locateCanvas() {
30
+ let canvas = null;
31
+ if (args.selector) {
32
+ try {
33
+ const found = document.querySelector(args.selector);
34
+ if (found && found.tagName.toLowerCase() === "canvas") {
35
+ canvas = found;
36
+ }
37
+ }
38
+ catch (_) {
39
+ /* ignore — fall through */
40
+ }
41
+ }
42
+ if (!canvas && args.ref) {
43
+ try {
44
+ const found = document.querySelector(`[data-browx-ref="${args.ref}"]`);
45
+ if (found && found.tagName.toLowerCase() === "canvas") {
46
+ canvas = found;
47
+ }
48
+ }
49
+ catch (_) {
50
+ /* ignore */
51
+ }
52
+ }
53
+ if (!canvas) {
54
+ const all = document.getElementsByTagName("canvas");
55
+ if (all.length > 0)
56
+ canvas = all[0];
57
+ }
58
+ return canvas;
59
+ }
60
+ // --- shared encode helper ---
61
+ // base64-encode a Uint8Array using only DOM-available builtins. btoa wants
62
+ // binary string input; build it in chunks so we don't blow the call stack
63
+ // on huge buffers.
64
+ function bytesToB64(bytes) {
65
+ let binary = "";
66
+ const chunk = 0x8000;
67
+ for (let i = 0; i < bytes.length; i += chunk) {
68
+ const slice = bytes.subarray(i, Math.min(i + chunk, bytes.length));
69
+ binary += String.fromCharCode.apply(null, Array.prototype.slice.call(slice));
70
+ }
71
+ return btoa(binary);
72
+ }
73
+ // --- per-format captures ---
74
+ function capturePng(canvas, w, h) {
75
+ try {
76
+ const dataUrl = canvas.toDataURL("image/png");
77
+ const idx = dataUrl.indexOf("base64,");
78
+ if (idx < 0) {
79
+ return {
80
+ ok: false,
81
+ error: "toDataURL did not return a base64 payload",
82
+ code: "encode-failed",
83
+ };
84
+ }
85
+ const b64 = dataUrl.slice(idx + 7);
86
+ // Byte length of decoded PNG ≈ b64.length * 3/4 (minus padding).
87
+ let pad = 0;
88
+ if (b64.endsWith("=="))
89
+ pad = 2;
90
+ else if (b64.endsWith("="))
91
+ pad = 1;
92
+ const byteLength = Math.floor((b64.length * 3) / 4) - pad;
93
+ return { ok: true, format: "png", contentBase64: b64, byteLength, width: w, height: h };
94
+ }
95
+ catch (e) {
96
+ // toDataURL throws SecurityError on tainted canvases (cross-origin
97
+ // images without CORS). Surface a clean shape.
98
+ return {
99
+ ok: false,
100
+ error: "canvas.toDataURL failed: " + (e?.message || String(e)),
101
+ code: "taint-or-encode",
102
+ };
103
+ }
104
+ }
105
+ function captureImageData(canvas, w, h) {
106
+ const ctx = canvas.getContext("2d");
107
+ if (!ctx) {
108
+ return {
109
+ ok: false,
110
+ error: 'canvas has no 2d context (likely a WebGL/WebGPU canvas — try format:"webgl-framebuffer")',
111
+ code: "no-2d-context",
112
+ };
113
+ }
114
+ try {
115
+ const data = ctx.getImageData(0, 0, w, h);
116
+ const bytes = new Uint8Array(data.data.buffer, data.data.byteOffset, data.data.byteLength);
117
+ return {
118
+ ok: true,
119
+ format: "2d-imagedata",
120
+ contentBase64: bytesToB64(bytes),
121
+ width: w,
122
+ height: h,
123
+ channelCount: 4,
124
+ };
125
+ }
126
+ catch (e) {
127
+ return {
128
+ ok: false,
129
+ error: "getImageData failed: " + (e?.message || String(e)),
130
+ code: "taint-or-read",
131
+ };
132
+ }
133
+ }
134
+ function captureWebgl(canvas, w, h) {
135
+ // Try webgl2 first then webgl. Some apps configure
136
+ // preserveDrawingBuffer:false — readPixels then returns blank because the
137
+ // compositor cleared the buffer; the caller sees zero-bytes on diff in
138
+ // that case and we can't undo it without recreating the context.
139
+ let gl = null;
140
+ try {
141
+ gl = canvas.getContext("webgl2", { preserveDrawingBuffer: true });
142
+ }
143
+ catch (_) {
144
+ gl = null;
145
+ }
146
+ if (!gl) {
147
+ try {
148
+ gl = canvas.getContext("webgl", { preserveDrawingBuffer: true });
149
+ }
150
+ catch (_) {
151
+ gl = null;
152
+ }
153
+ }
154
+ if (!gl) {
155
+ return {
156
+ ok: false,
157
+ error: 'canvas has no webgl/webgl2 context (try format:"2d-imagedata" for a 2D canvas)',
158
+ code: "no-webgl-context",
159
+ };
160
+ }
161
+ try {
162
+ const pixels = new Uint8Array(w * h * 4);
163
+ gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
164
+ // WebGL's coordinate origin is bottom-left; flip into top-left order so
165
+ // downstream `canvas_diff` math is consistent with the imagedata format
166
+ // (and with PNG / typical screenshot conventions).
167
+ const flipped = new Uint8Array(w * h * 4);
168
+ const stride = w * 4;
169
+ for (let y = 0; y < h; y++) {
170
+ const src = (h - 1 - y) * stride;
171
+ const dst = y * stride;
172
+ flipped.set(pixels.subarray(src, src + stride), dst);
173
+ }
174
+ return {
175
+ ok: true,
176
+ format: "webgl-framebuffer",
177
+ contentBase64: bytesToB64(flipped),
178
+ width: w,
179
+ height: h,
180
+ channelCount: 4,
181
+ isWebGL: true,
182
+ };
183
+ }
184
+ catch (e) {
185
+ return {
186
+ ok: false,
187
+ error: "webgl readPixels failed: " + (e?.message || String(e)),
188
+ code: "webgl-read-failed",
189
+ };
190
+ }
191
+ }
192
+ // --- dispatch ---
193
+ const canvas = locateCanvas();
194
+ if (!canvas) {
195
+ return {
196
+ ok: false,
197
+ error: "no <canvas> element found on the page (ref/selector did not match and no fallback canvas exists)",
198
+ code: "no-canvas",
199
+ };
200
+ }
201
+ const w = canvas.width;
202
+ const h = canvas.height;
203
+ if (w <= 0 || h <= 0) {
204
+ return {
205
+ ok: false,
206
+ error: `canvas dimensions are non-positive (${w}x${h})`,
207
+ code: "bad-dimensions",
208
+ };
209
+ }
210
+ if (w > args.maxDimension || h > args.maxDimension) {
211
+ return {
212
+ ok: false,
213
+ error: `canvas dimensions ${w}x${h} exceed the maximum ${args.maxDimension}x${args.maxDimension} cap`,
214
+ code: "too-large",
215
+ };
216
+ }
217
+ if (args.format === "png")
218
+ return capturePng(canvas, w, h);
219
+ if (args.format === "2d-imagedata")
220
+ return captureImageData(canvas, w, h);
221
+ return captureWebgl(canvas, w, h);
222
+ };
223
+ export async function canvasCapture(page, args) {
224
+ const r = await page.evaluate(PAGE_CAPTURE_FN, {
225
+ ref: args.ref,
226
+ selector: args.selector,
227
+ format: args.format,
228
+ maxDimension: CANVAS_MAX_DIMENSION,
229
+ });
230
+ if (!r.ok)
231
+ return {
232
+ ok: false,
233
+ error: r.error ?? "canvas_capture failed",
234
+ ...(r.code ? { code: r.code } : {}),
235
+ };
236
+ if (r.format === "png") {
237
+ return {
238
+ ok: true,
239
+ format: "png",
240
+ contentBase64: r.contentBase64,
241
+ byteLength: r.byteLength,
242
+ width: r.width,
243
+ height: r.height,
244
+ };
245
+ }
246
+ const out = {
247
+ ok: true,
248
+ format: r.format,
249
+ contentBase64: r.contentBase64,
250
+ width: r.width,
251
+ height: r.height,
252
+ channelCount: 4,
253
+ };
254
+ if (r.isWebGL)
255
+ out.isWebGL = true;
256
+ return out;
257
+ }
@@ -0,0 +1,51 @@
1
+ export interface CanvasDiffRegion {
2
+ x: number;
3
+ y: number;
4
+ w: number;
5
+ h: number;
6
+ }
7
+ export interface CanvasDiffArgs {
8
+ /** Base64 RGBA bytes (or PNG — see note below) from a prior capture. */
9
+ beforeBase64: string;
10
+ /** Base64 RGBA bytes (or PNG) from a later capture. */
11
+ afterBase64: string;
12
+ /** Optional sub-rectangle (in pixels, top-left origin). When omitted,
13
+ * the diff covers the whole image. */
14
+ region?: CanvasDiffRegion;
15
+ /** Pixel dimensions of the two captures. Required when both inputs are
16
+ * RGBA bytes — the byte buffer alone does not carry width/height. */
17
+ width?: number;
18
+ height?: number;
19
+ /** Tag the inputs explicitly when known. Defaults to `rgba`; pass
20
+ * `png` to surface the PNG-decode caveat in the warnings. */
21
+ inputFormat?: "rgba" | "png";
22
+ }
23
+ export interface CanvasDiffResult {
24
+ ok: boolean;
25
+ /** Number of pixels with any RGBA channel differing between before/
26
+ * after within the region. For PNG inputs (no decode this cycle),
27
+ * reports 0 when the base64 strings match byte-for-byte, otherwise
28
+ * the total pixel count of the region and surfaces a warning. */
29
+ changedPixelCount: number;
30
+ /** Sum of absolute per-channel differences across all changed pixels
31
+ * (cap-summed at 4 channels per pixel). Useful for "how much
32
+ * changed", not just "did anything". */
33
+ changedBytes: number;
34
+ /** Ratio of changed pixels to total pixels in the region (0..1). */
35
+ percentageChanged: number;
36
+ /** Tight bounding box of the changed area, in image coordinates. Null
37
+ * when no pixels changed. */
38
+ bboxOfChanges: {
39
+ x: number;
40
+ y: number;
41
+ w: number;
42
+ h: number;
43
+ } | null;
44
+ warnings: string[];
45
+ error?: string;
46
+ code?: string;
47
+ }
48
+ /** Pure function — pixel diff math on two RGBA byte buffers. Exposed for
49
+ * unit tests; the MCP handler in server.ts unwraps the base64. */
50
+ export declare function diffRgba(before: Uint8Array, after: Uint8Array, width: number, height: number, region?: CanvasDiffRegion): Omit<CanvasDiffResult, "warnings" | "error" | "code">;
51
+ export declare function canvasDiff(args: CanvasDiffArgs): CanvasDiffResult;
@@ -0,0 +1,131 @@
1
+ // canvas_diff — pixel/region delta between two RGBA captures. Pure function
2
+ // over bytes; no page contact. (See canvas.ts header for the tool overview.)
3
+ /** Pure function — pixel diff math on two RGBA byte buffers. Exposed for
4
+ * unit tests; the MCP handler in server.ts unwraps the base64. */
5
+ export function diffRgba(before, after, width, height, region) {
6
+ const expected = width * height * 4;
7
+ if (before.length !== expected || after.length !== expected) {
8
+ return {
9
+ ok: false,
10
+ changedPixelCount: 0,
11
+ changedBytes: 0,
12
+ percentageChanged: 0,
13
+ bboxOfChanges: null,
14
+ };
15
+ }
16
+ const r = region ?? { x: 0, y: 0, w: width, h: height };
17
+ // Clamp the region to image bounds (an over-flow region collapses
18
+ // into the available pixel rectangle rather than throwing).
19
+ const x0 = Math.max(0, Math.min(width, Math.floor(r.x)));
20
+ const y0 = Math.max(0, Math.min(height, Math.floor(r.y)));
21
+ const x1 = Math.max(0, Math.min(width, Math.floor(r.x + r.w)));
22
+ const y1 = Math.max(0, Math.min(height, Math.floor(r.y + r.h)));
23
+ if (x1 <= x0 || y1 <= y0) {
24
+ return {
25
+ ok: true,
26
+ changedPixelCount: 0,
27
+ changedBytes: 0,
28
+ percentageChanged: 0,
29
+ bboxOfChanges: null,
30
+ };
31
+ }
32
+ let changed = 0;
33
+ let bytes = 0;
34
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
35
+ const totalPixels = (x1 - x0) * (y1 - y0);
36
+ for (let y = y0; y < y1; y++) {
37
+ for (let x = x0; x < x1; x++) {
38
+ const idx = (y * width + x) * 4;
39
+ const r0 = before[idx], g0 = before[idx + 1], b0 = before[idx + 2], a0 = before[idx + 3];
40
+ const r1 = after[idx], g1 = after[idx + 1], b1 = after[idx + 2], a1 = after[idx + 3];
41
+ const d = Math.abs(r1 - r0) + Math.abs(g1 - g0) + Math.abs(b1 - b0) + Math.abs(a1 - a0);
42
+ if (d !== 0) {
43
+ changed++;
44
+ bytes += d;
45
+ if (x < minX)
46
+ minX = x;
47
+ if (y < minY)
48
+ minY = y;
49
+ if (x > maxX)
50
+ maxX = x;
51
+ if (y > maxY)
52
+ maxY = y;
53
+ }
54
+ }
55
+ }
56
+ return {
57
+ ok: true,
58
+ changedPixelCount: changed,
59
+ changedBytes: bytes,
60
+ percentageChanged: totalPixels === 0 ? 0 : changed / totalPixels,
61
+ bboxOfChanges: changed === 0 ? null : { x: minX, y: minY, w: maxX - minX + 1, h: maxY - minY + 1 },
62
+ };
63
+ }
64
+ export function canvasDiff(args) {
65
+ const warnings = [];
66
+ const inputFormat = args.inputFormat ?? "rgba";
67
+ // PNG path (deferred — just compare base64 byte equality this cycle).
68
+ // The roadmap note in the spec: "for PNG format inputs: document that
69
+ // PNG-decoded-pixel diff is a follow-up (just compare base64 byte
70
+ // equality for now and surface a warning when inputs are PNG instead
71
+ // of RGBA)."
72
+ if (inputFormat === "png") {
73
+ warnings.push("PNG-decoded pixel diff is a follow-up — this cycle compares base64 byte equality only. " +
74
+ "For per-pixel + bbox math, recapture with format:'2d-imagedata' or format:'webgl-framebuffer'.");
75
+ const same = args.beforeBase64 === args.afterBase64;
76
+ return {
77
+ ok: true,
78
+ changedPixelCount: same ? 0 : 1,
79
+ changedBytes: same ? 0 : 1,
80
+ percentageChanged: same ? 0 : 1,
81
+ bboxOfChanges: null,
82
+ warnings,
83
+ };
84
+ }
85
+ if (args.width === undefined || args.height === undefined) {
86
+ return {
87
+ ok: false,
88
+ changedPixelCount: 0,
89
+ changedBytes: 0,
90
+ percentageChanged: 0,
91
+ bboxOfChanges: null,
92
+ warnings,
93
+ error: "canvas_diff with format:'rgba' inputs requires width + height — the byte buffer does not carry dimensions",
94
+ code: "missing-dimensions",
95
+ };
96
+ }
97
+ let before;
98
+ let after;
99
+ try {
100
+ before = Buffer.from(args.beforeBase64, "base64");
101
+ after = Buffer.from(args.afterBase64, "base64");
102
+ }
103
+ catch (e) {
104
+ return {
105
+ ok: false,
106
+ changedPixelCount: 0,
107
+ changedBytes: 0,
108
+ percentageChanged: 0,
109
+ bboxOfChanges: null,
110
+ warnings,
111
+ error: "canvas_diff: failed to base64-decode an input — " +
112
+ (e instanceof Error ? e.message : String(e)),
113
+ code: "decode-failed",
114
+ };
115
+ }
116
+ const expected = args.width * args.height * 4;
117
+ if (before.length !== expected || after.length !== expected) {
118
+ return {
119
+ ok: false,
120
+ changedPixelCount: 0,
121
+ changedBytes: 0,
122
+ percentageChanged: 0,
123
+ bboxOfChanges: null,
124
+ warnings,
125
+ error: `canvas_diff: RGBA byte length mismatch — got before=${before.length}, after=${after.length}, expected ${expected} (width*height*4)`,
126
+ code: "shape-mismatch",
127
+ };
128
+ }
129
+ const r = diffRgba(before, after, args.width, args.height, args.region);
130
+ return { ...r, warnings };
131
+ }
@@ -0,0 +1,53 @@
1
+ export type GestureChainStepKind = "down" | "move" | "up" | "wait" | "wheel";
2
+ export interface GestureChainStep {
3
+ kind: GestureChainStepKind;
4
+ x?: number;
5
+ y?: number;
6
+ deltaX?: number;
7
+ deltaY?: number;
8
+ ms?: number;
9
+ pointerId?: number;
10
+ }
11
+ export interface GestureChainArgs {
12
+ steps: GestureChainStep[];
13
+ }
14
+ export interface GestureChainResult {
15
+ ok: boolean;
16
+ stepsExecuted: number;
17
+ totalDurationMs: number;
18
+ warnings: string[];
19
+ error?: string;
20
+ code?: string;
21
+ }
22
+ export declare const GESTURE_CHAIN_MAX_STEPS = 200;
23
+ export declare const GESTURE_CHAIN_MIN_MOVE_MS = 5;
24
+ export declare const GESTURE_CHAIN_MAX_WAIT_MS = 5000;
25
+ export interface ValidateGestureChainResult {
26
+ ok: boolean;
27
+ steps: GestureChainStep[];
28
+ warnings: string[];
29
+ error?: string;
30
+ code?: string;
31
+ }
32
+ /** Validate + clamp a gesture-chain step list. Pure function — returns
33
+ * the normalised step list + any warnings the runtime should surface.
34
+ * Hard caps (max steps) refuse loudly; soft caps (min move ms, max wait
35
+ * ms) clamp + warn. */
36
+ export declare function validateGestureChain(steps: GestureChainStep[]): ValidateGestureChainResult;
37
+ /** Thin adapter so unit tests can stub Playwright's `page.mouse`. */
38
+ export interface GestureChainPage {
39
+ mouse: {
40
+ down(options?: {
41
+ button?: "left" | "right" | "middle";
42
+ }): Promise<void>;
43
+ move(x: number, y: number, options?: {
44
+ steps?: number;
45
+ }): Promise<void>;
46
+ up(options?: {
47
+ button?: "left" | "right" | "middle";
48
+ }): Promise<void>;
49
+ wheel(deltaX: number, deltaY: number): Promise<void>;
50
+ };
51
+ }
52
+ /** Execute a validated step list against a Playwright page mouse. */
53
+ export declare function runGestureChain(page: GestureChainPage, args: GestureChainArgs): Promise<GestureChainResult>;
@@ -0,0 +1,167 @@
1
+ // gesture_chain — multi-step pointer program (down / move / wheel / wait /
2
+ // up). Custom paint strokes, lasso paths, and gestures the canned `drag` /
3
+ // `gesture_swipe` family doesn't cover. (See canvas.ts header.)
4
+ //
5
+ // Bounded: caps at 200 steps, floors `move` step delays at 5 ms, bounds
6
+ // `wait` steps at 5000 ms.
7
+ export const GESTURE_CHAIN_MAX_STEPS = 200;
8
+ export const GESTURE_CHAIN_MIN_MOVE_MS = 5;
9
+ export const GESTURE_CHAIN_MAX_WAIT_MS = 5000;
10
+ function badStep(error) {
11
+ return { ok: false, error, code: "bad-step" };
12
+ }
13
+ /** Validate + clamp a single pointer step (`down`/`up`/`move`). `move`
14
+ * floors its delay at GESTURE_CHAIN_MIN_MOVE_MS, warning when it clamps. */
15
+ function validatePointerStep(s, i, warnings) {
16
+ if (typeof s.x !== "number" || typeof s.y !== "number") {
17
+ return badStep(`gesture_chain: step[${i}] kind="${s.kind}" requires numeric x + y`);
18
+ }
19
+ const clamped = { kind: s.kind, x: s.x, y: s.y };
20
+ if (s.pointerId !== undefined)
21
+ clamped.pointerId = s.pointerId;
22
+ if (s.kind === "move") {
23
+ const ms = typeof s.ms === "number" ? s.ms : GESTURE_CHAIN_MIN_MOVE_MS;
24
+ if (ms < GESTURE_CHAIN_MIN_MOVE_MS) {
25
+ warnings.push(`gesture_chain: step[${i}] move ms=${ms} floored to ${GESTURE_CHAIN_MIN_MOVE_MS}ms — tighter pacing rarely changes app behaviour and starves the renderer`);
26
+ clamped.ms = GESTURE_CHAIN_MIN_MOVE_MS;
27
+ }
28
+ else {
29
+ clamped.ms = ms;
30
+ }
31
+ }
32
+ return { ok: true, step: clamped };
33
+ }
34
+ /** Validate + clamp a `wait` step. Refuses negatives; clamps over-long
35
+ * waits at GESTURE_CHAIN_MAX_WAIT_MS with a warning. */
36
+ function validateWaitStep(s, i, warnings) {
37
+ const ms = typeof s.ms === "number" ? s.ms : 0;
38
+ if (ms < 0) {
39
+ return badStep(`gesture_chain: step[${i}] wait ms must be non-negative`);
40
+ }
41
+ const clamped = { kind: "wait" };
42
+ if (ms > GESTURE_CHAIN_MAX_WAIT_MS) {
43
+ warnings.push(`gesture_chain: step[${i}] wait ms=${ms} clamped to max ${GESTURE_CHAIN_MAX_WAIT_MS}ms — a single chained wait should not exceed 5s; split across calls`);
44
+ clamped.ms = GESTURE_CHAIN_MAX_WAIT_MS;
45
+ }
46
+ else {
47
+ clamped.ms = ms;
48
+ }
49
+ return { ok: true, step: clamped };
50
+ }
51
+ /** Validate a `wheel` step — requires a non-zero delta; carries optional
52
+ * cursor position. */
53
+ function validateWheelStep(s, i) {
54
+ const dx = typeof s.deltaX === "number" ? s.deltaX : 0;
55
+ const dy = typeof s.deltaY === "number" ? s.deltaY : 0;
56
+ if (dx === 0 && dy === 0) {
57
+ return badStep(`gesture_chain: step[${i}] wheel requires non-zero deltaX or deltaY`);
58
+ }
59
+ const clamped = { kind: "wheel", deltaX: dx, deltaY: dy };
60
+ if (typeof s.x === "number")
61
+ clamped.x = s.x;
62
+ if (typeof s.y === "number")
63
+ clamped.y = s.y;
64
+ return { ok: true, step: clamped };
65
+ }
66
+ function validateStep(s, i, warnings) {
67
+ if (!s || typeof s.kind !== "string") {
68
+ return badStep(`gesture_chain: step[${i}] missing kind`);
69
+ }
70
+ if (s.kind === "down" || s.kind === "up" || s.kind === "move") {
71
+ return validatePointerStep(s, i, warnings);
72
+ }
73
+ if (s.kind === "wait")
74
+ return validateWaitStep(s, i, warnings);
75
+ if (s.kind === "wheel")
76
+ return validateWheelStep(s, i);
77
+ return badStep(`gesture_chain: step[${i}] unknown kind "${String(s.kind)}"`);
78
+ }
79
+ /** Validate + clamp a gesture-chain step list. Pure function — returns
80
+ * the normalised step list + any warnings the runtime should surface.
81
+ * Hard caps (max steps) refuse loudly; soft caps (min move ms, max wait
82
+ * ms) clamp + warn. */
83
+ export function validateGestureChain(steps) {
84
+ const warnings = [];
85
+ if (!Array.isArray(steps) || steps.length === 0) {
86
+ return {
87
+ ok: false,
88
+ steps: [],
89
+ warnings,
90
+ error: "gesture_chain: `steps` must be a non-empty array",
91
+ code: "no-steps",
92
+ };
93
+ }
94
+ if (steps.length > GESTURE_CHAIN_MAX_STEPS) {
95
+ return {
96
+ ok: false,
97
+ steps: [],
98
+ warnings,
99
+ error: `gesture_chain: ${steps.length} steps exceeds the maximum ${GESTURE_CHAIN_MAX_STEPS}; split the program across multiple calls`,
100
+ code: "too-many-steps",
101
+ };
102
+ }
103
+ const out = [];
104
+ for (let i = 0; i < steps.length; i++) {
105
+ const outcome = validateStep(steps[i], i, warnings);
106
+ if (!outcome.ok) {
107
+ return { ok: false, steps: [], warnings, error: outcome.error, code: outcome.code };
108
+ }
109
+ out.push(outcome.step);
110
+ }
111
+ return { ok: true, steps: out, warnings };
112
+ }
113
+ /** Execute one validated step against the page mouse. */
114
+ async function runGestureStep(page, s) {
115
+ if (s.kind === "down") {
116
+ // Position the pointer at the down point so the press lands where the
117
+ // caller asked. Playwright's mouse.down() acts at the current pointer
118
+ // position only.
119
+ await page.mouse.move(s.x, s.y);
120
+ await page.mouse.down();
121
+ }
122
+ else if (s.kind === "up") {
123
+ await page.mouse.move(s.x, s.y);
124
+ await page.mouse.up();
125
+ }
126
+ else if (s.kind === "move") {
127
+ await page.mouse.move(s.x, s.y);
128
+ if (s.ms && s.ms > 0)
129
+ await new Promise((r) => setTimeout(r, s.ms));
130
+ }
131
+ else if (s.kind === "wait") {
132
+ if (s.ms && s.ms > 0)
133
+ await new Promise((r) => setTimeout(r, s.ms));
134
+ }
135
+ else if (s.kind === "wheel") {
136
+ if (typeof s.x === "number" && typeof s.y === "number") {
137
+ await page.mouse.move(s.x, s.y);
138
+ }
139
+ await page.mouse.wheel(s.deltaX ?? 0, s.deltaY ?? 0);
140
+ }
141
+ }
142
+ /** Execute a validated step list against a Playwright page mouse. */
143
+ export async function runGestureChain(page, args) {
144
+ const v = validateGestureChain(args.steps);
145
+ if (!v.ok) {
146
+ return {
147
+ ok: false,
148
+ stepsExecuted: 0,
149
+ totalDurationMs: 0,
150
+ warnings: v.warnings,
151
+ ...(v.error ? { error: v.error } : {}),
152
+ ...(v.code ? { code: v.code } : {}),
153
+ };
154
+ }
155
+ const started = Date.now();
156
+ let executed = 0;
157
+ for (const s of v.steps) {
158
+ await runGestureStep(page, s);
159
+ executed++;
160
+ }
161
+ return {
162
+ ok: true,
163
+ stepsExecuted: executed,
164
+ totalDurationMs: Date.now() - started,
165
+ warnings: v.warnings,
166
+ };
167
+ }