/** * Cost provider seam (FR3.1). * * A provider knows how to (a) detect its platform, (b) locate and validate * its usage records for a session, and (c) extract usage segments since a * cursor. Providers never touch ledgers or instances — attribution belongs * to the recorder. * * Design: design.md §3 */ import type { RecordInput, ResolveResult, SourceRef, UsageSegment } from '../types.js'; export interface ProviderEnv { projectRoot: string; /** Home directory override for tests. */ home?: string; } export interface CostProvider { readonly name: string; /** Is this platform present for the project/user? */ detect(env: ProviderEnv): boolean; /** * Validate hook input and resolve the usage-record source (FR3.9). * * Returns `{ok: false, reason}` rather than a bare null so the recorder can * tell a benign miss (`source-missing`: the session simply wrote no records) * from a rejection (`invalid-input`: malformed, or outside the platform's * known root). Containment is checked lexically before touching the disk, so * a non-existent path outside the root reports `invalid-input` and never * leaks whether it exists. */ resolveSource(input: RecordInput, env: ProviderEnv): ResolveResult; /** * Extract usage segments after `since` (a cursor previously returned in * a segment). Streaming and fail-soft: malformed records are skipped. */ extract(source: SourceRef, since: string | null, env: ProviderEnv): Promise; } export declare function registerProvider(p: CostProvider): void; export declare function getProvider(name: string): CostProvider | undefined; export declare function allProviders(): CostProvider[]; //# sourceMappingURL=provider.d.ts.map