@agentguard-run/burn 0.3.28 → 0.4.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.
- package/CHANGELOG.md +15 -0
- package/README.md +13 -0
- package/dist/src/adapters/codex.d.ts +4 -2
- package/dist/src/adapters/codex.js +55 -9
- package/dist/src/cli.js +35 -5
- package/dist/src/history/claude-transcript.d.ts +0 -13
- package/dist/src/history/claude-transcript.js +11 -10
- package/dist/src/hook/pre-tool-use.d.ts +0 -16
- package/dist/src/hook/pre-tool-use.js +15 -10
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.js +18 -1
- package/dist/src/insights/launch-evidence.d.ts +25 -0
- package/dist/src/insights/launch-evidence.js +54 -0
- package/dist/src/insights/price-shadow.js +2 -1
- package/dist/src/insights/tally.d.ts +45 -0
- package/dist/src/insights/tally.js +266 -0
- package/dist/src/insights/transcript.js +9 -1
- package/dist/src/insights/tree.d.ts +36 -0
- package/dist/src/insights/tree.js +285 -0
- package/dist/src/insights/types.d.ts +2 -0
- package/dist/src/receipt.d.ts +10 -0
- package/dist/src/receipt.js +53 -2
- package/dist/src/tool-names.d.ts +6 -0
- package/dist/src/tool-names.js +10 -0
- package/dist/src/upgrade-moments.js +2 -1
- package/docs/OCT5_VERIFICATION.md +118 -0
- package/docs/TREE_AND_TALLY.md +70 -0
- package/docs/launch-tree-local-oct5.txt +7 -0
- package/docs/oct5-followup/REPORT.md +105 -0
- package/docs/oct5-followup/checks.json +20 -0
- package/docs/oct5-followup/free-plugin-fixture-output.txt +12 -0
- package/docs/oct5-followup/tally-after.json +5 -0
- package/docs/oct5-followup/tally-after.txt +1 -0
- package/docs/oct5-followup/tree-after.json +40 -0
- package/docs/oct5-followup/tree-after.txt +7 -0
- package/docs/oct5-followup/tree-before.txt +7 -0
- package/docs/oct5-followup/verify-free-receipts.cjs +81 -0
- package/docs/session-tally-local-oct5.txt +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Synthetic lifecycle checks against the unchanged plugin writer and this
|
|
3
|
+
// branch's tally reader. No host session, model call, license or upload.
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const {execFileSync} = require('node:child_process');
|
|
9
|
+
const burnRoot = path.resolve(__dirname, '../..');
|
|
10
|
+
const pluginRoot = path.resolve(burnRoot, '../agentguard-codex-plugin');
|
|
11
|
+
const {sessionTally, renderSessionTally} = require(path.join(burnRoot, 'dist/src/insights/tally.js'));
|
|
12
|
+
const {Engine} = require(path.join(pluginRoot, 'runtime/engine.cjs'));
|
|
13
|
+
const {metadata} = require(path.join(pluginRoot, 'runtime/common.cjs'));
|
|
14
|
+
const receipt = require(path.join(pluginRoot, 'runtime/work-receipt.cjs'));
|
|
15
|
+
const scratch = fs.mkdtempSync(path.join(os.homedir(), 'dev', 'agentguard-free-receipt-fixture-'));
|
|
16
|
+
const originalEnv = {...process.env};
|
|
17
|
+
const hostKeys = ['PLUGIN_ROOT', 'PLUGIN_DATA', 'CLAUDE_PLUGIN_ROOT', 'CLAUDE_PLUGIN_DATA', 'CLAUDE_SESSION_ID', 'CODEX_THREAD_ID', 'AGENTGUARD_SESSION_ID', 'AGENTGUARD_PLUGIN_POLICY'];
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
try {
|
|
21
|
+
for (const host of ['claude-code', 'codex']) for (const mode of ['enforce', 'shadow']) {
|
|
22
|
+
for (const key of hostKeys) delete process.env[key];
|
|
23
|
+
const base = path.join(scratch, host, mode), data = path.join(base, 'data');
|
|
24
|
+
const home = path.join(base, 'burn'), config = path.join(base, 'claude');
|
|
25
|
+
for (const directory of [data, home, config]) fs.mkdirSync(directory, {recursive: true});
|
|
26
|
+
Object.assign(process.env, {AGENTGUARD_HOME: home, CLAUDE_CONFIG_DIR: config, CLAUDE_PROJECT_DIR: base,
|
|
27
|
+
AGENTGUARD_LICENSE_KEY: '', AGENTGUARD_NOTIFY_SUPPRESS: '1'}, host === 'claude-code'
|
|
28
|
+
? {CLAUDE_PLUGIN_DATA: data, CLAUDE_PLUGIN_ROOT: pluginRoot} : {PLUGIN_DATA: data, PLUGIN_ROOT: pluginRoot});
|
|
29
|
+
// Enforce uses the shipped defaults, with no local policy and no key.
|
|
30
|
+
if (mode === 'shadow') fs.writeFileSync(path.join(data, 'policy.json'), JSON.stringify({version: 1, mode}));
|
|
31
|
+
const session = 'synthetic-free-' + host + '-' + mode;
|
|
32
|
+
const transcript = path.join(base, session + '.jsonl');
|
|
33
|
+
fs.writeFileSync(transcript, JSON.stringify({type: 'assistant', timestamp: new Date().toISOString(),
|
|
34
|
+
message: {id: 'synthetic-usage', model: 'claude-opus-5-5', usage: {input_tokens: 10, output_tokens: 2}}}) + '\n');
|
|
35
|
+
const engine = new Engine();
|
|
36
|
+
try {
|
|
37
|
+
await engine.init();
|
|
38
|
+
const {license} = engine.context({sessionId: session});
|
|
39
|
+
assert.equal(license.paid, false); assert.equal(license.tier, 'free'); assert.equal(license.mode, mode);
|
|
40
|
+
const launch = async id => {
|
|
41
|
+
const raw = {session_id: session, tool_use_id: id, tool_name: host === 'claude-code' ? 'Agent' : 'spawn_agent',
|
|
42
|
+
tool_input: {}, cwd: base, transcript_path: transcript, permission_mode: 'default'};
|
|
43
|
+
const meta = {...metadata(raw, 'burn'), permissionMode: 'default'};
|
|
44
|
+
await engine.handle({meta, workingDirectory: base, transcriptPath: transcript});
|
|
45
|
+
await engine.handle({meta: metadata({...raw, hook_event_name: 'PostToolUse', tool_response: {status: 'completed'}}, 'receipt')});
|
|
46
|
+
};
|
|
47
|
+
await launch('synthetic-launch-one');
|
|
48
|
+
assert.equal((await sessionTally(session, {data})).status, 'missing');
|
|
49
|
+
const ended = await receipt.sessionEnd({sessionId: session, transcriptPath: transcript, data,
|
|
50
|
+
request: message => engine.sessionReceipt({sessionId: message.sessionId, transcriptPath: message.receipt?.transcriptPath})});
|
|
51
|
+
assert.equal(ended, 'appended');
|
|
52
|
+
await engine.flush();
|
|
53
|
+
const tally = await sessionTally(session, {data});
|
|
54
|
+
assert.equal(tally.status, 'verified'); assert.equal(tally.counts.launches, 1);
|
|
55
|
+
assert.equal(tally.counts[mode === 'enforce' ? 'allowed' : 'shadow'], 1);
|
|
56
|
+
// Shell discovery has no host plugin variables. Only the writer's
|
|
57
|
+
// registry points it at the real data directory in this fixture.
|
|
58
|
+
const env = {...process.env}; for (const key of hostKeys) delete env[key];
|
|
59
|
+
const output = execFileSync(process.execPath, [path.join(burnRoot, 'dist/src/cli.js'), 'tally', session], {env, encoding: 'utf8'}).trim();
|
|
60
|
+
assert.equal(output, renderSessionTally(tally));
|
|
61
|
+
console.log(`SYNTHETIC Free ${host} ${mode}: ${output}`);
|
|
62
|
+
const empty = session + '-no-tools';
|
|
63
|
+
await engine.sessionReceipt({sessionId: empty}); await engine.flush();
|
|
64
|
+
const zero = await sessionTally(empty, {data});
|
|
65
|
+
assert.equal(zero.status, 'verified'); assert.equal(zero.counts.launches, 0);
|
|
66
|
+
console.log(`SYNTHETIC no-tools ${host} ${mode}: ${renderSessionTally(zero)}`);
|
|
67
|
+
await launch('synthetic-launch-after-resume');
|
|
68
|
+
assert.equal((await engine.sessionReceipt({sessionId: session, transcriptPath: transcript})).receipt, 'duplicate');
|
|
69
|
+
await engine.flush();
|
|
70
|
+
const resumed = await sessionTally(session, {data});
|
|
71
|
+
assert.equal(resumed.status, 'missing');
|
|
72
|
+
assert.equal(resumed.reason, 'Signed receipts for the resumed session are incomplete.');
|
|
73
|
+
console.log(`SYNTHETIC resumed ${host} ${mode}: ${renderSessionTally(resumed)}`);
|
|
74
|
+
} finally { await engine.close(); }
|
|
75
|
+
}
|
|
76
|
+
} finally {
|
|
77
|
+
for (const key of Object.keys(process.env)) if (!(key in originalEnv)) delete process.env[key];
|
|
78
|
+
Object.assign(process.env, originalEnv);
|
|
79
|
+
fs.rmSync(scratch, {recursive: true, force: true});
|
|
80
|
+
}
|
|
81
|
+
})().catch(error => { console.error(error); process.exitCode = 1; });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Signed session receipts are missing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/burn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Local session usage and runaway-agent circuit breaker. Explain tokens, cache rewrites and API list cost, track pace, warn on heavy turns, and gate agent fan-out with signed receipts. Developer command ranking requires explicit --rank.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://agentguard.run/burn",
|
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
"types": "./dist/src/adapters/codex.d.ts",
|
|
32
32
|
"default": "./dist/src/adapters/codex.js"
|
|
33
33
|
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
34
|
+
"./package.json": "./package.json",
|
|
35
|
+
"./tool-names": {
|
|
36
|
+
"types": "./dist/src/tool-names.d.ts",
|
|
37
|
+
"default": "./dist/src/tool-names.js"
|
|
38
|
+
}
|
|
35
39
|
},
|
|
36
40
|
"bin": {
|
|
37
41
|
"agentguard-burn": "dist/src/cli.js"
|
|
@@ -58,7 +62,7 @@
|
|
|
58
62
|
},
|
|
59
63
|
"dependencies": {
|
|
60
64
|
"@napi-rs/canvas": "^1.0.9",
|
|
61
|
-
"@agentguard-run/spend": "0.
|
|
65
|
+
"@agentguard-run/spend": "0.21.0",
|
|
62
66
|
"ajv": "8.17.1"
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|