autokap 1.0.6 → 1.0.8
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/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
- package/assets/cursors/macos.svg +4 -0
- package/assets/cursors/windows.svg +15 -0
- package/assets/devices/ipad-pro-11-m4.json +52 -0
- package/assets/devices/iphone-16-pro.json +53 -0
- package/assets/devices/macbook-air-13.json +45 -0
- package/assets/frames/MacBook Air 13.svg +242 -0
- package/assets/frames/Status bar - iPhone.png +0 -0
- Menu bar- iPad.png +0 -0
- package/assets/frames/iPad Pro M4 11_.png +0 -0
- package/assets/frames/iPhone 16 Pro.png +0 -0
- package/assets/icons/Cellular Connection.svg +3 -0
- package/assets/icons/Union.svg +6 -0
- package/assets/icons/Wifi.svg +3 -0
- package/assets/icons/battery.svg +5 -0
- package/assets/icons/battery_charging.svg +8 -0
- package/assets/skill/OPCODE-REFERENCE.md +607 -0
- package/assets/skill/README.md +39 -0
- package/assets/skill/SKILL.md +453 -468
- package/assets/skill/STUDIO-SKILL.md +476 -0
- package/assets/skill/references/examples.md +104 -0
- package/assets/skill/references/interactive-demo.md +225 -0
- package/assets/skill/references/mock-data.md +178 -0
- package/dist/abort.d.ts +5 -0
- package/dist/abort.js +44 -0
- package/dist/action-verifier.d.ts +29 -0
- package/dist/action-verifier.js +133 -0
- package/dist/agent-action-recovery.d.ts +45 -0
- package/dist/agent-action-recovery.js +370 -0
- package/dist/agent-message-utils.d.ts +21 -0
- package/dist/agent-message-utils.js +77 -0
- package/dist/agent-url-utils.d.ts +30 -0
- package/dist/agent-url-utils.js +138 -0
- package/dist/agent.d.ts +226 -0
- package/dist/agent.js +6666 -0
- package/dist/ak-tree.d.ts +39 -0
- package/dist/ak-tree.js +368 -0
- package/dist/alt-text.d.ts +26 -0
- package/dist/alt-text.js +55 -0
- package/dist/auth-capture.d.ts +17 -0
- package/dist/auth-capture.js +164 -0
- package/dist/benchmark.d.ts +59 -0
- package/dist/benchmark.js +135 -0
- package/dist/billing-operation-logging.d.ts +38 -0
- package/dist/billing-operation-logging.js +248 -0
- package/dist/browser-bar.d.ts +48 -0
- package/dist/browser-bar.js +284 -0
- package/dist/browser-pool.d.ts +7 -0
- package/dist/browser-pool.js +15 -5
- package/dist/browser-utils.d.ts +31 -0
- package/dist/browser-utils.js +97 -0
- package/dist/browser.d.ts +76 -1
- package/dist/browser.js +1657 -39
- package/dist/capture-alt-text.d.ts +12 -0
- package/dist/capture-alt-text.js +52 -0
- package/dist/capture-encryption.d.ts +10 -0
- package/dist/capture-encryption.js +41 -0
- package/dist/capture-language-preflight.d.ts +41 -0
- package/dist/capture-language-preflight.js +300 -0
- package/dist/capture-llm-page-identity.d.ts +15 -0
- package/dist/capture-llm-page-identity.js +128 -0
- package/dist/capture-model-resolution.d.ts +9 -0
- package/dist/capture-model-resolution.js +21 -0
- package/dist/capture-page-identity.d.ts +7 -0
- package/dist/capture-page-identity.js +352 -0
- package/dist/capture-preset-credentials.d.ts +62 -0
- package/dist/capture-preset-credentials.js +184 -0
- package/dist/capture-request-plan.d.ts +58 -0
- package/dist/capture-request-plan.js +264 -0
- package/dist/capture-run-optimizer.d.ts +139 -0
- package/dist/capture-run-optimizer.js +863 -0
- package/dist/capture-selector-memory.d.ts +31 -0
- package/dist/capture-selector-memory.js +345 -0
- package/dist/capture-session-profile-encryption.d.ts +2 -0
- package/dist/capture-session-profile-encryption.js +22 -0
- package/dist/capture-step-timeout.d.ts +10 -0
- package/dist/capture-step-timeout.js +30 -0
- package/dist/capture-strategy.d.ts +36 -0
- package/dist/capture-strategy.js +95 -0
- package/dist/capture-studio-sync.d.ts +23 -0
- package/dist/capture-studio-sync.js +172 -0
- package/dist/capture-surface-contract.d.ts +36 -0
- package/dist/capture-surface-contract.js +299 -0
- package/dist/capture-transition-engine.d.ts +28 -0
- package/dist/capture-transition-engine.js +292 -0
- package/dist/capture-variant-state.d.ts +56 -0
- package/dist/capture-variant-state.js +182 -0
- package/dist/capture-verification.d.ts +35 -0
- package/dist/capture-verification.js +95 -0
- package/dist/capture-viewport-lock.d.ts +48 -0
- package/dist/capture-viewport-lock.js +74 -0
- package/dist/circuit-breaker.d.ts +42 -0
- package/dist/circuit-breaker.js +119 -0
- package/dist/cli-config.d.ts +8 -1
- package/dist/cli-config.js +62 -6
- package/dist/cli-contract.d.ts +15 -0
- package/dist/cli-contract.js +167 -0
- package/dist/cli-runner-local.d.ts +12 -0
- package/dist/cli-runner-local.js +102 -0
- package/dist/cli-runner.d.ts +34 -0
- package/dist/cli-runner.js +433 -0
- package/dist/cli-utils.d.ts +0 -1
- package/dist/cli-utils.js +2 -5
- package/dist/cli.js +1005 -252
- package/dist/clip-orchestrator.d.ts +148 -0
- package/dist/clip-orchestrator.js +957 -0
- package/dist/clip-postprocess.d.ts +42 -0
- package/dist/clip-postprocess.js +201 -0
- package/dist/cookie-dismiss.d.ts +2 -0
- package/dist/cookie-dismiss.js +48 -13
- package/dist/cost-logging.d.ts +35 -0
- package/dist/cost-logging.js +242 -0
- package/dist/cost-resolution-monitor.d.ts +16 -0
- package/dist/cost-resolution-monitor.js +34 -0
- package/dist/credential-templates.d.ts +5 -0
- package/dist/credential-templates.js +60 -0
- package/dist/cursor-overlay-script.d.ts +6 -0
- package/dist/cursor-overlay-script.js +169 -0
- package/dist/dom-css-purger.d.ts +65 -0
- package/dist/dom-css-purger.js +333 -0
- package/dist/dom-font-inliner.d.ts +45 -0
- package/dist/dom-font-inliner.js +148 -0
- package/dist/dom-patch-resolver.d.ts +52 -0
- package/dist/dom-patch-resolver.js +242 -0
- package/dist/dom-serializer.d.ts +82 -0
- package/dist/dom-serializer.js +378 -0
- package/dist/element-capture.d.ts +13 -0
- package/dist/element-capture.js +522 -0
- package/dist/env-validation.d.ts +5 -0
- package/dist/env-validation.js +29 -0
- package/dist/execution-schema.d.ts +4423 -0
- package/dist/execution-schema.js +507 -0
- package/dist/execution-types.d.ts +886 -0
- package/dist/execution-types.js +65 -0
- package/dist/fonts-loader.d.ts +14 -0
- package/dist/fonts-loader.js +55 -0
- package/dist/hybrid-navigator.d.ts +138 -0
- package/dist/hybrid-navigator.js +468 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/legacy/agent-action-recovery.d.ts +45 -0
- package/dist/legacy/agent-action-recovery.js +370 -0
- package/dist/legacy/agent-message-utils.d.ts +21 -0
- package/dist/legacy/agent-message-utils.js +77 -0
- package/dist/legacy/agent-url-utils.d.ts +30 -0
- package/dist/legacy/agent-url-utils.js +138 -0
- package/dist/legacy/agent.d.ts +226 -0
- package/dist/legacy/agent.js +6666 -0
- package/dist/legacy/clip-orchestrator.d.ts +148 -0
- package/dist/legacy/clip-orchestrator.js +957 -0
- package/dist/legacy/credential-templates.d.ts +5 -0
- package/dist/legacy/credential-templates.js +60 -0
- package/dist/legacy/hybrid-navigator.d.ts +138 -0
- package/dist/legacy/hybrid-navigator.js +468 -0
- package/dist/legacy/llm-usage.d.ts +17 -0
- package/dist/legacy/llm-usage.js +45 -0
- package/dist/legacy/prompt-cache.d.ts +10 -0
- package/dist/legacy/prompt-cache.js +24 -0
- package/dist/legacy/prompts.d.ts +175 -0
- package/dist/legacy/prompts.js +1038 -0
- package/dist/legacy/tools.d.ts +4 -0
- package/dist/legacy/tools.js +216 -0
- package/dist/legacy/video-agent.d.ts +143 -0
- package/dist/legacy/video-agent.js +4788 -0
- package/dist/legacy/video-observation.d.ts +36 -0
- package/dist/legacy/video-observation.js +192 -0
- package/dist/legacy/video-planner.d.ts +12 -0
- package/dist/legacy/video-planner.js +501 -0
- package/dist/legacy/video-prompts.d.ts +37 -0
- package/dist/legacy/video-prompts.js +569 -0
- package/dist/legacy/video-tools.d.ts +3 -0
- package/dist/legacy/video-tools.js +59 -0
- package/dist/legacy/video-variant-state.d.ts +29 -0
- package/dist/legacy/video-variant-state.js +80 -0
- package/dist/legacy/vision-model.d.ts +17 -0
- package/dist/legacy/vision-model.js +74 -0
- package/dist/llm-healer.d.ts +63 -0
- package/dist/llm-healer.js +166 -0
- package/dist/llm-provider.d.ts +29 -0
- package/dist/llm-provider.js +80 -0
- package/dist/llm-usage.d.ts +17 -0
- package/dist/llm-usage.js +45 -0
- package/dist/logger.d.ts +6 -2
- package/dist/logger.js +15 -1
- package/dist/mockup-html.d.ts +119 -0
- package/dist/mockup-html.js +263 -0
- package/dist/mockup.d.ts +187 -0
- package/dist/mockup.js +869 -0
- package/dist/mouse-animation.d.ts +46 -0
- package/dist/mouse-animation.js +114 -0
- package/dist/opcode-actions.d.ts +42 -0
- package/dist/opcode-actions.js +511 -0
- package/dist/opcode-runner.d.ts +51 -0
- package/dist/opcode-runner.js +770 -0
- package/dist/openrouter-client.d.ts +40 -0
- package/dist/openrouter-client.js +16 -0
- package/dist/overlay-engine.d.ts +24 -0
- package/dist/overlay-engine.js +176 -0
- package/dist/overlay-utils.d.ts +14 -0
- package/dist/overlay-utils.js +13 -0
- package/dist/postcondition.d.ts +16 -0
- package/dist/postcondition.js +269 -0
- package/dist/posthog.d.ts +4 -0
- package/dist/posthog.js +26 -0
- package/dist/program-patcher.d.ts +25 -0
- package/dist/program-patcher.js +44 -0
- package/dist/prompt-cache.d.ts +10 -0
- package/dist/prompt-cache.js +24 -0
- package/dist/prompts.d.ts +175 -0
- package/dist/prompts.js +1038 -0
- package/dist/provider-config.d.ts +12 -0
- package/dist/provider-config.js +15 -0
- package/dist/recovery-chain.d.ts +37 -0
- package/dist/recovery-chain.js +350 -0
- package/dist/remote-browser.d.ts +215 -0
- package/dist/remote-browser.js +360 -0
- package/dist/safari-browser-bar.d.ts +15 -0
- package/dist/safari-browser-bar.js +95 -0
- package/dist/safari-toolbar-asset.d.ts +15 -0
- package/dist/safari-toolbar-asset.js +12 -0
- package/dist/security.d.ts +21 -0
- package/dist/security.js +608 -0
- package/dist/selector-resolver.d.ts +34 -0
- package/dist/selector-resolver.js +181 -0
- package/dist/semantic-resolver.d.ts +35 -0
- package/dist/semantic-resolver.js +161 -0
- package/dist/server-capture-runtime.d.ts +125 -0
- package/dist/server-capture-runtime.js +585 -0
- package/dist/server-credit-usage.d.ts +12 -0
- package/dist/server-credit-usage.js +41 -0
- package/dist/server-posthog.d.ts +2 -0
- package/dist/server-posthog.js +16 -0
- package/dist/server-project-webhooks.d.ts +59 -0
- package/dist/server-project-webhooks.js +123 -0
- package/dist/server-screenshot-watermark.d.ts +7 -0
- package/dist/server-screenshot-watermark.js +60 -0
- package/dist/session-profile.d.ts +86 -0
- package/dist/session-profile.js +1536 -0
- package/dist/sf-pro-fonts.d.ts +4 -0
- package/dist/sf-pro-fonts.js +7 -0
- package/dist/sf-pro-symbols.d.ts +1 -0
- package/dist/sf-pro-symbols.js +55 -0
- package/dist/skill-packaging.d.ts +28 -0
- package/dist/skill-packaging.js +169 -0
- package/dist/smart-wait.d.ts +27 -0
- package/dist/smart-wait.js +81 -0
- package/dist/status-bar-l10n.d.ts +14 -0
- package/dist/status-bar-l10n.js +177 -0
- package/dist/status-bar-render.d.ts +20 -0
- package/dist/status-bar-render.js +410 -0
- package/dist/status-bar.d.ts +53 -0
- package/dist/status-bar.js +620 -0
- package/dist/svg-browser-bar.d.ts +33 -0
- package/dist/svg-browser-bar.js +206 -0
- package/dist/svg-status-bar.d.ts +36 -0
- package/dist/svg-status-bar.js +597 -0
- package/dist/svg-text.d.ts +61 -0
- package/dist/svg-text.js +118 -0
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +216 -0
- package/dist/types.d.ts +240 -5
- package/dist/types.js +23 -1
- package/dist/v2/action-verifier.d.ts +29 -0
- package/dist/v2/action-verifier.js +133 -0
- package/dist/v2/alt-text.d.ts +26 -0
- package/dist/v2/alt-text.js +55 -0
- package/dist/v2/benchmark.d.ts +59 -0
- package/dist/v2/benchmark.js +135 -0
- package/dist/v2/capture-strategy.d.ts +30 -0
- package/dist/v2/capture-strategy.js +67 -0
- package/dist/v2/capture-verification.d.ts +35 -0
- package/dist/v2/capture-verification.js +95 -0
- package/dist/v2/circuit-breaker.d.ts +42 -0
- package/dist/v2/circuit-breaker.js +119 -0
- package/dist/v2/cli-runner-local.d.ts +11 -0
- package/dist/v2/cli-runner-local.js +91 -0
- package/dist/v2/cli-runner.d.ts +34 -0
- package/dist/v2/cli-runner.js +300 -0
- package/dist/v2/compiler-prompts.d.ts +27 -0
- package/dist/v2/compiler-prompts.js +123 -0
- package/dist/v2/compiler.d.ts +37 -0
- package/dist/v2/compiler.js +147 -0
- package/dist/v2/explorer.d.ts +41 -0
- package/dist/v2/explorer.js +56 -0
- package/dist/v2/index.d.ts +37 -0
- package/dist/v2/index.js +31 -0
- package/dist/v2/llm-healer.d.ts +62 -0
- package/dist/v2/llm-healer.js +166 -0
- package/dist/v2/llm-provider.d.ts +29 -0
- package/dist/v2/llm-provider.js +80 -0
- package/dist/v2/opcode-runner.d.ts +47 -0
- package/dist/v2/opcode-runner.js +634 -0
- package/dist/v2/overlay-engine.d.ts +24 -0
- package/dist/v2/overlay-engine.js +150 -0
- package/dist/v2/postcondition.d.ts +16 -0
- package/dist/v2/postcondition.js +249 -0
- package/dist/v2/program-patcher.d.ts +25 -0
- package/dist/v2/program-patcher.js +44 -0
- package/dist/v2/recovery-chain.d.ts +30 -0
- package/dist/v2/recovery-chain.js +368 -0
- package/dist/v2/schema.d.ts +2580 -0
- package/dist/v2/schema.js +295 -0
- package/dist/v2/selector-resolver.d.ts +34 -0
- package/dist/v2/selector-resolver.js +181 -0
- package/dist/v2/semantic-resolver.d.ts +35 -0
- package/dist/v2/semantic-resolver.js +161 -0
- package/dist/v2/smart-wait.d.ts +27 -0
- package/dist/v2/smart-wait.js +81 -0
- package/dist/v2/types.d.ts +444 -0
- package/dist/v2/types.js +19 -0
- package/dist/v2/web-playwright-local.d.ts +69 -0
- package/dist/v2/web-playwright-local.js +392 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/video-agent.d.ts +143 -0
- package/dist/video-agent.js +4788 -0
- package/dist/video-observation.d.ts +36 -0
- package/dist/video-observation.js +192 -0
- package/dist/video-planner.d.ts +12 -0
- package/dist/video-planner.js +501 -0
- package/dist/video-prompts.d.ts +37 -0
- package/dist/video-prompts.js +554 -0
- package/dist/video-tools.d.ts +3 -0
- package/dist/video-tools.js +59 -0
- package/dist/video-variant-state.d.ts +29 -0
- package/dist/video-variant-state.js +80 -0
- package/dist/vision-model.d.ts +17 -0
- package/dist/vision-model.js +74 -0
- package/dist/web-playwright-local.d.ts +126 -0
- package/dist/web-playwright-local.js +819 -0
- package/dist/ws-auth.d.ts +20 -0
- package/dist/ws-auth.js +70 -0
- package/dist/ws-broadcast.d.ts +34 -0
- package/dist/ws-broadcast.js +85 -0
- package/dist/ws-connection-limits.d.ts +12 -0
- package/dist/ws-connection-limits.js +44 -0
- package/dist/ws-handler-utils.d.ts +32 -0
- package/dist/ws-handler-utils.js +139 -0
- package/dist/ws-handler.d.ts +10 -0
- package/dist/ws-handler.js +1793 -0
- package/dist/ws-metrics-server.d.ts +9 -0
- package/dist/ws-metrics-server.js +31 -0
- package/dist/ws-server.d.ts +9 -0
- package/dist/ws-server.js +92 -0
- package/package.json +142 -71
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared OpenRouter provider configuration.
|
|
3
|
+
*
|
|
4
|
+
* Zero Data Retention (ZDR) tells OpenRouter to only route requests to
|
|
5
|
+
* providers that guarantee they won't store or train on request data.
|
|
6
|
+
* Controlled by the ENABLE_ZDR environment variable (default: off).
|
|
7
|
+
*/
|
|
8
|
+
export declare function isZdrEnabled(): boolean;
|
|
9
|
+
/** Build the `provider.zdr` fragment for OpenRouter requests. */
|
|
10
|
+
export declare function zdrParam(): {
|
|
11
|
+
zdr?: true;
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared OpenRouter provider configuration.
|
|
3
|
+
*
|
|
4
|
+
* Zero Data Retention (ZDR) tells OpenRouter to only route requests to
|
|
5
|
+
* providers that guarantee they won't store or train on request data.
|
|
6
|
+
* Controlled by the ENABLE_ZDR environment variable (default: off).
|
|
7
|
+
*/
|
|
8
|
+
export function isZdrEnabled() {
|
|
9
|
+
return process.env.ENABLE_ZDR === '1' || process.env.ENABLE_ZDR === 'true';
|
|
10
|
+
}
|
|
11
|
+
/** Build the `provider.zdr` fragment for OpenRouter requests. */
|
|
12
|
+
export function zdrParam() {
|
|
13
|
+
return isZdrEnabled() ? { zdr: true } : {};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=provider-config.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Recovery Chain
|
|
3
|
+
*
|
|
4
|
+
* Ordered recovery strategies when a deterministic opcode fails:
|
|
5
|
+
* 1. Deterministic retry (same opcode, fresh observation)
|
|
6
|
+
* 2. Selector memory lookup (known-good selectors from Supabase)
|
|
7
|
+
* 3. Alternative interaction (keyboard, JS dispatch, coordinates)
|
|
8
|
+
* 4. Targeted reload (reload page and retry)
|
|
9
|
+
* 5. LLM Healer (last resort)
|
|
10
|
+
*/
|
|
11
|
+
import type { ExecutionOpcode, RuntimeAdapter } from './execution-types.js';
|
|
12
|
+
import type { RecoveryChain as IRecoveryChain, RecoveryAttemptResult, RecoveryAttemptOptions } from './opcode-runner.js';
|
|
13
|
+
import { type HealerLLMProvider } from './llm-healer.js';
|
|
14
|
+
export interface RecoveryChainOptions {
|
|
15
|
+
/** Selector memory: stepSignature -> known-good selectors */
|
|
16
|
+
selectorMemory?: Record<string, string[]>;
|
|
17
|
+
/** LLM provider for the healer (optional, disables healer if not provided) */
|
|
18
|
+
llmProvider?: HealerLLMProvider;
|
|
19
|
+
/** Max healer invocations per run. Default: 3 */
|
|
20
|
+
maxHealerInvocations?: number;
|
|
21
|
+
/** Full program steps for healer context */
|
|
22
|
+
programSteps?: ExecutionOpcode[];
|
|
23
|
+
/** Credentials for {{email}}/{{password}}/{{loginUrl}} substitution during recovery */
|
|
24
|
+
credentials?: {
|
|
25
|
+
email?: string;
|
|
26
|
+
password?: string;
|
|
27
|
+
loginUrl?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare class RecoveryChainImpl implements IRecoveryChain {
|
|
31
|
+
private healer;
|
|
32
|
+
private selectorMemory;
|
|
33
|
+
private programSteps;
|
|
34
|
+
private credentials?;
|
|
35
|
+
constructor(options?: RecoveryChainOptions);
|
|
36
|
+
attempt(failedOpcode: ExecutionOpcode, opcodeIndex: number, adapter: RuntimeAdapter, options?: RecoveryAttemptOptions): Promise<RecoveryAttemptResult>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Recovery Chain
|
|
3
|
+
*
|
|
4
|
+
* Ordered recovery strategies when a deterministic opcode fails:
|
|
5
|
+
* 1. Deterministic retry (same opcode, fresh observation)
|
|
6
|
+
* 2. Selector memory lookup (known-good selectors from Supabase)
|
|
7
|
+
* 3. Alternative interaction (keyboard, JS dispatch, coordinates)
|
|
8
|
+
* 4. Targeted reload (reload page and retry)
|
|
9
|
+
* 5. LLM Healer (last resort)
|
|
10
|
+
*/
|
|
11
|
+
import { resolveSelector } from './selector-resolver.js';
|
|
12
|
+
import { evaluatePostcondition } from './postcondition.js';
|
|
13
|
+
import { LLMHealer } from './llm-healer.js';
|
|
14
|
+
import { serializeAKTree } from './ak-tree.js';
|
|
15
|
+
import { executeOpcodeCoreAction, substituteCredentialPlaceholders } from './opcode-actions.js';
|
|
16
|
+
import { dismissAllOverlays } from './overlay-engine.js';
|
|
17
|
+
import { logger } from './logger.js';
|
|
18
|
+
export class RecoveryChainImpl {
|
|
19
|
+
healer;
|
|
20
|
+
selectorMemory;
|
|
21
|
+
programSteps;
|
|
22
|
+
credentials;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.selectorMemory = options.selectorMemory ?? {};
|
|
25
|
+
this.programSteps = options.programSteps ?? [];
|
|
26
|
+
this.credentials = options.credentials;
|
|
27
|
+
this.healer = options.llmProvider
|
|
28
|
+
? new LLMHealer(options.llmProvider, { maxInvocations: options.maxHealerInvocations ?? 3 })
|
|
29
|
+
: null;
|
|
30
|
+
}
|
|
31
|
+
async attempt(failedOpcode, opcodeIndex, adapter, options = {}) {
|
|
32
|
+
const recovery = failedOpcode.recovery;
|
|
33
|
+
logger.debug(`[recovery ${opcodeIndex}] starting — remainingMs=${options.remainingTimeMs ?? '∞'}, flags=[retries=${recovery.retries},selMem=${recovery.useSelectorMemory},alt=${recovery.useAltInteraction},reload=${recovery.allowReload},healer=${recovery.allowHealer}]`);
|
|
34
|
+
// Strategy 1: Deterministic retry
|
|
35
|
+
const retryBudget = Math.max(0, Math.min(recovery.retries, options.maxDeterministicRetries ?? recovery.retries));
|
|
36
|
+
if (retryBudget > 0) {
|
|
37
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 1 (retry x${retryBudget})`);
|
|
38
|
+
const result = await retryOpcode(failedOpcode, adapter, retryBudget, options.remainingTimeMs, options.currentVariant, this.credentials);
|
|
39
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 1 → recovered=${result.recovered}, reason=${result.reason}`);
|
|
40
|
+
if (result.recovered)
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
// Strategy 2: Selector memory + alternate selectors
|
|
44
|
+
if (recovery.useSelectorMemory && hasSelector(failedOpcode)) {
|
|
45
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 2 (selector memory)`);
|
|
46
|
+
const result = await trySelectorAlternatives(failedOpcode, opcodeIndex, adapter, this.selectorMemory, this.credentials);
|
|
47
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 2 → recovered=${result.recovered}, reason=${result.reason}`);
|
|
48
|
+
if (result.recovered)
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
// Strategy 3: Alternative interaction methods
|
|
52
|
+
if (recovery.useAltInteraction && hasSelector(failedOpcode)) {
|
|
53
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 3 (alt interaction: keyboard, js_dispatch, coords)`);
|
|
54
|
+
const result = await tryAltInteraction(failedOpcode, adapter, this.credentials);
|
|
55
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 3 → recovered=${result.recovered}, reason=${result.reason}`);
|
|
56
|
+
if (result.recovered)
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
// Strategy 4: Targeted reload
|
|
60
|
+
if (recovery.allowReload) {
|
|
61
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 4 (reload)`);
|
|
62
|
+
const result = await tryReload(failedOpcode, adapter, options.currentVariant, this.credentials);
|
|
63
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 4 → recovered=${result.recovered}, reason=${result.reason}`);
|
|
64
|
+
if (result.recovered)
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
// Strategy 5: LLM Healer
|
|
68
|
+
if (recovery.allowHealer && this.healer && this.healer.remainingInvocations > 0) {
|
|
69
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 5 (LLM healer)`);
|
|
70
|
+
const result = await tryHealer(failedOpcode, opcodeIndex, adapter, this.healer, this.programSteps, options.currentVariant, this.credentials);
|
|
71
|
+
logger.debug(`[recovery ${opcodeIndex}] strategy 5 → recovered=${result.recovered}, reason=${result.reason}`);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
logger.debug(`[recovery ${opcodeIndex}] all strategies exhausted`);
|
|
75
|
+
return { recovered: false, reason: 'all recovery strategies exhausted' };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ── Strategy 1: Deterministic retry ─────────────────────────────────
|
|
79
|
+
async function retryOpcode(opcode, adapter, maxRetries, remainingTimeMs, currentVariant, credentials) {
|
|
80
|
+
const deadlineMs = typeof remainingTimeMs === 'number'
|
|
81
|
+
? Date.now() + remainingTimeMs
|
|
82
|
+
: Number.POSITIVE_INFINITY;
|
|
83
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
84
|
+
if (Date.now() >= deadlineMs) {
|
|
85
|
+
return { recovered: false, reason: 'retry budget exhausted by timeout' };
|
|
86
|
+
}
|
|
87
|
+
await sleep(500 * (i + 1)); // backoff
|
|
88
|
+
try {
|
|
89
|
+
await executeRawAction(opcode, adapter, currentVariant, credentials);
|
|
90
|
+
const postcondition = await evaluatePostcondition(adapter, clampPostconditionWait(opcode.postcondition, deadlineMs));
|
|
91
|
+
if (postcondition.passed) {
|
|
92
|
+
return { recovered: true, strategy: 'retry', reason: `retry ${i + 1}/${maxRetries} succeeded` };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// continue to next retry
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { recovered: false, reason: `${maxRetries} retries exhausted` };
|
|
100
|
+
}
|
|
101
|
+
// ── Strategy 2: Selector memory ─────────────────────────────────────
|
|
102
|
+
async function trySelectorAlternatives(opcode, opcodeIndex, adapter, selectorMemory, credentials) {
|
|
103
|
+
if (!hasSelector(opcode)) {
|
|
104
|
+
return { recovered: false, reason: 'opcode has no selector' };
|
|
105
|
+
}
|
|
106
|
+
const selectorOpcode = opcode;
|
|
107
|
+
const primarySelector = selectorOpcode.selector ?? '';
|
|
108
|
+
const stepSignature = `${opcode.kind}:${primarySelector}`;
|
|
109
|
+
const resolved = await resolveSelector(adapter, {
|
|
110
|
+
primary: primarySelector,
|
|
111
|
+
fingerprint: selectorOpcode.fingerprint,
|
|
112
|
+
alternates: selectorOpcode.selectorAlternates,
|
|
113
|
+
selectorMemory,
|
|
114
|
+
stepSignature,
|
|
115
|
+
description: opcode.description,
|
|
116
|
+
});
|
|
117
|
+
if (!resolved || resolved.strategy === 'primary') {
|
|
118
|
+
return { recovered: false, reason: 'no alternative selectors found' };
|
|
119
|
+
}
|
|
120
|
+
// Try the resolved selector
|
|
121
|
+
try {
|
|
122
|
+
await executeWithSelector(opcode, adapter, resolved.selector, credentials);
|
|
123
|
+
const postcondition = await evaluatePostcondition(adapter, opcode.postcondition);
|
|
124
|
+
if (postcondition.passed) {
|
|
125
|
+
return {
|
|
126
|
+
recovered: true,
|
|
127
|
+
strategy: 'selector_memory',
|
|
128
|
+
reason: `resolved via ${resolved.strategy}: "${resolved.selector}"`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// fall through
|
|
134
|
+
}
|
|
135
|
+
return { recovered: false, reason: `resolved selector "${resolved.selector}" also failed` };
|
|
136
|
+
}
|
|
137
|
+
// ── Strategy 3: Alternative interaction ─────────────────────────────
|
|
138
|
+
async function tryAltInteraction(opcode, adapter, _credentials) {
|
|
139
|
+
if (opcode.kind !== 'CLICK' || !opcode.selector) {
|
|
140
|
+
return { recovered: false, reason: 'alt interaction only for CLICK opcodes with selectors' };
|
|
141
|
+
}
|
|
142
|
+
const clickOpcode = opcode;
|
|
143
|
+
const sel = clickOpcode.selector;
|
|
144
|
+
const methods = [
|
|
145
|
+
{ name: 'keyboard', options: { useKeyboard: true } },
|
|
146
|
+
{ name: 'js_dispatch', options: { useJsDispatch: true } },
|
|
147
|
+
];
|
|
148
|
+
for (const method of methods) {
|
|
149
|
+
try {
|
|
150
|
+
await adapter.click(sel, method.options);
|
|
151
|
+
await sleep(500);
|
|
152
|
+
const postcondition = await evaluatePostcondition(adapter, opcode.postcondition);
|
|
153
|
+
if (postcondition.passed) {
|
|
154
|
+
return {
|
|
155
|
+
recovered: true,
|
|
156
|
+
strategy: 'alt_interaction',
|
|
157
|
+
reason: `${method.name} interaction succeeded`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// continue to next method
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Try coordinate-based click from AKTree
|
|
166
|
+
try {
|
|
167
|
+
const tree = await adapter.getAKTree();
|
|
168
|
+
const node = findInteractiveNodeBySelector(tree, sel);
|
|
169
|
+
if (node) {
|
|
170
|
+
const x = node.bounds.x + node.bounds.w / 2;
|
|
171
|
+
const y = node.bounds.y + node.bounds.h / 2;
|
|
172
|
+
await adapter.click(sel, { coordinates: { x, y } });
|
|
173
|
+
await sleep(500);
|
|
174
|
+
const postcondition = await evaluatePostcondition(adapter, opcode.postcondition);
|
|
175
|
+
if (postcondition.passed) {
|
|
176
|
+
return {
|
|
177
|
+
recovered: true,
|
|
178
|
+
strategy: 'alt_interaction',
|
|
179
|
+
reason: `coordinate click at (${x}, ${y}) succeeded`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// fall through
|
|
186
|
+
}
|
|
187
|
+
return { recovered: false, reason: 'all alternative interactions failed' };
|
|
188
|
+
}
|
|
189
|
+
// ── Strategy 4: Targeted reload ─────────────────────────────────────
|
|
190
|
+
async function tryReload(opcode, adapter, currentVariant, credentials) {
|
|
191
|
+
try {
|
|
192
|
+
if (adapter.reloadPage) {
|
|
193
|
+
await adapter.reloadPage();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const url = await adapter.getCurrentUrl();
|
|
197
|
+
await adapter.navigate(url);
|
|
198
|
+
}
|
|
199
|
+
await sleep(1000);
|
|
200
|
+
await dismissAllOverlays(adapter);
|
|
201
|
+
await executeRawAction(opcode, adapter, currentVariant, credentials);
|
|
202
|
+
const postcondition = await evaluatePostcondition(adapter, opcode.postcondition);
|
|
203
|
+
if (postcondition.passed) {
|
|
204
|
+
return { recovered: true, strategy: 'reload', reason: 'reload + retry succeeded' };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// fall through
|
|
209
|
+
}
|
|
210
|
+
return { recovered: false, reason: 'reload + retry failed' };
|
|
211
|
+
}
|
|
212
|
+
// ── Strategy 5: LLM Healer ─────────────────────────────────────────
|
|
213
|
+
async function tryHealer(failedOpcode, opcodeIndex, adapter, healer, programSteps, currentVariant, credentials) {
|
|
214
|
+
try {
|
|
215
|
+
const tree = await adapter.getAKTree();
|
|
216
|
+
const akTreeSerialized = serializeAKTree(tree);
|
|
217
|
+
const currentUrl = await adapter.getCurrentUrl();
|
|
218
|
+
let screenshot;
|
|
219
|
+
try {
|
|
220
|
+
screenshot = await adapter.takeScreenshot();
|
|
221
|
+
}
|
|
222
|
+
catch { /* optional */ }
|
|
223
|
+
// Get surrounding opcodes for context
|
|
224
|
+
const start = Math.max(0, opcodeIndex - 3);
|
|
225
|
+
const end = Math.min(programSteps.length, opcodeIndex + 4);
|
|
226
|
+
const surroundingOpcodes = programSteps.slice(start, end).filter((_, i) => start + i !== opcodeIndex);
|
|
227
|
+
const context = {
|
|
228
|
+
failedOpcode,
|
|
229
|
+
opcodeIndex,
|
|
230
|
+
akTreeSerialized,
|
|
231
|
+
currentUrl,
|
|
232
|
+
screenshot,
|
|
233
|
+
surroundingOpcodes,
|
|
234
|
+
errorMessage: `opcode ${failedOpcode.kind} failed after all deterministic recovery strategies`,
|
|
235
|
+
};
|
|
236
|
+
const result = await healer.heal(context);
|
|
237
|
+
if (result.healed && result.patch) {
|
|
238
|
+
// Execute the replacement opcode(s) to verify they work
|
|
239
|
+
for (const replacementOp of result.patch.replacementOpcodes) {
|
|
240
|
+
try {
|
|
241
|
+
await executeRawAction(replacementOp, adapter, currentVariant, credentials);
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
return {
|
|
245
|
+
recovered: false,
|
|
246
|
+
llmResult: result.llmResult,
|
|
247
|
+
reason: `healer patch failed during execution: ${err instanceof Error ? err.message : String(err)}`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Verify the last replacement's postcondition
|
|
252
|
+
const lastOp = result.patch.replacementOpcodes[result.patch.replacementOpcodes.length - 1];
|
|
253
|
+
const postcondition = await evaluatePostcondition(adapter, lastOp.postcondition);
|
|
254
|
+
if (postcondition.passed) {
|
|
255
|
+
return {
|
|
256
|
+
recovered: true,
|
|
257
|
+
strategy: 'healer',
|
|
258
|
+
patch: result.patch,
|
|
259
|
+
llmResult: result.llmResult,
|
|
260
|
+
reason: result.reason,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
recovered: false,
|
|
265
|
+
llmResult: result.llmResult,
|
|
266
|
+
reason: `healer patch executed but postcondition failed: ${postcondition.reason}`,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
return { recovered: false, llmResult: result.llmResult, reason: result.reason };
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
return {
|
|
273
|
+
recovered: false,
|
|
274
|
+
reason: `healer error: ${err instanceof Error ? err.message : String(err)}`,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// ── Shared helpers ──────────────────────────────────────────────────
|
|
279
|
+
function hasSelector(opcode) {
|
|
280
|
+
return 'selector' in opcode && typeof opcode.selector === 'string' && !!opcode.selector;
|
|
281
|
+
}
|
|
282
|
+
async function executeRawAction(opcode, adapter, currentVariant, credentials) {
|
|
283
|
+
const result = await executeOpcodeCoreAction(opcode, adapter, { currentVariant, credentials });
|
|
284
|
+
if (!result.success) {
|
|
285
|
+
throw new Error(result.error ?? `opcode ${opcode.kind} could not be replayed`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async function executeWithSelector(opcode, adapter, newSelector, credentials) {
|
|
289
|
+
switch (opcode.kind) {
|
|
290
|
+
case 'CLICK':
|
|
291
|
+
await adapter.click(newSelector, opcode.button ? { button: opcode.button } : undefined);
|
|
292
|
+
break;
|
|
293
|
+
case 'TYPE': {
|
|
294
|
+
const text = substituteCredentialPlaceholders(opcode.text, credentials);
|
|
295
|
+
await adapter.type(newSelector, text, opcode.clearFirst);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case 'HOVER':
|
|
299
|
+
if (!adapter.hover)
|
|
300
|
+
throw new Error('adapter does not support HOVER');
|
|
301
|
+
await adapter.hover(newSelector);
|
|
302
|
+
break;
|
|
303
|
+
case 'SELECT_OPTION':
|
|
304
|
+
if (!adapter.selectOption)
|
|
305
|
+
throw new Error('adapter does not support SELECT_OPTION');
|
|
306
|
+
await adapter.selectOption(newSelector, {
|
|
307
|
+
label: opcode.optionLabel,
|
|
308
|
+
value: opcode.optionValue,
|
|
309
|
+
index: opcode.optionIndex,
|
|
310
|
+
});
|
|
311
|
+
break;
|
|
312
|
+
case 'CHECK':
|
|
313
|
+
if (!adapter.check)
|
|
314
|
+
throw new Error('adapter does not support CHECK');
|
|
315
|
+
await adapter.check(newSelector, opcode.checked);
|
|
316
|
+
break;
|
|
317
|
+
case 'DOUBLE_CLICK':
|
|
318
|
+
if (!adapter.doubleClick)
|
|
319
|
+
throw new Error('adapter does not support DOUBLE_CLICK');
|
|
320
|
+
await adapter.doubleClick(newSelector);
|
|
321
|
+
break;
|
|
322
|
+
default:
|
|
323
|
+
throw new Error(`cannot swap selector for opcode kind: ${opcode.kind}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function findInteractiveNodeBySelector(tree, selector) {
|
|
327
|
+
function walk(node) {
|
|
328
|
+
if (node.visible && node.interactive && node.sourceRef.includes(selector.replace(/[[\]"#.]/g, ''))) {
|
|
329
|
+
return node;
|
|
330
|
+
}
|
|
331
|
+
for (const child of node.children) {
|
|
332
|
+
const found = walk(child);
|
|
333
|
+
if (found)
|
|
334
|
+
return found;
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
return walk(tree.root);
|
|
339
|
+
}
|
|
340
|
+
function sleep(ms) {
|
|
341
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
342
|
+
}
|
|
343
|
+
function clampPostconditionWait(spec, deadlineMs) {
|
|
344
|
+
const remainingTimeMs = Math.max(1, deadlineMs - Date.now());
|
|
345
|
+
return {
|
|
346
|
+
...spec,
|
|
347
|
+
waitMs: Math.max(1, Math.min(spec.waitMs ?? remainingTimeMs, remainingTimeMs)),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=recovery-chain.js.map
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RemoteBrowser — Server-side proxy that mirrors the Browser interface
|
|
3
|
+
* but forwards every method call to a remote CLI via WebSocket.
|
|
4
|
+
*
|
|
5
|
+
* Used by the WS server to control a Playwright browser running on the user's machine.
|
|
6
|
+
*/
|
|
7
|
+
import type { WebSocket } from 'ws';
|
|
8
|
+
import type { PageState, PageStateLite, InteractiveElement, BrowserStorageState, BrowserSessionStorageState, VideoPageSignals, OutscaleConfig, SelectorValidationResult, AKTree, AKNode, AKNodeRuntimeIndexEntry, FocusQuery } from './types.js';
|
|
9
|
+
import type { BrowserObservation, BrowserReaction, BrowserSelectorProbe, BrowserStorageHintWriteParams, BrowserVerificationBundle, BrowserVideoVerificationBundle } from './browser.js';
|
|
10
|
+
export interface WsCommand {
|
|
11
|
+
id: string;
|
|
12
|
+
method: string;
|
|
13
|
+
params: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface WsResult {
|
|
16
|
+
id: string;
|
|
17
|
+
result?: unknown;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface WsEvent {
|
|
21
|
+
type: 'done' | 'error' | 'progress' | 'live_url';
|
|
22
|
+
message?: string;
|
|
23
|
+
url?: string;
|
|
24
|
+
summary?: {
|
|
25
|
+
successes: number;
|
|
26
|
+
total: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const REMOTE_BROWSER_PROTOCOL_VERSION = 3;
|
|
30
|
+
export interface RemoteBrowserClientInfo {
|
|
31
|
+
version?: string;
|
|
32
|
+
protocolVersion?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface WsClientHello {
|
|
35
|
+
type: 'client_hello';
|
|
36
|
+
client: RemoteBrowserClientInfo;
|
|
37
|
+
apiKey?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildRemoteBrowserClientHello(version: string, apiKey?: string): WsClientHello;
|
|
40
|
+
export declare function getRemoteBrowserCompatibilityError(client: RemoteBrowserClientInfo | null | undefined): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Lightweight proxy for `browser.currentPage` — only exposes the methods
|
|
43
|
+
* that `runAgent` actually calls: `.url()`, `.viewportSize()`, `.title()`.
|
|
44
|
+
*/
|
|
45
|
+
declare class RemotePageProxy {
|
|
46
|
+
private callFn;
|
|
47
|
+
constructor(callFn: (method: string, params: Record<string, unknown>) => Promise<unknown>);
|
|
48
|
+
url(): string;
|
|
49
|
+
viewportSize(): {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
} | null;
|
|
53
|
+
title(): Promise<string>;
|
|
54
|
+
_cachedUrl: string;
|
|
55
|
+
_cachedViewport: {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
} | null;
|
|
59
|
+
_sync(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare class RemoteBrowser {
|
|
62
|
+
private ws;
|
|
63
|
+
private pending;
|
|
64
|
+
private idCounter;
|
|
65
|
+
private _pageProxy;
|
|
66
|
+
/** Proxy for browser.currentPage — provides url(), viewportSize(), title() */
|
|
67
|
+
get currentPage(): RemotePageProxy;
|
|
68
|
+
constructor(ws: WebSocket);
|
|
69
|
+
launch(): Promise<void>;
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
closeContext(): Promise<void>;
|
|
72
|
+
recreateContext(options: {
|
|
73
|
+
viewport?: {
|
|
74
|
+
width: number;
|
|
75
|
+
height: number;
|
|
76
|
+
};
|
|
77
|
+
deviceScaleFactor?: number;
|
|
78
|
+
lang?: string;
|
|
79
|
+
colorScheme?: 'light' | 'dark';
|
|
80
|
+
storageState?: BrowserStorageState;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
setDeviceScaleFactor(deviceScaleFactor: number): Promise<void>;
|
|
83
|
+
navigateTo(url: string): Promise<void>;
|
|
84
|
+
addCookies(cookies: Array<Record<string, unknown>>): Promise<void>;
|
|
85
|
+
takeScreenshot(): Promise<Buffer>;
|
|
86
|
+
takeScreenshotForAI(options?: {
|
|
87
|
+
timeoutMs?: number;
|
|
88
|
+
}): Promise<Buffer>;
|
|
89
|
+
screenshotElement(index: number, padding?: number): Promise<Buffer>;
|
|
90
|
+
screenshotRegion(x: number, y: number, width: number, height: number, padding?: number): Promise<Buffer>;
|
|
91
|
+
screenshotBySelector(selector: string, outscale?: OutscaleConfig | number): Promise<{
|
|
92
|
+
buffer: Buffer;
|
|
93
|
+
validation: SelectorValidationResult;
|
|
94
|
+
}>;
|
|
95
|
+
screenshotByRegion(region: {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
width: number;
|
|
99
|
+
height: number;
|
|
100
|
+
}, outscale?: OutscaleConfig | number): Promise<Buffer>;
|
|
101
|
+
getPageState(opts?: {
|
|
102
|
+
skipAnnotation?: boolean;
|
|
103
|
+
}): Promise<PageState>;
|
|
104
|
+
getPageStateLite(): Promise<PageStateLite>;
|
|
105
|
+
getAccessibilityTree(options?: {
|
|
106
|
+
timeoutMs?: number;
|
|
107
|
+
}): Promise<string>;
|
|
108
|
+
getInteractiveElements(options?: {
|
|
109
|
+
timeoutMs?: number;
|
|
110
|
+
}): Promise<InteractiveElement[]>;
|
|
111
|
+
getSimplifiedDOM(): Promise<string>;
|
|
112
|
+
captureObservation(): Promise<BrowserObservation>;
|
|
113
|
+
capturePageSignals(options?: {
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
}): Promise<VideoPageSignals>;
|
|
116
|
+
captureVerificationBundle(options?: {
|
|
117
|
+
settleMs?: number;
|
|
118
|
+
maxAttempts?: number;
|
|
119
|
+
}): Promise<BrowserVerificationBundle>;
|
|
120
|
+
captureVideoVerificationBundle(options?: {
|
|
121
|
+
settleMs?: number;
|
|
122
|
+
maxAttempts?: number;
|
|
123
|
+
helperTimeoutMs?: number;
|
|
124
|
+
}): Promise<BrowserVideoVerificationBundle>;
|
|
125
|
+
clickByIndex(index: number): Promise<void>;
|
|
126
|
+
clickBySelector(selector: string, options?: {
|
|
127
|
+
force?: boolean;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
clickByCoordinates(x: number, y: number): Promise<void>;
|
|
130
|
+
hoverByIndex(index: number): Promise<void>;
|
|
131
|
+
hoverBySelector(selector: string): Promise<void>;
|
|
132
|
+
hoverByCoordinates(x: number, y: number): Promise<void>;
|
|
133
|
+
typeText(text: string, options?: {
|
|
134
|
+
index?: number;
|
|
135
|
+
selector?: string;
|
|
136
|
+
clearFirst?: boolean;
|
|
137
|
+
}): Promise<void>;
|
|
138
|
+
selectOption(options: {
|
|
139
|
+
index?: number;
|
|
140
|
+
selector?: string;
|
|
141
|
+
optionLabel?: string;
|
|
142
|
+
optionValue?: string;
|
|
143
|
+
optionIndex?: number;
|
|
144
|
+
}): Promise<void>;
|
|
145
|
+
scroll(direction: string, amount?: number, selector?: string): Promise<void>;
|
|
146
|
+
scrollElementIntoView(index: number, options?: {
|
|
147
|
+
align?: 'start' | 'center' | 'end';
|
|
148
|
+
margin?: number;
|
|
149
|
+
}): Promise<void>;
|
|
150
|
+
safeExpand(options: {
|
|
151
|
+
index?: number;
|
|
152
|
+
selector?: string;
|
|
153
|
+
expectedText?: string;
|
|
154
|
+
expectedSelector?: string;
|
|
155
|
+
}): Promise<void>;
|
|
156
|
+
pressKey(key: string): Promise<void>;
|
|
157
|
+
searchText(query: string): Promise<Array<Record<string, unknown>>>;
|
|
158
|
+
getAKTree(): Promise<AKTree>;
|
|
159
|
+
resolveAKNode(nodeId: string, options?: {
|
|
160
|
+
reparse?: boolean;
|
|
161
|
+
}): Promise<AKNodeRuntimeIndexEntry | null>;
|
|
162
|
+
tapNode(nodeId: string, options?: {
|
|
163
|
+
force?: boolean;
|
|
164
|
+
}): Promise<void>;
|
|
165
|
+
typeIntoNode(nodeId: string, text: string, options?: {
|
|
166
|
+
clearFirst?: boolean;
|
|
167
|
+
}): Promise<void>;
|
|
168
|
+
captureNode(nodeId?: string): Promise<Buffer>;
|
|
169
|
+
focusTree(query: FocusQuery): Promise<{
|
|
170
|
+
tree: AKTree;
|
|
171
|
+
serialized: string;
|
|
172
|
+
matches: AKNode[];
|
|
173
|
+
}>;
|
|
174
|
+
centerNodeInView(centerNodeId: string, options?: {
|
|
175
|
+
containerNodeId?: string;
|
|
176
|
+
offset?: number;
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
waitForPageReaction(before?: BrowserObservation, options?: {
|
|
179
|
+
timeoutMs?: number;
|
|
180
|
+
settleMs?: number;
|
|
181
|
+
idleGraceMs?: number;
|
|
182
|
+
}): Promise<BrowserReaction>;
|
|
183
|
+
wait(ms: number): Promise<void>;
|
|
184
|
+
dismissOverlays(): Promise<{
|
|
185
|
+
dismissed: boolean;
|
|
186
|
+
method: string | null;
|
|
187
|
+
}>;
|
|
188
|
+
setColorScheme(scheme: 'light' | 'dark'): Promise<void>;
|
|
189
|
+
setLanguage(lang: string): Promise<void>;
|
|
190
|
+
resizeViewport(width: number, height: number): Promise<void>;
|
|
191
|
+
forceLoadLazyImages(options?: {
|
|
192
|
+
timeout?: number;
|
|
193
|
+
}): Promise<void>;
|
|
194
|
+
exportStorageState(): Promise<BrowserStorageState>;
|
|
195
|
+
exportSessionStorage(): Promise<BrowserSessionStorageState>;
|
|
196
|
+
reloadCurrentPage(options?: {
|
|
197
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
|
198
|
+
timeout?: number;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
writeStorageHintCandidate(params: BrowserStorageHintWriteParams): Promise<boolean>;
|
|
201
|
+
probeSelector(selector: string): Promise<BrowserSelectorProbe | null>;
|
|
202
|
+
prepareSessionStorage(bundle: BrowserSessionStorageState | undefined, options?: {
|
|
203
|
+
replace?: boolean;
|
|
204
|
+
}): Promise<void>;
|
|
205
|
+
observeNetworkRequests(url: string, waitMs?: number): Promise<Array<Record<string, unknown>>>;
|
|
206
|
+
setupRouteInterception(mocks: Array<Record<string, unknown>>): Promise<void>;
|
|
207
|
+
clearRouteInterception(): Promise<void>;
|
|
208
|
+
/** Explicit allowlist of callable RPC methods — defense-in-depth. */
|
|
209
|
+
private static readonly ALLOWED_METHODS;
|
|
210
|
+
private call;
|
|
211
|
+
private callAndSyncPageInfo;
|
|
212
|
+
sendEvent(event: WsEvent): void;
|
|
213
|
+
destroy(): void;
|
|
214
|
+
}
|
|
215
|
+
export {};
|