/** * Turning transformation records into something a person reads. * * WHAT THIS IS FOR. The proxy has always known, to the byte, what it removed * from every request and what the provider then billed for it. Until now that * knowledge went either nowhere or into a JSONL ledger two benchmark scripts * read. The question an operator actually has -- "is this thing doing anything, * and if not, why not" -- had no answer short of reading the source. * * THE `reason` COLUMN IS THE POINT, not the percentage. A request that was not * compressed is the interesting case: the percentages answer "how much", and * `reason` answers "why not", which is the question someone asks when the * number disappoints them. So an uncompressed row spends its widest column on * the refusal rather than printing a zero and leaving the reader to guess. */ import type { AccountingRecord } from '../proxy/accounting.js'; /** Byte counts rendered the way a reader compares them: same unit, aligned. */ export declare function formatBytes(bytes: number): string; /** * Character counts, which are NOT byte counts and must not be printed as if * they were. * * `injectedChars`, `deferredToolChars`, `systemChars`, `toolsChars` and * `messagesChars` are `String.length` -- UTF-16 code units -- taken before the * body is serialised. For the ASCII-dominant JSON a model request mostly is, * one unit happens to be one byte, which is exactly why rendering them as `KB` * passes a casual read and is still wrong: a request carrying CJK text or * emoji would have the label overstate the bytes by up to three times. The * unit is named instead of converted, because the conversion is not available * here and guessing it would be the inaccuracy, not the fix. */ export declare function formatChars(chars: number): string; /** Thousands separators, because these numbers are read, not summed by hand. */ export declare function formatCount(value: number | undefined): string; /** * The change in size, signed from the request's point of view. * * NEGATIVE MEANS SMALLER, which is the convention the rest of this repository's * measurements use: a saving reads as -68.9%, and a request the knowledge block * made bigger reads as +4.2% rather than as a saving of minus four percent. */ export declare function formatDelta(before: number, after: number): string; /** The clock time, which is all a reader needs to line a row up with a turn. */ export declare function formatTime(ts: string): string; /** * The short note that goes in the last column. * * Only what fired, never a list of zeroes. A row reading `0 elisions, 0 tools * deferred, 0 injected` tells a reader nothing they could not see from the * percentage, and three of them stacked hide the one row that says something. */ export declare function notesFor(record: AccountingRecord): string; /** The columns of the default view, in order. */ export declare const COLUMNS: readonly ["time", "path", "code", "before", "after", "change", "saved", "billed", "cached", "out", "notes"]; /** Every field of one record, for the reader who needs the one not in a column. */ export declare function detailFor(record: AccountingRecord): readonly string[]; /** What a window of records adds up to. */ export interface TransformationTotals { readonly requests: number; readonly compressed: number; readonly beforeBytes: number; readonly afterBytes: number; readonly inputTokens: number; readonly cachedTokens: number; readonly outputTokens: number; /** Tokens not spent, summed over the requests that were actually counted. */ readonly savedTokens: number; /** * How many requests contributed to `savedTokens`. * * REPORTED BESIDE THE TOTAL BECAUSE THE TOTAL IS MEANINGLESS WITHOUT IT. A * saving summed over three of two hundred requests is not a saving over two * hundred requests, and printing only the figure would invite exactly that * reading -- which is the mistake the live analytics ledger had already made * once, pricing a whole week from the five rows that happened to carry a * model id. */ readonly countedRequests: number; } /** * Totals across the window. * * COUNTED OVER EVERY RECORD, including the ones that were not compressed. A * ratio taken only over the compressed requests answers "how well does the * compressor do when it runs", which flatters it; the question being asked * here is "what is this saving me", and a request that was skipped saved * nothing and still cost its bytes. */ export declare function totalsFor(records: readonly AccountingRecord[]): TransformationTotals; /** The table, header included, as lines with no trailing newline. */ export declare function renderTransformations(records: readonly AccountingRecord[], options?: { readonly full?: boolean; }): readonly string[]; //# sourceMappingURL=render.d.ts.map