$ show openclaw/AXorcist
AXorcist is a Swift library and CLI tool for macOS accessibility automation, wrapping the Accessibility (AX) APIs to inspect, query, and control UI elements programmatically. The core library provides a typed `Element` struct over `AXUIElement`, a command-response protocol with JSON envelopes, a powerful observer system with retry/backoff and process-generation tracking, input simulation (mouse, keyboard), and tree traversal with search criteria. The CLI (`axorc`) exposes commands like `find`, `tree`, `raw`, `permissions`, and `observe`, all producing structured JSON output. The architecture is modular with heavy use of Swift extensions, `@MainActor` isolation, and async/await concurrency. The codebase is well-structured, extensively tested (unit and integration tests), and follows modern Swift practices with pinned dependencies (Commander, swift-log) and strict concurrency checking. It is actively maintained with CI workflows for building, linting, and security scanning.
The LLM identified 3 files worth highlighting for reuse:
A type-safe enum representing all possible Accessibility attribute values (string, bool, int, double, array, dictionary, null). It conforms to Codable, Equatable, and provides convenience accessors for each variant. This is a self-contained, reusable pattern for bridging CoreFoundation types to Swift in a safe, expressive way, and can be extracted into any project needing structured CF value handling.
Provides `withTimeout` and related helpers for running async operations with a configurable timeout, supporting cancellation and nested scope detection. The implementation uses `Task.sleep` and continuation-based gates, avoiding `DispatchSemaphore` blocking. This is a clean, reusable pattern for adding timeout guards to any async workflow, especially useful for protecting against hanging system calls (like AX APIs).
A utility that converts opaque `AXValue` objects (e.g., CGPoint, CGRect, CFRange) into native Swift types (structs, tuples, numbers) using reflection and type-checking. It handles nil, pointers, and numeric bridging with depth limits. This module is self-contained and solves a recurring data engineering problem: safely extracting typed values from C opaque types in Swift, reusable in any project interfacing with CoreGraphics or CoreFoundation.