import type { BudgetConfig, BudgetCheckResult, CostRecord } from "../types.js"; /** Minimal Redis interface (compatible with ioredis) */ export interface RedisLike { get(key: string): Promise; incrbyfloat(key: string, increment: number): Promise; expire(key: string, seconds: number): Promise; } export interface CostTrackerOptions { /** * Cap on in-memory CostRecord retention (ring-buffer). * Default: 10_000. Set to 0 to disable record retention entirely * (use this in long-running processes that only care about budget * counters, not per-request records). * Override via env: AI_SHIELD_MAX_RECORDS. */ maxRecords?: number; } export declare class CostTracker { private store; private budgets; private records; private maxRecords; constructor(budgets?: Record, redis?: RedisLike, options?: CostTrackerOptions); /** Check if a request is within budget BEFORE sending to LLM */ checkBudget(entityId: string, model: string, estimatedInputTokens: number, estimatedOutputTokens?: number): Promise; /** Record actual cost AFTER receiving response */ recordCost(entityId: string, model: string, inputTokens: number, outputTokens: number): Promise; /** * Append a record with ring-buffer semantics to prevent unbounded memory growth. * When maxRecords is 0, records are not retained. */ private appendRecord; /** Clear all in-memory records (e.g., after export) */ clearRecords(): void; /** Get current spend for an entity */ getCurrentSpend(entityId: string): Promise; /** Get all recorded costs (for export/audit) */ getRecords(): CostRecord[]; private budgetKey; private periodSeconds; } //# sourceMappingURL=tracker.d.ts.map