CLI reference
The Gambi CLI runs hubs and manages rooms, participants, and room events.
The CLI is resource-oriented:
gambi hub servegambi room creategambi room listgambi room getgambi participant joingambi participant leavegambi events watchgambi self updategambi-tui remains the separate human-first monitoring interface.
Installation
Section titled “Installation”curl -fsSL https://raw.githubusercontent.com/arthurbm/gambi/main/scripts/install.sh | bashirm https://raw.githubusercontent.com/arthurbm/gambi/main/scripts/install.ps1 | iexnpm install -g gambi# orbun add -g gambiVerify the install:
gambi --versionThe 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.
Global behavior
Section titled “Global behavior”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.
Global flags
Section titled “Global flags”| 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.
Output modes
Section titled “Output modes”| 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 bothjsonandndjson. events watchprints each room event as one JSON line injsonandndjson; intext, the time, the type, and a summary.- Errors go to stderr. Outside
textthey are one JSON line,{ "error": { "name", "message", "hint", "details", "exitCode" } }. Intext:Error (Name): message, then aHint:line and the hub’srequest_idwhen there is one. - Log lines also go to stderr, never to stdout.
Prompts
Section titled “Prompts”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.
Environment variables
Section titled “Environment variables”| 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.
Exit codes
Section titled “Exit codes”| 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.
gambi hub serve
Section titled “gambi hub serve”Start the Gambi hub and keep it running until Ctrl+C.
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:
gambi hub servegambi hub serve --port 3000 --mdnsgambi hub serve --dry-run --format jsonA 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.
gambi room create
Section titled “gambi room create”Create a room through the management API.
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:
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 jsonThe structured result is { "data": { "room": { "code", ... }, "hostId" } }, so jq -r .data.room.code reads the room code.
gambi room list
Section titled “gambi room list”List room summaries from the management API.
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:
gambi room listgambi room list --format jsongambi room list --sort created-at --reversegambi room list --hub http://192.168.1.10:3000gambi room get
Section titled “gambi room get”Fetch one room summary by code.
gambi room get --code <room-code> [options]Options:
| Option | Description |
|---|---|
--code, -c |
room code |
--hub, -H |
hub URL |
Examples:
gambi room get --code ABC123gambi room get --code ABC123 --format jsongambi participant join
Section titled “gambi participant join”Join a room with a model endpoint or a local ACP harness. Press Ctrl+C to leave.
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-idis 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 withModelNotOnEndpoint, both with exit code3.--modelmust match a listed name exactly: Ollama lists names with their tag, such asllama3:latest(seeollama list). - Every participant joins through a tunnel, so the provider endpoint can stay on
localhosteven when the hub runs on another machine.--headerand--header-envvalues 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 firstWelcome, the join fails withTunnelOpenFailed(exit code3) without emittingleft. - Ctrl+C exits
0. The command names its ownruntimeIdwhen 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-runprobes 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--workspacewithout--harnessexits with code2. - A workspace whose snapshot is larger than 8 MiB is not sent at all: the command prints
artifact_skippedinstead. --endpoint,--header, and--header-envare invalid with--harness(exit code2). The harness uses its existing login on the participant machine. Gambi does not read or upload those credentials.- The
opencodeadapter runsopencode acp. If OpenCode is missing or has no detected credentials, the command exits with code3and prints the command needed to fix it. - The
claude-codeadapter runs the publishedclaude-agent-acpbridge. Install it withnpm install -g @agentclientprotocol/claude-agent-acp, install Claude Code withnpm install -g @anthropic-ai/claude-code, and authenticate locally withclaude 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
codexadapter runs the publishedcodex-acpbridge. Install it withnpm install -g @agentclientprotocol/codex-acp, install Codex CLI withnpm install -g @openai/codex, and authenticate locally withcodex login. - Claude Code and Codex readiness checks use
claude auth status --jsonandcodex login status. Authentication state and credentials remain on the participant machine and are never included in registration, lifecycle events, or the tunnel. - The
fakeadapter 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:
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-fixtureLifecycle 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.
gambi participant leave
Section titled “gambi participant leave”Take a participant out of a room, whoever is hosting it.
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:
gambi participant leave --room ABC123 --participant-id worker-1The 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.
gambi events watch
Section titled “gambi events watch”Write the events of a room as they happen, until Ctrl+C or until the hub closes.
gambi events watch --room <room> [options]Options:
| Option | Description |
|---|---|
--room, -r |
room code |
--hub, -H |
hub URL |
Examples:
gambi events watch --room ABC123gambi events watch --room ABC123 --format ndjson | jq .typeWith --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.snapshotparticipant.joinedparticipant.updatedparticipant.onlineparticipant.busyparticipant.offlineparticipant.removedllm.requestllm.completellm.error
See Observability for the fields of each event.
gambi self update
Section titled “gambi self update”Update the installed CLI. The command detects the install source (bun, npm, or standalone binary) and runs the matching upgrade path.
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:
gambi self updategambi self update --yesgambi self update --dry-run --format jsonIt 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.
See also
Section titled “See also”- API reference for the HTTP routes behind the CLI.
- SDK reference for programmatic equivalents.
- How tunnels work for the conceptual model behind
participant join.