import { IMessage, User } from '../Models'; /** Fields you provide when opening a stream for an assistant reply. */ export type StartStreamInput = Partial & { user: User; }; /** Handle returned by `startStream` to feed tokens into the placeholder message. */ export interface StreamHandle { /** _id of the streaming message. */ id: IMessage['_id']; /** Append a token/chunk to the message text (batched per animation frame). */ push: (chunk: string) => void; /** Replace the whole message text. */ set: (text: string) => void; /** Flush remaining text, clear the streaming flag, optionally patch fields. */ done: (finalPatch?: Partial) => void; /** AbortSignal tied to this stream; pass it to your fetch/LLM call. */ signal: AbortSignal; } export interface UseStreamingMessagesOptions { initialMessages?: TMessage[]; /** Newest message first in the array (matches `` default). Default true. */ inverted?: boolean; } export interface UseStreamingMessagesResult { messages: TMessage[]; setMessages: React.Dispatch>; /** Add message(s) respecting the configured order. */ append: (newMessages: TMessage | TMessage[]) => void; /** Insert an empty assistant message flagged `streaming` and return a feed handle. */ startStream: (assistant: StartStreamInput) => StreamHandle; /** True between `startStream` and `done`/`stop`. */ isStreaming: boolean; /** Abort the active stream (also fires the stream's AbortSignal). */ stop: () => void; } /** * Message state tuned for streamed (AI) replies. Token pushes are coalesced * with `requestAnimationFrame` so a fast stream produces at most one render per * frame, and only the streaming message is updated. */ export declare function useStreamingMessages(options?: UseStreamingMessagesOptions): UseStreamingMessagesResult; //# sourceMappingURL=useStreamingMessages.d.ts.map