Skip to main content

Module a11y

Module a11y 

Source
Expand description

Accessibility-tree snapshots with element refs.

This module is pure: it turns the JSON returned by CDP Accessibility.getFullAXTree into a compact, Playwright-style YAML listing that agents can read cheaply, and it hands out stable element refs ([ref=eN]) that the native input path (crate::session::input) resolves back to backendDOMNodeIds. Nothing here talks to a browser, so every rule is unit-tested against canned tree fixtures.

Why the AX tree rather than an injected JS walker: Chromium’s accessibility tree is already composed across shadow roots, carries the computed accessible name/role the same way Playwright reports them, and attaches a backendDOMNodeId per node — exactly the handle DOM.* and Input.* accept. A DOM walker would have to reimplement accessible-name computation and could not cross closed shadow roots.

Re-exports§

pub use refs::RefEntry;
pub use refs::RefTable;

Modules§

refs
Per-tab element reference table.

Structs§

AxNode
One node of the accessibility tree, normalised from an AXNode.
AxTree
The whole tree, indexed by nodeId.
FindOptions
Options for find.
Match
One find hit.
Snapshot
Rendered snapshot.
SnapshotOptions
Rendering options for render_snapshot.

Constants§

DEFAULT_FIND_LIMIT
DEFAULT_MAX_CHARS

Functions§

document_token
Identity of the document the tree was taken from: the root (RootWebArea) node’s backendDOMNodeId, which is the Document node. It changes on every navigation, so it doubles as a staleness token for refs. None when the tree carries no backend ids (mock/partial).
find
Score every candidate node against a free-text query. Pure text matching — no model call. Returns at most opts.limit matches, best first, ties broken by document order.
is_interactive_role
Roles that mean “the agent can act on this”.
parse_full_ax_tree
Parse a Accessibility.getFullAXTree result ({ nodes: [...] }).
render_snapshot
Render the tree as indented YAML-ish lines, interning refs as it goes.