key-cli owns the machine-facing JSON emitted by the key command. This document
describes the stable external contract consumed by Clavis. A breaking response change
requires updates here and a corresponding public-contract test; Python module layout and
function names are not part of the protocol.
JSON output is requested with --json or --format json where the command supports the
latter. Responses contain these common fields:
schemaVersion: integer, currently1;command: the public operation name, such asrecord.statusorclipboard.list;ok: boolean matching whether the command succeeded;error:nullon success, otherwise an object with at leastcodeandmessage;exitCodemay be present when a delegated process has its own result code.
Consumers must reject an unknown schemaVersion instead of guessing field meanings. Error
objects may include a details mapping with command-specific information.
The stable command names currently exposed by JSON responses are:
versionanddoctorfor metadata and dependency diagnostics;shell.start,shell.kill,shell.logandshell.ipcfor Quickshell lifecycle actions;ipc.showandipc.callfor public Quickshell IPC forwarding;record.start,record.status,record.pause,record.resumeandrecord.stop;audio.start,audio.statusandaudio.stop;clipboard.status,clipboard.list,clipboard.inspect,clipboard.restore,clipboard.delete,clipboard.clear,clipboard.watchandclipboard.store.
Recording and audio responses include a versioned state object. Stable state fields include
state, sessionId, pid, processStartTicks, processStartedAtMs, startedAtMs,
completedAtMs, updatedAtMs, temporaryPath, outputPath and error when applicable.
The recording command additionally reports type, target, fps and audio; audio
reports the selected source and final duration when available. Paths are external paths,
not implementation-specific temporary object names.
Clipboard responses report the selected operation, dependency/capability information,
watcher state and, for entries, the stable id, MIME/payload classification and decoded
metadata. Binary payload data is not embedded in the normal JSON response.
The process exit code is part of the contract:
0: success;1: general backend failure;2: usage or argument error;3: required dependency unavailable;4: another recording/session operation is active;5: invalid or unavailable saved state;6: recorder failed to start;7: recorder failed to stop safely;8: recording/audio post-processing failed.
The JSON ok value and the exit code must agree. Dependency and state errors still return
the standard envelope so callers can report a useful error without parsing human text.