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,287 @@
1
+ import type { z } from "zod";
2
+ import type { Capability, CapabilityConfig } from "../util/capabilities.js";
3
+ import type { SessionEntry, SessionRegistry } from "../session/registry.js";
4
+ import type { DiagnosticsRecorder } from "../util/diagnostics.js";
5
+ import type { RefRegistry } from "../page/refs.js";
6
+ import type { ActionContext } from "../page/actionresult.js";
7
+ import type { Workspace } from "../util/workspace.js";
8
+ import type { BrowxConfig } from "../util/config.js";
9
+ import type { ConfigStore, ResolvedConfig } from "../util/config-store.js";
10
+ import type { StartOptions } from "../server.js";
11
+ import type { ConfirmContext, ApprovalStore } from "../policy/confirm.js";
12
+ import type { CredentialProvider, CredentialsConfig } from "../util/credentials.js";
13
+ import type { PluginRecord } from "../plugin/types.js";
14
+ import type { ActionSubstrate } from "../page/action-substrate.js";
15
+ import type { CaptureSubstrate } from "../page/capture-substrate.js";
16
+ import type { StorageSubstrate } from "../page/storage-substrate.js";
17
+ import type { ScriptSubstrate } from "../page/script-substrate.js";
18
+ import type { EmulationSubstrate } from "../page/emulation-substrate.js";
19
+ import type { EgressSanitiser } from "../util/egress-sanitiser.js";
20
+ /** The MCP content shape every registered handler returns — the same `{ content }`
21
+ * envelope an over-the-wire MCP call produces. Shared with `createServer` so the
22
+ * composition root and the extracted tool modules speak one type. */
23
+ export type TextItem = {
24
+ type: "text";
25
+ text: string;
26
+ };
27
+ export type ImageItem = {
28
+ type: "image";
29
+ data: string;
30
+ mimeType: string;
31
+ };
32
+ export type ToolResponse = {
33
+ content: Array<TextItem | ImageItem>;
34
+ };
35
+ /** A target as the action tools accept it on the wire (ref / selector / named /
36
+ * coords), before `asTarget` narrows it to the substrate's `ActionTarget`. */
37
+ export interface RawTargetArgs {
38
+ ref?: string;
39
+ selector?: string;
40
+ named?: string;
41
+ contextRef?: string;
42
+ coords?: {
43
+ x: number;
44
+ y: number;
45
+ };
46
+ }
47
+ /** The narrowed target `asTarget` produces. */
48
+ export type ResolvedTarget = {
49
+ ref: string;
50
+ } | {
51
+ selector: string;
52
+ contextRef?: string;
53
+ } | {
54
+ coords: {
55
+ x: number;
56
+ y: number;
57
+ };
58
+ };
59
+ /**
60
+ * The gating metadata a tool declares inline at its `host.register` call
61
+ * (RFC 0004 P2 / D2). Colocating these facts with the tool makes the three
62
+ * central maps DERIVABLE rather than hand-maintained:
63
+ * - `capability` → the `TOOL_CAPABILITY` row (replaces `util/capabilities.ts`)
64
+ * - `batchable` → membership in the batch allow-set (replaces the host-build `Set`)
65
+ * - `deep` → membership in `DEEP_TOOLS` (replaces `engine/tool-gate.ts`)
66
+ * The single source of truth becomes the registration call; the maps iterate the
67
+ * registrations at startup. A tool that omits `capability` is treated as the
68
+ * `human` coordination default (the control-plane primitives that legitimately
69
+ * carry no browser capability — open_session, batch, get_config, …).
70
+ */
71
+ export interface ToolMeta {
72
+ /** The capability that gates this tool. Omit only for a control-plane
73
+ * coordination primitive that defaults to `human`. */
74
+ capability?: Capability;
75
+ /** May a compound/batch tool dispatch to this tool? Replaces batch-set membership. */
76
+ batchable?: boolean;
77
+ /** Needs the raw-CDP escape hatch — refused on engines that declare `deep:false`.
78
+ * Replaces `DEEP_TOOLS` membership. */
79
+ deep?: boolean;
80
+ }
81
+ /** One tool's accumulated registration record — its `ToolMeta` plus the
82
+ * description and zod input schema the `register` call carried. The host stores
83
+ * these so the central maps and the SDK tool-types codegen (RFC 0004 D7) derive
84
+ * from one place. The schema is type-erased to `z.ZodRawShape` (the codegen reads
85
+ * it structurally; the per-handler generic relation is enforced at the call site). */
86
+ export interface ToolRegistration extends ToolMeta {
87
+ description: string;
88
+ inputSchema?: z.ZodRawShape;
89
+ }
90
+ /**
91
+ * The composition seam between `createServer` (the registry composition root)
92
+ * and the per-family tool modules under `src/tools/`. `createServer` builds the
93
+ * shared state and helper closures once, bundles them into a single `ToolHost`,
94
+ * and hands that host to each `registerXxxTools(host)` module. The modules own
95
+ * the `register()` blocks; the host owns the closures those blocks need.
96
+ *
97
+ * Members are exposed at the granularity handlers consume them — a handler asks
98
+ * the host for exactly the closure it calls and nothing else.
99
+ */
100
+ /**
101
+ * RFC 0004 P3 / D3 (ISP). `ToolHost` is segregated into composable sub-ports a
102
+ * handler depends on à la carte. The 35 members already clustered by role in the
103
+ * source — gating, session resolution, action dispatch, the five engine-selected
104
+ * substrate ports, envelope builders, config, server services — so this is a
105
+ * REGROUPING, not a redesign. `ToolHost` stays as their INTERSECTION (declared at
106
+ * the bottom): the composition root keeps building one object that satisfies all
107
+ * of them, and a handler's signature may narrow to its slice (e.g.
108
+ * `registerActionTools(host: RegisterHost & GateHost & SessionHost & ActionHost)`)
109
+ * so the function signature compiles a guarantee of what it touches. Per
110
+ * 0004-03 §3.
111
+ */
112
+ /** Tool registration + the derived registration surface. Every function that
113
+ * wires a tool depends on this role. */
114
+ export interface RegisterHost {
115
+ /** Register one MCP tool: wires it into the server surface and the in-process
116
+ * handler side-table. The handler's `args` are typed from the tool's own zod
117
+ * `inputSchema` (the exact shape the MCP SDK parses and validates the wire
118
+ * payload into before dispatch), so a handler reads a precise object, never
119
+ * `any`. Tools with no `inputSchema` receive an empty object. */
120
+ register: <S extends z.ZodRawShape = Record<string, never>>(name: string, def: {
121
+ description: string;
122
+ inputSchema?: S;
123
+ /** The capability that gates this tool — derived into `TOOL_CAPABILITY`
124
+ * (RFC 0004 P2). Omit only for a `human` control-plane primitive. */
125
+ capability?: Capability;
126
+ /** Whether a compound/batch tool may dispatch to this tool — derived into
127
+ * the batch allow-set. */
128
+ batchable?: boolean;
129
+ /** Whether the tool needs the raw-CDP escape hatch — derived into
130
+ * `DEEP_TOOLS`, refused on engines that declare `deep:false`. */
131
+ deep?: boolean;
132
+ }, handler: (args: z.infer<z.ZodObject<S>>) => Promise<ToolResponse>) => void;
133
+ /** The batch whitelist — the set of tool names a compound/batch tool may dispatch
134
+ * to. Read lazily so the host can expose it before the set is populated. Derived
135
+ * (RFC 0004 P2) from each `register({ batchable: true })` call. */
136
+ readonly batchAllowedTools: ReadonlySet<string>;
137
+ /** The accumulated per-tool registration metadata (RFC 0004 P2 / D2 + D7): the
138
+ * `ToolMeta` each `register` call declared, plus the tool's zod `inputSchema`
139
+ * (the source the SDK tool-types codegen reads). Keyed by tool name, populated
140
+ * as each `registerXxxTools(host)` module runs. */
141
+ readonly registrations: ReadonlyMap<string, ToolRegistration>;
142
+ }
143
+ /** Capability/engine gating + denial envelopes. */
144
+ export interface GateHost {
145
+ /** Capability-dimension early return: disabled-tool refusal content, or null
146
+ * when the tool is enabled. */
147
+ gateCheck: (toolName: string) => ToolResponse | null;
148
+ /** Engine-dimension early return: unsupported-engine refusal content, or null
149
+ * when the engine supports the tool. */
150
+ engineGate: (toolName: string, e: SessionEntry) => ToolResponse | null;
151
+ /** Confirm-hook rejection content for a denied decision. */
152
+ denyContent: (toolName: string, decision: {
153
+ reason: string;
154
+ }) => ToolResponse;
155
+ }
156
+ /** Session resolution + the per-session contexts a handler builds. */
157
+ export interface SessionHost {
158
+ /** Resolve a session entry by id (defaulting to the default session). */
159
+ entryFor: (sessionId?: string) => Promise<SessionEntry>;
160
+ /** Build the confirm-hook context for a session entry. */
161
+ confirmCtxFor: (e: SessionEntry) => ConfirmContext;
162
+ /** Build the action/observe context for a session entry (page + substrates +
163
+ * per-session buffers + policies), as the read/observe + compound tools need. */
164
+ ctxFor: (e: SessionEntry) => ActionContext;
165
+ /** The session registry — the live source of truth for which sessions are open
166
+ * (the QA-evidence report bundles its `list()`). */
167
+ registry: SessionRegistry;
168
+ }
169
+ /** Action dispatch: targets, deadlines, the engine-selected action port, envelopes. */
170
+ export interface ActionHost {
171
+ /** Narrow wire target args to a resolved `ActionTarget`; throws on ambiguity /
172
+ * unbound name / missing target. */
173
+ asTarget: (args: RawTargetArgs, toolName: string, refs: RefRegistry) => ResolvedTarget;
174
+ /** Reconstruct the recorder `selectorHint` for a resolved target. */
175
+ hintFromTarget: (e: SessionEntry, target: RawTargetArgs) => {
176
+ selectorHint: string;
177
+ stability?: "high" | "medium" | "low";
178
+ } | undefined;
179
+ /** Resolve a call's effective anti-wedge deadline (per-call over config over default). */
180
+ actionTimeout: (args: {
181
+ timeoutMs?: number;
182
+ }) => {
183
+ ms: number;
184
+ warning?: string;
185
+ };
186
+ /** The effective config action-timeout, for tools without a per-call override. */
187
+ cfgActionTimeout: () => number;
188
+ /** The action capability port for a session (engine-selected). */
189
+ actionsFor: (e: SessionEntry) => ActionSubstrate;
190
+ /** Wrap an ActionResult promise as the standard `{ content: [text] }` envelope. */
191
+ asActionResultText: (p: Promise<unknown>) => Promise<ToolResponse>;
192
+ }
193
+ /** The capture capability port. */
194
+ export interface CaptureHost {
195
+ /** The capture capability port for a session (engine-selected). */
196
+ captureFor: (e: SessionEntry) => CaptureSubstrate;
197
+ }
198
+ /** The storage capability port. */
199
+ export interface StorageHost {
200
+ /** The storage capability port for a session (engine-selected). */
201
+ storageFor: (e: SessionEntry) => StorageSubstrate;
202
+ }
203
+ /** The script (page-eval) capability port. */
204
+ export interface ScriptHost {
205
+ /** The script capability port for a session (engine-selected). */
206
+ scriptFor: (e: SessionEntry) => ScriptSubstrate;
207
+ }
208
+ /** The live-emulation capability port. */
209
+ export interface EmulationHost {
210
+ /** The live-emulation capability port for a session (engine-selected). */
211
+ emulationFor: (e: SessionEntry) => EmulationSubstrate;
212
+ }
213
+ /** The egress-masking chokepoint (RFC 0004 P3 / D4). A family that returns
214
+ * page-derived text/JSON masks it through the injected `EgressSanitiser` instead
215
+ * of hand-calling `caps.enabled.has("secrets") ? e.secrets.applyMaskDeep(x) : x`.
216
+ * The capability decision is made ONCE here (the sanitiser holds a null registry
217
+ * when `secrets` is off), so a sink no longer inlines the gate. */
218
+ export interface EgressHost {
219
+ /** The egress sanitiser for a session: `EgressSanitiser(e.secrets)` when the
220
+ * `secrets` capability is on, else `EgressSanitiser(null)`. `maskDeep` /
221
+ * `maskText` / `containsAnySecret` are byte-identical to the prior hand-calls. */
222
+ egressFor: (e: SessionEntry) => EgressSanitiser;
223
+ }
224
+ /** JSON / ActionResult envelope builders shared by every JSON-returning family. */
225
+ export interface EnvelopeHost {
226
+ /** JSON envelope builder for the non-action (JSON-returning) families: stringify
227
+ * the body with an appended `tokensEstimate`. Every such family — storage,
228
+ * cookies, auth, caches, … — returns through this so callers see one shape. */
229
+ okText: (body: Record<string, unknown>) => ToolResponse;
230
+ /** The `ok:false` rejection counterpart of `okText`, same envelope shape. */
231
+ errText: (tool: string, err: unknown) => ToolResponse;
232
+ }
233
+ /** Resolved config, capabilities, and the workspace root the tools read. */
234
+ export interface ConfigHost {
235
+ /** Resolved workspace (root dir for file-io-bound captures and archives). */
236
+ workspace: Workspace;
237
+ /** Resolved capability policy (active set + warnings). */
238
+ caps: CapabilityConfig;
239
+ /** Resolved server config (test attributes, timeouts, …). */
240
+ config: BrowxConfig;
241
+ /** Layered config store — the live source for re-resolvable settings. */
242
+ configStore: ConfigStore;
243
+ /** The once-resolved config snapshot taken at server start — the
244
+ * extension-rebuild path reads creation-time launch defaults (headless,
245
+ * device, viewport) from it. */
246
+ resolvedConfig: ResolvedConfig;
247
+ /** The server start options — the extension-rebuild path reads the
248
+ * operator's `headless` override from them. */
249
+ startOptions: StartOptions;
250
+ }
251
+ /** Server-scoped services the tool families dispatch through: zod, the in-process
252
+ * handler table, the diagnostics/approvals/credentials stores, the loaded-plugin
253
+ * records, and the per-call metrics/diagnostics hooks. */
254
+ export interface ServerServicesHost {
255
+ /** zod, so tool modules build their input schemas with the same instance the
256
+ * composition root uses. */
257
+ z: typeof z;
258
+ /** The in-process handler side-table — the compound tools (act_and_wait_for_network,
259
+ * …) dispatch an inner tool by name through this rather than re-implementing it. */
260
+ toolHandlers: Record<string, (args: unknown) => Promise<ToolResponse>>;
261
+ /** The diagnostics JSONL recorder — the note/search/report family reads and
262
+ * writes the agent-feedback store through it. */
263
+ diagnostics: DiagnosticsRecorder;
264
+ /** The session-independent pre-approval store — the approve_actions /
265
+ * list_approvals tools grant and list confirm-scope pre-approvals through it. */
266
+ approvals: ApprovalStore;
267
+ /** The credentials provider resolved once at server start — the get_totp /
268
+ * get_credential tools shell out through it (off-by-default `credentials`). */
269
+ credentialsResolved: {
270
+ provider: CredentialProvider;
271
+ config: CredentialsConfig;
272
+ };
273
+ /** The loaded-plugin records — get_config reports the live enabled-plugin set
274
+ * from them. A getter: the records are assigned after the host is built. */
275
+ readonly pluginRecords: ReadonlyArray<PluginRecord>;
276
+ /** Record one dispatch on the session's metrics counter — the plugin runtime
277
+ * reuses it so plugin-tool calls roll up into the same per-session metrics. */
278
+ noteMetrics: (toolName: string, args: unknown, res: ToolResponse, startedAt: number) => void;
279
+ /** Record one dispatched call into the diagnostics JSONL store — the plugin
280
+ * runtime reuses it so plugin-tool calls land in the same store. */
281
+ noteDiagnostics: (toolName: string, args: unknown, res: ToolResponse, startedAt: number) => void;
282
+ }
283
+ /** The full host the composition root assembles — the INTERSECTION of every
284
+ * sub-port. `buildHost` returns one object that satisfies all of them; a handler
285
+ * may type its `host` parameter to the narrower slice it actually calls. */
286
+ export interface ToolHost extends RegisterHost, GateHost, SessionHost, ActionHost, CaptureHost, StorageHost, ScriptHost, EmulationHost, EgressHost, EnvelopeHost, ConfigHost, ServerServicesHost {
287
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ToolHost } from "./host.js";
2
+ /**
3
+ * Low-level input primitives: the raw mouse pipeline (mouse_down / mouse_move /
4
+ * mouse_up), the CDP touch pipeline (touch_start / touch_move / touch_end), and
5
+ * the profile checkpoint pair (profile_snapshot / profile_restore). Every block
6
+ * is registered through the shared `ToolHost` seam; the host owns the closures
7
+ * (gate, engine-gate, entry) and the registry/workspace state, this module owns
8
+ * the registrations.
9
+ */
10
+ export declare function registerInputTools(host: ToolHost): void;
@@ -0,0 +1,176 @@
1
+ import { withDeadline } from "../util/deadline.js";
2
+ import { estimateTokens } from "../util/tokens.js";
3
+ import { mouseAction, touchAction } from "../page/gestures.js";
4
+ import { snapshotProfile, restoreProfile } from "../session/profile-snapshot.js";
5
+ import { requireCdp } from "../engine/session-cdp.js";
6
+ import { SESSION_ARG } from "./schemas.js";
7
+ /**
8
+ * Low-level input primitives: the raw mouse pipeline (mouse_down / mouse_move /
9
+ * mouse_up), the CDP touch pipeline (touch_start / touch_move / touch_end), and
10
+ * the profile checkpoint pair (profile_snapshot / profile_restore). Every block
11
+ * is registered through the shared `ToolHost` seam; the host owns the closures
12
+ * (gate, engine-gate, entry) and the registry/workspace state, this module owns
13
+ * the registrations.
14
+ */
15
+ export function registerInputTools(host) {
16
+ const { z, register, gateCheck, engineGate, entryFor, cfgActionTimeout, registry, workspace } = host;
17
+ // A *factory* — each call returns a fresh schema instance. Reusing one
18
+ // shared instance across `from`/`to`/`target` made zod-to-json-schema emit a
19
+ // `$ref` for the repeats, which some MCP schema viewers render wrong (the
20
+ // reported `drag.to.coords` showing as `string`). Distinct instances → no
21
+ // `$ref` dedup → every field renders identically.
22
+ for (const act of ["mouse_down", "mouse_move", "mouse_up"]) {
23
+ register(act, {
24
+ // mouse_down / mouse_move / mouse_up — low-level pointer dispatch.
25
+ capability: "action",
26
+ description: `Low-level ${act.replace("_", " ")} for custom gestures the higher-level tools don't cover (scrub/trim handles). ${act === "mouse_move" ? "Requires `coords`." : "`coords` optional — moves there first when given, else acts at the current pointer position."}`,
27
+ inputSchema: {
28
+ coords: z
29
+ .object({ x: z.number(), y: z.number() })
30
+ .optional()
31
+ .describe("Viewport CSS px."),
32
+ ...SESSION_ARG,
33
+ },
34
+ }, async ({ coords, session }) => {
35
+ const g = gateCheck(act);
36
+ if (g)
37
+ return g;
38
+ const e = await entryFor(session);
39
+ try {
40
+ const r = await withDeadline(mouseAction(e.session.page(), act.slice(6), coords), cfgActionTimeout(), act);
41
+ return { content: [{ type: "text", text: JSON.stringify(r, null, 2) }] };
42
+ }
43
+ catch (err) {
44
+ return {
45
+ content: [
46
+ {
47
+ type: "text",
48
+ text: JSON.stringify({ ok: false, error: err instanceof Error ? err.message : String(err) }, null, 2),
49
+ },
50
+ ],
51
+ };
52
+ }
53
+ });
54
+ }
55
+ // ---------- Touch + multi-touch gestures ----------
56
+ //
57
+ // A separate dispatch pipeline from the `mouse_*` family. CDP
58
+ // `Input.dispatchTouchEvent` is the touch sibling of `dispatchMouseEvent`;
59
+ // mobile-default apps and canvas apps wire touch handlers that the mouse
60
+ // pipeline does NOT reach. Touch events do not auto-fire mouse events
61
+ // (browsers MAY synthesize mouse events from touchend, but it's app-policy
62
+ // via `touch-action` / `preventDefault`); an agent that needs both must
63
+ // dispatch both. The `identifier` field is the DOM-side
64
+ // TouchEvent.changedTouches[].identifier — distinct ids for distinct
65
+ // fingers across a multi-touch sequence (default 1).
66
+ for (const act of ["touch_start", "touch_move", "touch_end"]) {
67
+ const requiresCoords = act !== "touch_end";
68
+ register(act, {
69
+ // touch_start / touch_move / touch_end — CDP touch pipeline; deep (no
70
+ // off-Chromium Playwright equivalent).
71
+ capability: "action",
72
+ deep: true,
73
+ description: `Dispatch ${act.replace("_", " ")} via CDP Input.dispatchTouchEvent — a separate pipeline from \`mouse_*\` for mobile-default apps and canvas / map / drawing widgets that listen for \`touchstart\` / \`touchmove\` / \`touchend\`. ${requiresCoords ? "`coords` required (viewport CSS px)." : "`coords` optional — when omitted, dispatches an empty touchPoints[] (the 'all fingers up' form)."} ` +
74
+ "`identifier` (default 1) maps to DOM `TouchEvent.changedTouches[].identifier` — use distinct ids per finger to fan out multi-touch. Touch does NOT synthesise mouse events — dispatch mouse_* explicitly if both pipelines are needed.",
75
+ inputSchema: {
76
+ coords: requiresCoords
77
+ ? z.object({ x: z.number(), y: z.number() }).describe("Viewport CSS px.")
78
+ : z
79
+ .object({ x: z.number(), y: z.number() })
80
+ .optional()
81
+ .describe("Viewport CSS px. Omit to dispatch empty touchPoints[] (all fingers up)."),
82
+ identifier: z
83
+ .number()
84
+ .int()
85
+ .nonnegative()
86
+ .optional()
87
+ .describe("Touch identifier (default 1) — distinct values per finger for multi-touch fan-out."),
88
+ ...SESSION_ARG,
89
+ },
90
+ }, async ({ coords, identifier, session }) => {
91
+ const g = gateCheck(act);
92
+ if (g)
93
+ return g;
94
+ const e = await entryFor(session);
95
+ const eg = engineGate(act, e);
96
+ if (eg)
97
+ return eg;
98
+ try {
99
+ const r = await withDeadline(touchAction(requireCdp(e.session), act.slice(6), {
100
+ coords,
101
+ identifier,
102
+ }), cfgActionTimeout(), act);
103
+ const json = JSON.stringify(r);
104
+ return {
105
+ content: [
106
+ {
107
+ type: "text",
108
+ text: JSON.stringify({ ...r, tokensEstimate: estimateTokens(json) }, null, 2),
109
+ },
110
+ ],
111
+ };
112
+ }
113
+ catch (err) {
114
+ const body = { ok: false, error: err instanceof Error ? err.message : String(err) };
115
+ return {
116
+ content: [
117
+ {
118
+ type: "text",
119
+ text: JSON.stringify({ ...body, tokensEstimate: estimateTokens(JSON.stringify(body)) }, null, 2),
120
+ },
121
+ ],
122
+ };
123
+ }
124
+ });
125
+ }
126
+ for (const action of ["profile_snapshot", "profile_restore"]) {
127
+ register(action, {
128
+ // profile_snapshot / profile_restore — human coordination primitives.
129
+ capability: "human",
130
+ description: action === "profile_snapshot"
131
+ ? 'Copy a persistent session\'s profile directory into a named snapshot under `<workspace>/profile-snapshots/` — checkpoint a clean authenticated state before a destructive media-editor test. `profile` defaults to "default". ALL sessions must be closed first (copying a live profile dir corrupts it).'
132
+ : "Restore a named profile snapshot back over a session's profile directory — reset to a clean checkpoint between destructive test runs. ALL sessions must be closed first.",
133
+ inputSchema: {
134
+ snapshot: z.string().describe("Snapshot name (letters/digits/._- only)."),
135
+ profile: z
136
+ .string()
137
+ .optional()
138
+ .describe('Profile to snapshot/restore. Default "default" (the legacy single-profile dir); else a named profile under <workspace>/profiles/.'),
139
+ },
140
+ }, async ({ snapshot, profile }) => {
141
+ const g = gateCheck(action);
142
+ if (g)
143
+ return g;
144
+ if (registry.list().length > 0) {
145
+ return {
146
+ content: [
147
+ {
148
+ type: "text",
149
+ text: JSON.stringify({
150
+ ok: false,
151
+ error: `${action}: close all sessions first (close_sessions({all:true})) — copying a profile directory while Chromium has it open corrupts it`,
152
+ openSessions: registry.list().map((s) => s.id),
153
+ }, null, 2),
154
+ },
155
+ ],
156
+ };
157
+ }
158
+ try {
159
+ const r = action === "profile_snapshot"
160
+ ? snapshotProfile(workspace.root, profile, snapshot)
161
+ : restoreProfile(workspace.root, profile, snapshot);
162
+ return { content: [{ type: "text", text: JSON.stringify(r, null, 2) }] };
163
+ }
164
+ catch (err) {
165
+ return {
166
+ content: [
167
+ {
168
+ type: "text",
169
+ text: JSON.stringify({ ok: false, error: err instanceof Error ? err.message : String(err) }, null, 2),
170
+ },
171
+ ],
172
+ };
173
+ }
174
+ });
175
+ }
176
+ }
@@ -0,0 +1,9 @@
1
+ import type { ToolHost } from "./host.js";
2
+ /**
3
+ * Per-primitive live emulation — the seven sibling mutators that each set ONE
4
+ * live knob on the session (`set_locale` / `set_timezone` / `set_geolocation` /
5
+ * `set_color_scheme` / `set_reduced_motion` / `set_user_agent` /
6
+ * `grant_permissions`) plus `tab_visibility`. State persists on the SessionEntry.
7
+ * Registered through the shared `ToolHost` seam.
8
+ */
9
+ export declare function registerLiveEmulationTools(host: ToolHost): void;