import type { AgentMessage } from "@earendil-works/pi-agent-core";
import type { ImageContent } from "@earendil-works/pi-ai/compat";
import type { BuildSystemPromptOptions } from "../system-prompt.ts";
import type { BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, ContextEvent, Extension, ExtensionContext, ExtensionError, ExtensionEvent, InputEvent, InputEventResult, InputSource, MessageEndEvent, ProjectTrustEvent, ResourcesDiscoverEvent, SessionBeforeCompactResult, SessionBeforeForkResult, SessionBeforeSwitchResult, SessionBeforeTreeResult, ToolCallEvent, ToolCallEventResult, ToolResultEvent, ToolResultEventResult, UserBashEvent, UserBashEventResult } from "./types.ts";
/** Combined result from all before_agent_start handlers. */
export interface BeforeAgentStartCombinedResult {
    messages?: NonNullable<BeforeAgentStartEventResult["message"]>[];
    systemPrompt?: string;
}
export interface ResourcesDiscoverCombinedResult {
    skillPaths: Array<{
        path: string;
        extensionPath: string;
    }>;
    promptPaths: Array<{
        path: string;
        extensionPath: string;
    }>;
    themePaths: Array<{
        path: string;
        extensionPath: string;
    }>;
}
/** Events handled by the generic emit() method. */
export type RunnerEmitEvent = Exclude<ExtensionEvent, ToolCallEvent | ProjectTrustEvent | ToolResultEvent | UserBashEvent | ContextEvent | BeforeProviderRequestEvent | BeforeAgentStartEvent | MessageEndEvent | ResourcesDiscoverEvent | InputEvent>;
export type RunnerEmitResult<TEvent extends RunnerEmitEvent> = TEvent extends {
    type: "session_before_switch";
} ? SessionBeforeSwitchResult | undefined : TEvent extends {
    type: "session_before_fork";
} ? SessionBeforeForkResult | undefined : TEvent extends {
    type: "session_before_compact";
} ? SessionBeforeCompactResult | undefined : TEvent extends {
    type: "session_before_tree";
} ? SessionBeforeTreeResult | undefined : undefined;
type EmitExtensionError = (error: ExtensionError) => void;
export declare function runGenericHandlers<TEvent extends RunnerEmitEvent>(extensions: Extension[], ctx: ExtensionContext, event: TEvent, emitError: EmitExtensionError): Promise<RunnerEmitResult<TEvent>>;
export declare function runMessageEndHandlers(extensions: Extension[], ctx: ExtensionContext, event: MessageEndEvent, emitError: EmitExtensionError): Promise<AgentMessage | undefined>;
export declare function runToolResultHandlers(extensions: Extension[], ctx: ExtensionContext, event: ToolResultEvent, emitError: EmitExtensionError): Promise<ToolResultEventResult | undefined>;
export declare function runToolCallHandlers(extensions: Extension[], ctx: ExtensionContext, event: ToolCallEvent): Promise<ToolCallEventResult | undefined>;
export declare function runUserBashHandlers(extensions: Extension[], ctx: ExtensionContext, event: UserBashEvent, emitError: EmitExtensionError): Promise<UserBashEventResult | undefined>;
export declare function runContextHandlers(extensions: Extension[], ctx: ExtensionContext, messages: AgentMessage[], emitError: EmitExtensionError): Promise<AgentMessage[]>;
export declare function runBeforeProviderRequestHandlers(extensions: Extension[], ctx: ExtensionContext, payload: unknown, emitError: EmitExtensionError): Promise<unknown>;
export declare function runBeforeAgentStartHandlers(extensions: Extension[], baseCtx: ExtensionContext, assertActive: () => void, prompt: string, images: ImageContent[] | undefined, systemPrompt: string, systemPromptOptions: BuildSystemPromptOptions, emitError: EmitExtensionError): Promise<BeforeAgentStartCombinedResult | undefined>;
export declare function runResourcesDiscoverHandlers(extensions: Extension[], ctx: ExtensionContext, cwd: string, reason: ResourcesDiscoverEvent["reason"], emitError: EmitExtensionError): Promise<ResourcesDiscoverCombinedResult>;
export declare function runInputHandlers(extensions: Extension[], ctx: ExtensionContext, text: string, images: ImageContent[] | undefined, source: InputSource, streamingBehavior: "steer" | "followUp" | undefined, emitError: EmitExtensionError): Promise<InputEventResult>;
export {};
//# sourceMappingURL=runner-events.d.ts.map