4.1 KiB
Runtime Output Contract
This document defines the current output contract for deskctl.
It is intentionally scoped to the current Linux X11 runtime surface. It does not promise stability for future Wayland or window-manager-specific features.
Goals
- Keep
deskctlfully non-interactive - Make text output actionable for quick terminal and agent loops
- Make
--jsonsafe for agent consumption without depending on incidental formatting
JSON Envelope
Every runtime command uses the same top-level JSON envelope:
{
"success": true,
"data": {},
"error": null
}
Stable top-level fields:
successdataerror
success is always the authoritative success/failure bit.
When success is false, the CLI exits non-zero in both text mode and --json mode.
Stable Fields
These fields are stable for agent consumption in the current Phase 1 runtime contract.
Window Identity
Whenever a runtime response includes a window payload, these fields are stable:
ref_idwindow_idtitleapp_namexywidthheightfocusedminimized
window_id is the stable public identifier for a live daemon session.
ref_id is a short-lived convenience handle for the current window snapshot/ref map.
Grouped Reads
deskctl get active-window
- stable:
data.window
deskctl get monitors
- stable:
data.count - stable:
data.monitors - stable per monitor:
namexywidthheightwidth_mmheight_mmprimaryautomatic
deskctl get version
- stable:
data.version - stable:
data.backend
deskctl get systeminfo
- stable:
data.backend - stable:
data.display - stable:
data.session_type - stable:
data.session - stable:
data.socket_path - stable:
data.screen - stable:
data.monitor_count - stable:
data.monitors
Waits
deskctl wait window
deskctl wait focus
- stable:
data.wait - stable:
data.selector - stable:
data.elapsed_ms - stable:
data.window
Selector-Driven Action Success
For selector-driven action commands that resolve a window target, these identifiers are stable when present:
data.ref_iddata.window_iddata.titledata.selector
This applies to:
clickdblclickfocusclosemove-windowresize-window
The exact human-readable text rendering of those commands is not part of the JSON contract.
Artifact-Producing Commands
snapshot
screenshot
- stable:
data.screenshot
When the command also returns windows, data.windows uses the stable window payload documented above.
Stable Structured Error Kinds
When a runtime command returns structured JSON failure data, these error kinds are stable:
selector_not_foundselector_ambiguousselector_invalidtimeoutnot_foundwindow_not_focusedasdata.last_observation.kindor equivalent observation payload
Stable structured failure fields include:
data.kinddata.selectorwhen selector-relateddata.modewhen selector-relateddata.candidatesfor ambiguous selector failuresdata.messagefor invalid selector failuresdata.waitdata.timeout_msdata.poll_msdata.last_observation
Best-Effort Fields
These values are useful but environment-dependent and should be treated as best-effort:
- exact monitor naming conventions
- EWMH/window-manager-dependent window ordering details
- cosmetic text formatting in non-JSON mode
- screenshot file names when the caller did not provide an explicit path
- command stderr wording outside the structured
kindclassifications above
Text Mode Expectations
Text mode is intended to stay compact and follow-up-useful.
The exact whitespace/alignment of text output is not stable. The following expectations are stable at the behavioral level:
- important runtime reads print actionable identifiers or geometry
- selector failures print enough detail to recover without
--json - artifact-producing commands print the artifact path
- window listings print both
@wNrefs andwindow_idvalues
If an agent needs strict parsing, it should use --json.