/** * @fileoverview Message parsing and section building for the chat UI. * Transforms raw message arrays into structured sections that group * user messages with their corresponding AI responses, sources, and suggestions. * @module components/ResearchAgent/state/chat/buildSections */ import { Message } from "../../components/ChatConversation/ChatWindow"; import { Section } from "../../types/chat"; /** * Transforms a flat array of messages into structured UI sections. * * Each section groups together: * - A user message * - The corresponding AI assistant response * - Source citations used for the response * - Follow-up suggestions * * The function also performs message processing: * - Converts citation markers `[1]`, `[2,3]` into clickable `` elements * - Handles thinking/reasoning tags (`...`) * - Creates a speech-friendly version with citations removed * * @param messages - Array of all chat messages (user, assistant, source, suggestion) * @returns Array of Section objects for rendering in the UI * * @example * ```typescript * const sections = buildSections(messages); * * // userMessage: { role: 'user', content: 'What is React?' }, * // assistantMessage: { role: 'assistant', content: 'React is...' }, * // parsedAssistantMessage: 'React is... 1', * // speechMessage: 'React is...', * // sourceMessage: { sources: [...] }, * // thinkingEnded: true, * // suggestions: ['How does React compare to Vue?', ...] * ``` */ export declare const buildSections: (messages: Message[]) => Section[];