import { type ExtensionUIContext, type ExtensionUIDialogOptions } from "../../extensibility/extensions";
import type { AgentSession } from "../../session/agent-session";
import type { EventBus } from "../../utils/event-bus";
import { RpcSubagentRegistry } from "./rpc-subagents";
import type { RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcHostToolCallRequest, RpcHostToolCancelRequest, RpcHostUriCancelRequest, RpcHostUriRequest, RpcResponse } from "./rpc-types";
export type * from "./rpc-types";
export type PendingExtensionRequest = {
    resolve: (response: RpcExtensionUIResponse) => void;
    reject: (error: Error) => void;
};
type RpcOutput = (obj: RpcResponse | RpcExtensionUIRequest | RpcHostToolCallRequest | RpcHostToolCancelRequest | RpcHostUriRequest | RpcHostUriCancelRequest | object) => void;
export type RpcSessionChangeCommand = Extract<RpcCommand, {
    type: "new_session";
} | {
    type: "switch_session";
} | {
    type: "branch";
}>;
export type RpcSessionChangeResult = {
    type: "new_session";
    data: {
        cancelled: boolean;
    };
} | {
    type: "switch_session";
    data: {
        cancelled: boolean;
    };
} | {
    type: "branch";
    data: {
        text: string;
        cancelled: boolean;
    };
};
export type RpcSessionChangeSession = Pick<AgentSession, "newSession" | "switchSession" | "branch">;
export type RpcSkillCommandSession = Pick<AgentSession, "promptCustomMessage" | "skills" | "skillsSettings">;
export type RpcSkillCommandResult = {
    agentInvoked: true;
};
export declare function tryRunRpcSkillCommand(session: RpcSkillCommandSession, text: string): Promise<RpcSkillCommandResult | false>;
export declare function reportLocalOnlyPromptResult(input: {
    id: string | undefined;
    prompt: Promise<boolean>;
    output: (obj: object) => void;
    onError: (error: Error) => void;
    hasExtensionAgentMessageTask?: () => boolean;
    waitForExtensionAgentMessageTasks?: () => Promise<void>;
}): void;
/**
 * Tracks extension-originated messages while an RPC prompt is executing.
 * A slash command can resolve the outer prompt as local-only while also
 * scheduling agent work through pi.sendUserMessage() or pi.sendMessage()
 * with triggerTurn; that prompt must not report agentInvoked:false to the host.
 */
export declare class RpcExtensionUserMessageTracker {
    #private;
    markAgentMessageTask(): void;
    trackAgentMessageTask(task: Promise<unknown>): void;
    watchPrompt<T>(startPrompt: () => Promise<T>): {
        prompt: Promise<T>;
        hasAgentMessageTask: () => boolean;
        waitForAgentMessageTasks: () => Promise<void>;
    };
}
export declare function watchAndReportLocalOnlyPromptResult(input: {
    id: string | undefined;
    startPrompt: () => Promise<boolean>;
    output: (obj: object) => void;
    onError: (error: Error) => void;
    extensionUserMessageTracker: RpcExtensionUserMessageTracker;
}): void;
export type RpcSubagentResetRegistry = Pick<RpcSubagentRegistry, "clear">;
export declare function handleRpcSessionChange(session: RpcSessionChangeSession, command: RpcSessionChangeCommand, subagentRegistry?: RpcSubagentResetRegistry): Promise<RpcSessionChangeResult>;
export declare function requestRpcEditor(pendingRequests: Map<string, PendingExtensionRequest>, output: RpcOutput, title: string, prefill?: string, dialogOptions?: ExtensionUIDialogOptions, editorOptions?: {
    promptStyle?: boolean;
}): Promise<string | undefined>;
/**
 * Run in RPC mode.
 * Listens for JSON commands on stdin, outputs events and responses on stdout.
 */
export declare function runRpcMode(session: AgentSession, setToolUIContext?: (uiContext: ExtensionUIContext, hasUI: boolean) => void, eventBus?: EventBus): Promise<never>;
