import type { PartDelta } from '../adapter/types.js'; import type { ChatMessage, MessagePart, TokenUsage } from '../types.js'; import type { ChatAction } from './chatReducer.js'; export interface ReplyFollower { onContent: (chunk: string) => void; onReasoning: (reasoning: string) => void; onPart: (delta: PartDelta) => void; onUsage: (usage: TokenUsage) => void; onFinish: (message: ChatMessage | null) => void; } export interface BackgroundStream { content: string; reasoning: string; parts: MessagePart[]; messageId: string | null; isActive: boolean; owner: object; controller: AbortController; follower: ReplyFollower | null; } interface UseSSEStreamResult { /** Feed a chunk of text into the animation buffer */ onStreamingChunk: (chunk: string) => void; /** Start the animation loop for a conversation */ startStreaming: (conversationId: string) => void; /** Stop the animation loop, flush remaining content */ stopAnimationLoop: () => { unrevealed: string; }; /** Resolves once the buffered text has been revealed, or after maxMs */ drainReveal: (maxMs?: number) => Promise; /** Runs fn once the text received so far has been revealed */ afterReveal: (fn: () => void) => void; /** Reset all animation refs (used when navigating away) */ resetAnimationRefs: () => void; /** Ref to the target content buffer */ targetStreamContentRef: React.RefObject; /** Ref tracking whether streaming is active */ streamActiveRef: React.MutableRefObject; /** Ref tracking which conversation is being streamed */ streamingConversationIdRef: React.MutableRefObject; /** Per-conversation background stream storage */ backgroundStreamsRef: React.MutableRefObject>; /** AbortController ref for canceling fetch requests */ abortControllerRef: React.MutableRefObject; } /** Moves a reveal boundary to the end of the word it falls in, when that end is near. */ export declare function toWordEnd(text: string, end: number): number; /** Characters to reveal after dt ms with remaining characters buffered. */ export declare function revealCount(remaining: number, dt: number): number; export declare function useSSEStream(dispatch: React.Dispatch): UseSSEStreamResult; export {};