agent-desktop-ffi
Skill2 starsChanged 6 months agoApache-2.0View on GitHub
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.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- betoxf/universal-computer-usetheir own version, first seen Nov 15, 2026
- vercel-labs/agent-desktoptheir own version, first seen Nov 1, 2026
- lahfir/agent-desktoptheir own version, first seen Oct 30, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- lahfir/agent-desktop★ 24ksame name
- vercel-labs/agent-desktop★ 24ksame name
- betoxf/universal-computer-use★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-desktopSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
Main thread only (macOS): Call every adapter-touching entrypoint (ad_get_tree, ad_resolve_element, ad_execute_action, ad_screenshot, …
- Very specific: line 60
Handle release: Every ad_resolve_element result must be released with ad_free_handle(adapter, handle) on the same adapter that produced it.
- Very specific: line 76
Enum discriminants: Every #[repr(i32)] enum field is validated at the C boundary — invalid discriminants return AD_RESULT_ERR_INVALID_ARGS …
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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-ffiThe 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. - Action policy.
ad_execute_actionuses the headless policy by default, matching CLI ref commands: no focus stealing and no cursor movement. Usead_execute_action_with_policy(..., AD_POLICY_KIND_FOCUS_FALLBACK, ...)only when focus-changing behavior is intended, andAD_POLICY_KIND_PHYSICALonly for explicit physical/headed input semantics. - Text input privacy. On macOS, explicit focus/physical policy can use the clipboard briefly for non-ASCII text insertion. Keep the default headless policy or set values directly for sensitive text when the target supports it.
- 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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

