/** * Per-agent transcript adapters. * * Each agent's CLI writes its conversation history to a different place * with a different schema. This module abstracts both: a [TranscriptAdapter] * knows where to find the right file for a given (cwd, spawn time) and * how to translate parsed records into our wire-shape [ChatEvent]. * * Supported today: * - claude → ~/.claude/projects//.jsonl * - gemini → ~/.gemini/tmp//chats/session--.jsonl * - codex → ~/.codex/sessions/YYYY/MM/DD/rollout--.jsonl * * Not yet: * - opencode → primary store is SQLite (~/.local/share/opencode/opencode.db). * Tailing a SQLite write-ahead log requires different plumbing * (polling + sqlite client) than the JSONL file-tail pattern, so * it's deferred until we have a need for it. */ import type { ChatEvent, ChatBlock } from './chat-event-stream.js'; export interface ResolveOptions { /** The cwd the PTY was spawned in. */ cwd: string; /** Epoch-ms when the PTY was spawned. Used to bind to the right file. */ spawnedAtMs: number; /** Explicit session id when we already know it from a prior discovery. */ sessionId?: string; /** * Loopsy-side session id. Adapters that maintain a discovered-on-spawn * mapping (currently only Claude) use this to re-check the tracker on * each poll iteration — so a JSONL that appears mid-poll is picked up * the instant the discovery service finishes persisting it. */ loopsySessionId?: string; } export interface RecordTranslator { /** Translate a parsed JSON record into zero or more ChatEvents. */ translate(rec: unknown): Generator; /** Final flush — close any open turn. Called at stream end. */ flush(): Generator; } export interface TranscriptAdapter { /** Resolve the absolute file path of the transcript for this session. */ resolveFile(opts: ResolveOptions): Promise; /** Construct a fresh per-stream translator. */ createTranslator(): RecordTranslator; } /** Encode a filesystem path the way Claude does for its projects dir. */ export declare function encodeCwdToClaudeProjectDir(cwd: string): string; export declare const claudeAdapter: TranscriptAdapter; export declare const geminiAdapter: TranscriptAdapter; export declare const codexAdapter: TranscriptAdapter; /** Re-export for chat-event-stream's old callsite that built its own block types. */ export type { ChatBlock }; /** * Pick the adapter for a given agent. Returns null for agents we don't * have transcript support for yet (currently: opencode). */ export declare function adapterForAgent(agent: string): TranscriptAdapter | null; //# sourceMappingURL=transcript-adapters.d.ts.map