Skip to content

CLI reference

The Gambi CLI runs hubs and manages rooms, participants, and room events.

The CLI is resource-oriented:

Terminal window
gambi hub serve
gambi room create
gambi room list
gambi room get
gambi participant join
gambi participant leave
gambi events watch
gambi self update

gambi-tui remains the separate human-first monitoring interface.

Terminal window
curl -fsSL https://raw.githubusercontent.com/arthurbm/gambi/main/scripts/install.sh | bash

Verify the install:

Terminal window
gambi --version

The hub and every participant must run the same minor version of Gambi (for example, any 0.8.x with any other 0.8.x). A hub refuses a participant from another minor with VersionMismatch, and the message names the version it expects.

Every command accepts the same global flags. Environment variables can set some of them, which helps in scripts and supervisors. Run gambi <command> --help for the flags of one command.

Flag Description
--format <text|json|ndjson> select output format
--no-interactive never prompt for a missing value, even on a terminal; fail instead
--log-level <all|trace|debug|info|warn|warning|error|fatal|none> minimum level of the log lines written to stderr
--help, -h show help
--version, -v show the version
--completions <bash|zsh|fish|powershell|sh|pwsh> print a shell completion script
--wizard build a command step by step

Every command that talks to a hub also accepts --hub <url> (-H). Without it, the hub is GAMBI_HUB, and without that http://localhost:3000.

Mode Meaning
text compact human-readable output
json the result as one indented JSON object
ndjson the result on one JSON line

Without --format, the format is GAMBI_FORMAT, and without that text when stdout is a terminal and json otherwise.

  • A one-shot command prints its result as { "data": ... }.
  • A long-running command (hub serve, participant join) prints one JSON line per step, { "type", "timestamp", "data" }, in both json and ndjson.
  • events watch prints each room event as one JSON line in json and ndjson; in text, the time, the type, and a summary.
  • Errors go to stderr. Outside text they are one JSON line, { "error": { "name", "message", "hint", "details", "exitCode" } }. In text: Error (Name): message, then a Hint: line and the hub’s request_id when there is one.
  • Log lines also go to stderr, never to stdout.

On a terminal, a missing required flag becomes a prompt. Prompts need stdin and stdout on a terminal, and are off with --no-interactive or GAMBI_NO_INTERACTIVE=1. Without a prompt, a missing flag fails with exit code 2. Passwords and nicknames are never asked: pass --password and --nickname.

Variable Effect
GAMBI_HUB hub URL when --hub is not passed
GAMBI_FORMAT fallback for --format
GAMBI_NO_INTERACTIVE=1 disable prompts everywhere
GAMBI_UPDATE_BASE_URL where self update downloads standalone binaries from

Named environments are gone since 0.8: there is no --env, no GAMBI_ENV, and no ~/.config/gambi/config.json. Set GAMBI_HUB instead.

Code Meaning
0 success
1 internal or unexpected failure
2 invalid usage (missing flag, bad value, flags that do not combine, port already in use, request the hub found invalid)
3 connectivity or dependency failure (unreachable hub, a server that is not a hub, unreachable provider, harness not installed or not logged in, tunnel that did not open)
4 hub refusal (missing room or participant, wrong password, version mismatch, or ownership conflict), or a runtime that was replaced or removed
130 a signal stopped a command that was not waiting for one

Automation supervisors can key retries off these codes. Do not retry 2. Retry 3 in most cases. 4 means the hub refused the operation because of its current state. On error, name in the JSON (or Error (Name) in text) is the stable name of the failure, such as RoomNotFound or HubUnreachable.

Start the Gambi hub and keep it running until Ctrl+C.

Terminal window
gambi hub serve [options]

Options:

Option Description
--host interface to listen on (default 0.0.0.0)
--port port to listen on (default 3000; 0 takes any free port)
--mdns announce the hub over mDNS so other machines can find it
--dry-run print what would start, without starting it

Examples:

Terminal window
gambi hub serve
gambi hub serve --port 3000 --mdns
gambi hub serve --dry-run --format json

A port that is already in use fails with PortInUse, which names the port, and exit code 2. A failed start leaves no mDNS announcement behind.

Lifecycle events (--format json|ndjson):

Event data Meaning
started host, port, mdns, hubUrl the hub listens; port is the real one when you asked for 0
mdns_registered name mDNS announcement is active
signal_received signal SIGINT or SIGTERM received; shutdown started
stopped signal the hub closed its tunnels and released the port

Rooms live in the hub’s memory. Stopping the hub ends its rooms, and participants that try to come back to a restarted hub end with RoomNotFound.

Create a room through the management API.

Terminal window
gambi room create --name <name> [options]

Options:

Option Description
--name, -n room display name
--password, -p optional room password
--config <file|-> runtime defaults of the room as JSON: a file, or - for stdin
--hub, -H hub URL
--dry-run print the request without creating the room

Examples:

Terminal window
gambi room create --name "Demo"
gambi room create --name "Demo" --config ./room.json
cat ./room.json | gambi room create --name "Demo" --config -
gambi room create --name "Demo" --dry-run --format json

