autokap 1.0.7 → 1.0.10
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/cursors/macos.svg +4 -0
- package/assets/cursors/windows.svg +15 -0
- package/assets/skill/OPCODE-REFERENCE.md +635 -0
- package/assets/skill/README.md +39 -0
- package/assets/skill/SKILL.md +454 -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/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 +92 -8
- package/dist/agent.js +2936 -781
- 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 +197 -0
- package/dist/benchmark.d.ts +59 -0
- package/dist/benchmark.js +135 -0
- package/dist/billing-operation-logging.d.ts +3 -1
- package/dist/billing-operation-logging.js +4 -0
- package/dist/browser-bar.d.ts +14 -6
- package/dist/browser-bar.js +145 -8
- 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 +61 -11
- package/dist/browser.js +1513 -59
- package/dist/capture-alt-text.js +2 -1
- package/dist/capture-encryption.d.ts +3 -1
- package/dist/capture-encryption.js +21 -6
- package/dist/capture-language-preflight.js +14 -0
- package/dist/capture-llm-page-identity.js +22 -10
- package/dist/capture-page-identity.d.ts +5 -7
- package/dist/capture-page-identity.js +211 -78
- package/dist/capture-preset-credentials.d.ts +50 -0
- package/dist/capture-preset-credentials.js +127 -0
- package/dist/capture-request-plan.d.ts +2 -2
- package/dist/capture-request-plan.js +64 -16
- package/dist/capture-run-optimizer.js +48 -33
- package/dist/capture-selector-memory.d.ts +5 -0
- package/dist/capture-selector-memory.js +18 -0
- package/dist/capture-strategy.d.ts +36 -0
- package/dist/capture-strategy.js +96 -0
- package/dist/capture-studio-sync.d.ts +1 -0
- package/dist/capture-studio-sync.js +9 -3
- 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 +2 -0
- package/dist/capture-variant-state.js +26 -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 +9 -1
- package/dist/cli-config.js +112 -7
- package/dist/cli-contract.d.ts +19 -0
- package/dist/cli-contract.js +173 -0
- package/dist/cli-runner-local.d.ts +12 -0
- package/dist/cli-runner-local.js +115 -0
- package/dist/cli-runner.d.ts +34 -0
- package/dist/cli-runner.js +580 -0
- package/dist/cli-utils.d.ts +0 -1
- package/dist/cli-utils.js +2 -5
- package/dist/cli.js +1011 -267
- package/dist/clip-begin-frame-recorder.d.ts +44 -0
- package/dist/clip-begin-frame-recorder.js +250 -0
- package/dist/clip-capture-backend.d.ts +25 -0
- package/dist/clip-capture-backend.js +189 -0
- package/dist/clip-capture-loop.d.ts +61 -0
- package/dist/clip-capture-loop.js +111 -0
- package/dist/clip-frame-recorder.d.ts +63 -0
- package/dist/clip-frame-recorder.js +305 -0
- package/dist/clip-orchestrator.js +9 -2
- package/dist/clip-postprocess.d.ts +31 -2
- package/dist/clip-postprocess.js +194 -68
- package/dist/clip-runtime.d.ts +18 -0
- package/dist/clip-runtime.js +67 -0
- package/dist/clip-scale.d.ts +10 -0
- package/dist/clip-scale.js +21 -0
- package/dist/clip-screencast-recorder.d.ts +42 -0
- package/dist/clip-screencast-recorder.js +242 -0
- package/dist/clip-sidecar.d.ts +54 -0
- package/dist/clip-sidecar.js +208 -0
- package/dist/cookie-dismiss.d.ts +2 -0
- package/dist/cookie-dismiss.js +48 -13
- package/dist/cost-logging.d.ts +8 -0
- package/dist/cost-logging.js +160 -46
- package/dist/cost-resolution-monitor.d.ts +16 -0
- package/dist/cost-resolution-monitor.js +34 -0
- package/dist/credential-templates.js +2 -2
- 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 +1 -41
- package/dist/element-capture.js +202 -446
- package/dist/env-validation.d.ts +5 -0
- package/dist/env-validation.js +63 -0
- package/dist/execution-schema.d.ts +4753 -0
- package/dist/execution-schema.js +563 -0
- package/dist/execution-types.d.ts +936 -0
- package/dist/execution-types.js +66 -0
- package/dist/fonts-loader.d.ts +14 -0
- package/dist/fonts-loader.js +55 -0
- package/dist/hybrid-navigator.js +12 -12
- package/dist/index.d.ts +11 -6
- package/dist/index.js +11 -4
- 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 +55 -0
- package/dist/llm-healer.js +213 -0
- package/dist/llm-provider.d.ts +29 -0
- package/dist/llm-provider.js +83 -0
- package/dist/logger.d.ts +6 -2
- package/dist/logger.js +15 -1
- package/dist/mockup-html.js +35 -25
- package/dist/mockup.d.ts +95 -2
- package/dist/mockup.js +427 -166
- package/dist/mouse-animation.d.ts +2 -2
- package/dist/mouse-animation.js +34 -20
- package/dist/opcode-actions.d.ts +42 -0
- package/dist/opcode-actions.js +524 -0
- package/dist/opcode-runner.d.ts +51 -0
- package/dist/opcode-runner.js +779 -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/postcondition.d.ts +16 -0
- package/dist/postcondition.js +269 -0
- package/dist/program-patcher.d.ts +25 -0
- package/dist/program-patcher.js +44 -0
- package/dist/program-signing.d.ts +1094 -0
- package/dist/program-signing.js +140 -0
- package/dist/prompts.d.ts +13 -5
- package/dist/prompts.js +224 -351
- package/dist/provider-config.d.ts +17 -0
- package/dist/provider-config.js +42 -0
- package/dist/recovery-chain.d.ts +37 -0
- package/dist/recovery-chain.js +374 -0
- package/dist/remote-browser.d.ts +28 -4
- package/dist/remote-browser.js +60 -5
- 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 +2 -1
- package/dist/security.js +49 -10
- 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 +5 -3
- package/dist/server-capture-runtime.js +42 -95
- package/dist/server-credit-usage.d.ts +2 -2
- package/dist/server-project-webhooks.d.ts +15 -1
- package/dist/server-project-webhooks.js +34 -8
- package/dist/server-screenshot-watermark.js +27 -5
- package/dist/session-profile.js +164 -1
- 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-render.d.ts +20 -0
- package/dist/status-bar-render.js +410 -0
- package/dist/status-bar.d.ts +9 -0
- package/dist/status-bar.js +298 -14
- 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.js +89 -451
- package/dist/types.d.ts +248 -7
- 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.js +18 -13
- package/dist/video-planner.js +2 -1
- package/dist/video-prompts.js +3 -3
- package/dist/web-playwright-local.d.ts +156 -0
- package/dist/web-playwright-local.js +989 -0
- package/dist/ws-auth.js +4 -1
- 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.js +294 -164
- package/dist/ws-metrics-server.d.ts +9 -0
- package/dist/ws-metrics-server.js +31 -0
- package/dist/ws-server.js +41 -1
- package/package.json +62 -35
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — IR Types
|
|
3
|
+
*
|
|
4
|
+
* All types for the compiled execution model:
|
|
5
|
+
* preset (natural language) -> ExecutionProgram (typed IR) -> deterministic runtime
|
|
6
|
+
*/
|
|
7
|
+
import type { AKTree, BrowserStorageState, BrowserSessionStorageState, VideoCursorTheme, VideoPageSignals } from '../types.js';
|
|
8
|
+
export type OpcodeKind = 'NAVIGATE' | 'DISMISS_OVERLAYS' | 'ASSERT_ROUTE' | 'ASSERT_SURFACE' | 'CLICK' | 'TYPE' | 'PRESS_KEY' | 'WAIT_FOR' | 'SET_LOCALE' | 'SET_THEME' | 'SCROLL' | 'CAPTURE_SCREENSHOT' | 'BEGIN_CLIP' | 'END_CLIP';
|
|
9
|
+
export type PostconditionType = 'route_matches' | 'element_visible' | 'element_absent' | 'text_contains' | 'overlay_dismissed' | 'screenshot_stable' | 'any_change' | 'always';
|
|
10
|
+
export interface PostconditionSpec {
|
|
11
|
+
type: PostconditionType;
|
|
12
|
+
/** URL pattern (glob) for route_matches */
|
|
13
|
+
pattern?: string;
|
|
14
|
+
/** CSS/AKTree selector for element_visible, element_absent, text_contains */
|
|
15
|
+
selector?: string;
|
|
16
|
+
/** Expected text substring for text_contains */
|
|
17
|
+
text?: string;
|
|
18
|
+
/** Pixel diff threshold (0-1) for screenshot_stable. Default: 0.01 */
|
|
19
|
+
threshold?: number;
|
|
20
|
+
/** Max wait time (ms) for the postcondition to become true. Default: 5000 */
|
|
21
|
+
waitMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Describes an element semantically, without requiring a CSS selector.
|
|
25
|
+
* The runtime resolves the target using Playwright semantic locators
|
|
26
|
+
* (getByRole, getByText, getByLabel) then falls back to AKTree fuzzy matching.
|
|
27
|
+
*
|
|
28
|
+
* At least one of text/role/label should be provided.
|
|
29
|
+
*/
|
|
30
|
+
export interface SemanticTarget {
|
|
31
|
+
/** Visible text content of the element (exact or partial match) */
|
|
32
|
+
text?: string;
|
|
33
|
+
/** ARIA role: "button", "link", "textbox", "checkbox", "tab", "menuitem", etc. */
|
|
34
|
+
role?: string;
|
|
35
|
+
/** Accessible name: aria-label, associated label text, or title attribute */
|
|
36
|
+
label?: string;
|
|
37
|
+
/** Nearby text or heading for disambiguation (e.g. "in the pricing section") */
|
|
38
|
+
near?: string;
|
|
39
|
+
/** Placeholder text (for inputs) */
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
/** Whether the text match should be exact. Default: false (substring match) */
|
|
42
|
+
exact?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface RecoveryPolicy {
|
|
45
|
+
/** Number of deterministic retries before escalating. Default: 2 */
|
|
46
|
+
retries: number;
|
|
47
|
+
/** Try selector memory alternatives. Default: true */
|
|
48
|
+
useSelectorMemory: boolean;
|
|
49
|
+
/** Try alternative interaction methods (keyboard, JS, coords). Default: true */
|
|
50
|
+
useAltInteraction: boolean;
|
|
51
|
+
/** Reload the page and retry from last checkpoint. Default: false */
|
|
52
|
+
allowReload: boolean;
|
|
53
|
+
/** Allow LLM healer as last resort. Default: true */
|
|
54
|
+
allowHealer: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare const DEFAULT_RECOVERY_POLICY: RecoveryPolicy;
|
|
57
|
+
interface OpcodeBase {
|
|
58
|
+
kind: OpcodeKind;
|
|
59
|
+
/** Human-readable description of what this opcode does */
|
|
60
|
+
description: string;
|
|
61
|
+
postcondition: PostconditionSpec;
|
|
62
|
+
recovery: RecoveryPolicy;
|
|
63
|
+
/** Max time (ms) for this opcode to complete, including recovery. Default: 15000 */
|
|
64
|
+
timeoutMs: number;
|
|
65
|
+
/** Max recovery attempts before this opcode is considered failed. Default: 3 */
|
|
66
|
+
maxFailures: number;
|
|
67
|
+
}
|
|
68
|
+
export interface NavigateOpcode extends OpcodeBase {
|
|
69
|
+
kind: 'NAVIGATE';
|
|
70
|
+
url: string;
|
|
71
|
+
}
|
|
72
|
+
export interface DismissOverlaysOpcode extends OpcodeBase {
|
|
73
|
+
kind: 'DISMISS_OVERLAYS';
|
|
74
|
+
}
|
|
75
|
+
export interface AssertRouteOpcode extends OpcodeBase {
|
|
76
|
+
kind: 'ASSERT_ROUTE';
|
|
77
|
+
/** URL pattern (glob or regex) to assert */
|
|
78
|
+
urlPattern: string;
|
|
79
|
+
}
|
|
80
|
+
export interface AssertSurfaceOpcode extends OpcodeBase {
|
|
81
|
+
kind: 'ASSERT_SURFACE';
|
|
82
|
+
/** Selector(s) that must be visible */
|
|
83
|
+
selectors: string[];
|
|
84
|
+
/** If true, ALL selectors must match. If false, ANY one suffices. Default: true */
|
|
85
|
+
matchAll: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface ClickOpcode extends OpcodeBase {
|
|
88
|
+
kind: 'CLICK';
|
|
89
|
+
/** CSS selector — typically a data-ak attribute set by the user's AI assistant */
|
|
90
|
+
selector: string;
|
|
91
|
+
/** Semantic target fallback — used by recovery chain when selector fails */
|
|
92
|
+
target?: SemanticTarget;
|
|
93
|
+
/** AKTree fingerprint for fuzzy matching fallback */
|
|
94
|
+
fingerprint?: string;
|
|
95
|
+
/** Alternative selectors to try in order */
|
|
96
|
+
selectorAlternates?: string[];
|
|
97
|
+
}
|
|
98
|
+
export interface TypeOpcode extends OpcodeBase {
|
|
99
|
+
kind: 'TYPE';
|
|
100
|
+
/** CSS selector — typically a data-ak attribute set by the user's AI assistant */
|
|
101
|
+
selector: string;
|
|
102
|
+
/** Semantic target fallback */
|
|
103
|
+
target?: SemanticTarget;
|
|
104
|
+
text: string;
|
|
105
|
+
/** Clear existing value before typing. Default: true */
|
|
106
|
+
clearFirst: boolean;
|
|
107
|
+
fingerprint?: string;
|
|
108
|
+
selectorAlternates?: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface PressKeyOpcode extends OpcodeBase {
|
|
111
|
+
kind: 'PRESS_KEY';
|
|
112
|
+
key: string;
|
|
113
|
+
}
|
|
114
|
+
export interface WaitForOpcode extends OpcodeBase {
|
|
115
|
+
kind: 'WAIT_FOR';
|
|
116
|
+
/** CSS selector to wait for — required unless target is provided */
|
|
117
|
+
selector?: string;
|
|
118
|
+
/** Semantic target fallback — used when selector is not available */
|
|
119
|
+
target?: SemanticTarget;
|
|
120
|
+
/** 'visible' = element visible in viewport, 'attached' = exists in DOM. Default: 'visible' */
|
|
121
|
+
state: 'visible' | 'attached';
|
|
122
|
+
}
|
|
123
|
+
export interface SetLocaleOpcode extends OpcodeBase {
|
|
124
|
+
kind: 'SET_LOCALE';
|
|
125
|
+
/** Target BCP-47 locale (e.g. "fr", "en-US") */
|
|
126
|
+
locale: string;
|
|
127
|
+
/** Strategy to set locale */
|
|
128
|
+
method: 'browser_context' | 'ui_interaction' | 'storage';
|
|
129
|
+
/** Selector to interact with (for ui_interaction) */
|
|
130
|
+
selector?: string;
|
|
131
|
+
/** Storage key/value pairs to set (for storage method) */
|
|
132
|
+
storageHints?: {
|
|
133
|
+
storage: 'localStorage' | 'sessionStorage';
|
|
134
|
+
key: string;
|
|
135
|
+
value: string;
|
|
136
|
+
}[];
|
|
137
|
+
}
|
|
138
|
+
export interface SetThemeOpcode extends OpcodeBase {
|
|
139
|
+
kind: 'SET_THEME';
|
|
140
|
+
theme: 'light' | 'dark';
|
|
141
|
+
method: 'color_scheme' | 'ui_interaction' | 'storage';
|
|
142
|
+
selector?: string;
|
|
143
|
+
storageHints?: {
|
|
144
|
+
storage: 'localStorage' | 'sessionStorage';
|
|
145
|
+
key: string;
|
|
146
|
+
value: string;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
export interface ScrollOpcode extends OpcodeBase {
|
|
150
|
+
kind: 'SCROLL';
|
|
151
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
152
|
+
/** Pixels to scroll. Default: viewport height */
|
|
153
|
+
amount?: number;
|
|
154
|
+
/** Optional target selector to scroll into view */
|
|
155
|
+
targetSelector?: string;
|
|
156
|
+
/** Semantic target to scroll into view (used when targetSelector is absent) */
|
|
157
|
+
target?: SemanticTarget;
|
|
158
|
+
}
|
|
159
|
+
export interface CaptureScreenshotOpcode extends OpcodeBase {
|
|
160
|
+
kind: 'CAPTURE_SCREENSHOT';
|
|
161
|
+
/** Stable preset capture identifier (page id / element name) for Studio and dev links */
|
|
162
|
+
captureId?: string;
|
|
163
|
+
/** Human-readable preset capture name */
|
|
164
|
+
captureName?: string;
|
|
165
|
+
/** Optional element selector for element-level capture */
|
|
166
|
+
elementSelector?: string;
|
|
167
|
+
}
|
|
168
|
+
export interface BeginClipOpcode extends OpcodeBase {
|
|
169
|
+
kind: 'BEGIN_CLIP';
|
|
170
|
+
/** Stable preset clip identifier for Studio and dev links */
|
|
171
|
+
clipId?: string;
|
|
172
|
+
/** Human-readable preset clip name */
|
|
173
|
+
clipName?: string;
|
|
174
|
+
}
|
|
175
|
+
export interface EndClipOpcode extends OpcodeBase {
|
|
176
|
+
kind: 'END_CLIP';
|
|
177
|
+
/** Stable preset clip identifier for Studio and dev links */
|
|
178
|
+
clipId?: string;
|
|
179
|
+
/** Human-readable preset clip name */
|
|
180
|
+
clipName?: string;
|
|
181
|
+
}
|
|
182
|
+
export type ExecutionOpcode = NavigateOpcode | DismissOverlaysOpcode | AssertRouteOpcode | AssertSurfaceOpcode | ClickOpcode | TypeOpcode | PressKeyOpcode | WaitForOpcode | SetLocaleOpcode | SetThemeOpcode | ScrollOpcode | CaptureScreenshotOpcode | BeginClipOpcode | EndClipOpcode;
|
|
183
|
+
export interface VariantSpec {
|
|
184
|
+
id: string;
|
|
185
|
+
viewport: {
|
|
186
|
+
width: number;
|
|
187
|
+
height: number;
|
|
188
|
+
};
|
|
189
|
+
deviceScaleFactor?: number;
|
|
190
|
+
locale?: string;
|
|
191
|
+
theme?: 'light' | 'dark';
|
|
192
|
+
/** Stable target identifier from the preset config */
|
|
193
|
+
targetId?: string;
|
|
194
|
+
/** Human-readable target label from the preset config */
|
|
195
|
+
targetLabel?: string;
|
|
196
|
+
/** Device frame label (e.g. "iPhone 15 Pro") for mockup rendering */
|
|
197
|
+
deviceFrame?: string;
|
|
198
|
+
}
|
|
199
|
+
export interface PreconditionSpec {
|
|
200
|
+
/** Auth requirement */
|
|
201
|
+
auth: 'authenticated' | 'anonymous' | 'any';
|
|
202
|
+
/** Credentials reference ID (resolved at runtime from CLI config) */
|
|
203
|
+
credentialsId?: string;
|
|
204
|
+
/** Pre-loaded storage state */
|
|
205
|
+
storageState?: BrowserStorageState;
|
|
206
|
+
sessionStorage?: BrowserSessionStorageState;
|
|
207
|
+
/** Cookies to set before execution */
|
|
208
|
+
cookies?: Array<{
|
|
209
|
+
name: string;
|
|
210
|
+
value: string;
|
|
211
|
+
domain: string;
|
|
212
|
+
path?: string;
|
|
213
|
+
}>;
|
|
214
|
+
}
|
|
215
|
+
export type MediaMode = 'screenshot' | 'clip';
|
|
216
|
+
export interface ArtifactSpec {
|
|
217
|
+
mediaMode: MediaMode;
|
|
218
|
+
/** Output format preferences */
|
|
219
|
+
format?: {
|
|
220
|
+
/** For clips: 'gif' | 'mp4' | 'both'. Default: 'gif' */
|
|
221
|
+
clipFormat?: 'gif' | 'mp4' | 'both';
|
|
222
|
+
/** For screenshots: 'png' | 'jpeg'. Default: 'png' */
|
|
223
|
+
screenshotFormat?: 'png' | 'jpeg';
|
|
224
|
+
};
|
|
225
|
+
/** Cursor style for clip recordings. Default: 'minimal'. */
|
|
226
|
+
cursorTheme?: VideoCursorTheme;
|
|
227
|
+
/** Whether to apply device frame mockup. Default: false */
|
|
228
|
+
applyMockup?: boolean;
|
|
229
|
+
/** Whether to add status bar. Default: false */
|
|
230
|
+
applyStatusBar?: boolean;
|
|
231
|
+
}
|
|
232
|
+
export interface ExecutionProgram {
|
|
233
|
+
presetId: string;
|
|
234
|
+
programVersion: number;
|
|
235
|
+
mediaMode: MediaMode;
|
|
236
|
+
baseUrl: string;
|
|
237
|
+
variants: VariantSpec[];
|
|
238
|
+
preconditions: PreconditionSpec;
|
|
239
|
+
steps: ExecutionOpcode[];
|
|
240
|
+
artifactPlan: ArtifactSpec;
|
|
241
|
+
/** Hash of the source preset content, used to detect recompilation needs */
|
|
242
|
+
compileFingerprint: string;
|
|
243
|
+
/** ISO timestamp of compilation */
|
|
244
|
+
compiledAt: string;
|
|
245
|
+
/** Model used for compilation */
|
|
246
|
+
compiledWith?: string;
|
|
247
|
+
}
|
|
248
|
+
export interface CircuitBreakerConfig {
|
|
249
|
+
/** Max recovery attempts per opcode. Default: 3 */
|
|
250
|
+
maxPerOpcode: number;
|
|
251
|
+
/** Max total failures per page navigation. Default: 5 */
|
|
252
|
+
maxPerPage: number;
|
|
253
|
+
/** Max total failures per run. Default: 10 */
|
|
254
|
+
maxPerRun: number;
|
|
255
|
+
}
|
|
256
|
+
export declare const DEFAULT_CIRCUIT_BREAKER: CircuitBreakerConfig;
|
|
257
|
+
export interface HealerPatch {
|
|
258
|
+
/** Index of the opcode in the program that was patched */
|
|
259
|
+
opcodeIndex: number;
|
|
260
|
+
/** The original opcode before patching */
|
|
261
|
+
originalOpcode: ExecutionOpcode;
|
|
262
|
+
/** The replacement opcode(s). Usually 1, max 3. */
|
|
263
|
+
replacementOpcodes: ExecutionOpcode[];
|
|
264
|
+
/** Why the healer made this change */
|
|
265
|
+
reason: string;
|
|
266
|
+
/** Timestamp */
|
|
267
|
+
patchedAt: string;
|
|
268
|
+
}
|
|
269
|
+
export type OpcodeResultStatus = 'ok' | 'recovered' | 'skipped' | 'failed';
|
|
270
|
+
export interface OpcodeResult {
|
|
271
|
+
opcodeIndex: number;
|
|
272
|
+
kind: OpcodeKind;
|
|
273
|
+
status: OpcodeResultStatus;
|
|
274
|
+
/** Time taken for this opcode (ms) */
|
|
275
|
+
durationMs: number;
|
|
276
|
+
/** Number of recovery attempts used */
|
|
277
|
+
recoveryAttempts: number;
|
|
278
|
+
/** Recovery strategy that succeeded, if any */
|
|
279
|
+
recoveryStrategy?: 'retry' | 'selector_memory' | 'alt_interaction' | 'reload' | 'healer';
|
|
280
|
+
/** Error message if failed */
|
|
281
|
+
error?: string;
|
|
282
|
+
}
|
|
283
|
+
export interface VariantResult {
|
|
284
|
+
variantId: string;
|
|
285
|
+
success: boolean;
|
|
286
|
+
opcodeResults: OpcodeResult[];
|
|
287
|
+
/** Total duration for this variant (ms) */
|
|
288
|
+
durationMs: number;
|
|
289
|
+
/** Artifact buffers produced */
|
|
290
|
+
artifacts: ArtifactResult[];
|
|
291
|
+
error?: string;
|
|
292
|
+
}
|
|
293
|
+
export interface ArtifactResult {
|
|
294
|
+
mediaMode: MediaMode;
|
|
295
|
+
buffer: Buffer;
|
|
296
|
+
mimeType: string;
|
|
297
|
+
durationMs?: number;
|
|
298
|
+
trimStartMs?: number;
|
|
299
|
+
/** For screenshots: viewport dimensions of the capture */
|
|
300
|
+
dimensions?: {
|
|
301
|
+
width: number;
|
|
302
|
+
height: number;
|
|
303
|
+
};
|
|
304
|
+
/** Generated alt text for accessibility */
|
|
305
|
+
altText?: string;
|
|
306
|
+
/** Final URL at the time the artifact was produced */
|
|
307
|
+
captureUrl?: string;
|
|
308
|
+
/** Step index that produced the artifact */
|
|
309
|
+
stepIndex?: number;
|
|
310
|
+
/** Human-readable label for the artifact */
|
|
311
|
+
stepDescription?: string;
|
|
312
|
+
/** Variant metadata used by persistence and gallery views */
|
|
313
|
+
variantId?: string;
|
|
314
|
+
/** Stable preset capture identifier for screenshots */
|
|
315
|
+
captureId?: string;
|
|
316
|
+
/** Human-readable preset capture name for screenshots */
|
|
317
|
+
captureName?: string;
|
|
318
|
+
/** Stable preset clip identifier for clips */
|
|
319
|
+
clipId?: string;
|
|
320
|
+
/** Human-readable preset clip name for clips */
|
|
321
|
+
clipName?: string;
|
|
322
|
+
captureType?: 'fullpage' | 'element';
|
|
323
|
+
elementSelector?: string;
|
|
324
|
+
}
|
|
325
|
+
export type LLMStepType = 'capture_verification' | 'alt_text_generation' | 'healer_invocation';
|
|
326
|
+
export interface LLMStepUsage {
|
|
327
|
+
stepType: LLMStepType;
|
|
328
|
+
generationId: string | null;
|
|
329
|
+
model: string;
|
|
330
|
+
promptTokens: number;
|
|
331
|
+
completionTokens: number;
|
|
332
|
+
}
|
|
333
|
+
export interface RunTelemetry {
|
|
334
|
+
/** Total LLM calls (compilation excluded) */
|
|
335
|
+
llmCallCount: number;
|
|
336
|
+
/** Total LLM cost in EUR */
|
|
337
|
+
llmCostEur: number;
|
|
338
|
+
/** Detailed per-call LLM usage for cost logging */
|
|
339
|
+
llmStepUsages: LLMStepUsage[];
|
|
340
|
+
/** Total opcodes executed across all variants */
|
|
341
|
+
totalOpcodes: number;
|
|
342
|
+
/** Opcodes that needed recovery */
|
|
343
|
+
recoveredOpcodes: number;
|
|
344
|
+
/** Opcodes that failed even after recovery */
|
|
345
|
+
failedOpcodes: number;
|
|
346
|
+
/** Number of healer invocations */
|
|
347
|
+
healerInvocations: number;
|
|
348
|
+
/** Circuit breaker trips */
|
|
349
|
+
circuitBreakerTrips: number;
|
|
350
|
+
}
|
|
351
|
+
export interface RunResult {
|
|
352
|
+
programId: string;
|
|
353
|
+
success: boolean;
|
|
354
|
+
variantResults: VariantResult[];
|
|
355
|
+
telemetry: RunTelemetry;
|
|
356
|
+
/** Healer patches accumulated during the run. Only propagate to server if success=true */
|
|
357
|
+
healerPatches: HealerPatch[];
|
|
358
|
+
/** Total run duration (ms) */
|
|
359
|
+
totalDurationMs: number;
|
|
360
|
+
error?: string;
|
|
361
|
+
}
|
|
362
|
+
export interface WaitCondition {
|
|
363
|
+
selector: string;
|
|
364
|
+
state: 'visible' | 'attached';
|
|
365
|
+
timeoutMs: number;
|
|
366
|
+
}
|
|
367
|
+
export interface ClickOptions {
|
|
368
|
+
/** Force click even if element is covered */
|
|
369
|
+
force?: boolean;
|
|
370
|
+
/** Use keyboard (Tab + Enter) instead of mouse */
|
|
371
|
+
useKeyboard?: boolean;
|
|
372
|
+
/** Use JS dispatch instead of Playwright click */
|
|
373
|
+
useJsDispatch?: boolean;
|
|
374
|
+
/** Click by coordinates from bounding box */
|
|
375
|
+
coordinates?: {
|
|
376
|
+
x: number;
|
|
377
|
+
y: number;
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
export interface RecordingOptions {
|
|
381
|
+
mediaMode: 'clip';
|
|
382
|
+
}
|
|
383
|
+
export interface RecordingResult {
|
|
384
|
+
buffer: Buffer;
|
|
385
|
+
durationMs: number;
|
|
386
|
+
mimeType: string;
|
|
387
|
+
trimStartMs?: number;
|
|
388
|
+
}
|
|
389
|
+
export interface RuntimeAdapter {
|
|
390
|
+
navigate(url: string): Promise<void>;
|
|
391
|
+
getCurrentUrl(): Promise<string>;
|
|
392
|
+
getAKTree(): Promise<AKTree>;
|
|
393
|
+
getPageSignals(): Promise<VideoPageSignals>;
|
|
394
|
+
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
395
|
+
type(selector: string, text: string, clearFirst?: boolean): Promise<void>;
|
|
396
|
+
pressKey(key: string): Promise<void>;
|
|
397
|
+
scroll(direction: 'up' | 'down' | 'left' | 'right', amount?: number): Promise<void>;
|
|
398
|
+
scrollIntoView(selector: string): Promise<void>;
|
|
399
|
+
waitFor(condition: WaitCondition): Promise<boolean>;
|
|
400
|
+
dismissOverlays(): Promise<{
|
|
401
|
+
dismissed: boolean;
|
|
402
|
+
method: string | null;
|
|
403
|
+
}>;
|
|
404
|
+
takeScreenshot(): Promise<Buffer>;
|
|
405
|
+
takeElementScreenshot?(selector: string): Promise<Buffer>;
|
|
406
|
+
takeCleanScreenshot(): Promise<Buffer>;
|
|
407
|
+
beginRecording(options: RecordingOptions): Promise<void>;
|
|
408
|
+
endRecording(): Promise<RecordingResult>;
|
|
409
|
+
setLocale(locale: string): Promise<void>;
|
|
410
|
+
setColorScheme(scheme: 'light' | 'dark'): Promise<void>;
|
|
411
|
+
reloadPage?(): Promise<void>;
|
|
412
|
+
writeStorageHint?(params: {
|
|
413
|
+
storage: 'localStorage' | 'sessionStorage';
|
|
414
|
+
key: string;
|
|
415
|
+
value: string;
|
|
416
|
+
kind: 'locale' | 'theme';
|
|
417
|
+
}): Promise<boolean>;
|
|
418
|
+
close(): Promise<void>;
|
|
419
|
+
/** Click an element by semantic target. Falls back to selector if target not found. */
|
|
420
|
+
clickByTarget?(opts: {
|
|
421
|
+
selector?: string;
|
|
422
|
+
target?: SemanticTarget;
|
|
423
|
+
selectorAlternates?: string[];
|
|
424
|
+
}): Promise<void>;
|
|
425
|
+
/** Type into an element by semantic target. */
|
|
426
|
+
typeByTarget?(opts: {
|
|
427
|
+
selector?: string;
|
|
428
|
+
target?: SemanticTarget;
|
|
429
|
+
selectorAlternates?: string[];
|
|
430
|
+
}, text: string, clearFirst?: boolean): Promise<void>;
|
|
431
|
+
/** Wait for an element by semantic target. */
|
|
432
|
+
waitForTarget?(opts: {
|
|
433
|
+
selector?: string;
|
|
434
|
+
target?: SemanticTarget;
|
|
435
|
+
selectorAlternates?: string[];
|
|
436
|
+
}, timeoutMs?: number): Promise<boolean>;
|
|
437
|
+
/** Scroll an element into view by semantic target. */
|
|
438
|
+
scrollIntoViewByTarget?(opts: {
|
|
439
|
+
selector?: string;
|
|
440
|
+
target?: SemanticTarget;
|
|
441
|
+
selectorAlternates?: string[];
|
|
442
|
+
}): Promise<void>;
|
|
443
|
+
}
|
|
444
|
+
export {};
|
package/dist/v2/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — IR Types
|
|
3
|
+
*
|
|
4
|
+
* All types for the compiled execution model:
|
|
5
|
+
* preset (natural language) -> ExecutionProgram (typed IR) -> deterministic runtime
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_RECOVERY_POLICY = {
|
|
8
|
+
retries: 2,
|
|
9
|
+
useSelectorMemory: true,
|
|
10
|
+
useAltInteraction: true,
|
|
11
|
+
allowReload: false,
|
|
12
|
+
allowHealer: true,
|
|
13
|
+
};
|
|
14
|
+
export const DEFAULT_CIRCUIT_BREAKER = {
|
|
15
|
+
maxPerOpcode: 3,
|
|
16
|
+
maxPerPage: 5,
|
|
17
|
+
maxPerRun: 10,
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — WebPlaywrightLocal RuntimeAdapter
|
|
3
|
+
*
|
|
4
|
+
* Thin adapter delegating to the existing Browser class from src/browser.ts.
|
|
5
|
+
* This is the first (and for now only) RuntimeAdapter implementation.
|
|
6
|
+
*/
|
|
7
|
+
import type { Browser } from '../browser.js';
|
|
8
|
+
import type { AKTree, VideoPageSignals } from '../types.js';
|
|
9
|
+
import type { RuntimeAdapter, ClickOptions, WaitCondition, RecordingOptions, RecordingResult } from './types.js';
|
|
10
|
+
import { type ResolveOptions } from './semantic-resolver.js';
|
|
11
|
+
export declare class WebPlaywrightLocal implements RuntimeAdapter {
|
|
12
|
+
private browser;
|
|
13
|
+
private recordingDir?;
|
|
14
|
+
private readonly sessionStartedAt;
|
|
15
|
+
private recording;
|
|
16
|
+
private clipCursor;
|
|
17
|
+
constructor(browser: Browser, recordingDir?: string | undefined);
|
|
18
|
+
navigate(url: string): Promise<void>;
|
|
19
|
+
getCurrentUrl(): Promise<string>;
|
|
20
|
+
getAKTree(): Promise<AKTree>;
|
|
21
|
+
getPageSignals(): Promise<VideoPageSignals>;
|
|
22
|
+
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Click an element using semantic target resolution.
|
|
25
|
+
* Tries CSS selector first, falls back to Playwright semantic locators.
|
|
26
|
+
*/
|
|
27
|
+
clickByTarget(opts: ResolveOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Type into an element using semantic target resolution.
|
|
30
|
+
*/
|
|
31
|
+
typeByTarget(opts: ResolveOptions, text: string, clearFirst?: boolean): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Wait for an element using semantic target resolution.
|
|
34
|
+
*/
|
|
35
|
+
waitForTarget(opts: ResolveOptions, timeoutMs?: number): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Scroll an element into view using semantic target resolution.
|
|
38
|
+
*/
|
|
39
|
+
scrollIntoViewByTarget(opts: ResolveOptions): Promise<void>;
|
|
40
|
+
type(selector: string, text: string, clearFirst?: boolean): Promise<void>;
|
|
41
|
+
pressKey(key: string): Promise<void>;
|
|
42
|
+
scroll(direction: 'up' | 'down' | 'left' | 'right', amount?: number): Promise<void>;
|
|
43
|
+
scrollIntoView(selector: string): Promise<void>;
|
|
44
|
+
waitFor(condition: WaitCondition): Promise<boolean>;
|
|
45
|
+
dismissOverlays(): Promise<{
|
|
46
|
+
dismissed: boolean;
|
|
47
|
+
method: string | null;
|
|
48
|
+
}>;
|
|
49
|
+
takeScreenshot(): Promise<Buffer>;
|
|
50
|
+
takeElementScreenshot(selector: string): Promise<Buffer>;
|
|
51
|
+
takeCleanScreenshot(): Promise<Buffer>;
|
|
52
|
+
beginRecording(options: RecordingOptions): Promise<void>;
|
|
53
|
+
endRecording(): Promise<RecordingResult>;
|
|
54
|
+
setLocale(locale: string): Promise<void>;
|
|
55
|
+
setColorScheme(scheme: 'light' | 'dark'): Promise<void>;
|
|
56
|
+
reloadPage(): Promise<void>;
|
|
57
|
+
writeStorageHint(params: {
|
|
58
|
+
storage: 'localStorage' | 'sessionStorage';
|
|
59
|
+
key: string;
|
|
60
|
+
value: string;
|
|
61
|
+
kind: 'locale' | 'theme';
|
|
62
|
+
}): Promise<boolean>;
|
|
63
|
+
close(): Promise<void>;
|
|
64
|
+
private typeIntoLocator;
|
|
65
|
+
private seedClipCursor;
|
|
66
|
+
private moveClipCursorToViewportCenter;
|
|
67
|
+
private moveClipCursorToLocator;
|
|
68
|
+
private moveClipCursorToPoint;
|
|
69
|
+
}
|