/**
 * OpenCode SDK Adapter
 *
 * 主干流程：
 * 1. spawn `opencode serve --port <port>` 进程（使用 shell: true）
 * 2. 创建 SDK 客户端连接到该端口
 * 3. 通过 client.session.create() 创建 OpenCode 会话
 * 4. 订阅 SSE 事件流并映射到统一 ProviderEvent
 * 5. 通过 client.session.prompt() 发送用户消息
 *
 * 参考：spectrai-community/src/main/adapter/OpenCodeSdkAdapter.ts
 */
import { EventEmitter } from 'node:events';
import type { AdapterSessionConfig, BaseProviderAdapter, ConversationMessage, SessionStatus } from './types.js';
export declare class OpencodeSdkAdapter extends EventEmitter implements BaseProviderAdapter {
    readonly providerId = "opencode";
    readonly displayName = "OpenCode";
    private sessions;
    private sdkModule?;
    startSession(sessionId: string, config: AdapterSessionConfig): Promise<void>;
    sendMessage(sessionId: string, message: string, options?: {
        keepWaitingStatus?: boolean;
    }): Promise<void>;
    sendConfirmation(sessionId: string, accept: boolean): Promise<void>;
    sendQuestionAnswer(_sessionId: string, _answers: Record<string, string>): Promise<void>;
    setIdleCommands(sessionId: string, commands: {
        idleInputCommand: string;
        nonInputCommand: string;
    }): void;
    abortCurrentTurn(sessionId: string): Promise<void>;
    terminateSession(sessionId: string): Promise<void>;
    getConversation(sessionId: string): ConversationMessage[];
    hasSession(sessionId: string): boolean;
    getProviderSessionId(sessionId: string): string | undefined;
    getSessionStatus(sessionId: string): SessionStatus | undefined;
    getSessionPid(sessionId: string): number | undefined;
    cleanup(): void;
    /**
     * 按需加载 OpenCode SDK：只有启动 OpenCode provider 时才解析依赖，
     * 避免 bridge 基础安装默认携带所有可选 runtime SDK。
     */
    private loadSdk;
    private waitForServer;
    /**
     * 记录 OpenCode serve 启动阶段输出，用于进程提前退出时返回可诊断错误。
     */
    private recordStartupOutput;
    /**
     * 将 OpenCode serve 提前退出信息转成前端可直接展示的错误文本。
     */
    private formatStartupExitMessage;
    /**
     * 异步投递启动提示，避免首轮 OpenCode 处理耗时导致 /runtime/start 被前端误判为启动失败。
     */
    private dispatchInitialPrompt;
    private startSseLoop;
    private runSseLoop;
    private handleOpenCodeEvent;
    private handlePartUpdate;
    private emitEvent;
    private startIdleDetection;
    private stopIdleDetection;
    private checkIdleState;
    private toIdlePrompt;
    private isMessagePollingIdleCommand;
}
//# sourceMappingURL=OpencodeSdkAdapter.d.ts.map