import type { Message } from './types.js'; import type { TranscriptStoredRow } from './session-context-for-llm.js'; /** Transcript row for TUI and HTTP clients (flattened from persisted session messages). */ export interface ClientHistoryMessage { id?: string; role: 'user' | 'assistant' | 'system'; content: string; displayIndex?: number; rawContent?: string | unknown[]; /** Persisted inbound attachment metadata used by chat clients to reload media. */ media?: Message['media']; timestamp?: number; kind?: 'message' | 'compaction' | 'context' | 'bash' | 'custom' | 'branch'; tokensBefore?: number; tokensAfter?: number; bash?: { command: string; output?: string; exitCode?: number | null; signal?: string | null; excludeFromContext?: boolean; truncated?: boolean; fullOutputPath?: string; }; custom?: { customType: string; details?: unknown; state?: boolean; display?: boolean; }; branch?: { summary: string; fromId?: string; }; toolCalls?: Array<{ id?: string; name: string; args?: unknown; result?: string; isError?: boolean; details?: unknown; }>; } export declare function flattenMessageContent(content: string | unknown[]): string; /** * Maps gateway/session API messages into a linear chat history for clients. * Tool / toolResult rows are merged into assistant `toolCalls` when ids match; otherwise skipped. */ export declare function messagesToClientHistory(messages: Message[], opts?: { limit?: number; }): ClientHistoryMessage[]; /** * Maps persisted transcript rows into linear chat history, preserving non-LLM * audit rows that the TUI can render as dedicated components. */ export declare function transcriptRowsToClientHistory(rows: TranscriptStoredRow[], opts?: { limit?: number; startRowNumber?: number; endRowNumber?: number; }): ClientHistoryMessage[];