What is the Accessibility tree?
The Accessibility tree is provided by macOS through the Accessibility APIs (Carbon’sAXUIElement). Every running application exposes its UI hierarchy through this system, which was originally designed for assistive technologies like VoiceOver.
Each node in the tree represents a UI element—buttons, text fields, windows, menus, etc. The tree structure mirrors the visual hierarchy: windows contain groups, groups contain buttons, and so on.
The Accessibility tree is built dynamically by querying macOS APIs. agent-native doesn’t modify the tree—it’s a read-only view of the application’s current UI state.
AX roles
Every element has a role that describes what kind of UI component it is:AXWindow- Application windowsAXButton- Clickable buttonsAXTextField- Text input fieldsAXStaticText- Read-only text labelsAXGroup- Container elementsAXMenuBar- Menu barsAXMenuItem- Individual menu itemsAXCheckBox,AXRadioButton,AXSlider, etc.
SnapshotCommand.swift:26-33.
AX attributes
Beyond role, elements have attributes that provide additional information:Not all attributes exist on every element. A button might have
title but no value, while a text field has value but might not have title.AX actions
Elements expose actions that can be performed on them:AXPress- Click a buttonAXConfirm- Activate/confirmAXCancel- Cancel/dismissAXRaise- Bring window to frontAXShowMenu- Show context menu
AXEngine.swift:188-193, agent-native queries available actions:
Tree structure and traversal
The tree is built by recursively walking from the application root element down through children. FromAXEngine.swift:236-275:
How agent-native uses the AX tree
Agent-native accesses the tree through these operations:1
Create application element
Connect to a running app by PID:
2
Read attributes
Query element properties:
3
Find elements
Search the tree by role, title, label, or identifier (see
AXEngine.swift:279-356).4
Perform actions
Execute actions like
AXPress:Permissions required
Accessing the Accessibility tree requires explicit user permission. agent-native checks and requests access:See also
Refs and snapshots
How agent-native assigns refs to tree elements
Workflow
The snapshot → interact → re-snapshot pattern