@agentguard-run/burn 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +3 -0
- package/dist/src/canvas.d.ts +2 -0
- package/dist/src/canvas.js +26 -0
- package/dist/src/cli.js +2 -2
- package/dist/src/frames.d.ts +1 -0
- package/dist/src/insights/pricing.js +4 -0
- package/dist/src/live-panel.d.ts +4 -0
- package/dist/src/live-panel.js +92 -0
- package/dist/src/render-recording.d.ts +11 -1
- package/dist/src/render-recording.js +24 -9
- package/docs/USAGE_AND_PRICING.md +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.6 (2026-09-22)
|
|
4
|
+
|
|
5
|
+
- Add `render --phone`: a 1080 by 1350 frame with a stacked 40 by 32 cell layout (spawn count, spawn rate, last three decisions, STOP card, two-line explainer) so recorded runs stay readable on a phone screen. Provenance records the layout and frame size. Wide renders are unchanged.
|
|
6
|
+
|
|
7
|
+
## 0.3.5 (2026-09-22)
|
|
8
|
+
|
|
9
|
+
- Price `claude-opus-5-5` (4, 0.2, 5, 8, 20 USD per million tokens), `gpt-6-sol` (2, 0.2, 2.5, 10) and `gpt-6-luna` (0.1, 0.01, 0.125, 0.5) at the published list rates checked on 2026-09-22. The two OpenAI rows use the documented 272K input threshold for long-context pricing. Sessions on these models were previously reported as unpriced.
|
|
10
|
+
- Recorded renders use a showcase layout for live frames: seven-row spawn digits, the spawn-rate bar, a short explanation of what a spawn is and a boxed STOP card. Token and replay panels appear only when the recording measured them. Video output uses bold white text, a frame margin and CRF 16.
|
|
11
|
+
|
|
3
12
|
## 0.3.4 (2026-09-22)
|
|
4
13
|
|
|
5
14
|
- Add local, read-only `limits` reports for Claude plan rejections, allowed warnings and HTTP 429 events, with reset interval arithmetic and nearby Burn decisions. Keep Codex limits unsupported and label proximity as correlation.
|
package/README.md
CHANGED
|
@@ -506,8 +506,11 @@ Reconstruct an event after it happened, entirely from local ledgers:
|
|
|
506
506
|
```sh
|
|
507
507
|
agentguard-burn record --session 0b0c2202 --from 2026-09-20T20:20:32Z --to 2026-09-20T20:20:52Z --out run.jsonl
|
|
508
508
|
agentguard-burn render run.jsonl --mp4 run.mp4 --gif run.gif
|
|
509
|
+
agentguard-burn render run.jsonl --mp4 run-phone.mp4 --phone
|
|
509
510
|
```
|
|
510
511
|
|
|
512
|
+
`--phone` renders a 1080 by 1350 frame with a stacked 40 by 32 cell layout (spawn count, spawn rate, the last three decisions, the STOP card and a two-line explainer), so a recorded run stays readable on a phone screen. The provenance file records the layout and frame size.
|
|
513
|
+
|
|
511
514
|
`record` writes each decision at its real timestamp, with one frame per second
|
|
512
515
|
between decisions. Bounds are optional and otherwise use the session's first
|
|
513
516
|
and last decisions. Earlier decisions still supply window context. The output
|
package/dist/src/canvas.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare class Canvas {
|
|
|
27
27
|
});
|
|
28
28
|
put(row: number, col: number, text: string, color?: CanvasColor): this;
|
|
29
29
|
digits(row: number, col: number, value: string | number, color?: CanvasColor): this;
|
|
30
|
+
/** Seven-row block digits, two cells per pixel, for recorded showcase frames. */
|
|
31
|
+
bigDigits(row: number, col: number, value: string | number, color?: CanvasColor): this;
|
|
30
32
|
bar(row: number, col: number, width: number, fraction: number, color?: CanvasColor): this;
|
|
31
33
|
rule(row: number, col: number, width?: number): this;
|
|
32
34
|
header(left?: string, right?: string): this;
|
package/dist/src/canvas.js
CHANGED
|
@@ -18,6 +18,19 @@ const GLYPHS = {
|
|
|
18
18
|
'8': ['█▀█', '█▀█', '█▄█'], '9': ['█▀█', '▀▀█', '▄▄█'],
|
|
19
19
|
'.': [' ', ' ', '▄'], '-': [' ', '▀▀▀', ' '],
|
|
20
20
|
};
|
|
21
|
+
const BIG_GLYPHS = {
|
|
22
|
+
'0': [' ### ', '# #', '# #', '# #', '# #', '# #', ' ### '],
|
|
23
|
+
'1': [' # ', ' ## ', ' # ', ' # ', ' # ', ' # ', ' ### '],
|
|
24
|
+
'2': [' ### ', '# #', ' #', ' # ', ' # ', ' # ', '#####'],
|
|
25
|
+
'3': ['#### ', ' #', ' #', ' ### ', ' #', ' #', '#### '],
|
|
26
|
+
'4': [' # ', ' ## ', ' # # ', '# # ', '#####', ' # ', ' # '],
|
|
27
|
+
'5': ['#####', '# ', '#### ', ' #', ' #', '# #', ' ### '],
|
|
28
|
+
'6': [' ### ', '# ', '# ', '#### ', '# #', '# #', ' ### '],
|
|
29
|
+
'7': ['#####', ' #', ' # ', ' # ', ' # ', ' # ', ' # '],
|
|
30
|
+
'8': [' ### ', '# #', '# #', ' ### ', '# #', '# #', ' ### '],
|
|
31
|
+
'9': [' ### ', '# #', '# #', ' ####', ' #', ' #', ' ### '],
|
|
32
|
+
'-': [' ', ' ', ' ', '#####', ' ', ' ', ' '],
|
|
33
|
+
};
|
|
21
34
|
const colors = new Set(['mint', 'slate', 'amber', 'red', 'white', 'none']);
|
|
22
35
|
function dimension(value, fallback, limit) {
|
|
23
36
|
return Math.max(1, Math.min(limit, Math.floor(typeof value === 'number' && Number.isFinite(value) ? value : fallback)));
|
|
@@ -76,6 +89,19 @@ class Canvas {
|
|
|
76
89
|
}
|
|
77
90
|
return this;
|
|
78
91
|
}
|
|
92
|
+
/** Seven-row block digits, two cells per pixel, for recorded showcase frames. */
|
|
93
|
+
bigDigits(row, col, value, color = 'mint') {
|
|
94
|
+
let x = col;
|
|
95
|
+
for (const char of characters(String(value))) {
|
|
96
|
+
const glyph = BIG_GLYPHS[char] ?? BIG_GLYPHS['-'];
|
|
97
|
+
for (let y = 0; y < 7; y++)
|
|
98
|
+
this.put(row + y, x, glyph[y].replace(/#/g, '██').replace(/ /g, ' '), color);
|
|
99
|
+
x += 12;
|
|
100
|
+
if (x >= this.width)
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
79
105
|
bar(row, col, width, fraction, color = 'mint') {
|
|
80
106
|
if (!Number.isFinite(width) || width <= 0)
|
|
81
107
|
return this;
|
package/dist/src/cli.js
CHANGED
|
@@ -163,9 +163,9 @@ async function main(argv) {
|
|
|
163
163
|
}
|
|
164
164
|
const source = rest[0], mp4 = flag('--mp4'), gif = flag('--gif');
|
|
165
165
|
if (!source || source.startsWith('--') || !mp4 || mp4.startsWith('--') || (has('--gif') && (!gif || gif.startsWith('--'))))
|
|
166
|
-
throw new Error('Usage: agentguard-burn render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>]');
|
|
166
|
+
throw new Error('Usage: agentguard-burn render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone]');
|
|
167
167
|
const { renderRecording } = await Promise.resolve().then(() => __importStar(require('./render-recording')));
|
|
168
|
-
const result = await renderRecording(source, { mp4, gif });
|
|
168
|
+
const result = await renderRecording(source, { mp4, gif, phone: has('--phone') });
|
|
169
169
|
show({ kind: 'command', command: 'render', values: { ...result } }, `PNG frames: ${result.framesDir}\n${result.mp4 ? `MP4: ${result.mp4}\n` : `ffmpeg unavailable. Run: ${result.ffmpegCommand}\n`}${result.gif ? `GIF: ${result.gif}\n` : ''}Provenance: ${result.provenancePath}\n`);
|
|
170
170
|
return 0;
|
|
171
171
|
}
|
package/dist/src/frames.d.ts
CHANGED
|
@@ -13,11 +13,15 @@ const openaiRates = (input, cacheRead, cacheWrite, output, sourceUrl, longContex
|
|
|
13
13
|
exports.MODEL_PRICING = Object.freeze({
|
|
14
14
|
'claude-fable-5-1': rates(10, 0.25, 12.5, 20, 50),
|
|
15
15
|
'claude-fable-5': rates(10, 1, 12.5, 20, 50),
|
|
16
|
+
// Verified 2026-09-22: cache hits on Opus 5.5 are 0.05x base input.
|
|
17
|
+
'claude-opus-5-5': Object.freeze({ ...rates(4, 0.2, 5, 8, 20), verifiedAt: '2026-09-22' }),
|
|
16
18
|
'claude-opus-5': rates(5, 0.5, 6.25, 10, 25),
|
|
17
19
|
'claude-opus-4-8': rates(5, 0.5, 6.25, 10, 25),
|
|
18
20
|
'claude-sonnet-5': rates(2, 0.2, 2.5, 4, 10),
|
|
19
21
|
'claude-haiku-4-5-20251001': rates(1, 0.1, 1.25, 2, 5),
|
|
20
22
|
'gpt-6-astra': openaiRates(10, 1, 12.5, 50, 'https://developers.openai.com/api/docs/pricing'),
|
|
23
|
+
'gpt-6-sol': Object.freeze({ ...openaiRates(2, 0.2, 2.5, 10, 'https://developers.openai.com/api/docs/pricing'), verifiedAt: '2026-09-22' }),
|
|
24
|
+
'gpt-6-luna': Object.freeze({ ...openaiRates(0.1, 0.01, 0.125, 0.5, 'https://developers.openai.com/api/docs/pricing'), verifiedAt: '2026-09-22' }),
|
|
21
25
|
'gpt-5.6-sol': openaiRates(4, 0.4, 5, 20, 'https://developers.openai.com/api/docs/pricing'),
|
|
22
26
|
'gpt-5.6-luna': openaiRates(0.2, 0.02, 0.25, 1.2, 'https://developers.openai.com/api/docs/pricing'),
|
|
23
27
|
'gpt-5.4-mini': openaiRates(0.75, 0.075, null, 4.5, 'https://developers.openai.com/api/docs/models/gpt-5.4-mini', false),
|
package/dist/src/live-panel.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export declare class SessionFollow {
|
|
|
40
40
|
update(snapshot: LivePanelSnapshot, now: number): LivePanelSnapshot;
|
|
41
41
|
}
|
|
42
42
|
export declare function spawnBarColor(spawns: number | null, ceiling: number | null): CanvasColor;
|
|
43
|
+
/** Recorded showcase layout: the spawn count is the hero, unrecorded panels are omitted, never faked. */
|
|
44
|
+
export declare function renderShowcasePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
|
|
45
|
+
/** Recorded phone layout: 40 by 32 cells stacked for a 4:5 frame, the spawn count first, nothing faked. */
|
|
46
|
+
export declare function renderPhonePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
|
|
43
47
|
export declare function renderLivePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
|
|
44
48
|
/** STOP report adaptation uses only already-computed metadata, never local I/O. */
|
|
45
49
|
export declare function panelFromReport(report: BurnReport, at: number, outcome?: 'blocked' | 'shadow' | 'overridden' | 'allowed', subject?: 'spawn' | 'call'): LivePanelSnapshot;
|
package/dist/src/live-panel.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.StopHold = exports.SessionFollow = void 0;
|
|
|
4
4
|
exports.panelDecisions = panelDecisions;
|
|
5
5
|
exports.collectLivePanel = collectLivePanel;
|
|
6
6
|
exports.spawnBarColor = spawnBarColor;
|
|
7
|
+
exports.renderShowcasePanel = renderShowcasePanel;
|
|
8
|
+
exports.renderPhonePanel = renderPhonePanel;
|
|
7
9
|
exports.renderLivePanel = renderLivePanel;
|
|
8
10
|
exports.panelFromReport = panelFromReport;
|
|
9
11
|
exports.runLivePanel = runLivePanel;
|
|
@@ -41,7 +43,97 @@ function elapsed(ms) {
|
|
|
41
43
|
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
42
44
|
return `${String(Math.floor(seconds / 3600)).padStart(2, '0')}:${String(Math.floor(seconds / 60) % 60).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}`;
|
|
43
45
|
}
|
|
46
|
+
/** Recorded showcase layout: the spawn count is the hero, unrecorded panels are omitted, never faked. */
|
|
47
|
+
function renderShowcasePanel(snapshot, options = {}) {
|
|
48
|
+
const c = new canvas_1.Canvas(options), w = c.width, h = c.height, split = Math.floor(w * .45), right = split + 3, room = w - right;
|
|
49
|
+
const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
|
|
50
|
+
c.header('AGENTGUARD / BURN', 'RECORDED RUN · 1x');
|
|
51
|
+
c.footer('local observation only', `elapsed ${snapshot.elapsedMs === null ? 'unknown' : elapsed(snapshot.elapsedMs ?? snapshot.observedAt - snapshot.startedAt)}`);
|
|
52
|
+
c.put(2, 0, `session ${snapshot.session} · ${at.slice(11, 19)} UTC`, 'slate');
|
|
53
|
+
for (let y = 3; y < h - 3; y++)
|
|
54
|
+
c.put(y, split + 1, '│', 'slate');
|
|
55
|
+
c.put(4, 0, 'AGENT SPAWNS IN WINDOW', 'slate');
|
|
56
|
+
c.bigDigits(6, 0, snapshot.spawns === null ? '-' : snapshot.spawns, color);
|
|
57
|
+
c.put(14, 0, `${snapshot.spawns ?? '?'} of ${snapshot.spawnCeiling ?? '?'} allowed · ${snapshot.windowActiveMinutes ?? '?'} active min`.slice(0, split), 'white');
|
|
58
|
+
const fraction = snapshot.spawns === null || snapshot.spawnCeiling === null ? 0 : snapshot.spawns / snapshot.spawnCeiling;
|
|
59
|
+
const rate = `${snapshot.spawns ?? '?'} / ${snapshot.spawnCeiling ?? '?'}`;
|
|
60
|
+
c.put(16, 0, 'SPAWN RATE', 'slate').put(16, Math.max(11, split - rate.length), rate, color);
|
|
61
|
+
c.bar(17, 0, split, fraction, color).bar(18, 0, split, fraction, color);
|
|
62
|
+
let y = 21;
|
|
63
|
+
if (snapshot.tokens !== null) {
|
|
64
|
+
const tokens = compact(snapshot.tokens);
|
|
65
|
+
c.put(y, 0, 'TOKENS IN WINDOW', 'slate').digits(y + 1, 0, tokens.digits, 'mint').put(y + 4, 0, tokens.unit.slice(0, split), 'slate');
|
|
66
|
+
y += 6;
|
|
67
|
+
}
|
|
68
|
+
if (snapshot.replayShare !== null && y + 5 < h - 3) {
|
|
69
|
+
c.put(y, 0, 'REPLAY SHARE %', 'slate').digits(y + 1, 0, Math.round(snapshot.replayShare * 100), 'mint').put(y + 4, 0, 'session cache-read / tokens'.slice(0, split), 'slate');
|
|
70
|
+
y += 6;
|
|
71
|
+
}
|
|
72
|
+
if (y + 5 < h - 3) {
|
|
73
|
+
c.put(y, 0, 'WHAT A SPAWN IS', 'slate');
|
|
74
|
+
['Each spawn is a new agent copy that re-reads', 'the whole context and burns its own tokens.', 'Past the ceiling, the next spawn is refused.', 'Every decision is signed on this machine.']
|
|
75
|
+
.forEach((line, i) => c.put(y + 1 + i, 0, line.slice(0, split), 'white'));
|
|
76
|
+
}
|
|
77
|
+
c.put(4, right, 'LAST 8 DECISIONS', 'slate');
|
|
78
|
+
snapshot.decisions.slice(-8).forEach((d, index) => {
|
|
79
|
+
const row = 5 + index * 2, chip = d.verdict === 'OK' ? 'clean' : d.verdict, tint = d.verdict === 'STOP' ? 'red' : d.verdict === 'WARN' ? 'amber' : 'mint';
|
|
80
|
+
c.put(row, right, `${new Date(d.at).toISOString().slice(11, 19)} ${d.tool}`.slice(0, Math.max(0, room - 8)), 'white');
|
|
81
|
+
c.put(row, Math.max(right, w - 7), `[${chip}]`, tint);
|
|
82
|
+
c.put(row + 1, right, d.reason.slice(0, room), 'slate');
|
|
83
|
+
});
|
|
84
|
+
if (!snapshot.decisions.length)
|
|
85
|
+
c.put(6, right, 'No recorded decisions yet.', 'slate');
|
|
86
|
+
if (snapshot.stop) {
|
|
87
|
+
const top = h - 11;
|
|
88
|
+
for (let i = 0; i < 5; i++)
|
|
89
|
+
c.put(top + i, right, ' '.repeat(room), 'none');
|
|
90
|
+
c.put(top - 1, right, '─'.repeat(room), 'red');
|
|
91
|
+
c.put(top, right, 'STOP · ' + (snapshot.stop.blocked === true ? 'blocked' : snapshot.stop.blocked === false ? 'shadow / allowed' : 'outcome unknown'), 'red');
|
|
92
|
+
c.put(top + 1, right, snapshot.stop.reason.slice(0, room), 'red');
|
|
93
|
+
c.put(top + 2, right, snapshot.stopHold === false ? 'Latest STOP reason.' : 'Reason held for 2 seconds.', 'slate');
|
|
94
|
+
c.put(top + 3, right, '─'.repeat(room), 'red');
|
|
95
|
+
}
|
|
96
|
+
c.put(h - 3, 0, snapshot.note.slice(0, w), 'slate');
|
|
97
|
+
return c;
|
|
98
|
+
}
|
|
99
|
+
/** Recorded phone layout: 40 by 32 cells stacked for a 4:5 frame, the spawn count first, nothing faked. */
|
|
100
|
+
function renderPhonePanel(snapshot, options = {}) {
|
|
101
|
+
const c = new canvas_1.Canvas(options), w = c.width, h = c.height;
|
|
102
|
+
const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
|
|
103
|
+
c.header('AGENTGUARD / BURN', 'RECORDED · 1x');
|
|
104
|
+
c.footer('signed on this machine', `elapsed ${snapshot.elapsedMs === null ? 'unknown' : elapsed(snapshot.elapsedMs ?? snapshot.observedAt - snapshot.startedAt)}`);
|
|
105
|
+
c.put(2, 0, `session ${snapshot.session} · ${at.slice(11, 19)} UTC`.slice(0, w), 'slate');
|
|
106
|
+
c.put(3, 0, 'AGENT SPAWNS IN WINDOW', 'slate');
|
|
107
|
+
c.bigDigits(4, 0, snapshot.spawns === null ? '-' : snapshot.spawns, color);
|
|
108
|
+
c.put(11, 0, `${snapshot.spawns ?? '?'} of ${snapshot.spawnCeiling ?? '?'} allowed · ${snapshot.windowActiveMinutes ?? '?'} active min`.slice(0, w), 'white');
|
|
109
|
+
const fraction = snapshot.spawns === null || snapshot.spawnCeiling === null ? 0 : snapshot.spawns / snapshot.spawnCeiling;
|
|
110
|
+
const rate = `${snapshot.spawns ?? '?'} / ${snapshot.spawnCeiling ?? '?'}`;
|
|
111
|
+
c.put(12, 0, 'SPAWN RATE', 'slate').put(12, Math.max(11, w - rate.length), rate, color);
|
|
112
|
+
c.bar(13, 0, w, fraction, color).bar(14, 0, w, fraction, color);
|
|
113
|
+
c.put(16, 0, 'LAST 3 DECISIONS', 'slate');
|
|
114
|
+
snapshot.decisions.slice(-3).forEach((d, index) => {
|
|
115
|
+
const row = 17 + index * 2, chip = d.verdict === 'OK' ? 'clean' : d.verdict, tint = d.verdict === 'STOP' ? 'red' : d.verdict === 'WARN' ? 'amber' : 'mint';
|
|
116
|
+
c.put(row, 0, `${new Date(d.at).toISOString().slice(11, 19)} ${d.tool}`.slice(0, Math.max(0, w - 8)), 'white');
|
|
117
|
+
c.put(row, Math.max(0, w - chip.length - 2), `[${chip}]`, tint);
|
|
118
|
+
c.put(row + 1, 0, d.reason.slice(0, w), 'slate');
|
|
119
|
+
});
|
|
120
|
+
if (!snapshot.decisions.length)
|
|
121
|
+
c.put(17, 0, 'No recorded decisions yet.', 'slate');
|
|
122
|
+
if (snapshot.stop) {
|
|
123
|
+
c.put(23, 0, '─'.repeat(w), 'red');
|
|
124
|
+
c.put(24, 0, ('STOP · ' + (snapshot.stop.blocked === true ? 'blocked' : snapshot.stop.blocked === false ? 'shadow / allowed' : 'outcome unknown')).slice(0, w), 'red');
|
|
125
|
+
c.put(25, 0, snapshot.stop.reason.slice(0, w), 'red');
|
|
126
|
+
c.put(26, 0, '─'.repeat(w), 'red');
|
|
127
|
+
}
|
|
128
|
+
c.put(28, 0, 'Each spawn re-reads all the context.'.slice(0, w), 'white');
|
|
129
|
+
c.put(29, 0, 'Past the limit, the next is refused.'.slice(0, w), 'white');
|
|
130
|
+
return c;
|
|
131
|
+
}
|
|
44
132
|
function renderLivePanel(snapshot, options = {}) {
|
|
133
|
+
if (options.showcase && (options.height ?? 35) >= 30 && (options.width ?? 104) >= 80)
|
|
134
|
+
return renderShowcasePanel(snapshot, options);
|
|
135
|
+
if (options.showcase && (options.height ?? 35) >= 32 && (options.width ?? 104) >= 36 && (options.width ?? 104) < 80)
|
|
136
|
+
return renderPhonePanel(snapshot, options);
|
|
45
137
|
const c = new canvas_1.Canvas(options), w = c.width, h = c.height, narrow = w < 80, split = narrow ? w : Math.floor(w * .45), right = narrow ? 0 : split + 3, room = w - right;
|
|
46
138
|
const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
|
|
47
139
|
c.header('AGENTGUARD / BURN', options.recorded ? 'RECORDED RUN · 1x' : 'LIVE');
|
|
@@ -7,9 +7,19 @@ export interface RenderRecordingResult {
|
|
|
7
7
|
ffmpegCommand: string;
|
|
8
8
|
frameCount: number;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type RenderStyle = 'default' | 'showcase' | 'phone';
|
|
11
|
+
export declare const PHONE_VIEWPORT: Readonly<{
|
|
12
|
+
width: 40;
|
|
13
|
+
height: 32;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const PHONE_FRAME: Readonly<{
|
|
16
|
+
width: 1080;
|
|
17
|
+
height: 1350;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function renderCanvasPng(snapshot: CanvasSnapshot, width?: number, height?: number, style?: RenderStyle): Promise<Buffer>;
|
|
11
20
|
export declare function renderRecording(source: string, options: {
|
|
12
21
|
mp4: string;
|
|
13
22
|
gif?: string;
|
|
14
23
|
ffmpeg?: string | null;
|
|
24
|
+
phone?: boolean;
|
|
15
25
|
}): Promise<RenderRecordingResult>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PHONE_FRAME = exports.PHONE_VIEWPORT = void 0;
|
|
3
4
|
exports.renderCanvasPng = renderCanvasPng;
|
|
4
5
|
exports.renderRecording = renderRecording;
|
|
5
6
|
/** Offline PNG and video rendering from validated, recorded Canvas data. */
|
|
@@ -68,26 +69,36 @@ function timestampMicros(at) {
|
|
|
68
69
|
const fraction = /\.(\d+)(?:Z|[+-]\d{2}:?\d{2})$/i.exec(at)?.[1] ?? '';
|
|
69
70
|
return BigInt(milliseconds) * 1000n + BigInt(fraction.slice(3, 6).padEnd(3, '0'));
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
exports.PHONE_VIEWPORT = Object.freeze({ width: 40, height: 32 });
|
|
73
|
+
exports.PHONE_FRAME = Object.freeze({ width: 1080, height: 1350 });
|
|
74
|
+
async function renderCanvasPng(snapshot, width = 1920, height = 1080, style = 'default') {
|
|
72
75
|
await font();
|
|
73
76
|
if (!Number.isInteger(width) || !Number.isInteger(height) || width < 64 || height < 64 || width > 4096 || height > 4096)
|
|
74
77
|
throw new Error('Canvas raster dimensions must be integers between 64 and 4096.');
|
|
75
78
|
const canvas = (0, canvas_1.createCanvas)(width, height);
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
// Showcase frames keep a real margin so block digits never touch the frame edge; other frames keep the exact recorded geometry.
|
|
80
|
+
// Phone frames are tall and narrow with few cells, so cells grow to roughly 26 by 40 px and type stays legible on a phone screen.
|
|
81
|
+
const marginX = style === 'showcase' ? 160 : style === 'phone' ? 40 : 32, marginY = style === 'showcase' ? 120 : style === 'phone' ? 60 : 32;
|
|
82
|
+
const maxCellWidth = style === 'phone' ? 27 : CELL_WIDTH, maxCellHeight = style === 'phone' ? 42 : CELL_HEIGHT;
|
|
83
|
+
let cellWidth = Math.min(maxCellWidth, Math.max(1, Math.floor((width - marginX) / snapshot.width)));
|
|
84
|
+
const cellHeight = Math.min(maxCellHeight, Math.max(1, Math.floor((height - marginY) / snapshot.height)), Math.round(cellWidth * CELL_HEIGHT / CELL_WIDTH));
|
|
85
|
+
// Keep the cell aspect ratio when the height is the limit, so lines never overlap.
|
|
86
|
+
cellWidth = Math.max(1, Math.min(cellWidth, Math.round(cellHeight * CELL_WIDTH / CELL_HEIGHT)));
|
|
78
87
|
const paddingX = Math.floor((canvas.width - snapshot.width * cellWidth) / 2);
|
|
79
88
|
const paddingY = Math.floor((canvas.height - snapshot.height * cellHeight) / 2);
|
|
80
89
|
const ctx = canvas.getContext('2d');
|
|
81
90
|
ctx.fillStyle = '#0B1117';
|
|
82
91
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
83
|
-
ctx.font = `${26 * cellWidth / CELL_WIDTH}px "${FONT_ALIAS}"`;
|
|
92
|
+
ctx.font = `${style === 'default' ? '' : 'bold '}${26 * cellWidth / CELL_WIDTH}px "${FONT_ALIAS}"`;
|
|
84
93
|
ctx.textBaseline = 'alphabetic';
|
|
94
|
+
// Showcase and phone palette: brighter than the terminal palette so text survives re-encoding on social players.
|
|
95
|
+
const VIDEO_HEX = style === 'default' ? {} : { mint: '#2ABCB4', slate: '#B4BECF', amber: '#F59E0B', red: '#FF5A4E', white: '#FFFFFF' };
|
|
85
96
|
for (let row = 0; row < snapshot.height; row++)
|
|
86
97
|
for (let col = 0; col < snapshot.width; col++) {
|
|
87
98
|
const cell = snapshot.cells[row][col];
|
|
88
99
|
if (cell.char === ' ')
|
|
89
100
|
continue;
|
|
90
|
-
ctx.fillStyle = canvas_2.CANVAS_PALETTE[cell.color === 'none' ? 'white' : cell.color].hex;
|
|
101
|
+
ctx.fillStyle = VIDEO_HEX[cell.color === 'none' ? 'white' : cell.color] ?? canvas_2.CANVAS_PALETTE[cell.color === 'none' ? 'white' : cell.color].hex;
|
|
91
102
|
const x = paddingX + col * cellWidth, y = paddingY + row * cellHeight;
|
|
92
103
|
if (cell.char === '█')
|
|
93
104
|
ctx.fillRect(x, y, cellWidth, cellHeight);
|
|
@@ -145,8 +156,10 @@ async function renderRecording(source, options) {
|
|
|
145
156
|
for (let index = 0; index < frames.length; index++) {
|
|
146
157
|
const frame = frames[index];
|
|
147
158
|
const name = `frame-${String(index).padStart(6, '0')}.png`;
|
|
148
|
-
const
|
|
149
|
-
|
|
159
|
+
const viewport = options.phone ? exports.PHONE_VIEWPORT : { width: frame.viewport?.width ?? 104, height: frame.viewport?.height ?? 35 };
|
|
160
|
+
const image = (0, frames_1.renderFrame)(frame.data, { recorded: true, showcase: true, at: frame.at, width: viewport.width, height: viewport.height, colour: true });
|
|
161
|
+
const size = options.phone ? exports.PHONE_FRAME : { width: 1920, height: 1080 };
|
|
162
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(framesDir, name), await renderCanvasPng(image.toJSON(), size.width, size.height, frame.data.kind !== 'live' ? 'default' : options.phone ? 'phone' : 'showcase'), { flag: 'wx', mode: 0o600 });
|
|
150
163
|
}
|
|
151
164
|
for (const [position, index] of videoIndices.entries()) {
|
|
152
165
|
const next = videoIndices[position + 1];
|
|
@@ -160,7 +173,7 @@ async function renderRecording(source, options) {
|
|
|
160
173
|
const common = ['-hide_banner', '-loglevel', 'error', '-nostdin', '-n', '-protocol_whitelist', 'file,pipe', '-f', 'concat', '-safe', '0', '-i', concatPath];
|
|
161
174
|
// B-frame reordering can collapse the MP4 track duration to rapid DTS steps even
|
|
162
175
|
// when the final presentation timestamp correctly includes the one-second hold.
|
|
163
|
-
const mp4Args = [...common, '-fps_mode', 'vfr', '-c:v', 'libx264', '-bf', '0', '-enc_time_base', '1:1000000', '-video_track_timescale', '1000000', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', mp4Path];
|
|
176
|
+
const mp4Args = [...common, '-fps_mode', 'vfr', '-c:v', 'libx264', '-crf', '16', '-preset', 'slow', '-bf', '0', '-enc_time_base', '1:1000000', '-video_track_timescale', '1000000', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', mp4Path];
|
|
164
177
|
const gifArgs = [...common, '-fps_mode', 'vfr', '-frames:v', String(videoIndices.length), '-final_delay', '100', '-vf', 'split[a][b];[a]palettegen[p];[b][p]paletteuse', '-loop', '0', ...(gifPath ? [gifPath] : [])];
|
|
165
178
|
const command = [ffmpeg || 'ffmpeg', ...mp4Args].map(shellWord).join(' ')
|
|
166
179
|
+ (gifPath ? `\n${[ffmpeg || 'ffmpeg', ...gifArgs].map(shellWord).join(' ')}` : '');
|
|
@@ -171,7 +184,9 @@ async function renderRecording(source, options) {
|
|
|
171
184
|
font: { family: FONT_ALIAS, path: fontPath },
|
|
172
185
|
frame_count: frames.length,
|
|
173
186
|
frame_times: frames.map(frame => frame.at),
|
|
174
|
-
frame_viewports: frames.map(frame => frame.viewport ?? { width: 104, height: 35 }),
|
|
187
|
+
frame_viewports: frames.map(frame => options.phone ? { ...exports.PHONE_VIEWPORT } : frame.viewport ?? { width: 104, height: 35 }),
|
|
188
|
+
layout: options.phone ? 'phone' : 'wide',
|
|
189
|
+
frame_size: options.phone ? { ...exports.PHONE_FRAME } : { width: 1920, height: 1080 },
|
|
175
190
|
video_frame_indices: videoIndices,
|
|
176
191
|
video_timestamp_precision: 'microseconds; equal timestamps retain the last frame in video and every PNG',
|
|
177
192
|
final_hold_seconds: 1,
|
|
@@ -39,12 +39,13 @@ For `claude-fable-5-1`, 500,000 cache-read tokens have a $0.125 API equivalent.
|
|
|
39
39
|
|
|
40
40
|
## Pricing sources and overrides
|
|
41
41
|
|
|
42
|
-
Every bundled row includes its exact model identifier, `sourceUrl` and `verifiedAt`. The rates were checked on 2026-09-17. The runtime never downloads pricing. Run `agentguard-burn pricing` to inspect the installed table.
|
|
42
|
+
Every bundled row includes its exact model identifier, `sourceUrl` and `verifiedAt`. The rates were checked on 2026-09-17, except `claude-opus-5-5`, `gpt-6-sol` and `gpt-6-luna`, which were checked on 2026-09-22. The runtime never downloads pricing. Run `agentguard-burn pricing` to inspect the installed table.
|
|
43
43
|
|
|
44
44
|
The Claude rows use the [official model price list](https://platform.claude.com/docs/en/about-claude/pricing). Amounts below are USD per million tokens in the order fresh input, cache read, five-minute write, one-hour write, output:
|
|
45
45
|
|
|
46
46
|
* `claude-fable-5-1`: 10, 0.25, 12.5, 20, 50.
|
|
47
47
|
* `claude-fable-5`: 10, 1, 12.5, 20, 50.
|
|
48
|
+
* `claude-opus-5-5`: 4, 0.2, 5, 8, 20.
|
|
48
49
|
* `claude-opus-5` and `claude-opus-4-8`: 5, 0.5, 6.25, 10, 25.
|
|
49
50
|
* `claude-sonnet-5`: 2, 0.2, 2.5, 4, 10.
|
|
50
51
|
* `claude-haiku-4-5-20251001`: 1, 0.1, 1.25, 2, 5.
|
|
@@ -52,6 +53,8 @@ The Claude rows use the [official model price list](https://platform.claude.com/
|
|
|
52
53
|
The [OpenAI API price list](https://developers.openai.com/api/docs/pricing) supplies these standard rates in the order fresh input, cache read, cache write, output:
|
|
53
54
|
|
|
54
55
|
* `gpt-6-astra`: 10, 1, 12.5, 50.
|
|
56
|
+
* `gpt-6-sol`: 2, 0.2, 2.5, 10.
|
|
57
|
+
* `gpt-6-luna`: 0.1, 0.01, 0.125, 0.5.
|
|
55
58
|
* `gpt-5.6-sol`: 4, 0.4, 5, 20. These are the published promotional rates on the verification date.
|
|
56
59
|
* `gpt-5.6-luna`: 0.2, 0.02, 0.25, 1.2.
|
|
57
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/burn",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
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
|
"type": "commonjs",
|