/** * Reading the durable side: an accounting ledger written by the proxy. * * WHY BOTH THIS AND THE LIVE RING. The ring in `proxy/transformations.ts` * answers "what just happened" with no configuration at all, and loses * everything when the proxy stops. The ledger answers "what happened on * Tuesday" but only for an operator who set `TOKEN_OPTIMIZER_PROXY_ACCOUNTING` * before Tuesday. Neither is a substitute for the other, so `inspect` reads * whichever the caller asks for. * * STREAMED, NOT SLURPED, AND BOUNDED. A ledger accumulates one line per * request for as long as it is configured, which in a long-lived session is * megabytes. Reading it whole to show the last ten records would make the * diagnostic the most expensive thing in the session, so this streams and keeps * a ring of the last `last` parsed records. * * A TORN OR FOREIGN LINE IS SKIPPED, NOT FATAL. `appendRecord` writes * synchronously precisely so lines are whole, but a ledger can also be * truncated by a disk filling or concatenated by hand, and refusing to show * nine good records because the tenth is half-written would be the wrong * trade. The count of skipped lines is returned so the reader is told. */ import type { AccountingRecord } from '../proxy/accounting.js'; /** What a ledger read found, including what it could not parse. */ export interface LedgerRead { readonly records: readonly AccountingRecord[]; readonly skipped: number; } /** * Whether a parsed line is a record rather than some other JSON. * * CHECKS THE FIELDS A RENDERER DEREFERENCES, not every field of the interface. * The optional ones are optional in the type too, and demanding them would * reject a record written by an older version of this package over a field * that had not been added yet -- which is exactly the ledger a reader is most * likely to be looking at when something went wrong. */ export declare function looksLikeRecord(value: unknown): value is AccountingRecord; /** The last `last` records of a JSONL ledger, oldest first. */ export declare function readLedger(path: string, last?: number): Promise; //# sourceMappingURL=ledger.d.ts.map