Skip to content

JSON output

How abx reports results and failures for scripts, the error envelope, the JSON shape of each command, and the metadata of the JSON command reference.

Updated

Scripts and coding agents can read abx results as JSON. This page covers the conventions, the error envelope, the shape of each command’s output and the versioned reference printed by abx help --json. For driving abx from a script, see headless automation and driving abx from another coding agent.

Conventions

  • Results go to stdout. Diagnostics, progress and errors go to stderr. Errors start with abx: when stderr is not a terminal.
  • JSON on stdout is pretty-printed.
  • A command accepts --json when it lists the option in the CLI reference. Most of them also have a documented shape, below. auth and help list --json but have no result shape of their own: abx auth --json is abx auth status --json, and abx help --json prints the command reference.
  • A field marked (optional) in a shape is present only when it applies.
  • New fields appear only in JSON. The plain-text table of ls, for example, keeps fixed columns.
  • Without a terminal and without --json, ls, net and workspace ls print tab-separated or single-line text. Use --json when you need structure.

Error envelope

A failure exits non-zero with empty stdout. When JSON was requested, the last line of stderr is a single-line JSON object:

{
  "error": {
    "code": "no-box",
    "message": "No managed box has that name in this scratch directory.",
    "hint": null,
    "retryable": false
  }
}

JSON is requested by --json among the arguments before --, or by ABX_JSON=1. This holds for usage errors too, so abx bogus --json also gets an envelope. Earlier stderr lines (notices, progress) can precede the envelope, so read the last line.

Field Meaning
code One of the error codes. It is stable: match on it, not on the message.
message What went wrong. It may name this box or this command and is not stable.
hint The command or step that resolves the failure, or null when none is known. It is not stable either.
retryable true when running the same command again may succeed. Only lock-busy is retryable.

Message and hint are escaped so that guest-derived text cannot carry terminal control characters.

Without --json and without ABX_JSON, a failure is an error block on a terminal, or one abx: <message> <hint> line when stderr is redirected. The process exit status is described in exit codes.

Partial failures

Commands that act on several boxes (stop --all, and rm with several names) do not stop at the first failure. The result document is still printed on stdout, each failed box appears in failed[], abx exits 1, and it prints no error envelope. Each failed entry has this form:

{
  "name": "fix-auth",
  "error": { "code": "box-busy", "message": "…", "hint": null, "retryable": false }
}

Output shapes

Each block shows the field names and, as strings, the type or the allowed values of each field. string | null means a string or null. Arrays show one element as a template.

ls

Every box in scope. workspace is the folder the workspace registry records, and null when neither the registry nor the box records one. kind is null for a machine whose workspace is not registered. state, network and machine are null unless status is ready. connectors lists the agents whose account connectors the box turned on, empty unless status is ready. message explains an error or missing-state row. sessions is present only with –sessions: the sessions the box recorded, or null unless the box is ready and running. running is whether the session is live in the guest, or null when the guest could not be asked. conversationState is updated on the next launch of the session.

{
  "boxes": [
    {
      "name": "string",
      "workspace": "string | null",
      "workspaceId": "string",
      "kind": "git | scratch | null",
      "status": "ready | incomplete | error | missing-state",
      "state": "string | null",
      "network": {
        "mode": "off | restricted",
        "hosts": ["string"]
      },
      "machine": "string | null",
      "access": ["string"],
      "connectors": ["string"],
      "message": "string | null",
      "sessions": [
        {
          "name": "string",
          "program": "string",
          "conversation": "string",
          "conversationState": "pending | confirmed",
          "running": "boolean | null"
        }
      ]
    }
  ]
}

net

The verified network policy of one box.

{
  "box": "string",
  "mode": "off | restricted",
  "hosts": ["string"]
}

stop

One result per box: stopped, already-stopped, force-stopped (a running box whose policy could not be verified, with –force), or absent (with –if-exists; id is null). With –all and a failure, the document is still printed and abx exits 1 without an error envelope; each failed entry carries its own error.

{
  "results": [
    {
      "name": "string",
      "id": "string | null",
      "result": "stopped | already-stopped | force-stopped | absent"
    }
  ],
  "failed": [
    {
      "name": "string",
      "error": {
        "code": "string",
        "message": "string",
        "hint": "string | null",
        "retryable": "boolean"
      }
    }
  ]
}

rm

The boxes deleted, the boxes that did not exist (only with –if-exists), and the boxes that failed. transcripts is the archived transcript directory. With several boxes and a failure, the document is still printed and abx exits 1 without an error envelope; each failed entry carries its own error.

{
  "removed": [
    {
      "name": "string",
      "id": "string",
      "archive": "string",
      "transcripts": "string",
      "machine": "deleted | missing"
    }
  ],
  "absent": ["string"],
  "failed": [
    {
      "name": "string",
      "error": {
        "code": "string",
        "message": "string",
        "hint": "string | null",
        "retryable": "boolean"
      }
    }
  ]
}

