Computer use CLI for AI agents
Capture and Clipboard on Linux
X11 needs no permission and no outside tool. Wayland asks a person once for
screenshot and needs wl-clipboard. agent-desktop permissions shows the
case: screen_recording is not_required on X11 and unknown on Wayland.
screenshot has no timeout flag.
screenshot on X11
agent-desktop screenshot --app gnome-calculator /tmp/calc.png
agent-desktop screenshot --screen 0 /tmp/screen0.png
agent-desktop screenshot /tmp/everything.png
- No permission and no prompt. Targets: a window (
--app,--window-id), a display bylist-displaysindex (--screen), or with no selector the primary display (the first if none is marked primary). With no output path the image returns as base64 indata. - A window is read from its own drawable. Under a compositing window manager (mutter), covered and minimized windows are captured.
- Under a non-compositing window manager (openbox) that read is not possible. A
covered window answers
ACTION_FAILEDwithdetails.reason: "covered"and the suggestion to raise it with--headed focus-window; the same capture after the focus returns the window. A minimized window answersINVALID_ARGS("The window is not viewable and the window manager does not composite, so it has no pixels to capture") with the suggestion torestoreit. Both arenot_deliveredandretry: safe. On a non-compositing manager, whole-screen and--screencaptures are exact. - Under a compositor such as GNOME on X11 the root window holds only the
manager's own stage, so whole-screen and
--screencaptures answerPLATFORM_NOT_SUPPORTEDwithdetails.reason: "compositing"and the suggestion to capture one window with--window-id. The area no X window owns (wallpaper, shell chrome) cannot be read under a compositor. - Two windows of one process with the same title:
--window-idcaptures the one the toolkit reports active, and its twin when exactly two windows share the title. Any other tie answersAMBIGUOUS_TARGET("More than one X11 window matches this window") withcandidatesand the suggestion to give the windows distinct titles. - The tool hides its own cursor overlays during capture and restores them; they neither block the screenshot nor appear in its pixels.
- A display-server or caller-deadline timeout stays
TIMEOUT, including when capturing a covered window. It does not prove coverage or advise focus. - Resource, connection and visibility failures keep their own errors. Only a
window whose paint cannot be proven gets the
coveredadvice.
screenshot on Wayland
Wayland has no window position and no per-window capture. The portal's
Screenshot captures the desktop; the CLI returns the primary display by
default, cropping the image on a multi-monitor desktop. --screen N selects
another monitor.
agent-desktop screenshot /tmp/desktop.png
- The first call shows a consent dialog ("Allow Applications to Take Screenshots?", Deny focused) that is not on the accessibility bus. A person must answer it. The CLI waits for the portal's answer, bounded by the longer of the command's own budget and 30 s.
- Allow returns the selected display as a PNG. Deny, or a dismissed dialog,
gives
PERM_DENIED. - Nobody answers: the portal gives up after about 25 s and the call returns
TIMEOUT, with the dialog named in its suggestion. The dialog stays open, and later calls returnPERM_DENIEDat once, with no second dialog, until a person dismisses it. Do not retry in a loop: ask the user to answer it. - The desktop remembers the answer per user for the host process. After Allow,
later calls return in about 50 ms with no dialog. After Deny, every call is
PERM_DENIEDuntil the user resets it in the desktop's privacy settings. --screen Nand a display target crop the whole-desktop image to that monitor. Cropping requires dimensions that confirm the monitor layout; otherwise the call answersPLATFORM_NOT_SUPPORTEDwith reasondisplay_mapping.- A known display layout is rechecked after consent, including when it had only
one monitor. A changed layout returns
ACTION_FAILEDwithout pixels. - A window target (
--app,--window-id) isPLATFORM_NOT_SUPPORTEDon Wayland, permanently. Capture a display, or read the window withsnapshot. - The portal writes the PNG under the user's home. The CLI accepts the file only inside the temp, runtime or home directory, checks it is a regular file of the user made for this request, reads it and removes it.
Clipboard
agent-desktop clipboard-set "hello from agent-desktop"
agent-desktop clipboard-get
agent-desktop clipboard-clear
Formats and output follow the core commands-system reference. Text, images and
file lists all work on Linux.
X11
clipboard-sethands the selection to a detached owner process, the helperagent-desktop-linux-clipboard-owner, which serves the content until another client takes the selection orclipboard-clearends it. The CLI exits first; the content stays available while the owner lives.- The helper must sit beside the
agent-desktopbinary and be a regular executable file, not a symlink, owned by the user or root. Neither it nor its directory may be group-writable, even when the group appears private; the file must not be world-writable. Remove group-write permission from both the helper and its directory before using a build made with a group-writable umask. A world-writable directory is accepted only with the sticky bit and without group-write permission. A 777 copy is refused withPLATFORM_NOT_SUPPORTED, "writable by others". npm installs and release archives ship it in place. A binary copied alone cannot set the clipboard:PLATFORM_NOT_SUPPORTEDnames the missing helper. Both refusals arenot_delivered,safe. - Without a clipboard manager the content ends with the owner. GNOME's shell keeps only text and PNG after the owner dies, caps text at 4 MiB, and does not take over a file copy or a custom target: do not rely on content outliving the owner.
- A file copy serves
x-special/gnome-copied-filesandtext/uri-list. A plain-text path pastes nothing in a file manager. - Content above the X server's single-request limit transfers with
INCR, so large content works. - "Nothing there" and "target not available" are different answers: an absent
format is
absent, not an error.
Wayland
- The clipboard goes through
wl-clipboard(wl-copy,wl-paste): install the package. Text, images and file lists round-trip against foreign readers and writers under GNOME.clipboard-clearrunswl-copy --clear. - Routing follows the display-server detector: an empty
WAYLAND_DISPLAYcounts as unset, and a stale socket falls through to a reachableDISPLAY. Once Wayland is selected, clipboard failures never fall back to X11. A missingwl-copyorwl-pastereturnsPLATFORM_NOT_SUPPORTEDwith awl-clipboardinstall hint, even whenDISPLAYis set. - After Wayland is selected, a failed connection ("Failed to connect to a Wayland server"), a seat with no keyboard ("This seat has no keyboard") and a timeout from a shell that has stopped serving clients are distinct errors, never an empty clipboard.
Clipboard through FFI
The C library reaches the same code; its clipboard API is text-only. Set and
clear take the cross-process interaction lease; reads have a deadline but do not
take that mutation lease. The matching owner helper can sit beside
libagent_desktop_ffi.so; it need not sit beside the host's executable. The
library has no stable SONAME.