/** * `token-optimizer-inspect` -- what did the proxy do to my last few requests? * * WHY THIS EXISTS. Every number this command prints was already being computed * on the request path, in full, for every request: `AccountingRecord` carries * the bytes before and after, the elisions, the deferred tools, the injected * knowledge and the provider's own billed token counts. It was built only when * an environment variable named a ledger file, and the only two things in the * repository that ever read that file are benchmark scripts. So the proxy could * tell you exactly what it had saved you, and there was no way to ask. * * READS NOTHING IT SHOULD NOT. The live window holds counts, durations, * statuses, fixed-vocabulary reasons and tool names -- no message, no system * prompt, no tool body, no response text. See the header of * `proxy/transformations.ts` for why that distinction is load-bearing: it is * what lets this be on by default instead of opt-in like `proxy/capture.ts`. * * TWO SOURCES, DELIBERATELY. With no arguments it asks the running supervisor, * which needs no setup and is what someone wants ten seconds after a turn felt * expensive. With `--ledger ` it reads a JSONL accounting ledger, which * survives a restart but only exists if it was configured in advance. Offering * only the second would have made the common question the harder one to ask. */ import { type TransformationWindow } from '../proxy/supervisor.js'; import { type LedgerRead } from './ledger.js'; import { type AuditReport } from './audit.js'; /** What the command was asked to show. */ export interface Options { readonly last: number; readonly port: number | null; readonly ledger: string | null; readonly full: boolean; readonly json: boolean; readonly help: boolean; /** * A capture directory to check the ledger against, or null for the normal * per-request view. * * A SECOND QUESTION, NOT A SECOND FORMAT. Every other flag here changes how * the records are shown; this one asks whether the records are right, which * is why it has its own rendering and its own exit status. */ readonly audit: string | null; } /** * Parses argv, or returns the refusal to print. * * A STRING IS A REFUSAL, which is the shape the other bins in this package use: * it keeps the parser pure and total, so every bad input is a value a test can * assert on rather than an exception or a process exit. */ export declare function parseArguments(args: readonly string[]): Options | string; /** * The outside world, injectable. * * The supervisor query, the ledger read and the writing are passed in rather * than reached for, so a test can drive every branch without a listening * supervisor, a file on disk, or output on the real stdout. Nothing in * production passes these -- the defaults are the real ones. */ export interface MainDependencies { readonly live?: (options: { readonly last?: number; readonly port?: number; }) => Promise; readonly ledger?: (path: string, last: number) => Promise; readonly write?: (text: string) => void; readonly audit?: (captureDir: string, ledgerPath: string) => Promise; /** The environment the default ledger path is taken from. */ readonly env?: NodeJS.ProcessEnv; } /** * The machine-readable form. * * TOTALS ARE COMPUTED HERE RATHER THAN LEFT TO THE CALLER, because the one * thing that is genuinely easy to get wrong about these records is which * denominator a saving is taken over -- see `totalsFor`. A consumer that has to * re-derive it will eventually derive it differently from the table above it. */ export declare function inspectJson(source: 'proxy' | 'ledger', windows: readonly TransformationWindow[], skipped: number): Record; export declare function main(args: readonly string[], dependencies?: MainDependencies): Promise; //# sourceMappingURL=cli.d.ts.map