/** * Codex CLI capture connector (Wave 4c, ADR-008). * * OpenAI Codex CLI persists every session as append-only JSONL under * ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl. This module turns those * files into astramem-capture@1 transcript envelopes for POST * /ingest/transcript — the daemon's stage-0 redaction and full distill * pipeline take it from there, identical to Claude Code captures. * * The parser is deliberately tolerant: Codex has shipped several line * shapes across versions (session_meta wrappers, response_item wrappers, * bare message items). Unknown lines are skipped, never fatal — a session * that yields zero usable turns is simply not captured. * * Decision (2026-07-02): Codex first, Cursor postponed — Codex's on-disk * format is open and stable; Cursor stores chats in a proprietary SQLite * blob that breaks on updates. Cursor users get the MCP-recall path. */ export interface CodexTurn { role: 'user' | 'assistant'; text: string; } export interface ParsedCodexSession { sessionId: string; cwd: string | null; turns: CodexTurn[]; } export interface CaptureEnvelope { event: 'session_end'; session_id: string; project_id: string; agent_type: string; cwd?: string; captured_at: string; kind: 'transcript'; tool: 'codex-cli'; turns: Array<{ role: 'user' | 'assistant'; text: string; }>; client_scrub_applied: boolean; client_scrub_hits: number; client_version: string; client_scrub_version: string; wire_version: 'v1.0'; } export declare function defaultCodexSessionsDir(): string; /** Recursively list *.jsonl session files under the Codex sessions dir. */ export declare function scanCodexSessionFiles(dir: string): string[]; export declare function parseCodexSession(jsonl: string, filePath: string): ParsedCodexSession; export declare function buildCodexEnvelope(parsed: ParsedCodexSession, clientVersion: string, capturedAt?: string): CaptureEnvelope; /** Stable idempotency key: same session content → same key → server-side replay. */ export declare function codexIdempotencyKey(parsed: ParsedCodexSession): string; export type CaptureState = Record; export interface CandidateSession { filePath: string; parsed: ParsedCodexSession; size: number; } /** Files that are new or have grown since `state`, parsed to ≥ 2 usable turns. */ export declare function findNewSessions(sessionsDir: string, state: CaptureState): CandidateSession[];