/**
 * OpenCode Server Manager (Singleton)
 *
 * Manages the lifecycle of a single shared OpenCode server process.
 * Multiple sessions share one server; ref counting shuts it down
 * when the last session releases.
 *
 * @module
 */
/** Session object from the SDK */
export interface OpencodeSession {
    id: string;
    projectID?: string;
    directory?: string;
}
/** SDK response wrapper — all SDK methods return { data, error, request, response } */
export interface SdkResponse<T> {
    data: T | undefined;
    error?: unknown;
}
/** SSE subscribe result — returns { stream: AsyncGenerator<Event> } */
export interface SseSubscribeResult {
    stream: AsyncIterable<unknown>;
}
/** Text part input for prompts */
export interface TextPartInput {
    type: 'text';
    text: string;
}
/** Model information from OpenCode SDK */
export interface OpencodeModel {
    id: string;
    providerID?: string;
    name: string;
}
/** Provider information from OpenCode SDK (config.providers) */
export interface OpencodeProvider {
    id: string;
    name: string;
    models: Record<string, OpencodeModel>;
}
/** Response from config.providers() */
export interface ConfigProvidersResponse {
    providers: OpencodeProvider[];
    default: Record<string, string>;
}
/** Provider entry from provider.list() — includes all available providers */
export interface OpencodeProviderListItem {
    id: string;
    name: string;
    models: Record<string, OpencodeModel>;
}
/** Response from provider.list() */
export interface ProviderListResponse {
    all: OpencodeProviderListItem[];
    default: Record<string, string>;
    connected: string[];
}
/** Model specification for promptAsync */
export interface ModelSpec {
    providerID: string;
    modelID: string;
}
/** Minimal OpenCode client shape matching the real SDK response wrappers */
export interface OpencodeClient {
    session: {
        create(opts: {
            body: {
                title?: string;
            };
        }): Promise<SdkResponse<OpencodeSession>>;
        get(opts: {
            path: {
                id: string;
            };
        }): Promise<SdkResponse<OpencodeSession>>;
        abort(opts: {
            path: {
                id: string;
            };
        }): Promise<SdkResponse<unknown>>;
        promptAsync(opts: {
            path: {
                id: string;
            };
            body: {
                parts: TextPartInput[];
                model?: ModelSpec;
            };
        }): Promise<SdkResponse<void>>;
    };
    event: {
        subscribe(): Promise<SseSubscribeResult>;
    };
    config: {
        providers(): Promise<SdkResponse<ConfigProvidersResponse>>;
    };
    provider: {
        list(): Promise<SdkResponse<ProviderListResponse>>;
    };
}
export interface ServerManagerConfig {
    port?: number;
    cwd?: string;
    stoneforgeRoot?: string;
}
/**
 * Manages a single shared OpenCode 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 OpenCodeServerManager {
    private client;
    private server;
    private refCount;
    private startPromise;
    acquire(config?: ServerManagerConfig): Promise<OpencodeClient>;
    release(): void;
    shutdown(): void;
    /**
     * List all available models from OpenCode providers.
     * Uses provider.list() to get the full catalog (not just configured providers).
     * Each model ID is formatted as `providerID/modelID`.
     * @returns Flattened array of models with composite IDs
     */
    listModels(config?: ServerManagerConfig): Promise<Array<{
        id: string;
        displayName: string;
        description?: string;
        isDefault?: boolean;
        providerName?: string;
    }>>;
    /**
     * Fallback: list models from config.providers() (only configured providers).
     */
    private listModelsFromConfig;
    private startServer;
    private loadSDK;
}
/** Singleton instance */
export declare const serverManager: OpenCodeServerManager;
export {};
//# sourceMappingURL=server-manager.d.ts.map