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.
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/THIRD_PARTY_NOTICES.md +45 -0
- package/dist/cli/chrome.d.ts +1 -0
- package/dist/cli/chrome.js +130 -0
- package/dist/cli/command-registry.d.ts +15 -0
- package/dist/cli/command-registry.js +35 -0
- package/dist/cli/doctor-plugins.d.ts +18 -0
- package/dist/cli/doctor-plugins.js +338 -0
- package/dist/cli/doctor.d.ts +9 -0
- package/dist/cli/doctor.js +407 -0
- package/dist/cli/init.d.ts +1 -0
- package/dist/cli/init.js +200 -0
- package/dist/cli/register-commands.d.ts +1 -0
- package/dist/cli/register-commands.js +22 -0
- package/dist/cli/serve.d.ts +14 -0
- package/dist/cli/serve.js +151 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +129 -0
- package/dist/engine/adapters/adb.d.ts +72 -0
- package/dist/engine/adapters/adb.js +200 -0
- package/dist/engine/adapters/android-cdp.d.ts +54 -0
- package/dist/engine/adapters/android-cdp.js +110 -0
- package/dist/engine/adapters/android.engine.d.ts +1 -0
- package/dist/engine/adapters/android.engine.js +31 -0
- package/dist/engine/adapters/chromium.engine.d.ts +1 -0
- package/dist/engine/adapters/chromium.engine.js +44 -0
- package/dist/engine/adapters/firefox.engine.d.ts +1 -0
- package/dist/engine/adapters/firefox.engine.js +43 -0
- package/dist/engine/adapters/playwright-chromium.d.ts +43 -0
- package/dist/engine/adapters/playwright-chromium.js +56 -0
- package/dist/engine/adapters/playwright-firefox.d.ts +52 -0
- package/dist/engine/adapters/playwright-firefox.js +97 -0
- package/dist/engine/adapters/playwright-webkit.d.ts +40 -0
- package/dist/engine/adapters/playwright-webkit.js +79 -0
- package/dist/engine/adapters/safari/bidi-client.d.ts +46 -0
- package/dist/engine/adapters/safari/bidi-client.js +130 -0
- package/dist/engine/adapters/safari/launch.d.ts +56 -0
- package/dist/engine/adapters/safari/launch.js +104 -0
- package/dist/engine/adapters/safari/webdriver-client.d.ts +102 -0
- package/dist/engine/adapters/safari/webdriver-client.js +175 -0
- package/dist/engine/adapters/safari.engine.d.ts +1 -0
- package/dist/engine/adapters/safari.engine.js +52 -0
- package/dist/engine/adapters/safaridriver-hybrid.d.ts +56 -0
- package/dist/engine/adapters/safaridriver-hybrid.js +127 -0
- package/dist/engine/adapters/webkit.engine.d.ts +1 -0
- package/dist/engine/adapters/webkit.engine.js +47 -0
- package/dist/engine/capabilities.d.ts +53 -0
- package/dist/engine/capabilities.js +122 -0
- package/dist/engine/capability-registry.d.ts +9 -0
- package/dist/engine/capability-registry.js +20 -0
- package/dist/engine/index.d.ts +18 -0
- package/dist/engine/index.js +14 -0
- package/dist/engine/register-engines.d.ts +5 -0
- package/dist/engine/register-engines.js +16 -0
- package/dist/engine/registry.d.ts +145 -0
- package/dist/engine/registry.js +67 -0
- package/dist/engine/select.d.ts +48 -0
- package/dist/engine/select.js +128 -0
- package/dist/engine/session-cdp.d.ts +13 -0
- package/dist/engine/session-cdp.js +22 -0
- package/dist/engine/tool-gate.d.ts +19 -0
- package/dist/engine/tool-gate.js +226 -0
- package/dist/engine/types.d.ts +71 -0
- package/dist/engine/types.js +16 -0
- package/dist/helper/bridge.d.ts +48 -0
- package/dist/helper/bridge.js +200 -0
- package/dist/helper/browx-page.d.ts +1 -0
- package/dist/helper/browx-page.js +47 -0
- package/dist/helper/overlay-hide.d.ts +9 -0
- package/dist/helper/overlay-hide.js +49 -0
- package/dist/helper/stealth.d.ts +10 -0
- package/dist/helper/stealth.js +88 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +15 -0
- package/dist/page/a11y.d.ts +81 -0
- package/dist/page/a11y.js +219 -0
- package/dist/page/action-substrate.d.ts +64 -0
- package/dist/page/action-substrate.js +118 -0
- package/dist/page/actionresult-blocks.d.ts +99 -0
- package/dist/page/actionresult-blocks.js +144 -0
- package/dist/page/actionresult-shape.d.ts +48 -0
- package/dist/page/actionresult-shape.js +155 -0
- package/dist/page/actionresult-types.d.ts +368 -0
- package/dist/page/actionresult-types.js +4 -0
- package/dist/page/actionresult.d.ts +4 -0
- package/dist/page/actionresult.js +299 -0
- package/dist/page/actions-probe.d.ts +32 -0
- package/dist/page/actions-probe.js +294 -0
- package/dist/page/actions-scroll.d.ts +40 -0
- package/dist/page/actions-scroll.js +53 -0
- package/dist/page/actions.d.ts +132 -0
- package/dist/page/actions.js +453 -0
- package/dist/page/archive-assets.d.ts +39 -0
- package/dist/page/archive-assets.js +187 -0
- package/dist/page/archive.d.ts +47 -0
- package/dist/page/archive.js +349 -0
- package/dist/page/asset-export.d.ts +122 -0
- package/dist/page/asset-export.js +376 -0
- package/dist/page/await_network.d.ts +16 -0
- package/dist/page/await_network.js +23 -0
- package/dist/page/bbox.d.ts +37 -0
- package/dist/page/bbox.js +115 -0
- package/dist/page/canvas-capture.d.ts +82 -0
- package/dist/page/canvas-capture.js +257 -0
- package/dist/page/canvas-diff.d.ts +51 -0
- package/dist/page/canvas-diff.js +131 -0
- package/dist/page/canvas-gesture.d.ts +53 -0
- package/dist/page/canvas-gesture.js +167 -0
- package/dist/page/canvas-transform.d.ts +96 -0
- package/dist/page/canvas-transform.js +150 -0
- package/dist/page/canvas.d.ts +8 -0
- package/dist/page/canvas.js +50 -0
- package/dist/page/capture-substrate.d.ts +111 -0
- package/dist/page/capture-substrate.js +139 -0
- package/dist/page/clipboard.d.ts +25 -0
- package/dist/page/clipboard.js +50 -0
- package/dist/page/clock.d.ts +36 -0
- package/dist/page/clock.js +167 -0
- package/dist/page/compose.d.ts +55 -0
- package/dist/page/compose.js +169 -0
- package/dist/page/console.d.ts +39 -0
- package/dist/page/console.js +73 -0
- package/dist/page/coverage.d.ts +97 -0
- package/dist/page/coverage.js +280 -0
- package/dist/page/dom-export.d.ts +41 -0
- package/dist/page/dom-export.js +193 -0
- package/dist/page/dom-walk.d.ts +91 -0
- package/dist/page/dom-walk.js +267 -0
- package/dist/page/dom_diff.d.ts +48 -0
- package/dist/page/dom_diff.js +121 -0
- package/dist/page/downloads.d.ts +80 -0
- package/dist/page/downloads.js +244 -0
- package/dist/page/drop-files.d.ts +78 -0
- package/dist/page/drop-files.js +310 -0
- package/dist/page/element-export-discovery.d.ts +64 -0
- package/dist/page/element-export-discovery.js +346 -0
- package/dist/page/element-export.d.ts +46 -0
- package/dist/page/element-export.js +251 -0
- package/dist/page/emulation-substrate.d.ts +53 -0
- package/dist/page/emulation-substrate.js +87 -0
- package/dist/page/emulation.d.ts +60 -0
- package/dist/page/emulation.js +162 -0
- package/dist/page/export-playwright-script.d.ts +47 -0
- package/dist/page/export-playwright-script.js +304 -0
- package/dist/page/extract-resolve.d.ts +22 -0
- package/dist/page/extract-resolve.js +341 -0
- package/dist/page/extract-schema.d.ts +20 -0
- package/dist/page/extract-schema.js +200 -0
- package/dist/page/extract-types.d.ts +127 -0
- package/dist/page/extract-types.js +8 -0
- package/dist/page/extract-warnings.d.ts +8 -0
- package/dist/page/extract-warnings.js +56 -0
- package/dist/page/extract.d.ts +9 -0
- package/dist/page/extract.js +174 -0
- package/dist/page/fill-form.d.ts +58 -0
- package/dist/page/fill-form.js +261 -0
- package/dist/page/find.d.ts +158 -0
- package/dist/page/find.js +470 -0
- package/dist/page/frames.d.ts +45 -0
- package/dist/page/frames.js +133 -0
- package/dist/page/generate-locator.d.ts +57 -0
- package/dist/page/generate-locator.js +136 -0
- package/dist/page/gestures.d.ts +128 -0
- package/dist/page/gestures.js +198 -0
- package/dist/page/har.d.ts +91 -0
- package/dist/page/har.js +174 -0
- package/dist/page/heap.d.ts +97 -0
- package/dist/page/heap.js +285 -0
- package/dist/page/inspect.d.ts +34 -0
- package/dist/page/inspect.js +75 -0
- package/dist/page/layout-thrash.d.ts +34 -0
- package/dist/page/layout-thrash.js +232 -0
- package/dist/page/learning.d.ts +21 -0
- package/dist/page/learning.js +84 -0
- package/dist/page/locator.d.ts +54 -0
- package/dist/page/locator.js +142 -0
- package/dist/page/memory-diff.d.ts +48 -0
- package/dist/page/memory-diff.js +105 -0
- package/dist/page/network-mask.d.ts +8 -0
- package/dist/page/network-mask.js +18 -0
- package/dist/page/network-playwright.d.ts +96 -0
- package/dist/page/network-playwright.js +353 -0
- package/dist/page/network-substrate-select.d.ts +18 -0
- package/dist/page/network-substrate-select.js +32 -0
- package/dist/page/network-substrate.d.ts +109 -0
- package/dist/page/network-substrate.js +161 -0
- package/dist/page/network-ws.d.ts +46 -0
- package/dist/page/network-ws.js +113 -0
- package/dist/page/network.d.ts +194 -0
- package/dist/page/network.js +415 -0
- package/dist/page/overflow-detect.d.ts +102 -0
- package/dist/page/overflow-detect.js +449 -0
- package/dist/page/pdf.d.ts +69 -0
- package/dist/page/pdf.js +109 -0
- package/dist/page/perf-audit-analysers.d.ts +40 -0
- package/dist/page/perf-audit-analysers.js +369 -0
- package/dist/page/perf-audit-runner.d.ts +20 -0
- package/dist/page/perf-audit-runner.js +195 -0
- package/dist/page/perf-audit-types.d.ts +41 -0
- package/dist/page/perf-audit-types.js +5 -0
- package/dist/page/perf-audit.d.ts +37 -0
- package/dist/page/perf-audit.js +377 -0
- package/dist/page/perf.d.ts +127 -0
- package/dist/page/perf.js +373 -0
- package/dist/page/plan.d.ts +192 -0
- package/dist/page/plan.js +308 -0
- package/dist/page/point_probe.d.ts +46 -0
- package/dist/page/point_probe.js +99 -0
- package/dist/page/recording.d.ts +67 -0
- package/dist/page/recording.js +172 -0
- package/dist/page/refs.d.ts +92 -0
- package/dist/page/refs.js +134 -0
- package/dist/page/regions.d.ts +23 -0
- package/dist/page/regions.js +32 -0
- package/dist/page/routes.d.ts +40 -0
- package/dist/page/routes.js +87 -0
- package/dist/page/safari-actions.d.ts +12 -0
- package/dist/page/safari-actions.js +144 -0
- package/dist/page/sample.d.ts +64 -0
- package/dist/page/sample.js +216 -0
- package/dist/page/screenshot-on.d.ts +51 -0
- package/dist/page/screenshot-on.js +150 -0
- package/dist/page/screenshot-save.d.ts +36 -0
- package/dist/page/screenshot-save.js +53 -0
- package/dist/page/screenshot-schedule.d.ts +50 -0
- package/dist/page/screenshot-schedule.js +155 -0
- package/dist/page/script-substrate.d.ts +32 -0
- package/dist/page/script-substrate.js +47 -0
- package/dist/page/seed-random.d.ts +45 -0
- package/dist/page/seed-random.js +144 -0
- package/dist/page/set-of-marks.d.ts +96 -0
- package/dist/page/set-of-marks.js +245 -0
- package/dist/page/shadow.d.ts +136 -0
- package/dist/page/shadow.js +400 -0
- package/dist/page/shortcut.d.ts +50 -0
- package/dist/page/shortcut.js +147 -0
- package/dist/page/snapshot-substrate-safari.d.ts +30 -0
- package/dist/page/snapshot-substrate-safari.js +84 -0
- package/dist/page/snapshot-substrate-select.d.ts +24 -0
- package/dist/page/snapshot-substrate-select.js +34 -0
- package/dist/page/snapshot-substrate.d.ts +58 -0
- package/dist/page/snapshot-substrate.js +135 -0
- package/dist/page/snapshot.d.ts +24 -0
- package/dist/page/snapshot.js +162 -0
- package/dist/page/solve-captcha.d.ts +76 -0
- package/dist/page/solve-captcha.js +286 -0
- package/dist/page/storage-substrate-types.d.ts +221 -0
- package/dist/page/storage-substrate-types.js +6 -0
- package/dist/page/storage-substrate.d.ts +215 -0
- package/dist/page/storage-substrate.js +280 -0
- package/dist/page/structural.d.ts +9 -0
- package/dist/page/structural.js +152 -0
- package/dist/page/substrate-bundle-safari.d.ts +8 -0
- package/dist/page/substrate-bundle-safari.js +42 -0
- package/dist/page/substrate-bundle.d.ts +6 -0
- package/dist/page/substrate-bundle.js +53 -0
- package/dist/page/text_search.d.ts +44 -0
- package/dist/page/text_search.js +90 -0
- package/dist/page/upload.d.ts +28 -0
- package/dist/page/upload.js +62 -0
- package/dist/page/verify.d.ts +63 -0
- package/dist/page/verify.js +451 -0
- package/dist/page/video.d.ts +115 -0
- package/dist/page/video.js +169 -0
- package/dist/page/visibility.d.ts +22 -0
- package/dist/page/visibility.js +94 -0
- package/dist/page/watch.d.ts +29 -0
- package/dist/page/watch.js +99 -0
- package/dist/page/workers.d.ts +126 -0
- package/dist/page/workers.js +490 -0
- package/dist/page/ws-interactive.d.ts +82 -0
- package/dist/page/ws-interactive.js +318 -0
- package/dist/plugin/cli.d.ts +45 -0
- package/dist/plugin/cli.js +496 -0
- package/dist/plugin/command-registry.d.ts +9 -0
- package/dist/plugin/command-registry.js +23 -0
- package/dist/plugin/depgraph.d.ts +37 -0
- package/dist/plugin/depgraph.js +186 -0
- package/dist/plugin/manifest.d.ts +182 -0
- package/dist/plugin/manifest.js +219 -0
- package/dist/plugin/package-manager.d.ts +22 -0
- package/dist/plugin/package-manager.js +40 -0
- package/dist/plugin/resolver.d.ts +85 -0
- package/dist/plugin/resolver.js +166 -0
- package/dist/plugin/runtime.d.ts +77 -0
- package/dist/plugin/runtime.js +402 -0
- package/dist/plugin/types.d.ts +113 -0
- package/dist/plugin/types.js +4 -0
- package/dist/policy/confirm.d.ts +76 -0
- package/dist/policy/confirm.js +162 -0
- package/dist/policy/origin.d.ts +17 -0
- package/dist/policy/origin.js +79 -0
- package/dist/sdk/client.d.ts +21 -0
- package/dist/sdk/client.js +174 -0
- package/dist/sdk/index.d.ts +32 -0
- package/dist/sdk/index.js +61 -0
- package/dist/sdk/plugin-types.d.ts +33 -0
- package/dist/sdk/plugin-types.js +22 -0
- package/dist/sdk/registry.d.ts +17 -0
- package/dist/sdk/registry.js +94 -0
- package/dist/sdk/socket-transport.d.ts +20 -0
- package/dist/sdk/socket-transport.js +90 -0
- package/dist/sdk/tool-types.d.ts +634 -0
- package/dist/sdk/tool-types.js +28 -0
- package/dist/sdk/transport-in-process.d.ts +21 -0
- package/dist/sdk/transport-in-process.js +44 -0
- package/dist/sdk/transport-registry.d.ts +19 -0
- package/dist/sdk/transport-registry.js +31 -0
- package/dist/sdk/transport-socket.d.ts +12 -0
- package/dist/sdk/transport-socket.js +77 -0
- package/dist/sdk/transport-stdio-child.d.ts +10 -0
- package/dist/sdk/transport-stdio-child.js +47 -0
- package/dist/sdk/transport.d.ts +10 -0
- package/dist/sdk/transport.js +35 -0
- package/dist/sdk/types.d.ts +176 -0
- package/dist/sdk/types.js +10 -0
- package/dist/server.d.ts +33 -0
- package/dist/server.js +327 -0
- package/dist/session/artifacts.d.ts +52 -0
- package/dist/session/artifacts.js +177 -0
- package/dist/session/byob-attach.d.ts +26 -0
- package/dist/session/byob-attach.js +187 -0
- package/dist/session/byob.d.ts +8 -0
- package/dist/session/byob.js +20 -0
- package/dist/session/cache-storage.d.ts +100 -0
- package/dist/session/cache-storage.js +166 -0
- package/dist/session/device-emu.d.ts +149 -0
- package/dist/session/device-emu.js +545 -0
- package/dist/session/device.d.ts +14 -0
- package/dist/session/device.js +44 -0
- package/dist/session/dialog.d.ts +62 -0
- package/dist/session/dialog.js +164 -0
- package/dist/session/emulation.d.ts +69 -0
- package/dist/session/emulation.js +168 -0
- package/dist/session/extensions.d.ts +113 -0
- package/dist/session/extensions.js +237 -0
- package/dist/session/fs-picker.d.ts +144 -0
- package/dist/session/fs-picker.js +666 -0
- package/dist/session/idb-storage.d.ts +86 -0
- package/dist/session/idb-storage.js +229 -0
- package/dist/session/incognito.d.ts +3 -0
- package/dist/session/incognito.js +20 -0
- package/dist/session/launch-options.d.ts +41 -0
- package/dist/session/launch-options.js +200 -0
- package/dist/session/managed.d.ts +3 -0
- package/dist/session/managed.js +16 -0
- package/dist/session/metrics.d.ts +45 -0
- package/dist/session/metrics.js +75 -0
- package/dist/session/notification.d.ts +122 -0
- package/dist/session/notification.js +426 -0
- package/dist/session/permission.d.ts +144 -0
- package/dist/session/permission.js +600 -0
- package/dist/session/playwright-post-wire.d.ts +8 -0
- package/dist/session/playwright-post-wire.js +148 -0
- package/dist/session/policy-buffer.d.ts +21 -0
- package/dist/session/policy-buffer.js +47 -0
- package/dist/session/profile-snapshot.d.ts +11 -0
- package/dist/session/profile-snapshot.js +53 -0
- package/dist/session/registry.d.ts +365 -0
- package/dist/session/registry.js +98 -0
- package/dist/session/safari-post-wire.d.ts +8 -0
- package/dist/session/safari-post-wire.js +28 -0
- package/dist/session/safari-session.d.ts +10 -0
- package/dist/session/safari-session.js +39 -0
- package/dist/session/storage.d.ts +148 -0
- package/dist/session/storage.js +350 -0
- package/dist/session/types.d.ts +113 -0
- package/dist/session/types.js +5 -0
- package/dist/session/wedge.d.ts +15 -0
- package/dist/session/wedge.js +41 -0
- package/dist/tools/action-core-tools.d.ts +13 -0
- package/dist/tools/action-core-tools.js +156 -0
- package/dist/tools/action-form-tools.d.ts +12 -0
- package/dist/tools/action-form-tools.js +179 -0
- package/dist/tools/action-gesture-tools.d.ts +9 -0
- package/dist/tools/action-gesture-tools.js +115 -0
- package/dist/tools/action-history-tools.d.ts +8 -0
- package/dist/tools/action-history-tools.js +67 -0
- package/dist/tools/action-tool.d.ts +42 -0
- package/dist/tools/action-tool.js +58 -0
- package/dist/tools/action-tools.d.ts +20 -0
- package/dist/tools/action-tools.js +28 -0
- package/dist/tools/batch-act-tools.d.ts +10 -0
- package/dist/tools/batch-act-tools.js +276 -0
- package/dist/tools/batch-human-tools.d.ts +8 -0
- package/dist/tools/batch-human-tools.js +148 -0
- package/dist/tools/canvas-tools.d.ts +40 -0
- package/dist/tools/canvas-tools.js +368 -0
- package/dist/tools/capture-report-diagnostics-tools.d.ts +7 -0
- package/dist/tools/capture-report-diagnostics-tools.js +318 -0
- package/dist/tools/capture-report-element-export-tools.d.ts +8 -0
- package/dist/tools/capture-report-element-export-tools.js +197 -0
- package/dist/tools/capture-report-export-tools.d.ts +8 -0
- package/dist/tools/capture-report-export-tools.js +246 -0
- package/dist/tools/capture-report-marks-tools.d.ts +9 -0
- package/dist/tools/capture-report-marks-tools.js +221 -0
- package/dist/tools/capture-report-upload-tools.d.ts +8 -0
- package/dist/tools/capture-report-upload-tools.js +277 -0
- package/dist/tools/config-approval-tools.d.ts +8 -0
- package/dist/tools/config-approval-tools.js +166 -0
- package/dist/tools/deep-coverage-tools.d.ts +8 -0
- package/dist/tools/deep-coverage-tools.js +325 -0
- package/dist/tools/deep-determinism-tools.d.ts +8 -0
- package/dist/tools/deep-determinism-tools.js +276 -0
- package/dist/tools/deep-perf-tools.d.ts +19 -0
- package/dist/tools/deep-perf-tools.js +324 -0
- package/dist/tools/device-emulation-tools.d.ts +9 -0
- package/dist/tools/device-emulation-tools.js +137 -0
- package/dist/tools/extensions-batch-tools.d.ts +18 -0
- package/dist/tools/extensions-batch-tools.js +24 -0
- package/dist/tools/extensions-rebuild.d.ts +22 -0
- package/dist/tools/extensions-rebuild.js +208 -0
- package/dist/tools/extensions-tools.d.ts +2 -0
- package/dist/tools/extensions-tools.js +331 -0
- package/dist/tools/forms-fill-tools.d.ts +8 -0
- package/dist/tools/forms-fill-tools.js +109 -0
- package/dist/tools/forms-plan-tools.d.ts +7 -0
- package/dist/tools/forms-plan-tools.js +159 -0
- package/dist/tools/forms-recording-mode-tools.d.ts +8 -0
- package/dist/tools/forms-recording-mode-tools.js +71 -0
- package/dist/tools/forms-recording-tools.d.ts +14 -0
- package/dist/tools/forms-recording-tools.js +22 -0
- package/dist/tools/forms-refs-tools.d.ts +8 -0
- package/dist/tools/forms-refs-tools.js +90 -0
- package/dist/tools/gesture-coord-tools.d.ts +8 -0
- package/dist/tools/gesture-coord-tools.js +168 -0
- package/dist/tools/gesture-emulation-tools.d.ts +8 -0
- package/dist/tools/gesture-emulation-tools.js +135 -0
- package/dist/tools/gesture-network-tools.d.ts +17 -0
- package/dist/tools/gesture-network-tools.js +27 -0
- package/dist/tools/gesture-route-tools.d.ts +8 -0
- package/dist/tools/gesture-route-tools.js +142 -0
- package/dist/tools/gesture-websocket-tools.d.ts +8 -0
- package/dist/tools/gesture-websocket-tools.js +122 -0
- package/dist/tools/gesture-worker-tools.d.ts +9 -0
- package/dist/tools/gesture-worker-tools.js +200 -0
- package/dist/tools/host-build.d.ts +76 -0
- package/dist/tools/host-build.js +516 -0
- package/dist/tools/host.d.ts +287 -0
- package/dist/tools/host.js +1 -0
- package/dist/tools/input-tools.d.ts +10 -0
- package/dist/tools/input-tools.js +176 -0
- package/dist/tools/live-emulation-tools.d.ts +9 -0
- package/dist/tools/live-emulation-tools.js +353 -0
- package/dist/tools/plugin-runtime.d.ts +36 -0
- package/dist/tools/plugin-runtime.js +274 -0
- package/dist/tools/read-observe-buffer-tools.d.ts +9 -0
- package/dist/tools/read-observe-buffer-tools.js +385 -0
- package/dist/tools/read-observe-capture-tools.d.ts +12 -0
- package/dist/tools/read-observe-capture-tools.js +376 -0
- package/dist/tools/read-observe-dom-tools.d.ts +8 -0
- package/dist/tools/read-observe-dom-tools.js +308 -0
- package/dist/tools/read-observe-extract-tools.d.ts +8 -0
- package/dist/tools/read-observe-extract-tools.js +232 -0
- package/dist/tools/read-observe-verify-tools.d.ts +8 -0
- package/dist/tools/read-observe-verify-tools.js +316 -0
- package/dist/tools/schemas.d.ts +29 -0
- package/dist/tools/schemas.js +58 -0
- package/dist/tools/secrets-captcha-tools.d.ts +9 -0
- package/dist/tools/secrets-captcha-tools.js +231 -0
- package/dist/tools/session-dialog-permission-tools.d.ts +9 -0
- package/dist/tools/session-dialog-permission-tools.js +287 -0
- package/dist/tools/session-lifecycle-tools.d.ts +8 -0
- package/dist/tools/session-lifecycle-tools.js +314 -0
- package/dist/tools/session-notification-device-tools.d.ts +9 -0
- package/dist/tools/session-notification-device-tools.js +156 -0
- package/dist/tools/session-policy-tools.d.ts +16 -0
- package/dist/tools/session-policy-tools.js +22 -0
- package/dist/tools/session-registry.d.ts +28 -0
- package/dist/tools/session-registry.js +427 -0
- package/dist/tools/storage-artifact-har-video-tools.d.ts +8 -0
- package/dist/tools/storage-artifact-har-video-tools.js +311 -0
- package/dist/tools/storage-cache-idb-tools.d.ts +8 -0
- package/dist/tools/storage-cache-idb-tools.js +347 -0
- package/dist/tools/storage-state-cookies-tools.d.ts +8 -0
- package/dist/tools/storage-state-cookies-tools.js +223 -0
- package/dist/tools/storage-tools.d.ts +17 -0
- package/dist/tools/storage-tools.js +25 -0
- package/dist/tools/storage-web-auth-tools.d.ts +10 -0
- package/dist/tools/storage-web-auth-tools.js +230 -0
- package/dist/tools/tool-metadata.d.ts +8 -0
- package/dist/tools/tool-metadata.js +185 -0
- package/dist/util/batch.d.ts +83 -0
- package/dist/util/batch.js +191 -0
- package/dist/util/capabilities.d.ts +504 -0
- package/dist/util/capabilities.js +254 -0
- package/dist/util/config-store.d.ts +103 -0
- package/dist/util/config-store.js +206 -0
- package/dist/util/config.d.ts +11 -0
- package/dist/util/config.js +28 -0
- package/dist/util/credentials.d.ts +136 -0
- package/dist/util/credentials.js +622 -0
- package/dist/util/deadline.d.ts +22 -0
- package/dist/util/deadline.js +62 -0
- package/dist/util/diagnostics.d.ts +161 -0
- package/dist/util/diagnostics.js +579 -0
- package/dist/util/egress-sanitiser.d.ts +29 -0
- package/dist/util/egress-sanitiser.js +52 -0
- package/dist/util/failure.d.ts +8 -0
- package/dist/util/failure.js +50 -0
- package/dist/util/flake-check.d.ts +109 -0
- package/dist/util/flake-check.js +342 -0
- package/dist/util/invariant.d.ts +25 -0
- package/dist/util/invariant.js +66 -0
- package/dist/util/logging.d.ts +6 -0
- package/dist/util/logging.js +12 -0
- package/dist/util/predicates.d.ts +62 -0
- package/dist/util/predicates.js +340 -0
- package/dist/util/secrets.d.ts +104 -0
- package/dist/util/secrets.js +219 -0
- package/dist/util/tokens.d.ts +6 -0
- package/dist/util/tokens.js +24 -0
- package/dist/util/url-sanitizer.d.ts +19 -0
- package/dist/util/url-sanitizer.js +70 -0
- package/dist/util/version.d.ts +2 -0
- package/dist/util/version.js +21 -0
- package/dist/util/workspace.d.ts +7 -0
- package/dist/util/workspace.js +22 -0
- package/package.json +120 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface CanvasTransform {
|
|
2
|
+
scale: number;
|
|
3
|
+
panX: number;
|
|
4
|
+
panY: number;
|
|
5
|
+
/** Optional origin offsets — added after the scale/pan. Default 0. */
|
|
6
|
+
originX?: number;
|
|
7
|
+
originY?: number;
|
|
8
|
+
}
|
|
9
|
+
export type CanvasAdapterHint = "figma" | "tldraw" | "excalidraw" | "generic";
|
|
10
|
+
export interface CanvasWorldToScreenArgs {
|
|
11
|
+
worldX: number;
|
|
12
|
+
worldY: number;
|
|
13
|
+
ref?: string;
|
|
14
|
+
selector?: string;
|
|
15
|
+
transform?: CanvasTransform;
|
|
16
|
+
}
|
|
17
|
+
export interface CanvasScreenToWorldArgs {
|
|
18
|
+
screenX: number;
|
|
19
|
+
screenY: number;
|
|
20
|
+
ref?: string;
|
|
21
|
+
selector?: string;
|
|
22
|
+
transform?: CanvasTransform;
|
|
23
|
+
}
|
|
24
|
+
export interface CanvasWorldToScreenResult {
|
|
25
|
+
ok: boolean;
|
|
26
|
+
screenX?: number;
|
|
27
|
+
screenY?: number;
|
|
28
|
+
transformDiscovered?: CanvasTransform;
|
|
29
|
+
adapterHint?: CanvasAdapterHint;
|
|
30
|
+
warnings?: string[];
|
|
31
|
+
error?: string;
|
|
32
|
+
code?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CanvasScreenToWorldResult {
|
|
35
|
+
ok: boolean;
|
|
36
|
+
worldX?: number;
|
|
37
|
+
worldY?: number;
|
|
38
|
+
transformDiscovered?: CanvasTransform;
|
|
39
|
+
adapterHint?: CanvasAdapterHint;
|
|
40
|
+
warnings?: string[];
|
|
41
|
+
error?: string;
|
|
42
|
+
code?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Pure math — apply an affine transform to a world point.
|
|
45
|
+
* `screen = (world + pan) * scale + origin`. Documented this way (rather
|
|
46
|
+
* than the matrix form) because that's the shape the discovery probes
|
|
47
|
+
* return for the three named editors. */
|
|
48
|
+
export declare function applyWorldToScreen(world: {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
}, t: CanvasTransform): {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
};
|
|
55
|
+
/** Inverse: `world = (screen - origin) / scale - pan`. Round-trips with
|
|
56
|
+
* `applyWorldToScreen` to within fp precision. */
|
|
57
|
+
export declare function applyScreenToWorld(screen: {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
}, t: CanvasTransform): {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
};
|
|
64
|
+
/** Page-side discovery probe — REAL function literal. Returns the best
|
|
65
|
+
* candidate transform found by walking known app-side global shapes,
|
|
66
|
+
* plus an adapter hint naming which shape matched. Order matters:
|
|
67
|
+
* Figma/Excalidraw shape is the most common; Tldraw's distinct shape
|
|
68
|
+
* is tried next; finally the generic 3x3 matrix path. */
|
|
69
|
+
export declare const PAGE_DISCOVER_TRANSFORM_FN: () => {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
transform?: CanvasTransform;
|
|
72
|
+
adapterHint?: CanvasAdapterHint;
|
|
73
|
+
};
|
|
74
|
+
/** Thin adapter interface — server.ts owns the page-side evaluate call. */
|
|
75
|
+
export interface CanvasDiscoverPage {
|
|
76
|
+
evaluate<T, Arg>(fn: (arg: Arg) => T | Promise<T>, args?: Arg): Promise<T>;
|
|
77
|
+
evaluate<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
78
|
+
}
|
|
79
|
+
export declare function canvasWorldToScreen(page: CanvasDiscoverPage, args: CanvasWorldToScreenArgs): Promise<CanvasWorldToScreenResult>;
|
|
80
|
+
export declare function canvasScreenToWorld(page: CanvasDiscoverPage, args: CanvasScreenToWorldArgs): Promise<CanvasScreenToWorldResult>;
|
|
81
|
+
export interface CanvasQueryArgs {
|
|
82
|
+
adapter: string;
|
|
83
|
+
op: string;
|
|
84
|
+
args?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export interface CanvasQueryNoAdapterError {
|
|
87
|
+
ok: false;
|
|
88
|
+
error: string;
|
|
89
|
+
code: "no-adapter";
|
|
90
|
+
requestedAdapter: string;
|
|
91
|
+
requestedOp: string;
|
|
92
|
+
}
|
|
93
|
+
/** Build the structured `no-adapter` error returned when `canvas_query`
|
|
94
|
+
* cannot find a plugin registered under the requested namespace. The
|
|
95
|
+
* shape is kept stable so adopters can match on `code:"no-adapter"`. */
|
|
96
|
+
export declare function noAdapterError(adapter: string, op: string): CanvasQueryNoAdapterError;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// canvas_world_to_screen / canvas_screen_to_world — affine transform helpers
|
|
2
|
+
// (explicit transform OR heuristic discovery of common app-side globals), and
|
|
3
|
+
// canvas_query's structured no-adapter error. (See canvas.ts header.)
|
|
4
|
+
const DISCOVERY_HEURISTIC_WARNING = "discovery probes are HEURISTIC — they match common app-side global shapes (Figma/Excalidraw `app.viewport.{zoom,center}`, Tldraw `app.{scale,offset}`, generic `app.transform.matrix`). Confirm the transform on a known landmark before relying on the result; for production, pass `transform` explicitly or install a canvas-app adapter plugin.";
|
|
5
|
+
/** Pure math — apply an affine transform to a world point.
|
|
6
|
+
* `screen = (world + pan) * scale + origin`. Documented this way (rather
|
|
7
|
+
* than the matrix form) because that's the shape the discovery probes
|
|
8
|
+
* return for the three named editors. */
|
|
9
|
+
export function applyWorldToScreen(world, t) {
|
|
10
|
+
const ox = t.originX ?? 0;
|
|
11
|
+
const oy = t.originY ?? 0;
|
|
12
|
+
return {
|
|
13
|
+
x: (world.x + t.panX) * t.scale + ox,
|
|
14
|
+
y: (world.y + t.panY) * t.scale + oy,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Inverse: `world = (screen - origin) / scale - pan`. Round-trips with
|
|
18
|
+
* `applyWorldToScreen` to within fp precision. */
|
|
19
|
+
export function applyScreenToWorld(screen, t) {
|
|
20
|
+
if (t.scale === 0 || !Number.isFinite(t.scale)) {
|
|
21
|
+
return { x: NaN, y: NaN };
|
|
22
|
+
}
|
|
23
|
+
const ox = t.originX ?? 0;
|
|
24
|
+
const oy = t.originY ?? 0;
|
|
25
|
+
return {
|
|
26
|
+
x: (screen.x - ox) / t.scale - t.panX,
|
|
27
|
+
y: (screen.y - oy) / t.scale - t.panY,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Page-side discovery probe — REAL function literal. Returns the best
|
|
31
|
+
* candidate transform found by walking known app-side global shapes,
|
|
32
|
+
* plus an adapter hint naming which shape matched. Order matters:
|
|
33
|
+
* Figma/Excalidraw shape is the most common; Tldraw's distinct shape
|
|
34
|
+
* is tried next; finally the generic 3x3 matrix path. */
|
|
35
|
+
export const PAGE_DISCOVER_TRANSFORM_FN = () => {
|
|
36
|
+
// Helper — pull a finite number out of `obj[path]` (dot-path); returns
|
|
37
|
+
// undefined if any segment misses or the leaf is non-finite.
|
|
38
|
+
function get(obj, path) {
|
|
39
|
+
const parts = path.split(".");
|
|
40
|
+
let cur = obj;
|
|
41
|
+
for (const p of parts) {
|
|
42
|
+
if (cur && typeof cur === "object" && p in cur) {
|
|
43
|
+
cur = cur[p];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return typeof cur === "number" && Number.isFinite(cur) ? cur : undefined;
|
|
50
|
+
}
|
|
51
|
+
const w = window;
|
|
52
|
+
// 1) Figma / Excalidraw shape — `app.viewport.zoom` + `app.viewport.center.{x,y}`.
|
|
53
|
+
const zoom = get(w.app, "viewport.zoom");
|
|
54
|
+
const cx = get(w.app, "viewport.center.x");
|
|
55
|
+
const cy = get(w.app, "viewport.center.y");
|
|
56
|
+
if (zoom !== undefined && cx !== undefined && cy !== undefined) {
|
|
57
|
+
return {
|
|
58
|
+
ok: true,
|
|
59
|
+
transform: { scale: zoom, panX: -cx, panY: -cy, originX: 0, originY: 0 },
|
|
60
|
+
adapterHint: "figma",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// 2) Tldraw-like shape — `app.scale` + `app.offset.{x,y}`.
|
|
64
|
+
const tlScale = get(w.app, "scale");
|
|
65
|
+
const tlOffsetX = get(w.app, "offset.x");
|
|
66
|
+
const tlOffsetY = get(w.app, "offset.y");
|
|
67
|
+
if (tlScale !== undefined && tlOffsetX !== undefined && tlOffsetY !== undefined) {
|
|
68
|
+
return {
|
|
69
|
+
ok: true,
|
|
70
|
+
transform: { scale: tlScale, panX: tlOffsetX, panY: tlOffsetY, originX: 0, originY: 0 },
|
|
71
|
+
adapterHint: "tldraw",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// 3) Generic matrix shape — `app.transform.matrix` as a 6-element
|
|
75
|
+
// affine (a,b,c,d,e,f → [[a,c,e],[b,d,f],[0,0,1]]) or as a uniform
|
|
76
|
+
// scale matrix.
|
|
77
|
+
const m = w.app?.transform;
|
|
78
|
+
const mat = m?.matrix;
|
|
79
|
+
if (Array.isArray(mat) &&
|
|
80
|
+
mat.length >= 6 &&
|
|
81
|
+
mat.every((v) => typeof v === "number" && Number.isFinite(v))) {
|
|
82
|
+
const a = mat[0];
|
|
83
|
+
const e = mat[4];
|
|
84
|
+
const f = mat[5];
|
|
85
|
+
return {
|
|
86
|
+
ok: true,
|
|
87
|
+
transform: { scale: a, panX: 0, panY: 0, originX: e, originY: f },
|
|
88
|
+
adapterHint: "generic",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return { ok: false };
|
|
92
|
+
};
|
|
93
|
+
export async function canvasWorldToScreen(page, args) {
|
|
94
|
+
if (args.transform) {
|
|
95
|
+
const p = applyWorldToScreen({ x: args.worldX, y: args.worldY }, args.transform);
|
|
96
|
+
return { ok: true, screenX: p.x, screenY: p.y };
|
|
97
|
+
}
|
|
98
|
+
const discovered = await page.evaluate(PAGE_DISCOVER_TRANSFORM_FN);
|
|
99
|
+
if (!discovered.ok || !discovered.transform) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: "no transform discoverable — pass `transform` explicitly OR use a canvas-app adapter plugin",
|
|
103
|
+
code: "no-transform",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const p = applyWorldToScreen({ x: args.worldX, y: args.worldY }, discovered.transform);
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
screenX: p.x,
|
|
110
|
+
screenY: p.y,
|
|
111
|
+
transformDiscovered: discovered.transform,
|
|
112
|
+
...(discovered.adapterHint ? { adapterHint: discovered.adapterHint } : {}),
|
|
113
|
+
warnings: [DISCOVERY_HEURISTIC_WARNING],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export async function canvasScreenToWorld(page, args) {
|
|
117
|
+
if (args.transform) {
|
|
118
|
+
const p = applyScreenToWorld({ x: args.screenX, y: args.screenY }, args.transform);
|
|
119
|
+
return { ok: true, worldX: p.x, worldY: p.y };
|
|
120
|
+
}
|
|
121
|
+
const discovered = await page.evaluate(PAGE_DISCOVER_TRANSFORM_FN);
|
|
122
|
+
if (!discovered.ok || !discovered.transform) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
error: "no transform discoverable — pass `transform` explicitly OR use a canvas-app adapter plugin",
|
|
126
|
+
code: "no-transform",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const p = applyScreenToWorld({ x: args.screenX, y: args.screenY }, discovered.transform);
|
|
130
|
+
return {
|
|
131
|
+
ok: true,
|
|
132
|
+
worldX: p.x,
|
|
133
|
+
worldY: p.y,
|
|
134
|
+
transformDiscovered: discovered.transform,
|
|
135
|
+
...(discovered.adapterHint ? { adapterHint: discovered.adapterHint } : {}),
|
|
136
|
+
warnings: [DISCOVERY_HEURISTIC_WARNING],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** Build the structured `no-adapter` error returned when `canvas_query`
|
|
140
|
+
* cannot find a plugin registered under the requested namespace. The
|
|
141
|
+
* shape is kept stable so adopters can match on `code:"no-adapter"`. */
|
|
142
|
+
export function noAdapterError(adapter, op) {
|
|
143
|
+
return {
|
|
144
|
+
ok: false,
|
|
145
|
+
error: `no canvas adapter registered for ${adapter}; install @browxai/plugin-${adapter} or pass a registered adapter namespace`,
|
|
146
|
+
code: "no-adapter",
|
|
147
|
+
requestedAdapter: adapter,
|
|
148
|
+
requestedOp: op,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { CanvasFormat, CanvasCaptureArgs, CanvasCapturePngResult, CanvasCaptureRgbaResult, CanvasCaptureResult, PageCaptureRaw, CanvasCapturePage, } from "./canvas-capture.js";
|
|
2
|
+
export { CANVAS_MAX_DIMENSION, PAGE_CAPTURE_FN, canvasCapture } from "./canvas-capture.js";
|
|
3
|
+
export type { CanvasDiffRegion, CanvasDiffArgs, CanvasDiffResult } from "./canvas-diff.js";
|
|
4
|
+
export { diffRgba, canvasDiff } from "./canvas-diff.js";
|
|
5
|
+
export type { GestureChainStepKind, GestureChainStep, GestureChainArgs, GestureChainResult, ValidateGestureChainResult, GestureChainPage, } from "./canvas-gesture.js";
|
|
6
|
+
export { GESTURE_CHAIN_MAX_STEPS, GESTURE_CHAIN_MIN_MOVE_MS, GESTURE_CHAIN_MAX_WAIT_MS, validateGestureChain, runGestureChain, } from "./canvas-gesture.js";
|
|
7
|
+
export type { CanvasTransform, CanvasAdapterHint, CanvasWorldToScreenArgs, CanvasScreenToWorldArgs, CanvasWorldToScreenResult, CanvasScreenToWorldResult, CanvasDiscoverPage, CanvasQueryArgs, CanvasQueryNoAdapterError, } from "./canvas-transform.js";
|
|
8
|
+
export { applyWorldToScreen, applyScreenToWorld, PAGE_DISCOVER_TRANSFORM_FN, canvasWorldToScreen, canvasScreenToWorld, noAdapterError, } from "./canvas-transform.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference lib="dom" />
|
|
2
|
+
// Canvas-app automation primitives — capability `canvas`.
|
|
3
|
+
//
|
|
4
|
+
// The substrate. Five MCP tools + a pure-math diff, split across cohesive
|
|
5
|
+
// sibling modules and re-exported here so `../page/canvas.js` stays the single
|
|
6
|
+
// public barrel (callers and tests import unchanged):
|
|
7
|
+
//
|
|
8
|
+
// - `canvas_capture` — framebuffer / 2D ImageData / PNG bytes
|
|
9
|
+
// of a `<canvas>` element. App-agnostic.
|
|
10
|
+
// → ./canvas-capture.js
|
|
11
|
+
// - `canvas_diff` — pixel/region delta between two RGBA
|
|
12
|
+
// captures. Pure function over bytes;
|
|
13
|
+
// no page contact. → ./canvas-diff.js
|
|
14
|
+
// - `gesture_chain` — multi-step pointer program (down /
|
|
15
|
+
// move / wheel / wait / up). Custom
|
|
16
|
+
// paint strokes, lasso paths, gestures
|
|
17
|
+
// the canned `drag` / `gesture_swipe`
|
|
18
|
+
// family doesn't cover. → ./canvas-gesture.js
|
|
19
|
+
// - `canvas_world_to_screen` + `canvas_screen_to_world` —
|
|
20
|
+
// affine transform helpers, two modes:
|
|
21
|
+
// explicit (caller passes transform)
|
|
22
|
+
// or discovery (probe common app-side
|
|
23
|
+
// globals — Figma / Tldraw / Excalidraw
|
|
24
|
+
// shapes; documented as heuristic).
|
|
25
|
+
// → ./canvas-transform.js
|
|
26
|
+
// - `canvas_query` — dispatcher to a canvas-app adapter
|
|
27
|
+
// plugin. The router lives in
|
|
28
|
+
// server.ts (it has the plugin handler
|
|
29
|
+
// map); only the structured no-adapter
|
|
30
|
+
// error shape lives here. → ./canvas-transform.js
|
|
31
|
+
//
|
|
32
|
+
// Design principle (project-wide, see CLAUDE.md
|
|
33
|
+
// `feedback_design_for_problem_class`): the primitives are app-agnostic.
|
|
34
|
+
// Discovery probes common globals — those are HEURISTIC; the structured
|
|
35
|
+
// failure path tells the caller to pass `transform` explicitly OR install
|
|
36
|
+
// a canvas-app adapter plugin.
|
|
37
|
+
//
|
|
38
|
+
// BYO-vision pattern (docs only this cycle, see docs/tool-reference.md
|
|
39
|
+
// "Canvas-app automation — BYO vision pattern"): browxai does NOT bundle
|
|
40
|
+
// OCR or a hosted vision API. `canvas_capture` is the pixel source;
|
|
41
|
+
// composition with the host agent's own multimodal vision is the loop.
|
|
42
|
+
//
|
|
43
|
+
// Bounded:
|
|
44
|
+
// - canvas_capture refuses canvases larger than 16384×16384 pixels.
|
|
45
|
+
// - gesture_chain caps at 200 steps, floors `move` step delays at 5 ms,
|
|
46
|
+
// bounds `wait` steps at 5000 ms.
|
|
47
|
+
export { CANVAS_MAX_DIMENSION, PAGE_CAPTURE_FN, canvasCapture } from "./canvas-capture.js";
|
|
48
|
+
export { diffRgba, canvasDiff } from "./canvas-diff.js";
|
|
49
|
+
export { GESTURE_CHAIN_MAX_STEPS, GESTURE_CHAIN_MIN_MOVE_MS, GESTURE_CHAIN_MAX_WAIT_MS, validateGestureChain, runGestureChain, } from "./canvas-gesture.js";
|
|
50
|
+
export { applyWorldToScreen, applyScreenToWorld, PAGE_DISCOVER_TRANSFORM_FN, canvasWorldToScreen, canvasScreenToWorld, noAdapterError, } from "./canvas-transform.js";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Locator, Page } from "playwright-core";
|
|
2
|
+
import type { RefRegistry } from "./refs.js";
|
|
3
|
+
import type { SafariSessionHandle } from "../engine/index.js";
|
|
4
|
+
import type { ScreenshotSaveResult } from "./screenshot-save.js";
|
|
5
|
+
/** Normalised screenshot request — the handler's already-validated args, engine-
|
|
6
|
+
* blind. `resolveTarget`, when present, marks an element-scoped capture and is the
|
|
7
|
+
* DEFERRED `asTarget` resolution: an adapter calls it only after its own refusals
|
|
8
|
+
* pass, so a malformed target (multi-target / unbound `named`) surfaces as the
|
|
9
|
+
* engine/`fullPage` refusal it sat behind pre-seam, not as a preempting throw. Its
|
|
10
|
+
* absence means a viewport (or `fullPage`) capture. `path`, when set, swaps the
|
|
11
|
+
* inline image for a workspace-rooted disk write (the handler has already enforced
|
|
12
|
+
* the `file-io` capability). */
|
|
13
|
+
export interface ScreenshotRequest {
|
|
14
|
+
format: "png" | "jpeg";
|
|
15
|
+
quality?: number;
|
|
16
|
+
scale?: "css" | "device";
|
|
17
|
+
fullPage: boolean;
|
|
18
|
+
describe: boolean;
|
|
19
|
+
resolveTarget?: () => {
|
|
20
|
+
ref: string;
|
|
21
|
+
} | {
|
|
22
|
+
selector: string;
|
|
23
|
+
contextRef?: string;
|
|
24
|
+
};
|
|
25
|
+
path?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Inline-image outcome: the encoded bytes + mime, an optional `describe`
|
|
28
|
+
* caption, and an optional page-text source the handler's secrets sweep reads
|
|
29
|
+
* (only the Playwright path can offer it — Safari has no Page to evaluate, the
|
|
30
|
+
* same as before the seam, where the Safari branch returned before the sweep). */
|
|
31
|
+
export interface CaptureImage {
|
|
32
|
+
kind: "image";
|
|
33
|
+
data: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
caption?: string;
|
|
36
|
+
pageText?: () => Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
/** Disk-write outcome (`path` mode): the `screenshot-save` envelope plus the
|
|
39
|
+
* optional caption the handler folds into the JSON body. */
|
|
40
|
+
export interface CaptureSaved {
|
|
41
|
+
kind: "saved";
|
|
42
|
+
result: ScreenshotSaveResult;
|
|
43
|
+
caption?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Disk-write FAILURE (`path` mode): the workspace path escaped the root, or the
|
|
46
|
+
* write itself failed. Carries the bare message the handler renders as the same
|
|
47
|
+
* `{ ok:false, error, tokensEstimate }` envelope the deleted try/catch produced —
|
|
48
|
+
* a throw here was a returned JSON envelope, never a crashed handler. */
|
|
49
|
+
export interface CaptureSaveError {
|
|
50
|
+
kind: "save-error";
|
|
51
|
+
error: string;
|
|
52
|
+
}
|
|
53
|
+
/** Structured refusal — an engine that cannot honour the request (Safari for
|
|
54
|
+
* element-scoped / `path` / jpeg), or a request the capability itself rejects
|
|
55
|
+
* (`fullPage` + a target). The handler renders `error`/`hint` as the same JSON
|
|
56
|
+
* envelope the deleted branches produced. */
|
|
57
|
+
export interface CaptureRefusal {
|
|
58
|
+
kind: "refusal";
|
|
59
|
+
error: string;
|
|
60
|
+
hint?: string;
|
|
61
|
+
}
|
|
62
|
+
export type CaptureResult = CaptureImage | CaptureSaved | CaptureSaveError | CaptureRefusal;
|
|
63
|
+
/** The capture capability port. One instance wraps one session's engine handle;
|
|
64
|
+
* the methods carry no engine type, so the handler above this seam is
|
|
65
|
+
* engine-blind. Mirrors the ActionSubstrate / SnapshotSubstrate shape. */
|
|
66
|
+
export interface CaptureSubstrate {
|
|
67
|
+
readonly engine: string;
|
|
68
|
+
screenshot(req: ScreenshotRequest): Promise<CaptureResult>;
|
|
69
|
+
}
|
|
70
|
+
/** Playwright engines — the existing screenshot logic, verbatim. The `page` and
|
|
71
|
+
* `describe`/`save` collaborators are injected so this adapter stays free of the
|
|
72
|
+
* server's handler closures (the caption + disk-write helpers live in server.ts
|
|
73
|
+
* and are passed through unchanged). No behaviour change. */
|
|
74
|
+
export declare class PlaywrightCaptureSubstrate implements CaptureSubstrate {
|
|
75
|
+
private readonly page;
|
|
76
|
+
private readonly refs;
|
|
77
|
+
private readonly deps;
|
|
78
|
+
readonly engine: string;
|
|
79
|
+
constructor(page: () => Page, refs: RefRegistry, deps: {
|
|
80
|
+
describeTarget: (loc: Locator, refs: RefRegistry, target: {
|
|
81
|
+
ref: string;
|
|
82
|
+
} | {
|
|
83
|
+
selector: string;
|
|
84
|
+
} | {
|
|
85
|
+
coords: {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
};
|
|
89
|
+
}) => Promise<string>;
|
|
90
|
+
save: (buf: Buffer, args: {
|
|
91
|
+
path: string;
|
|
92
|
+
format: "png" | "jpeg";
|
|
93
|
+
fullPage: boolean;
|
|
94
|
+
}) => ScreenshotSaveResult;
|
|
95
|
+
}, engine?: string);
|
|
96
|
+
/** Capture the screenshot bytes + caption for either the element-scoped target
|
|
97
|
+
* (deferred `asTarget` resolution) or the whole page. */
|
|
98
|
+
private captureBytes;
|
|
99
|
+
screenshot(req: ScreenshotRequest): Promise<CaptureResult>;
|
|
100
|
+
}
|
|
101
|
+
/** Safari — the WebDriver-Classic capture path. safaridriver captures the whole
|
|
102
|
+
* document as PNG; the element-scoped / `path` variants need a Playwright Page
|
|
103
|
+
* Safari lacks, so they refuse cleanly here (the gating is in the adapter, not
|
|
104
|
+
* the handler). The `format`/`scale`/`fullPage`/`describe` args are inert as they
|
|
105
|
+
* were before the seam — the WebDriver client always returns a full-document PNG. */
|
|
106
|
+
export declare class SafariCaptureSubstrate implements CaptureSubstrate {
|
|
107
|
+
private readonly handle;
|
|
108
|
+
readonly engine = "safari";
|
|
109
|
+
constructor(handle: SafariSessionHandle);
|
|
110
|
+
screenshot(req: ScreenshotRequest): Promise<CaptureResult>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// The CaptureSubstrate interface — the engine-agnostic seam beneath the capture
|
|
2
|
+
// tools (screenshot today; pdf / video later). It is the capture side of the
|
|
3
|
+
// engine-decoupling seam: the `screenshot` handler asks a substrate to capture and gets back a
|
|
4
|
+
// universal `CaptureResult`; an engine-specific implementation does the work. The
|
|
5
|
+
// handler never names Playwright, safaridriver, or an engine — it calls
|
|
6
|
+
// `captureFor(e).screenshot(args)`, the same shape as `actionsFor(e).click(args)`
|
|
7
|
+
// / `snapshotSubstrateFor(e.session).compose(...)`.
|
|
8
|
+
//
|
|
9
|
+
// Dependency direction (architecture doctrine §1): tool handler → CaptureSubstrate
|
|
10
|
+
// (this interface) → implementation → Playwright | safaridriver. Two impls today:
|
|
11
|
+
// - PlaywrightCaptureSubstrate (chromium / firefox / webkit / android): wraps the
|
|
12
|
+
// existing screenshot logic verbatim (viewport / fullPage / element-scoped via
|
|
13
|
+
// locator, jpeg + quality + scale, the `path` disk-write envelope, the
|
|
14
|
+
// `describe` caption) — byte-identical to the pre-seam handler, so the four
|
|
15
|
+
// engines' keystones stay green unchanged.
|
|
16
|
+
// - SafariCaptureSubstrate (safari): wraps `webDriver.screenshot` (full-document
|
|
17
|
+
// PNG; safaridriver has no Playwright Page). The element-scoped / `path` / jpeg
|
|
18
|
+
// variants refuse cleanly IN THE ADAPTER as they did in the handler's deleted
|
|
19
|
+
// `if (safariShotHandle)` branch — so the gating lives here, not as an engine
|
|
20
|
+
// check in the handler.
|
|
21
|
+
/** Build the Locator for an element-scoped capture. Lazily imported so the
|
|
22
|
+
* page-layer locator core is pulled only when a target is actually present —
|
|
23
|
+
* the handler did the same `await import("./locator.js")` inline. */
|
|
24
|
+
async function locatorForTarget(page, refs, target) {
|
|
25
|
+
const { locatorFor } = await import("./locator.js");
|
|
26
|
+
return locatorFor(page, refs, target);
|
|
27
|
+
}
|
|
28
|
+
/** Playwright engines — the existing screenshot logic, verbatim. The `page` and
|
|
29
|
+
* `describe`/`save` collaborators are injected so this adapter stays free of the
|
|
30
|
+
* server's handler closures (the caption + disk-write helpers live in server.ts
|
|
31
|
+
* and are passed through unchanged). No behaviour change. */
|
|
32
|
+
export class PlaywrightCaptureSubstrate {
|
|
33
|
+
page;
|
|
34
|
+
refs;
|
|
35
|
+
deps;
|
|
36
|
+
engine;
|
|
37
|
+
constructor(page, refs, deps, engine = "chromium") {
|
|
38
|
+
this.page = page;
|
|
39
|
+
this.refs = refs;
|
|
40
|
+
this.deps = deps;
|
|
41
|
+
this.engine = engine;
|
|
42
|
+
}
|
|
43
|
+
/** Capture the screenshot bytes + caption for either the element-scoped target
|
|
44
|
+
* (deferred `asTarget` resolution) or the whole page. */
|
|
45
|
+
async captureBytes(page, req, fmt) {
|
|
46
|
+
if (req.resolveTarget) {
|
|
47
|
+
// Deferred: only now does the `asTarget` chokepoint run. A malformed target
|
|
48
|
+
// throws here — past the `fullPage` refusal, matching the pre-seam handler.
|
|
49
|
+
const target = req.resolveTarget();
|
|
50
|
+
const loc = await locatorForTarget(page, this.refs, target);
|
|
51
|
+
// Locator.screenshot doesn't accept `scale`; pass type/quality only there.
|
|
52
|
+
const locOpts = { type: fmt };
|
|
53
|
+
if (fmt === "jpeg")
|
|
54
|
+
locOpts.quality = req.quality ?? 80;
|
|
55
|
+
const buf = await loc.screenshot(locOpts);
|
|
56
|
+
const caption = req.describe ? await this.deps.describeTarget(loc, this.refs, target) : "";
|
|
57
|
+
return { buf, caption };
|
|
58
|
+
}
|
|
59
|
+
const opts = {
|
|
60
|
+
type: fmt,
|
|
61
|
+
};
|
|
62
|
+
if (fmt === "jpeg")
|
|
63
|
+
opts.quality = req.quality ?? 80;
|
|
64
|
+
if (req.scale)
|
|
65
|
+
opts.scale = req.scale;
|
|
66
|
+
const buf = await page.screenshot({ fullPage: req.fullPage, ...opts });
|
|
67
|
+
const caption = req.describe ? `${req.fullPage ? "fullPage" : "viewport"} (${page.url()})` : "";
|
|
68
|
+
return { buf, caption };
|
|
69
|
+
}
|
|
70
|
+
async screenshot(req) {
|
|
71
|
+
const page = this.page();
|
|
72
|
+
const fmt = req.format;
|
|
73
|
+
const mimeType = fmt === "jpeg" ? "image/jpeg" : "image/png";
|
|
74
|
+
const fullPage = req.fullPage;
|
|
75
|
+
if (fullPage && req.resolveTarget) {
|
|
76
|
+
return {
|
|
77
|
+
kind: "refusal",
|
|
78
|
+
error: "screenshot: `fullPage:true` is mutually exclusive with `ref`/`selector`/`named` — element-scoped captures are already bounded by the element's box",
|
|
79
|
+
hint: "Drop `fullPage` for an element capture, or drop the target for a whole-document capture.",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const { buf, caption } = await this.captureBytes(page, req, fmt);
|
|
83
|
+
// `path` mode: write bytes to a workspace-rooted file and return the save
|
|
84
|
+
// envelope instead of inline base64. The `file-io` capability check already
|
|
85
|
+
// ran (handler gate); a path escaping the workspace or a failed write throws
|
|
86
|
+
// out of `screenshotSave` and becomes a structured `save-error` here — never
|
|
87
|
+
// a crashed handler, matching the deleted try/catch.
|
|
88
|
+
if (req.path !== undefined) {
|
|
89
|
+
try {
|
|
90
|
+
const result = this.deps.save(buf, { path: req.path, format: fmt, fullPage });
|
|
91
|
+
return { kind: "saved", result, caption: caption || undefined };
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
return { kind: "save-error", error: err instanceof Error ? err.message : String(err) };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: "image",
|
|
99
|
+
data: buf.toString("base64"),
|
|
100
|
+
mimeType,
|
|
101
|
+
caption: caption || undefined,
|
|
102
|
+
// The secrets sweep reads the document's visible text (innerText falls
|
|
103
|
+
// back to "" on failure — the page may be navigating). Bounded so a giant
|
|
104
|
+
// page doesn't make the scan O(n^2-pathological).
|
|
105
|
+
pageText: () => page
|
|
106
|
+
.evaluate(() => {
|
|
107
|
+
const w = globalThis;
|
|
108
|
+
return (w.document?.body?.innerText ?? "").slice(0, 200_000);
|
|
109
|
+
})
|
|
110
|
+
.catch(() => ""),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Safari — the WebDriver-Classic capture path. safaridriver captures the whole
|
|
115
|
+
* document as PNG; the element-scoped / `path` variants need a Playwright Page
|
|
116
|
+
* Safari lacks, so they refuse cleanly here (the gating is in the adapter, not
|
|
117
|
+
* the handler). The `format`/`scale`/`fullPage`/`describe` args are inert as they
|
|
118
|
+
* were before the seam — the WebDriver client always returns a full-document PNG. */
|
|
119
|
+
export class SafariCaptureSubstrate {
|
|
120
|
+
handle;
|
|
121
|
+
engine = "safari";
|
|
122
|
+
constructor(handle) {
|
|
123
|
+
this.handle = handle;
|
|
124
|
+
}
|
|
125
|
+
async screenshot(req) {
|
|
126
|
+
// Refuse on the raw element-scoped / `path` signals WITHOUT invoking the
|
|
127
|
+
// deferred `asTarget` resolver — a malformed target must surface as this
|
|
128
|
+
// engine refusal, exactly as the pre-seam Safari branch (which never reached
|
|
129
|
+
// `asTarget`) returned it.
|
|
130
|
+
if (req.resolveTarget || req.path !== undefined) {
|
|
131
|
+
return {
|
|
132
|
+
kind: "refusal",
|
|
133
|
+
error: "the Safari engine supports only the default inline PNG screenshot — element-scoped (`ref`/`selector`/`named`) and `path` captures need a chromium/firefox/webkit session.",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const data = await this.handle.webDriver.screenshot(this.handle.sessionId);
|
|
137
|
+
return { kind: "image", data, mimeType: "image/png" };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ClipOp = "copy" | "cut";
|
|
2
|
+
export interface ClipEntry {
|
|
3
|
+
text: string;
|
|
4
|
+
op: ClipOp;
|
|
5
|
+
ts: number;
|
|
6
|
+
}
|
|
7
|
+
/** One per SessionEntry. In-memory; nothing persisted. */
|
|
8
|
+
export declare class ClipboardBuffer {
|
|
9
|
+
private entry;
|
|
10
|
+
set(text: string, op: ClipOp): void;
|
|
11
|
+
get(): ClipEntry | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Best-effort, zero-dependency, **write-only** OS clipboard set. Fixed argv
|
|
15
|
+
* (no shell, content via stdin — no injection surface). Called ONLY as part
|
|
16
|
+
* of an explicit copy/cut/paste command. Degrades gracefully when the
|
|
17
|
+
* platform tool is absent (e.g. CI without `xclip`): the per-session buffer
|
|
18
|
+
* still works for same-session paste reasoning; the result just notes
|
|
19
|
+
* `osSync:false`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function osClipboardWrite(text: string): Promise<{
|
|
22
|
+
ok: boolean;
|
|
23
|
+
tool: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Per-session clipboard model (capability `clipboard`, off by default).
|
|
2
|
+
//
|
|
3
|
+
// The OS clipboard is a single shared resource; concurrent browxai sessions
|
|
4
|
+
// must not clobber each other through it. So each session owns its OWN
|
|
5
|
+
// clipboard buffer (the source of truth for what *this* session copied/cut),
|
|
6
|
+
// and the real OS clipboard is touched **only transactionally, at the exact
|
|
7
|
+
// moment of an explicit copy / cut / paste shortcut command** — never polled,
|
|
8
|
+
// never synced in the background, and left exactly as the user left it
|
|
9
|
+
// between commands. We never *read* the OS clipboard into a session (that
|
|
10
|
+
// would import another session's or the human's content — clipboard bleed).
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
/** One per SessionEntry. In-memory; nothing persisted. */
|
|
13
|
+
export class ClipboardBuffer {
|
|
14
|
+
entry = null;
|
|
15
|
+
set(text, op) {
|
|
16
|
+
this.entry = { text, op, ts: Date.now() };
|
|
17
|
+
}
|
|
18
|
+
get() {
|
|
19
|
+
return this.entry;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Best-effort, zero-dependency, **write-only** OS clipboard set. Fixed argv
|
|
24
|
+
* (no shell, content via stdin — no injection surface). Called ONLY as part
|
|
25
|
+
* of an explicit copy/cut/paste command. Degrades gracefully when the
|
|
26
|
+
* platform tool is absent (e.g. CI without `xclip`): the per-session buffer
|
|
27
|
+
* still works for same-session paste reasoning; the result just notes
|
|
28
|
+
* `osSync:false`.
|
|
29
|
+
*/
|
|
30
|
+
export async function osClipboardWrite(text) {
|
|
31
|
+
const plat = process.platform;
|
|
32
|
+
const argv = plat === "darwin"
|
|
33
|
+
? ["pbcopy"]
|
|
34
|
+
: plat === "win32"
|
|
35
|
+
? ["clip"]
|
|
36
|
+
: ["xclip", "-selection", "clipboard"];
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
try {
|
|
39
|
+
const cp = spawn(argv[0], argv.slice(1), { stdio: ["pipe", "ignore", "ignore"] });
|
|
40
|
+
cp.on("error", (e) => resolve({ ok: false, tool: argv[0], error: e.message }));
|
|
41
|
+
cp.on("close", (code) => resolve(code === 0
|
|
42
|
+
? { ok: true, tool: argv[0] }
|
|
43
|
+
: { ok: false, tool: argv[0], error: `exit ${code}` }));
|
|
44
|
+
cp.stdin.end(text);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
resolve({ ok: false, tool: argv[0], error: e instanceof Error ? e.message : String(e) });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CDPSession, Page } from "playwright-core";
|
|
2
|
+
export type ClockMode = "freeze" | "advance" | "release";
|
|
3
|
+
export interface ClockInput {
|
|
4
|
+
mode: ClockMode;
|
|
5
|
+
/** Absolute ISO-8601 instant. `freeze` → pin time there. `advance` → jump to it. */
|
|
6
|
+
atIso?: string;
|
|
7
|
+
/** `advance` only — relative jump in ms (mutually exclusive with `atIso`). */
|
|
8
|
+
byMs?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Cached state used by the re-apply hook. `release` is represented by `undefined`. */
|
|
11
|
+
export interface ClockState {
|
|
12
|
+
/** Effective virtual-time anchor, epoch ms. Mirrors what the page now sees. */
|
|
13
|
+
nowMs: number;
|
|
14
|
+
/** Whether the policy is currently a pause (true) or actively advancing (false). */
|
|
15
|
+
paused: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Per-session clock controller. One per SessionEntry. */
|
|
18
|
+
export declare class ClockRegistry {
|
|
19
|
+
private state;
|
|
20
|
+
/** Re-apply hook installed once per page on first use. */
|
|
21
|
+
private reattachInstalled;
|
|
22
|
+
/** Apply the requested mode and remember it. Returns the normalized state. */
|
|
23
|
+
apply(cdp: CDPSession, page: Page, input: ClockInput): Promise<{
|
|
24
|
+
state: ClockState | undefined;
|
|
25
|
+
mode: ClockMode;
|
|
26
|
+
appliedAtIso: string | null;
|
|
27
|
+
}>;
|
|
28
|
+
/** Reset on close/teardown if a non-default policy is active. */
|
|
29
|
+
resetAll(cdp: CDPSession): Promise<void>;
|
|
30
|
+
/** Test introspection. */
|
|
31
|
+
current(): ClockState | undefined;
|
|
32
|
+
private installReattach;
|
|
33
|
+
private sendPauseAt;
|
|
34
|
+
private sendAdvance;
|
|
35
|
+
private sendRelease;
|
|
36
|
+
}
|