import type { ThreadSuggestion, RuntimeCapabilities, ThreadRuntimeCore, SpeechState, VoiceSessionState, ThreadRuntimeEventCallback, ThreadRuntimeEventType, StartRunConfig, ResumeRunConfig } from "../interfaces/thread-runtime-core.js";
import type { ExportedMessageRepository } from "../utils/message-repository.js";
import type { ThreadMessageLike } from "../utils/thread-message-like.js";
import { type MessageRuntime, MessageRuntimeImpl } from "./message-runtime.js";
import type { SubscribableWithState } from "../../subscribable/subscribable.js";
import { type ThreadComposerRuntime, ThreadComposerRuntimeImpl } from "./composer-runtime.js";
import type { ThreadListItemRuntimePath, ThreadRuntimePath } from "./paths.js";
import type { ThreadListItemState } from "./bindings.js";
import type { AppendMessage, ThreadMessage } from "../../types/message.js";
import type { Unsubscribe } from "../../types/unsubscribe.js";
import type { RunConfig } from "../../types/message.js";
import type { ModelContext } from "../../model-context/types.js";
import type { ChatModelRunOptions, ChatModelRunResult } from "../utils/chat-model-adapter.js";
import type { ReadonlyJSONValue } from "assistant-stream/utils";
export type CreateStartRunConfig = {
    parentId: string | null;
    sourceId?: string | null | undefined;
    runConfig?: RunConfig | undefined;
};
export type CreateResumeRunConfig = CreateStartRunConfig & {
    stream?: (options: ChatModelRunOptions) => AsyncGenerator<ChatModelRunResult, void, unknown>;
};
export type CreateAppendMessage = string | {
    parentId?: string | null | undefined;
    sourceId?: string | null | undefined;
    role?: AppendMessage["role"] | undefined;
    content: AppendMessage["content"];
    attachments?: AppendMessage["attachments"] | undefined;
    metadata?: AppendMessage["metadata"] | undefined;
    createdAt?: Date | undefined;
    runConfig?: AppendMessage["runConfig"] | undefined;
    startRun?: boolean | undefined;
};
export type ThreadRuntimeCoreBinding = SubscribableWithState<ThreadRuntimeCore, ThreadRuntimePath> & {
    outerSubscribe(callback: () => void): Unsubscribe;
};
export type ThreadListItemRuntimeBinding = SubscribableWithState<ThreadListItemState, ThreadListItemRuntimePath>;
export type ThreadState = {
    /**
     * The thread ID.
     * @deprecated This field is deprecated and will be removed in 0.12.0. Use `useThreadListItem().id` instead.
     */
    readonly threadId: string;
    /**
     * The thread metadata.
     *
     * @deprecated Use `useThreadListItem()` instead. This field is deprecated and will be removed in 0.12.0.
     */
    readonly metadata: ThreadListItemState;
    /**
     * Whether the thread is disabled. Disabled threads cannot receive new messages.
     */
    readonly isDisabled: boolean;
    /**
     * Whether the thread is loading its history.
     */
    readonly isLoading: boolean;
    /**
     * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend.
     */
    readonly isRunning: boolean;
    /**
     * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc.
     */
    readonly capabilities: RuntimeCapabilities;
    /**
     * The messages in the currently selected branch of the thread.
     */
    readonly messages: readonly ThreadMessage[];
    /**
     * The thread state.
     *
     * @deprecated This feature is experimental
     */
    readonly state: ReadonlyJSONValue;
    /**
     * Follow up message suggestions to show the user.
     */
    readonly suggestions: readonly ThreadSuggestion[];
    /**
     * Custom extra information provided by the runtime.
     */
    readonly extras: unknown;
    /**
     * @deprecated This API is still under active development and might change without notice.
     */
    readonly speech: SpeechState | undefined;
    readonly voice: VoiceSessionState | undefined;
};
export declare const getThreadState: (runtime: ThreadRuntimeCore, threadListItemState: ThreadListItemState) => ThreadState;
export type ThreadRuntime = {
    /**
     * The selector for the thread runtime.
     */
    readonly path: ThreadRuntimePath;
    /**
     * The thread composer runtime.
     */
    readonly composer: ThreadComposerRuntime;
    /**
     * Gets a snapshot of the thread state.
     */
    getState(): ThreadState;
    /**
     * Append a new message to the thread.
     *
     * @example ```ts
     * // append a new user message with the text "Hello, world!"
     * threadRuntime.append("Hello, world!");
     * ```
     *
     * @example ```ts
     * // append a new assistant message with the text "Hello, world!"
     * threadRuntime.append({
     *   role: "assistant",
     *   content: [{ type: "text", text: "Hello, world!" }],
     * });
     * ```
     */
    append(message: CreateAppendMessage): void;
    /**
     * @deprecated pass an object with `parentId` instead. This will be removed in 0.12.0.
     */
    startRun(parentId: string | null): void;
    /**
     * Start a new run with the given configuration.
     * @param config The configuration for starting the run
     */
    startRun(config: CreateStartRunConfig): void;
    /**
     * Resume a run with the given configuration.
     * @param config The configuration for resuming the run
     **/
    resumeRun(config: CreateResumeRunConfig): void;
    /**
     * @deprecated Use `resumeRun` instead.
     */
    unstable_resumeRun(config: CreateResumeRunConfig): void;
    /**
     * Export the thread state in the external store format.
     * For AI SDK runtimes, this returns the AI SDK message format.
     * For other runtimes, this may return different formats or throw an error.
     * @returns The thread state in the external format (typed as any)
     */
    exportExternalState(): any;
    /**
     * Import thread state from the external store format.
     * For AI SDK runtimes, this accepts AI SDK messages.
     * For other runtimes, this may accept different formats or throw an error.
     * @param state The thread state in the external format (typed as any)
     */
    importExternalState(state: any): void;
    /**
     * Load external state into the thread.
     * @deprecated Use importExternalState instead. This method will be removed in 0.12.0.
     * @param state The state to load into the thread
     */
    unstable_loadExternalState(state: any): void;
    subscribe(callback: () => void): Unsubscribe;
    cancelRun(): void;
    getModelContext(): ModelContext;
    /**
     * @deprecated This method was renamed to `getModelContext`.
     */
    getModelConfig(): ModelContext;
    export(): ExportedMessageRepository;
    import(repository: ExportedMessageRepository): void;
    /**
     * Reset the thread with optional initial messages.
     *
     * @param initialMessages - Optional array of initial messages to populate the thread
     */
    reset(initialMessages?: readonly ThreadMessageLike[]): void;
    getMessageByIndex(idx: number): MessageRuntime;
    getMessageById(messageId: string): MessageRuntime;
    /**
     * @deprecated This API is still under active development and might change without notice.
     */
    stopSpeaking(): void;
    connectVoice(): void;
    disconnectVoice(): void;
    getVoiceVolume(): number;
    subscribeVoiceVolume(callback: () => void): Unsubscribe;
    muteVoice(): void;
    unmuteVoice(): void;
    unstable_on<E extends ThreadRuntimeEventType>(event: E, callback: ThreadRuntimeEventCallback<E>): Unsubscribe;
};
export declare class ThreadRuntimeImpl implements ThreadRuntime {
    get path(): ThreadRuntimePath;
    get __internal_threadBinding(): import("../../internal").Subscribable & {
        path: ThreadRuntimePath;
        getState: () => Readonly<{
            getMessageById: (messageId: string) => {
                parentId: string | null;
                message: ThreadMessage;
                index: number;
            } | undefined;
            getBranches: (messageId: string) => readonly string[];
            switchToBranch: (branchId: string) => void;
            append: (message: AppendMessage) => void;
            startRun: (config: StartRunConfig) => void;
            resumeRun: (config: ResumeRunConfig) => void;
            cancelRun: () => void;
            addToolResult: (options: import("../..").AddToolResultOptions) => void;
            resumeToolCall: (options: import("../..").ResumeToolCallOptions) => void;
            speak: (messageId: string) => void;
            stopSpeaking: () => void;
            connectVoice: () => void;
            disconnectVoice: () => void;
            muteVoice: () => void;
            unmuteVoice: () => void;
            submitFeedback: (feedback: import("../..").SubmitFeedbackOptions) => void;
            getModelContext: () => ModelContext;
            composer: Readonly<{
                isEditing: boolean;
                canCancel: boolean;
                isEmpty: boolean;
                attachments: readonly import("../..").Attachment[];
                attachmentAccept: string;
                addAttachment: (fileOrAttachment: File | import("../..").CreateAttachment) => Promise<void>;
                removeAttachment: (attachmentId: string) => Promise<void>;
                text: string;
                setText: (value: string) => void;
                role: import("../..").MessageRole;
                setRole: (role: import("../..").MessageRole) => void;
                runConfig: RunConfig;
                setRunConfig: (runConfig: RunConfig) => void;
                quote: import("../..").QuoteInfo | undefined;
                setQuote: (quote: import("../..").QuoteInfo | undefined) => void;
                reset: () => Promise<void>;
                clearAttachments: () => Promise<void>;
                send: (options?: import("../..").SendOptions) => void;
                cancel: () => void;
                dictation: import("../..").DictationState | undefined;
                startDictation: () => void;
                stopDictation: () => void;
                subscribe: (callback: () => void) => Unsubscribe;
                unstable_on: <E extends import("../..").ComposerRuntimeEventType>(event: E, callback: import("../..").ComposerRuntimeEventCallback<E>) => Unsubscribe;
            }>;
            getEditComposer: (messageId: string) => import("../..").EditComposerRuntimeCore | undefined;
            beginEdit: (messageId: string) => void;
            speech: SpeechState | undefined;
            voice: VoiceSessionState | undefined;
            capabilities: Readonly<RuntimeCapabilities>;
            isDisabled: boolean;
            isLoading: boolean;
            isRunning?: boolean | undefined;
            messages: readonly ThreadMessage[];
            state: ReadonlyJSONValue;
            suggestions: readonly ThreadSuggestion[];
            extras: unknown;
            subscribe: (callback: () => void) => Unsubscribe;
            getVoiceVolume: () => number;
            subscribeVoiceVolume: (callback: () => void) => Unsubscribe;
            import(repository: ExportedMessageRepository): void;
            export(): ExportedMessageRepository;
            exportExternalState(): any;
            importExternalState(state: any): void;
            reset(initialMessages?: readonly ThreadMessageLike[]): void;
            unstable_on<E extends ThreadRuntimeEventType>(event: E, callback: ThreadRuntimeEventCallback<E>): Unsubscribe;
            unstable_loadExternalState: (state: any) => void;
        }>;
    } & {
        outerSubscribe(callback: () => void): Unsubscribe;
    } & {
        getStateState(): ThreadState;
    };
    private readonly _threadBinding;
    constructor(threadBinding: ThreadRuntimeCoreBinding, threadListItemBinding: ThreadListItemRuntimeBinding);
    protected __internal_bindMethods(): void;
    readonly composer: ThreadComposerRuntimeImpl;
    getState(): ThreadState;
    append(message: CreateAppendMessage): void;
    subscribe(callback: () => void): Unsubscribe;
    getModelContext(): ModelContext;
    getModelConfig(): ModelContext;
    startRun(configOrParentId: string | null | CreateStartRunConfig): void;
    resumeRun(config: CreateResumeRunConfig): void;
    /** @deprecated Use `resumeRun` instead. */
    unstable_resumeRun(config: CreateResumeRunConfig): void;
    exportExternalState(): any;
    importExternalState(state: any): void;
    unstable_loadExternalState(state: any): void;
    cancelRun(): void;
    stopSpeaking(): void;
    connectVoice(): void;
    disconnectVoice(): void;
    getVoiceVolume(): number;
    subscribeVoiceVolume(callback: () => void): Unsubscribe;
    muteVoice(): void;
    unmuteVoice(): void;
    export(): ExportedMessageRepository;
    import(data: ExportedMessageRepository): void;
    reset(initialMessages?: readonly ThreadMessageLike[]): void;
    getMessageByIndex(idx: number): MessageRuntimeImpl;
    getMessageById(messageId: string): MessageRuntimeImpl;
    private _getMessageRuntime;
    private _eventSubscriptionSubjects;
    unstable_on<E extends ThreadRuntimeEventType>(event: E, callback: ThreadRuntimeEventCallback<E>): Unsubscribe;
}
//# sourceMappingURL=thread-runtime.d.ts.map