@agledger/cli 0.4.1 → 0.5.2

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.
Files changed (172) hide show
  1. package/LICENSE +115 -22
  2. package/README.md +74 -42
  3. package/SKILL.md +51 -17
  4. package/dist/api-client.js +1 -1
  5. package/dist/base.d.ts +43 -22
  6. package/dist/base.d.ts.map +1 -1
  7. package/dist/base.js +76 -87
  8. package/dist/base.js.map +1 -1
  9. package/dist/commands/admin/create-agent.d.ts.map +1 -1
  10. package/dist/commands/admin/create-agent.js +1 -2
  11. package/dist/commands/admin/create-agent.js.map +1 -1
  12. package/dist/commands/admin/create-enterprise.d.ts.map +1 -1
  13. package/dist/commands/admin/create-enterprise.js +1 -2
  14. package/dist/commands/admin/create-enterprise.js.map +1 -1
  15. package/dist/commands/admin/set-config.d.ts.map +1 -1
  16. package/dist/commands/admin/set-config.js +6 -8
  17. package/dist/commands/admin/set-config.js.map +1 -1
  18. package/dist/commands/agent/list.d.ts +3 -0
  19. package/dist/commands/agent/list.d.ts.map +1 -1
  20. package/dist/commands/agent/list.js +10 -2
  21. package/dist/commands/agent/list.js.map +1 -1
  22. package/dist/commands/api.d.ts +42 -0
  23. package/dist/commands/api.d.ts.map +1 -0
  24. package/dist/commands/api.js +174 -0
  25. package/dist/commands/api.js.map +1 -0
  26. package/dist/commands/auth.d.ts +5 -0
  27. package/dist/commands/auth.d.ts.map +1 -1
  28. package/dist/commands/auth.js +12 -4
  29. package/dist/commands/auth.js.map +1 -1
  30. package/dist/commands/config.d.ts +24 -0
  31. package/dist/commands/config.d.ts.map +1 -0
  32. package/dist/commands/config.js +75 -0
  33. package/dist/commands/config.js.map +1 -0
  34. package/dist/commands/discover.d.ts +20 -0
  35. package/dist/commands/discover.d.ts.map +1 -0
  36. package/dist/commands/discover.js +44 -0
  37. package/dist/commands/discover.js.map +1 -0
  38. package/dist/commands/federation/create-token.d.ts.map +1 -1
  39. package/dist/commands/federation/create-token.js +1 -2
  40. package/dist/commands/federation/create-token.js.map +1 -1
  41. package/dist/commands/federation/revoke-gateway.d.ts.map +1 -1
  42. package/dist/commands/federation/revoke-gateway.js +1 -2
  43. package/dist/commands/federation/revoke-gateway.js.map +1 -1
  44. package/dist/commands/help-json.d.ts.map +1 -1
  45. package/dist/commands/help-json.js +4 -4
  46. package/dist/commands/help-json.js.map +1 -1
  47. package/dist/commands/list-commands.d.ts +8 -1
  48. package/dist/commands/list-commands.d.ts.map +1 -1
  49. package/dist/commands/list-commands.js +22 -57
  50. package/dist/commands/list-commands.js.map +1 -1
  51. package/dist/commands/login.d.ts +5 -0
  52. package/dist/commands/login.d.ts.map +1 -1
  53. package/dist/commands/login.js +16 -14
  54. package/dist/commands/login.js.map +1 -1
  55. package/dist/commands/logout.d.ts +14 -0
  56. package/dist/commands/logout.d.ts.map +1 -0
  57. package/dist/commands/logout.js +33 -0
  58. package/dist/commands/logout.js.map +1 -0
  59. package/dist/commands/mandate/accept.d.ts +1 -0
  60. package/dist/commands/mandate/accept.d.ts.map +1 -1
  61. package/dist/commands/mandate/accept.js +9 -2
  62. package/dist/commands/mandate/accept.js.map +1 -1
  63. package/dist/commands/mandate/cancel.d.ts +1 -0
  64. package/dist/commands/mandate/cancel.d.ts.map +1 -1
  65. package/dist/commands/mandate/cancel.js +5 -0
  66. package/dist/commands/mandate/cancel.js.map +1 -1
  67. package/dist/commands/mandate/counter-propose.d.ts +3 -1
  68. package/dist/commands/mandate/counter-propose.d.ts.map +1 -1
  69. package/dist/commands/mandate/counter-propose.js +18 -3
  70. package/dist/commands/mandate/counter-propose.js.map +1 -1
  71. package/dist/commands/mandate/create.d.ts.map +1 -1
  72. package/dist/commands/mandate/create.js +14 -10
  73. package/dist/commands/mandate/create.js.map +1 -1
  74. package/dist/commands/mandate/list.js +1 -1
  75. package/dist/commands/mandate/list.js.map +1 -1
  76. package/dist/commands/mandate/outcome.d.ts +3 -1
  77. package/dist/commands/mandate/outcome.d.ts.map +1 -1
  78. package/dist/commands/mandate/outcome.js +21 -4
  79. package/dist/commands/mandate/outcome.js.map +1 -1
  80. package/dist/commands/mandate/receipts.d.ts +20 -0
  81. package/dist/commands/mandate/receipts.d.ts.map +1 -0
  82. package/dist/commands/mandate/receipts.js +29 -0
  83. package/dist/commands/mandate/receipts.js.map +1 -0
  84. package/dist/commands/mandate/reject.d.ts +1 -0
  85. package/dist/commands/mandate/reject.d.ts.map +1 -1
  86. package/dist/commands/mandate/reject.js +5 -0
  87. package/dist/commands/mandate/reject.js.map +1 -1
  88. package/dist/commands/mandate/request-revision.d.ts +1 -0
  89. package/dist/commands/mandate/request-revision.d.ts.map +1 -1
  90. package/dist/commands/mandate/request-revision.js +5 -0
  91. package/dist/commands/mandate/request-revision.js.map +1 -1
  92. package/dist/commands/mandate/transition.d.ts +3 -1
  93. package/dist/commands/mandate/transition.d.ts.map +1 -1
  94. package/dist/commands/mandate/transition.js +15 -4
  95. package/dist/commands/mandate/transition.js.map +1 -1
  96. package/dist/commands/receipt/list.d.ts +1 -0
  97. package/dist/commands/receipt/list.d.ts.map +1 -1
  98. package/dist/commands/receipt/list.js +1 -0
  99. package/dist/commands/receipt/list.js.map +1 -1
  100. package/dist/commands/receipt/submit.d.ts.map +1 -1
  101. package/dist/commands/receipt/submit.js +7 -16
  102. package/dist/commands/receipt/submit.js.map +1 -1
  103. package/dist/commands/schema/blank-template.d.ts.map +1 -1
  104. package/dist/commands/schema/blank-template.js +5 -3
  105. package/dist/commands/schema/blank-template.js.map +1 -1
  106. package/dist/commands/schema/check-compatibility.d.ts.map +1 -1
  107. package/dist/commands/schema/check-compatibility.js +2 -3
  108. package/dist/commands/schema/check-compatibility.js.map +1 -1
  109. package/dist/commands/schema/deprecate.d.ts.map +1 -1
  110. package/dist/commands/schema/deprecate.js +1 -2
  111. package/dist/commands/schema/deprecate.js.map +1 -1
  112. package/dist/commands/schema/diff.d.ts.map +1 -1
  113. package/dist/commands/schema/diff.js +2 -0
  114. package/dist/commands/schema/diff.js.map +1 -1
  115. package/dist/commands/schema/export.d.ts.map +1 -1
  116. package/dist/commands/schema/export.js +5 -3
  117. package/dist/commands/schema/export.js.map +1 -1
  118. package/dist/commands/schema/import.d.ts.map +1 -1
  119. package/dist/commands/schema/import.js +2 -4
  120. package/dist/commands/schema/import.js.map +1 -1
  121. package/dist/commands/schema/list.d.ts +3 -0
  122. package/dist/commands/schema/list.d.ts.map +1 -1
  123. package/dist/commands/schema/list.js +14 -3
  124. package/dist/commands/schema/list.js.map +1 -1
  125. package/dist/commands/schema/meta-schema.d.ts.map +1 -1
  126. package/dist/commands/schema/meta-schema.js +5 -3
  127. package/dist/commands/schema/meta-schema.js.map +1 -1
  128. package/dist/commands/schema/preview.d.ts.map +1 -1
  129. package/dist/commands/schema/preview.js +3 -2
  130. package/dist/commands/schema/preview.js.map +1 -1
  131. package/dist/commands/schema/register.d.ts.map +1 -1
  132. package/dist/commands/schema/register.js +2 -4
  133. package/dist/commands/schema/register.js.map +1 -1
  134. package/dist/commands/schema/template.d.ts.map +1 -1
  135. package/dist/commands/schema/template.js +5 -3
  136. package/dist/commands/schema/template.js.map +1 -1
  137. package/dist/commands/schema/validate.d.ts.map +1 -1
  138. package/dist/commands/schema/validate.js +3 -2
  139. package/dist/commands/schema/validate.js.map +1 -1
  140. package/dist/commands/schema/versions.d.ts +3 -0
  141. package/dist/commands/schema/versions.d.ts.map +1 -1
  142. package/dist/commands/schema/versions.js +14 -4
  143. package/dist/commands/schema/versions.js.map +1 -1
  144. package/dist/commands/verdict/render.d.ts +1 -0
  145. package/dist/commands/verdict/render.d.ts.map +1 -1
  146. package/dist/commands/verdict/render.js +5 -0
  147. package/dist/commands/verdict/render.js.map +1 -1
  148. package/dist/commands/verify.d.ts +27 -0
  149. package/dist/commands/verify.d.ts.map +1 -0
  150. package/dist/commands/verify.js +85 -0
  151. package/dist/commands/verify.js.map +1 -0
  152. package/dist/commands/webhook/create.d.ts.map +1 -1
  153. package/dist/commands/webhook/create.js +1 -2
  154. package/dist/commands/webhook/create.js.map +1 -1
  155. package/dist/commands/webhook/delete.d.ts +1 -0
  156. package/dist/commands/webhook/delete.d.ts.map +1 -1
  157. package/dist/commands/webhook/delete.js +9 -2
  158. package/dist/commands/webhook/delete.js.map +1 -1
  159. package/dist/commands/webhook/list.d.ts +3 -0
  160. package/dist/commands/webhook/list.d.ts.map +1 -1
  161. package/dist/commands/webhook/list.js +10 -3
  162. package/dist/commands/webhook/list.js.map +1 -1
  163. package/dist/util/config.d.ts +17 -0
  164. package/dist/util/config.d.ts.map +1 -0
  165. package/dist/util/config.js +37 -0
  166. package/dist/util/config.js.map +1 -0
  167. package/dist/util/field-parser.d.ts +28 -0
  168. package/dist/util/field-parser.d.ts.map +1 -0
  169. package/dist/util/field-parser.js +138 -0
  170. package/dist/util/field-parser.js.map +1 -0
  171. package/oclif.manifest.json +1167 -570
  172. package/package.json +2 -1
