Skip to main content

@svatah/yam-adapter-ax

macOS Accessibility adapter: the Yam agent surface over AXUIElement

Exports

ExportKindSignature
accessibilityGrantedfunctionexport function accessibilityGranted(options: { runner?: GrantRunner; platform?: string } = {}):Whether Accessibility is granted, without showing anything.
automationIdOffunctionexport function automationIdOf(node: AxNode): string | undefinedThe automationId candidate's value (LLD §3.3, §7.5).
AX_ADAPTER_NAMEvariableAX_ADAPTER_NAME = "ax"The name this adapter is selected by in yam.config.yaml (LLD §2.4).
AX_CAPABILITIESvariableAX_CAPABILITIES: Capabilities What this adapter can do (LLD §2.4).
AX_SUBROLE_MAPvariableAX_SUBROLE_MAP: Readonly<Record<string, string>> The subroles that mean something different from their role (LLD §7.5).
AX_SUBROLE_NAMEvariableAX_SUBROLE_NAME: Readonly<Record<string, string>> The accessible name a window-chrome control has by virtue of its subrole
AxAdapterOptionsinterfaceexport interface AxAdapterOptions
AxBridgeinterfaceexport interface AxBridgeWhat the adapter needs from macOS. Everything else is a pure function.
AxBridgeErrorclassexport class AxBridgeError extends Error
AxCheckContextinterfaceexport interface AxCheckContext
AxCommandtypealiasexport type AxCommand An action the bridge performs on one element, addressed by its path.
AxIdentityinterfaceexport interface AxIdentityWho a running application actually is (native-feedback D4).
AxNodeinterfaceexport interface AxNodeOne accessibility element, flattened (LLD §7.5).
AxPermissioninterfaceexport interface AxPermission
AxPermissionStatetypealiasexport type AxPermissionState Why an accessibility call could not be made.
AxSessioninterfaceexport interface AxSessionWhether anything in this login session owns a window (Draft 2.12 §7.5, P9-F7).
AxSnapshotCostinterfaceexport interface AxSnapshotCostWhat one snapshot() cost, which Draft 2.8 §7.5 requires the desktop
AxSnapshotNodeinterfaceexport interface AxSnapshotNode extends SnapshotNodeA snapshot node, plus what only the walk knows.
AxSurfaceclassexport class AxSurface implements AgentSurface
AxWindowinterfaceexport interface AxWindowWhat the bridge was asked to do, and what came back.
childIndexfunctionexport function childIndex(nodes: readonly AxNode[]): Map<number, number[]>The children index controlPathOf needs, for callers that have only nodes.
controlPathOffunctionexport function controlPathOf(Window[Yam]/AXGroup[2]/AXButton[Run] (LLD §3.3, §7.5).
ConvertOptionsinterfaceexport interface ConvertOptions
convertTreefunctionexport function convertTree(nodes: readonly AxNode[], options: ConvertOptions): AxSnapshotNode[]Flatten one window's tree into snapshot nodes.
createAxSurfacefunctionexport function createAxSurface(config:The factory the registry calls (LLD §2.4).
evaluateAxPredicatefunctionexport function evaluateAxPredicate(
GrantRunnerinterfaceexport interface GrantRunnerHow this module reaches the host; replaced in tests.
insideListfunctionexport function insideList(nodes: readonly AxNode[], index: number): booleanWhether this node is inside a list (see roleOf).
insidePopUpfunctionexport function insidePopUp(nodes: readonly AxNode[], index: number): booleanWhether this node is inside a pop-up button's menu (see roleOf).
isTextualfunctionexport function isTextual(node: AxNode): boolean
keyChordfunctionexport function keyChord(key: string): { text: string; code?: number; using: string[] }A key name → what System Events sends.
literalValuefunctionexport function literalValue(ref: ValueRef): stringThe literal a ValueRef names; an unresolved one is a caller mistake (LLD §8.2).
LOGIN_WINDOWvariableLOGIN_WINDOW = "loginwindow"The process that owns the screen when nobody is at it.
machineLoadfunctionexport function machineLoad(): { loadAverage1m: number; cpus: number }What the machine was doing when a read finished (Draft 2.10 §7.5, P8-F2).
matchNodesfunctionexport function matchNodes(Every node the candidate matches, in snapshot order.
nameForfunctionexport function nameFor(who: ResponsibleProgram): stringHow to say "add this program" when the program has a name.
nameOffunctionexport function nameOf(node: AxNode): stringThe accessible name (REQ-SURF-4).
osascriptBridgefunctionexport function osascriptBridge(options: OsascriptBridgeOptions): AxBridgeThe real bridge: osascript, System Events, and this machine.
OsascriptBridgeOptionsinterfaceexport interface OsascriptBridgeOptions
OsascriptLanguagetypealiasexport type OsascriptLanguage = "JavaScript" | "AppleScript";Which osascript dialect a script is written in.
parseWindowfunctionexport function parseWindow(stdout: string):
PERFORM_SCRIPTvariablePERFORM_SCRIPT = function processWithWindow(se, name)`
registerAxAdapterfunctionexport function registerAxAdapter(): voidRegister the adapter. Idempotent, because the registry refuses a silent
requestAccessibilityfunctionexport function requestAccessibility(options: { runner?: GrantRunner; platform?: string } = {}):Ask macOS to show the Accessibility prompt, and answer whether it is granted.
requestScreenRecordingfunctionexport function requestScreenRecording(options: { runner?: GrantRunner; platform?: string } = {}):The same, for Screen Recording. Also once per application, forever.
responsibleProgramfunctionexport function responsibleProgram(The application that owns this process, by walking ps to launchd.
ResponsiblePrograminterfaceexport interface ResponsibleProgramThe application a macOS permission would be attached to.
roleOffunctionexport function roleOf(AXRole → an ARIA role, with the subrole consulted first.
runOsascriptfunctionexport async function runOsascript(Run one JXA script, with a hard deadline.
saidByfunctionexport function saidBy(node:The words an element itself puts on the screen (native-feedback D3).
screenRecordingGrantedfunctionexport function screenRecordingGranted(options: { runner?: GrantRunner; platform?: string } = {}):Is Screen Recording granted?
statesOffunctionexport function statesOf(node: AxNode): NodeState[]The states LLD §2.2 lists, from the attributes macOS exposes.
synthesisefunctionexport function synthesise(The candidate bundle for one element, best first (REQ-REC-3, LLD §3.3).
valueOffunctionexport function valueOf(node: AxNode): string | undefinedThe value a read("value") and a value predicate see.