@agentguard-run/burn 0.3.11 → 0.3.13
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 +9 -1
- package/dist/src/cli.js +8 -4
- package/dist/src/dashboard-model.d.ts +2 -0
- package/dist/src/dashboard-render.d.ts +1 -0
- package/dist/src/dashboard-render.js +11 -3
- package/dist/src/defaults.js +1 -0
- package/dist/src/detectors/evaluate.js +10 -1
- package/dist/src/frames.d.ts +1 -0
- package/dist/src/insights/sessions.d.ts +2 -0
- package/dist/src/insights/sessions.js +12 -1
- package/dist/src/live-panel.js +3 -2
- package/dist/src/render-recording.d.ts +1 -0
- package/dist/src/render-recording.js +7 -2
- package/dist/src/types.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.13 (2026-09-24)
|
|
4
|
+
|
|
5
|
+
- `why`, `blocks` and the other insight commands: with no session given, the newest top-level transcript is selected. A subagent's own transcript (`<session>/subagents/agent-*.jsonl`) was often the newest file on disk and, read alone, reported 100% fan-out and nothing else. Subagent transcripts stay selectable by id.
|
|
6
|
+
- `account.stopConcurrentSessions` (default `null`): a hard ceiling on live sessions for the machine. Above it, every spawn proposal on the machine is refused with an `account` STOP until a session finishes; other tool calls are untouched and a plain status evaluation only warns. For hosts that start sessions on their own, such as Claude Code Projects running threads locally. `calibrate` and `policy` print the machine line beside the spawn-rate line.
|
|
7
|
+
|
|
8
|
+
## 0.3.12 (2026-09-24)
|
|
9
|
+
|
|
10
|
+
- `render --playback <rate>` (1 to 4) for both the recorded render and the dashboard: a faster cut of the same recording. Recorded renders divide every frame interval by the rate and the header reads "RECORDED · 1.5x"; the dashboard samples recorded time at the rate and draws "PLAYBACK 1.5x" under the counters on every frame. Frame times in provenance stay in recorded time; provenance records `playback` (and `video_seconds` for the dashboard).
|
|
11
|
+
|
|
3
12
|
## 0.3.11 (2026-09-23)
|
|
4
13
|
|
|
5
14
|
- `render --label <text>` for both the recorded render and the dashboard: a caller-supplied name for what the recording was (for example "deliberate fan-out test"), drawn in the frame and written to the provenance file. Never inferred.
|
package/README.md
CHANGED
|
@@ -462,6 +462,14 @@ Both token limits default to `null`. Closed gateway sessions are excluded;
|
|
|
462
462
|
hook and gateway session files are both read. WARN never blocks. STOP records
|
|
463
463
|
a would-block decision in shadow and blocks new work only in enforce mode.
|
|
464
464
|
|
|
465
|
+
`account.stopConcurrentSessions` (default `null`) is a hard ceiling on live
|
|
466
|
+
sessions for the machine. Above it, every spawn proposal on the machine is
|
|
467
|
+
refused until a session finishes; other tool calls are untouched, and a plain
|
|
468
|
+
status evaluation only warns. It is meant for hosts that start sessions on
|
|
469
|
+
their own, such as Claude Code Projects running threads locally: the project
|
|
470
|
+
can run as many threads as it likes, but none of them may add copies while
|
|
471
|
+
the machine is over your number.
|
|
472
|
+
|
|
465
473
|
## Terminal canvas and local recordings
|
|
466
474
|
|
|
467
475
|
Interactive screens use a fixed 104 by 35 cell canvas, with mint for good, slate for neutral, amber for WARN and red for STOP. Smaller terminals drop side detail and paginate rows without wrapping. Use --no-color for the existing plain-text commands and hook cards. Hook JSON and the one-line statusline remain host protocols, with no canvas control sequences inserted.
|
|
@@ -509,7 +517,7 @@ agentguard-burn render run.jsonl --mp4 run.mp4 --gif run.gif
|
|
|
509
517
|
agentguard-burn render run.jsonl --mp4 run-phone.mp4 --phone
|
|
510
518
|
```
|
|
511
519
|
|
|
512
|
-
`--phone` renders a 1080 by 1350 frame with a stacked 40 by 36 cell layout (spawn count, spawn attempts against the ceiling, one block per copy that launched, 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. `--label <text>` (1 to 40 printable characters) names what the recording was, for example `--label "deliberate fan-out test"`; it is drawn in the frame (phone: the explainer row; wide: the header; dashboard: the session line) and recorded in the provenance file. It is never inferred from the recording.
|
|
520
|
+
`--phone` renders a 1080 by 1350 frame with a stacked 40 by 36 cell layout (spawn count, spawn attempts against the ceiling, one block per copy that launched, 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. `--label <text>` (1 to 40 printable characters) names what the recording was, for example `--label "deliberate fan-out test"`; it is drawn in the frame (phone: the explainer row; wide: the header; dashboard: the session line) and recorded in the provenance file. It is never inferred from the recording. `--playback <rate>` (1 to 4) renders a faster cut of the same recording; the frame says the rate ("RECORDED · 1.5x" or "PLAYBACK 1.5x") and provenance records it, while frame times stay in recorded time.
|
|
513
521
|
|
|
514
522
|
`record` writes each decision at its real timestamp, with one frame per second
|
|
515
523
|
between decisions. Bounds are optional and otherwise use the session's first
|
package/dist/src/cli.js
CHANGED
|
@@ -162,24 +162,26 @@ async function main(argv) {
|
|
|
162
162
|
process.stdout.write('not supported on this platform yet\n');
|
|
163
163
|
return 0;
|
|
164
164
|
}
|
|
165
|
-
const source = rest[0], mp4 = flag('--mp4'), gif = flag('--gif'), economics = flag('--economics'), fpsFlag = flag('--fps'), label = flag('--label');
|
|
166
|
-
const usage = 'Usage: agentguard-burn render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] [--label <text>] | --dashboard [--wide] [--economics <blocks.json>] [--fps <n>] [--label <text>]';
|
|
165
|
+
const source = rest[0], mp4 = flag('--mp4'), gif = flag('--gif'), economics = flag('--economics'), fpsFlag = flag('--fps'), label = flag('--label'), playbackFlag = flag('--playback');
|
|
166
|
+
const usage = 'Usage: agentguard-burn render <run.jsonl> --mp4 <out.mp4> [--gif <out.gif>] [--phone] [--label <text>] [--playback <rate>] | --dashboard [--wide] [--economics <blocks.json>] [--fps <n>] [--label <text>] [--playback <rate>]';
|
|
167
167
|
if (has('--label') && (!label || label.startsWith('--')))
|
|
168
168
|
throw new Error(usage);
|
|
169
|
+
if (has('--playback') && !/^[1-4](\.\d{1,2})?$/.test(playbackFlag ?? ''))
|
|
170
|
+
throw new Error(usage);
|
|
169
171
|
if (!source || source.startsWith('--') || !mp4 || mp4.startsWith('--') || (has('--gif') && (!gif || gif.startsWith('--'))))
|
|
170
172
|
throw new Error(usage);
|
|
171
173
|
if (has('--dashboard')) {
|
|
172
174
|
if (has('--gif') || has('--phone') || (has('--economics') && (!economics || economics.startsWith('--'))) || (has('--fps') && !/^\d{1,2}$/.test(fpsFlag ?? '')))
|
|
173
175
|
throw new Error(usage);
|
|
174
176
|
const { renderDashboard } = await Promise.resolve().then(() => __importStar(require('./dashboard-render')));
|
|
175
|
-
const result = await renderDashboard(source, { mp4, economics, wide: has('--wide'), ...(fpsFlag ? { fps: Number(fpsFlag) } : {}), ...(label ? { label } : {}) });
|
|
177
|
+
const result = await renderDashboard(source, { mp4, economics, wide: has('--wide'), ...(fpsFlag ? { fps: Number(fpsFlag) } : {}), ...(label ? { label } : {}), ...(playbackFlag ? { playback: Number(playbackFlag) } : {}) });
|
|
176
178
|
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`);
|
|
177
179
|
return 0;
|
|
178
180
|
}
|
|
179
181
|
if (has('--wide') || has('--economics') || has('--fps'))
|
|
180
182
|
throw new Error(usage);
|
|
181
183
|
const { renderRecording } = await Promise.resolve().then(() => __importStar(require('./render-recording')));
|
|
182
|
-
const result = await renderRecording(source, { mp4, gif, phone: has('--phone'), ...(label ? { label } : {}) });
|
|
184
|
+
const result = await renderRecording(source, { mp4, gif, phone: has('--phone'), ...(label ? { label } : {}), ...(playbackFlag ? { playback: Number(playbackFlag) } : {}) });
|
|
183
185
|
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`);
|
|
184
186
|
return 0;
|
|
185
187
|
}
|
|
@@ -276,6 +278,7 @@ async function main(argv) {
|
|
|
276
278
|
` sustained WARN ${(t.sustained.warnTokens / 1e9).toFixed(2)}B STOP ${(t.sustained.stopTokens / 1e9).toFixed(2)}B`,
|
|
277
279
|
` fan-out lifetime WARN ${t.fanout.warn}; STOP above ${t.fanout.stop} spawns in ${t.fanout.windowActiveMinutes ?? 120} active minutes; depth above ${t.fanout.maxDepth}`,
|
|
278
280
|
` spawn-rate WARN ${t.spawnRate?.warn ?? 8}; STOP ${t.spawnRate?.stop ?? 16} in ${t.spawnRate?.windowActiveMinutes ?? 15} active minutes; ${t.spawnRate?.enforce === false ? 'shadow only' : 'enforcing in enforce mode'}`,
|
|
281
|
+
` machine WARN above ${t.account?.warnConcurrentSessions ?? 4} live sessions; ${t.account?.stopConcurrentSessions != null ? `no new copies above ${t.account.stopConcurrentSessions}` : 'no concurrency ceiling (account.stopConcurrentSessions is null)'}`,
|
|
279
282
|
` burn-debt ${t.burnDebt.enabled ? `ON, baseline ${Math.round(t.burnDebt.baselinePerActiveMinute / 1e6)}M/active-min` : 'off'}`,
|
|
280
283
|
...result.notes.map((n) => ` note: ${n}`),
|
|
281
284
|
`Policy written to ${(0, node_path_1.join)(HOME, 'burn-policy.json')} in SHADOW mode.`,
|
|
@@ -293,6 +296,7 @@ async function main(argv) {
|
|
|
293
296
|
`mode: ${policy.mode}${policy.mode === 'enforce' ? ' (the next STOP blocks)' : ' (recording only; nothing is blocked)'}`,
|
|
294
297
|
`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}`,
|
|
295
298
|
`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'}`,
|
|
299
|
+
`machine: WARN above ${policy.thresholds.account?.warnConcurrentSessions ?? 4} live sessions; ${policy.thresholds.account?.stopConcurrentSessions != null ? `no new copies above ${policy.thresholds.account.stopConcurrentSessions}` : 'no concurrency ceiling (account.stopConcurrentSessions is null)'}`,
|
|
296
300
|
`sustained: ${(policy.thresholds.sustained.warnTokens / 1e9).toFixed(1)}B/${(policy.thresholds.sustained.stopTokens / 1e9).toFixed(1)}B local-compute warn at ${lc?.warnConcurrent ?? 4} concurrent${lc?.stopConcurrent ? `, stop at ${lc.stopConcurrent}` : ' (no stop set)'}`,
|
|
297
301
|
policy.calibration ? `calibrated from ${policy.calibration.sessionsSampled} sessions` : 'using shipped defaults (run: agentguard-burn calibrate)',
|
|
298
302
|
`shadow observation: ${e.decisions} decisions over ${e.days.toFixed(1)} days`,
|
|
@@ -57,6 +57,8 @@ export interface DashboardModel {
|
|
|
57
57
|
launched: number;
|
|
58
58
|
/** Caller-supplied name for what the recording was (for example "deliberate fan-out test"); drawn in the header, never inferred. */
|
|
59
59
|
label?: string;
|
|
60
|
+
/** Playback rate of the rendered video relative to recorded time; 1 unless the caller asks for a faster cut. */
|
|
61
|
+
playback?: number;
|
|
60
62
|
events: DashboardEvent[];
|
|
61
63
|
samples: DashboardSample[];
|
|
62
64
|
economics: DashboardEconomics | null;
|
|
@@ -135,6 +135,9 @@ function header(ctx, model, state, g) {
|
|
|
135
135
|
const agent = text(ctx, 'Agent', g.margin, g.header.y, wordSize, { weight: 600 });
|
|
136
136
|
text(ctx, 'Guard', g.margin + agent, g.header.y, wordSize, { weight: 600, color: exports.INK.teal });
|
|
137
137
|
text(ctx, `session ${model.session} · ${model.startAt.slice(0, 10)} ${model.startAt.slice(11, 16)} UTC · spawn gate${model.label ? ` · ${model.label}` : ''}`, g.margin, g.header.y + 34, g.small, { color: exports.INK.secondary });
|
|
138
|
+
// A faster-than-recorded cut says so in the header, under the counters, on every frame.
|
|
139
|
+
if (model.playback && model.playback !== 1)
|
|
140
|
+
text(ctx, `PLAYBACK ${model.playback}x`, g.width - g.margin, g.header.y + 34 + g.small * 2.1, Math.round(g.small * 1.2), { family: 'mono', weight: 700, color: exports.INK.ink, align: 'right' });
|
|
138
141
|
// Counters step at the recorded event time, in the same frame as the log row and the ring marker, so no frame shows
|
|
139
142
|
// a marker or log row the counters have not yet counted. Copies = allowed decisions; the ledger's attempt counter drives the rate bar.
|
|
140
143
|
const values = [
|
|
@@ -366,6 +369,9 @@ async function renderDashboard(source, options) {
|
|
|
366
369
|
throw new Error('Dashboard fps must be an integer from 1 to 60.');
|
|
367
370
|
if (options.label !== undefined && !/^[\x20-\x7e]{1,40}$/.test(options.label))
|
|
368
371
|
throw new Error('Render label must be 1 to 40 printable ASCII characters.');
|
|
372
|
+
const playback = options.playback ?? 1;
|
|
373
|
+
if (!Number.isFinite(playback) || playback < 1 || playback > 4)
|
|
374
|
+
throw new Error('Playback rate must be between 1 and 4.');
|
|
369
375
|
const sourcePath = (0, node_path_1.resolve)(source), mp4Path = (0, node_path_1.resolve)(options.mp4), provenancePath = `${mp4Path}.provenance.json`;
|
|
370
376
|
const economicsPath = options.economics ? (0, node_path_1.resolve)(options.economics) : null;
|
|
371
377
|
const outputs = [mp4Path, provenancePath];
|
|
@@ -386,15 +392,16 @@ async function renderDashboard(source, options) {
|
|
|
386
392
|
const economics = economicsPath ? (0, dashboard_model_1.readDashboardEconomics)(economicsPath, frames[0].snapshot.session, (0, dashboard_model_1.recordingWindow)(frames)) : null;
|
|
387
393
|
if (!sourceBytes.equals(await (0, promises_1.readFile)(sourcePath)))
|
|
388
394
|
throw new Error('Recording changed while it was being read; render the saved file again.');
|
|
389
|
-
const model = { ...(0, dashboard_model_1.dashboardModel)(frames, economics, dashboard_model_1.DASHBOARD_HOLD_MS), ...(options.label ? { label: options.label } : {}) };
|
|
395
|
+
const model = { ...(0, dashboard_model_1.dashboardModel)(frames, economics, dashboard_model_1.DASHBOARD_HOLD_MS), ...(options.label ? { label: options.label } : {}), ...(playback !== 1 ? { playback } : {}) };
|
|
390
396
|
const layout = options.wide ? 'wide' : 'phone', g = geometry(layout), seed = options.seed ?? exports.DASHBOARD_SEED;
|
|
391
397
|
const fonts = await registerFonts();
|
|
392
|
-
|
|
398
|
+
// Frames sample recorded time at `playback` times the rate they are shown, so the video runs shorter while every frame time stays real.
|
|
399
|
+
const total = Math.round((model.durationMs + model.holdMs) / playback / 1000 * fps), frameCount = total + 1;
|
|
393
400
|
await (0, promises_1.mkdir)((0, node_path_1.dirname)(mp4Path), { recursive: true });
|
|
394
401
|
const framesDir = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_path_1.dirname)(mp4Path), `${(0, node_path_1.basename)(mp4Path)}.frames-`));
|
|
395
402
|
const concatPath = (0, node_path_1.join)(framesDir, 'frames.ffconcat'), lines = ['ffconcat version 1.0'], frameTimes = [];
|
|
396
403
|
for (let index = 0; index < frameCount; index++) {
|
|
397
|
-
const offset = index * 1000 / fps, name = `frame-${String(index).padStart(6, '0')}.png`;
|
|
404
|
+
const offset = index * 1000 / fps * playback, name = `frame-${String(index).padStart(6, '0')}.png`;
|
|
398
405
|
frameTimes.push(new Date(model.startMs + offset).toISOString());
|
|
399
406
|
await (0, promises_1.writeFile)((0, node_path_1.join)(framesDir, name), await renderDashboardFrame(model, offset, layout, seed), { flag: 'wx', mode: 0o600 });
|
|
400
407
|
if (index < total)
|
|
@@ -415,6 +422,7 @@ async function renderDashboard(source, options) {
|
|
|
415
422
|
fonts, layout: 'dashboard', frame_size: { width: g.width, height: g.height }, aspect: layout, fps, seed,
|
|
416
423
|
frame_count: frameCount, frame_times: frameTimes,
|
|
417
424
|
label: options.label ?? null,
|
|
425
|
+
playback, video_seconds: (model.durationMs + model.holdMs) / playback / 1000,
|
|
418
426
|
recording_span_seconds: model.durationMs / 1000, final_hold_seconds: model.holdMs / 1000,
|
|
419
427
|
video_timestamp_precision: 'microseconds; fixed 1/fps frame durations from the first recorded timestamp',
|
|
420
428
|
ffmpeg_command: command,
|
package/dist/src/defaults.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.DEFAULT_THRESHOLDS = {
|
|
|
44
44
|
warnTokens: null,
|
|
45
45
|
windowActiveMinutes: 300,
|
|
46
46
|
warnConcurrentSessions: 4,
|
|
47
|
+
stopConcurrentSessions: null,
|
|
47
48
|
},
|
|
48
49
|
// Local model runtimes. Elapsed request time is not GPU utilisation (it
|
|
49
50
|
// includes queueing and transport), so it is called occupied time and it
|
|
@@ -140,7 +140,16 @@ function evaluate(state, thresholds, proposedSpawnDepth = null, account) {
|
|
|
140
140
|
if (account && thresholds.account) {
|
|
141
141
|
const t = thresholds.account;
|
|
142
142
|
const live = account.sessions.filter((s) => account.now - s.lastEventAt <= account_1.ACTIVE_SESSION_WINDOW_MS);
|
|
143
|
-
if (live.length > t.
|
|
143
|
+
if (t.stopConcurrentSessions != null && live.length > t.stopConcurrentSessions) {
|
|
144
|
+
// The machine is over its concurrency ceiling. A spawn proposal is refused;
|
|
145
|
+
// a plain session evaluation only reports it, since nothing is being added.
|
|
146
|
+
const severity = proposedSpawnDepth !== null ? 'STOP' : 'WARN';
|
|
147
|
+
findings.push({ detector: 'account', verdict: severity,
|
|
148
|
+
summary: `${live.length} concurrent active sessions on this machine; ceiling is ${t.stopConcurrentSessions}. ${proposedSpawnDepth !== null ? 'No session may add a copy until one finishes.' : 'New copies are refused until one finishes.'}`,
|
|
149
|
+
observed: live.length, threshold: t.stopConcurrentSessions });
|
|
150
|
+
verdict = worst(verdict, severity);
|
|
151
|
+
}
|
|
152
|
+
else if (live.length > t.warnConcurrentSessions) {
|
|
144
153
|
findings.push({ detector: 'account', verdict: 'WARN',
|
|
145
154
|
summary: `${live.length} concurrent active sessions on this machine; warning threshold is ${t.warnConcurrentSessions}.`,
|
|
146
155
|
observed: live.length, threshold: t.warnConcurrentSessions });
|
package/dist/src/frames.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface FrameOptions {
|
|
|
42
42
|
height?: number;
|
|
43
43
|
colour?: boolean;
|
|
44
44
|
label?: string;
|
|
45
|
+
playback?: number;
|
|
45
46
|
}
|
|
46
47
|
export declare function auditFrame(command: 'ps' | 'reap', report: AuditReport): BurnFrame;
|
|
47
48
|
export declare function framePageCount(data: BurnFrame, options?: FrameOptions): number;
|
|
@@ -10,3 +10,5 @@ export declare function discoverInsightTranscripts(roots?: {
|
|
|
10
10
|
codex: string;
|
|
11
11
|
}): TranscriptLocation[];
|
|
12
12
|
export declare function selectInsightTranscript(session?: string, locations?: TranscriptLocation[]): TranscriptLocation;
|
|
13
|
+
/** Claude Code stores each subagent's transcript beside its parent under `subagents/`. */
|
|
14
|
+
export declare function isSubagentTranscript(location: Pick<TranscriptLocation, 'path' | 'sessionId'>): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.discoverInsightTranscripts = discoverInsightTranscripts;
|
|
4
4
|
exports.selectInsightTranscript = selectInsightTranscript;
|
|
5
|
+
exports.isSubagentTranscript = isSubagentTranscript;
|
|
5
6
|
const node_fs_1 = require("node:fs");
|
|
6
7
|
const node_path_1 = require("node:path");
|
|
7
8
|
const node_os_1 = require("node:os");
|
|
@@ -44,8 +45,18 @@ function selectInsightTranscript(session, locations) {
|
|
|
44
45
|
return { path, host: /(?:rollout-|[\\/]\.codex[\\/])/.test(path) ? 'codex' : 'claude', sessionId: (0, node_path_1.basename)(path, '.jsonl'), modifiedAt: (0, node_fs_1.statSync)(path).mtimeMs };
|
|
45
46
|
}
|
|
46
47
|
const candidates = locations ?? discoverInsightTranscripts();
|
|
47
|
-
|
|
48
|
+
// With nothing requested, the newest top-level session wins. A subagent's own
|
|
49
|
+
// transcript (Claude Code keeps them under <session>/subagents/agent-*.jsonl) is
|
|
50
|
+
// often the newest file on disk, and read alone it reports 100% fan-out and
|
|
51
|
+
// nothing else, which tells the operator nothing. It stays reachable by id.
|
|
52
|
+
const selected = requested
|
|
53
|
+
? candidates.find(item => item.sessionId === requested || item.sessionId.endsWith(`-${requested}`))
|
|
54
|
+
: candidates.find(item => !isSubagentTranscript(item)) ?? candidates[0];
|
|
48
55
|
if (!selected)
|
|
49
56
|
throw new Error(requested ? 'Session transcript not found. Pass its local JSONL path.' : 'No local Claude Code or Codex transcript found.');
|
|
50
57
|
return selected;
|
|
51
58
|
}
|
|
59
|
+
/** Claude Code stores each subagent's transcript beside its parent under `subagents/`. */
|
|
60
|
+
function isSubagentTranscript(location) {
|
|
61
|
+
return (0, node_path_1.basename)((0, node_path_1.dirname)(location.path)) === 'subagents' || location.sessionId.startsWith('agent-');
|
|
62
|
+
}
|
package/dist/src/live-panel.js
CHANGED
|
@@ -48,7 +48,8 @@ function renderShowcasePanel(snapshot, options = {}) {
|
|
|
48
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
49
|
const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
|
|
50
50
|
// A render label (for example "deliberate fan-out test") names what the recording was; it is caller-supplied, never inferred.
|
|
51
|
-
|
|
51
|
+
const speed = `${options.playback ?? 1}x`;
|
|
52
|
+
c.header('AGENTGUARD / BURN', options.label ? `${options.label.toUpperCase()} · RECORDED · ${speed}` : `RECORDED RUN · ${speed}`);
|
|
52
53
|
c.footer('local observation only', `elapsed ${snapshot.elapsedMs === null ? 'unknown' : elapsed(snapshot.elapsedMs ?? snapshot.observedAt - snapshot.startedAt)}`);
|
|
53
54
|
c.put(2, 0, `session ${snapshot.session} · ${at.slice(11, 19)} UTC`, 'slate');
|
|
54
55
|
for (let y = 3; y < h - 3; y++)
|
|
@@ -101,7 +102,7 @@ function renderShowcasePanel(snapshot, options = {}) {
|
|
|
101
102
|
function renderPhonePanel(snapshot, options = {}) {
|
|
102
103
|
const c = new canvas_1.Canvas(options), w = c.width;
|
|
103
104
|
const at = options.at ?? new Date(snapshot.observedAt).toISOString(), color = spawnBarColor(snapshot.spawns, snapshot.spawnCeiling);
|
|
104
|
-
c.header('AGENTGUARD / BURN',
|
|
105
|
+
c.header('AGENTGUARD / BURN', `RECORDED · ${options.playback ?? 1}x`);
|
|
105
106
|
c.footer('signed on this machine', `elapsed ${snapshot.elapsedMs === null ? 'unknown' : elapsed(snapshot.elapsedMs ?? snapshot.observedAt - snapshot.startedAt)}`);
|
|
106
107
|
c.put(2, 0, `session ${snapshot.session} · ${at.slice(11, 19)} UTC`.slice(0, w), 'slate');
|
|
107
108
|
c.put(3, 0, 'SPAWN ATTEMPTS IN WINDOW', 'slate');
|
|
@@ -119,6 +119,10 @@ async function renderCanvasPng(snapshot, width = 1920, height = 1080, style = 'd
|
|
|
119
119
|
async function renderRecording(source, options) {
|
|
120
120
|
if (options.label !== undefined && !/^[\x20-\x7e]{1,40}$/.test(options.label))
|
|
121
121
|
throw new Error('Render label must be 1 to 40 printable ASCII characters.');
|
|
122
|
+
// Playback divides every recorded interval; the frame stays labelled with the rate and provenance records it.
|
|
123
|
+
const playback = options.playback ?? 1;
|
|
124
|
+
if (!Number.isFinite(playback) || playback < 1 || playback > 4)
|
|
125
|
+
throw new Error('Playback rate must be between 1 and 4.');
|
|
122
126
|
const sourcePath = (0, node_path_1.resolve)(source), mp4Path = (0, node_path_1.resolve)(options.mp4);
|
|
123
127
|
const gifPath = options.gif ? (0, node_path_1.resolve)(options.gif) : null;
|
|
124
128
|
const provenancePath = `${mp4Path}.provenance.json`;
|
|
@@ -162,13 +166,13 @@ async function renderRecording(source, options) {
|
|
|
162
166
|
const frame = frames[index];
|
|
163
167
|
const name = `frame-${String(index).padStart(6, '0')}.png`;
|
|
164
168
|
const viewport = options.phone ? exports.PHONE_VIEWPORT : { width: frame.viewport?.width ?? 104, height: frame.viewport?.height ?? 35 };
|
|
165
|
-
const image = (0, frames_1.renderFrame)(frame.data, { recorded: true, showcase: true, at: frame.at, width: viewport.width, height: viewport.height, colour: true, ...(options.label ? { label: options.label } : {}) });
|
|
169
|
+
const image = (0, frames_1.renderFrame)(frame.data, { recorded: true, showcase: true, at: frame.at, width: viewport.width, height: viewport.height, colour: true, ...(options.label ? { label: options.label } : {}), ...(playback !== 1 ? { playback } : {}) });
|
|
166
170
|
const size = options.phone ? exports.PHONE_FRAME : { width: 1920, height: 1080 };
|
|
167
171
|
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 });
|
|
168
172
|
}
|
|
169
173
|
for (const [position, index] of videoIndices.entries()) {
|
|
170
174
|
const next = videoIndices[position + 1];
|
|
171
|
-
const seconds = next === undefined ? 1 : Number(times[next] - times[index]) / 1_000_000;
|
|
175
|
+
const seconds = (next === undefined ? 1 : Number(times[next] - times[index]) / 1_000_000) / playback;
|
|
172
176
|
lines.push(`file 'frame-${String(index).padStart(6, '0')}.png'`, 'option framerate 1000000', `duration ${seconds.toFixed(6)}`);
|
|
173
177
|
}
|
|
174
178
|
// The concat demuxer needs a terminal file to honor the final frame hold.
|
|
@@ -192,6 +196,7 @@ async function renderRecording(source, options) {
|
|
|
192
196
|
frame_viewports: frames.map(frame => options.phone ? { ...exports.PHONE_VIEWPORT } : frame.viewport ?? { width: 104, height: 35 }),
|
|
193
197
|
layout: options.phone ? 'phone' : 'wide',
|
|
194
198
|
label: options.label ?? null,
|
|
199
|
+
playback,
|
|
195
200
|
frame_size: options.phone ? { ...exports.PHONE_FRAME } : { width: 1920, height: 1080 },
|
|
196
201
|
video_frame_indices: videoIndices,
|
|
197
202
|
video_timestamp_precision: 'microseconds; equal timestamps retain the last frame in video and every PNG',
|
package/dist/src/types.d.ts
CHANGED
|
@@ -118,6 +118,14 @@ export interface Thresholds {
|
|
|
118
118
|
warnTokens: number | null;
|
|
119
119
|
windowActiveMinutes: number;
|
|
120
120
|
warnConcurrentSessions: number;
|
|
121
|
+
/**
|
|
122
|
+
* Hard ceiling on live sessions for this machine. Above it, no session may
|
|
123
|
+
* add a copy until one finishes (a spawn proposal is refused; other tool
|
|
124
|
+
* calls are untouched). `null` keeps the WARN-only default. Meant for
|
|
125
|
+
* hosts that start sessions on their own, such as Claude Code Projects
|
|
126
|
+
* running threads locally.
|
|
127
|
+
*/
|
|
128
|
+
stopConcurrentSessions: number | null;
|
|
121
129
|
};
|
|
122
130
|
/**
|
|
123
131
|
* Local inference plane (Ollama, vLLM, LM Studio). Token dollars are close
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentguard-run/burn",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
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",
|