erosolar-cli
Version:
Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning
87 lines • 2.2 kB
TypeScript
/**
* Cost Tracker - Claude Code Style
*
* Tracks token usage and API costs across the session.
* Provides real-time cost display and detailed breakdowns.
*
* Features:
* - Real-time token counting (input/output)
* - Cost estimation based on model pricing
* - Session and lifetime cost tracking
* - Detailed breakdown by model and request
*/
export interface TokenUsage {
inputTokens: number;
outputTokens: number;
totalTokens: number;
}
export interface RequestCost {
timestamp: number;
model: string;
inputTokens: number;
outputTokens: number;
inputCost: number;
outputCost: number;
totalCost: number;
requestType: 'chat' | 'tool' | 'embedding';
}
export interface SessionUsage {
sessionId: string;
startTime: number;
requests: RequestCost[];
totalInputTokens: number;
totalOutputTokens: number;
totalCost: number;
}
export interface LifetimeUsage {
totalInputTokens: number;
totalOutputTokens: number;
totalCost: number;
sessions: number;
firstUse: number;
lastUse: number;
}
/**
* Cost Tracker class
*/
export declare class CostTracker {
private sessionId;
private startTime;
private requests;
constructor(sessionId?: string);
/**
* Record a request's token usage
*/
recordUsage(model: string, inputTokens: number, outputTokens: number, requestType?: 'chat' | 'tool' | 'embedding'): RequestCost;
/**
* Get session usage summary
*/
getSessionUsage(): SessionUsage;
/**
* Get lifetime usage
*/
getLifetimeUsage(): LifetimeUsage;
/**
* Save request to lifetime usage
*/
private saveToLifetime;
/**
* Format session usage for display
*/
formatSessionUsage(): string;
/**
* Format cost breakdown for display
*/
formatCostBreakdown(): string;
/**
* Format compact cost display for status bar
*/
formatCompactCost(): string;
/**
* Reset session tracking
*/
reset(): void;
}
export declare function getCostTracker(sessionId?: string): CostTracker;
export declare function resetCostTracker(): void;
//# sourceMappingURL=costTracker.d.ts.map