@agentguard-run/burn 0.3.18 → 0.3.20
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 +33 -0
- package/README.md +105 -5
- package/dist/src/canvas.d.ts +7 -1
- package/dist/src/canvas.js +10 -1
- package/dist/src/cli.js +101 -7
- package/dist/src/frames.d.ts +10 -0
- package/dist/src/frames.js +5 -0
- package/dist/src/history/claude-transcript.d.ts +26 -1
- package/dist/src/history/claude-transcript.js +58 -2
- package/dist/src/hook/pre-tool-use.d.ts +6 -2
- package/dist/src/hook/pre-tool-use.js +35 -8
- package/dist/src/insights/calendar-render.d.ts +48 -0
- package/dist/src/insights/calendar-render.js +196 -0
- package/dist/src/insights/calendar.d.ts +138 -0
- package/dist/src/insights/calendar.js +431 -0
- package/dist/src/insights/compare.d.ts +104 -0
- package/dist/src/insights/compare.js +210 -0
- package/dist/src/insights/i18n.d.ts +134 -8
- package/dist/src/insights/i18n.js +200 -13
- package/dist/src/insights/render.d.ts +93 -13
- package/dist/src/insights/render.js +212 -28
- package/dist/src/insights/sessions.d.ts +25 -0
- package/dist/src/insights/sessions.js +72 -5
- package/dist/src/insights/transcript.d.ts +13 -2
- package/dist/src/insights/transcript.js +61 -6
- package/dist/src/insights/types.d.ts +17 -0
- package/dist/src/insights/types.js +3 -1
- package/dist/src/recording.js +5 -1
- package/dist/src/replay/render.d.ts +2 -0
- package/dist/src/replay/render.js +4 -0
- package/dist/src/stop-text.d.ts +16 -5
- package/dist/src/stop-text.js +28 -6
- package/dist/src/subagent-cost.d.ts +38 -0
- package/dist/src/subagent-cost.js +65 -0
- package/package.json +1 -1
|
@@ -1,22 +1,102 @@
|
|
|
1
|
-
import { type DollarRange, type PricingTable } from './pricing';
|
|
2
|
-
import { type InsightHost, type InsightTranscript, type InsightTurn, type RewriteCause, type RewriteEvidence } from './types';
|
|
1
|
+
import { type DollarRange, type PricingTable, type TurnPrice } from './pricing';
|
|
2
|
+
import { type AttributionSummary, type InsightBucket, type InsightHost, type InsightTranscript, type InsightTurn, type RewriteCause, type RewriteEvidence } from './types';
|
|
3
3
|
import { type WhyLang } from './i18n';
|
|
4
4
|
export declare function sumPrices(values: Array<DollarRange | null>): DollarRange | null;
|
|
5
5
|
export declare function totalTokens(turn: InsightTurn): number;
|
|
6
|
+
/** What the two header lines of `why` are computed from; `compare` reads the same object, so both commands print the same figures. */
|
|
7
|
+
export interface SessionFigures {
|
|
8
|
+
/** Deduplicated responses in time order, child transcripts included when the transcript carries them. */
|
|
9
|
+
turns: InsightTurn[];
|
|
10
|
+
attribution: AttributionSummary;
|
|
11
|
+
prices: TurnPrice[];
|
|
12
|
+
totals: {
|
|
13
|
+
input: number;
|
|
14
|
+
write: number;
|
|
15
|
+
read: number;
|
|
16
|
+
output: number;
|
|
17
|
+
};
|
|
18
|
+
/** The API list equivalent `why` prints; null when any response has no verified rate. */
|
|
19
|
+
totalUsd: DollarRange | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function sessionFigures(transcript: InsightTranscript, rates?: PricingTable): SessionFigures;
|
|
22
|
+
/** Left-aligned columns two spaces apart; widths follow the widest cell, so translated labels widen their column. */
|
|
23
|
+
export declare function table(headers: string[], rows: string[][]): string;
|
|
24
|
+
/** Token counts in en-US digits in every language. */
|
|
25
|
+
export declare const count: (n: number) => string;
|
|
26
|
+
/** The table's share column; the tip prints the same figure. */
|
|
27
|
+
export declare const share: (tokens: number, total: number) => string;
|
|
6
28
|
export declare const WHY_TIP_HIDE_LINE: string;
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
export declare function whyTip(input: {
|
|
29
|
+
/** A model id as people say it: claude-opus-5-5 is Opus 5.5 and claude-haiku-4-5-20251001 is Haiku 4.5. Any other id prints as it is. */
|
|
30
|
+
export declare function modelLabel(model: string): string;
|
|
31
|
+
/** What the coach tip is chosen from: each cause's measured size in this session, and the facts its action line quotes. */
|
|
32
|
+
export interface WhyTipInput {
|
|
33
|
+
/** The table's session total, children included. */
|
|
14
34
|
totalTokens: number;
|
|
15
|
-
|
|
16
|
-
historyTokens: number;
|
|
17
|
-
rewriteUsd: DollarRange | null;
|
|
35
|
+
/** The session's API list equivalent; null when a model is unpriced, and causes then compare by tokens. */
|
|
18
36
|
totalUsd: DollarRange | null;
|
|
19
|
-
|
|
37
|
+
/** The table's sub-agent row, the main conversation's model, and the sub-agents that ran on it with their share of all sub-agent tokens. */
|
|
38
|
+
subagents: {
|
|
39
|
+
tokens: number;
|
|
40
|
+
usd: DollarRange | null;
|
|
41
|
+
mainModel?: string | null;
|
|
42
|
+
onMainModel?: number;
|
|
43
|
+
onMainModelShare?: number;
|
|
44
|
+
};
|
|
45
|
+
/** The table's full-prefix rewrite row, and its largest cause at list price with that cause's count and longest idle gap. */
|
|
46
|
+
reloads: {
|
|
47
|
+
tokens: number;
|
|
48
|
+
usd: DollarRange | null;
|
|
49
|
+
cause?: RewriteCause | null;
|
|
50
|
+
count?: number;
|
|
51
|
+
longestIdleMs?: number | null;
|
|
52
|
+
};
|
|
53
|
+
/** Main-conversation cached reads past the first call's context: the conversation Claude re-reads on every message. */
|
|
54
|
+
conversation: {
|
|
55
|
+
tokens: number;
|
|
56
|
+
usd: DollarRange | null;
|
|
57
|
+
medianPerCall: number;
|
|
58
|
+
};
|
|
59
|
+
/** The first call's context, and each later call's cached reads up to that size: the setup Claude reads before every message. */
|
|
60
|
+
setup: {
|
|
61
|
+
tokens: number;
|
|
62
|
+
usd: DollarRange | null;
|
|
63
|
+
medianPerCall: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The coach: one next step, for the largest cause that stands out in this
|
|
68
|
+
* session; null when none does, never a generic line. A cause stands out at the
|
|
69
|
+
* 0.3.16 thresholds: sub-agents at 20% of session tokens, full-prefix rewrites at
|
|
70
|
+
* 15% of the list total (priced sessions only), and the re-read conversation and
|
|
71
|
+
* the setup at 30% of session tokens each. Among those the largest at list price
|
|
72
|
+
* wins (a dollar range at its midpoint), or the largest in tokens when a model is
|
|
73
|
+
* unpriced; a tie keeps that order. Each action is Anthropic's published advice
|
|
74
|
+
* for its cause (code.claude.com/docs/en/costs, /prompt-caching, /sub-agents),
|
|
75
|
+
* and every figure is this session's own. Where the cause has no sharper action,
|
|
76
|
+
* the share tip prints for sub-agents and the 0.3.16 dollars tip for rewrites.
|
|
77
|
+
*/
|
|
78
|
+
export declare function whyTip(input: WhyTipInput, lang?: WhyLang): string | null;
|
|
79
|
+
/**
|
|
80
|
+
* What `whyTip` weighs, from the figures `why` prints. The sub-agent and rewrite
|
|
81
|
+
* rows are the table's own. The setup and the re-read conversation split each
|
|
82
|
+
* main-conversation call's cached reads at the size of the session's first call,
|
|
83
|
+
* so a rewrite that resets the table's fixed-prefix baseline never turns re-read
|
|
84
|
+
* conversation into setup; they are measured, like every row, from recorded usage.
|
|
85
|
+
*/
|
|
86
|
+
export declare function whyTipInput(figures: Pick<SessionFigures, 'turns' | 'attribution' | 'totalUsd'>, rates?: PricingTable, bucketUsd?: (bucket: InsightBucket) => DollarRange | null): WhyTipInput;
|
|
87
|
+
/** Messages on each side of an event the measured change compares, at most and at least. */
|
|
88
|
+
export declare const PROOF_WINDOW = 20;
|
|
89
|
+
export declare const PROOF_MINIMUM = 5;
|
|
90
|
+
/**
|
|
91
|
+
* One measured change, around the latest compaction, /clear or model switch the
|
|
92
|
+
* main conversation's transcript records: the median tokens Claude read per
|
|
93
|
+
* message in the N messages after it against the N before it. N is 20, or fewer
|
|
94
|
+
* when the session, or the previous or next such event, leaves fewer on a side;
|
|
95
|
+
* below 5 on either side that event says nothing and an earlier one is tried.
|
|
96
|
+
* It states what was measured next to the event, never a saving and never that
|
|
97
|
+
* the event caused it.
|
|
98
|
+
*/
|
|
99
|
+
export declare function proofLine(turns: InsightTurn[], lang?: WhyLang): string | null;
|
|
20
100
|
/** `lang` changes words only: every figure, id, command and URL prints as it does in English, and `why json` never passes through here. */
|
|
21
101
|
export declare function renderWhy(transcript: InsightTranscript, rates?: PricingTable, options?: {
|
|
22
102
|
tips?: boolean;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WHY_TIP_HIDE_LINE = void 0;
|
|
3
|
+
exports.PROOF_MINIMUM = exports.PROOF_WINDOW = exports.WHY_TIP_HIDE_LINE = exports.share = exports.count = void 0;
|
|
4
4
|
exports.sumPrices = sumPrices;
|
|
5
5
|
exports.totalTokens = totalTokens;
|
|
6
|
+
exports.sessionFigures = sessionFigures;
|
|
7
|
+
exports.table = table;
|
|
8
|
+
exports.modelLabel = modelLabel;
|
|
6
9
|
exports.whyTip = whyTip;
|
|
10
|
+
exports.whyTipInput = whyTipInput;
|
|
11
|
+
exports.proofLine = proofLine;
|
|
7
12
|
exports.renderWhy = renderWhy;
|
|
8
13
|
exports.rewriteReport = rewriteReport;
|
|
9
14
|
exports.rewriteReportJson = rewriteReportJson;
|
|
@@ -15,10 +20,18 @@ const live_1 = require("./live");
|
|
|
15
20
|
const transcript_1 = require("./transcript");
|
|
16
21
|
const types_1 = require("./types");
|
|
17
22
|
const i18n_1 = require("./i18n");
|
|
23
|
+
const stop_text_1 = require("../stop-text");
|
|
18
24
|
function sumPrices(values) {
|
|
19
25
|
return values.some(value => value === null) ? null : values.reduce((sum, value) => ({ min: sum.min + value.min, max: sum.max + value.max }), { min: 0, max: 0 });
|
|
20
26
|
}
|
|
21
27
|
function totalTokens(turn) { return turn.inputTokens + turn.cacheWriteTokens + turn.cacheReadTokens + turn.outputTokens; }
|
|
28
|
+
function sessionFigures(transcript, rates = {}) {
|
|
29
|
+
const turns = (0, transcript_1.deduplicateTurns)(transcript.turns).sort((a, b) => (a.at ?? 0) - (b.at ?? 0));
|
|
30
|
+
const prices = turns.map(turn => (0, pricing_1.priceTurn)(turn, rates));
|
|
31
|
+
const totals = { input: 0, write: 0, read: 0, output: 0 };
|
|
32
|
+
turns.forEach(turn => { totals.input += turn.inputTokens; totals.write += turn.cacheWriteTokens; totals.read += turn.cacheReadTokens; totals.output += turn.outputTokens; });
|
|
33
|
+
return { turns, attribution: (0, attribution_1.attributeTurns)(turns), prices, totals, totalUsd: sumPrices(prices.map(price => price.usd)) };
|
|
34
|
+
}
|
|
22
35
|
function bucketPrice(turn, allocation, rates) {
|
|
23
36
|
const quantities = allocation.categories;
|
|
24
37
|
if (Object.values(quantities).every(value => value === 0))
|
|
@@ -31,30 +44,203 @@ function bucketPrice(turn, allocation, rates) {
|
|
|
31
44
|
cacheWrite5mTokens: completeWrites ? turn.cacheWrite5mTokens : undefined,
|
|
32
45
|
cacheWrite1hTokens: completeWrites ? turn.cacheWrite1hTokens : undefined }, rates).usd;
|
|
33
46
|
}
|
|
47
|
+
/** Left-aligned columns two spaces apart; widths follow the widest cell, so translated labels widen their column. */
|
|
34
48
|
function table(headers, rows) {
|
|
35
49
|
const widths = headers.map((header, i) => Math.max(header.length, ...rows.map(row => row[i]?.length ?? 0)));
|
|
36
50
|
return [headers, ...rows].map(row => row.map((cell, i) => cell.padEnd(widths[i])).join(' ').trimEnd()).join('\n');
|
|
37
51
|
}
|
|
52
|
+
/** Token counts in en-US digits in every language. */
|
|
38
53
|
const count = (n) => n.toLocaleString('en-US');
|
|
54
|
+
exports.count = count;
|
|
39
55
|
/** The table's share column; the tip prints the same figure. */
|
|
40
56
|
const share = (tokens, total) => `${(total ? tokens / total * 100 : 0).toFixed(1)}%`;
|
|
57
|
+
exports.share = share;
|
|
41
58
|
const midpoint = (value) => (value.min + value.max) / 2;
|
|
42
59
|
exports.WHY_TIP_HIDE_LINE = i18n_1.WHY_TEXT.en.hide;
|
|
60
|
+
const median = (values) => {
|
|
61
|
+
if (!values.length)
|
|
62
|
+
return 0;
|
|
63
|
+
const sorted = [...values].sort((a, b) => a - b), middle = Math.floor(sorted.length / 2);
|
|
64
|
+
return sorted.length % 2 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
65
|
+
};
|
|
66
|
+
/** A model id as people say it: claude-opus-5-5 is Opus 5.5 and claude-haiku-4-5-20251001 is Haiku 4.5. Any other id prints as it is. */
|
|
67
|
+
function modelLabel(model) {
|
|
68
|
+
const match = /^claude-(opus|sonnet|haiku|fable)-(\d{1,2})(?:-(\d{1,2}))?(?:-\d{8})?$/.exec(model);
|
|
69
|
+
return match ? `${match[1][0].toUpperCase()}${match[1].slice(1)} ${match[2]}${match[3] ? `.${match[3]}` : ''}` : model;
|
|
70
|
+
}
|
|
71
|
+
/** The model with the most output tokens, then the most responses; null when no response names one. */
|
|
72
|
+
function dominantModel(turns) {
|
|
73
|
+
const byModel = new Map();
|
|
74
|
+
for (const turn of turns) {
|
|
75
|
+
if (!turn.model)
|
|
76
|
+
continue;
|
|
77
|
+
const row = byModel.get(turn.model) ?? { output: 0, responses: 0 };
|
|
78
|
+
row.output += turn.outputTokens;
|
|
79
|
+
row.responses++;
|
|
80
|
+
byModel.set(turn.model, row);
|
|
81
|
+
}
|
|
82
|
+
return [...byModel].sort(([a, x], [b, y]) => y.output - x.output || y.responses - x.responses || (a < b ? -1 : a > b ? 1 : 0))[0]?.[0] ?? null;
|
|
83
|
+
}
|
|
84
|
+
/** A main model with a smaller Claude model below it, the one CLAUDE_CODE_SUBAGENT_MODEL=haiku names. */
|
|
85
|
+
const HAS_SMALLER_MODEL = /^claude-(?:opus|fable|sonnet)-/;
|
|
43
86
|
/**
|
|
44
|
-
*
|
|
45
|
-
* when
|
|
46
|
-
*
|
|
47
|
-
*
|
|
87
|
+
* The coach: one next step, for the largest cause that stands out in this
|
|
88
|
+
* session; null when none does, never a generic line. A cause stands out at the
|
|
89
|
+
* 0.3.16 thresholds: sub-agents at 20% of session tokens, full-prefix rewrites at
|
|
90
|
+
* 15% of the list total (priced sessions only), and the re-read conversation and
|
|
91
|
+
* the setup at 30% of session tokens each. Among those the largest at list price
|
|
92
|
+
* wins (a dollar range at its midpoint), or the largest in tokens when a model is
|
|
93
|
+
* unpriced; a tie keeps that order. Each action is Anthropic's published advice
|
|
94
|
+
* for its cause (code.claude.com/docs/en/costs, /prompt-caching, /sub-agents),
|
|
95
|
+
* and every figure is this session's own. Where the cause has no sharper action,
|
|
96
|
+
* the share tip prints for sub-agents and the 0.3.16 dollars tip for rewrites.
|
|
48
97
|
*/
|
|
49
98
|
function whyTip(input, lang = 'en') {
|
|
50
|
-
const { totalTokens,
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
99
|
+
const { totalTokens, totalUsd } = input, text = i18n_1.WHY_TEXT[lang];
|
|
100
|
+
const priced = totalUsd !== null && midpoint(totalUsd) > 0;
|
|
101
|
+
const tokenShare = (tokens) => totalTokens > 0 ? tokens / totalTokens : 0;
|
|
102
|
+
const { subagents, reloads, conversation, setup } = input;
|
|
103
|
+
const causes = [
|
|
104
|
+
['subagents', tokenShare(subagents.tokens) >= 0.2, subagents],
|
|
105
|
+
['reloads', priced && reloads.usd !== null && midpoint(reloads.usd) / midpoint(totalUsd) >= 0.15, reloads],
|
|
106
|
+
['conversation', tokenShare(conversation.tokens) >= 0.3 && conversation.medianPerCall > 0, conversation],
|
|
107
|
+
['setup', tokenShare(setup.tokens) >= 0.3 && setup.medianPerCall > 0, setup],
|
|
108
|
+
];
|
|
109
|
+
let largest = null;
|
|
110
|
+
for (const [cause, standsOut, { tokens, usd }] of causes) {
|
|
111
|
+
const size = !standsOut ? null : priced ? (usd === null ? null : midpoint(usd)) : tokens;
|
|
112
|
+
if (size !== null && (largest === null || size > largest.size))
|
|
113
|
+
largest = { cause, size };
|
|
114
|
+
}
|
|
115
|
+
switch (largest?.cause) {
|
|
116
|
+
case 'subagents': {
|
|
117
|
+
const { mainModel, onMainModel = 0, onMainModelShare = 0 } = input.subagents;
|
|
118
|
+
return mainModel && onMainModel > 0 && onMainModelShare >= 0.5 && HAS_SMALLER_MODEL.test(mainModel)
|
|
119
|
+
? text.tipSubagentModel(onMainModel, modelLabel(mainModel))
|
|
120
|
+
: text.tipFanout((0, exports.share)(input.subagents.tokens, totalTokens));
|
|
121
|
+
}
|
|
122
|
+
case 'reloads': {
|
|
123
|
+
const { cause, count = 0, longestIdleMs = null } = input.reloads;
|
|
124
|
+
if (cause === 'idle_ttl_expired' && count > 0 && longestIdleMs !== null)
|
|
125
|
+
return text.tipIdleReloads(count, (0, attribution_1.idleLabel)(longestIdleMs));
|
|
126
|
+
if (cause === 'model_switch' && count > 0)
|
|
127
|
+
return text.tipModelSwitch(count);
|
|
128
|
+
return text.tipRewrites((0, live_1.dollars)(input.reloads.usd, text), (0, live_1.dollars)(totalUsd, text));
|
|
129
|
+
}
|
|
130
|
+
case 'conversation': return text.tipConversation((0, stop_text_1.shortTokens)(input.conversation.medianPerCall));
|
|
131
|
+
case 'setup': return text.tipSetup((0, stop_text_1.shortTokens)(input.setup.medianPerCall));
|
|
132
|
+
default: return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* What `whyTip` weighs, from the figures `why` prints. The sub-agent and rewrite
|
|
137
|
+
* rows are the table's own. The setup and the re-read conversation split each
|
|
138
|
+
* main-conversation call's cached reads at the size of the session's first call,
|
|
139
|
+
* so a rewrite that resets the table's fixed-prefix baseline never turns re-read
|
|
140
|
+
* conversation into setup; they are measured, like every row, from recorded usage.
|
|
141
|
+
*/
|
|
142
|
+
function whyTipInput(figures, rates = {}, bucketUsd) {
|
|
143
|
+
const { turns, attribution, totalUsd } = figures;
|
|
144
|
+
const byTurn = new Map(attribution.turnAttributions.map(turn => [turn.turnId, turn]));
|
|
145
|
+
const usdOf = bucketUsd ?? ((bucket) => sumPrices(turns.map(turn => bucketPrice(turn, byTurn.get(turn.id).buckets.find(item => item.bucket === bucket), rates))));
|
|
146
|
+
const tokensOf = (bucket) => attribution.buckets.find(item => item.bucket === bucket).tokens;
|
|
147
|
+
const main = turns.filter(turn => !turn.subagent);
|
|
148
|
+
// Sub-agents on the main conversation's model, and their share of all sub-agent tokens.
|
|
149
|
+
const mainModel = dominantModel(main);
|
|
150
|
+
const children = new Map();
|
|
151
|
+
for (const turn of turns) {
|
|
152
|
+
if (!turn.subagent)
|
|
153
|
+
continue;
|
|
154
|
+
const own = children.get(turn.sessionId);
|
|
155
|
+
if (own)
|
|
156
|
+
own.push(turn);
|
|
157
|
+
else
|
|
158
|
+
children.set(turn.sessionId, [turn]);
|
|
159
|
+
}
|
|
160
|
+
let childTokens = 0, onMainTokens = 0, onMainModel = 0;
|
|
161
|
+
for (const own of children.values()) {
|
|
162
|
+
const tokens = own.reduce((sum, turn) => sum + totalTokens(turn), 0);
|
|
163
|
+
childTokens += tokens;
|
|
164
|
+
if (mainModel !== null && dominantModel(own) === mainModel) {
|
|
165
|
+
onMainModel++;
|
|
166
|
+
onMainTokens += tokens;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// The rewrite cause with the largest cache-write list price, then the most rewrites, then precedence.
|
|
170
|
+
const byId = new Map(turns.map(turn => [turn.id, turn]));
|
|
171
|
+
const causes = new Map();
|
|
172
|
+
for (const rewrite of attribution.rewrites) {
|
|
173
|
+
const turn = byId.get(rewrite.turnId);
|
|
174
|
+
const price = turn ? (0, pricing_1.priceTurn)({ ...turn, inputTokens: 0, cacheReadTokens: 0, outputTokens: 0 }, rates).usd : null;
|
|
175
|
+
const row = causes.get(rewrite.cause) ?? { usd: 0, count: 0, longestIdleMs: null };
|
|
176
|
+
row.usd += price ? midpoint(price) : 0;
|
|
177
|
+
row.count++;
|
|
178
|
+
if (rewrite.idleMs !== undefined)
|
|
179
|
+
row.longestIdleMs = Math.max(row.longestIdleMs ?? 0, rewrite.idleMs);
|
|
180
|
+
causes.set(rewrite.cause, row);
|
|
181
|
+
}
|
|
182
|
+
const [cause, top] = [...causes].sort(([a, x], [b, y]) => y.usd - x.usd || y.count - x.count || types_1.REWRITE_CAUSES.indexOf(a) - types_1.REWRITE_CAUSES.indexOf(b))[0] ?? [null, null];
|
|
183
|
+
// Setup and re-read conversation, split at the first call's context.
|
|
184
|
+
const rewritten = new Set(attribution.rewrites.map(rewrite => rewrite.turnId));
|
|
185
|
+
const baseline = main[0]?.contextTokens ?? 0;
|
|
186
|
+
const setup = { tokens: 0, usd: { min: 0, max: 0 }, perCall: [] };
|
|
187
|
+
const conversation = { tokens: 0, usd: { min: 0, max: 0 }, perCall: [] };
|
|
188
|
+
main.forEach((turn, index) => {
|
|
189
|
+
// The first call's whole context sets the baseline, as the table's first row does.
|
|
190
|
+
const opening = index === 0 && !rewritten.has(turn.id) && !turn.explicitAttribution.length;
|
|
191
|
+
const setupTokens = opening ? turn.inputTokens + turn.cacheWriteTokens + turn.cacheReadTokens : Math.min(turn.cacheReadTokens, baseline);
|
|
192
|
+
const conversationTokens = opening ? 0 : turn.cacheReadTokens - setupTokens;
|
|
193
|
+
const reads = (tokens) => (0, pricing_1.priceTurn)({ ...turn, inputTokens: 0, cacheWriteTokens: 0, cacheWrite5mTokens: undefined, cacheWrite1hTokens: undefined, outputTokens: 0, cacheReadTokens: tokens }, rates).usd;
|
|
194
|
+
setup.tokens += setupTokens;
|
|
195
|
+
setup.perCall.push(setupTokens);
|
|
196
|
+
setup.usd = sumPrices([setup.usd, opening ? (0, pricing_1.priceTurn)({ ...turn, outputTokens: 0 }, rates).usd : reads(setupTokens)]);
|
|
197
|
+
conversation.tokens += conversationTokens;
|
|
198
|
+
conversation.perCall.push(conversationTokens);
|
|
199
|
+
conversation.usd = sumPrices([conversation.usd, reads(conversationTokens)]);
|
|
200
|
+
});
|
|
201
|
+
return { totalTokens: attribution.totalTokens, totalUsd,
|
|
202
|
+
subagents: { tokens: tokensOf('subagent_fanout'), usd: usdOf('subagent_fanout'), mainModel, onMainModel, onMainModelShare: childTokens ? onMainTokens / childTokens : 0 },
|
|
203
|
+
reloads: { tokens: tokensOf('full_prefix_rewrites'), usd: usdOf('full_prefix_rewrites'), cause, count: top?.count ?? 0, longestIdleMs: top?.longestIdleMs ?? null },
|
|
204
|
+
conversation: { tokens: conversation.tokens, usd: conversation.usd, medianPerCall: median(conversation.perCall) },
|
|
205
|
+
setup: { tokens: setup.tokens, usd: setup.usd, medianPerCall: median(setup.perCall) } };
|
|
206
|
+
}
|
|
207
|
+
/** Messages on each side of an event the measured change compares, at most and at least. */
|
|
208
|
+
exports.PROOF_WINDOW = 20;
|
|
209
|
+
exports.PROOF_MINIMUM = 5;
|
|
210
|
+
/**
|
|
211
|
+
* One measured change, around the latest compaction, /clear or model switch the
|
|
212
|
+
* main conversation's transcript records: the median tokens Claude read per
|
|
213
|
+
* message in the N messages after it against the N before it. N is 20, or fewer
|
|
214
|
+
* when the session, or the previous or next such event, leaves fewer on a side;
|
|
215
|
+
* below 5 on either side that event says nothing and an earlier one is tried.
|
|
216
|
+
* It states what was measured next to the event, never a saving and never that
|
|
217
|
+
* the event caused it.
|
|
218
|
+
*/
|
|
219
|
+
function proofLine(turns, lang = 'en') {
|
|
220
|
+
const main = turns.filter(turn => !turn.subagent);
|
|
221
|
+
const events = [];
|
|
222
|
+
main.forEach((turn, index) => {
|
|
223
|
+
if (index === 0)
|
|
224
|
+
return;
|
|
225
|
+
const reset = turn.signals.reset;
|
|
226
|
+
if (reset)
|
|
227
|
+
events.push({ index, at: reset.at ?? turn.at,
|
|
228
|
+
event: { kind: reset.kind === 'clear' ? 'clear' : reset.trigger === 'manual' ? 'compact' : reset.trigger === 'auto' ? 'auto' : 'compaction' } });
|
|
229
|
+
else if (turn.signals.modelChanged && turn.model)
|
|
230
|
+
events.push({ index, at: turn.at, event: { kind: 'model', model: modelLabel(turn.model) } });
|
|
231
|
+
});
|
|
232
|
+
for (let e = events.length - 1; e >= 0; e--) {
|
|
233
|
+
const { index, at, event } = events[e];
|
|
234
|
+
const from = e > 0 ? events[e - 1].index : 0, to = e + 1 < events.length ? events[e + 1].index : main.length;
|
|
235
|
+
const messages = Math.min(exports.PROOF_WINDOW, index - from, to - index);
|
|
236
|
+
if (at === undefined || messages < exports.PROOF_MINIMUM)
|
|
237
|
+
continue;
|
|
238
|
+
const before = median(main.slice(index - messages, index).map(turn => turn.contextTokens));
|
|
239
|
+
const after = median(main.slice(index, index + messages).map(turn => turn.contextTokens));
|
|
240
|
+
const [printedAfter, printedBefore] = [(0, stop_text_1.shortTokens)(after), (0, stop_text_1.shortTokens)(before)];
|
|
241
|
+
const stamp = new Date(at).toISOString();
|
|
242
|
+
return i18n_1.WHY_TEXT[lang].proof(event, { date: stamp.slice(0, 10), time: stamp.slice(11, 16) }, printedAfter, printedBefore, messages, printedAfter === printedBefore ? 'same' : after < before ? 'down' : 'up');
|
|
243
|
+
}
|
|
58
244
|
return null;
|
|
59
245
|
}
|
|
60
246
|
/** `lang` changes words only: every figure, id, command and URL prints as it does in English, and `why json` never passes through here. */
|
|
@@ -67,31 +253,28 @@ function renderWhy(transcript, rates = {}, options = {}) {
|
|
|
67
253
|
text.forkUnavailable,
|
|
68
254
|
table(text.headers, types_1.INSIGHT_BUCKETS.map(bucket => [text.labels[bucket], text.unattributed, text.unattributed, text.unattributed, text.unattributed])),
|
|
69
255
|
].join('\n');
|
|
70
|
-
const turns
|
|
71
|
-
const
|
|
256
|
+
const { turns, attribution, prices, totals, totalUsd } = sessionFigures(transcript, rates);
|
|
257
|
+
const lastAttribution = attribution.turnAttributions.at(-1);
|
|
72
258
|
const byTurn = new Map(attribution.turnAttributions.map(turn => [turn.turnId, turn]));
|
|
73
|
-
const prices = turns.map(turn => (0, pricing_1.priceTurn)(turn, rates));
|
|
74
259
|
const mixedWriteAllocation = turns.some(turn => (turn.cacheWrite5mTokens ?? 0) > 0 && (turn.cacheWrite1hTokens ?? 0) > 0
|
|
75
260
|
&& byTurn.get(turn.id).buckets.some(bucket => bucket.categories.cacheCreation > 0 && bucket.categories.cacheCreation < turn.cacheWriteTokens));
|
|
76
|
-
const totals = { input: 0, write: 0, read: 0, output: 0 };
|
|
77
|
-
turns.forEach(turn => { totals.input += turn.inputTokens; totals.write += turn.cacheWriteTokens; totals.read += turn.cacheReadTokens; totals.output += turn.outputTokens; });
|
|
78
261
|
const bucketTokens = (bucket) => attribution.buckets.find(item => item.bucket === bucket).tokens;
|
|
79
262
|
const bucketUsd = (bucket) => sumPrices(turns.map(turn => bucketPrice(turn, byTurn.get(turn.id).buckets.find(item => item.bucket === bucket), rates)));
|
|
80
|
-
const totalUsd = sumPrices(prices.map(price => price.usd));
|
|
81
263
|
const rows = types_1.INSIGHT_BUCKETS.map(bucket => {
|
|
82
264
|
const tokens = bucketTokens(bucket), lastTokens = lastAttribution?.buckets.find(item => item.bucket === bucket).tokens ?? 0;
|
|
83
|
-
return [text.labels[bucket], count(tokens), money(bucketUsd(bucket)), share(tokens, attribution.totalTokens), share(lastTokens, lastAttribution?.totalTokens ?? 0)];
|
|
265
|
+
return [text.labels[bucket], (0, exports.count)(tokens), money(bucketUsd(bucket)), (0, exports.share)(tokens, attribution.totalTokens), (0, exports.share)(lastTokens, lastAttribution?.totalTokens ?? 0)];
|
|
84
266
|
});
|
|
85
267
|
const unknownModels = [...new Set(prices.filter(price => price.usd === null).map(price => price.model ?? text.missingModel))];
|
|
86
|
-
const tip = options.tips ? whyTip({
|
|
87
|
-
|
|
268
|
+
const tip = options.tips ? whyTip(whyTipInput({ turns, attribution, totalUsd }, rates, bucketUsd), lang) : null;
|
|
269
|
+
// A measurement, not a tip: it prints whether or not tips are on.
|
|
270
|
+
const proof = proofLine(turns, lang);
|
|
88
271
|
return [
|
|
89
272
|
`AgentGuard why: ${transcript.sessionId}`,
|
|
90
|
-
text.summary(turns.length, count(attribution.totalTokens), totalUsd === null ? null : money(totalUsd)),
|
|
91
|
-
text.usage(count(totals.input), count(totals.write), count(totals.read), count(totals.output)),
|
|
273
|
+
text.summary(turns.length, (0, exports.count)(attribution.totalTokens), totalUsd === null ? null : money(totalUsd)),
|
|
274
|
+
text.usage((0, exports.count)(totals.input), (0, exports.count)(totals.write), (0, exports.count)(totals.read), (0, exports.count)(totals.output)),
|
|
92
275
|
'', table(text.headers, rows), '',
|
|
93
276
|
text.shares,
|
|
94
|
-
text.increments(attribution.sharedTurns, attribution.prefixRebaselines, count(attribution.previousOutputTokensReserved)),
|
|
277
|
+
text.increments(attribution.sharedTurns, attribution.prefixRebaselines, (0, exports.count)(attribution.previousOutputTokensReserved)),
|
|
95
278
|
text.observed(transcript.observations),
|
|
96
279
|
'', text.methodTitle,
|
|
97
280
|
...types_1.INSIGHT_BUCKETS.map(bucket => `${text.labels[bucket]}: ${text.method[bucket]}`),
|
|
@@ -100,6 +283,7 @@ function renderWhy(transcript, rates = {}, options = {}) {
|
|
|
100
283
|
...(prices.some(price => price.unknownCacheWriteTokens > 0) ? [text.missingTtl] : []),
|
|
101
284
|
...(mixedWriteAllocation ? [text.mixedRanges] : []),
|
|
102
285
|
text.diagnostics(transcript.diagnostics.duplicateUsageRecords, transcript.diagnostics.malformedLines),
|
|
286
|
+
...(proof ? ['', proof] : []),
|
|
103
287
|
...(tip ? ['', tip, text.hide] : []),
|
|
104
288
|
].join('\n');
|
|
105
289
|
}
|
|
@@ -145,15 +329,15 @@ function renderRewrites(transcripts, rates = {}) {
|
|
|
145
329
|
for (const session of report.sessions) {
|
|
146
330
|
const groups = new Map();
|
|
147
331
|
session.records.forEach(record => {
|
|
148
|
-
detail.push([stamp(record.at), session.sessionId, session.host, record.model ?? 'unknown', record.cause, idle(record.idleMs), count(record.cacheWriteTokens), (0, live_1.dollars)(record.usd), record.explanation]);
|
|
332
|
+
detail.push([stamp(record.at), session.sessionId, session.host, record.model ?? 'unknown', record.cause, idle(record.idleMs), (0, exports.count)(record.cacheWriteTokens), (0, live_1.dollars)(record.usd), record.explanation]);
|
|
149
333
|
groups.set(record.cause, [...groups.get(record.cause) ?? [], record]);
|
|
150
334
|
totals.set(record.cause, [...totals.get(record.cause) ?? [], record]);
|
|
151
335
|
});
|
|
152
336
|
for (const [cause, records] of groups)
|
|
153
|
-
summary.push([session.sessionId, cause, String(records.length), count(records.reduce((sum, record) => sum + record.cacheWriteTokens, 0)), (0, live_1.dollars)(sumPrices(records.map(record => record.usd)))]);
|
|
337
|
+
summary.push([session.sessionId, cause, String(records.length), (0, exports.count)(records.reduce((sum, record) => sum + record.cacheWriteTokens, 0)), (0, live_1.dollars)(sumPrices(records.map(record => record.usd)))]);
|
|
154
338
|
}
|
|
155
339
|
for (const [cause, records] of totals)
|
|
156
|
-
summary.push(['ALL', cause, String(records.length), count(records.reduce((sum, record) => sum + record.cacheWriteTokens, 0)), (0, live_1.dollars)(sumPrices(records.map(record => record.usd)))]);
|
|
340
|
+
summary.push(['ALL', cause, String(records.length), (0, exports.count)(records.reduce((sum, record) => sum + record.cacheWriteTokens, 0)), (0, live_1.dollars)(sumPrices(records.map(record => record.usd)))]);
|
|
157
341
|
const sessions = report.sessions.length === 1 ? 'session' : 'combined session';
|
|
158
342
|
const share = report.usd && report.sessionUsd && report.shareOfSessionUsd !== null
|
|
159
343
|
? `Rewrites: ${(0, live_1.dollars)(report.usd)}, ${(report.shareOfSessionUsd * 100).toFixed(1)}% of the ${sessions} list total ${(0, live_1.dollars)(report.sessionUsd)} (API list equivalent, not a bill).`
|
|
@@ -4,11 +4,36 @@ export interface TranscriptLocation {
|
|
|
4
4
|
sessionId: string;
|
|
5
5
|
modifiedAt: number;
|
|
6
6
|
}
|
|
7
|
+
/** Claude Code keeps one directory per project here, each session a JSONL file directly inside it; Codex keeps dated rollouts. */
|
|
8
|
+
export declare function transcriptRoots(): {
|
|
9
|
+
claude: string;
|
|
10
|
+
codex: string;
|
|
11
|
+
};
|
|
7
12
|
/** Local locators only. Never follows directory symlinks or reads message content. */
|
|
8
13
|
export declare function discoverInsightTranscripts(roots?: {
|
|
9
14
|
claude: string;
|
|
10
15
|
codex: string;
|
|
11
16
|
}): TranscriptLocation[];
|
|
12
17
|
export declare function selectInsightTranscript(session?: string, locations?: TranscriptLocation[]): TranscriptLocation;
|
|
18
|
+
/**
|
|
19
|
+
* A file Claude Code keeps inside a session's own directory, such as
|
|
20
|
+
* `<session>/skill-injections.jsonl`. It is not a session, so a no-argument
|
|
21
|
+
* `why` must not pick it even when it is the newest file on disk.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSessionSidecar(location: Pick<TranscriptLocation, 'path' | 'sessionId'>): boolean;
|
|
13
24
|
/** Claude Code stores each subagent's transcript beside its parent under `subagents/`. */
|
|
14
25
|
export declare function isSubagentTranscript(location: Pick<TranscriptLocation, 'path' | 'sessionId'>): boolean;
|
|
26
|
+
export interface TranscriptOrigin {
|
|
27
|
+
/** The working directory the host recorded as the session began; null when the first megabyte records none. */
|
|
28
|
+
workingDirectory: string | null;
|
|
29
|
+
/** The usage parser's verdict on those same first records: a spawned sub-agent (Codex session_meta, Claude sidechain). */
|
|
30
|
+
spawned: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Where a transcript ran, from its first complete records only: the working
|
|
34
|
+
* directory the host recorded (Claude Code writes `cwd` on its records, Codex on
|
|
35
|
+
* its session_meta and turn_context payloads) and whether the usage parser marks
|
|
36
|
+
* those records a spawned sub-agent. Reads at most one megabyte, stops at the
|
|
37
|
+
* first recorded directory and keeps no other field.
|
|
38
|
+
*/
|
|
39
|
+
export declare function transcriptOrigin(location: Pick<TranscriptLocation, 'path' | 'host'>): TranscriptOrigin;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transcriptRoots = transcriptRoots;
|
|
3
4
|
exports.discoverInsightTranscripts = discoverInsightTranscripts;
|
|
4
5
|
exports.selectInsightTranscript = selectInsightTranscript;
|
|
6
|
+
exports.isSessionSidecar = isSessionSidecar;
|
|
5
7
|
exports.isSubagentTranscript = isSubagentTranscript;
|
|
8
|
+
exports.transcriptOrigin = transcriptOrigin;
|
|
6
9
|
const node_fs_1 = require("node:fs");
|
|
7
10
|
const node_path_1 = require("node:path");
|
|
8
11
|
const node_os_1 = require("node:os");
|
|
12
|
+
const transcript_1 = require("./transcript");
|
|
13
|
+
/** Claude Code keeps one directory per project here, each session a JSONL file directly inside it; Codex keeps dated rollouts. */
|
|
14
|
+
function transcriptRoots() {
|
|
15
|
+
return { claude: (0, node_path_1.join)((0, node_os_1.homedir)(), '.claude', 'projects'), codex: (0, node_path_1.join)((0, node_os_1.homedir)(), '.codex', 'sessions') };
|
|
16
|
+
}
|
|
9
17
|
/** Local locators only. Never follows directory symlinks or reads message content. */
|
|
10
|
-
function discoverInsightTranscripts(roots = {
|
|
11
|
-
claude: (0, node_path_1.join)((0, node_os_1.homedir)(), '.claude', 'projects'),
|
|
12
|
-
codex: (0, node_path_1.join)((0, node_os_1.homedir)(), '.codex', 'sessions'),
|
|
13
|
-
}) {
|
|
18
|
+
function discoverInsightTranscripts(roots = transcriptRoots()) {
|
|
14
19
|
const found = [];
|
|
15
20
|
function visit(directory, host, depth) {
|
|
16
21
|
if (depth > 8)
|
|
@@ -51,12 +56,74 @@ function selectInsightTranscript(session, locations) {
|
|
|
51
56
|
// nothing else, which tells the operator nothing. It stays reachable by id.
|
|
52
57
|
const selected = requested
|
|
53
58
|
? candidates.find(item => item.sessionId === requested || item.sessionId.endsWith(`-${requested}`))
|
|
54
|
-
: candidates.find(item => !isSubagentTranscript(item)) ?? candidates[0];
|
|
59
|
+
: candidates.find(item => !isSubagentTranscript(item) && !isSessionSidecar(item)) ?? candidates[0];
|
|
55
60
|
if (!selected)
|
|
56
61
|
throw new Error(requested ? 'Session transcript not found. Pass its local JSONL path.' : 'No local Claude Code or Codex transcript found.');
|
|
57
62
|
return selected;
|
|
58
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* A file Claude Code keeps inside a session's own directory, such as
|
|
66
|
+
* `<session>/skill-injections.jsonl`. It is not a session, so a no-argument
|
|
67
|
+
* `why` must not pick it even when it is the newest file on disk.
|
|
68
|
+
*/
|
|
69
|
+
function isSessionSidecar(location) {
|
|
70
|
+
return location.sessionId === 'skill-injections'
|
|
71
|
+
|| /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test((0, node_path_1.basename)((0, node_path_1.dirname)(location.path)));
|
|
72
|
+
}
|
|
59
73
|
/** Claude Code stores each subagent's transcript beside its parent under `subagents/`. */
|
|
60
74
|
function isSubagentTranscript(location) {
|
|
61
75
|
return (0, node_path_1.basename)((0, node_path_1.dirname)(location.path)) === 'subagents' || location.sessionId.startsWith('agent-');
|
|
62
76
|
}
|
|
77
|
+
const ORIGIN_CHUNK_BYTES = 64 * 1024, ORIGIN_LIMIT_BYTES = 1024 * 1024;
|
|
78
|
+
/**
|
|
79
|
+
* Where a transcript ran, from its first complete records only: the working
|
|
80
|
+
* directory the host recorded (Claude Code writes `cwd` on its records, Codex on
|
|
81
|
+
* its session_meta and turn_context payloads) and whether the usage parser marks
|
|
82
|
+
* those records a spawned sub-agent. Reads at most one megabyte, stops at the
|
|
83
|
+
* first recorded directory and keeps no other field.
|
|
84
|
+
*/
|
|
85
|
+
function transcriptOrigin(location) {
|
|
86
|
+
const lines = [];
|
|
87
|
+
let workingDirectory = null, fd;
|
|
88
|
+
try {
|
|
89
|
+
fd = (0, node_fs_1.openSync)(location.path, 'r');
|
|
90
|
+
let pending = Buffer.alloc(0), offset = 0;
|
|
91
|
+
while (workingDirectory === null && offset < ORIGIN_LIMIT_BYTES) {
|
|
92
|
+
const chunk = Buffer.alloc(Math.min(ORIGIN_CHUNK_BYTES, ORIGIN_LIMIT_BYTES - offset));
|
|
93
|
+
const read = (0, node_fs_1.readSync)(fd, chunk, 0, chunk.length, offset);
|
|
94
|
+
if (!read)
|
|
95
|
+
break;
|
|
96
|
+
offset += read;
|
|
97
|
+
pending = Buffer.concat([pending, chunk.subarray(0, read)]);
|
|
98
|
+
for (let newline = pending.indexOf(10); workingDirectory === null && newline >= 0; newline = pending.indexOf(10)) {
|
|
99
|
+
const line = pending.subarray(0, newline).toString('utf8');
|
|
100
|
+
pending = pending.subarray(newline + 1);
|
|
101
|
+
if (!line.trim())
|
|
102
|
+
continue;
|
|
103
|
+
lines.push(line);
|
|
104
|
+
workingDirectory = recordedDirectory(line);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch { /* unreadable or removed: nothing is recorded */ }
|
|
109
|
+
finally {
|
|
110
|
+
if (fd !== undefined)
|
|
111
|
+
(0, node_fs_1.closeSync)(fd);
|
|
112
|
+
}
|
|
113
|
+
return { workingDirectory, spawned: lines.length > 0 && (0, transcript_1.parseInsightTranscript)(`${lines.join('\n')}\n`, { host: location.host }).state.spawnedSession };
|
|
114
|
+
}
|
|
115
|
+
function recordedDirectory(line) {
|
|
116
|
+
let value;
|
|
117
|
+
try {
|
|
118
|
+
value = JSON.parse(line);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (!value || typeof value !== 'object')
|
|
124
|
+
return null;
|
|
125
|
+
const record = value;
|
|
126
|
+
const payload = record.payload && typeof record.payload === 'object' ? record.payload : {};
|
|
127
|
+
const cwd = typeof record.cwd === 'string' ? record.cwd : record.type === 'session_meta' || record.type === 'turn_context' ? payload.cwd : undefined;
|
|
128
|
+
return typeof cwd === 'string' && cwd.length > 0 ? cwd : null;
|
|
129
|
+
}
|
|
@@ -7,8 +7,19 @@ export declare const providerResponseIdentity: (host: InsightHost, id: unknown)
|
|
|
7
7
|
* to previous totals because an assistant message can gain output usage later.
|
|
8
8
|
*/
|
|
9
9
|
export declare function parseInsightTranscript(text: string, options?: InsightParseOptions): InsightTranscript;
|
|
10
|
-
|
|
10
|
+
/** How a transcript file is read, never how it is parsed. */
|
|
11
|
+
export interface InsightReadOptions {
|
|
12
|
+
/**
|
|
13
|
+
* A file larger than this many bytes is read in pieces cut at line ends, each
|
|
14
|
+
* parsed with the parser state the previous piece returned, so no single string
|
|
15
|
+
* holds the whole file (V8 cannot hold a string past about 512 MB). The turns,
|
|
16
|
+
* observations and summed diagnostics equal a whole-file parse. Unset reads the
|
|
17
|
+
* whole file at once, as `why` does.
|
|
18
|
+
*/
|
|
19
|
+
chunkBytes?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function readInsightTranscript(filename: string, options?: InsightParseOptions, read?: InsightReadOptions): InsightTranscript;
|
|
11
22
|
/** Read one Claude session plus its explicitly stored child transcripts. */
|
|
12
|
-
export declare function readInsightSession(filename: string, options?: InsightParseOptions): InsightTranscript;
|
|
23
|
+
export declare function readInsightSession(filename: string, options?: InsightParseOptions, read?: InsightReadOptions): InsightTranscript;
|
|
13
24
|
/** Forked transcript copies can repeat provider response ids across files. */
|
|
14
25
|
export declare function deduplicateTurns(turns: InsightTurn[]): InsightTurn[];
|