backdesk

backdesk Operations Reference: Arguments, Receipts and Errors

backdesk has 27 operations. They are the same over the CLI (backdesk call <op> --json '{...}') and over MCP (backdesk mcp serves each non-human operation as a tool). This page was written from the output of backdesk ops; run that command for the current list.

Shapes

Request on backdesk call --hold (one JSON object per line):

{"id":"7","op":"set_text","args":{"sessionId":"<session-id>","leaseId":"<lease-id>","hwnd":<hwnd>,"nodeId":"<node-id>","text":"Ada Lovelace"}}

Success reply:

{"id":"7","ok":true,"result":{ ... }}

Error reply. The same error object is used over MCP:

{"id":"7","ok":false,"error":{"code":"stale_observation","message":"...","retryable":true,"handoffRecommended":false,"details":{}}}

Error codes are listed on the recovery page.

Input operations (click, double_click, scroll, type_text, key, drag, invoke, set_text) return a receipt and an isolation check. This is a real receipt from the fixture workflow, trimmed:

{
  "receipt": {
    "operation": "type_text",
    "route": "posted-message",
    "target": {"hwnd": <hwnd>, "class": "WindowsForms10.Edit.app.0.1c138_r3_ad1", "title": "", "control": "id:<id>"},
    "dispatched": ["WM_CHAR x10 (text length 10)"],
    "activated": true,
    "observed": {"frameChanged": true, "textDiff": "length 0 -> 10", "windowsOpened": [], "windowsClosed": []},
    "unverified": ["app_semantics: whether the app acted on the input beyond frame and window changes"],
    "durationMs": 305,
    "accessibility": null
  },
  "isolation": {
    "ok": true,
    "passed": ["input_desktop_is_not_session (Default)", "target_thread_on_session_desktop", "target_valid_and_in_session_job"],
    "failed": []
  }
}

The receipt says what was dispatched and what changed. unverified lists what backdesk did not check: whether the app did what you meant is yours to verify, for example by reading the file it saved.

Common Arguments

Every operation accepts machineId (string): the expected machine id. A mismatch returns wrong_machine. It is left out of the tables below. backdesk doctor reports the machine id. All operations reject unknown arguments. Input operations take leaseId and, where listed, observationId: the action is rejected if the window changed since that observation.

Operations

doctor

Check whether this machine supports the backend. Sends no host input.

No arguments besides machineId.

session_start

Start an isolated session. Everything not listed in the spec is denied.

