/** * TranscriptExtractor — reads a Claude session JSONL file and extracts * durable memories using the warm-to-cold LLM backend resolver. * * Pipeline: * 1. Read + decode JSONL session file → raw conversation text * 2. Resolve best available LLM backend (warm: Ollama → transformers.js → Sonnet) * 3. `generateObject()` with Vercel AI SDK → typed `ExtractedMemory[]` * 4. Store each memory via existing CLEO brain APIs (routing through verifyAndStore gate) * 5. Write tombstone observation (`transcript-extracted`) to brain_observations * 6. Delete source JSONL after successful extraction (unless dry-run) * * Acceptance criteria (T730): * - Reads a session JSONL and emits ExtractedMemory[] using existing llm-extraction.ts pipeline * - Extracted memories tagged with source_session_id + type transcript-warm-extract * - After success: JSONL deleted + brain_observations tombstone written * - Supports dry-run mode * * @task T730 * @epic T726 */ /** Options for extracting memories from a JSONL transcript file. */ export interface ExtractTranscriptOptions { /** Absolute path to the session JSONL file. */ transcriptPath: string; /** CLEO project root for brain.db access. */ projectRoot: string; /** * LLM tier to use. * `warm` (default): Ollama → transformers.js → Sonnet escalation. * `cold`: Claude Sonnet only (requires ANTHROPIC_API_KEY). */ tier?: 'warm' | 'cold'; /** * If true, report what would happen without writing to brain.db or * deleting the JSONL file. */ dryRun?: boolean; /** * CLEO session ID associated with this transcript (used as source tag). * If omitted, derived from the JSONL filename. */ sessionId?: string; } /** Summary of extraction results for a single JSONL file. */ export interface ExtractionResult { /** Path to the JSONL file processed. */ transcriptPath: string; /** CLEO session ID used as source tag. */ sessionId: string; /** Backend that performed the extraction. */ backend: string; /** Number of memories the LLM returned. */ extractedCount: number; /** Number of memories stored to brain.db (0 in dry-run). */ storedCount: number; /** Number of memories rejected (below threshold, dedup, errors). */ rejectedCount: number; /** Whether the JSONL file was deleted post-extraction. */ deleted: boolean; /** Whether this was a dry-run (no writes). */ dryRun: boolean; /** Non-fatal warnings. */ warnings: string[]; /** Bytes freed by deleting the JSONL (0 if not deleted or dry-run). */ bytesFreed: number; } /** * Extract memories from a single Claude session JSONL file. * * Reads the file, resolves the best LLM backend, extracts structured * memories via `generateObject()`, stores them through existing CLEO brain * APIs, writes a tombstone, and deletes the JSONL. * * Never throws — all errors produce warnings in the result. * * @param options - Extraction options including file path and tier. * @returns Extraction summary. * * @example * ```ts * const result = await extractTranscript({ * transcriptPath: '/home/user/.claude/projects/myproject/session.jsonl', * projectRoot: '/home/user/projects/myproject', * tier: 'warm', * }); * console.log(`Stored ${result.storedCount} memories`); * ``` */ export declare function extractTranscript(options: ExtractTranscriptOptions): Promise; /** * Decode a Claude session JSONL file into a plain text transcript. * * Each line is a JSON object. We extract user/assistant message turns, * skipping file-history snapshots, tool calls, and other non-content events. * The result is a compact text suitable for LLM extraction. */ export declare function decodeJsonlTranscript(raw: string): string; /** * Resolve the directory containing Claude session JSONLs for a project path. * * Claude stores sessions at `~/.claude/projects//.jsonl`. * The project path is encoded by replacing `/` with `-`. * * @param projectPath - Absolute project path (e.g. `/mnt/projects/myapp`) * @returns Absolute path to the Claude project directory. */ export declare function resolveClaudeProjectDir(projectPath: string): Promise; //# sourceMappingURL=transcript-extractor.d.ts.map