/**
 * Codex Server Manager (Singleton)
 *
 * Manages the lifecycle of a single shared Codex app-server process.
 * Multiple sessions share one server; ref counting shuts it down
 * when the last session releases.
 *
 * Communicates via JSON-RPC 2.0 over JSONL stdio.
 *
 * @module
 */
import type { NotificationHandler } from './jsonrpc-client.js';
/** Model information returned by the Codex app-server */
export interface CodexModelInfo {
    id: string;
    name?: string;
    description?: string;
}
/** Typed facade over the JSON-RPC client for Codex app-server operations */
export interface CodexClient {
    model: {
        list(params?: {
            limit?: number;
        }): Promise<{
            models?: CodexModelInfo[];
            data?: CodexModelInfo[];
        }>;
    };
    thread: {
        start(params: {
            model?: string;
            cwd?: string;
            approvalPolicy?: string;
            sandbox?: string;
        }): Promise<{
            thread: {
                id: string;
            };
        }>;
        resume(params: {
            threadId: string;
            model?: string;
            cwd?: string;
            approvalPolicy?: string;
            sandbox?: string;
        }): Promise<{
            thread: {
                id: string;
            };
        }>;
        read(params: {
            threadId: string;
        }): Promise<{
            thread: {
                id: string;
            };
        }>;
    };
    turn: {
        start(params: {
            threadId: string;
            input: Array<{
                type: 'text';
                text: string;
            }>;
        }): Promise<void>;
        interrupt(params: {
            threadId: string;
        }): Promise<void>;
    };
    onNotification(handler: NotificationHandler): () => void;
    respondToServer(id: number, result: unknown): void;
    close(): void;
}
export interface ServerManagerConfig {
    cwd?: string;
    stoneforgeRoot?: string;
}
/**
 * Manages a single shared Codex app-server instance.
 *
 * - `acquire()` starts or reuses the server, increments ref count
 * - `release()` decrements ref count, stops server at zero
 * - Concurrent acquire() calls are coalesced into a single startup
 */
declare class CodexServerManager {
    private client;
    private process;
    private rpcClient;
    private refCount;
    private startPromise;
    acquire(config?: ServerManagerConfig): Promise<CodexClient>;
    release(): void;
    shutdown(): void;
    private startServer;
}
/** Singleton instance */
export declare const serverManager: CodexServerManager;
export {};
//# sourceMappingURL=server-manager.d.ts.map