/** * Playwright executor for {@link ComputerAction} (#A7 Phase 1). * * Translates Anthropic's `computer_20250124` action vocabulary into * Playwright `Page` calls. Stateless apart from {@link ComputerExecutorState}, * which the caller threads through so `cursor_position` can answer. * * # Errors * * Playwright throws on failures (selector misses, timeouts, navigation * during action). The executor catches and returns * `{ type: 'error', text: }` so the agent loop can hand the * failure back to the model as a tool-result with `is_error: true`. The * model decides whether to retry, recover, or give up — failing the * whole agent run on a single missed click is too brittle. * * # Modifier keys & key chords * * Anthropic uses xdotool naming (`ctrl`, `cmd`, `Return`); Playwright * uses its own (`Control`, `Meta`, `Enter`). {@link normalizeKey} maps * the common ones; unmapped keys pass through verbatim and Playwright * either accepts them (single chars, function keys) or throws — which * surfaces as the standard error path above. * * # Scroll units * * Anthropic's `scroll_amount` is in mouse-wheel "clicks". A typical * desktop wheel click is ~100px; the executor multiplies through * {@link SCROLL_PIXELS_PER_CLICK}. Tunable later if customer feedback * shows drift. */ import type { ComputerAction, ComputerActionResult, ComputerExecutorState, PageLike } from './actions.js'; /** * Pixels per `scroll_amount` unit. Roughly matches a desktop mouse * wheel click on most platforms. */ export declare const SCROLL_PIXELS_PER_CLICK = 100; /** * Number of intermediate move steps Playwright interpolates when the * executor moves the mouse to a target. Higher = smoother (more hover * events fire), but slower. 5 is a reasonable default — instant enough * for most pages, slow enough that hover-driven UI (tooltips, menus) * has a chance to react. */ export declare const MOUSE_MOVE_STEPS = 5; /** * Dispatch a single {@link ComputerAction} against a Playwright `Page`. * * Updates `state.cursor` after every action that targets a coordinate * (move / click / drag / scroll). Caller owns `state` and threads it * through every call within an agent run. * * Returns a {@link ComputerActionResult} suitable for forwarding to the * model as a tool-result. Never throws — Playwright failures surface as * `{ type: 'error', text }`. */ export declare function executeComputerAction(page: PageLike, action: ComputerAction, state: ComputerExecutorState): Promise; /** * Parse Anthropic's `+`-separated modifier text into Playwright key * names. Empty / undefined input → empty array (no modifiers). */ export declare function parseModifiers(text: string | undefined): string[]; /** * Map Anthropic / xdotool key names to Playwright key names. * Unmapped keys (single chars, F-keys, anything we haven't covered) * pass through verbatim — Playwright either accepts them or throws, * which is the right failure mode. */ export declare function normalizeKey(key: string): string; /** * Normalize a key chord (`+`-separated). Playwright's * `keyboard.press()` parses chords natively, so we just normalize each * segment and rejoin. */ export declare function normalizeChord(chord: string): string; //# sourceMappingURL=playwright.d.ts.map