The structured result is { "data": { "room": { "code", ... }, "hostId" } }, so jq -r .data.room.code reads the room code.

List room summaries from the management API.

Terminal window
gambi room list [options]

Options:

Option Description
--hub, -H hub URL
--sort <participant-count|created-at|name> sort key (default participant-count)
--reverse reverse the selected sort order

Examples:

Terminal window
gambi room list
gambi room list --format json
gambi room list --sort created-at --reverse
gambi room list --hub http://192.168.1.10:3000

Fetch one room summary by code.

Terminal window
gambi room get --code <room-code> [options]

Options:

Option Description
--code, -c room code
--hub, -H hub URL

Examples:

Terminal window
gambi room get --code ABC123
gambi room get --code ABC123 --format json

Join a room with a model endpoint or a local ACP harness. Press Ctrl+C to leave.

Terminal window
gambi participant join --room <room> --participant-id <id> --model <model> [options]
gambi participant join --room <room> --participant-id <id> --harness <id> [options]

Options:

Option Description
--room, -r room code
--participant-id stable participant identifier
--model, -m model to share; with --harness, an optional label for the model the harness runs on
--endpoint, -e where the provider listens on this machine (default http://localhost:11434)
--header Name=Value header for the requests to the provider, such as Authorization; repeatable. A blank name or value is invalid usage
--header-env Name=VARIABLE header whose value is read from an environment variable; repeatable. A missing, empty, or blank variable is invalid usage
--harness <opencode|claude-code|codex|fake> share a local ACP harness instead of a model endpoint
--workspace <folder> harness mode only: the folder the harness runs in
--nickname, -n display name (default <model>@<first six characters of the participant id>)
--password, -p room password
--config <file|-> runtime config of the participant as JSON: a file, or - for stdin
--no-specs do not send this machine’s specs
--hub, -H hub URL
--dry-run run the local checks and print what would be registered, without joining

Notes:

  • --participant-id is required. Reusing it is what lets a participant come back as the same one.
  • On a terminal, the command prompts for a missing room, participant ID, and model. In model mode it lists the models found on the endpoint.
  • The CLI probes the endpoint before registration: an endpoint that does not answer fails with EndpointUnreachable, and a model the endpoint does not list fails with ModelNotOnEndpoint, both with exit code 3. --model must match a listed name exactly: Ollama lists names with their tag, such as llama3:latest (see ollama list).
  • Every participant joins through a tunnel, so the provider endpoint can stay on localhost even when the hub runs on another machine. --header and --header-env values are used only for the probe and the requests to the provider, on this machine. See How tunnels work.
  • When the tunnel drops, the participant reconnects by itself, waiting 1 second and doubling up to 30, with the same participant ID. If it stays away for more than 60 seconds the hub removes it, and the next attempt brings it back as a new participant with the same ID.
  • The runtime ends when the hub refuses its return (for example, after a restart that lost the room), another runtime takes its tunnel, or the hub closes it because someone removed the participant. If the hub replaces (4001) or removes (4002) the tunnel before the first Welcome, the join fails with TunnelOpenFailed (exit code 3) without emitting left.
  • Ctrl+C exits 0. The command names its own runtimeId when it asks the hub to remove the participant, even if the signal arrives during the join. If the runtime is waiting to reconnect, the CLI stops it before sending the request. If the hub does not answer within 3 seconds, the CLI exits and the offline deadline still applies.
  • --dry-run probes the endpoint, or detects the harness and checks its login, then prints the registration with the password and headers redacted. It does not talk to the hub.

Harness mode:

  • Harness mode starts the harness process in a workspace folder and sends a snapshot of the folder after it stays unchanged for one second. Without --workspace, the folder is ~/.gambi/workspaces/<room>/<participant-id>/: created empty apart from .gambi.json (which is never sent) the first time, and reused with what it holds by a later join with the same room and participant ID. .git, node_modules, and symbolic links are never sent. Passing --workspace without --harness exits with code 2.
  • A workspace whose snapshot is larger than 8 MiB is not sent at all: the command prints artifact_skipped instead.
  • --endpoint, --header, and --header-env are invalid with --harness (exit code 2). The harness uses its existing login on the participant machine. Gambi does not read or upload those credentials.
  • The opencode adapter runs opencode acp. If OpenCode is missing or has no detected credentials, the command exits with code 3 and prints the command needed to fix it.
  • The claude-code adapter runs the published claude-agent-acp bridge. Install it with npm install -g @agentclientprotocol/claude-agent-acp, install Claude Code with npm install -g @anthropic-ai/claude-code, and authenticate locally with claude auth login.
  • Claude Code terms: each end user must run the unmodified Anthropic binary with their own local authentication. Gambi never intermediates a Claude subscription login and must never host Claude Code for third parties. Review Anthropic’s legal and compliance terms before joining.
  • The codex adapter runs the published codex-acp bridge. Install it with npm install -g @agentclientprotocol/codex-acp, install Codex CLI with npm install -g @openai/codex, and authenticate locally with codex login.
  • Claude Code and Codex readiness checks use claude auth status --json and codex login status. Authentication state and credentials remain on the participant machine and are never included in registration, lifecycle events, or the tunnel.
  • The fake adapter is deterministic and calls no model. It is for rehearsals and automated tests.
  • On Ctrl+C, a harness participant first takes a final snapshot while the harness and the tunnel are still running (best effort, up to 2 seconds), then closes the tunnel, stops the harness, and leaves the room. The harness gets 2 seconds to stop before it is killed. If the CLI itself is killed with kill -9, a harness that does not watch its standard input can keep running.

For a task-oriented setup for OpenCode, Claude Code, and Codex, see Bring your harness.

Examples:

Terminal window
gambi participant join \
--room ABC123 \
--participant-id worker-1 \
--model llama3:latest
gambi participant join \
--room ABC123 \
--participant-id worker-1 \
--model llama3:latest \
--endpoint http://localhost:1234
gambi participant join \
--room ABC123 \
--participant-id worker-1 \
--model llama3:latest \
--hub http://192.168.1.10:3000
gambi participant join \
--room ABC123 \
--participant-id worker-1 \
--model llama3:latest \
--dry-run \
--format json
gambi participant join \
--room ABC123 \
--participant-id arthur-opencode \
--nickname Arthur \
--harness opencode
gambi participant join \
--room ABC123 \
--participant-id bia-claude \
--nickname Bia \
--harness claude-code
gambi participant join \
--room ABC123 \
--participant-id caio-codex \
--nickname Caio \
--harness codex
gambi participant join \
--room ABC123 \
--participant-id rehearsal-1 \
--harness fake \
--model deterministic-fixture

Lifecycle events (--format json|ndjson). Every event’s data has roomCode, and all but registered have participantId:

Event Other fields of data Meaning
harness_started harness, pid, sessionId, workspace harness mode: the harness is running and its first session is open. Comes before registered
registered participant the hub registered the participant; its ID is participant.id
tunnel_connected attempt, hubVersion the tunnel is open and the participant is online; attempt is 0 on the join
reconnecting attempt, delayMillis, reason the tunnel dropped and the participant tries again in delayMillis
artifact_sent sessionId, version, reason, fileCount, bytes harness mode: a workspace snapshot entered the queue to the hub. It may still be lost if the tunnel drops before it is sent
artifact_skipped sessionId, reason, cause, maxBytes harness mode: the snapshot was not sent (tooLarge or collectFailed)
harness_exited harness, message, exitCode harness mode: the harness ended on its own
leaving signal SIGINT or SIGTERM asked the participant to leave
left reason, removed always the last event

left.reason and the exit code:

reason Meaning Exit code
stopped a signal asked the participant to leave 0
refused the hub refused the participant on the way back; the error is on stderr the error’s code, usually 4
replaced another runtime joined the room with the same participant ID 4
removed the hub closed this runtime’s tunnel because someone removed the participant. The error on stderr is ParticipantRemoved 4
harnessExited the harness ended on its own 3

left.removed is true when the hub confirms the participant is out of the room, including reason: "removed". If another runtime owns the ID when a local join stops, its participant stays in the room (online or offline) and removed is false.

Take a participant out of a room, whoever is hosting it.

Terminal window
gambi participant leave --room <room> --participant-id <id> [options]

Options:

Option Description
--room, -r room code
--participant-id participant identifier
--hub, -H hub URL

Example:

Terminal window
gambi participant leave --room ABC123 --participant-id worker-1

The command reads the participant’s runtimeId from the room listing. Success prints { "data": { "participantId" } } and a connected participant join exits with code 4 without reconnecting. If the participant changes owners between listing and removal, leave exits with ParticipantOfAnotherRuntime (code 4) and the new owner stays. A runtime removed between reconnection attempts can return.

Write the events of a room as they happen, until Ctrl+C or until the hub closes.

Terminal window
gambi events watch --room <room> [options]

Options:

Option Description
--room, -r room code
--hub, -H hub URL

Examples:

Terminal window
gambi events watch --room ABC123
gambi events watch --room ABC123 --format ndjson | jq .type

With --format json or ndjson, each line is one room event, as the hub sent it: { "type", "roomCode", "timestamp", ... }. The first one is always room.snapshot, the room and its participants at that moment. On a terminal (text), each line is the time, the event type, and a summary. The command exits 0 when the hub closes the stream; it does not reconnect.

Event types:

  • room.snapshot
  • participant.joined
  • participant.updated
  • participant.online
  • participant.busy
  • participant.offline
  • participant.removed
  • llm.request
  • llm.complete
  • llm.error

See Observability for the fields of each event.

Update the installed CLI. The command detects the install source (bun, npm, or standalone binary) and runs the matching upgrade path.

Terminal window
gambi self update [options]

Options:

Option Description
--manager <bun|npm> force a package manager instead of auto-detection
--yes skip confirmation prompt
--dry-run print the resolved update plan and exit

Examples:

Terminal window
gambi self update
gambi self update --yes
gambi self update --dry-run --format json

It always installs the latest release; it cannot pick a version. Outside a terminal the command updates without asking. Answering no exits 0. A package manager that fails exits 1, with its own exit code in details.code; a download that fails exits 3.