package/LICENSE CHANGED
@@ -2,33 +2,126 @@ Copyright (c) 2026 AGLedger LLC. All rights reserved.
2
2
 
3
3
  PROPRIETARY SOFTWARE LICENSE
4
4
 
5
- This software and associated documentation files (the "Software") are the
6
- proprietary property of AGLedger LLC. The Software is provided for use
7
- exclusively with a self-hosted AGLedger API instance.
5
+ This software, together with its associated documentation files (the "Software"),
6
+ is the proprietary property of AGLedger LLC ("Licensor"). The Software is
7
+ licensed, not sold. Your right to use the Software is limited as set out below.
8
8
 
9
- Permission is hereby granted to use the Software solely for the purpose of
10
- integrating with AGLedger services via the AGLedger API, subject to the
11
- following conditions:
9
+ BY DOWNLOADING, INSTALLING, COPYING, OR OTHERWISE USING THE SOFTWARE (INCLUDING
10
+ VIA `npm install`, `pip install`, OR ANY EQUIVALENT PACKAGE-MANAGER COMMAND),
11
+ YOU AGREE TO THE TERMS OF THIS LICENSE. IF YOU DO NOT AGREE, DO NOT DOWNLOAD,
12
+ INSTALL, OR USE THE SOFTWARE.
12
13
 
