/** * Claude Code JSONL session file parser for cost data collection. * * Parses Claude Code session JSONL files (main session and subagent files) * to extract token usage data and compute costs. Each assistant message with * a `usage` block becomes a {@link CostEventData} entry. * * JSONL format (one JSON object per line): * ```json * { * "type": "assistant", * "message": { * "model": "claude-opus-4-6", * "usage": { * "input_tokens": 3, * "cache_creation_input_tokens": 26928, * "cache_read_input_tokens": 0, * "cache_creation": { "ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 26928 }, * "output_tokens": 28, * "service_tier": "standard" * } * }, * "timestamp": "2026-04-05T..." * } * ``` */ import type { CostEventData, ModelCostStats } from "./types"; /** * Parse a single Claude Code session JSONL file into cost events. * * Reads the file, splits by newline, and for each line that represents an * assistant message with usage data, extracts token counts and computes * the USD cost using the extended pricing model. * * @param sessionJsonlPath - Absolute path to the `.jsonl` file. * @returns Array of cost events extracted from assistant messages. */ export declare function parseClaudeCodeSession(sessionJsonlPath: string): Promise; /** * Parse a Claude Code session JSONL file and all associated subagent files. * * Subagent files live at `/subagents/agent-*.jsonl` where * `` is derived by stripping the `.jsonl` extension from the * main session file path. * * @param sessionJsonlPath - Absolute path to the main session `.jsonl` file. * @returns Merged array of cost events from the main session and all subagents. */ export declare function parseClaudeCodeSessionWithSubagents(sessionJsonlPath: string): Promise; /** Aggregated usage summary returned by {@link aggregateUsageData}. */ export interface AggregatedUsage { /** Total number of cost events. */ eventCount: number; /** Total base input tokens across all events. */ totalInputTokens: number; /** Total output tokens across all events. */ totalOutputTokens: number; /** Total cache-creation tokens (top-level) across all events. */ totalCacheCreationTokens: number; /** Total cache-read tokens across all events. */ totalCacheReadTokens: number; /** Total 5-minute cache-creation tokens. */ totalCacheCreation5mTokens: number; /** Total 1-hour cache-creation tokens. */ totalCacheCreation1hTokens: number; /** Total computed cost in USD. */ totalCostUsd: number; /** Per-model breakdown of usage statistics. */ byModel: Record; } /** * Aggregate usage data across an array of cost events. * * Sums token counts and costs, producing both overall totals and a * per-model breakdown. * * @param events - Array of cost events (e.g. from {@link parseClaudeCodeSessionWithSubagents}). * @returns Aggregated usage summary with per-model breakdown. */ export declare function aggregateUsageData(events: CostEventData[]): AggregatedUsage; //# sourceMappingURL=claudeCodeParser.d.ts.map