← Back to Skills Marketplace
lahfir

Agent Desktop Ffi

by lahfir · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
68
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install 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.{dyl...
README (SKILL.md)

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 T the 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 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.

  • Release profile. cargo build --release produces panic = "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.

  • 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_element result must be released with ad_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.

  • Enum discriminants. Every #[repr(i32)] enum field is validated at the C boundary — invalid discriminants return AD_RESULT_ERR_INVALID_ARGS instead 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_tree returns a raw adapter tree, not the CLI snapshot. Ref IDs are always null, no skeleton/drill-down pipeline is wired through, and 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.

Usage Guidance
This skill is an on-disk FFI usage and build guide rather than executable code fetched at install time, and its requirements are reasonable for that purpose. Before integrating: build the cdylib locally with the documented --profile release-ffi to preserve panic/unwind guarantees; pin the library version you link against because the ABI is unstable before 1.0; follow the ownership/free rules exactly to avoid memory errors; and on macOS be aware that granting Accessibility (AXIsProcessTrusted) is granted to the hosting interpreter (python/node/etc.) — granting it to one process that dlopens this library effectively grants it to other code using the same interpreter. If you need higher assurance, inspect the built binary and the committed header in your own repo rather than relying on an external binary.
Capability Analysis
Type: OpenClaw Skill Name: agent-desktop-ffi Version: 1.0.0 The agent-desktop-ffi skill bundle provides a legitimate C-ABI interface for desktop automation, allowing various programming languages to interact with the agent-desktop PlatformAdapter. The documentation (SKILL.md and the references directory) is exceptionally thorough, covering memory ownership, thread-local error handling, and macOS-specific threading constraints. While the skill facilitates high-privilege actions like UI automation and screenshot capture, these are the stated purpose of the tool, and the documentation explicitly warns about security implications such as AXIsProcessTrusted permission inheritance in hosting processes (threading.md).
Capability Assessment
Purpose & Capability
Name/description claim C-ABI bindings and the included docs explain building, linking, ownership, threading, and error handling. There are no unrelated env vars, binaries, or installs requested — everything asked for (cargo build, header, linking) fits the stated purpose.
Instruction Scope
SKILL.md and reference files limit runtime instructions to local build/link steps and safe usage patterns (main-thread rule, allocation/free contracts, last-error semantics). No instructions to read unrelated files, send data externally, or access unrelated credentials. The docs explicitly call out a macOS permission inheritance concern (AXIsProcessTrusted) as a warning.
Install Mechanism
No install spec or external downloads are present; the skill is instruction-only and expects consumers to build the cdylib locally via cargo. This is low risk and proportionate to the task.
Credentials
No environment variables, credentials, or config paths are required. The references explain runtime constraints but do not request secrets or unrelated tokens.
Persistence & Privilege
always is false and the skill does not request persistent system presence or modify other skills' configs. Autonomous invocation defaults are unchanged and no elevated privilege is requested.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install agent-desktop-ffi
  3. After installation, invoke the skill by name or use /agent-desktop-ffi
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of agent-desktop-ffi. - Provides direct C-ABI bindings to agent-desktop's PlatformAdapter for use in Python, Swift, Node, Go, C++, and Ruby. - Distributes a shared library (`libagent_desktop_ffi.{dylib, so, dll}`) and C header for integration. - Enforces core constraints, including main-thread-only execution on macOS and safe enum handling. - Documents error handling, handle ownership, threading, and build/linking procedures. - ABI is marked unstable pre-1.0; breaking changes may occur between minor versions.
Metadata
Slug agent-desktop-ffi
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 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... It is an AI Agent Skill for Claude Code / OpenClaw, with 68 downloads so far.

How do I install Agent Desktop Ffi?

Run "/install agent-desktop-ffi" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Agent Desktop Ffi free?

Yes, Agent Desktop Ffi is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Agent Desktop Ffi support?

Agent Desktop Ffi is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Agent Desktop Ffi?

It is built and maintained by lahfir (@lahfir); the current version is v1.0.0.

💬 Comments