docs · reference
CLI reference#
This page lists every hekma command in Hekma 0.11.0 with its flags, a short example and the errors you are most likely to hit, and the commands on Hekma's main branch, each marked Unreleased: after 0.11.0. Results go to stdout and notes and errors go to stderr, so --json output is always safe to pipe. For the reasoning behind a command, follow the links to the guides.
The hkm binary is the same program under a shorter name; every example works with either.
Commands at a glance#
| Command | What it does |
|---|---|
hekma agent register | Add an agent to the fleet from a built-in kind or an adapter.toml. |
hekma agent list | Show every agent with its state, supervision, budget and usage. |
hekma agent show | Show one agent's capabilities and runtime status. |
hekma agent usage | Show token and cost totals for one agent or the whole fleet. |
hekma agent start | Start an agent, for this command only or detached. |
hekma agent stop | Stop an agent: graceful first, then forced. On main (Unreleased: after 0.11.0), also a Run or a Selector's set. |
hekma agent pause / resume | Suspend and wake a running agent. On main (Unreleased: after 0.11.0), also a Run or a Selector's set. |
hekma agent drain (Unreleased: after 0.11.0) | Stop new work, wait a bounded time for the agent to go idle, then stop it. |
hekma agent send | Write a line to an agent's input (one prompt turn for ACP agents). |
hekma agent logs | Print an agent's captured output, optionally following it. |
hekma agent remove | Remove an agent from the fleet. |
hekma agent memory attach | Give an agent a memory backing. |
hekma agent memory detach | Remove an agent's memory backing (its files stay). |
hekma agent config set | Set one config key on an agent. |
hekma agent config get | Read an agent's effective config and where each value came from. |
hekma agent governance-vectors (Unreleased: after 0.11.0) | Print the governance conformance vectors and their checksum. |
hekma run open / close / show (Unreleased: after 0.11.0) | Open and close child Runs, and show any Run. |
hekma run keys / revoke-keys (Unreleased: after 0.11.0) | List a Run's credentials by token id, and revoke them. |
hekma ps (Unreleased: after 0.11.0) | List the Runs that need you, newest first. |
hekma label set / remove (Unreleased: after 0.11.0) | Bind and unbind labels on Runs. |
hekma budget show / set (Unreleased: after 0.11.0) | Read and set the limits of Runs. |
hekma policy list / show / create / change / delete (Unreleased: after 0.11.0) | Manage standing limits for every Run a Selector matches. |
hekma self-update | Update the hekma binary through the channel you installed it with. |
hekma serve (Unreleased: after 0.11.0) | Run a long-lived host that supervises a state directory. On main it also serves the CLI's writes, and a non-loopback --listen needs --tls-cert and --tls-key. See Run Hekma as a service. |
Every agent command takes the agent's name as its first argument; on main (Unreleased: after 0.11.0) stop, pause, resume and drain also take a run id or --selector. Names use lowercase letters, digits, - and _, and start with a letter or digit; a bad name exits with code 2.
Every command opens the engine for as long as it runs and closes it when it exits. That is why commands print a line such as [hekma] NAME: adopted from a previous engine ... while a detached agent is running: the command found the agent and supervises it until the command exits. Supervision and detached runs explains what this means in practice. On Hekma's main branch this changes: writes go through a local Service Host and reads open the state read-only (next section).
How the CLI reaches the Service Host#
Unreleased: after 0.11.0. This section describes Hekma's main branch. In 0.11.0 each command runs the engine itself, as described above.
One process owns a state directory: the Service Host, hekma serve. Every command that writes is one call to that host's local endpoint: register, remove, start, stop, pause, resume, drain, send, config set, memory attach and memory detach, and also hekma run open and close, hekma run revoke-keys, hekma label set and remove, hekma budget set and hekma policy create, change and delete. The command finds the host through control.json in the state directory. When no host serves the directory, the first write starts one in the background (hekma serve --autostart, its output appended to serve.log in the state directory) and waits up to 10 seconds for it. Commands running at the same time share that one host.
Commands that only read (list, show, usage, logs, config get, governance-vectors, hekma run show, hekma run keys, hekma ps, hekma budget show and hekma policy list and show) open the state database read-only and never start a host, with one exception: a state.db left at an older schema by an earlier Hekma makes the read start the host, which upgrades the database, and then read again. config get --reveal resolves secrets in the command itself. On a fresh machine, hekma agent list prints the empty-fleet hint and creates nothing.
What this means day to day:
Agents outlive the terminal. A started agent runs under the host, not under the command. It stays supervised (crash detection, budget enforcement, events) after the command and its terminal exit, until
hekma agent stopor the host's own shutdown.startsays so:$ hekma agent start worker ✓ Started Agent Instance worker running • note: the agent runs under the local Service Host (pid 19918) and keeps running after this command exits; stop it with: hekma agent stop workerThe background host leaves on its own. It ignores SIGHUP, so closing the terminal does not end it. It drains and exits once no agent is
starting,running,pausedorstoppingand no command has reached it for 30 seconds, or when its state directory is deleted. An explicithekma servenever exits when idle.Messages and exit codes are unchanged. Each command prints the engine's errors exactly as before, and the engine's notes raised during a write (a start's delivery note, an adoption note) still appear on the command's stderr. Notes the host raises on its own, such as crash and liveness diagnostics, go to the host's output:
serve.logfor a background host. A host that cannot be found or started exits with code 1, and the error namesserve.log.The agents' environment. A background host inherits the environment of the command that started it and passes it to the agents it starts, as the CLI always did, so
export KEY=…; hekma agent start workerkeeps working in that shell.secret:NAMEreferences resolve in the host (its environment, thensecrets.toml). A variable you export after the host started does not reach it: restart the host to pick it up, by stopping its agents and letting it exit, or by ending its process (control.jsonnames its pid). An explicithekma servekeeps its child-environment allowlist.A host from another build, still running after an upgrade, is used with one note on stderr naming both versions. Restart it to match.
Reads never write. When
listorshowfinds arunningorpausedagent whose process is gone (its host and the agent were killed, or the machine went down), it shows the agent asfailed, with a cause naming the pid, keeps the stored state in the JSON fieldrecorded_state, and says so on stderr. The next write's host records the change:• note: worker: its process is gone, so it is shown as failed although the record still says running (reads write nothing; the next hekma write records it). Start it again with: hekma agent start worker
A control.json left behind by a host that crashed is harmless: the next write finds the host gone, starts a new one, and that host adopts the agents that survived.
hekma agent register <name> (--kind <kind> | --manifest <path>)#
hekma agent register <NAME> --kind <KIND>
hekma agent register <NAME> --manifest <DIR-OR-FILE>Registers a new agent under a name that is unique in the fleet and creates its Agent Home. Hekma validates the adapter first: an adapter with no supported capability or no metering source is rejected and nothing is written. On success it prints the Agent Home path and the agent's capability declaration for your OS.
| Argument or flag | Meaning |
|---|---|
<NAME> | The new agent's name. |
--kind <KIND> | A built-in kind: acp, hermes (deprecated) or mock. See Supported agents. |
--manifest <PATH> | A directory holding adapter.toml, or the file itself. See Adapter manifest. |
Give exactly one of --kind and --manifest.
hekma agent register worker --manifest /Users/you/agents/worker✓ Registered Agent Instance worker (worker)
/Users/you/Library/Application Support/ktesio/agents/worker
▸ Capabilities for worker (OS: macos) (1 row)
Capability Support (curren…
──────────────────────────────
pause guaranteedHekma copies the manifest's launch command at registration. If you edit adapter.toml later, remove and register the agent again for the change to apply. Hekma also reads the file again at every start for its config mappings, from the path you gave, so register with an absolute path.
| Error | Exit code |
|---|---|
| The name is taken, or is not a valid name | 2 |
Unknown --kind | 2 |
No adapter.toml at the --manifest path | 3 |
| The manifest is invalid, unreadable, or targets another contract major version | 1 |
| The adapter declares no capabilities or no metering source | 1 |
Guides: Run an ACP agent, Bring your own agent.
hekma agent list [--json]#
hekma agent list [--json]Shows every agent in the fleet as a table, followed by a fleet total line.
| Flag | Meaning |
|---|---|
--json | Print the fleet as one JSON document instead. See JSON output. |
$ hekma agent list
▸ Fleet (1 row)
Name Kind State Supervision Restarts Budget (tok, est. $) Usage (tok, est. $) Agent Home
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
worker worker running detached 0 cum 3000/6000 tok (pause) in 2400 / out 600 / cac… /Users/you/Libr…
Fleet total: in 2400 / out 600 / cached 800 · ≈ $0.01 (estimated)| Column | What it shows |
|---|---|
| State | The agent's lifecycle state. |
| Supervision | detached, session, or — when no live process is recorded. See supervision. |
| Restarts | Consecutive restarts made by the restart policy. |
| Budget | Remaining over limit for each budget scope, then the breach action, for example cum 3000/6000 tok (pause). — means no budget. |
| Usage | Cumulative input, output and cached tokens from the usage ledger, plus an estimated cost when a rate is set. |
Cells are cut to fit the terminal; widen it (or set COLUMNS), or use --json. With an empty fleet the command prints a hint to register an agent and exits 0. The metering source is not a column; read it from show, usage or --json.
On Hekma's main branch (Unreleased: after 0.11.0), session means the agent lives as long as the engine holding it, which for a CLI start is the local Service Host, and list never writes: an agent whose process is gone shows as failed until the next write records it.
hekma agent show <name> [--json]#
hekma agent show <NAME> [--json]Shows one agent: its capability declaration for your OS, then its runtime status (state, restart policy and count, budget, usage, estimated cost, metering source and supervision). A failed agent also gets a Failed cause line, and an ACP agent gets an ACP context usage row.
| Flag | Meaning |
|---|---|
--json | Print the status as one JSON document. See JSON output. |
$ hekma agent show worker
▸ Capabilities for worker (OS: macos) (1 row)
Capability Support (curren…
──────────────────────────────
pause guaranteed
▸ Runtime status for worker (8 rows)
Field Value
──────────────────────────────────────────────────────────────────
State failed
Restart policy on-failure
Restart count 0
Budget cum 4500/6000 tok (pause)
Usage (tokens) in 1200 / out 300 / cached 400 · $0.01 (estimat…
Cost (estimated) $0.01 (estimated)
Metering source self-reported
Supervision —
• Failed cause: orphan not found on engine restart (process pid 65596 is gone or was reused); last known: no prior cause recordedThat failed cause is what you see after a plain start whose command has exited: the agent stopped with the command, and the next command recorded it as failed. See start.
On Hekma's main branch (Unreleased: after 0.11.0):
- A plain
startkeeps the agent running under the Service Host, so this cause no longer follows it. When the host and the agent are both gone,showreadsfailedwith a cause that beginsprocess pid N is gone (not recorded yet: the next hekma write reconciles the row to failed)and ends with the last cause recorded, and writes nothing. - The tables no longer cut a header or a value they have room for: the capability header reads
Support (current OS)in full, and the Value column grows with the terminal up to its longest cell. The width comes fromCOLUMNS, else the terminal, else 80 columns when stdout is not a terminal (79 on Windows), between 40 and 132. The same applies tousage NAMEandconfig get;listkeeps its compact layout.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
hekma agent usage [<name>] [--json]#
hekma agent usage [NAME] [--json]With a name, shows that agent's tokens over its whole life (cumulative) and for its current run, the estimated cost of each, and its metering source. Without a name, shows the fleet total. The numbers are the ones list and show print, read from the same ledger.
| Argument or flag | Meaning |
|---|---|
[NAME] | The agent to report on. Omit it for the fleet total. |
--json | Print one JSON document. See JSON output. |
$ hekma agent usage worker
▸ Usage for worker (5 rows)
Field Value
──────────────────────────────────────────────────
Cumulative tokens in 2400 / out 600 / cached 800
Cumulative cost $0.01 (estimated)
Current-run tokens in 1200 / out 300 / cached 400
Current-run cost $0.01 (estimated)
Metering source self-reportedCached tokens are part of the input count, never added on top. Costs appear only when a rate is set and are always labelled estimates; with no rate the cost reads —. When some agents have usage but no rate, the fleet cost is a lower bound and says how many agents it left out.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
Guides: Meter token usage, Budgets and cost.
hekma agent start <name> [--detach]#
hekma agent start <NAME> [--detach]Starts a registered, stopped or failed agent and prints its new state, running. Before launching, Hekma resolves the agent's config and secrets and writes the effective config (secrets masked) to effective-config.json in the Agent Home.
| Flag | Meaning |
|---|---|
--detach | Keep the agent running after this command exits. |
Without --detach, the agent belongs to this command, and the command exits as soon as the agent is up. Hekma says so:
$ hekma agent start worker
✓ Started Agent Instance worker
running
• note: the started process is supervised only for this engine session and stops when this command exits; start it with --detach to keep it running across commands.So a plain start from a terminal is useful only to check that an agent launches: the agent stops a moment later, and the next command marks it failed with "orphan not found on engine restart". To keep an agent running, add --detach:
$ hekma agent start worker --detach
✓ Started Agent Instance worker
running
• note: detached: the agent keeps running after this command exits, and the next `hekma` command re-adopts it. Until then it is NOT supervised: no crash detection, no budget enforcement, and no usage/event delivery happen between commands (supervision is command-scoped).A detached agent is supervised only while some hekma command runs, and usage it reports between commands is not counted later. Keep hekma agent logs NAME --follow running to supervise it continuously; Supervision and detached runs shows the pattern. A detached agent also starts with stdin closed, so an agent that reads stdin exits at once and the start ends failed.
Unreleased: after 0.11.0. On Hekma's main branch every start runs under the local Service Host, so a plain
startkeeps the agent running and supervised after the command exits (the note in that section).--detachkeeps its engine meaning: the agent also survives the host's exit, and the next host adopts it. Between a host's exit and that adoption there is no crash detection, no budget enforcement and no usage or event delivery:• note: detached: the agent's process is not tied to the local Service Host (pid 22226) and keeps running even if that host exits. While the host runs it is supervised; after a host exit the next hekma command's host re-adopts it, and until then there is no crash detection, no budget enforcement and no usage/event delivery. Stop it with: hekma agent stop worker
--detachon anengine-observedagent is still refused with code 5: its metering listener lives in the host. Each start opens a new Run with a run id; a Restart Policy relaunch after a crash keeps the same Run, so per-run budgets keep counting (see Runs).The readiness gate. When the adapter declares a
[readiness]probe,startwaits, after the launch and any ACP handshake, until the probe passes within itstimeout_ms, and only then recordsrunning. A note on stderr names the probe when the wait begins, and another when it passes. A probe that never passes leaves the agentfailedwith thereadiness-timeoutcause, and the Restart Policy is not consulted. An agent that exits while the probe waits takes the ordinary crash path instead.--detachwaits for the probe too.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
| The agent is already running or paused | 4 |
| A memory attach or detach in another terminal raced this start (nothing launched; retry) | 4 |
--detach on an engine-observed agent (nothing changed) | 5 |
The launch failed and the agent is now failed. This includes the mock kind, which has no launch command, and an acp agent without acp.command | 1 |
A secret:NAME value could not be resolved (nothing changed) | 1 |
hekma agent stop <name> [--timeout <secs>]#
hekma agent stop <NAME> [--timeout <SECS>]
hekma agent stop <RUN_ID|--selector <SELECTOR>> [--timeout <SECS>] [--dry-run] [--yes] [--json]Unreleased: after 0.11.0. On main, stop, pause, resume and drain also take a run id or a Selector: see Selectors on the lifecycle verbs.
Stops a running or paused agent. Hekma asks the process to exit (SIGTERM to its process group on Unix), waits up to the timeout, then kills the whole group. An ACP agent with a prompt turn in progress gets session/cancel first.
| Flag | Meaning |
|---|---|
--timeout <SECS> | Seconds to wait before the forced kill. Default 30; 0 kills at once. |
$ hekma agent stop worker --timeout 3
✓ Stopped Agent Instance worker
stoppedOn Hekma's main branch (Unreleased: after 0.11.0), the Service Host serves windows of 1 to 86400 seconds: --timeout 0 becomes a 1-second window and a value above 86400 becomes 86400, each with a note:
$ hekma agent stop worker --timeout 0
• note: --timeout 0 is served as a 1s window (the stop window is bounded to 1..=86400 seconds)
✓ Stopped Agent Instance worker
stoppedStopping a paused agent on main first wakes a suspended process, so it gets the graceful signal instead of an immediate forced kill.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
| The agent is not running or paused | 4 |
The process could not be confirmed dead after the forced kill (it stays stopping; run stop again) | 4 |
hekma agent pause <name> / hekma agent resume <name>#
hekma agent pause <NAME>
hekma agent resume <NAME>
hekma agent pause <RUN_ID|--selector <SELECTOR>> [--dry-run] [--yes] [--json]
hekma agent resume <RUN_ID|--selector <SELECTOR>> [--dry-run] [--yes] [--json]Unreleased: after 0.11.0. The second pair is on main only: see Selectors on the lifecycle verbs.
pause suspends a running agent and resume wakes a paused one. The result depends on the agent's declared pause capability on your OS: guaranteed really suspends the process (SIGSTOP and SIGCONT on Unix), best-effort records the pause with a note that it is cooperative, and unsupported fails before anything changes.
$ hekma agent pause worker
✓ Paused Agent Instance worker
pausedAn operator pause lasts only while some command holds the agent. On a detached agent, Hekma resumes the process when the pause command exits, and says so:
[hekma] worker: paused detached child resumed at engine release (SIGCONT before the handle was released) — a detached instance is only paused while an engine session holds it; the row is now 'running'A pause caused by a budget breach is different: it holds between commands until you resume or stop the agent. See Budgets and cost.
On Hekma's main branch (Unreleased: after 0.11.0), the holder is the local Service Host, not the command: an operator pause lasts until you resume, or until the host exits, when a detached agent is woken before the host lets it go.
Pause commands (Unreleased: after 0.11.0). When the adapter declares the [lifecycle.pause] and [lifecycle.resume] command pair, pause runs the declared command instead of sending a signal, the same way on every OS and even where the declaration reads unsupported: the agent pauses itself. resume runs the declared resume command only for a pause made that way; an agent frozen by a signal (an operator pause without the pair, or a budget breach) is woken with SIGCONT as before. A budget-breach pause always uses the signal. A command that exits non-zero, cannot start, or runs past 30 seconds fails the verb with exit code 1 and leaves the state unchanged, with the end of the command's stderr in the error. The transitions record the causes pause-cooperative and resume-cooperative, naming the command. An agent paused this way stays paused when its host exits, since there is no frozen process to wake, and stop skips the wake-up signal with a note.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
pause on an agent that is not running, or resume on one that is not paused | 4 |
The agent declares pause unsupported on this OS | 5 |
resume of a paused agent whose declaration now reads unsupported (recover with stop, then start) | 5 |
| A declared pause or resume command failed or timed out (nothing changed; Unreleased: after 0.11.0) | 1 |
hekma agent drain <name> [--timeout-ms <ms>]#
Unreleased: after 0.11.0.
drainis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma agent drain <NAME> [--timeout-ms <MS>]
hekma agent drain <RUN_ID|--selector <SELECTOR>> [--timeout-ms <MS>] [--dry-run] [--yes] [--json]The second form takes a run id or a Selector: see Selectors on the lifecycle verbs.
Stops new work, waits a bounded time for the agent's work in flight to finish, then stops it. drain runs the adapter's declared [lifecycle.pause] command (never a signal), watches the declared [drain] idle_file and the agent's process, then stops the agent through the ordinary stop sequence.
| Flag | Meaning |
|---|---|
--timeout-ms <MS> | How long to wait, from 1 to 600000 milliseconds. It overrides the manifest's [drain] timeout_ms; with neither, the wait is 30 seconds. The bound covers the pause command too. |
Both outcomes exit 0. A drain whose wait completed prints the final state like stop. A drain that ran out of time still stops the agent, says on stderr that the wait did not complete, and records it on the final drain-stopped transition. An agent that exits on its own during the wait ends the wait early, and the drain counts as not completed. A pause command that outlives the bound is killed and leaves no pause-cooperative record; the drain goes on to the stop. An adapter with neither the command pair nor a [drain] section has nothing to wait for, so the drain stops the agent at once:
$ hekma agent drain worker
[hekma] worker: drain has no declared wait — no `[lifecycle.pause]` command and no `[drain].idle_file` — so there is nothing to pause or wait for; stopping directly
✓ Drained Agent Instance worker
stopped| Error | Exit code |
|---|---|
--timeout-ms outside 1 to 600000 | 2 |
| No agent with that name | 3 |
The agent is not running (a paused agent is stopped with stop) | 4 |
| The declared pause command exited non-zero or could not start (nothing changed) | 1 |
The Control API has the same verb, POST /v0/instances/{name}/drain; see Control API.
Selectors on the lifecycle verbs#
Unreleased: after 0.11.0. Selectors on the lifecycle verbs are on Hekma's main branch and ship in the next release; Hekma 0.11.0 takes only an agent's name.
hekma agent stop|pause|resume|drain <NAME|RUN_ID|--selector <SELECTOR>> [--dry-run] [--yes] [--json]
hekma run close <RUN_ID|--selector <SELECTOR>> [--dry-run] [--yes] [--json]hekma agent stop, pause, resume and drain, and hekma run close, take one target or a set (Runs: verbs at scale). stop keeps its --timeout and drain its --timeout-ms.
| Argument or flag | Meaning |
|---|---|
<NAME> | An agent: today's command, unchanged. |
<RUN_ID> | A Run. On the Run that owns an agent's process, the verb is the agent's own; any other Run is refused, naming its depth. A registered agent whose name has an older run id's shape (run-<digits>-<digits>) is read as that agent. |
--selector <SELECTOR> | Every open Run carrying all these labels, bound or caller: key=value[,key=value...]. At most 1000 Runs. |
--dry-run | Show each Run's planned outcome (would-stop, or the refusal and its code), change nothing and start no Service Host. |
--yes | Do not ask before acting on several Runs. |
--json | Print {"schema_version": 1, "verb", "dry_run", "matched", "results": [{"run_id", "outcome", "instance", "error"}]}. See JSON output. |
When a Selector matches more than one Run, the set is listed (run id, CONTROL, STATUS, agent) and you are asked to confirm, for example Stop these 3 Runs? [y/N]. Only a terminal is asked: without one the command is refused (exit 2) unless --yes is given, and stdin is never read.
A child Run's lifecycle verbs act on its model calls, which Hekma cannot hold or reject yet, so a child is refused (exit 4) and the others still act. A child held because its parent is paused is refused naming the parent. Each Run reports its own result, and the exit code is the first failure's, with the count in its message. A Selector that matches nothing is a success with a note.
A set is acted on in one call that carries a set token, so exactly the listed Runs act; a Run that ended in between is its own run-ended refusal. Stops and drains on a set wait out their windows one after another, so the command waits at most 10 seconds plus each Run's bound (capped at 10 minutes), then says it stopped waiting while the acts may still be committing. start and send take no Selector: a Selector matches open Runs, so there is nothing to start, and send carries text to one agent.
| Error | Exit code |
|---|---|
An invalid request, or several matches with no terminal and no --yes | 2 |
| No such Run or agent | 3 |
| Refused by the Run's state or depth (a child Run, an ended Run) | 4 |
hekma agent send <name> <text>#
hekma agent send <NAME> <TEXT>Writes <TEXT> to a running agent's stdin, adding a trailing newline if there is none. For an acp agent, the text becomes one prompt turn: the command returns at once and the reply streams into hekma agent logs. <TEXT> may start with - and is still sent as text; for that reason send has no --help flag.
From the CLI alone, send has no usable target in 0.11.0. send needs the stdin pipe that the starting process holds. An agent started without --detach stops when its start command exits, and a detached agent starts with stdin closed, so a later send fails:
$ hekma agent send sleeper "hello"
✗ Agent Instance 'sleeper' cannot receive input right now: no live stdin pipe is held for this instance in this engine session (an adopted instance has no recoverable pipe; ...). Durable cross-invocation interaction needs a persistent engine session (planned for a future release); within a single `hekma` process/embedding session this works.Sending works from a program that embeds the engine and keeps it open from start to send.
Unreleased: after 0.11.0. On Hekma's main branch
sendgoes through the local Service Host, which holds the input pipe of every agent it started, sosendreaches an agent that a separatestartcommand started:$ hekma agent start echo ✓ Started Agent Instance echo running • note: the agent runs under the local Service Host (pid 22226) and keeps running after this command exits; stop it with: hekma agent stop echo $ hekma agent send echo "hello" ✓ Sent input to Agent Instance echoAn agent the host adopted (after a host restart, or a detached start) still has no input pipe, and
sendto it fails with code 5; stop and start it for a fresh one. The Control API has the same verb,POST /v0/instances/{name}/send.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
| The agent is not running | 4 |
An acp agent already has a prompt turn in progress | 4 |
The agent declares interaction unsupported on this OS | 5 |
| This command holds no input pipe for the agent (the case above) | 5 |
| The agent did not read its input in time; its input stays closed until it is restarted | 6 |
hekma agent logs <name> [--follow] [--json]#
hekma agent logs <NAME> [-f | --follow] [--json]Prints the agent's captured output as <time> [<stream>] <text>, one line per entry, in the order it was captured. The stream is agent-out (the agent's stdout), agent-err (its stderr) or engine (a line Hekma adds at each state change). Logs work for every agent, whatever capabilities it declares.
| Flag | Meaning |
|---|---|
-f, --follow | After printing what is captured, keep printing new lines until the agent stops, pauses or fails. |
--json | Print each line as one JSON object (NDJSON). See JSON output. |
$ hekma agent logs worker
2026-10-22T19:07:20Z [agent-out] worker ready, model=gpt-4o-mini
2026-10-22T19:07:20Z [agent-out] KTESIO_USAGE {"sequence": 0, "input_tokens": 1200, "output_tokens": 300, "cached_tokens": 400}
2026-10-22T19:07:20Z [engine] engine: starting -> running--follow keeps running until the agent leaves running or you press Ctrl+C, and it keeps the engine open the whole time: while it runs, a detached agent's usage is metered and its budgets are enforced. It ends with a note when the agent leaves running, for example note: Agent Instance 'worker' is paused; no further output until it is resumed. For a detached agent, new lines come straight from the agent's raw log, after a note that their timestamps are when the command read them. Lines written before the follow started are not replayed; see Follow live output.
On Hekma's main branch (Unreleased: after 0.11.0), logs only reads and never starts a host. While a Service Host serves the state directory, the host attributes the agent's output itself, so --follow reads the raw log only when no host is running, for a detached agent whose host has exited.
Hekma keeps up to 10 MB of attributed output per file plus the two previous files. The one-shot form prints whatever is retained and never fails because of rotation. Ending the output early (for example with | head) exits cleanly with code 0.
| Error | Exit code |
|---|---|
| No agent with that name | 3 |
Guide: Logs, JSON and scripting.
hekma agent remove <name> [--delete | --retain] [--force]#
hekma agent remove <NAME> [--delete | --retain] [--force]Removes an agent from the fleet. By default its Agent Home stays on disk.
| Flag | Meaning |
|---|---|
--retain | Keep the Agent Home (the default). |
--delete | Delete the Agent Home too, including its logs and any memory/ folder. |
--force | Remove even if the agent is running; its process is stopped. |
$ hekma agent remove worker
✓ Agent Instance worker removed (Agent Home retained)| Error | Exit code |
|---|---|
--delete together with --retain | 2 |
| No agent with that name | 3 |
The agent is running and --force was not given | 4 |
| The Agent Home could not be deleted (the agent is removed; delete the folder yourself) | 1 |
hekma agent memory attach <name> --kind <kind>#
hekma agent memory attach <NAME> --kind <filesystem|native> [--json]Attaches a memory backing. filesystem creates a memory/ folder in the Agent Home and passes its path to the agent at every start; native records that the agent manages its own memory and creates nothing. The agent must be registered, stopped or failed.
| Flag | Meaning |
|---|---|
--kind <KIND> | filesystem or native. |
--json | Print one JSON document. See JSON output. |
The confirmation ends with the folder path alone on the last line, so a script can read it with tail -n 1:
$ hekma agent memory attach worker --kind filesystem
✓ Attached filesystem Memory Backing to Agent Instance worker
Ktesio guarantees the managed directory: it exists, survives restarts byte-identically, and travels with the Agent Home.
/Users/you/Library/Application Support/ktesio/agents/worker/memoryAttaching the same kind again succeeds and changes nothing.
| Error | Exit code |
|---|---|
Unknown --kind | 2 |
| No agent with that name | 3 |
| The agent is running, paused, starting or stopping | 4 |
| A different kind is already attached (detach it first) | 4 |
| The attachment was saved but the folder could not be created (the next start creates it) | 1 |
Guide: Config, secrets and memory.
Moving an Agent Home to another machine#
This moved to Config, secrets and memory.
hekma agent memory detach <name>#
hekma agent memory detach <NAME> [--json]Removes the memory backing record. The memory/ folder and its files stay on disk, and attaching filesystem again later picks them up. The same state rule applies as for attach.
| Flag | Meaning |
|---|---|
--json | Print one JSON document. See JSON output. |
$ hekma agent memory detach worker
✓ Detached the Memory Backing from Agent Instance worker (the managed directory and its contents remain on disk)| Error | Exit code |
|---|---|
| No agent with that name | 3 |
| The agent is running, paused, starting or stopping | 4 |
hekma agent config set <name> <key> <value>#
hekma agent config set <NAME> <KEY> <VALUE>Sets one key on the agent's own config layer. Hekma checks the key and, for budget and price keys, the value before writing anything. The value is stored as written: a secret:NAME reference stays a reference and is resolved only at start. The file is replaced in one step, so a crash never leaves it half-written.
| Argument | Meaning |
|---|---|
<KEY> | A key from Config keys, or any key under agent. |
<VALUE> | The value. A value that starts with - is taken literally; -- before it is optional. |
$ hekma agent config set worker budget.tokens.cumulative 6000
✓ Set budget.tokens.cumulative = 6000 on Agent Instance worker (instance layer)Changes apply at the agent's next start. Budget, breach action and rate keys are the exception: Hekma reads them again at every usage event, so they apply at once to a supervised agent. If you put a secret: value on a key the adapter passes as a command-line flag, the write succeeds with a warning, because other local users can read a process's arguments.
On Hekma's main branch (Unreleased: after 0.11.0):
labels.<key>binds a label on the agent's Runs. Set withconfig seton a running agent, it applies to the agent's open Run at once:$ hekma agent config set worker labels.team payments ✓ Set labels.team = payments on Agent Instance worker (instance layer)Two
config setcommands on the same agent at the same time both land. Each write holds a lock file,config.toml.lockbeside the agent'sconfig.toml, for its read and write; the lock is released by the system if the writer dies. In 0.11.0 two concurrent writes could drop one of the keys while both exited 0.
| Error | Exit code |
|---|---|
Unknown key outside agent. (the error suggests the nearest key) | 2 |
| No agent with that name | 3 |
Invalid value for a budget, breach action or price key, or (Unreleased: after 0.11.0) for a labels.<key> key (nothing changed) | 1 |
Guide: Config, secrets and memory.
hekma agent config get <name> [<key>] [--json] [--reveal]#
hekma agent config get <NAME> [KEY] [--json] [--reveal]Prints the agent's effective config: each key, its value, whether Hekma validated the key, and the config layer the value came from. With a key, prints only that value.
| Argument or flag | Meaning |
|---|---|
[KEY] | Print only this key's value. |
--json | Print one JSON document. See JSON output. |
--reveal | Show secret: values in clear text. Hekma resolves them again now, from the environment and then secrets.toml. |
$ hekma agent config get worker
▸ Effective config for worker (4 rows)
Key Value Validated Source
─────────────────────────────────────────────────────────────────
agent.api_key secret:**** unvalidated instance
budget.tokens.cumulative 6000 validated instance
cost.rate.input 3.00 validated instance
model gpt-4o-mini validated instance| Error | Exit code |
|---|---|
The key has no value (for a prefix such as budget, the error lists the keys under it) | 2 |
| No agent with that name | 3 |
--reveal could not resolve a secret, or secrets.toml is readable by other users | 1 |
hekma agent governance-vectors [--json]#
Unreleased: after 0.11.0. This command is on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma agent governance-vectors [--json]Prints the governance conformance vectors: the versioned, checksummed set of worked budget and cost decisions that a Host pins to show that its own guard follows Hekma's rules. The command reads the copy built into the binary, so it touches no state directory, needs no registered agent and works offline. The same files ship as assets with every release.
| Flag | Meaning |
|---|---|
--json | Print the artifact itself, byte for byte the released vectors-v1.json, so its SHA-256 matches the published checksum. |
$ hekma agent governance-vectors
✓ governance conformance vectors 1.4.0 — artifact `hekma-governance-vectors`, schema v1
checksum sha256:0818e4c2e5560c9360ab46bc2a959f8427db73c3cb0a488dea520faff61f2629
cases 69 (20 decision, 11 derivation, 5 fence, 5 chain, 18 policy, 10 rearm)
artifact crates/hekma-engine/governance/vectors-v1.json
pin vectors_version + sha256 — re-run every case against your guard on any upgrade
$ hekma agent governance-vectors --json | shasum -a 256
0818e4c2e5560c9360ab46bc2a959f8427db73c3cb0a488dea520faff61f2629 -hekma run open --parent <run-id|agent> / close <run-id|--selector <selector>> / show <run-id>#
Unreleased: after 0.11.0.
hekma runis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma run open --parent <RUN_ID|AGENT> [--label <KEY=VALUE>]... [--token-budget <TOKENS>] [--dollar-cap <DOLLARS>] [--breach-action warn] [--external-id <ID>] [--print-key] [--json]
hekma run close <RUN_ID|--selector <SELECTOR>> [--dry-run] [--yes] [--json]
hekma run show <RUN_ID> [--json]Every started agent owns a Run. open starts a child Run under it for one unit of a Host's own work, with its own ceilings; close ends a child Run; show prints any Run. open and close are writes and go through the local Service Host; show only reads. Runs explains the model.
Flag (open) | Meaning |
|---|---|
--parent <RUN_ID|AGENT> | The parent: a run id, or an agent's name for that agent's open Run. |
--label <KEY=VALUE> | A caller label on the child. Repeat it for more. |
--token-budget <TOKENS> | A per-run token ceiling over the child and its own children. |
--dollar-cap <DOLLARS> | A per-run dollar cap over the child and its own children, such as 3.00. Needs the agent's rate. |
--breach-action warn | The child's ceilings take warn. pause, stop and block are refused for a child Run. |
--external-id <ID> | A retried open with the same id returns the same Run instead of opening another. |
--print-key | Issue the child's Run Key and refresh credential and print them once (run key: hk_run_…, refresh credential: hk_ref_…; with --json a credentials object), with a stderr note that they are not shown again. Without it no credential is issued. |
--json | Print the Run as {"schema_version": 1, "run": {…}}. See JSON output. |
$ hekma run open --parent worker --label task=review --token-budget 20000
✓ Run run_01M76G2SYFNPXBKPHCYV4BCSF7 opened
CONTROL announced
STATUS active
ANOMALIES —
PARENT run_01M76G2GZDTHGJV3X7EP61Y78C
INSTANCE worker
LABELS task=review (caller)
LIMITS 20000 tokens per run (warn)
USAGE 0 tokens (0 in / 0 out), $0.00 (estimated)
CHILDREN 0 open
$ hekma run show run_01M76G2GZDTHGJV3X7EP61Y78C
✓ Run run_01M76G2GZDTHGJV3X7EP61Y78C
CONTROL supervised (no wire)
STATUS active
ANOMALIES —
PARENT —
INSTANCE worker
LABELS env=prod (bound, label-verb), team=payments (bound, config), tier=gold (bound, label-verb)
LIMITS —
USAGE 1500 tokens (1200 in / 300 out), $0.00 (estimated)
CHILDREN 2 openshow prints the Run's Control Depth (supervised (no wire) when the agent's model calls skip the metering listener), its Run Status, its Anomalies, its parent and agent, its labels with their source (bound, config, bound, label-verb or caller), its limits, the usage of the Run and its children, and its open children. A child of a supervised agent runs inside that agent's process, at depth announced. A child's usage counts on every ancestor, and every ancestor's ceilings apply to it. Closing a Run that has already ended changes nothing. A Run that owns an agent's process is ended with hekma agent stop, never closed:
$ hekma run close run_01M76G2GZDTHGJV3X7EP61Y78C
✗ Run `run_01M76G2GZDTHGJV3X7EP61Y78C` owns the supervised process of `worker` — stop the instance instead of closing the Run| Error | Exit code |
|---|---|
A malformed flag, more than 8 levels of nesting, or a breach action the child cannot carry out (pause, stop, block) | 2 |
| No Run has that id | 3 |
The agent has no open Run, the parent has ended, or the Run owns a process (close) | 4 |
close also takes --selector, --dry-run, --yes and --json, like the lifecycle verbs; a Run that owns an agent's process is that Run's refusal.
hekma run keys <run-id> [--json] / revoke-keys <run-id> [--no-cascade] [--json]#
Unreleased: after 0.11.0.
hekma run keysandrevoke-keysare on Hekma's main branch and ship in the next release; Hekma 0.11.0 does not have them.
hekma run keys <RUN_ID> [--json]
hekma run revoke-keys <RUN_ID> [--no-cascade] [--json]keys lists a Run's credentials (see Run Keys): each one's token id, class (run-key, refresh), state (active, retired, revoked), launch generation, the token id it was issued under, the issue time and the revocation cause. Never a key. It reads state.db read-only and starts nothing; for a live supervised Run with no key it says "This Run started before Run Keys; it gets one at its next launch."
revoke-keys revokes the Run's active credentials and, by default, every credential issued under any of them — the keys of child Runs opened with them, and their refresh chains. --no-cascade revokes the Run's own only. It goes through the local Service Host and returns once the revocation is committed, so the next request presenting a revoked key is refused:
✓ Revoked 2 credential(s) for run_01JZ6Q9G3S8V2X7K4M1N5P0R2T and 1 under its child Runs; calls presenting them are refused from now on.
run_01JZ6Q9G3S8V2X7K4M1N5P0R2T run-key 3f9a1c0b7d2e
…It also clears the Run's credential-reuse Anomaly. Revocation never ends a Run. Exit codes: 3 when no Run has the id, 1 when the host cannot be reached.
| Error | Exit code |
|---|---|
| No Run has that id | 3 |
| The host cannot be reached | 1 |
hekma ps [--selector <sel>] [--all] [--limit <n>] [--cursor <c>] [--json]#
Unreleased: after 0.11.0.
hekma psis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma ps [--selector <SELECTOR>] [--all] [--limit <N>] [--cursor <C>] [--json]Lists the Runs that need you, newest first (Runs). It is a read: it opens the state database read-only, never starts a host, and on a fresh state directory prints the empty note and creates nothing.
hekma ps
hekma ps --selector team=core,env=prod
hekma ps --all --limit 100 --json| Flag | Meaning |
|---|---|
--selector <SELECTOR> | Only Runs carrying all these labels, bound or caller: key=value[,key=value...]. |
--all | List every Run inside the ended-Run window, not just the exceptions. |
--limit <N> | Page size: default 50, at most 1000. 0 means the maximum; above the cap it clamps with a note. |
--cursor <C> | Continue after a previous page. The footer prints the exact command: the same --all, --selector and --limit, plus the cursor. |
--json | Print {"schema_version": 1, "view", "selector", "items", "next_cursor", "counts"}, one document. See JSON output. |
The default view is exception-first. A Run is listed when it carries an Anomaly (an ended Run only within seven days of its end) or a held, silent or stale status. Healthy open Runs are counted in the footer, not listed, and --all adds every Run inside the window. Rows are ordered by run id, newest first, and the cursor pages without duplicates.
The columns:
- RUN: the agent's name on process-owning rows, the run id on child Runs.
- CONTROL: the depth;
supervised (no wire)for an agent whose model calls skip the metering listener. - STATUS and ANOMALIES: the Run Status, and the Anomalies with each latched Breach Action (
breach[block]). - LABELS: a caller label is suffixed
(caller). - Usage: the Run's subtree tokens and derived dollars, an estimate. A dollar figure appears only where a Rate prices one.
- Headroom: what remains against the Run's resolved ceilings, naming the Policy that set them, plus the cumulative token headroom on process-owning rows.
--json carries every figure whole, each row's labels with source and origin, its latches as latched: [{dimension, scope, action}], its resolved limits' sources and the effective Breach Action, and the kept_on_pause marker where the breach-default upgrade holds an agent on pause. An empty page prints a note naming what was asked (the view, the Selector, or a cursor past the last Run) and still prints the counts footer. hekma agent list stays the supervised-instance projection beside it, unchanged.
| Error | Exit code |
|---|---|
| An invalid selector, cursor or limit | 2 |
| A store failure | 1 |
An empty listing exits 0. The same listing is on the Control API as GET /v0/runs; see The Run listing.
hekma label set|remove <run-id|agent|--selector <selector>> <labels>...#
Unreleased: after 0.11.0.
hekma labelis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma label set <RUN_ID|AGENT> <KEY=VALUE>... [--dry-run] [--yes] [--json]
hekma label set --selector <SELECTOR> <KEY=VALUE>... [--dry-run] [--yes] [--json]
hekma label remove <RUN_ID|AGENT> <KEY>... [--dry-run] [--yes] [--json]
hekma label remove --selector <SELECTOR> <KEY>... [--dry-run] [--yes] [--json]Binds and unbinds labels on Runs. set takes key=value pairs; remove takes keys. The target is a run id, an agent's name for its open Run, or a Selector.
| Argument or flag | Meaning |
|---|---|
<RUN_ID|AGENT> | The target, unless --selector is given. |
--selector <SELECTOR> | Every open Run carrying all these labels, bound or caller: key=value[,key=value...]. At most 1000 Runs. |
--dry-run | Show each Run's planned change, and each refusal as Run <id> would refuse (<code>): <reason> on stdout like every set-taking verb. Write nothing. |
--yes | Do not ask before acting on several Runs. |
--json | Print {"schema_version": 1, "verb": "label", "dry_run", "matched", "results"}. See JSON output. |
$ hekma label set worker env=prod
✓ Run run_01M76G2GZDTHGJV3X7EP61Y78C labeled: env=prod (bound, label-verb), team=payments (bound, config)
$ hekma label set --selector env=prod owner=ops --dry-run
Run run_01M76G2GZDTHGJV3X7EP61Y78C would label: env=prod (bound, label-verb), owner=ops (bound, label-verb), team=payments (bound, config) (now: env=prod (bound, label-verb), team=payments (bound, config))A label set here is bound to the Run with origin label-verb. Per key it outranks the agent's labels.<key> configuration (origin config) and any caller label, and it stays with the Run across a crash relaunch; a new start opens a Run without it. remove takes back such a label, and if the configuration binds the same key, its value returns in the same change. Removing an absent key changes nothing. Removing a label that comes from configuration is refused, naming the key to change:
$ hekma label remove worker team
✗ label `team` on Run `run_01M76G2GZDTHGJV3X7EP61Y78C` comes from the configuration key `labels.team` of agent `worker`, so it cannot be removed from the Run — change it with `hekma agent config set worker labels.team <value>`, or override it on the Run with `hekma label set run_01M76G2GZDTHGJV3X7EP61Y78C team=<value>`Removing a caller label is refused too, and so is any change to a Run that has ended.
When a Selector matches more than one Run, the command lists them and asks you to confirm. Without a terminal it is refused unless you pass --yes, so a script never hangs. Each Run prints one line (labeled, unchanged, would label, or its refusal, on stderr, or on stdout under --dry-run), and a refusal on one Run does not stop the others. A Selector that matches nothing exits 0 with a note. The target, the Selector and a --dry-run are read from the state directory and start nothing; each change goes through the local Service Host.
The exit code is the first failure's:
| Error | Exit code |
|---|---|
A malformed label or Selector, a Selector matching more than 1000 Runs, or several matches with no terminal and no --yes | 2 |
| No Run has that id, or no agent has that name | 3 |
| The agent has no open Run, the Run has ended, or the label cannot be removed | 4 |
The Control API has the same change as PATCH /v0/runs/{id}/labels; see Control API.
hekma budget show|set <run-id|agent|--selector <selector>> [flags]#
Unreleased: after 0.11.0.
hekma budgetis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
hekma budget show [<RUN_ID|AGENT>|--selector <SELECTOR>] [--limit <N>] [--cursor <C>] [--json]
hekma budget set <RUN_ID|AGENT|--selector <SELECTOR>> [limit flags] [--dry-run] [--yes] [--json]Reads and sets the limits of Runs (Runs: limits on a Run).
hekma budget show my-agent
hekma budget show --selector team=core --limit 20 --json
hekma budget set my-agent --tokens-per-run 500000
hekma budget set run_01JZ6Q9G3S8V2X7K4M1N5P0R2T --dollars-per-run 3.00 --breach-action pause
hekma budget set --selector team=core --clear tokens-per-run,breach-action --yesFlag (set) | Meaning |
|---|---|
--tokens-per-run <N> | A per-run token ceiling on the Run. |
--tokens-cumulative <N> | A cumulative token ceiling. An agent's own Run only, because it counts the agent's lifetime usage. |
--dollars-per-run <DOLLARS> | A per-run dollar cap, such as 3.00. Needs a Rate. |
--dollars-cumulative <DOLLARS> | A cumulative dollar cap. An agent's own Run only. |
--breach-action <ACTION> | The Run's Breach Action: warn, pause, stop or block. |
--clear <LIMIT>[,<LIMIT>] | Clear limits set on the Run: tokens-per-run, tokens-cumulative, dollars-per-run, dollars-cumulative, breach-action. Repeatable. |
--dry-run, --yes, --json | As for the lifecycle verbs. --json carries verb: "budget" and, per Run, the outcome (raised, lowered, cleared, set, unchanged, would-set), the limits before and after, the resolved limits with their sources, what fired or re-armed, run_scoped: true and a note. See JSON output. |
A limit set here outranks the agent's budget.* configuration and every Policy for that limit, and it belongs to the Run: a crash relaunch keeps it, it ends with the Run, and a new start opens a new Run without it. Every result says so. For limits every future Run should carry, use the agent's budget.* configuration or a Policy. A ceiling raised above the usage re-arms its breach and lifts a matching block fence at once. One lowered to or below the usage breaches at once and applies the Breach Action. Over a Selector, the command waits up to 45 seconds per Run (capped at 10 minutes), enough for a breach whose stop runs the default 30-second ladder inside the act.
show prints, per Run, each ceiling with its source (run, instance, policy:<name>, default, or caller where a Caller's tighter limit applies), its usage and headroom, the Breach Action, the latched breaches and the limits set on the Run itself. With --selector, or with no target at all, show lists Runs the way hekma ps --all does, every open Run and those that ended in the last seven days, newest first. It pages with --limit (default 50, at most 1000) and --cursor <cursor>; the next page's cursor is printed on stderr, and is next_cursor in --json. show only reads and starts no Service Host.
| Error | Exit code |
|---|---|
A cumulative ceiling on a child Run (scope-unavailable), or a Breach Action the Run cannot execute, such as block with no wire path (the error names the Metering Source) or pause on a child Run | 2 |
| No such Run or agent | 3 |
| The Run has ended | 4 |
The Control API has the same change as PATCH /v0/runs/{id}/limits; see Limits on a Run.
hekma policy list|show|create|change|delete <name> [flags]#
Unreleased: after 0.11.0.
hekma policyis on Hekma's main branch and ships in the next release; Hekma 0.11.0 does not have it.
Manages Policies, the standing limits that apply to every Run their Selector matches (Policies and the warn default).
hekma policy create nightly-research \
--selector team=research,env=prod \
--tokens-per-run 2000000 --dollars-per-run 25 --breach-action pause
hekma policy change default --rate-for gpt-4.1 --rate-input 2.00 --rate-output 8.00
hekma policy change default --clear rate:gpt-4.1
hekma policy change nightly-research --clear dollars-per-run
hekma policy delete nightly-research| Argument or flag | Meaning |
|---|---|
list, show | Read Policies. These are reads: no Service Host starts for them. |
create <name> --selector <SELECTOR> | A new Policy. The name is 1 to 63 characters of lowercase letters, digits, - and _. |
--tokens-per-run, --tokens-cumulative <N>; --dollars-per-run, --dollars-cumulative <DOLLARS> | Token ceilings and Cost Caps. Dollars parse like 25 or 0.0001. |
--breach-action <warn|pause|stop|block> | The Breach Action for these ceilings. |
--rate-input <DOLLARS> --rate-output <DOLLARS> [--rate-cached <DOLLARS>] | A flat Rate for the Policy's matched Runs. |
change <name> ... | Set limits (a field you set wins), or --clear <LIMIT>[,<LIMIT>] to remove one: tokens-per-run, dollars-per-run, breach-action, rate and so on. |
change default --rate-for <MODEL> ... | Price a model in the default Policy's Rate table. --clear rate:<MODEL> removes the entry. |
--dry-run | Report what the change would match, and how many matched Runs fall back to warn at their depth. Write nothing. |
--json | The versioned documents that show, list and the write answers render. |
Every change applies at once to every matched open Run: a ceiling lowered to or below a Run's usage breaches it now, and raising one re-arms the breach so the next crossing fires again. The default Policy has no ceilings, Breach Action warn and an empty Rate table you can fill. It cannot be deleted or given a Selector, so change it instead. Writes go through the local Service Host like every write.
| Error | Exit code |
|---|---|
| No Policy has that name | 3 |
A malformed request, a taken name, an unknown --clear field, or the default Policy's reserved shape (a Selector, a deletion or a flat Rate) | 2 |
The Control API has the same operations under /v0/policies; see Policies.
Config keys#
The full list of keys, with types, defaults and validation, is on Config keys. How budgets behave is on Budgets and cost.
Exit codes#
Every command exits 0 on success, or 1 to 6 by error class: 1 general, 2 usage, 3 not found, 4 invalid state, 5 unsupported, 6 timed out. The full table, with every condition, is on Exit codes and environment.
Environment variables#
The variables Hekma reads, such as HEKMA_STATE_DIR and HEKMA_NO_UPDATE_CHECK, and the ones it sets for agents are listed on Exit codes and environment.
Update checks#
When you run any command other than self-update, Hekma checks GitHub for a newer release at most once an hour and, if there is one, prints a one-line note on stderr suggesting hekma self-update. JSON on stdout is unaffected. Set HEKMA_NO_UPDATE_CHECK=1 to turn the check off; it is also off when CI is set. Details are on Exit codes and environment.
hekma self-update#
hekma self-updateUpdates the hekma binary through the channel you installed it with: brew upgrade for Homebrew, cargo install --force for Cargo, and a verified download of the latest GitHub release archive for a manual install. Agents are separate programs, so an update does not touch them: detached agents keep running, and the next hekma command, now the new version, adopts them. On Hekma's main branch (Unreleased: after 0.11.0), a Service Host that is still running from the old version keeps serving the CLI, with a note naming both versions, until you restart it.
| Error | Exit code |
|---|---|
| The update failed | 1 |
Guide: Install.
Read next#
- Config keys: every key
config setaccepts. - JSON output: the documents
--jsonprints. - Exit codes and environment: codes for scripts and the variables Hekma reads.
- Supervision and detached runs: how to keep agents running and governed.