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,50 @@
|
|
|
1
|
+
// Classify a failure as app-origin vs browxai-origin.
|
|
2
|
+
//
|
|
3
|
+
// A browxai-side context teardown/detach (another agent closed the session,
|
|
4
|
+
// an incognito context was discarded, an anti-wedge deadline fired) surfaces
|
|
5
|
+
// as a Playwright/CDP error that *looks* identical to an application
|
|
6
|
+
// navigation or renderer crash. Agents then file expensive false "CRITICAL:
|
|
7
|
+
// page crashed" defects against the app. This labels the failure so the agent
|
|
8
|
+
// can tell "the app broke" from "the tool tore the context down".
|
|
9
|
+
const BROWXAI_PATTERNS = /(target (page|context|browser).*(closed|crashed)|context (was|has been) (closed|destroyed)|execution context was destroyed|browser has been closed|session closed|page has been closed|protocol error.*(target closed|session closed)|anti-wedge|deadline exceeded|deadlineerror|invariant violated|invarianterror)/i;
|
|
10
|
+
const APP_PATTERNS = /(page crashed|renderer (crash|process gone)|net::err_|err_(connection|name_not_resolved|aborted|timed_out)|navigation (failed|to .* was interrupted)|frame was detached due to navigation)/i;
|
|
11
|
+
/** Pure; exported for unit tests. */
|
|
12
|
+
export function classifyFailure(message) {
|
|
13
|
+
const m = message || "";
|
|
14
|
+
// browxai teardown is checked first: "target closed" mid-navigation is far
|
|
15
|
+
// more often a session reap than a genuine app crash, and a false
|
|
16
|
+
// app-crash defect is the expensive mistake we're preventing.
|
|
17
|
+
if (BROWXAI_PATTERNS.test(m)) {
|
|
18
|
+
// Three browxai-origin shapes match here, each with a different recovery: a
|
|
19
|
+
// context teardown is fixed by reopening; an anti-wedge deadline must NOT be
|
|
20
|
+
// blindly retried (that is the wedged-session loop); an invariant violation
|
|
21
|
+
// (L8) is a browxai-internal contract failure — a defect to report, not a
|
|
22
|
+
// usage error, and the session itself is usually unaffected.
|
|
23
|
+
const isDeadline = /anti-wedge|deadline exceeded|deadlineerror/i.test(m);
|
|
24
|
+
const isInvariant = /invariant violated|invarianterror/i.test(m);
|
|
25
|
+
let hint;
|
|
26
|
+
if (isInvariant) {
|
|
27
|
+
hint =
|
|
28
|
+
"browxai-internal invariant violated (L8) — browxai reached a state one of its own modules guarantees cannot happen and refused with a structured error instead of returning a wrong answer. NOT an application crash and NOT a usage error: this indicates a bug in browxai. The session is usually unaffected — retry once; if it recurs, capture the message and file it as a browxai defect.";
|
|
29
|
+
}
|
|
30
|
+
else if (isDeadline) {
|
|
31
|
+
hint =
|
|
32
|
+
"anti-wedge deadline fired — browxai returned instead of stalling on a wedged page op. NOT an application crash; do not file an app-crash defect. Retry the call ONCE; if timeouts keep recurring on this session it is wedged — discard it (`close_session`) and `open_session` a fresh one. A bigger `timeoutMs` will not recover a wedged session.";
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
hint =
|
|
36
|
+
"browxai-side context teardown/detach (session closed by another agent, or an incognito context discarded) — NOT an application crash. Re-open the session and retry; do not file an app-crash defect.";
|
|
37
|
+
}
|
|
38
|
+
return { source: "browxai", hint };
|
|
39
|
+
}
|
|
40
|
+
if (APP_PATTERNS.test(m)) {
|
|
41
|
+
return {
|
|
42
|
+
source: "app",
|
|
43
|
+
hint: "application-origin failure (navigation/renderer). This one is a real app signal — safe to investigate as a defect.",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
source: "unknown",
|
|
48
|
+
hint: "origin indeterminate — confirm the session is still open (list_sessions) before treating this as an app defect.",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type BatchCall, type BatchOptions, type BatchReport, type BatchEntry } from "./batch.js";
|
|
2
|
+
import type { ActionDescriptor, PlanEvidence } from "../page/plan.js";
|
|
3
|
+
export interface FlakeCheckOptions extends BatchOptions {
|
|
4
|
+
/** How many times to run the same call sequence. Bounded by the caller
|
|
5
|
+
* schema (3..20) — the impl tolerates anything ≥1 so unit tests stay
|
|
6
|
+
* lightweight, but the MCP surface enforces the documented range. */
|
|
7
|
+
n: number;
|
|
8
|
+
/** Short-circuit when `stopOnAllGreen` consecutive runs all-pass. Off by
|
|
9
|
+
* default — set to a number to opt in. */
|
|
10
|
+
stopOnAllGreen?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Per-step roll-up across all completed runs. */
|
|
13
|
+
export interface StepStats {
|
|
14
|
+
/** Step index (0-based; matches the `calls[]` argument order). */
|
|
15
|
+
step: number;
|
|
16
|
+
/** Tool name (echoed for cross-reference; same as `calls[step].tool`). */
|
|
17
|
+
tool: string;
|
|
18
|
+
/** Echo of the call's label when supplied. */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Number of runs that reached this step. (When `runBatch` halts early on
|
|
21
|
+
* a failure earlier in the sequence, later steps never run — their `runs`
|
|
22
|
+
* count drops below `n`.) */
|
|
23
|
+
runs: number;
|
|
24
|
+
/** Number of those reaching-this-step runs where the step succeeded. */
|
|
25
|
+
ok: number;
|
|
26
|
+
/** `ok / runs` — null when the step was never reached. */
|
|
27
|
+
successRate: number | null;
|
|
28
|
+
/** Distinct error messages observed (deduped, capped at 8 entries for
|
|
29
|
+
* result-size sanity — anything noisier is itself the finding). */
|
|
30
|
+
errors: string[];
|
|
31
|
+
/** Distinct resolution signatures observed (`<ref>::<selectorHint>` for
|
|
32
|
+
* plan/find, or `target:<ref|selector|named>` for bound calls). One entry
|
|
33
|
+
* means the step landed identically across every run that reached it. */
|
|
34
|
+
signatures: string[];
|
|
35
|
+
}
|
|
36
|
+
/** A `{step → cached resolver}` entry — the self-heal artifact. Shape mirrors
|
|
37
|
+
* the `ActionDescriptor` returned by `plan()` so a downstream caller can hand
|
|
38
|
+
* it to `execute()` directly (after re-snapshotting to refresh the ref). */
|
|
39
|
+
export interface CachedResolver {
|
|
40
|
+
step: number;
|
|
41
|
+
tool: string;
|
|
42
|
+
label?: string;
|
|
43
|
+
/** The resolved ref the step landed on (from plan/find result). */
|
|
44
|
+
ref?: string;
|
|
45
|
+
/** The `selectorHint` captured at plan/find time — what a downstream
|
|
46
|
+
* Playwright export would write. */
|
|
47
|
+
selectorHint?: string;
|
|
48
|
+
/** Carried only when the source step was a `plan` call — re-usable by a
|
|
49
|
+
* follow-up `execute` against a fresh snapshot. Note: `expiresAt` is
|
|
50
|
+
* echoed from the source run; the consumer is expected to re-plan if it's
|
|
51
|
+
* in the past. */
|
|
52
|
+
descriptor?: Pick<ActionDescriptor, "ref" | "verb" | "args"> & {
|
|
53
|
+
/** Carried for evidence-trail purposes only — caller should not trust
|
|
54
|
+
* the `score` / `actionable` fields if it intends to re-execute later. */
|
|
55
|
+
evidence?: Pick<PlanEvidence, "selectorHint" | "selectorTier" | "stability" | "role" | "name" | "testId">;
|
|
56
|
+
};
|
|
57
|
+
/** How many of the reaching-this-step runs agreed on this resolver. The
|
|
58
|
+
* caller's read of `runs == n` + `agreedRuns == runs` is the "100% green"
|
|
59
|
+
* case where this cache is safe to replay. */
|
|
60
|
+
agreedRuns: number;
|
|
61
|
+
}
|
|
62
|
+
export interface FlakeCheckReport {
|
|
63
|
+
/** Number of inner-batch runs actually performed (may be < n when
|
|
64
|
+
* `stopOnAllGreen` short-circuited). */
|
|
65
|
+
runsCompleted: number;
|
|
66
|
+
/** True when every completed run passed every step. */
|
|
67
|
+
allGreen: boolean;
|
|
68
|
+
/** When `stopOnAllGreen` short-circuited, the count of consecutive all-green
|
|
69
|
+
* runs that triggered the break. Absent otherwise. */
|
|
70
|
+
shortCircuitedAfter?: number;
|
|
71
|
+
/** Per-step roll-up. Indexed by call-array position. */
|
|
72
|
+
steps: StepStats[];
|
|
73
|
+
/** Earliest step (0-based) where `ok` differed across the completed runs,
|
|
74
|
+
* or null when every run agreed on every step's pass/fail (whether that
|
|
75
|
+
* was all-green or all-red — agreement IS the finding). */
|
|
76
|
+
firstDivergence: {
|
|
77
|
+
step: number;
|
|
78
|
+
tool: string;
|
|
79
|
+
label?: string;
|
|
80
|
+
} | null;
|
|
81
|
+
/** Cached resolvers for steps where every reaching-this-step run agreed on
|
|
82
|
+
* the resolution signature AND succeeded. Replay-safe in that strict
|
|
83
|
+
* sense — not a free pass past a `descriptor expired`. */
|
|
84
|
+
cachedResolvers: CachedResolver[];
|
|
85
|
+
/** Echo of the per-run BatchReports so the caller can drill in. Order is
|
|
86
|
+
* chronological. */
|
|
87
|
+
runs: BatchReport[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run `calls` repeatedly through `runBatch` and roll up variance + cached
|
|
91
|
+
* resolvers. Always runs the inner batch with `stopOnError:false` so the
|
|
92
|
+
* variance picture survives a mid-sequence failure (the whole point — knowing
|
|
93
|
+
* step 4 sometimes fails AND that step 5 then also fails differently).
|
|
94
|
+
*/
|
|
95
|
+
export declare function runFlakeCheck(calls: BatchCall[], opts: FlakeCheckOptions): Promise<FlakeCheckReport>;
|
|
96
|
+
/** Pure; exported for unit tests. Walks every run's results and produces a
|
|
97
|
+
* per-step StepStats record. */
|
|
98
|
+
export declare function rollUpSteps(calls: BatchCall[], runs: BatchReport[]): StepStats[];
|
|
99
|
+
/** Pure; exported for tests. Smallest step index where `ok` differed across
|
|
100
|
+
* the runs that reached that step. */
|
|
101
|
+
export declare function findFirstDivergence(calls: BatchCall[], runs: BatchReport[]): FlakeCheckReport["firstDivergence"];
|
|
102
|
+
/** Pure; exported for tests. Builds the self-heal cache for steps where every
|
|
103
|
+
* reaching-this-step run agreed on the resolution signature AND succeeded.
|
|
104
|
+
* Steps with no extractable resolver (no ref/selectorHint payload + no bound
|
|
105
|
+
* target) yield no entry. */
|
|
106
|
+
export declare function extractCachedResolvers(calls: BatchCall[], runs: BatchReport[], steps: StepStats[]): CachedResolver[];
|
|
107
|
+
/** Pure; exported for tests. Computes a per-step resolution signature from
|
|
108
|
+
* the inner call + its result entry. */
|
|
109
|
+
export declare function signatureFor(call: BatchCall, entry: BatchEntry): string;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// Flake-check — run the same `batch` payload N times and report what shifted
|
|
2
|
+
// between runs. Composes existing primitives (no parallel dispatcher, no
|
|
3
|
+
// parallel action surface): `runBatch` is the inner runner; the cached-selector
|
|
4
|
+
// artifact uses the `ActionDescriptor` shape already shipped with `plan`/
|
|
5
|
+
// `execute`. Diagnoses AND fixes — green runs produce a `{step → resolved
|
|
6
|
+
// ref/selectorHint}` map a follow-up run can replay against (the Stagehand
|
|
7
|
+
// self-heal trick).
|
|
8
|
+
//
|
|
9
|
+
// Determining "the step landed identically" — judgment captured here so the
|
|
10
|
+
// next reader doesn't have to reconstruct it:
|
|
11
|
+
//
|
|
12
|
+
// 1. Strict resolution-signature match. Where the inner tool's result carries
|
|
13
|
+
// a resolution payload — `plan` returns a descriptor with `ref` +
|
|
14
|
+
// `evidence.selectorHint`; `find` returns a candidate list with `ref` +
|
|
15
|
+
// `selectorHint` — we use `<ref>::<selectorHint>` as the signature.
|
|
16
|
+
// Identical only when every green run produced the same pair.
|
|
17
|
+
//
|
|
18
|
+
// 2. Bound-target steps (click/fill/etc. called with a fixed `ref`/`selector`/
|
|
19
|
+
// `named`) have no candidate ranker to disagree about — their signature
|
|
20
|
+
// is just the supplied target string. They contribute a cached entry
|
|
21
|
+
// iff every green run reported ok=true. (The artifact is the same input
|
|
22
|
+
// the original call used — the value is the per-step pass/fail summary,
|
|
23
|
+
// not a new resolver.)
|
|
24
|
+
//
|
|
25
|
+
// 3. Steps where the runs produced different signatures get NO cached entry.
|
|
26
|
+
// `variance.signatures[step]` lists what was seen so the agent can decide.
|
|
27
|
+
//
|
|
28
|
+
// This module is intentionally dep-free below `runBatch` — unit tests can
|
|
29
|
+
// exercise the variance / cache logic without standing up the MCP server.
|
|
30
|
+
import { runBatch, } from "./batch.js";
|
|
31
|
+
const MAX_DISTINCT_ERRORS_PER_STEP = 8;
|
|
32
|
+
const MAX_DISTINCT_SIGNATURES_PER_STEP = 8;
|
|
33
|
+
/**
|
|
34
|
+
* Run `calls` repeatedly through `runBatch` and roll up variance + cached
|
|
35
|
+
* resolvers. Always runs the inner batch with `stopOnError:false` so the
|
|
36
|
+
* variance picture survives a mid-sequence failure (the whole point — knowing
|
|
37
|
+
* step 4 sometimes fails AND that step 5 then also fails differently).
|
|
38
|
+
*/
|
|
39
|
+
export async function runFlakeCheck(calls, opts) {
|
|
40
|
+
const n = Math.max(1, opts.n | 0);
|
|
41
|
+
const runs = [];
|
|
42
|
+
let consecutiveGreen = 0;
|
|
43
|
+
let shortCircuitedAfter;
|
|
44
|
+
for (let runIdx = 0; runIdx < n; runIdx++) {
|
|
45
|
+
const report = await runBatch(calls, {
|
|
46
|
+
allowed: opts.allowed,
|
|
47
|
+
handlers: opts.handlers,
|
|
48
|
+
// Variance-on-the-tail is the entire point — don't let a stopOnError
|
|
49
|
+
// setting from the caller hide the variance picture.
|
|
50
|
+
stopOnError: false,
|
|
51
|
+
});
|
|
52
|
+
runs.push(report);
|
|
53
|
+
const green = report.failedAt === null && report.results.every((r) => r.ok);
|
|
54
|
+
consecutiveGreen = green ? consecutiveGreen + 1 : 0;
|
|
55
|
+
if (opts.stopOnAllGreen !== undefined &&
|
|
56
|
+
opts.stopOnAllGreen > 0 &&
|
|
57
|
+
consecutiveGreen >= opts.stopOnAllGreen) {
|
|
58
|
+
shortCircuitedAfter = consecutiveGreen;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const steps = rollUpSteps(calls, runs);
|
|
63
|
+
const firstDivergence = findFirstDivergence(calls, runs);
|
|
64
|
+
const cachedResolvers = extractCachedResolvers(calls, runs, steps);
|
|
65
|
+
const allGreen = runs.every((r) => r.failedAt === null && r.results.every((e) => e.ok));
|
|
66
|
+
const out = {
|
|
67
|
+
runsCompleted: runs.length,
|
|
68
|
+
allGreen,
|
|
69
|
+
steps,
|
|
70
|
+
firstDivergence,
|
|
71
|
+
cachedResolvers,
|
|
72
|
+
runs,
|
|
73
|
+
};
|
|
74
|
+
if (shortCircuitedAfter !== undefined)
|
|
75
|
+
out.shortCircuitedAfter = shortCircuitedAfter;
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/** Pure; exported for unit tests. Walks every run's results and produces a
|
|
79
|
+
* per-step StepStats record. */
|
|
80
|
+
export function rollUpSteps(calls, runs) {
|
|
81
|
+
return calls.map((call, step) => {
|
|
82
|
+
const entries = [];
|
|
83
|
+
for (const r of runs) {
|
|
84
|
+
const e = r.results[step];
|
|
85
|
+
if (e)
|
|
86
|
+
entries.push(e);
|
|
87
|
+
}
|
|
88
|
+
const ok = entries.filter((e) => e.ok).length;
|
|
89
|
+
const runsAt = entries.length;
|
|
90
|
+
const errorSet = new Set();
|
|
91
|
+
for (const e of entries) {
|
|
92
|
+
if (e.ok)
|
|
93
|
+
continue;
|
|
94
|
+
// `runBatch` only sets `entry.error` on its own failure surfaces (expect
|
|
95
|
+
// mismatch / thrown handler / unknown tool). When the inner call returns
|
|
96
|
+
// `{ok:false, error:"…"}`, the message lives on `entry.result.error` —
|
|
97
|
+
// surface that too so the variance roll-up isn't blank when the inner
|
|
98
|
+
// tool failed cleanly.
|
|
99
|
+
const fromEntry = typeof e.error === "string" ? e.error : null;
|
|
100
|
+
const fromResult = e.result &&
|
|
101
|
+
typeof e.result === "object" &&
|
|
102
|
+
typeof e.result.error === "string"
|
|
103
|
+
? e.result.error
|
|
104
|
+
: null;
|
|
105
|
+
const msg = fromEntry ?? fromResult;
|
|
106
|
+
if (msg) {
|
|
107
|
+
errorSet.add(msg);
|
|
108
|
+
if (errorSet.size >= MAX_DISTINCT_ERRORS_PER_STEP)
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const sigSet = new Set();
|
|
113
|
+
for (const e of entries) {
|
|
114
|
+
const s = signatureFor(call, e);
|
|
115
|
+
sigSet.add(s);
|
|
116
|
+
if (sigSet.size >= MAX_DISTINCT_SIGNATURES_PER_STEP)
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
const stats = {
|
|
120
|
+
step,
|
|
121
|
+
tool: call.tool,
|
|
122
|
+
runs: runsAt,
|
|
123
|
+
ok,
|
|
124
|
+
successRate: runsAt === 0 ? null : ok / runsAt,
|
|
125
|
+
errors: [...errorSet],
|
|
126
|
+
signatures: [...sigSet],
|
|
127
|
+
};
|
|
128
|
+
if (call.label !== undefined)
|
|
129
|
+
stats.label = call.label;
|
|
130
|
+
return stats;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** Pure; exported for tests. Smallest step index where `ok` differed across
|
|
134
|
+
* the runs that reached that step. */
|
|
135
|
+
export function findFirstDivergence(calls, runs) {
|
|
136
|
+
for (let step = 0; step < calls.length; step++) {
|
|
137
|
+
let seenOk = false;
|
|
138
|
+
let seenFail = false;
|
|
139
|
+
for (const r of runs) {
|
|
140
|
+
const e = r.results[step];
|
|
141
|
+
if (!e)
|
|
142
|
+
continue;
|
|
143
|
+
if (e.ok)
|
|
144
|
+
seenOk = true;
|
|
145
|
+
else
|
|
146
|
+
seenFail = true;
|
|
147
|
+
if (seenOk && seenFail) {
|
|
148
|
+
const out = {
|
|
149
|
+
step,
|
|
150
|
+
tool: calls[step].tool,
|
|
151
|
+
};
|
|
152
|
+
if (calls[step].label !== undefined)
|
|
153
|
+
out.label = calls[step].label;
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
/** Pure; exported for tests. Builds the self-heal cache for steps where every
|
|
161
|
+
* reaching-this-step run agreed on the resolution signature AND succeeded.
|
|
162
|
+
* Steps with no extractable resolver (no ref/selectorHint payload + no bound
|
|
163
|
+
* target) yield no entry. */
|
|
164
|
+
export function extractCachedResolvers(calls, runs, steps) {
|
|
165
|
+
const out = [];
|
|
166
|
+
for (let step = 0; step < calls.length; step++) {
|
|
167
|
+
const call = calls[step];
|
|
168
|
+
const stat = steps[step];
|
|
169
|
+
// Only cache when every reaching-this-step run agreed and all succeeded.
|
|
170
|
+
if (stat.runs === 0)
|
|
171
|
+
continue;
|
|
172
|
+
if (stat.ok !== stat.runs)
|
|
173
|
+
continue;
|
|
174
|
+
if (stat.signatures.length !== 1)
|
|
175
|
+
continue;
|
|
176
|
+
// Take the first reaching-this-step entry as the source (all agreed,
|
|
177
|
+
// so any one is canonical).
|
|
178
|
+
let source;
|
|
179
|
+
for (const r of runs) {
|
|
180
|
+
const e = r.results[step];
|
|
181
|
+
if (e) {
|
|
182
|
+
source = e;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (!source)
|
|
187
|
+
continue;
|
|
188
|
+
const resolver = buildResolver(step, call, source);
|
|
189
|
+
if (resolver) {
|
|
190
|
+
resolver.agreedRuns = stat.runs;
|
|
191
|
+
out.push(resolver);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
/** Pure; exported for tests. Computes a per-step resolution signature from
|
|
197
|
+
* the inner call + its result entry. */
|
|
198
|
+
export function signatureFor(call, entry) {
|
|
199
|
+
// Plan: descriptor.ref + evidence.selectorHint.
|
|
200
|
+
const planSig = planSignature(entry.result);
|
|
201
|
+
if (planSig)
|
|
202
|
+
return `plan:${planSig}`;
|
|
203
|
+
// Find: top candidate ref + selectorHint.
|
|
204
|
+
const findSig = findSignature(entry.result);
|
|
205
|
+
if (findSig)
|
|
206
|
+
return `find:${findSig}`;
|
|
207
|
+
// Bound target: just the supplied target string (ref / selector / named).
|
|
208
|
+
// Coords intentionally not cached — by construction non-replayable across
|
|
209
|
+
// a re-render (see plan.ts's policy note).
|
|
210
|
+
const args = call.args ?? {};
|
|
211
|
+
if (typeof args.ref === "string")
|
|
212
|
+
return `ref:${args.ref}`;
|
|
213
|
+
if (typeof args.selector === "string")
|
|
214
|
+
return `selector:${args.selector}`;
|
|
215
|
+
if (typeof args.named === "string")
|
|
216
|
+
return `named:${args.named}`;
|
|
217
|
+
// No structured target — signature is the ok-ness plus a tool tag so
|
|
218
|
+
// step success-rate still rolls up cleanly.
|
|
219
|
+
return `${call.tool}:${entry.ok ? "ok" : "fail"}`;
|
|
220
|
+
}
|
|
221
|
+
function planSignature(result) {
|
|
222
|
+
if (!result || typeof result !== "object")
|
|
223
|
+
return null;
|
|
224
|
+
const r = result;
|
|
225
|
+
const d = r.descriptor;
|
|
226
|
+
if (!d || typeof d !== "object")
|
|
227
|
+
return null;
|
|
228
|
+
const ref = typeof d.ref === "string" ? d.ref : null;
|
|
229
|
+
if (!ref)
|
|
230
|
+
return null;
|
|
231
|
+
const ev = d.evidence;
|
|
232
|
+
const hint = ev &&
|
|
233
|
+
typeof ev === "object" &&
|
|
234
|
+
typeof ev.selectorHint === "string"
|
|
235
|
+
? ev.selectorHint
|
|
236
|
+
: "";
|
|
237
|
+
return `${ref}::${hint}`;
|
|
238
|
+
}
|
|
239
|
+
function findSignature(result) {
|
|
240
|
+
if (!result || typeof result !== "object")
|
|
241
|
+
return null;
|
|
242
|
+
const r = result;
|
|
243
|
+
if (!Array.isArray(r.candidates) || r.candidates.length === 0)
|
|
244
|
+
return null;
|
|
245
|
+
const top = r.candidates[0];
|
|
246
|
+
const ref = typeof top.ref === "string" ? top.ref : null;
|
|
247
|
+
if (!ref)
|
|
248
|
+
return null;
|
|
249
|
+
const hint = typeof top.selectorHint === "string" ? top.selectorHint : "";
|
|
250
|
+
return `${ref}::${hint}`;
|
|
251
|
+
}
|
|
252
|
+
function buildResolver(step, call, source) {
|
|
253
|
+
const base = { step, tool: call.tool, agreedRuns: 0 };
|
|
254
|
+
if (call.label !== undefined)
|
|
255
|
+
base.label = call.label;
|
|
256
|
+
// plan() — richest cache (full descriptor projection).
|
|
257
|
+
const planDescriptor = extractPlanDescriptor(source.result);
|
|
258
|
+
if (planDescriptor) {
|
|
259
|
+
base.ref = planDescriptor.ref;
|
|
260
|
+
base.selectorHint = planDescriptor.evidence?.selectorHint;
|
|
261
|
+
base.descriptor = planDescriptor;
|
|
262
|
+
return base;
|
|
263
|
+
}
|
|
264
|
+
// find() — top candidate's ref + selectorHint.
|
|
265
|
+
const findTop = extractFindTop(source.result);
|
|
266
|
+
if (findTop) {
|
|
267
|
+
base.ref = findTop.ref;
|
|
268
|
+
base.selectorHint = findTop.selectorHint;
|
|
269
|
+
return base;
|
|
270
|
+
}
|
|
271
|
+
// Bound target — at minimum record what the caller used. Useful because
|
|
272
|
+
// the per-step success rate is the load-bearing finding here, not a new
|
|
273
|
+
// resolver.
|
|
274
|
+
const args = call.args ?? {};
|
|
275
|
+
if (typeof args.ref === "string") {
|
|
276
|
+
base.ref = args.ref;
|
|
277
|
+
return base;
|
|
278
|
+
}
|
|
279
|
+
if (typeof args.selector === "string") {
|
|
280
|
+
base.selectorHint = args.selector;
|
|
281
|
+
return base;
|
|
282
|
+
}
|
|
283
|
+
if (typeof args.named === "string") {
|
|
284
|
+
base.selectorHint = `named:${args.named}`;
|
|
285
|
+
return base;
|
|
286
|
+
}
|
|
287
|
+
// No target info to cache — skip the step entirely so the artifact stays
|
|
288
|
+
// signal-dense.
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
function extractPlanDescriptor(result) {
|
|
292
|
+
if (!result || typeof result !== "object")
|
|
293
|
+
return null;
|
|
294
|
+
const r = result;
|
|
295
|
+
const d = r.descriptor;
|
|
296
|
+
if (!d || typeof d !== "object")
|
|
297
|
+
return null;
|
|
298
|
+
const ref = d.ref;
|
|
299
|
+
const verb = d.verb;
|
|
300
|
+
const args = d.args;
|
|
301
|
+
if (typeof ref !== "string" || typeof verb !== "string")
|
|
302
|
+
return null;
|
|
303
|
+
const out = {
|
|
304
|
+
ref,
|
|
305
|
+
verb: verb,
|
|
306
|
+
args: args && typeof args === "object" ? args : {},
|
|
307
|
+
};
|
|
308
|
+
const ev = d.evidence;
|
|
309
|
+
if (ev && typeof ev === "object") {
|
|
310
|
+
const e = ev;
|
|
311
|
+
const projected = {
|
|
312
|
+
selectorHint: typeof e.selectorHint === "string" ? e.selectorHint : "",
|
|
313
|
+
selectorTier: (typeof e.selectorTier === "number"
|
|
314
|
+
? e.selectorTier
|
|
315
|
+
: 5),
|
|
316
|
+
stability: (typeof e.stability === "string"
|
|
317
|
+
? e.stability
|
|
318
|
+
: "low"),
|
|
319
|
+
role: typeof e.role === "string" ? e.role : "",
|
|
320
|
+
};
|
|
321
|
+
if (typeof e.name === "string")
|
|
322
|
+
projected.name = e.name;
|
|
323
|
+
if (typeof e.testId === "string")
|
|
324
|
+
projected.testId = e.testId;
|
|
325
|
+
out.evidence = projected;
|
|
326
|
+
}
|
|
327
|
+
return out;
|
|
328
|
+
}
|
|
329
|
+
function extractFindTop(result) {
|
|
330
|
+
if (!result || typeof result !== "object")
|
|
331
|
+
return null;
|
|
332
|
+
const r = result;
|
|
333
|
+
if (!Array.isArray(r.candidates) || r.candidates.length === 0)
|
|
334
|
+
return null;
|
|
335
|
+
const top = r.candidates[0];
|
|
336
|
+
if (typeof top.ref !== "string")
|
|
337
|
+
return null;
|
|
338
|
+
return {
|
|
339
|
+
ref: top.ref,
|
|
340
|
+
selectorHint: typeof top.selectorHint === "string" ? top.selectorHint : "",
|
|
341
|
+
};
|
|
342
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A contained, structured invariant violation — the L8 analogue of
|
|
2
|
+
* `DeadlineError`. Carries the violated-contract message verbatim; the
|
|
3
|
+
* dispatcher renders it as a structured refusal (`ToolResponse{ok:false}`),
|
|
4
|
+
* never a raw throw past the dispatch boundary. `name` is `"InvariantError"` so
|
|
5
|
+
* the failure classifier and any catch-site can recognise a browxai-origin
|
|
6
|
+
* internal fault (vs an application/page error). */
|
|
7
|
+
export declare class InvariantError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Assert an internal invariant. On a falsy `cond`, throws `InvariantError` (a
|
|
12
|
+
* contained, structured refusal — never a bare `assert`/crash). The TypeScript
|
|
13
|
+
* `asserts cond` signature narrows the type after the call, so a passing
|
|
14
|
+
* invariant also tells the compiler the condition holds (the L6 boundary
|
|
15
|
+
* discipline, applied internally) — e.g. `invariant(x !== undefined, …)` lets
|
|
16
|
+
* the code below treat `x` as defined.
|
|
17
|
+
*
|
|
18
|
+
* Use ONLY for contracts the surrounding code already depends on, so the call is
|
|
19
|
+
* a no-op on every valid input. Never validate user/wire data here (that is the
|
|
20
|
+
* boundary's job, L6); never assert an optional or best-effort condition.
|
|
21
|
+
*
|
|
22
|
+
* invariant(REGISTRY.size > 0, "engine registry is empty at dispatch");
|
|
23
|
+
* invariant(cap > 0, `ring cap must be positive, got ${cap}`);
|
|
24
|
+
*/
|
|
25
|
+
export declare function invariant(cond: unknown, msg: string): asserts cond;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// invariant() — assert an internal contract (RFC 0004 L8).
|
|
2
|
+
//
|
|
3
|
+
// browxai already contains faults at three boundaries as STRUCTURED, recoverable
|
|
4
|
+
// refusals rather than crashes: the anti-wedge deadline (`DeadlineError`,
|
|
5
|
+
// deadline.ts:13-32), the secrets scope check (`materialize` returns
|
|
6
|
+
// `{ok:false, error}`, secrets.ts), and the capability gate (a denied tool
|
|
7
|
+
// returns a refusal). L8 generalizes that single proven pattern: every internal
|
|
8
|
+
// invariant that, if violated, means browxai itself is in a corrupt state — a
|
|
9
|
+
// registry with two entries for one key, a ring whose cap went non-positive, a
|
|
10
|
+
// precedence chain that lost a layer — surfaces through the SAME structured-
|
|
11
|
+
// refusal envelope, contained at the dispatch boundary, never propagated as an
|
|
12
|
+
// uncontained throw that wedges the dispatch loop.
|
|
13
|
+
//
|
|
14
|
+
// `invariant(cond, msg)` is the fault-containment generalization: it throws an
|
|
15
|
+
// `InvariantError` (a tagged, contained error, NOT a bare `assert`) whose message
|
|
16
|
+
// is an explicit agent-facing playbook — same posture as `DeadlineError`. The
|
|
17
|
+
// dispatcher maps `InvariantError` to a `ToolResponse{ok:false}` the agent can
|
|
18
|
+
// act on, exactly as it maps `DeadlineError`. The `classifyFailure` patterns
|
|
19
|
+
// (failure.ts) already route a browxai-origin fault to the right recovery, and
|
|
20
|
+
// `invariant violated` joins that family.
|
|
21
|
+
//
|
|
22
|
+
// CRITICAL: an invariant asserts only what the surrounding code ALREADY
|
|
23
|
+
// guarantees on valid inputs, so it is a NO-OP in production and on every test —
|
|
24
|
+
// the assertion-density fitness function and the full unit + keystone suites run
|
|
25
|
+
// with NO invariant firing. An invariant that fires on a legitimate edge case is
|
|
26
|
+
// a bug in the invariant, not a feature; assert contracts the code depends on,
|
|
27
|
+
// never user-supplied data (that is the boundary's job — L6, validate at the
|
|
28
|
+
// edge), and never an optional/best-effort condition.
|
|
29
|
+
/** A contained, structured invariant violation — the L8 analogue of
|
|
30
|
+
* `DeadlineError`. Carries the violated-contract message verbatim; the
|
|
31
|
+
* dispatcher renders it as a structured refusal (`ToolResponse{ok:false}`),
|
|
32
|
+
* never a raw throw past the dispatch boundary. `name` is `"InvariantError"` so
|
|
33
|
+
* the failure classifier and any catch-site can recognise a browxai-origin
|
|
34
|
+
* internal fault (vs an application/page error). */
|
|
35
|
+
export class InvariantError extends Error {
|
|
36
|
+
constructor(message) {
|
|
37
|
+
super(`invariant violated: ${message}. This is a browxai-internal contract failure ` +
|
|
38
|
+
`(NOT an application or page error) — browxai reached a state one of its own ` +
|
|
39
|
+
`modules guarantees cannot happen, so it refused instead of returning a wrong ` +
|
|
40
|
+
`answer or crashing the dispatch loop. This is a RECOVERABLE signal: the tool ` +
|
|
41
|
+
`returned a structured refusal. Treat it as a defect to report (it indicates a ` +
|
|
42
|
+
`bug in browxai, not in your usage); the session itself is usually unaffected ` +
|
|
43
|
+
`— retry the call, and if it recurs, capture the message and file it.`);
|
|
44
|
+
this.name = "InvariantError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Assert an internal invariant. On a falsy `cond`, throws `InvariantError` (a
|
|
49
|
+
* contained, structured refusal — never a bare `assert`/crash). The TypeScript
|
|
50
|
+
* `asserts cond` signature narrows the type after the call, so a passing
|
|
51
|
+
* invariant also tells the compiler the condition holds (the L6 boundary
|
|
52
|
+
* discipline, applied internally) — e.g. `invariant(x !== undefined, …)` lets
|
|
53
|
+
* the code below treat `x` as defined.
|
|
54
|
+
*
|
|
55
|
+
* Use ONLY for contracts the surrounding code already depends on, so the call is
|
|
56
|
+
* a no-op on every valid input. Never validate user/wire data here (that is the
|
|
57
|
+
* boundary's job, L6); never assert an optional or best-effort condition.
|
|
58
|
+
*
|
|
59
|
+
* invariant(REGISTRY.size > 0, "engine registry is empty at dispatch");
|
|
60
|
+
* invariant(cap > 0, `ring cap must be positive, got ${cap}`);
|
|
61
|
+
*/
|
|
62
|
+
export function invariant(cond, msg) {
|
|
63
|
+
if (!cond) {
|
|
64
|
+
throw new InvariantError(msg);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type LogLevel = "info" | "warn" | "error";
|
|
2
|
+
export declare const log: {
|
|
3
|
+
info: (msg: string, fields?: Record<string, unknown>) => void;
|
|
4
|
+
warn: (msg: string, fields?: Record<string, unknown>) => void;
|
|
5
|
+
error: (msg: string, fields?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// stderr-only structured logger. stdout is the MCP wire — anything we write there
|
|
2
|
+
// corrupts the protocol. Importing `console.log` in src/ is a bug.
|
|
3
|
+
function emit(level, msg, fields) {
|
|
4
|
+
const ts = new Date().toISOString();
|
|
5
|
+
const tail = fields && Object.keys(fields).length ? " " + JSON.stringify(fields) : "";
|
|
6
|
+
process.stderr.write(`[${ts}] ${level} browxai: ${msg}${tail}\n`);
|
|
7
|
+
}
|
|
8
|
+
export const log = {
|
|
9
|
+
info: (msg, fields) => emit("info", msg, fields),
|
|
10
|
+
warn: (msg, fields) => emit("warn", msg, fields),
|
|
11
|
+
error: (msg, fields) => emit("error", msg, fields),
|
|
12
|
+
};
|