# cmdop command line

`cmdop` is the program that keeps a machine online for your agents. These are the commands a
person runs on the machine.

**In short:** `cmdop run` connects and stays connected. `cmdop control status.get` asks the running program how
it stands. `cmdop config set <key> <value>` changes `machine.json`.

## Global options

| Option | Meaning |
|---|---|
| `--config-dir <path>` | Use another folder for the machine's identity and data. Default: `~/Library/Application Support/cmdop` on macOS, `~/.config/cmdop` on Linux. |
| `--version` | The version and the build kind, for example `0.1.0 (release)`. |
| `--help` | Help for `cmdop` or any command. |

The first command a person types on a release build shows the terms of use and asks to accept
them, once. `cmdop run` and `cmdop service` never ask. With no terminal, set
[`CMDOP_ACCEPT_AGREEMENT`](https://docs.cmdop.ai/reference/config/environment.md) instead.

## `cmdop key`

Prints this machine's public key, and creates it on first use. The key identifies the machine: the
CMDOP team admits it to your contour. It is not a secret.

## `cmdop pair`

```bash
cmdop pair <client-key> [--note <text>]
```

Pairs a client (an SDK key, the Mac app) with this machine. Calls from a paired client are
encrypted end to end, the server cannot read them, and they may use the whole ceiling, not only its
`unpaired_risks` part ([`ceiling.json`](https://docs.cmdop.ai/reference/config/ceiling-json.md)). `--note` tells clients
apart.

## `cmdop unpair`

```bash
cmdop unpair <client-key>
```

Removes a paired client. Its calls fall back to the `unpaired_risks` part of the ceiling.

## `cmdop pairs`

Lists the paired clients with their notes.

## `cmdop config`

Shows or changes [`machine.json`](https://docs.cmdop.ai/reference/config/machine-json.md).

| Command | Does |
|---|---|
| `cmdop config show [--request key=value]…` | Prints `machine.json` and the policy in effect, with where each value came from. `--request` tries a value for this run only and writes nothing. |
| `cmdop config set <key> <value>` | Sets one key: `server`, `name`, `daemon.autostart`, `daemon.restart`, `gui.enabled`, `gui.autostart`, `gui.launch`, `service.scope`, `service.manager`. A running program reads it at its next start. |
| `cmdop config migrate [--dry-run]` | Rewrites an old `machine.json` in the current shape, keeping a backup. `--dry-run` prints the result and writes nothing. |
| `cmdop config migrate --rollback <backup>` | Restores a backup a migration made. |

## `cmdop control`

```bash
cmdop control <call> ['<json args>']
```

Asks the running program and prints JSON.

| Call | Answers |
|---|---|
| `status.get` | the link state (`connecting`, `up`, `down`, `refused`, `failed`), the machine, the version, whether it is paused, the OS permissions, and `blocking`: what stops it from working and what to do |
| `permissions.list` | the OS permissions the machine has and still needs |
| `control.state` | whether the machine is paused, and who controls the screen |
| `control.pause` | pauses the machine ([pause a machine](https://docs.cmdop.ai/guides/pause-and-presence.md)) |
| `ceiling.get` | the [ceiling](https://docs.cmdop.ai/reference/config/ceiling-json.md) it enforces, including the classes for unpaired calls and the app lists |
| `pairs.list` | the paired clients |
| `audit.tail '{"limit": 20}'` | the latest screen and control actions |
| `journal.tail '{"kind": "call"}'` | the latest entries of the machine's own record |
| `config.get` | `machine.json` as the program loaded it |
| `selftest` | checks that the screen and input tools work on this machine, one row per check |
| `subscribe` | prints events until the program stops |

Exit codes: `0` answered, `2` the program is not running, `3` the call needs a person at the
machine (for example `control.resume`; use the CMDOP app).

## `cmdop run`

```bash
cmdop run [--server <url>] [--name <name>] [--ca-file <pem>] [--keep-sessions | --no-sessions]
```

Connects to the server and stays connected. On a Mac the CMDOP app starts it at login.

| Option | Meaning |
|---|---|
| `--server <url>` | `wss://<contour>.cmdop.ai/ws/machine`. Default: `server` in `machine.json`. |
| `--name <name>` | How the machine shows on your page. Default: `name` in `machine.json`, else the host name. |
| `--ca-file <pem>` | Extra trusted root certificates, for a server with its own certificate authority. |
| `--keep-sessions` | Keep a copy of every Claude Code and Codex session file, so a session the vendor deletes is not lost. The copy costs the file's size once the vendor deletes it; CMDOP never deletes it. |
| `--no-sessions` | Do not index Claude Code and Codex sessions at all. |

When the server refuses the machine's key, the program stays up and dials again every 60 seconds.

## `cmdop service`

Used by the installer and the updater to set up and update the service that starts `cmdop run`.
You do not run it by hand.
