@relayburn/sdk 1.9.0 → 2.0.0
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 +27 -29
- package/README.md +27 -34
- package/package.json +46 -17
- package/src/binding.cjs +91 -0
- package/src/binding.d.ts +21 -0
- package/src/index.cjs +68 -0
- package/src/index.d.ts +422 -0
- package/src/index.js +144 -0
- package/index.d.ts +0 -234
- package/index.js +0 -630
package/index.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
export interface LedgerOpenOptions { home?: string }
|
|
2
|
-
export declare class Ledger { static open(opts?: LedgerOpenOptions): Promise<Ledger> }
|
|
3
|
-
|
|
4
|
-
export interface IngestOptions { sessionId?: string; harness?: 'claude-code'|'codex'|'opencode'; ledgerHome?: string }
|
|
5
|
-
export declare function ingest(opts?: IngestOptions): Promise<unknown>
|
|
6
|
-
|
|
7
|
-
export interface SummaryOptions {
|
|
8
|
-
session?: string;
|
|
9
|
-
project?: string;
|
|
10
|
-
/** ISO timestamp (e.g. `2026-04-01T00:00:00Z`) or relative range (`24h`, `7d`, `4w`, `2m`). */
|
|
11
|
-
since?: string;
|
|
12
|
-
ledgerHome?: string;
|
|
13
|
-
/** Optional logger invoked when the SQLite archive read fails and the SDK falls back to a full ledger walk. */
|
|
14
|
-
onLog?: (msg: string) => void;
|
|
15
|
-
}
|
|
16
|
-
export declare function summary(opts?: SummaryOptions): Promise<{
|
|
17
|
-
totalTokens: number;
|
|
18
|
-
totalCost: number;
|
|
19
|
-
turnCount: number;
|
|
20
|
-
byTool: Array<{ tool: string; tokens: number; cost: number; count: number }>;
|
|
21
|
-
byModel: Array<{ model: string; tokens: number; cost: number }>;
|
|
22
|
-
}>
|
|
23
|
-
|
|
24
|
-
export interface SessionCostOptions {
|
|
25
|
-
/** Session id to total. Omit for `{ note: 'no session id provided' }`. */
|
|
26
|
-
session?: string;
|
|
27
|
-
ledgerHome?: string;
|
|
28
|
-
onLog?: (msg: string) => void;
|
|
29
|
-
}
|
|
30
|
-
export interface SessionCostResult {
|
|
31
|
-
sessionId: string | null;
|
|
32
|
-
totalUSD: number;
|
|
33
|
-
totalTokens: number;
|
|
34
|
-
turnCount: number;
|
|
35
|
-
models: string[];
|
|
36
|
-
note?: string;
|
|
37
|
-
}
|
|
38
|
-
/** Compact session-scoped cost shape; powers the MCP `burn__sessionCost` tool. */
|
|
39
|
-
export declare function sessionCost(opts?: SessionCostOptions): Promise<SessionCostResult>
|
|
40
|
-
|
|
41
|
-
export type OverheadFileKind = 'claude-md' | 'agents-md';
|
|
42
|
-
export type OverheadHarness = 'claude-code' | 'codex' | 'opencode';
|
|
43
|
-
|
|
44
|
-
export interface OverheadOptions {
|
|
45
|
-
/** Project path to inspect; defaults to process.cwd(). */
|
|
46
|
-
project?: string;
|
|
47
|
-
/** ISO timestamp or relative range (`24h`, `7d`, `4w`, `2m`); the SDK normalizes both forms before querying. */
|
|
48
|
-
since?: string;
|
|
49
|
-
/** Narrow to a single overhead file kind. */
|
|
50
|
-
kind?: OverheadFileKind;
|
|
51
|
-
ledgerHome?: string;
|
|
52
|
-
onLog?: (msg: string) => void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface OverheadSection {
|
|
56
|
-
heading: string;
|
|
57
|
-
startLine: number;
|
|
58
|
-
endLine: number;
|
|
59
|
-
tokens: number;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface OverheadSectionCost {
|
|
63
|
-
filePath: string;
|
|
64
|
-
section: OverheadSection;
|
|
65
|
-
tokenShare: number;
|
|
66
|
-
costPerSession: number;
|
|
67
|
-
totalCost: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface OverheadAttributionDetail {
|
|
71
|
-
sessionCount: number;
|
|
72
|
-
perSessionAvg: number;
|
|
73
|
-
perSessionP95: number;
|
|
74
|
-
totalCost: number;
|
|
75
|
-
sectionCosts: OverheadSectionCost[];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface OverheadFileSummary {
|
|
79
|
-
kind: OverheadFileKind;
|
|
80
|
-
path: string;
|
|
81
|
-
appliesTo: OverheadHarness[];
|
|
82
|
-
totalLines: number;
|
|
83
|
-
bytes: number;
|
|
84
|
-
tokens: number;
|
|
85
|
-
sections: OverheadSection[];
|
|
86
|
-
groupingLevel: number;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface OverheadPerFileEntry {
|
|
90
|
-
path: string;
|
|
91
|
-
kind: OverheadFileKind;
|
|
92
|
-
appliesTo: OverheadHarness[];
|
|
93
|
-
attribution: OverheadAttributionDetail;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface OverheadResult {
|
|
97
|
-
project: string;
|
|
98
|
-
files: OverheadFileSummary[];
|
|
99
|
-
perFile: OverheadPerFileEntry[];
|
|
100
|
-
grandTotal: number;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Per-file + per-section overhead cost attribution. Powers `burn overhead`. */
|
|
104
|
-
export declare function overhead(opts?: OverheadOptions): Promise<OverheadResult>
|
|
105
|
-
|
|
106
|
-
export interface OverheadTrimOptions extends OverheadOptions {
|
|
107
|
-
/** Recommendations per file. Default 3. */
|
|
108
|
-
top?: number;
|
|
109
|
-
/** Include the unified-diff text per recommendation (requires a file read per recommended file). Default true; pass false to skip. */
|
|
110
|
-
includeDiff?: boolean;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface OverheadTrimRecommendation {
|
|
114
|
-
file: string;
|
|
115
|
-
kind: OverheadFileKind;
|
|
116
|
-
appliesTo: OverheadHarness[];
|
|
117
|
-
section: { heading: string; startLine: number; endLine: number; tokens: number };
|
|
118
|
-
projectedSavings: {
|
|
119
|
-
perSessionUsd: number;
|
|
120
|
-
acrossWindowUsd: number;
|
|
121
|
-
tokens: number;
|
|
122
|
-
tokenShare: number;
|
|
123
|
-
};
|
|
124
|
-
diff?: string;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface OverheadTrimResult {
|
|
128
|
-
project: string;
|
|
129
|
-
since: string;
|
|
130
|
-
recommendations: OverheadTrimRecommendation[];
|
|
131
|
-
summary: {
|
|
132
|
-
filesAnalyzed: number;
|
|
133
|
-
filesWithRecommendations: number;
|
|
134
|
-
totalRecommendations: number;
|
|
135
|
-
totalProjectedSavingsPerSession: number;
|
|
136
|
-
totalProjectedSavingsAcrossWindow: number;
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Trim recommendations for high-cost overhead-file sections. Powers `burn overhead trim`. */
|
|
141
|
-
export declare function overheadTrim(opts?: OverheadTrimOptions): Promise<OverheadTrimResult>
|
|
142
|
-
|
|
143
|
-
export interface HotspotsOptions {
|
|
144
|
-
session?: string;
|
|
145
|
-
/**
|
|
146
|
-
* Pattern kinds to detect. Supported kinds:
|
|
147
|
-
* - core (via `detectPatterns`): `retry-loop`, `failure-run`,
|
|
148
|
-
* `cancellation-run`, `compaction-loss`, `edit-revert`, `edit-heavy`,
|
|
149
|
-
* `skill-recall-dup`, `skill-pruning-protection`, `system-prompt-tax`
|
|
150
|
-
* - side-channel: `tool-output-bloat`, `ghost-surface`, `tool-call-pattern`
|
|
151
|
-
*
|
|
152
|
-
* When omitted or empty, returns the attribution result instead of a
|
|
153
|
-
* findings array.
|
|
154
|
-
*/
|
|
155
|
-
patterns?: string[];
|
|
156
|
-
ledgerHome?: string;
|
|
157
|
-
}
|
|
158
|
-
export declare function hotspots(opts?: HotspotsOptions): Promise<unknown>
|
|
159
|
-
|
|
160
|
-
export type FidelityClass = 'full' | 'usage-only' | 'aggregate-only' | 'cost-only' | 'partial';
|
|
161
|
-
|
|
162
|
-
export interface FidelitySummaryShape {
|
|
163
|
-
total: number;
|
|
164
|
-
byClass: Record<FidelityClass, number>;
|
|
165
|
-
unknown: number;
|
|
166
|
-
missingCoverage: Record<string, number>;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface CompareExcludedBreakdown {
|
|
170
|
-
total: number;
|
|
171
|
-
aggregateOnly: number;
|
|
172
|
-
costOnly: number;
|
|
173
|
-
partial: number;
|
|
174
|
-
usageOnly: number;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface CompareCellResult {
|
|
178
|
-
model: string;
|
|
179
|
-
category: string;
|
|
180
|
-
turns: number;
|
|
181
|
-
editTurns: number;
|
|
182
|
-
oneShotTurns: number;
|
|
183
|
-
pricedTurns: number;
|
|
184
|
-
totalCost: number;
|
|
185
|
-
costPerTurn: number | null;
|
|
186
|
-
oneShotRate: number | null;
|
|
187
|
-
cacheHitRate: number | null;
|
|
188
|
-
medianRetries: number | null;
|
|
189
|
-
noData: boolean;
|
|
190
|
-
insufficientSample: boolean;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export interface CompareOptions {
|
|
194
|
-
/** Required: ≥2 model names to compare. */
|
|
195
|
-
models: string[];
|
|
196
|
-
session?: string;
|
|
197
|
-
project?: string;
|
|
198
|
-
/** ISO timestamp (e.g. `2026-04-01T00:00:00Z`) or relative range (`24h`, `7d`, `4w`, `2m`). */
|
|
199
|
-
since?: string;
|
|
200
|
-
workflow?: string;
|
|
201
|
-
agent?: string;
|
|
202
|
-
/** Resolved provider filter (e.g. `['anthropic', 'synthetic']`). */
|
|
203
|
-
provider?: string[];
|
|
204
|
-
/** Insufficient-sample threshold; cells below this get flagged. Default 5. */
|
|
205
|
-
minSample?: number;
|
|
206
|
-
/** Minimum fidelity class to include in the aggregate. Default `'usage-only'`. */
|
|
207
|
-
minFidelity?: FidelityClass;
|
|
208
|
-
ledgerHome?: string;
|
|
209
|
-
onLog?: (msg: string) => void;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface CompareResult {
|
|
213
|
-
analyzedTurns: number;
|
|
214
|
-
minSample: number;
|
|
215
|
-
models: string[];
|
|
216
|
-
categories: string[];
|
|
217
|
-
totals: Record<string, { turns: number; totalCost: number }>;
|
|
218
|
-
cells: CompareCellResult[];
|
|
219
|
-
fidelity: {
|
|
220
|
-
minimum: FidelityClass;
|
|
221
|
-
excluded: CompareExcludedBreakdown;
|
|
222
|
-
summary: FidelitySummaryShape;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Per-(model, activity) comparison shape. Powers `burn compare` and the
|
|
228
|
-
* future `burn__compare` MCP tool. Reads through the SQLite archive when
|
|
229
|
-
* `minFidelity === 'partial'` and no provider filter is set; otherwise
|
|
230
|
-
* walks the ledger so the fidelity gate / provider filter can be applied
|
|
231
|
-
* per-turn. Falls back transparently to the ledger walk when the archive
|
|
232
|
-
* read fails.
|
|
233
|
-
*/
|
|
234
|
-
export declare function compare(opts: CompareOptions): Promise<CompareResult>
|