import type { NativeRequests, NativeServerRequests } from "./codex/native-protocol.generated.js"; /** The retained native request types, exposed only through this client surface. */ export type CodexRequestMethod = keyof NativeRequests; /** Native callback handlers receive cancellation when their process is disposed. */ export type CodexServerRequestHandlers = { [M in keyof NativeServerRequests]?: (params: NativeServerRequests[M]["params"], signal: AbortSignal) => Promise; }; /** Explicit process inputs keep managed callers from inheriting ambient credentials. */ export interface CodexAppServerOptions { command: string; args: string[]; cwd: string; env: Record; clientInfo: NativeRequests["initialize"]["params"]["clientInfo"]; requestTimeoutMs?: number; serverRequestTimeoutMs?: number; maxPendingRequests?: number; maxFrameBytes?: number; /** Isolate and reap the native process group on POSIX. */ processGroup?: boolean; onServerRequest?: CodexServerRequestHandlers; /** Final synchronous lifecycle veto before a callback reply; cannot grant a missing handler. */ canReplyToServerRequest?: (method: string, params: unknown) => boolean; onNotification?: (method: string, params: unknown) => void; /** Exactly once on terminal failure or disposal, even with no RPC pending. */ onClose?: (error: CodexAppServerError) => void; } /** Safe error codes never contain stderr, native errors, RPC payloads or credentials. */ export declare class CodexAppServerError extends Error { readonly code: "closed" | "process" | "protocol" | "timeout" | "rejected" | "capacity"; constructor(code: "closed" | "process" | "protocol" | "timeout" | "rejected" | "capacity"); } /** One initialized stdio process with correlated, bounded requests and terminal disposal. */ export declare class CodexAppServerClient { private readonly options; private readonly pending; private readonly callbacks; private readonly timeout; private readonly callbackTimeout; private readonly capacity; private readonly frameLimit; private readonly child; private readonly closed; private terminal; private childClosed; private nextId; private buffer; private constructor(); /** Spawn and finish the native initialize/initialized handshake before returning. */ static connect(options: CodexAppServerOptions, signal?: AbortSignal): Promise; /** Timeout closes this generation, so late replies can never satisfy a later request. */ request(method: M, params: NativeRequests[M]["params"]): Promise; /** Reject pending work immediately and wait a bounded interval for process shutdown. */ dispose(): Promise; /** Positive exit proof for callers that may replace a failed native generation. */ get terminationConfirmed(): boolean; private fail; private write; private receive; private handleServerRequest; } //# sourceMappingURL=codex-app-server.d.ts.map