eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
62 lines (61 loc) • 3.33 kB
TypeScript
/**
* 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. Activation and action spans provide the user and tool
* cards directly; model response spans provide assistant cards.
*/
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. */
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 available on a subagent activation or its caller. */
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 from eve's activation, model, and action spans. */
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;