@agledger/cli 0.4.0 → 0.5.1
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 +73 -42
- package/SKILL.md +39 -18
- package/dist/api-client.js +1 -1
- package/dist/base.d.ts +43 -21
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +76 -65
- package/dist/base.js.map +1 -1
- package/dist/commands/admin/create-agent.d.ts.map +1 -1
- package/dist/commands/admin/create-agent.js +1 -2
- package/dist/commands/admin/create-agent.js.map +1 -1
- package/dist/commands/admin/create-enterprise.d.ts.map +1 -1
- package/dist/commands/admin/create-enterprise.js +1 -2
- package/dist/commands/admin/create-enterprise.js.map +1 -1
- package/dist/commands/admin/set-config.d.ts.map +1 -1
- package/dist/commands/admin/set-config.js +6 -8
- package/dist/commands/admin/set-config.js.map +1 -1
- package/dist/commands/agent/list.d.ts +3 -0
- package/dist/commands/agent/list.d.ts.map +1 -1
- package/dist/commands/agent/list.js +10 -2
- package/dist/commands/agent/list.js.map +1 -1
- package/dist/commands/api.d.ts +42 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +174 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/auth.d.ts +5 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +12 -4
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/config.d.ts +24 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +75 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/discover.d.ts +20 -0
- package/dist/commands/discover.d.ts.map +1 -0
- package/dist/commands/discover.js +44 -0
- package/dist/commands/discover.js.map +1 -0
- package/dist/commands/federation/create-token.d.ts.map +1 -1
- package/dist/commands/federation/create-token.js +1 -2
- package/dist/commands/federation/create-token.js.map +1 -1
- package/dist/commands/federation/revoke-gateway.d.ts.map +1 -1
- package/dist/commands/federation/revoke-gateway.js +1 -2
- package/dist/commands/federation/revoke-gateway.js.map +1 -1
- package/dist/commands/help-json.d.ts.map +1 -1
- package/dist/commands/help-json.js +4 -4
- package/dist/commands/help-json.js.map +1 -1
- package/dist/commands/list-commands.d.ts +8 -1
- package/dist/commands/list-commands.d.ts.map +1 -1
- package/dist/commands/list-commands.js +21 -57
- package/dist/commands/list-commands.js.map +1 -1
- package/dist/commands/login.d.ts +5 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +16 -14
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +14 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +33 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/mandate/accept.d.ts +1 -0
- package/dist/commands/mandate/accept.d.ts.map +1 -1
- package/dist/commands/mandate/accept.js +9 -2
- package/dist/commands/mandate/accept.js.map +1 -1
- package/dist/commands/mandate/cancel.d.ts +1 -0
- package/dist/commands/mandate/cancel.d.ts.map +1 -1
- package/dist/commands/mandate/cancel.js +5 -0
- package/dist/commands/mandate/cancel.js.map +1 -1
- package/dist/commands/mandate/counter-propose.d.ts +3 -1
- package/dist/commands/mandate/counter-propose.d.ts.map +1 -1
- package/dist/commands/mandate/counter-propose.js +18 -3
- package/dist/commands/mandate/counter-propose.js.map +1 -1
- package/dist/commands/mandate/create.d.ts.map +1 -1
- package/dist/commands/mandate/create.js +14 -10
- package/dist/commands/mandate/create.js.map +1 -1
- package/dist/commands/mandate/list.js +1 -1
- package/dist/commands/mandate/list.js.map +1 -1
- package/dist/commands/mandate/outcome.d.ts +3 -1
- package/dist/commands/mandate/outcome.d.ts.map +1 -1
- package/dist/commands/mandate/outcome.js +21 -4
- package/dist/commands/mandate/outcome.js.map +1 -1
- package/dist/commands/mandate/receipts.d.ts +20 -0
- package/dist/commands/mandate/receipts.d.ts.map +1 -0
- package/dist/commands/mandate/receipts.js +29 -0
- package/dist/commands/mandate/receipts.js.map +1 -0
- package/dist/commands/mandate/reject.d.ts +1 -0
- package/dist/commands/mandate/reject.d.ts.map +1 -1
- package/dist/commands/mandate/reject.js +5 -0
- package/dist/commands/mandate/reject.js.map +1 -1
- package/dist/commands/mandate/request-revision.d.ts +1 -0
- package/dist/commands/mandate/request-revision.d.ts.map +1 -1
- package/dist/commands/mandate/request-revision.js +5 -0
- package/dist/commands/mandate/request-revision.js.map +1 -1
- package/dist/commands/mandate/transition.d.ts +3 -1
- package/dist/commands/mandate/transition.d.ts.map +1 -1
- package/dist/commands/mandate/transition.js +15 -4
- package/dist/commands/mandate/transition.js.map +1 -1
- package/dist/commands/receipt/list.d.ts +1 -0
- package/dist/commands/receipt/list.d.ts.map +1 -1
- package/dist/commands/receipt/list.js +1 -0
- package/dist/commands/receipt/list.js.map +1 -1
- package/dist/commands/receipt/submit.d.ts.map +1 -1
- package/dist/commands/receipt/submit.js +7 -16
- package/dist/commands/receipt/submit.js.map +1 -1
- package/dist/commands/schema/blank-template.d.ts.map +1 -1
- package/dist/commands/schema/blank-template.js +5 -3
- package/dist/commands/schema/blank-template.js.map +1 -1
- package/dist/commands/schema/check-compatibility.d.ts.map +1 -1
- package/dist/commands/schema/check-compatibility.js +2 -3
- package/dist/commands/schema/check-compatibility.js.map +1 -1
- package/dist/commands/schema/deprecate.d.ts.map +1 -1
- package/dist/commands/schema/deprecate.js +1 -2
- package/dist/commands/schema/deprecate.js.map +1 -1
- package/dist/commands/schema/diff.d.ts.map +1 -1
- package/dist/commands/schema/diff.js +2 -0
- package/dist/commands/schema/diff.js.map +1 -1
- package/dist/commands/schema/export.d.ts.map +1 -1
- package/dist/commands/schema/export.js +5 -3
- package/dist/commands/schema/export.js.map +1 -1
- package/dist/commands/schema/import.d.ts.map +1 -1
- package/dist/commands/schema/import.js +2 -4
- package/dist/commands/schema/import.js.map +1 -1
- package/dist/commands/schema/list.d.ts +3 -0
- package/dist/commands/schema/list.d.ts.map +1 -1
- package/dist/commands/schema/list.js +14 -3
- package/dist/commands/schema/list.js.map +1 -1
- package/dist/commands/schema/meta-schema.d.ts.map +1 -1
- package/dist/commands/schema/meta-schema.js +5 -3
- package/dist/commands/schema/meta-schema.js.map +1 -1
- package/dist/commands/schema/preview.d.ts.map +1 -1
- package/dist/commands/schema/preview.js +3 -2
- package/dist/commands/schema/preview.js.map +1 -1
- package/dist/commands/schema/register.d.ts.map +1 -1
- package/dist/commands/schema/register.js +2 -4
- package/dist/commands/schema/register.js.map +1 -1
- package/dist/commands/schema/template.d.ts.map +1 -1
- package/dist/commands/schema/template.js +5 -3
- package/dist/commands/schema/template.js.map +1 -1
- package/dist/commands/schema/validate.d.ts.map +1 -1
- package/dist/commands/schema/validate.js +3 -2
- package/dist/commands/schema/validate.js.map +1 -1
- package/dist/commands/schema/versions.d.ts +3 -0
- package/dist/commands/schema/versions.d.ts.map +1 -1
- package/dist/commands/schema/versions.js +14 -4
- package/dist/commands/schema/versions.js.map +1 -1
- package/dist/commands/verdict/render.d.ts +1 -0
- package/dist/commands/verdict/render.d.ts.map +1 -1
- package/dist/commands/verdict/render.js +5 -0
- package/dist/commands/verdict/render.js.map +1 -1
- package/dist/commands/webhook/create.d.ts.map +1 -1
- package/dist/commands/webhook/create.js +1 -2
- package/dist/commands/webhook/create.js.map +1 -1
- package/dist/commands/webhook/delete.d.ts +1 -0
- package/dist/commands/webhook/delete.d.ts.map +1 -1
- package/dist/commands/webhook/delete.js +9 -2
- package/dist/commands/webhook/delete.js.map +1 -1
- package/dist/commands/webhook/list.d.ts +3 -0
- package/dist/commands/webhook/list.d.ts.map +1 -1
- package/dist/commands/webhook/list.js +10 -3
- package/dist/commands/webhook/list.js.map +1 -1
- package/dist/util/config.d.ts +17 -0
- package/dist/util/config.d.ts.map +1 -0
- package/dist/util/config.js +37 -0
- package/dist/util/config.js.map +1 -0
- package/dist/util/field-parser.d.ts +28 -0
- package/dist/util/field-parser.d.ts.map +1 -0
- package/dist/util/field-parser.js +138 -0
- package/dist/util/field-parser.js.map +1 -0
- package/oclif.manifest.json +1254 -732
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @agledger/cli
|
|
2
2
|
|
|
3
|
-
The official CLI for the [AGLedger](https://agledger.ai) API
|
|
3
|
+
The official CLI for the [AGLedger](https://www.agledger.ai) API — accountability and audit infrastructure for agentic systems.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A **thin cover** over the API. The CLI passes your request straight through to the API and forwards the response — no hand-coded per-endpoint wrappers, no flag-to-body translation, no drift. Every AGLedger API route is reachable via `agledger api <METHOD> <path>`.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -13,73 +13,104 @@ npm install -g @agledger/cli
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
# Authenticate
|
|
17
16
|
export AGLEDGER_API_KEY=ach_ent_...
|
|
18
|
-
export AGLEDGER_API_URL=
|
|
17
|
+
export AGLEDGER_API_URL=https://your-agledger-instance
|
|
19
18
|
|
|
20
|
-
#
|
|
21
|
-
agledger
|
|
22
|
-
|
|
19
|
+
# Check health, identity, scopes, and get the quickstart workflow
|
|
20
|
+
agledger discover
|
|
21
|
+
|
|
22
|
+
# List contract types
|
|
23
|
+
agledger api GET /v1/schemas
|
|
24
|
+
|
|
25
|
+
# Create a mandate (raw JSON body)
|
|
26
|
+
agledger api POST /v1/mandates --data '{
|
|
27
|
+
"contractType": "ACH-PROC-v1",
|
|
28
|
+
"criteria": { "item_spec": "500 units copper wire", "quantity": { "target": 500 } }
|
|
29
|
+
}'
|
|
30
|
+
|
|
31
|
+
# Or build the body with typed fields
|
|
32
|
+
agledger api POST /v1/mandates \
|
|
33
|
+
-F contractType=ACH-PROC-v1 \
|
|
34
|
+
-F criteria.item_spec='500 units copper wire' \
|
|
35
|
+
-F criteria.quantity.target=500
|
|
23
36
|
|
|
24
37
|
# Submit a receipt
|
|
25
|
-
agledger
|
|
26
|
-
--data '{"
|
|
38
|
+
agledger api POST /v1/mandates/<mandate-id>/receipts \
|
|
39
|
+
--data '{"evidence":{"items_delivered":"copper wire","quantity_delivered":500}}'
|
|
27
40
|
|
|
28
41
|
# Render a verdict
|
|
29
|
-
agledger
|
|
42
|
+
agledger api POST /v1/mandates/<mandate-id>/outcome \
|
|
43
|
+
-F receiptId=<receipt-id> -F outcome=PASS
|
|
30
44
|
```
|
|
31
45
|
|
|
32
|
-
##
|
|
46
|
+
## Why a thin cover?
|
|
47
|
+
|
|
48
|
+
- **Zero drift.** When the API adds, renames, or removes a route, the CLI keeps working — no code change required.
|
|
49
|
+
- **One mental model.** The API docs are the CLI docs. What you read in the OpenAPI spec is what you type.
|
|
50
|
+
- **All 250+ routes on day one.** You get full parity, not a hand-picked subset.
|
|
51
|
+
|
|
52
|
+
## Ways to pass a body
|
|
53
|
+
|
|
54
|
+
| Flag | When to use |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `--data '{...}'` | Agent-friendly: one JSON string |
|
|
57
|
+
| `--input file.json` | Complex payloads; reuse files |
|
|
58
|
+
| `--input -` | Pipe JSON from stdin |
|
|
59
|
+
| `-F key=value` (repeatable) | Shell-friendly; typed (`true`/`false`/`null`/numbers); nested via `a.b=v`; arrays via `arr[]=v`; JSON literals via `k={...}` / `k=[...]` |
|
|
33
60
|
|
|
34
|
-
|
|
61
|
+
Merging order (low → high): `--data` → `--input` → `-F` → `--query`. Later sources override earlier keys.
|
|
35
62
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
63
|
+
## Agent-native DX
|
|
64
|
+
|
|
65
|
+
- `--json` on every command (auto when stdout is piped)
|
|
66
|
+
- `--quiet` suppresses output (exit code only)
|
|
67
|
+
- `--dry-run` on `agledger api` shows the request without sending
|
|
68
|
+
- `--paginate` on GET follows cursor pagination and streams NDJSON
|
|
69
|
+
- Structured errors on stderr: `{error: true, code, message, suggestion, ...}` — API errors pass through verbatim
|
|
70
|
+
- Semantic exit codes: 0 (OK), 2 (usage), 3 (auth), 4 (forbidden), 5 (not found), 6 (conflict), 7 (rate limit), 8 (server), 9 (network), 10 (timeout)
|
|
71
|
+
- `NO_COLOR` supported per [no-color.org](https://no-color.org)
|
|
43
72
|
|
|
44
73
|
## Discovery
|
|
45
74
|
|
|
46
75
|
```bash
|
|
47
|
-
#
|
|
48
|
-
agledger
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
agledger help-json "mandate create" --json
|
|
76
|
+
agledger list-commands --json # 8 CLI-local commands
|
|
77
|
+
agledger help-json api --json # Schema for `api` (args + flags)
|
|
78
|
+
agledger discover # Health + identity + quickstart
|
|
79
|
+
agledger api GET /openapi.json # Full API route catalog
|
|
52
80
|
```
|
|
53
81
|
|
|
54
|
-
##
|
|
82
|
+
## CLI-local commands (everything else is `agledger api`)
|
|
55
83
|
|
|
56
|
-
|
|
|
57
|
-
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
| admin | 3 | Enterprise/agent creation, config |
|
|
84
|
+
| Command | Purpose |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `api` | Call any API endpoint |
|
|
87
|
+
| `discover` | Health + identity + scopes + quickstart |
|
|
88
|
+
| `login` | Verify API key, store in `~/.agledger/config.json` (0600) |
|
|
89
|
+
| `logout` | Remove profile(s) |
|
|
90
|
+
| `auth` | Check current login state (exit 0 either way) |
|
|
91
|
+
| `config` | `list` / `get` / `use <profile>` / `path` |
|
|
92
|
+
| `list-commands` | Inventory (this list) |
|
|
93
|
+
| `help-json` | Per-command schema |
|
|
67
94
|
|
|
68
95
|
## Authentication
|
|
69
96
|
|
|
70
|
-
Set `AGLEDGER_API_KEY` environment variable or pass `--api-key` flag:
|
|
71
|
-
|
|
72
97
|
```bash
|
|
73
|
-
|
|
74
|
-
|
|
98
|
+
# Verifies the key against the API, stores under ~/.agledger/config.json
|
|
99
|
+
agledger login --api-key ach_ent_... --profile prod
|
|
100
|
+
|
|
101
|
+
# Switch profiles
|
|
102
|
+
agledger config use prod
|
|
103
|
+
|
|
104
|
+
# Or just use env vars per-invocation
|
|
105
|
+
AGLEDGER_API_KEY=... AGLEDGER_API_URL=... agledger api GET /v1/mandates
|
|
75
106
|
```
|
|
76
107
|
|
|
77
|
-
Agent keys (`ach_age_*`)
|
|
108
|
+
Agent keys (`ach_age_*`) and enterprise keys (`ach_ent_*`) are both accepted — the API routes them appropriately.
|
|
78
109
|
|
|
79
110
|
## Requirements
|
|
80
111
|
|
|
81
112
|
- Node.js >= 22.0.0
|
|
82
|
-
- A running [AGLedger API](https://agledger.ai) instance
|
|
113
|
+
- A running [AGLedger API](https://www.agledger.ai) instance
|
|
83
114
|
|
|
84
115
|
## License
|
|
85
116
|
|
package/SKILL.md
CHANGED
|
@@ -1,25 +1,46 @@
|
|
|
1
1
|
# AGLedger CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Thin cover over the AGLedger API. The CLI passes your call through to the API and forwards the response — no flag-to-body translation, no drift.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
|
-
Requires: `AGLEDGER_API_KEY` env var or `--api-key` flag.
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
```bash
|
|
14
|
-
agledger mandate list --status ACTIVE --json
|
|
15
|
-
agledger mandate create --type ACH-PROC-v1 --data '{"criteria":{"item":"widgets"}}'
|
|
16
|
-
agledger receipt submit MANDATE_ID --data '{"agentId":"agent-1","evidence":{"delivered":true}}'
|
|
17
|
-
agledger verdict render MANDATE_ID PASS --reason "Delivered as requested"
|
|
18
|
-
agledger audit trail MANDATE_ID
|
|
6
|
+
Requires: `AGLEDGER_API_KEY` env var or `--api-key` flag. Optional: `AGLEDGER_API_URL`.
|
|
7
|
+
|
|
8
|
+
## Primary command: `agledger api`
|
|
9
|
+
Call any API endpoint:
|
|
10
|
+
|
|
19
11
|
```
|
|
12
|
+
agledger api <METHOD> <PATH> [--data JSON | --input FILE | -F key=value ...]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Workflow (start here)
|
|
16
|
+
1. `agledger discover` — health, identity, scopes, quickstart steps.
|
|
17
|
+
2. `agledger api GET /v1/schemas` — list contract types.
|
|
18
|
+
3. `agledger api GET /v1/schemas/{contractType}` — required fields + examples.
|
|
19
|
+
4. `agledger api POST /v1/mandates --data '{"contractType":"...","criteria":{...}}'` — create a mandate.
|
|
20
|
+
5. `agledger api POST /v1/mandates/{id}/receipts --data '{"evidence":{...}}'` — submit receipt when done.
|
|
21
|
+
6. Every API response includes `nextSteps` — follow them.
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Ways to pass a body
|
|
24
|
+
- `--data '{"k":"v"}'` — raw JSON string (agent-friendly)
|
|
25
|
+
- `--input file.json` — read JSON from file
|
|
26
|
+
- `--input -` — read JSON from stdin
|
|
27
|
+
- `-F key=value` — repeatable; types parsed (`true`/`false`/`null`/numbers); nested via `a.b=v`; arrays via `arr[]=v`
|
|
28
|
+
|
|
29
|
+
## Discovery commands
|
|
30
|
+
- `agledger list-commands --json` — full CLI inventory (8 commands)
|
|
31
|
+
- `agledger help-json <command> --json` — per-command schema with args and flags
|
|
32
|
+
- `agledger api GET /openapi.json` — full API route catalog
|
|
33
|
+
|
|
34
|
+
## Agent-native patterns
|
|
22
35
|
- `--json` on every command (auto when piped)
|
|
23
|
-
- `--
|
|
24
|
-
- `--dry-run` on
|
|
25
|
-
-
|
|
36
|
+
- `--quiet` for exit-code-only operation
|
|
37
|
+
- `--dry-run` on `agledger api` shows the request without sending
|
|
38
|
+
- `--paginate` on GET follows cursors, streams NDJSON
|
|
39
|
+
- Structured errors on stderr: `{code, message, suggestion, ...}`
|
|
40
|
+
- Semantic exit codes (0-10)
|
|
41
|
+
|
|
42
|
+
## Credentials
|
|
43
|
+
- `agledger login --api-key <key> [--profile NAME]` — verifies key, stores in `~/.agledger/config.json` (0600)
|
|
44
|
+
- `agledger logout [--profile NAME | --all]`
|
|
45
|
+
- `agledger config list | get | use <profile> | path`
|
|
46
|
+
- `agledger auth` — check login state (exit 0 whether logged in or not)
|
package/dist/api-client.js
CHANGED
|
@@ -19,7 +19,7 @@ export class ApiClient {
|
|
|
19
19
|
const headers = {
|
|
20
20
|
Authorization: `Bearer ${this.apiKey}`,
|
|
21
21
|
Accept: 'application/json',
|
|
22
|
-
'User-Agent': 'agledger-cli/0.
|
|
22
|
+
'User-Agent': 'agledger-cli/0.5.1',
|
|
23
23
|
};
|
|
24
24
|
if (options?.body !== undefined) {
|
|
25
25
|
headers['Content-Type'] = 'application/json';
|
package/dist/base.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AGLedger CLI — Base command with dual-mode output and
|
|
3
|
-
*
|
|
2
|
+
* AGLedger CLI — Base command with dual-mode output, auth, and error forwarding.
|
|
3
|
+
* The CLI is a thin pass-through over the API — this base exists to make that
|
|
4
|
+
* pass-through consistent (same exit codes, same error shape, same output modes).
|
|
4
5
|
*/
|
|
5
6
|
import { Command } from '@oclif/core';
|
|
6
7
|
import { ApiClient } from './api-client.js';
|
|
7
8
|
import type { ApiResponse } from './api-client.js';
|
|
8
|
-
/** Semantic exit codes for agent consumption. */
|
|
9
|
+
/** Semantic exit codes for agent consumption. Stable across releases. */
|
|
9
10
|
export declare const ExitCode: {
|
|
10
11
|
readonly SUCCESS: 0;
|
|
11
12
|
readonly GENERAL_ERROR: 1;
|
|
@@ -19,6 +20,24 @@ export declare const ExitCode: {
|
|
|
19
20
|
readonly NETWORK_ERROR: 9;
|
|
20
21
|
readonly TIMEOUT: 10;
|
|
21
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Canonical CLI-origin error codes emitted in the `code` field of structured errors.
|
|
25
|
+
* Used only when the CLI itself can't forward an API error (no auth, bad JSON input,
|
|
26
|
+
* network failure). API-origin codes come through untouched from the API response body.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ErrorCode: {
|
|
29
|
+
readonly AUTH_REQUIRED: "AUTH_REQUIRED";
|
|
30
|
+
readonly COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND";
|
|
31
|
+
readonly MISSING_INPUT: "MISSING_INPUT";
|
|
32
|
+
readonly INVALID_JSON_INPUT: "INVALID_JSON_INPUT";
|
|
33
|
+
readonly INVALID_PATH: "INVALID_PATH";
|
|
34
|
+
readonly INVALID_METHOD: "INVALID_METHOD";
|
|
35
|
+
readonly INVALID_FIELD: "INVALID_FIELD";
|
|
36
|
+
readonly FILE_READ_ERROR: "FILE_READ_ERROR";
|
|
37
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
38
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
39
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
40
|
+
};
|
|
22
41
|
export declare abstract class BaseCommand extends Command {
|
|
23
42
|
static baseFlags: {
|
|
24
43
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -32,31 +51,34 @@ export declare abstract class BaseCommand extends Command {
|
|
|
32
51
|
'api-key'?: string;
|
|
33
52
|
'api-url'?: string;
|
|
34
53
|
}): ApiClient;
|
|
35
|
-
/**
|
|
36
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Call the API. Path is passed through as-is — caller provides the full path
|
|
56
|
+
* (e.g. `/v1/mandates`, `/health`, `/federation/v1/register`). No auto-prefixing.
|
|
57
|
+
*/
|
|
58
|
+
protected callApi(flags: {
|
|
37
59
|
'api-key'?: string;
|
|
38
60
|
'api-url'?: string;
|
|
39
61
|
}, method: string, path: string, options?: {
|
|
40
62
|
query?: Record<string, unknown>;
|
|
41
63
|
body?: unknown;
|
|
42
|
-
}): Promise<
|
|
43
|
-
protected output(data:
|
|
44
|
-
protected outputPage(page: {
|
|
45
|
-
data: unknown[];
|
|
46
|
-
hasMore?: boolean;
|
|
47
|
-
cursor?: string;
|
|
48
|
-
}, columns: string[]): void;
|
|
64
|
+
}): Promise<ApiResponse>;
|
|
65
|
+
protected output(data: unknown): void;
|
|
49
66
|
protected outputNdjson(item: unknown): void;
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Show a dry-run payload. Suppressed under --quiet. Writes header to stderr, payload to stdout.
|
|
69
|
+
* `label` describes the action concretely so agents can log what would have happened.
|
|
70
|
+
*/
|
|
71
|
+
protected dryRunOutput(payload: unknown, label: string): void;
|
|
72
|
+
/** Parse JSON with structured error on failure. Use for any user-supplied JSON input. */
|
|
73
|
+
protected parseJsonInput(source: string, fieldName: string): unknown;
|
|
74
|
+
/** Read and parse a JSON file with structured errors. `-` reads from stdin. */
|
|
75
|
+
protected readJsonSource(path: string, fieldName: string): unknown;
|
|
58
76
|
protected failWith(code: string, message: string, exitCode: number, suggestion?: string): never;
|
|
59
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Forward the full API error body to stderr verbatim. The API owns error
|
|
79
|
+
* guidance (code, message, suggestion, validationErrors, nextSteps); the CLI
|
|
80
|
+
* does not enrich, translate, or inject fields the API didn't return.
|
|
81
|
+
*/
|
|
60
82
|
protected handleApiError(response: ApiResponse): never;
|
|
61
83
|
protected handleError(err: unknown): never;
|
|
62
84
|
private statusToExitCode;
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC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AoBlE,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK;IAQ/F;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,KAAK;IAStD,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK;IA0B1C,OAAO,CAAC,gBAAgB;CASzB"}
|
package/dist/base.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AGLedger CLI — Base command with dual-mode output and
|
|
3
|
-
*
|
|
2
|
+
* AGLedger CLI — Base command with dual-mode output, auth, and error forwarding.
|
|
3
|
+
* The CLI is a thin pass-through over the API — this base exists to make that
|
|
4
|
+
* pass-through consistent (same exit codes, same error shape, same output modes).
|
|
4
5
|
*/
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
5
7
|
import { Command, Flags } from '@oclif/core';
|
|
6
8
|
import { ApiClient } from './api-client.js';
|
|
7
|
-
/** Semantic exit codes for agent consumption. */
|
|
9
|
+
/** Semantic exit codes for agent consumption. Stable across releases. */
|
|
8
10
|
export const ExitCode = {
|
|
9
11
|
SUCCESS: 0,
|
|
10
12
|
GENERAL_ERROR: 1,
|
|
@@ -18,9 +20,27 @@ export const ExitCode = {
|
|
|
18
20
|
NETWORK_ERROR: 9,
|
|
19
21
|
TIMEOUT: 10,
|
|
20
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Canonical CLI-origin error codes emitted in the `code` field of structured errors.
|
|
25
|
+
* Used only when the CLI itself can't forward an API error (no auth, bad JSON input,
|
|
26
|
+
* network failure). API-origin codes come through untouched from the API response body.
|
|
27
|
+
*/
|
|
28
|
+
export const ErrorCode = {
|
|
29
|
+
AUTH_REQUIRED: 'AUTH_REQUIRED',
|
|
30
|
+
COMMAND_NOT_FOUND: 'COMMAND_NOT_FOUND',
|
|
31
|
+
MISSING_INPUT: 'MISSING_INPUT',
|
|
32
|
+
INVALID_JSON_INPUT: 'INVALID_JSON_INPUT',
|
|
33
|
+
INVALID_PATH: 'INVALID_PATH',
|
|
34
|
+
INVALID_METHOD: 'INVALID_METHOD',
|
|
35
|
+
INVALID_FIELD: 'INVALID_FIELD',
|
|
36
|
+
FILE_READ_ERROR: 'FILE_READ_ERROR',
|
|
37
|
+
TIMEOUT: 'TIMEOUT',
|
|
38
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
39
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
40
|
+
};
|
|
21
41
|
export class BaseCommand extends Command {
|
|
22
42
|
static baseFlags = {
|
|
23
|
-
json: Flags.boolean({ description: '
|
|
43
|
+
json: Flags.boolean({ description: 'Force JSON output (default when stdout is piped)', default: false }),
|
|
24
44
|
quiet: Flags.boolean({ description: 'Suppress output (exit code only)', default: false }),
|
|
25
45
|
'api-key': Flags.string({ description: 'AGLedger API key', env: 'AGLEDGER_API_KEY' }),
|
|
26
46
|
'api-url': Flags.string({ description: 'AGLedger API base URL', env: 'AGLEDGER_API_URL' }),
|
|
@@ -34,20 +54,17 @@ export class BaseCommand extends Command {
|
|
|
34
54
|
createApiClient(flags) {
|
|
35
55
|
const apiKey = flags['api-key'];
|
|
36
56
|
if (!apiKey) {
|
|
37
|
-
this.failWith(
|
|
57
|
+
this.failWith(ErrorCode.AUTH_REQUIRED, 'No API key. Set AGLEDGER_API_KEY, use --api-key, or run `agledger login`.', ExitCode.AUTH_ERROR);
|
|
38
58
|
}
|
|
39
59
|
return new ApiClient(flags['api-url'] || 'https://agledger.example.com', apiKey);
|
|
40
60
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Call the API. Path is passed through as-is — caller provides the full path
|
|
63
|
+
* (e.g. `/v1/mandates`, `/health`, `/federation/v1/register`). No auto-prefixing.
|
|
64
|
+
*/
|
|
65
|
+
async callApi(flags, method, path, options) {
|
|
43
66
|
const client = this.createApiClient(flags);
|
|
44
|
-
|
|
45
|
-
const fullPath = path.startsWith('/health') || path.startsWith('/federation/') ? path : `/v1${path}`;
|
|
46
|
-
const response = await client.request(method, fullPath, options);
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
this.handleApiError(response);
|
|
49
|
-
}
|
|
50
|
-
return response.body;
|
|
67
|
+
return client.request(method, path, options);
|
|
51
68
|
}
|
|
52
69
|
output(data) {
|
|
53
70
|
if (this.isQuiet)
|
|
@@ -59,60 +76,51 @@ export class BaseCommand extends Command {
|
|
|
59
76
|
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
60
77
|
}
|
|
61
78
|
}
|
|
62
|
-
|
|
79
|
+
outputNdjson(item) {
|
|
63
80
|
if (this.isQuiet)
|
|
64
81
|
return;
|
|
65
|
-
|
|
66
|
-
process.stdout.write(JSON.stringify(page) + '\n');
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
if (page.data.length === 0) {
|
|
70
|
-
process.stderr.write('No results.\n');
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const rows = page.data;
|
|
74
|
-
const header = columns.join('\t');
|
|
75
|
-
process.stdout.write(header + '\n');
|
|
76
|
-
process.stdout.write(columns.map(() => '---').join('\t') + '\n');
|
|
77
|
-
for (const row of rows) {
|
|
78
|
-
process.stdout.write(columns.map((c) => String(row[c] ?? '')).join('\t') + '\n');
|
|
79
|
-
}
|
|
80
|
-
if (page.hasMore) {
|
|
81
|
-
process.stderr.write(`\n(more results available — use --all to stream all pages)\n`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
82
|
+
process.stdout.write(JSON.stringify(item) + '\n');
|
|
84
83
|
}
|
|
85
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Show a dry-run payload. Suppressed under --quiet. Writes header to stderr, payload to stdout.
|
|
86
|
+
* `label` describes the action concretely so agents can log what would have happened.
|
|
87
|
+
*/
|
|
88
|
+
dryRunOutput(payload, label) {
|
|
86
89
|
if (this.isQuiet)
|
|
87
90
|
return;
|
|
88
|
-
|
|
91
|
+
if (!this.isJson) {
|
|
92
|
+
process.stderr.write(`Dry run — ${label}:\n`);
|
|
93
|
+
}
|
|
94
|
+
this.output(payload);
|
|
89
95
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let prevCursor;
|
|
95
|
-
do {
|
|
96
|
-
if (cursor)
|
|
97
|
-
query.cursor = cursor;
|
|
98
|
-
const page = await this.api(flags, 'GET', path, { query });
|
|
99
|
-
const items = (page.data ?? []);
|
|
100
|
-
for (const item of items) {
|
|
101
|
-
this.outputNdjson(item);
|
|
102
|
-
}
|
|
103
|
-
if (page.hasMore === false || items.length === 0)
|
|
104
|
-
break;
|
|
105
|
-
const nextCursor = (page.nextCursor ?? page.cursor);
|
|
106
|
-
if (nextCursor === prevCursor || nextCursor === cursor)
|
|
107
|
-
break; // stale cursor guard
|
|
108
|
-
prevCursor = cursor;
|
|
109
|
-
cursor = nextCursor;
|
|
110
|
-
} while (cursor);
|
|
96
|
+
/** Parse JSON with structured error on failure. Use for any user-supplied JSON input. */
|
|
97
|
+
parseJsonInput(source, fieldName) {
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(source);
|
|
111
100
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err instanceof Error && err.message.startsWith('EEXIT:'))
|
|
103
|
+
throw err;
|
|
104
|
+
this.failWith(ErrorCode.INVALID_JSON_INPUT, `${fieldName} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`, ExitCode.USAGE_ERROR, 'Check that the JSON is properly quoted. For complex payloads, use --input <file> instead of --data.');
|
|
105
|
+
throw new Error('unreachable');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Read and parse a JSON file with structured errors. `-` reads from stdin. */
|
|
109
|
+
readJsonSource(path, fieldName) {
|
|
110
|
+
let content;
|
|
111
|
+
try {
|
|
112
|
+
if (path === '-') {
|
|
113
|
+
content = readFileSync(0, 'utf-8');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
content = readFileSync(path, 'utf-8');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
this.failWith(ErrorCode.FILE_READ_ERROR, `Cannot read ${fieldName} at ${path === '-' ? 'stdin' : path}: ${err instanceof Error ? err.message : String(err)}`, ExitCode.USAGE_ERROR, 'Check that the path exists and is readable, or pipe JSON to stdin with --input -.');
|
|
121
|
+
throw new Error('unreachable');
|
|
115
122
|
}
|
|
123
|
+
return this.parseJsonInput(content, path === '-' ? 'stdin' : `${fieldName} ${path}`);
|
|
116
124
|
}
|
|
117
125
|
failWith(code, message, exitCode, suggestion) {
|
|
118
126
|
const error = { error: true, code, message };
|
|
@@ -122,7 +130,11 @@ export class BaseCommand extends Command {
|
|
|
122
130
|
this.exit(exitCode);
|
|
123
131
|
throw new Error('unreachable');
|
|
124
132
|
}
|
|
125
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Forward the full API error body to stderr verbatim. The API owns error
|
|
135
|
+
* guidance (code, message, suggestion, validationErrors, nextSteps); the CLI
|
|
136
|
+
* does not enrich, translate, or inject fields the API didn't return.
|
|
137
|
+
*/
|
|
126
138
|
handleApiError(response) {
|
|
127
139
|
const body = (response.body ?? {});
|
|
128
140
|
const exitCode = this.statusToExitCode(response.status);
|
|
@@ -132,16 +144,15 @@ export class BaseCommand extends Command {
|
|
|
132
144
|
throw new Error('unreachable');
|
|
133
145
|
}
|
|
134
146
|
handleError(err) {
|
|
135
|
-
// Re-throw oclif exit errors — already handled by handleApiError/failWith
|
|
136
147
|
if (err instanceof Error && err.message.startsWith('EEXIT:'))
|
|
137
148
|
throw err;
|
|
138
149
|
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
139
|
-
this.failWith(
|
|
150
|
+
this.failWith(ErrorCode.TIMEOUT, 'Request timed out.', ExitCode.TIMEOUT, 'Retry the same command. If it persists, run `agledger discover` to check API connectivity.');
|
|
140
151
|
}
|
|
141
152
|
if (err instanceof TypeError && String(err.message).includes('fetch')) {
|
|
142
|
-
this.failWith(
|
|
153
|
+
this.failWith(ErrorCode.NETWORK_ERROR, String(err.message), ExitCode.NETWORK_ERROR, 'Check that AGLEDGER_API_URL is correct. Run `agledger discover` to verify connectivity.');
|
|
143
154
|
}
|
|
144
|
-
this.failWith(
|
|
155
|
+
this.failWith(ErrorCode.UNKNOWN_ERROR, err instanceof Error ? err.message : String(err), ExitCode.GENERAL_ERROR, 'Run `agledger api --help` to see usage.');
|
|
145
156
|
}
|
|
146
157
|
statusToExitCode(status) {
|
|
147
158
|
if (status === 401)
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,yEAAyE;AACzE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,CAAC;IAChB,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,EAAE;CACH,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,aAAa,EAAE,eAAe;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ources":["../../../src/commands/admin/create-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,WAAW;IACvD,OAAgB,WAAW,SAA6E;IACxG,OAAgB,KAAK;;;;;;;;;MAMnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"create-agent.d.ts","sourceRoot":"","sources":["../../../src/commands/admin/create-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,WAAW;IACvD,OAAgB,WAAW,SAA6E;IACxG,OAAgB,KAAK;;;;;;;;;MAMnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB3B"}
|
|
@@ -18,8 +18,7 @@ export default class AdminCreateAgent extends BaseCommand {
|
|
|
18
18
|
if (flags.email)
|
|
19
19
|
body.email = flags.email;
|
|
20
20
|
if (flags['dry-run']) {
|
|
21
|
-
|
|
22
|
-
this.output(body);
|
|
21
|
+
this.dryRunOutput(body, `would create agent "${flags.name}"`);
|
|
23
22
|
return;
|
|
24
23
|
}
|
|
25
24
|
const result = await this.api(flags, 'POST', '/admin/agents', { body });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent.js","sourceRoot":"","sources":["../../../src/commands/admin/create-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,WAAW;IACvD,MAAM,CAAU,WAAW,GAAG,yEAAyE,CAAC;IACxG,MAAM,CAAU,KAAK,GAAG;QACtB,GAAG,WAAW,CAAC,SAAS;QACxB,IAAI,EAAE,KAAK,CAAC,MAAM,CAA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AAe,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IAC5D,OAAgB,WAAW,SAAkF;IAC7G,OAAgB,KAAK;;;;;;;;;;MAOnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"create-enterprise.d.ts","sourceRoot":"","sources":["../../../src/commands/admin/create-enterprise.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IAC5D,OAAgB,WAAW,SAAkF;IAC7G,OAAgB,KAAK;;;;;;;;;;MAOnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmB3B"}
|
|
@@ -21,8 +21,7 @@ export default class AdminCreateEnterprise extends BaseCommand {
|
|
|
21
21
|
if (flags['trust-level'])
|
|
22
22
|
body.trustLevel = flags['trust-level'];
|
|
23
23
|
if (flags['dry-run']) {
|
|
24
|
-
|
|
25
|
-
this.output(body);
|
|
24
|
+
this.dryRunOutput(body, `would create enterprise "${flags.name}"`);
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
const result = await this.api(flags, 'POST', '/admin/enterprises', { body });
|