13
- 1. You may not copy, modify, merge, publish, distribute, sublicense, or sell
14
- copies of the Software, except as required to use it with the AGLedger API.
14
+ 1. GRANT OF USE
15
15
 
16
- 2. You may not use the Software to create a competing product or service.
16
+ Licensor grants you a limited, non-exclusive, non-transferable, revocable
17
+ license to install and use the Software solely for the purpose of integrating
18
+ with a self-hosted AGLedger deployment operated by you or your organization, or
19
+ by a third party on your behalf with your authorization. The Software is not
20
+ designed for, and is not licensed for use with, any AGLedger-hosted service.
21
+ AGLedger operates the AGLedger software on a self-hosted model; there is no
22
+ hosted AGLedger API.
17
23
 
18
- 3. You may not reverse engineer, decompile, or disassemble the Software,
19
- except to the extent permitted by applicable law.
24
+ 2. RESTRICTIONS
20
25
 
21
- Use of this software is subject to the AGLedger Terms of Service at
22
- https://agledger.ai/terms.
26
+ You may not:
23
27
 
24
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27
- AGLEDGER LLC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28
- AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ (a) copy, modify, merge, publish, distribute, sublicense, sell, rent, lease,
29
+ or transfer copies of the Software, except as strictly required to use
30
+ the Software for its intended integration purpose;
31
+ (b) offer the Software, or the functionality enabled by the Software, as a
32
+ hosted or managed service to third parties, whether as a standalone
33
+ offering or embedded within a larger service;
34
+ (c) use the Software to build, train, or benchmark a product or service that
35
+ competes with AGLedger;
36
+ (d) reverse engineer, decompile, or disassemble the Software, except to the
37
+ extent expressly permitted by applicable law that cannot be waived by
38
+ contract;
39
+ (e) circumvent, disable, or tamper with any authentication, license, or usage-
40
+ enforcement mechanism of the Software or of any AGLedger deployment;
41
+ (f) remove, alter, or obscure any copyright, trademark, patent, or other
42
+ proprietary notice in the Software;
43
+ (g) use the Software in violation of U.S. Export Administration Regulations,
44
+ economic sanctions, or other applicable export and trade-control laws.
30
45
 
