/** * feed-serializer — rebuild the TUI feed from persisted messages. * * When a session is resumed, its `Message[]` history must be projected back * into the `FeedEntry` union the feed renders. During a live run, entries are * built imperatively from `StepResult` callbacks (see use-agent.ts); on replay * there is no loop, so this pure function does the equivalent mapping in one * pass. * * `manage_todos` is handled exactly like the live path: it updates the * persistent todo panel, NOT the feed. The most-recent `manage_todos` result is * returned as `latestTodos` so the caller (session resume) can restore the * pinned panel — otherwise the todos would only appear as a scrolling box. * * Tool results are NOT stored on the assistant message's toolCalls[].result — * runAgentLoop emits them as separate role:"tool" messages linked by * toolCallId (agent-loop.ts:459). This serializer joins the two so replayed * tool blocks show their output. Tool durationMs is not persisted, so replayed * blocks render without duration (cosmetic only). */ import type { Message } from '../../../core/types.js'; import type { FeedEntryInput } from './types.js'; import type { Todo } from './components/goal-status.js'; export interface RebuiltFeed { entries: FeedEntryInput[]; /** The most-recent manage_todos result (the current todo list), or null. */ latestTodos: Todo[] | null; } export declare function messagesToFeedEntries(messages: Message[]): RebuiltFeed;