@grantex/cli 0.1.5 → 0.1.7
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 +177 -52
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +50 -11
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/anomalies.d.ts.map +1 -1
- package/dist/commands/anomalies.js +10 -2
- package/dist/commands/anomalies.js.map +1 -1
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +65 -3
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/authorize.d.ts +3 -0
- package/dist/commands/authorize.d.ts.map +1 -0
- package/dist/commands/authorize.js +42 -0
- package/dist/commands/authorize.js.map +1 -0
- package/dist/commands/billing.d.ts.map +1 -1
- package/dist/commands/billing.js +10 -2
- package/dist/commands/billing.js.map +1 -1
- package/dist/commands/budgets.d.ts +3 -0
- package/dist/commands/budgets.d.ts.map +1 -0
- package/dist/commands/budgets.js +83 -0
- package/dist/commands/budgets.js.map +1 -0
- package/dist/commands/compliance.d.ts.map +1 -1
- package/dist/commands/compliance.js +13 -3
- package/dist/commands/compliance.js.map +1 -1
- package/dist/commands/credentials.d.ts +3 -0
- package/dist/commands/credentials.d.ts.map +1 -0
- package/dist/commands/credentials.js +106 -0
- package/dist/commands/credentials.js.map +1 -0
- package/dist/commands/domains.d.ts +3 -0
- package/dist/commands/domains.d.ts.map +1 -0
- package/dist/commands/domains.js +70 -0
- package/dist/commands/domains.js.map +1 -0
- package/dist/commands/events.d.ts +3 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +34 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/grants.d.ts.map +1 -1
- package/dist/commands/grants.js +58 -3
- package/dist/commands/grants.js.map +1 -1
- package/dist/commands/me.d.ts +3 -0
- package/dist/commands/me.d.ts.map +1 -0
- package/dist/commands/me.js +46 -0
- package/dist/commands/me.js.map +1 -0
- package/dist/commands/passports.d.ts +3 -0
- package/dist/commands/passports.d.ts.map +1 -0
- package/dist/commands/passports.js +89 -0
- package/dist/commands/passports.js.map +1 -0
- package/dist/commands/policies.d.ts.map +1 -1
- package/dist/commands/policies.js +18 -2
- package/dist/commands/policies.js.map +1 -1
- package/dist/commands/principal-sessions.d.ts +3 -0
- package/dist/commands/principal-sessions.d.ts.map +1 -0
- package/dist/commands/principal-sessions.js +31 -0
- package/dist/commands/principal-sessions.js.map +1 -0
- package/dist/commands/scim.d.ts.map +1 -1
- package/dist/commands/scim.js +96 -4
- package/dist/commands/scim.js.map +1 -1
- package/dist/commands/sso.d.ts.map +1 -1
- package/dist/commands/sso.js +25 -2
- package/dist/commands/sso.js.map +1 -1
- package/dist/commands/tokens.d.ts.map +1 -1
- package/dist/commands/tokens.js +60 -2
- package/dist/commands/tokens.js.map +1 -1
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +44 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/vault.d.ts +3 -0
- package/dist/commands/vault.d.ts.map +1 -0
- package/dist/commands/vault.js +117 -0
- package/dist/commands/vault.js.map +1 -0
- package/dist/commands/webauthn.d.ts +3 -0
- package/dist/commands/webauthn.d.ts.map +1 -0
- package/dist/commands/webauthn.js +78 -0
- package/dist/commands/webauthn.js.map +1 -0
- package/dist/commands/webhooks.d.ts.map +1 -1
- package/dist/commands/webhooks.js +10 -2
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/format.d.ts +13 -5
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +42 -8
- package/dist/format.js.map +1 -1
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Command-line tool for the [Grantex](https://grantex.dev) delegated authorization protocol.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
83 commands covering the full Grantex API — agents, grants, tokens, policies, budgets, audit, compliance, credentials, and more. All commands support `--json` for machine-readable output.
|
|
6
6
|
|
|
7
|
-
> **[Homepage](https://grantex.dev)** | **[Docs](https://grantex.dev
|
|
7
|
+
> **[Homepage](https://grantex.dev)** | **[Docs](https://docs.grantex.dev)** | **[CLI Docs](https://docs.grantex.dev/integrations/cli)** | **[GitHub](https://github.com/mishrasanjeev/grantex)**
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -14,122 +14,247 @@ npm install -g @grantex/cli
|
|
|
14
14
|
|
|
15
15
|
## Configure
|
|
16
16
|
|
|
17
|
-
Point the CLI at your Grantex server and set your API key:
|
|
18
|
-
|
|
19
17
|
```bash
|
|
20
|
-
# Interactive setup
|
|
21
18
|
grantex config set --url https://grantex-auth-dd4mtrt2gq-uc.a.run.app --key YOUR_API_KEY
|
|
22
19
|
|
|
23
20
|
# Or use environment variables
|
|
24
21
|
export GRANTEX_URL=https://grantex-auth-dd4mtrt2gq-uc.a.run.app
|
|
25
22
|
export GRANTEX_KEY=YOUR_API_KEY
|
|
23
|
+
|
|
24
|
+
# Verify your setup
|
|
25
|
+
grantex me
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Config is saved to `~/.grantex/config.json`. Environment variables override the config file.
|
|
29
29
|
|
|
30
|
+
## JSON Output
|
|
31
|
+
|
|
32
|
+
All commands support `--json` for machine-readable output — ideal for scripting, `jq`, and AI coding assistants (Claude Code, Cursor, Codex).
|
|
33
|
+
|
|
30
34
|
```bash
|
|
31
|
-
|
|
32
|
-
grantex
|
|
35
|
+
grantex --json agents list | jq '.[0].agentId'
|
|
36
|
+
grantex --json tokens verify <jwt> | jq '.valid'
|
|
33
37
|
```
|
|
34
38
|
|
|
39
|
+
Set `NO_COLOR=1` to disable colored output.
|
|
40
|
+
|
|
35
41
|
## Commands
|
|
36
42
|
|
|
43
|
+
### Core Flow
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. Register an agent
|
|
47
|
+
grantex agents register --name "My Bot" --description "Reads email" --scopes email:read
|
|
48
|
+
|
|
49
|
+
# 2. Start authorization
|
|
50
|
+
grantex authorize --agent ag_... --principal user@example.com --scopes email:read
|
|
51
|
+
|
|
52
|
+
# 3. Exchange code for token
|
|
53
|
+
grantex tokens exchange --code <code> --agent-id ag_...
|
|
54
|
+
|
|
55
|
+
# 4. Verify the token
|
|
56
|
+
grantex tokens verify <jwt>
|
|
57
|
+
|
|
58
|
+
# 5. Refresh when needed
|
|
59
|
+
grantex tokens refresh --refresh-token <token> --agent-id ag_...
|
|
60
|
+
|
|
61
|
+
# 6. Revoke when done
|
|
62
|
+
grantex grants revoke grnt_...
|
|
63
|
+
```
|
|
64
|
+
|
|
37
65
|
### Agents
|
|
38
66
|
|
|
39
67
|
```bash
|
|
40
68
|
grantex agents list
|
|
41
|
-
grantex agents register --name
|
|
42
|
-
grantex agents get
|
|
43
|
-
grantex agents update
|
|
44
|
-
grantex agents delete
|
|
69
|
+
grantex agents register --name bot --description "..." --scopes email:read,calendar:write
|
|
70
|
+
grantex agents get ag_...
|
|
71
|
+
grantex agents update ag_... --name new-name --scopes email:read
|
|
72
|
+
grantex agents delete ag_...
|
|
45
73
|
```
|
|
46
74
|
|
|
47
75
|
### Grants
|
|
48
76
|
|
|
49
77
|
```bash
|
|
50
|
-
grantex grants list
|
|
51
|
-
grantex grants
|
|
52
|
-
grantex grants revoke
|
|
78
|
+
grantex grants list [--agent ag_... --status active]
|
|
79
|
+
grantex grants get grnt_...
|
|
80
|
+
grantex grants revoke grnt_...
|
|
81
|
+
grantex grants delegate --grant-token <jwt> --agent-id ag_child... --scopes email:read
|
|
53
82
|
```
|
|
54
83
|
|
|
55
84
|
### Tokens
|
|
56
85
|
|
|
57
86
|
```bash
|
|
58
|
-
grantex tokens
|
|
87
|
+
grantex tokens exchange --code <code> --agent-id ag_...
|
|
88
|
+
grantex tokens verify <jwt>
|
|
89
|
+
grantex tokens refresh --refresh-token <token> --agent-id ag_...
|
|
59
90
|
grantex tokens revoke <jti>
|
|
60
91
|
```
|
|
61
92
|
|
|
62
|
-
###
|
|
93
|
+
### Authorize
|
|
63
94
|
|
|
64
95
|
```bash
|
|
65
|
-
grantex
|
|
66
|
-
grantex
|
|
96
|
+
grantex authorize --agent ag_... --principal user@example.com --scopes email:read
|
|
97
|
+
grantex authorize --agent ag_... --principal user@example.com --scopes email:read \
|
|
98
|
+
--code-challenge <S256-challenge> --redirect-uri https://app.com/callback
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Audit
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
grantex audit list [--agent ag_... --grant grnt_... --action email.read --since 2026-01-01]
|
|
105
|
+
grantex audit get alog_...
|
|
106
|
+
grantex audit log --agent-id ag_... --agent-did did:grantex:ag_... --grant-id grnt_... \
|
|
107
|
+
--principal-id user@example.com --action email.read --status success
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Policies
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
grantex policies list
|
|
114
|
+
grantex policies get pol_...
|
|
115
|
+
grantex policies create --name "Allow Bot" --effect allow --agent-id ag_... --scopes email:read
|
|
116
|
+
grantex policies update pol_... --priority 50
|
|
117
|
+
grantex policies delete pol_...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Budgets
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
grantex budgets allocate --grant-id grnt_... --amount 100 [--currency USD]
|
|
124
|
+
grantex budgets debit --grant-id grnt_... --amount 25.50 --description "API call"
|
|
125
|
+
grantex budgets balance grnt_...
|
|
126
|
+
grantex budgets transactions grnt_...
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Usage
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
grantex usage current
|
|
133
|
+
grantex usage history [--days 7]
|
|
67
134
|
```
|
|
68
135
|
|
|
69
136
|
### Webhooks
|
|
70
137
|
|
|
71
138
|
```bash
|
|
72
139
|
grantex webhooks list
|
|
73
|
-
grantex webhooks create --url https://example.com/hook --events grant.created,
|
|
74
|
-
grantex webhooks delete
|
|
140
|
+
grantex webhooks create --url https://example.com/hook --events grant.created,token.issued
|
|
141
|
+
grantex webhooks delete wh_...
|
|
75
142
|
```
|
|
76
143
|
|
|
77
|
-
|
|
144
|
+
### Events
|
|
78
145
|
|
|
79
|
-
|
|
146
|
+
```bash
|
|
147
|
+
grantex events stream [--types grant.created,token.issued]
|
|
148
|
+
grantex --json events stream # One JSON object per line
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Domains
|
|
80
152
|
|
|
81
153
|
```bash
|
|
82
|
-
|
|
83
|
-
grantex
|
|
84
|
-
grantex
|
|
154
|
+
grantex domains list
|
|
155
|
+
grantex domains add --domain auth.mycompany.com
|
|
156
|
+
grantex domains verify dom_...
|
|
157
|
+
grantex domains delete dom_...
|
|
158
|
+
```
|
|
85
159
|
|
|
86
|
-
|
|
87
|
-
grantex compliance export grants --format json --output grants.json
|
|
160
|
+
### Vault (Credential Storage)
|
|
88
161
|
|
|
89
|
-
|
|
90
|
-
grantex
|
|
162
|
+
```bash
|
|
163
|
+
grantex vault list [--principal user@example.com --service google]
|
|
164
|
+
grantex vault get cred_...
|
|
165
|
+
grantex vault store --principal-id user@example.com --service google --access-token ya29...
|
|
166
|
+
grantex vault delete cred_...
|
|
167
|
+
grantex vault exchange --grant-token <jwt> --service google
|
|
168
|
+
```
|
|
91
169
|
|
|
92
|
-
|
|
170
|
+
### WebAuthn / FIDO2
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
grantex webauthn register-options --principal-id user@example.com
|
|
174
|
+
grantex webauthn register-verify --challenge-id ch_... --response '{"id":"..."}' --device-name "MacBook"
|
|
175
|
+
grantex webauthn list user@example.com
|
|
176
|
+
grantex webauthn delete cred_...
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Verifiable Credentials
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
grantex credentials list [--grant-id grnt_... --status active]
|
|
183
|
+
grantex credentials get vc_...
|
|
184
|
+
grantex credentials verify --vc-jwt eyJ...
|
|
185
|
+
grantex credentials present --sd-jwt eyJ... --nonce abc123
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Agent Passports (MPP)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
grantex passports issue --agent-id ag_... --grant-id grnt_... --categories "compute,storage" --max-amount 100
|
|
192
|
+
grantex passports list [--agent-id ag_...]
|
|
193
|
+
grantex passports get pp_...
|
|
194
|
+
grantex passports revoke pp_...
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Principal Sessions
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
grantex principal-sessions create --principal-id user@example.com [--expires-in 1h]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Account
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
grantex me
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Compliance
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
grantex compliance summary [--since 2026-01-01 --until 2026-02-01]
|
|
213
|
+
grantex compliance export grants --format json --output grants.json
|
|
214
|
+
grantex compliance export audit --format json --output audit.json
|
|
93
215
|
grantex compliance evidence-pack --framework soc2 --output evidence.json
|
|
94
216
|
```
|
|
95
217
|
|
|
96
|
-
###
|
|
218
|
+
### Anomalies
|
|
97
219
|
|
|
98
220
|
```bash
|
|
99
221
|
grantex anomalies detect
|
|
100
|
-
grantex anomalies list
|
|
101
|
-
grantex anomalies
|
|
102
|
-
grantex anomalies acknowledge anom_01XYZ...
|
|
222
|
+
grantex anomalies list [--unacknowledged]
|
|
223
|
+
grantex anomalies acknowledge anom_...
|
|
103
224
|
```
|
|
104
225
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
For local development with `docker compose`:
|
|
226
|
+
### Billing
|
|
108
227
|
|
|
109
228
|
```bash
|
|
110
|
-
grantex
|
|
229
|
+
grantex billing status
|
|
230
|
+
grantex billing checkout pro --success-url https://app.com/ok --cancel-url https://app.com/cancel
|
|
231
|
+
grantex billing portal --return-url https://app.com/settings
|
|
111
232
|
```
|
|
112
233
|
|
|
113
|
-
|
|
234
|
+
### SCIM
|
|
114
235
|
|
|
115
|
-
|
|
236
|
+
```bash
|
|
237
|
+
grantex scim tokens list | create --label "Okta" | revoke tok_...
|
|
238
|
+
grantex scim users list | get usr_... | create --user-name john@co.com | update usr_... | delete usr_...
|
|
239
|
+
```
|
|
116
240
|
|
|
117
|
-
|
|
241
|
+
### SSO
|
|
118
242
|
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
|
|
122
|
-
|
|
243
|
+
```bash
|
|
244
|
+
grantex sso get | configure --issuer-url ... --client-id ... | delete
|
|
245
|
+
grantex sso login-url my-org
|
|
246
|
+
grantex sso callback --code CODE --state STATE
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Local Development
|
|
123
250
|
|
|
124
|
-
|
|
251
|
+
```bash
|
|
252
|
+
grantex config set --url http://localhost:3001 --key dev-api-key-local
|
|
253
|
+
```
|
|
125
254
|
|
|
126
|
-
|
|
255
|
+
## Requirements
|
|
127
256
|
|
|
128
|
-
-
|
|
129
|
-
- [`grantex`](https://pypi.org/project/grantex/) — Python SDK
|
|
130
|
-
- [`@grantex/langchain`](https://www.npmjs.com/package/@grantex/langchain) — LangChain integration
|
|
131
|
-
- [`@grantex/mcp`](https://www.npmjs.com/package/@grantex/mcp) — MCP server for Claude Desktop / Cursor / Windsurf
|
|
132
|
-
- [`@grantex/vercel-ai`](https://www.npmjs.com/package/@grantex/vercel-ai) — Vercel AI SDK integration
|
|
257
|
+
- Node.js 18+
|
|
133
258
|
|
|
134
259
|
## License
|
|
135
260
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,aAAa,IAAI,OAAO,CAuGvC"}
|
package/dist/commands/agents.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { requireClient } from '../client.js';
|
|
4
|
-
import { printTable, printRecord, shortDate } from '../format.js';
|
|
4
|
+
import { printTable, printRecord, shortDate, isJsonMode } from '../format.js';
|
|
5
|
+
// The API returns `agentId` but the SDK type says `id`. Handle both.
|
|
6
|
+
function agentId(a) {
|
|
7
|
+
return String(a.agentId ?? a.id ?? '');
|
|
8
|
+
}
|
|
5
9
|
export function agentsCommand() {
|
|
6
10
|
const cmd = new Command('agents').description('Manage registered agents');
|
|
7
11
|
cmd
|
|
@@ -11,11 +15,11 @@ export function agentsCommand() {
|
|
|
11
15
|
const client = await requireClient();
|
|
12
16
|
const { agents } = await client.agents.list();
|
|
13
17
|
printTable(agents.map((a) => ({
|
|
14
|
-
ID: a
|
|
18
|
+
ID: agentId(a),
|
|
15
19
|
NAME: a.name,
|
|
16
20
|
DID: a.did,
|
|
17
21
|
CREATED: shortDate(a.createdAt),
|
|
18
|
-
})), ['ID', 'NAME', 'DID', 'CREATED']);
|
|
22
|
+
})), ['ID', 'NAME', 'DID', 'CREATED'], agents.map((a) => ({ ...a })));
|
|
19
23
|
});
|
|
20
24
|
cmd
|
|
21
25
|
.command('register')
|
|
@@ -30,9 +34,14 @@ export function agentsCommand() {
|
|
|
30
34
|
description: opts.description,
|
|
31
35
|
scopes: opts.scopes.split(',').map((s) => s.trim()),
|
|
32
36
|
});
|
|
33
|
-
|
|
37
|
+
if (isJsonMode()) {
|
|
38
|
+
console.log(JSON.stringify(agent, null, 2));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const id = agentId(agent);
|
|
42
|
+
console.log(chalk.green('✓') + ` Agent registered: ${id}`);
|
|
34
43
|
printRecord({
|
|
35
|
-
id
|
|
44
|
+
id,
|
|
36
45
|
name: agent.name,
|
|
37
46
|
did: agent.did,
|
|
38
47
|
scopes: agent.scopes.join(', '),
|
|
@@ -42,11 +51,15 @@ export function agentsCommand() {
|
|
|
42
51
|
cmd
|
|
43
52
|
.command('get <agentId>')
|
|
44
53
|
.description('Get details for a single agent')
|
|
45
|
-
.action(async (
|
|
54
|
+
.action(async (agentIdArg) => {
|
|
46
55
|
const client = await requireClient();
|
|
47
|
-
const agent = await client.agents.get(
|
|
56
|
+
const agent = await client.agents.get(agentIdArg);
|
|
57
|
+
if (isJsonMode()) {
|
|
58
|
+
console.log(JSON.stringify(agent, null, 2));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
48
61
|
printRecord({
|
|
49
|
-
id: agent
|
|
62
|
+
id: agentId(agent),
|
|
50
63
|
name: agent.name,
|
|
51
64
|
did: agent.did,
|
|
52
65
|
description: agent.description,
|
|
@@ -54,13 +67,39 @@ export function agentsCommand() {
|
|
|
54
67
|
createdAt: shortDate(agent.createdAt),
|
|
55
68
|
});
|
|
56
69
|
});
|
|
70
|
+
cmd
|
|
71
|
+
.command('update <agentId>')
|
|
72
|
+
.description('Update an agent')
|
|
73
|
+
.option('--name <name>', 'New agent name')
|
|
74
|
+
.option('--description <desc>', 'New agent description')
|
|
75
|
+
.option('--scopes <scopes>', 'New comma-separated scopes')
|
|
76
|
+
.action(async (agentIdArg, opts) => {
|
|
77
|
+
const client = await requireClient();
|
|
78
|
+
const updates = {};
|
|
79
|
+
if (opts.name !== undefined)
|
|
80
|
+
updates.name = opts.name;
|
|
81
|
+
if (opts.description !== undefined)
|
|
82
|
+
updates.description = opts.description;
|
|
83
|
+
if (opts.scopes !== undefined)
|
|
84
|
+
updates.scopes = opts.scopes.split(',').map((s) => s.trim());
|
|
85
|
+
const agent = await client.agents.update(agentIdArg, updates);
|
|
86
|
+
if (isJsonMode()) {
|
|
87
|
+
console.log(JSON.stringify(agent, null, 2));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log(chalk.green('✓') + ` Agent ${agentIdArg} updated.`);
|
|
91
|
+
});
|
|
57
92
|
cmd
|
|
58
93
|
.command('delete <agentId>')
|
|
59
94
|
.description('Delete an agent')
|
|
60
|
-
.action(async (
|
|
95
|
+
.action(async (agentIdArg) => {
|
|
61
96
|
const client = await requireClient();
|
|
62
|
-
await client.agents.delete(
|
|
63
|
-
|
|
97
|
+
await client.agents.delete(agentIdArg);
|
|
98
|
+
if (isJsonMode()) {
|
|
99
|
+
console.log(JSON.stringify({ deleted: agentIdArg }));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
console.log(chalk.green('✓') + ` Agent ${agentIdArg} deleted.`);
|
|
64
103
|
});
|
|
65
104
|
return cmd;
|
|
66
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9E,qEAAqE;AACrE,SAAS,OAAO,CAAC,CA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,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC9D,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,UAAU,WAAW,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEL,GAAG;SACA,OAAO,CAAC,kBAAkB,CAAC;SAC3B,WAAW,CAAC,iBAAiB,CAAC;SAC9B,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,EAAE;QACnC,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;QACrC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,UAAU,WAAW,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anomalies.d.ts","sourceRoot":"","sources":["../../src/commands/anomalies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wBAAgB,gBAAgB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"anomalies.d.ts","sourceRoot":"","sources":["../../src/commands/anomalies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBpC,wBAAgB,gBAAgB,IAAI,OAAO,CA0D1C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { requireClient } from '../client.js';
|
|
4
|
-
import { printTable } from '../format.js';
|
|
4
|
+
import { printTable, isJsonMode } from '../format.js';
|
|
5
5
|
const SEVERITY_COLOR = {
|
|
6
6
|
high: chalk.red,
|
|
7
7
|
medium: chalk.yellow,
|
|
@@ -18,6 +18,10 @@ export function anomaliesCommand() {
|
|
|
18
18
|
.action(async () => {
|
|
19
19
|
const client = await requireClient();
|
|
20
20
|
const result = await client.anomalies.detect();
|
|
21
|
+
if (isJsonMode()) {
|
|
22
|
+
console.log(JSON.stringify(result, null, 2));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
21
25
|
if (result.total === 0) {
|
|
22
26
|
console.log(chalk.green('✓') + ' No anomalies detected.');
|
|
23
27
|
return;
|
|
@@ -34,7 +38,7 @@ export function anomaliesCommand() {
|
|
|
34
38
|
const result = await client.anomalies.list({
|
|
35
39
|
...(opts.unacknowledged ? { unacknowledged: true } : {}),
|
|
36
40
|
});
|
|
37
|
-
printTable(result.anomalies.map(formatRow), ['ID', 'TYPE', 'SEVERITY', 'AGENT', 'DESCRIPTION']);
|
|
41
|
+
printTable(result.anomalies.map(formatRow), ['ID', 'TYPE', 'SEVERITY', 'AGENT', 'DESCRIPTION'], result.anomalies.map((a) => ({ ...a })));
|
|
38
42
|
});
|
|
39
43
|
cmd
|
|
40
44
|
.command('acknowledge <anomalyId>')
|
|
@@ -42,6 +46,10 @@ export function anomaliesCommand() {
|
|
|
42
46
|
.action(async (anomalyId) => {
|
|
43
47
|
const client = await requireClient();
|
|
44
48
|
await client.anomalies.acknowledge(anomalyId);
|
|
49
|
+
if (isJsonMode()) {
|
|
50
|
+
console.log(JSON.stringify({ acknowledged: anomalyId }));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
45
53
|
console.log(chalk.green('✓') + ` Anomaly ${anomalyId} acknowledged.`);
|
|
46
54
|
});
|
|
47
55
|
return cmd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anomalies.js","sourceRoot":"","sources":["../../src/commands/anomalies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"anomalies.js","sourceRoot":"","sources":["../../src/commands/anomalies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,cAAc,CAAC;AAGjE,MAAM,cAAc,GAA0C;IAC5D,IAAI,EAAI,KAAK,CAAC,GAAG;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM;IACpB,GAAG,EAAK,KAAK,CAAC,IAAI;CACnB,CAAC;AAEF,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,mCAAmC,CAAC,CAAC;IAEtF,GAAG;SACA,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;QACrC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-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,YAAY,IAAI,OAAO,CAyHtC"}
|
package/dist/commands/audit.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import { requireClient } from '../client.js';
|
|
3
|
-
import { printTable, shortDate } from '../format.js';
|
|
4
|
+
import { printTable, printRecord, shortDate, isJsonMode } from '../format.js';
|
|
4
5
|
export function auditCommand() {
|
|
5
|
-
const cmd = new Command('audit').description('View the audit log');
|
|
6
|
+
const cmd = new Command('audit').description('View and manage the audit log');
|
|
6
7
|
cmd
|
|
7
8
|
.command('list')
|
|
8
9
|
.description('List audit entries')
|
|
@@ -28,7 +29,68 @@ export function auditCommand() {
|
|
|
28
29
|
ACTION: e.action,
|
|
29
30
|
STATUS: e.status,
|
|
30
31
|
TIMESTAMP: shortDate(e.timestamp),
|
|
31
|
-
})), ['ID', 'AGENT', 'ACTION', 'STATUS', 'TIMESTAMP']);
|
|
32
|
+
})), ['ID', 'AGENT', 'ACTION', 'STATUS', 'TIMESTAMP'], entries.map((e) => ({ ...e })));
|
|
33
|
+
});
|
|
34
|
+
cmd
|
|
35
|
+
.command('get <entryId>')
|
|
36
|
+
.description('Get a single audit entry by ID')
|
|
37
|
+
.action(async (entryId) => {
|
|
38
|
+
const client = await requireClient();
|
|
39
|
+
const entry = await client.audit.get(entryId);
|
|
40
|
+
if (isJsonMode()) {
|
|
41
|
+
console.log(JSON.stringify(entry, null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
printRecord({
|
|
45
|
+
entryId: entry.entryId,
|
|
46
|
+
agentId: entry.agentId,
|
|
47
|
+
agentDid: entry.agentDid ?? '',
|
|
48
|
+
grantId: entry.grantId ?? '',
|
|
49
|
+
principalId: entry.principalId ?? '',
|
|
50
|
+
action: entry.action,
|
|
51
|
+
status: entry.status,
|
|
52
|
+
hash: entry.hash ?? '',
|
|
53
|
+
previousHash: entry.prevHash ?? '',
|
|
54
|
+
timestamp: shortDate(entry.timestamp),
|
|
55
|
+
metadata: JSON.stringify(entry.metadata ?? {}),
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
cmd
|
|
59
|
+
.command('log')
|
|
60
|
+
.description('Log a new audit entry')
|
|
61
|
+
.requiredOption('--agent-id <agentId>', 'Agent ID')
|
|
62
|
+
.requiredOption('--agent-did <agentDid>', 'Agent DID (e.g. did:grantex:ag_...)')
|
|
63
|
+
.requiredOption('--grant-id <grantId>', 'Grant ID')
|
|
64
|
+
.requiredOption('--principal-id <principalId>', 'Principal ID')
|
|
65
|
+
.requiredOption('--action <action>', 'Action name (e.g. email.read, payment.initiated)')
|
|
66
|
+
.option('--status <status>', 'Status: success, failure, or blocked')
|
|
67
|
+
.option('--metadata <json>', 'JSON metadata object')
|
|
68
|
+
.action(async (opts) => {
|
|
69
|
+
const client = await requireClient();
|
|
70
|
+
let metadata;
|
|
71
|
+
if (opts.metadata !== undefined) {
|
|
72
|
+
try {
|
|
73
|
+
metadata = JSON.parse(opts.metadata);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
console.error('Error: --metadata must be valid JSON.');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const entry = await client.audit.log({
|
|
81
|
+
agentId: opts.agentId,
|
|
82
|
+
agentDid: opts.agentDid,
|
|
83
|
+
grantId: opts.grantId,
|
|
84
|
+
principalId: opts.principalId,
|
|
85
|
+
action: opts.action,
|
|
86
|
+
...(opts.status !== undefined ? { status: opts.status } : {}),
|
|
87
|
+
...(metadata !== undefined ? { metadata } : {}),
|
|
88
|
+
});
|
|
89
|
+
if (isJsonMode()) {
|
|
90
|
+
console.log(JSON.stringify(entry, null, 2));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
console.log(chalk.green('✓') + ` Audit entry logged: ${entry.entryId}`);
|
|
32
94
|
});
|
|
33
95
|
return cmd;
|
|
34
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,UAAU,YAAY;IAC1B,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAE9E,GAAG;SACA,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;SACjD,MAAM,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;SACjD,MAAM,CAAC,2BAA2B,EAAE,wBAAwB,CAAC;SAC7D,MAAM,CAAC,mBAAmB,EAAE,yBAAyB,CAAC;SACtD,MAAM,CAAC,eAAe,EAAE,kCAAkC,CAAC;SAC3D,MAAM,CAAC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YAClG,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC,CAAC;QAEH,IAAI,UAAU,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC5C,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC,CACF,CAAC;IAEJ,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../src/commands/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,gBAAgB,IAAI,OAAO,CAiD1C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { requireClient } from '../client.js';
|
|
4
|
+
import { printRecord, shortDate, isJsonMode } from '../format.js';
|
|
5
|
+
export function authorizeCommand() {
|
|
6
|
+
const cmd = new Command('authorize').description('Start an authorization request');
|
|
7
|
+
cmd
|
|
8
|
+
.requiredOption('--agent <agentId>', 'Agent ID to authorize')
|
|
9
|
+
.requiredOption('--principal <principalId>', 'Principal (user) identifier')
|
|
10
|
+
.requiredOption('--scopes <scopes>', 'Comma-separated scopes to request')
|
|
11
|
+
.option('--redirect-uri <uri>', 'Redirect URI for callback')
|
|
12
|
+
.option('--expires-in <duration>', 'Expiry duration (e.g. 1h, 24h)')
|
|
13
|
+
.option('--code-challenge <challenge>', 'PKCE S256 code challenge')
|
|
14
|
+
.action(async (opts) => {
|
|
15
|
+
const client = await requireClient();
|
|
16
|
+
const res = await client.authorize({
|
|
17
|
+
agentId: opts.agent,
|
|
18
|
+
userId: opts.principal,
|
|
19
|
+
scopes: opts.scopes.split(',').map((s) => s.trim()),
|
|
20
|
+
...(opts.redirectUri !== undefined ? { redirectUri: opts.redirectUri } : {}),
|
|
21
|
+
...(opts.expiresIn !== undefined ? { expiresIn: opts.expiresIn } : {}),
|
|
22
|
+
...(opts.codeChallenge !== undefined ? { codeChallenge: opts.codeChallenge, codeChallengeMethod: 'S256' } : {}),
|
|
23
|
+
});
|
|
24
|
+
if (isJsonMode()) {
|
|
25
|
+
console.log(JSON.stringify(res, null, 2));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
console.log(chalk.green('✓') + ` Authorization request created.`);
|
|
29
|
+
const display = {
|
|
30
|
+
authRequestId: res.authRequestId,
|
|
31
|
+
consentUrl: res.consentUrl,
|
|
32
|
+
expiresAt: shortDate(res.expiresAt),
|
|
33
|
+
};
|
|
34
|
+
if ('code' in res && res.code) {
|
|
35
|
+
display.code = res.code;
|
|
36
|
+
console.log(chalk.yellow(' (sandbox auto-approved — code returned directly)'));
|
|
37
|
+
}
|
|
38
|
+
printRecord(display);
|
|
39
|
+
});
|
|
40
|
+
return cmd;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=authorize.js.map
|