@agentguard-run/burn 0.3.6 → 0.3.8
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 +12 -1
- package/README.md +7 -1
- package/dist/src/cli.js +19 -4
- package/dist/src/dashboard-model.d.ts +80 -0
- package/dist/src/dashboard-model.js +118 -0
- package/dist/src/dashboard-render.d.ts +33 -0
- package/dist/src/dashboard-render.js +426 -0
- package/dist/src/gateway.js +3 -0
- package/dist/src/ledger-panel.js +1 -1
- package/dist/src/live-panel.d.ts +1 -1
- package/dist/src/live-panel.js +25 -12
- package/dist/src/render-recording.d.ts +5 -1
- package/dist/src/render-recording.js +4 -1
- package/dist/src/upgrade-moments.d.ts +13 -0
- package/dist/src/upgrade-moments.js +122 -0
- package/docs/assets/burn-real-stop-sep20.blocks.json +374 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/Inter-SemiBold.ttf +0 -0
- package/fonts/JetBrainsMono-Bold.ttf +0 -0
- package/fonts/JetBrainsMono-Regular.ttf +0 -0
- package/fonts/LICENSE-Inter.txt +92 -0
- package/fonts/LICENSE-JetBrainsMono.txt +93 -0
- package/fonts/README.md +10 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.8 (2026-09-23)
|
|
4
|
+
|
|
5
|
+
- Add `render --dashboard` (`--wide` for 1920 by 1080, `--economics <blocks.json>`, `--fps <n>`): an animated dashboard of a recorded run drawn offline with @napi-rs/canvas. Header counters (copies, decisions, refused, elapsed), a ring with one marker per recorded spawn (teal, amber past the warn threshold, red X marks for refused attempts at the gate), the spawn-rate bar with warn and ceiling ticks, the signed decision log, a subagents panel that prices the measured child transcripts after the run, and a STOP card at the first refusal. Every value comes from the recording or the blocks JSON; motion follows the recorded clock and a fixed seed; frames run at a fixed rate across the recorded span plus a three second hold; provenance records layout, source and economics hashes, fps, seed and every frame time. Vendors Inter and JetBrains Mono (OFL) in `fonts/`.
|
|
6
|
+
- Add a local month-to-date status summary of enforced spawn stops and blocked commands from registered plugin ledgers. Show one Team invitation per UTC month, with permanent dismissal shared with policy-cli quiet on. No network requests or changes to block reasons.
|
|
7
|
+
- Record the gateway decision id on every decision row, so an unsigned decision joins its plugin mirror once in local counts.
|
|
8
|
+
- Carry the monthly Team line on the summary itself, so a JSON status prints the line it consumed.
|
|
9
|
+
|
|
10
|
+
## 0.3.7 (2026-09-22)
|
|
11
|
+
|
|
12
|
+
- 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.
|
|
13
|
+
|
|
3
14
|
## 0.3.6 (2026-09-22)
|
|
4
15
|
|
|
5
|
-
- Add `render --phone`: a 1080 by 1350 frame with a stacked 40 by
|
|
16
|
+
- 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.
|
|
6
17
|
|
|
7
18
|
## 0.3.5 (2026-09-22)
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -509,10 +509,16 @@ agentguard-burn render run.jsonl --mp4 run.mp4 --gif run.gif
|
|
|
509
509
|
agentguard-burn render run.jsonl --mp4 run-phone.mp4 --phone
|
|
510
510
|
```
|
|
511
511
|
|
|
512
|
-
`--phone` renders a 1080 by 1350 frame with a stacked 40 by
|
|
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
513
|
|
|
514
514
|
`record` writes each decision at its real timestamp, with one frame per second
|
|
515
515
|
between decisions. Bounds are optional and otherwise use the session's first
|
|
516
516
|
and last decisions. Earlier decisions still supply window context. The output
|
|
517
517
|
must be new. It contains identifiers and measured metadata, never tool input,
|
|
518
518
|
output or transcript content. See [the live panel and September 20 evidence](docs/LIVE_PANEL_2026_09.md).
|
|
519
|
+
|
|
520
|
+
## Local monthly summary
|
|
521
|
+
|
|
522
|
+
`agentguard-burn status` shows this UTC month’s recorded spawn stops and blocked shell commands. It reads Burn’s local ledger and plugin ledgers registered by either host, joins mirrored spawn receipts once, and excludes shadow decisions, approval holds and outcomes. Missing command history is unknown. Nothing is uploaded. Free installations see one Team line per UTC month. Counts update on later status calls without repeating that line.
|
|
523
|
+
|
|
524
|
+
Run `node runtime/policy-cli.cjs quiet on` from the AgentGuard plugin directory to permanently dismiss the monthly summary, weekly STOP invitation and plugin version announcements on this machine. Both packages use `AGENTGUARD_HOME` or the default local AgentGuard home for this preference.
|
package/dist/src/cli.js
CHANGED
|
@@ -71,6 +71,7 @@ const server_1 = require("./proxy/server");
|
|
|
71
71
|
const render_1 = require("./replay/render");
|
|
72
72
|
const simulate_1 = require("./replay/simulate");
|
|
73
73
|
const status_1 = require("./status");
|
|
74
|
+
const upgrade_moments_1 = require("./upgrade-moments");
|
|
74
75
|
const eligibility_1 = require("./eligibility");
|
|
75
76
|
const sessions_1 = require("./insights/sessions");
|
|
76
77
|
const transcript_1 = require("./insights/transcript");
|
|
@@ -161,9 +162,20 @@ async function main(argv) {
|
|
|
161
162
|
process.stdout.write('not supported on this platform yet\n');
|
|
162
163
|
return 0;
|
|
163
164
|
}
|
|
164
|
-
const source = rest[0], mp4 = flag('--mp4'), gif = flag('--gif');
|
|
165
|
+
const source = rest[0], mp4 = flag('--mp4'), gif = flag('--gif'), economics = flag('--economics'), fpsFlag = flag('--fps');
|
|
166
|
+
const usage = 'Usage: agentguard-burn render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] | --dashboard [--wide] [--economics <blocks.json>] [--fps <n>]';
|
|
165
167
|
if (!source || source.startsWith('--') || !mp4 || mp4.startsWith('--') || (has('--gif') && (!gif || gif.startsWith('--'))))
|
|
166
|
-
throw new Error(
|
|
168
|
+
throw new Error(usage);
|
|
169
|
+
if (has('--dashboard')) {
|
|
170
|
+
if (has('--gif') || has('--phone') || (has('--economics') && (!economics || economics.startsWith('--'))) || (has('--fps') && !/^\d{1,2}$/.test(fpsFlag ?? '')))
|
|
171
|
+
throw new Error(usage);
|
|
172
|
+
const { renderDashboard } = await Promise.resolve().then(() => __importStar(require('./dashboard-render')));
|
|
173
|
+
const result = await renderDashboard(source, { mp4, economics, wide: has('--wide'), ...(fpsFlag ? { fps: Number(fpsFlag) } : {}) });
|
|
174
|
+
show({ kind: 'command', command: 'render', values: { ...result } }, `PNG frames: ${result.framesDir}\n${result.mp4 ? `MP4: ${result.mp4}\n` : `ffmpeg unavailable. Run: ${result.ffmpegCommand}\n`}Provenance: ${result.provenancePath}\n`);
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
if (has('--wide') || has('--economics') || has('--fps'))
|
|
178
|
+
throw new Error(usage);
|
|
167
179
|
const { renderRecording } = await Promise.resolve().then(() => __importStar(require('./render-recording')));
|
|
168
180
|
const result = await renderRecording(source, { mp4, gif, phone: has('--phone') });
|
|
169
181
|
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`);
|
|
@@ -269,12 +281,13 @@ async function main(argv) {
|
|
|
269
281
|
return 0;
|
|
270
282
|
}
|
|
271
283
|
case 'status': {
|
|
284
|
+
const monthly = (0, upgrade_moments_1.monthlySummary)(HOME);
|
|
272
285
|
const policy = (0, pre_tool_use_1.loadPolicy)(HOME);
|
|
273
286
|
const e = shadowEligibility();
|
|
274
287
|
const gateway = new gateway_1.Gateway(HOME, { sign: false });
|
|
275
288
|
const lc = policy.thresholds.localCompute;
|
|
276
289
|
const override = (0, override_1.readOverride)(HOME);
|
|
277
|
-
show({ kind: 'command', command, values: { mode: policy.mode, thresholds: policy.thresholds, eligibility: e, override: override ? { active: true, once: override.once, until: override.until } : null, hosts: ['claude', 'cursor', 'codex'].map(h => { const { command: omitted, ...metadata } = (0, install_1.health)(h); return metadata; }), sessions: [...(0, status_1.readHookSessions)(HOME), ...gateway.sessions()].map(row => ({ sessionId: row.sessionId, hosts: row.hosts, tokens: row.state.totalTokens, spawns: row.state.spawnCount, liveSpawns: row.liveSpawns, capabilities: row.capabilities })) } }, [
|
|
290
|
+
show({ kind: 'command', command, values: { monthly, mode: policy.mode, thresholds: policy.thresholds, eligibility: e, override: override ? { active: true, once: override.once, until: override.until } : null, hosts: ['claude', 'cursor', 'codex'].map(h => { const { command: omitted, ...metadata } = (0, install_1.health)(h); return metadata; }), sessions: [...(0, status_1.readHookSessions)(HOME), ...gateway.sessions()].map(row => ({ sessionId: row.sessionId, hosts: row.hosts, tokens: row.state.totalTokens, spawns: row.state.spawnCount, liveSpawns: row.liveSpawns, capabilities: row.capabilities })) } }, [
|
|
278
291
|
`mode: ${policy.mode}${policy.mode === 'enforce' ? ' (the next STOP blocks)' : ' (recording only; nothing is blocked)'}`,
|
|
279
292
|
`thresholds: fan-out lifetime WARN ${policy.thresholds.fanout.warn}; STOP above ${policy.thresholds.fanout.stop} spawns in ${policy.thresholds.fanout.windowActiveMinutes ?? 120} active minutes; depth above ${policy.thresholds.fanout.maxDepth}`,
|
|
280
293
|
`spawn-rate: WARN ${policy.thresholds.spawnRate?.warn ?? 8}; STOP ${policy.thresholds.spawnRate?.stop ?? 16} in ${policy.thresholds.spawnRate?.windowActiveMinutes ?? 15} active minutes; ${policy.thresholds.spawnRate?.enforce === false ? 'shadow only' : 'enforcing in enforce mode'}`,
|
|
@@ -291,6 +304,7 @@ async function main(argv) {
|
|
|
291
304
|
(0, status_1.renderMachineStatus)([...(0, status_1.readHookSessions)(HOME), ...gateway.sessions()], gateway.compute()),
|
|
292
305
|
'',
|
|
293
306
|
'content logging: off · telemetry: none · state: this machine only',
|
|
307
|
+
(0, upgrade_moments_1.renderMonthlySummary)(monthly),
|
|
294
308
|
]
|
|
295
309
|
.filter((l) => l !== '' || true)
|
|
296
310
|
.join('\n')
|
|
@@ -422,7 +436,8 @@ async function main(argv) {
|
|
|
422
436
|
default:
|
|
423
437
|
show({ kind: 'command', command: 'help', values: { commands: ['ps', 'reap', 'live', 'record', 'render', 'blocks', 'limits', 'price-shadow', 'why', 'rewrites', 'pace', 'statusline', 'pricing', 'replay', 'calibrate', 'status', 'init', 'enforce', 'shadow', 'resume', 'proxy', 'conformance'] } }, 'agentguard-burn <ps|reap|live|record|render|blocks|limits|price-shadow|why|rewrites|pace|statusline|pricing|replay|calibrate|status|init|enforce|shadow|resume|proxy|conformance>\n' +
|
|
424
438
|
' ps [--json] local agent processes, held memory and workspace disk\n' +
|
|
425
|
-
' render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] local recorded-run export\n' +
|
|
439
|
+
' render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] local recorded-run export\n' +
|
|
440
|
+
' render <run.jsonl> --mp4 <out.mp4> --dashboard [--wide] [--economics <blocks.json>] dashboard export\n' +
|
|
426
441
|
' record --session <id> [--from <iso>] [--to <iso>] --out <run.jsonl> reconstruct local ledger frames\n' +
|
|
427
442
|
' live [--session ID] [--once] [--replay run.jsonl] local instrument panel\n' +
|
|
428
443
|
' --record <file.jsonl> append structured frames for any command; --no-color keeps plain output\n' +
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { LivePanelSnapshot } from './live-panel';
|
|
2
|
+
import type { DollarRange } from './insights/pricing';
|
|
3
|
+
export declare const DASHBOARD_HOLD_MS = 3000;
|
|
4
|
+
export interface DashboardFrame {
|
|
5
|
+
at: string;
|
|
6
|
+
atMs: number;
|
|
7
|
+
snapshot: LivePanelSnapshot;
|
|
8
|
+
}
|
|
9
|
+
export interface DashboardChild {
|
|
10
|
+
child: string;
|
|
11
|
+
kind: 'fork' | 'fresh';
|
|
12
|
+
tokens: number | null;
|
|
13
|
+
usd: DollarRange | null;
|
|
14
|
+
}
|
|
15
|
+
export interface DashboardEconomics {
|
|
16
|
+
session: string;
|
|
17
|
+
children: DashboardChild[];
|
|
18
|
+
measuredCount: number;
|
|
19
|
+
pricedCount: number;
|
|
20
|
+
totalTokens: number;
|
|
21
|
+
totalUsd: DollarRange;
|
|
22
|
+
}
|
|
23
|
+
export interface DashboardEvent {
|
|
24
|
+
id: string;
|
|
25
|
+
atMs: number;
|
|
26
|
+
offsetMs: number;
|
|
27
|
+
tool: string;
|
|
28
|
+
verdict: 'OK' | 'WARN' | 'STOP';
|
|
29
|
+
reason: string;
|
|
30
|
+
blocked: boolean | null;
|
|
31
|
+
copies: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DashboardSample {
|
|
34
|
+
offsetMs: number;
|
|
35
|
+
copies: number;
|
|
36
|
+
elapsedMs: number;
|
|
37
|
+
}
|
|
38
|
+
export interface DashboardModel {
|
|
39
|
+
session: string;
|
|
40
|
+
startAt: string;
|
|
41
|
+
startMs: number;
|
|
42
|
+
durationMs: number;
|
|
43
|
+
holdMs: number;
|
|
44
|
+
ceiling: number | null;
|
|
45
|
+
warnAt: number | null;
|
|
46
|
+
windowActiveMinutes: number | null;
|
|
47
|
+
events: DashboardEvent[];
|
|
48
|
+
samples: DashboardSample[];
|
|
49
|
+
economics: DashboardEconomics | null;
|
|
50
|
+
firstStopMs: number | null;
|
|
51
|
+
}
|
|
52
|
+
export interface DashboardStop {
|
|
53
|
+
copies: number;
|
|
54
|
+
ceiling: number | null;
|
|
55
|
+
windowActiveMinutes: number | null;
|
|
56
|
+
offsetMs: number;
|
|
57
|
+
reason: string;
|
|
58
|
+
blocked: boolean | null;
|
|
59
|
+
}
|
|
60
|
+
export interface DashboardState {
|
|
61
|
+
t: number;
|
|
62
|
+
phase: 'run' | 'hold';
|
|
63
|
+
copies: number;
|
|
64
|
+
copiesChangedAt: number;
|
|
65
|
+
previousCopies: number;
|
|
66
|
+
decisions: number;
|
|
67
|
+
refused: number;
|
|
68
|
+
elapsedMs: number;
|
|
69
|
+
log: DashboardEvent[];
|
|
70
|
+
stop: DashboardStop | null;
|
|
71
|
+
warned: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Live frames only, every field known. Unknown fields fail the render instead of being ignored. */
|
|
74
|
+
export declare function readDashboardRecording(file: string): DashboardFrame[];
|
|
75
|
+
/** The blocks JSON is the output of `agentguard-burn blocks <session> --json`; only the recorded session's children are used. */
|
|
76
|
+
export declare function readDashboardEconomics(file: string, session: string): DashboardEconomics;
|
|
77
|
+
/** Distinct decisions in time order; each carries the spawn count of the first frame that showed it. */
|
|
78
|
+
export declare function dashboardModel(frames: DashboardFrame[], economics?: DashboardEconomics | null, holdMs?: number): DashboardModel;
|
|
79
|
+
/** The dashboard at offset t (ms from the first frame): the latest sample and every decision up to t. */
|
|
80
|
+
export declare function dashboardState(model: DashboardModel, t: number): DashboardState;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DASHBOARD_HOLD_MS = void 0;
|
|
4
|
+
exports.readDashboardRecording = readDashboardRecording;
|
|
5
|
+
exports.readDashboardEconomics = readDashboardEconomics;
|
|
6
|
+
exports.dashboardModel = dashboardModel;
|
|
7
|
+
exports.dashboardState = dashboardState;
|
|
8
|
+
/** Dashboard data model: a strict reading of a live recording plus the child economics of the same session. */
|
|
9
|
+
const node_fs_1 = require("node:fs");
|
|
10
|
+
const recording_1 = require("./recording");
|
|
11
|
+
const FRAME_KEYS = ['version', 'at', 'data', 'viewport'];
|
|
12
|
+
const DATA_KEYS = ['kind', 'snapshot'];
|
|
13
|
+
const VIEWPORT_KEYS = ['width', 'height'];
|
|
14
|
+
const SNAPSHOT_KEYS = ['session', 'sessionDigest', 'startedAt', 'observedAt', 'sessionSwitch', 'spawns', 'tokens', 'replayShare', 'windowActiveMinutes', 'spawnCeiling', 'decisions', 'elapsedMs', 'controls', 'stopHold', 'note', 'stop'];
|
|
15
|
+
const SWITCH_KEYS = ['from', 'to', 'at'];
|
|
16
|
+
const DECISION_KEYS = ['id', 'at', 'tool', 'verdict', 'reason', 'blocked'];
|
|
17
|
+
exports.DASHBOARD_HOLD_MS = 3000;
|
|
18
|
+
function rejectUnknown(value, allowed, where, frame) {
|
|
19
|
+
for (const key of Object.keys(value))
|
|
20
|
+
if (!allowed.includes(key))
|
|
21
|
+
throw new Error(`Dashboard recording has an unknown field "${key}" in ${where} at frame ${frame}.`);
|
|
22
|
+
}
|
|
23
|
+
/** Live frames only, every field known. Unknown fields fail the render instead of being ignored. */
|
|
24
|
+
function readDashboardRecording(file) {
|
|
25
|
+
const frames = (0, recording_1.readRecording)(file);
|
|
26
|
+
return frames.map((frame, index) => {
|
|
27
|
+
const number = index + 1;
|
|
28
|
+
rejectUnknown(frame, FRAME_KEYS, 'frame', number);
|
|
29
|
+
if (frame.data.kind !== 'live')
|
|
30
|
+
throw new Error(`Dashboard renders live frames only; frame ${number} is ${frame.data.kind}.`);
|
|
31
|
+
rejectUnknown(frame.data, DATA_KEYS, 'frame data', number);
|
|
32
|
+
if (frame.viewport)
|
|
33
|
+
rejectUnknown(frame.viewport, VIEWPORT_KEYS, 'viewport', number);
|
|
34
|
+
const snapshot = frame.data.snapshot;
|
|
35
|
+
rejectUnknown(snapshot, SNAPSHOT_KEYS, 'snapshot', number);
|
|
36
|
+
if (snapshot.sessionSwitch)
|
|
37
|
+
rejectUnknown(snapshot.sessionSwitch, SWITCH_KEYS, 'session switch', number);
|
|
38
|
+
for (const decision of [...snapshot.decisions, ...(snapshot.stop ? [snapshot.stop] : [])])
|
|
39
|
+
rejectUnknown(decision, DECISION_KEYS, 'decision', number);
|
|
40
|
+
return { at: frame.at, atMs: Date.parse(frame.at), snapshot };
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
44
|
+
function dollarRange(value) {
|
|
45
|
+
if (value === null)
|
|
46
|
+
return null;
|
|
47
|
+
const range = value;
|
|
48
|
+
if (!range || !finite(range.min) || !finite(range.max) || range.max < range.min)
|
|
49
|
+
throw new Error('Blocks JSON has a child price that is not a dollar range.');
|
|
50
|
+
return { min: range.min, max: range.max };
|
|
51
|
+
}
|
|
52
|
+
/** The blocks JSON is the output of `agentguard-burn blocks <session> --json`; only the recorded session's children are used. */
|
|
53
|
+
function readDashboardEconomics(file, session) {
|
|
54
|
+
const report = JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
|
|
55
|
+
const sessions = Array.isArray(report.sessions) ? report.sessions : [];
|
|
56
|
+
const match = sessions.find(entry => typeof entry.session === 'string' && (entry.session === session || entry.session.startsWith(session)));
|
|
57
|
+
const children = match?.economics?.available === true && Array.isArray(match.economics.children) ? match.economics.children : [];
|
|
58
|
+
if (!match || !children.length)
|
|
59
|
+
throw new Error(`Blocks JSON has no child economics for session ${session}.`);
|
|
60
|
+
const rows = children.map(child => {
|
|
61
|
+
if (typeof child.child !== 'string' || (child.kind !== 'fork' && child.kind !== 'fresh') || !(child.tokens === null || finite(child.tokens)))
|
|
62
|
+
throw new Error('Blocks JSON has a malformed child row.');
|
|
63
|
+
return { child: child.child, kind: child.kind, tokens: child.tokens, usd: dollarRange(child.usd) };
|
|
64
|
+
});
|
|
65
|
+
const measured = rows.filter(row => row.tokens !== null), priced = rows.filter(row => row.usd !== null);
|
|
66
|
+
return {
|
|
67
|
+
session: match.session, children: rows, measuredCount: measured.length, pricedCount: priced.length,
|
|
68
|
+
totalTokens: measured.reduce((sum, row) => sum + row.tokens, 0),
|
|
69
|
+
totalUsd: { min: priced.reduce((sum, row) => sum + row.usd.min, 0), max: priced.reduce((sum, row) => sum + row.usd.max, 0) },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Distinct decisions in time order; each carries the spawn count of the first frame that showed it. */
|
|
73
|
+
function dashboardModel(frames, economics = null, holdMs = exports.DASHBOARD_HOLD_MS) {
|
|
74
|
+
if (!frames.length)
|
|
75
|
+
throw new Error('Dashboard recording has no frames.');
|
|
76
|
+
const first = frames[0], last = frames[frames.length - 1];
|
|
77
|
+
const seen = new Map();
|
|
78
|
+
for (const frame of frames) {
|
|
79
|
+
for (const decision of frame.snapshot.decisions) {
|
|
80
|
+
if (seen.has(decision.id))
|
|
81
|
+
continue;
|
|
82
|
+
seen.set(decision.id, { id: decision.id, atMs: decision.at, offsetMs: Math.max(0, decision.at - first.atMs), tool: decision.tool, verdict: decision.verdict, reason: decision.reason, blocked: decision.blocked, copies: frame.snapshot.spawns ?? 0 });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const events = [...seen.values()].sort((a, b) => a.atMs - b.atMs || a.id.localeCompare(b.id));
|
|
86
|
+
const samples = frames.map(frame => ({ offsetMs: frame.atMs - first.atMs, copies: frame.snapshot.spawns ?? 0, elapsedMs: frame.snapshot.elapsedMs ?? frame.atMs - first.atMs }));
|
|
87
|
+
const ceiling = frames.map(frame => frame.snapshot.spawnCeiling).find(value => value !== null) ?? null;
|
|
88
|
+
const windowActiveMinutes = frames.map(frame => frame.snapshot.windowActiveMinutes).find(value => value !== null) ?? null;
|
|
89
|
+
const firstWarn = events.find(event => event.verdict === 'WARN'), firstStop = events.find(event => event.verdict === 'STOP');
|
|
90
|
+
return {
|
|
91
|
+
session: first.snapshot.session, startAt: first.at, startMs: first.atMs, durationMs: last.atMs - first.atMs, holdMs,
|
|
92
|
+
ceiling, warnAt: firstWarn ? firstWarn.copies : null, windowActiveMinutes, events, samples, economics, firstStopMs: firstStop ? firstStop.offsetMs : null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** The dashboard at offset t (ms from the first frame): the latest sample and every decision up to t. */
|
|
96
|
+
function dashboardState(model, t) {
|
|
97
|
+
const clamped = Math.max(0, Math.min(t, model.durationMs + model.holdMs));
|
|
98
|
+
let sample = model.samples[0], previous = sample, changedAt = 0;
|
|
99
|
+
for (const next of model.samples) {
|
|
100
|
+
if (next.offsetMs > clamped)
|
|
101
|
+
break;
|
|
102
|
+
if (next.copies !== sample.copies) {
|
|
103
|
+
previous = sample;
|
|
104
|
+
changedAt = next.offsetMs;
|
|
105
|
+
}
|
|
106
|
+
sample = next;
|
|
107
|
+
}
|
|
108
|
+
const log = model.events.filter(event => event.offsetMs <= clamped);
|
|
109
|
+
const stop = log.find(event => event.verdict === 'STOP');
|
|
110
|
+
return {
|
|
111
|
+
t: clamped, phase: clamped > model.durationMs ? 'hold' : 'run',
|
|
112
|
+
copies: sample.copies, copiesChangedAt: changedAt, previousCopies: previous.copies,
|
|
113
|
+
decisions: log.length, refused: log.filter(event => event.verdict === 'STOP').length,
|
|
114
|
+
elapsedMs: sample.elapsedMs, log,
|
|
115
|
+
stop: stop ? { copies: stop.copies, ceiling: model.ceiling, windowActiveMinutes: model.windowActiveMinutes, offsetMs: stop.offsetMs, reason: stop.reason, blocked: stop.blocked } : null,
|
|
116
|
+
warned: model.warnAt !== null && sample.copies >= model.warnAt,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DashboardModel } from './dashboard-model';
|
|
2
|
+
export * from './dashboard-model';
|
|
3
|
+
export declare const DASHBOARD_SEED = 20260920;
|
|
4
|
+
export declare const INK: {
|
|
5
|
+
paper: string;
|
|
6
|
+
ink: string;
|
|
7
|
+
secondary: string;
|
|
8
|
+
teal: string;
|
|
9
|
+
amber: string;
|
|
10
|
+
red: string;
|
|
11
|
+
grid: string;
|
|
12
|
+
panel: string;
|
|
13
|
+
line: string;
|
|
14
|
+
};
|
|
15
|
+
export type DashboardLayout = 'phone' | 'wide';
|
|
16
|
+
export interface DashboardRenderResult {
|
|
17
|
+
framesDir: string;
|
|
18
|
+
provenancePath: string;
|
|
19
|
+
mp4: string | null;
|
|
20
|
+
ffmpegCommand: string;
|
|
21
|
+
frameCount: number;
|
|
22
|
+
}
|
|
23
|
+
/** One frame at offset t (ms from the first recorded frame). */
|
|
24
|
+
export declare function renderDashboardFrame(model: DashboardModel, t: number, layout?: DashboardLayout, seed?: number): Promise<Buffer>;
|
|
25
|
+
/** Frames at a fixed rate across the recorded span plus the hold, encoded like the terminal render. */
|
|
26
|
+
export declare function renderDashboard(source: string, options: {
|
|
27
|
+
mp4: string;
|
|
28
|
+
economics?: string;
|
|
29
|
+
wide?: boolean;
|
|
30
|
+
ffmpeg?: string | null;
|
|
31
|
+
fps?: number;
|
|
32
|
+
seed?: number;
|
|
33
|
+
}): Promise<DashboardRenderResult>;
|