본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)15k · #10913

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/NanmiCoder/cc-haha/blob/main/native/agent-desktop/skills/agent-desktop-ffi/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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 returns AD_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; new ad_* symbols and error codes are additive. Pin the exact libagent_desktop_ffi version 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 like ad_adapter_create(). An invalid ID returns null (read ad_last_error_*).

  • Ref actions. ad_execute_by_ref is the primary action entrypoint. It loads the RefStore, resolves the ref strictly (STALE_REF when the snapshot has no such ref or the element changed, AMBIGUOUS_TARGET on 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; on AD_RESULT_ERR_ACTION_FAILED the check report is JSON in ad_last_error_details(). It auto-waits 5000 ms before the preflight; ad_execute_by_ref_timeout takes timeout_ms (-1 = 5000 ms default, 0 = single-shot). PressKey defaults to focus_fallback; every other action, including TypeText, defaults to headless. Pass AD_POLICY_KIND_FOCUS_FALLBACK (1) to allow focus without cursor movement, or AD_POLICY_KIND_HEADED (2) to allow physical cursor and keyboard delivery. ad_execute_ref_action_exact_with_policy runs the same preflight from an AdExactRefEntry.

  • 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 *_exact symbols. AdRefEntry, AdWindowInfo, and AdSurfaceInfo exist only as fields embedded in the exact structs. ad_list_surfaces_exact keeps the surface id. From AD_EXACT_SURFACE_INFO_VERSION 2, AdExactSurfaceInfo.unclassified names the surface kinds its probe could not read (for example sheet,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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