import { type ChildProcessWithoutNullStreams } from "node:child_process";
import { ClientSideConnection, type Client as ACPClient, type CreateTerminalRequest, type InitializeResponse, type KillTerminalRequest, type LoadSessionResponse, type NewSessionResponse, type ReadTextFileRequest, type RequestPermissionRequest, type RequestPermissionResponse, type ResumeSessionResponse, type SessionConfigOption, type SessionMode, type SessionModelState, type SessionNotification, type TerminalOutputRequest, type TerminalOutputResponse, type ToolCallContent, type ToolCallLocation, type ToolCallStatus, type ToolKind, type Usage, type WaitForTerminalExitRequest, type WriteTextFileRequest } from "@agentclientprotocol/sdk";
import type { Logger } from "pino";
import type { AgentCapabilityFlags, AgentClient, AgentLaunchContext, AgentMode, AgentModelDefinition, AgentPermissionRequest, AgentPermissionResponse, AgentPersistenceHandle, AgentPromptInput, AgentRunOptions, AgentRunResult, AgentRuntimeInfo, AgentSession, AgentSessionConfig, AgentSlashCommand, AgentStreamEvent, AgentUsage, ListModesOptions, ListModelsOptions, ListPersistedAgentsOptions, PersistedAgentDescriptor } from "../agent-sdk-types.js";
import { type ProviderRuntimeSettings } from "../provider-launch-config.js";
type ACPAgentClientOptions = {
    provider: string;
    logger: Logger;
    runtimeSettings?: ProviderRuntimeSettings;
    defaultCommand: [string, ...string[]];
    defaultModes?: AgentMode[];
    modelTransformer?: (models: AgentModelDefinition[]) => AgentModelDefinition[];
    sessionResponseTransformer?: (response: SessionStateResponse) => SessionStateResponse;
    toolSnapshotTransformer?: (snapshot: ACPToolSnapshot) => ACPToolSnapshot;
    thinkingOptionWriter?: (connection: ClientSideConnection, sessionId: string, thinkingOptionId: string) => Promise<void>;
    capabilities?: AgentCapabilityFlags;
};
type ACPAgentSessionOptions = {
    provider: string;
    logger: Logger;
    runtimeSettings?: ProviderRuntimeSettings;
    defaultCommand: [string, ...string[]];
    defaultModes: AgentMode[];
    modelTransformer?: (models: AgentModelDefinition[]) => AgentModelDefinition[];
    sessionResponseTransformer?: (response: SessionStateResponse) => SessionStateResponse;
    toolSnapshotTransformer?: (snapshot: ACPToolSnapshot) => ACPToolSnapshot;
    thinkingOptionWriter?: (connection: ClientSideConnection, sessionId: string, thinkingOptionId: string) => Promise<void>;
    capabilities: AgentCapabilityFlags;
    handle?: AgentPersistenceHandle;
    launchEnv?: Record<string, string>;
};
type SpawnedACPProcess = {
    child: ChildProcessWithoutNullStreams;
    connection: ClientSideConnection;
    initialize: InitializeResponse;
};
export type ACPToolSnapshot = {
    toolCallId: string;
    title: string;
    kind?: ToolKind | null;
    status?: ToolCallStatus | null;
    content?: ToolCallContent[] | null;
    locations?: ToolCallLocation[] | null;
    rawInput?: unknown;
    rawOutput?: unknown;
};
export type SessionStateResponse = NewSessionResponse | LoadSessionResponse | ResumeSessionResponse;
type TerminalExit = {
    exitCode?: number | null;
    signal?: string | null;
};
export declare function mapACPUsage(usage: Usage | null | undefined): AgentUsage | undefined;
export declare function deriveModesFromACP(fallbackModes: AgentMode[], modeState?: {
    availableModes?: SessionMode[] | null;
    currentModeId?: string | null;
} | null, configOptions?: SessionConfigOption[] | null): {
    modes: AgentMode[];
    currentModeId: string | null;
};
export declare function deriveModelDefinitionsFromACP(provider: string, models: SessionModelState | null | undefined, configOptions?: SessionConfigOption[] | null): AgentModelDefinition[];
export declare class ACPAgentClient implements AgentClient {
    readonly provider: string;
    readonly capabilities: AgentCapabilityFlags;
    protected readonly logger: Logger;
    protected readonly runtimeSettings?: ProviderRuntimeSettings;
    protected readonly defaultCommand: [string, ...string[]];
    protected readonly defaultModes: AgentMode[];
    private readonly modelTransformer?;
    private readonly sessionResponseTransformer?;
    private readonly toolSnapshotTransformer?;
    private readonly thinkingOptionWriter?;
    constructor(options: ACPAgentClientOptions);
    createSession(config: AgentSessionConfig, launchContext?: AgentLaunchContext): Promise<AgentSession>;
    resumeSession(handle: AgentPersistenceHandle, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
    listModels(options?: ListModelsOptions): Promise<AgentModelDefinition[]>;
    listModes(options?: ListModesOptions): Promise<AgentMode[]>;
    listPersistedAgents(options?: ListPersistedAgentsOptions): Promise<PersistedAgentDescriptor[]>;
    isAvailable(): Promise<boolean>;
    protected spawnProcess(launchEnv?: Record<string, string>): Promise<SpawnedACPProcess>;
    protected buildProbeClient(): ACPClient;
    protected closeProbe(probe: SpawnedACPProcess): Promise<void>;
    protected resolveLaunchCommand(): {
        command: string;
        args: string[];
    };
    private assertProvider;
    protected transformSessionResponse(response: SessionStateResponse): SessionStateResponse;
}
export declare class ACPAgentSession implements AgentSession, ACPClient {
    readonly provider: string;
    readonly capabilities: AgentCapabilityFlags;
    private readonly logger;
    private readonly runtimeSettings?;
    private readonly defaultCommand;
    private readonly defaultModes;
    protected readonly modelTransformer?: (models: AgentModelDefinition[]) => AgentModelDefinition[];
    private readonly sessionResponseTransformer?;
    private readonly toolSnapshotTransformer?;
    private readonly thinkingOptionWriter?;
    private readonly launchEnv?;
    private readonly subscribers;
    private readonly pendingPermissions;
    private readonly messageAssemblies;
    private readonly toolCalls;
    private readonly terminalEntries;
    private readonly persistedHistory;
    private readonly initialHandle?;
    private readonly config;
    private child;
    private connection;
    private agentCapabilities;
    private sessionId;
    private currentMode;
    private availableModes;
    private availableModels;
    private currentModel;
    private thinkingOptionId;
    private currentTitle;
    private lastActivityAt;
    private configOptions;
    private cachedCommands;
    private currentTurnUsage;
    private activeForegroundTurnId;
    private closed;
    private historyPending;
    private replayingHistory;
    private suppressUserEchoMessageId;
    private suppressUserEchoText;
    private bootstrapThreadEventPending;
    constructor(config: AgentSessionConfig, options: ACPAgentSessionOptions);
    get id(): string | null;
    initializeNewSession(): Promise<void>;
    initializeResumedSession(): Promise<void>;
    run(prompt: AgentPromptInput, options?: AgentRunOptions): Promise<AgentRunResult>;
    startTurn(prompt: AgentPromptInput, _options?: AgentRunOptions): Promise<{
        turnId: string;
    }>;
    subscribe(callback: (event: AgentStreamEvent) => void): () => void;
    streamHistory(): AsyncGenerator<AgentStreamEvent>;
    getRuntimeInfo(): Promise<AgentRuntimeInfo>;
    getAvailableModes(): Promise<AgentMode[]>;
    getCurrentMode(): Promise<string | null>;
    listCommands(): Promise<AgentSlashCommand[]>;
    setMode(modeId: string): Promise<void>;
    setModel(modelId: string | null): Promise<void>;
    setThinkingOption(thinkingOptionId: string | null): Promise<void>;
    getPendingPermissions(): AgentPermissionRequest[];
    respondToPermission(requestId: string, response: AgentPermissionResponse): Promise<void>;
    describePersistence(): AgentPersistenceHandle | null;
    interrupt(): Promise<void>;
    close(): Promise<void>;
    requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
    sessionUpdate(params: SessionNotification): Promise<void>;
    readTextFile(params: ReadTextFileRequest): Promise<{
        content: string;
    }>;
    writeTextFile(params: WriteTextFileRequest): Promise<Record<string, never>>;
    createTerminal(params: CreateTerminalRequest): Promise<{
        terminalId: string;
    }>;
    terminalOutput(params: TerminalOutputRequest): Promise<TerminalOutputResponse>;
    waitForTerminalExit(params: WaitForTerminalExitRequest): Promise<TerminalExit>;
    releaseTerminal(params: {
        sessionId: string;
        terminalId: string;
    }): Promise<void>;
    killTerminal(params: KillTerminalRequest): Promise<Record<string, never>>;
    private spawnProcess;
    private applySessionState;
    private applyConfiguredOverrides;
    private translateSessionUpdate;
    private createMessageTimelineItem;
    private handleCurrentModeUpdate;
    private handleConfigOptionUpdate;
    private deriveAvailableModels;
    private handleSessionInfoUpdate;
    private handleUsageUpdate;
    private handlePromptResponse;
    private wrapTimeline;
    private pushEvent;
    private finishTurn;
    private emitBootstrapThreadEvent;
    private synthesizeCanceledToolCalls;
    private collectDiagnostic;
    private getSelectConfigOption;
    private getTerminalEntry;
}
export {};
//# sourceMappingURL=acp-agent.d.ts.map