/** * One trace model for every run kind, so the detail view is a single, uniform * timeline. A run is a flat list of steps (chat turns / execution events); a * loop adds one level of nesting (phases that wrap their work), rendered as * collapsible groups in the SAME timeline — the loop is fused in, not a * separate view. * * chat → conversation turns (user / assistant, with tool calls) * task → session log events ({ ts, event, data }) * loop → phases (steps) wrapping tool/transition events * * Pure module: converters run on the server page, the client `` renders. */ export type TraceActor = "user" | "assistant" | "system" | "tool" | "event"; export type TraceTone = "neutral" | "success" | "running" | "failed" | "warning"; /** * A payload block attached to a step (tool input/output, event data). The * renderer auto-detects the best presentation (JSON / code / markdown / text); * a `format` hint forces one when the shape is known. */ export type TracePayload = { label: string; value: string; format?: "auto" | "json" | "code" | "markdown" | "text"; lang?: string; }; /** A leaf item — a conversation turn or an execution event. */ export type TraceStep = { kind?: "step"; id: string; actor: TraceActor; label: string; sublabel?: string; body?: string; /** Render the body as markdown (chat turns) vs auto-detect (events). */ markdown?: boolean; status?: string; tone?: TraceTone; ts?: string; payload?: TracePayload[]; /** The original source object, verbatim — for the raw/log view. */ raw?: unknown; }; /** A group (a loop step/phase) that wraps child steps — one nesting level. */ export type TracePhase = { kind: "phase"; id: string; label: string; status?: string; tone: TraceTone; startTs?: string; endTs?: string; children: TraceStep[]; }; export type TraceNode = TraceStep | TracePhase; /** Back-compat alias — callers historically import `TraceItem`. */ export type TraceItem = TraceStep; type RawToolCall = { id?: string; name?: string; toolName?: string; arguments?: unknown; input?: unknown; args?: unknown; result?: unknown; output?: unknown; state?: string; }; type RawChatMessage = { id?: string; role?: string; content?: unknown; ts?: string; createdAt?: string; toolCalls?: RawToolCall[]; reasoning?: string; reasoningTruncated?: boolean; }; /** * Flattens a chat thread into the raw transcript: one step per message, then * one step per tool call (name + input + output) so the full trace shows every * call as its own row instead of folding them into the assistant message. */ export declare function chatToItems(messages: RawChatMessage[]): TraceStep[]; type RawLogEntry = { ts?: string; event?: string; type?: string; tool?: string; data?: unknown; text?: string; content?: unknown; input?: unknown; }; export declare function logToItems(entries: RawLogEntry[]): TraceStep[]; type RawRunRecord = { id?: string; status?: string; engine?: string; delivery?: string; executionMode?: string; startedAt?: string; completedAt?: string; updatedAt?: string; result?: { exitCode?: number; stdout?: string; stderr?: string; duration?: number; }; }; /** Durable Run lifecycle rows, independent from the conversational transcript. */ export declare function runToItems(run?: RawRunRecord | null): TraceStep[]; type RawLoopEvent = { id?: string; type: string; ts?: string; step?: string; stepKey?: string; tool?: string; from?: string; to?: string; fromStepKey?: string; toStepKey?: string; status?: string; input?: unknown; output?: unknown; error?: string; data?: unknown; }; /** * A debug trace shows EVERY loop event as its own flat row — loop.start/end, * step.start/end, tool.call/result, transitions, permission/policy results — * verbatim, in order, no phase folding or hiding of structural markers. */ export declare function loopToNodes(events: RawLoopEvent[]): TraceNode[]; export {}; //# sourceMappingURL=trace-detail.d.ts.map