@agentrhq/webcmd 0.1.1 → 0.1.2
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/README.md +317 -24
- package/dist/src/adapter-shadow.d.ts +11 -0
- package/dist/src/adapter-shadow.js +72 -0
- package/dist/src/adapter-shadow.test.d.ts +1 -0
- package/dist/src/adapter-shadow.test.js +49 -0
- package/dist/src/adapter-source.d.ts +11 -0
- package/dist/src/adapter-source.js +24 -0
- package/dist/src/adapter-source.test.d.ts +1 -0
- package/dist/src/adapter-source.test.js +29 -0
- package/dist/src/brand.d.ts +9 -0
- package/dist/src/brand.js +9 -0
- package/dist/src/brand.test.d.ts +1 -0
- package/dist/src/brand.test.js +15 -0
- package/dist/src/browser/analyze.d.ts +118 -0
- package/dist/src/browser/analyze.js +405 -0
- package/dist/src/browser/analyze.test.d.ts +1 -0
- package/dist/src/browser/analyze.test.js +209 -0
- package/dist/src/browser/article-extract.d.ts +57 -0
- package/dist/src/browser/article-extract.e2e.test.d.ts +1 -0
- package/dist/src/browser/article-extract.e2e.test.js +105 -0
- package/dist/src/browser/article-extract.js +169 -0
- package/dist/src/browser/article-extract.test.d.ts +1 -0
- package/dist/src/browser/article-extract.test.js +94 -0
- package/dist/src/browser/ax-snapshot.d.ts +37 -0
- package/dist/src/browser/ax-snapshot.js +217 -0
- package/dist/src/browser/ax-snapshot.test.d.ts +1 -0
- package/dist/src/browser/ax-snapshot.test.js +91 -0
- package/dist/src/browser/base-page.d.ts +151 -0
- package/dist/src/browser/base-page.js +1060 -0
- package/dist/src/browser/base-page.test.d.ts +1 -0
- package/dist/src/browser/base-page.test.js +803 -0
- package/dist/src/browser/bridge-readiness.d.ts +14 -0
- package/dist/src/browser/bridge-readiness.js +24 -0
- package/dist/src/browser/bridge-readiness.test.d.ts +1 -0
- package/dist/src/browser/bridge-readiness.test.js +58 -0
- package/dist/src/browser/bridge.d.ts +26 -0
- package/dist/src/browser/bridge.js +58 -0
- package/dist/src/browser/cdp-click-fixture.test.d.ts +1 -0
- package/dist/src/browser/cdp-click-fixture.test.js +87 -0
- package/dist/src/browser/cdp.d.ts +46 -0
- package/dist/src/browser/cdp.js +536 -0
- package/dist/src/browser/cdp.test.d.ts +1 -0
- package/dist/src/browser/cdp.test.js +79 -0
- package/dist/src/browser/compound.d.ts +59 -0
- package/dist/src/browser/compound.js +112 -0
- package/dist/src/browser/compound.test.d.ts +1 -0
- package/dist/src/browser/compound.test.js +175 -0
- package/dist/src/browser/config.d.ts +2 -0
- package/dist/src/browser/config.js +14 -0
- package/dist/src/browser/daemon-client.d.ts +32 -0
- package/dist/src/browser/daemon-client.js +135 -0
- package/dist/src/browser/daemon-client.test.d.ts +1 -0
- package/dist/src/browser/daemon-client.test.js +326 -0
- package/dist/src/browser/daemon-lifecycle.d.ts +37 -0
- package/dist/src/browser/daemon-lifecycle.js +147 -0
- package/dist/src/browser/daemon-transport.d.ts +54 -0
- package/dist/src/browser/daemon-transport.js +68 -0
- package/dist/src/browser/daemon-version.d.ts +4 -0
- package/dist/src/browser/daemon-version.js +12 -0
- package/dist/src/browser/dom-helpers.d.ts +41 -0
- package/dist/src/browser/dom-helpers.js +239 -0
- package/dist/src/browser/dom-helpers.test.d.ts +1 -0
- package/dist/src/browser/dom-helpers.test.js +106 -0
- package/dist/src/browser/dom-snapshot.d.ts +93 -0
- package/dist/src/browser/dom-snapshot.js +894 -0
- package/dist/src/browser/dom-snapshot.test.d.ts +11 -0
- package/dist/src/browser/dom-snapshot.test.js +313 -0
- package/dist/src/browser/errors.d.ts +38 -0
- package/dist/src/browser/errors.js +79 -0
- package/dist/src/browser/errors.test.d.ts +1 -0
- package/dist/src/browser/errors.test.js +60 -0
- package/dist/src/browser/extract.d.ts +69 -0
- package/dist/src/browser/extract.js +132 -0
- package/dist/src/browser/extract.test.d.ts +1 -0
- package/dist/src/browser/extract.test.js +129 -0
- package/dist/src/browser/find.d.ts +84 -0
- package/dist/src/browser/find.js +398 -0
- package/dist/src/browser/find.test.d.ts +1 -0
- package/dist/src/browser/find.test.js +180 -0
- package/dist/src/browser/html-tree.d.ts +75 -0
- package/dist/src/browser/html-tree.js +112 -0
- package/dist/src/browser/html-tree.test.d.ts +1 -0
- package/dist/src/browser/html-tree.test.js +181 -0
- package/dist/src/browser/index.d.ts +14 -0
- package/dist/src/browser/index.js +12 -0
- package/dist/src/browser/network-cache.d.ts +49 -0
- package/dist/src/browser/network-cache.js +78 -0
- package/dist/src/browser/network-cache.test.d.ts +1 -0
- package/dist/src/browser/network-cache.test.js +75 -0
- package/dist/src/browser/network-interceptor.d.ts +11 -0
- package/dist/src/browser/network-interceptor.js +11 -0
- package/dist/src/browser/network-key.d.ts +22 -0
- package/dist/src/browser/network-key.js +66 -0
- package/dist/src/browser/network-key.test.d.ts +1 -0
- package/dist/src/browser/network-key.test.js +49 -0
- package/dist/src/browser/page.d.ts +83 -0
- package/dist/src/browser/page.js +453 -0
- package/dist/src/browser/page.test.d.ts +1 -0
- package/dist/src/browser/page.test.js +406 -0
- package/dist/src/browser/profile.d.ts +14 -0
- package/dist/src/browser/profile.js +86 -0
- package/dist/src/browser/protocol.d.ts +63 -0
- package/dist/src/browser/protocol.js +1 -0
- package/dist/src/browser/runtime/local-cloak/actions.d.ts +3 -0
- package/dist/src/browser/runtime/local-cloak/actions.js +240 -0
- package/dist/src/browser/runtime/local-cloak/downloads.d.ts +3 -0
- package/dist/src/browser/runtime/local-cloak/downloads.js +28 -0
- package/dist/src/browser/runtime/local-cloak/network.d.ts +28 -0
- package/dist/src/browser/runtime/local-cloak/network.js +120 -0
- package/dist/src/browser/runtime/local-cloak/network.test.d.ts +1 -0
- package/dist/src/browser/runtime/local-cloak/network.test.js +124 -0
- package/dist/src/browser/runtime/local-cloak/profiles.d.ts +6 -0
- package/dist/src/browser/runtime/local-cloak/profiles.js +17 -0
- package/dist/src/browser/runtime/local-cloak/profiles.test.d.ts +1 -0
- package/dist/src/browser/runtime/local-cloak/profiles.test.js +19 -0
- package/dist/src/browser/runtime/local-cloak/provider.d.ts +15 -0
- package/dist/src/browser/runtime/local-cloak/provider.js +27 -0
- package/dist/src/browser/runtime/local-cloak/provider.test.d.ts +1 -0
- package/dist/src/browser/runtime/local-cloak/provider.test.js +244 -0
- package/dist/src/browser/runtime/local-cloak/session-manager.d.ts +77 -0
- package/dist/src/browser/runtime/local-cloak/session-manager.js +280 -0
- package/dist/src/browser/runtime/local-cloak/session-manager.test.d.ts +1 -0
- package/dist/src/browser/runtime/local-cloak/session-manager.test.js +92 -0
- package/dist/src/browser/runtime/provider.d.ts +9 -0
- package/dist/src/browser/runtime/provider.js +1 -0
- package/dist/src/browser/runtime/provider.test.d.ts +2 -0
- package/dist/src/browser/runtime/provider.test.js +49 -0
- package/dist/src/browser/shape-filter.d.ts +52 -0
- package/dist/src/browser/shape-filter.js +101 -0
- package/dist/src/browser/shape-filter.test.d.ts +1 -0
- package/dist/src/browser/shape-filter.test.js +101 -0
- package/dist/src/browser/shape.d.ts +23 -0
- package/dist/src/browser/shape.js +95 -0
- package/dist/src/browser/shape.test.d.ts +1 -0
- package/dist/src/browser/shape.test.js +82 -0
- package/dist/src/browser/stealth.d.ts +11 -0
- package/dist/src/browser/stealth.js +359 -0
- package/dist/src/browser/stealth.test.d.ts +1 -0
- package/dist/src/browser/stealth.test.js +134 -0
- package/dist/src/browser/tabs.d.ts +13 -0
- package/dist/src/browser/tabs.js +70 -0
- package/dist/src/browser/target-errors.d.ts +39 -0
- package/dist/src/browser/target-errors.js +45 -0
- package/dist/src/browser/target-errors.test.d.ts +1 -0
- package/dist/src/browser/target-errors.test.js +94 -0
- package/dist/src/browser/target-resolver.d.ts +158 -0
- package/dist/src/browser/target-resolver.js +570 -0
- package/dist/src/browser/target-resolver.test.d.ts +1 -0
- package/dist/src/browser/target-resolver.test.js +118 -0
- package/dist/src/browser/utils.d.ts +20 -0
- package/dist/src/browser/utils.js +64 -0
- package/dist/src/browser/utils.test.d.ts +1 -0
- package/dist/src/browser/utils.test.js +29 -0
- package/dist/src/browser/verify-fixture.d.ts +65 -0
- package/dist/src/browser/verify-fixture.js +318 -0
- package/dist/src/browser/verify-fixture.test.d.ts +1 -0
- package/dist/src/browser/verify-fixture.test.js +219 -0
- package/dist/src/browser/visual-refs.d.ts +11 -0
- package/dist/src/browser/visual-refs.js +108 -0
- package/dist/src/browser.test.d.ts +1 -0
- package/dist/src/browser.test.js +297 -0
- package/dist/src/build-manifest.d.ts +103 -0
- package/dist/src/build-manifest.js +363 -0
- package/dist/src/build-manifest.test.d.ts +1 -0
- package/dist/src/build-manifest.test.js +341 -0
- package/dist/src/capabilityRouting.d.ts +19 -0
- package/dist/src/capabilityRouting.js +56 -0
- package/dist/src/capabilityRouting.test.d.ts +1 -0
- package/dist/src/capabilityRouting.test.js +63 -0
- package/dist/src/cli-argv-preprocess.d.ts +63 -0
- package/dist/src/cli-argv-preprocess.js +303 -0
- package/dist/src/cli-argv-preprocess.test.d.ts +1 -0
- package/dist/src/cli-argv-preprocess.test.js +304 -0
- package/dist/src/cli.d.ts +79 -0
- package/dist/src/cli.js +3350 -0
- package/dist/src/cli.test.d.ts +1 -0
- package/dist/src/cli.test.js +3041 -0
- package/dist/src/commanderAdapter.d.ts +21 -0
- package/dist/src/commanderAdapter.js +208 -0
- package/dist/src/commanderAdapter.test.d.ts +1 -0
- package/dist/src/commanderAdapter.test.js +352 -0
- package/dist/src/commands/auth.d.ts +40 -0
- package/dist/src/commands/auth.js +434 -0
- package/dist/src/commands/auth.test.d.ts +1 -0
- package/dist/src/commands/auth.test.js +252 -0
- package/dist/src/commands/daemon.d.ts +9 -0
- package/dist/src/commands/daemon.js +91 -0
- package/dist/src/commands/daemon.test.d.ts +1 -0
- package/dist/src/commands/daemon.test.js +293 -0
- package/dist/src/completion-fast.d.ts +22 -0
- package/dist/src/completion-fast.js +88 -0
- package/dist/src/completion-shared.d.ts +13 -0
- package/dist/src/completion-shared.js +61 -0
- package/dist/src/completion.d.ts +21 -0
- package/dist/src/completion.js +68 -0
- package/dist/src/completion.test.d.ts +1 -0
- package/dist/src/completion.test.js +24 -0
- package/dist/src/constants.d.ts +18 -0
- package/dist/src/constants.js +41 -0
- package/dist/src/convention-audit.d.ts +50 -0
- package/dist/src/convention-audit.js +553 -0
- package/dist/src/convention-audit.test.d.ts +1 -0
- package/dist/src/convention-audit.test.js +255 -0
- package/dist/src/daemon/server.d.ts +13 -0
- package/dist/src/daemon/server.js +185 -0
- package/dist/src/daemon/server.test.d.ts +1 -0
- package/dist/src/daemon/server.test.js +132 -0
- package/dist/src/daemon-utils.d.ts +18 -0
- package/dist/src/daemon-utils.js +37 -0
- package/dist/src/daemon.d.ts +1 -0
- package/dist/src/daemon.js +27 -0
- package/dist/src/daemon.test.d.ts +1 -0
- package/dist/src/daemon.test.js +60 -0
- package/dist/src/discovery.d.ts +46 -0
- package/dist/src/discovery.js +341 -0
- package/dist/src/doctor.d.ts +39 -0
- package/dist/src/doctor.js +168 -0
- package/dist/src/doctor.test.d.ts +1 -0
- package/dist/src/doctor.test.js +302 -0
- package/dist/src/download/article-download.d.ts +72 -0
- package/dist/src/download/article-download.js +305 -0
- package/dist/src/download/article-download.test.d.ts +1 -0
- package/dist/src/download/article-download.test.js +235 -0
- package/dist/src/download/index.d.ts +71 -0
- package/dist/src/download/index.js +363 -0
- package/dist/src/download/index.test.d.ts +1 -0
- package/dist/src/download/index.test.js +174 -0
- package/dist/src/download/media-download.d.ts +49 -0
- package/dist/src/download/media-download.js +127 -0
- package/dist/src/download/media-download.test.d.ts +1 -0
- package/dist/src/download/media-download.test.js +112 -0
- package/dist/src/download/progress.d.ts +36 -0
- package/dist/src/download/progress.js +120 -0
- package/dist/src/download/progress.test.d.ts +1 -0
- package/dist/src/download/progress.test.js +36 -0
- package/dist/src/electron-apps.d.ts +31 -0
- package/dist/src/electron-apps.js +91 -0
- package/dist/src/electron-apps.test.d.ts +1 -0
- package/dist/src/electron-apps.test.js +76 -0
- package/dist/src/engine.test.d.ts +1 -0
- package/dist/src/engine.test.js +312 -0
- package/dist/src/errors.d.ts +114 -0
- package/dist/src/errors.js +174 -0
- package/dist/src/errors.test.d.ts +1 -0
- package/dist/src/errors.test.js +109 -0
- package/dist/src/execution.d.ts +24 -0
- package/dist/src/execution.js +509 -0
- package/dist/src/execution.test.d.ts +1 -0
- package/dist/src/execution.test.js +645 -0
- package/dist/src/external.d.ts +49 -0
- package/dist/src/external.js +211 -0
- package/dist/src/external.test.d.ts +1 -0
- package/dist/src/external.test.js +110 -0
- package/dist/src/help.d.ts +88 -0
- package/dist/src/help.js +556 -0
- package/dist/src/help.test.d.ts +1 -0
- package/dist/src/help.test.js +58 -0
- package/dist/src/hooks.d.ts +46 -0
- package/dist/src/hooks.js +58 -0
- package/dist/src/hooks.test.d.ts +4 -0
- package/dist/src/hooks.test.js +92 -0
- package/dist/src/interceptor.d.ts +44 -0
- package/dist/src/interceptor.js +183 -0
- package/dist/src/interceptor.test.d.ts +4 -0
- package/dist/src/interceptor.test.js +81 -0
- package/dist/src/launcher.d.ts +41 -0
- package/dist/src/launcher.js +226 -0
- package/dist/src/launcher.test.d.ts +1 -0
- package/dist/src/launcher.test.js +153 -0
- package/dist/src/logger.d.ts +26 -0
- package/dist/src/logger.js +49 -0
- package/dist/src/main.d.ts +5 -0
- package/dist/src/main.js +177 -0
- package/dist/src/manifest-types.d.ts +43 -0
- package/dist/src/manifest-types.js +9 -0
- package/dist/src/node-network.d.ts +10 -0
- package/dist/src/node-network.js +174 -0
- package/dist/src/node-network.test.d.ts +1 -0
- package/dist/src/node-network.test.js +55 -0
- package/dist/src/observation/artifact.d.ts +16 -0
- package/dist/src/observation/artifact.js +260 -0
- package/dist/src/observation/artifact.test.d.ts +1 -0
- package/dist/src/observation/artifact.test.js +121 -0
- package/dist/src/observation/events.d.ts +89 -0
- package/dist/src/observation/events.js +1 -0
- package/dist/src/observation/index.d.ts +7 -0
- package/dist/src/observation/index.js +7 -0
- package/dist/src/observation/manager.d.ts +9 -0
- package/dist/src/observation/manager.js +27 -0
- package/dist/src/observation/manager.test.d.ts +1 -0
- package/dist/src/observation/manager.test.js +13 -0
- package/dist/src/observation/redaction.d.ts +11 -0
- package/dist/src/observation/redaction.js +81 -0
- package/dist/src/observation/redaction.test.d.ts +1 -0
- package/dist/src/observation/redaction.test.js +32 -0
- package/dist/src/observation/retention.d.ts +32 -0
- package/dist/src/observation/retention.js +160 -0
- package/dist/src/observation/retention.test.d.ts +1 -0
- package/dist/src/observation/retention.test.js +118 -0
- package/dist/src/observation/ring-buffer.d.ts +22 -0
- package/dist/src/observation/ring-buffer.js +45 -0
- package/dist/src/observation/ring-buffer.test.d.ts +1 -0
- package/dist/src/observation/ring-buffer.test.js +22 -0
- package/dist/src/observation/session.d.ts +25 -0
- package/dist/src/observation/session.js +50 -0
- package/dist/src/output.d.ts +14 -0
- package/dist/src/output.js +152 -0
- package/dist/src/output.test.d.ts +1 -0
- package/dist/src/output.test.js +53 -0
- package/dist/src/package-exports.test.d.ts +1 -0
- package/dist/src/package-exports.test.js +112 -0
- package/dist/src/package-paths.d.ts +8 -0
- package/dist/src/package-paths.js +41 -0
- package/dist/src/pipeline/executor.d.ts +11 -0
- package/dist/src/pipeline/executor.js +93 -0
- package/dist/src/pipeline/executor.test.d.ts +4 -0
- package/dist/src/pipeline/executor.test.js +182 -0
- package/dist/src/pipeline/index.d.ts +5 -0
- package/dist/src/pipeline/index.js +5 -0
- package/dist/src/pipeline/registry.d.ts +28 -0
- package/dist/src/pipeline/registry.js +55 -0
- package/dist/src/pipeline/steps/browser.d.ts +13 -0
- package/dist/src/pipeline/steps/browser.js +86 -0
- package/dist/src/pipeline/steps/download.d.ts +18 -0
- package/dist/src/pipeline/steps/download.js +252 -0
- package/dist/src/pipeline/steps/download.test.d.ts +1 -0
- package/dist/src/pipeline/steps/download.test.js +102 -0
- package/dist/src/pipeline/steps/fetch.d.ts +5 -0
- package/dist/src/pipeline/steps/fetch.js +122 -0
- package/dist/src/pipeline/steps/fetch.test.d.ts +1 -0
- package/dist/src/pipeline/steps/fetch.test.js +117 -0
- package/dist/src/pipeline/steps/intercept.d.ts +5 -0
- package/dist/src/pipeline/steps/intercept.js +50 -0
- package/dist/src/pipeline/steps/tap.d.ts +12 -0
- package/dist/src/pipeline/steps/tap.js +93 -0
- package/dist/src/pipeline/steps/transform.d.ts +9 -0
- package/dist/src/pipeline/steps/transform.js +70 -0
- package/dist/src/pipeline/template.d.ts +17 -0
- package/dist/src/pipeline/template.js +344 -0
- package/dist/src/pipeline/template.test.d.ts +4 -0
- package/dist/src/pipeline/template.test.js +197 -0
- package/dist/src/pipeline/transform.test.d.ts +4 -0
- package/dist/src/pipeline/transform.test.js +133 -0
- package/dist/src/plugin-manifest.d.ts +70 -0
- package/dist/src/plugin-manifest.js +160 -0
- package/dist/src/plugin-manifest.test.d.ts +4 -0
- package/dist/src/plugin-manifest.test.js +179 -0
- package/dist/src/plugin-scaffold.d.ts +28 -0
- package/dist/src/plugin-scaffold.js +143 -0
- package/dist/src/plugin-scaffold.test.d.ts +4 -0
- package/dist/src/plugin-scaffold.test.js +83 -0
- package/dist/src/plugin.d.ts +146 -0
- package/dist/src/plugin.js +1303 -0
- package/dist/src/plugin.test.d.ts +4 -0
- package/dist/src/plugin.test.js +1363 -0
- package/dist/src/registry-api.d.ts +13 -0
- package/dist/src/registry-api.js +10 -0
- package/dist/src/registry.d.ts +123 -0
- package/dist/src/registry.js +125 -0
- package/dist/src/registry.test.d.ts +4 -0
- package/dist/src/registry.test.js +209 -0
- package/dist/src/runtime-copy.test.d.ts +1 -0
- package/dist/src/runtime-copy.test.js +29 -0
- package/dist/src/runtime-detect.d.ts +31 -0
- package/dist/src/runtime-detect.js +47 -0
- package/dist/src/runtime-detect.test.d.ts +1 -0
- package/dist/src/runtime-detect.test.js +39 -0
- package/dist/src/runtime-identity.test.d.ts +1 -0
- package/dist/src/runtime-identity.test.js +18 -0
- package/dist/src/runtime.d.ts +47 -0
- package/dist/src/runtime.js +54 -0
- package/dist/src/scripts/framework.d.ts +7 -0
- package/dist/src/scripts/framework.js +25 -0
- package/dist/src/scripts/interact.d.ts +4 -0
- package/dist/src/scripts/interact.js +20 -0
- package/dist/src/scripts/store.d.ts +13 -0
- package/dist/src/scripts/store.js +48 -0
- package/dist/src/serialization.d.ts +42 -0
- package/dist/src/serialization.js +103 -0
- package/dist/src/serialization.test.d.ts +1 -0
- package/dist/src/serialization.test.js +78 -0
- package/dist/src/skills.d.ts +14 -0
- package/dist/src/skills.js +127 -0
- package/dist/src/skills.test.d.ts +1 -0
- package/dist/src/skills.test.js +71 -0
- package/dist/src/snapshotFormatter.d.ts +11 -0
- package/dist/src/snapshotFormatter.js +338 -0
- package/dist/src/snapshotFormatter.test.d.ts +7 -0
- package/dist/src/snapshotFormatter.test.js +521 -0
- package/dist/src/tui.d.ts +28 -0
- package/dist/src/tui.js +179 -0
- package/dist/src/tui.test.d.ts +1 -0
- package/dist/src/tui.test.js +19 -0
- package/dist/src/types.d.ts +236 -0
- package/dist/src/types.js +7 -0
- package/dist/src/update-check.d.ts +66 -0
- package/dist/src/update-check.js +206 -0
- package/dist/src/update-check.test.d.ts +1 -0
- package/dist/src/update-check.test.js +117 -0
- package/dist/src/utils.d.ts +57 -0
- package/dist/src/utils.js +152 -0
- package/dist/src/utils.test.d.ts +1 -0
- package/dist/src/utils.test.js +155 -0
- package/dist/src/validate.d.ts +21 -0
- package/dist/src/validate.js +130 -0
- package/dist/src/validate.test.d.ts +9 -0
- package/dist/src/validate.test.js +90 -0
- package/dist/src/verify.d.ts +26 -0
- package/dist/src/verify.js +67 -0
- package/dist/src/version.d.ts +4 -0
- package/dist/src/version.js +22 -0
- package/dist/src/weixin-download.test.d.ts +1 -0
- package/dist/src/weixin-download.test.js +45 -0
- package/package.json +4 -3
- package/scripts/check-package-bin.mjs +95 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { TargetError } from './target-errors.js';
|
|
3
|
+
describe('TargetError', () => {
|
|
4
|
+
it('creates not_found error with code and hint', () => {
|
|
5
|
+
const err = new TargetError({
|
|
6
|
+
code: 'not_found',
|
|
7
|
+
message: 'ref=99 not found in DOM',
|
|
8
|
+
hint: 'Re-run `webcmd browser state` to get a fresh snapshot.',
|
|
9
|
+
});
|
|
10
|
+
expect(err).toBeInstanceOf(Error);
|
|
11
|
+
expect(err.name).toBe('TargetError');
|
|
12
|
+
expect(err.code).toBe('not_found');
|
|
13
|
+
expect(err.message).toBe('ref=99 not found in DOM');
|
|
14
|
+
expect(err.hint).toContain('fresh snapshot');
|
|
15
|
+
expect(err.candidates).toBeUndefined();
|
|
16
|
+
});
|
|
17
|
+
it('creates selector_ambiguous error with candidates + matches_n', () => {
|
|
18
|
+
const err = new TargetError({
|
|
19
|
+
code: 'selector_ambiguous',
|
|
20
|
+
message: 'CSS selector ".btn" matched 3 elements',
|
|
21
|
+
hint: 'Use a more specific selector, or pass --nth.',
|
|
22
|
+
candidates: ['<button> "Login"', '<button> "Sign Up"', '<button> "Cancel"'],
|
|
23
|
+
matches_n: 3,
|
|
24
|
+
});
|
|
25
|
+
expect(err.code).toBe('selector_ambiguous');
|
|
26
|
+
expect(err.candidates).toHaveLength(3);
|
|
27
|
+
expect(err.candidates[0]).toContain('Login');
|
|
28
|
+
expect(err.matches_n).toBe(3);
|
|
29
|
+
});
|
|
30
|
+
it('creates invalid_selector error', () => {
|
|
31
|
+
const err = new TargetError({
|
|
32
|
+
code: 'invalid_selector',
|
|
33
|
+
message: 'Invalid CSS selector: >>> (unexpected token)',
|
|
34
|
+
hint: 'Check the selector syntax.',
|
|
35
|
+
});
|
|
36
|
+
expect(err.code).toBe('invalid_selector');
|
|
37
|
+
expect(err.message).toContain('Invalid CSS selector');
|
|
38
|
+
});
|
|
39
|
+
it('creates selector_not_found error with matches_n=0', () => {
|
|
40
|
+
const err = new TargetError({
|
|
41
|
+
code: 'selector_not_found',
|
|
42
|
+
message: 'CSS selector ".missing" matched 0 elements',
|
|
43
|
+
hint: 'Check the page or use browser find.',
|
|
44
|
+
matches_n: 0,
|
|
45
|
+
});
|
|
46
|
+
expect(err.code).toBe('selector_not_found');
|
|
47
|
+
expect(err.matches_n).toBe(0);
|
|
48
|
+
});
|
|
49
|
+
it('creates selector_nth_out_of_range error', () => {
|
|
50
|
+
const err = new TargetError({
|
|
51
|
+
code: 'selector_nth_out_of_range',
|
|
52
|
+
message: 'matched 3 elements, but --nth=5 is out of range',
|
|
53
|
+
hint: 'Use --nth between 0 and 2.',
|
|
54
|
+
matches_n: 3,
|
|
55
|
+
});
|
|
56
|
+
expect(err.code).toBe('selector_nth_out_of_range');
|
|
57
|
+
expect(err.matches_n).toBe(3);
|
|
58
|
+
});
|
|
59
|
+
it('creates stale_ref error', () => {
|
|
60
|
+
const err = new TargetError({
|
|
61
|
+
code: 'stale_ref',
|
|
62
|
+
message: 'ref=12 was <button>"Login" but now points to <div>"Header"',
|
|
63
|
+
hint: 'Re-run `webcmd browser state` to refresh.',
|
|
64
|
+
});
|
|
65
|
+
expect(err.code).toBe('stale_ref');
|
|
66
|
+
expect(err.message).toContain('was <button>');
|
|
67
|
+
});
|
|
68
|
+
it('serializes to JSON for structured output', () => {
|
|
69
|
+
const err = new TargetError({
|
|
70
|
+
code: 'selector_ambiguous',
|
|
71
|
+
message: 'matched 3',
|
|
72
|
+
hint: 'be specific',
|
|
73
|
+
candidates: ['a', 'b'],
|
|
74
|
+
matches_n: 3,
|
|
75
|
+
});
|
|
76
|
+
const json = err.toJSON();
|
|
77
|
+
expect(json).toEqual({
|
|
78
|
+
code: 'selector_ambiguous',
|
|
79
|
+
message: 'matched 3',
|
|
80
|
+
hint: 'be specific',
|
|
81
|
+
candidates: ['a', 'b'],
|
|
82
|
+
matches_n: 3,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
it('omits candidates from JSON when not present', () => {
|
|
86
|
+
const err = new TargetError({
|
|
87
|
+
code: 'not_found',
|
|
88
|
+
message: 'gone',
|
|
89
|
+
hint: 'refresh',
|
|
90
|
+
});
|
|
91
|
+
const json = err.toJSON();
|
|
92
|
+
expect(json).not.toHaveProperty('candidates');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified target resolver for browser actions.
|
|
3
|
+
*
|
|
4
|
+
* Resolution pipeline:
|
|
5
|
+
*
|
|
6
|
+
* 1. Input classification: all-digit → numeric ref path, otherwise → CSS path.
|
|
7
|
+
* The CSS path passes the raw string to `querySelectorAll` and lets the
|
|
8
|
+
* browser parser decide what's valid. No frontend regex whitelist — the
|
|
9
|
+
* goal is that any selector accepted by `browser find --css` is accepted
|
|
10
|
+
* by the same selector on `get/click/type/select`.
|
|
11
|
+
* 2. Ref path: cascading match levels (see below), using data-webcmd-ref
|
|
12
|
+
* plus the fingerprint map populated by snapshot + find.
|
|
13
|
+
* 3. CSS path: querySelectorAll + match-count policy (see ResolveOptions)
|
|
14
|
+
* 4. Structured errors:
|
|
15
|
+
* - numeric: not_found / stale_ref
|
|
16
|
+
* - CSS: invalid_selector / selector_not_found / selector_ambiguous
|
|
17
|
+
* / selector_nth_out_of_range
|
|
18
|
+
*
|
|
19
|
+
* All JS is generated as strings for page.evaluate() — runs in the browser.
|
|
20
|
+
*
|
|
21
|
+
* ── Cascading stale-ref (browser-use style) ──────────────────────────
|
|
22
|
+
* Strict equality on the fingerprint rejected too many live pages — SPA
|
|
23
|
+
* re-renders swap text / role while keeping id + testId. The resolver
|
|
24
|
+
* now walks three tiers before giving up:
|
|
25
|
+
*
|
|
26
|
+
* 1. EXACT — tag + strong id (id or testId) agree, ≤1 soft mismatch
|
|
27
|
+
* 2. STABLE — tag + strong id agree, soft signals drifted (aria-label,
|
|
28
|
+
* role, text) — agent gets a warning but the action
|
|
29
|
+
* proceeds so dynamic pages don't stall
|
|
30
|
+
* 3. REIDENTIFIED — original ref either missing from the DOM or fully
|
|
31
|
+
* mismatched, but the fingerprint uniquely identifies
|
|
32
|
+
* a single other live element via id / testId /
|
|
33
|
+
* aria-label. Re-tag that element with the old ref and
|
|
34
|
+
* surface match_level so the caller knows we swapped.
|
|
35
|
+
*
|
|
36
|
+
* Only when all three fail do we emit `stale_ref`. Every success envelope
|
|
37
|
+
* carries `match_level` so downstream CLIs can surface the weakest tier
|
|
38
|
+
* a caller actually traversed.
|
|
39
|
+
*/
|
|
40
|
+
export interface ResolveOptions {
|
|
41
|
+
/**
|
|
42
|
+
* When CSS matches multiple elements, pick the element at this 0-based
|
|
43
|
+
* index instead of raising `selector_ambiguous`. Raises
|
|
44
|
+
* `selector_nth_out_of_range` if `nth >= matches.length`.
|
|
45
|
+
*/
|
|
46
|
+
nth?: number;
|
|
47
|
+
/**
|
|
48
|
+
* When CSS matches multiple elements, pick the first match instead of
|
|
49
|
+
* raising `selector_ambiguous`. Used by read commands (get text / value /
|
|
50
|
+
* attributes) to deliver a best-effort answer + matches_n in the envelope.
|
|
51
|
+
* Ignored when `nth` is also set (nth wins).
|
|
52
|
+
*/
|
|
53
|
+
firstOnMulti?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Tier the resolver traversed to land the target. Callers may surface this to agents. */
|
|
56
|
+
export type TargetMatchLevel = 'exact' | 'stable' | 'reidentified';
|
|
57
|
+
/**
|
|
58
|
+
* Generate JS that resolves a target to a single DOM element.
|
|
59
|
+
*
|
|
60
|
+
* Returns a JS expression that evaluates to:
|
|
61
|
+
* { ok: true, matches_n, match_level } — success (el stored in `__resolved`)
|
|
62
|
+
* { ok: false, code, message, hint, candidates, matches_n? } — structured error
|
|
63
|
+
*
|
|
64
|
+
* `match_level` is always set on success:
|
|
65
|
+
* - CSS path → 'exact'
|
|
66
|
+
* - numeric ref path → whichever tier matched ('exact' / 'stable' / 'reidentified')
|
|
67
|
+
*
|
|
68
|
+
* The resolved element is stored in `window.__resolved` for downstream helpers.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveTargetJs(ref: string, opts?: ResolveOptions): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate JS that scrolls + measures `__resolved` without clicking.
|
|
73
|
+
*
|
|
74
|
+
* Generic click prefers CDP `Input.dispatchMouseEvent`, which fires the full
|
|
75
|
+
* pointer/mouse chain that Radix/MUI/shadcn dropdowns rely on. Keep measurement
|
|
76
|
+
* separate so the CDP-primary path does not call DOM `el.click()` first.
|
|
77
|
+
*/
|
|
78
|
+
export declare function boundingRectResolvedJs(opts?: {
|
|
79
|
+
skipScroll?: boolean;
|
|
80
|
+
}): string;
|
|
81
|
+
/**
|
|
82
|
+
* Generate JS for click that uses the unified resolver.
|
|
83
|
+
* Assumes resolveTargetJs has been called and __resolved is set.
|
|
84
|
+
*
|
|
85
|
+
* This is the JS fallback path. BasePage.click uses boundingRectResolvedJs for
|
|
86
|
+
* the CDP-primary path and only reaches this when native click is unavailable
|
|
87
|
+
* or the target has no usable rect.
|
|
88
|
+
*/
|
|
89
|
+
export declare function clickResolvedJs(opts?: {
|
|
90
|
+
skipScroll?: boolean;
|
|
91
|
+
}): string;
|
|
92
|
+
/**
|
|
93
|
+
* Generate JS for type that uses the unified resolver.
|
|
94
|
+
*/
|
|
95
|
+
export declare function typeResolvedJs(text: string): string;
|
|
96
|
+
export type FillResolvedResult = {
|
|
97
|
+
ok: true;
|
|
98
|
+
actual: string;
|
|
99
|
+
expected: string;
|
|
100
|
+
length: number;
|
|
101
|
+
mode: 'input' | 'textarea' | 'contenteditable';
|
|
102
|
+
} | {
|
|
103
|
+
ok: false;
|
|
104
|
+
actual: string;
|
|
105
|
+
expected: string;
|
|
106
|
+
length: number;
|
|
107
|
+
mode: 'input' | 'textarea' | 'contenteditable';
|
|
108
|
+
} | {
|
|
109
|
+
ok: false;
|
|
110
|
+
reason: string;
|
|
111
|
+
tag?: string;
|
|
112
|
+
type?: string;
|
|
113
|
+
role?: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Prepare the resolved element for native CDP Input.insertText.
|
|
117
|
+
*
|
|
118
|
+
* This preserves `browser type`'s existing "replace current text" semantics:
|
|
119
|
+
* focus the editable target, select its current contents, then let CDP insert
|
|
120
|
+
* real browser text input so rich editors can update their internal state.
|
|
121
|
+
*/
|
|
122
|
+
export declare function prepareNativeTypeResolvedJs(opts?: {
|
|
123
|
+
skipScroll?: boolean;
|
|
124
|
+
skipFocus?: boolean;
|
|
125
|
+
}): string;
|
|
126
|
+
/**
|
|
127
|
+
* Verify the exact value/text currently held by the resolved editable target.
|
|
128
|
+
* Assumes resolveTargetJs and prepareNativeTypeResolvedJs have already set
|
|
129
|
+
* `window.__resolved` to the normalized editable host.
|
|
130
|
+
*/
|
|
131
|
+
export declare function verifyFilledResolvedJs(expected: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Generate JS for scrollTo that uses the unified resolver.
|
|
134
|
+
* Assumes resolveTargetJs has been called and __resolved is set.
|
|
135
|
+
*/
|
|
136
|
+
export declare function scrollResolvedJs(opts?: {
|
|
137
|
+
skipScroll?: boolean;
|
|
138
|
+
}): string;
|
|
139
|
+
/**
|
|
140
|
+
* Generate JS to get text content of resolved element.
|
|
141
|
+
*/
|
|
142
|
+
export declare function getTextResolvedJs(): string;
|
|
143
|
+
/**
|
|
144
|
+
* Generate JS to get value of resolved input/textarea element.
|
|
145
|
+
*/
|
|
146
|
+
export declare function getValueResolvedJs(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Generate JS to get all attributes of resolved element.
|
|
149
|
+
*/
|
|
150
|
+
export declare function getAttributesResolvedJs(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Generate JS to select an option on a resolved <select> element.
|
|
153
|
+
*/
|
|
154
|
+
export declare function selectResolvedJs(option: string): string;
|
|
155
|
+
/**
|
|
156
|
+
* Generate JS to check if resolved element is an autocomplete/combobox field.
|
|
157
|
+
*/
|
|
158
|
+
export declare function isAutocompleteResolvedJs(): string;
|