मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)15k · #10913

agent-desktop-ffi

यह क्या करती है

यह स्किल प्रोग्रामरों को डेस्कटॉप ऑटोमेशन लाइब्रेरी का C इंटरफ़ेस देती है, जिसमें बिल्ड के चरण और ओनरशिप के नियम हैं। यह उन डेवलपर्स के लिए है जो अपने कोड से कंप्यूटर पर ऐप नियंत्रित करना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब आप अपने Python या Go प्रोग्राम से डेस्कटॉप ऑटोमेशन बुलाना चाहते हैं।
  • ✓जब आपको agent-desktop लाइब्रेरी बनानी है और उसे किसी ऐप में जोड़ना है।
  • ✓जब आप हर कार्रवाई के लिए कमांड-लाइन टूल शुरू करने से बचना चाहते हैं।

Skill का लिंक

https://github.com/NanmiCoder/cc-haha/blob/main/native/agent-desktop/skills/agent-desktop-ffi/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/NanmiCoder/cc-haha/blob/main/native/agent-desktop/skills/agent-desktop-ffi/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी Python स्क्रिप्ट से डेस्कटॉप ऑटोमेशन लाइब्रेरी को बुलाकर Finder का स्नैपशॉट लेने का तरीका दिखाइए।”

हर हफ़्ते 5 नई skills, 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
लाइसेंस
—
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

agent-desktop-linux

15k

आपके एजेंट को agent-desktop से Linux डेस्कटॉप ऐप नियंत्रित करना सिखाती है, जिसमें X11 और Wayland पर क्या चलता है और पहली बार की आम समस्याओं के हल शामिल हैं।

AI और एजेंटएजेंट

agent-desktop-macos

15k

आपके एजेंट को Mac ऐप ऑटोमेट करना सिखाती है, जिसमें ज़रूरी अनुमतियाँ देना, मेन्यू और डायलॉग संभालना, और Chromium या Electron ऐप पर काम करना शामिल है।

AI और एजेंटएजेंट

agent-desktop-windows

15k

आपके एजेंट को Windows ऐप ऑटोमेट करना सिखाती है, जिसमें क्या काम करता है, PowerShell में quoting, मिनिमाइज़ की गई विंडो और ऊँचे अधिकार वाले ऐप की सीमाएँ शामिल हैं।

AI और एजेंटएजेंट

agent-desktop

15k

आपके एजेंट को एक्सेसिबिलिटी ट्री पढ़कर, क्लिक और टाइप करके और नतीजे जाँचकर Mac, Windows या Linux के डेस्कटॉप ऐप चलाने देती है।

AI और एजेंटएजेंट

मिलती-जुलती skills