import { EventEmitter } from 'node:events'; import type { PendingServerRequest, RequestId, RuntimeOperation } from '../types/codex.js'; interface RequestOptions { timeoutMs?: number | undefined; } interface RequestWithBridgeOptions extends RequestOptions { threadId?: string | undefined; bridgeTimeoutMs?: number | undefined; } interface WaitOptions { timeoutMs?: number | undefined; pollIntervalMs?: number | undefined; } export interface AppServerClientOptions { command: string; args: string[]; env: NodeJS.ProcessEnv; codexHome: string; appName?: string | undefined; appVersion?: string | undefined; } export interface BridgedOperationResult { status: 'completed' | 'pending_request' | 'running'; operationId: string; requestId: RequestId; pendingRequestIds: RequestId[]; result?: unknown; } export declare class AppServerClient extends EventEmitter { private readonly options; private readonly pendingRequests; private readonly serverRequests; private readonly operations; private readonly operationsByRequestId; private readonly threadEvents; private process?; private nextRequestCounter; private nextOperationCounter; private buffer; private started; constructor(options: AppServerClientOptions); start(): Promise; stop(): Promise; request(method: string, params: unknown, options?: RequestOptions): Promise; requestWithBridge(method: string, params: unknown, options?: RequestWithBridgeOptions): Promise; waitForOperation(operationId: string, options?: WaitOptions): Promise; getOperation(operationId: string): RuntimeOperation | undefined; listOperations(): RuntimeOperation[]; listOperationsForThread(threadId: string): RuntimeOperation[]; listServerRequests(includeResolved?: boolean): PendingServerRequest[]; getServerRequest(id: RequestId): PendingServerRequest | undefined; respondToServerRequest(id: RequestId, payload: unknown): Promise; getThreadEvents(threadId: string): unknown[]; private sendRequest; private consumeStdout; private handleMessage; private resolveClientRequest; private storeServerRequest; private handleNotification; private updateOperationsFromNotification; /** * Pulls a human-readable message out of an `error` notification. * * The Codex app-server emits `ErrorNotification` with shape * `{ error: { message, codexErrorInfo, additionalDetails }, willRetry, threadId, turnId }` * (see src/protocol/v2/ErrorNotification.ts). We surface the nested message and * append the `codexErrorInfo` tag so downstream classifiers in * `codex-runtime.ts` (isAuthSignal / isRateLimitSignal) can match on keywords * like `unauthorized` or `usageLimitExceeded` to drive profile failover. */ private extractErrorNotificationMessage; private normalizeCodexErrorInfo; private extractThreadIdFromParams; private extractTurnId; private extractTurnError; private writeLine; private evictStaleEntries; } export {};