/** * Capture Agent — Selector Resolver * * Progressive selector resolution for opcodes that target elements: * 1. Primary selector from compiled program * 2. AKTree fingerprint match * 3. Selector memory candidates (from Supabase) * 4. Fuzzy text match on AKTree nodes */ import type { AKTree } from './types.js'; import type { RuntimeAdapter, SemanticTarget } from './execution-types.js'; export interface ResolvedSelector { selector: string; strategy: 'primary' | 'fingerprint' | 'memory' | 'fuzzy_text' | 'alternate' | 'target_text'; confidence: 'high' | 'medium' | 'low'; } export interface SelectorResolverOptions { /** Primary selector from the compiled opcode. Absent for target-only opcodes. */ primary?: string; /** Semantic target from the compiled opcode (for text-based AKTree matching) */ target?: SemanticTarget; /** AKTree fingerprint for fuzzy matching */ fingerprint?: string; /** Alternative selectors from the compiled opcode */ alternates?: string[]; /** Selector memory map: stepSignature -> known-good selectors */ selectorMemory?: Record; /** Step signature for memory lookup */ stepSignature?: string; /** Human-readable description of the target element (for fuzzy matching) */ description?: string; } /** * Resolves a selector by trying multiple strategies in order. * Returns the first working selector, or null if nothing matches. */ export declare function resolveSelector(adapter: RuntimeAdapter, options: SelectorResolverOptions): Promise; /** * Flattens a SemanticTarget into the text used for AKTree fuzzy matching: * base label/text/placeholder plus every locale variant. Returns '' when the * target carries no text at all (e.g. role-only). */ export declare function semanticTargetFuzzyText(target: SemanticTarget): string; /** * Resolves a CSS selector for a visible interactive AKTree node matching the * given text. Used by recovery strategies that need a concrete selector for a * target-only opcode (e.g. coordinate clicks). */ export declare function resolveSelectorByFuzzyText(tree: AKTree, text: string): string | null;