agent-desktop-linux
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseagent-desktop-linux
agent-desktop-linux
The observe-act loop, refs, JSON envelope, sessions and tracing match every
platform. This file covers only what differs on Linux.
Needs Ubuntu 24.04+ (x86_64 or aarch64), a graphical session of the signed-in
user and a running AT-SPI bus. Other distributions need the at-spi2-core bridge
fix dc0dc33; Ubuntu 22.04's bridge aborts on . The archive
loader floor is glibc 2.35. Run the CLI inside the target apps' desktop session:
the session bus, display and runtime directory come from its environment. A TTY
login, an SSH shell without session variables, a container without a bus or
another user's session sees no apps. GNOME is the measured desktop; X11 and
Wayland sessions both work and differ in input, capture and window control.
Observation and semantic actions need no helper tool.
Action.GetActionsobserve-act 循环、refs、JSON envelope、sessions 和 tracing 在所有平台上均一致。本文件仅介绍 Linux 上的差异。
需要 Ubuntu 24.04+(x86_64 或 aarch64)、已登录用户的图形会话,以及正在运行的 AT-SPI 总线。其他发行版需要应用 at-spi2-core bridge 修复 dc0dc33;Ubuntu 22.04 的 bridge 在执行 时会中止。归档加载器的最低要求为 glibc 2.35。应在目标应用的 desktop session 内运行 CLI:session bus、display 和 runtime directory 均来自该环境。TTY 登录、未设置 session 变量的 SSH shell、没有 bus 的 container,或其他用户的 session 都看不到应用。GNOME 是经过实测的 desktop;X11 和 Wayland session 均可使用,但在输入、捕获和窗口控制方面有所不同。观察和语义操作不需要 helper tool。
Action.GetActionsCapability Table
能力表
| Group | Commands | Status on Linux |
|---|---|---|
| Observation | | Works on X11 and Wayland through AT-SPI. Supports |
| Surfaces | | Lists an app's windows, sheets and open menus; shell reads use |
| Ref interaction | | Need a readable live identity and the required AT-SPI capability. See the shell reference for menu-ref resolution limits; X11 headed fallback also needs usable geometry and does not bypass identity checks |
| Wheel scrolling | | Physical wheel input; X11 and |
| Pointer gestures | | |
| Focus | | Needs |
| Keyboard and mouse | | |
| Held input | | Fail closed on every platform: on Linux, |
| App and window | | Launch and listing work on X11 and Wayland; |
| Displays | | Works |
| Capture | | X11: a window without permission; a display only under a non-compositing manager. Wayland: portal consent, with display cropping. No selector returns the primary display. See |
| Clipboard | | Works; text, images and file lists. Wayland needs |
| Wait | | Works for ms, |
| Notifications | | GNOME Shell only; list headless, mutations |
| Shell surfaces | | Only |
| Cursor overlay | | Requires an active session; see Cursor overlay below. X11 enable returns |
| System | | Works |
| 命令组 | 命令 | Linux 上的状态 |
|---|---|---|
| 观察 | | 通过 AT-SPI 在 X11 和 Wayland 上均可工作。支持 |
| Surfaces | | 列出应用的窗口、sheet 和已打开的菜单;shell 读取使用 |
| Ref 操作 | | 需要可读的实时 identity 和所需的 AT-SPI capability。请参阅 shell reference 了解 menu-ref 解析限制;X11 headed fallback 还需要可用 geometry,且不会绕过 identity 检查 |
| 滚轮滚动 | | 物理滚轮输入;仅支持 X11 和 |
| 指针手势 | | 仅支持 |
| 焦点 | | 需要 |
| 键盘和鼠标 | | |
| 按住输入 | | 在所有平台上均 fail closed:在 Linux 上, |
| 应用和窗口 | | Launch 和 listing 在 X11 和 Wayland 上均可工作; |
| Displays | | 可用 |
| 捕获 | | X11:捕获窗口无需权限;仅在非合成 display manager 下捕获整个 display。Wayland:需要 portal consent,并会裁剪 display。未指定 selector 时返回主 display。参见 |
| 剪贴板 | | 可用;支持文本、图片和文件列表。Wayland 需要 |
| 等待 | | 支持毫秒、 |
| 通知 | | 仅支持 GNOME Shell;list 可 headless 运行,mutation 在 X11 上需要 |
| Shell surfaces | | 仅 |
| Cursor overlay | | 需要活动 session;参见下方的 Cursor overlay。X11 enable 返回 |
| 系统 | | 可用 |
First Contact
首次使用
- Run first. An empty
agent-desktop statusmeans the accessibility bus did not answer, not an empty desktop. Readsupported_surfaces; do not restart a bus you did not start.references/bus-and-permissions.md - takes the name
--appprints (list-apps,gnome-calculator) or a desktop-entry name or id backed by verified executable and argument identity, never a window title or an arbitrary registry label. A desktop-entry name such asnautilusis accepted once the entry exists.Filesis exact (aliases included);list-windows --appcombines a substring of the listed name with exact adapter aliases, ignoring case.list-apps --app - Window ids are opaque addresses of 34 to 70 characters, valid for the
life of the window's process; run again after a restart.
list-windowsrows carrylist-apps(desktop id when known) andbundle_id.process_instance - GTK4 apps nest deeply. and
--max-depthcount semantic levels, so empty layout wrappers add output levels.--skeletonstill shows nested nameless-i --compactnodes: read past them.group - An empty file view does not prove an empty folder. If an icon view exposes no file items, try an available list or detailed view, then take a fresh snapshot and verify which items the application exposes.
- A window appears before its content. Run
first, then
wait --window "Text Editor" --app gnome-text-editor, which matches a node's own name, value or description. For a web-engine app (detected from its AT-SPI toolkit metadata), a window observation waits for three equal full reads and a web-document role, or a requested depth cut. A shell with no document yet stays incomplete when the budget ends. Await --textshorter than the first read returns--timeout, never a partial tree.TIMEOUT - Geometry-only refs require unchanged geometry. Position and size must
both match, in the ref's recorded coordinate frame; a one-pixel change breaks
identity. After a layout change or a window move, take a fresh snapshot
instead of retrying the old ref. Indistinguishable siblings stay
: in a Text Editor window with three tabs, the text views share one rectangle and one state, so a ref to any of them answers
AMBIGUOUS_TARGETwithAMBIGUOUS_TARGET3 until the extra tabs close. A ref belongs to the window it was taken in, so two windows with the same title each resolve their own refs.candidate_count - Chromium and Qt apps need a launch flag or variable to appear on the bus;
Electron apps need none, only where
--no-sandboxis not setuid. Seechrome-sandbox.references/troubleshooting.md - Headed ref actions need a window that can take focus. A window the
window manager never activated ends . See
activation_not_granted.references/windows-and-lifecycle.md - A GTK4 secret field can show its text. Only a password role is withheld. Treat a GTK4 entry with hidden characters as readable by every observation command.
- Blocked key combos refuse without . See
--force.references/display-servers-and-input.md - After opening a menu-role popup, inspect . A
data.surfacesentry leads tomenu. If absent, usesnapshot --surface menu --app <name> -iandwait --menubefore assuming the opener failed. A list-backed dropdown is part of the window, not a menu surface; see the shell reference.list-surfaces - Shell pointer input requires receiver proof. On X11 a headed shell click is proven from the shell's own tree: the receiver must be the target and stand still, or the click refuses before any pointer event. Wayland shell clicks refuse. Notifications need the GNOME notification service; tray snapshots also need a StatusNotifierWatcher.
- The state root must be private. A group-writable or world-accessible
or
AGENT_DESKTOP_HOMEmakes~/.agent-desktopfail withsnapshot; runINTERNALon it or let the tool create it.chmod 700
- 首先运行 。
agent-desktop status为空表示无障碍总线没有响应,并不表示 desktop 为空。请阅读supported_surfaces;不要重启并非由你启动的 bus。references/bus-and-permissions.md - 应使用
--app输出的名称(list-apps、gnome-calculator),或者使用以已验证的 executable 和 argument identity 为依据的 desktop-entry name 或 id;绝不要使用窗口标题或任意的 registry label。desktop-entry 名称(如nautilus)在对应 entry 已存在后即可接受。Files是精确匹配(包含 aliases);list-windows --app会将所列名称的子串与精确的 adapter aliases 组合匹配,并忽略大小写。list-apps --app - 窗口 id 是不透明地址,长度为 34 到 70 个字符,仅在窗口进程的生命周期内有效;重启后需要再次运行 。
list-windows的各行包含list-apps(已知时为 desktop id)和bundle_id。process_instance - GTK4 应用会深层嵌套。 和
--max-depth计算语义层级,因此空的 layout wrapper 也会增加输出层级。--skeleton仍会显示嵌套的匿名-i --compact节点:应读取并跳过这些节点。group - 空的文件视图不能证明文件夹为空。 如果 icon view 未公开任何 file item,请尝试可用的 list view 或 detailed view,然后重新 snapshot,并验证 application 公开了哪些 item。
- 窗口会先于其内容出现。 先运行 ,然后运行
wait --window "Text Editor" --app gnome-text-editor;后者会匹配节点自身的 name、value 或 description。对于 web-engine app(根据其 AT-SPI toolkit metadata 检测),window observation 会等待三次相同的完整读取以及一个 web-document role,或达到请求的 depth cut。如果 shell 在预算耗尽前仍没有 document,则会保持 incomplete。wait --text若短于首次读取所需时间,将返回--timeout,绝不会返回部分 tree。TIMEOUT - 仅含 geometry 的 ref 要求 geometry 保持不变。 位置和大小都必须在 ref 记录的 coordinate frame 中匹配;一个像素的变化就会破坏 identity。布局变化或窗口移动后,应重新 snapshot,而不是重试旧 ref。无法区分的 sibling 会保持 :在包含三个标签页的 Text Editor 窗口中,各 text view 共享同一 rectangle 和 state,因此指向其中任意一个的 ref 都会返回
AMBIGUOUS_TARGET和AMBIGUOUS_TARGET3,直到关闭多余标签页。ref 归属于获取它的窗口,因此两个标题相同的窗口会分别解析各自的 ref。candidate_count - Chromium 和 Qt 应用需要 launch flag 或 variable 才能出现在 bus 上; Electron 应用不需要,仅在 未设置为 setuid 时需要
chrome-sandbox。参见--no-sandbox。references/troubleshooting.md - Headed ref 操作需要一个能够接收焦点的窗口。 如果 window manager 从未激活该窗口,操作会以 结束。参见
activation_not_granted。references/windows-and-lifecycle.md - GTK4 secret field 可能会显示其文本。 只有 password role 会被隐藏。应将隐藏字符的 GTK4 entry 视为每个 observation command 均可读取。
- 被阻止的组合键在没有 时会拒绝执行。 参见
--force。references/display-servers-and-input.md - 打开 menu-role popup 后,应检查 。
data.surfacesentry 可用于menu。如果不存在,应先使用snapshot --surface menu --app <name> -i和wait --menu,再假定 opener 失败。基于 list 的 dropdown 是窗口的一部分,而不是 menu surface;参见 shell reference。list-surfaces - Shell pointer 输入需要 receiver proof。 在 X11 上,headed shell click 可从 shell 自身的 tree 中得到证明:receiver 必须是目标且保持静止,否则命令会在发送任何 pointer event 前拒绝执行。Wayland shell click 会直接拒绝。通知需要 GNOME notification service;tray snapshot 还需要 StatusNotifierWatcher。
- State root 必须保持私有。 group-writable 或 world-accessible 的 或
AGENT_DESKTOP_HOME会导致~/.agent-desktop以snapshot失败;应对其执行INTERNAL,或让工具自行创建。chmod 700
Wait for a window
等待窗口
Wait for an app window to appear ( requires a title or title substring):
--windowbash
agent-desktop wait --window "Text Editor" --app gnome-text-editor --timeout 10000To wait for a close that you cause, batch it so the baseline is taken before the
close (Calculator has no unsaved-document prompt to interrupt it):
bash
agent-desktop batch '[{"command":"close-app","args":{"app":"gnome-calculator"}},{"command":"wait","args":{"event":"window-closed","app":"gnome-calculator","timeout":10000}}]' --stop-on-errorTo watch someone else close a window, start
before they close the window. There is no flag.
agent-desktop wait --event window-closed --app gnome-text-editor --timeout 10000--window-closed等待应用窗口出现( 需要完整标题或标题子串):
--windowbash
agent-desktop wait --window "Text Editor" --app gnome-text-editor --timeout 10000要等待由自己触发的关闭操作,应使用 batch,以便在关闭前获取 baseline(Calculator 没有会中断流程的未保存文档提示):
bash
agent-desktop batch '[{"command":"close-app","args":{"app":"gnome-calculator"}},{"command":"wait","args":{"event":"window-closed","app":"gnome-calculator","timeout":10000}}]' --stop-on-error要观察其他人关闭窗口,应在对方关闭窗口前启动 。不存在 flag。
agent-desktop wait --event window-closed --app gnome-text-editor --timeout 10000--window-closedCursor overlay
Cursor overlay
Start a session and pass its returned ID to every overlay command:
bash
session_id=$(agent-desktop session start --name docs-example | jq -r '.data.session_id')
agent-desktop cursor-overlay enable --session "$session_id"
agent-desktop cursor-overlay disable --session "$session_id"
agent-desktop session end "$session_id"Without a session, and return .
On X11, enable returns ; on Wayland it saves the setting
and returns without drawing an overlay.
cursor-overlay enabledisableINVALID_ARGSdata.rendered: truedata.rendered: falsesession start --cursor --multi-agentdata.rendered: false启动 session,并将返回的 ID 传给每条 overlay 命令:
bash
session_id=$(agent-desktop session start --name docs-example | jq -r '.data.session_id')
agent-desktop cursor-overlay enable --session "$session_id"
agent-desktop cursor-overlay disable --session "$session_id"
agent-desktop session end "$session_id"如果没有 session, 和 会返回 。
cursor-overlay enabledisableINVALID_ARGS在 X11 上,enable 返回 ;在 Wayland 上,它会保存设置并返回 ,但不会绘制 overlay。
data.rendered: truedata.rendered: falsesession start --cursor --multi-agentdata.rendered: falseWhat differs on Linux
Linux 上的差异
- Firefox/Gecko can change the selected value without firing
selectorchangeevents, so dependent page handlers do not run. The result staysinputeven when value readback matches. Check the dependent application effect before continuing: value readback alone is no commit proof.delivered_unverified - Two calls on one GTK4 button less than about 250 ms apart act once. Both answer
clickwithok: true. To click one button several times, wait for the effect between the clicks: usedelivered_unverifiedon the element that shows the result, orwait --element <ref> --predicate value --value <expected>.wait 300 - Ref actions are semantic AT-SPI calls that never move the pointer or change
the active window. Under , ref
--headed,clickandright-clicktry physical input first and fall back to the semantic action only after atyperefusal (Windows works the other way round). On Wayland, headed pointer commands and a headednot_deliveredrefuse at once withselect, causeACTION_NOT_SUPPORTED; a headedwayland_sessionneeds the Mutter RemoteDesktop capability.typehas the full rules.references/display-servers-and-input.md - tries the semantic route first and the pointer second; the pointer route needs an explicit
selectrequest on X11. A Qt combo's semantic selection only highlights its popup row, so headless selection refuses with--headed, kindPOLICY_DENIED, before changing that highlight. Headed, on a list whose toolkit index cannot be mapped to the row (a GTK4 list) it clicks the row and checks itspointer_requiredstate; on a combo with no semantic opener (a libadwaita combo row) it clicks the combo open, selects the choice through the popup's own list and checks the value the combo shows. Headless, a list refuses withselected, and a combo with no semantic opener withselection_index_unproven, kindPOLICY_DENIED, unless the combo already shows the choice. A GTK4 drop-down that opens through its own toggle takespointer_requiredwithoutselectand checks the value it shows.--headed - A ref can expose no safe semantic mutation route. Headless requests then
return an unsupported-action error without inventing or
hiddenstate and without switching to physical input. GTK4 entry and passworddisabledactions are one such case: useActivateto edit the field, or requesttypeexplicitly when a pointer click is intended.--headed - Opening a native Wayland Qt combo returns , kind
ACTION_NOT_SUPPORTED, before invoking its action. Qt needs a user input serial to show that popup. An already open combo may be collapsed; Qt windows proven to use Xwayland retain their semantic opener.native_popup_requires_input - Headless writes through
type. A terminal's text node is aEditableTextnamedtextfieldwhose only action isTerminal; headlessRightClickon it istypewith checkPOLICY_DENIED, and its value is null. It receives keys only undersupported_action.--headed - In key combos and
cmdare the Super key. Key names are the macOS and Windows names plus X keysym names.metatakes mapped keys only;presshandles characters the layout cannot produce.type - Window ops act on X11 clients; and headed scoped
focus-windowrequire an X11 session. Headless scopedpressrequires live target focus on either display server. Focusing a window on another workspace can switch the user's current desktop.press - Linux exact FFI refs carrying bounds or a bounds hash require window-relative geometry, even when the ref also carries a name or identifier. Geometry-free identity refs are supported.
- Firefox/Gecko 的 可以在不触发
select或changeevent 的情况下更改所选 value,因此依赖该 value 的 page handler 不会运行。即使 value readback 匹配,结果仍会保持input。继续操作前应检查依赖它的 application effect:仅凭 value readback 无法证明提交成功。delivered_unverified - 对同一个 GTK4 button 执行两次 ,若间隔小于约 250 ms,则只会生效一次。两次调用都会返回
click和ok: true。若要多次点击同一个 button,应在每次点击之间等待效果出现:可在显示结果的 element 上使用delivered_unverified,或者使用wait --element <ref> --predicate value --value <expected>。wait 300 - Ref 操作是语义 AT-SPI 调用,绝不会移动 pointer 或更改 active window。在 下,ref
--headed、click和right-click会先尝试 physical input,仅在收到type拒绝后才回退到 semantic action(Windows 的顺序相反)。在 Wayland 上,headed pointer command 和 headednot_delivered会立即以select拒绝,cause 为ACTION_NOT_SUPPORTED;headedwayland_session则需要 Mutter RemoteDesktop capability。完整规则参见type。references/display-servers-and-input.md - 会先尝试 semantic route,再尝试 pointer route;在 X11 上,pointer route 需要显式指定
select。Qt combo 的 semantic selection 只会高亮 popup row,因此 headless selection 会在改变该高亮之前,以--headed和 kindPOLICY_DENIED拒绝。在 headed 模式下,如果某个 list 的 toolkit index 无法映射到具体 row(例如 GTK4 list),则会点击该 row 并检查其pointer_required状态;对于没有 semantic opener 的 combo(例如 libadwaita combo row),则会点击 combo 将其打开,通过 popup 自身的 list 选择选项,并检查 combo 所显示的 value。在 headless 模式下,list 会以selected拒绝;没有 semantic opener 的 combo 会以selection_index_unproven和 kindPOLICY_DENIED拒绝,除非 combo 已经显示了该选项。通过自身 toggle 打开的 GTK4 drop-down 无需pointer_required即可执行--headed,并会检查其显示的 value。select - 某个 ref 可能没有安全的 semantic mutation route。此时 headless 请求会返回 unsupported-action error,既不会虚构 或
hidden状态,也不会切换为 physical input。GTK4 entry 和 password 的disabledaction 就属于这种情况:应使用Activate编辑字段;如果明确需要 pointer click,则显式请求type。--headed - 打开原生 Wayland Qt combo 时,会在调用 action 前返回 和 kind
ACTION_NOT_SUPPORTED。Qt 需要 user input serial 才能显示 popup。已经打开的 combo 可以折叠;已证明使用 Xwayland 的 Qt window 会保留其 semantic opener。native_popup_requires_input - Headless 通过
type写入。Terminal 的 text node 是一个名为EditableText的Terminal,其唯一 action 是textfield;headlessRightClick会以type拒绝,check 为POLICY_DENIED,且其 value 为 null。只有在supported_action下,它才会接收按键。--headed - 在组合键中,和
cmd表示 Super key。键名采用 macOS 和 Windows 的名称以及 X keysym 名称。meta仅接受已映射的按键;press可处理当前 layout 无法生成的字符。type - Window op 作用于 X11 client;和 headed scoped
focus-window需要 X11。Headless scopedpress要求在任一 display server 上,目标都拥有实时焦点。聚焦另一个 workspace 上的窗口可能会切换用户当前的 desktop。press - 在 Linux 上,携带 bounds 或 bounds hash 的 exact FFI ref 需要相对窗口的 geometry,即使该 ref 同时携带 name 或 identifier。无 geometry 的 identity ref 仍受支持。
References
参考资料
- : bus bootstrap, the three bus states,
references/bus-and-permissions.mdandstatusoutput, state-root rules.permissions - : X11 versus Wayland table,
references/display-servers-and-input.md,press, pointer, wheel, drag, blocked combos, key names.type - :
references/windows-and-lifecycle.md,launch, window ops, focus, workspaces, stopped apps, backgroundclose-app.press - :
references/capture-and-clipboard.mdon X11 and Wayland, the Wayland consent dialog, clipboard owner and helper.screenshot - : menus and GTK4 popovers, GNOME Overview/top bar, shell reads and input, notification identity guards, SNI and AppIndicator requirements and refusals, sandbox guidance.
references/shell-tray-and-notifications.md - : symptom-to-cause map, Chromium, Electron and Qt flags, toolkit limits, error codes with
references/troubleshooting.md.platform_detail
Read any file from the binary:
.
agent-desktop skills get agent-desktop-linux references/troubleshooting.md- :bus bootstrap、三种 bus state、
references/bus-and-permissions.md和status输出、state-root 规则。permissions - :X11 与 Wayland 对照表、
references/display-servers-and-input.md、press、pointer、wheel、drag、被阻止的组合键、键名。type - :
references/windows-and-lifecycle.md、launch、window op、focus、workspace、已停止的应用、backgroundclose-app。press - :X11 和 Wayland 上的
references/capture-and-clipboard.md、Wayland consent dialog、clipboard owner 和 helper。screenshot - :menu 和 GTK4 popover、GNOME Overview/top bar、shell 读取和输入、通知 identity guard、SNI 和 AppIndicator 要求及拒绝规则、sandbox 指南。
references/shell-tray-and-notifications.md - :症状到原因的映射、Chromium、Electron 和 Qt flags、toolkit 限制、带
references/troubleshooting.md的错误代码。platform_detail
可从 binary 中读取任意文件:
。
agent-desktop skills get agent-desktop-linux references/troubleshooting.md