ArgumentTypeRequiredDescription
allowedAppsarraynoExecutables app_launch may start: fully qualified paths only (C:\...\app.exe); bare names and relative paths are rejected.
readableFoldersarraynoFolders whose paths wait_for file_exists may check.
writableFoldersarraynoTreated like readableFolders by wait_for file_exists, and nothing else. Not enforced: it does not restrict what launched apps can read or write (they run with the user's file access).
saveCapturesbooleannoPersist observation PNGs under the data dir (default false).
logTextbooleannoShow typed text in receipts and full app_launch paths in the journal (default false: text length and file name only).
idleSecondsintegernoLease idle release (default 15).
ttlSecondsintegernoLease hard ttl (default 300).
observationTtlSecondsintegernoObservation lifetime (default 30).
settleMsintegernoDelay before the after-frame of a receipt (default 150).
accessibilitystring (auto, win32)noControl tree provider: auto (UI Automation when it works, else Win32) or win32.
desktopstring (visible, hidden)noWhere apps run. visible (default): on your desktop, outlined with a green glow, with a green agent pointer; input is posted to the app, never through your cursor or keyboard, and a window you are using is refused. hidden: a separate desktop you never see.

session_list

List sessions on this machine.

No arguments besides machineId.

session_inspect

Session state, lease holder and windows.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

session_stop

Stop a session: release input, kill its processes, close its desktop.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

session_pause

Pause input on a session (held input is released).

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

session_resume

Resume a paused session.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

lease_acquire

Take the session's input lease for this connection.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
agentIdstringnoWho holds the lease.

lease_release

Release the lease (held input is released first).

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringyesLease id.

app_launch

Start an allowlisted executable inside the session. Returns {pid, path, window, windowPid}: window is the first new window of the started process, else of any session process (a launcher may start the real app), and windowPid is its owner.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringyesLease id.
pathstringyesFully qualified executable path (must match an allowedApps entry).
argsarraynoArguments.
cwdstringnoWorking directory.
waitForWindowMsintegernoWait for a first window (default 10000, 0 = no wait).

window_list

List session windows (owned windows, dialogs, menus included); with hwnd and tree=true, the control tree.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
hwndintegernoWindow for the control tree.
treebooleannoReturn the control tree of hwnd.

recover_report

Actions interrupted by a daemon stop (interrupted_ambiguous; never replayed).

No arguments besides machineId.

observe

Capture a session window (window-px) or the whole session desktop (desktop-px) and record an observation.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
hwndintegernoWindow to capture; omit for the session desktop.
cropobjectnoOptional {x, y, width, height} in the window's pixels.
includeImagebooleannoReturn the PNG (default true).
includeTreebooleannoAlso return the window's control tree (needs hwnd).

wait_for

Poll until a condition holds, without a lease. condition.type: window_exists {titleRegex}, window_gone {titleRegex|hwnd}, control_text {nodeId|class, contains} (needs hwnd), file_exists {path in an allowed folder}, frame_changed {observationId}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
conditionobjectyesCondition object.
hwndintegernoWindow for control_text.
timeoutMsintegernoGive up after this long (default 10000).
pollMsintegernoPoll interval (default 200).

click

Click at (x, y) in the observation's coordinate space (posted mouse messages). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegernoTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
xintegeryesX in frame pixels.
yintegeryesY in frame pixels.
buttonstring (left, right, middle)noMouse button (default left).

double_click

Double-click at (x, y) in the observation's coordinate space. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegernoTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
xintegeryesX in frame pixels.
yintegeryesY in frame pixels.
buttonstring (left, right, middle)noMouse button (default left).

scroll

Scroll at (x, y): dy > 0 scrolls up (wheel away), dx > 0 scrolls right. Units are wheel notches. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegernoTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
xintegeryesX in frame pixels.
yintegeryesY in frame pixels.
dxintegernoHorizontal notches.
dyintegernoVertical notches.

type_text

Type text into the focused control of the target window (WM_CHAR per UTF-16 unit). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegeryesTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
textstringyesText to type.

key

Press a key with optional modifiers (ctrl, shift, alt, win) in the target window. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegeryesTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
keystringyesKey name: a-z, 0-9, enter, tab, escape, backspace, delete, up, down, left, right, home, end, pageup, pagedown, space, f1-f12.
modifiersarraynoModifier names.

drag

Drag from (x1, y1) to (x2, y2) with interpolated moves; cancellable between steps; held input is released on any failure. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegernoTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
x1integeryesStart X.
y1integeryesStart Y.
x2integeryesEnd X.
y2integeryesEnd Y.
stepsintegernoNumber of moves (default 10).
stepDelayMsintegernoDelay between moves (default 10).
buttonstring (left, right, middle)noMouse button (default left).

invoke

Invoke a control from the window tree (button click via the control, not coordinates). Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegeryesTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
nodeIdstringyesNode id from window_list with tree=true.

set_text

Replace the text of an edit control from the window tree. Returns {receipt: {operation, route, target, dispatched, activated, observed: {frameChanged, textDiff, windowsOpened, windowsClosed}, unverified, durationMs, accessibility}, isolation}.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
leaseIdstringnoLease id from lease_acquire on this connection.
hwndintegeryesTarget window handle from window_list (when no observationId).
observationIdstringnoObservation the coordinates refer to; the action is rejected if the window changed since.
nodeIdstringyesNode id from window_list with tree=true.
textstringyesNew text.

handoff_request

Ask a human to take over (sign-in, payment, sensitive or confusing steps). The lease is released and input is refused with human_in_control until the human hands back. With waitSeconds the call waits for the answer: handback returns outcome handed_back, a refusal returns permission_denied, no answer in time returns approval_timeout.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
reasonstringyesWhat the human should do, shown in the viewer.
waitSecondsintegernoWait this long for the human's answer (default 0: return at once).

handback

Human: return control to the agent (ends a takeover first). Human-only operation: an agent should not call it.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

handoff_decline

Human: refuse the pending handoff request (the agent gets permission_denied). Human-only operation: an agent should not call it.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

takeover

Human: show the session desktop on this screen with a guard bar (return button, Ctrl+Alt+Backspace, timeout). Agent input is refused with human_in_control until it ends. Human-only operation: an agent should not call it.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.
timeoutSecondsintegernoReturn automatically after this long (default 120).
dryRunbooleannoRun the guard without switching desktops (testing).

takeover_end

Human: end the takeover and return to the previous desktop. Human-only operation: an agent should not call it.

ArgumentTypeRequiredDescription
sessionIdstringyesSession id.

Recovery and error codes, permissions and privacy, examples.