import type { ArtifactDocument } from '../../lib/agent-tools'; import type { TelemetrySnapshot, ToolEvent } from '../../lib/contracts'; import { formatBytes, formatPercent } from '../../lib/format'; interface InspectorPanelProps { hidden?: boolean; telemetry: TelemetrySnapshot; toolEvents: ToolEvent[]; artifacts: ArtifactDocument[]; onSelectArtifact: (artifactId: string) => void; } export function InspectorPanel({ hidden = false, telemetry, toolEvents, artifacts, onSelectArtifact }: InspectorPanelProps) { const contextRatio = telemetry.contextLimit > 0 ? telemetry.contextUsed / telemetry.contextLimit : 0; const prefillRatio = telemetry.promptTotal > 0 ? telemetry.promptProcessed / telemetry.promptTotal : 0; const activeRate = telemetry.inferencePhase === 'prefill' ? telemetry.prefillTokensPerSecond : telemetry.decodeTokensPerSecond || telemetry.tokensPerSecond; const speedRatio = Math.min(1, Math.max(0, activeRate / 50)); const gaugeLabel = telemetry.inferencePhase === 'prefill' ? 'Prefill' : telemetry.inferencePhase === 'decode' ? 'Decode' : 'Average'; const samplingLabel = telemetry.inferencePhase === 'idle' ? 'Ready' : telemetry.inferencePhase === 'complete' ? 'Average' : 'Live'; return ( ); } function TelemetryMetric({ label, value, detail, ratio, active, progressLabel, }: { label: string; value: string; detail: string; ratio: number; active: boolean; progressLabel: string; }) { const percentage = Math.round(Math.min(1, Math.max(0, ratio)) * 100); return (
{label}{value}
{detail}
); } function Meter({ label, value, detail }: { label: string; value: number; detail: string }) { const percentage = Math.round(Math.min(1, Math.max(0, value)) * 100); return (
{label}{detail}
); }