@hagicode/cli 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,12 +5,12 @@
5
5
  [![license](https://img.shields.io/npm/l/%40hagicode%2Fcli?color=ffd43b)](https://www.npmjs.com/package/@hagicode/cli)
6
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D24.0.0-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
7
7
 
8
- `@hagicode/cli` provides the published `hagi` command, which lets you drive a HagiCode backend from a terminal, scripts, or an AI agent without opening the app. Manage projects, proposals (generate, execute, archive, and send), vaults and their files, chat sessions, HagiTasks, scheduled plans, and skills (local list, enable, disable and uninstall, gallery search and install, and trusted providers). Every command supports a shared `--json` output for scripting, and an embedded Hagi skill under [`skills/`](skills/) guides agent workflows.
8
+ `@hagicode/cli` provides the published `hagi` command, which lets you drive a HagiCode backend from a terminal, scripts, or an AI agent without opening the app. Manage projects, proposals (generate, execute, archive, and send), local Sagas, vaults and their files, chat sessions, HagiTasks, scheduled plans, and skills (local list, enable, disable and uninstall, gallery search and install, and trusted providers). Every command supports a shared `--json` output for scripting, and an embedded Hagi skill under [`skills/`](skills/) guides agent workflows.
9
9
 
10
10
  ## Requirements
11
11
 
12
12
  - Node.js 24+
13
- - Access to a HagiCode backend API
13
+ - Access to a HagiCode backend API for backend-selected commands; Saga commands with `--path` work locally without one, except `saga session create`, which needs the backend to find the registered project
14
14
 
15
15
  ## Installation
16
16
 
@@ -76,9 +76,55 @@ Example:
76
76
  hagi --base-url https://api.example.com --token "$HAGI_TOKEN" project list --json
77
77
  ```
78
78
 
79
+ ## Saga Commands
80
+
81
+ Each Saga command requires exactly one project selector: `--path <directory>` or `--project-id <id>`. Missing, empty,
82
+ or conflicting selectors exit with code `2`. `--path` is resolved on the CLI host, relative to the current directory,
83
+ and does not read backend configuration or contact the backend; backend flags do not change local behavior. The one
84
+ exception is `saga session create`, which looks up the registered project through the backend (see below). Quote paths
85
+ that contain spaces.
86
+
87
+ ```bash
88
+ hagi saga init --path "./My Project"
89
+ hagi saga method run --json
90
+ hagi saga new demo --path "./My Project" --json
91
+ hagi saga list --path "./My Project"
92
+ hagi saga status demo --project-id <project-id> --json
93
+ hagi saga items demo --path "./My Project" --json
94
+ hagi saga claim demo --path "./My Project" --session orchestrator-1 --json
95
+ hagi saga check demo --path "./My Project" --phase run --json
96
+ hagi saga tick demo T1 --path "./My Project" --token "$SAGA_EXECUTION_TOKEN" --json
97
+ ```
98
+
99
+ Write and check commands (`claim`, `assert-owner`, `release`, `freeze`, `check`, `tick`, `block`, `set-status`, `amend`,
100
+ `archive`) run in the CLI itself. The CLI installs only the ignore rule and reads the six method prompts from its own package with `hagi saga method <name>`; there is no standalone Saga tool and no project-local copy of the methods. Mutating commands read the execution token
101
+ from `--token` or `SAGA_EXECUTION_TOKEN`; with `--project-id`, `--token` is rejected because it is the backend token, so use
102
+ `SAGA_EXECUTION_TOKEN` there. Exit code `0` means success, `1` a refusal or failed check, and `2` a usage error.
103
+
104
+ `saga session create --saga <id> --path <root> --title <title> --role implementation|verification --master <session-id> [--item <id>]`
105
+ creates one Worker chat session and records it in `runtime/sessions.md`. Unlike the other Saga commands it calls the
106
+ backend even with `--path`: the registered project whose real path matches `<root>` supplies the project ID, and no match
107
+ or several matches is a refusal. The execution token comes only from `SAGA_EXECUTION_TOKEN`; `--token` is refused with
108
+ either selector. The session carries `saga.*` metadata. The command sends no message and does not archive the session.
109
+ See the [Saga command reference](skills/hagi/references/saga.md#worker-sessions) for the options, metadata keys and exit codes.
110
+
111
+ With `--project-id`, the CLI uses the normal base URL, token, and language settings to resolve the project through the
112
+ backend. The returned project path must exist on the machine running the CLI; it is not a remote filesystem path.
113
+
114
+ `saga init` installs only the runtime ignore rule in `.hagicode/sagas/.gitignore`, merged additively, and creates no
115
+ `prompts/` directory. Existing project-local `prompts/` files are left untouched and are no longer read. `saga method <name>`
116
+ prints a published method (`goal`, `research`, `acceptance`, `plan`, `run`, `amend`) from the installed package, verified
117
+ against its manifest, with `--json` returning `{ name, sha256, content }`. `freeze` records the method digests in
118
+ `contract.lock`, and `check --phase run --json` reports method drift as a notice that never fails the check. Initialization
119
+ refuses redirected or unsafe targets and leaves identical resources untouched on repeat runs. See the
120
+ [Saga command reference](skills/hagi/references/saga.md) for outcomes, safety behavior, and JSON details.
121
+
122
+ For offline use, install the package or use a cached `npx` package. An uncached `npx @hagicode/cli` invocation may need
123
+ network access to download the package even though `saga ... --path` itself does not use a backend, except `saga session create`, which does.
124
+
79
125
  ## Connection Setup
80
126
 
81
- Every operation command resolves the backend base URL on each invocation, in this order:
127
+ Every backend operation resolves the base URL on each invocation, in this order:
82
128
 
83
129
  1. `--base-url <url>` flag
84
130
  2. `HAGI_API_BASE_URL` environment variable
@@ -86,11 +132,14 @@ Every operation command resolves the backend base URL on each invocation, in thi
86
132
 
87
133
  ```json
88
134
  {
89
- "baseUrl": "https://hagicode.example.com"
135
+ "baseUrl": "https://hagicode.example.com",
136
+ "steer": false
90
137
  }
91
138
  ```
92
139
 
93
- If none of the three is set, the command exits with code `2` and sends no backend request.
140
+ If none of the three is set, a backend operation exits with code `2` and sends no backend request. Saga commands using
141
+ `--path` bypass this resolution and do not read backend configuration, except `saga session create`, which resolves its project through the backend. The `steer` key is the default for `hagi chat send`,
142
+ `hagi proposal send`, and `hagi hagitask send` (see [Steer](#steer-send-option)); it must be `true` or `false`.
94
143
 
95
144
  Operation commands send requests without a credential by default. Pass `--token` (or set `HAGI_API_TOKEN`) only when your backend requires one.
96
145
 
@@ -110,17 +159,21 @@ $ echo $?
110
159
  hagi
111
160
  |-- project list | repositories | create | update | delete
112
161
  | `-- monospecs show | init | set | validate | reload | clone | remove-checkout
113
- |-- proposal list | create | optimize-description | generate | annotate | execute | archive | status | complete | send
162
+ |-- proposal list | create | optimize-description | generate | annotate | execute | archive | status | complete | send | get | messages
163
+ |-- saga init | new | list | status | items | claim | assert-owner | release | freeze | check | tick | block | set-status | amend | archive
114
164
  |-- vault list | create | update | delete
115
165
  | `-- files list | preview
116
166
  |-- chat list | create | archive | delete | send
117
- |-- hagitask list | schema | create | send
167
+ |-- hagitask list | schema | create | send | get | messages
118
168
  |-- plan list | get | create | update | enable | disable | delete | run
119
- `-- skills local list | enable | disable | uninstall
120
- gallery search | detail | install
121
- trusted list | upsert | delete | reset
169
+ |-- skills local list | enable | disable | uninstall
170
+ | gallery search | detail | install
171
+ | trusted list | upsert | delete | reset
172
+ `-- agent lock acquire | status | renew | heartbeat | release | requisition | list
122
173
  ```
123
174
 
175
+ The `send` commands of `chat`, `proposal`, and `hagitask` also take `--steer` and `--no-steer`, and `HAGI_SEND_STEER` sets the default. See [Steer](#steer-send-option).
176
+
124
177
  ## Example Setup
125
178
 
126
179
  The examples in the family sections run in order against a local backend. They assume:
@@ -243,6 +296,14 @@ hagi proposal status --session-id "$PROPOSAL_ID" --status Reviewing
243
296
  hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue"
244
297
  ```
245
298
 
299
+ Steer the message into the running turn, from the environment, or with a normal send that overrides the environment:
300
+
301
+ ```bash
302
+ hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue" --steer
303
+ HAGI_SEND_STEER=1 hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue"
304
+ hagi proposal send --session-id "$PROPOSAL_ID" --content "Please continue" --no-steer
305
+ ```
306
+
246
307
  The next steps are AI lifecycle actions and need a backend with an AI executor. `optimize-description` writes the optimized title, description, and proposal name to the session in one backend step, and `generate` needs that name. Without the AI executor, or before the name exists, the backend answers with a 400 that names the missing state:
247
308
 
248
309
  ```bash
@@ -260,6 +321,17 @@ hagi proposal complete --session-id "$PROPOSAL_ID"
260
321
  hagi proposal archive --session-id "$PROPOSAL_ID"
261
322
  ```
262
323
 
324
+ ### Follow a Run
325
+
326
+ `proposal get` reads one session. With `--wait` it polls until the status settles, so the next lifecycle command runs at the right time. `proposal messages` reads the session's messages, newest first.
327
+
328
+ ```bash
329
+ hagi proposal get --session-id "$PROPOSAL_ID" --wait --json
330
+ hagi proposal messages --session-id "$PROPOSAL_ID" --last 1 --json
331
+ ```
332
+
333
+ The options are the same as `hagitask get`. WaitingForReply counts as settled, because a person must answer. Which stage each command starts is in [references/openspec-workflow.md](skills/hagi/references/openspec-workflow.md).
334
+
263
335
  ### Explicit Lifecycle Sequence
264
336
 
265
337
  The CLI keeps proposal lifecycle actions explicit and non-interactive. Each command maps to one backend action:
@@ -277,6 +349,19 @@ The CLI may suggest a next command, but it never chains later lifecycle APIs aut
277
349
 
278
350
  Each command maps to one backend action. The CLI may suggest a next command, but it never chains later lifecycle APIs automatically.
279
351
 
352
+ `proposal create` takes the same `--metadata` and `--metadata-json` options as `chat create`, with the same rules and limits; see [Session Metadata](#session-metadata). A master marker and worker markers, for example:
353
+
354
+ ```bash
355
+ MASTER_ID=$(hagi chat create --title "Batch master" --project-id "$PROJECT_ID" --metadata role=master --metadata batch=2026-11-07 --json | json_field '.session.sessionId')
356
+ hagi proposal create --project-id "$PROJECT_ID" --chief-complaint "Repository scope
357
+ Writable repositories:
358
+ - none
359
+ Read-only repositories:
360
+ - none
361
+
362
+ Tighten the settings page copy" --default-title --metadata role=worker --metadata master="$MASTER_ID" --json
363
+ ```
364
+
280
365
  ## Vault Commands
281
366
 
282
367
  Create a vault with a local folder to browse. The new id is read from `vault.id`:
@@ -341,10 +426,31 @@ Send a message, archive, and delete:
341
426
 
342
427
  ```bash
343
428
  hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff"
429
+ hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff" --steer
430
+ HAGI_SEND_STEER=1 hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff"
431
+ hagi chat send --session-id "$CHAT_ID" --content "Summarize the current diff" --no-steer
344
432
  hagi chat archive --session-id "$CHAT_ID"
345
433
  hagi chat delete --session-id "$CHAT_ID"
346
434
  ```
347
435
 
436
+ ### Session Metadata
437
+
438
+ `chat create` and `proposal create` take write-once metadata entries, for example the role markers an orchestrator uses to find its sessions again:
439
+
440
+ ```bash
441
+ hagi chat create --title "Master" --project-id "$PROJECT_ID" --metadata role=master --metadata batch=2026-11-07 --json
442
+ hagi chat create --title "Worker 1" --project-id "$PROJECT_ID" --metadata role=worker --metadata master="$MASTER_ID" --json
443
+ printf '{"role":"worker","master":"%s"}' "$MASTER_ID" | hagi chat create --title "Worker 2" --project-id "$PROJECT_ID" --metadata-json - --json
444
+ ```
445
+
446
+ - `--metadata key=value` is repeatable. The text is split at the first `=`, so a value may contain `=`.
447
+ - `--metadata-json <file|->` reads a JSON object of string values from a file, or from stdin with `-`. It is repeatable.
448
+ - A key may appear once across both options. A missing `=`, an empty key, a repeated key, or JSON that is not an object of string values is a usage error: the command exits `2` and sends no request.
449
+ - Limits, checked by the backend: at most 16 entries; a key of 1 to 64 characters matching `^[a-z][a-z0-9._-]{0,63}$`; a value of 1 to 512 characters with no control characters. A rejection exits with the backend's message as it is, and the session is not created.
450
+ - Metadata is write-once: it is set when the session is created and cannot be changed later. Every reader of the session can see it, so do not put secrets in it.
451
+ - The entries come back as `userMetadata` in the `--json` output of `chat create`, `chat list`, `proposal create` and `proposal get`. The human output adds one `userMetadata` line, keys sorted, when there are entries. A session without metadata has no `userMetadata` field.
452
+
453
+
348
454
  ## HagiTask Commands
349
455
 
350
456
  A HagiTask is a preset task with a structured input. Read its schema first, write the input from the schema, then create the session. `hagitask list` shows the active tasks:
@@ -357,8 +463,8 @@ hagi hagitask list --json
357
463
  `hagitask schema` shows one task's target scope, commands, parameters, requirements and scenes. Each required parameter is marked `yes`. The `--json` output adds the input JSON Schema and an example request body:
358
464
 
359
465
  ```bash
360
- hagi hagitask schema --task-id compose-commit
361
- hagi hagitask schema --task-id compose-commit --json
466
+ hagi hagitask schema --task-id <task-id>
467
+ hagi hagitask schema --task-id <task-id> --json
362
468
  ```
363
469
 
364
470
  Write the input file. Its keys are the parameter keys the schema lists under `inputs`, plus the `targets` and `targetScopes` keys when the schema's scope lists targets. For example, `input.json` for a task with one required input:
@@ -375,17 +481,28 @@ Create the session from that task and input. The new id is read from `session.se
375
481
 
376
482
  ```bash
377
483
  HAGITASK_ID=$(hagi hagitask create \
378
- --title "Auto compose commit" \
484
+ --title "Auto task" \
379
485
  --project-id "$PROJECT_ID" \
380
- --task-id compose-commit \
486
+ --task-id <task-id> \
381
487
  --input input.json \
488
+ --json | json_field '.session.sessionId')
489
+ ```
490
+
491
+ Super Commit is a prompt, not a preset task. It has no schema and takes no `--input`. Start it with its prompt id, and pass the Git options it accepts:
492
+
493
+ ```bash
494
+ SUPER_COMMIT_ID=$(hagi hagitask create \
495
+ --title "Commit the CLI changes" \
496
+ --project-id "$PROJECT_ID" \
497
+ --prompt-id auto-compose-commit.en-US \
382
498
  --repository-path repos/cli \
383
- --need-push \
384
499
  --target-branch-mode new-custom \
385
500
  --target-branch-name feature/cli-completion \
386
501
  --json | json_field '.session.sessionId')
387
502
  ```
388
503
 
504
+ Start a Super Commit only when the user asked for it. Add `--need-push` only when the user asked for a push. See [references/super-commit.md](skills/hagi/references/super-commit.md) for the options, the branch modes, the result and the explicit-request rule.
505
+
389
506
  Use `--prompt-id` instead of `--task-id` for a prompt template with no structured input. `--input` needs `--task-id`. Input is read from a file, or from stdin with `--input -`. The CLI only checks that the input is a JSON object. The backend checks the keys and values. It rejects a key that the schema does not list, and a missing required value. Its error is printed unchanged, and no session is reported as created. `--hero-selection-mode` takes `first` (the default) or `random`.
390
507
 
391
508
  The backend must have a hero available for the task's script. Without one, `hagitask create` fails with a 400 whose error is `no-executable-hero`.
@@ -396,6 +513,23 @@ Send a follow-up message to the HagiTask session:
396
513
  hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff"
397
514
  ```
398
515
 
516
+ Steer the message into the running task, from the environment, or with a normal send that overrides the environment:
517
+
518
+ ```bash
519
+ hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff" --steer
520
+ HAGI_SEND_STEER=1 hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff"
521
+ hagi hagitask send --session-id "$HAGITASK_ID" --content "Retry with a smaller diff" --no-steer
522
+ ```
523
+
524
+ Read one HagiTask session, or wait until its status settles, and read its messages:
525
+
526
+ ```bash
527
+ hagi hagitask get --session-id "$SUPER_COMMIT_ID" --wait --timeout 900 --json
528
+ hagi hagitask messages --session-id "$SUPER_COMMIT_ID" --last 1 --json
529
+ ```
530
+
531
+ `hagitask get` reads one session. With `--wait` it polls every `--interval` seconds (default 5) until the status is no longer Optimizing, Openspecing, Executing or Archiving. `--timeout` (default 900) and `--grace` (default 10, `0` disables) are seconds, and `--timeout`, `--interval` and `--grace` need `--wait`. `--interval` must be less than `--timeout`. A timeout exits `31` and prints the last status. `hagitask messages --last <n>` reads the n newest messages; `--json` prints the list unchanged.
532
+
399
533
  **Migration from AutoTask:** `hagi hagitask create` and `hagi hagitask send` replace `hagi autotask create` and `hagi autotask send`. There is no `autotask` alias, so an `autotask` command now fails as an unknown command. Read the task schema with `hagitask schema` to find the input keys that replace the old flags.
400
534
 
401
535
  ## Plan Commands
@@ -553,6 +687,26 @@ hagi skills gallery search --query react --json
553
687
  hagi skills gallery detail --id vercel-react-best-practices --source vercel-labs/agent-skills
554
688
  ```
555
689
 
690
+ `gallery detail` also shows third-party audit ratings for the skill, supplied by skills.sh (providers such as `ath`, `socket` and `snyk`). In `--json` output every detail field is unchanged and an `audit` object is added. It lists one entry per provider that supplied data; `risk`, `alerts`, `score` and `analyzedAt` appear only when the backend has them:
691
+
692
+ ```json
693
+ {
694
+ "id": "vercel-react-best-practices",
695
+ "source": "vercel-labs/agent-skills",
696
+ "...": "all other detail fields",
697
+ "audit": {
698
+ "providers": [
699
+ { "provider": "ath", "risk": "low", "alerts": 0, "score": 92, "analyzedAt": "2026-10-30T08:00:00Z" },
700
+ { "provider": "socket", "risk": "medium", "alerts": 2 }
701
+ ]
702
+ }
703
+ }
704
+ ```
705
+
706
+ In human output the detail table is followed by one line per provider, for example `skills.sh audit (socket): risk=medium, alerts=2, score=--, analyzedAt=--`, where `--` marks a value the backend did not supply.
707
+
708
+ The audit is best-effort. If the audit call fails, times out or has no data, the detail still prints and the command exits `0`; in `--json` output `audit.providers` is then `[]`, never missing. The backend bounds the audit wait, and the CLI adds no timeout of its own. A failure of the detail call itself fails the command as before, and the audit never hides it. The audit does not change the install command preview or whether the skill is installable.
709
+
556
710
  Start a managed install of a gallery skill. This writes the skill into your local skill directories, so run it only when you intend to install it:
557
711
 
558
712
  ```bash
@@ -575,6 +729,78 @@ hagi skills trusted delete --provider-id example-provider
575
729
  hagi skills trusted reset
576
730
  ```
577
731
 
732
+ ## Agent Lock Commands
733
+
734
+ `hagi agent lock` lets several agents take turns on one shared resource, such as a game server that only one agent may use at a time. The backend keeps a fair queue per lock; the lock is cooperative and cannot stop an action already running on the remote resource. There is no top-level `hagi lock`. The agent-facing protocol is in [`skills/hagi/references/resource-lock.md`](skills/hagi/references/resource-lock.md).
735
+
736
+ ```bash
737
+ hagi agent lock acquire --lock-id eu-1/duckov --owner sess-7f2c
738
+ hagi agent lock acquire --server eu-1 --game duckov --owner sess-7f2c --wait --timeout 900
739
+ hagi agent lock status --lock-id eu-1/duckov --owner sess-7f2c --json
740
+ hagi agent lock heartbeat --lock-id eu-1/duckov --owner sess-7f2c --epoch 7
741
+ hagi agent lock release --lock-id eu-1/duckov --owner sess-7f2c --epoch 7
742
+ hagi agent lock requisition --lock-id eu-1/duckov --owner sess-7f2c --reason "User order: take the lock now"
743
+ hagi agent lock list --prefix eu-1/
744
+ ```
745
+
746
+ - Lock: `--lock-id <id>` (one to four `/`-separated segments) or `--server <name> --game <name>`, which means `<server>/<game>`. Giving both forms, or only one of `--server` and `--game`, exits `2` before any request.
747
+ - Owner: `--owner <id>`, then `HAGI_LOCK_OWNER`, then `HAGI_SESSION_ID`. An agent passes its own session ID. The CLI never invents or stores an owner ID; with none set it exits `2`.
748
+ - `acquire` takes the lock or joins the queue and exits `0` for `Holding` and `Queued`. `acquire --wait` long-polls until the owner holds the lock (exit `0`), the `--timeout` passes (default 900 seconds, exit `31`, the queue entry it created is released), or the entry is dropped (exit `32`). Ctrl-C releases the entry it created and never a lock held before. `acquire` has no force option.
749
+ - `status` reads one owner's state (`Holding`, `Queued`, `Expired`, `Requisitioned`, `None`) and exits `0` for all of them; `--wait-seconds` long-polls. `renew` sends one renewal. `release` exits `0` whether or not anything was released. `list` shows the busy locks; `--prefix` filters them.
750
+ - `heartbeat` renews at once and then every `--interval` seconds (default 120), is quiet on success (`--verbose` prints each beat), prints a line and exits `32` when the lock is lost, retries transport errors with backoff and never reports them as loss. SIGINT or SIGTERM ends it with exit `0` and does not release. Run it under a Monitor or another watcher.
751
+ - `requisition` requires `--reason` (1 to 200 characters), takes the lock at once, and displaces the holder, who is told by its next heartbeat. Use it only when a user explicitly ordered a forced take.
752
+ - Answers show the valid-until time, the 24-hour hard cap, the check-in window and, for a queued owner, the turn window.
753
+
754
+ | Timing | Default |
755
+ | --- | --- |
756
+ | Feedback timeout (no heartbeat releases the lock) | 10 minutes |
757
+ | Maximum hold | 24 hours |
758
+ | Heartbeat interval | 2 minutes |
759
+ | Claim window after a handoff | 30 seconds |
760
+ | Waiter TTL | 60 seconds |
761
+ | `acquire --wait` timeout | 900 seconds |
762
+
763
+ Agent loop: `acquire`, read the windows, start `heartbeat` under a watcher before any work (or, when queued, a continuous `acquire --wait` watcher), stop the heartbeat when done and then `release`, and stop using the resource as soon as a command exits `32`. After losing track, repeat `acquire` with the same owner; it is safe.
764
+
765
+ ## Steer (send option)
766
+
767
+ `hagi chat send`, `hagi proposal send`, and `hagi hagitask send` deliver a message in one of two ways:
768
+
769
+ - **Normal send** (default): the message waits behind the running turn, as before.
770
+ - **Steer**: the message is inserted into the running turn through the backend's `SteerSession` RPC. The CLI makes one call.
771
+
772
+ Steer is off unless you ask for it. The first source that is set decides, in this order:
773
+
774
+ 1. `--steer` (on) or `--no-steer` (off) on the command.
775
+ 2. `HAGI_SEND_STEER`: `1`, `true`, `yes`, `on` turn Steer on; `0`, `false`, `no`, `off` turn it off. Case and surrounding spaces are ignored. Any other value exits with code `2` and sends no request.
776
+ 3. `"steer": true` or `"steer": false` in the config file. Any other type exits with code `2` and names the file.
777
+ 4. The default, `false`.
778
+
779
+ A lower source is not read once a higher one is set, so `--no-steer` works even when `HAGI_SEND_STEER` holds a value the CLI does not recognize.
780
+
781
+ ### Outcomes
782
+
783
+ - `steered`: a running task took the message. It does not guarantee the text was used: the backend can return a steered message to the queue when the run ends.
784
+ - `queued`: no running task took the message, so it was sent as the next message. This is a success and exits with code `0`. The backend also answers `queued` for an idle session, where the message starts a run at once.
785
+
786
+ Human output adds `steer`, `effective`, `outcome`, and `messageId` rows, and a line saying no running task took the message for `queued`. `--json` keeps `sessionId`, `message`, and `requested`, and adds a `steer` object: `{ requested, source, effective, outcome?, messageId?, reason? }`. `source` is `flag`, `env`, `config`, or `default`. `reason` appears only when Steer was requested but not used. On the Steer path `message` is `Steered` or `Queued`.
787
+
788
+ ### Conflicts and fallback
789
+
790
+ Steer carries text only, so it cannot be combined with `--mode` or `--executor-type`:
791
+
792
+ - `--steer` with either option exits with code `2` and sends nothing.
793
+ - When Steer comes only from `HAGI_SEND_STEER` or the config file, the command sends a normal message with the options and records the reason in `steer.reason`.
794
+ - When Steer comes only from `HAGI_SEND_STEER` or the config file and the backend does not implement `SteerSession`, the command sends a normal message and records the reason `the backend does not support Steer`. An explicit `--steer` reports the backend error instead.
795
+
796
+ A queued Steer is always sent in `Edit` mode. A session that must keep another mode should send with `--no-steer --mode <mode>`.
797
+
798
+ Steer works with the executors the backend supports. For any other executor, the backend answers `queued`.
799
+
800
+ ### Unattended messaging
801
+
802
+ For session-to-session messages sent by an orchestrator without a person watching, set `HAGI_SEND_STEER=1` in its environment. Add `--no-steer` to a single call that must go through the normal queue.
803
+
578
804
  ## Environment Variables
579
805
 
580
806
  The CLI resolves runtime settings centrally before every command. Explicit flags always override environment variables.
@@ -584,6 +810,7 @@ The CLI resolves runtime settings centrally before every command. Explicit flags
584
810
  | `HAGI_API_BASE_URL` | Backend base URL, used when `--base-url` is not given. Overrides the config file. Required when neither is set. |
585
811
  | `HAGI_API_TOKEN` | Bearer token attached as `Authorization: Bearer <token>`. |
586
812
  | `HAGI_API_LANG` | Shared `Accept-Language` header value. |
813
+ | `HAGI_SEND_STEER` | Turns Steer on (`1`, `true`, `yes`, `on`) or off (`0`, `false`, `no`, `off`) for the send commands, ignoring case and surrounding spaces. Any other value exits with code `2`. Overridden by `--steer` / `--no-steer`. Order: flag, then this variable, then the `steer` config key, then `false`. |
587
814
 
588
815
  ## Backend Transport
589
816
 
@@ -604,6 +831,8 @@ Stable non-zero exits used by the CLI. The HTTP numbers are the equivalents of t
604
831
  | `24` | HTTP 404 |
605
832
  | `29` | HTTP 409 |
606
833
  | `30` | Operation failed: the backend returned a refusal, for example `skills local enable` or `disable` on a name that is not a built-in skill, an invalid MonoSpecs configuration from `project monospecs validate`, or a failed clone from `project monospecs clone` or `set --clone` |
834
+ | `31` | Wait timed out: `--wait` on `proposal get`, `hagitask get` or `agent lock acquire` reached `--timeout` before the session settled. The last status is printed. Not a success, and not a backend error |
835
+ | `32` | Lock lost: a `hagi agent lock` command learned that the owner no longer holds the lock (expired, taken back at the 24-hour cap, stale epoch, requisitioned). Stop using the resource. Distinct from `31` |
607
836
  | `40` | Other HTTP 4xx |
608
837
  | `50` | HTTP 5xx |
609
838
  | `60` | Transport or connection failure |