workspace

The workspace of the current folder. id is null when the folder has no marker yet, and registered is false until a box is created. recordedPath is the folder the registry records, which differs from folder in a copy. directory is the state directory below $ABX_HOME/workspaces, or null.

{
  "id": "string | null",
  "kind": "git | scratch",
  "name": "string",
  "folder": "string",
  "registered": "boolean",
  "recordedPath": "string | null",
  "directory": "string | null",
  "boxes": {
    "live": "number",
    "archived": "number"
  }
}

workspace ls

Every directory below $ABX_HOME/workspaces. status is ok when the folder at path carries the workspace marker, missing-folder when the folder is gone, id-differs when its marker is missing, invalid or names another workspace, and damaged when the workspace.json is unreadable; a damaged row has null fields besides directory and message.

{
  "workspaces": [
    {
      "id": "string | null",
      "name": "string | null",
      "kind": "git | scratch | null",
      "path": "string | null",
      "directory": "string",
      "lastUsed": "string | null",
      "status": "ok | missing-folder | id-differs | damaged",
      "boxes": {
        "live": "number",
        "archived": "number"
      },
      "message": "string | null"
    }
  ]
}

The workspace this folder now belongs to: its id, the folder, and its live and archived box counts.

{
  "id": "string",
  "path": "string",
  "boxes": {
    "live": "number",
    "archived": "number"
  }
}

diff

Only with –stat. commits counts the guest commits under review and files the lines added and removed per file (null for a binary file). reviewRecorded is true: the review is recorded for abx land once the document is written, and abx exits non-zero if recording fails.

{
  "box": "string",
  "mode": "fast-forward | merge | squash",
  "commits": "number",
  "files": [
    {
      "path": "string",
      "added": "number | null",
      "removed": "number | null"
    }
  ],
  "reviewRecorded": "boolean"
}

land

result is already-landed when the guest tip and checkout still match the result applied in the requested mode. head is the checkout HEAD afterwards, landed the guest commit recorded as landed, and staged is true when this invocation stages a squash.

{
  "box": "string",
  "mode": "fast-forward | merge | squash",
  "result": "landed | already-landed",
  "head": "string",
  "landed": "string",
  "staged": "boolean"
}

status

home.layout is null for a missing or empty home. backend is the smolvm check; error is present only when it is not supported. image is null when its metadata is damaged; agents lists the agents it contains. Each agent entry has auth from abx auth status --json, and ready means it is in the image and has a saved sign-in. workspace is abx workspace --json, or null when this folder cannot hold boxes. next lists setup steps (empty argv for manual installation); needsTerminal marks those that prompt or attach a terminal.

{
  "host": {
    "os": "darwin | linux | other",
    "arch": "arm64 | x64 | other",
    "guestArch": "arm64 | amd64 | other",
    "support": "supported | refuse",
    "warning": "string | null"
  },
  "requirements": [
    {
      "name": "string",
      "ok": "boolean",
      "required": "boolean",
      "unsafe": "true (optional)",
      "detail": "string",
      "hint": "string | null"
    }
  ],
  "home": {
    "path": "string",
    "layout": "number | null",
    "exists": "boolean"
  },
  "backend": {
    "binary": "string | null",
    "version": "string | null",
    "supported": "boolean",
    "error": "string (optional)"
  },
  "image": {
    "present": "boolean",
    "template": "string | null",
    "agents": ["string"],
    "digest": "string | null",
    "guestArch": "arm64 | amd64 | null",
    "metadataVersion": "2 | null",
    "artifactDigest": "string | null"
  },
  "agents": [
    {
      "name": "string",
      "inImage": "boolean",
      "ready": "boolean",
      "auth": "object | null"
    }
  ],
  "workspace": "object | null",
  "next": [
    {
      "argv": ["string"],
      "needsTerminal": "boolean",
      "reason": "string"
    }
  ]
}

Notes on status:

  • host.support is supported on Apple Silicon and for unprivileged users on arm64 or x86_64 Linux. refuse (Linux root, an unknown effective UID, another Linux architecture, or any other host such as an Intel Mac) allows only help, --version/-V, --agent-mode and status; other commands fail with host-unsupported, which exits 125 on Linux and 1 elsewhere (125 for a one-shot launch).
  • requirements has one row per applicable tool or device. Rows with required: false are advisory, and unsafe: true marks a failed trust check. Missing requirements carry a hint.
  • next lists setup steps in order. For a manual fix, argv is empty and reason gives the instructions. argv has no placeholders.
  • A fresh home with no installed image has image.present set to false, image.agents set to [] and the other image fields null.

image

The installed image, as image in abx status --json. Without one, present is false. Read from the image metadata; the pack itself is verified when a box is created.

