@paybond/kit 0.9.8 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cli/audit-export.d.ts +7 -0
  2. package/dist/cli/audit-export.js +120 -0
  3. package/dist/cli/automation.d.ts +25 -0
  4. package/dist/cli/automation.js +297 -0
  5. package/dist/cli/body.d.ts +7 -0
  6. package/dist/cli/body.js +22 -0
  7. package/dist/cli/color.d.ts +15 -0
  8. package/dist/cli/color.js +39 -0
  9. package/dist/cli/command-spec.d.ts +12 -0
  10. package/dist/cli/command-spec.js +330 -0
  11. package/dist/cli/commands/discovery.d.ts +8 -0
  12. package/dist/cli/commands/discovery.js +194 -0
  13. package/dist/cli/commands/setup.d.ts +15 -0
  14. package/dist/cli/commands/setup.js +397 -0
  15. package/dist/cli/commands/workflows.d.ts +7 -0
  16. package/dist/cli/commands/workflows.js +209 -0
  17. package/dist/cli/config.d.ts +14 -0
  18. package/dist/cli/config.js +96 -0
  19. package/dist/cli/context.d.ts +22 -0
  20. package/dist/cli/context.js +109 -0
  21. package/dist/cli/credentials.d.ts +21 -0
  22. package/dist/cli/credentials.js +141 -0
  23. package/dist/cli/doctor-agent.d.ts +15 -0
  24. package/dist/cli/doctor-agent.js +311 -0
  25. package/dist/cli/envelope.d.ts +14 -0
  26. package/dist/cli/envelope.js +46 -0
  27. package/dist/cli/globals.d.ts +22 -0
  28. package/dist/cli/globals.js +238 -0
  29. package/dist/cli/help.d.ts +3 -0
  30. package/dist/cli/help.js +51 -0
  31. package/dist/cli/mcp-install.d.ts +41 -0
  32. package/dist/cli/mcp-install.js +95 -0
  33. package/dist/cli/mcp-policy.d.ts +23 -0
  34. package/dist/cli/mcp-policy.js +104 -0
  35. package/dist/cli/mcp-verify-config.d.ts +37 -0
  36. package/dist/cli/mcp-verify-config.js +174 -0
  37. package/dist/cli/redact.d.ts +4 -0
  38. package/dist/cli/redact.js +67 -0
  39. package/dist/cli/request-id.d.ts +2 -0
  40. package/dist/cli/request-id.js +5 -0
  41. package/dist/cli/router.d.ts +2 -0
  42. package/dist/cli/router.js +275 -0
  43. package/dist/cli/suggest.d.ts +4 -0
  44. package/dist/cli/suggest.js +58 -0
  45. package/dist/cli/support-diagnostics.d.ts +19 -0
  46. package/dist/cli/support-diagnostics.js +47 -0
  47. package/dist/cli/types.d.ts +72 -0
  48. package/dist/cli/types.js +60 -0
  49. package/dist/cli/ux.d.ts +8 -0
  50. package/dist/cli/ux.js +164 -0
  51. package/dist/cli.d.ts +2 -0
  52. package/dist/cli.js +38 -0
  53. package/dist/init.js +9 -14
  54. package/dist/login.d.ts +14 -1
  55. package/dist/login.js +123 -63
  56. package/dist/mcp-server.d.ts +4 -0
  57. package/dist/mcp-server.js +204 -76
  58. package/package.json +5 -2
