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,350 @@
|
|
|
1
|
+
// Three-layer storage-state primitives — .
|
|
2
|
+
//
|
|
3
|
+
// The deferred bulk-state ask, with the @playwright/mcp lesson baked
|
|
4
|
+
// in: bulk alone isn't enough — adopters constantly need to read a single
|
|
5
|
+
// cookie ("am I logged in?") or set one ("opt-out=1") without round-tripping
|
|
6
|
+
// a full blob. So three layers ship together:
|
|
7
|
+
//
|
|
8
|
+
// 1. Bulk — `dump_storage_state` / `inject_storage_state` (wraps
|
|
9
|
+
// `BrowserContext.storageState()` / `setStorageState()`).
|
|
10
|
+
// 2. Granular — cookies + localStorage + sessionStorage CRUD (cookies via
|
|
11
|
+
// Playwright's `BrowserContext.addCookies`/`cookies`/
|
|
12
|
+
// `clearCookies`; web-storage via `page.evaluate(...)` since
|
|
13
|
+
// it's origin-scoped — the page MUST be navigated to the
|
|
14
|
+
// target origin first).
|
|
15
|
+
// 3. Named — `auth_save({name})` / `auth_load({name})` wrap layer 1 with
|
|
16
|
+
// workspace-rooted JSON files at
|
|
17
|
+
// `$BROWX_WORKSPACE/.auth-states/<name>.json`. No parallel
|
|
18
|
+
// implementation — they delegate to layer 1.
|
|
19
|
+
//
|
|
20
|
+
// Capability split (server.ts):
|
|
21
|
+
// - reads (`*_get`, `*_list`, `dump_storage_state`) → `read`
|
|
22
|
+
// - writes (`*_set`, `*_delete`, `*_clear`,
|
|
23
|
+
// `inject_storage_state`, `auth_save`, `auth_load`) → `action`
|
|
24
|
+
//
|
|
25
|
+
// Workspace contract: every `path` arg resolves inside `$BROWX_WORKSPACE`;
|
|
26
|
+
// path-traversal is rejected (same posture as `upload_file`). Named-state
|
|
27
|
+
// names are restricted to a safe character set (no separators, no `..`).
|
|
28
|
+
//
|
|
29
|
+
// Secrets-masking interplay: cookie *values* may carry credentials. A
|
|
30
|
+
// future secrets-masking pass will mask them on egress. For now the gap
|
|
31
|
+
// is documented; no extra work here.
|
|
32
|
+
import { resolve, sep, join } from "node:path";
|
|
33
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, statSync, rmSync, } from "node:fs";
|
|
34
|
+
// ---- workspace path / name validators -------------------------------------
|
|
35
|
+
/** Names for named-states + similar file-naming use. No path separators,
|
|
36
|
+
* no leading dots, no `..`. Same posture as `profile-snapshot.ts`. */
|
|
37
|
+
const SAFE_NAME = /^[A-Za-z0-9._-]+$/;
|
|
38
|
+
export function assertSafeName(kind, name) {
|
|
39
|
+
if (!name || !SAFE_NAME.test(name) || name === "." || name === "..") {
|
|
40
|
+
throw new Error(`${kind} "${name}" invalid — use only letters, digits, '.', '_', '-' ` +
|
|
41
|
+
`(no path separators, no "..")`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Resolve a workspace-rooted path. Rejects any path that escapes the root
|
|
45
|
+
* (`..` segments, absolute paths pointing outside, etc.). Mirrors the
|
|
46
|
+
* `upload_file` contract. */
|
|
47
|
+
export function resolveWorkspacePath(workspaceRoot, p, tool) {
|
|
48
|
+
const resolved = resolve(workspaceRoot, p);
|
|
49
|
+
if (resolved !== workspaceRoot && !resolved.startsWith(workspaceRoot + sep)) {
|
|
50
|
+
throw new Error(`${tool}: \`path\` must resolve inside $BROWX_WORKSPACE — got "${p}". ` +
|
|
51
|
+
`Use a workspace-relative path (or call \`auth_save\` for the named-state path).`);
|
|
52
|
+
}
|
|
53
|
+
return resolved;
|
|
54
|
+
}
|
|
55
|
+
// ---- layer 1: bulk --------------------------------------------------------
|
|
56
|
+
/** Dump the context's storage state. Optionally writes JSON to a
|
|
57
|
+
* workspace-rooted path; ALWAYS returns the blob. */
|
|
58
|
+
export async function dumpStorageState(context, workspaceRoot, opts = {}) {
|
|
59
|
+
const state = await context.storageState();
|
|
60
|
+
if (opts.path === undefined)
|
|
61
|
+
return { state };
|
|
62
|
+
// `resolved` is workspace-rooted by construction — `resolveWorkspacePath`
|
|
63
|
+
// (above) rejects any path outside `workspace.root` / $BROWX_WORKSPACE.
|
|
64
|
+
const resolved = resolveWorkspacePath(workspaceRoot, opts.path, "dump_storage_state");
|
|
65
|
+
const json = JSON.stringify(state, null, 2);
|
|
66
|
+
// ensure parent dir exists — still under workspace.root by construction.
|
|
67
|
+
const parent = resolved.substring(0, Math.max(resolved.lastIndexOf(sep), 0));
|
|
68
|
+
if (parent && !existsSync(parent))
|
|
69
|
+
mkdirSync(parent, { recursive: true });
|
|
70
|
+
writeFileSync(resolved, json, "utf8");
|
|
71
|
+
return { state, path: resolved, bytes: Buffer.byteLength(json, "utf8") };
|
|
72
|
+
}
|
|
73
|
+
/** Read + validate a state blob from a workspace-rooted file path. */
|
|
74
|
+
export function readStorageStateFile(workspaceRoot, p, tool) {
|
|
75
|
+
const resolved = resolveWorkspacePath(workspaceRoot, p, tool);
|
|
76
|
+
if (!existsSync(resolved)) {
|
|
77
|
+
throw new Error(`${tool}: storage-state file not found at "${resolved}"`);
|
|
78
|
+
}
|
|
79
|
+
const raw = readFileSync(resolved, "utf8");
|
|
80
|
+
let parsed;
|
|
81
|
+
try {
|
|
82
|
+
parsed = JSON.parse(raw);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw new Error(`${tool}: storage-state file "${resolved}" is not valid JSON (${err instanceof Error ? err.message : String(err)})`);
|
|
86
|
+
}
|
|
87
|
+
validateStorageStateShape(parsed, tool);
|
|
88
|
+
return parsed;
|
|
89
|
+
}
|
|
90
|
+
function validateStorageStateShape(value, tool) {
|
|
91
|
+
if (!value || typeof value !== "object") {
|
|
92
|
+
throw new Error(`${tool}: storage-state must be an object with \`cookies\` and \`origins\` arrays`);
|
|
93
|
+
}
|
|
94
|
+
const v = value;
|
|
95
|
+
if (!Array.isArray(v.cookies)) {
|
|
96
|
+
throw new Error(`${tool}: storage-state.\`cookies\` must be an array`);
|
|
97
|
+
}
|
|
98
|
+
if (!Array.isArray(v.origins)) {
|
|
99
|
+
throw new Error(`${tool}: storage-state.\`origins\` must be an array`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Inject a storage-state into an EXISTING context. Two modes:
|
|
103
|
+
* - `replace` (default) — wipes the context's cookies/localStorage/IndexedDB
|
|
104
|
+
* and applies the new state. Uses Playwright's `setStorageState`.
|
|
105
|
+
* - `merge` — adds cookies via `addCookies` without clearing; localStorage
|
|
106
|
+
* merge requires a navigation to each origin and runs via `page.evaluate`
|
|
107
|
+
* (best-effort: only the currently-loaded page's origin is updated; other
|
|
108
|
+
* origins in the blob are skipped with a note in the result). */
|
|
109
|
+
export async function injectStorageState(context, page, state, opts = {}) {
|
|
110
|
+
const mode = opts.mode ?? "replace";
|
|
111
|
+
if (mode === "replace") {
|
|
112
|
+
// setStorageState clears existing cookies + localStorage + IndexedDB first.
|
|
113
|
+
await context.setStorageState(state);
|
|
114
|
+
return {
|
|
115
|
+
mode,
|
|
116
|
+
cookiesApplied: state.cookies.length,
|
|
117
|
+
originsApplied: state.origins.length,
|
|
118
|
+
originsSkipped: [],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// merge: cookies are safe to add without clearing.
|
|
122
|
+
if (state.cookies.length)
|
|
123
|
+
await context.addCookies(state.cookies);
|
|
124
|
+
let originsApplied = 0;
|
|
125
|
+
const originsSkipped = [];
|
|
126
|
+
const currentOrigin = (() => {
|
|
127
|
+
try {
|
|
128
|
+
return new URL(page.url()).origin;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
for (const o of state.origins) {
|
|
135
|
+
if (currentOrigin === o.origin) {
|
|
136
|
+
await page.evaluate((entries) => {
|
|
137
|
+
for (const e of entries)
|
|
138
|
+
window.localStorage.setItem(e.name, e.value);
|
|
139
|
+
}, o.localStorage);
|
|
140
|
+
originsApplied += 1;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
originsSkipped.push(o.origin);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return { mode, cookiesApplied: state.cookies.length, originsApplied, originsSkipped };
|
|
147
|
+
}
|
|
148
|
+
// ---- layer 2: cookies CRUD ------------------------------------------------
|
|
149
|
+
export async function cookiesGet(context, args) {
|
|
150
|
+
if (!args.name)
|
|
151
|
+
throw new Error("cookies_get: `name` is required");
|
|
152
|
+
const list = await context.cookies(args.url ? [args.url] : undefined);
|
|
153
|
+
return list.find((c) => c.name === args.name) ?? null;
|
|
154
|
+
}
|
|
155
|
+
export async function cookiesList(context, args = {}) {
|
|
156
|
+
const list = await context.cookies(args.urls);
|
|
157
|
+
return list;
|
|
158
|
+
}
|
|
159
|
+
export async function cookiesSet(context, args) {
|
|
160
|
+
if (!args.name)
|
|
161
|
+
throw new Error("cookies_set: `name` is required");
|
|
162
|
+
if (typeof args.value !== "string")
|
|
163
|
+
throw new Error("cookies_set: `value` (string) is required");
|
|
164
|
+
if (!args.url && !(args.domain && args.path)) {
|
|
165
|
+
throw new Error("cookies_set: pass either `url` (recommended) OR both `domain` and `path` — " +
|
|
166
|
+
"Playwright's addCookies requires one of those two forms");
|
|
167
|
+
}
|
|
168
|
+
await context.addCookies([args]);
|
|
169
|
+
return { ok: true };
|
|
170
|
+
}
|
|
171
|
+
/** The cookie `path` Playwright assigns when `addCookies` is given a `url`:
|
|
172
|
+
* the parent directory of the url path ("/storage" → "/", "/a/b" → "/a/").
|
|
173
|
+
* Used so `cookies_delete` filters by the same path the URL-form
|
|
174
|
+
* `cookies_set` stored under. */
|
|
175
|
+
function urlCookiePath(pathname) {
|
|
176
|
+
return pathname.substring(0, pathname.lastIndexOf("/") + 1) || "/";
|
|
177
|
+
}
|
|
178
|
+
export async function cookiesDelete(context, args) {
|
|
179
|
+
if (!args.name)
|
|
180
|
+
throw new Error("cookies_delete: `name` is required");
|
|
181
|
+
// `clearCookies` accepts a filter — name + (optional) url / domain / path.
|
|
182
|
+
const filter = { name: args.name };
|
|
183
|
+
if (args.domain)
|
|
184
|
+
filter.domain = args.domain;
|
|
185
|
+
if (args.path)
|
|
186
|
+
filter.path = args.path;
|
|
187
|
+
if (args.url) {
|
|
188
|
+
try {
|
|
189
|
+
const u = new URL(args.url);
|
|
190
|
+
filter.domain = filter.domain ?? u.hostname;
|
|
191
|
+
// Match Playwright's URL→cookie-path rule (the parent "directory" of the
|
|
192
|
+
// url path), so a delete by the SAME url that `cookies_set` used actually
|
|
193
|
+
// matches: addCookies({url}) stores e.g. "/storage" at path "/", so a
|
|
194
|
+
// delete filter of the raw pathname "/storage" would match nothing.
|
|
195
|
+
filter.path = filter.path ?? urlCookiePath(u.pathname);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
throw new Error(`cookies_delete: invalid url "${args.url}"`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
await context.clearCookies(filter);
|
|
202
|
+
return { ok: true };
|
|
203
|
+
}
|
|
204
|
+
export async function cookiesClear(context) {
|
|
205
|
+
await context.clearCookies();
|
|
206
|
+
return { ok: true };
|
|
207
|
+
}
|
|
208
|
+
/** localStorage/sessionStorage are origin-scoped and tied to the current
|
|
209
|
+
* page; we must drive them via `page.evaluate`. The page MUST be navigated
|
|
210
|
+
* to the target origin first — on `about:blank` or a different origin the
|
|
211
|
+
* call throws a Playwright SecurityError, which we re-frame with a clearer
|
|
212
|
+
* hint. */
|
|
213
|
+
function webStorageGuard(page, kind, tool) {
|
|
214
|
+
let url;
|
|
215
|
+
try {
|
|
216
|
+
url = page.url();
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
url = "";
|
|
220
|
+
}
|
|
221
|
+
if (!url || url === "about:blank") {
|
|
222
|
+
throw new Error(`${tool}: ${kind} is origin-scoped and the page is at "${url || "(unknown)"}". ` +
|
|
223
|
+
`Navigate the session to the target origin first.`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Browser-side storage references — string form to avoid pulling the DOM
|
|
227
|
+
// lib into tsconfig. Mirrors `src/page/shortcut.ts`. The `kind` parameter is
|
|
228
|
+
// the literal `localStorage` or `sessionStorage` member name on `window`.
|
|
229
|
+
export async function webStorageGet(page, kind, args, tool) {
|
|
230
|
+
if (!args.key)
|
|
231
|
+
throw new Error(`${tool}: \`key\` is required`);
|
|
232
|
+
webStorageGuard(page, kind, tool);
|
|
233
|
+
const expr = `(() => { var s = window.${kind}; ` +
|
|
234
|
+
`return { value: s.getItem(${JSON.stringify(args.key)}), origin: window.location.origin }; })()`;
|
|
235
|
+
return await page.evaluate(expr);
|
|
236
|
+
}
|
|
237
|
+
export async function webStorageSet(page, kind, args, tool) {
|
|
238
|
+
if (!args.key)
|
|
239
|
+
throw new Error(`${tool}: \`key\` is required`);
|
|
240
|
+
if (typeof args.value !== "string")
|
|
241
|
+
throw new Error(`${tool}: \`value\` (string) is required`);
|
|
242
|
+
webStorageGuard(page, kind, tool);
|
|
243
|
+
const expr = `(() => { var s = window.${kind}; ` +
|
|
244
|
+
`s.setItem(${JSON.stringify(args.key)}, ${JSON.stringify(args.value)}); ` +
|
|
245
|
+
`return { ok: true, origin: window.location.origin }; })()`;
|
|
246
|
+
return await page.evaluate(expr);
|
|
247
|
+
}
|
|
248
|
+
export async function webStorageList(page, kind, tool) {
|
|
249
|
+
webStorageGuard(page, kind, tool);
|
|
250
|
+
const expr = `(() => { var s = window.${kind}; var out = []; ` +
|
|
251
|
+
`for (var i = 0; i < s.length; i++) { var k = s.key(i); if (k === null) continue; ` +
|
|
252
|
+
`out.push({ key: k, value: s.getItem(k) || "" }); } ` +
|
|
253
|
+
`return { entries: out, origin: window.location.origin }; })()`;
|
|
254
|
+
return await page.evaluate(expr);
|
|
255
|
+
}
|
|
256
|
+
export async function webStorageDelete(page, kind, args, tool) {
|
|
257
|
+
if (!args.key)
|
|
258
|
+
throw new Error(`${tool}: \`key\` is required`);
|
|
259
|
+
webStorageGuard(page, kind, tool);
|
|
260
|
+
const expr = `(() => { var s = window.${kind}; s.removeItem(${JSON.stringify(args.key)}); ` +
|
|
261
|
+
`return { ok: true, origin: window.location.origin }; })()`;
|
|
262
|
+
return await page.evaluate(expr);
|
|
263
|
+
}
|
|
264
|
+
export async function webStorageClear(page, kind, tool) {
|
|
265
|
+
webStorageGuard(page, kind, tool);
|
|
266
|
+
const expr = `(() => { var s = window.${kind}; s.clear(); ` +
|
|
267
|
+
`return { ok: true, origin: window.location.origin }; })()`;
|
|
268
|
+
return await page.evaluate(expr);
|
|
269
|
+
}
|
|
270
|
+
// ---- layer 3: named auth-states -------------------------------------------
|
|
271
|
+
const AUTH_STATES_DIR = ".auth-states";
|
|
272
|
+
/** Resolve the on-disk path for a named auth-state. Validates the name. */
|
|
273
|
+
export function authStatePath(workspaceRoot, name) {
|
|
274
|
+
assertSafeName("auth state name", name);
|
|
275
|
+
return join(workspaceRoot, AUTH_STATES_DIR, `${name}.json`);
|
|
276
|
+
}
|
|
277
|
+
/** Capture the context's storage state into the named slot. Overwrites an
|
|
278
|
+
* existing slot of the same name. */
|
|
279
|
+
export async function authSave(context, workspaceRoot, name) {
|
|
280
|
+
// `dest` + `dir` below are rooted at `workspaceRoot` ($BROWX_WORKSPACE) by
|
|
281
|
+
// construction — `authStatePath` validates the name through `assertSafeName`
|
|
282
|
+
// (no separators / no traversal) before joining under workspaceRoot.
|
|
283
|
+
const dest = authStatePath(workspaceRoot, name);
|
|
284
|
+
const dir = join(workspaceRoot, AUTH_STATES_DIR);
|
|
285
|
+
// workspace.root-rooted by construction (see comment above).
|
|
286
|
+
if (!existsSync(dir))
|
|
287
|
+
mkdirSync(dir, { recursive: true });
|
|
288
|
+
const state = await context.storageState();
|
|
289
|
+
const json = JSON.stringify(state, null, 2);
|
|
290
|
+
// workspace.root-rooted by construction (see comment above).
|
|
291
|
+
writeFileSync(dest, json, "utf8");
|
|
292
|
+
return {
|
|
293
|
+
ok: true,
|
|
294
|
+
name,
|
|
295
|
+
path: dest,
|
|
296
|
+
bytes: Buffer.byteLength(json, "utf8"),
|
|
297
|
+
cookies: state.cookies.length,
|
|
298
|
+
origins: state.origins.length,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/** Load a named auth-state from disk. Returns the parsed blob ready to feed
|
|
302
|
+
* into `open_session({ storageState })` or `inject_storage_state`. */
|
|
303
|
+
export function authLoad(workspaceRoot, name) {
|
|
304
|
+
const path = authStatePath(workspaceRoot, name);
|
|
305
|
+
if (!existsSync(path)) {
|
|
306
|
+
throw new Error(`auth_load: no named state "${name}" — call auth_save({ name }) first (looked for ${path})`);
|
|
307
|
+
}
|
|
308
|
+
const raw = readFileSync(path, "utf8");
|
|
309
|
+
let parsed;
|
|
310
|
+
try {
|
|
311
|
+
parsed = JSON.parse(raw);
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
throw new Error(`auth_load: named state "${name}" is corrupt JSON (${err instanceof Error ? err.message : String(err)})`);
|
|
315
|
+
}
|
|
316
|
+
validateStorageStateShape(parsed, "auth_load");
|
|
317
|
+
return parsed;
|
|
318
|
+
}
|
|
319
|
+
/** Enumerate every named state in the workspace. Read-only; returns
|
|
320
|
+
* `{name, path, bytes, modifiedAt}` per slot. */
|
|
321
|
+
export function authList(workspaceRoot) {
|
|
322
|
+
const dir = join(workspaceRoot, AUTH_STATES_DIR);
|
|
323
|
+
if (!existsSync(dir))
|
|
324
|
+
return [];
|
|
325
|
+
const out = [];
|
|
326
|
+
for (const entry of readdirSync(dir)) {
|
|
327
|
+
if (!entry.endsWith(".json"))
|
|
328
|
+
continue;
|
|
329
|
+
const name = entry.slice(0, -".json".length);
|
|
330
|
+
if (!SAFE_NAME.test(name))
|
|
331
|
+
continue;
|
|
332
|
+
const path = join(dir, entry);
|
|
333
|
+
try {
|
|
334
|
+
const st = statSync(path);
|
|
335
|
+
out.push({ name, path, bytes: st.size, modifiedAt: new Date(st.mtimeMs).toISOString() });
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
/* skip unreadable */
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
342
|
+
}
|
|
343
|
+
/** Delete a named state. Returns whether the slot existed. */
|
|
344
|
+
export function authDelete(workspaceRoot, name) {
|
|
345
|
+
const path = authStatePath(workspaceRoot, name);
|
|
346
|
+
const existed = existsSync(path);
|
|
347
|
+
if (existed)
|
|
348
|
+
rmSync(path, { force: true });
|
|
349
|
+
return { ok: true, existed, path };
|
|
350
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, CDPSession, Page } from "playwright-core";
|
|
2
|
+
import type { EngineKind, SafariSessionHandle } from "../engine/index.js";
|
|
3
|
+
export type SessionMode = "managed" | "byob";
|
|
4
|
+
/** resolved device/viewport emulation options applied at context
|
|
5
|
+
* creation. A subset of Playwright's context options — enough for
|
|
6
|
+
* responsive / touch / DPR testing without re-exposing the whole API. */
|
|
7
|
+
export interface DeviceConfig {
|
|
8
|
+
viewport?: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
deviceScaleFactor?: number;
|
|
13
|
+
isMobile?: boolean;
|
|
14
|
+
hasTouch?: boolean;
|
|
15
|
+
userAgent?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SessionOptions {
|
|
18
|
+
headless?: boolean;
|
|
19
|
+
/** BYOB only: `http://127.0.0.1:9222` etc. Loopback enforced. */
|
|
20
|
+
attachCdp?: string;
|
|
21
|
+
/** Workspace-rooted profile dir (managed only). */
|
|
22
|
+
profileDir?: string;
|
|
23
|
+
/** device/viewport emulation, applied at context creation. */
|
|
24
|
+
device?: DeviceConfig;
|
|
25
|
+
/** launch with `--disable-web-security --disable-site-isolation-trials`
|
|
26
|
+
* (SOP/CORS OFF browser-wide). managed/incognito only; loud-warned. */
|
|
27
|
+
disableWebSecurity?: boolean;
|
|
28
|
+
/** Seed the new context's storage state at creation. Honoured by
|
|
29
|
+
* **incognito** mode (where `browser.newContext({storageState})` is the
|
|
30
|
+
* native primitive). For **persistent** (managed) mode the context's
|
|
31
|
+
* state is on disk in the profile dir — the storageState is applied
|
|
32
|
+
* post-create via `context.setStorageState`, which CLEARS the profile's
|
|
33
|
+
* existing cookies / localStorage first. For BYOB/attached the value is
|
|
34
|
+
* ignored (not-owned: we don't mutate the consumer's Chrome). */
|
|
35
|
+
storageState?: import("./storage.js").StorageStateBlob;
|
|
36
|
+
/** Enable HAR recording at context creation via Playwright's native
|
|
37
|
+
* `recordHar` context option. Honoured by managed + incognito (we own the
|
|
38
|
+
* context); ignored on BYOB/attached (not-owned). The HAR is finalized by
|
|
39
|
+
* Playwright when the context closes. The path is workspace-rooted by
|
|
40
|
+
* construction (resolved upstream). */
|
|
41
|
+
recordHar?: {
|
|
42
|
+
path: string;
|
|
43
|
+
mode?: "full" | "minimal";
|
|
44
|
+
content?: "embed" | "attach" | "omit";
|
|
45
|
+
urlFilter?: string | RegExp;
|
|
46
|
+
};
|
|
47
|
+
/** Enable video recording at context creation via Playwright's native
|
|
48
|
+
* `recordVideo` context option. Honoured by managed + incognito (we own
|
|
49
|
+
* the context); ignored on BYOB/attached (not-owned). The .webm is
|
|
50
|
+
* finalized by Playwright when the context closes — the registry's
|
|
51
|
+
* teardown calls `page.video().saveAs(targetPath)` for a deterministic
|
|
52
|
+
* output filename. The `dir` is workspace-rooted by construction
|
|
53
|
+
* (resolved upstream — Playwright auto-names the file inside). */
|
|
54
|
+
recordVideo?: {
|
|
55
|
+
dir: string;
|
|
56
|
+
size?: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/** Absolute filesystem paths to unpacked Chromium extension directories
|
|
62
|
+
* (each containing `manifest.json`). Honoured by **persistent (managed)**
|
|
63
|
+
* launches in **headed** mode only — chromium's `--load-extension` +
|
|
64
|
+
* `--disable-extensions-except` flags are emitted from this list. Empty /
|
|
65
|
+
* unset → no extension flags. Path safety (workspace-rooted) is enforced
|
|
66
|
+
* at the tool layer (`extensions_install`); this option is the trusted
|
|
67
|
+
* internal pipe. Refused on incognito / attached at the tool layer. */
|
|
68
|
+
extensionPaths?: readonly string[];
|
|
69
|
+
/** Which browser engine to launch. Defaults to `"chromium"` everywhere — the
|
|
70
|
+
* default makes every launch byte-identical to the pre-seam behavior.
|
|
71
|
+
* chromium, firefox, webkit, and android are all implemented (each via its
|
|
72
|
+
* adapter); a future-declared engine without an adapter throws
|
|
73
|
+
* `engine-not-yet-supported` at the launch path (see src/engine/). `android`
|
|
74
|
+
* is attach-only (real Chrome-on-Android over adb + CDP) — managed/ephemeral
|
|
75
|
+
* launch refuses with `android-launch-not-supported`. */
|
|
76
|
+
browserType?: EngineKind;
|
|
77
|
+
/** The launch mode the EngineRegistry's `makeAdapter` builds for. The three
|
|
78
|
+
* session factories (managed / incognito / byob) thread this through so the
|
|
79
|
+
* per-engine launch/attach branching collapses into one registry lookup —
|
|
80
|
+
* the factory keeps the MODE concern (option-building), the engine entry owns
|
|
81
|
+
* the per-engine launch. Defaults to `"managed"` (a bare `makeAdapter(opts)`
|
|
82
|
+
* with no `launchMode` is the managed launch, matching the 0004-03 §1 safari
|
|
83
|
+
* example). Internal: never set from the wire — `open_session` carries
|
|
84
|
+
* `mode`, which the factory maps to this. */
|
|
85
|
+
launchMode?: "managed" | "incognito" | "byob";
|
|
86
|
+
}
|
|
87
|
+
export interface BrowserSession {
|
|
88
|
+
readonly mode: SessionMode;
|
|
89
|
+
readonly ownsBrowser: boolean;
|
|
90
|
+
/** The engine backing this session. Always `"chromium"` today. */
|
|
91
|
+
readonly engine: EngineKind;
|
|
92
|
+
page(): Page;
|
|
93
|
+
/** Raw CDP handle. Optional: present + fully functional on chromium (the only
|
|
94
|
+
* engine wired today), absent on engines without a CDP escape hatch. This is
|
|
95
|
+
* the one mandatory interface member that used to hard-gate multi-engine.
|
|
96
|
+
* Consumers that need the handle route through `requireCdp()` (src/engine/),
|
|
97
|
+
* which asserts presence with a structured, engine-naming error. */
|
|
98
|
+
cdp?(): CDPSession;
|
|
99
|
+
/** The Safari-native handle — present ONLY on the `safari` engine, the first
|
|
100
|
+
* engine with no Playwright `Page`. On a Safari session,
|
|
101
|
+
* `page()` THROWS (`safari-no-playwright-page`); consumers that can run on
|
|
102
|
+
* Safari (snapshot/find/navigate/screenshot/cookies via this handle's
|
|
103
|
+
* WebDriver Classic + BiDi clients) route through `safari()` instead, and the
|
|
104
|
+
* capability gate refuses the rest up front. Absent on every other engine. */
|
|
105
|
+
safari?(): SafariSessionHandle;
|
|
106
|
+
close(): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
export interface SessionInternals {
|
|
109
|
+
browser?: Browser;
|
|
110
|
+
context: BrowserContext;
|
|
111
|
+
page: Page;
|
|
112
|
+
cdp: CDPSession;
|
|
113
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// BrowserSession is the lifecycle abstraction the rest of the server uses.
|
|
2
|
+
// Two implementations: managed.ts (we launch the browser, we own its lifecycle)
|
|
3
|
+
// and byob.ts (we attach to an externally-launched Chrome via CDP; not-owned —
|
|
4
|
+
// no close, no storage reset on shutdown).
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const WEDGE_THRESHOLD = 3;
|
|
2
|
+
export declare class WedgeTracker {
|
|
3
|
+
private consecutive;
|
|
4
|
+
/** A call against this session hit the anti-wedge deadline. */
|
|
5
|
+
recordTimeout(): void;
|
|
6
|
+
/** A call against this session returned responsively (a success, or a fast
|
|
7
|
+
* non-timeout error). The session answered — clear the streak. */
|
|
8
|
+
recordResponsive(): void;
|
|
9
|
+
/** Consecutive anti-wedge timeouts seen so far. */
|
|
10
|
+
get count(): number;
|
|
11
|
+
/** True once the session has timed out WEDGE_THRESHOLD times in a row. */
|
|
12
|
+
wedged(): boolean;
|
|
13
|
+
/** Agent-facing recovery hint for a wedged session. */
|
|
14
|
+
hint(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Per-session wedge detector.
|
|
2
|
+
//
|
|
3
|
+
// The anti-wedge deadline (see util/deadline.ts) makes every individual call
|
|
4
|
+
// return within its budget — but an agent driving a wedged session sees only
|
|
5
|
+
// a stream of separate `ok:false` timeouts and must *infer* that the whole
|
|
6
|
+
// session is dead. In practice agents miss that inference and retry the dead
|
|
7
|
+
// session for a long time. This converts the inference into a server-provided
|
|
8
|
+
// signal: after WEDGE_THRESHOLD consecutive anti-wedge deadline-timeouts on a
|
|
9
|
+
// session, results carry `sessionWedged: true` + a discard-and-reopen hint.
|
|
10
|
+
// Any responsive call (a success, or a fast non-timeout error) clears the
|
|
11
|
+
// streak — a responsive call proves the session is still alive.
|
|
12
|
+
export const WEDGE_THRESHOLD = 3;
|
|
13
|
+
export class WedgeTracker {
|
|
14
|
+
consecutive = 0;
|
|
15
|
+
/** A call against this session hit the anti-wedge deadline. */
|
|
16
|
+
recordTimeout() {
|
|
17
|
+
this.consecutive += 1;
|
|
18
|
+
}
|
|
19
|
+
/** A call against this session returned responsively (a success, or a fast
|
|
20
|
+
* non-timeout error). The session answered — clear the streak. */
|
|
21
|
+
recordResponsive() {
|
|
22
|
+
this.consecutive = 0;
|
|
23
|
+
}
|
|
24
|
+
/** Consecutive anti-wedge timeouts seen so far. */
|
|
25
|
+
get count() {
|
|
26
|
+
return this.consecutive;
|
|
27
|
+
}
|
|
28
|
+
/** True once the session has timed out WEDGE_THRESHOLD times in a row. */
|
|
29
|
+
wedged() {
|
|
30
|
+
return this.consecutive >= WEDGE_THRESHOLD;
|
|
31
|
+
}
|
|
32
|
+
/** Agent-facing recovery hint for a wedged session. */
|
|
33
|
+
hint() {
|
|
34
|
+
return (`${this.consecutive} consecutive anti-wedge timeouts on this session — ` +
|
|
35
|
+
`it is wedged. STOP retrying it: raising \`timeoutMs\` or re-navigating ` +
|
|
36
|
+
`in place will NOT recover a wedged session. Discard it with ` +
|
|
37
|
+
`\`close_session\`, then \`open_session\` (or any call on a fresh id) ` +
|
|
38
|
+
`to get a clean session. Page state in the wedged session is lost — ` +
|
|
39
|
+
`restart that work in the new session.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ActionToolHost } from "./action-tool.js";
|
|
2
|
+
import type { ConfigHost, ServerServicesHost } from "./host.js";
|
|
3
|
+
/**
|
|
4
|
+
* Core action verbs: navigate / click / fill / press / shortcut. Split out of
|
|
5
|
+
* `action-tools` by cohesive family (RFC 0004 P3 / D3 SRP); registered through
|
|
6
|
+
* the shared `ToolHost` seam in the same source order. `click` and `fill` are the
|
|
7
|
+
* canonical confirm-gated target-resolving handlers, so they ride the `actionTool`
|
|
8
|
+
* wrapper (RFC 0004 P3 / D4) — byte-identical to the prior hand-written body.
|
|
9
|
+
* navigate (confirmNavigation), press (optional target), and shortcut (try/catch
|
|
10
|
+
* over runShortcut) keep their own bodies — their shapes differ from the canonical
|
|
11
|
+
* pipeline.
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerActionCoreTools(host: ActionToolHost & ConfigHost & ServerServicesHost): void;
|