{
  "present": "boolean",
  "template": "string | null",
  "agents": ["string"],
  "digest": "string | null",
  "guestArch": "arm64 | amd64 | null",
  "metadataVersion": "2 | null",
  "artifactDigest": "string | null"
}

image build

The image new boxes now use. reused is true when an intact image with the same agents already existed and nothing was built.

{
  "template": "string",
  "digest": "string",
  "agents": ["string"],
  "guestArch": "arm64 | amd64",
  "metadataVersion": "2",
  "artifactDigest": "string | null",
  "reused": "boolean"
}

auth status

Authentication support per agent and for GitHub. configured is the saved selection or null. Each mode appears once per access route; unsupported modes have access null. connectors is the account-connector setting, null for agents without connectors. agents is empty for the github subject, and github is null for an agent subject. With –box the result contains box, machine, worker, action and credentials (agent, state, checkedAt and expiresAt in Unix milliseconds).

{
  "agents": [
    {
      "name": "string",
      "configured": {
        "provider": "string",
        "mode": "string",
        "access": "masked | global | local",
        "profile": "string | null"
      },
      "modes": [
        {
          "provider": "string",
          "mode": "string",
          "kind": "credential | host-login | native-login | unsupported",
          "access": "masked | global | local | null",
          "status": "verified | unverified | experimental | unsupported",
          "configured": "boolean",
          "description": "string"
        }
      ],
      "connectors": "on | off | null"
    }
  ],
  "github": {
    "status": "unverified",
    "credentialBinding": "boolean",
    "mappings": "number"
  }
}

auth status with –box

With --box NAME, the result contains box, machine, worker, action and credentials. Each credential carries agent, state, checkedAt and expiresAt, where the times are in Unix milliseconds. Run abx auth status --box NAME --json to see the exact document.

Not covered by a shape

run, shell, tui, wizard, auth set, auth login, auth connectors, auth verify, auth refresh, auth revoke and help have no JSON result shape (their reference entry has json: null). Their failures still use the error envelope when JSON is requested.

The command reference

abx help --json prints the versioned command reference. It is generated from the same tables that drive parsing and help text, so it is the authoritative description of the CLI for tools. This site’s CLI reference is written from it.

schemaVersion is 5 for this release and changes with the contract. The top-level keys are:

Key Contents
schemaVersion The version of the reference format.
name abx.
version The abx version, for example 0.3.0.
description One-sentence description of the tool.
boxSelection How a box is chosen when a command does not name one.
globalOptions The global options, as option entries.
exitCodes The exit codes, each with code and meaning.
output streams and errors: where results and errors go, and the error envelope in prose.
errors Every error code with code, meaning and retryable.
environment The environment variables listed in environment variables, each with name and description.
commands One entry per command, with subcommands nested.
agents The built-in agents and, for each, the authentication modes it offers.

Command entries

Each entry in commands (and in a command’s subcommands) has these fields:

Field Meaning
name, path The command name and its full path, such as auth set.
aliases Alternative names, such as list for ls.
summary One-line description.
usage The usage lines.
arguments Positional arguments, each with name, description, optional and repeatable.
options The options of the command, described below.
acceptsGuestArguments true when arguments after -- go to the guest.
terminal Whether the command needs an interactive terminal: never, always, or unless <condition>. A command marked always fails with needs-terminal without one, and so does shell without a guest command. auth set without a terminal fails when it would prompt, with the code internal.
startsBox true when the command may start the box’s VM: launches, diff, land and rm (which checks for unlanded commits).
bootsProbeMachine true when the command starts a short-lived probe machine and can incur provider charges (abx auth verify).
json null when the command has no result shape. Otherwise an object with a description and a shape.
notes Further behavior, as sentences.
examples Example command lines.
subcommands Nested command entries, such as auth set.

terminal is never for most commands, including run. shell is unless a guest command follows --, auth set is unless --from is given or the mode needs no secret, and tui, wizard and auth login are always.

Option entries

Entries in options and globalOptions have these fields:

Field Meaning
name The long name, such as --net.
short The short name, such as -s, or null.
value The placeholder of the value, such as HOST, or null for a switch.
choices The only accepted values, or null.
default A description of what applies when the option is absent, or null.
repeatable true when the option may be given more than once.
appliesAt creation for options that only matter when a box is created and must equal the recorded value afterwards, otherwise null.
hidden true when the option is accepted but left out of the text help.
deprecated true for a deprecated option. --agent-mode is the only one in this release.
description What the option does.

Agent entries

Each entry in agents has a name (claude, codex, opencode, pi, agy, cursor) and an auth list. Each auth entry has provider, mode, status, description and access, the list of access routes that mode offers (masked, global, local; empty when the mode is unsupported). abx help auth <agent> prints the same data as text. See agents and access modes.

Type to search…

↑↓ navigate↵ selectEsc close