/** * Utility for extracting incomplete message state from historical messages * Used to continue building messages across realtime connections */ import type { ProcessedMessage } from '../types'; import type { InitializeExtras } from '../stream/chat-stream-reducer'; /** * What the realtime accumulator needs to RESUME an unfinished turn. * * DERIVED, not restated: this is exactly the reducer's `InitializeExtras` * minus `escalatedApprovals` (which only the live stream can produce — it has * no historical representation to extract). Hosts pass the result straight * into `reducer.initializeWithState(messages, extras)`, so the two must not * drift; a structural coincidence is not a contract. */ export type IncompleteMessageState = Omit; /** * Extract incomplete message state from the last historical assistant message * Used to initialize realtime chunk processor when continuing an incomplete message */ export declare function extractIncompleteMessageState(lastMessage: ProcessedMessage | undefined): IncompleteMessageState | undefined; /** * THREAD-level generalization of `extractIncompleteMessageState`: given a * processed thread, look at the TRAILING RUN of consecutive assistant * messages (not just the very last row), flatten it to one segment list, and * ask the single-message extractor whether that tail is unfinished. * * Why the run and not the last row: the backend can split one logical turn * across several assistant messages (a preamble bubble, then the approval * card, then the continuation). The unfinished artifact — a pending approval, * an EXECUTING_TOOL with no result, an open compaction — can therefore sit in * an EARLIER bubble of the same trailing run, and a last-row-only check * reports "complete" while the turn is very much still in flight. * * SSOT for every "is the tail incomplete?" question — the NATS adapter (which * used to inline the single-row check) and hosts replaying a stored thread * both call this instead of re-deriving the walk. * * A trailing non-assistant row (user / error) means the last turn closed → * `undefined`. */ export declare function extractIncompleteTailState(messages: readonly ProcessedMessage[] | undefined): IncompleteMessageState | undefined; //# sourceMappingURL=extract-incomplete-message-state.d.ts.map