/** * What a Codex rollout file is: where it lives, how it is named, and which entries it holds. * * Every fact here was confirmed against codex-cli 0.146.0 (Constraints: "Facts about Codex are * verified against the installed version, never assumed"). The entry names below are the ones * C-7 and C-8 measured: `event_msg` drives the visible history and the picker preview, * `response_item` drives the model history only. */ import type { HomePath, SessionId } from "./contract.js"; /** Codex reads this variable to find its home; so does this adapter (FR-2, FR-3). */ export declare const CODEX_HOME_ENV = "CODEX_HOME"; /** The version this module's format knowledge was verified against. */ export declare const CODEX_CLI_VERSION = "0.146.0"; /** Recorded in the rollout so a thread imported by this tool is identifiable. */ export declare const CODEX_ORIGINATOR = "resume-from"; /** `thread/list`'s default filter keeps interactive sources; "cli" is one of them (C-7). */ export declare const CODEX_SOURCE_CLI = "cli"; export declare const CODEX_ENTRY_SESSION_META = "session_meta"; export declare const CODEX_ENTRY_EVENT_MSG = "event_msg"; export declare const CODEX_ENTRY_RESPONSE_ITEM = "response_item"; export declare const CODEX_ENTRY_COMPACTED = "compacted"; export declare const CODEX_EVENT_USER_MESSAGE = "user_message"; export declare const CODEX_EVENT_AGENT_MESSAGE = "agent_message"; export declare const CODEX_ITEM_FUNCTION_CALL = "function_call"; export declare const CODEX_ITEM_FUNCTION_CALL_OUTPUT = "function_call_output"; export declare const CODEX_ITEM_CUSTOM_TOOL_CALL = "custom_tool_call"; export declare const CODEX_ITEM_CUSTOM_TOOL_CALL_OUTPUT = "custom_tool_call_output"; /** * Top-level entry types codex-cli 0.146.0 writes. An entry outside this set is an entry this * module does not understand: it is skipped and counted, never guessed at (C-6). */ export declare const KNOWN_ENTRY_TYPES: ReadonlySet; /** One JSONL line of a rollout file. */ export interface RolloutEntry { timestamp: string; type: string; payload: Record; } /** The `session_meta` payload, in the fields this module uses. */ export interface CodexSessionMeta { id: string; timestamp: string | null; cwd: string | null; commit: string | null; branch: string | null; } /** Always absolute: a HomePath is an absolute path, whatever the environment holds (FR-2). */ export declare function defaultCodexHome(): HomePath; export declare function sessionsRoot(home: HomePath): string; /** `/sessions/YYYY/MM/DD/rollout-YYYY-MM-DDTHH-mm-ss-.jsonl`, as Codex lays them out. */ export declare function rolloutFilePath(home: HomePath, sessionId: SessionId, at: Date): string; /** True when the file name is a rollout the picker would consider. */ export declare function isRolloutFileName(name: string): boolean; /** The exact thread id encoded after Codex's fixed timestamp prefix. */ export declare function sessionIdFromRolloutFileName(name: string): string | null; /** Rollouts below one sessions root, without following symlinks or hiding I/O failures. */ export declare function listRolloutFiles(root: string): Promise; export declare function parseEntry(line: string): RolloutEntry | null; /** * A rollout that cannot be parsed line for line is truncated: Codex writes one whole JSON * object per line, so a line that is not one means the file was cut mid-entry. */ export declare function parseRolloutText(text: string): { entries: RolloutEntry[]; truncated: boolean; }; export declare function stringifyRollout(entries: RolloutEntry[]): string; export declare function payloadType(entry: RolloutEntry): string; /** The entries Codex renders as history, and the only ones this module writes (C-7, C-8). */ export declare function isMessageEvent(entry: RolloutEntry): boolean; export declare function messageTextOf(entry: RolloutEntry): string; export declare function readSessionMeta(entry: RolloutEntry): CodexSessionMeta | null; export declare function isNotFoundError(error: unknown): boolean; /** ISO-8601 UTC, or null when the source recorded nothing usable. */ export declare function toIsoUtc(value: string | null): string | null;