Skip to main content

Output Format

All cosh-cli commands output a unified JSON envelope CoshResponse<T>, making it easy for AI Agents to parse.

Success Response

{
"ok": true,
"data": { ... },
"meta": {
"subsystem": "pkg",
"duration_ms": 342,
"distro": "alinux",
"dry_run": false
}
}

Error Response

{
"ok": false,
"error": {
"code": "PkgNotFound",
"message": "package 'nginx-extra' not found",
"recoverable": true,
"hint": "try 'cosh-cli pkg search nginx'",
"subsystem": "pkg"
},
"meta": {
"subsystem": "pkg",
"duration_ms": 120,
"distro": "ubuntu",
"dry_run": false
}
}

Key Fields

FieldTypeDescription
okboolWhether the operation succeeded
dataobjectBusiness data carried on success
error.codestringError code enum (see below)
error.recoverableboolWhether the Agent should retry
error.hintstringSuggested next action
meta.subsystemstringSource subsystem (pkg/svc/checkpoint/audit)
meta.duration_msu64Operation duration (milliseconds)
meta.distrostringDetected distribution
meta.dry_runboolWhether this was a preview

Error Codes

Error CodeSubsystemMeaning
PkgNotFoundpkgPackage does not exist
PkgBackendErrorpkgPackage manager execution failed
UnsupportedDistropkg/svcUnsupported distribution
SvcNotFoundsvcService does not exist
SvcStartFailedsvcService start failed
SvcStopFailedsvcService stop failed
CheckpointDaemonUnavailablecheckpointws-ckpt daemon not running
CheckpointNotFoundcheckpointSnapshot does not exist
AuditDeniedauditPolicy denied
Timeout*Command execution timed out
PermissionDenied*Insufficient permissions

Exit Codes

  • 0 — Operation successful (ok: true)
  • 1 — Operation failed (ok: false)

Agent Integration Pattern

For AI Agents consuming cosh-cli output, the recommended pattern is:

  1. Parse JSON, check the ok field
  2. If ok: false, read error.recoverable to decide whether to retry
  3. If not recoverable, display error.hint to the user or execute the suggested command
  4. When meta.dry_run is true, this is a preview result and the actual operation has not been executed