/** * Cost Tracker * * Tracks and estimates token usage costs for autopilot runs. */ import { EventEmitter } from 'events'; import type { TokenUsage } from '../types.js'; /** * Model pricing (per million tokens) */ export interface ModelPricing { inputCostPer1M: number; outputCostPer1M: number; } /** * Built-in model pricing */ export declare const MODEL_PRICING: Record; /** * Cost threshold warning */ export interface CostThresholdWarning { threshold: number; currentCost: number; percentUsed: number; message: string; } /** * Cost snapshot */ export interface CostSnapshot { totalCostUsd: number; totalInputTokens: number; totalOutputTokens: number; ticketCount: number; averageCostPerTicket: number; timestamp: Date; } /** * Cost Tracker Events */ export interface CostTrackerEvents { 'cost:updated': { totalCost: number; lastCost: number; }; 'cost:threshold': CostThresholdWarning; 'cost:limit_reached': { limit: number; currentCost: number; }; } /** * Cost Tracker Options */ export interface CostTrackerOptions { maxTotalCostUsd?: number; warningThresholds?: number[]; modelPricing?: Record; } /** * Cost Tracker * * Tracks token usage and estimates costs, emitting warnings at thresholds. */ export declare class CostTracker extends EventEmitter { private totalCostUsd; private totalInputTokens; private totalOutputTokens; private ticketCount; private maxTotalCostUsd; private warningThresholds; private triggeredThresholds; private modelPricing; private costHistory; constructor(options?: CostTrackerOptions); /** * Estimate cost from token usage */ estimateCost(tokens: TokenUsage, model?: string): number; /** * Add token usage and update cost */ addTokenUsage(tokens: TokenUsage, model?: string): number; /** * Add direct cost (when tokens aren't available) */ addDirectCost(costUsd: number): void; /** * Check and emit threshold warnings */ private checkThresholds; /** * Get threshold warning message */ private getThresholdMessage; /** * Check if cost limit is reached */ isLimitReached(): boolean; /** * Get remaining budget */ getRemainingBudget(): number; /** * Get budget utilization percentage */ getBudgetUtilization(): number; /** * Get total cost */ getTotalCost(): number; /** * Get total tokens */ getTotalTokens(): TokenUsage; /** * Get average cost per ticket */ getAverageCostPerTicket(): number; /** * Get ticket count */ getTicketCount(): number; /** * Get cost snapshot */ getSnapshot(): CostSnapshot; /** * Get cost history */ getCostHistory(): CostSnapshot[]; /** * Estimate remaining tickets based on average cost */ estimateRemainingTickets(): number; /** * Format cost as currency string */ formatCost(cost: number): string; /** * Get cost summary string */ getSummary(): string; /** * Reset tracker */ reset(): void; /** * Update max cost limit */ setMaxCost(maxCostUsd: number): void; /** * Get max cost limit */ getMaxCost(): number; } /** * Create a cost tracker */ export declare function createCostTracker(options?: CostTrackerOptions): CostTracker; //# sourceMappingURL=cost-tracker.d.ts.map