/** * Deterministic interaction strategy selection shared by batch results and * future adapters. MCP/WebMCP is intentionally absent: this project uses the * visible supervised browser and falls back through its strongest local * representation. */ export type BrowserInteractionStrategy = | 'ax' | 'role-locator' | 'playwright-locator' | 'dom-cua' | 'visual-coordinate' | 'cdp'; export type BrowserInteractionTarget = { locator?: { by?: string }; selector?: string; node_id?: number; x?: number; y?: number; }; export function resolveInteractionStrategy( target: BrowserInteractionTarget, ): BrowserInteractionStrategy { if (target.locator?.by === 'ax' || target.locator?.by === 'ref') return 'ax'; if ( target.locator?.by === 'role' || target.locator?.by === 'label' || target.locator?.by === 'text' || target.locator?.by === 'placeholder' || target.locator?.by === 'testid' ) return 'role-locator'; if (target.locator || target.selector) return 'playwright-locator'; if (target.node_id !== undefined) return 'dom-cua'; if (target.x !== undefined && target.y !== undefined) return 'visual-coordinate'; return 'cdp'; }