/** * Session Parser for Claude Code JSONL format * * Parses Claude Code session files and extracts structured conversation data * with temporal ordering and source links for provenance. */ export interface SourceLink { sessionId: string; messageUuid: string; timestamp: Date; filePath: string; } export interface Message { role: 'user' | 'assistant'; content: string; timestamp: Date; source: SourceLink; } export interface Conversation { sessionId: string; project: string; messages: Message[]; startTime: Date; endTime: Date; processedBytes: number; /** * The Claude Code entrypoint that launched this session. `'cli'` means an * interactive terminal session; `'sdk-cli'` means a one-shot SDK invocation * (Claude Code's internal automation: commit-message generation, summaries, * subagents). Undefined for Codex / opencode / pre-entrypoint sessions. */ entrypoint?: string; sourceType?: SourceType; } export type SourceType = 'claude-code' | 'git' | 'antigravity' | 'codex' | 'opencode' | 'cursor'; export interface SessionFile { path: string; sessionId: string; project: string; modifiedTime: Date; /** File size in bytes (for fast append-only change detection) */ fileSize: number; /** Type of source */ sourceType?: SourceType; /** * Working directory the session was launched in, when known at discovery time. * Populated by Codex discovery (read from session metadata). Claude Code * sessions leave this undefined — cwd is per-message and resolved on parse. */ cwd?: string; } /** * Get the Claude projects directory path */ export declare function getClaudeProjectsDir(): string; /** * Discover all session files for a given project. * If currentCwd is provided, it will also scan for recent sessions in other project directories * where the internal CWD matches (to catch sessions misappropriated by Claude Code). */ export declare function discoverSessionFiles(projectPath?: string, currentCwd?: string): SessionFile[]; /** * Parse a single session file into a Conversation */ export declare function parseSessionFile(filePath: string): Conversation; /** * Parse only NEW content from a session file, starting from a byte offset. * For append-only JSONL files, this reads only the bytes added since last processing. */ export declare function parseSessionFileFromOffset(filePath: string, startOffset: number, existingSessionId?: string, existingProject?: string): { messages: Message[]; processedBytes: number; }; /** * Parse multiple session files, optionally filtering by date range */ export declare function parseSessions(options: { projectPath?: string; since?: Date; until?: Date; limit?: number; }): Conversation[]; /** * Format a conversation as readable text (for debugging/preview) */ export declare function formatConversation(conversation: Conversation): string; /** * Get statistics about available sessions */ export declare function getSessionStats(projectPath?: string): { totalSessions: number; totalMessages: number; projects: string[]; dateRange: { earliest: Date | null; latest: Date | null; }; }; //# sourceMappingURL=session-parser.d.ts.map