# Hecaton CLI

Use the `hecaton` command to drive Hecaton from a terminal or a CI job. The npm package is `@hecaton-io/cli` and requires Node.js 24.

## Connect

Install from npm when the package is available. Replace `<version>` with the published version you want to use.

```sh
npm install --global '@hecaton-io/cli@<version>'
```

On your computer, run `hecaton login` and approve **Drive workspaces** in your browser. `hecaton logout` revokes the login on this computer and removes its local credentials. You can also revoke access in **Settings → Connected tools**.

On a machine without a browser, store an [API token](tokens.md) in `HECATON_TOKEN`, or supply it on standard input with `--token-stdin`. The CLI tries standard input when requested, then the environment, then the local login. Keep credentials out of arguments and logs. The default origin is `https://api.hecaton.io`. Set `HECATON_API_ORIGIN` to an HTTPS origin without `/v1` for another environment.

## Commands

| Command                         | Actions                                                                                         |
| ------------------------------- | ----------------------------------------------------------------------------------------------- |
| `hecaton workspace`             | `create`, `list`, `get`, `send`, `messages`, `turn`, `results`, `sleep`, `wake`, `archive`      |
| `hecaton question`              | `list`, `answer`                                                                                |
| `hecaton project`               | `list`                                                                                          |
| `hecaton job`                   | `list`, `create`, `get`, `update`, `delete`, `runs`, `pause`, `resume`, `run`                   |
| `hecaton webhook`               | `list`, `create`, `get`, `update`, `delete`, `rotate-secret`, `test`, `deliveries`, `redeliver` |
| `hecaton events <workspace-id>` | Stream workspace events, optionally from `--last-event-id <id>`                                 |
| `hecaton me`, `hecaton openapi` | Read the calling identity or the anonymous API contract                                         |

Run `hecaton <command> --help` for arguments and options. Paginated commands accept `--limit` and `--cursor`. Commands that take a JSON body accept `--body-file <path>` or `--body-file -` if standard input is free. See the [API reference](api.md) for bodies and required permissions. Commands that require an idempotency key generate one automatically. Pass `--idempotency-key <key>` to reuse it across calls. Use `--yes` for an authorized archive from a script.

## JSON output and exit codes

The CLI emits JSON when standard output is redirected or when you pass `--json`. A stream emits one JSON object per line. With `--wait`, workspace creation and send print the admission first, then events. A successful creation with `--wait` ends with the result document. Errors in JSON mode include `code`, `message` and `requestId` (which can be null).

| Exit code | Meaning                                                         |
| --------- | --------------------------------------------------------------- |
| 0         | The command succeeded or the requested turn completed.          |
| 1         | Command or API error.                                           |
| 2         | Invalid usage or missing archive confirmation.                  |
| 3         | Missing or invalid authentication, or insufficient permissions. |
| 4         | An agent question is pending.                                   |
| 5         | The turn failed or was stopped.                                 |
| 124       | The deadline expired.                                           |

`--wait` defaults to 1,800 seconds. Override it with `--timeout <seconds>`. You can also bound `hecaton events` with that flag. After a timeout, use the workspace ID to read its state or resume events. The CLI's timeout stops the wait on your machine, and the workspace continues its work.

See examples in [GitHub Actions](github-actions.md), [GitLab CI](gitlab-ci.md) and [Local agent](local-agent.md).
