Engine reference — generated from the canonical engineering source. Do not edit this page by hand.
CLI Reference
The zerg CLI is a LuaJIT binary (zero Python dependency, cli_commands=92 handler functions in AGENTS.counts) that communicates with the Sol server via its HTTP API.
Global Options
| Flag | Description |
|---|---|
--json | Output raw JSON instead of formatted tables |
--format FORMAT | Output format (text or json; an unknown value errors and exits 1 — a value is REQUIRED, --format followed by the command word is a usage error) |
--quiet | Strip ANSI styling (the flag is enforced at the output boundary; colors are ALREADY stripped when stdout is not a TTY, so --quiet only matters on a terminal) |
--bearer TOKEN | Bearer token for auth (global flag — must appear BEFORE the command). The value is visible to other users via ps/argv. |
--token TOKEN | Deprecated global auth form (use --bearer or the ZERG_TOKEN env var). Note: value is visible to other users via ps/argv. After the command name, --token belongs to the command (e.g. channel-add, which prints the same argv-visibility warning) and is never a global credential. |
--profile NAME | Use connection profile from config (login/logout apply to that profile) |
--api-url URL | Override API base URL. A stored token is sent only when its recorded origin matches the override (or an explicit --bearer/--token/ZERG_TOKEN is supplied) |
--verbose, -v | Verbose diagnostics. Transport traces pass a redacting debug receiver: Authorization/Cookie/Set-Cookie/Proxy-Authorization header values are replaced with [REDACTED], and request/response BODIES are never echoed (a size note replaces the bytes) — a credential can never reach stderr through --verbose. |
--version | Show CLI version |
--help | Show help text |
Global flags are only parsed before the command name (the first
positional argument); everything after the command is the command’s own
argv. --json, --format and --quiet are additionally honored after
the command name, and so are --api-url/--profile (see the
post-command connection rules below).
Flag syntax
Explicit arity. Boolean flags (--json, --no-stream, --keyring,
…) never consume the next token; value flags (--model, --api-url,
…) REQUIRE one. The documented forms work exactly as written:
run --model m --no-stream "prompt", login --keyring user@x,
show --json model.
A missing value is a usage error (exit 1): --api-url followed by
the command word — zerg --api-url status — is refused, never a
silent help-and-exit-0.
-- ends option parsing. Everything after it is positional:
zerg status -- runs, and a token that merely looks like a flag
(zerg status -- --json) is a positional argument, not a flag.
--bool=value is refused (--json=true → “does not take a
value”); value flags keep the = form (--format=json).
Family flags before the verb resolve against the verb:
update --json check and team mail --team list work — the first
non-flag token is the verb.
Post-command connection flags
--api-url after the command is an endpoint-only mutation: it
never reloads the stored credential, never clears the selected
profile, and an explicit --bearer keeps precedence
(zerg --bearer X status --api-url U sends X).
--profile after the command applies the full profile scope
(selecting a profile IS the credential-scope change).
The same flag before AND after the command is a conflict refusal
(exit 1, nothing dispatched); a pre-command --api-url cannot combine
with a post-command --profile.
Origin binding still guards the wire: an override endpoint never
receives a stored token minted for a different origin.
With --json, every failure — HTTP/API errors, argument/usage
validation, login 4xx, and dispatcher errors (unknown command/subcommand,
bad flag value) — emits exactly one
{"ok":false,"error":{"code","message"}} document on stdout. Invoking
only global flags (for example zerg --json) prints the help text and
exits 0. run/chat switch to the buffered request under --json
(token deltas are never interleaved with the document). JSON documents
are machine-boundary output: their string values are JSON-escaped for
structural safety but C1 control bytes (0x80–0x9F) are NOT stripped from
the decoded values — consumers that render them must apply their own
terminal sanitizer (the human path does: see the C1 strip below).
Connection profiles
--profile NAME selects a complete connection scope, not just a
hostname:
Endpoint: the profile’s api_url when set; otherwise the
top-level api_url / ZERG_API_URL / default. The active profile’s
URL is never used as a fallback for a different selected profile.
Credential: the profile’s token → ZERG_TOKEN (env). The
active/top-level config token and its token_keyring marker are out
of scope — zerg --profile dev status with a prod active profile
never sends the prod bearer. A profile without a token sends no
Authorization header (explicit no-token sentinel).
--bearer TOKEN before the command overrides every stored token and
applies within the selected scope.
Without --profile, connection resolution is unchanged (active profile
first, then the top-level config/env fallbacks). A token stored by
zerg login (no --profile) is the top-level credential;
zerg --profile NAME login stores that profile’s credential (including a
per-profile --keyring entry) and zerg --profile NAME logout revokes
and clears only that profile. A login records the origin it minted the
token for (token_origin), and that token is never replayed to a
different origin. A legacy token without a recorded origin is not sent to
an explicit --api-url override.
All commands accept --json for machine-readable output (streaming
run/chat/task output streams tokens by design — --json applies to
their non-streaming forms).
Health & Status
zerg status
Check server health (GET /api/v1/health).
zerg status
# Status: ok Models running: 3
zerg metrics
Show ETS-backed inference metrics (model lifecycle counters, requests, tokens, errors, durations) as a formatted table.
zerg metrics
Model Management
zerg discover
Scan NFS and local directories for GGUF model files.
zerg discover
# Discovered 12 models
zerg list
List all registered models with slug, family, quantization, and size.
zerg list
zerg ps
Show currently running inference processes.
zerg ps
zerg show <model>
Show detailed information for a specific model.
zerg show glm-4.7-flash
zerg start <model>
Start an inference model.
zerg start glm-4.7-flash
# With parameter template
zerg start glm-4.7-flash --template coding
# With parameter overrides
zerg start glm-4.7-flash --temp 0.3 --top-p 0.9 --batch-size 4096
| Flag | Type | Description |
|---|---|---|
--template | string | Parameter template: default, coding, chat, reasoning |
--temp | float | Override temperature |
--top-p | float | Override top-p |
--batch-size | int | Override batch size |
(No -t shorthand: the parser accepts single-dash tokens generically, but
start only reads --template.)
zerg stop <model>
Stop a running inference model.
zerg stop glm-4.7-flash
zerg stop-all
Stop all running inference models.
zerg stop-all
zerg prepare <model>
Sync a model from NFS to local disk via rsync.
zerg prepare glm-4.7-flash
Inference
zerg run <prompt> --model <model>
Run an OpenAI-compatible chat completion.
# Streaming (default)
zerg run --model glm-4.7-flash "Explain quicksort"
# Non-streaming
zerg run --model glm-4.7-flash --no-stream "What is 2+2?"
# With parameters
zerg run --model glm-4.7-flash --temp 0.3 --max-tokens 4096 "Write a fib function"
# With timeout
zerg run --model glm-4.7-flash --timeout 30000 "Long prompt..."
| Flag | Type | Description |
|---|---|---|
--model, -m | string | Model slug (defaults to default) |
--no-stream | flag | Return complete response (no streaming) |
--temp | float | Override temperature |
--max-tokens | int | Maximum tokens to generate |
--top-p | float | Override top-p |
--timeout | int | Request timeout in milliseconds (non-streaming only; 1–2147483; converted to seconds at the transport) |
--low-speed-time | int | Seconds of inactivity before a stalled stream aborts (default 60) |
--low-speed-limit | int | Bytes/s below which a stream counts as stalled (default 1) |
--verbose, -v | flag | Show token count after response |
Streams carry no total-transfer timeout — they abort on inactivity
instead: fewer than --low-speed-limit bytes/s for --low-speed-time
seconds. Raise both for slow-first-token reasoning models, e.g.
zerg run --model m --low-speed-time 300 --low-speed-limit 1 "...".
zerg chat <prompt> --model <model>
Chat via the Anthropic Messages API (/v1/messages).
# Streaming (default)
zerg chat --model glm-4.7-flash "Explain quicksort"
# Non-streaming
zerg chat --model glm-4.7-flash --no-stream "What is 2+2?"
# With system prompt
zerg chat --model glm-4.7-flash --system "Be concise" "Explain monads"
| Flag | Type | Description |
|---|---|---|
--model, -m | string | Model slug (defaults to default) |
--no-stream | flag | Return complete response |
--temp | float | Override temperature |
--max-tokens | int | Maximum tokens to generate (default 4096) |
--top-p | float | Override top-p |
--system, -s | string | System prompt |
--low-speed-time | int | Seconds of inactivity before a stalled stream aborts (default 60) |
--low-speed-limit | int | Bytes/s below which a stream counts as stalled (default 1) |
--verbose, -v | flag | Show token count/usage (usage on the non-streaming path: input=/output= token counts) |
Agent Workers
zerg agents
List all spawned agent workers.
zerg agents
zerg spawn
Spawn new agent worker(s).
zerg spawn
# Spawn multiple
zerg spawn --count 4
# With custom worker binary
zerg spawn --worker-path /opt/sol/etc/luna
| Flag | Type | Description |
|---|---|---|
--count, -n | int | Number of agents to spawn |
--worker-path | string | Path to worker binary |
Exit semantics. The command exits non-zero
when no worker was spawned — a 200 response whose results array is
empty or carries an error on every row is a FAILURE, not success. A
mixed batch (at least one success) is a documented partial success:
exit 0 and the spawned/failed counts in the output. Under --json
the all-failed case emits the standard {ok:false, error:{code: "spawn_failed", message}} document with spawned/failed beside it, and
a successful/mixed batch emits {ok:true, spawned, failed, items, total}.
zerg kill <agent_id>
Kill a running agent worker.
zerg kill agent-abc123
zerg task <agent_id> <prompt>
Dispatch a task to an agent worker.
# Streaming (default)
zerg task agent-abc123 "Fix the bug in main.rs"
# Non-streaming, poll for result
zerg task agent-abc123 --no-stream --wait "Fix the bug in main.rs"
| Flag | Type | Description |
|---|---|---|
--no-stream | flag | Queue task without streaming |
--stream | flag | Force SSE streaming |
--wait | flag | Poll for result (with --no-stream); Ctrl-C during the poll exits 130 |
--timeout | int | Poll budget for --wait in milliseconds |
--verbose, -v | flag | Show token count |
Both buffered forms (--wait and --no-stream) send stream:false in
the dispatch body — the server’s SSE default never answers a buffered
client. If a streamed dispatch is QUEUED server-side, Sol answers the
202 {status:"queued",task_id} JSON ack instead of a stream; the CLI
prints the queued state and follows the task to its terminal (same
contract as --wait).
With --no-stream --wait the CLI polls GET /api/v1/tasks/<id> and
exits by the task’s final status:
| Final status | Meaning | Exit |
|---|---|---|
pending, queued, in_progress | still running — keep polling | — |
ok, completed | terminal success | 0 |
cancelled, timeout, crashed, error | terminal failure | 1 |
| anything unrecognized | fails closed (never claimed as success) | 1 |
A 404 while the task’s first row/token is still landing is tolerated
for a bounded 10-second window (in-flight dispatch); past the window
it is a normal 4xx (exit 1). The --wait budget itself timing out
exits 1.
zerg task-cancel <task_id>
Cancel a running task.
zerg task-cancel task-xyz789
zerg task-status <task_id>
Get task status and result.
zerg task-status task-xyz789
Cluster
zerg cluster
Show cluster membership status.
zerg cluster
zerg catalog
Show the global model catalog across all cluster nodes.
zerg catalog
zerg join <node>
Join a cluster node.
zerg join sol@gpu-node-2
zerg leave
Leave the cluster.
zerg leave
Circuit Breaker
zerg circuits
List all circuit breaker states.
zerg circuits
zerg circuits-reset <key>
Force reset a circuit breaker to closed state.
zerg circuits-reset my-model
Plugin Workers
zerg plugin-eval <code>
Evaluate Lua code in a sandboxed Luerl worker.
zerg plugin-eval "return 1 + 1"
zerg plugin-workers
List all running Lua (Luerl) workers.
zerg plugin-workers
zerg plugin-spawn
Spawn a new Lua sandbox worker.
zerg plugin-spawn
# With default script
zerg plugin-spawn --script hello
| Flag | Type | Description |
|---|---|---|
--script | string | Default script to load |
ZMQ Workers
zerg zmq-workers
List connected ZMQ workers.
zerg zmq-workers
zerg zmq-dispatch <prompt>
Dispatch a task to a ZMQ worker.
zerg zmq-dispatch "Fix the bug" --model glm-4.7-flash
| Flag | Type | Description |
|---|---|---|
--model, -m | string | Model to use |
--context | string | Additional context |
zerg zmq-status
Show ZMQ gateway status (port, connected workers, queue depth).
zerg zmq-status
Scheduler
zerg schedule list
List all scheduled jobs.
zerg schedule list
zerg schedule add <prompt>
Create a scheduled job.
# Cron expression (every weekday at 9am)
zerg schedule add "Summarize yesterday's logs" --cron "0 9 * * 1-5" --name "daily-summary"
# Run at a specific time (epoch seconds)
zerg schedule add "Deploy model" --at 1777626000
# Run every 30 minutes
zerg schedule add "Health check" --every 1800 --name "health-check"
# One-time job (delete after run)
zerg schedule add "Generate report" --at 1777626000 --delete
| Flag | Type | Description |
|---|---|---|
--cron | string | Cron expression (min hour day month weekday) |
--at | int | Unix epoch seconds for one-time execution (tonumber-parsed — an ISO 8601 string is silently dropped) |
--every | int | Interval in seconds |
--name | string | Job name |
--model, -m | string | Model to use |
--delete | flag | Delete job after one run |
Exactly one schedule source is sent: --every wins over --cron, which
wins over --at (elseif chain in the handler).
zerg schedule show <job_id>
Show job details.
zerg schedule show 1
zerg schedule pause <job_id>
Pause a scheduled job. POST only.
zerg schedule pause 1
zerg schedule unpause <job_id>
Resume a paused job. POST only.
zerg schedule unpause 1
zerg schedule run <job_id>
Trigger immediate execution of a scheduled job.
zerg schedule run 1
zerg schedule delete <job_id>
Delete a scheduled job.
zerg schedule delete 1
Channels
zerg channels
List all registered delivery channels.
zerg channels
zerg channel-add
Register a delivery channel.
# Telegram channel (token is argv-visible — the command warns)
zerg channel-add --type telegram --token "BOT_TOKEN" --chat-id "CHAT_ID" --name "alerts"
# Discord channel (webhook)
zerg channel-add --type discord --webhook-url "https://discord.com/api/webhooks/..." --name "ops"
# Non-argv JSON config (file, or `-` for stdin)
zerg channel-add --type telegram --config-file /etc/zerg/telegram.json
printf '%s' '{"bot_token":"...","chat_id":"..."}' | zerg channel-add --type telegram --config-file -
# Inline JSON config (also argv-visible — the command warns)
zerg channel-add --type telegram --config '{"bot_token":"...","chat_id":"..."}'
| Flag | Type | Description |
|---|---|---|
--type, -t | string | Channel type: telegram (default), discord |
--token | string | Telegram bot token (required for --type telegram without --config) |
--chat-id | string | Telegram chat ID (required for --type telegram without --config) |
--webhook-url | string | Discord webhook URL (required for --type discord) |
--name | string | Channel display name |
--config | string | JSON config object (overrides --token/--chat-id/--webhook-url); argv-visible, warns |
--config-file | string | Read the JSON config from a file, or - for stdin (mutually exclusive with --config); no argv exposure |
: the advertised
--type webhookbranch is removed — the bundled plugin universe is telegram/discord/slack/teams, so awebhooktype could never load. When the server has no loaded backends (for exampleplugin_config_pathis unset)channel-addnow prints the server’s typed cause (HTTP 503channel_backends_unavailable) verbatim.
** (CL-20) /:** the
--token/-tbot token, the Discord webhook URL AND the inline--configJSON are all argv-visible to other users viaps— each carrier prints the loud visibility warning. The non-argv path is--config-file <path>(or--config-file -for stdin); the pre-fix guidance recommended--config, which was itself argv-visible. The channel request itself declares its body secret and forces the proxy bypass (NOPROXY=*), so the token never transits a configured (TLS-inspecting) proxy.
zerg channel-remove <channel_id>
Remove a registered channel.
zerg channel-remove ch-abc123
zerg channel-test <channel_id>
Send a test message to a channel.
zerg channel-test ch-abc123
zerg channel-send <channel_id> <message>
Send an arbitrary message to a channel.
zerg channel-send ch-abc123 "Deploy complete"
zerg channel-pause <channel_id>
Pause delivery for a channel (POST /api/v1/channels/:id/pause). The
channel row, its configuration and its queued history are kept; the
delivery worker skips it until channel-resume. --json returns the
server envelope.
zerg channel-pause ch-abc123
zerg channel-resume <channel_id>
Resume a paused channel (POST /api/v1/channels/:id/resume). Delivery
restarts on the next dispatch — messages emitted while paused are not
replayed. --json returns the server envelope.
zerg channel-resume ch-abc123
Recipes
zerg recipe-list
List available recipe templates.
zerg recipe-list
zerg recipe-show <name>
Show details for a specific recipe template.
zerg recipe-show incident-analysis
zerg recipe-run <name>
Run a recipe as a workflow.
zerg recipe-run incident-analysis
# With a JSON payload
zerg recipe-run incident-analysis --payload '{"alert_id":"42"}'
| Flag | Type | Description |
|---|---|---|
--payload | string | JSON object passed to the workflow as its initial payload |
zerg recipe-reload
Reload recipe templates from disk.
zerg recipe-reload
Skills
zerg skills
List all registered agent skills.
zerg skills
zerg skill-search <query>
Search skills by name, description, or tags.
zerg skill-search "code review"
zerg skill-register <file>
Register a skill from a JSON file.
zerg skill-register skill.json
zerg skill-remove <name>
Remove a registered skill.
zerg skill-remove my-skill
zerg skill install <name> <author>
Install a marketplace skill: calls POST /api/v1/marketplace/:name/:author/install,
writes the returned SKILL.md body atomically to
~/.luna/skills/remote/marketplace/<author>/<name>/SKILL.md and records
provenance.json ({source, version, fetched_at, author_uuid}) beside it, so
the existing skill-discovery path prompt-injects it. LUNA_SKILLS_ROOT (or
LUNA_HOME) relocates the target root.
Install atomicity. Both files are staged to
same-directory 0600 temp names (fsync’d) before either is published;
SKILL.md is renamed into place first and provenance.json last. If
provenance cannot be staged nothing is published; if its publish fails the
just-published SKILL.md is removed, so skill discovery never observes a
half-install.
zerg skill install code-review 8f0c...-author-uuid
Team Mail
The member-readable team mailbox is server-complete;
these two verbs are its operator surface. Both hit the EXISTING routes
(GET/POST /api/v1/teams/:id/mail) — no new store. Reads require the
caller to be a team member (or creator/admin); sends require the
creator/admin mutator gate (teams:manage on the wire). The default list
is TEAM-WIDE for a member (the authorized visibility contract — mail is
addressed, not access-controlled per addressee); callers can narrow with
the server’s ?mine=1 poll (the CLI lists the team view).
zerg team mail list --team <id>
List the team’s mail, oldest first, as the server renders it
(id, from_kind:from, to, priority, subject, body, status).
--json prints the raw {ok, messages} envelope.
zerg team mail list --team team_ab12cd
zerg team mail list --team team_ab12cd --json
zerg team mail send --team <id> --to <member> --body <text>
Send mail into the team mailbox. --to accepts a member worker id, a
user uuid (resolved to the member’s worker id server-side), or all
(default). Optional: --subject <text>, --priority high|normal|low.
zerg team mail send --team team_ab12cd --to member-w1 \
subject status --body "report when done"
Reply semantics: a received mail carries a sender struct
(from_kind/from_id); reply by passing the struct’s id as --to — the
server resolves user uuids to the member worker id at send time.
Local Analytics
Read verbs over Luna’s local usage ledger, ~/.luna/analytics.db (written
by the agent/ZMQ worker; 90-day retention). The DB is read
Read-only — these commands never create or migrate it; a missing
ledger is a typed error naming the path. Override the path with --db
(e.g. a worker’s mounted home), the window with --days N (default 7).
zerg analytics summary
Tool call counts/latencies, model selection counts, and token/cost totals over the window.
zerg analytics summary
zerg analytics summary --days 30
zerg analytics top-tools
Tools ranked by call count (all time in the ledger); --limit N caps the
list (default 10).
zerg analytics top-tools --limit 5
zerg analytics cost
Daily token cost over the window (one row per YYYY-MM-DD).
zerg analytics cost --days 14
All three accept the global --json for machine consumption.
Keyring
zerg keyring-test
Check which OS keyring backend is available.
zerg keyring-test
No backend is a failure: exit 1, and under --json the one failure
document carries error.code = "keyring_unavailable" (,
). The keyring path has no pkill/killall dependency —
the bounded-run watchdog uses only POSIX shell builtins plus sleep and
signals only the exact PIDs it forked.
zerg keyring-set <provider>
Store an API key for a provider in the OS keyring.
zerg keyring-set anthropic
The key is read via a hidden prompt. The legacy --key KEY form still
works but prints a deprecation warning — the value is visible to other
users via ps/argv, exactly like the deprecated --password/--token
forms.
The store is verified by the backend command’s real exit status
the secret goes to the backend over stdin (it never
appears in argv) and a failed secret-tool/security write exits
non-zero and is reported — never printed as success.
zerg keyring-get <provider>
Retrieve a stored API key (masked display).
zerg keyring-get anthropic
Keys shorter than 16 characters are fully masked (****); longer keys
show only their first and last four characters.
zerg keyring-delete <provider>
Remove a stored API key from the keyring.
zerg keyring-delete anthropic
Auth
zerg login <account>
Login to Mango auth service.
zerg login user@example.com
| Flag | Type | Description |
|---|---|---|
--email, -e | string | Account (the positional <account> is the same thing) |
--password | string | Deprecated — argv-visible via ps; omit to get the hidden prompt |
--keyring | flag | Store the bearer in the OS keyring instead of the config file |
--password on the command line is argv-visible to other users (ps) and
deprecated — omit it and the CLI prompts with echo hidden (or set the
token via zerg login’s response and ZERG_TOKEN for API calls).
Pass --keyring to store the bearer in the OS keyring (libsecret’s
secret-tool on Linux, macOS Keychain — the same backends as
zerg keyring-set) instead of the config file:
zerg login --keyring user@example.com
Prefixing the global --profile NAME stores the credential in that
profile instead of the top level; the matching --profile NAME logout
revokes and clears the same profile only:
zerg --profile staging login user@example.com
zerg --profile staging logout
Token storage truth
By default the login bearer is stored in plaintext in
~/.zerg/config.json. The file is created 0600 from birth (the umask
can only remove bits) and the atomic-save path fsyncs before rename — but
the token itself is not encrypted. On Linux x86_64 the CLI additionally
stat-probes the file and warns when it is world-readable; every other
platform skips that probe silently (a warn-only check must never read a
foreign struct stat layout), so the permission warning is a no-op off
Linux x86_64. Keep the config directory access-controlled.
zerg login --keyring is the migration path out of the plaintext: the
token goes to the OS keyring and the config keeps only a
token_keyring: true marker (never the token). A keyring write failure
fails the login loudly — the real backend exit status is checked, the
token_keyring marker is not written, and the plaintext fallback
never happens. zerg logout clears the keyring entry
and the marker together.
zerg login exits by the documented HTTP contract:
2xx → 0, 4xx → 1, 5xx → 2, a transport failure or a local
credential-transport refusal → 3.
zerg logout
Logout from Mango auth.
zerg logout
Prints Logged out (exit 0) after a 2xx remote revoke;
Not logged in (exit 0) with no stored token. The local credential
clear always runs first: a failed remote revoke prints
Logged out (remote logout failed: …) /
Logged out (server returned N) and exits by the documented HTTP
contract — 4xx → 1, 5xx → 2, a transport
failure or a local credential-transport refusal → 3 — so scripts can
tell the remote token may still be live.
Admin
The two documented-outage Mango token-admin verbs. Both require an
Admin-bearer for Sol (the routes are {admin, require}-scoped at the
middleware and re-checked inline) and are strict-audited: a 200 is only
answered once the audit entry has landed (503 audit_unavailable
otherwise). Sol performs the Mango mutation with its service principal —
zerg never talks to Mango directly.
zerg admin unlock <user_uuid>
Clear a Mango account lockout (the hard lockout window).
zerg admin unlock 11111111-2222-3333-4444-555555555555
# Account unlocked: 11111111-2222-3333-4444-555555555555
POST /api/v1/admin/users/:user_uuid/unlock. The uuid is shape-checked
server-side (400 invalid_user_uuid); an unknown user is 404 not_found;
a Mango-side admin-plane failure is fail-closed 503 mango_admin_unavailable (never a fake success).
zerg admin revoke-token <token_id>
Revoke one Mango token by its persisted SHA-256 id (the 64-hex id from the
service-token listing, GET /auth/service-tokens).
zerg admin revoke-token 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
# Token revoked: 0123…cdef
POST /api/v1/admin/tokens/:token_id/revoke. 400 invalid_token_id on a
malformed id; 404 not_found for an unknown id; 503 on an audit or
Mango-admin outage. Use this for rotation hygiene after a leak or a
deprovisioned host.
Both verbs are also available directly over the API with the same bodies —
see docs/api-reference.md.
OAuth Providers
Browser PKCE login for declarative providers that carry an oauth sub-map
in their provider JSON. Requires an admin-bearer; Sol holds the PKCE
verifier and performs the code exchange (POST /api/v1/oauth/login, then
POST /api/v1/oauth/login/complete) and persists the access+refresh
tokens server-side (0600, Sol’s data dir). resolve_api_key consumes
them; a provider 401 refreshes via the pool’s auth-class report path, and
a background tick renews tokens near expiry. The code exchange is a
body-carried credential: the CLI forces the proxy bypass for it (see the
proxy residual below). The printed authorize URL is validated and
terminal-sanitized BEFORE anything is written — a hostile
(C1/OSC-bearing) URL is refused with zero bytes emitted.
zerg oauth login <provider>
zerg oauth login my-idp
# Authorize my-idp by opening: https://idp.example/authorize?...
# Connected my-idp
Opens the authorize URL (best-effort xdg-open/open; --no-browser
prints only) and binds the provider’s loopback redirect URI for the
callback. --timeout N caps the wait (default 180s). The CLI refuses to
bind a non-loopback redirect URI.
zerg oauth status
List providers with a stored token (GET /api/v1/oauth/providers).
zerg oauth logout <provider>
Delete the stored token (DELETE /api/v1/oauth/providers/:provider,
strict-audited); the provider falls back to keyring/env resolution.
Air-gap: this flow needs browser + IdP reachability — use
zerg keyring-set / api_key_env on air-gapped fleets (see
docs/security.md).
Background Workers
zerg bg-workers start <task>
Start a background worker session.
zerg bg-workers start "Analyze the codebase"
The <task> text is sent as the server-side prompt field; a missing or
empty prompt is answered 400 (prompt required) by the server.
zerg bg-workers list
List all background workers.
zerg bg-workers list
zerg bg-workers status <id>
Show background worker status.
zerg bg-workers status bg-abc123
zerg bg-workers logs <id>
Show background worker output logs.
zerg bg-workers logs bg-abc123
zerg bg-workers kill <id>
Kill a background worker.
zerg bg-workers kill bg-abc123
Workflows
The workflow family manages running workflow instances (started
directly or via zerg recipe-run). All subcommands take their target as
a positional argument and no command-specific flags; --format text
(the default) renders the top-level scalar fields as key: value lines,
while --format json prints the full payload.
zerg workflow list
List all workflows.
zerg workflow list
zerg workflow start <name>
Start a workflow by recipe/template name.
zerg workflow start incident-analysis
zerg workflow show <id>
Show a workflow’s details and current state.
zerg workflow show wf-abc123
zerg workflow cancel <id>
Cancel a running workflow.
zerg workflow cancel wf-abc123
zerg workflow branch <id>
Branch a workflow (no flags — the server derives the branch).
zerg workflow branch wf-abc123
zerg workflow tree <id>
Show the workflow step tree. The tree is deeply nested — in --format text only top-level scalars render, with a pointer at --format json.
zerg workflow tree wf-abc123
zerg workflow tree wf-abc123 --format json
zerg workflow lineage <id>
Show the workflow’s execution lineage (ancestry across branches).
zerg workflow lineage wf-abc123
Session shares
zerg session share --file <path> | --data <string> [--format FMT] [--ttl-days N]
Mint a share link from exported session data (POST /api/v1/sessions).
session_data is a string on the wire (see docs/sessions.md):
--file reads it verbatim, --data passes the literal — --data puts
the payload (which can carry private transcript content) on the argv
where every local user can read it via ps, so the command prints the
same loud visibility warning the credential flags carry; prefer --file.
--format and --ttl-days are forwarded to the server’s
quarantine/expiry policy. Prints the server’s url when the response
carries one, otherwise the share_id (the client constructs the link).
--json returns the server envelope.
zerg session share --file session-export.json --ttl-days 7
zerg session share --data '{"messages":[]}' --format json
Updates
Update channel
The zerg update commands resolve a release channel per invocation:
| Priority | Source | Key | Values |
|---|---|---|---|
| 1 | Environment | ZERG_UPDATE_CHANNEL | forgejo (default) | github |
| 2 | Config (~/.zerg/config.json) | update_channel | forgejo (default) | github |
| 3 | Built-in default | — | forgejo |
The default channel is Forgejo because that is where releases are
actually published: the CD pipeline (.crow.yml publish-release →
wild’s publish-release.sh) uploads release assets (zerg CLI, luna,
sol-<ver>.tar.gz, SHA256SUMS, minisign signatures) to the RELEASE
forge (git.zergs.net). The retired dev mirror git.nonsense.ws is not the
release origin. The latest-release endpoint is
https://git.zergs.net/api/v1/repos/spacebeam/zerg/releases/latest.
GitHub is an explicit override for operators who mirror releases
there: set update_channel: "github" in ~/.zerg/config.json (or
ZERG_UPDATE_CHANNEL=github in the environment). The GitHub channel
queries https://api.github.com/repos/anomalyco/zerg/releases/latest.
The repository defaults per channel (spacebeam/zerg for forgejo,
anomalyco/zerg for github) can be overridden with update_repo in the
config or ZERG_UPDATE_REPO in the environment (both apply to whatever
channel is active). An explicitly configured channel that is neither
forgejo nor github is refused loudly — the updater never silently
falls back to a different distribution.
zerg update check
Check for available updates.
zerg update check
zerg update download
Download the latest release.
zerg update download
Downloads into a private 0700 staging directory ( — the old
world-readable /tmp/zerg-update-<ver>.tar.gz path was a local
swap/root-write target). The channel is authenticated and integrity
checked (, — the old “integrity only, no authenticity”
caveat was closed): the release must carry a minisign detached signature
(*.minisig) which is verified against a TOFU-pinned key at
~/.config/zerg/trusted-key before anything is extracted — the first
verified install pins the release’s minisign.pub asset (fingerprint =
SHA-256 of the raw Ed25519 public key), subsequent updates must match the
pin, key changes are refused, and unsigned releases are refused outright.
Integrity is additionally verified against the same-origin SHA256 asset;
a release missing either the signature or the SHA256 asset fails closed.
zerg update trust-key <minisign.pub> is the deliberate re-pin escape
hatch (see below).
zerg update apply
Apply a downloaded update.
zerg update apply
Re-verifies the SHA256 and re-runs the minisign signature verification
of the exact file about to be extracted (the TOFU-pinned key is consulted
again at apply time — a stale or swapped staging artifact cannot pass
integrity alone; ) and rejects archives containing anything
but regular files/directories (symlinks, hardlinks, devices, fifos,
../absolute paths, control characters are all refused — ).
The install root is never a baked-in default: /opt/zerg is
the legacy Sol root and /opt/sol the current one, so applying a CLI
update there could replace Sol (or plant a parallel tree). The updater
derives the root from the running zerg executable when it is a real
installed layout (zerg + VERSION siblings) and refuses /opt/zerg or
any directory carrying bin/sol; pass --install-dir DIR for any other
layout:
zerg update apply --install-dir /opt/zerg-cli
The current version comes from <root>/VERSION, falling back to the
version embedded in the running binary. The installed tree is moved
aside to <root>.<timestamp>.bak before the new tree is installed; the
post-install probe execs the INSTALLED binary (--version + an offline
completion render) and a failure rolls back automatically.
--install-dir is a VALUE at the command layer — a
valueless/empty flag is refused before anything resolves — and the value
must be ABSOLUTE. It is canonicalized (realpath + lexical pass; an
explicit .. segment is refused) before the guard checks, so
/opt/./zerg, /opt//zerg, /opt/zerg/ and symlink aliases cannot
dodge the legacy-root or bin/sol verdicts.
Install-root containment. The update
dance renames, RENAME_EXCHANGEs and rm -rfs the root, so an EXISTING
--install-dir must be a real CLI install (zerg + VERSION siblings)
or an empty directory (an explicit fresh-install target); an existing
non-install tree, the home directory, and filesystem roots (/, /home,
/usr, /tmp, …) are refused before any destructive step. A
non-existent root is accepted only when its parent exists.
Staging reclamation. A successful apply
removes the downloaded artifact and its private staging directory; a
FAILED apply keeps them for retry. Repeated/abandoned downloads are
bounded: update download sweeps stale /tmp/zerg-update.* trees (age
7 days, or beyond the newest 8 after a 1-hour grace) before minting a
new staging dir.
Corrupt TOFU pin: a pin file that EXISTS but cannot be parsed (truncated, non-hex fingerprint, garbage) is a typed corruption refusal — the updater never treats it as “no pin” and never re-pins silently from the channel. Recovery is exactly
zerg update trust-key <minisign.pub>.
zerg update rollback
Rollback to the previous version.
zerg update rollback
Restores the newest <root>.*.bak tree, most-mtime-first (same root
resolution/refusals as apply; --install-dir overrides — same
absolute/canonical contract). Note when
that tree exists: a successful apply deletes its backup after the
post-install health check passes, and a failed health check consumes it
for the automatic rollback — so a leftover .bak normally exists only
after an interrupted apply (crash between the install swap and
cleanup). With no backup present the command fails with
no backup found (exit 1).
zerg update trust-key <minisign.pub>
Deliberately re-pin the release signing key (TOFU override). Any auto-detected key change is refused by the updater; this command is the explicit operator acknowledgement that the signing key has rotated:
zerg update trust-key /path/to/new/minisign.pub
The dashed
trust-keysubcommand is dispatched explicitly (main.luamaps it tocmd_update_trust; closed a dispatch regression that briefly made the subcommand unreachable — regression suitezerg-cli/tests/test_zcli_update_dispatch.lua). The updater’s own key-change refusals direct operators to this exact command line.
Diagnostics
zerg doctor
One-command verdict for an incident: CLI version, resolved API URL,
GET /health, and GET /api/v1/ready (a 503 names the failing check
family). Exit 0 only when both probes are healthy; --json emits the same
facts as one document. It is safe to run with no credential.
zerg doctor
zerg doctor --json
zerg support-bundle [output_dir] [--log-dir DIR]
Writes a redacted support bundle for an incident report:
version.txt — CLI + platform;
environment.txt — only ZERG_*/SOL_*/LUNA_*/MANGO_* environment
keys, with secret-keyed values replaced by <redacted> and URL/DSN
userinfo (postgres://user:pass@host/db) replaced by
postgres://<redacted>@host/db;
config.json — the loaded CLI config with secret-keyed values redacted
(tokens never written);
health.json — API URL, /health, /ready and /api/v1/infra/status
(best-effort; an offline node still produces the local half);
logs/*.tail — bounded tails of the discovered Sol/Mango runit logs and
$SOL_DATA_DIR/logs, line-scrubbed;
manifest.json — generation time, version and the file list.
The output directory is created exclusively — it must not already exist. An existing path (a home directory, a project tree, a mounted volume) is refused with a non-zero exit and is never written into or deleted. On a scan refusal or any write failure, only the files created by that run are removed.
A secret scan runs before the bundle is published: if any collected secret
value, credential-bearing URL userinfo, value-shaped token (for example
sk-…, ghp_…, AKIA…, xoxb-…, a JWT) or private-key block is found,
the partially written bundle is removed and the command refuses
(non-zero). Never attach a bundle that contains a secret you did not
expect.
zerg support-bundle /tmp/zerg-support
zerg support-bundle /tmp/zerg-support --log-dir /var/log/runit/zerg-sol
Shell Completion
zerg completion <shell>
Output shell completion script for bash, zsh, or fish.
zerg completion bash > /etc/bash_completion.d/zerg
zerg completion zsh > ~/.zfunc/_zerg
zerg completion fish > ~/.config/fish/completions/zerg.fish
The <shell> argument is optional: with no argument the script is chosen
from $SHELL (fish/zsh detected, bash otherwise). An unknown shell
errors (Unknown shell: … (supported: bash, zsh, fish)) and exits 1.
The generated scripts mirror the parser grammar: flags
are offered PER COMMAND from the parser’s closed grammar (with the
documented short forms — -m, -s, -t, -v, -n, -e) instead of
the old every-flag-on-every-command dump; --bearer/--token/--api-url/
--profile/--format complete ONLY before the command word (where the
parser accepts them); the universal set (--json, --quiet, --help,
--version, …) completes everywhere.
Air-Gapped Deployment
For offline environments, deploy WILDZERG (the on-prem variant) via the
Wild blueprint — see wild/AGENTS.md (§“CD Build Execution”) and
wild/scripts/provision/. The legacy
deployment/infra/scripts/setup.sh --air-gapped was archived with the old
on-host deploy model and no longer exists.
Security: credential transport
The CLI refuses to send credentials (bearer tokens, login passwords) over
plaintext http:// to a remote host. The accepted transport matrix
(for the initial request):
| Target | Allowed with credentials |
|---|---|
https:// | yes (default) |
http:// strict loopback (localhost, 127.0.0.0/8 with valid octets, [::1], [::ffff:127.0.0.1]) | yes (local dev) |
http:// remote host | only with ZERG_ALLOW_INSECURE=1 (loud warning printed) |
userinfo-bearing URL (http(s)://user@host) | never — refused even with ZERG_ALLOW_INSECURE=1 unless the real host is loopback |
The loopback classifier is exact: 127.evil.com, the
userinfo trick (http://127.0.0.1@evil.com) and arbitrary bracketed IPv6
literals ([2001:db8::1], [::ffff:8.8.8.8]) are all refused — the
Pattern matcher accepted them.
Authenticated requests additionally walk redirects manually instead of
letting curl auto-follow (curl replays every header verbatim to the
redirect target). Per-hop rule: the Authorization
header is stripped on any cross-origin hop — a change of host OR scheme
with one warning per request on the first strip. The former loopback
exception is closed: a remote 302 to localhost used to deliver
the bearer to the loopback target; it now strips like any cross-origin hop.
Same-origin hops (same host AND same scheme) keep the header; a port change
alone is not an origin change.
| Redirect hop (carrying Authorization) | Bearer |
|---|---|
| https → https, same host | kept |
| https → https, cross host | stripped |
| https → http, same host | stripped (scheme change) |
| https → http, cross host (incl. loopback targets) | stripped |
| http → https, same host (upgrade) | stripped (scheme change) |
| http → http, same host | kept |
| http → http, cross host | stripped |
Redirect body policy — browser-default for every
walked request, uniform, with no per-caller opt-in (the
credential_body knob is removed; the chat/stream path is covered by the
same policy, ):
| Redirect | Behavior |
|---|---|
| 301 / 302 / 303 | method drops to GET, body discarded (browser-equivalent) |
| 307 / 308, same origin | method + body preserved (re-POST) |
| 307 / 308, cross-host | refused before any hop-2 request |
| 307 / 308, https→http downgrade | refused before any hop-2 request |
follow_redirects = true on a credential-carrying request is refused
an explicit true used to silently re-enable curl’s
verbatim header replay. The manual walk is the only redirect mode for
authenticated requests; credential-less callers may still pass it.
Capture caps: response-header capture aborts past
256 KiB total / 128 header lines with a loud error (a hostile endpoint
could previously stream unbounded unique headers past the 32 MiB body cap);
SSE streams fail closed when a single line exceeds 1 MiB without a
newline. The header callback receives RAW lines, so obs-fold continuation
lines (>16 KiB permitted by RFC 7230) and interim 1xx header blocks each
count toward both ceilings — a folded-header flood is capped by the same
budget. Lines that do not parse as key: value (status lines,
continuations) are never written into the header map, so an interim block
cannot inject a forged Location.
Proxy bypass for body secrets: every request whose
BODY carries a credential — the login password, a channel-add bot
token/webhook URL, the OAuth code exchange — forces NOPROXY=* in
addition to the manual redirect walk (the pre-fix bypass keyed only on
the Authorization header, so body secrets transited any configured
proxy). Residual: a TLS-terminating (TLS-inspecting) or malicious
proxy can still read any authenticated traffic it terminates — bypassing
the proxy removes the passive-HTTP-proxy exposure (a plain HTTP forward
proxy sees only the CONNECT target); if your network REQUIRES a
TLS-inspecting proxy, that operator is in the credential path by
construction. The transport matrix above (https-or-loopback for
credentials) still applies end to end.
Terminal sanitizer: the human output boundary
(ansi_sanitize/term_safe) strips ESC-introduced sequences AND the
8-bit C1 forms (0x80–0x9F, e.g. 0x9B CSI / 0x9D OSC on a non-UTF-8 or
C1-capable terminal) plus invalid UTF-8 byte sequences; valid multibyte
text round-trips byte-exact. JSON documents (--json) are structural
boundaries: values are JSON-escaped, not C1-stripped — consumers that
render them must sanitize (that is the documented raw-document choice).
Read-side hardening: config.json, the analytics DB
probe, the TOFU pin and the update-dest state file are read through the
protected contract — open(2) with O_NOFOLLOW (a planted symlink is a
typed refusal, never followed) and O_NONBLOCK (a planted FIFO
cannot hang the open), plus regular-file + owner checks where the
platform stat probe exists. Platform gap: the struct-stat layout is
probed only on Linux x86_64 — on macOS and other architectures the
regular-file/owner layer is skipped and the O_NOFOLLOW/O_NONBLOCK
refusals are the only active read-side layers (documented residual).
Exit codes & response envelopes
Every command exits by the documented contract — scripts gate on the exit status, so the status is truth:
| Exit | Meaning |
|---|---|
0 | Success |
1 | The server answered 4xx (client error — bad request, not found, unauthorized), or a 2xx response carried a non-JSON body |
2 | The server answered 5xx (server error / upstream failure) |
2 | An SSE stream carried the typed server terminal event: stream_error — the stream-side server-error class; the frame’s reason is printed on stderr |
3 | The request never completed — connection refused, curl abort, transfer truncation, or a local credential-transport refusal |
Before every failure exited 0 or 1 indiscriminately: a 404/500
whose body was valid JSON without an error key parsed as a success
table. Streaming commands classify the same way — the SSE readers
return the status class they captured (4xx → 1, 5xx → 2, transport/
truncation → 3), plus the typed stream_error terminal (exit 2; a
defensive arm — no Sol route the CLI streams emits it today).
Paginated envelope. Sol answers every paginated list route with
{"items": [...], "total": N, "limit": …, "offset": …, "page": …, "total_pages": …, "has_more": …}. The CLI unwraps this envelope once,
inside the API layer — list commands (list, ps, agents, catalog,
circuits, channels, skills, skill-search, schedule list,
zmq-workers, plugin-workers, spawn, workflow list,
bg-workers list) render their rows directly. --json output stays
Envelope-truthful: it prints the full {items, total,...} wire shape,
never a bare array.
Luna completion entry
client/run --complete is Luna’s FIM entry for editor ghost text. It is not
a zerg CLI command, and it never calls a lane endpoint or ollama — the only
network surface is Sol’s POST /v1/completions.
stdin: one JSON object {"prefix", "suffix", "model?", "max_tokens?", "stop?", "temperature?"}
stdout: raw completion text (no JSON envelope; no added newline)
stderr: typed error, non-zero exit (H1 silent-failure contract)
Endpoint/credential: ZERG_API_URL (full base) wins; otherwise
SOL_HOST/SOL_HTTP_HOST + SOL_HTTP_PORT (loopback http, off-loopback
https). Bearer: SOL_TOKEN → SOL_API_KEY → MANGO_TOKEN; the token is
never logged. Plaintext credential transport is loopback-only unless
ZERG_ALLOW_INSECURE=1.
Empty prefix: no request, no output, exit 0.
Truncation: prefix keeps its tail, suffix its head (defaults 8000/1000
bytes, ZERG_COMPLETE_MAX_PREFIX_BYTES/_SUFFIX_BYTES, 0 = unlimited);
cuts never split a UTF-8 codepoint.
Stop/overlap: stop (string or array of at most 4 strings) cuts the
completion and the stop text is not returned; a completion tail duplicating
the suffix head is removed; CRLF is normalized to LF; trailing whitespace is
trimmed. max_tokens is clamped to the server ceiling (1024).
Refusals: HTTP/auth/transport failures are typed on stderr with a
non-zero exit. A server refusal code is preserved (e.g. fim_unsupported
for a non-FIM model, lane_warming on a cold lane).
Options: --model/-m MODEL (otherwise request model, then
ZERG_COMPLETE_MODEL, then the Sol default) and --max-tokens N.
Sol-less hosts: typed refusal until the standalone leg lands; there is
no client-side lane/ollama fallback.
printf '{"prefix":"def add(a, b):\\n ","suffix":""}' | client/run --complete
Luna TUI Slash Commands
These commands are available inside the Luna TUI (prefixed with /).
Agent Modes
| Command | Description |
|---|---|
/modes | List all available agent modes |
/mode <name> | Switch to a specific mode |
/build | Switch to Build mode |
/plan | Switch to Plan mode |
/explore | Switch to Explore mode |
/review | Switch to Review mode |
/general | Switch to General mode |
/menu, /m | Open mode selection menu |
Permission Modes
| Command | Description |
|---|---|
/auto | Enable AI classifier permission mode |
Session
| Command | Description |
|---|---|
/new | Start a new session |
/compact | Manually trigger context compaction |
/compact --from <id> | Compact messages before the specified entry |
/compact --up-to <id> | Compact messages up to and including the specified entry |
/copy | Copy last assistant message to clipboard |
/copyall | Copy entire session to clipboard |
/export [path] | Export session to file |
/delete | Delete the current session’s whole corpus (primary, rotations, trajectory, SQLite rows, index entry) and start a fresh session |
/gc | Dry-run the opt-in session-corpus GC (lists eligible sessions; deletes nothing) |
/gc run [DAYS] | Apply the session-corpus GC older than DAYS (default: session_gc.max_age_days). Explicit run is required |
/tree | Show session branch tree |
/branch [name] | Create a session branch |
/switch <name> | Switch to a session branch |
Display
| Command | Description |
|---|---|
/clear | Clear chat display |
/theme <name> | Switch color theme (default, onedark, solarized, monokai) |
/thinking <level> | Set thinking display (none, minimal, low, medium, high, xhigh) |
/keymaps | Display all key bindings |
Information
| Command | Description |
|---|---|
/status | Show agent status (model, mode, cost, iterations) |
/cost | Show cost tracker summary |
/model [name] | Show or switch model |
/history | Show session history |
/mcp | Show MCP server status |
/tools-list | List all available tools (built-in + discovered) |
/tools-reload | Rescan workspace for custom tools |
Control
| Command | Description |
|---|---|
/interrupt | Interrupt current agent execution |
/help, /h | Show help |
/quit, /exit, /q | Exit Luna |