export type TokenUsage = { inputTokens: number outputTokens: number cacheCreationInputTokens: number cacheReadInputTokens: number cachedInputTokens: number reasoningTokens: number webSearchRequests: number } export type ToolUseBlock = { type: 'tool_use' id: string name: string input: Record } export type ContentBlock = | { type: 'text'; text: string } | { type: 'thinking'; thinking: string } | ToolUseBlock | { type: string; [key: string]: unknown } export type ApiUsage = { input_tokens: number output_tokens: number cache_creation_input_tokens?: number cache_read_input_tokens?: number server_tool_use?: { web_search_requests?: number web_fetch_requests?: number } speed?: 'standard' | 'fast' } export type AssistantMessageContent = { model: string id?: string type: 'message' role: 'assistant' content: ContentBlock[] usage: ApiUsage stop_reason?: string } export type JournalEntry = { type: string uuid?: string parentUuid?: string | null timestamp?: string sessionId?: string cwd?: string version?: string gitBranch?: string promptId?: string message?: AssistantMessageContent | { role: 'user'; content: string | ContentBlock[] } isSidechain?: boolean [key: string]: unknown } export type ParsedTurn = { userMessage: string assistantCalls: ParsedApiCall[] timestamp: string sessionId: string } export type ParsedApiCall = { provider: string model: string usage: TokenUsage costUSD: number tools: string[] mcpTools: string[] skills: string[] hasAgentSpawn: boolean hasPlanMode: boolean speed: 'standard' | 'fast' timestamp: string bashCommands: string[] deduplicationKey: string } export type TaskCategory = | 'coding' | 'debugging' | 'feature' | 'refactoring' | 'testing' | 'exploration' | 'planning' | 'delegation' | 'git' | 'build/deploy' | 'conversation' | 'brainstorming' | 'general' export type ClassifiedTurn = ParsedTurn & { category: TaskCategory subCategory?: string retries: number hasEdits: boolean } export type SessionSummary = { sessionId: string project: string firstTimestamp: string lastTimestamp: string totalCostUSD: number totalInputTokens: number totalOutputTokens: number totalCacheReadTokens: number totalCacheWriteTokens: number apiCalls: number turns: ClassifiedTurn[] modelBreakdown: Record toolBreakdown: Record mcpBreakdown: Record bashBreakdown: Record categoryBreakdown: Record skillBreakdown: Record // Observed MCP tools available in this session, captured from // `attachment.deferred_tools_delta.addedNames` entries. Union across all // turns. Each name is a fully-qualified `mcp____` identifier. // Built-in tools (Bash, Edit, etc.) are filtered out. Provider-agnostic field; // currently populated only by the Claude parser. mcpInventory?: string[] } export type ProjectSummary = { project: string projectPath: string sessions: SessionSummary[] totalCostUSD: number totalApiCalls: number } export type DateRange = { start: Date end: Date } export const CATEGORY_LABELS: Record = { coding: 'Coding', debugging: 'Debugging', feature: 'Feature Dev', refactoring: 'Refactoring', testing: 'Testing', exploration: 'Exploration', planning: 'Planning', delegation: 'Delegation', git: 'Git Ops', 'build/deploy': 'Build/Deploy', conversation: 'Conversation', brainstorming: 'Brainstorming', general: 'General', }