/** * Transcript Ingestor — full-fidelity Claude session JSONL → brain_transcript_events (T1002). * * Pipeline: * 1. Scan a directory (or accept an explicit list) of Claude session JSONL files. * 2. Parse each file: extract every content block (text, tool_use, tool_result, * thinking, system). * 3. Run redaction on each block before persist. * 4. Write rows to brain_transcript_events via INSERT OR IGNORE (idempotent on * the (session_id, seq) unique index). * 5. After ingest, run auto-research mining on the new session IDs. * * Constraints: * - Does NOT touch brain_observations, brain_learnings, or brain_patterns — * those are T1001 territory. * - Does NOT ingest real transcripts during tests — callers pass synthetic * fixtures or use the ingestEvents() low-level API. * * @task T1002 * @epic T1000 */ import type { AutoResearchResult } from './auto-research.js'; /** A single parsed block ready for storage. */ export interface TranscriptEventBlock { sessionId: string; seq: number; role: string; blockType: string; content: string; tokens?: number; } /** Result from ingesting one or more transcript files. */ export interface IngestResult { /** Number of new rows written to brain_transcript_events. */ rowsInserted: number; /** Number of rows skipped because they already existed (idempotent re-ingest). */ rowsSkipped: number; /** Session IDs processed in this batch. */ sessionIds: string[]; /** Auto-research findings from the ingested sessions. */ autoResearch: AutoResearchResult; /** Any non-fatal warnings (e.g. malformed JSONL lines). */ warnings: string[]; } /** * Parse a Claude JSONL transcript string into transcript event blocks. * * Handles all block types: text, tool_use, tool_result, thinking, system. * Skips file-history-snapshot and other non-message entry types. * * @param raw - Raw JSONL string content. * @param sessionId - Session ID to tag the blocks with. * @returns Ordered array of TranscriptEventBlock (seq 0-based). */ export declare function parseJsonlBlocks(raw: string, sessionId: string): TranscriptEventBlock[]; /** * Derive a session ID from a JSONL filename. * * Tries to extract a `ses_YYYYMMDD_xxxxx` style ID from the filename. * Falls back to the basename without extension. * * @param filePath - Absolute or relative path to the JSONL file. * @returns Session ID string. */ export declare function deriveSessionId(filePath: string): string; /** * Ingest a list of pre-parsed TranscriptEventBlock rows into brain_transcript_events. * * Uses INSERT OR IGNORE for idempotency — re-ingesting the same (session_id, seq) * pair is a safe no-op. * * Callers that want full-pipeline ingest (parse + store + auto-research) should * use ingestTranscriptFiles() instead. * * @param blocks - Pre-parsed blocks (from parseJsonlBlocks). * @param cwd - Optional project root for getBrainDb path resolution. * @returns Number of rows actually inserted (skipped rows are excluded). */ export declare function ingestEvents(blocks: TranscriptEventBlock[], cwd?: string): Promise<{ inserted: number; skipped: number; }>; /** * Ingest one or more Claude session JSONL files into brain_transcript_events. * * For each file: * 1. Reads + parses the JSONL into blocks. * 2. Writes blocks to brain_transcript_events (idempotent INSERT OR IGNORE). * 3. After all files, runs auto-research mining on the new session IDs. * * @param filePaths - Absolute paths to JSONL files to ingest. * @param cwd - Optional project root for brain.db path resolution. * @returns IngestResult summary. */ export declare function ingestTranscriptFiles(filePaths: string[], cwd?: string): Promise; /** * Scan a directory for Claude session JSONL files and ingest them all. * * @param dir - Directory to scan for *.jsonl files. * @param cwd - Optional project root for brain.db path resolution. * @returns IngestResult summary. */ export declare function ingestTranscriptDirectory(dir: string, cwd?: string): Promise; //# sourceMappingURL=transcript-ingestor.d.ts.map