/** * In-memory aggregation: fold {@link CallRecord}s into per-model hourly buckets * and render {@link UsageSummary} snapshots. Pure — no I/O, no cordis. * @module @dsh-usage-meter/usage/ledger */ import type { CallRecord, UsageBucket, UsageSummary } from './types.ts'; /** Hour-bucketing timezone. */ export type HourTimezone = 'local' | 'utc'; /** * Hour key for a Unix epoch millisecond timestamp. * @param time - Unix epoch milliseconds. * @param timezone - `local` uses the process timezone, `utc` the UTC hour. * @returns `YYYY-MM-DD HH:00`. */ export declare function hourKey(time: number, timezone: HourTimezone): string; /** An empty bucket; mutate with {@link addRecord}. */ export declare function zeroBucket(): UsageBucket; /** Fold one call record into a bucket, mutating it in place. */ export declare function addRecord(bucket: UsageBucket, record: CallRecord): void; /** Accumulate `source` into `target`, mutating `target` in place. */ export declare function addBucket(target: UsageBucket, source: UsageBucket): void; /** * Durable per-model hourly usage. Seeded from persisted records at startup and * grown by the live event firehose; `summary()` snapshots the current state. */ export declare class UsageLedger { private readonly timezone; private readonly hours; /** * @param timezone - hour-bucketing timezone. * @param records - seed records (the persisted ledger tail, if any). */ constructor(timezone: HourTimezone, records?: readonly CallRecord[]); /** Fold one call record into the ledger. */ record(record: CallRecord): void; /** Snapshot the complete ledger as a summary. */ summary(): UsageSummary; } //# sourceMappingURL=ledger.d.ts.map