Skip to content

CLI Output

The CLI supports two output modes:

  • default human-readable output
  • --json for structured output designed for scripts and agents

When you pass --json, the CLI prints a single JSON object to stdout.

{
"success": true,
"message": "logged out of agent@example.com",
"data": { "removed": ["agent@example.com"] }
}
  • success — always true
  • message (string, optional) — present when there is no data
  • data (any, nullable) — command-specific payload
{
"success": false,
"error": "imap: ECONNREFUSED",
"code": "CONNECTION",
"data": null
}
  • success — always false
  • error (string) — human-readable description of what went wrong
  • code (string) — machine-readable identifier so agents can branch on error type without regex matching
  • data — always null on failure

In JSON mode, the CLI suppresses any additional console output so parsers do not break.

The code field in error envelopes takes one of these values:

CodeMeaning
AUTHAuthentication failed or not logged in
CONNECTIONCould not reach the server (IMAP or SMTP)
VALIDATIONInvalid input — a flag value or argument is malformed
TIMEOUTOperation did not complete within the allowed time
NOT_FOUNDThe requested resource does not exist (e.g. unknown mailbox, missing message)
POLICYServer refused the operation by policy (e.g. outbound email to an address outside the organization)
UNKNOWNUnclassified error — inspect error for details

Agents should branch on code, not on the error string. The error string is for human display and may change between releases.

When the CLI reports a missing mailbox or message directly, it uses a consistent human-readable pattern: {resource} {identifier} not found. Examples include mailbox agent@example.com not found and message 1234 not found.

The process exit code is derived from the error code:

Exit codeMeaning
0Success
1Error (VALIDATION, TIMEOUT, NOT_FOUND, POLICY, UNKNOWN)
2Authentication error (AUTH)
3Connection error (CONNECTION)

Scripts that only need a pass/fail check can rely on exit codes alone. Scripts that need to distinguish error types should use --json and read the code field.