import type { CliId } from '../adapters/cli/types.js'; export interface SessionCost { inputTokens: number; outputTokens: number; cacheReadTokens: number; cacheCreateTokens: number; model: string; turns: number; } export interface SessionTokenUsage extends SessionCost { in: number; out: number; } /** Latest Context Usage reported by the Agent CLI. A missing window means the * CLI reported usage but not its model's context capacity. `percentUsed`, when * present, is produced by the source parser from native facts and remains * consistent with the displayed measurement; the card renderer never infers * it. */ export interface SessionContextUsage { usedTokens: number; windowTokens?: number; percentUsed?: number; } /** Card-facing usage snapshot. Context is latest-turn state while Token Usage * is cumulative for the Session; neither value is inferred from the other. * `turnTokens` is the delta for the latest user turn (cumulative since the last * user message) — small, matches what the CLI's own TUI shows for "this turn", * whereas `tokens` is the whole-session cumulative (cache-inclusive, large). */ export interface SessionUsageSnapshot { context: SessionContextUsage | null; tokens: SessionTokenUsage | null; turnTokens: { in: number; out: number; } | null; model?: string; reasoningEffort?: string; } export interface SessionTokenUsageQuery { cliId?: CliId | 'unknown'; sessionId: string; cliSessionId?: string; cwd?: string; /** Owning bot's Lark app id — lets the transcript resolver find sandboxed * (CLI-data-redirected) bots' transcripts under BOT_HOME. */ larkAppId?: string; /** Bypass the reparse throttle (stat short-circuit and incremental folding * still apply). Use at low-frequency exact points like ledger/card snapshots. */ fresh?: boolean; } export declare function getSessionJsonlPath(sessionId: string, cwd: string): string | null; export declare function getSessionCost(sessionId: string, cwd: string): SessionCost | null; /** Per-CLI transcript dialect. Each kind only counts the events that dialect * defines as billable turns — no cross-CLI guessing on usage-shaped lines. */ type UsageKind = 'claude' | 'codex' | 'coco' | 'pi' | 'grok' | 'generic'; type CachedUsageKind = UsageKind | 'aiden'; /** Token usage is advisory. Never let dashboard row rendering synchronously * scan pathological multi-GB transcripts. */ export declare const MAX_USAGE_TRANSCRIPT_BYTES: number; /** Codex token_count events are cumulative snapshots, so an oversized cold * restore starts from a bounded tail window and recovers the latest usage * card from it. Real 150MiB+ rollouts almost always carry a token_count * snapshot in the last 4MiB, so this window is the common-case fast path. */ export declare const CODEX_USAGE_TRANSCRIPT_TAIL_BYTES: number; /** When the last tail window is missing a metric (a single huge turn can push * the newest token_count snapshot — or the model line — out of it), do ONE * bounded widen to this size and re-scan that whole window. It is the width of * the single widened pass, NOT a cumulative ladder: the worst-case synchronous * dashboard read is `tail + this`, and past it we fail closed (yield whatever * the widened window found, never inheriting a possibly-stale value across an * unverifiable generation boundary). */ export declare const CODEX_USAGE_MAX_BACKSCAN_BYTES: number; export declare function __resetSessionUsageCachesForTest(): void; /** Read a transcript's token usage through the stat/incremental cache. * This is the reusable entry point for dashboard rows and, later, the * persistent usage ledger. */ export declare function readSessionTokenUsageFile(path: string, kind: CachedUsageKind, opts?: { fresh?: boolean; }): SessionTokenUsage | null; export declare function getSessionTokenUsage(q: SessionTokenUsageQuery): SessionTokenUsage | null; export declare function getSessionUsageSnapshot(q: SessionTokenUsageQuery): SessionUsageSnapshot; export declare function formatNumber(n: number): string; export {}; //# sourceMappingURL=cost-calculator.d.ts.map