@hagicode/cli 0.1.0-dev.41.1.8543fd3 → 0.1.0-dev.43.1.03d9a6a
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 +70 -4
- package/dist/chunks/main-mvnmEVmb.js +201 -0
- package/dist/cli.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/skills/README.md +1 -0
- package/skills/hagi/SKILL.md +14 -0
- package/skills/hagi/references/cli-usage.md +46 -4
- package/skills/hagi/references/proposal-flow.md +27 -0
- package/skills/hagi/references/resource-lock.md +135 -0
- package/dist/chunks/main-C3T3Iu-a.js +0 -176
package/README.md
CHANGED
|
@@ -117,9 +117,10 @@ hagi
|
|
|
117
117
|
|-- chat list | create | archive | delete | send
|
|
118
118
|
|-- hagitask list | schema | create | send | get | messages
|
|
119
119
|
|-- plan list | get | create | update | enable | disable | delete | run
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
|-- skills local list | enable | disable | uninstall
|
|
121
|
+
| gallery search | detail | install
|
|
122
|
+
| trusted list | upsert | delete | reset
|
|
123
|
+
`-- agent lock acquire | status | renew | heartbeat | release | requisition | list
|
|
123
124
|
```
|
|
124
125
|
|
|
125
126
|
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).
|
|
@@ -299,6 +300,19 @@ The CLI may suggest a next command, but it never chains later lifecycle APIs aut
|
|
|
299
300
|
|
|
300
301
|
Each command maps to one backend action. The CLI may suggest a next command, but it never chains later lifecycle APIs automatically.
|
|
301
302
|
|
|
303
|
+
`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:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
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')
|
|
307
|
+
hagi proposal create --project-id "$PROJECT_ID" --chief-complaint "Repository scope
|
|
308
|
+
Writable repositories:
|
|
309
|
+
- none
|
|
310
|
+
Read-only repositories:
|
|
311
|
+
- none
|
|
312
|
+
|
|
313
|
+
Tighten the settings page copy" --default-title --metadata role=worker --metadata master="$MASTER_ID" --json
|
|
314
|
+
```
|
|
315
|
+
|
|
302
316
|
## Vault Commands
|
|
303
317
|
|
|
304
318
|
Create a vault with a local folder to browse. The new id is read from `vault.id`:
|
|
@@ -370,6 +384,24 @@ hagi chat archive --session-id "$CHAT_ID"
|
|
|
370
384
|
hagi chat delete --session-id "$CHAT_ID"
|
|
371
385
|
```
|
|
372
386
|
|
|
387
|
+
### Session Metadata
|
|
388
|
+
|
|
389
|
+
`chat create` and `proposal create` take write-once metadata entries, for example the role markers an orchestrator uses to find its sessions again:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
hagi chat create --title "Master" --project-id "$PROJECT_ID" --metadata role=master --metadata batch=2026-11-07 --json
|
|
393
|
+
hagi chat create --title "Worker 1" --project-id "$PROJECT_ID" --metadata role=worker --metadata master="$MASTER_ID" --json
|
|
394
|
+
printf '{"role":"worker","master":"%s"}' "$MASTER_ID" | hagi chat create --title "Worker 2" --project-id "$PROJECT_ID" --metadata-json - --json
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
- `--metadata key=value` is repeatable. The text is split at the first `=`, so a value may contain `=`.
|
|
398
|
+
- `--metadata-json <file|->` reads a JSON object of string values from a file, or from stdin with `-`. It is repeatable.
|
|
399
|
+
- 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.
|
|
400
|
+
- 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.
|
|
401
|
+
- 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.
|
|
402
|
+
- 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.
|
|
403
|
+
|
|
404
|
+
|
|
373
405
|
## HagiTask Commands
|
|
374
406
|
|
|
375
407
|
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:
|
|
@@ -648,6 +680,39 @@ hagi skills trusted delete --provider-id example-provider
|
|
|
648
680
|
hagi skills trusted reset
|
|
649
681
|
```
|
|
650
682
|
|
|
683
|
+
## Agent Lock Commands
|
|
684
|
+
|
|
685
|
+
`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).
|
|
686
|
+
|
|
687
|
+
```bash
|
|
688
|
+
hagi agent lock acquire --lock-id eu-1/duckov --owner sess-7f2c
|
|
689
|
+
hagi agent lock acquire --server eu-1 --game duckov --owner sess-7f2c --wait --timeout 900
|
|
690
|
+
hagi agent lock status --lock-id eu-1/duckov --owner sess-7f2c --json
|
|
691
|
+
hagi agent lock heartbeat --lock-id eu-1/duckov --owner sess-7f2c --epoch 7
|
|
692
|
+
hagi agent lock release --lock-id eu-1/duckov --owner sess-7f2c --epoch 7
|
|
693
|
+
hagi agent lock requisition --lock-id eu-1/duckov --owner sess-7f2c --reason "User order: take the lock now"
|
|
694
|
+
hagi agent lock list --prefix eu-1/
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
- 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.
|
|
698
|
+
- 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`.
|
|
699
|
+
- `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.
|
|
700
|
+
- `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.
|
|
701
|
+
- `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.
|
|
702
|
+
- `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.
|
|
703
|
+
- Answers show the valid-until time, the 24-hour hard cap, the check-in window and, for a queued owner, the turn window.
|
|
704
|
+
|
|
705
|
+
| Timing | Default |
|
|
706
|
+
| --- | --- |
|
|
707
|
+
| Feedback timeout (no heartbeat releases the lock) | 10 minutes |
|
|
708
|
+
| Maximum hold | 24 hours |
|
|
709
|
+
| Heartbeat interval | 2 minutes |
|
|
710
|
+
| Claim window after a handoff | 30 seconds |
|
|
711
|
+
| Waiter TTL | 60 seconds |
|
|
712
|
+
| `acquire --wait` timeout | 900 seconds |
|
|
713
|
+
|
|
714
|
+
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.
|
|
715
|
+
|
|
651
716
|
## Steer (send option)
|
|
652
717
|
|
|
653
718
|
`hagi chat send`, `hagi proposal send`, and `hagi hagitask send` deliver a message in one of two ways:
|
|
@@ -717,7 +782,8 @@ Stable non-zero exits used by the CLI. The HTTP numbers are the equivalents of t
|
|
|
717
782
|
| `24` | HTTP 404 |
|
|
718
783
|
| `29` | HTTP 409 |
|
|
719
784
|
| `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` |
|
|
720
|
-
| `31` | Wait timed out: `--wait` on `proposal get` or `
|
|
785
|
+
| `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 |
|
|
786
|
+
| `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` |
|
|
721
787
|
| `40` | Other HTTP 4xx |
|
|
722
788
|
| `50` | HTTP 5xx |
|
|
723
789
|
| `60` | Transport or connection failure |
|