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 पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
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 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
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
agent-desktop-linux
15kआपके एजेंट को agent-desktop से Linux डेस्कटॉप ऐप नियंत्रित करना सिखाती है, जिसमें X11 और Wayland पर क्या चलता है और पहली बार की आम समस्याओं के हल शामिल हैं।
agent-desktop-macos
15kआपके एजेंट को Mac ऐप ऑटोमेट करना सिखाती है, जिसमें ज़रूरी अनुमतियाँ देना, मेन्यू और डायलॉग संभालना, और Chromium या Electron ऐप पर काम करना शामिल है।
agent-desktop-windows
15kआपके एजेंट को Windows ऐप ऑटोमेट करना सिखाती है, जिसमें क्या काम करता है, PowerShell में quoting, मिनिमाइज़ की गई विंडो और ऊँचे अधिकार वाले ऐप की सीमाएँ शामिल हैं।
agent-desktop
15kआपके एजेंट को एक्सेसिबिलिटी ट्री पढ़कर, क्लिक और टाइप करके और नतीजे जाँचकर Mac, Windows या Linux के डेस्कटॉप ऐप चलाने देती है।
मिलती-जुलती skills
api-connector-builder
280kयह आपके एजेंट को मौजूदा pattern के हिसाब से नए API connections बनाने देता है। जब बिना कोई नया तरीका बनाए एक और integration जोड़ना हो, तब इसका इस्तेमाल करें।
api-design
280kयह आपके एजेंट को best practices के हिसाब से REST APIs डिज़ाइन करने में मदद करता है। यह तय करने में काम आता है कि APIs आपस में कैसे बात करें, errors कैसे दिखें, और data को कैसे व्यवस्थित करें।
backend-patterns
280kआपके एजेंट को server-side architecture patterns और database optimization में मदद करता है। server पर चलने वाला code बनाने या review करने के लिए उपयोगी है।