import { ImporterAdapter, ImportedMemory } from '@remnic/core'; /** * A single saved memory entry. OpenAI has changed the shape several times; * we accept the union of fields observed across 2024-2026 exports. */ interface ChatGPTSavedMemory { /** Stable identifier — uuid in recent exports, numeric string in older ones. */ id?: string; /** The memory body. Required. */ content: string; /** ISO 8601 or epoch create timestamp. */ created_at?: string | number; /** ISO 8601 or epoch last-update timestamp, if different from created_at. */ updated_at?: string | number; /** Soft-delete flag seen in 2025+ exports. When true, we skip the record. */ deleted?: boolean; /** Whether the memory is pinned / manually curated. */ pinned?: boolean; /** Tags the user applied to the memory. */ tags?: string[]; } interface ChatGPTConversationMessage { /** Message id. */ id?: string; /** Author role: user / assistant / system / tool. */ author?: { role?: string; name?: string | null; }; /** Content envelope — we read `parts[]` for text content. */ content?: { parts?: unknown[]; content_type?: string; } | null; create_time?: number | string | null; update_time?: number | string | null; parent?: string | null; } interface ChatGPTConversationNode { id: string; message?: ChatGPTConversationMessage | null; parent?: string | null; children?: string[]; } interface ChatGPTConversation { id?: string; title?: string; create_time?: number | string | null; update_time?: number | string | null; /** Messages by id. Present in 2023+ conversation exports. */ mapping?: Record | null; /** Some older exports inline messages as an array instead. */ messages?: ChatGPTConversationMessage[]; /** Root message id (for graph traversal). */ current_node?: string | null; } /** * Unified parsed shape we pass into `transform()`. Holds both saved memories * and (optionally) conversations; either may be empty. */ interface ParsedChatGPTExport { savedMemories: ChatGPTSavedMemory[]; conversations: ChatGPTConversation[]; /** Source path the export came from (for provenance). */ filePath?: string; } interface ChatGPTParseOptions { /** When true, throw on any validation failure instead of skipping. */ strict?: boolean; /** File path of the source — preserved for provenance in transformed memories. */ filePath?: string; } /** * Parse a raw export payload. Accepts either: * - A JSON string (common CLI path — the CLI reads the file contents). * - An already-parsed object or array (`JSON.parse` result). * * Returns the unified `ParsedChatGPTExport`. Non-export payloads throw a * descriptive error; silently ignoring them would mask user errors * (CLAUDE.md rule 51). */ declare function parseChatGPTExport(input: unknown, options?: ChatGPTParseOptions): ParsedChatGPTExport; /** * Walk a conversation's message graph and return only the user-authored text * turns in chronological order. Exported so the transform layer can build * conversation summaries from the same graph. */ declare function collectUserTurnsFromConversation(conversation: ChatGPTConversation): Array<{ content: string; createdAt?: string; }>; declare const adapter: ImporterAdapter; /** Alias kept for symmetry with other @remnic/import-* packages. */ declare const chatgptAdapter: ImporterAdapter; declare const CHATGPT_SOURCE_LABEL = "chatgpt"; interface ChatGPTTransformOptions { /** When true, produce conversation-summary memories in addition to saved memories. */ includeConversations?: boolean; /** Optional cap on total memories emitted — primarily for tests. */ maxMemories?: number; /** Maximum characters for a conversation summary memory. */ maxConversationSummaryChars?: number; } /** * Transform a parsed ChatGPT export into `ImportedMemory[]`. * Saved memories are emitted first (in parse order), then conversation * summaries when opted in. */ declare function transformChatGPTExport(parsed: ParsedChatGPTExport, options?: ChatGPTTransformOptions): ImportedMemory[]; export { CHATGPT_SOURCE_LABEL, type ChatGPTConversation, type ChatGPTConversationMessage, type ChatGPTConversationNode, type ChatGPTParseOptions, type ChatGPTSavedMemory, type ChatGPTTransformOptions, type ParsedChatGPTExport, adapter, chatgptAdapter, collectUserTurnsFromConversation, parseChatGPTExport, transformChatGPTExport };