import type { PermissionResult, Options } from '@anthropic-ai/claude-code'; import { ToolType } from './toolTypes'; export interface TextBlock { type: 'text'; text: string; } export interface ToolUseBlock { type: 'tool_use'; id: string; name: string; input: Record; } export interface ToolResultBlock { type: 'tool_result'; tool_use_id: string; content: string | Array; is_error?: boolean; } export type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock; export interface UserMessage { type: 'user'; content: string; session_id?: string; } export interface ToolResultMessage { type: 'tool_result'; content: ToolResultBlock[] | string[]; session_id?: string; } export interface HookFeedbackMessage { type: 'hook_feedback'; content: string[]; session_id?: string; } export interface AssistantMessage { type: 'assistant'; content: ContentBlock[]; session_id?: string; } export interface SystemMessage { type: 'system'; subtype?: string; data?: unknown; session_id?: string; } export interface ResultMessage { type: 'result'; subtype?: string; content: string; session_id?: string; usage?: { input_tokens?: number; output_tokens?: number; cache_creation_input_tokens?: number; cache_read_input_tokens?: number; }; cost?: { input_cost?: number; output_cost?: number; cache_creation_cost?: number; cache_read_cost?: number; total_cost?: number; }; } export type Message = UserMessage | AssistantMessage | SystemMessage | ResultMessage | ToolResultMessage | HookFeedbackMessage; /** * Shared type definitions for Claude API data structures * These types are used across multiple modules that parse Claude's JSONL files */ /** * Content item with text property */ export interface TextContentItem { text: string; type?: string; [key: string]: unknown; } /** * Content item with legacy content property (used in some older formats) */ export interface LegacyContentItem { content: string; type?: string; [key: string]: unknown; } /** * Generic content item that can appear in message.content arrays */ export interface ContentItem { text?: string; type?: string; [key: string]: unknown; } /** * Specific content item types that we know about */ export type SpecificContentItem = TextContentItem | LegacyContentItem | ContentItem; /** * Message content can be either a string or an array of content items */ export type MessageContent = string | SpecificContentItem[]; /** * Core structure of a JSONL entry from Claude session files */ export interface ClaudeJSONLEntry { sessionId?: string; uuid?: string; parentUuid?: string; timestamp?: string; type?: 'user' | 'assistant' | 'system'; cwd?: string; message?: { role: string; content: MessageContent; }; } /** * Session representation focused on metadata and activity */ export interface ClaudeSession { id: string; summary?: string; title?: string; lastActivity: string; messageCount: number; created: string; projectName?: string; __provider?: string; } /** * Project representation with sessions */ export interface ClaudeProject { name: string; path: string; displayName: string; fullPath: string; sessions: ClaudeSession[]; sessionMeta?: { hasMore: boolean; total: number; offset?: number; limit?: number; }; } /** * Session message with full details */ export interface SessionMessage { sessionId: string; type: 'user' | 'assistant' | 'system'; message?: { role: string; content: MessageContent; id?: string; }; timestamp: string; uuid?: string; } /** * Simplified message for tree analysis */ export interface SimpleSessionMessage { text: string; uuid: string; parentUuid: string; type: string; } /** * Session data for relationship analysis */ export interface SessionData { sessionId: string | null; messages: SimpleSessionMessage[]; uuids: Set; firstUserMessageUuid: string | null; filepath: string; } /** * Session node in tree structure */ export interface SessionNode { sessionId: string; filename: string; path: string; messageCount: number; firstMessage: string | null; lastMessage: string | null; size: number; modified: string; created: string; branches: SessionNode[]; } /** * Branch endpoint information */ export interface BranchEndpoint { endpoint: string; sessionId: string; messageCount: number; lastMessage: string | null; path: string[]; } /** * Fork point in session tree */ export interface ForkPoint { forkAt: string; sessionId: string; branchCount: number; branches: string[]; } /** * Branch information */ export interface BranchInfo { branches: BranchEndpoint[]; forkPoints: ForkPoint[]; } /** * Complete session tree structure */ export interface SessionTree { rootId: string; root: string; firstMessage: string | null; latestUserMessage: string | null; totalBranches: number; maxDepth: number; branches: BranchEndpoint[]; forkPoints: ForkPoint[]; structure: SessionNode; } /** * Session trees result */ export interface SessionTreesResult { totalTrees: number; totalSessions: number; trees: SessionTree[]; } /** * Latest session information */ export interface LatestSession { rootId: string; sessionId: string; filename: string; messageCount: number; lastMessage: string | null; isFork: boolean; forkFrom: string | null; path: string[]; } /** * Type guard to check if content is a ContentItem array */ export declare function isContentItemArray(content: MessageContent): content is SpecificContentItem[]; /** * Type guard for TextContentItem */ export declare function isTextContentItem(item: unknown): item is TextContentItem; /** * Type guard for LegacyContentItem */ export declare function isLegacyContentItem(item: unknown): item is LegacyContentItem; /** * Helper to extract text from a content item */ export declare function extractTextFromContentItem(item: unknown): string; /** * Type guard to check if an error has a code property */ export declare function isNodeError(error: unknown): error is Error & { code?: string; }; export interface ToolsSettings { allowedTools?: ToolType[]; disallowedTools?: ToolType[]; skipPermissions?: boolean; } export interface ImageData { data: string; } export type ClaudeCommandMessage = { type: 'claude-command'; command: string; options: Options; }; export type ClaudePermissionMessage = { type: 'permissions-response'; sessionId: string; requestId: string; result: PermissionResult; }; export * from './toolTypes'; //# sourceMappingURL=types.d.ts.map