@agentguard-run/spend 0.1.4 → 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.
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ /**
3
+ * `agentguard explain` — decode a signed receipt with cap math + signature breakdown.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runExplain = runExplain;
40
+ const fs = __importStar(require("fs"));
41
+ const os = __importStar(require("os"));
42
+ const path = __importStar(require("path"));
43
+ const index_1 = require("../index");
44
+ const colors_1 = require("./colors");
45
+ const DEMO_RECEIPT = path.join(os.homedir(), '.agentguard', 'demo', 'latest-receipt.json');
46
+ const WINDOW_LABELS = {
47
+ per_call: 'per call',
48
+ per_minute: 'per minute',
49
+ per_hour: 'per hour',
50
+ per_day: 'per day',
51
+ per_month: 'per month',
52
+ };
53
+ const WINDOW_RESETS = {
54
+ per_call: 'next call',
55
+ per_minute: 'top of next minute (UTC)',
56
+ per_hour: 'top of next hour (UTC)',
57
+ per_day: 'UTC midnight',
58
+ per_month: '1st of next month (UTC)',
59
+ };
60
+ function formatCents(cents) {
61
+ const sign = cents < 0 ? '-' : '';
62
+ const abs = Math.abs(Math.round(cents));
63
+ const dollars = Math.floor(abs / 100);
64
+ const remainder = abs % 100;
65
+ const dollarsStr = dollars.toLocaleString('en-US');
66
+ const remainderStr = String(remainder).padStart(2, '0');
67
+ return `${sign}$${dollarsStr}.${remainderStr}`;
68
+ }
69
+ async function runExplain(argv) {
70
+ if (argv.includes('--help') || argv.includes('-h')) {
71
+ console.log('agentguard explain [latest|<path>]');
72
+ return 0;
73
+ }
74
+ const receiptArg = argv.find((a) => !a.startsWith('-')) || 'latest';
75
+ console.log('');
76
+ console.log(' ' + (0, colors_1.banner)(index_1.AGENTGUARD_SPEND_VERSION));
77
+ console.log('');
78
+ console.log(' ' + (0, colors_1.cyanBold)(`agentguard explain ${receiptArg}`));
79
+ console.log('');
80
+ let source;
81
+ if (receiptArg === 'latest') {
82
+ if (!fs.existsSync(DEMO_RECEIPT)) {
83
+ console.log(' ' + (0, colors_1.redBold)('error: ') + 'no demo receipt found.');
84
+ console.log(` run ${(0, colors_1.greenBold)('agentguard demo')} first to produce a receipt.`);
85
+ console.log('');
86
+ return 2;
87
+ }
88
+ source = DEMO_RECEIPT;
89
+ }
90
+ else {
91
+ source = path.resolve(receiptArg.replace(/^~/, os.homedir()));
92
+ if (!fs.existsSync(source)) {
93
+ console.log(' ' + (0, colors_1.redBold)('error: ') + `receipt file not found: ${source}`);
94
+ console.log('');
95
+ return 2;
96
+ }
97
+ }
98
+ const raw = JSON.parse(fs.readFileSync(source, 'utf-8'));
99
+ const decision = raw.decision;
100
+ const cap = decision.triggeredCap;
101
+ const agentId = String(decision.triggeredScopeKey || 'unknown')
102
+ .split('|')
103
+ .pop()
104
+ .replace('agentId=', '');
105
+ // 1. What happened
106
+ console.log((0, colors_1.dim)(' what happened'));
107
+ console.log((0, colors_1.dim)(' ─────────────'));
108
+ const action = decision.action || '?';
109
+ const colorAction = action === 'block'
110
+ ? (0, colors_1.redBold)(action.toUpperCase())
111
+ : action === 'downgrade'
112
+ ? (0, colors_1.yellow)(action.toUpperCase())
113
+ : (0, colors_1.green)(action.toUpperCase());
114
+ console.log(` action ${colorAction}`);
115
+ console.log(` agent ${agentId}`);
116
+ console.log(` provider ${decision.provider || '?'}`);
117
+ console.log(` model ${decision.modelRequested || '?'}`);
118
+ console.log('');
119
+ // 2. Cap math
120
+ console.log((0, colors_1.dim)(' cap math'));
121
+ console.log((0, colors_1.dim)(' ────────'));
122
+ const projected = decision.projectedCents || 0;
123
+ const windowBefore = decision.windowSpendBefore || 0;
124
+ console.log(` this call would have cost ${(0, colors_1.greenBold)(formatCents(projected))}`);
125
+ console.log(` spent in window before ${formatCents(windowBefore)}`);
126
+ if (cap) {
127
+ const capCents = cap.amountCents || 0;
128
+ const window = cap.window || '?';
129
+ const windowLabel = WINDOW_LABELS[window] || window;
130
+ const remaining = Math.max(0, capCents - windowBefore);
131
+ const overBy = Math.max(0, projected - remaining);
132
+ console.log(` cap ${(0, colors_1.redBold)(formatCents(capCents))} ${(0, colors_1.dim)(windowLabel)}`);
133
+ console.log(` remaining in window ${formatCents(remaining)}`);
134
+ if (overBy > 0)
135
+ console.log(` call exceeds remaining by ${(0, colors_1.redBold)(formatCents(overBy))}`);
136
+ const saved = Math.max(0, projected - remaining);
137
+ if (saved > 0)
138
+ console.log(` amount saved by block ${(0, colors_1.greenBold)('+' + formatCents(saved))}`);
139
+ console.log('');
140
+ console.log((0, colors_1.dim)(' what unblocks'));
141
+ console.log((0, colors_1.dim)(' ─────────────'));
142
+ const reset = WINDOW_RESETS[window] || 'next window boundary';
143
+ console.log(` window resets at ${(0, colors_1.greenBold)(reset)}`);
144
+ if (cap.downgradeTo)
145
+ console.log(` downgrade target ${(0, colors_1.greenBold)(cap.downgradeTo)}`);
146
+ console.log('');
147
+ }
148
+ // 3. Cryptographic receipt
149
+ console.log((0, colors_1.dim)(' cryptographic receipt'));
150
+ console.log((0, colors_1.dim)(' ─────────────────────'));
151
+ console.log(` sequence ${raw.sequence ?? '?'}`);
152
+ console.log(` entry hash ${String(raw.entryHash || '?').slice(0, 48)}${(0, colors_1.dim)('...')}`);
153
+ console.log(` prev hash ${String(raw.previousHash || '?').slice(0, 48)}${(0, colors_1.dim)('...')}`);
154
+ console.log(` signer (fp) ${String(raw.signerFingerprint || '?').slice(0, 32)}${(0, colors_1.dim)('...')}`);
155
+ const signature = String(raw.signature || '');
156
+ console.log(` signature ${signature.slice(0, 48)}${signature.length > 48 ? (0, colors_1.dim)('...') : ''}`);
157
+ console.log('');
158
+ console.log(` ${(0, colors_1.dim)('to verify cryptographically:')} ${(0, colors_1.greenBold)('agentguard verify --trace latest')}`);
159
+ console.log('');
160
+ // 4. Policy
161
+ console.log((0, colors_1.dim)(' policy'));
162
+ console.log((0, colors_1.dim)(' ──────'));
163
+ console.log(` id ${decision.policyId || '?'}`);
164
+ console.log(` version ${decision.policyVersion || '?'}`);
165
+ console.log(` mode ${decision.enforcementMode || '?'}`);
166
+ const reasons = decision.reasons || [];
167
+ if (reasons.length > 0)
168
+ console.log(` reasons ${reasons.join('; ')}`);
169
+ console.log('');
170
+ return 0;
171
+ }
172
+ //# sourceMappingURL=explain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explain.js","sourceRoot":"","sources":["../../src/cli/explain.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCH,gCA6GC;AA/ID,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,oCA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,eAAe,QAAQ,CAAC,QAAQ,IAAI,GAAG,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,eAAe,QAAQ,CAAC,aAAa,IAAI,GAAG,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,eAAe,QAAQ,CAAC,eAAe,IAAI,GAAG,EAAE,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAa,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;IACjD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `agentguard init` — scaffold a project to use AgentGuard Spend.
3
+ */
4
+ export declare function runInit(argv: string[]): Promise<number>;
5
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuGH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E7D"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * `agentguard init` — scaffold a project to use AgentGuard Spend.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runInit = runInit;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const index_1 = require("../index");
43
+ const colors_1 = require("./colors");
44
+ const POLICY_TEMPLATE = (now) => `# AgentGuard Spend policy (generated by \`agentguard init\`)
45
+ # All amounts are integer cents. 500 = $5.00.
46
+ id: my-default-policy-v1
47
+ name: My default AgentGuard policy
48
+ version: 1
49
+ effectiveFrom: "${now}"
50
+ mode: enforce
51
+
52
+ scope:
53
+ tenantId: my-tenant
54
+
55
+ caps:
56
+ # Soft daily cap: when $5/day reached, downgrade to a cheaper model.
57
+ - amountCents: 500
58
+ window: per_day
59
+ action: downgrade
60
+ downgradeTo: gpt-4o-mini
61
+ reason: "Soft daily cap reached, routing to gpt-4o-mini"
62
+
63
+ # Hard daily ceiling: at $20/day, block the call.
64
+ - amountCents: 2000
65
+ window: per_day
66
+ action: block
67
+ reason: "Hard daily ceiling ($20/day)"
68
+
69
+ # Per-minute burst guard: catches runaway loops.
70
+ - amountCents: 200
71
+ window: per_minute
72
+ action: block
73
+ reason: "Per-minute burst guard ($2/min)"
74
+ `;
75
+ const QUICKSTART_TEMPLATE = `/**
76
+ * AgentGuard Spend quickstart (generated by \`agentguard init\`).
77
+ *
78
+ * Run after \`npm install @agentguard-run/spend openai\`:
79
+ * node agentguard_quickstart.js
80
+ */
81
+ import OpenAI from 'openai';
82
+ import {
83
+ withSpendGuard,
84
+ AgentGuardBlockedError,
85
+ type SpendPolicy,
86
+ } from '@agentguard-run/spend';
87
+ import { randomBytes } from 'crypto';
88
+
89
+ const policy: SpendPolicy = {
90
+ id: 'my-default-policy-v1',
91
+ name: 'My default AgentGuard policy',
92
+ scope: { tenantId: 'my-tenant' },
93
+ caps: [
94
+ {
95
+ amountCents: 500,
96
+ window: 'per_day',
97
+ action: 'downgrade',
98
+ downgradeTo: 'gpt-4o-mini',
99
+ reason: 'Soft daily cap reached, routing to gpt-4o-mini',
100
+ },
101
+ {
102
+ amountCents: 2000,
103
+ window: 'per_day',
104
+ action: 'block',
105
+ reason: 'Hard daily ceiling (\$20/day)',
106
+ },
107
+ ],
108
+ mode: 'enforce',
109
+ version: 1,
110
+ effectiveFrom: '${new Date().toISOString()}',
111
+ };
112
+
113
+ const privateKey = new Uint8Array(randomBytes(32));
114
+
115
+ const client = withSpendGuard(new OpenAI(), {
116
+ policy,
117
+ scope: { tenantId: 'my-tenant', agentId: 'my-first-agent' },
118
+ config: {
119
+ policy,
120
+ signingKeys: { privateKey, publicKey: new Uint8Array(32) },
121
+ },
122
+ });
123
+
124
+ try {
125
+ const response = await client.chat.completions.create({
126
+ model: 'gpt-4o',
127
+ messages: [{ role: 'user', content: 'Hello from AgentGuard!' }],
128
+ });
129
+ console.log(response.choices[0].message.content);
130
+ } catch (err) {
131
+ if (err instanceof AgentGuardBlockedError) {
132
+ console.error(err.message);
133
+ } else {
134
+ throw err;
135
+ }
136
+ }
137
+ `;
138
+ async function runInit(argv) {
139
+ const force = argv.includes('--force');
140
+ const policyOnly = argv.includes('--policy-only');
141
+ if (argv.includes('--help') || argv.includes('-h')) {
142
+ console.log('agentguard init [--force] [--policy-only]');
143
+ return 0;
144
+ }
145
+ const cwd = process.cwd();
146
+ const policyPath = path.join(cwd, 'agentguard.policy.yaml');
147
+ const quickstartPath = path.join(cwd, 'agentguard_quickstart.ts');
148
+ const gitignorePath = path.join(cwd, '.gitignore');
149
+ console.log('');
150
+ console.log(' ' + (0, colors_1.banner)(index_1.AGENTGUARD_SPEND_VERSION));
151
+ console.log('');
152
+ console.log(' ' + (0, colors_1.cyanBold)('agentguard init') + (0, colors_1.dim)(' · scaffold a project'));
153
+ console.log('');
154
+ const created = [];
155
+ const skipped = [];
156
+ if (fs.existsSync(policyPath) && !force) {
157
+ skipped.push([path.basename(policyPath), 'already exists (use --force to overwrite)']);
158
+ }
159
+ else {
160
+ const now = new Date().toISOString();
161
+ fs.writeFileSync(policyPath, POLICY_TEMPLATE(now));
162
+ created.push(path.basename(policyPath));
163
+ }
164
+ if (!policyOnly) {
165
+ if (fs.existsSync(quickstartPath) && !force) {
166
+ skipped.push([path.basename(quickstartPath), 'already exists (use --force to overwrite)']);
167
+ }
168
+ else {
169
+ fs.writeFileSync(quickstartPath, QUICKSTART_TEMPLATE);
170
+ created.push(path.basename(quickstartPath));
171
+ }
172
+ }
173
+ let gitignoreModified = false;
174
+ if (fs.existsSync(gitignorePath)) {
175
+ const existing = fs.readFileSync(gitignorePath, 'utf-8');
176
+ if (!existing.includes('.agentguard')) {
177
+ const prefix = existing.endsWith('\n') ? '' : '\n';
178
+ fs.appendFileSync(gitignorePath, prefix + '.agentguard/\n');
179
+ gitignoreModified = true;
180
+ }
181
+ }
182
+ else {
183
+ fs.writeFileSync(gitignorePath, '.agentguard/\n');
184
+ gitignoreModified = true;
185
+ created.push('.gitignore');
186
+ }
187
+ for (const p of created)
188
+ console.log(` ${(0, colors_1.green)('+ created')} ${p}`);
189
+ if (gitignoreModified && !created.includes('.gitignore')) {
190
+ console.log(` ${(0, colors_1.green)('~ updated')} .gitignore ${(0, colors_1.dim)('(added .agentguard/)')}`);
191
+ }
192
+ for (const [p, reason] of skipped) {
193
+ console.log(` ${(0, colors_1.yellow)('= skipped')} ${p} ${(0, colors_1.dim)('(' + reason + ')')}`);
194
+ }
195
+ if (created.length === 0 && !gitignoreModified) {
196
+ console.log(` ${(0, colors_1.yellow)('nothing to do')} ${(0, colors_1.dim)('all files exist; pass --force to overwrite')}`);
197
+ return 0;
198
+ }
199
+ console.log('');
200
+ console.log((0, colors_1.dim)(' ───────────────────────────────────────────'));
201
+ console.log(` ${(0, colors_1.dim)('next:')}`);
202
+ console.log(` 1. edit ${(0, colors_1.greenBold)('agentguard.policy.yaml')} to set your caps`);
203
+ console.log(` 2. ${(0, colors_1.greenBold)('node agentguard_quickstart.js')} ${(0, colors_1.dim)('to see it in action')}`);
204
+ console.log(` 3. ${(0, colors_1.greenBold)('agentguard doctor')} ${(0, colors_1.dim)('to verify your setup')}`);
205
+ console.log('');
206
+ return 0;
207
+ }
208
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGH,0BA2EC;AAhLD,uCAAyB;AACzB,2CAA6B;AAC7B,oCAAoD;AACpD,qCAA2E;AAE3E,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC;;;;;kBAKvB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBpB,CAAC;AAEF,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAmCR,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B3C,CAAC;AAEK,KAAK,UAAU,OAAO,CAAC,IAAc;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAA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AC,CAAC;IACnG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAA,kBAAS,EAAC,mBAAmB,CAAC,KAAK,IAAA,YAAG,EAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * AgentGuard CLI entry point.
3
+ *
4
+ * Usage:
5
+ * agentguard demo Run a deterministic simulation
6
+ * agentguard verify --trace latest Verify the latest demo receipt
7
+ * agentguard --version Show installed SDK version
8
+ * agentguard --help Show this help
9
+ */
10
+ export declare function main(argv?: string[]): Promise<number>;
11
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6BH,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAqClF"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ /**
3
+ * AgentGuard CLI entry point.
4
+ *
5
+ * Usage:
6
+ * agentguard demo Run a deterministic simulation
7
+ * agentguard verify --trace latest Verify the latest demo receipt
8
+ * agentguard --version Show installed SDK version
9
+ * agentguard --help Show this help
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.main = main;
46
+ const index_1 = require("../index");
47
+ const HELP = `agentguard — local-runtime spend caps + signed receipts for AI agents
48
+
49
+ usage:
50
+ agentguard <command> [options]
51
+
52
+ commands:
53
+ demo Run a deterministic simulation with a real cryptographic receipt.
54
+ verify Verify a signed AgentGuard receipt.
55
+ init Scaffold a project (policy.yaml + quickstart + .gitignore).
56
+ doctor Check installation health and configuration.
57
+ explain Decode a signed receipt with cap math + signature breakdown.
58
+ --version Show the installed SDK version.
59
+ --help Show this help.
60
+
61
+ examples:
62
+ agentguard init
63
+ agentguard doctor
64
+ agentguard demo
65
+ agentguard verify --trace latest
66
+ agentguard explain latest
67
+
68
+ docs: https://agentguard.run
69
+ install: pip install agentguard-spend / npm install @agentguard-run/spend
70
+ `;
71
+ async function main(argv = process.argv.slice(2)) {
72
+ if (argv.length === 0 || ['-h', '--help', 'help'].includes(argv[0])) {
73
+ process.stdout.write(HELP);
74
+ return 0;
75
+ }
76
+ if (['-v', '--version', 'version'].includes(argv[0])) {
77
+ console.log(`agentguard ${index_1.AGENTGUARD_SPEND_VERSION}`);
78
+ return 0;
79
+ }
80
+ const command = argv[0];
81
+ const rest = argv.slice(1);
82
+ if (command === 'demo') {
83
+ const { runDemo } = await Promise.resolve().then(() => __importStar(require('./demo')));
84
+ return runDemo(rest);
85
+ }
86
+ if (command === 'verify') {
87
+ const { runVerify } = await Promise.resolve().then(() => __importStar(require('./verify')));
88
+ return runVerify(rest);
89
+ }
90
+ if (command === 'init') {
91
+ const { runInit } = await Promise.resolve().then(() => __importStar(require('./init')));
92
+ return runInit(rest);
93
+ }
94
+ if (command === 'doctor') {
95
+ const { runDoctor } = await Promise.resolve().then(() => __importStar(require('./doctor')));
96
+ return runDoctor(rest);
97
+ }
98
+ if (command === 'explain') {
99
+ const { runExplain } = await Promise.resolve().then(() => __importStar(require('./explain')));
100
+ return runExplain(rest);
101
+ }
102
+ process.stderr.write(`agentguard: unknown command '${command}'\n\n`);
103
+ process.stderr.write(HELP);
104
+ return 2;
105
+ }
106
+ // Allow `node dist/cli/main.js demo` directly
107
+ if (require.main === module) {
108
+ main().then((code) => process.exit(code), (err) => {
109
+ console.error(err);
110
+ process.exit(1);
111
+ });
112
+ }
113
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,oBAqCC;AAhED,oCAAoD;AAEpD,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuBZ,CAAC;AAEK,KAAK,UAAU,IAAI,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,CAA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I,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,8CAA8C;AAC9C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,IAAI,CACT,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAG,EAAE,EAAE;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `agentguard verify` — verify a signed decision log entry.
3
+ *
4
+ * Default target: --trace latest reads ~/.agentguard/demo/latest-receipt.json
5
+ * (produced by `agentguard demo`) and verifies its Ed25519 signature.
6
+ */
7
+ export declare function runVerify(argv: string[]): Promise<number>;
8
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/cli/verify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E/D"}