/install agent-desktop-ffi
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:
- ownership.md — who allocates / who frees,
for every
*mut Tthe FFI hands back to the caller. - error-handling.md — errno-style last-error contract, enum validation, panic boundary.
- threading.md — macOS main-thread rule, AXIsProcessTrusted inheritance when Python/Node dlopens the cdylib, and the single-owner handle invariant.
- build-and-link.md — minimum working example for Python ctypes and a C program that links the dylib.
⚠ Core constraints before you integrate
-
Main thread only (macOS). Call every adapter-touching entrypoint (
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 returnsAD_RESULT_ERR_INTERNALwith a diagnostic last-error. On non-macOS platforms the check is a compile-time true; there is no runtime cost. -
Release profile.
cargo build --releaseproducespanic = "abort"— any Rust panic inside anextern "C"fn willSIGABRTthe host. Use--profile release-ffito get the correctpanic = "unwind"profile. CI enforces this. -
Last-error lifetime. Pointers returned by
ad_last_error_*remain valid across any number of subsequent successful FFI calls on the same thread. Only the next failing call rotates them. Cache the pointer once, read it as many times as you need. -
Handle release. Every
ad_resolve_elementresult must be released withad_free_handle(adapter, handle)on the same adapter that produced it. On macOS this balances the internalCFRetain; on Windows/Linux the call is a no-op but safe to issue. -
Enum discriminants. Every
#[repr(i32)]enum field is validated at the C boundary — invalid discriminants returnAD_RESULT_ERR_INVALID_ARGSinstead of undefined behavior. -
ABI is unstable before 1.0. The header lists the exact current shapes. Anything added or reordered in a later patch is a breaking change; pin the version of libagent_desktop_ffi you link against.
-
ad_get_treereturns a raw adapter tree, not the CLI snapshot. Ref IDs are always null, no skeleton/drill-down pipeline is wired through, andinteractive_only/compactfollow adapter semantics which may diverge slightly from the CLI's post-processed shape. Usead_find+ad_get/ad_isfor point lookups, or invoke the CLI if you need CLI-parity JSON snapshots.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install agent-desktop-ffi - 安装完成后,直接呼叫该 Skill 的名称或使用
/agent-desktop-ffi触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Agent Desktop Ffi 是什么?
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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 68 次。
如何安装 Agent Desktop Ffi?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install agent-desktop-ffi」即可一键安装,无需额外配置。
Agent Desktop Ffi 是免费的吗?
是的,Agent Desktop Ffi 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Agent Desktop Ffi 支持哪些平台?
Agent Desktop Ffi 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Agent Desktop Ffi?
由 lahfir(@lahfir)开发并维护,当前版本 v1.0.0。