/** * DeepSeek Harness usage recorder (host half). * * A cordis Service plugin: listens to the `session/event` firehose, folds * `request/header` routes and `assistant/message` usage samples into a * per-model hourly {@link UsageLedger}, persists every call as one JSONL line * under `$DSH_HOME/usage-meter/usage.jsonl`, and exposes the ledger through the * `usage-meter/summary` Typert remote endpoint the Web GUI dashboard calls. * * The single `@dsh-usage-meter/usage` package ships this host half as its * default export and the browser dashboard under `./client`; its * self-mounting `cordis.patch.yml` inserts one row mounting both halves. * * @module @dsh-usage-meter/usage */ import { Context, Service } from '@deepseek-ai/cordis'; import { dshHomePath } from '@deepseek-ai/dsh-home-paths'; import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'; import s from '@deepseek-ai/schemastery'; import { type HourTimezone } from './ledger.ts'; import type { UsageSummary } from './types.ts'; export type { CallRecord, UsageBucket, UsageHour, UsageSummary } from './types.ts'; export type { HourTimezone } from './ledger.ts'; export type { SessionFoldState } from './fold.ts'; export { hourKey, UsageLedger, zeroBucket } from './ledger.ts'; export { parseRecord, JsonlUsageStore } from './store.ts'; export { applyEvent, createSessionFoldState } from './fold.ts'; /** Deployment-varying configuration; every field has a safe default. */ export interface Config { /** Directory holding `usage.jsonl`; empty resolves to `$DSH_HOME/usage-meter`. */ readonly dir?: string; /** Hour-bucketing timezone; defaults to the process timezone (`local`). */ readonly timezone?: HourTimezone; } declare module '@deepseek-ai/cordis' { interface Context { dshHomePath: typeof dshHomePath; usageMeter: UsageMeterService; } } /** * The usage recorder service. * @typert service usageMeter */ export declare class UsageMeterService extends TypertRemoteService { static inject: string[]; /** Loader validation for the one deployment-varying policy. */ static Config: s; private readonly timezone; private readonly store; private readonly sessionState; private ledger; private writeTail; /** * @param ctx - host context carrying the sessions store and `dshHomePath`. * @param config - validated plugin configuration. */ constructor(ctx: Context, config: Config); /** * Load the persisted ledger, backfill every live session, register the * strict Typert endpoint, and subscribe to the event firehose. */ protected [Service.init](): Promise; /** Fold every event of one live session without re-emitting persisted writes. */ private backfill; /** Fold a record into the ledger and queue its persistence (failure contained). */ private accept; /** * Snapshot the complete per-model hourly usage. * @returns the current ledger summary. */ summary(): Promise; } export default UsageMeterService; //# sourceMappingURL=index.d.ts.map