/** * Accessibility tree generation. * Produces a lightweight tree representation of the page for AI agents. * * Enhanced with AI mode, better hidden detection, and richer node properties. * Based on Playwright's ariaSnapshot implementation patterns. */ /** * Enhanced AriaNode with support for mixed children (elements and text). */ export interface AriaNode { /** * Reference ID for the element (can be used with getElementByRef). * Optional in AI mode when refs='interactable' and element is not interactable. */ ref?: string; /** * ARIA role of the element. */ role: string | null; /** * Accessible name of the element. */ name: string; /** * Tag name of the element (lowercase). */ tag: string; /** * Child nodes - can be AriaNode or string (for text content in AI mode). */ children?: (AriaNode | string)[]; /** * Bounding box information. */ box?: { visible: boolean; inline: boolean; cursor?: string; }; /** * Whether the element receives pointer events (not blocked by pointer-events:none). */ receivesPointerEvents?: boolean; /** * Whether the element is focused (document.activeElement). */ focused?: boolean; /** * Whether the element is disabled. */ disabled?: boolean; /** * Whether the element is selected (for options, tabs, etc.). */ selected?: boolean; /** * Checkbox/radio/switch checked state. */ checked?: boolean | 'mixed'; /** * Whether the element is expanded (aria-expanded). */ expanded?: boolean; /** * Toggle button pressed state (aria-pressed). */ pressed?: boolean | 'mixed'; /** * Heading level (1-6). */ level?: number; /** * Current value (for inputs, textareas, etc.). */ value?: string; /** * Description from aria-describedby. */ description?: string; /** * Whether the element has invalid input. */ invalid?: boolean; /** * Whether the element is required. */ required?: boolean; /** * Whether the element is busy. */ busy?: boolean; /** * Current state (aria-current value). */ current?: string; /** * URL for links. */ url?: string; /** * Placeholder for text inputs. */ placeholder?: string; /** * Internal: reference to the DOM element (not serialized). */ _element?: Element; } /** * Legacy flat node for backward compatibility. */ export interface A11yNode { ref: string; role: string | null; name: string; tag: string; focused?: boolean; disabled?: boolean; selected?: boolean; value?: string; level?: number; bbox?: { x: number; y: number; width: number; height: number; }; expanded?: boolean; pressed?: boolean | 'mixed'; checked?: boolean | 'mixed'; invalid?: boolean; required?: boolean; busy?: boolean; current?: string; description?: string; children?: A11yNode[]; } /** * Enhanced options for accessibility tree generation. */ export interface A11yTreeOptions { /** * Tree generation mode: * - 'default': Standard flat list (backward compatible) * - 'ai': Optimized for AI/LLM consumption with text nodes and compact output * - 'strict': Full tree with all elements and no filtering */ mode?: 'default' | 'ai' | 'strict'; /** * Visibility mode: * - 'aria': Only check ARIA visibility (aria-hidden, etc.) * - 'ariaOrVisible': Include if ARIA-visible OR visually visible * - 'ariaAndVisible': Must be both ARIA-visible AND visually visible (default) */ visibility?: 'aria' | 'ariaOrVisible' | 'ariaAndVisible'; /** * Reference ID generation mode: * - 'all': Generate refs for all elements * - 'interactable': Only generate refs for interactable elements (default for AI mode) * - 'none': Don't generate refs */ refs?: 'all' | 'interactable' | 'none'; /** * Maximum depth to traverse. */ maxDepth?: number; /** * Whether to include bounding box information. */ includeBbox?: boolean; /** * Whether to include cursor style for clickable elements. */ includeCursor?: boolean; /** * Whether to include pointer-events capability. */ includePointerEvents?: boolean; /** * Whether to only include interactive elements (legacy option). */ interactiveOnly?: boolean; /** * CSS selector to scope the tree to. */ selector?: string; /** * Whether to traverse shadow DOM. */ pierceShadowDom?: boolean; /** * Whether to include the 'generic' role for elements without explicit roles. * Default: true for AI mode, false otherwise. */ includeGenericRole?: boolean; } /** * Generate an enhanced accessibility tree with AI mode support. */ export declare function generateAriaTree(rootElement: Element, options?: A11yTreeOptions): { root: AriaNode; elements: Map; refs: Map; }; /** * Generate an accessibility tree for the document or a subtree. * Legacy function for backward compatibility. */ export declare function generateA11yTree(root?: Element | Document, options?: A11yTreeOptions): A11yNode[]; /** * Format the accessibility tree as a compact string representation. */ export declare function formatA11yTree(nodes: A11yNode[], compact?: boolean): string; /** * Format AriaNode tree as YAML-like string (for AI consumption). */ export declare function formatAriaTree(root: AriaNode, options?: { indent?: number; }): string; //# sourceMappingURL=tree.d.ts.map