@agentguard-run/burn 0.5.1 → 0.6.1
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 +16 -0
- package/README.md +78 -1
- package/dist/src/cli.js +150 -4
- package/dist/src/display-mode.d.ts +12 -0
- package/dist/src/display-mode.js +67 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +12 -1
- package/dist/src/insights/compact-replay.d.ts +97 -0
- package/dist/src/insights/compact-replay.js +414 -0
- package/dist/src/insights/compact-settings.d.ts +30 -0
- package/dist/src/insights/compact-settings.js +122 -0
- package/dist/src/insights/i18n.d.ts +19 -0
- package/dist/src/insights/i18n.js +82 -1
- package/dist/src/insights/render.d.ts +13 -1
- package/dist/src/insights/render.js +32 -19
- package/dist/src/insights/simple-data.d.ts +20 -0
- package/dist/src/insights/simple-data.js +229 -0
- package/dist/src/insights/simple-render.d.ts +26 -0
- package/dist/src/insights/simple-render.js +92 -0
- package/dist/src/insights/simple-text.d.ts +33 -0
- package/dist/src/insights/simple-text.js +44 -0
- package/dist/src/insights/status-fields.d.ts +7 -2
- package/dist/src/insights/status-fields.js +18 -1
- package/dist/src/insights/status-text.d.ts +18 -0
- package/dist/src/insights/status-text.js +6 -0
- package/dist/src/insights/week-render.d.ts +4 -0
- package/dist/src/insights/week-render.js +31 -0
- package/dist/src/insights/week.d.ts +75 -0
- package/dist/src/insights/week.js +253 -0
- package/dist/src/live-panel.d.ts +2 -1
- package/dist/src/live-panel.js +29 -2
- package/docs/OCT5_VERIFICATION.md +1 -1
- package/docs/simple-views.md +17 -0
- package/fixtures/burn-week-v1.json +1 -0
- package/package.json +3 -3
package/dist/src/live-panel.js
CHANGED
|
@@ -15,6 +15,11 @@ const node_fs_1 = require("node:fs");
|
|
|
15
15
|
const canvas_1 = require("./canvas");
|
|
16
16
|
const ledger_panel_1 = require("./ledger-panel");
|
|
17
17
|
const recording_1 = require("./recording");
|
|
18
|
+
const sessions_1 = require("./insights/sessions");
|
|
19
|
+
const simple_data_1 = require("./insights/simple-data");
|
|
20
|
+
const simple_render_1 = require("./insights/simple-render");
|
|
21
|
+
const i18n_1 = require("./insights/i18n");
|
|
22
|
+
const upgrade_moments_1 = require("./upgrade-moments");
|
|
18
23
|
const digest = (text) => (0, node_crypto_1.createHash)('sha256').update(text).digest('hex');
|
|
19
24
|
/** The ledger is the single source for decisions, counters and session selection. */
|
|
20
25
|
function panelDecisions(home, sessionId, at = Date.now()) {
|
|
@@ -236,7 +241,7 @@ class StopHold {
|
|
|
236
241
|
}
|
|
237
242
|
}
|
|
238
243
|
exports.StopHold = StopHold;
|
|
239
|
-
async function runLivePanel(home, args) {
|
|
244
|
+
async function runLivePanel(home, args, mode = 'detailed') {
|
|
240
245
|
const flag = (key) => {
|
|
241
246
|
const i = args.indexOf(key);
|
|
242
247
|
if (i < 0)
|
|
@@ -246,6 +251,7 @@ async function runLivePanel(home, args) {
|
|
|
246
251
|
return args[i + 1];
|
|
247
252
|
};
|
|
248
253
|
const replayFile = flag('--replay'), selected = flag('--session');
|
|
254
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: flag('--lang') ?? args.find(arg => arg.startsWith('--lang='))?.slice(7), env: process.env });
|
|
249
255
|
const once = args.includes('--once') || !process.stdout.isTTY;
|
|
250
256
|
const colour = !args.includes('--no-color') && process.env.NO_COLOR === undefined && Boolean(process.stdout.isTTY);
|
|
251
257
|
const viewport = { width: Math.min(104, process.stdout.columns || 104), height: Math.min(35, process.stdout.rows || 35) };
|
|
@@ -256,7 +262,28 @@ async function runLivePanel(home, args) {
|
|
|
256
262
|
const stop = () => { stopped = true; };
|
|
257
263
|
const display = (snapshot, recorded, at) => {
|
|
258
264
|
(0, recording_1.recordFrame)({ kind: 'live', snapshot }, at, viewport);
|
|
259
|
-
|
|
265
|
+
let panel;
|
|
266
|
+
if (mode === 'simple') {
|
|
267
|
+
let usage = { billing: 'unknown', now: snapshot.observedAt, windows: [], spentTodayUsd: null, paceUsdPerHour: null };
|
|
268
|
+
// Old recordings have no host quota/cost evidence. Do not borrow live data.
|
|
269
|
+
if (!recorded)
|
|
270
|
+
try {
|
|
271
|
+
const locations = (0, sessions_1.discoverInsightTranscripts)();
|
|
272
|
+
const location = selected ? (0, sessions_1.selectInsightTranscript)(selected, locations)
|
|
273
|
+
: snapshot.sessionDigest ? locations.find(item => digest(item.sessionId) === snapshot.sessionDigest)
|
|
274
|
+
: (0, sessions_1.selectInsightTranscript)(undefined, locations);
|
|
275
|
+
if (location)
|
|
276
|
+
usage = (0, simple_data_1.readSimpleUsage)(home, { location, locations, now: snapshot.observedAt });
|
|
277
|
+
}
|
|
278
|
+
catch { /* Missing transcripts leave both limits unavailable. */ }
|
|
279
|
+
const stop = snapshot.stop ?? snapshot.decisions.at(-1);
|
|
280
|
+
const next = !(0, node_fs_1.existsSync)((0, upgrade_moments_1.quietFile)(home)) && stop?.verdict === 'STOP' && /^(spawn_rate|fanout):STOP/.test(stop.reason)
|
|
281
|
+
? i18n_1.SIMPLE_TEXT[language].steps.stopped : null;
|
|
282
|
+
panel = (0, simple_render_1.renderSimplePanel)(usage, { ...viewport, at, recorded, colour, lang: language, next });
|
|
283
|
+
}
|
|
284
|
+
else
|
|
285
|
+
panel = renderLivePanel(snapshot, { ...viewport, at, recorded, colour });
|
|
286
|
+
process.stdout.write((process.stdout.isTTY ? '\x1b[H\x1b[2J' : '') + panel.render() + '\n');
|
|
260
287
|
};
|
|
261
288
|
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
262
289
|
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
@@ -4,7 +4,7 @@ Branches: `burn/launch-tree-tally-oct5` in the monorepo and `site/team-view-oct5
|
|
|
4
4
|
|
|
5
5
|
## Feature 1: real local launch tree
|
|
6
6
|
|
|
7
|
-
Actual command: `node dist/src/cli.js tree
|
|
7
|
+
Actual command: `node dist/src/cli.js tree ~/.claude/projects/<project>/<session>.jsonl`.
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
Launch tree
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## Simple and detailed views
|
|
2
|
+
|
|
3
|
+
`statusline`, `why` and `live` start in simple mode. `compact-replay` starts detailed, because its table is the answer; a flag, the environment or a saved `mode simple` preference switches it. Save your preference with `agentguard-burn mode simple` or `agentguard-burn mode detailed`. Burn stores `displayMode` in `burn-config.json` inside `AGENTGUARD_HOME`, normally `~/.agentguard`. `AGENTGUARD_BURN_MODE=simple` or `detailed` overrides that setting. The per-command flags named `simple` and `detailed`, each prefixed by two hyphens, override both. Passing both flags is an error. Detailed mode preserves the previous reports. JSON is byte-identical across modes and does not consume the first-use notice.
|
|
4
|
+
|
|
5
|
+
Simple subscription views show the host's 5-hour and weekly percentages, reset times and remaining time at the observed pace. Without fresh host evidence they say "limit not available". They never show dollars. Remaining time needs two rising observations from the same host pool and reset period; Burn never converts recorded work into plan-limit points. A single fresh observation can show a percentage and reset time, with remaining time unavailable.
|
|
6
|
+
|
|
7
|
+
For explicitly identified API or usage-credit sessions, simple views total host-reported USD in today's local transcripts for that host. They use recorded `costUSD`, or a fresh statusline `cost.total_cost_usd` when the recorded session began today. Missing billing identity, missing amounts, incomplete history and sessions crossing midnight without daily amounts stay unavailable. Burn does not substitute API list prices. Next to today's total, simple views show the last ten minutes' reported dollar pace per hour. Burn never extends that pace into a day total: a short burst is not a forecast. These are locally recorded amounts, not an invoice fetched from the provider. Only numerical host observations and the billing category are saved under `display-observations`; no credentials or message content are read from account files or saved.
|
|
8
|
+
|
|
9
|
+
There is at most one next step, selected from Burn's existing findings. A reliable replay can suggest a smaller window; its percentage describes estimated recorded work, never plan-limit savings. English, Spanish and Portuguese use the existing language preference and language flag. On their first simple view, existing users see one line on stderr: "Showing the simple view. For tokens and cache detail: agentguard-burn mode detailed". That requested migration line is the only simple-view exception to the plain vocabulary. The local `simpleViewSeen` marker prevents repetition. Existing recordings lack these host figures, so simple playback leaves them unavailable.
|
|
10
|
+
|
|
11
|
+
## Evidence and verification
|
|
12
|
+
|
|
13
|
+
Billing categories come from explicit host metadata such as `billing_type`, `billing.type`, `auth_type` or `plan_type`. Claude named plan windows also identify subscription usage. Burn does not infer API billing from a model name, an absent percentage or a credential in the shell. Unknown billing hides dollars. Percentages must be from the past minute; pace uses up to ten minutes of samples with the same pool, duration and reset. Codex quota samples obey the existing transcript ownership checks.
|
|
14
|
+
|
|
15
|
+
Reported per-response amounts are counted once by provider response ID and first observed date. A copied old response stays on its original day. Session totals with overlapping helper or copied history stay unavailable. Today means the local calendar day; a cumulative lifetime total is never split across midnight by guesswork.
|
|
16
|
+
|
|
17
|
+
The existing suite keeps its detailed-output assertions with `AGENTGUARD_BURN_MODE=detailed npm test`. New mode tests clear that preference, use temporary HOME and AGENTGUARD_HOME directories, and forbid real host home reads and network requests. They check the simple default, flag precedence, all four views, translations, dollars and limits, missing evidence, unchanged detailed output and byte-identical JSON. No existing tests are edited.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"schema":"agentguard.burn-week.v1","weekStart":"2026-09-28","viewedAt":"2026-10-05T09:12:00.000Z","figures":{"tokens":{"total":10000000,"useful":4000000,"waste":5800000,"unattributed":200000},"usdMicros":{"total":18400000,"useful":9000000,"waste":9100000,"unattributed":300000},"causes":{"history_resent":{"tokens":4000000,"usdMicros":4000000},"reread_files":{"tokens":300000,"usdMicros":600000},"subagent_fanout":{"tokens":1200000,"usdMicros":3000000},"reloads":{"tokens":300000,"usdMicros":1500000}},"reloadsByCause":{"idle":{"tokens":200000,"usdMicros":1000000},"model_switch":{"tokens":50000,"usdMicros":250000},"other":{"tokens":50000,"usdMicros":250000}},"subagentTokens":1500000,"wrongModel":{"tokens":1000000,"usdMicros":2400000,"smallerUsdMicros":60000},"topCause":"history_resent","basis":"estimated_api_list_price"}}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/burn",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
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",
|
|
7
7
|
"bugs": {
|
|
8
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "https://github.com/agentguard-run/agentguard-codex-plugin/issues"
|
|
9
9
|
},
|
|
10
10
|
"type": "commonjs",
|
|
11
11
|
"main": "dist/src/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsc -p tsconfig.json",
|
|
58
|
-
"test": "tsc -p tsconfig.json && node --test \"dist/tests/**/*.test.js\"",
|
|
58
|
+
"test": "tsc -p tsconfig.json && AGENTGUARD_BURN_MODE=detailed node --test \"dist/tests/**/*.test.js\"",
|
|
59
59
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
60
60
|
"conformance": "tsc -p tsconfig.json && node dist/src/cli.js conformance",
|
|
61
61
|
"replay": "node dist/src/cli.js replay"
|