/** * Capture Agent — Opcode Runner * * Deterministic execution engine for ExecutionProgram. * Executes opcodes sequentially, verifies postconditions, * delegates to recovery chain on failure, and respects circuit breaker. */ import type { ExecutionProgram, ExecutionOpcode, RuntimeAdapter, OpcodeResultStatus, RunResult, HealerPatch, VariantSpec, ProgressSnapshot } from './execution-types.js'; import type { LLMProviderConfig, LLMCallResult } from './llm-provider.js'; export interface RecoveryChain { attempt(failedOpcode: ExecutionOpcode, opcodeIndex: number, adapter: RuntimeAdapter, options?: RecoveryAttemptOptions): Promise; } export interface RecoveryAttemptResult { recovered: boolean; strategy?: 'retry' | 'selector_memory' | 'alt_interaction' | 'reload' | 'healer'; patch?: HealerPatch; llmResult?: LLMCallResult; reason: string; } export interface RecoveryAttemptOptions { remainingTimeMs?: number; /** * AUT-240 (Phase 5): absolute global wait deadline. Lets recovery re-checks * extend-on-progress (like the main path) instead of replaying a fixed budget. */ globalDeadlineMs?: number; /** Progress probe for the recovery watchdog (omitted ⇒ fixed budgets). */ getProgress?: () => Promise; maxDeterministicRetries?: number; currentVariant?: VariantSpec; allowPageReload?: boolean; suppressPageReloads?: boolean; } /** Default recovery chain for consumers that do not inject one. */ export declare class NoOpRecoveryChain implements RecoveryChain { attempt(): Promise; } export interface RunOptions { /** Recovery chain implementation. Defaults to no-op. */ recoveryChain?: RecoveryChain; /** Abort signal for cancellation */ abortSignal?: AbortSignal; /** Maximum number of variants to execute in parallel. Defaults to 1. */ maxParallelVariants?: number; /** Callback for progress updates */ onProgress?: (event: ProgressEvent) => void; /** LLM config for capture verification + alt text. If absent, verification is skipped. */ llmConfig?: LLMProviderConfig; /** Preset name for alt text context */ presetName?: string; /** Dry run: skip CAPTURE_SCREENSHOT/BEGIN_CLIP/END_CLIP — other opcodes still execute. */ dryRun?: boolean; } export interface ProgressEvent { type: 'variant_start' | 'variant_end' | 'opcode_start' | 'opcode_end' | 'recovery' | 'breaker_trip' | 'upload_start' | 'upload_end' | 'tts_progress'; variantId: string; opcodeIndex?: number; /** Total opcode count in the variant program (set on opcode_start). */ opcodeTotal?: number; opcodeKind?: string; status?: OpcodeResultStatus; message: string; /** tts_progress only: 'synthesizing' | 'uploading' | 'done'. */ stage?: string; /** tts_progress only: 1-based segment index and total. */ index?: number; total?: number; /** tts_progress only: the SLEEP anchor / step id being synthesized. */ stepId?: string; } export declare function executeProgram(program: ExecutionProgram, createAdapter: (variant: VariantSpec) => Promise, options?: RunOptions): Promise;