@agentguard-run/burn 0.7.0 → 0.7.2
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 +14 -0
- package/README.md +18 -0
- package/dist/src/canvas.d.ts +7 -1
- package/dist/src/canvas.js +17 -1
- package/dist/src/cli.js +42 -1
- package/dist/src/copy-ramp.d.ts +73 -0
- package/dist/src/copy-ramp.js +118 -0
- package/dist/src/dashboard-render.js +8 -4
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +14 -1
- package/dist/src/insights/i18n.d.ts +39 -0
- package/dist/src/insights/i18n.js +80 -1
- package/dist/src/insights/models.d.ts +169 -0
- package/dist/src/insights/models.js +280 -0
- package/dist/src/insights/pricing.js +2 -0
- package/dist/src/live-panel.js +5 -2
- package/dist/src/render-recording.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.2 (2026-11-13)
|
|
4
|
+
|
|
5
|
+
- Add `models [--days N] [--limit N] [--max-mb N] [json] [--lang en|es|pt]`: the top-level Claude Code and Codex sessions that started in the last N days (default 30, up to 365), each under its dominant model, models ordered by first session so the report reads as before, then after a switch. Per model: sessions, first and last session date, and per-session medians and totals of input tokens, output tokens, cache share, sub-agents launched, sub-agents that ended without finishing, and the API list-price equivalent. Every session's figures are the ones `compare` and `why` print for it, child transcripts included. Unpriced stays unpriced. How sub-agents ended is counted only where a sub-agent transcript records it; elsewhere it is unknown, left out of that row and counted, never 0. Measurement only: it never says which model did better.
|
|
6
|
+
- `models` reads at most the 300 most recently changed sessions in the window (`--limit`, up to 2000) and skips any session whose transcript plus sub-agent transcripts pass 256 MB (`--max-mb`, up to 4096), reading files in 16 MB pieces. Each session it does not count is counted by reason (over the size cap, unreadable, Codex usage unavailable, past the limit, started before the window, no timed response) and printed, never dropped.
|
|
7
|
+
- The package exports `modelsReport(options)`, `renderModels(report, lang)` and `modelGroups(sessions)`, so the AgentGuard plugin can offer `agentguard-burn models` where the installed Burn has it (`typeof modelsReport === 'function'`).
|
|
8
|
+
- Price Claude Fable 5.2 (`claude-fable-5-2`): $8 input, $10 five-minute and $16 one-hour cache writes, $0.20 cache hits, $40 output per million tokens, verified on Anthropic's pricing page on 2026-11-13. Its sessions were unpriced in `why`, `compare` and `models` before.
|
|
9
|
+
|
|
10
|
+
## 0.7.1 (2026-10-29)
|
|
11
|
+
|
|
12
|
+
- Brand ramp for the copies of a recorded run (`src/copy-ramp.ts`): fifteen oklch hues from teal 185 to violet 300 at chroma 0.105, chips at lightness 0.76, token cells at 0.63 with alpha 0.88, ledger text at 0.78, with the sRGB conversion and the nearest xterm index for 256-colour terminals. The canvas palette carries them as `copy01` to `copy15`, and showcase and phone frames use the same values. Teal stays for OK, red for STOP and every refused attempt, amber for WARN, and the done tick stays ink; no copy colour comes near any of them, so copy 1 no longer reads as allowed and copy 15 no longer reads as refused.
|
|
13
|
+
- The phone panel paints one ramp colour per launched copy instead of the spawn bar's state colour, which at the ceiling painted every copy red. The dashboard's ring markers and child cost bars carry the ramp too; the warn state stays on the arc, the bar and the counters.
|
|
14
|
+
- `ajv` moves to 8.18.0 (still an exact pin, was 8.17.1), which carries the upstream fix for GHSA-2g4f-4pwh-qvx6. The lockfile resolves `fast-uri` 3.1.9 (was 3.1.8), which carries the upstream fixes for GHSA-w74x-v6f9-j3xg and GHSA-wjr9-j795-jxcr.
|
|
15
|
+
- The `agentguard-burn` wrapper (0.7.1) requires `@agentguard-run/burn` ^0.7.1, so `npx agentguard-burn` gets this release.
|
|
16
|
+
|
|
3
17
|
## 0.7.0 (2026-10-28)
|
|
4
18
|
|
|
5
19
|
- Add `install`: one command for every agent host on this computer. It finds Claude Code, Codex, Cursor and Hermes by their command on PATH and their config folder, reading files only, and prints the plan: each host, the exact commands and the files they change. `--yes` carries it out: the AgentGuard plugin through Claude Code's and Codex's own plugin commands (with `npm ci` in Codex's plugin folder, and in Claude Code's only when it left the dependencies out), Burn's hook merged into `~/.cursor/hooks.json`, and `agentguard-spend-hermes` installed with uv into the Python environment Hermes runs from, then enabled. It then reads each host again and prints one line per host (installed, already installed, skipped, or failed with the reason) with the mode AgentGuard runs in and the status command that confirms the effective mode. `--only` and `--skip` choose hosts; `--json` gives an agent the plan and the results. A second run changes nothing. A failed host does not stop the others, and the exit code is 1. It never runs a downloaded script, never uses sudo, never installs a host itself, never asks for a key and never writes `burn-policy.json`, so the plugin's enforce default still applies to a fresh install.
|
package/README.md
CHANGED
|
@@ -463,6 +463,24 @@ AgentGuard cannot tell whether these sessions did the same task. Compare runs of
|
|
|
463
463
|
|
|
464
464
|
`compare` measures and does not rank models. `--lang es|pt` and your locale choose the language exactly as for `why`. `compare json` is never translated: both sessions with ids, paths, project, models and every metric, and each change as an unrounded fraction of A.
|
|
465
465
|
|
|
466
|
+
## Sessions by model
|
|
467
|
+
|
|
468
|
+
```sh
|
|
469
|
+
agentguard-burn models
|
|
470
|
+
agentguard-burn models --days 14
|
|
471
|
+
agentguard-burn models --days 90 --limit 1000 json
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
After you switch models (Fable 5.2 to Opus 5.5, or one Codex model to another), `models` shows how your own sessions on each model differ. It reads the top-level Claude Code and Codex sessions that started in the last 30 days (`--days N`, 1 to 365), puts each one under its dominant model (the model with the most of its output tokens, as `compare` names it), and lists the models by their first session, oldest first, so the report reads as before, then after. Sessions whose responses carry no model id form their own `unknown model` group.
|
|
475
|
+
|
|
476
|
+
For each model it prints the number of sessions, the first and last session date (UTC), and per-session medians and totals of: input tokens (cache reads, cache writes and fresh input), output tokens, cache share (a median of each session's share, and in the totals the group's cache reads over its input), sub-agents launched, sub-agents that ended without finishing, and the API list-price equivalent. Each session's figures are the ones `compare` and `why` print for it, child transcripts included, so a Codex rollout's spawned sub-agents (separate rollouts that Burn does not add to their parent) are not in it. A dollar range's median runs from the median low end to the median high end. A model without a verified rate prints `unpriced`, and so does any group with one unpriced session: it never prints as $0.00.
|
|
477
|
+
|
|
478
|
+
Sub-agents that ended without finishing are the ones `why` counts: recorded as failed, killed or stopped and never as completed or resumed, read from the sub-agent transcripts Claude Code keeps beside a session. A session that launched none counts 0. A session that launched some with no such transcripts (every Codex session with a launch, and a Claude Code session without the files) is unknown: it is left out of that row, never counted as 0, and a line says for how many sessions of each model it is unknown.
|
|
479
|
+
|
|
480
|
+
The work is bounded. Only files changed in the window are candidates; the 300 most recently changed are read (`--limit N`, up to 2000); and a session whose transcript plus sub-agent transcripts pass 256 MB (`--max-mb N`, up to 4096) is skipped without being read. Nothing is dropped silently: the report ends with one line per reason for every session it did not count, for example `Skipped 2 sessions over 256 MB (transcript plus sub-agent transcripts). Run why on one to see it alone, or raise the cap with --max-mb.` The other reasons are an unreadable file, inherited Codex history with no verifiable boundary (its usage is unavailable, as in `compare`), sessions past the limit, a session changed in the window that started before it, and a session with no timed response.
|
|
481
|
+
|
|
482
|
+
`models` measures and does not rank models: sessions on two models may have done different work. `--lang es|pt` and your locale choose the language exactly as for `why`. `models json` is never translated: the window, each model's figures (medians, totals, known and unknown sub-agent outcomes, unpriced sessions), every counted session with the same fields as `compare json` plus `subagentsUnfinished` and `bytes`, the counts by skip reason, and the path and size of each session skipped for its size, an unreadable file or unavailable usage. The library export is `modelsReport(options)` with `renderModels(report, lang)`.
|
|
483
|
+
|
|
466
484
|
## Tokens per day
|
|
467
485
|
|
|
468
486
|
```sh
|
package/dist/src/canvas.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { type CopyRampName } from './copy-ramp';
|
|
1
2
|
/**
|
|
2
3
|
* Heat ramps for calendar cells: `shade0` is a day with no tokens; `teal1` to
|
|
3
4
|
* `teal4` and `amber1` to `amber4` are the four token levels, mixed from the
|
|
4
5
|
* canvas background toward mint and amber, so the top level is the brand colour.
|
|
5
6
|
*/
|
|
6
7
|
export type CanvasHeatColor = 'shade0' | 'teal1' | 'teal2' | 'teal3' | 'teal4' | 'amber1' | 'amber2' | 'amber3' | 'amber4';
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `copy01` to `copy15` are the brand ramp for the copies of a recorded run (see copy-ramp.ts): one hue per copy from
|
|
10
|
+
* teal into violet at one lightness, so no copy reads as allowed (mint) or refused (red). The values below are the
|
|
11
|
+
* chip colours of that ramp; tests/copy-ramp.test.ts checks them against the conversion.
|
|
12
|
+
*/
|
|
13
|
+
export type CanvasColor = 'mint' | 'slate' | 'amber' | 'red' | 'white' | 'none' | CanvasHeatColor | CopyRampName;
|
|
8
14
|
export type CanvasColorMode = 'truecolor' | '256' | 'none';
|
|
9
15
|
export interface CanvasCell {
|
|
10
16
|
char: string;
|
package/dist/src/canvas.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Canvas = exports.CANVAS_PALETTE = void 0;
|
|
4
4
|
/** A clipped grid of terminal cells. Rendering adds only palette-owned ANSI. */
|
|
5
5
|
const node_util_1 = require("node:util");
|
|
6
|
+
const copy_ramp_1 = require("./copy-ramp");
|
|
6
7
|
exports.CANVAS_PALETTE = {
|
|
7
8
|
mint: { hex: '#2ABCB4', rgb: [42, 188, 180], ansi256: 37 },
|
|
8
9
|
slate: { hex: '#64748B', rgb: [100, 116, 139], ansi256: 66 },
|
|
@@ -18,6 +19,21 @@ exports.CANVAS_PALETTE = {
|
|
|
18
19
|
amber2: { hex: '#8C5F10', rgb: [140, 95, 16], ansi256: 136 },
|
|
19
20
|
amber3: { hex: '#C27F0E', rgb: [194, 127, 14], ansi256: 172 },
|
|
20
21
|
amber4: { hex: '#F59E0B', rgb: [245, 158, 11], ansi256: 214 },
|
|
22
|
+
copy01: { hex: '#55C7BA', rgb: [85, 199, 186], ansi256: 79 },
|
|
23
|
+
copy02: { hex: '#50C6C4', rgb: [80, 198, 196], ansi256: 80 },
|
|
24
|
+
copy03: { hex: '#4FC5CD', rgb: [79, 197, 205], ansi256: 80 },
|
|
25
|
+
copy04: { hex: '#51C3D5', rgb: [81, 195, 213], ansi256: 74 },
|
|
26
|
+
copy05: { hex: '#57C1DD', rgb: [87, 193, 221], ansi256: 74 },
|
|
27
|
+
copy06: { hex: '#5EBFE4', rgb: [94, 191, 228], ansi256: 74 },
|
|
28
|
+
copy07: { hex: '#68BCEA', rgb: [104, 188, 234], ansi256: 74 },
|
|
29
|
+
copy08: { hex: '#72B9EE', rgb: [114, 185, 238], ansi256: 75 },
|
|
30
|
+
copy09: { hex: '#7DB6F2', rgb: [125, 182, 242], ansi256: 111 },
|
|
31
|
+
copy10: { hex: '#88B2F4', rgb: [136, 178, 244], ansi256: 111 },
|
|
32
|
+
copy11: { hex: '#93AFF4', rgb: [147, 175, 244], ansi256: 111 },
|
|
33
|
+
copy12: { hex: '#9EACF4', rgb: [158, 172, 244], ansi256: 147 },
|
|
34
|
+
copy13: { hex: '#A8A8F2', rgb: [168, 168, 242], ansi256: 147 },
|
|
35
|
+
copy14: { hex: '#B2A5EF', rgb: [178, 165, 239], ansi256: 147 },
|
|
36
|
+
copy15: { hex: '#BBA2EA', rgb: [187, 162, 234], ansi256: 146 },
|
|
21
37
|
};
|
|
22
38
|
const GLYPHS = {
|
|
23
39
|
'0': ['█▀█', '█ █', '█▄█'], '1': [' ▀█', ' █', ' █'],
|
|
@@ -40,7 +56,7 @@ const BIG_GLYPHS = {
|
|
|
40
56
|
'9': [' ### ', '# #', '# #', ' ####', ' #', ' #', ' ### '],
|
|
41
57
|
'-': [' ', ' ', ' ', '#####', ' ', ' ', ' '],
|
|
42
58
|
};
|
|
43
|
-
const colors = new Set(['mint', 'slate', 'amber', 'red', 'white', 'none', 'shade0', 'teal1', 'teal2', 'teal3', 'teal4', 'amber1', 'amber2', 'amber3', 'amber4']);
|
|
59
|
+
const colors = new Set(['mint', 'slate', 'amber', 'red', 'white', 'none', 'shade0', 'teal1', 'teal2', 'teal3', 'teal4', 'amber1', 'amber2', 'amber3', 'amber4', ...copy_ramp_1.COPY_RAMP_NAMES]);
|
|
44
60
|
function dimension(value, fallback, limit) {
|
|
45
61
|
return Math.max(1, Math.min(limit, Math.floor(typeof value === 'number' && Number.isFinite(value) ? value : fallback)));
|
|
46
62
|
}
|
package/dist/src/cli.js
CHANGED
|
@@ -389,6 +389,46 @@ async function main(argv) {
|
|
|
389
389
|
show({ kind: 'command', command, values: { ...report } }, json ? JSON.stringify(report, null, 2) + '\n' : renderCompare(report, language) + '\n', json);
|
|
390
390
|
return 0;
|
|
391
391
|
}
|
|
392
|
+
case 'models': {
|
|
393
|
+
// `--days N` (1 to 365), `--limit N` (1 to 2000), `--max-mb N` (1 to 4096), each also as --name=N; `json`, and `--lang` exactly as `why` takes it.
|
|
394
|
+
const { MODELS_DEFAULT_DAYS, MODELS_DEFAULT_LIMIT, MODELS_DEFAULT_MAX_SESSION_BYTES, MODELS_MAX_DAYS, MODELS_MAX_LIMIT, MODELS_MAX_SESSION_MEGABYTES, modelsReport, renderModels } = await Promise.resolve().then(() => __importStar(require('./insights/models')));
|
|
395
|
+
const numbers = { '--days': undefined, '--limit': undefined, '--max-mb': undefined };
|
|
396
|
+
const args = [];
|
|
397
|
+
let lang, langGiven = false, invalid = false;
|
|
398
|
+
for (let i = 0; i < rest.length; i++) {
|
|
399
|
+
const arg = rest[i], name = Object.keys(numbers).find(key => arg === key || arg.startsWith(`${key}=`));
|
|
400
|
+
if (arg === '--lang') {
|
|
401
|
+
langGiven = true;
|
|
402
|
+
lang = rest[++i];
|
|
403
|
+
}
|
|
404
|
+
else if (arg.startsWith('--lang=')) {
|
|
405
|
+
langGiven = true;
|
|
406
|
+
lang = arg.slice('--lang='.length);
|
|
407
|
+
}
|
|
408
|
+
else if (name) {
|
|
409
|
+
if (numbers[name] !== undefined)
|
|
410
|
+
invalid = true;
|
|
411
|
+
numbers[name] = arg === name ? rest[++i] ?? '' : arg.slice(name.length + 1);
|
|
412
|
+
}
|
|
413
|
+
else
|
|
414
|
+
args.push(arg);
|
|
415
|
+
}
|
|
416
|
+
const whole = (value, fallback, high) => value === undefined ? fallback : /^\d{1,4}$/.test(value) && Number(value) >= 1 && Number(value) <= high ? Number(value) : null;
|
|
417
|
+
const days = whole(numbers['--days'], MODELS_DEFAULT_DAYS, MODELS_MAX_DAYS), limit = whole(numbers['--limit'], MODELS_DEFAULT_LIMIT, MODELS_MAX_LIMIT);
|
|
418
|
+
const megabytes = whole(numbers['--max-mb'], MODELS_DEFAULT_MAX_SESSION_BYTES / 1024 / 1024, MODELS_MAX_SESSION_MEGABYTES);
|
|
419
|
+
const json = args.includes('json') || args.includes('--json');
|
|
420
|
+
if (invalid || (langGiven && (0, i18n_1.whyLangOf)(lang) === null) || days === null || limit === null || megabytes === null || args.some(value => value !== 'json' && value !== '--json')) {
|
|
421
|
+
process.stderr.write('Usage: agentguard-burn models [--days N] [--limit N] [--max-mb N] [json] [--lang en|es|pt]\n');
|
|
422
|
+
return 64;
|
|
423
|
+
}
|
|
424
|
+
const roots = (0, sessions_1.transcriptRoots)(), locations = (0, sessions_1.discoverInsightTranscripts)(roots);
|
|
425
|
+
if (!locations.length)
|
|
426
|
+
return showNoSessions(Object.values(roots), json);
|
|
427
|
+
const language = (0, i18n_1.detectWhyLang)({ flag: lang, env: process.env, intlLocale: intlLocale() });
|
|
428
|
+
const report = modelsReport({ days, limit, maxSessionBytes: megabytes * 1024 * 1024, roots, locations, rates: (0, live_1.readPricing)(HOME, (0, pre_tool_use_1.loadPolicy)(HOME)) });
|
|
429
|
+
show({ kind: 'command', command, values: { ...report } }, json ? JSON.stringify(report, null, 2) + '\n' : renderModels(report, language) + '\n', true);
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
392
432
|
case 'week': {
|
|
393
433
|
let lang, weekStart, invalid = false;
|
|
394
434
|
const json = rest.includes('json') || rest.includes('--json');
|
|
@@ -893,7 +933,7 @@ async function main(argv) {
|
|
|
893
933
|
show({ kind: 'command', command: 'help', values: { commands: ['why', 'calendar', 'card'] } }, starter + '\nStart here: npx agentguard-burn why\nAll commands: npx agentguard-burn --help all\n', true);
|
|
894
934
|
return !command || command === 'help' || command === '--help' || command === '-h' ? 0 : 64;
|
|
895
935
|
}
|
|
896
|
-
show({ kind: 'command', command: 'help', values: { commands: ['tree', 'tally', 'ps', 'reap', 'live', 'record', 'render', 'blocks', 'limits', 'price-shadow', 'calendar', 'week', 'why', 'compare', 'rewrites', 'compact-replay', 'ttl', 'pace', 'statusline', 'pricing', 'telemetry', 'replay', 'calibrate', 'status', 'install', 'init', 'enforce', 'shadow', 'resume', 'quiet', 'proxy', 'conformance'] } }, starter + '\nAll commands\n' +
|
|
936
|
+
show({ kind: 'command', command: 'help', values: { commands: ['tree', 'tally', 'ps', 'reap', 'live', 'record', 'render', 'blocks', 'limits', 'price-shadow', 'calendar', 'week', 'why', 'compare', 'models', 'rewrites', 'compact-replay', 'ttl', 'pace', 'statusline', 'pricing', 'telemetry', 'replay', 'calibrate', 'status', 'install', 'init', 'enforce', 'shadow', 'resume', 'quiet', 'proxy', 'conformance'] } }, starter + '\nAll commands\n' +
|
|
897
937
|
' ps [--json] local agent processes, held memory and workspace disk\n' +
|
|
898
938
|
' render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] local recorded-run export\n' +
|
|
899
939
|
' render <run.jsonl> --mp4 <out.mp4> --dashboard [--wide] [--economics <blocks.json>] dashboard export\n' +
|
|
@@ -910,6 +950,7 @@ async function main(argv) {
|
|
|
910
950
|
' --lang es|pt the why report in Latin American Spanish or Brazilian Portuguese; your locale picks it by default\n' +
|
|
911
951
|
' --commits count the commits that landed in its git repository while it ran (runs git on this computer; off by default)\n' +
|
|
912
952
|
' compare [sessionA] [sessionB] two sessions side by side: tokens, cache, sub-agents, rewrites, list USD; json and --lang as for why\n' +
|
|
953
|
+
' models [--days N] [--limit N] [--max-mb N] your sessions grouped by model, oldest first: per-session medians and totals of tokens, cache, sub-agents, list USD; json and --lang as for why\n' +
|
|
913
954
|
' calendar [--weeks N] tokens per day, Claude Code and Codex together: sub-agent days, launches AgentGuard held, dollars at API prices; json and --lang as for why\n' +
|
|
914
955
|
' week [--week YYYY-MM-DD] [json] [--lang en|es|pt] your last completed UTC week: useful work, waste causes and one fix\n' +
|
|
915
956
|
' card [--weeks N] [--out file.png] the calendar\'s totals as one 1200x675 image to share (default 4 weeks); written locally, nothing uploaded\n' +
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand ramp for the copies of a recorded run: fifteen hues from teal (185) through blue into violet (300) in oklch,
|
|
3
|
+
* at one lightness and one chroma, so copy 1 and copy 15 read as the same kind of thing. Teal stays reserved for OK,
|
|
4
|
+
* red for refusals and STOP, amber for WARN, and the done tick stays ink; no copy colour comes near any of them.
|
|
5
|
+
* Token sheet: oklch lightness 0.76 chroma 0.105 for chips, lightness 0.63 at alpha 0.88 for token cells,
|
|
6
|
+
* lightness 0.78 for ledger text in the copy's hue (Claude Design, Oct 28 2026).
|
|
7
|
+
*/
|
|
8
|
+
export declare const COPY_RAMP_SIZE = 15;
|
|
9
|
+
export declare const COPY_RAMP_HUE: Readonly<{
|
|
10
|
+
from: 185;
|
|
11
|
+
to: 300;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const COPY_RAMP_CHROMA = 0.105;
|
|
14
|
+
export declare const COPY_RAMP_LIGHTNESS: Readonly<{
|
|
15
|
+
chip: 0.76;
|
|
16
|
+
cell: 0.63;
|
|
17
|
+
ledger: 0.78;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const COPY_CELL_ALPHA = 0.88;
|
|
20
|
+
export type CopyRole = 'chip' | 'cell' | 'ledger';
|
|
21
|
+
export type Rgb = readonly [number, number, number];
|
|
22
|
+
export interface CopyRampEntry {
|
|
23
|
+
index: number;
|
|
24
|
+
name: CopyRampName;
|
|
25
|
+
hue: number;
|
|
26
|
+
chip: string;
|
|
27
|
+
cell: string;
|
|
28
|
+
ledger: string;
|
|
29
|
+
rgb: Rgb;
|
|
30
|
+
ansi256: number;
|
|
31
|
+
}
|
|
32
|
+
export type CopyRampName = 'copy01' | 'copy02' | 'copy03' | 'copy04' | 'copy05' | 'copy06' | 'copy07' | 'copy08' | 'copy09' | 'copy10' | 'copy11' | 'copy12' | 'copy13' | 'copy14' | 'copy15';
|
|
33
|
+
export declare const COPY_RAMP_NAMES: readonly CopyRampName[];
|
|
34
|
+
/** Copy k of 15 (0-based) sits at an even step from the first hue to the last, both inclusive. */
|
|
35
|
+
export declare function copyHue(index: number): number;
|
|
36
|
+
/** oklch to sRGB, the Ottosson matrices, gamma encoded and clipped to the sRGB cube. */
|
|
37
|
+
export declare function oklchToRgb(lightness: number, chroma: number, hue: number): [number, number, number];
|
|
38
|
+
export declare function rgbToHex(rgb: Rgb): string;
|
|
39
|
+
export declare function hexToRgb(hex: string): [number, number, number];
|
|
40
|
+
/** Nearest of the 240 xterm colours (the 6x6x6 cube and the grey ramp) by sRGB distance, for 256-colour terminals. */
|
|
41
|
+
export declare function nearestAnsi256(rgb: Rgb): number;
|
|
42
|
+
/** The fifteen ramp entries, computed once from the token sheet. */
|
|
43
|
+
export declare const COPY_RAMP: readonly CopyRampEntry[];
|
|
44
|
+
/** Copy k (0-based, wrapping past 15) in one role: the chip fill, the token cell fill, or the ledger line text. */
|
|
45
|
+
export declare function copyColor(index: number, role?: CopyRole): string;
|
|
46
|
+
/** Palette name of copy k, for terminal cells. */
|
|
47
|
+
export declare function copyName(index: number): CopyRampName;
|
|
48
|
+
/**
|
|
49
|
+
* Fixed meanings the ramp never borrows: OK is the brand teal, WARN amber, STOP and every refusal red. The done tick on a
|
|
50
|
+
* chip is drawn in the panel's ink, the same as the copy number, as the Claude Design sample keeps it; it is never a ramp colour.
|
|
51
|
+
*/
|
|
52
|
+
export declare const ROLE_COLORS: Readonly<{
|
|
53
|
+
ok: "#2ABCB4";
|
|
54
|
+
done: "#0B1117";
|
|
55
|
+
warn: "#F59E0B";
|
|
56
|
+
stop: "#FF5A4E";
|
|
57
|
+
}>;
|
|
58
|
+
export type Verdict = 'OK' | 'WARN' | 'STOP';
|
|
59
|
+
export declare function verdictColor(verdict: Verdict): string;
|
|
60
|
+
/**
|
|
61
|
+
* One rule for every mark that stands for a copy or a decision. A refused attempt is red whatever its position;
|
|
62
|
+
* a finished copy keeps its ramp colour and earns an ink tick; a copy that is running is simply its ramp colour.
|
|
63
|
+
*/
|
|
64
|
+
export declare function copyPaint(input: {
|
|
65
|
+
index: number;
|
|
66
|
+
role?: CopyRole;
|
|
67
|
+
refused?: boolean;
|
|
68
|
+
done?: boolean;
|
|
69
|
+
}): {
|
|
70
|
+
color: string;
|
|
71
|
+
tick: string | null;
|
|
72
|
+
alpha: number;
|
|
73
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROLE_COLORS = exports.COPY_RAMP = exports.COPY_RAMP_NAMES = exports.COPY_CELL_ALPHA = exports.COPY_RAMP_LIGHTNESS = exports.COPY_RAMP_CHROMA = exports.COPY_RAMP_HUE = exports.COPY_RAMP_SIZE = void 0;
|
|
4
|
+
exports.copyHue = copyHue;
|
|
5
|
+
exports.oklchToRgb = oklchToRgb;
|
|
6
|
+
exports.rgbToHex = rgbToHex;
|
|
7
|
+
exports.hexToRgb = hexToRgb;
|
|
8
|
+
exports.nearestAnsi256 = nearestAnsi256;
|
|
9
|
+
exports.copyColor = copyColor;
|
|
10
|
+
exports.copyName = copyName;
|
|
11
|
+
exports.verdictColor = verdictColor;
|
|
12
|
+
exports.copyPaint = copyPaint;
|
|
13
|
+
/**
|
|
14
|
+
* Brand ramp for the copies of a recorded run: fifteen hues from teal (185) through blue into violet (300) in oklch,
|
|
15
|
+
* at one lightness and one chroma, so copy 1 and copy 15 read as the same kind of thing. Teal stays reserved for OK,
|
|
16
|
+
* red for refusals and STOP, amber for WARN, and the done tick stays ink; no copy colour comes near any of them.
|
|
17
|
+
* Token sheet: oklch lightness 0.76 chroma 0.105 for chips, lightness 0.63 at alpha 0.88 for token cells,
|
|
18
|
+
* lightness 0.78 for ledger text in the copy's hue (Claude Design, Oct 28 2026).
|
|
19
|
+
*/
|
|
20
|
+
exports.COPY_RAMP_SIZE = 15;
|
|
21
|
+
exports.COPY_RAMP_HUE = Object.freeze({ from: 185, to: 300 });
|
|
22
|
+
exports.COPY_RAMP_CHROMA = 0.105;
|
|
23
|
+
exports.COPY_RAMP_LIGHTNESS = Object.freeze({ chip: 0.76, cell: 0.63, ledger: 0.78 });
|
|
24
|
+
exports.COPY_CELL_ALPHA = 0.88;
|
|
25
|
+
exports.COPY_RAMP_NAMES = Object.freeze(['copy01', 'copy02', 'copy03', 'copy04', 'copy05', 'copy06', 'copy07', 'copy08', 'copy09', 'copy10', 'copy11', 'copy12', 'copy13', 'copy14', 'copy15']);
|
|
26
|
+
/** Copy k of 15 (0-based) sits at an even step from the first hue to the last, both inclusive. */
|
|
27
|
+
function copyHue(index) {
|
|
28
|
+
const k = ((Math.floor(index) % exports.COPY_RAMP_SIZE) + exports.COPY_RAMP_SIZE) % exports.COPY_RAMP_SIZE;
|
|
29
|
+
return exports.COPY_RAMP_HUE.from + k * (exports.COPY_RAMP_HUE.to - exports.COPY_RAMP_HUE.from) / (exports.COPY_RAMP_SIZE - 1);
|
|
30
|
+
}
|
|
31
|
+
/** oklch to sRGB, the Ottosson matrices, gamma encoded and clipped to the sRGB cube. */
|
|
32
|
+
function oklchToRgb(lightness, chroma, hue) {
|
|
33
|
+
const radians = hue * Math.PI / 180, a = chroma * Math.cos(radians), b = chroma * Math.sin(radians);
|
|
34
|
+
const l = Math.pow(lightness + 0.3963377774 * a + 0.2158037573 * b, 3);
|
|
35
|
+
const m = Math.pow(lightness - 0.1055613458 * a - 0.0638541728 * b, 3);
|
|
36
|
+
const s = Math.pow(lightness - 0.0894841775 * a - 1.2914855480 * b, 3);
|
|
37
|
+
const linear = [
|
|
38
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
39
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
40
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s,
|
|
41
|
+
];
|
|
42
|
+
return linear.map(value => {
|
|
43
|
+
const clipped = Math.max(0, Math.min(1, value));
|
|
44
|
+
const encoded = clipped <= 0.0031308 ? 12.92 * clipped : 1.055 * Math.pow(clipped, 1 / 2.4) - 0.055;
|
|
45
|
+
return Math.round(encoded * 255);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function rgbToHex(rgb) {
|
|
49
|
+
return `#${rgb.map(channel => Math.max(0, Math.min(255, Math.round(channel))).toString(16).padStart(2, '0').toUpperCase()).join('')}`;
|
|
50
|
+
}
|
|
51
|
+
function hexToRgb(hex) {
|
|
52
|
+
const match = /^#?([0-9a-f]{6})$/i.exec(hex);
|
|
53
|
+
if (!match)
|
|
54
|
+
throw new Error(`Not a six digit hex colour: ${hex}`);
|
|
55
|
+
const value = parseInt(match[1], 16);
|
|
56
|
+
return [value >> 16 & 255, value >> 8 & 255, value & 255];
|
|
57
|
+
}
|
|
58
|
+
const CUBE_LEVELS = [0, 95, 135, 175, 215, 255];
|
|
59
|
+
/** Nearest of the 240 xterm colours (the 6x6x6 cube and the grey ramp) by sRGB distance, for 256-colour terminals. */
|
|
60
|
+
function nearestAnsi256(rgb) {
|
|
61
|
+
let best = 16, bestDistance = Infinity;
|
|
62
|
+
const consider = (index, candidate) => {
|
|
63
|
+
const distance = (rgb[0] - candidate[0]) ** 2 + (rgb[1] - candidate[1]) ** 2 + (rgb[2] - candidate[2]) ** 2;
|
|
64
|
+
if (distance < bestDistance) {
|
|
65
|
+
best = index;
|
|
66
|
+
bestDistance = distance;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
for (let r = 0; r < 6; r++)
|
|
70
|
+
for (let g = 0; g < 6; g++)
|
|
71
|
+
for (let b = 0; b < 6; b++)
|
|
72
|
+
consider(16 + 36 * r + 6 * g + b, [CUBE_LEVELS[r], CUBE_LEVELS[g], CUBE_LEVELS[b]]);
|
|
73
|
+
for (let i = 0; i < 24; i++) {
|
|
74
|
+
const grey = 8 + 10 * i;
|
|
75
|
+
consider(232 + i, [grey, grey, grey]);
|
|
76
|
+
}
|
|
77
|
+
return best;
|
|
78
|
+
}
|
|
79
|
+
function entry(index) {
|
|
80
|
+
const hue = copyHue(index), rgb = oklchToRgb(exports.COPY_RAMP_LIGHTNESS.chip, exports.COPY_RAMP_CHROMA, hue);
|
|
81
|
+
return {
|
|
82
|
+
index, name: exports.COPY_RAMP_NAMES[index], hue,
|
|
83
|
+
chip: rgbToHex(rgb),
|
|
84
|
+
cell: rgbToHex(oklchToRgb(exports.COPY_RAMP_LIGHTNESS.cell, exports.COPY_RAMP_CHROMA, hue)),
|
|
85
|
+
ledger: rgbToHex(oklchToRgb(exports.COPY_RAMP_LIGHTNESS.ledger, exports.COPY_RAMP_CHROMA, hue)),
|
|
86
|
+
rgb, ansi256: nearestAnsi256(rgb),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** The fifteen ramp entries, computed once from the token sheet. */
|
|
90
|
+
exports.COPY_RAMP = Object.freeze(Array.from({ length: exports.COPY_RAMP_SIZE }, (_, index) => Object.freeze(entry(index))));
|
|
91
|
+
/** Copy k (0-based, wrapping past 15) in one role: the chip fill, the token cell fill, or the ledger line text. */
|
|
92
|
+
function copyColor(index, role = 'chip') {
|
|
93
|
+
const k = ((Math.floor(index) % exports.COPY_RAMP_SIZE) + exports.COPY_RAMP_SIZE) % exports.COPY_RAMP_SIZE;
|
|
94
|
+
return exports.COPY_RAMP[k][role];
|
|
95
|
+
}
|
|
96
|
+
/** Palette name of copy k, for terminal cells. */
|
|
97
|
+
function copyName(index) {
|
|
98
|
+
const k = ((Math.floor(index) % exports.COPY_RAMP_SIZE) + exports.COPY_RAMP_SIZE) % exports.COPY_RAMP_SIZE;
|
|
99
|
+
return exports.COPY_RAMP_NAMES[k];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Fixed meanings the ramp never borrows: OK is the brand teal, WARN amber, STOP and every refusal red. The done tick on a
|
|
103
|
+
* chip is drawn in the panel's ink, the same as the copy number, as the Claude Design sample keeps it; it is never a ramp colour.
|
|
104
|
+
*/
|
|
105
|
+
exports.ROLE_COLORS = Object.freeze({ ok: '#2ABCB4', done: '#0B1117', warn: '#F59E0B', stop: '#FF5A4E' });
|
|
106
|
+
function verdictColor(verdict) {
|
|
107
|
+
return verdict === 'STOP' ? exports.ROLE_COLORS.stop : verdict === 'WARN' ? exports.ROLE_COLORS.warn : exports.ROLE_COLORS.ok;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* One rule for every mark that stands for a copy or a decision. A refused attempt is red whatever its position;
|
|
111
|
+
* a finished copy keeps its ramp colour and earns an ink tick; a copy that is running is simply its ramp colour.
|
|
112
|
+
*/
|
|
113
|
+
function copyPaint(input) {
|
|
114
|
+
if (input.refused)
|
|
115
|
+
return { color: exports.ROLE_COLORS.stop, tick: null, alpha: 1 };
|
|
116
|
+
const role = input.role ?? 'chip';
|
|
117
|
+
return { color: copyColor(input.index, role), tick: input.done ? exports.ROLE_COLORS.done : null, alpha: role === 'cell' ? exports.COPY_CELL_ALPHA : 1 };
|
|
118
|
+
}
|
|
@@ -25,6 +25,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
25
25
|
const node_util_1 = require("node:util");
|
|
26
26
|
const node_path_1 = require("node:path");
|
|
27
27
|
const canvas_1 = require("@napi-rs/canvas");
|
|
28
|
+
const copy_ramp_1 = require("./copy-ramp");
|
|
28
29
|
const live_1 = require("./insights/live");
|
|
29
30
|
const render_recording_1 = require("./render-recording");
|
|
30
31
|
const dashboard_model_1 = require("./dashboard-model");
|
|
@@ -195,18 +196,19 @@ function ring(ctx, model, state, g, phases) {
|
|
|
195
196
|
ctx.lineTo(cx + gateW, cy - r);
|
|
196
197
|
ctx.stroke();
|
|
197
198
|
text(ctx, 'gate', cx - gateW - 14, cy - r + 8, g.small, { color: exports.INK.secondary, align: 'right' });
|
|
198
|
-
// One marker per recorded spawn, popping in at its decision time
|
|
199
|
+
// One marker per recorded spawn, popping in at its decision time, in its copy's ramp colour (teal into violet, copy 1 to 15).
|
|
200
|
+
// The warn state stays on the arc, the bar and the counters; a copy is never drawn amber or red, only the attempts are.
|
|
199
201
|
for (let k = 1; k <= shown; k++) {
|
|
200
202
|
const event = model.events.filter(event => event.verdict !== 'STOP')[k - 1];
|
|
201
203
|
const born = event ? event.offsetMs : 0, scale = easeOut((state.t - born) / 320);
|
|
202
204
|
if (scale <= 0)
|
|
203
205
|
continue;
|
|
204
|
-
const a = angle(k), x = cx + Math.cos(a) * r, y = cy + Math.sin(a) * r
|
|
206
|
+
const a = angle(k), x = cx + Math.cos(a) * r, y = cy + Math.sin(a) * r;
|
|
205
207
|
ctx.fillStyle = exports.INK.paper;
|
|
206
208
|
ctx.beginPath();
|
|
207
209
|
ctx.arc(x, y, 19 * scale, 0, Math.PI * 2);
|
|
208
210
|
ctx.fill();
|
|
209
|
-
ctx.fillStyle =
|
|
211
|
+
ctx.fillStyle = (0, copy_ramp_1.copyColor)(k - 1);
|
|
210
212
|
ctx.beginPath();
|
|
211
213
|
ctx.arc(x, y, 14 * scale, 0, Math.PI * 2);
|
|
212
214
|
ctx.fill();
|
|
@@ -305,6 +307,8 @@ function agents(ctx, model, state, g) {
|
|
|
305
307
|
text(ctx, who, x + 20, cap1, g.body, { color: exports.INK.ink, alpha: reveal });
|
|
306
308
|
text(ctx, 'list price · not a bill', x + 20, cap2, g.body, { color: exports.INK.secondary, alpha: reveal });
|
|
307
309
|
const sorted = [...economics.children].sort((a, b) => (b.tokens ?? 0) - (a.tokens ?? 0)), top = sorted.slice(0, rows), max = top[0]?.tokens ?? 1;
|
|
310
|
+
// A child's bar keeps the ramp colour of its launch position (the economics rows are in start order), so the same copy is the same colour everywhere.
|
|
311
|
+
const launchOrder = new Map(economics.children.map((child, index) => [child.child, index]));
|
|
308
312
|
const first = cap2 + g.body * .7, pitch = (h - (first - y) - 44) / rows, barW = w - 40 - g.number * 3.6;
|
|
309
313
|
top.forEach((child, i) => {
|
|
310
314
|
const row = first + i * pitch, fill = clamp01((child.tokens ?? 0) / max) * reveal;
|
|
@@ -312,7 +316,7 @@ function agents(ctx, model, state, g) {
|
|
|
312
316
|
ctx.beginPath();
|
|
313
317
|
ctx.roundRect(x + 20, row + pitch * .3, barW, 10, 5);
|
|
314
318
|
ctx.fill();
|
|
315
|
-
ctx.fillStyle =
|
|
319
|
+
ctx.fillStyle = (0, copy_ramp_1.copyColor)(launchOrder.get(child.child) ?? i);
|
|
316
320
|
ctx.beginPath();
|
|
317
321
|
ctx.roundRect(x + 20, row + pitch * .3, Math.max(10, barW * fill), 10, 5);
|
|
318
322
|
ctx.fill();
|
package/dist/src/index.d.ts
CHANGED
|
@@ -34,3 +34,4 @@ export { formatStatusFields, parseStatusFields, statusPace, statusColor, type St
|
|
|
34
34
|
export { readStatusBurn, readStatusMetrics } from './insights/status-data';
|
|
35
35
|
export { collectWeek, saveWeek, weekFigures, weekStartOf, lastCompletedWeekStart, isMonday, WEEK_SCHEMA, SMALLER_MODEL, type WeekFigures, type WeekReport, type WeekAmount, type WeekCause, type WeekTopCause, type BurnWeekFile, type CollectWeekOptions, type SaveWeekResult } from './insights/week';
|
|
36
36
|
export { renderWeek } from './insights/week-render';
|
|
37
|
+
export { modelsReport, renderModels, modelGroups, subagentsUnfinished, sessionBytes, MODELS_DEFAULT_DAYS, MODELS_MAX_DAYS, MODELS_DEFAULT_LIMIT, MODELS_MAX_LIMIT, MODELS_DEFAULT_MAX_SESSION_BYTES, MODELS_MAX_SESSION_MEGABYTES, type ModelsReport, type ModelsGroup, type ModelsSession, type ModelsSessionInput, type ModelsSkipped, type ModelsSkippedSession, type ModelsOptions } from './insights/models';
|
package/dist/src/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.agentOverrideAttempt = exports.asksPerson = exports.settingsSnippet = exports.loadPolicy = exports.refreshSession = exports.handlePreToolUse = exports.calibrate = exports.OVERRIDE_COMMAND = exports.stopSummary = exports.sessionSoFar = exports.primarySummary = exports.overriddenLine = exports.continueLines = exports.askReason = exports.renderStop = exports.renderReplay = exports.discoverTranscripts = exports.replayEvents = exports.replaySession = exports.replayAll = exports.RESERVATION_TTL_MS = exports.Transaction = exports.ReservationStore = exports.cacheReadRatio = exports.medianCompletedMinute = exports.windowSum = exports.newSessionState = exports.applyCorrection = exports.applyEvent = exports.checkPolicyFile = exports.sessionTip = exports.MIN_FINISHED_SUBAGENTS = exports.decisionCostLine = exports.subagentCostLine = exports.finishedSubagents = exports.cloneReaderCursor = exports.restoreReaderCursor = exports.saveReaderCursor = exports.readSessionIncremental = exports.normaliseLine = exports.newCursor = exports.readAll = exports.readIncremental = exports.evaluateLocalCompute = exports.fmt = exports.evaluate = exports.CALL_RESERVATION_TTL_MS = exports.DEFAULT_LOCAL_COMPUTE = exports.DEFAULT_THRESHOLDS = exports.DEFAULT_POLICY = void 0;
|
|
18
18
|
exports.parseStatusFields = exports.formatStatusFields = exports.sessionLaunchReceipts = exports.pluginLedgerDirectories = exports.renderSessionTally = exports.readLedgerDailyTallies = exports.readLedgerTallies = exports.tallyEntries = exports.sessionTally = exports.renderLaunchTree = exports.buildLaunchTree = exports.readLaunchTreeWithReceipts = exports.readLaunchTree = exports.inflateHookSession = exports.findingSignature = exports.renderHostHealth = exports.readHookSessions = exports.configPath = exports.health = exports.install = exports.OVERRIDE_WINDOW_MS = exports.clearOverride = exports.consumeOverride = exports.readOverride = exports.writeOverride = exports.runConformance = exports.renderMachineStatus = exports.UsageObserver = exports.profileFor = exports.startProxy = exports.LAUNCH_TOOLS = exports.isLaunchTool = exports.CODEX_FORBIDDEN_FIELDS = exports.readCodexTranscriptUsage = exports.parseCodexTranscript = exports.codexHooksSnippet = exports.handleCodexHook = exports.cursorHooksSnippet = exports.handleCursorHook = exports.BurnStopError = exports.createRawApiGuard = exports.sha256 = exports.canonical = exports.readSpawnAdmission = exports.receiptDigest = exports.verifyReceipt = exports.ReceiptSigner = exports.mergeCapabilities = exports.Gateway = exports.AGENT_OVERRIDE_REASON = void 0;
|
|
19
|
-
exports.renderWeek = exports.SMALLER_MODEL = exports.WEEK_SCHEMA = exports.isMonday = exports.lastCompletedWeekStart = exports.weekStartOf = exports.weekFigures = exports.saveWeek = exports.collectWeek = exports.readStatusMetrics = exports.readStatusBurn = exports.statusColor = exports.statusPace = void 0;
|
|
19
|
+
exports.MODELS_MAX_SESSION_MEGABYTES = exports.MODELS_DEFAULT_MAX_SESSION_BYTES = exports.MODELS_MAX_LIMIT = exports.MODELS_DEFAULT_LIMIT = exports.MODELS_MAX_DAYS = exports.MODELS_DEFAULT_DAYS = exports.sessionBytes = exports.subagentsUnfinished = exports.modelGroups = exports.renderModels = exports.modelsReport = exports.renderWeek = exports.SMALLER_MODEL = exports.WEEK_SCHEMA = exports.isMonday = exports.lastCompletedWeekStart = exports.weekStartOf = exports.weekFigures = exports.saveWeek = exports.collectWeek = exports.readStatusMetrics = exports.readStatusBurn = exports.statusColor = exports.statusPace = void 0;
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
21
|
var defaults_1 = require("./defaults");
|
|
22
22
|
Object.defineProperty(exports, "DEFAULT_POLICY", { enumerable: true, get: function () { return defaults_1.DEFAULT_POLICY; } });
|
|
@@ -170,3 +170,16 @@ Object.defineProperty(exports, "WEEK_SCHEMA", { enumerable: true, get: function
|
|
|
170
170
|
Object.defineProperty(exports, "SMALLER_MODEL", { enumerable: true, get: function () { return week_1.SMALLER_MODEL; } });
|
|
171
171
|
var week_render_1 = require("./insights/week-render");
|
|
172
172
|
Object.defineProperty(exports, "renderWeek", { enumerable: true, get: function () { return week_render_1.renderWeek; } });
|
|
173
|
+
// Sessions grouped by dominant model over a window, for a before and after across a model switch. The plugin detects it by `typeof modelsReport === 'function'`.
|
|
174
|
+
var models_1 = require("./insights/models");
|
|
175
|
+
Object.defineProperty(exports, "modelsReport", { enumerable: true, get: function () { return models_1.modelsReport; } });
|
|
176
|
+
Object.defineProperty(exports, "renderModels", { enumerable: true, get: function () { return models_1.renderModels; } });
|
|
177
|
+
Object.defineProperty(exports, "modelGroups", { enumerable: true, get: function () { return models_1.modelGroups; } });
|
|
178
|
+
Object.defineProperty(exports, "subagentsUnfinished", { enumerable: true, get: function () { return models_1.subagentsUnfinished; } });
|
|
179
|
+
Object.defineProperty(exports, "sessionBytes", { enumerable: true, get: function () { return models_1.sessionBytes; } });
|
|
180
|
+
Object.defineProperty(exports, "MODELS_DEFAULT_DAYS", { enumerable: true, get: function () { return models_1.MODELS_DEFAULT_DAYS; } });
|
|
181
|
+
Object.defineProperty(exports, "MODELS_MAX_DAYS", { enumerable: true, get: function () { return models_1.MODELS_MAX_DAYS; } });
|
|
182
|
+
Object.defineProperty(exports, "MODELS_DEFAULT_LIMIT", { enumerable: true, get: function () { return models_1.MODELS_DEFAULT_LIMIT; } });
|
|
183
|
+
Object.defineProperty(exports, "MODELS_MAX_LIMIT", { enumerable: true, get: function () { return models_1.MODELS_MAX_LIMIT; } });
|
|
184
|
+
Object.defineProperty(exports, "MODELS_DEFAULT_MAX_SESSION_BYTES", { enumerable: true, get: function () { return models_1.MODELS_DEFAULT_MAX_SESSION_BYTES; } });
|
|
185
|
+
Object.defineProperty(exports, "MODELS_MAX_SESSION_MEGABYTES", { enumerable: true, get: function () { return models_1.MODELS_MAX_SESSION_MEGABYTES; } });
|
|
@@ -161,6 +161,45 @@ export interface CompareText {
|
|
|
161
161
|
fewerThanTwo: (found: number, project: string | null) => string;
|
|
162
162
|
}
|
|
163
163
|
export declare const COMPARE_TEXT: Readonly<Record<WhyLang, CompareText>>;
|
|
164
|
+
/**
|
|
165
|
+
* Every line of the plain `models` report, under the rules of `compare`: words
|
|
166
|
+
* change, figures, ids, model ids, dates and commands do not. The metric labels,
|
|
167
|
+
* the sub-agent note and the list-price line are `compare`'s own, and the
|
|
168
|
+
* unpriced, missing-lifetime and fork wording is `why`'s, so the three reports
|
|
169
|
+
* use one vocabulary. A label (1, 2, 3) names a model group as A and B name a
|
|
170
|
+
* session in `compare`.
|
|
171
|
+
*/
|
|
172
|
+
export interface ModelsText {
|
|
173
|
+
/** `days` is the window the report covers, 1 to 365. */
|
|
174
|
+
title: (days: number) => string;
|
|
175
|
+
/** `since` is `YYYY-MM-DD HH:MM UTC`. */
|
|
176
|
+
scope: (sessions: number, since: string) => string;
|
|
177
|
+
none: (days: number) => string;
|
|
178
|
+
/** The group of sessions whose responses carry no model id. */
|
|
179
|
+
unknownModel: string;
|
|
180
|
+
sessions: (count: number) => string;
|
|
181
|
+
/** First and last session date, `YYYY-MM-DD`; one date when they are the same day. */
|
|
182
|
+
dates: (first: string, last: string) => string;
|
|
183
|
+
medianHeader: string;
|
|
184
|
+
totalHeader: string;
|
|
185
|
+
/** The row under Sub-agents launched. */
|
|
186
|
+
unfinished: string;
|
|
187
|
+
/** A cell no session of the group can fill. */
|
|
188
|
+
unknown: string;
|
|
189
|
+
/** How sub-agents ended is unknown for `unknown` of the group's `sessions`; the row covers the rest. */
|
|
190
|
+
unfinishedUnknown: (label: string, unknown: number, sessions: number) => string;
|
|
191
|
+
unfinishedSource: string;
|
|
192
|
+
/** `unpriced` of the group's `sessions` used a model without a verified rate, so the group's dollars are unpriced. */
|
|
193
|
+
unpricedGroup: (label: string, unpriced: number, sessions: number) => string;
|
|
194
|
+
overSize: (count: number, megabytes: number) => string;
|
|
195
|
+
unreadable: (count: number) => string;
|
|
196
|
+
usageUnavailable: (count: number) => string;
|
|
197
|
+
overLimit: (count: number, limit: number, maxLimit: number) => string;
|
|
198
|
+
startedBefore: (count: number) => string;
|
|
199
|
+
noResponseTime: (count: number) => string;
|
|
200
|
+
sameWork: string;
|
|
201
|
+
}
|
|
202
|
+
export declare const MODELS_TEXT: Readonly<Record<WhyLang, ModelsText>>;
|
|
164
203
|
/** A calendar date as the report names it: the month's short name, the day of the month and the year. */
|
|
165
204
|
export interface CalendarDate {
|
|
166
205
|
month: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WEEK_TEXT = exports.CALENDAR_TEXT = exports.COMPARE_TEXT = exports.DECISION_TEXT = exports.WHY_TEXT = exports.SIMPLE_TEXT = exports.STATUS_TEXT = void 0;
|
|
3
|
+
exports.WEEK_TEXT = exports.CALENDAR_TEXT = exports.MODELS_TEXT = exports.COMPARE_TEXT = exports.DECISION_TEXT = exports.WHY_TEXT = exports.SIMPLE_TEXT = exports.STATUS_TEXT = void 0;
|
|
4
4
|
exports.whyLangOf = whyLangOf;
|
|
5
5
|
exports.detectWhyLang = detectWhyLang;
|
|
6
6
|
/**
|
|
@@ -347,6 +347,85 @@ const comparePt = {
|
|
|
347
347
|
: `Só uma sessão principal foi encontrada${project ? ` em ${project}` : ''}, e o compare precisa de duas. Passe dois ids: ${TWO_IDS}`,
|
|
348
348
|
};
|
|
349
349
|
exports.COMPARE_TEXT = { en: compareEn, es: compareEs, pt: comparePt };
|
|
350
|
+
const lastDays = (days) => days === 1 ? 'last day' : `last ${days} days`;
|
|
351
|
+
const sessionsEn = (n) => `${n} ${n === 1 ? 'session' : 'sessions'}`;
|
|
352
|
+
const modelsEn = {
|
|
353
|
+
title: days => `AgentGuard models: your sessions on each model, ${lastDays(days)}`,
|
|
354
|
+
scope: (sessions, since) => `${sessionsEn(sessions)} that started since ${since}: top-level Claude Code and Codex sessions, each under the model with the most of its output tokens, oldest model first.`,
|
|
355
|
+
none: days => `No top-level Claude Code or Codex session started in the ${lastDays(days)}.`,
|
|
356
|
+
unknownModel: 'unknown model',
|
|
357
|
+
sessions: sessionsEn,
|
|
358
|
+
dates: (first, last) => first === last ? first : `${first} to ${last}`,
|
|
359
|
+
medianHeader: 'Per session, median',
|
|
360
|
+
totalHeader: 'All sessions, total',
|
|
361
|
+
unfinished: ' ended without finishing',
|
|
362
|
+
unknown: 'unknown',
|
|
363
|
+
unfinishedUnknown: (label, unknown, sessions) => unknown === sessions
|
|
364
|
+
? `${label}: how its sub-agents ended is unknown in ${sessions === 1 ? 'its one session' : `all ${sessions} sessions`}.`
|
|
365
|
+
: `${label}: how its sub-agents ended is unknown for ${unknown} of ${sessionsEn(sessions)}, so the ended without finishing row covers the other ${sessions - unknown === 1 ? 'one' : sessions - unknown}.`,
|
|
366
|
+
unfinishedSource: 'Burn reads how a sub-agent ended from the sub-agent transcripts Claude Code keeps beside a session; Codex records nothing it reads for this.',
|
|
367
|
+
unpricedGroup: (label, unpriced, sessions) => `${label}: ${unpriced === sessions ? (sessions === 1 ? 'its one session' : `all ${sessions} sessions`) : `${unpriced} of ${sessionsEn(sessions)}`} used a model with no verified rate, so its List USD is unpriced.`,
|
|
368
|
+
overSize: (count, megabytes) => `Skipped ${sessionsEn(count)} over ${megabytes} MB (transcript plus sub-agent transcripts). Run why on one to see it alone, or raise the cap with --max-mb.`,
|
|
369
|
+
unreadable: count => `${sessionsEn(count)} could not be read and ${count === 1 ? 'is' : 'are'} left out.`,
|
|
370
|
+
usageUnavailable: count => `${count} Codex ${count === 1 ? 'session' : 'sessions'}: inherited history has no verifiable boundary, so usage is unavailable. Copied usage is excluded, not counted as zero.`,
|
|
371
|
+
overLimit: (count, limit, maxLimit) => `${count} older ${count === 1 ? 'session' : 'sessions'} changed in this window ${count === 1 ? 'was' : 'were'} not read: the report reads the ${limit} most recent. Raise it with --limit, up to ${maxLimit}.`,
|
|
372
|
+
startedBefore: count => `${sessionsEn(count)} changed in this window but started before it, so ${count === 1 ? 'it is' : 'they are'} left out.`,
|
|
373
|
+
noResponseTime: count => `${sessionsEn(count)} ${count === 1 ? 'records' : 'record'} no timed assistant response, so ${count === 1 ? 'it has' : 'they have'} no start time and ${count === 1 ? 'is' : 'are'} in no group.`,
|
|
374
|
+
sameWork: 'AgentGuard cannot tell whether the sessions on each model did comparable work, so a difference can come from the work as well as from the model.',
|
|
375
|
+
};
|
|
376
|
+
const ultimosDias = (days) => days === 1 ? 'último día' : `últimos ${days} días`;
|
|
377
|
+
const sesiones = (n) => plural(n, 'sesión', 'sesiones');
|
|
378
|
+
const modelsEs = {
|
|
379
|
+
title: days => `AgentGuard models: tus sesiones en cada modelo, ${ultimosDias(days)}`,
|
|
380
|
+
scope: (sessions, since) => `${sesiones(sessions)} ${sessions === 1 ? 'iniciada' : 'iniciadas'} desde ${since}: sesiones principales de Claude Code y Codex, cada una bajo el modelo con más de sus tokens de salida, del modelo más antiguo al más reciente.`,
|
|
381
|
+
none: days => `Ninguna sesión principal de Claude Code ni de Codex comenzó ${days === 1 ? 'en el último día' : `en los últimos ${days} días`}.`,
|
|
382
|
+
unknownModel: 'modelo desconocido',
|
|
383
|
+
sessions: sesiones,
|
|
384
|
+
dates: (first, last) => first === last ? first : `${first} a ${last}`,
|
|
385
|
+
medianHeader: 'Por sesión, mediana',
|
|
386
|
+
totalHeader: 'Todas las sesiones, total',
|
|
387
|
+
unfinished: ' quedaron sin terminar',
|
|
388
|
+
unknown: 'desconocido',
|
|
389
|
+
unfinishedUnknown: (label, unknown, sessions) => unknown === sessions
|
|
390
|
+
? `${label}: no se sabe cómo terminaron sus subagentes en ${sessions === 1 ? 'su única sesión' : `ninguna de sus ${sessions} sesiones`}.`
|
|
391
|
+
: `${label}: no se sabe cómo terminaron sus subagentes en ${unknown} de ${sesiones(sessions)}, así que la fila de los que quedaron sin terminar cubre ${sessions - unknown === 1 ? 'la otra' : `las otras ${sessions - unknown}`}.`,
|
|
392
|
+
unfinishedSource: 'Burn lee cómo terminó un subagente en las transcripciones de subagentes que Claude Code guarda junto a cada sesión; Codex no registra nada que Burn pueda leer para esto.',
|
|
393
|
+
unpricedGroup: (label, unpriced, sessions) => `${label}: ${unpriced === sessions ? (sessions === 1 ? 'su única sesión usó' : `sus ${sessions} sesiones usaron`) : `${unpriced} de ${sesiones(sessions)} ${unpriced === 1 ? 'usó' : 'usaron'}`} un modelo sin tarifa verificada, así que su USD de lista queda sin precio.`,
|
|
394
|
+
overSize: (count, megabytes) => `${count === 1 ? 'Se omitió' : 'Se omitieron'} ${sesiones(count)} de más de ${megabytes} MB (transcripción más transcripciones de subagentes). Ejecuta why en una para verla sola, o sube el límite con --max-mb.`,
|
|
395
|
+
unreadable: count => `${count === 1 ? 'No se pudo leer 1 sesión y queda fuera.' : `No se pudieron leer ${count} sesiones y quedan fuera.`}`,
|
|
396
|
+
usageUnavailable: count => `${count === 1 ? '1 sesión' : `${count} sesiones`} de Codex: el historial heredado no tiene un punto de corte verificable, así que su uso no está disponible. El uso copiado queda excluido, no se cuenta como cero.`,
|
|
397
|
+
overLimit: (count, limit, maxLimit) => `${count === 1 ? 'No se leyó 1 sesión más antigua' : `No se leyeron ${count} sesiones más antiguas`} con cambios en este período: el informe lee las ${limit} más recientes. Súbelo con --limit, hasta ${maxLimit}.`,
|
|
398
|
+
startedBefore: count => `${sesiones(count)} con cambios en este período ${count === 1 ? 'comenzó' : 'comenzaron'} antes, así que ${count === 1 ? 'queda' : 'quedan'} fuera.`,
|
|
399
|
+
noResponseTime: count => `${sesiones(count)} no ${count === 1 ? 'registra' : 'registran'} ninguna respuesta del asistente con hora, así que no ${count === 1 ? 'tiene' : 'tienen'} hora de inicio y no ${count === 1 ? 'entra' : 'entran'} en ningún grupo.`,
|
|
400
|
+
sameWork: 'AgentGuard no puede saber si las sesiones de cada modelo hicieron un trabajo comparable, así que una diferencia puede venir del trabajo tanto como del modelo.',
|
|
401
|
+
};
|
|
402
|
+
const ultimosDiasPt = (days) => days === 1 ? 'último dia' : `últimos ${days} dias`;
|
|
403
|
+
const sessoes = (n) => plural(n, 'sessão', 'sessões');
|
|
404
|
+
const modelsPt = {
|
|
405
|
+
title: days => `AgentGuard models: suas sessões em cada modelo, ${ultimosDiasPt(days)}`,
|
|
406
|
+
scope: (sessions, since) => `${sessoes(sessions)} ${sessions === 1 ? 'iniciada' : 'iniciadas'} desde ${since}: sessões principais do Claude Code e do Codex, cada uma sob o modelo com mais tokens de saída dela, do modelo mais antigo ao mais recente.`,
|
|
407
|
+
none: days => `Nenhuma sessão principal do Claude Code ou do Codex começou ${days === 1 ? 'no último dia' : `nos últimos ${days} dias`}.`,
|
|
408
|
+
unknownModel: 'modelo desconhecido',
|
|
409
|
+
sessions: sessoes,
|
|
410
|
+
dates: (first, last) => first === last ? first : `${first} a ${last}`,
|
|
411
|
+
medianHeader: 'Por sessão, mediana',
|
|
412
|
+
totalHeader: 'Todas as sessões, total',
|
|
413
|
+
unfinished: ' pararam sem terminar',
|
|
414
|
+
unknown: 'desconhecido',
|
|
415
|
+
unfinishedUnknown: (label, unknown, sessions) => unknown === sessions
|
|
416
|
+
? `${label}: não se sabe como os subagentes terminaram ${sessions === 1 ? 'na única sessão' : `em nenhuma das ${sessions} sessões`}.`
|
|
417
|
+
: `${label}: não se sabe como os subagentes terminaram em ${unknown} de ${sessoes(sessions)}, então a linha dos que pararam sem terminar cobre ${sessions - unknown === 1 ? 'a outra' : `as outras ${sessions - unknown}`}.`,
|
|
418
|
+
unfinishedSource: 'O Burn lê como um subagente terminou nas transcrições de subagentes que o Claude Code guarda junto de cada sessão; o Codex não registra nada que o Burn leia para isso.',
|
|
419
|
+
unpricedGroup: (label, unpriced, sessions) => `${label}: ${unpriced === sessions ? (sessions === 1 ? 'a única sessão usou' : `as ${sessions} sessões usaram`) : `${unpriced} de ${sessoes(sessions)} ${unpriced === 1 ? 'usou' : 'usaram'}`} um modelo sem tarifa verificada, então o USD de tabela fica sem preço.`,
|
|
420
|
+
overSize: (count, megabytes) => `${count === 1 ? '1 sessão acima' : `${count} sessões acima`} de ${megabytes} MB ${count === 1 ? 'ficou' : 'ficaram'} de fora (transcrição mais transcrições de subagentes). Rode why em uma para vê-la sozinha, ou aumente o limite com --max-mb.`,
|
|
421
|
+
unreadable: count => `${count === 1 ? 'Não foi possível ler 1 sessão, que fica de fora.' : `Não foi possível ler ${count} sessões, que ficam de fora.`}`,
|
|
422
|
+
usageUnavailable: count => `${count === 1 ? '1 sessão' : `${count} sessões`} do Codex: o histórico herdado não tem um ponto de corte verificável, então o uso fica indisponível. O uso copiado fica de fora, não é contado como zero.`,
|
|
423
|
+
overLimit: (count, limit, maxLimit) => `${count === 1 ? '1 sessão mais antiga' : `${count} sessões mais antigas`} com mudanças neste período não ${count === 1 ? 'foi lida' : 'foram lidas'}: o relatório lê as ${limit} mais recentes. Aumente com --limit, até ${maxLimit}.`,
|
|
424
|
+
startedBefore: count => `${sessoes(count)} com mudanças neste período ${count === 1 ? 'começou' : 'começaram'} antes dele, então ${count === 1 ? 'fica' : 'ficam'} de fora.`,
|
|
425
|
+
noResponseTime: count => `${sessoes(count)} não ${count === 1 ? 'registra' : 'registram'} nenhuma resposta do assistente com horário, então não ${count === 1 ? 'tem' : 'têm'} horário de início e não ${count === 1 ? 'entra' : 'entram'} em nenhum grupo.`,
|
|
426
|
+
sameWork: 'O AgentGuard não consegue saber se as sessões de cada modelo fizeram um trabalho comparável, então uma diferença pode vir do trabalho tanto quanto do modelo.',
|
|
427
|
+
};
|
|
428
|
+
exports.MODELS_TEXT = { en: modelsEn, es: modelsEs, pt: modelsPt };
|
|
350
429
|
const hostList = (claude, codex, and, of = '') => [claude ? `${of}Claude Code` : '', codex ? `${of}Codex` : ''].filter(Boolean).join(` ${and} `);
|
|
351
430
|
const calendarEn = {
|
|
352
431
|
weekdays: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { DollarRange, PricingTable } from './pricing';
|
|
2
|
+
import { type CompareSession } from './compare';
|
|
3
|
+
import { type TranscriptLocation, type TranscriptOrigin } from './sessions';
|
|
4
|
+
import type { InsightTranscript } from './types';
|
|
5
|
+
import { type WhyLang } from './i18n';
|
|
6
|
+
export declare const MODELS_DEFAULT_DAYS = 30;
|
|
7
|
+
export declare const MODELS_MAX_DAYS = 365;
|
|
8
|
+
/** The most recent sessions read by default, and the most `--limit` allows. */
|
|
9
|
+
export declare const MODELS_DEFAULT_LIMIT = 300;
|
|
10
|
+
export declare const MODELS_MAX_LIMIT = 2000;
|
|
11
|
+
/**
|
|
12
|
+
* A session whose transcript plus sub-agent transcripts pass this many bytes is
|
|
13
|
+
* skipped and counted, never read. 256 MB is the size above which `why` itself
|
|
14
|
+
* stops reading a file whole (WHOLE_FILE_MAX_BYTES); on the machine this was
|
|
15
|
+
* built on, a 30-day window of 84 sessions holding 14 GB read 1 GB under it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MODELS_DEFAULT_MAX_SESSION_BYTES: number;
|
|
18
|
+
/** The most `--max-mb` allows. */
|
|
19
|
+
export declare const MODELS_MAX_SESSION_MEGABYTES = 4096;
|
|
20
|
+
/** One session the report counted: compare's figures plus how many of its sub-agents ended without finishing. */
|
|
21
|
+
export interface ModelsSession extends CompareSession {
|
|
22
|
+
/**
|
|
23
|
+
* Sub-agents recorded as failed, killed or stopped and never as completed or
|
|
24
|
+
* resumed, the count `why` prints. 0 when the session launched none. Null
|
|
25
|
+
* when it launched some and no transcript Burn reads records how they ended:
|
|
26
|
+
* every Codex session with a launch, and a Claude Code session with no
|
|
27
|
+
* sub-agent transcripts beside it.
|
|
28
|
+
*/
|
|
29
|
+
subagentsUnfinished: number | null;
|
|
30
|
+
/** The transcript plus its sub-agent transcripts, in bytes. */
|
|
31
|
+
bytes: number;
|
|
32
|
+
}
|
|
33
|
+
/** What a group is computed from; `ModelsSession` carries it all. */
|
|
34
|
+
export type ModelsSessionInput = Pick<ModelsSession, 'host' | 'startedAt' | 'dominantModel' | 'usageAvailable' | 'metrics' | 'unpricedModels' | 'subagentsUnfinished'>;
|
|
35
|
+
export interface ModelsGroup {
|
|
36
|
+
/** The dominant model of every session in the group; null groups sessions whose responses carry no model id. */
|
|
37
|
+
model: string | null;
|
|
38
|
+
sessions: number;
|
|
39
|
+
hosts: {
|
|
40
|
+
claude: number;
|
|
41
|
+
codex: number;
|
|
42
|
+
};
|
|
43
|
+
/** The earliest and latest session start, ISO 8601 UTC. */
|
|
44
|
+
firstSessionAt: string;
|
|
45
|
+
lastSessionAt: string;
|
|
46
|
+
/** Cache reads plus cache writes plus fresh input, per session. */
|
|
47
|
+
inputTokens: {
|
|
48
|
+
median: number;
|
|
49
|
+
total: number;
|
|
50
|
+
};
|
|
51
|
+
outputTokens: {
|
|
52
|
+
median: number;
|
|
53
|
+
total: number;
|
|
54
|
+
};
|
|
55
|
+
/** Per-session cache reads over all input, 0 to 1; `pooled` is the group's cache reads over its input. Both are 0 without input, as `compare` prints a share of nothing. */
|
|
56
|
+
cacheShare: {
|
|
57
|
+
median: number;
|
|
58
|
+
pooled: number;
|
|
59
|
+
};
|
|
60
|
+
subagentsLaunched: {
|
|
61
|
+
median: number;
|
|
62
|
+
total: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Over the `known` sessions only; `unknown` sessions are left out, never
|
|
66
|
+
* counted as 0. Median and total are null when no session is known.
|
|
67
|
+
*/
|
|
68
|
+
subagentsUnfinished: {
|
|
69
|
+
median: number | null;
|
|
70
|
+
total: number | null;
|
|
71
|
+
known: number;
|
|
72
|
+
unknown: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* API list equivalents. Null while any session of the group is unpriced
|
|
76
|
+
* (`unpricedSessions`), as `why` prints a session unpriced. The median of
|
|
77
|
+
* dollar ranges is the median of their low ends to the median of their high
|
|
78
|
+
* ends, which holds the median of the true figures.
|
|
79
|
+
*/
|
|
80
|
+
usd: {
|
|
81
|
+
median: DollarRange | null;
|
|
82
|
+
total: DollarRange | null;
|
|
83
|
+
unpricedSessions: number;
|
|
84
|
+
};
|
|
85
|
+
/** Models without a verified rate in any session of the group; null is a missing model id. */
|
|
86
|
+
unpricedModels: Array<string | null>;
|
|
87
|
+
}
|
|
88
|
+
export interface ModelsSkipped {
|
|
89
|
+
/** Not read: transcript plus sub-agent transcripts over `maxSessionBytes`. */
|
|
90
|
+
overSizeCap: number;
|
|
91
|
+
/** Not read: the file or its sub-agent folder could not be read. */
|
|
92
|
+
unreadable: number;
|
|
93
|
+
/** Read, but inherited Codex history has no verifiable boundary, so its usage is unavailable (compare prints nothing for it). */
|
|
94
|
+
usageUnavailable: number;
|
|
95
|
+
/** Not read: changed in the window but older than the `limit` most recent. */
|
|
96
|
+
overLimit: number;
|
|
97
|
+
/** Read: changed in the window, but its first response is before it. */
|
|
98
|
+
startedBeforeWindow: number;
|
|
99
|
+
/** Read: no assistant response with a time, so no start time and no group. */
|
|
100
|
+
noResponseTime: number;
|
|
101
|
+
}
|
|
102
|
+
export interface ModelsSkippedSession {
|
|
103
|
+
sessionId: string;
|
|
104
|
+
host: TranscriptLocation['host'];
|
|
105
|
+
path: string;
|
|
106
|
+
reason: 'over_size_cap' | 'unreadable' | 'usage_unavailable';
|
|
107
|
+
/** Null when the size could not be read. */
|
|
108
|
+
bytes: number | null;
|
|
109
|
+
/** For an unreadable session, the system error code (EACCES, ENOTDIR) or the error's name; null otherwise. */
|
|
110
|
+
error: string | null;
|
|
111
|
+
}
|
|
112
|
+
export interface ModelsReport {
|
|
113
|
+
window: {
|
|
114
|
+
days: number;
|
|
115
|
+
since: string;
|
|
116
|
+
until: string;
|
|
117
|
+
};
|
|
118
|
+
limit: number;
|
|
119
|
+
maxSessionBytes: number;
|
|
120
|
+
/** Oldest first session first, so the report reads as before, then after. */
|
|
121
|
+
models: ModelsGroup[];
|
|
122
|
+
/** Every counted session, earliest start first. */
|
|
123
|
+
sessions: ModelsSession[];
|
|
124
|
+
skipped: ModelsSkipped;
|
|
125
|
+
/** The sessions behind overSizeCap, unreadable and usageUnavailable, so each can be opened with `why`. */
|
|
126
|
+
skippedSessions: ModelsSkippedSession[];
|
|
127
|
+
subagentsIncluded: true;
|
|
128
|
+
basis: 'estimated_api_list_price';
|
|
129
|
+
}
|
|
130
|
+
export interface ModelsOptions {
|
|
131
|
+
/** 1 to 365; default 30. Sessions that started in the last N days count. */
|
|
132
|
+
days?: number;
|
|
133
|
+
/** 1 to 2000; default 300. At most this many of the most recently changed sessions are read. */
|
|
134
|
+
limit?: number;
|
|
135
|
+
/** Default 256 MB. */
|
|
136
|
+
maxSessionBytes?: number;
|
|
137
|
+
now?: number;
|
|
138
|
+
roots?: {
|
|
139
|
+
claude: string;
|
|
140
|
+
codex: string;
|
|
141
|
+
};
|
|
142
|
+
/** Discovered transcripts, when the caller already has them; else discovered under `roots`. */
|
|
143
|
+
locations?: TranscriptLocation[];
|
|
144
|
+
rates?: PricingTable;
|
|
145
|
+
origin?: (location: TranscriptLocation) => TranscriptOrigin;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The sub-agents of one session that ended without finishing, or null when that
|
|
149
|
+
* cannot be known. `unfinishedSubagents` is `why`'s own count; it reads only the
|
|
150
|
+
* session's sub-agent transcripts and the outcomes recorded in it and them.
|
|
151
|
+
*/
|
|
152
|
+
export declare function subagentsUnfinished(transcript: Pick<InsightTranscript, 'subagents' | 'observations'>): number | null;
|
|
153
|
+
/** The bytes `readInsightSession` reads for a session: its transcript and every `.jsonl` in its `subagents` folder. Throws when either cannot be listed. */
|
|
154
|
+
export declare function sessionBytes(path: string): number;
|
|
155
|
+
/** Sessions grouped under their dominant model, groups ordered by first session, oldest first (then by model id, a missing one last). */
|
|
156
|
+
export declare function modelGroups(sessions: readonly ModelsSessionInput[]): ModelsGroup[];
|
|
157
|
+
/**
|
|
158
|
+
* Reads and groups the window's top-level sessions. A top-level session is the
|
|
159
|
+
* one `compare` picks: a Claude Code transcript directly inside its project
|
|
160
|
+
* directory (never a sub-agent's file or another file a session keeps beside
|
|
161
|
+
* it), or a Codex rollout whose first records do not mark a spawned sub-agent.
|
|
162
|
+
* A file last changed before the window cannot hold a session that started in
|
|
163
|
+
* it, so only files changed in the window are candidates; the `limit` most
|
|
164
|
+
* recently changed are read, and a session counts when its first response is
|
|
165
|
+
* in the window. Everything not counted is counted by reason.
|
|
166
|
+
*/
|
|
167
|
+
export declare function modelsReport(options?: ModelsOptions): ModelsReport;
|
|
168
|
+
/** `lang` changes words only; every figure, id, model id, date and command prints as it does in English. */
|
|
169
|
+
export declare function renderModels(report: ModelsReport, lang?: WhyLang): string;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MODELS_MAX_SESSION_MEGABYTES = exports.MODELS_DEFAULT_MAX_SESSION_BYTES = exports.MODELS_MAX_LIMIT = exports.MODELS_DEFAULT_LIMIT = exports.MODELS_MAX_DAYS = exports.MODELS_DEFAULT_DAYS = void 0;
|
|
4
|
+
exports.subagentsUnfinished = subagentsUnfinished;
|
|
5
|
+
exports.sessionBytes = sessionBytes;
|
|
6
|
+
exports.modelGroups = modelGroups;
|
|
7
|
+
exports.modelsReport = modelsReport;
|
|
8
|
+
exports.renderModels = renderModels;
|
|
9
|
+
/**
|
|
10
|
+
* `models`: every top-level session of a window, grouped under its dominant
|
|
11
|
+
* model, for someone who switched models and wants to see, from their own
|
|
12
|
+
* transcripts, how sessions on the new model differ from sessions on the old
|
|
13
|
+
* one. Each session's figures are the ones `compare` (and so `why`) prints for
|
|
14
|
+
* it, child transcripts included; this file only selects sessions, reads them
|
|
15
|
+
* within a bound and summarizes each group. Measurement only: nothing here
|
|
16
|
+
* judges which model did better.
|
|
17
|
+
*/
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const live_1 = require("./live");
|
|
21
|
+
const compare_1 = require("./compare");
|
|
22
|
+
const render_1 = require("./render");
|
|
23
|
+
const sessions_1 = require("./sessions");
|
|
24
|
+
const transcript_1 = require("./transcript");
|
|
25
|
+
const i18n_1 = require("./i18n");
|
|
26
|
+
exports.MODELS_DEFAULT_DAYS = 30;
|
|
27
|
+
exports.MODELS_MAX_DAYS = 365;
|
|
28
|
+
/** The most recent sessions read by default, and the most `--limit` allows. */
|
|
29
|
+
exports.MODELS_DEFAULT_LIMIT = 300;
|
|
30
|
+
exports.MODELS_MAX_LIMIT = 2000;
|
|
31
|
+
/**
|
|
32
|
+
* A session whose transcript plus sub-agent transcripts pass this many bytes is
|
|
33
|
+
* skipped and counted, never read. 256 MB is the size above which `why` itself
|
|
34
|
+
* stops reading a file whole (WHOLE_FILE_MAX_BYTES); on the machine this was
|
|
35
|
+
* built on, a 30-day window of 84 sessions holding 14 GB read 1 GB under it.
|
|
36
|
+
*/
|
|
37
|
+
exports.MODELS_DEFAULT_MAX_SESSION_BYTES = 256 * 1024 * 1024;
|
|
38
|
+
/** The most `--max-mb` allows. */
|
|
39
|
+
exports.MODELS_MAX_SESSION_MEGABYTES = 4096;
|
|
40
|
+
/** Files are read in pieces this size, so no session needs one string of its whole transcript. The figures equal a whole-file read. */
|
|
41
|
+
const READ_CHUNK_BYTES = 16 * 1024 * 1024;
|
|
42
|
+
const DAY_MS = 86_400_000;
|
|
43
|
+
const median = (values) => {
|
|
44
|
+
if (!values.length)
|
|
45
|
+
return null;
|
|
46
|
+
const sorted = [...values].sort((a, b) => a - b), middle = Math.floor(sorted.length / 2);
|
|
47
|
+
return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
48
|
+
};
|
|
49
|
+
const sum = (values) => values.reduce((total, value) => total + value, 0);
|
|
50
|
+
const byName = (a, b) => a === b ? 0 : a === null ? 1 : b === null ? -1 : a < b ? -1 : 1;
|
|
51
|
+
const wholeNumber = (value, low, high) => typeof value === 'number' && Number.isSafeInteger(value) && value >= low && value <= high;
|
|
52
|
+
/**
|
|
53
|
+
* The sub-agents of one session that ended without finishing, or null when that
|
|
54
|
+
* cannot be known. `unfinishedSubagents` is `why`'s own count; it reads only the
|
|
55
|
+
* session's sub-agent transcripts and the outcomes recorded in it and them.
|
|
56
|
+
*/
|
|
57
|
+
function subagentsUnfinished(transcript) {
|
|
58
|
+
if (transcript.subagents)
|
|
59
|
+
return (0, render_1.unfinishedSubagents)(transcript, { turns: [], prices: [] })?.count ?? 0;
|
|
60
|
+
return transcript.observations.spawnCalls === 0 ? 0 : null;
|
|
61
|
+
}
|
|
62
|
+
/** The bytes `readInsightSession` reads for a session: its transcript and every `.jsonl` in its `subagents` folder. Throws when either cannot be listed. */
|
|
63
|
+
function sessionBytes(path) {
|
|
64
|
+
let bytes = (0, node_fs_1.statSync)(path).size, names;
|
|
65
|
+
const children = (0, node_path_1.join)(path.replace(/\.jsonl$/, ''), 'subagents');
|
|
66
|
+
try {
|
|
67
|
+
names = (0, node_fs_1.readdirSync)(children).filter(name => name.endsWith('.jsonl'));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error.code === 'ENOENT')
|
|
71
|
+
return bytes;
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
for (const name of names)
|
|
75
|
+
bytes += (0, node_fs_1.statSync)((0, node_path_1.join)(children, name)).size;
|
|
76
|
+
return bytes;
|
|
77
|
+
}
|
|
78
|
+
/** One group's figures. Every input must have usage and a start time; a row without either is a caller error, never silently left out. */
|
|
79
|
+
function group(model, rows) {
|
|
80
|
+
const starts = rows.map(row => row.startedAt).sort();
|
|
81
|
+
const figure = (key) => rows.map(row => row.metrics[key]);
|
|
82
|
+
const input = figure('inputTokens'), output = figure('outputTokens'), launched = figure('subagentsLaunched');
|
|
83
|
+
const known = rows.flatMap(row => row.subagentsUnfinished === null ? [] : [row.subagentsUnfinished]);
|
|
84
|
+
const usd = rows.map(row => row.metrics.usd);
|
|
85
|
+
const priced = usd.filter((value) => value !== null);
|
|
86
|
+
const totalInput = sum(input);
|
|
87
|
+
return {
|
|
88
|
+
model, sessions: rows.length,
|
|
89
|
+
hosts: { claude: rows.filter(row => row.host === 'claude').length, codex: rows.filter(row => row.host === 'codex').length },
|
|
90
|
+
firstSessionAt: starts[0], lastSessionAt: starts.at(-1),
|
|
91
|
+
inputTokens: { median: median(input), total: totalInput },
|
|
92
|
+
outputTokens: { median: median(output), total: sum(output) },
|
|
93
|
+
cacheShare: { median: median(figure('cacheShare')), pooled: totalInput ? sum(figure('cacheReadTokens')) / totalInput : 0 },
|
|
94
|
+
subagentsLaunched: { median: median(launched), total: sum(launched) },
|
|
95
|
+
subagentsUnfinished: { median: median(known), total: known.length ? sum(known) : null, known: known.length, unknown: rows.length - known.length },
|
|
96
|
+
usd: { median: priced.length === usd.length ? { min: median(priced.map(value => value.min)), max: median(priced.map(value => value.max)) } : null,
|
|
97
|
+
total: (0, render_1.sumPrices)(usd), unpricedSessions: usd.length - priced.length },
|
|
98
|
+
unpricedModels: [...new Set(rows.flatMap(row => row.unpricedModels))].sort(byName),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Sessions grouped under their dominant model, groups ordered by first session, oldest first (then by model id, a missing one last). */
|
|
102
|
+
function modelGroups(sessions) {
|
|
103
|
+
const byModel = new Map();
|
|
104
|
+
for (const session of sessions) {
|
|
105
|
+
if (!session.usageAvailable || session.startedAt === null)
|
|
106
|
+
throw new TypeError('modelGroups: every session needs usage and a start time');
|
|
107
|
+
const rows = byModel.get(session.dominantModel);
|
|
108
|
+
if (rows)
|
|
109
|
+
rows.push(session);
|
|
110
|
+
else
|
|
111
|
+
byModel.set(session.dominantModel, [session]);
|
|
112
|
+
}
|
|
113
|
+
return [...byModel].map(([model, rows]) => group(model, rows))
|
|
114
|
+
.sort((a, b) => a.firstSessionAt < b.firstSessionAt ? -1 : a.firstSessionAt > b.firstSessionAt ? 1 : byName(a.model, b.model));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Reads and groups the window's top-level sessions. A top-level session is the
|
|
118
|
+
* one `compare` picks: a Claude Code transcript directly inside its project
|
|
119
|
+
* directory (never a sub-agent's file or another file a session keeps beside
|
|
120
|
+
* it), or a Codex rollout whose first records do not mark a spawned sub-agent.
|
|
121
|
+
* A file last changed before the window cannot hold a session that started in
|
|
122
|
+
* it, so only files changed in the window are candidates; the `limit` most
|
|
123
|
+
* recently changed are read, and a session counts when its first response is
|
|
124
|
+
* in the window. Everything not counted is counted by reason.
|
|
125
|
+
*/
|
|
126
|
+
function modelsReport(options = {}) {
|
|
127
|
+
const days = options.days ?? exports.MODELS_DEFAULT_DAYS, limit = options.limit ?? exports.MODELS_DEFAULT_LIMIT;
|
|
128
|
+
const maxSessionBytes = options.maxSessionBytes ?? exports.MODELS_DEFAULT_MAX_SESSION_BYTES;
|
|
129
|
+
if (!wholeNumber(days, 1, exports.MODELS_MAX_DAYS))
|
|
130
|
+
throw new RangeError(`days must be a whole number from 1 to ${exports.MODELS_MAX_DAYS}`);
|
|
131
|
+
if (!wholeNumber(limit, 1, exports.MODELS_MAX_LIMIT))
|
|
132
|
+
throw new RangeError(`limit must be a whole number from 1 to ${exports.MODELS_MAX_LIMIT}`);
|
|
133
|
+
if (!wholeNumber(maxSessionBytes, 1, Number.MAX_SAFE_INTEGER))
|
|
134
|
+
throw new RangeError('maxSessionBytes must be a positive whole number');
|
|
135
|
+
const now = options.now ?? Date.now(), since = now - days * DAY_MS;
|
|
136
|
+
const roots = options.roots ?? (0, sessions_1.transcriptRoots)(), rates = options.rates ?? {};
|
|
137
|
+
const origins = new Map(), readOrigin = options.origin ?? sessions_1.transcriptOrigin;
|
|
138
|
+
const origin = (location) => {
|
|
139
|
+
let value = origins.get(location.path);
|
|
140
|
+
if (!value) {
|
|
141
|
+
value = readOrigin(location);
|
|
142
|
+
origins.set(location.path, value);
|
|
143
|
+
}
|
|
144
|
+
return value;
|
|
145
|
+
};
|
|
146
|
+
const topLevel = (location) => !(0, sessions_1.isSubagentTranscript)(location)
|
|
147
|
+
&& (location.host === 'claude' ? (0, node_path_1.dirname)((0, node_path_1.dirname)(location.path)) === roots.claude : !origin(location).spawned);
|
|
148
|
+
const candidates = (options.locations ?? (0, sessions_1.discoverInsightTranscripts)(roots))
|
|
149
|
+
.filter(location => location.modifiedAt >= since)
|
|
150
|
+
.sort((a, b) => b.modifiedAt - a.modifiedAt || a.path.localeCompare(b.path))
|
|
151
|
+
.filter(topLevel);
|
|
152
|
+
const skipped = { overSizeCap: 0, unreadable: 0, usageUnavailable: 0, overLimit: Math.max(0, candidates.length - limit), startedBeforeWindow: 0, noResponseTime: 0 };
|
|
153
|
+
const skippedSessions = [];
|
|
154
|
+
const skip = (location, reason, bytes, error = null) => {
|
|
155
|
+
skipped[reason === 'over_size_cap' ? 'overSizeCap' : reason === 'unreadable' ? 'unreadable' : 'usageUnavailable']++;
|
|
156
|
+
const code = error === null ? null : error?.code ?? (error instanceof Error ? error.name : 'Error');
|
|
157
|
+
skippedSessions.push({ sessionId: location.sessionId, host: location.host, path: location.path, reason, bytes, error: typeof code === 'string' ? code : null });
|
|
158
|
+
};
|
|
159
|
+
const sessions = [];
|
|
160
|
+
for (const location of candidates.slice(0, limit)) {
|
|
161
|
+
let bytes;
|
|
162
|
+
try {
|
|
163
|
+
bytes = sessionBytes(location.path);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
skip(location, 'unreadable', null, error);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (bytes > maxSessionBytes) {
|
|
170
|
+
skip(location, 'over_size_cap', bytes);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
let session;
|
|
174
|
+
try {
|
|
175
|
+
const transcript = (0, transcript_1.readInsightSession)(location.path, { host: location.host, sessionId: location.sessionId }, { chunkBytes: READ_CHUNK_BYTES });
|
|
176
|
+
session = { ...(0, compare_1.compareSession)(location, transcript, rates, origin(location)), subagentsUnfinished: subagentsUnfinished(transcript), bytes };
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
skip(location, 'unreadable', bytes, error);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (!session.usageAvailable) {
|
|
183
|
+
skip(location, 'usage_unavailable', bytes);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (session.startedAt === null) {
|
|
187
|
+
skipped.noResponseTime++;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (Date.parse(session.startedAt) < since) {
|
|
191
|
+
skipped.startedBeforeWindow++;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
sessions.push(session);
|
|
195
|
+
}
|
|
196
|
+
sessions.sort((a, b) => a.startedAt < b.startedAt ? -1 : a.startedAt > b.startedAt ? 1 : a.path.localeCompare(b.path));
|
|
197
|
+
return {
|
|
198
|
+
window: { days, since: new Date(since).toISOString(), until: new Date(now).toISOString() }, limit, maxSessionBytes,
|
|
199
|
+
models: modelGroups(sessions), sessions, skipped, skippedSessions, subagentsIncluded: true, basis: 'estimated_api_list_price',
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const stamp = (iso) => `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
203
|
+
const isRange = (value) => value !== null && Math.abs(value.max - value.min) >= 0.000001;
|
|
204
|
+
/** A median of counts is whole or a half; tokens print whole, as everywhere in `why`. */
|
|
205
|
+
const tokens = (value) => (0, render_1.count)(Math.round(value));
|
|
206
|
+
const subagents = (value) => Number.isInteger(value) ? (0, render_1.count)(value) : value.toFixed(1);
|
|
207
|
+
const percent = (value) => `${(value * 100).toFixed(1)}%`;
|
|
208
|
+
/** Columns per table, so three groups of ordinary figures fit 80 columns; more groups continue in another table. */
|
|
209
|
+
const COLUMNS = 3;
|
|
210
|
+
/** `lang` changes words only; every figure, id, model id, date and command prints as it does in English. */
|
|
211
|
+
function renderModels(report, lang = 'en') {
|
|
212
|
+
const text = i18n_1.MODELS_TEXT[lang], words = i18n_1.WHY_TEXT[lang], labels = i18n_1.COMPARE_TEXT[lang].labels;
|
|
213
|
+
const name = (model) => model ?? text.unknownModel;
|
|
214
|
+
const groups = report.models.map((group, index) => ({ label: String(index + 1), group }));
|
|
215
|
+
const lines = [text.title(report.window.days)];
|
|
216
|
+
if (!groups.length)
|
|
217
|
+
lines.push(text.none(report.window.days));
|
|
218
|
+
else {
|
|
219
|
+
lines.push(text.scope(report.sessions.length, stamp(report.window.since)), '');
|
|
220
|
+
const width = Math.max(...groups.map(({ group }) => name(group.model).length));
|
|
221
|
+
const counts = Math.max(...groups.map(({ group }) => text.sessions(group.sessions).length));
|
|
222
|
+
for (const { label, group } of groups) {
|
|
223
|
+
lines.push(`${label.padEnd(String(groups.length).length)} ${name(group.model).padEnd(width)} ${text.sessions(group.sessions).padEnd(counts)} ${text.dates(group.firstSessionAt.slice(0, 10), group.lastSessionAt.slice(0, 10))}`);
|
|
224
|
+
}
|
|
225
|
+
const unfinished = (value) => value === null ? text.unknown : subagents(value);
|
|
226
|
+
const money = (value) => (0, live_1.dollars)(value, words);
|
|
227
|
+
for (let start = 0; start < groups.length; start += COLUMNS) {
|
|
228
|
+
const shown = groups.slice(start, start + COLUMNS), heads = shown.map(({ label }) => label);
|
|
229
|
+
const row = (label, cell) => [label, ...shown.map(({ group }) => cell(group))];
|
|
230
|
+
// One table, so both halves share their column widths; the empty row prints as a blank line.
|
|
231
|
+
lines.push('', (0, render_1.table)([text.medianHeader, ...heads], [
|
|
232
|
+
row(labels.inputTokens, group => tokens(group.inputTokens.median)),
|
|
233
|
+
row(labels.outputTokens, group => tokens(group.outputTokens.median)),
|
|
234
|
+
row(labels.cacheShare, group => percent(group.cacheShare.median)),
|
|
235
|
+
row(labels.subagentsLaunched, group => subagents(group.subagentsLaunched.median)),
|
|
236
|
+
row(text.unfinished, group => unfinished(group.subagentsUnfinished.median)),
|
|
237
|
+
row(labels.usd, group => money(group.usd.median)),
|
|
238
|
+
[],
|
|
239
|
+
[text.totalHeader, ...heads],
|
|
240
|
+
row(labels.inputTokens, group => (0, render_1.count)(group.inputTokens.total)),
|
|
241
|
+
row(labels.outputTokens, group => (0, render_1.count)(group.outputTokens.total)),
|
|
242
|
+
row(labels.cacheShare, group => percent(group.cacheShare.pooled)),
|
|
243
|
+
row(labels.subagentsLaunched, group => (0, render_1.count)(group.subagentsLaunched.total)),
|
|
244
|
+
row(text.unfinished, group => unfinished(group.subagentsUnfinished.total)),
|
|
245
|
+
row(labels.usd, group => money(group.usd.total)),
|
|
246
|
+
]));
|
|
247
|
+
}
|
|
248
|
+
lines.push(i18n_1.COMPARE_TEXT[lang].subagents);
|
|
249
|
+
}
|
|
250
|
+
const notes = [];
|
|
251
|
+
const unknownOutcomes = groups.filter(({ group }) => group.subagentsUnfinished.unknown > 0);
|
|
252
|
+
for (const { label, group } of unknownOutcomes)
|
|
253
|
+
notes.push(text.unfinishedUnknown(label, group.subagentsUnfinished.unknown, group.sessions));
|
|
254
|
+
if (unknownOutcomes.length)
|
|
255
|
+
notes.push(text.unfinishedSource);
|
|
256
|
+
for (const { label, group } of groups)
|
|
257
|
+
if (group.usd.unpricedSessions > 0)
|
|
258
|
+
notes.push(text.unpricedGroup(label, group.usd.unpricedSessions, group.sessions));
|
|
259
|
+
const unpriced = [...new Set(groups.flatMap(({ group }) => group.unpricedModels.map(name => name ?? words.missingModel)))];
|
|
260
|
+
if (unpriced.length)
|
|
261
|
+
notes.push(words.unpricedModels(unpriced.join(', ')));
|
|
262
|
+
if (groups.some(({ group }) => isRange(group.usd.median) || isRange(group.usd.total)))
|
|
263
|
+
notes.push(words.missingTtl);
|
|
264
|
+
const { skipped } = report;
|
|
265
|
+
if (skipped.overSizeCap)
|
|
266
|
+
notes.push(text.overSize(skipped.overSizeCap, Math.round(report.maxSessionBytes / 1024 / 1024 * 100) / 100));
|
|
267
|
+
if (skipped.unreadable)
|
|
268
|
+
notes.push(text.unreadable(skipped.unreadable));
|
|
269
|
+
if (skipped.usageUnavailable)
|
|
270
|
+
notes.push(text.usageUnavailable(skipped.usageUnavailable));
|
|
271
|
+
if (skipped.overLimit)
|
|
272
|
+
notes.push(text.overLimit(skipped.overLimit, report.limit, exports.MODELS_MAX_LIMIT));
|
|
273
|
+
if (skipped.startedBeforeWindow)
|
|
274
|
+
notes.push(text.startedBefore(skipped.startedBeforeWindow));
|
|
275
|
+
if (skipped.noResponseTime)
|
|
276
|
+
notes.push(text.noResponseTime(skipped.noResponseTime));
|
|
277
|
+
if (groups.length)
|
|
278
|
+
notes.push(i18n_1.COMPARE_TEXT[lang].listPrice, text.sameWork);
|
|
279
|
+
return [...lines, ...(notes.length ? ['', ...notes] : [])].join('\n');
|
|
280
|
+
}
|
|
@@ -27,6 +27,8 @@ const openaiRates = (input, cacheRead, cacheWrite, output, sourceUrl, longContex
|
|
|
27
27
|
cacheWriteTtl: 'not_tiered', ...(longContext ? { longContext: Object.freeze({ aboveInputTokens: 272_000, inputMultiplier: 2, outputMultiplier: 1.5 }) } : {}) });
|
|
28
28
|
/** Exact IDs only. Never price an unknown model by a similar family name. */
|
|
29
29
|
exports.MODEL_PRICING = Object.freeze({
|
|
30
|
+
// Verified 2026-11-13: Fable 5.2 lists at $8 input, $10 and $16 cache writes, $0.20 cache hits (0.025x base input), $40 output; no prompt-length tier.
|
|
31
|
+
'claude-fable-5-2': Object.freeze({ ...rates(8, 0.2, 10, 16, 40), verifiedAt: '2026-11-13' }),
|
|
30
32
|
'claude-fable-5-1': rates(10, 0.25, 12.5, 20, 50),
|
|
31
33
|
'claude-fable-5': rates(10, 1, 12.5, 20, 50),
|
|
32
34
|
// Verified 2026-09-22: cache hits on Opus 5.5 are 0.05x base input.
|
package/dist/src/live-panel.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.runLivePanel = runLivePanel;
|
|
|
13
13
|
const node_crypto_1 = require("node:crypto");
|
|
14
14
|
const node_fs_1 = require("node:fs");
|
|
15
15
|
const canvas_1 = require("./canvas");
|
|
16
|
+
const copy_ramp_1 = require("./copy-ramp");
|
|
16
17
|
const ledger_panel_1 = require("./ledger-panel");
|
|
17
18
|
const recording_1 = require("./recording");
|
|
18
19
|
const sessions_1 = require("./insights/sessions");
|
|
@@ -119,6 +120,8 @@ function renderPhonePanel(snapshot, options = {}) {
|
|
|
119
120
|
c.bar(13, 0, w, fraction, color).bar(14, 0, w, fraction, color);
|
|
120
121
|
// One block per copy that launched. The spawn-rate counter also counts the attempt that reached the ceiling and was refused,
|
|
121
122
|
// so once a STOP is shown the copies that ran are one fewer than the counter. The grid only exists when the ceiling was recorded.
|
|
123
|
+
// Each block carries its copy's ramp colour (copy01 to copy15, teal into violet), never the bar's state colour: at the
|
|
124
|
+
// ceiling the bar is red because the next attempt was refused, while the copies that ran are neither allowed-green nor refused-red.
|
|
122
125
|
if (snapshot.spawnCeiling !== null && snapshot.spawnCeiling > 0) {
|
|
123
126
|
const ceiling = snapshot.spawnCeiling, attempts = Math.min(ceiling, Math.max(0, snapshot.spawns ?? 0));
|
|
124
127
|
const filled = snapshot.stop && attempts >= ceiling ? attempts - 1 : attempts;
|
|
@@ -129,8 +132,8 @@ function renderPhonePanel(snapshot, options = {}) {
|
|
|
129
132
|
c.put(16, Math.max(13, w - tag.length), tag, refused ? 'red' : 'slate');
|
|
130
133
|
for (let index = 0; index < ceiling; index++) {
|
|
131
134
|
const row = 17 + Math.floor(index / perRow) * 2, col = (index % perRow) * (blockWidth + 1);
|
|
132
|
-
const on = index < filled, glyph = (on ? '█' : '░').repeat(blockWidth);
|
|
133
|
-
c.put(row, col, glyph,
|
|
135
|
+
const on = index < filled, glyph = (on ? '█' : '░').repeat(blockWidth), tint = on ? (0, copy_ramp_1.copyName)(index) : 'slate';
|
|
136
|
+
c.put(row, col, glyph, tint).put(row + 1, col, glyph, tint);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
c.put(22, 0, 'LAST 3 DECISIONS', 'slate');
|
|
@@ -15,6 +15,7 @@ const node_util_1 = require("node:util");
|
|
|
15
15
|
const node_path_1 = require("node:path");
|
|
16
16
|
const canvas_1 = require("@napi-rs/canvas");
|
|
17
17
|
const canvas_2 = require("./canvas");
|
|
18
|
+
const copy_ramp_1 = require("./copy-ramp");
|
|
18
19
|
const frames_1 = require("./frames");
|
|
19
20
|
const recording_1 = require("./recording");
|
|
20
21
|
const run = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
@@ -95,7 +96,8 @@ async function renderCanvasPng(snapshot, width = 1920, height = 1080, style = 'd
|
|
|
95
96
|
ctx.font = `${style === 'default' ? '' : 'bold '}${26 * cellWidth / CELL_WIDTH}px "${FONT_ALIAS}"`;
|
|
96
97
|
ctx.textBaseline = 'alphabetic';
|
|
97
98
|
// Showcase and phone palette: brighter than the terminal palette so text survives re-encoding on social players.
|
|
98
|
-
|
|
99
|
+
// The copies' ramp (copy01 to copy15) is the same in both, one hue per copy from teal into violet.
|
|
100
|
+
const VIDEO_HEX = style === 'default' ? {} : { mint: '#2ABCB4', slate: '#B4BECF', amber: '#F59E0B', red: '#FF5A4E', white: '#FFFFFF', ...Object.fromEntries(copy_ramp_1.COPY_RAMP.map(entry => [entry.name, entry.chip])) };
|
|
99
101
|
for (let row = 0; row < snapshot.height; row++)
|
|
100
102
|
for (let col = 0; col < snapshot.width; col++) {
|
|
101
103
|
const cell = snapshot.cells[row][col];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/burn",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
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",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@napi-rs/canvas": "^1.0.9",
|
|
65
65
|
"@agentguard-run/spend": "0.22.0",
|
|
66
|
-
"ajv": "8.
|
|
66
|
+
"ajv": "8.18.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/node": "^22",
|