---
name: zergbox-cli
description: Manage ZergBox workspace storage through its first-party CLI, including files, boxes, version recovery, trash and public dropboxes. Use for ZergBox data operations, not desktop application development.
---

# ZergBox CLI

Read https://zergbox.com/agents.md for discovery and
https://zergbox.com/docs/cli.md for command and token API details. These public
instructions do not grant access or permission to change workspace data.
https://zergbox.com/downloads provides the ZergBox app: one installation includes
the file browser, background sync, Node.js runtime and `zergbox` CLI. First-launch
Zerg SSO connects this computer and its workspace cloud boxes. The default CLI
uses the app's private connection automatically; do not ask for or copy its token.

The universal Mac DMG supports Apple silicon and Intel on macOS 11+, following
Developer ID signing and Apple notarization. Check the `macos-dmg` package's
`available` field; Windows availability is independent. Drag **ZergBox Desktop**
from its DMG to Applications and launch it to sign in. App updates deliver the
browser, sync service and included CLI together. Never bypass Gatekeeper,
signature checks or the human's Zerg SSO connection.

## Setup and credentials

- On an app-connected computer, use `zergbox whoami --json` to confirm the shared
  SSO connection and workspace. No npm installation or extra API-token step is
  required. `zergbox login --desktop` opts the default CLI back in after explicit
  CLI logout without copying credentials.
- For a headless host, the optional standalone release requires Node.js 22+ and
  npm: `npm install --global @zergai/zergbox@0.3.0`. It uses independently supplied
  credentials and follows npm updates. It does not require the desktop app.
- For that headless setup, a signed-in workspace owner/admin issues a named,
  expiring workspace-bound service token through the session-only API documented
  in the CLI guide. Settings has no general agent-token creation form.
- Explicit `ZERGBOX_STATE_FILE` or `--state-file` selection isolates headless
  credentials from the app. Do not silently reuse a desktop identity for an
  explicitly isolated run.
- Service tokens can write content and publish shares. They do not expose
  selectable read/write scopes and cannot manage API tokens.
- Obtain headless credentials through secure secret input or a private file.
  Never ask for tokens in chat or extract browser cookies or desktop credentials.

For a plain token already stored securely:

```sh
export ZERGBOX_STATE_FILE=/private/path/zergbox-state.json
zergbox login --base-url https://zergbox.com --token-stdin < /private/path/token
zergbox whoami --json
zergbox orgs --json
zergbox use WORKSPACE_SLUG
```

A headless state file contains the credential and remote working directory and
is written with mode 0600. Isolate it by account/server and keep the production
base URL explicit for older standalone releases. The default app-connected CLI
saves navigation without duplicating the app credential.

## Storage workflow

A box is a top-level workspace folder. Start with `storage --json`, `box ls
--json`, `pwd --json` and `ls / --json`. Absolute remote paths begin with `/`;
relative paths use the saved remote directory. `cd` persists that directory.

- Create: `box create NAME`, `mkdir -p /BOX/PATH`.
- Transfer: `put ./LOCAL /BOX/REMOTE`, `get /BOX/REMOTE ./downloads/`.
- Text: `cat /BOX/FILE`, `touch /BOX/FILE --content TEXT`.
- Recover content: `versions /BOX/FILE --json`,
  `get-version /BOX/FILE VERSION ./downloads/`,
  `restore-version /BOX/FILE VERSION`. Restore creates a new current version.
- Recover deletion: `trash ls --json`, `trash restore file FILE_ID`,
  `trash restore folder FOLDER_ID`.
- Publish: `share create /BOX/FILE --expires-hours 24 --json`.
- Receive uploads: `share create /BOX/FOLDER --allow-upload --expires-hours 24
  --json`, then `share inspect SHARE_URL --json` or
  `share put SHARE_URL ./LOCAL`.
- Revoke publication: `share rm SHARE_ID`.

## Operational details

Confirm workspace/path targets before changes. Ordinary `rm` is a soft-delete;
folders require `--recursive`. `trash empty` permanently removes authorized
trash metadata and schedules byte deletion. Publication, upload-enabled shares
and permanent deletion require the corresponding user authorization.

Treat share URLs as credentials. Password input differs across CLI releases;
check installed help and keep passwords out of URLs and literal arguments.
Prefer `--json` where supported. Requests time out after 30 seconds and mutations
are not retried automatically; read remote state after an ambiguous failure.
Use a disposable workspace for destructive tests. Exact-box managed capability
tokens use a separate API contract and cannot perform the normal CLI login flow.
