import { type CodexAppServerReadTransport } from "./codex-app-server-transport.js"; export type { CodexAppServerReadTransport } from "./codex-app-server-transport.js"; export type CodexAppServerTurnStatus = "completed" | "interrupted" | "failed" | "inProgress"; export type CodexAppServerThreadStatus = { type: "notLoaded" | "idle" | "systemError"; } | { type: "active"; activeFlags: ("waitingOnApproval" | "waitingOnUserInput")[]; }; export interface CodexAppServerUserInput { type: string; text?: string; [key: string]: unknown; } export interface CodexAppServerThreadItem { id: string; type: string; content?: CodexAppServerUserInput[]; clientId?: string | null; text?: string; phase?: string | null; /** Item-entry timestamps retained by native Status reads; absent on older protocols. */ startedAtMs?: number | null; completedAtMs?: number | null; delivery?: "async" | null; questions?: { title: string; options: string[] | null; }[] | null; [key: string]: unknown; } export interface CodexAppServerTurn { id: string; status: CodexAppServerTurnStatus; items: CodexAppServerThreadItem[]; itemsView: "notLoaded" | "summary" | "full"; error: { message: string; [key: string]: unknown; } | null; startedAt: number | null; completedAt: number | null; durationMs: number | null; [key: string]: unknown; } export interface CodexAppServerThread { id: string; sessionId: string; cwd: string; historyMode: "legacy" | "paginated"; cliVersion: string; originator: string | null; source: unknown; status: CodexAppServerThreadStatus; turns: CodexAppServerTurn[]; [key: string]: unknown; } export interface CodexAppServerItemEntry { turnId: string; item: CodexAppServerThreadItem; startedAtMs: number | null; completedAtMs: number | null; } export interface CodexAppServerPage { data: T[]; nextCursor: string | null; backwardsCursor: string | null; } export interface CodexAppServerMetadata { serverVersion: string; codexHome: string; socketPath: string; platformFamily: string; platformOs: string; } export interface CodexAppServerReadOptions { codexHome: string; expectedServerVersion: string; /** Read-only consumers revalidate the actual response contract on every connection. */ compatibility?: "read_contract"; /** Only the fresh TUI /status binding may discover an audited shared backend patch. */ allowAuditedBackendPatch?: true; timeoutMs?: number; transportFactory?: (options: { socketPath: string; timeoutMs: number; }) => Promise; } export interface CodexAppServerListOptions { threadId: string; cursor?: string; limit?: number; sortDirection?: "asc" | "desc"; } export declare class CodexAppServerReadError extends Error { readonly code: "invalid_response" | "incompatible_server" | "timeout" | "closed" | "rpc_error"; readonly rpcCode?: number | undefined; readonly rpcMessage?: string | undefined; readonly compatibilityDetails?: { stage: "initialize" | "thread/read" | "thread/turns/list" | "thread/items/list"; actual_backend_version?: string; expected_backend_version?: string; compatibility: "exact_version" | "read_contract"; } | undefined; constructor(code: "invalid_response" | "incompatible_server" | "timeout" | "closed" | "rpc_error", message: string, rpcCode?: number | undefined, rpcMessage?: string | undefined, compatibilityDetails?: { stage: "initialize" | "thread/read" | "thread/turns/list" | "thread/items/list"; actual_backend_version?: string; expected_backend_version?: string; compatibility: "exact_version" | "read_contract"; } | undefined); } export declare class CodexAppServerReadClient { private readonly transport; private readonly timeoutMs; private readonly readPolicy; readonly metadata: CodexAppServerMetadata; private readonly pending; private readonly unsubscribe; private nextRequestId; private closed; private constructor(); static connect(options: CodexAppServerReadOptions): Promise; readThread(threadId: string): Promise; listTurns(options: CodexAppServerListOptions & { itemsView?: "notLoaded" | "summary" | "full"; }): Promise>; listItems(options: CodexAppServerListOptions & { turnId?: string; }): Promise>; close(): void; private validatedRead; private withReadContext; private request; private receive; private finish; } export declare const connectCodexAppServerReadClient: typeof CodexAppServerReadClient.connect; export declare function isCodexUnmaterializedThreadError(error: unknown, threadId: string): boolean; export declare function parseCodexAppServerMetadata(value: unknown, options: CodexAppServerReadOptions, socketPath: string): CodexAppServerMetadata;