@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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aria snapshot formatter: parses snapshot text into clean format.
|
|
3
|
+
*
|
|
4
|
+
* 4-pass pipeline:
|
|
5
|
+
* 1. Parse & filter: strip annotations, metadata, noise, ads, boilerplate subtrees
|
|
6
|
+
* 2. Deduplicate: generic/text parent match, heading+link, nested identical links
|
|
7
|
+
* 3. Prune: empty containers (iterative bottom-up)
|
|
8
|
+
* 4. Collapse: single-child containers
|
|
9
|
+
*/
|
|
10
|
+
import type { SnapshotOptions } from './types.js';
|
|
11
|
+
export declare function formatSnapshot(raw: string, opts?: SnapshotOptions): string;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aria snapshot formatter: parses snapshot text into clean format.
|
|
3
|
+
*
|
|
4
|
+
* 4-pass pipeline:
|
|
5
|
+
* 1. Parse & filter: strip annotations, metadata, noise, ads, boilerplate subtrees
|
|
6
|
+
* 2. Deduplicate: generic/text parent match, heading+link, nested identical links
|
|
7
|
+
* 3. Prune: empty containers (iterative bottom-up)
|
|
8
|
+
* 4. Collapse: single-child containers
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_MAX_TEXT_LENGTH = 200;
|
|
11
|
+
// Roles that are pure noise and should always be filtered
|
|
12
|
+
const NOISE_ROLES = new Set([
|
|
13
|
+
'none', 'presentation', 'separator', 'paragraph', 'tooltip', 'status',
|
|
14
|
+
]);
|
|
15
|
+
// Roles whose entire subtree should be removed (footer boilerplate, etc.)
|
|
16
|
+
const SUBTREE_NOISE_ROLES = new Set([
|
|
17
|
+
'contentinfo',
|
|
18
|
+
]);
|
|
19
|
+
// Roles considered interactive (clickable/typeable)
|
|
20
|
+
const INTERACTIVE_ROLES = new Set([
|
|
21
|
+
'button', 'link', 'textbox', 'checkbox', 'radio',
|
|
22
|
+
'combobox', 'tab', 'menuitem', 'option', 'switch',
|
|
23
|
+
'slider', 'spinbutton', 'searchbox',
|
|
24
|
+
]);
|
|
25
|
+
// Structural landmark roles kept even in interactive mode
|
|
26
|
+
const LANDMARK_ROLES = new Set([
|
|
27
|
+
'main', 'navigation', 'banner', 'heading', 'search',
|
|
28
|
+
'region', 'list', 'listitem', 'article', 'complementary',
|
|
29
|
+
'group', 'toolbar', 'tablist',
|
|
30
|
+
]);
|
|
31
|
+
// Container roles eligible for pruning and collapse
|
|
32
|
+
const CONTAINER_ROLES = new Set([
|
|
33
|
+
'list', 'listitem', 'group', 'toolbar', 'tablist',
|
|
34
|
+
'navigation', 'region', 'complementary',
|
|
35
|
+
'search', 'article', 'paragraph', 'figure',
|
|
36
|
+
]);
|
|
37
|
+
// Decorator / separator text that adds no semantic value
|
|
38
|
+
const DECORATOR_TEXT = new Set(['•', '·', '|', '—', '-', '/', '\\']);
|
|
39
|
+
// Ad-related URL patterns
|
|
40
|
+
const AD_URL_PATTERNS = [
|
|
41
|
+
'googleadservices.com/pagead/',
|
|
42
|
+
'alb.reddit.com/cr?',
|
|
43
|
+
'doubleclick.net/',
|
|
44
|
+
'cm.bilibili.com/cm/api/fees/',
|
|
45
|
+
];
|
|
46
|
+
// Boilerplate button labels to filter (back-to-top, etc.)
|
|
47
|
+
const BOILERPLATE_LABELS = [
|
|
48
|
+
'回到顶部', 'back to top', 'scroll to top', 'go to top',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Parse role and text from a trimmed snapshot line.
|
|
52
|
+
* Handles quoted labels and trailing text after colon correctly,
|
|
53
|
+
* including lines wrapped in single quotes.
|
|
54
|
+
*/
|
|
55
|
+
function parseLine(trimmed) {
|
|
56
|
+
// Unwrap outer single quotes if present (snapshot wraps lines with special chars)
|
|
57
|
+
let line = trimmed;
|
|
58
|
+
if (line.startsWith("'") && line.endsWith("':")) {
|
|
59
|
+
line = line.slice(1, -2) + ':';
|
|
60
|
+
}
|
|
61
|
+
else if (line.startsWith("'") && line.endsWith("'")) {
|
|
62
|
+
line = line.slice(1, -1);
|
|
63
|
+
}
|
|
64
|
+
// Role is the first word
|
|
65
|
+
const roleMatch = line.match(/^([a-zA-Z]+)\b/);
|
|
66
|
+
const role = roleMatch ? roleMatch[1].toLowerCase() : '';
|
|
67
|
+
// Extract quoted text content (the semantic label)
|
|
68
|
+
const textMatch = line.match(/"([^"]*)"/);
|
|
69
|
+
const text = textMatch ? textMatch[1] : '';
|
|
70
|
+
// For trailing text: strip annotations and quoted strings first, then check after last colon
|
|
71
|
+
// This avoids matching colons inside quoted labels like "Account: user@email.com"
|
|
72
|
+
let stripped = line;
|
|
73
|
+
// Remove all quoted strings
|
|
74
|
+
stripped = stripped.replace(/"[^"]*"/g, '""');
|
|
75
|
+
// Remove all bracket annotations
|
|
76
|
+
stripped = stripped.replace(/\[[^\]]*\]/g, '');
|
|
77
|
+
const colonIdx = stripped.lastIndexOf(':');
|
|
78
|
+
let trailingText = '';
|
|
79
|
+
if (colonIdx !== -1) {
|
|
80
|
+
const afterColon = stripped.slice(colonIdx + 1).trim();
|
|
81
|
+
if (afterColon.length > 0) {
|
|
82
|
+
// Get the actual trailing text from original line at same position
|
|
83
|
+
const origColonIdx = line.lastIndexOf(':');
|
|
84
|
+
if (origColonIdx !== -1) {
|
|
85
|
+
trailingText = line.slice(origColonIdx + 1).trim();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { role, text, hasText: text.length > 0 || trailingText.length > 0, trailingText };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Strip ALL bracket annotations from a content line, preserving quoted strings.
|
|
93
|
+
* Handles both double-quoted and outer single-quoted lines.
|
|
94
|
+
*/
|
|
95
|
+
function stripAnnotations(content) {
|
|
96
|
+
// Unwrap outer single quotes first
|
|
97
|
+
let line = content;
|
|
98
|
+
if (line.startsWith("'") && (line.endsWith("':") || line.endsWith("'"))) {
|
|
99
|
+
if (line.endsWith("':")) {
|
|
100
|
+
line = line.slice(1, -2) + ':';
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
line = line.slice(1, -1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Split by double quotes to protect quoted content
|
|
107
|
+
const parts = line.split('"');
|
|
108
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
109
|
+
// Only strip annotations from non-quoted parts (even indices)
|
|
110
|
+
parts[i] = parts[i].replace(/\s*\[[^\]]*\]/g, '');
|
|
111
|
+
}
|
|
112
|
+
let result = parts.join('"').replace(/\s{2,}/g, ' ').trim();
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if a line is a metadata-only line (like /url: ...).
|
|
117
|
+
*/
|
|
118
|
+
function isMetadataLine(trimmed) {
|
|
119
|
+
return /^\/[a-zA-Z]+:/.test(trimmed);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if text content is purely decorative (separators, dots, etc.)
|
|
123
|
+
*/
|
|
124
|
+
function isDecoratorText(text) {
|
|
125
|
+
return DECORATOR_TEXT.has(text.trim());
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check if a node is ad-related based on its text content.
|
|
129
|
+
*/
|
|
130
|
+
function isAdNode(text, trailingText) {
|
|
131
|
+
const t = (text + ' ' + trailingText).toLowerCase();
|
|
132
|
+
if (t.includes('sponsored') || t.includes('advertisement'))
|
|
133
|
+
return true;
|
|
134
|
+
if (t.includes('广告'))
|
|
135
|
+
return true;
|
|
136
|
+
// Check for ad tracking URLs in the label
|
|
137
|
+
for (const pattern of AD_URL_PATTERNS) {
|
|
138
|
+
if (text.includes(pattern) || trailingText.includes(pattern))
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if a node is boilerplate UI (back-to-top, etc.)
|
|
145
|
+
*/
|
|
146
|
+
function isBoilerplateNode(text) {
|
|
147
|
+
const t = text.toLowerCase();
|
|
148
|
+
return BOILERPLATE_LABELS.some(label => t.includes(label));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if a role is noise that should be filtered.
|
|
152
|
+
*/
|
|
153
|
+
function isNoiseNode(role, hasText, text, trailingText) {
|
|
154
|
+
if (NOISE_ROLES.has(role))
|
|
155
|
+
return true;
|
|
156
|
+
// generic without text is a wrapper
|
|
157
|
+
if (role === 'generic' && !hasText)
|
|
158
|
+
return true;
|
|
159
|
+
// img without alt text is noise
|
|
160
|
+
if (role === 'img' && !hasText)
|
|
161
|
+
return true;
|
|
162
|
+
// Decorator-only text nodes
|
|
163
|
+
if ((role === 'generic' || role === 'text') && hasText) {
|
|
164
|
+
const content = trailingText || text;
|
|
165
|
+
if (isDecoratorText(content))
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
export function formatSnapshot(raw, opts = {}) {
|
|
171
|
+
if (!raw || typeof raw !== 'string')
|
|
172
|
+
return '';
|
|
173
|
+
const maxTextLen = opts.maxTextLength ?? DEFAULT_MAX_TEXT_LENGTH;
|
|
174
|
+
const lines = raw.split('\n');
|
|
175
|
+
// === Pass 1: Parse, filter, and collect entries (merged with ad/boilerplate subtree skip) ===
|
|
176
|
+
const parsed = [];
|
|
177
|
+
let refCounter = 0;
|
|
178
|
+
let skipUntilDepth = -1;
|
|
179
|
+
for (let i = 0; i < lines.length; i++) {
|
|
180
|
+
const line = lines[i];
|
|
181
|
+
if (!line.trim())
|
|
182
|
+
continue;
|
|
183
|
+
const indent = line.length - line.trimStart().length;
|
|
184
|
+
const depth = Math.floor(indent / 2);
|
|
185
|
+
// Subtree skip zone (noise roles, ads, boilerplate)
|
|
186
|
+
if (skipUntilDepth >= 0) {
|
|
187
|
+
if (depth > skipUntilDepth)
|
|
188
|
+
continue;
|
|
189
|
+
skipUntilDepth = -1;
|
|
190
|
+
}
|
|
191
|
+
let content = line.trimStart();
|
|
192
|
+
if (content.startsWith('- '))
|
|
193
|
+
content = content.slice(2);
|
|
194
|
+
if (isMetadataLine(content))
|
|
195
|
+
continue;
|
|
196
|
+
if (opts.maxDepth !== undefined && depth > opts.maxDepth)
|
|
197
|
+
continue;
|
|
198
|
+
const { role, text, hasText, trailingText } = parseLine(content);
|
|
199
|
+
if (isNoiseNode(role, hasText, text, trailingText))
|
|
200
|
+
continue;
|
|
201
|
+
// Subtree noise roles (contentinfo footer, etc.)
|
|
202
|
+
if (SUBTREE_NOISE_ROLES.has(role)) {
|
|
203
|
+
skipUntilDepth = depth;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
// Ads and boilerplate — skip entire subtree (merged from old Pass 2)
|
|
207
|
+
if (isAdNode(text, trailingText) || isBoilerplateNode(text)) {
|
|
208
|
+
skipUntilDepth = depth;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
content = stripAnnotations(content);
|
|
212
|
+
const isInteractive = INTERACTIVE_ROLES.has(role);
|
|
213
|
+
const isLandmark = LANDMARK_ROLES.has(role);
|
|
214
|
+
if (opts.interactive && !isInteractive && !isLandmark && !hasText)
|
|
215
|
+
continue;
|
|
216
|
+
if (opts.compact) {
|
|
217
|
+
content = content.replace(/\s*\[.*?\]\s*/g, ' ').replace(/\s+/g, ' ').trim();
|
|
218
|
+
}
|
|
219
|
+
if (maxTextLen > 0 && content.length > maxTextLen) {
|
|
220
|
+
content = content.slice(0, maxTextLen) + '…';
|
|
221
|
+
}
|
|
222
|
+
if (isInteractive) {
|
|
223
|
+
refCounter++;
|
|
224
|
+
content = `[@${refCounter}] ${content}`;
|
|
225
|
+
}
|
|
226
|
+
parsed.push({ depth, content, role, text, trailingText, isInteractive, isLandmark });
|
|
227
|
+
}
|
|
228
|
+
// === Pass 2: Deduplicate (merged: generic/text parent match + heading+link + nested links) ===
|
|
229
|
+
const deduped = [];
|
|
230
|
+
for (let i = 0; i < parsed.length; i++) {
|
|
231
|
+
const entry = parsed[i];
|
|
232
|
+
// Dedup: generic/text child matching parent label
|
|
233
|
+
if (entry.role === 'generic' || entry.role === 'text') {
|
|
234
|
+
let parent;
|
|
235
|
+
for (let j = deduped.length - 1; j >= 0; j--) {
|
|
236
|
+
if (deduped[j].depth < entry.depth) {
|
|
237
|
+
parent = deduped[j];
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
if (deduped[j].depth === entry.depth)
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
if (parent) {
|
|
244
|
+
const childText = entry.trailingText || entry.text;
|
|
245
|
+
if (childText && parent.text && childText === parent.text)
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Dedup: heading + child link with identical label
|
|
250
|
+
if (entry.role === 'heading' && entry.text) {
|
|
251
|
+
const next = parsed[i + 1];
|
|
252
|
+
if (next && next.role === 'link' && next.text === entry.text && next.depth === entry.depth + 1) {
|
|
253
|
+
deduped.push(entry);
|
|
254
|
+
i++; // skip the link, preserve its children
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Dedup: nested identical links (skip parent, keep child)
|
|
259
|
+
if (entry.role === 'link' && entry.text) {
|
|
260
|
+
const next = parsed[i + 1];
|
|
261
|
+
if (next && next.role === 'link' && next.text === entry.text && next.depth === entry.depth + 1) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
deduped.push(entry);
|
|
266
|
+
}
|
|
267
|
+
// === Pass 3: Iteratively prune empty containers (bottom-up) ===
|
|
268
|
+
let current = deduped;
|
|
269
|
+
let changed = true;
|
|
270
|
+
while (changed) {
|
|
271
|
+
changed = false;
|
|
272
|
+
const next = [];
|
|
273
|
+
for (let i = 0; i < current.length; i++) {
|
|
274
|
+
const entry = current[i];
|
|
275
|
+
if (CONTAINER_ROLES.has(entry.role) && !entry.text && !entry.trailingText) {
|
|
276
|
+
let hasChildren = false;
|
|
277
|
+
for (let j = i + 1; j < current.length; j++) {
|
|
278
|
+
if (current[j].depth <= entry.depth)
|
|
279
|
+
break;
|
|
280
|
+
if (current[j].depth > entry.depth) {
|
|
281
|
+
hasChildren = true;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (!hasChildren) {
|
|
286
|
+
changed = true;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
next.push(entry);
|
|
291
|
+
}
|
|
292
|
+
current = next;
|
|
293
|
+
}
|
|
294
|
+
// === Pass 4: Collapse single-child containers ===
|
|
295
|
+
const collapsed = [];
|
|
296
|
+
for (let i = 0; i < current.length; i++) {
|
|
297
|
+
const entry = current[i];
|
|
298
|
+
if (CONTAINER_ROLES.has(entry.role) && !entry.text && !entry.trailingText) {
|
|
299
|
+
let childCount = 0;
|
|
300
|
+
let childIdx = -1;
|
|
301
|
+
for (let j = i + 1; j < current.length; j++) {
|
|
302
|
+
if (current[j].depth <= entry.depth)
|
|
303
|
+
break;
|
|
304
|
+
if (current[j].depth === entry.depth + 1) {
|
|
305
|
+
childCount++;
|
|
306
|
+
if (childCount === 1)
|
|
307
|
+
childIdx = j;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (childCount === 1 && childIdx !== -1) {
|
|
311
|
+
const child = current[childIdx];
|
|
312
|
+
let hasGrandchildren = false;
|
|
313
|
+
for (let j = childIdx + 1; j < current.length; j++) {
|
|
314
|
+
if (current[j].depth <= child.depth)
|
|
315
|
+
break;
|
|
316
|
+
if (current[j].depth > child.depth) {
|
|
317
|
+
hasGrandchildren = true;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (!hasGrandchildren) {
|
|
322
|
+
collapsed.push({
|
|
323
|
+
...entry,
|
|
324
|
+
content: entry.content.replace(/:$/, '') + ' > ' + child.content,
|
|
325
|
+
role: child.role,
|
|
326
|
+
text: child.text,
|
|
327
|
+
trailingText: child.trailingText,
|
|
328
|
+
isInteractive: child.isInteractive,
|
|
329
|
+
});
|
|
330
|
+
i++;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
collapsed.push(entry);
|
|
336
|
+
}
|
|
337
|
+
return collapsed.map(e => ' '.repeat(e.depth) + e.content).join('\n');
|
|
338
|
+
}
|