import type { AiAgentMessage, AiAgentAttachment } from "./App";
import { type AiChatHandler, type AiDecisionChoice, type AiDecisionRequestPayload, type AiDecisionResponsePayload, type AiAgentImageAttachment, type AiEditorContextPayload } from "./client";
import type { AiToolApplyResult, AiToolCall, EasyEmailToolCallsPayload } from "./tools";
export type AiAgentRuntimeStatus = "ready" | "running" | "error";
export type AiAgentSnapshotMeta = {
    id: string;
    title?: string;
    summary?: string | null;
    createdAt: string;
};
export type AiAgentSnapshot = AiAgentSnapshotMeta & {
    template: unknown;
    reason: "before-ai-run" | "after-ai-apply";
    messageId?: string;
};
export type AiAgentHistory = {
    messages: AiAgentMessage[];
    currentSnapshotId?: string;
    snapshots?: AiAgentSnapshotMeta[];
};
export type AiAgentHistoryChange = {
    type: "message.appended";
    messages: AiAgentMessage[];
} | {
    type: "message.updated";
    messageId: string;
    patch: Partial<AiAgentMessage>;
} | {
    type: "snapshot.created";
    snapshot: AiAgentSnapshotMeta;
} | {
    type: "snapshot.restored";
    snapshotId: string;
};
export type UseAiAgentSessionOptions = {
    getTemplate: () => unknown;
    getEditorContext?: () => AiEditorContextPayload | undefined;
    onChat: AiChatHandler;
    onApplyTemplate?: (template: unknown) => void;
    onApplyToolCalls?: (toolCalls: AiToolCall[], payload: EasyEmailToolCallsPayload) => void | AiToolApplyResult | Promise<void | AiToolApplyResult>;
    onUploadGeneratedImage?: (image: AiAgentImageAttachment) => AiAgentImageAttachment | Promise<AiAgentImageAttachment>;
    history?: AiAgentHistory;
    onHistoryChange?: (history: AiAgentHistory, change: AiAgentHistoryChange) => void;
    snapshotsEnabled?: boolean;
    onSnapshotCreate?: (snapshot: AiAgentSnapshot) => void | Promise<void>;
    onRestoreSnapshot?: (snapshotId: string) => void | Promise<void>;
    initialMessages?: AiAgentMessage[];
    onError?: (error: Error) => void;
};
export type AiAgentPendingChange = {
    kind: "tool_calls";
    assistantMessageId: string;
    payload: EasyEmailToolCallsPayload;
    toolCalls: AiToolCall[];
} | {
    kind: "template";
    assistantMessageId: string;
    template: unknown;
    summary?: string | null;
};
export declare function useAiAgentSession(options: UseAiAgentSessionOptions): {
    history: AiAgentHistory;
    messages: AiAgentMessage[];
    snapshots: AiAgentSnapshotMeta[];
    currentSnapshotId: string | undefined;
    status: AiAgentRuntimeStatus;
    activity: string;
    pendingChange: AiAgentPendingChange | null;
    pendingDecision: AiDecisionRequestPayload | null;
    applyingPendingChange: boolean;
    applyPendingChange: () => Promise<void>;
    chooseDecision: (choice: AiDecisionChoice, response: AiDecisionResponsePayload) => Promise<void>;
    clearPendingDecision: () => void;
    restoreSnapshot: (snapshotId: string) => Promise<void>;
    send: (message: string, attachments?: AiAgentAttachment[], decisionResponse?: AiDecisionResponsePayload) => Promise<void>;
    stop: () => Promise<void>;
};
