/** * Platform usage statistics — the account-level monitor data behind the * desktop app's Coding Plan usage tab, aggregated for the mobile app's Usage * page (contract: `.zcode/docs/platform-usage-backend-requirements.md` in the * app repo). * * Lives in `src/quota/` next to the monitor client: same upstream family * (BigModel/Z.AI monitor API), same host derivation and credentials as the * quota windows. The settings route (`src/remote/settings-endpoint.ts`) mounts * it under `GET /settings/usage-platform`. * * Three upstream blocks are read in parallel (activity is a fixed 365-day * window; model/tool detail follow the requested range), each defensively * parsed: a missing block is empty data, not an error, and only a total * failure surfaces an error kind. Normalization is ported from the desktop * mapper (`packages/services/src/usage-stats/providers/bigmodelUsageMonitorMapper.ts`), * including its two load-bearing quirks: * * - credit-usage "cached/uncached/output" rows are billing components, not * models — unfiltered they would double the totals; * - every numeric field may arrive as number, numeric string or null. */ export type PlatformUsageRange = "today" | "7d" | "30d"; export type PlatformUsageKind = "success" | "auth_error" | "rate_limited" | "unavailable"; export declare const PLATFORM_USAGE_RANGES: ReadonlySet; export declare function isPlatformUsageRange(value: string): value is PlatformUsageRange; export interface PlatformHeatmapCell { date: string; level: number; tokens: number; } export interface PlatformActivity { summary: { totalTokens: number; peakDailyTokens: number; peakDailyTokensDate: string | null; totalUsageDurationMs: number; currentStreakDays: number; longestStreakDays: number; }; heatmap: { startDate: string | null; endDate: string | null; maxTokens: number; weeks: Array<{ days: Array; }>; }; } export interface PlatformDetailSummary { cacheHitRate: number | null; cacheHitRateTrend: number | null; totalCredits: number; totalCreditsTrend: number | null; averageDailyCredits: number; averageDailyCreditsTrend: number | null; } export interface PlatformModelRow { name: string; totalTokens: number; totalCredits?: number; cachedInputTokens?: number; uncachedInputTokens?: number; outputTokens?: number; sortOrder: number; } export interface PlatformToolRow { name: string; totalUsageCount: number; totalCredits?: number; } export interface PlatformSeries { granularity: "hour" | "day"; xTime: string[]; totals: number[]; } export interface PlatformUsageResult { kind: PlatformUsageKind; range: PlatformUsageRange; generatedAt: number; activity?: PlatformActivity; detail?: { model: PlatformDetailSummary | null; tool: PlatformDetailSummary | null; }; models?: PlatformModelRow[]; tools?: PlatformToolRow[]; series?: PlatformSeries; } /** * Read the platform usage snapshot for a range. * * Serves a cached result when fresh (< 15s); concurrent reads for the same * range share one upstream round trip (the 365-day activity fetch is the * expensive one, and a burst of range taps must not fan out). */ export declare function readPlatformUsage(range?: PlatformUsageRange): Promise; /** Test helper: drop cached results and in-flight promises. */ export declare function resetPlatformUsageCacheForTest(): void; /** Test helper: inject a fake clock. Pass `undefined` to restore real time. */ export declare function setPlatformUsageClockForTest(fn?: () => number): void; //# sourceMappingURL=platform-usage.d.ts.map