/** * Usage Service * * Tracks and reports usage against tier limits */ import type { Tier } from '../types/auth.js'; export type UsageAction = 'update_check' | 'download' | 'sync' | 'migration'; export interface UsageStat { used: number; limit: number; remaining: number; } export interface UsageReport { tier: Tier; today: { updateChecks: UsageStat; downloads: UsageStat; syncs: UsageStat; migrations: UsageStat; /** * API-metered template downloads. The CLI does not meter this action * locally (templateDownloadsPerDay was dropped from TierLimits in * v2.11.10), so this is an optional passthrough from the server usage * report — absent in offline/local fallback reports. */ templateDownloads?: UsageStat; }; } export interface LimitCheckResult { allowed: boolean; current: number; limit: number; remaining: number; tier: Tier; } export declare class UsageService { private apiUrl; private localUsage; constructor(apiUrl?: string); /** Get today's date string for usage tracking keys */ private getToday; /** Derive integrity key for HMAC signing (machine-specific, no salt file needed) */ private getIntegrityKey; /** Load local usage counts from disk */ private loadLocalUsage; /** Persist local usage counts to disk with HMAC integrity */ private saveLocalUsage; /** Acquire an exclusive file lock, execute fn, then release */ private withUsageLock; /** Increment local usage count for an action (with file lock) */ private incrementLocalUsage; /** Check action against local tier limits (fallback when server is unreachable) */ private checkLocalLimit; /** * Check if a 401 response indicates a revoked session. * If so, clear the local session and log a message. */ private handleSessionRevoked; private getHeaders; /** Update server time from API response Date header */ private trackServerTime; getUsage(): Promise; checkLimit(action: UsageAction): Promise; recordUsage(action: UsageAction): Promise; private getOfflineUsage; } export declare function getUsageService(): UsageService; //# sourceMappingURL=usage-service.d.ts.map