agent-desktop-ffi
하는 일
이 스킬은 프로그래머에게 데스크톱 자동화 라이브러리의 C 인터페이스를 빌드 단계와 소유권 규칙과 함께 제공합니다. 자신의 코드에서 컴퓨터의 앱을 제어하려는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓자신의 Python, Go, Swift 프로그램에서 데스크톱 자동화를 호출하고 싶을 때.
- ✓agent-desktop 라이브러리를 빌드해서 앱에 연결해야 할 때.
- ✓행동마다 명령줄 도구를 시작하지 않으려고 할 때.
스킬 링크
https://github.com/NanmiCoder/cc-haha/blob/main/native/agent-desktop/skills/agent-desktop-ffi/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Finder의 스냅샷을 찍기 위해 Python 스크립트에서 데스크톱 자동화 라이브러리를 호출하는 방법을 보여 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 라이브러리를 공유 라이브러리로 빌드하고, 함수를 고정된 순서로 호출하는 방법을 설명합니다. 초기화, 어댑터 생성, 스냅샷, 참조에 대한 작업 순서입니다. 메모리 소유권과 오류도 다룹니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
agent-desktop-ffi
Direct C-ABI access to PlatformAdapter operations. Build the cdylib with the
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,
agent_desktop_ffi.dll on Windows) plus a committed C header at
crates/ffi/include/agent_desktop.h. The default release profile uses
panic = "abort": a Rust panic inside an extern "C" function would SIGABRT
the host. release-ffi keeps panic = "unwind", which the panic traps need.
Four reference topics, loaded as needed:
- ownership.md: who allocates and who frees every pointer the FFI hands back.
- error-handling.md: errno-style last-error contract, error codes, enum validation, panic boundary.
- threading.md: host-thread contract, mutation ordering across threads and processes, adapter-bound native handles, AXIsProcessTrusted inheritance.
- build-and-link.md: prebuilt archives, ABI handshake, struct size validation, C and Python examples.
Observe-act workflow (canonical path)
ad_init(AD_ABI_VERSION_MAJOR) // verify header ↔ dylib match
adapter = ad_adapter_create_with_session("s1") // or ad_adapter_create()
rc = ad_snapshot(adapter, "Finder", 0, 10, false, false, &json_out)
// parse json_out: locate snapshot-qualified refs in data.tree
ad_free_string(json_out)
// build action:
AdAction act = {0}; act.kind = AD_ACTION_KIND_CLICK;
rc = ad_execute_by_ref(adapter, "@s8f3k2p9:e5", &act, 0, &result_out)
ad_free_string(result_out)
ad_adapter_destroy(adapter)
ad_snapshot returns the CLI envelope {version, ok, command, data}.
data.tree carries snapshot-qualified refs for interactive elements. Read
data.complete before trusting a tree: false means the observation budget ran
out and the tree is partial, not an error. ad_snapshot always targets the
focused window of app; window targeting, skeleton mode and --root drill-down
are not exposed over the ABI. A bare @eN ref returns
AD_RESULT_ERR_INVALID_ARGS.
Core constraints
ABI handshake. Call
ad_init(AD_ABI_VERSION_MAJOR)once after loading the library. A mismatch returnsAD_RESULT_ERR_INVALID_ARGS: abort.ad_abi_version()returns the library's major for display. The major increments on a removed symbol or a layout change; newad_*symbols and error codes are additive. Pin the exactlibagent_desktop_ffiversion you link against.Session adapters.
ad_adapter_create_with_session("session-id")scopes refmap persistence to a session namespace, like CLI--session <id>. IDs are 1 to 64 ASCII alphanumeric,-, or_characters. A null ID behaves likead_adapter_create(). An invalid ID returns null (readad_last_error_*).Ref actions.
ad_execute_by_refis the primary action entrypoint. It loads the RefStore, resolves the ref strictly (STALE_REFwhen the snapshot has no such ref or the element changed,AMBIGUOUS_TARGETon several candidates), runs the live actionability preflight (visible, stable, enabled, supported action, policy, editable), then dispatches. A disabled or unsupported target fails before any platform call; onAD_RESULT_ERR_ACTION_FAILEDthe check report is JSON inad_last_error_details(). It auto-waits 5000 ms before the preflight;ad_execute_by_ref_timeouttakestimeout_ms(-1= 5000 ms default,0= single-shot).PressKeydefaults tofocus_fallback; every other action, includingTypeText, defaults toheadless. PassAD_POLICY_KIND_FOCUS_FALLBACK(1) to allow focus without cursor movement, orAD_POLICY_KIND_HEADED(2) to allow physical cursor and keyboard delivery.ad_execute_ref_action_exact_with_policyruns the same preflight from anAdExactRefEntry.Generation-safe direct APIs. Every direct targeting function takes process-generation evidence:
AdExactRefEntry,AdExactWindowInfo,ad_list_windows_exact,ad_launch_app_exact, and the other*_exactsymbols.AdRefEntry,AdWindowInfo, andAdSurfaceInfoexist only as fields embedded in the exact structs.ad_list_surfaces_exactkeeps the surfaceid. FromAD_EXACT_SURFACE_INFO_VERSION2,AdExactSurfaceInfo.unclassifiednames the surface kinds its probe could not read (for examplesheet,menu), or is null. A missi
자주 묻는 질문
어떤 플랫폼을 지원하나요?
이 가이드는 macOS, Linux, Windows에서 라이브러리를 빌드하는 방법을 다루며, 각 플랫폼은 서로 다른 라이브러리 파일 형식을 만듭니다.
특별한 빌드 프로필이 왜 필요한가요?
표준 릴리스 프로필은 충돌이 나면 호스트 프로그램 전체가 멈추므로, 별도 프로필을 써서 오류를 잡을 수 있게 합니다.
어떤 단계를 가장 먼저 해야 하나요?
어댑터를 만들기 전에 헤더와 라이브러리 버전이 일치하는지 확인하세요.
상세 정보
작성자의 원본 설명
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. The canonical observe-act workflow is: ad_init → ad_adapter_create[_with_session] → ad_snapshot → read qualified refs (@s8f3k2p9:e5) → ad_execute_by_ref → ad_free_string → ad_adapter_destroy.
repo: NanmiCoder/cc-haha
인기도
- GitHub 스타
- 15k
- 순위
- #10913
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
agent-desktop-linux
15kagent-desktop으로 Linux 데스크톱 앱을 제어하는 방법을 에이전트에게 알려 줍니다. X11과 Wayland에서 무엇이 작동하는지, 처음 실행할 때의 흔한 해결법을 포함합니다.
agent-desktop-macos
15k에이전트가 Mac 앱을 자동화하는 방법을 보여 줍니다. 필요한 권한 허용, 메뉴와 대화상자, Chromium이나 Electron 앱 다루기를 포함합니다.
agent-desktop-windows
15k에이전트가 Windows 앱을 자동화하는 방법을 보여 줍니다. 작동하는 것, PowerShell 따옴표, 최소화된 창, 권한이 높은 앱의 한계를 다룹니다.
agent-desktop
15k접근성 트리를 읽고, 클릭하고, 입력하고, 결과를 확인해 Mac, Windows, Linux의 데스크톱 앱을 에이전트가 보고 조작하도록 합니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.