# machine.json

Where a machine connects, the name it shows, and how its program starts. Change it with
`cmdop config set`; what agents may do lives in [`ceiling.json`](https://docs.cmdop.ai/reference/config/ceiling-json.md).

**In short:** `cmdop config set server wss://<contour>.cmdop.ai/ws/machine`, `cmdop config set name <name>`,
then `cmdop config show` to see what is in effect.

## Where it lives

The machine's config folder: `~/Library/Application Support/cmdop/machine.json` on macOS,
`~/.config/cmdop/machine.json` on Linux. A running program reads it at its next start.
`cmdop run --server` and `--name` override it for one run.

## Keys

| Key | Type | Default | Meaning |
|---|---|---|---|
| `schema_version` | integer | `1` | The shape of the file. `cmdop config migrate` rewrites an older file. |
| `server` | string | none | `wss://<contour>.cmdop.ai/ws/machine`, the address your page shows. |
| `name` | string | the host name | How the machine shows on your page and to agents. |
| `daemon.autostart` | boolean | `true` | Start the machine program on its own: at login, or at boot for a system service. |
| `daemon.restart` | `on_failure` \| `never` | `on_failure` | Restart it after it fails. |
| `gui.enabled` | boolean | `true` | Allow the CMDOP app (menu bar and window) on this machine. |
| `gui.autostart` | boolean | `true` | Start the app when you log in. |
| `gui.launch` | `when_daemon_ready` \| `login` \| `manual` | `when_daemon_ready` | When the app opens. |
| `service.scope` | `user` \| `system` | `user` | Run as your user's service or as a system service. |
| `service.manager` | `auto` \| `launchd` \| `systemd` \| `windows` | `auto` | Which service manager starts it; `auto` picks the system's own. |

Each policy key can also be set for one run with an [environment variable](https://docs.cmdop.ai/reference/config/environment.md).

## Example

```json
{
  "schema_version": 1,
  "server": "wss://<contour>.cmdop.ai/ws/machine",
  "name": "build-box",
  "daemon": { "autostart": true, "restart": "on_failure" },
  "gui": { "enabled": false, "autostart": false, "launch": "manual" },
  "service": { "scope": "user", "manager": "auto" }
}
```

## Errors

- A key the program does not know is an error: `machine.json` is read strictly, so a typo stops
  the start instead of being ignored. Fix the key, or set values with `cmdop config set`.
- `cmdop config migrate` keeps a backup of the file it replaces; `--rollback <backup>` restores it.

## Related

[cmdop command line](https://docs.cmdop.ai/reference/cli.md#cmdop-config) · [Environment variables](https://docs.cmdop.ai/reference/config/environment.md)
