C+
Packages · View as Markdown

agent_appkit

The macOS GUI backend for the agent surface: it binds the framework-agnostic agent_core rules to a live AppKit window.

  • open(window) walks the live NSView tree into a Surface — the controllable model an agent sees.
  • describe_ui returns a snapshot of the exposed nodes (Vec[UiNode]). A node is exposed by giving it an agent id with set_agent_id.
  • Authorized actionsclick, set_text, and scroll_to run through the agent_core authorization brain. Text edits use optimistic-concurrency versioning, so a stale edit is rejected.
  • Events — AppKit notifications are translated into verbs and delivered as the bubbling events agent_core defines.
  • Main-thread safeclick / set_text / scroll_to marshal onto the main thread when called off it, so an MCP bridge driven on a background connection can never message AppKit off-main. It is closure-free (a [NSThread isMainThread] fast path over performSelectorOnMainThread:), and on_main_thread() is public if you need the same check.
  • Layout diagnosticsSurface::layout_diagnostics reports per-node Auto Layout health (uses_autolayout, has_ambiguous_layout), so an agent can catch a broken generated layout without taking a screenshot.

Pair it with agent_mcp to expose the surface to an external agent. AppKit agent surface documents the checked docs/examples/recipes/appkit_agent recipe from the C+ source tree: describe the tagged UI, act on a real AppKit button, reject stale text edits, and refuse requests through a closed consent gate.