31
- ---
46
+ 3. OPEN SOURCE COMPONENTS
32
47
 
33
- AGLedger™ and the Agentic Contract Specification™ are trademarks of
34
- AGLedger LLC. Patent pending.
48
+ The Software may include third-party open-source components, each subject to
49
+ its own license terms. A list of such components and their licenses is included
50
+ with or referenced from the Software. In the event of a conflict between this
51
+ License and an open-source license, the open-source license governs solely with
52
+ respect to that component.
53
+
54
+ 4. NO WARRANTY
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT WARRANTY OF ANY
57
+ KIND, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE
58
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
59
+ NONINFRINGEMENT. AGLEDGER LLC DOES NOT WARRANT THAT THE SOFTWARE WILL BE ERROR-
60
+ FREE, SECURE, OR UNINTERRUPTED.
61
+
62
+ 5. LIMITATION OF LIABILITY
63
+
64
+ The limitations in this Section 5 are a material inducement to AGLedger LLC to
65
+ make the Software publicly available at no charge, and they apply notwithstanding
66
+ any failure of essential purpose of any limited remedy and regardless of the
67
+ theory of liability (contract, tort, strict liability, statute, or otherwise).
68
+
69
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL AGLEDGER
70
+ LLC BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY,
71
+ OR PUNITIVE DAMAGES, OR FOR LOSS OF PROFITS, REVENUE, DATA, USE, GOODWILL, OR
72
+ BUSINESS OPPORTUNITY, ARISING FROM OR RELATED TO THE SOFTWARE, EVEN IF ADVISED
73
+ OF THE POSSIBILITY OF SUCH DAMAGES. AGLEDGER LLC'S TOTAL AGGREGATE LIABILITY
74
+ FOR ALL CLAIMS RELATED TO THE SOFTWARE SHALL NOT EXCEED ONE HUNDRED U.S.
75
+ DOLLARS ($100.00). Any claim must be commenced within one (1) year after the
76
+ cause of action accrues, to the maximum extent permitted by applicable law.
77
+
78
+ 6. EXPORT COMPLIANCE
79
+
80
+ The Software may include cryptographic functionality (including Ed25519, AES-
81
+ 256-GCM, SHA-256, and X25519). AGLedger LLC classifies the Software under
82
+ ECCN 5D002 in good faith. To the extent AGLedger LLC makes the source code of
83
+ the Software publicly available through a public repository, that source code
84
+ is subject to the treatment afforded under 15 CFR § 742.15(b) of the U.S.
85
+ Export Administration Regulations. Binary and object-code distributions are
86
+ subject to License Exception ENC under 15 CFR § 740.17, subject to the one-
87
+ time notification and any required Encryption Registration to the U.S. Bureau
88
+ of Industry and Security (BIS) and the NSA ENC Encryption Request Coordinator.
89
+ This statement is not a warranty; you are responsible for independently
90
+ confirming the correct classification and license authority for your use,
91
+ destination, and end-user. You shall not export or re-export the Software to
92
+ any destination, entity, or end-use prohibited by applicable export, sanctions,
93
+ or trade-control laws.
94
+
95
+ 7. TRADEMARKS
96
+
97
+ AGLedger, Agentic Ledger, Settlement Signal, and Agentic Operations and
98
+ Accountability Protocol (AOAP) are trademarks of AGLedger LLC. All other
99
+ trademarks are the property of their respective owners.
100
+
101
+ 8. PATENTS
102
+
103
+ The Software is covered by one or more U.S. patent applications pending before
104
+ the U.S. Patent and Trademark Office in AGLedger LLC's patent portfolio.
105
+
106
+ 9. RELATIONSHIP TO OTHER AGLEDGER AGREEMENTS
107
+
108
+ If you are also a Licensee under an AGLedger Software License Agreement
109
+ executed with an Order Form, that Software License Agreement governs your
110
+ organization's use of the Licensed Software (including the Software distributed
111
+ under this License) and supersedes this License to the extent of any conflict.
112
+ Absent such an agreement, this License is the exclusive and entire license
113
+ between you and AGLedger LLC for the Software.
114
+
115
+ 10. GOVERNING LAW
116
+
117
+ This License is governed by the laws of the State of Idaho, without regard to
118
+ its conflict-of-laws provisions. Any dispute arising out of or related to this
119
+ License shall first be subject to good-faith negotiation for thirty (30) days,
120
+ and then, at AGLedger LLC's option, to binding arbitration under the rules of
121
+ the American Arbitration Association in Ada County, Idaho, or to the state or
122
+ federal courts located in Ada County, Idaho. You consent to the personal
123
+ jurisdiction and venue of those forums.
124
+
125
+ 11. CONTACT
126
+
127
+ For licensing inquiries, contact: legal@agledger.ai
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 -- accountability and audit infrastructure for agentic systems.
3
+ The official CLI for the [AGLedger](https://www.agledger.ai) API — accountability and audit infrastructure for agentic systems.
4
4
 
5
- 54 commands across 10 topics. Designed for both human developers and AI agents.
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,105 @@ 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=http://localhost:3000
17
+ export AGLEDGER_API_URL=https://your-agledger-instance
19
18
 
20
- # Create and activate a mandate
21
- agledger mandate create --type ACH-PROC-v1 --activate \
22
- --data '{"enterpriseId":"...","contractVersion":"1","platform":"cli","criteria":{"item_spec":"500 units copper wire","quantity":{"target":500,"unit":"units"}}}'
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 receipt submit <mandate-id> \
26
- --data '{"item_secured":"Copper wire","quantity":500,"total_cost":{"amount":1150,"currency":"USD"},"supplier":{"id":"SUP-001","name":"Acme Wire Co"},"confirmation_ref":"PO-2026-0042"}'
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 mandate outcome <mandate-id> --receipt-id <receipt-id> --outcome PASS
42
+ agledger api POST /v1/mandates/<mandate-id>/outcome \
43
+ -F receiptId=<receipt-id> -F outcome=PASS
30
44
  ```
31
45
 
32
- ## Agent-Native Design
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
- The CLI is designed for AI agent consumption:
61
+ Merging order (low → high): `--data` → `--input` → `-F` → `--query`. Later sources override earlier keys.
35
62
 
36
- - **`--json`** on every command, auto-JSON when piped (non-TTY)
37
- - **`--quiet`** for exit-code-only operation
38
- - **`--dry-run`** on all mutating commands
39
- - **Structured errors** to stderr with `code`, `message`, `suggestion`
40
- - **Semantic exit codes** (0-10) for programmatic handling
41
- - **Three-tier discovery**: `SKILL.md` (~50 tokens) -> `list-commands --json` -> `help-json <command>`
42
- - **Never prompts interactively** -- fails with structured error
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
- # List all commands (~700 tokens)
48
- agledger list-commands --json
49
-
50
- # Get per-command schema (~200 tokens)
51
- agledger help-json "mandate create" --json
76
+ agledger list-commands --json # 9 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
- ## Topics
82
+ ## CLI-local commands (everything else is `agledger api`)
55
83
 
56
- | Topic | Commands | Description |
57
- |-------|----------|-------------|
58
- | mandate | 12 | Create, activate, transition, batch, chain, counter-propose, outcome |
59
- | schema | 16 | Contract type CRUD, diff, import/export, compatibility checking |
60
- | receipt | 3 | Submit evidence, list, get |
61
- | webhook | 3 | Create, list, delete |
62
- | audit | 2 | Trail (per-mandate), events (enterprise-wide) |
63
- | agent | 2 | List agents, reputation history |
64
- | verdict | 1 | Render principal verdict |
65
- | federation | 6 | Gateway management, health, audit log |
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
+ | `verify` | Offline audit export verification (hash chain + Ed25519, no network) |
93
+ | `list-commands` | Inventory (this list) |
94
+ | `help-json` | Per-command schema |
67
95
 
68
96
  ## Authentication
69
97
 
70
- Set `AGLEDGER_API_KEY` environment variable or pass `--api-key` flag:
71
-
72
98
  ```bash
73
- export AGLEDGER_API_KEY=ach_ent_... # Enterprise key
74
- export AGLEDGER_API_KEY=ach_age_... # Agent key (auto-routes to agent endpoints)
99
+ # Verifies the key against the API, stores under ~/.agledger/config.json
100
+ agledger login --api-key ach_ent_... --profile prod
101
+
102
+ # Switch profiles
103
+ agledger config use prod
104
+
105
+ # Or just use env vars per-invocation
106
+ AGLEDGER_API_KEY=... AGLEDGER_API_URL=... agledger api GET /v1/mandates
75
107
  ```
76
108
 
77
- Agent keys (`ach_age_*`) automatically route mandate creation to `POST /v1/mandates/agent`.
109
+ Agent keys (`ach_age_*`) and enterprise keys (`ach_ent_*`) are both accepted — the API routes them appropriately.
78
110
 
79
111
  ## Requirements
80
112
 
81
113
  - Node.js >= 22.0.0
82
- - A running [AGLedger API](https://agledger.ai) instance
114
+ - A running [AGLedger API](https://www.agledger.ai) instance
83
115
 
84
116
  ## License
85
117
 
package/SKILL.md CHANGED
@@ -1,25 +1,59 @@
1
1
  # AGLedger CLI
2
2
 
3
- Accountability and audit infrastructure for AI agents.
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.
6
+ Requires: `AGLEDGER_API_KEY` env var or `--api-key` flag. Optional: `AGLEDGER_API_URL`.
7
7
 
8
- ## Workflow
9
- Follow these steps to track accountability for your work:
10
- 1. `agledger schema list` — see available contract types
11
- 2. `agledger schema get <type>` — see required fields and examples
12
- 3. `agledger mandate create --type <type> --data '{"criteria":{...}}'` — create a mandate
13
- 4. `agledger receipt submit <mandateId> --data '{"evidence":{...}}'` — submit evidence when done
14
- 5. `agledger verdict render <mandateId> PASS --reason "..."` — record the outcome
8
+ ## Primary command: `agledger api`
9
+ Call any API endpoint:
15
10
 
16
- ## Discovery
17
- - `agledger list-commands --json` — full command inventory
18
- - `agledger help-json <command>` — per-command schema with args and flags
11
+ ```
12
+ agledger api <METHOD> <PATH> [--data JSON | --input FILE | -F key=value ...]
13
+ ```
19
14
 
20
- ## Key patterns
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.
22
+
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 (9 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
+ ## Offline audit verification
35
+ - `agledger verify <audit-export.json>` — verify a mandate audit export offline (RFC 8785 hash chain + Ed25519). No network, no API key. Exit 0 if valid, 1 if broken; `--json` for structured output; `--keys <file>` overrides embedded keys; `--require-key-id <id>` for high-assurance flows.
36
+
37
+ **What verification proves:**
38
+ - Every entry was signed by a key listed in the export (or supplied via `--keys`) at the moment the vault wrote it.
39
+ - Payloads have not been altered since signing (SHA-256 recomputation matches stored `payloadHash`).
40
+ - The hash chain is contiguous — no entries were inserted, removed, or reordered between positions.
41
+
42
+ **What verification does NOT prove:**
43
+ - That the signing key is *legitimate* — verify the key against `/.well-known/agledger-vault-keys.json` on the issuing instance (or the `/v1/verification-keys` API) out-of-band.
44
+ - That the export is *complete* — a vault operator can still truncate the export at either end.
45
+ - That the *content* the payload describes actually happened. Payloads record what the agent reported (declared intent); the verifier does not cross-check against external systems.
46
+
47
+ ## Agent-native patterns
21
48
  - `--json` on every command (auto when piped)
22
- - `--all` streams NDJSON through all pages
23
- - `--dry-run` on mutating commands
24
- - Structured errors on stderr with semantic exit codes (0-10)
25
- - Error responses include `suggestion` field with recovery guidance
49
+ - `--quiet` for exit-code-only operation
50
+ - `--dry-run` on `agledger api` shows the request without sending
51
+ - `--paginate` on GET follows cursors, streams NDJSON
52
+ - Structured errors on stderr: `{code, message, suggestion, ...}`
53
+ - Semantic exit codes (0-10)
54
+
55
+ ## Credentials
56
+ - `agledger login --api-key <key> [--profile NAME]` — verifies key, stores in `~/.agledger/config.json` (0600)
57
+ - `agledger logout [--profile NAME | --all]`
58
+ - `agledger config list | get | use <profile> | path`
59
+ - `agledger auth` — check login state (exit 0 whether logged in or not)
@@ -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.4.1',
22
+ 'User-Agent': 'agledger-cli/0.5.2',
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 auth.
3
- * All commands extend this for consistent behavior.
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,34 +51,36 @@ export declare abstract class BaseCommand extends Command {
32
51
  'api-key'?: string;
33
52
  'api-url'?: string;
34
53
  }): ApiClient;
35
- /** API call — passes through the full response body unchanged on success and error. */
36
- protected api(flags: {
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<Record<string, unknown>>;
43
- protected output(data: Record<string, unknown>): void;
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
- /** Stream all pages as NDJSON, or return a single page for outputPage(). */
51
- protected paginate(flags: {
52
- 'api-key'?: string;
53
- 'api-url'?: string;
54
- }, path: string, query: Record<string, unknown>, opts: {
55
- all: boolean;
56
- columns: string[];
57
- }): Promise<void>;
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
- /** Forward the full API error body to stderr — enriches with recovery suggestion if missing. */
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
- private recoveryHint;
63
84
  private statusToExitCode;
64
85
  }
65
86
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,iDAAiD;AACjD,eAAO,MAAM,QAAQ;;;;;;;;;;;;CAYX,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