@agentguard-run/spend 0.1.4 → 0.1.6
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/bin/agentguard.js +9 -0
- package/dist/cli/colors.d.ts +22 -0
- package/dist/cli/colors.d.ts.map +1 -0
- package/dist/cli/colors.js +52 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/demo.d.ts +13 -0
- package/dist/cli/demo.d.ts.map +1 -0
- package/dist/cli/demo.js +173 -0
- package/dist/cli/demo.js.map +1 -0
- package/dist/cli/main.d.ts +11 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +95 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/verify.d.ts +8 -0
- package/dist/cli/verify.d.ts.map +1 -0
- package/dist/cli/verify.js +124 -0
- package/dist/cli/verify.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI color helpers with TTY detection.
|
|
3
|
+
*
|
|
4
|
+
* Honors:
|
|
5
|
+
* - NO_COLOR=1 (industry standard; https://no-color.org)
|
|
6
|
+
* - AGENTGUARD_COLOR=0 (product-specific opt-out)
|
|
7
|
+
* - process.stdout.isTTY (no color when piped to file or non-TTY)
|
|
8
|
+
*/
|
|
9
|
+
export declare const red: (text: string) => string;
|
|
10
|
+
export declare const green: (text: string) => string;
|
|
11
|
+
export declare const yellow: (text: string) => string;
|
|
12
|
+
export declare const cyan: (text: string) => string;
|
|
13
|
+
export declare const brightRed: (text: string) => string;
|
|
14
|
+
export declare const brightGreen: (text: string) => string;
|
|
15
|
+
export declare const brightCyan: (text: string) => string;
|
|
16
|
+
export declare const bold: (text: string) => string;
|
|
17
|
+
export declare const dim: (text: string) => string;
|
|
18
|
+
export declare function cyanBold(text: string): string;
|
|
19
|
+
export declare function redBold(text: string): string;
|
|
20
|
+
export declare function greenBold(text: string): string;
|
|
21
|
+
export declare function banner(version: string): string;
|
|
22
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/cli/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH,eAAO,MAAM,GAAG,SAJoB,MAAM,KAAK,MAIlB,CAAC;AAC9B,eAAO,MAAM,KAAK,SALkB,MAAM,KAAK,MAKhB,CAAC;AAChC,eAAO,MAAM,MAAM,SANiB,MAAM,KAAK,MAMf,CAAC;AACjC,eAAO,MAAM,IAAI,SAPmB,MAAM,KAAK,MAOjB,CAAC;AAC/B,eAAO,MAAM,SAAS,SARc,MAAM,KAAK,MAQZ,CAAC;AACpC,eAAO,MAAM,WAAW,SATY,MAAM,KAAK,MASV,CAAC;AACtC,eAAO,MAAM,UAAU,SAVa,MAAM,KAAK,MAUX,CAAC;AACrC,eAAO,MAAM,IAAI,SAXmB,MAAM,KAAK,MAWlB,CAAC;AAC9B,eAAO,MAAM,GAAG,SAZoB,MAAM,KAAK,MAYnB,CAAC;AAE7B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ANSI color helpers with TTY detection.
|
|
4
|
+
*
|
|
5
|
+
* Honors:
|
|
6
|
+
* - NO_COLOR=1 (industry standard; https://no-color.org)
|
|
7
|
+
* - AGENTGUARD_COLOR=0 (product-specific opt-out)
|
|
8
|
+
* - process.stdout.isTTY (no color when piped to file or non-TTY)
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.dim = exports.bold = exports.brightCyan = exports.brightGreen = exports.brightRed = exports.cyan = exports.yellow = exports.green = exports.red = void 0;
|
|
12
|
+
exports.cyanBold = cyanBold;
|
|
13
|
+
exports.redBold = redBold;
|
|
14
|
+
exports.greenBold = greenBold;
|
|
15
|
+
exports.banner = banner;
|
|
16
|
+
function colorEnabled() {
|
|
17
|
+
if (typeof process === 'undefined')
|
|
18
|
+
return false;
|
|
19
|
+
if (process.env.NO_COLOR)
|
|
20
|
+
return false;
|
|
21
|
+
const ag = (process.env.AGENTGUARD_COLOR || '').toLowerCase();
|
|
22
|
+
if (['0', 'false', 'no', 'off'].includes(ag))
|
|
23
|
+
return false;
|
|
24
|
+
if (!process.stdout || !process.stdout.isTTY)
|
|
25
|
+
return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
function wrap(code) {
|
|
29
|
+
return (text) => (colorEnabled() ? `\x1b[${code}m${text}\x1b[0m` : text);
|
|
30
|
+
}
|
|
31
|
+
exports.red = wrap('31');
|
|
32
|
+
exports.green = wrap('32');
|
|
33
|
+
exports.yellow = wrap('33');
|
|
34
|
+
exports.cyan = wrap('36');
|
|
35
|
+
exports.brightRed = wrap('91');
|
|
36
|
+
exports.brightGreen = wrap('92');
|
|
37
|
+
exports.brightCyan = wrap('96');
|
|
38
|
+
exports.bold = wrap('1');
|
|
39
|
+
exports.dim = wrap('2');
|
|
40
|
+
function cyanBold(text) {
|
|
41
|
+
return colorEnabled() ? `\x1b[1;36m${text}\x1b[0m` : text;
|
|
42
|
+
}
|
|
43
|
+
function redBold(text) {
|
|
44
|
+
return colorEnabled() ? `\x1b[1;31m${text}\x1b[0m` : text;
|
|
45
|
+
}
|
|
46
|
+
function greenBold(text) {
|
|
47
|
+
return colorEnabled() ? `\x1b[1;32m${text}\x1b[0m` : text;
|
|
48
|
+
}
|
|
49
|
+
function banner(version) {
|
|
50
|
+
return cyanBold(`⬡ AGENTGUARD SPEND · v${version}`);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/cli/colors.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAyBH,4BAEC;AAED,0BAEC;AAED,8BAEC;AAED,wBAEC;AArCD,SAAS,YAAY;IACnB,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACjD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9D,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAC3D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,IAAI,CAAC,IAAY;IACxB,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACnF,CAAC;AAEY,QAAA,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,QAAA,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACnB,QAAA,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AAClB,QAAA,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,QAAA,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,QAAA,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,QAAA,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AACjB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAE7B,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,YAAY,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,OAAO,YAAY,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,YAAY,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC;AAED,SAAgB,MAAM,CAAC,OAAe;IACpC,OAAO,QAAQ,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agentguard demo` — deterministic simulation with real cryptographic receipt.
|
|
3
|
+
*
|
|
4
|
+
* Output matches agentguard.run/the-block/ exactly. Dollar amounts and
|
|
5
|
+
* agent name are simulated parameters (fixed for reproducibility). The
|
|
6
|
+
* Ed25519 signature, SHA-256 chain hash, and canonical-JSON
|
|
7
|
+
* serialization are REAL — the receipt can be verified with
|
|
8
|
+
* `agentguard verify --trace latest`.
|
|
9
|
+
*
|
|
10
|
+
* No network calls. Fully offline. Deterministic across runs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runDemo(argv: string[]): Promise<number>;
|
|
13
|
+
//# sourceMappingURL=demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../src/cli/demo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuBH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmI7D"}
|
package/dist/cli/demo.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agentguard demo` — deterministic simulation with real cryptographic receipt.
|
|
4
|
+
*
|
|
5
|
+
* Output matches agentguard.run/the-block/ exactly. Dollar amounts and
|
|
6
|
+
* agent name are simulated parameters (fixed for reproducibility). The
|
|
7
|
+
* Ed25519 signature, SHA-256 chain hash, and canonical-JSON
|
|
8
|
+
* serialization are REAL — the receipt can be verified with
|
|
9
|
+
* `agentguard verify --trace latest`.
|
|
10
|
+
*
|
|
11
|
+
* No network calls. Fully offline. Deterministic across runs.
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.runDemo = runDemo;
|
|
48
|
+
const fs = __importStar(require("fs"));
|
|
49
|
+
const os = __importStar(require("os"));
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const ed = __importStar(require("@noble/ed25519"));
|
|
52
|
+
const decision_log_1 = require("../decision-log");
|
|
53
|
+
const i18n_1 = require("../i18n");
|
|
54
|
+
const index_1 = require("../index");
|
|
55
|
+
const colors_1 = require("./colors");
|
|
56
|
+
const DEMO_HOME = path.join(os.homedir(), '.agentguard', 'demo');
|
|
57
|
+
const DEMO_PRIVATE_KEY = path.join(DEMO_HOME, 'demo-private.key');
|
|
58
|
+
const DEMO_PUBLIC_KEY = path.join(DEMO_HOME, 'demo-public.key');
|
|
59
|
+
const DEMO_RECEIPT = path.join(DEMO_HOME, 'latest-receipt.json');
|
|
60
|
+
async function runDemo(argv) {
|
|
61
|
+
if (argv.includes('--no-color')) {
|
|
62
|
+
process.env.NO_COLOR = '1';
|
|
63
|
+
}
|
|
64
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
65
|
+
console.log('agentguard demo');
|
|
66
|
+
console.log('Run a deterministic simulation with a real cryptographic receipt.');
|
|
67
|
+
console.log('Options:');
|
|
68
|
+
console.log(' --no-color Disable colored output (same as NO_COLOR=1).');
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
// Simulated parameters - match the marketing screenshot at agentguard.run/the-block/.
|
|
72
|
+
const agentId = 'agent-finance-bot-v3';
|
|
73
|
+
const provider = 'anthropic';
|
|
74
|
+
const modelRequested = 'claude-opus-4-7';
|
|
75
|
+
const dailyCapCents = 50000; // $500.00
|
|
76
|
+
const projectedCents = 112241; // $1,122.41
|
|
77
|
+
const windowSpendBefore = 0;
|
|
78
|
+
const timestamp = '2026-05-24T18:00:00.000Z';
|
|
79
|
+
// Deterministic keypair from a fixed seed.
|
|
80
|
+
// Public + reproducible by design - NEVER use for production.
|
|
81
|
+
const privateSeed = new Uint8Array(32);
|
|
82
|
+
for (let i = 0; i < 32; i++)
|
|
83
|
+
privateSeed[i] = i;
|
|
84
|
+
const publicKey = await ed.getPublicKeyAsync(privateSeed);
|
|
85
|
+
const triggeredCap = {
|
|
86
|
+
amountCents: dailyCapCents,
|
|
87
|
+
window: 'per_day',
|
|
88
|
+
action: 'block',
|
|
89
|
+
reason: `Hard daily ceiling ($${(dailyCapCents / 100).toFixed(2)}/day)`,
|
|
90
|
+
};
|
|
91
|
+
const decision = {
|
|
92
|
+
decisionId: 'agentguard-demo-decision-v1',
|
|
93
|
+
timestamp,
|
|
94
|
+
policyId: 'agentguard-demo-policy-v1',
|
|
95
|
+
policyVersion: 1,
|
|
96
|
+
enforcementMode: 'enforce',
|
|
97
|
+
action: 'block',
|
|
98
|
+
reasons: [`Cap 'per_day=${dailyCapCents}c' exceeded`],
|
|
99
|
+
provider,
|
|
100
|
+
modelRequested,
|
|
101
|
+
modelResolved: modelRequested,
|
|
102
|
+
projectedCents,
|
|
103
|
+
windowSpendBefore,
|
|
104
|
+
windowSpendAfter: windowSpendBefore,
|
|
105
|
+
triggeredCap,
|
|
106
|
+
triggeredScopeKey: `tenantId=demo|agentId=${agentId}`,
|
|
107
|
+
};
|
|
108
|
+
// REAL Ed25519 signature over REAL canonical JSON.
|
|
109
|
+
const sequence = 0;
|
|
110
|
+
const previousHash = decision_log_1.GENESIS_PREVIOUS_HASH;
|
|
111
|
+
const entryHash = (0, decision_log_1.computeEntryHash)({ sequence, decision, previousHash });
|
|
112
|
+
void entryHash; // computed for the persisted receipt below
|
|
113
|
+
const signedEntry = await (0, decision_log_1.signDecision)({
|
|
114
|
+
sequence,
|
|
115
|
+
decision,
|
|
116
|
+
previousHash,
|
|
117
|
+
privateKey: privateSeed,
|
|
118
|
+
publicKey,
|
|
119
|
+
});
|
|
120
|
+
const signerFingerprint = (0, decision_log_1.computeSignerFingerprint)(publicKey);
|
|
121
|
+
console.log('');
|
|
122
|
+
console.log(' ' + (0, colors_1.banner)(index_1.AGENTGUARD_SPEND_VERSION));
|
|
123
|
+
console.log('');
|
|
124
|
+
console.log(' ' +
|
|
125
|
+
(0, colors_1.cyanBold)('AgentGuard Demo') +
|
|
126
|
+
(0, colors_1.dim)(' · ') +
|
|
127
|
+
(0, colors_1.dim)('[simulated transaction · real cryptographic receipt]'));
|
|
128
|
+
console.log('');
|
|
129
|
+
console.log((0, i18n_1.formatBlockedTrace)({
|
|
130
|
+
policyId: decision.policyId,
|
|
131
|
+
provider: decision.provider,
|
|
132
|
+
projectedCents: decision.projectedCents,
|
|
133
|
+
windowSpendBefore: decision.windowSpendBefore,
|
|
134
|
+
reasons: decision.reasons,
|
|
135
|
+
triggeredCap: { amountCents: triggeredCap.amountCents, window: triggeredCap.window },
|
|
136
|
+
agentId,
|
|
137
|
+
}));
|
|
138
|
+
console.log('');
|
|
139
|
+
// Persist the receipt so `agentguard verify --trace latest` works.
|
|
140
|
+
try {
|
|
141
|
+
fs.mkdirSync(DEMO_HOME, { recursive: true });
|
|
142
|
+
fs.writeFileSync(DEMO_PRIVATE_KEY, Buffer.from(privateSeed), { mode: 0o600 });
|
|
143
|
+
fs.writeFileSync(DEMO_PUBLIC_KEY, Buffer.from(publicKey));
|
|
144
|
+
fs.writeFileSync(DEMO_RECEIPT, JSON.stringify({
|
|
145
|
+
sequence,
|
|
146
|
+
entryHash,
|
|
147
|
+
previousHash,
|
|
148
|
+
signature: signedEntry.signature,
|
|
149
|
+
signerFingerprint,
|
|
150
|
+
publicKeyHex: Buffer.from(publicKey).toString('hex'),
|
|
151
|
+
decision,
|
|
152
|
+
}, null, 2));
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// best-effort persist; demo still prints if disk write fails
|
|
156
|
+
}
|
|
157
|
+
const receiptId = entryHash.slice(0, 16);
|
|
158
|
+
console.log((0, colors_1.dim)(' ───────────────────────────────────────────'));
|
|
159
|
+
console.log(` ${(0, colors_1.dim)('receipt ')} ${receiptId}${(0, colors_1.dim)('...')}`);
|
|
160
|
+
console.log(` ${(0, colors_1.dim)('signer ')} ${signerFingerprint.slice(0, 16)}${(0, colors_1.dim)('...')}`);
|
|
161
|
+
console.log(` ${(0, colors_1.dim)('sequence ')} ${sequence}`);
|
|
162
|
+
console.log((0, colors_1.dim)(' ───────────────────────────────────────────'));
|
|
163
|
+
console.log('');
|
|
164
|
+
console.log(' ' +
|
|
165
|
+
(0, colors_1.green)('→') +
|
|
166
|
+
' ' +
|
|
167
|
+
(0, colors_1.dim)('verify this receipt:') +
|
|
168
|
+
' ' +
|
|
169
|
+
(0, colors_1.greenBold)('agentguard verify --trace latest'));
|
|
170
|
+
console.log('');
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=demo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../../src/cli/demo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,0BAmIC;AAxJD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAC7B,mDAAqC;AAErC,kDAKyB;AAEzB,kCAA6C;AAC7C,oCAAoD;AACpD,qCAAmE;AAEnE,MAAM,SAAS,GAAG,IAAI,CAAC,I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
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;AAuBH,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlF"}
|
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
--version Show the installed SDK version.
|
|
56
|
+
--help Show this help.
|
|
57
|
+
|
|
58
|
+
examples:
|
|
59
|
+
agentguard demo
|
|
60
|
+
agentguard verify --trace latest
|
|
61
|
+
|
|
62
|
+
docs: https://agentguard.run
|
|
63
|
+
install: pip install agentguard-spend / npm install @agentguard-run/spend
|
|
64
|
+
`;
|
|
65
|
+
async function main(argv = process.argv.slice(2)) {
|
|
66
|
+
if (argv.length === 0 || ['-h', '--help', 'help'].includes(argv[0])) {
|
|
67
|
+
process.stdout.write(HELP);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
if (['-v', '--version', 'version'].includes(argv[0])) {
|
|
71
|
+
console.log(`agentguard ${index_1.AGENTGUARD_SPEND_VERSION}`);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
const command = argv[0];
|
|
75
|
+
const rest = argv.slice(1);
|
|
76
|
+
if (command === 'demo') {
|
|
77
|
+
const { runDemo } = await Promise.resolve().then(() => __importStar(require('./demo')));
|
|
78
|
+
return runDemo(rest);
|
|
79
|
+
}
|
|
80
|
+
if (command === 'verify') {
|
|
81
|
+
const { runVerify } = await Promise.resolve().then(() => __importStar(require('./verify')));
|
|
82
|
+
return runVerify(rest);
|
|
83
|
+
}
|
|
84
|
+
process.stderr.write(`agentguard: unknown command '${command}'\n\n`);
|
|
85
|
+
process.stderr.write(HELP);
|
|
86
|
+
return 2;
|
|
87
|
+
}
|
|
88
|
+
// Allow `node dist/cli/main.js demo` directly
|
|
89
|
+
if (require.main === module) {
|
|
90
|
+
main().then((code) => process.exit(code), (err) => {
|
|
91
|
+
console.error(err);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,oBAyBC;AA9CD,oCAAoD;AAEpD,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;CAiBZ,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,CA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ACnB,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"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agentguard verify` — verify a signed decision log entry.
|
|
4
|
+
*
|
|
5
|
+
* Default target: --trace latest reads ~/.agentguard/demo/latest-receipt.json
|
|
6
|
+
* (produced by `agentguard demo`) and verifies its Ed25519 signature.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.runVerify = runVerify;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const decision_log_1 = require("../decision-log");
|
|
47
|
+
const index_1 = require("../index");
|
|
48
|
+
const colors_1 = require("./colors");
|
|
49
|
+
const DEMO_RECEIPT = path.join(os.homedir(), '.agentguard', 'demo', 'latest-receipt.json');
|
|
50
|
+
async function runVerify(argv) {
|
|
51
|
+
let trace = 'latest';
|
|
52
|
+
let publicKeyHex;
|
|
53
|
+
for (let i = 0; i < argv.length; i++) {
|
|
54
|
+
const a = argv[i];
|
|
55
|
+
if (a === '--trace') {
|
|
56
|
+
trace = argv[++i] ?? 'latest';
|
|
57
|
+
}
|
|
58
|
+
else if (a === '--public-key') {
|
|
59
|
+
publicKeyHex = argv[++i];
|
|
60
|
+
}
|
|
61
|
+
else if (a === '--help' || a === '-h') {
|
|
62
|
+
console.log('agentguard verify [--trace latest|<path>] [--public-key <hex>]');
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let source;
|
|
67
|
+
if (trace === 'latest') {
|
|
68
|
+
source = DEMO_RECEIPT;
|
|
69
|
+
if (!fs.existsSync(source)) {
|
|
70
|
+
console.log((0, colors_1.redBold)('error: ') + 'no demo receipt found.');
|
|
71
|
+
console.log('');
|
|
72
|
+
console.log(` run ${(0, colors_1.greenBold)('agentguard demo')} first to produce a receipt.`);
|
|
73
|
+
return 2;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
source = path.resolve(trace.replace(/^~/, os.homedir()));
|
|
78
|
+
if (!fs.existsSync(source)) {
|
|
79
|
+
console.log((0, colors_1.redBold)('error: ') + `receipt file not found: ${source}`);
|
|
80
|
+
return 2;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const raw = JSON.parse(fs.readFileSync(source, 'utf-8'));
|
|
84
|
+
const entry = {
|
|
85
|
+
sequence: raw.sequence,
|
|
86
|
+
entryHash: raw.entryHash,
|
|
87
|
+
previousHash: raw.previousHash,
|
|
88
|
+
signature: raw.signature,
|
|
89
|
+
signerFingerprint: raw.signerFingerprint,
|
|
90
|
+
decision: raw.decision,
|
|
91
|
+
};
|
|
92
|
+
const pubHex = publicKeyHex || raw.publicKeyHex;
|
|
93
|
+
if (!pubHex) {
|
|
94
|
+
console.log((0, colors_1.redBold)('error: ') + 'no public key available for verification.');
|
|
95
|
+
return 2;
|
|
96
|
+
}
|
|
97
|
+
const publicKey = Uint8Array.from(Buffer.from(pubHex, 'hex'));
|
|
98
|
+
const ok = await (0, decision_log_1.verifyEntry)(entry, publicKey);
|
|
99
|
+
console.log('');
|
|
100
|
+
console.log(' ' + (0, colors_1.banner)(index_1.AGENTGUARD_SPEND_VERSION));
|
|
101
|
+
console.log('');
|
|
102
|
+
console.log(' ' + (0, colors_1.cyanBold)(`agentguard verify --trace ${trace}`));
|
|
103
|
+
console.log('');
|
|
104
|
+
const label = (s) => (0, colors_1.dim)(` ${s.padEnd(14)}`);
|
|
105
|
+
console.log(label('receipt') + entry.entryHash.slice(0, 32) + (0, colors_1.dim)('...'));
|
|
106
|
+
console.log(label('signer') + entry.signerFingerprint.slice(0, 32) + (0, colors_1.dim)('...'));
|
|
107
|
+
console.log(label('sequence') + String(entry.sequence));
|
|
108
|
+
console.log(label('policy') + entry.decision.policyId);
|
|
109
|
+
console.log(label('action') + entry.decision.action);
|
|
110
|
+
console.log('');
|
|
111
|
+
if (ok) {
|
|
112
|
+
console.log(' ' + (0, colors_1.greenBold)('✓ signature valid'));
|
|
113
|
+
console.log(' ' + (0, colors_1.green)('✓ entry hash matches canonical JSON'));
|
|
114
|
+
console.log(' ' + (0, colors_1.green)('✓ chain link to previous entry intact'));
|
|
115
|
+
console.log('');
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
console.log(' ' + (0, colors_1.redBold)('✗ verification FAILED'));
|
|
119
|
+
console.log('');
|
|
120
|
+
console.log((0, colors_1.dim)(' one or more of: signature mismatch, entryHash mismatch, chain broken.'));
|
|
121
|
+
console.log('');
|
|
122
|
+
return 1;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/cli/verify.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaH,8BA2EC;AAtFD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,kDAA8C;AAE9C,oCAAoD;AACpD,qCAA4E;AAE5E,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,qBAAqB,CAAC,CA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AC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,IAAA,gBAAO,EAAC,uBAAuB,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,IAAA,YAAG,EAAC,yEAAyE,CAAC,CAAC,CAAC;IAC5F,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { canonicalJson, sha256Hex, computeEntryHash, computeSignerFingerprint, s
|
|
|
12
12
|
export { InMemorySpendStore } from './store-memory';
|
|
13
13
|
export { SpendGuard, withSpendGuard, AgentGuardBlockedError, type SpendGuardConfig, type OpenAIBindingOptions, } from './spend-guard';
|
|
14
14
|
export { DEFAULT_LOCALE, SUPPORTED_LOCALES, TRANSLATIONS, type SupportedLocale, resolveLocale, t, formatBlockedTrace, type BlockedTraceArgs, } from './i18n';
|
|
15
|
-
export declare const AGENTGUARD_SPEND_VERSION = "0.1.
|
|
15
|
+
export declare const AGENTGUARD_SPEND_VERSION = "0.1.6";
|
|
16
16
|
/** Patent marking. 35 U.S.C. § 287 constructive notice. */
|
|
17
17
|
export declare const PATENT_NOTICE: string;
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ Object.defineProperty(exports, "TRANSLATIONS", { enumerable: true, get: function
|
|
|
46
46
|
Object.defineProperty(exports, "resolveLocale", { enumerable: true, get: function () { return i18n_1.resolveLocale; } });
|
|
47
47
|
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
|
|
48
48
|
Object.defineProperty(exports, "formatBlockedTrace", { enumerable: true, get: function () { return i18n_1.formatBlockedTrace; } });
|
|
49
|
-
exports.AGENTGUARD_SPEND_VERSION = '0.1.
|
|
49
|
+
exports.AGENTGUARD_SPEND_VERSION = '0.1.6';
|
|
50
50
|
/** Patent marking. 35 U.S.C. § 287 constructive notice. */
|
|
51
51
|
exports.PATENT_NOTICE = 'Protected by U.S. patent-pending technology ' +
|
|
52
52
|
'(App. Nos. 63/983,615; 63/983,621; 63/983,843; 63/984,626; ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/spend",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Local-runtime spend caps and capability-gated model routing for AI agents. Prompts, API keys, and signing keys stay inside the customer runtime. Zero data plane involvement.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,12 @@
|
|
|
21
21
|
"default": "./dist/decision-log.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"agentguard": "./bin/agentguard.js"
|
|
26
|
+
},
|
|
24
27
|
"files": [
|
|
25
28
|
"dist",
|
|
29
|
+
"bin",
|
|
26
30
|
"README.md",
|
|
27
31
|
"LICENSE",
|
|
28
32
|
"PATENTS.md"
|