@@ -0,0 +1,330 @@
1
+ // Generated by kit/cli-parity/generate.mjs — do not edit by hand.
2
+ export const COMMAND_PATHS = [
3
+ "onboarding",
4
+ "help",
5
+ "examples",
6
+ "completion",
7
+ "login",
8
+ "init guardrail",
9
+ "mcp serve",
10
+ "mcp install",
11
+ "mcp verify-config",
12
+ "mcp tools",
13
+ "doctor",
14
+ "version",
15
+ "diagnose",
16
+ "config get",
17
+ "config set",
18
+ "config unset",
19
+ "config list",
20
+ "whoami",
21
+ "keys list",
22
+ "keys create",
23
+ "keys rotate",
24
+ "keys revoke",
25
+ "intents list",
26
+ "intents get",
27
+ "intents create",
28
+ "intents fund",
29
+ "intents evidence",
30
+ "intents settlement-confirm",
31
+ "guardrails bootstrap",
32
+ "guardrails evidence",
33
+ "spend authorize",
34
+ "signal reputation",
35
+ "signal portfolio",
36
+ "signal fraud",
37
+ "receipts get",
38
+ "receipts verify",
39
+ "mandates verify",
40
+ "mandates import",
41
+ "a2a card",
42
+ "a2a contracts",
43
+ "audit exports list",
44
+ "audit exports get",
45
+ "audit exports verify",
46
+ "audit exports delete"
47
+ ];
48
+ export const GLOBAL_FLAG_NAMES = [
49
+ "--gateway",
50
+ "--env-file",
51
+ "--format",
52
+ "--json",
53
+ "--jq",
54
+ "--profile",
55
+ "--request-id",
56
+ "--yes",
57
+ "--no-open",
58
+ "--color",
59
+ "--no-color"
60
+ ];
61
+ export const COMMAND_EXAMPLES = {
62
+ "onboarding": [
63
+ "paybond onboarding",
64
+ "paybond onboarding --host claude --format json"
65
+ ],
66
+ "help": [
67
+ "paybond help",
68
+ "paybond help login",
69
+ "paybond help mcp install"
70
+ ],
71
+ "examples": [
72
+ "paybond examples",
73
+ "paybond examples doctor"
74
+ ],
75
+ "completion": [
76
+ "paybond completion bash >> ~/.bashrc",
77
+ "paybond completion zsh >> ~/.zshrc",
78
+ "paybond completion fish | source"
79
+ ],
80
+ "login": [
81
+ "paybond login",
82
+ "paybond login --no-open --format json"
83
+ ],
84
+ "init guardrail": [
85
+ "paybond init guardrail",
86
+ "paybond init guardrail --framework openai --out guard.ts"
87
+ ],
88
+ "mcp serve": [
89
+ "paybond mcp serve"
90
+ ],
91
+ "mcp install": [
92
+ "paybond mcp install --host claude",
93
+ "paybond mcp install --host generic --scope project --tool-policy readonly"
94
+ ],
95
+ "mcp verify-config": [
96
+ "paybond mcp verify-config --host claude",
97
+ "paybond mcp verify-config --host generic --config .paybond/mcp.json"
98
+ ],
99
+ "mcp tools": [
100
+ "paybond mcp tools"
101
+ ],
102
+ "doctor": [
103
+ "paybond doctor",
104
+ "paybond doctor --agent --format json"
105
+ ],
106
+ "version": [
107
+ "paybond version",
108
+ "paybond version --verbose --format json"
109
+ ],
110
+ "diagnose": [
111
+ "paybond diagnose --redacted",
112
+ "paybond diagnose --redacted --format json"
113
+ ],
114
+ "config get": [
115
+ "paybond config get gateway"
116
+ ],
117
+ "config set": [
118
+ "paybond config set gateway https://api.paybond.ai"
119
+ ],
120
+ "config unset": [
121
+ "paybond config unset gateway"
122
+ ],
123
+ "config list": [
124
+ "paybond config list --format json"
125
+ ],
126
+ "whoami": [
127
+ "paybond whoami",
128
+ "paybond whoami --format json"
129
+ ],
130
+ "keys list": [
131
+ "paybond keys list --format json"
132
+ ],
133
+ "keys create": [
134
+ "paybond keys create --name ci-bot --role operator"
135
+ ],
136
+ "keys rotate": [
137
+ "paybond keys rotate key-123 --yes"
138
+ ],
139
+ "keys revoke": [
140
+ "paybond keys revoke key-123 --yes"
141
+ ],
142
+ "intents list": [
143
+ "paybond intents list --limit 10"
144
+ ],
145
+ "intents get": [
146
+ "paybond intents get intent-123"
147
+ ],
148
+ "intents create": [
149
+ "paybond intents create --body intent.json"
150
+ ],
151
+ "intents fund": [
152
+ "paybond intents fund intent-123"
153
+ ],
154
+ "intents evidence": [
155
+ "paybond intents evidence intent-123 --body evidence.json"
156
+ ],
157
+ "intents settlement-confirm": [
158
+ "paybond intents settlement-confirm intent-123"
159
+ ],
160
+ "guardrails bootstrap": [
161
+ "paybond guardrails bootstrap --operation paid-tool --requested-spend-cents 100"
162
+ ],
163
+ "guardrails evidence": [
164
+ "paybond guardrails evidence --intent-id intent-123 --body evidence.json"
165
+ ],
166
+ "spend authorize": [
167
+ "paybond spend authorize --intent-id intent-123 --token cap --operation paid-tool"
168
+ ],
169
+ "signal reputation": [
170
+ "paybond signal reputation --did did:example:alice"
171
+ ],
172
+ "signal portfolio": [
173
+ "paybond signal portfolio"
174
+ ],
175
+ "signal fraud": [
176
+ "paybond signal fraud --did did:example:alice"
177
+ ],
178
+ "receipts get": [
179
+ "paybond receipts get receipt-123"
180
+ ],
181
+ "receipts verify": [
182
+ "paybond receipts verify receipt-123"
183
+ ],
184
+ "mandates verify": [
185
+ "paybond mandates verify --body mandate.json"
186
+ ],
187
+ "mandates import": [
188
+ "paybond mandates import --body mandate.json"
189
+ ],
190
+ "a2a card": [
191
+ "paybond a2a card"
192
+ ],
193
+ "a2a contracts": [
194
+ "paybond a2a contracts"
195
+ ],
196
+ "audit exports list": [
197
+ "paybond audit exports list --format json"
198
+ ],
199
+ "audit exports get": [
200
+ "paybond audit exports get job-123"
201
+ ],
202
+ "audit exports verify": [
203
+ "paybond audit exports verify ./bundle"
204
+ ],
205
+ "audit exports delete": [
206
+ "paybond audit exports delete job-123 --yes"
207
+ ]
208
+ };
209
+ export const COMPLETIONS = {
210
+ "top_level": [
211
+ "onboarding",
212
+ "help",
213
+ "examples",
214
+ "completion",
215
+ "login",
216
+ "init",
217
+ "mcp",
218
+ "doctor",
219
+ "version",
220
+ "diagnose",
221
+ "config",
222
+ "whoami",
223
+ "keys",
224
+ "intents",
225
+ "guardrails",
226
+ "spend",
227
+ "signal",
228
+ "receipts",
229
+ "mandates",
230
+ "a2a",
231
+ "audit"
232
+ ],
233
+ "init": [
234
+ "guardrail"
235
+ ],
236
+ "mcp": [
237
+ "serve",
238
+ "install",
239
+ "verify-config",
240
+ "tools"
241
+ ],
242
+ "config": [
243
+ "get",
244
+ "set",
245
+ "unset",
246
+ "list"
247
+ ],
248
+ "keys": [
249
+ "list",
250
+ "create",
251
+ "rotate",
252
+ "revoke"
253
+ ],
254
+ "intents": [
255
+ "list",
256
+ "get",
257
+ "create",
258
+ "fund",
259
+ "evidence",
260
+ "settlement-confirm"
261
+ ],
262
+ "guardrails": [
263
+ "bootstrap",
264
+ "evidence"
265
+ ],
266
+ "spend": [
267
+ "authorize"
268
+ ],
269
+ "signal": [
270
+ "reputation",
271
+ "portfolio",
272
+ "fraud"
273
+ ],
274
+ "receipts": [
275
+ "get",
276
+ "verify"
277
+ ],
278
+ "mandates": [
279
+ "verify",
280
+ "import"
281
+ ],
282
+ "a2a": [
283
+ "card",
284
+ "contracts"
285
+ ],
286
+ "audit": [
287
+ "exports"
288
+ ],
289
+ "completion": [
290
+ "bash",
291
+ "zsh",
292
+ "fish"
293
+ ]
294
+ };
295
+ export const WORKFLOWS = [
296
+ {
297
+ "title": "Sandbox setup",
298
+ "description": "Authenticate, validate the runtime, and confirm tenant context.",
299
+ "examples": [
300
+ "paybond login",
301
+ "paybond doctor --format json"
302
+ ],
303
+ "next": "paybond whoami"
304
+ },
305
+ {
306
+ "title": "Agent + MCP host",
307
+ "description": "Preview MCP host config and list tools exposed to agents.",
308
+ "examples": [
309
+ "paybond mcp install --host claude --scope local",
310
+ "paybond mcp verify-config --host claude",
311
+ "paybond mcp tools"
312
+ ],
313
+ "next": "paybond doctor --agent"
314
+ },
315
+ {
316
+ "title": "Paid-tool guardrail",
317
+ "description": "Scaffold a sandbox guardrail integration file for your agent runtime.",
318
+ "examples": [
319
+ "paybond init guardrail",
320
+ "paybond guardrails bootstrap --operation paid-tool --requested-spend-cents 100"
321
+ ],
322
+ "next": "paybond spend authorize --help"
323
+ }
324
+ ];
325
+ export const DOCS_BASE_URL = "https://docs.paybond.ai/kit";
326
+ export const COMPLETION_SCRIPTS = {
327
+ "bash": "# Generated by kit/cli-parity/generate.mjs — do not edit by hand.\n# # top_level: onboarding help examples completion login init mcp doctor version diagnose config whoami keys intents guardrails spend signal receipts mandates a2a audit\n# init: guardrail\n# mcp: serve install verify-config tools\n# config: get set unset list\n# keys: list create rotate revoke\n# intents: list get create fund evidence settlement-confirm\n# guardrails: bootstrap evidence\n# spend: authorize\n# signal: reputation portfolio fraud\n# receipts: get verify\n# mandates: verify import\n# a2a: card contracts\n# audit: exports\n# completion: bash zsh fish\n_paybond_completion() {\n local cur prev words cword\n COMPREPLY=()\n cur=\"${COMP_WORDS[COMP_CWORD]}\"\n prev=\"${COMP_WORDS[COMP_CWORD-1]}\"\n\n if [[ $COMP_CWORD -eq 1 ]]; then\n COMPREPLY=($(compgen -W \"onboarding help examples completion login init mcp doctor version diagnose config whoami keys intents guardrails spend signal receipts mandates a2a audit\" -- \"$cur\"))\n return 0\n fi\n\n case \"${COMP_WORDS[1]}\" in\n init) COMPREPLY=($(compgen -W \"guardrail\" -- \"$cur\")) ;;\n mcp) COMPREPLY=($(compgen -W \"serve install verify-config tools\" -- \"$cur\")) ;;\n config) COMPREPLY=($(compgen -W \"get set unset list\" -- \"$cur\")) ;;\n keys) COMPREPLY=($(compgen -W \"list create rotate revoke\" -- \"$cur\")) ;;\n intents) COMPREPLY=($(compgen -W \"list get create fund evidence settlement-confirm\" -- \"$cur\")) ;;\n guardrails) COMPREPLY=($(compgen -W \"bootstrap evidence\" -- \"$cur\")) ;;\n spend) COMPREPLY=($(compgen -W \"authorize\" -- \"$cur\")) ;;\n signal) COMPREPLY=($(compgen -W \"reputation portfolio fraud\" -- \"$cur\")) ;;\n receipts) COMPREPLY=($(compgen -W \"get verify\" -- \"$cur\")) ;;\n mandates) COMPREPLY=($(compgen -W \"verify import\" -- \"$cur\")) ;;\n a2a) COMPREPLY=($(compgen -W \"card contracts\" -- \"$cur\")) ;;\n audit) COMPREPLY=($(compgen -W \"exports\" -- \"$cur\")) ;;\n completion) COMPREPLY=($(compgen -W \"bash zsh fish\" -- \"$cur\")) ;;\n *) ;;\n esac\n}\ncomplete -F _paybond_completion paybond\n",
328
+ "zsh": "#compdef paybond\n# Generated by kit/cli-parity/generate.mjs — do not edit by hand.\n# # top_level: onboarding help examples completion login init mcp doctor version diagnose config whoami keys intents guardrails spend signal receipts mandates a2a audit\n# init: guardrail\n# mcp: serve install verify-config tools\n# config: get set unset list\n# keys: list create rotate revoke\n# intents: list get create fund evidence settlement-confirm\n# guardrails: bootstrap evidence\n# spend: authorize\n# signal: reputation portfolio fraud\n# receipts: get verify\n# mandates: verify import\n# a2a: card contracts\n# audit: exports\n# completion: bash zsh fish\n\n_paybond() {\n local -a commands\n commands=(\n 'onboarding' 'help' 'examples' 'completion' 'login' 'init' 'mcp' 'doctor' 'version' 'diagnose' 'config' 'whoami' 'keys' 'intents' 'guardrails' 'spend' 'signal' 'receipts' 'mandates' 'a2a' 'audit'\n )\n _arguments -C \\\n '(--gateway)--gateway[Gateway base URL]:url:' \\\n '(--env-file)--env-file[Local secrets file]:path:_files' \\\n '(--format)--format[Output format]:(table json)' \\\n '(--color)--color[Color mode]:(auto always never)' \\\n '--no-color[Disable color output]' \\\n '1: :->command' \\\n '*::arg:->args'\n\n case $state in\n command)\n _describe -t commands 'paybond commands' commands\n ;;\n args)\n case $words[1] in\n 'init:subcommand:(guardrail)'\n 'mcp:subcommand:(serve install verify-config tools)'\n 'config:subcommand:(get set unset list)'\n 'keys:subcommand:(list create rotate revoke)'\n 'intents:subcommand:(list get create fund evidence settlement-confirm)'\n 'guardrails:subcommand:(bootstrap evidence)'\n 'spend:subcommand:(authorize)'\n 'signal:subcommand:(reputation portfolio fraud)'\n 'receipts:subcommand:(get verify)'\n 'mandates:subcommand:(verify import)'\n 'a2a:subcommand:(card contracts)'\n 'audit:subcommand:(exports)'\n 'completion:subcommand:(bash zsh fish)'\n esac\n ;;\n esac\n}\n\ncompdef _paybond paybond\n",
329
+ "fish": "# Generated by kit/cli-parity/generate.mjs — do not edit by hand.\n# # top_level: onboarding help examples completion login init mcp doctor version diagnose config whoami keys intents guardrails spend signal receipts mandates a2a audit\n# init: guardrail\n# mcp: serve install verify-config tools\n# config: get set unset list\n# keys: list create rotate revoke\n# intents: list get create fund evidence settlement-confirm\n# guardrails: bootstrap evidence\n# spend: authorize\n# signal: reputation portfolio fraud\n# receipts: get verify\n# mandates: verify import\n# a2a: card contracts\n# audit: exports\n# completion: bash zsh fish\ncomplete -c paybond -f\ncomplete -c paybond -l gateway -d 'Gateway base URL'\ncomplete -c paybond -l env-file -d 'Local secrets file' -r\ncomplete -c paybond -l format -d 'Output format' -xa 'table json'\ncomplete -c paybond -l color -d 'Color mode' -xa 'auto always never'\ncomplete -c paybond -l no-color -d 'Disable color output'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'onboarding'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'help'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'examples'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'completion'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'login'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'init'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'mcp'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'doctor'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'version'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'diagnose'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'config'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'whoami'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'keys'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'intents'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'guardrails'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'spend'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'signal'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'receipts'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'mandates'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'a2a'\ncomplete -c paybond -n '__fish_use_subcommand' -a 'audit'\ncomplete -c paybond -n '__fish_seen_subcommand_from init' -a 'guardrail'\ncomplete -c paybond -n '__fish_seen_subcommand_from mcp' -a 'serve'\ncomplete -c paybond -n '__fish_seen_subcommand_from mcp' -a 'install'\ncomplete -c paybond -n '__fish_seen_subcommand_from mcp' -a 'verify-config'\ncomplete -c paybond -n '__fish_seen_subcommand_from mcp' -a 'tools'\ncomplete -c paybond -n '__fish_seen_subcommand_from config' -a 'get'\ncomplete -c paybond -n '__fish_seen_subcommand_from config' -a 'set'\ncomplete -c paybond -n '__fish_seen_subcommand_from config' -a 'unset'\ncomplete -c paybond -n '__fish_seen_subcommand_from config' -a 'list'\ncomplete -c paybond -n '__fish_seen_subcommand_from keys' -a 'list'\ncomplete -c paybond -n '__fish_seen_subcommand_from keys' -a 'create'\ncomplete -c paybond -n '__fish_seen_subcommand_from keys' -a 'rotate'\ncomplete -c paybond -n '__fish_seen_subcommand_from keys' -a 'revoke'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'list'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'get'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'create'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'fund'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'evidence'\ncomplete -c paybond -n '__fish_seen_subcommand_from intents' -a 'settlement-confirm'\ncomplete -c paybond -n '__fish_seen_subcommand_from guardrails' -a 'bootstrap'\ncomplete -c paybond -n '__fish_seen_subcommand_from guardrails' -a 'evidence'\ncomplete -c paybond -n '__fish_seen_subcommand_from spend' -a 'authorize'\ncomplete -c paybond -n '__fish_seen_subcommand_from signal' -a 'reputation'\ncomplete -c paybond -n '__fish_seen_subcommand_from signal' -a 'portfolio'\ncomplete -c paybond -n '__fish_seen_subcommand_from signal' -a 'fraud'\ncomplete -c paybond -n '__fish_seen_subcommand_from receipts' -a 'get'\ncomplete -c paybond -n '__fish_seen_subcommand_from receipts' -a 'verify'\ncomplete -c paybond -n '__fish_seen_subcommand_from mandates' -a 'verify'\ncomplete -c paybond -n '__fish_seen_subcommand_from mandates' -a 'import'\ncomplete -c paybond -n '__fish_seen_subcommand_from a2a' -a 'card'\ncomplete -c paybond -n '__fish_seen_subcommand_from a2a' -a 'contracts'\ncomplete -c paybond -n '__fish_seen_subcommand_from audit' -a 'exports'\ncomplete -c paybond -n '__fish_seen_subcommand_from completion' -a 'bash'\ncomplete -c paybond -n '__fish_seen_subcommand_from completion' -a 'zsh'\ncomplete -c paybond -n '__fish_seen_subcommand_from completion' -a 'fish'\n"
330
+ };
@@ -0,0 +1,8 @@
1
+ import { commandPath, type CliContext } from "../context.js";
2
+ import { type CommandResult } from "../types.js";
3
+ export declare function handleSignal(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
4
+ export declare function handleReceipts(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
5
+ export declare function handleMandates(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
6
+ export declare function handleA2a(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
7
+ export declare function handleAuditExports(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
8
+ export { commandPath };
@@ -0,0 +1,194 @@
1
+ import { resolveJsonBody } from "../body.js";
2
+ import { verifyAuditBundleLocal } from "../audit-export.js";
3
+ import { buildListQueryParams, extractNextCursor, partialResultsWarning, writeAtomicFileAsync, } from "../automation.js";
4
+ import { commandPath, gatewayUrl, requireConfirmation, withGateway } from "../context.js";
5
+ import { consumeBooleanFlag, consumeFlag } from "../globals.js";
6
+ import { CliError } from "../types.js";
7
+ export async function handleSignal(ctx, subcommand, argv) {
8
+ return withGateway(ctx, async (gateway) => {
9
+ const principal = await gateway.getJson("/v1/auth/principal");
10
+ const tenantId = String(principal.tenant_id ?? "");
11
+ if (subcommand === "portfolio") {
12
+ const body = await gateway.getJson(`/signal/v1/tenants/${encodeURIComponent(tenantId)}/portfolio/summary`);
13
+ return { data: body };
14
+ }
15
+ const didFlag = consumeFlag(argv, "--did");
16
+ if (!didFlag.value) {
17
+ throw new CliError(`signal ${subcommand} requires --did`, { category: "usage", code: "cli.usage.missing_did" });
18
+ }
19
+ if (subcommand === "reputation") {
20
+ const body = await gateway.getJson(`/signal/v1/tenants/${encodeURIComponent(tenantId)}/reputation/${encodeURIComponent(didFlag.value)}`);
21
+ return { data: body };
22
+ }
23
+ if (subcommand === "fraud") {
24
+ const body = await gateway.getJson(`/fraud/v1/tenants/${encodeURIComponent(tenantId)}/assessments/${encodeURIComponent(didFlag.value)}`);
25
+ return { data: body };
26
+ }
27
+ throw new CliError(`unknown signal subcommand: ${subcommand}`, { category: "usage", code: "cli.usage.unknown_command" });
28
+ });
29
+ }
30
+ export async function handleReceipts(ctx, subcommand, argv) {
31
+ return withGateway(ctx, async (gateway) => {
32
+ const receiptId = argv[0];
33
+ if (!receiptId) {
34
+ throw new CliError(`receipts ${subcommand} requires <receipt_id>`, { category: "usage", code: "cli.usage.missing_receipt_id" });
35
+ }
36
+ if (subcommand === "get") {
37
+ const body = await gateway.getJson(`/protocol/v2/receipts/${encodeURIComponent(receiptId)}`);
38
+ return { data: body };
39
+ }
40
+ if (subcommand === "verify") {
41
+ const body = await gateway.postJson("/protocol/v2/receipts/verify", { receipt_id: receiptId });
42
+ return { data: body };
43
+ }
44
+ throw new CliError(`unknown receipts subcommand: ${subcommand}`, { category: "usage", code: "cli.usage.unknown_command" });
45
+ });
46
+ }
47
+ export async function handleMandates(ctx, subcommand, argv) {
48
+ return withGateway(ctx, async (gateway) => {
49
+ const { payload } = await resolveJsonBody(argv, {
50
+ missingMessage: `mandates ${subcommand} requires --body <json-file> or --stdin`,
51
+ });
52
+ if (subcommand === "verify") {
53
+ const body = await gateway.postJson("/protocol/v2/mandates/verify", payload);
54
+ return { data: body };
55
+ }
56
+ if (subcommand === "import") {
57
+ const body = await gateway.postJson("/protocol/v2/mandates/import", payload);
58
+ return { data: body };
59
+ }
60
+ throw new CliError(`unknown mandates subcommand: ${subcommand}`, { category: "usage", code: "cli.usage.unknown_command" });
61
+ });
62
+ }
63
+ export async function handleA2a(ctx, subcommand, argv) {
64
+ return withGateway(ctx, async (gateway) => {
65
+ if (subcommand === "card") {
66
+ const body = await gateway.getJson("/.well-known/agent-card.json");
67
+ return { data: body };
68
+ }
69
+ if (subcommand === "contracts") {
70
+ const contractFlag = consumeFlag(argv, "--contract-id");
71
+ if (contractFlag.value) {
72
+ const body = await gateway.getJson(`/protocol/v2/a2a/task-contracts/${encodeURIComponent(contractFlag.value)}`);
73
+ return { data: body };
74
+ }
75
+ const limitFlag = consumeFlag(argv, "--limit");
76
+ const cursorFlag = consumeFlag(argv, "--cursor");
77
+ const params = buildListQueryParams(limitFlag.value, cursorFlag.value);
78
+ const body = await gateway.getJson(`/protocol/v2/a2a/task-contracts?${params.toString()}`);
79
+ const nextCursor = extractNextCursor(body);
80
+ const warnings = partialResultsWarning(nextCursor) ? [partialResultsWarning(nextCursor)] : undefined;
81
+ if (nextCursor && !body.next_cursor) {
82
+ body.next_cursor = nextCursor;
83
+ }
84
+ return { data: body, warnings };
85
+ }
86
+ throw new CliError(`unknown a2a subcommand: ${subcommand}`, { category: "usage", code: "cli.usage.unknown_command" });
87
+ });
88
+ }
89
+ export async function handleAuditExports(ctx, subcommand, argv) {
90
+ if (subcommand === "verify") {
91
+ const path = argv[0];
92
+ if (!path) {
93
+ throw new CliError("audit exports verify requires <path>", { category: "usage", code: "cli.usage.missing_path" });
94
+ }
95
+ try {
96
+ const data = await verifyAuditBundleLocal(path, ctx.cwd);
97
+ return { data };
98
+ }
99
+ catch (err) {
100
+ if (err instanceof CliError) {
101
+ throw err;
102
+ }
103
+ throw new CliError(err instanceof Error ? err.message : String(err), {
104
+ category: "validation",
105
+ code: "cli.audit.verify_failed",
106
+ });
107
+ }
108
+ }
109
+ return withGateway(ctx, async (gateway) => {
110
+ if (subcommand === "list") {
111
+ const limitFlag = consumeFlag(argv, "--limit");
112
+ const cursorFlag = consumeFlag(argv, "--cursor");
113
+ const params = buildListQueryParams(limitFlag.value, cursorFlag.value, { limit: "50" });
114
+ const body = await gateway.getJson(`/v1/compliance/audit-exports?${params.toString()}`);
115
+ const exports = Array.isArray(body.jobs)
116
+ ? body.jobs
117
+ : Array.isArray(body.items)
118
+ ? body.items
119
+ : Array.isArray(body.exports)
120
+ ? body.exports
121
+ : [];
122
+ const nextCursor = extractNextCursor(body);
123
+ const warnings = partialResultsWarning(nextCursor) ? [partialResultsWarning(nextCursor)] : undefined;
124
+ const data = {
125
+ exports: exports.map((item) => {
126
+ const row = item;
127
+ return {
128
+ job_id: String(row.job_id ?? row.id ?? ""),
129
+ status: String(row.status ?? ""),
130
+ created_at: String(row.created_at ?? ""),
131
+ expires_at: row.expires_at ? String(row.expires_at) : null,
132
+ scope: row.scope ? String(row.scope) : undefined,
133
+ };
134
+ }),
135
+ };
136
+ if (nextCursor) {
137
+ data.next_cursor = nextCursor;
138
+ }
139
+ return { data, warnings };
140
+ }
141
+ const jobId = argv[0];
142
+ if (!jobId) {
143
+ throw new CliError(`audit exports ${subcommand} requires <job_id>`, { category: "usage", code: "cli.usage.missing_job_id" });
144
+ }
145
+ if (subcommand === "get") {
146
+ const issueDownload = consumeBooleanFlag(argv.slice(1), "--issue-download").present;
147
+ const outputFlag = consumeFlag(argv.slice(1), "--output");
148
+ const query = issueDownload ? "?issue_download=1" : "";
149
+ const body = await gateway.getJson(`/v1/compliance/audit-exports/${encodeURIComponent(jobId)}${query}`);
150
+ if (outputFlag.value) {
151
+ const job = (body.job ?? body);
152
+ const token = String(job.download_token ?? "");
153
+ if (!token) {
154
+ throw new CliError("audit exports get --output requires a ready export with --issue-download", {
155
+ category: "validation",
156
+ code: "cli.audit.missing_download_token",
157
+ });
158
+ }
159
+ const bundleUrl = gatewayUrl(ctx.globals.gateway, `/v1/compliance/audit-exports/${encodeURIComponent(jobId)}/bundle?token=${encodeURIComponent(token)}`);
160
+ const apiKey = await import("../credentials.js").then((mod) => mod.resolveApiKey(ctx.globals, ctx.cwd));
161
+ const response = await ctx.fetch(bundleUrl, {
162
+ headers: {
163
+ authorization: `Bearer ${apiKey}`,
164
+ "x-request-id": ctx.globals.requestId,
165
+ },
166
+ });
167
+ if (!response.ok) {
168
+ throw new CliError(`failed to download audit export bundle (${response.status})`, {
169
+ category: "gateway",
170
+ code: "cli.audit.bundle_download_failed",
171
+ exitCode: 5,
172
+ });
173
+ }
174
+ const bytes = new Uint8Array(await response.arrayBuffer());
175
+ await writeAtomicFileAsync(outputFlag.value, bytes, 0o600);
176
+ return {
177
+ data: {
178
+ job_id: jobId,
179
+ output: outputFlag.value,
180
+ bytes_written: bytes.byteLength,
181
+ },
182
+ };
183
+ }
184
+ return { data: body };
185
+ }
186
+ if (subcommand === "delete") {
187
+ requireConfirmation(ctx.globals, "delete audit export job");
188
+ await gateway.deleteJson(`/v1/compliance/audit-exports/${encodeURIComponent(jobId)}`);
189
+ return { data: { job_id: jobId, deleted: true } };
190
+ }
191
+ throw new CliError(`unknown audit exports subcommand: ${subcommand}`, { category: "usage", code: "cli.usage.unknown_command" });
192
+ });
193
+ }
194
+ export { commandPath };
@@ -0,0 +1,15 @@
1
+ import { commandPath, type CliContext } from "../context.js";
2
+ import { type CommandResult } from "../types.js";
3
+ declare function readJsonFile(filePath: string): Promise<Record<string, unknown>>;
4
+ export declare function handleLogin(ctx: CliContext, argv: string[]): Promise<CommandResult>;
5
+ export declare function handleInitGuardrail(ctx: CliContext, argv: string[]): Promise<CommandResult>;
6
+ export declare function handleMcpServe(ctx: CliContext, argv: string[]): Promise<CommandResult>;
7
+ export declare function handleMcpTools(ctx: CliContext): Promise<CommandResult>;
8
+ export declare function handleMcpInstall(ctx: CliContext, argv: string[]): Promise<CommandResult>;
9
+ export declare function handleMcpVerifyConfig(ctx: CliContext, argv: string[]): Promise<CommandResult>;
10
+ export declare function handleDoctor(ctx: CliContext, argv: string[]): Promise<CommandResult>;
11
+ export declare function handleConfig(ctx: CliContext, subcommand: string, argv: string[]): Promise<CommandResult>;
12
+ export declare function handleWhoami(ctx: CliContext): Promise<CommandResult>;
13
+ export declare function handleVersion(ctx: CliContext, argv: string[]): Promise<CommandResult>;
14
+ export declare function handleDiagnose(ctx: CliContext, argv: string[]): Promise<CommandResult>;
15
+ export { readJsonFile, commandPath };