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,324 @@
|
|
|
1
|
+
import { requireCdp } from "../engine/index.js";
|
|
2
|
+
import { estimateTokens } from "../util/tokens.js";
|
|
3
|
+
import { DEFAULT_TRACE_CATEGORIES, defaultTracePath, writeTraceFile, readTraceFile, extractInsights, } from "../page/perf.js";
|
|
4
|
+
import { ALL_AUDIT_CATEGORIES } from "../page/perf-audit.js";
|
|
5
|
+
import { runPerfAudit } from "../page/perf-audit-runner.js";
|
|
6
|
+
import { SESSION_ARG } from "./schemas.js";
|
|
7
|
+
/** Whether a `ResourceSendRequest` event is render-blocking. */
|
|
8
|
+
function isRenderBlockingEvent(ev) {
|
|
9
|
+
const data = (ev.args && ev.args.data);
|
|
10
|
+
const rb = data && typeof data.renderBlocking === "string" ? data.renderBlocking : "";
|
|
11
|
+
return rb === "blocking" || rb === "in_body_parser_blocking";
|
|
12
|
+
}
|
|
13
|
+
/** Whether an event is a long task (`RunTask`/`LongTask` ≥ 50ms). */
|
|
14
|
+
function isLongTaskEvent(ev, name) {
|
|
15
|
+
return ((name === "RunTask" || name === "LongTask") && typeof ev.dur === "number" && ev.dur / 1000 >= 50);
|
|
16
|
+
}
|
|
17
|
+
/** Classify a trace event into the perf counter it bumps, or null. */
|
|
18
|
+
function perfCountKey(ev) {
|
|
19
|
+
if (!ev || typeof ev !== "object")
|
|
20
|
+
return null;
|
|
21
|
+
const name = typeof ev.name === "string" ? ev.name : "";
|
|
22
|
+
if (!name)
|
|
23
|
+
return null;
|
|
24
|
+
if (isLongTaskEvent(ev, name))
|
|
25
|
+
return "longTaskCount";
|
|
26
|
+
if (name === "LayoutShift")
|
|
27
|
+
return "layoutShiftCount";
|
|
28
|
+
if (name === "largestContentfulPaint::Candidate")
|
|
29
|
+
return "lcpCandidateCount";
|
|
30
|
+
if (name === "ResourceSendRequest" && isRenderBlockingEvent(ev))
|
|
31
|
+
return "renderBlockingCount";
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function inlineCounts(events) {
|
|
35
|
+
const counts = {
|
|
36
|
+
longTaskCount: 0,
|
|
37
|
+
layoutShiftCount: 0,
|
|
38
|
+
renderBlockingCount: 0,
|
|
39
|
+
lcpCandidateCount: 0,
|
|
40
|
+
};
|
|
41
|
+
for (const ev of events) {
|
|
42
|
+
const key = perfCountKey(ev);
|
|
43
|
+
if (key)
|
|
44
|
+
counts[key]++;
|
|
45
|
+
}
|
|
46
|
+
return counts;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Deep-diagnostics tools — the heavyweight observation surface an agent reaches
|
|
50
|
+
* for when a flow is slow, leaky, or non-deterministic: performance tracing
|
|
51
|
+
* (perf_start / perf_stop / perf_insights), the orchestrated perf_audit, JS+CSS
|
|
52
|
+
* coverage, layout-thrash tracing, V8 heap snapshots + retainer / memory-diff
|
|
53
|
+
* queries, the virtual clock + seeded RNG determinism knobs, and the
|
|
54
|
+
* network-aware act_and_wait_for_network / poll_eval waiters. Every block is
|
|
55
|
+
* registered through the shared `ToolHost` seam; the host owns the closures
|
|
56
|
+
* (gate, engine-gate, session, workspace, batch dispatch), this module owns the
|
|
57
|
+
* registrations.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Deep tools — performance tracing & audit. `perf_start` / `perf_stop` (Chromium
|
|
61
|
+
* trace capture), `perf_insights` (post-hoc trace analysis), and `perf_audit`
|
|
62
|
+
* (the category-driven optimisation pass). All CDP-deep (refused off Chromium).
|
|
63
|
+
* Registered through the shared `ToolHost` seam.
|
|
64
|
+
*/
|
|
65
|
+
export function registerDeepPerfTools(host) {
|
|
66
|
+
const { z, register, gateCheck, engineGate, entryFor, workspace } = host;
|
|
67
|
+
// -------- performance tracing --------
|
|
68
|
+
register("perf_start", {
|
|
69
|
+
capability: "action",
|
|
70
|
+
batchable: true,
|
|
71
|
+
deep: true,
|
|
72
|
+
description: "Arm a CDP performance trace on this session — wraps `Tracing.start`. Use to diagnose **why** a slow interaction was slow: a paired `perf_stop` flushes a chromium-format trace file under `<workspace>/perf-traces/` and a `perf_insights` call extracts structured long-tasks / layout-shifts / render-blocking / LCP / navigation-timing data from it. Per-session; one trace in flight at a time. **Idempotent restart:** calling `perf_start` while a trace is already running cleanly stops the in-flight one (events discarded) and starts fresh — an agent that lost track of state always recovers by just calling again. Empty `categories` uses a DevTools-Performance-equivalent default (devtools.timeline + loading + blink.user_timing + frame). Tracing is per-target (the attached chromium); BYOB sessions: a `perf_stop` is REQUIRED to detach the trace buffer on the human's Chrome — `close_session` also cleans up on its way out.",
|
|
73
|
+
inputSchema: {
|
|
74
|
+
categories: z
|
|
75
|
+
.array(z.string())
|
|
76
|
+
.optional()
|
|
77
|
+
.describe(`Tracing categories to include. Omit for the default set (${DEFAULT_TRACE_CATEGORIES.join(", ")}).`),
|
|
78
|
+
...SESSION_ARG,
|
|
79
|
+
},
|
|
80
|
+
}, async ({ categories, session }) => {
|
|
81
|
+
const g = gateCheck("perf_start");
|
|
82
|
+
if (g)
|
|
83
|
+
return g;
|
|
84
|
+
const e = await entryFor(session);
|
|
85
|
+
const eg = engineGate("perf_start", e);
|
|
86
|
+
if (eg)
|
|
87
|
+
return eg;
|
|
88
|
+
try {
|
|
89
|
+
const r = await e.perf.start(requireCdp(e.session), { categories });
|
|
90
|
+
const body = {
|
|
91
|
+
ok: true,
|
|
92
|
+
running: true,
|
|
93
|
+
categories: r.categories,
|
|
94
|
+
restarted: r.restarted,
|
|
95
|
+
hint: "Drive your action(s), then call perf_stop to flush the trace. Insights come from perf_insights({tracePath}).",
|
|
96
|
+
};
|
|
97
|
+
if (r.restarted) {
|
|
98
|
+
body.warning =
|
|
99
|
+
"A prior perf_start was still active — it has been cleanly stopped (events discarded) and a fresh trace started.";
|
|
100
|
+
}
|
|
101
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
const body = { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
110
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
register("perf_stop", {
|
|
119
|
+
capability: "action",
|
|
120
|
+
batchable: true,
|
|
121
|
+
deep: true,
|
|
122
|
+
description: "Stop the in-flight performance trace and flush it to a workspace-rooted JSON file. Wraps `Tracing.end`. Returns `{ path, bytes, eventCount, categories, durationMs }` plus a tiny summary (long-task count, layout-shift count, render-blocking count) so you don't have to call `perf_insights` for a one-glance answer. Default file path: `<workspace>/perf-traces/<sessionId>-<ts>.json` (override with `path`, which is rejected if it resolves outside `$BROWX_WORKSPACE`). **Safe to call any number of times:** if no trace is running, returns `notRunning:true` rather than an error — pairs cleanly with idempotent agent retries. The file is chromium-tracing format (`{ traceEvents, metadata }`), so it loads in DevTools' Performance panel and `chrome://tracing` directly.",
|
|
123
|
+
inputSchema: {
|
|
124
|
+
path: z
|
|
125
|
+
.string()
|
|
126
|
+
.optional()
|
|
127
|
+
.describe("Workspace-rooted output path for the trace JSON. Default: <workspace>/perf-traces/<sessionId>-<ts>.json. Rejected if it escapes $BROWX_WORKSPACE."),
|
|
128
|
+
...SESSION_ARG,
|
|
129
|
+
},
|
|
130
|
+
}, async ({ path, session }) => {
|
|
131
|
+
const g = gateCheck("perf_stop");
|
|
132
|
+
if (g)
|
|
133
|
+
return g;
|
|
134
|
+
const e = await entryFor(session);
|
|
135
|
+
const eg = engineGate("perf_stop", e);
|
|
136
|
+
if (eg)
|
|
137
|
+
return eg;
|
|
138
|
+
try {
|
|
139
|
+
const r = await e.perf.stop(requireCdp(e.session));
|
|
140
|
+
if (r.notRunning) {
|
|
141
|
+
const body = {
|
|
142
|
+
ok: true,
|
|
143
|
+
notRunning: true,
|
|
144
|
+
hint: "No trace was active for this session — perf_stop is idempotent; call perf_start first.",
|
|
145
|
+
};
|
|
146
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
147
|
+
return {
|
|
148
|
+
content: [
|
|
149
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const targetPath = path ?? defaultTracePath(workspace.root, e.id);
|
|
154
|
+
// `targetPath` is rooted at workspace.root by construction (defaultTracePath
|
|
155
|
+
// uses workspace.root; explicit `path` is enforced by resolvePerfTracePath
|
|
156
|
+
// inside writeTraceFile).
|
|
157
|
+
const written = writeTraceFile(workspace.root, targetPath, r.events, { categories: r.categories, sessionId: e.id, durationMs: r.durationMs }, "perf_stop");
|
|
158
|
+
// Tiny inline summary — agent can decide whether to spend tokens on
|
|
159
|
+
// perf_insights or move on. Doesn't reparse: we count event names only.
|
|
160
|
+
const summary = inlineCounts(r.events);
|
|
161
|
+
const body = {
|
|
162
|
+
ok: true,
|
|
163
|
+
path: written.resolved,
|
|
164
|
+
bytes: written.bytes,
|
|
165
|
+
eventCount: r.events.length,
|
|
166
|
+
categories: r.categories,
|
|
167
|
+
durationMs: r.durationMs,
|
|
168
|
+
summary,
|
|
169
|
+
hint: "Call perf_insights({tracePath}) for structured long-tasks / layout-shifts / render-blocking / LCP / navigation-timing data.",
|
|
170
|
+
};
|
|
171
|
+
if (e.mode === "attached") {
|
|
172
|
+
body.warning =
|
|
173
|
+
"BYOB / attached Chrome: the trace buffer on the human's Chrome has been released. The JSON file remains under $BROWX_WORKSPACE.";
|
|
174
|
+
}
|
|
175
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
176
|
+
return {
|
|
177
|
+
content: [
|
|
178
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
const body = { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
184
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
185
|
+
return {
|
|
186
|
+
content: [
|
|
187
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
register("perf_insights", {
|
|
193
|
+
capability: "action",
|
|
194
|
+
batchable: true,
|
|
195
|
+
deep: true,
|
|
196
|
+
description: "Extract structured insights from a written performance trace file. Returns `{ longTasks, layoutShifts, renderBlocking, lcpCandidates, navigation?, totals }`: top-50 long tasks (≥50ms blocking work, sorted longest-first); layout shifts with per-shift score + sum; render-blocking CSS/JS resources with duration; LCP candidates (final = effective LCP); navigation milestones (FP / FCP / DCL / load) relative to `navigationStart`. `tracePath` is workspace-rooted (the path `perf_stop` returned) and rejected if it escapes `$BROWX_WORKSPACE`. Same chromium-tracing JSON format the DevTools Performance panel consumes — bring-your-own trace works too.",
|
|
197
|
+
inputSchema: {
|
|
198
|
+
tracePath: z
|
|
199
|
+
.string()
|
|
200
|
+
.describe("Workspace-rooted path to a chromium trace JSON file (the path returned by perf_stop)."),
|
|
201
|
+
...SESSION_ARG,
|
|
202
|
+
},
|
|
203
|
+
}, async ({ tracePath, session: _session }) => {
|
|
204
|
+
const g = gateCheck("perf_insights");
|
|
205
|
+
if (g)
|
|
206
|
+
return g;
|
|
207
|
+
// No session-touching needed — pure file read + parse. But we still
|
|
208
|
+
// resolve the entry to honour the SESSION_ARG contract for consistency.
|
|
209
|
+
try {
|
|
210
|
+
const { events, metadata } = readTraceFile(workspace.root, tracePath, "perf_insights");
|
|
211
|
+
const insights = extractInsights(events);
|
|
212
|
+
const body = {
|
|
213
|
+
ok: true,
|
|
214
|
+
tracePath,
|
|
215
|
+
eventCount: events.length,
|
|
216
|
+
metadata: metadata ?? null,
|
|
217
|
+
insights,
|
|
218
|
+
};
|
|
219
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
223
|
+
],
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
const body = { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
228
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
229
|
+
return {
|
|
230
|
+
content: [
|
|
231
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
// -------- perf optimization module --------
|
|
237
|
+
//
|
|
238
|
+
// Four new primitives that promote browxai's perf surface from
|
|
239
|
+
// measurement to actionable:
|
|
240
|
+
// - perf_audit → orchestrated audit across 8 pluggable
|
|
241
|
+
// categories, with remediation suggestions.
|
|
242
|
+
// Summary mode capped at 2000 tokens.
|
|
243
|
+
// - coverage_start/stop → CDP Profiler.startPreciseCoverage +
|
|
244
|
+
// CSS.startRuleUsageTracking pair, exposing
|
|
245
|
+
// per-script + per-stylesheet usage% for the
|
|
246
|
+
// dead-code analysis the audit consumes.
|
|
247
|
+
// - layout_thrash_trace → focused 5-30s trace just for forced
|
|
248
|
+
// synchronous layouts + LayoutShift events,
|
|
249
|
+
// aggregated by originating call-stack.
|
|
250
|
+
// - memory_diff → pure-function heap-snapshot diff (two
|
|
251
|
+
// existing `.heapsnapshot` paths in) →
|
|
252
|
+
// retainer-growth report.
|
|
253
|
+
//
|
|
254
|
+
// Capability split (also in util/capabilities.ts):
|
|
255
|
+
// perf_audit, coverage_stop, layout_thrash_trace, memory_diff → `read`
|
|
256
|
+
// coverage_start → `action`
|
|
257
|
+
register("perf_audit", {
|
|
258
|
+
capability: "read",
|
|
259
|
+
batchable: true,
|
|
260
|
+
deep: true,
|
|
261
|
+
description: 'Run a structured performance audit on this session and return remediation-shaped findings — the headline tool. Records a CDP trace + JS/CSS precise coverage + network response metadata for `durationMs` (default 5000, max 30000), then runs 8 pluggable category analysers against the assembled context and composes a report. **Categories** (default = all): `render-blocking` (resources blocking first paint), `unused-code` (scripts/stylesheets with <30% usage), `oversize-images` (>500KB), `layout-thrashing` (>5 forced sync layouts), `long-tasks` (>50ms main-thread blockers), `leak-suspects` (>10% retainer growth — requires `memory_diff` data passed via the runner), `cache-opportunities` (static assets with missing/short Cache-Control), `font-loading` (fonts loaded >200ms after document start). **Output shape:** `{summary:{score, topIssues[]}, byCategory:{[cat]:{issues[], remediations[]}}, evidence:{tracePath, coveragePath?}, warnings[], tokensEstimate}`. **`format`** (default `"summary"`) caps each category to 3 issues + 3 remediations AND enforces a 2000-token budget on the body — over-budget low/medium severity entries are dropped + a `warnings[]` entry surfaces it. `"full"` is unbounded. **Evidence files** (workspace-rooted): the trace under `<workspace>/perf/<sessionId>-audit-<ts>.json` + coverage JSON alongside; both are loadable in DevTools\' Performance / Coverage panels. Internally pluggable — future categories add by extending `ANALYSERS` in `src/page/perf-audit.ts` without changing this public surface. Capability `read` (non-mutating observation).',
|
|
262
|
+
inputSchema: {
|
|
263
|
+
categories: z
|
|
264
|
+
.array(z.enum(ALL_AUDIT_CATEGORIES))
|
|
265
|
+
.optional()
|
|
266
|
+
.describe("Subset of audit categories. Default = all 8."),
|
|
267
|
+
durationMs: z
|
|
268
|
+
.number()
|
|
269
|
+
.int()
|
|
270
|
+
.positive()
|
|
271
|
+
.max(30_000)
|
|
272
|
+
.optional()
|
|
273
|
+
.describe("Observation window in ms. Default 5000, max 30000. Longer windows give more data but cost more wall-clock."),
|
|
274
|
+
format: z
|
|
275
|
+
.enum(["summary", "full"])
|
|
276
|
+
.optional()
|
|
277
|
+
.describe("`summary` (default) caps each category to 3 issues + enforces a 2000-token body budget. `full` is unbounded."),
|
|
278
|
+
...SESSION_ARG,
|
|
279
|
+
},
|
|
280
|
+
}, async ({ categories, durationMs, format, session }) => {
|
|
281
|
+
const g = gateCheck("perf_audit");
|
|
282
|
+
if (g)
|
|
283
|
+
return g;
|
|
284
|
+
const e = await entryFor(session);
|
|
285
|
+
const eg = engineGate("perf_audit", e);
|
|
286
|
+
if (eg)
|
|
287
|
+
return eg;
|
|
288
|
+
try {
|
|
289
|
+
const r = await runPerfAudit(requireCdp(e.session), workspace.root, e.id, {
|
|
290
|
+
categories: categories,
|
|
291
|
+
durationMs,
|
|
292
|
+
format,
|
|
293
|
+
});
|
|
294
|
+
const body = {
|
|
295
|
+
ok: true,
|
|
296
|
+
summary: r.report.summary,
|
|
297
|
+
byCategory: r.report.byCategory,
|
|
298
|
+
evidence: r.evidence,
|
|
299
|
+
durationMs: r.durationMs,
|
|
300
|
+
categoriesRun: r.categoriesRun,
|
|
301
|
+
warnings: r.report.warnings,
|
|
302
|
+
};
|
|
303
|
+
if (e.mode === "attached") {
|
|
304
|
+
body.warning =
|
|
305
|
+
"BYOB / attached Chrome: trace + coverage state has been released on the human's Chrome. Evidence files remain under $BROWX_WORKSPACE.";
|
|
306
|
+
}
|
|
307
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
308
|
+
return {
|
|
309
|
+
content: [
|
|
310
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
311
|
+
],
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
const body = { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
316
|
+
const tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
317
|
+
return {
|
|
318
|
+
content: [
|
|
319
|
+
{ type: "text", text: JSON.stringify({ ...body, tokensEstimate }, null, 2) },
|
|
320
|
+
],
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolHost } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* Synthetic device emulation — the off-by-default `device-emulation` surface.
|
|
4
|
+
* Web Bluetooth / WebUSB / WebHID catalog staging (`emulate_bluetooth` /
|
|
5
|
+
* `emulate_usb` / `emulate_hid`): the page-side wrapper around
|
|
6
|
+
* `navigator.<api>.requestDevice()` resolves with agent-supplied devices.
|
|
7
|
+
* Registered through the shared `ToolHost` seam.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerDeviceEmulationTools(host: ToolHost): void;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BYOB_DEVICE_EMU_WARNING } from "../session/device-emu.js";
|
|
2
|
+
import { estimateTokens } from "../util/tokens.js";
|
|
3
|
+
import { SESSION_ARG } from "./schemas.js";
|
|
4
|
+
/**
|
|
5
|
+
* Synthetic device emulation — the off-by-default `device-emulation` surface.
|
|
6
|
+
* Web Bluetooth / WebUSB / WebHID catalog staging (`emulate_bluetooth` /
|
|
7
|
+
* `emulate_usb` / `emulate_hid`): the page-side wrapper around
|
|
8
|
+
* `navigator.<api>.requestDevice()` resolves with agent-supplied devices.
|
|
9
|
+
* Registered through the shared `ToolHost` seam.
|
|
10
|
+
*/
|
|
11
|
+
export function registerDeviceEmulationTools(host) {
|
|
12
|
+
const { z, register, gateCheck, entryFor } = host;
|
|
13
|
+
// ---------- Web Bluetooth / WebUSB / WebHID device emulation
|
|
14
|
+
// (capability `device-emulation`) ----------
|
|
15
|
+
//
|
|
16
|
+
// Three sibling mutators (`emulate_bluetooth` / `emulate_usb` / `emulate_hid`)
|
|
17
|
+
// plus a read-side companion (`device_requests`). All four gate behind the
|
|
18
|
+
// off-by-default `device-emulation` capability — same posture class as
|
|
19
|
+
// `eval` / `network-body` / `secrets` / `extensions` / `stealth` / `captcha`.
|
|
20
|
+
// The page-side init-script wrappers install eagerly at session creation
|
|
21
|
+
// (so a page that calls `requestDevice()` on initial document parse never
|
|
22
|
+
// hangs); the check binding short-circuits to `refused` when the capability
|
|
23
|
+
// is off, so a server without `device-emulation` still surfaces "page
|
|
24
|
+
// asked but capability was off" on `device_requests`.
|
|
25
|
+
//
|
|
26
|
+
// Shared input schema — the SyntheticDevice union (every field optional;
|
|
27
|
+
// wrappers default missing fields to deterministic placeholders so the
|
|
28
|
+
// page sees a complete shape). A single shape covers all three APIs;
|
|
29
|
+
// each wrapper picks the fields its spec exposes.
|
|
30
|
+
const SYNTHETIC_DEVICE_SCHEMA = z.object({
|
|
31
|
+
name: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Display name. Bluetooth: `.name`; USB: `.productName`; HID: `.productName`. Default `"browxai-virtual"`.'),
|
|
35
|
+
id: z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Bluetooth: stable device id (UUID-style string). Default `"browxai-<api>-<index>"`.'),
|
|
39
|
+
vendorId: z
|
|
40
|
+
.number()
|
|
41
|
+
.int()
|
|
42
|
+
.nonnegative()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("USB / HID: 16-bit USB-IF vendor id. Default `0x0000`."),
|
|
45
|
+
productId: z
|
|
46
|
+
.number()
|
|
47
|
+
.int()
|
|
48
|
+
.nonnegative()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("USB / HID: 16-bit product id. Default `0x0000`."),
|
|
51
|
+
manufacturerName: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('USB: human-readable manufacturer string. Default `"browxai virtual"`.'),
|
|
55
|
+
serialNumber: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('USB: serial number string. Default `"BROWX-VIRTUAL"`.'),
|
|
59
|
+
deviceClass: z
|
|
60
|
+
.number()
|
|
61
|
+
.int()
|
|
62
|
+
.nonnegative()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("USB: 8-bit device class. Default `0xFF` (vendor-specific)."),
|
|
65
|
+
deviceSubclass: z
|
|
66
|
+
.number()
|
|
67
|
+
.int()
|
|
68
|
+
.nonnegative()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("USB: 8-bit device subclass. Default `0x00`."),
|
|
71
|
+
deviceProtocol: z
|
|
72
|
+
.number()
|
|
73
|
+
.int()
|
|
74
|
+
.nonnegative()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe("USB: 8-bit device protocol. Default `0x00`."),
|
|
77
|
+
services: z
|
|
78
|
+
.array(z.string())
|
|
79
|
+
.optional()
|
|
80
|
+
.describe("Bluetooth: GATT primary service UUIDs the device advertises. Surfaced on the synthetic device as `device.uuids`. v1 does NOT emulate GATT service exchange — `gatt.getPrimaryService()` rejects."),
|
|
81
|
+
collections: z
|
|
82
|
+
.array(z.unknown())
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("HID: report-descriptor collection topology exposed on `device.collections`. Pass-through — the page sees whatever shape you supplied."),
|
|
85
|
+
});
|
|
86
|
+
const registerEmulateApi = (toolName, api, hint) => {
|
|
87
|
+
register(toolName, {
|
|
88
|
+
// emulate_bluetooth / emulate_usb / emulate_hid — all device-emulation.
|
|
89
|
+
capability: "device-emulation",
|
|
90
|
+
description: `Stage a synthetic ${api === "bluetooth" ? "Web Bluetooth" : api === "usb" ? "WebUSB" : "WebHID"} device catalog for this session. The page-side wrapper around \`navigator.${api}.requestDevice()\` resolves with the agent-supplied device(s) the next time the page calls it. ${hint} ` +
|
|
91
|
+
`Pass \`{devices: [...]}\` to install a non-empty catalog (the next requestDevice call ${api === "hid" ? "resolves with the matching device list" : "resolves with the first matching device"}); pass \`{devices: []}\` or omit \`devices\` to clear the catalog (the next call ${api === "hid" ? "resolves with `[]` — the user-dismissed shape for HID" : "rejects with `NotFoundError` — the user-dismissed shape for the picker"}). Persists across navigation: the init-script is re-injected on every new document within the session. Captured page-side calls surface on \`device_requests({session})\`. ` +
|
|
92
|
+
`**Gated behind the off-by-default \`device-emulation\` capability** — the wrappers tell the page it found physical devices that don't exist, a posture-broadening change distinct from the surrounding policies. v1 covers the picker-clear path only — ${api === "bluetooth" ? "GATT service exchange (`getPrimaryService()`) rejects" : api === "usb" ? "transfer endpoints (`transferIn`/`transferOut`) resolve with zero-byte results" : "input/output reports (`oninputreport`, `sendReport()`) are stubs"}. Same posture class as \`eval\` / \`network-body\` / \`secrets\` / \`extensions\` / \`stealth\` / \`captcha\` — see docs/threat-model.md. Returns \`{ok, session, api, catalog:{devices:[…]}, warnings?, tokensEstimate}\`.`,
|
|
93
|
+
inputSchema: {
|
|
94
|
+
devices: z
|
|
95
|
+
.array(SYNTHETIC_DEVICE_SCHEMA)
|
|
96
|
+
.optional()
|
|
97
|
+
.describe(`Synthetic devices to expose. Omit or pass \`[]\` to clear the catalog. ${api === "hid" ? "All entries are returned to the page on every requestDevice() call." : "Only the first entry is returned to the page on requestDevice() (Bluetooth/USB pickers are single-result)."}`),
|
|
98
|
+
...SESSION_ARG,
|
|
99
|
+
},
|
|
100
|
+
}, async (args) => {
|
|
101
|
+
const g = gateCheck(toolName);
|
|
102
|
+
if (g)
|
|
103
|
+
return g;
|
|
104
|
+
const e = await entryFor(args.session);
|
|
105
|
+
try {
|
|
106
|
+
const devices = args.devices ?? [];
|
|
107
|
+
const catalog = e.webDeviceEmulation.set(api, devices);
|
|
108
|
+
const warnings = [];
|
|
109
|
+
if (e.mode === "attached")
|
|
110
|
+
warnings.push(BYOB_DEVICE_EMU_WARNING);
|
|
111
|
+
const body = {
|
|
112
|
+
ok: true,
|
|
113
|
+
session: e.id,
|
|
114
|
+
api,
|
|
115
|
+
catalog,
|
|
116
|
+
};
|
|
117
|
+
if (warnings.length)
|
|
118
|
+
body.warnings = warnings;
|
|
119
|
+
body.tokensEstimate = estimateTokens(JSON.stringify(body));
|
|
120
|
+
return { content: [{ type: "text", text: JSON.stringify(body, null, 2) }] };
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return {
|
|
124
|
+
content: [
|
|
125
|
+
{
|
|
126
|
+
type: "text",
|
|
127
|
+
text: JSON.stringify({ ok: false, error: err instanceof Error ? err.message : String(err) }, null, 2),
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
registerEmulateApi("emulate_bluetooth", "bluetooth", "The synthetic `BluetoothDevice` carries `{id, name, uuids, gatt}`; `gatt.connect()` resolves with a stub server whose `getPrimaryService()` rejects (no GATT emulation in v1) — enough for pages that gate flow on the picker-clear, not enough for pages that go on to exchange characteristic data.");
|
|
135
|
+
registerEmulateApi("emulate_usb", "usb", "The synthetic `USBDevice` carries vendor/product/class/manufacturer/serial fields; `open()` / `selectConfiguration()` / `claimInterface()` resolve; transfer endpoints (`transferIn` / `transferOut` / `controlTransferIn` / `controlTransferOut`) resolve with zero-byte payloads (no synthetic data flow).");
|
|
136
|
+
registerEmulateApi("emulate_hid", "hid", "The synthetic `HIDDevice` carries vendor/product/productName/collections; `open()` / `sendReport()` / `sendFeatureReport()` resolve; `receiveFeatureReport()` resolves with an empty DataView; `oninputreport` is never fired (no synthetic device traffic).");
|
|
137
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolHost } from "./host.js";
|
|
2
|
+
/**
|
|
3
|
+
* Chrome-extension management + the server-side compound primitives:
|
|
4
|
+
* extensions_install / extensions_list / extensions_reload /
|
|
5
|
+
* extensions_trigger / extensions_uninstall, plus await_human, batch,
|
|
6
|
+
* act_and_sample, act_and_diff, flake_check.
|
|
7
|
+
*
|
|
8
|
+
* RFC 0004 P3 / D3 (SRP): the registrations were split by cohesive family into
|
|
9
|
+
* three sibling modules (extensions / batch-human / batch-act), and the
|
|
10
|
+
* persistent-session context rebuild was extracted to `extensions-rebuild.ts`.
|
|
11
|
+
* This module stays the single entry point `server.ts` + `tool-metadata.ts` call,
|
|
12
|
+
* and invokes each family in the EXACT prior source order so the registered-name
|
|
13
|
+
* set + the derived maps stay byte-identical. The extension tools rebuild the
|
|
14
|
+
* underlying browser context on mutation (Chromium can't add/remove extensions on
|
|
15
|
+
* a live context). The host owns the closures; the family modules own the
|
|
16
|
+
* registrations.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerExtensionsBatchTools(host: ToolHost): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { registerExtensionsTools } from "./extensions-tools.js";
|
|
2
|
+
import { registerBatchHumanTools } from "./batch-human-tools.js";
|
|
3
|
+
import { registerBatchActTools } from "./batch-act-tools.js";
|
|
4
|
+
/**
|
|
5
|
+
* Chrome-extension management + the server-side compound primitives:
|
|
6
|
+
* extensions_install / extensions_list / extensions_reload /
|
|
7
|
+
* extensions_trigger / extensions_uninstall, plus await_human, batch,
|
|
8
|
+
* act_and_sample, act_and_diff, flake_check.
|
|
9
|
+
*
|
|
10
|
+
* RFC 0004 P3 / D3 (SRP): the registrations were split by cohesive family into
|
|
11
|
+
* three sibling modules (extensions / batch-human / batch-act), and the
|
|
12
|
+
* persistent-session context rebuild was extracted to `extensions-rebuild.ts`.
|
|
13
|
+
* This module stays the single entry point `server.ts` + `tool-metadata.ts` call,
|
|
14
|
+
* and invokes each family in the EXACT prior source order so the registered-name
|
|
15
|
+
* set + the derived maps stay byte-identical. The extension tools rebuild the
|
|
16
|
+
* underlying browser context on mutation (Chromium can't add/remove extensions on
|
|
17
|
+
* a live context). The host owns the closures; the family modules own the
|
|
18
|
+
* registrations.
|
|
19
|
+
*/
|
|
20
|
+
export function registerExtensionsBatchTools(host) {
|
|
21
|
+
registerExtensionsTools(host);
|
|
22
|
+
registerBatchHumanTools(host);
|
|
23
|
+
registerBatchActTools(host);
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type SessionEntry } from "../session/registry.js";
|
|
2
|
+
import type { CapabilityConfig } from "../util/capabilities.js";
|
|
3
|
+
import type { ConfigStore, ResolvedConfig } from "../util/config-store.js";
|
|
4
|
+
import type { Workspace } from "../util/workspace.js";
|
|
5
|
+
import type { StartOptions } from "../server.js";
|
|
6
|
+
/** The per-server boundary deps the rebuild threads in (was the closure the
|
|
7
|
+
* in-module helper held over `buildHost`'s scope). Passed explicitly so a second
|
|
8
|
+
* server in the same process can't cross-wire this server's sessions. */
|
|
9
|
+
export interface ExtensionRebuildDeps {
|
|
10
|
+
caps: CapabilityConfig;
|
|
11
|
+
configStore: ConfigStore;
|
|
12
|
+
workspace: Workspace;
|
|
13
|
+
opts: StartOptions;
|
|
14
|
+
resolvedConfig: ResolvedConfig;
|
|
15
|
+
}
|
|
16
|
+
/** Rebuild the persistent session's browser context with the entry's current
|
|
17
|
+
* extension list reflected as launch flags. Closes the existing BrowserSession +
|
|
18
|
+
* bridge, relaunches via `openManagedSession`, and replaces the entry's inner
|
|
19
|
+
* pieces in-place so the registry mapping (sessionId → entry) stays valid. Caller
|
|
20
|
+
* MUST have verified the entry is `persistent` and not headless (via the
|
|
21
|
+
* extension-refusal check). */
|
|
22
|
+
export declare function rebuildPersistentForExtensions(e: SessionEntry, deps: ExtensionRebuildDeps): Promise<void>;
|