import { UIMessage, ChatStatus } from 'ai'; import { FunctionCall } from './main'; export interface ChatManagerMessageMetadata extends Record { clientOnly?: boolean; isError?: boolean; userRating?: number; userRatingReason?: string; } export declare class ChatManager = UIMessage> { private readonly _assistantId; private readonly _clientId?; private readonly _emitter; readonly on: { >(type: Key, handler: import("mitt").Handler[Key]>): void; (type: "*", handler: import("mitt").WildcardHandler>): void; }; readonly off: { >(type: Key, handler?: import("mitt").Handler[Key]> | undefined): void; (type: "*", handler: import("mitt").WildcardHandler>): void; }; private _recurringKeepAliveInterval; private _recurringKeepAliveCallers; private _conversationDetails; private _aiSDKChat; private _status; private _messages; private _error?; inputDisabled: boolean; private chatEndingWarningSent; chatEnded: boolean; private _inactivityTimeout; private _inactivityWarningTimeout; private _isStreaming; private _queuedFunctionCalls; options: ChatManagerOptions; get status(): ChatStatus; get messages(): CustomUIMessage[]; get error(): Error | undefined; setStatus(newStatus: ChatStatus, skipHistory?: boolean): void; setMessages(newMessages: CustomUIMessage[], skipHistory?: boolean): void; setError(newError: Error | undefined): void; handleError(error: Error): void; constructor(assistantId: string, options?: Partial>); private isLegacyMessage; private convertLegacyMessageToUIMessage; get lastNonClientOnlyMessage(): CustomUIMessage | undefined; get hasPendingToolCalls(): boolean; get isInputBlocked(): boolean; private onStorageEvent; private onMessageHistoryStorageEvent; endChat(reason?: string, updateUi?: boolean): Promise; stop(): Promise; reset(reason?: string): void; destroy(): void; retrieveQueuedFunctionCalls(): { functionCallId: string; params: Record; rerunLLM: boolean; }[]; respondToFunctionCall(functionCallId: string, params: Record, rerunLLM?: boolean): Promise; private attemptSendQueuedFunctionCalls; stopInactivityTimers(): void; keepAlive(lastActivity?: number, skipHistory?: boolean): void; registerRecurringKeepAlive(): () => void; startChat(): Promise; addClientOnlyMessages(messages: (Omit & Partial>)[]): void; addClientOnlyMessage(message: Omit & Partial>): CustomUIMessage; removeMessage(messageId: string): void; private userMessageTypingId; sendUserMessage(message: string): Promise; rateMessage(messageId: string, rating: number, reason?: string): Promise; sendErrorMessage(content?: string): void; private setConversationDetails; setInputDisabled(inputDisabled: boolean, skipHistory?: boolean): void; setChatEnded(chatEnded: boolean, skipHistory?: boolean): void; setChatEndingWarningSent(warningSent: boolean, skipHistory?: boolean): void; sendChatEndingWarning(): void; get assistantId(): string; get clientId(): string | undefined; get params(): any; get threadId(): string | undefined; get timeUntilChatEnds(): number | null; get timeUntilWarnAboutChatEnding(): number; get chatStarted(): boolean; storageSet(key: string, value: any): void; storageGet(key: string, defaultValue?: any): any; storageRemove(key: string): void; storageRemoveAll(): void; } export interface ChatManagerOptions { params: any; clientId?: string; events?: { [K in keyof ChatManagerEvents]: (event: ChatManagerEvents[K]) => void; }; historyKey: string | null; resetEndedChatOnLoad: boolean; initialReplyMessage?: string | null; welcomeMessage?: string; createThreadHandler?: (options: { assistantId: string; params: any; clientId?: string; welcomeMessage?: string; }) => Promise<{ id: string; inactivityWaitTime?: number; inactivityWarningTime?: number; }>; } export type ChatManagerEvents = { messages: CustomUIMessage[]; status: ChatStatus; inputDisabled: boolean; functionCall: FunctionCall; error: Error; reset: void; destroy: void; chatEnded: void; inactivityWarning: void; }; export type ConversationDetails = { threadId: string; inactivityWaitTime: number; inactivityWarningTime: number; };