/** * Conversation view for the `/traces` viewer: the same trace, re-told as a * flow of user messages, assistant replies, and tool calls instead of a * latency waterfall. Items are built from the span tree (turns in order, * subtrees in time order) with text pulled from the content attributes — * the user's message from the turn's first model prompt, replies and tool * calls from response/tool spans. */ import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import type { Theme } from "../theme.js"; import type { TraceViewerSurfaces } from "./trace-surfaces.js"; export interface ConversationItem { readonly kind: "system" | "user" | "assistant" | "tool"; /** Detail-drawer source for this item (the turn marker span for users). */ readonly span: LocalTraceSpan; /** Tool name for tool items. */ readonly name?: string; /** Message text for system/user/assistant items. */ readonly text?: string; /** Model reasoning for assistant items (shown dim above the reply). */ readonly reasoning?: string; /** Tool names from the model's tool-call decision (shown when no text). */ readonly toolCallNames?: readonly string[]; /** Raw JSON for tool input / output. */ readonly args?: string; readonly result?: string; /** Assistant card metadata. */ readonly model?: string; readonly inputTokens?: number; readonly outputTokens?: number; /** Gateway-reported inference cost in USD (from the ancestor step span). */ readonly costUsd?: number; /** Set when the item's turn was delegated by another turn (a subagent). */ readonly subagent?: ConversationSubagent; readonly durationMs: number; readonly error: boolean; } /** Dispatch lineage for a subagent turn, read from the turn span. */ export interface ConversationSubagent { /** Subagent name, when the turn arrived through the subagent adapter. */ readonly name?: string; /** Turn id of the dispatching parent turn. */ readonly parentTurnId: string; /** Tool call id of the dispatch, when recorded. */ readonly parentCallId?: string; } /** Builds the conversation flow for a trace, one item per message/action. */ export declare function buildConversationItems(trace: LocalTrace): ConversationItem[]; /** * Renders one conversation card, width-clipped: a title row (bold kind plus * dim metadata, metrics right-aligned) over body rows. With `surfaces` * (derived from the terminal's background via the OSC 11 probe) the card * draws as two elevated bands; without them it falls back to a gutter rail — * the same vocabulary the dev transcript uses. Both layouts occupy identical * rows and columns, so scroll/click math and drag-copy column mapping never * depend on whether the probe was answered. Collapsed cards cap their * payloads; expanded ones render them in full. */ export declare function renderConversationItem(item: ConversationItem, width: number, theme: Theme, selected: boolean, expanded: boolean, surfaces?: TraceViewerSurfaces): string[]; /** Rendered height of one card — the conversation viewport scrolls by lines. */ export declare function conversationItemLineCount(item: ConversationItem, width: number, theme: Theme, expanded: boolean): number; /** Whether a card has content hidden behind the collapsed cap at this width. */ export declare function conversationItemExpandable(item: ConversationItem, width: number): boolean;