/** * Capture Agent — Shared Opcode Actions * * Deterministic action dispatch shared by the main opcode runner and the * recovery chain so both paths execute the same behavior. */ import type { ExecutionOpcode, MockDataGroup, RuntimeAdapter, VariantSpec } from './execution-types.js'; export interface OpcodeActionContext { currentVariant?: VariantSpec; /** Disallow opcodes that would reload the page while a clip is being recorded. */ suppressPageReloads?: boolean; /** Mock data groups available to INJECT_MOCK_DATA. Plumbed from ExecutionProgram. */ mockDataGroups?: MockDataGroup[]; /** * Live credentials used to substitute {{email}}/{{password}}/{{loginUrl}} * placeholders in TYPE / NAVIGATE opcodes. Plumbed from * `program.preconditions.credentials`. */ credentials?: { email?: string; password?: string; loginUrl?: string; }; } /** * Substitute credential placeholders inside opcode text fields. * Only the {{email}}, {{password}} and {{loginUrl}} tokens are replaced. * No-op if no credentials are present or the text contains no placeholder. */ export declare function substituteCredentialPlaceholders(text: string, credentials?: OpcodeActionContext['credentials']): string; /** * Returns the list of credential placeholders (`{{email}}`, `{{password}}`, * `{{loginUrl}}`) that the input string references but the provided * `credentials` object does NOT have a non-empty value for. Used by the * opcode dispatcher to fail loudly with a clear message when a NAVIGATE / * TYPE / etc. would otherwise resolve to an empty string and crash * Playwright with a confusing "Cannot navigate to invalid URL" error. */ export declare function findUnresolvedCredentialPlaceholders(text: string, credentials?: OpcodeActionContext['credentials']): string[]; export interface OpcodeActionResult { success: boolean; error?: string; /** * For TYPE opcodes: absolute wall-clock timestamps (`Date.now()`) of each * keystroke produced by `humanType`. The runner converts these to * clip-relative offsets so the video compositor can fire per-keystroke SFX. */ keystrokeTimestampsMs?: number[]; /** * For CLICK / DOUBLE_CLICK / CHECK opcodes: absolute wall-clock timestamps * captured INSIDE the adapter, just before Playwright dispatches the * actual click — i.e. AFTER the cursor animation has settled on the * target. Lets the compositor place the mouse SFX in sync with the visible * click instead of when the cursor was still travelling. */ clickTimestampsMs?: number[]; /** * For CAPTURE_SCREENSHOT: index in the variant's `artifacts` array of the * screenshot this action just delivered. The deterministic capture pushes the * artifact immediately; LLM enrichment (quality verification + alt text) runs * afterwards in `executeOpcode` and mutates this artifact in place, so it can * never void an already-captured screenshot or trip the action timeout. */ captureArtifactIndex?: number; /** For CAPTURE_SCREENSHOT: page URL at capture time, reused by enrichment. */ captureUrl?: string; } export declare function executeOpcodeCoreAction(opcode: ExecutionOpcode, adapter: RuntimeAdapter, context?: OpcodeActionContext): Promise;