import type { NodeName } from '../lib/events' import { NODE_LABELS, TOOL_LABELS } from '../lib/events' import type { TraceEntry } from '../lib/useAgentStream' const NODE_ACCENT: Record = { gatekeeper: 'text-sky-300 border-sky-400/30 bg-sky-400/10', planner: 'text-violet-300 border-violet-400/30 bg-violet-400/10', tool_executor: 'text-amber-300 border-amber-400/30 bg-amber-400/10', auditor: 'text-rose-300 border-rose-400/30 bg-rose-400/10', synthesizer: 'text-emerald-300 border-emerald-400/30 bg-emerald-400/10', } function formatMs(ms?: number) { if (ms === undefined) return null return ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(1)}s` } function Spinner() { return ( ) } function ToolRow({ tool }: { tool: TraceEntry['tools'][number] }) { return (
  • {tool.status === 'running' ? ( ) : tool.status === 'failed' ? ( ✕ ) : ( ✓ )} {TOOL_LABELS[tool.toolName] ?? tool.toolName} {formatMs(tool.durationMs)} {tool.resultCount != null && tool.resultCount > 0 && ( · {tool.resultCount} hits )}

    “{tool.toolInput}”

    {tool.preview && (

    {tool.preview}

    )} {tool.error &&

    {tool.error}

    }
  • ) } function AuditVerdict({ audit }: { audit: NonNullable }) { const replan = audit.action === 'replan' return (
    confidence {[1, 2, 3, 4, 5].map((n) => ( ))} {audit.confidenceScore}/5 {replan ? 'replan' : 'accept'}

    {audit.reasoning}

    ) } function TraceCard({ entry, isLast }: { entry: TraceEntry; isLast: boolean }) { const running = entry.status === 'running' return (
  • {/* Connector down to the next node. */} {!isLast && } {running ? : '✓'}

    {NODE_LABELS[entry.node]}

    {entry.attempt > 1 && ( attempt {entry.attempt} )} {running ? 'running…' : formatMs(entry.durationMs)}
    {entry.plan && (
      {entry.plan.map((step, i) => (
    1. {i + 1}. {TOOL_LABELS[step.tool_name] ?? step.tool_name} {step.tool_input && ( {step.tool_input} )}
    2. ))}
    )} {entry.tools.length > 0 && (
      {entry.tools.map((tool, i) => ( ))}
    )} {entry.audit && }
  • ) } export function AgentTrace({ trace }: { trace: TraceEntry[] }) { if (trace.length === 0) { return (

    Node transitions appear here as the supervisor graph runs — plans, tool calls, and the Auditor's verdict on each one.

    ) } return (
      {trace.map((entry, i) => ( ))}
    ) }