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,57 @@
|
|
|
1
|
+
import type { RefLocatorInputs } from "./refs.js";
|
|
2
|
+
/** A `generate_locator` result, suitable for pasting into a `.spec.ts`. */
|
|
3
|
+
export interface GeneratedLocator {
|
|
4
|
+
/** A Playwright locator expression — e.g. `page.getByRole('button', { name: 'Save' })`
|
|
5
|
+
* or `page.getByTestId('save-btn')` or `page.locator('table > tbody > tr:nth-child(4)')`.
|
|
6
|
+
* Always rooted on the bare identifier `page` so the adopter can rename
|
|
7
|
+
* ergonomically (`const saveBtn = page.getByRole(...)`). */
|
|
8
|
+
playwright: string;
|
|
9
|
+
/** Per-tier stability label, same vocabulary `find()` already emits.
|
|
10
|
+
* high — testid OR role+name (uniquely identifies the element via a stable signal)
|
|
11
|
+
* medium — stable text on a stable role OR stable structural path
|
|
12
|
+
* low — positional / role-only (likely to drift on the next render)
|
|
13
|
+
*/
|
|
14
|
+
stability: "high" | "medium" | "low";
|
|
15
|
+
/** Structured breakdown of the parts the locator string is built from.
|
|
16
|
+
* Adopters who want to compose their own locator (e.g. chain `.filter()`
|
|
17
|
+
* or combine two kinds) can read this without re-parsing the string. */
|
|
18
|
+
components: GeneratedLocatorComponent[];
|
|
19
|
+
}
|
|
20
|
+
export interface GeneratedLocatorComponent {
|
|
21
|
+
kind: "testid" | "role" | "text" | "css";
|
|
22
|
+
value: string;
|
|
23
|
+
/** Present on `role` components when an accessible name disambiguated the role. */
|
|
24
|
+
name?: string;
|
|
25
|
+
/** Present on `testid` components when a non-default test-attribute name
|
|
26
|
+
* drove the match (e.g. `data-cy`, `data-type`). */
|
|
27
|
+
attribute?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Structured failure shape — ref-not-found returns this rather than throwing. */
|
|
30
|
+
export interface GenerateLocatorFailure {
|
|
31
|
+
ok: false;
|
|
32
|
+
failure: {
|
|
33
|
+
kind: "ref-not-found";
|
|
34
|
+
ref: string;
|
|
35
|
+
hint: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface GenerateLocatorSuccess extends GeneratedLocator {
|
|
39
|
+
ok: true;
|
|
40
|
+
}
|
|
41
|
+
export type GenerateLocatorResult = GenerateLocatorSuccess | GenerateLocatorFailure;
|
|
42
|
+
/**
|
|
43
|
+
* Build a Playwright-string locator + structured breakdown for a `RefLocatorInputs`.
|
|
44
|
+
*
|
|
45
|
+
* Priority (mirrors `locatorFromInputs` in `locator.ts`):
|
|
46
|
+
* 1. testId present → getByTestId / [attr="…"] (high)
|
|
47
|
+
* 2. DOM-only ref without testId, cssPath present → locator(cssPath) (medium / low)
|
|
48
|
+
* 3. role + accessible name → getByRole(role, { name }) (high)
|
|
49
|
+
* 4. cssPath fallback (e.g. `both` refs that lost the name)→ locator(cssPath) (medium / low)
|
|
50
|
+
* 5. role only → getByRole(role) (low)
|
|
51
|
+
*/
|
|
52
|
+
export declare function generatePlaywrightLocator(inputs: RefLocatorInputs): GeneratedLocator;
|
|
53
|
+
/** Top-level entry: look the ref up in a registry-shaped lookup and produce
|
|
54
|
+
* either a structured success or a structured ref-not-found failure. The
|
|
55
|
+
* generator is split from the registry lookup so unit tests can drive it
|
|
56
|
+
* directly from `RefLocatorInputs`. */
|
|
57
|
+
export declare function generateLocator(ref: string, lookup: (ref: string) => RefLocatorInputs | undefined): GenerateLocatorResult;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// generate_locator(ref) — adopter-facing bridge from a browxai-internal `eN` ref
|
|
2
|
+
// to a *Playwright-string* locator expression an adopter can paste into a
|
|
3
|
+
// `.spec.ts`.
|
|
4
|
+
//
|
|
5
|
+
// browxai's internal locator-resolution machinery (locator.ts) takes a
|
|
6
|
+
// `RefLocatorInputs` record and produces a live Playwright `Locator` object on
|
|
7
|
+
// the page. That's the right shape for *acting* in-process; it's the wrong
|
|
8
|
+
// shape for the regression-suite handoff use case, where the adopter needs a
|
|
9
|
+
// *string* they can transcribe verbatim into their own test file.
|
|
10
|
+
//
|
|
11
|
+
// This module mirrors the resolution priority in `locatorFromInputs` exactly
|
|
12
|
+
// — testId → DOM cssPath (for DOM-only refs) → role+name → cssPath → role-only
|
|
13
|
+
// — so the string we hand back lines up with the locator browxai itself would
|
|
14
|
+
// resolve at action time. It also emits a structured `components` breakdown
|
|
15
|
+
// (the parts that built the string) and a `stability` label derived from the
|
|
16
|
+
// same tier system `find()` already uses.
|
|
17
|
+
/**
|
|
18
|
+
* Build a Playwright-string locator + structured breakdown for a `RefLocatorInputs`.
|
|
19
|
+
*
|
|
20
|
+
* Priority (mirrors `locatorFromInputs` in `locator.ts`):
|
|
21
|
+
* 1. testId present → getByTestId / [attr="…"] (high)
|
|
22
|
+
* 2. DOM-only ref without testId, cssPath present → locator(cssPath) (medium / low)
|
|
23
|
+
* 3. role + accessible name → getByRole(role, { name }) (high)
|
|
24
|
+
* 4. cssPath fallback (e.g. `both` refs that lost the name)→ locator(cssPath) (medium / low)
|
|
25
|
+
* 5. role only → getByRole(role) (low)
|
|
26
|
+
*/
|
|
27
|
+
export function generatePlaywrightLocator(inputs) {
|
|
28
|
+
// Tier 1: testId. Default `data-testid` lowers to `getByTestId` (Playwright's
|
|
29
|
+
// ergonomic helper); any other configured attribute lowers to the attribute
|
|
30
|
+
// CSS form so non-standard test attributes (`data-cy`, `data-type`) Just Work.
|
|
31
|
+
if (inputs.testId) {
|
|
32
|
+
const attr = inputs.testIdAttr ?? "data-testid";
|
|
33
|
+
if (attr === "data-testid") {
|
|
34
|
+
return {
|
|
35
|
+
playwright: `page.getByTestId(${jsStringLiteral(inputs.testId)})`,
|
|
36
|
+
stability: "high",
|
|
37
|
+
components: [{ kind: "testid", value: inputs.testId }],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const cssAttr = `[${attr}=${jsonAttrValue(inputs.testId)}]`;
|
|
41
|
+
return {
|
|
42
|
+
playwright: `page.locator(${jsStringLiteral(cssAttr)})`,
|
|
43
|
+
stability: "high",
|
|
44
|
+
components: [{ kind: "testid", value: inputs.testId, attribute: attr }],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Tier 2: DOM-only refs (no a11y name available) — the structural path is
|
|
48
|
+
// the only signal we have. Stability is medium when the path looks stable
|
|
49
|
+
// (semantic anchors / id / data-attrs) and low when it's purely positional
|
|
50
|
+
// (`:nth-child` chains all the way down).
|
|
51
|
+
if (inputs.source === "dom" && inputs.cssPath) {
|
|
52
|
+
return cssPathLocator(inputs.cssPath);
|
|
53
|
+
}
|
|
54
|
+
// Tier 3: role + accessible name — strong when the a11y pass saw it.
|
|
55
|
+
// Stability "high": role+name is one of Playwright's most resilient signals
|
|
56
|
+
// (it survives DOM reshuffling as long as the control's accessible name
|
|
57
|
+
// doesn't change).
|
|
58
|
+
if (inputs.name) {
|
|
59
|
+
const role = inputs.role;
|
|
60
|
+
return {
|
|
61
|
+
playwright: `page.getByRole(${jsStringLiteral(role)}, { name: ${jsStringLiteral(inputs.name)} })`,
|
|
62
|
+
stability: "high",
|
|
63
|
+
components: [
|
|
64
|
+
{ kind: "role", value: role, name: inputs.name },
|
|
65
|
+
{ kind: "text", value: inputs.name },
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Tier 4: cssPath fallback for `both` refs that the a11y pass saw without a
|
|
70
|
+
// name. Same stability heuristic as tier 2.
|
|
71
|
+
if (inputs.cssPath) {
|
|
72
|
+
return cssPathLocator(inputs.cssPath);
|
|
73
|
+
}
|
|
74
|
+
// Tier 5: role only. The agent saw `stability: "low"` from `find()` — same
|
|
75
|
+
// verdict here.
|
|
76
|
+
return {
|
|
77
|
+
playwright: `page.getByRole(${jsStringLiteral(inputs.role)})`,
|
|
78
|
+
stability: "low",
|
|
79
|
+
components: [{ kind: "role", value: inputs.role }],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Build a `page.locator(...)` for a structural CSS path, deriving stability
|
|
83
|
+
* from whether the path is purely positional. A path that's entirely
|
|
84
|
+
* `:nth-child(N)` segments under generic tags is `low`; a path with semantic
|
|
85
|
+
* anchors, ids, or stable test attributes is `medium`. */
|
|
86
|
+
function cssPathLocator(cssPath) {
|
|
87
|
+
return {
|
|
88
|
+
playwright: `page.locator(${jsStringLiteral(cssPath)})`,
|
|
89
|
+
stability: cssPathStability(cssPath),
|
|
90
|
+
components: [{ kind: "css", value: cssPath }],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** A CSS path is "stable-structural" (medium) when it carries at least one
|
|
94
|
+
* non-positional anchor — an `#id`, a `[data-*]`/`[aria-*]`/`[role=]` attribute
|
|
95
|
+
* selector, or a semantic landmark tag (`main`, `nav`, `header`, `footer`,
|
|
96
|
+
* `aside`, `form`, `section`, `article`). Otherwise it's purely positional
|
|
97
|
+
* (chains of `:nth-child`/bare tags) and falls back to `low`. */
|
|
98
|
+
function cssPathStability(cssPath) {
|
|
99
|
+
if (/#[A-Za-z]/.test(cssPath))
|
|
100
|
+
return "medium";
|
|
101
|
+
if (/\[(data-|aria-|role=|id=|name=)/.test(cssPath))
|
|
102
|
+
return "medium";
|
|
103
|
+
if (/\b(main|nav|header|footer|aside|form|section|article)\b/.test(cssPath))
|
|
104
|
+
return "medium";
|
|
105
|
+
return "low";
|
|
106
|
+
}
|
|
107
|
+
/** JS string literal — single-quoted, with backslash + single-quote escapes.
|
|
108
|
+
* Matches Playwright's own examples (`page.getByRole('button', { name: 'Save' })`). */
|
|
109
|
+
function jsStringLiteral(s) {
|
|
110
|
+
return `'${s.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
111
|
+
}
|
|
112
|
+
/** CSS attribute-value JSON form — double-quoted, escapes only `\` and `"`.
|
|
113
|
+
* Used inside a bigger JS string literal that we'll quote separately. */
|
|
114
|
+
function jsonAttrValue(s) {
|
|
115
|
+
return JSON.stringify(s);
|
|
116
|
+
}
|
|
117
|
+
/** Top-level entry: look the ref up in a registry-shaped lookup and produce
|
|
118
|
+
* either a structured success or a structured ref-not-found failure. The
|
|
119
|
+
* generator is split from the registry lookup so unit tests can drive it
|
|
120
|
+
* directly from `RefLocatorInputs`. */
|
|
121
|
+
export function generateLocator(ref, lookup) {
|
|
122
|
+
const inputs = lookup(ref);
|
|
123
|
+
if (!inputs) {
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
failure: {
|
|
127
|
+
kind: "ref-not-found",
|
|
128
|
+
ref,
|
|
129
|
+
hint: `ref "${ref}" is not in this session's registry. Call snapshot() or find() first ` +
|
|
130
|
+
`to populate refs (refs survive across snapshots by stable element-key, but a fresh ` +
|
|
131
|
+
`session starts empty).`,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return { ok: true, ...generatePlaywrightLocator(inputs) };
|
|
136
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { CDPSession, Page } from "playwright-core";
|
|
2
|
+
import type { RefRegistry } from "./refs.js";
|
|
3
|
+
import { type ActionTarget } from "./locator.js";
|
|
4
|
+
import { type PointProbeResult } from "./point_probe.js";
|
|
5
|
+
export interface Point {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
/** Resolve an action target to a viewport point — the element's box centre
|
|
10
|
+
* for ref/selector, or the literal coords. */
|
|
11
|
+
export declare function targetPoint(page: Page, refs: RefRegistry, t: ActionTarget): Promise<Point>;
|
|
12
|
+
export interface DragResult {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
from: Point;
|
|
15
|
+
to: Point;
|
|
16
|
+
steps: number;
|
|
17
|
+
}
|
|
18
|
+
export interface DragPreflight {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
preflight: {
|
|
21
|
+
point: Point;
|
|
22
|
+
hit: PointProbeResult;
|
|
23
|
+
/** true when something under the press point looks like a resize handle
|
|
24
|
+
* (a `*-resize` cursor) — dragging here is likely to resize, not move. */
|
|
25
|
+
resizeRisk: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Press at `from`, move to `to` over `steps` intermediate points, release.
|
|
29
|
+
* With `preflight: true`, instead probe the `from` point and report what's
|
|
30
|
+
* under it (top hit element + resize-handle risk) WITHOUT dragging — so the
|
|
31
|
+
* agent can confirm the press lands on draggable content, not a resize
|
|
32
|
+
* handle, before committing. Element targets resolve to the box centre. */
|
|
33
|
+
export declare function drag(page: Page, refs: RefRegistry, args: {
|
|
34
|
+
from: ActionTarget;
|
|
35
|
+
to: ActionTarget;
|
|
36
|
+
steps?: number;
|
|
37
|
+
preflight?: boolean;
|
|
38
|
+
}): Promise<DragResult | DragPreflight>;
|
|
39
|
+
export interface DoubleClickResult {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
point: Point;
|
|
42
|
+
}
|
|
43
|
+
export declare function doubleClick(page: Page, refs: RefRegistry, target: ActionTarget): Promise<DoubleClickResult>;
|
|
44
|
+
/** Coordinate-space wheel event — for canvas / virtualised lists / map tiles
|
|
45
|
+
* that listen for `wheel` and ignore Playwright's element-level scroll.
|
|
46
|
+
* Dispatched via CDP `Input.dispatchMouseEvent` (`type: "mouseWheel"`) so the
|
|
47
|
+
* event fires at `coords` regardless of the current pointer position, with
|
|
48
|
+
* the caller's `deltaX`/`deltaY` (CSS px; positive Y scrolls content up,
|
|
49
|
+
* matching the DOM `WheelEvent` convention). One of `deltaX`/`deltaY` must be
|
|
50
|
+
* non-zero. */
|
|
51
|
+
export declare function mouseWheel(cdp: CDPSession, args: {
|
|
52
|
+
coords: Point;
|
|
53
|
+
deltaX?: number;
|
|
54
|
+
deltaY?: number;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
ok: boolean;
|
|
57
|
+
coords: Point;
|
|
58
|
+
deltaX: number;
|
|
59
|
+
deltaY: number;
|
|
60
|
+
}>;
|
|
61
|
+
export type MouseAction = "down" | "move" | "up";
|
|
62
|
+
/** Low-level mouse control for gestures the higher-level tools don't cover
|
|
63
|
+
* (custom scrub/trim handles). `move` requires coords; `down`/`up` move
|
|
64
|
+
* there first when coords are given, else act at the current position. */
|
|
65
|
+
export declare function mouseAction(page: Page, action: MouseAction, coords?: Point): Promise<{
|
|
66
|
+
ok: boolean;
|
|
67
|
+
action: MouseAction;
|
|
68
|
+
coords?: Point;
|
|
69
|
+
}>;
|
|
70
|
+
export type TouchAction = "start" | "move" | "end";
|
|
71
|
+
/** Dispatch a single touch event at `coords` via CDP. `identifier` tracks the
|
|
72
|
+
* finger across a multi-touch sequence (default `1`). `touch_end` accepts
|
|
73
|
+
* optional `coords`; when omitted CDP gets an empty `touchPoints[]` — the
|
|
74
|
+
* spec's "all fingers up" form. */
|
|
75
|
+
export declare function touchAction(cdp: CDPSession, action: TouchAction, args: {
|
|
76
|
+
coords?: Point;
|
|
77
|
+
identifier?: number;
|
|
78
|
+
}): Promise<{
|
|
79
|
+
ok: boolean;
|
|
80
|
+
action: TouchAction;
|
|
81
|
+
coords?: Point;
|
|
82
|
+
identifier: number;
|
|
83
|
+
}>;
|
|
84
|
+
export interface GesturePinchResult {
|
|
85
|
+
ok: boolean;
|
|
86
|
+
coords: Point;
|
|
87
|
+
scale: number;
|
|
88
|
+
steps: number;
|
|
89
|
+
startOffset: number;
|
|
90
|
+
endOffset: number;
|
|
91
|
+
}
|
|
92
|
+
/** Two-finger pinch in/out, centred on `coords`. Two touch points start at
|
|
93
|
+
* `coords ± startOffset` (a fixed 40 CSS px each side — wider than any
|
|
94
|
+
* realistic finger pair but small enough to land inside a typical canvas) and
|
|
95
|
+
* converge or diverge so the final separation = startOffset × scale.
|
|
96
|
+
* `scale < 1` is pinch-in (zoom out); `scale > 1` is pinch-out (zoom in).
|
|
97
|
+
* Linear interpolation across `steps` intermediate `touchMove` dispatches —
|
|
98
|
+
* pinch handlers (Hammer.js, GoogleMaps, Figma) read the delta between
|
|
99
|
+
* successive `changedTouches`, so a linear ramp is sufficient and avoids the
|
|
100
|
+
* velocity-detection misfires a sinusoidal curve can trigger on fling-detect
|
|
101
|
+
* libraries. */
|
|
102
|
+
export declare function gesturePinch(cdp: CDPSession, args: {
|
|
103
|
+
coords: Point;
|
|
104
|
+
scale: number;
|
|
105
|
+
steps?: number;
|
|
106
|
+
startOffset?: number;
|
|
107
|
+
}): Promise<GesturePinchResult>;
|
|
108
|
+
export interface GestureSwipeResult {
|
|
109
|
+
ok: boolean;
|
|
110
|
+
from: Point;
|
|
111
|
+
to: Point;
|
|
112
|
+
steps: number;
|
|
113
|
+
durationMs: number;
|
|
114
|
+
}
|
|
115
|
+
/** Single-finger swipe from `from` to `to`. Distinct from `drag` — drag uses
|
|
116
|
+
* the mouse pipeline; swipe uses the touch pipeline. `durationMs` controls
|
|
117
|
+
* pacing (default 200 ms — fast flick; 500+ ms reads as a deliberate scroll).
|
|
118
|
+
* Smoothed via an ease-out curve (`1 - (1-t)²`) — touch libraries derive
|
|
119
|
+
* velocity from per-frame deltas; ease-out matches the natural deceleration
|
|
120
|
+
* most fling-detect heuristics are tuned for (Hammer.js, native scroll
|
|
121
|
+
* inertia, react-spring-style physics). */
|
|
122
|
+
export declare function gestureSwipe(cdp: CDPSession, args: {
|
|
123
|
+
from: Point;
|
|
124
|
+
to: Point;
|
|
125
|
+
durationMs?: number;
|
|
126
|
+
steps?: number;
|
|
127
|
+
identifier?: number;
|
|
128
|
+
}): Promise<GestureSwipeResult>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// Pointer-gesture primitives — capability `action`.
|
|
2
|
+
//
|
|
3
|
+
// `click`/`hover` cover taps; media editors and drag-reorder UIs also need
|
|
4
|
+
// drag, double-click, and raw mouse down/move/up.
|
|
5
|
+
import { locatorFor } from "./locator.js";
|
|
6
|
+
import { pointProbe } from "./point_probe.js";
|
|
7
|
+
/** Resolve an action target to a viewport point — the element's box centre
|
|
8
|
+
* for ref/selector, or the literal coords. */
|
|
9
|
+
export async function targetPoint(page, refs, t) {
|
|
10
|
+
if (t.coords)
|
|
11
|
+
return { x: t.coords.x, y: t.coords.y };
|
|
12
|
+
const box = await locatorFor(page, refs, t).boundingBox();
|
|
13
|
+
if (!box || box.width <= 0 || box.height <= 0) {
|
|
14
|
+
throw new Error("drag/gesture target has no rendered box");
|
|
15
|
+
}
|
|
16
|
+
return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
|
17
|
+
}
|
|
18
|
+
const RESIZE_CURSOR = /resize/i;
|
|
19
|
+
/** Press at `from`, move to `to` over `steps` intermediate points, release.
|
|
20
|
+
* With `preflight: true`, instead probe the `from` point and report what's
|
|
21
|
+
* under it (top hit element + resize-handle risk) WITHOUT dragging — so the
|
|
22
|
+
* agent can confirm the press lands on draggable content, not a resize
|
|
23
|
+
* handle, before committing. Element targets resolve to the box centre. */
|
|
24
|
+
export async function drag(page, refs, args) {
|
|
25
|
+
const from = await targetPoint(page, refs, args.from);
|
|
26
|
+
if (args.preflight) {
|
|
27
|
+
const hit = await pointProbe(page, from);
|
|
28
|
+
const resizeRisk = hit.stack.some((el) => RESIZE_CURSOR.test(el.cursor || ""));
|
|
29
|
+
return { ok: true, preflight: { point: from, hit, resizeRisk } };
|
|
30
|
+
}
|
|
31
|
+
const steps = Math.min(Math.max(args.steps ?? 12, 1), 100);
|
|
32
|
+
const to = await targetPoint(page, refs, args.to);
|
|
33
|
+
await page.mouse.move(from.x, from.y);
|
|
34
|
+
await page.mouse.down();
|
|
35
|
+
await page.mouse.move(to.x, to.y, { steps });
|
|
36
|
+
await page.mouse.up();
|
|
37
|
+
return { ok: true, from, to, steps };
|
|
38
|
+
}
|
|
39
|
+
export async function doubleClick(page, refs, target) {
|
|
40
|
+
const point = await targetPoint(page, refs, target);
|
|
41
|
+
await page.mouse.dblclick(point.x, point.y);
|
|
42
|
+
return { ok: true, point };
|
|
43
|
+
}
|
|
44
|
+
/** Coordinate-space wheel event — for canvas / virtualised lists / map tiles
|
|
45
|
+
* that listen for `wheel` and ignore Playwright's element-level scroll.
|
|
46
|
+
* Dispatched via CDP `Input.dispatchMouseEvent` (`type: "mouseWheel"`) so the
|
|
47
|
+
* event fires at `coords` regardless of the current pointer position, with
|
|
48
|
+
* the caller's `deltaX`/`deltaY` (CSS px; positive Y scrolls content up,
|
|
49
|
+
* matching the DOM `WheelEvent` convention). One of `deltaX`/`deltaY` must be
|
|
50
|
+
* non-zero. */
|
|
51
|
+
export async function mouseWheel(cdp, args) {
|
|
52
|
+
const deltaX = args.deltaX ?? 0;
|
|
53
|
+
const deltaY = args.deltaY ?? 0;
|
|
54
|
+
if (deltaX === 0 && deltaY === 0) {
|
|
55
|
+
throw new Error("mouse_wheel requires non-zero deltaX or deltaY");
|
|
56
|
+
}
|
|
57
|
+
await cdp.send("Input.dispatchMouseEvent", {
|
|
58
|
+
type: "mouseWheel",
|
|
59
|
+
x: args.coords.x,
|
|
60
|
+
y: args.coords.y,
|
|
61
|
+
deltaX,
|
|
62
|
+
deltaY,
|
|
63
|
+
button: "none",
|
|
64
|
+
pointerType: "mouse",
|
|
65
|
+
});
|
|
66
|
+
return { ok: true, coords: args.coords, deltaX, deltaY };
|
|
67
|
+
}
|
|
68
|
+
/** Low-level mouse control for gestures the higher-level tools don't cover
|
|
69
|
+
* (custom scrub/trim handles). `move` requires coords; `down`/`up` move
|
|
70
|
+
* there first when coords are given, else act at the current position. */
|
|
71
|
+
export async function mouseAction(page, action, coords) {
|
|
72
|
+
if (action === "move") {
|
|
73
|
+
if (!coords)
|
|
74
|
+
throw new Error("mouse_move requires coords");
|
|
75
|
+
await page.mouse.move(coords.x, coords.y);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (coords)
|
|
79
|
+
await page.mouse.move(coords.x, coords.y);
|
|
80
|
+
if (action === "down")
|
|
81
|
+
await page.mouse.down();
|
|
82
|
+
else
|
|
83
|
+
await page.mouse.up();
|
|
84
|
+
}
|
|
85
|
+
return { ok: true, action, ...(coords ? { coords } : {}) };
|
|
86
|
+
}
|
|
87
|
+
const TOUCH_CDP_TYPE = {
|
|
88
|
+
start: "touchStart",
|
|
89
|
+
move: "touchMove",
|
|
90
|
+
end: "touchEnd",
|
|
91
|
+
};
|
|
92
|
+
/** Dispatch a single touch event at `coords` via CDP. `identifier` tracks the
|
|
93
|
+
* finger across a multi-touch sequence (default `1`). `touch_end` accepts
|
|
94
|
+
* optional `coords`; when omitted CDP gets an empty `touchPoints[]` — the
|
|
95
|
+
* spec's "all fingers up" form. */
|
|
96
|
+
export async function touchAction(cdp, action, args) {
|
|
97
|
+
const identifier = args.identifier ?? 1;
|
|
98
|
+
if (action !== "end" && !args.coords) {
|
|
99
|
+
throw new Error(`touch_${action} requires coords`);
|
|
100
|
+
}
|
|
101
|
+
const touchPoints = args.coords ? [{ x: args.coords.x, y: args.coords.y, id: identifier }] : [];
|
|
102
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
103
|
+
type: TOUCH_CDP_TYPE[action],
|
|
104
|
+
touchPoints,
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
ok: true,
|
|
108
|
+
action,
|
|
109
|
+
...(args.coords ? { coords: args.coords } : {}),
|
|
110
|
+
identifier,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Two-finger pinch in/out, centred on `coords`. Two touch points start at
|
|
114
|
+
* `coords ± startOffset` (a fixed 40 CSS px each side — wider than any
|
|
115
|
+
* realistic finger pair but small enough to land inside a typical canvas) and
|
|
116
|
+
* converge or diverge so the final separation = startOffset × scale.
|
|
117
|
+
* `scale < 1` is pinch-in (zoom out); `scale > 1` is pinch-out (zoom in).
|
|
118
|
+
* Linear interpolation across `steps` intermediate `touchMove` dispatches —
|
|
119
|
+
* pinch handlers (Hammer.js, GoogleMaps, Figma) read the delta between
|
|
120
|
+
* successive `changedTouches`, so a linear ramp is sufficient and avoids the
|
|
121
|
+
* velocity-detection misfires a sinusoidal curve can trigger on fling-detect
|
|
122
|
+
* libraries. */
|
|
123
|
+
export async function gesturePinch(cdp, args) {
|
|
124
|
+
const scale = args.scale;
|
|
125
|
+
if (!Number.isFinite(scale) || scale <= 0) {
|
|
126
|
+
throw new Error("gesture_pinch requires a positive finite scale");
|
|
127
|
+
}
|
|
128
|
+
const steps = Math.min(Math.max(args.steps ?? 12, 1), 100);
|
|
129
|
+
const startOffset = args.startOffset ?? 40;
|
|
130
|
+
const endOffset = startOffset * scale;
|
|
131
|
+
const cx = args.coords.x;
|
|
132
|
+
const cy = args.coords.y;
|
|
133
|
+
const id1 = 1;
|
|
134
|
+
const id2 = 2;
|
|
135
|
+
// touchStart with both fingers
|
|
136
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
137
|
+
type: "touchStart",
|
|
138
|
+
touchPoints: [
|
|
139
|
+
{ x: cx - startOffset, y: cy, id: id1 },
|
|
140
|
+
{ x: cx + startOffset, y: cy, id: id2 },
|
|
141
|
+
],
|
|
142
|
+
});
|
|
143
|
+
for (let i = 1; i <= steps; i++) {
|
|
144
|
+
const t = i / steps;
|
|
145
|
+
const offset = startOffset + (endOffset - startOffset) * t;
|
|
146
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
147
|
+
type: "touchMove",
|
|
148
|
+
touchPoints: [
|
|
149
|
+
{ x: cx - offset, y: cy, id: id1 },
|
|
150
|
+
{ x: cx + offset, y: cy, id: id2 },
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// touchEnd lifts all fingers (empty touchPoints[])
|
|
155
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
156
|
+
type: "touchEnd",
|
|
157
|
+
touchPoints: [],
|
|
158
|
+
});
|
|
159
|
+
return { ok: true, coords: args.coords, scale, steps, startOffset, endOffset };
|
|
160
|
+
}
|
|
161
|
+
/** Single-finger swipe from `from` to `to`. Distinct from `drag` — drag uses
|
|
162
|
+
* the mouse pipeline; swipe uses the touch pipeline. `durationMs` controls
|
|
163
|
+
* pacing (default 200 ms — fast flick; 500+ ms reads as a deliberate scroll).
|
|
164
|
+
* Smoothed via an ease-out curve (`1 - (1-t)²`) — touch libraries derive
|
|
165
|
+
* velocity from per-frame deltas; ease-out matches the natural deceleration
|
|
166
|
+
* most fling-detect heuristics are tuned for (Hammer.js, native scroll
|
|
167
|
+
* inertia, react-spring-style physics). */
|
|
168
|
+
export async function gestureSwipe(cdp, args) {
|
|
169
|
+
const identifier = args.identifier ?? 1;
|
|
170
|
+
const durationMs = Math.min(Math.max(args.durationMs ?? 200, 0), 60_000);
|
|
171
|
+
const steps = Math.min(Math.max(args.steps ?? 16, 1), 200);
|
|
172
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
173
|
+
type: "touchStart",
|
|
174
|
+
touchPoints: [{ x: args.from.x, y: args.from.y, id: identifier }],
|
|
175
|
+
});
|
|
176
|
+
const dx = args.to.x - args.from.x;
|
|
177
|
+
const dy = args.to.y - args.from.y;
|
|
178
|
+
const perStepDelay = durationMs / steps;
|
|
179
|
+
for (let i = 1; i <= steps; i++) {
|
|
180
|
+
const t = i / steps;
|
|
181
|
+
// ease-out: 1 - (1 - t)^2 — fast start, gentle settle
|
|
182
|
+
const eased = 1 - (1 - t) * (1 - t);
|
|
183
|
+
const x = args.from.x + dx * eased;
|
|
184
|
+
const y = args.from.y + dy * eased;
|
|
185
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
186
|
+
type: "touchMove",
|
|
187
|
+
touchPoints: [{ x, y, id: identifier }],
|
|
188
|
+
});
|
|
189
|
+
if (perStepDelay > 0) {
|
|
190
|
+
await new Promise((resolve) => setTimeout(resolve, perStepDelay));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
await cdp.send("Input.dispatchTouchEvent", {
|
|
194
|
+
type: "touchEnd",
|
|
195
|
+
touchPoints: [],
|
|
196
|
+
});
|
|
197
|
+
return { ok: true, from: args.from, to: args.to, steps, durationMs };
|
|
198
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { BrowserContext } from "playwright-core";
|
|
2
|
+
/** Maximum size (in bytes) at which a finalized HAR is returned inline rather
|
|
3
|
+
* than only by path. Mirrors the same cap used by `network_body` / storage
|
|
4
|
+
* dumps — agents that hit it should rely on the path field instead. */
|
|
5
|
+
export declare const HAR_INLINE_CAP_BYTES: number;
|
|
6
|
+
/** Per-session HAR recorder state. One per `SessionEntry`. */
|
|
7
|
+
export interface HarRecorderState {
|
|
8
|
+
/** True between a successful `start_har` (or `open_session({har})`) and the
|
|
9
|
+
* next `stop_har` / session close. */
|
|
10
|
+
active: boolean;
|
|
11
|
+
/** Workspace-absolute path the HAR is being written to. Reserved at start. */
|
|
12
|
+
path?: string;
|
|
13
|
+
/** epoch ms the recorder was started. */
|
|
14
|
+
startedAt?: number;
|
|
15
|
+
/** Capture mode (full vs minimal). Same semantics as Playwright. */
|
|
16
|
+
mode?: "full" | "minimal";
|
|
17
|
+
/** Content policy — `embed` inlines bodies (default for `.har`), `attach`
|
|
18
|
+
* splits into sidecar files (default for `.zip`), `omit` drops bodies. */
|
|
19
|
+
content?: "embed" | "attach" | "omit";
|
|
20
|
+
/** When true, the HAR was wired at context creation via Playwright's native
|
|
21
|
+
* `recordHar` option (open_session({har:{...}})) — `stop_har` is a no-op
|
|
22
|
+
* for this case (you can't undo a context-creation primitive without
|
|
23
|
+
* closing the context). */
|
|
24
|
+
nativeRecord?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function newHarRecorderState(): HarRecorderState;
|
|
27
|
+
/** Configuration accepted by `start_har` AND `open_session({har})`. */
|
|
28
|
+
export interface HarStartConfig {
|
|
29
|
+
/** Workspace-rooted path. Optional — defaults to
|
|
30
|
+
* `<workspace>/har/<session-id>-<ISO>.har` when omitted. Path traversal
|
|
31
|
+
* outside the workspace is rejected (mirrors the storage-state contract). */
|
|
32
|
+
path?: string;
|
|
33
|
+
mode?: "full" | "minimal";
|
|
34
|
+
content?: "embed" | "attach" | "omit";
|
|
35
|
+
/** Optional URL filter (glob or regex) — only matching requests are stored. */
|
|
36
|
+
urlFilter?: string;
|
|
37
|
+
}
|
|
38
|
+
/** Default HAR filename for an auto-named recording. ISO timestamp with
|
|
39
|
+
* `:` / `.` mapped to `-` so the name is filesystem-safe on every platform. */
|
|
40
|
+
export declare function defaultHarFilename(sessionId: string, now?: Date): string;
|
|
41
|
+
/** Resolve an explicit user-supplied path (workspace-escape rejected) OR
|
|
42
|
+
* build the default `<workspace>/har/<auto>.har` path. Creates the parent
|
|
43
|
+
* dir on demand — still under the workspace root by construction. */
|
|
44
|
+
export declare function resolveHarPath(workspaceRoot: string, sessionId: string, userPath: string | undefined, tool: string): string;
|
|
45
|
+
/** Validate replay HAR file paths supplied to `open_session({hars})`. Each
|
|
46
|
+
* must resolve under `$BROWX_WORKSPACE` and the file must exist (a typo
|
|
47
|
+
* silently falling back to live network would defeat the point). */
|
|
48
|
+
export declare function resolveHarReplayPaths(workspaceRoot: string, hars: readonly string[], tool: string): string[];
|
|
49
|
+
/** Begin HAR recording on a live context via `routeFromHAR(update:true)`. The
|
|
50
|
+
* HAR file on disk is finalized when the context closes — this returns the
|
|
51
|
+
* reserved path and the caller is responsible for `close_session` (or the
|
|
52
|
+
* natural session teardown) to flush. Re-calling `start_har` on an already-
|
|
53
|
+
* active recorder replaces the in-flight target after a transparent stop. */
|
|
54
|
+
export declare function startHar(context: BrowserContext, state: HarRecorderState, workspaceRoot: string, sessionId: string, cfg?: HarStartConfig): Promise<{
|
|
55
|
+
path: string;
|
|
56
|
+
mode: "full" | "minimal";
|
|
57
|
+
content: "embed" | "attach" | "omit";
|
|
58
|
+
replacedPrior: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
/** Stop HAR recording on a live context. Removes the recording route; the HAR
|
|
61
|
+
* file is written to disk when the context closes (Playwright constraint).
|
|
62
|
+
* No-op + `{wasActive:false}` when no recorder is active. */
|
|
63
|
+
export declare function stopHar(context: BrowserContext, state: HarRecorderState): Promise<{
|
|
64
|
+
wasActive: boolean;
|
|
65
|
+
path?: string;
|
|
66
|
+
finalized: boolean;
|
|
67
|
+
nativeRecord: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/** Best-effort read of a finalized HAR. Used by callers that want the file
|
|
70
|
+
* inlined when small. Returns `undefined` when the file doesn't yet exist
|
|
71
|
+
* (HAR not finalized) or is over the inline cap. */
|
|
72
|
+
export declare function readHarIfSmall(path: string, capBytes?: number): string | undefined;
|
|
73
|
+
/** Apply replay HAR(s) to a live context. Each file is wired with
|
|
74
|
+
* `notFound:"fallback"` so a request that isn't in the archive falls through
|
|
75
|
+
* to the live network (the safer default; agents who want a hermetic replay
|
|
76
|
+
* can route the rest themselves). */
|
|
77
|
+
export declare function applyHarReplay(context: BrowserContext, files: readonly string[]): Promise<void>;
|
|
78
|
+
/** Build the Playwright `recordHar` option for `open_session({har})`. The
|
|
79
|
+
* caller passes this into `browser.newContext({recordHar})` / equivalent
|
|
80
|
+
* on `chromium.launchPersistentContext`. */
|
|
81
|
+
export declare function buildRecordHarOption(workspaceRoot: string, sessionId: string, cfg: HarStartConfig): {
|
|
82
|
+
path: string;
|
|
83
|
+
mode: "full" | "minimal";
|
|
84
|
+
content: "embed" | "attach" | "omit";
|
|
85
|
+
recordHar: {
|
|
86
|
+
path: string;
|
|
87
|
+
mode?: "full" | "minimal";
|
|
88
|
+
content?: "embed" | "attach" | "omit";
|
|
89
|
+
urlFilter?: string | RegExp;
|
|
90
|
+
};
|
|
91
|
+
};
|