import { TypingGuard } from '../browser/human-input-guard'; import { type CdpPage, type ElementInfo } from './browse-types'; /** Maps a character to its CDP key/code/shift properties. */ export declare function charToKey(c: string): { key: string; code: string; shift: boolean; }; /** * Strips the common leading whitespace from all non-empty lines. * Fixes LLM output that has consistent extra indentation (e.g. 8 spaces * instead of 4). The relative indentation between lines is preserved. */ export declare function normalizeCodeIndent(text: string): string; /** Clear editor content: Ctrl+A → Backspace. */ export declare function clearEditor(page: CdpPage): Promise; /** Read current editor content from Monaco/CM5/CM6/Ace. */ export declare function readEditorContent(page: CdpPage): Promise; /** Scroll an off-screen element into view before clicking. */ export declare function scrollElementIntoView(page: CdpPage, el: ElementInfo): Promise; /** Check if there are genuinely unanswered questions — catches premature 'done' from LLM. */ /** Normalized identity for ledger keys (text can differ in whitespace/case). */ export declare function normKey(s: string | undefined): string; /** Ledger key for an option: its question plus its own label. */ export declare function clickKeyOf(el: ElementInfo | undefined): string; /** Ledger key for the question an option belongs to. */ export declare function questionKeyOf(el: ElementInfo | undefined): string; export declare function hasUnansweredQuestions(elements: ElementInfo[], answeredQuestions?: Set): boolean; /** * Single-choice option (radio / role=radio|option|tab|menuitem / option-styled * label). Used to refuse re-clicking an already-selected answer, which * would otherwise deselect it on toggle-style widgets. Checkboxes are excluded: * unchecking a checked box is a legitimate (if rare) action. * * Button/li/div option widgets are deliberately NOT here: whether their * question takes one answer or several is the model's per-question decision * (see CHOICE_WIDGET_LABEL in browse-llm.ts), so presuming single-choice * would veto legitimate unchecks on multi-answer questions. The per-screen * click ledger still prevents repeat activations, and the prompt forbids * re-clicking a checked option just to keep it. */ export declare function isSingleChoice(el: ElementInfo | undefined): boolean; /** Normalize code for fuzzy comparison — strip whitespace, normalize quotes. */ export declare function normalizeCode(code: string): string; /** Find how many leading characters two strings share. */ export declare function findCommonPrefix(a: string, b: string): number; /** Wait for the page to change by comparing screenshots periodically. Returns true if changed, false if stopped. */ export declare function waitForScreenChange(page: CdpPage, previousScreenshot: string, intervalMs: number, quality: number, stopped: () => boolean): Promise; /** Box-Muller transform: Gaussian-distributed random number (mean 0, stddev 1). */ export declare function gaussianRandom(): number; /** Variable typing delay — Gaussian distribution with character-specific offsets. */ export declare function variableDelay(baseMs: number, char: string, index: number, _total: number): number; /** * Detect and remove extra trailing closing brackets in the editor. * Handles: } } } → removes extras, keeps correct one. */ export declare function removeTrailingBrackets(page: CdpPage): Promise; /** Insert text into ANY code editor — character-by-character typing, no pasting. */ export declare function insertIntoCodeEditor(page: CdpPage, selector: string, text: string, charDelayMs: number, guard?: TypingGuard): Promise; /** Insert text into a generic input — click focus + char-by-char typing. */ export declare function insertIntoGenericInput(page: CdpPage, el: { x: number; y: number; }, text: string, charDelayMs: number, guard?: TypingGuard): Promise; export interface EditorInfo { type: 'monaco' | 'cm5' | 'cm6' | 'ace' | 'quill' | 'prosemirror' | 'draft' | 'ck5' | 'generic'; selector: string; } /** * Extract page context for the LLM: title, URL, headings, errors, editor content. * This gives the LLM full visibility into what's on screen. */ export declare function extractPageContext(page: CdpPage): Promise; /** * Detect which code/rich-text editor is active on the page. * Returns the editor type and the CSS selector to focus. */ export declare function detectEditor(page: CdpPage): Promise; /** * Focus an element by CSS selector via CDP. * Uses Runtime.evaluate to call .focus() on the element. */ export declare function focusSelector(page: CdpPage, selector: string): Promise;