@agentguard-run/burn 0.3.5 → 0.3.7

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.7 (2026-09-22)
4
+
5
+ - Phone render: add one block per allowed copy under the spawn rate, filled from the recorded count, red with "next copy refused" at a STOP; grow the layout to 40 by 36 cells.
6
+
7
+ ## 0.3.6 (2026-09-22)
8
+
9
+ - Add `render --phone`: a 1080 by 1350 frame with a stacked 40 by 36 cell layout (spawn count, spawn rate, one block per allowed copy, last three decisions, STOP card, explainer) so recorded runs stay readable on a phone screen. Provenance records the layout and frame size. Wide renders are unchanged.
10
+
3
11
  ## 0.3.5 (2026-09-22)
4
12
 
5
13
  - 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.
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 36 cell layout (spawn count, spawn rate, one block per allowed copy, the last three decisions, the STOP card and an 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/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
  }
@@ -42,6 +42,8 @@ export declare class SessionFollow {
42
42
  export declare function spawnBarColor(spawns: number | null, ceiling: number | null): CanvasColor;
43
43
  /** Recorded showcase layout: the spawn count is the hero, unrecorded panels are omitted, never faked. */
44
44
  export declare function renderShowcasePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
45
+ /** Recorded phone layout: 40 by 36 cells stacked for a 4:5 frame, the spawn count first, nothing faked. */
46
+ export declare function renderPhonePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
45
47
  export declare function renderLivePanel(snapshot: LivePanelSnapshot, options?: FrameOptions): Canvas;
46
48
  /** STOP report adaptation uses only already-computed metadata, never local I/O. */
47
49
  export declare function panelFromReport(report: BurnReport, at: number, outcome?: 'blocked' | 'shadow' | 'overridden' | 'allowed', subject?: 'spawn' | 'call'): LivePanelSnapshot;
@@ -5,6 +5,7 @@ exports.panelDecisions = panelDecisions;
5
5
  exports.collectLivePanel = collectLivePanel;
6
6
  exports.spawnBarColor = spawnBarColor;
7
7
  exports.renderShowcasePanel = renderShowcasePanel;
8
+ exports.renderPhonePanel = renderPhonePanel;
8
9
  exports.renderLivePanel = renderLivePanel;
9
10
  exports.panelFromReport = panelFromReport;
10
11
  exports.runLivePanel = runLivePanel;
@@ -95,9 +96,57 @@ function renderShowcasePanel(snapshot, options = {}) {
95
96
  c.put(h - 3, 0, snapshot.note.slice(0, w), 'slate');
96
97
  return c;
97
98
  }
99
+ /** Recorded phone layout: 40 by 36 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;
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
+ // One block per allowed copy, filled from the recorded count. The grid only exists when the ceiling was recorded.
114
+ if (snapshot.spawnCeiling !== null && snapshot.spawnCeiling > 0) {
115
+ const ceiling = snapshot.spawnCeiling, filled = Math.min(ceiling, Math.max(0, snapshot.spawns ?? 0));
116
+ const perRow = Math.ceil(ceiling / 2), blockWidth = Math.max(1, Math.floor((w + 1) / perRow) - 1);
117
+ const refused = snapshot.stop !== undefined;
118
+ c.put(16, 0, 'AGENT COPIES', 'slate');
119
+ const tag = refused ? 'next copy refused' : 'one block per copy';
120
+ c.put(16, Math.max(13, w - tag.length), tag, refused ? 'red' : 'slate');
121
+ for (let index = 0; index < ceiling; index++) {
122
+ const row = 17 + Math.floor(index / perRow) * 2, col = (index % perRow) * (blockWidth + 1);
123
+ const on = index < filled, glyph = (on ? '█' : '░').repeat(blockWidth);
124
+ c.put(row, col, glyph, on ? color : 'slate').put(row + 1, col, glyph, on ? color : 'slate');
125
+ }
126
+ }
127
+ c.put(22, 0, 'LAST 3 DECISIONS', 'slate');
128
+ snapshot.decisions.slice(-3).forEach((d, index) => {
129
+ const row = 23 + index * 2, chip = d.verdict === 'OK' ? 'clean' : d.verdict, tint = d.verdict === 'STOP' ? 'red' : d.verdict === 'WARN' ? 'amber' : 'mint';
130
+ c.put(row, 0, `${new Date(d.at).toISOString().slice(11, 19)} ${d.tool}`.slice(0, Math.max(0, w - 8)), 'white');
131
+ c.put(row, Math.max(0, w - chip.length - 2), `[${chip}]`, tint);
132
+ c.put(row + 1, 0, d.reason.slice(0, w), 'slate');
133
+ });
134
+ if (!snapshot.decisions.length)
135
+ c.put(23, 0, 'No recorded decisions yet.', 'slate');
136
+ c.put(29, 0, 'Each spawn re-reads all the context.'.slice(0, w), 'white');
137
+ if (snapshot.stop) {
138
+ c.put(30, 0, '─'.repeat(w), 'red');
139
+ c.put(31, 0, ('STOP · ' + (snapshot.stop.blocked === true ? 'blocked' : snapshot.stop.blocked === false ? 'shadow / allowed' : 'outcome unknown') + ' · ' + snapshot.stop.reason).slice(0, w), 'red');
140
+ c.put(32, 0, '─'.repeat(w), 'red');
141
+ }
142
+ c.put(33, 0, 'Past the limit, the next is refused.'.slice(0, w), 'white');
143
+ return c;
144
+ }
98
145
  function renderLivePanel(snapshot, options = {}) {
99
146
  if (options.showcase && (options.height ?? 35) >= 30 && (options.width ?? 104) >= 80)
100
147
  return renderShowcasePanel(snapshot, options);
148
+ if (options.showcase && (options.height ?? 35) >= 36 && (options.width ?? 104) >= 36 && (options.width ?? 104) < 80)
149
+ return renderPhonePanel(snapshot, options);
101
150
  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;
102
151
  const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
103
152
  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 declare function renderCanvasPng(snapshot: CanvasSnapshot, width?: number, height?: number, style?: 'default' | 'showcase'): Promise<Buffer>;
10
+ export type RenderStyle = 'default' | 'showcase' | 'phone';
11
+ export declare const PHONE_VIEWPORT: Readonly<{
12
+ width: 40;
13
+ height: 36;
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,24 +69,30 @@ 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
  }
72
+ exports.PHONE_VIEWPORT = Object.freeze({ width: 40, height: 36 });
73
+ exports.PHONE_FRAME = Object.freeze({ width: 1080, height: 1350 });
71
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
79
  // Showcase frames keep a real margin so block digits never touch the frame edge; other frames keep the exact recorded geometry.
77
- const marginX = style === 'showcase' ? 160 : 32, marginY = style === 'showcase' ? 120 : 32;
78
- const cellWidth = Math.min(CELL_WIDTH, Math.max(1, Math.floor((width - marginX) / snapshot.width)));
79
- const cellHeight = Math.min(CELL_HEIGHT, Math.max(1, Math.floor((height - marginY) / snapshot.height)), Math.round(cellWidth * CELL_HEIGHT / CELL_WIDTH));
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)));
80
87
  const paddingX = Math.floor((canvas.width - snapshot.width * cellWidth) / 2);
81
88
  const paddingY = Math.floor((canvas.height - snapshot.height * cellHeight) / 2);
82
89
  const ctx = canvas.getContext('2d');
83
90
  ctx.fillStyle = '#0B1117';
84
91
  ctx.fillRect(0, 0, canvas.width, canvas.height);
85
- ctx.font = `${style === 'showcase' ? 'bold ' : ''}${26 * cellWidth / CELL_WIDTH}px "${FONT_ALIAS}"`;
92
+ ctx.font = `${style === 'default' ? '' : 'bold '}${26 * cellWidth / CELL_WIDTH}px "${FONT_ALIAS}"`;
86
93
  ctx.textBaseline = 'alphabetic';
87
- // Showcase palette: brighter than the terminal palette so text survives re-encoding on social players.
88
- const VIDEO_HEX = style === 'showcase' ? { mint: '#2ABCB4', slate: '#B4BECF', amber: '#F59E0B', red: '#FF5A4E', white: '#FFFFFF' } : {};
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' };
89
96
  for (let row = 0; row < snapshot.height; row++)
90
97
  for (let col = 0; col < snapshot.width; col++) {
91
98
  const cell = snapshot.cells[row][col];
@@ -149,8 +156,10 @@ async function renderRecording(source, options) {
149
156
  for (let index = 0; index < frames.length; index++) {
150
157
  const frame = frames[index];
151
158
  const name = `frame-${String(index).padStart(6, '0')}.png`;
152
- const image = (0, frames_1.renderFrame)(frame.data, { recorded: true, showcase: true, at: frame.at, width: frame.viewport?.width ?? 104, height: frame.viewport?.height ?? 35, colour: true });
153
- await (0, promises_1.writeFile)((0, node_path_1.join)(framesDir, name), await renderCanvasPng(image.toJSON(), 1920, 1080, frame.data.kind === 'live' ? 'showcase' : 'default'), { flag: 'wx', mode: 0o600 });
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 });
154
163
  }
155
164
  for (const [position, index] of videoIndices.entries()) {
156
165
  const next = videoIndices[position + 1];
@@ -175,7 +184,9 @@ async function renderRecording(source, options) {
175
184
  font: { family: FONT_ALIAS, path: fontPath },
176
185
  frame_count: frames.length,
177
186
  frame_times: frames.map(frame => frame.at),
178
- 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 },
179
190
  video_frame_indices: videoIndices,
180
191
  video_timestamp_precision: 'microseconds; equal timestamps retain the last frame in video and every PNG',
181
192
  final_hold_seconds: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentguard-run/burn",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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",