agent-desktop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseagent-desktop
agent-desktop
agent-desktop is a CLI that lets an AI agent observe and operate desktop apps through the OS accessibility tree. It is a tool, not an agent. Every command prints one JSON envelope (, or ). The observe, act and verify loop runs in you.
okdataerroragent-desktop 是一个 CLI,可让 AI Agent 通过操作系统无障碍树观察并操作桌面应用。它是一个工具,而不是 Agent。每条命令都会打印一个 JSON 信封(、 或 )。观察、操作和验证循环由你执行。
okdataerrorShell syntax
Shell 语法
Examples use a POSIX shell. In PowerShell, quote every ref (), because a bare is the splatting operator. Use instead of , and instead of and . The Windows skill has the PowerShell forms.
'@s8f3k2p9:e1'@token$env:NAME = 'value'export| ConvertFrom-Json$(...)jq示例使用 POSIX shell。在 PowerShell 中,必须为每个引用加引号(),因为裸 会被视为 splatting 运算符。使用 代替 ,并使用 代替 和 。Windows skill 中提供了对应的 PowerShell 写法。
'@s8f3k2p9:e1'@token$env:NAME = 'value'export| ConvertFrom-Json$(...)jqFirst run
首次运行
- Run . It reports the platform, permissions and
agent-desktop status.supported_surfaces - Run . It loads the skill for the OS the binary runs on (macOS, Windows or Linux).
agent-desktop skills get platform - For flags and syntax, run . This skill does not repeat flag lists.
agent-desktop <command> --help
- 运行 。它会报告平台、权限和
agent-desktop status。supported_surfaces - 运行 。它会为二进制文件所在的操作系统(macOS、Windows 或 Linux)加载对应的 skill。
agent-desktop skills get platform - 如需了解参数和语法,请运行 。本 skill 不重复列出参数列表。
agent-desktop <command> --help
The loop
循环
Use when you know the role or exact name. Otherwise map the app first and drill into one region.
findagent-desktop snapshot --skeleton --app "Notes" -i --compact # shallow map, children_count on cut branches
agent-desktop snapshot --root @s8f3k2p9:e3 -i --compact # drill into one region
agent-desktop click @s8f3k2p9:e12 # act on a qualified ref
agent-desktop snapshot --root @s8f3k2p9:e3 -i --compact # verify: re-read the same region- A small app needs no skeleton. Take a full .
snapshot -i - Never skeleton a surface (,
--surface menu,sheet). A surface is already focused.alert - An action that opens a menu, sheet or alert lists it in . Target that overlay next.
data.surfaces - After an async step, use (see
wait). A fixed sleep is a race.commands-system.md
如果你知道元素角色或确切名称,请使用 。否则,先梳理应用结构,再深入查看某个区域。
findagent-desktop snapshot --skeleton --app "Notes" -i --compact # shallow map, children_count on cut branches
agent-desktop snapshot --root @s8f3k2p9:e3 -i --compact # drill into one region
agent-desktop click @s8f3k2p9:e12 # act on a qualified ref
agent-desktop snapshot --root @s8f3k2p9:e3 -i --compact # verify: re-read the same region- 小型应用不需要 skeleton。请执行完整的 。
snapshot -i - 永远不要对 surface(、
--surface menu、sheet)使用 skeleton。surface 已经处于聚焦状态。alert - 如果操作打开了菜单、sheet 或 alert,它会列在 中。下一步应定位该 overlay。
data.surfaces - 异步步骤完成后,使用 (参阅
wait)。固定等待会引入竞态条件。commands-system.md
Refs
引用
- Output refs are qualified: , for example
@<snapshot_id>:e<N>. Pass them to later commands as they are.@s8f3k2p9:e1 - Refs are valid for one snapshot. After any UI change, re-drill the affected region or take a new snapshot.
- Only addressable elements get refs. Static text and inert containers do not.
- : the ref no longer matches the live UI. Take a fresh snapshot and use the new ref.
STALE_REF - : more than one live element matches. Narrow the target with
AMBIGUOUS_TARGETorfind --role --name --exact, then use the new ref.--root - : the snapshot id expired. Snapshot again.
SNAPSHOT_NOT_FOUND
- 输出引用采用限定格式:,例如
@<snapshot_id>:e<N>。请原样将其传递给后续命令。@s8f3k2p9:e1 - 引用仅在一次 snapshot 中有效。UI 发生任何变化后,请重新深入查看受影响的区域或获取新的 snapshot。
- 只有可寻址元素才会获得引用。静态文本和惰性容器不会获得引用。
- :引用不再与实时 UI 匹配。请获取新的 snapshot 并使用新引用。
STALE_REF - :有多个实时元素匹配。请使用
AMBIGUOUS_TARGET或find --role --name --exact缩小目标范围,然后使用新引用。--root - :snapshot ID 已过期。请重新获取 snapshot。
SNAPSHOT_NOT_FOUND
Delivery and retry
交付与重试
Action results carry and errors carry , each with and . Observation commands such as have none on success; their errors, and every refusal, carry and .
data.dispositionerror.dispositiondeliveryretrysnapshotINVALID_ARGSnot_deliveredretry: safe- Retry or substitute an action only when is
disposition.retry. Onlysafeis safe.not_delivered - Any other delivery value means the action may have landed. A repeat can click, type or submit twice, and can undo itself.
toggle - On a result that is not safe, read the live state (,
get, or a fresh snapshot) and decide from that.ishelps when present.details.post_state - Branch on and
error.code. Message and suggestion text can change.error.disposition - means waiting cannot change the outcome. Try a different approach.
details.retryable: false
操作结果包含 ,错误包含 ,二者都有 和 字段。 等观察命令成功时没有这些字段;它们的错误以及每次 拒绝都会包含 和 。
data.dispositionerror.dispositiondeliveryretrysnapshotINVALID_ARGSnot_deliveredretry: safe- 仅当 为
disposition.retry时,才能重试或替换操作。只有safe是安全的。not_delivered - 任何其他 delivery 值都意味着操作可能已经生效。重复执行可能会再次点击、输入或提交,而 甚至可能撤销自身状态。
toggle - 如果结果不是安全的,请读取实时状态(、
get或新的 snapshot),然后据此决定下一步。存在is时,它会提供帮助。details.post_state - 根据 和
error.code进行分支处理。消息和建议文本可能会变化。error.disposition - 表示等待无法改变结果。请尝试其他方法。
details.retryable: false
Headless and headed
Headless 与 Headed
Ref actions are headless by default. They use semantic accessibility calls and do not take focus, move the cursor, synthesize keys or use the clipboard. If no semantic path exists, the action fails closed. Use the global flag only when the user explicitly permits physical input, such as double-click, hover, drag, or focus. Never switch to headed mode to recover from a headless failure. Raw coordinates () never imply focus. Which actions need differs by OS: read the platform skill.
--headed--xy--headed基于引用的操作默认以 headless 模式执行。它们使用语义化无障碍调用,不会获取焦点、移动光标、模拟按键或使用剪贴板。如果不存在可用的语义路径,操作会安全失败。只有当用户明确允许实体输入时,例如双击、悬停、拖拽或聚焦,才使用全局 参数。绝不能为了恢复 headless 操作失败而切换到 headed 模式。原始坐标()不表示会获取焦点。不同操作系统需要 的操作有所不同,请阅读平台 skill。
--headed--xy--headedReferences
参考资料
Load one only when you need it: .
agent-desktop skills get desktop <reference>| Reference | Open it when |
|---|---|
| You need |
| You choose between click, type, set-value, select, toggle, scroll, press and mouse commands, or you debug an action error |
| You launch or close apps, manage windows, use the clipboard, |
| You want worked patterns (forms, menus, dialogs, waiting for a new window, scroll-find, drag) and the anti-patterns list |
仅在需要时加载一项:。
agent-desktop skills get desktop <reference>| 参考资料 | 何时打开 |
|---|---|
| 需要了解 |
| 需要在 click、type、set-value、select、toggle、scroll、press 和鼠标命令之间选择,或需要排查操作错误时 |
| 需要启动或关闭应用、管理窗口、使用剪贴板、执行 |
| 需要查看实战模式(表单、菜单、对话框、等待新窗口、滚动查找、拖拽)及其反模式列表时 |