@agentguard-run/burn 0.3.26 → 0.3.27

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.27 (2026-10-02)
4
+
5
+ - `why` and every other command that reads one session no longer stop on a session file over about 512 MB. A transcript over 256 MB is now read in 16 MB pieces cut at line ends, the way `calendar` reads every file, so no single string has to hold the whole file, and the report equals a whole-file read. One long-running Claude Code session had reached 568 MB, and `why` on it stopped with "Cannot create a string longer than 0x1fffffe8 characters"; it now reports in about 9 seconds. Files up to 256 MB are read exactly as before.
6
+ - Tests: 537 (536 pass, 1 skipped).
7
+
3
8
  ## 0.3.26 (2026-10-02)
4
9
 
5
10
  - Sub-agents that started, used tokens and ended without finishing now show up in `why`, `calendar` and the STOP line. A sub-agent counts only on terminal evidence: Claude Code recorded the status of its task notification as `failed`, `killed` or `stopped`, and never recorded it as `completed` or resumed (a SendMessage result that started it again). One launched in the background with no end recorded may still be running, so it never counts. A launch refused before it started (a hook, a permission rule, your no) has no transcript and used no tokens, so it is not counted either. Burn has no rule for a session being over, so it relies on these records alone. It knows whether a sub-agent finished, never whether its work was right, so every line says "ended without finishing", never "failed".
@@ -14,10 +14,20 @@ export interface InsightReadOptions {
14
14
  * parsed with the parser state the previous piece returned, so no single string
15
15
  * holds the whole file (V8 cannot hold a string past about 512 MB). The turns,
16
16
  * observations and summed diagnostics equal a whole-file parse. Unset reads the
17
- * whole file at once, as `why` does.
17
+ * whole file at once, as `why` does, unless the file is over
18
+ * WHOLE_FILE_MAX_BYTES: then it is read in pieces all the same.
18
19
  */
19
20
  chunkBytes?: number;
21
+ /** Tests only: the size above which a read with no chunkBytes still goes in pieces. */
22
+ wholeFileMaxBytes?: number;
20
23
  }
24
+ /**
25
+ * Above this size a whole-file read could pass V8's string limit, so the file is
26
+ * read in pieces even when no chunk size was asked for. Such a session is rare
27
+ * but real: one long-running Claude Code session reached 568 MB, and `why` on
28
+ * it stopped with "Cannot create a string longer than 0x1fffffe8 characters".
29
+ */
30
+ export declare const WHOLE_FILE_MAX_BYTES: number;
21
31
  export declare function readInsightTranscript(filename: string, options?: InsightParseOptions, read?: InsightReadOptions): InsightTranscript;
22
32
  /** Read one Claude session plus its explicitly stored child transcripts. */
23
33
  export declare function readInsightSession(filename: string, options?: InsightParseOptions, read?: InsightReadOptions): InsightTranscript;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.providerResponseIdentity = void 0;
3
+ exports.WHOLE_FILE_MAX_BYTES = exports.providerResponseIdentity = void 0;
4
4
  exports.parseInsightTranscript = parseInsightTranscript;
5
5
  exports.readInsightTranscript = readInsightTranscript;
6
6
  exports.readInsightSession = readInsightSession;
@@ -528,11 +528,23 @@ function parseInsightTranscript(text, options = {}) {
528
528
  return { host: state.host, sessionId: state.sessionId, turns: Object.values(state.seen), updatedTurns: [...updated.values()], diagnostics, state,
529
529
  observations: observations(state.observedCalls ?? {}), acceptedQuotaLineNumbers };
530
530
  }
531
+ /**
532
+ * Above this size a whole-file read could pass V8's string limit, so the file is
533
+ * read in pieces even when no chunk size was asked for. Such a session is rare
534
+ * but real: one long-running Claude Code session reached 568 MB, and `why` on
535
+ * it stopped with "Cannot create a string longer than 0x1fffffe8 characters".
536
+ */
537
+ exports.WHOLE_FILE_MAX_BYTES = 256 * 1024 * 1024;
538
+ const LARGE_FILE_CHUNK_BYTES = 16 * 1024 * 1024;
531
539
  const DIAGNOSTIC_KEYS = ['lines', 'malformedLines', 'duplicateUsageRecords', 'unsupportedUsageRecords', 'inheritedUsageRecords'];
532
540
  function parseFile(filename, options, read) {
533
- const limit = read.chunkBytes;
534
- if (!limit || !(limit > 0))
535
- return parseInsightTranscript((0, node_fs_1.readFileSync)(filename, 'utf8'), options);
541
+ let limit = read.chunkBytes;
542
+ if (!limit || !(limit > 0)) {
543
+ const max = read.wholeFileMaxBytes ?? exports.WHOLE_FILE_MAX_BYTES;
544
+ if ((0, node_fs_1.statSync)(filename).size <= max)
545
+ return parseInsightTranscript((0, node_fs_1.readFileSync)(filename, 'utf8'), options);
546
+ limit = Math.min(LARGE_FILE_CHUNK_BYTES, max);
547
+ }
536
548
  const fd = (0, node_fs_1.openSync)(filename, 'r');
537
549
  try {
538
550
  if ((0, node_fs_1.fstatSync)(fd).size <= limit)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentguard-run/burn",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Local session usage and runaway-agent circuit breaker. Explain tokens, cache rewrites and API list cost, track pace, warn on heavy turns, and gate agent fan-out with signed receipts. Developer command ranking requires explicit --rank.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://agentguard.run/burn",