π¦ ClawHub
Agent Desktop Ffi
by @lahfir
C-ABI bindings over agent-desktop's PlatformAdapter. Consumers (Python ctypes, Swift, Node ffi-napi, Go cgo, C++, Ruby fiddle) link libagent_desktop_ffi.{dyl...
TERMINAL
clawhub install agent-desktop-ffiπ About This Skill
name: agent-desktop-ffi version: 0.1.11 tags: ffi, c-bindings, cdylib, python, swift, node, go, rust-ffi requirements: - agent-desktop-ffi description: > C-ABI bindings over agent-desktop's PlatformAdapter. Consumers (Python ctypes, Swift, Node ffi-napi, Go cgo, C++, Ruby fiddle) link libagent_desktop_ffi.{dylib,so,dll} and call
ad_* functions
directly instead of spawning the CLI binary per call.
agent-desktop-ffi
Direct C-ABI access to every PlatformAdapter operation. Build the
cdylib with the workspace's release-ffi profile:
cargo build --profile release-ffi -p agent-desktop-ffi
The output is target/release-ffi/libagent_desktop_ffi.dylib
(.so on Linux, .dll on Windows) plus a committed C header at
crates/ffi/include/agent_desktop.h.
Four reference topics, loaded as needed:
*mut T the FFI hands back to the caller.
β Core constraints before you integrate
ad_get_tree, ad_resolve_element, ad_execute_action,
ad_screenshot, clipboard, launch/close, window ops, observation,
notifications, etc.) from the process's main thread. The FFI enforces
this at runtime in every build profile β a worker-thread call
returns AD_RESULT_ERR_INTERNAL with a diagnostic last-error. On
non-macOS platforms the check is a compile-time true; there is no
runtime cost.cargo build --release producespanic = "abort" β any Rust panic inside an extern "C" fn will
SIGABRT the host. Use --profile release-ffi to get the correct
panic = "unwind" profile. CI enforces this.ad_last_error_*ad_resolve_element result must bead_free_handle(adapter, handle) on the same adapter
that produced it. On macOS this balances the internal CFRetain;
on Windows/Linux the call is a no-op but safe to issue.#[repr(i32)] enum field is validatedAD_RESULT_ERR_INVALID_ARGS instead of undefined behavior.ad_get_tree returns a raw adapter tree, not the CLI snapshot.interactive_only / compact follow adapter
semantics which may diverge slightly from the CLI's post-processed
shape. Use ad_find + ad_get / ad_is for point lookups, or
invoke the CLI if you need CLI-parity JSON snapshots.