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,99 @@
|
|
|
1
|
+
import type { DispatchedAction } from "./actionresult.js";
|
|
2
|
+
import type { NetworkEntry, NetworkSummary, MutationEntry, WsFrame } from "./network.js";
|
|
3
|
+
import type { DialogRecord } from "../session/dialog.js";
|
|
4
|
+
import type { PermissionRecord } from "../session/permission.js";
|
|
5
|
+
import type { NotificationRecord } from "../session/notification.js";
|
|
6
|
+
import type { FsPickerRecord } from "../session/fs-picker.js";
|
|
7
|
+
import type { CapturedDownload } from "./downloads.js";
|
|
8
|
+
/** The mutable action outcome a `raise`-policy slice can flip. */
|
|
9
|
+
export interface ActionOutcome {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
error: string | undefined;
|
|
12
|
+
failure: import("../util/failure.js").FailureClass | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** If a policy fired in `raise` mode during the window and the action otherwise
|
|
15
|
+
* succeeded, flip it to a clean ok:false with the policy's stable hint. The
|
|
16
|
+
* page was handled server-side (not deadlocked), but the app saw the
|
|
17
|
+
* cancel/deny branch and the caller almost certainly didn't want that.
|
|
18
|
+
* Returns the (possibly) updated outcome; first raise wins (mirrors the prior
|
|
19
|
+
* inline order: dialog → permission → notification → fs-picker). */
|
|
20
|
+
export declare function applyPolicyRaise(outcome: ActionOutcome, raised: boolean, hint: string): ActionOutcome;
|
|
21
|
+
export declare function buildDialogsBlock(slice: DialogRecord[]): Omit<DialogRecord, "ts">[] | undefined;
|
|
22
|
+
export interface PermissionRequestBlock {
|
|
23
|
+
permission: PermissionRecord["permission"];
|
|
24
|
+
origin?: string;
|
|
25
|
+
handledAs: PermissionRecord["handledAs"];
|
|
26
|
+
}
|
|
27
|
+
export declare function buildPermissionRequestsBlock(slice: PermissionRecord[]): PermissionRequestBlock[] | undefined;
|
|
28
|
+
export interface NotificationBlock {
|
|
29
|
+
title: string;
|
|
30
|
+
body?: string;
|
|
31
|
+
icon?: string;
|
|
32
|
+
tag?: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
origin?: string;
|
|
35
|
+
handledAs: NotificationRecord["handledAs"];
|
|
36
|
+
}
|
|
37
|
+
export declare function buildNotificationsBlock(slice: NotificationRecord[]): NotificationBlock[] | undefined;
|
|
38
|
+
export interface FsPickerRequestBlock {
|
|
39
|
+
api: FsPickerRecord["api"];
|
|
40
|
+
suggestedName?: string;
|
|
41
|
+
handledAs: FsPickerRecord["handledAs"];
|
|
42
|
+
}
|
|
43
|
+
export declare function buildFsPickerRequestsBlock(slice: FsPickerRecord[]): FsPickerRequestBlock[] | undefined;
|
|
44
|
+
export interface DownloadBlock {
|
|
45
|
+
id: string;
|
|
46
|
+
suggestedFilename: string;
|
|
47
|
+
rawSuggestedFilename?: string;
|
|
48
|
+
mimeType?: string;
|
|
49
|
+
sizeBytes: number;
|
|
50
|
+
path: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function buildDownloadsBlock(slice: CapturedDownload[]): DownloadBlock[] | undefined;
|
|
53
|
+
export interface NetworkCloseResult {
|
|
54
|
+
summary: NetworkSummary;
|
|
55
|
+
requests: NetworkEntry[];
|
|
56
|
+
mutations: MutationEntry[];
|
|
57
|
+
}
|
|
58
|
+
export interface NetworkBlock {
|
|
59
|
+
summary: NetworkSummary;
|
|
60
|
+
requests?: NetworkEntry[];
|
|
61
|
+
egressOffAllowlist?: number;
|
|
62
|
+
mutations?: MutationEntry[];
|
|
63
|
+
wsFrames?: WsFrame[];
|
|
64
|
+
}
|
|
65
|
+
/** Build the `network` result block. Within the per-request cap the full
|
|
66
|
+
* request rows ride along; over the cap they're omitted with a warning
|
|
67
|
+
* pointing at `network_read`. Mutations + WS frames attach when present. */
|
|
68
|
+
export declare function buildNetworkBlock(network: NetworkCloseResult, wsSlice: WsFrame[], egressOffAllowlist: number, requestCap: number, warnings: string[]): NetworkBlock;
|
|
69
|
+
/** The five optional capture blocks, each present only when its slice was
|
|
70
|
+
* non-empty. Collected once so the orchestrator spreads a single object into
|
|
71
|
+
* both the token estimate and the final result (the prior code repeated ten
|
|
72
|
+
* `...(x ? {key:x} : {})` ternaries). */
|
|
73
|
+
export interface OptionalBlocks {
|
|
74
|
+
dialogs?: Omit<DialogRecord, "ts">[];
|
|
75
|
+
permissionRequests?: PermissionRequestBlock[];
|
|
76
|
+
notifications?: NotificationBlock[];
|
|
77
|
+
fsPickerRequests?: FsPickerRequestBlock[];
|
|
78
|
+
downloads?: DownloadBlock[];
|
|
79
|
+
}
|
|
80
|
+
export declare function assembleOptionalBlocks(parts: {
|
|
81
|
+
dialogs: Omit<DialogRecord, "ts">[] | undefined;
|
|
82
|
+
permissionRequests: PermissionRequestBlock[] | undefined;
|
|
83
|
+
notifications: NotificationBlock[] | undefined;
|
|
84
|
+
fsPickerRequests: FsPickerRequestBlock[] | undefined;
|
|
85
|
+
downloads: DownloadBlock[] | undefined;
|
|
86
|
+
}): OptionalBlocks;
|
|
87
|
+
export interface RecordableStep {
|
|
88
|
+
descriptor: DispatchedAction;
|
|
89
|
+
urlAfter: string;
|
|
90
|
+
recordingHint: {
|
|
91
|
+
selectorHint: string;
|
|
92
|
+
stability?: "high" | "medium" | "low";
|
|
93
|
+
} | undefined;
|
|
94
|
+
}
|
|
95
|
+
/** Append the action to an active recording when it is replayable as a
|
|
96
|
+
* flow-file step. Coord-mode click/hover (no ref/selector/hint) are an escape
|
|
97
|
+
* hatch flow files can't mechanically replay, so they're skipped with a
|
|
98
|
+
* warning. Navigation/history actions need no target and are always recorded. */
|
|
99
|
+
export declare function maybeRecord(recorder: import("./recording.js").Recorder | undefined, ok: boolean, step: RecordableStep, warnings: string[]): void;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// ActionResult post-state block builders — the pure shaping helpers that
|
|
2
|
+
// `runInActionWindow` (actionresult.ts) composes after the action window closes.
|
|
3
|
+
// Each function maps one captured slice into its public result block; pulling
|
|
4
|
+
// them out keeps the orchestrator under the size/complexity budget without
|
|
5
|
+
// changing any output shape (the blocks are byte-identical to the inline
|
|
6
|
+
// versions). No page contact — every input is already-captured data.
|
|
7
|
+
/** If a policy fired in `raise` mode during the window and the action otherwise
|
|
8
|
+
* succeeded, flip it to a clean ok:false with the policy's stable hint. The
|
|
9
|
+
* page was handled server-side (not deadlocked), but the app saw the
|
|
10
|
+
* cancel/deny branch and the caller almost certainly didn't want that.
|
|
11
|
+
* Returns the (possibly) updated outcome; first raise wins (mirrors the prior
|
|
12
|
+
* inline order: dialog → permission → notification → fs-picker). */
|
|
13
|
+
export function applyPolicyRaise(outcome, raised, hint) {
|
|
14
|
+
if (!raised || !outcome.ok)
|
|
15
|
+
return outcome;
|
|
16
|
+
return { ok: false, error: outcome.error ?? hint, failure: { source: "app", hint } };
|
|
17
|
+
}
|
|
18
|
+
export function buildDialogsBlock(slice) {
|
|
19
|
+
if (slice.length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
return slice.map((d) => {
|
|
22
|
+
const { ts: _ts, ...pub } = d;
|
|
23
|
+
return pub;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function buildPermissionRequestsBlock(slice) {
|
|
27
|
+
if (slice.length === 0)
|
|
28
|
+
return undefined;
|
|
29
|
+
return slice.map((r) => {
|
|
30
|
+
const out = { permission: r.permission, handledAs: r.handledAs };
|
|
31
|
+
if (r.origin !== undefined)
|
|
32
|
+
out.origin = r.origin;
|
|
33
|
+
return out;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function buildNotificationsBlock(slice) {
|
|
37
|
+
if (slice.length === 0)
|
|
38
|
+
return undefined;
|
|
39
|
+
return slice.map((n) => {
|
|
40
|
+
const out = {
|
|
41
|
+
title: n.title,
|
|
42
|
+
timestamp: n.timestamp,
|
|
43
|
+
handledAs: n.handledAs,
|
|
44
|
+
};
|
|
45
|
+
if (n.body !== undefined)
|
|
46
|
+
out.body = n.body;
|
|
47
|
+
if (n.icon !== undefined)
|
|
48
|
+
out.icon = n.icon;
|
|
49
|
+
if (n.tag !== undefined)
|
|
50
|
+
out.tag = n.tag;
|
|
51
|
+
if (n.origin !== undefined)
|
|
52
|
+
out.origin = n.origin;
|
|
53
|
+
return out;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function buildFsPickerRequestsBlock(slice) {
|
|
57
|
+
if (slice.length === 0)
|
|
58
|
+
return undefined;
|
|
59
|
+
return slice.map((r) => {
|
|
60
|
+
const out = { api: r.api, handledAs: r.handledAs };
|
|
61
|
+
if (r.suggestedName !== undefined)
|
|
62
|
+
out.suggestedName = r.suggestedName;
|
|
63
|
+
return out;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function buildDownloadsBlock(slice) {
|
|
67
|
+
if (slice.length === 0)
|
|
68
|
+
return undefined;
|
|
69
|
+
return slice.map((d) => {
|
|
70
|
+
const out = {
|
|
71
|
+
id: d.id,
|
|
72
|
+
suggestedFilename: d.suggestedFilename,
|
|
73
|
+
sizeBytes: d.sizeBytes,
|
|
74
|
+
path: d.path,
|
|
75
|
+
};
|
|
76
|
+
if (d.rawSuggestedFilename !== undefined)
|
|
77
|
+
out.rawSuggestedFilename = d.rawSuggestedFilename;
|
|
78
|
+
if (d.mimeType !== undefined)
|
|
79
|
+
out.mimeType = d.mimeType;
|
|
80
|
+
return out;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Build the `network` result block. Within the per-request cap the full
|
|
84
|
+
* request rows ride along; over the cap they're omitted with a warning
|
|
85
|
+
* pointing at `network_read`. Mutations + WS frames attach when present. */
|
|
86
|
+
export function buildNetworkBlock(network, wsSlice, egressOffAllowlist, requestCap, warnings) {
|
|
87
|
+
const mutationsBlock = network.mutations.length > 0 ? { mutations: network.mutations } : {};
|
|
88
|
+
const wsBlock = wsSlice.length > 0 ? { wsFrames: wsSlice } : {};
|
|
89
|
+
if (network.summary.total === 0) {
|
|
90
|
+
return { summary: network.summary, ...mutationsBlock, ...wsBlock };
|
|
91
|
+
}
|
|
92
|
+
if (network.requests.length <= requestCap) {
|
|
93
|
+
return {
|
|
94
|
+
summary: network.summary,
|
|
95
|
+
requests: network.requests,
|
|
96
|
+
...(egressOffAllowlist > 0 ? { egressOffAllowlist } : {}),
|
|
97
|
+
...mutationsBlock,
|
|
98
|
+
...wsBlock,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
warnings.push(`network.requests omitted (count ${network.requests.length} > cap ${requestCap}); call network_read for details`);
|
|
102
|
+
return {
|
|
103
|
+
summary: network.summary,
|
|
104
|
+
...(egressOffAllowlist > 0 ? { egressOffAllowlist } : {}),
|
|
105
|
+
...mutationsBlock,
|
|
106
|
+
...wsBlock,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export function assembleOptionalBlocks(parts) {
|
|
110
|
+
const out = {};
|
|
111
|
+
if (parts.dialogs)
|
|
112
|
+
out.dialogs = parts.dialogs;
|
|
113
|
+
if (parts.permissionRequests)
|
|
114
|
+
out.permissionRequests = parts.permissionRequests;
|
|
115
|
+
if (parts.notifications)
|
|
116
|
+
out.notifications = parts.notifications;
|
|
117
|
+
if (parts.fsPickerRequests)
|
|
118
|
+
out.fsPickerRequests = parts.fsPickerRequests;
|
|
119
|
+
if (parts.downloads)
|
|
120
|
+
out.downloads = parts.downloads;
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
const NON_TARGETED_ACTIONS = new Set(["navigate", "goBack", "goForward"]);
|
|
124
|
+
/** Append the action to an active recording when it is replayable as a
|
|
125
|
+
* flow-file step. Coord-mode click/hover (no ref/selector/hint) are an escape
|
|
126
|
+
* hatch flow files can't mechanically replay, so they're skipped with a
|
|
127
|
+
* warning. Navigation/history actions need no target and are always recorded. */
|
|
128
|
+
export function maybeRecord(recorder, ok, step, warnings) {
|
|
129
|
+
if (!ok || !recorder?.active())
|
|
130
|
+
return;
|
|
131
|
+
const { descriptor, urlAfter, recordingHint } = step;
|
|
132
|
+
const isElementAction = !NON_TARGETED_ACTIONS.has(descriptor.type);
|
|
133
|
+
const hasReplayableTarget = !!(descriptor.ref || descriptor.selector || recordingHint);
|
|
134
|
+
if (!isElementAction || hasReplayableTarget) {
|
|
135
|
+
try {
|
|
136
|
+
recorder.record(descriptor, urlAfter, recordingHint);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
/* swallow */
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
warnings.push("recorder: skipped untargeted action (coords-mode click/hover) — flow files replay deterministically by ref/selector; record the equivalent ref-based action if you want this step in the draft");
|
|
144
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type A11yNode } from "./a11y.js";
|
|
2
|
+
/** A page-level landmark region (dialog / alert / banner / …) tracked across the
|
|
3
|
+
* action window to diff appeared/removed structure. */
|
|
4
|
+
export type Region = {
|
|
5
|
+
role: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
ref: string;
|
|
8
|
+
};
|
|
9
|
+
export type SnapshotMode = "scoped_snapshot" | "tree_diff" | "full" | "none";
|
|
10
|
+
export interface NavigationInfo {
|
|
11
|
+
changed: boolean;
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
kind: "hash" | "full_load" | "spa" | null;
|
|
15
|
+
}
|
|
16
|
+
export interface SnapshotDeltaInfo {
|
|
17
|
+
mode: SnapshotMode;
|
|
18
|
+
scope: string;
|
|
19
|
+
tree?: string;
|
|
20
|
+
truncated: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface RegionDiff {
|
|
23
|
+
appeared: Region[];
|
|
24
|
+
removed: Region[];
|
|
25
|
+
newTabs: Array<{
|
|
26
|
+
url: string;
|
|
27
|
+
title: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare function topLevelRegions(tree: A11yNode): Map<string, Region>;
|
|
31
|
+
export declare function diffRegions(pre: Map<string, Region>, post: Map<string, Region>): RegionDiff;
|
|
32
|
+
export declare function describeNavigation(from: string, to: string, frameNavigated: boolean): NavigationInfo;
|
|
33
|
+
export declare function buildSnapshotDelta(mode: SnapshotMode, tree: A11yNode | null, maxTokens: number, warnings: string[],
|
|
34
|
+
/** refs to scope the delta to (action's ref + appeared regions).
|
|
35
|
+
* When empty + mode=scoped_snapshot, falls back to the full tree as before. */
|
|
36
|
+
scopeRefs?: string[]): SnapshotDeltaInfo | undefined;
|
|
37
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
38
|
+
export interface ConsoleSlice {
|
|
39
|
+
errors: string[];
|
|
40
|
+
warnings: number;
|
|
41
|
+
truncated_chars?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Inline summary of console errors — collapse multi-line stack-traces to their
|
|
44
|
+
* first line + a token-budget per error, and emit `truncated_chars` if any were
|
|
45
|
+
* trimmed. The full text is still in the session's `ConsoleBuffer`; an agent who
|
|
46
|
+
* needs it calls `console_read`. Pattern mirrors the existing
|
|
47
|
+
* `network.requests omitted (count N > cap)` design. */
|
|
48
|
+
export declare function summariseConsoleErrors(errors: string[], warnings: string[]): ConsoleSlice;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// ActionResult shape helpers — the pure tree/navigation/console shaping the
|
|
2
|
+
// action window composes. Split out of actionresult.ts to keep that file under
|
|
3
|
+
// the size budget; every function is behavior-identical to its prior inline form
|
|
4
|
+
// (no page contact, deterministic over already-captured inputs).
|
|
5
|
+
import { walk } from "./a11y.js";
|
|
6
|
+
import { findByRef, serialise } from "./snapshot.js";
|
|
7
|
+
import { truncateToBudget } from "../util/tokens.js";
|
|
8
|
+
const INTERESTING_REGION_ROLES = new Set([
|
|
9
|
+
"dialog",
|
|
10
|
+
"alertdialog",
|
|
11
|
+
"alert",
|
|
12
|
+
"status",
|
|
13
|
+
"banner",
|
|
14
|
+
"complementary",
|
|
15
|
+
"tablist",
|
|
16
|
+
"menu",
|
|
17
|
+
"menubar",
|
|
18
|
+
"tooltip",
|
|
19
|
+
"toolbar",
|
|
20
|
+
]);
|
|
21
|
+
export function topLevelRegions(tree) {
|
|
22
|
+
// "Top-level regions" = nodes whose role indicates a page-level appearance
|
|
23
|
+
// (dialog, alert, alertdialog, status, banner, etc.) anywhere in the tree.
|
|
24
|
+
const out = new Map();
|
|
25
|
+
for (const { node } of walk(tree)) {
|
|
26
|
+
if (INTERESTING_REGION_ROLES.has(node.role)) {
|
|
27
|
+
out.set(node.ref, { role: node.role, name: node.name, ref: node.ref });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
export function diffRegions(pre, post) {
|
|
33
|
+
const appeared = [];
|
|
34
|
+
const removed = [];
|
|
35
|
+
for (const [ref, r] of post)
|
|
36
|
+
if (!pre.has(ref))
|
|
37
|
+
appeared.push(r);
|
|
38
|
+
for (const [ref, r] of pre)
|
|
39
|
+
if (!post.has(ref))
|
|
40
|
+
removed.push(r);
|
|
41
|
+
return { appeared, removed, newTabs: [] };
|
|
42
|
+
}
|
|
43
|
+
export function describeNavigation(from, to, frameNavigated) {
|
|
44
|
+
if (from === to)
|
|
45
|
+
return { changed: false, from, to, kind: null };
|
|
46
|
+
try {
|
|
47
|
+
const a = new URL(from);
|
|
48
|
+
const b = new URL(to);
|
|
49
|
+
if (a.origin === b.origin &&
|
|
50
|
+
a.pathname === b.pathname &&
|
|
51
|
+
a.search === b.search &&
|
|
52
|
+
a.hash !== b.hash) {
|
|
53
|
+
return { changed: true, from, to, kind: "hash" };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
/* invalid URL — fall through */
|
|
58
|
+
}
|
|
59
|
+
return { changed: true, from, to, kind: frameNavigated ? "full_load" : "spa" };
|
|
60
|
+
}
|
|
61
|
+
/** Serialise the scoped subtrees for the snapshotDelta, truncated to the token
|
|
62
|
+
* budget. When no scope ref resolved in the post-tree, returns a tiny
|
|
63
|
+
* scope-marker delta instead of the full tree. */
|
|
64
|
+
function serialiseScopedSubtrees(tree, scopeRefs, maxTokens, warnings) {
|
|
65
|
+
const subtrees = scopeRefs
|
|
66
|
+
.map((ref) => findByRef(tree, ref))
|
|
67
|
+
.filter((n) => n !== null);
|
|
68
|
+
if (subtrees.length === 0) {
|
|
69
|
+
// All scope refs gone — element vanished + no appeared regions. Fall through
|
|
70
|
+
// to a tiny scope marker instead of the full tree.
|
|
71
|
+
return {
|
|
72
|
+
mode: "scoped_snapshot",
|
|
73
|
+
scope: "(scope refs not present in post-tree)",
|
|
74
|
+
truncated: false,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const text = subtrees
|
|
78
|
+
.map((n, i) => (subtrees.length > 1 ? `--- subtree ${i + 1}/${subtrees.length} ---\n` : "") + serialise(n))
|
|
79
|
+
.join("\n");
|
|
80
|
+
const { text: trimmed, truncated } = truncateToBudget(text, maxTokens);
|
|
81
|
+
if (truncated)
|
|
82
|
+
warnings.push(`snapshotDelta truncated to fit maxResultTokens=${maxTokens}; call snapshot() for the complete tree`);
|
|
83
|
+
return {
|
|
84
|
+
mode: "scoped_snapshot",
|
|
85
|
+
scope: `scoped to ${subtrees.length} subtree(s) [${scopeRefs.join(", ")}]`,
|
|
86
|
+
tree: trimmed,
|
|
87
|
+
truncated,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function buildSnapshotDelta(mode, tree, maxTokens, warnings,
|
|
91
|
+
/** refs to scope the delta to (action's ref + appeared regions).
|
|
92
|
+
* When empty + mode=scoped_snapshot, falls back to the full tree as before. */
|
|
93
|
+
scopeRefs = []) {
|
|
94
|
+
if (mode === "none")
|
|
95
|
+
return undefined;
|
|
96
|
+
if (!tree)
|
|
97
|
+
return { mode, scope: "(no tree)", truncated: false };
|
|
98
|
+
let renderMode = mode;
|
|
99
|
+
if (mode === "tree_diff") {
|
|
100
|
+
// partial: emit appeared/removed-as-subtrees instead of a unified diff.
|
|
101
|
+
// Closer in spirit to Vercel agent-browser's diff than the previous fallback,
|
|
102
|
+
// without needing the line-stable cross-snapshot diff plumbing.
|
|
103
|
+
warnings.push('mode=tree_diff: emitting appeared-region subtrees only (full unified diff not yet implemented; pass mode:"full" for the post-action tree)');
|
|
104
|
+
renderMode = "scoped_snapshot";
|
|
105
|
+
}
|
|
106
|
+
if (renderMode === "scoped_snapshot" && scopeRefs.length > 0) {
|
|
107
|
+
// real scope-down. Serialise just the action's element subtree + any
|
|
108
|
+
// newly-appeared top-level regions. Drops 7-10k-token snapshots to ~500-1500
|
|
109
|
+
// on the heavy-SPA / many-elements shape.
|
|
110
|
+
return serialiseScopedSubtrees(tree, scopeRefs, maxTokens, warnings);
|
|
111
|
+
}
|
|
112
|
+
// Fall-through: full tree. Honours explicit mode:"full" and the rare case where
|
|
113
|
+
// scoped_snapshot was asked-for but we have no scope refs (no action ref, no
|
|
114
|
+
// appeared regions — uncommon).
|
|
115
|
+
const scope = renderMode === "scoped_snapshot" ? "full (no scope refs)" : "full";
|
|
116
|
+
const { text, truncated } = truncateToBudget(serialise(tree), maxTokens);
|
|
117
|
+
if (truncated)
|
|
118
|
+
warnings.push(`snapshotDelta truncated to fit maxResultTokens=${maxTokens}; call snapshot() for the complete tree`);
|
|
119
|
+
return { mode: renderMode, scope, tree: text, truncated };
|
|
120
|
+
}
|
|
121
|
+
export function sleep(ms) {
|
|
122
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
123
|
+
}
|
|
124
|
+
const ERROR_MAX_CHARS_PER = 400;
|
|
125
|
+
const ERROR_MAX_TOTAL_ENTRIES = 20;
|
|
126
|
+
/** Inline summary of console errors — collapse multi-line stack-traces to their
|
|
127
|
+
* first line + a token-budget per error, and emit `truncated_chars` if any were
|
|
128
|
+
* trimmed. The full text is still in the session's `ConsoleBuffer`; an agent who
|
|
129
|
+
* needs it calls `console_read`. Pattern mirrors the existing
|
|
130
|
+
* `network.requests omitted (count N > cap)` design. */
|
|
131
|
+
export function summariseConsoleErrors(errors, warnings) {
|
|
132
|
+
if (errors.length === 0)
|
|
133
|
+
return { errors: [], warnings: 0 };
|
|
134
|
+
let trimmed = 0;
|
|
135
|
+
const out = [];
|
|
136
|
+
const slice = errors.slice(0, ERROR_MAX_TOTAL_ENTRIES);
|
|
137
|
+
for (const e of slice) {
|
|
138
|
+
if (e.length <= ERROR_MAX_CHARS_PER && !e.includes("\n")) {
|
|
139
|
+
out.push(e);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const firstLine = e.split("\n")[0].slice(0, ERROR_MAX_CHARS_PER);
|
|
143
|
+
out.push(firstLine + " …");
|
|
144
|
+
trimmed += Math.max(0, e.length - firstLine.length);
|
|
145
|
+
}
|
|
146
|
+
if (errors.length > ERROR_MAX_TOTAL_ENTRIES) {
|
|
147
|
+
warnings.push(`console.errors truncated (showing ${ERROR_MAX_TOTAL_ENTRIES} of ${errors.length}); call console_read for the full ring buffer`);
|
|
148
|
+
}
|
|
149
|
+
const result = { errors: out, warnings: 0 };
|
|
150
|
+
if (trimmed > 0) {
|
|
151
|
+
result.truncated_chars = trimmed;
|
|
152
|
+
warnings.push(`console.errors stack-traces summarised (${trimmed} chars trimmed); call console_read for the full text`);
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|