/** * Utility for processing historical messages from GraphQL/API into * display-ready format. * * Phase 3 of the chat unification reduced this file to DECODE + ENVELOPE: * * - `decodeHistoricalMessageData` maps one persisted `MessageData` item * into the shared `ChatStreamEvent` vocabulary (historical items share * the MESSAGE_TYPE vocabulary with NATS chunks but are NOT full chunk * envelopes — e.g. compaction summaries ride in `summary`, not `text`, * and APPROVAL_RESULT rows carry `resolvedByName` directly); * - `applyHistoryEvent` replays each decoded event into the shared * per-turn kernel (`MessageSegmentAccumulator` — the same kernel the * master `createChatStreamReducer` instantiates) with the * history-specific approval semantics (display-all default, pending * tracking + `flushPendingApprovals`, `approvalStatuses` overrides); * - the ENVELOPE (user/assistant flush-grouping, OWNER_TYPE author / * display-name / avatar resolution, standalone SYSTEM handling, * per-message contextItems mapping, per-turn streamSeq MAX) lives ONCE * in `processHistory` — the previous near-duplicate second copy was * deleted (`processHistoricalMessagesWithErrors` is an alias; the two * snapshots were byte-identical). * * Adapters then feed the processed rows into the reducer via * `initializeWithState` (see `useNatsChatAdapter.loadDialogHistory`). */ import { type HistoricalMessage, type PendingToolCallData, type ProcessedMessage, type MessageProcessingOptions, type MessageData } from '../types'; import { type ChatStreamEvent } from '../../../chat-protocol/events'; /** * Map one persisted `MessageData` item to a normalized `ChatStreamEvent`. * Thin shim over the NATS chunk decoder's core mapping — the differences * are exactly the persisted-row divergences from the realtime envelope: * * - compaction summaries arrive in `summary` (realtime: `text`); * - APPROVAL_RESULT rows carry `resolvedByName` (realtime chunks carry * the resolver's name as `displayName`); * - `approvalType` defaults to 'CLIENT' (legacy history parity; * realtime defaults APPROVAL_REQUEST to 'USER'); * - batch `toolCalls` pass through verbatim (already the persisted * `PendingToolCallData` shape — no normalization pass). * * Returns `null` for rows the assistant-turn path doesn't decode (SYSTEM * is handled by the envelope's standalone path; user TEXT rows are handled * by the envelope's user path). */ export declare function decodeHistoricalMessageData(data: MessageData): ChatStreamEvent | null; type EscalatedApprovals = Map; /** * Result type for historical message processing */ export interface ProcessHistoricalMessagesResult { messages: ProcessedMessage[]; escalatedApprovals: EscalatedApprovals; } /** * Process an array of historical messages into display-ready format */ export declare function processHistoricalMessages(messages: HistoricalMessage[], options?: MessageProcessingOptions): ProcessHistoricalMessagesResult; /** * Extract error messages from historical messages * Returns a separate array of error messages that should be displayed */ export declare function extractErrorMessages(messages: HistoricalMessage[], options?: MessageProcessingOptions): ProcessedMessage[]; /** * Process messages and include error messages in the correct order. * * HISTORICAL ALIAS: this was a byte-identical second copy of * `processHistoricalMessages` (both goldens snapshot identical output on the * same corpus). The duplicate envelope was deleted in Phase 3 — kept as an * alias for the established import sites. */ export declare const processHistoricalMessagesWithErrors: typeof processHistoricalMessages; export {}; //# sourceMappingURL=process-historical-messages.d.ts.map