// The single wire-renderer registry. Co-locates tone + label + headline + // detail for every record kind. Because `WIRE_RENDERERS` is typed as a mapped // type over the FULL `RecordType` union, TypeScript REQUIRES an entry for each // kind: adding a kind upstream in agent-core-v2 fails // `pnpm --filter @moonshot-ai/vis-web typecheck` here until a renderer is // added. This is the anti-rot guarantee that keeps vis from silently falling // behind the wire protocol. import type { ReactNode } from 'react'; import type { AgentRecord, AgentRecordOf } from '../../types'; import type { PillTone } from '../shared/Pill'; import { Pill } from '../shared/Pill'; import { Dim, type HeadlineRender, LoopEventDetail, MessageDetail, Mono, ContentPartView, FieldRow, firstText, truncate, loopEventSummary, } from './parts'; import { SizePreview } from '../shared/SizePreview'; import { JsonViewer } from '../shared/JsonViewer'; export type RecordType = AgentRecord['type']; export interface WireRenderer { tone: PillTone; /** Compact badge label. */ label: string; /** One-line collapsed summary. */ headline: (r: AgentRecordOf) => HeadlineRender; /** Expanded detail. Omit to fall back to a full structured JSON dump. */ detail?: (r: AgentRecordOf) => ReactNode; } /** A registry entry for every record kind. The value type is a mapped type * over the full `RecordType` union, so TypeScript forces an entry per kind. */ type RendererMap = { [K in RecordType]: WireRenderer }; interface CompactionSummaryView { label: 'summary' | 'contextSummary'; text: string; contextSummary?: string; message?: UnknownObject; } /** Normalize all three `context.apply_compaction` summary variants without * trusting imported wire payloads. */ function compactionSummaryView( r: AgentRecordOf<'context.apply_compaction'>, ): CompactionSummaryView { const record = r as unknown as UnknownObject; const summary = record.summary; const contextSummary = typeof record.contextSummary === 'string' ? record.contextSummary : undefined; if (typeof summary === 'string') { return { label: 'summary', text: summary, contextSummary: contextSummary === summary ? undefined : contextSummary, }; } const message = asObject(summary); const content = message?.content; if (Array.isArray(content)) { let text = ''; for (const part of content) { const candidate = asObject(part); if (candidate?.type === 'text' && typeof candidate.text === 'string') { text += candidate.text; } } return { label: 'summary', text, contextSummary: contextSummary === text ? undefined : contextSummary, message, }; } if (summary === undefined && contextSummary !== undefined) { return { label: 'contextSummary', text: contextSummary }; } return { label: 'summary', text: invalidValue(summary), contextSummary, }; } type UnknownObject = Record; function asObject(value: unknown): UnknownObject | undefined { return typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as UnknownObject) : undefined; } function wireLineRange(value: unknown): { start: number; end: number } | undefined { const range = asObject(value); if (range === undefined) return undefined; const { start, end } = range; if ( typeof start !== 'number' || !Number.isFinite(start) || !Number.isInteger(start) || start < 0 || typeof end !== 'number' || !Number.isFinite(end) || !Number.isInteger(end) || end < 0 ) { return undefined; } return { start, end }; } function valuePreview(value: unknown): string { if (value === null) return 'null'; if (typeof value === 'string') return JSON.stringify(value); if ( typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint' ) { return String(value); } if (value === undefined) return 'undefined'; try { const serialized = JSON.stringify(value); return serialized === undefined ? `[${typeof value}]` : truncate(serialized, 80); } catch { return '[unserializable]'; } } function invalidValue(value: unknown): string { return value === undefined ? '(missing)' : `(invalid: ${valuePreview(value)})`; } function stringValue(value: unknown): string { return typeof value === 'string' ? value : invalidValue(value); } function numberValue(value: unknown): string { return typeof value === 'number' && Number.isFinite(value) ? String(value) : invalidValue(value); } function checkpointPhase(value: unknown): { label: string; tone: PillTone } { if (value === undefined || value === 'start') return { label: 'start', tone: 'lifecycle' }; if (value === 'end') return { label: 'end', tone: 'success' }; return { label: invalidValue(value), tone: 'warning' }; } function trackedStatus(value: unknown): { label: string; tone: PillTone } { const entry = asObject(value); if (entry === undefined) return { label: 'entry unavailable', tone: 'warning' }; if (entry.oversize === true) return { label: 'oversize', tone: 'warning' }; if (entry.oversize !== undefined && typeof entry.oversize !== 'boolean') { return { label: 'invalid entry', tone: 'warning' }; } if (entry.key === null) return { label: 'new', tone: 'info' }; if (typeof entry.key !== 'string') return { label: 'invalid entry', tone: 'warning' }; if (typeof entry.version !== 'number' || !Number.isFinite(entry.version)) { return { label: 'invalid version', tone: 'warning' }; } return { label: `v${entry.version}`, tone: 'tools' }; } function snapshotKey(entry: UnknownObject | undefined): { label: string; dim: boolean } { if (entry === undefined) return { label: '(entry unavailable)', dim: true }; if (entry.oversize === true) return { label: '(not captured: oversized)', dim: true }; if (entry.key === null) return { label: '(file did not exist)', dim: true }; if (typeof entry.key === 'string') return { label: entry.key, dim: false }; return { label: invalidValue(entry.key), dim: true }; } function sizeValue(value: unknown): string { return typeof value === 'number' && Number.isFinite(value) ? `${value}b` : invalidValue(value); } function timestampValue(value: unknown): string { if (typeof value !== 'number' || !Number.isFinite(value)) return invalidValue(value); return new Date(value).toLocaleString(); } function optionalNumberValue(value: unknown, fallback: string): string { return value === undefined ? fallback : numberValue(value); } function compactionCount(record: UnknownObject): { label: 'compactedCount' | 'count'; value: string } { if (record.compactedCount !== undefined) { return { label: 'compactedCount', value: numberValue(record.compactedCount) }; } if (record.count !== undefined) { return { label: 'count', value: numberValue(record.count) }; } return { label: 'compactedCount', value: '(missing)' }; } export const WIRE_RENDERERS: RendererMap = { metadata: { tone: 'meta', label: 'meta', headline: (r) => ({ main: ( protocol v{r.protocol_version} · created {new Date(r.created_at).toLocaleString()} ), }), }, 'file_history.checkpoint': { tone: 'lifecycle', label: 'files·checkpoint', headline: (r) => { const record = r as unknown as UnknownObject; const phase = checkpointPhase(record.phase); const entries = asObject(record.entries); const count = entries === undefined ? undefined : Object.keys(entries).length; return { main: ( turn {numberValue(record.turnId)} {count === undefined ? 'entries unavailable' : `${count} file${count === 1 ? '' : 's'}`} ), right: ( {phase.label} ), }; }, detail: (r) => { const record = r as unknown as UnknownObject; const phase = checkpointPhase(record.phase); return (
{numberValue(record.turnId)} {phase.label}
); }, }, 'file_history.tracked': { tone: 'tools', label: 'file·tracked', headline: (r) => { const record = r as unknown as UnknownObject; const status = trackedStatus(record.entry); return { main: ( turn {numberValue(record.turnId)} {stringValue(record.path)} ), right: ( {status.label} ), }; }, detail: (r) => { const record = r as unknown as UnknownObject; const entry = asObject(record.entry); const key = snapshotKey(entry); const malformedOversize = entry !== undefined && entry.oversize !== undefined && typeof entry.oversize !== 'boolean'; return (
{numberValue(record.turnId)} {stringValue(record.path)} {entry === undefined ? '(entry unavailable)' : numberValue(entry.version)} {key.dim ? {key.label} : {key.label}} {entry !== undefined && entry.contentHash !== undefined ? ( {stringValue(entry.contentHash)} ) : null} {entry !== undefined && entry.size !== undefined ? ( {sizeValue(entry.size)} ) : null} {entry !== undefined && entry.mtimeMs !== undefined ? ( {timestampValue(entry.mtimeMs)} ) : null} {entry?.oversize === true ? ( true ) : malformedOversize ? ( {invalidValue(entry.oversize)} ) : null}
); }, }, forked: { tone: 'lifecycle', label: 'fork', headline: () => ({ main: session forked }), }, 'config.update': { tone: 'config', label: 'config', headline: (r) => { const cwd = r.environmentDisclosure?.cwd; const effort = r.thinkingEffort ?? r.thinkingLevel; const parts: string[] = []; if (r.profileName !== undefined) parts.push(`profile=${r.profileName}`); if (r.modelAlias !== undefined) parts.push(`model=${r.modelAlias}`); if (cwd !== undefined) parts.push(`cwd=${cwd}`); if (effort !== undefined) parts.push(`thinking=${effort}`); if (r.systemPrompt !== undefined) parts.push(`system(${r.systemPrompt.length}b)`); return { main: ( {parts.length === 0 ? (no fields) : parts.join(' · ')} ), }; }, }, 'profile.bind': { tone: 'config', label: 'profile', headline: (r) => { const parts: string[] = []; if (r.profileName !== undefined) parts.push(`profile=${r.profileName}`); if (r.modelAlias !== undefined) parts.push(`model=${r.modelAlias}`); if (r.thinkingEffort !== undefined) parts.push(`thinking=${r.thinkingEffort}`); if (r.activeToolNames !== undefined) { parts.push(`${r.activeToolNames.length} tools`); } else { parts.push('all tools'); } return { main: ( {parts.length === 0 ? (no fields) : parts.join(' · ')} ), }; }, }, 'turn.prompt': { tone: 'turn', label: 'prompt', headline: (r) => { const text = firstText(r.input); return { main: ( {r.origin.kind} → {truncate(text, 80)} ), }; }, detail: (r) => (
input ({r.input.length} part{r.input.length === 1 ? '' : 's'})
{r.input.map((part, i) => ( ))}
), }, 'turn.steer': { tone: 'turn', label: 'steer', headline: (r) => { const text = firstText(r.input); return { main: ( {r.origin.kind} → {truncate(text, 80)} ), }; }, detail: (r) => (
input ({r.input.length} part{r.input.length === 1 ? '' : 's'})
{r.input.map((part, i) => ( ))}
), }, 'turn.cancel': { tone: 'warning', label: 'cancel', headline: (r) => ({ main: {r.turnId !== undefined ? `turn ${r.turnId}` : '(latest)'}, }), }, 'context.append_message': { tone: 'assistant', label: 'message', headline: (r) => { const m = r.message; const tc = m.toolCalls.length > 0 ? `${m.toolCalls.length} tool_call(s)` : ''; return { main: ( {m.role} ({m.content.length} part{m.content.length === 1 ? '' : 's'}) {tc ? · {tc} : null} {m.origin?.kind ? · origin={m.origin.kind} : null} ), right: m.isError === true ? ( error ) : undefined, }; }, detail: (r) => , }, 'context.append_loop_event': { tone: 'meta', label: 'loop', headline: (r) => ({ main: ( {r.event.type} {loopEventSummary(r.event)} ), }), detail: (r) => , }, 'context.update_token_count': { tone: 'meta', label: 'tokens', headline: (r) => ({ main: context {r.tokenCount} tok }), }, 'context.clear': { tone: 'warning', label: 'clear', headline: () => ({ main: context cleared }), }, 'context.apply_compaction': { tone: 'compaction', label: 'compacted', headline: (r) => { // v2 payload variants: `summary` is a string on current records, a // ContextMessage on the legacy variant (which uses `count` instead of // `compactedCount`); `tokensBefore`/`tokensAfter` are optional. const record = r as unknown as UnknownObject; const summary = compactionSummaryView(r); const compactedCount = compactionCount(record); const wireLines = wireLineRange(record.wireLines); return { main: ( compacted {summary.label} {summary.text.length}b · {optionalNumberValue(record.tokensBefore, '?')}→ {optionalNumberValue(record.tokensAfter, '?')} tok ·{' '} {compactedCount.value} msgs ), right: wireLines === undefined ? undefined : ( L{wireLines.start}–{wireLines.end} ), }; }, detail: (r) => { const record = r as unknown as UnknownObject; const summary = compactionSummaryView(r); const compactedCount = compactionCount(record); const wireLines = wireLineRange(record.wireLines); return (
{summary.text}
{summary.message !== undefined ? ( ) : null} {summary.contextSummary !== undefined ? (
                  {summary.contextSummary}
                
) : null} {compactedCount.value} {optionalNumberValue(record.tokensBefore, '(n/a)')} {optionalNumberValue(record.tokensAfter, '(n/a)')} {record.summaryOutputTokens !== undefined ? ( {numberValue(record.summaryOutputTokens)} ) : null} {record.keptUserMessageCount !== undefined ? ( {numberValue(record.keptUserMessageCount)} ) : null} {record.keptHeadUserMessageCount !== undefined ? ( {numberValue(record.keptHeadUserMessageCount)} ) : null} {record.droppedCount !== undefined ? ( {numberValue(record.droppedCount)} ) : null} {record.legacyTail !== undefined ? ( {typeof record.legacyTail === 'boolean' ? String(record.legacyTail) : invalidValue(record.legacyTail)} ) : null} {wireLines !== undefined ? ( {wireLines.start}–{wireLines.end} ) : null}
); }, }, 'context.undo': { tone: 'warning', label: 'undo', headline: (r) => ({ main: ( undo {r.count} prompt{r.count === 1 ? '' : 's'} ), }), }, 'tools.register_user_tool': { tone: 'tools', label: 'tool+', headline: (r) => ({ main: ( + {r.name} ), }), }, 'tools.unregister_user_tool': { tone: 'tools', label: 'tool-', headline: (r) => ({ main: ( - {r.name} ), }), }, 'tools.set_active_tools': { tone: 'tools', label: 'tools', headline: (r) => { const head = r.names.slice(0, 3).join(', '); const rest = r.names.length > 3 ? ` +${r.names.length - 3} more` : ''; return { main: ( {head} {rest} ), right: {r.names.length} tools, }; }, }, 'tools.reset_active_tools': { tone: 'tools', label: 'reset', headline: () => ({ main: all tools active, }), }, 'tools.update_store': { tone: 'meta', label: 'store', headline: (r) => { const valuePreview = typeof r.value === 'object' && r.value !== null ? '(object)' : truncate(String(r.value), 60); return { main: ( {r.key} = {valuePreview} ), }; }, }, 'permission.set_mode': { tone: 'approval', label: 'perm', headline: (r) => ({ main: ( mode → {r.mode} ), }), }, 'permission.record_approval_result': { tone: 'approval', label: 'approval', headline: (r) => { const tone = r.result.decision === 'approved' ? 'success' : r.result.decision === 'rejected' ? 'error' : 'neutral'; return { main: ( {r.toolName}#{r.toolCallId.slice(-8)} {r.result.decision} {r.result.scope ? ({r.result.scope}) : null} ), }; }, detail: (r) => (
{r.toolName} {r.toolCallId} {r.action} {r.turnId} {r.result.decision} {r.result.scope !== undefined ? ( {r.result.scope} ) : null} {r.sessionApprovalRule !== undefined ? ( {r.sessionApprovalRule} ) : null} {r.result.selectedLabel !== undefined ? ( {r.result.selectedLabel} ) : null} {r.result.feedback !== undefined ? (
{r.result.feedback}
) : null}
), }, 'usage.record': { tone: 'meta', label: 'usage', headline: (r) => ({ main: ( {r.model} in {r.usage.inputOther} / out {r.usage.output} / cache r{r.usage.inputCacheRead} w {r.usage.inputCacheCreation} ), right: r.usageScope ? ( {r.usageScope} ) : undefined, }), }, 'full_compaction.begin': { tone: 'compaction', label: 'compact↻', headline: (r) => ({ main: ( {r.source} {r.instruction ? ( "{truncate(r.instruction, 40)}" ) : null} ), }), }, 'full_compaction.cancel': { tone: 'warning', label: 'compact×', headline: () => ({ main: cancelled }), }, // `full_compaction.complete` has an EMPTY payload (`{}`). The previous code // read `r.summary` / `r.compactedCount` / `r.tokensBefore` / `r.tokensAfter`, // none of which exist on this record — a runtime crash. Those fields belong // to `context.apply_compaction` (its own entry above). This is a static, // payload-free renderer; the generic JSON dump shows type + time only. 'full_compaction.complete': { tone: 'success', label: 'compact✓', headline: () => ({ main: compaction complete }), }, 'micro_compaction.apply': { tone: 'compaction', label: 'µcompact', headline: (r) => ({ main: ( micro cutoff {r.cutoff} ), }), }, 'plan_mode.enter': { tone: 'lifecycle', label: 'plan↻', headline: (r) => ({ main: ( enter {r.id} ), }), }, 'plan_mode.cancel': { tone: 'warning', label: 'plan×', headline: (r) => ({ main: ( cancel {r.id ?? '(latest)'} ), }), }, 'plan_mode.exit': { tone: 'success', label: 'plan✓', headline: (r) => ({ main: ( exit {r.id ?? '(latest)'} ), }), }, 'swarm_mode.enter': { tone: 'subagent', label: 'swarm↻', headline: (r) => ({ main: ( enter {r.trigger} ), }), }, 'swarm_mode.exit': { tone: 'subagent', label: 'swarm✓', headline: () => ({ main: swarm mode exited }), }, 'tower_mode.enter': { tone: 'subagent', label: 'tower↻', headline: () => ({ main: tower mode entered }), }, 'tower_mode.exit': { tone: 'subagent', label: 'tower✓', headline: () => ({ main: tower mode exited }), }, 'goal.create': { tone: 'lifecycle', label: 'goal+', headline: (r) => ({ main: ( goal {r.objective} ), }), }, 'goal.update': { tone: 'lifecycle', label: 'goal', headline: (r) => { const parts: string[] = []; if (r.status !== undefined) parts.push(`status=${r.status}`); if (r.actor !== undefined) parts.push(`by=${r.actor}`); if (r.turnsUsed !== undefined) parts.push(`turns=${r.turnsUsed}`); if (r.tokensUsed !== undefined) parts.push(`tok=${r.tokensUsed}`); return { main: ( {parts.length === 0 ? (no change) : parts.join(' · ')} ), }; }, }, 'goal.clear': { tone: 'warning', label: 'goal×', headline: () => ({ main: goal cleared }), }, // Observability records — the request trace (see the v2 wire manifest). 'llm.tools_snapshot': { tone: 'tools', label: 'req·tools', headline: (r) => ({ main: ( {r.tools.length} tool{r.tools.length === 1 ? '' : 's'} {r.tools .slice(0, 4) .map((tool) => tool.name) .join(', ')} {r.tools.length > 4 ? ` +${r.tools.length - 4} more` : ''} ), right: #{r.hash.slice(0, 8)}, }), }, 'llm.request': { tone: 'meta', label: 'llm→', headline: (r) => { const parts: string[] = []; if (r.turnStep !== undefined) parts.push(`step ${r.turnStep}`); if (r.attempt !== undefined) parts.push(`attempt ${r.attempt}`); parts.push(`${r.messageCount} msgs`); if (r.maxTokens !== undefined) parts.push(`max ${r.maxTokens} tok`); return { main: ( {r.kind} {r.model} {parts.join(' · ')} ), right: r.projection !== undefined ? ( {r.projection} ) : undefined, }; }, detail: (r) => (
{r.provider} {r.model} {r.modelAlias !== undefined ? ( {r.modelAlias} ) : null} {r.thinkingEffort !== undefined ? ( {r.thinkingEffort} ) : null} {r.thinkingKeep !== undefined ? ( {r.thinkingKeep} ) : null} {r.temperature !== undefined ? ( {r.temperature} ) : null} {r.topP !== undefined ? ( {r.topP} ) : null} {r.maxTokens !== undefined ? ( {r.maxTokens} ) : null} {r.betaApi !== undefined ? ( {String(r.betaApi)} ) : null} {String(r.toolSelect)} {r.toolsHash} {r.systemPromptHash} {r.systemPrompt !== undefined ? (
{r.systemPrompt}
) : null} {r.droppedCount !== undefined ? ( {r.droppedCount} ) : null}
), }, 'mcp.tools_discovered': { tone: 'tools', label: 'mcp·list', headline: (r) => ({ main: ( {r.serverName} {r.tools.length} tool{r.tools.length === 1 ? '' : 's'} · {r.enabledNames.length}{' '} enabled ), right: r.collisions !== undefined && r.collisions.length > 0 ? ( {r.collisions.length} collision{r.collisions.length === 1 ? '' : 's'} ) : ( #{r.hash.slice(0, 8)} ), }), }, 'turn.ended': { tone: 'turn', label: 'turn✓', headline: (r) => ({ main: ( turn {r.turnId} {r.reason} {r.durationMs !== undefined ? {r.durationMs}ms : null} {r.stopReason !== undefined ? ( {truncate(r.stopReason, 80)} ) : null} ), }), }, 'turn.step.interrupted': { tone: 'warning', label: 'step×', headline: (r) => ({ main: ( turn {r.turnId} · step {r.step} {r.reason} ), }), }, 'turn.step.retrying': { tone: 'warning', label: 'retry↻', headline: (r) => ({ main: ( turn {r.turnId} · step {r.step} attempt {r.nextAttempt}/{r.maxAttempts} {r.errorName}: {truncate(r.errorMessage, 60)} ), }), }, 'prompt.accepted': { tone: 'turn', label: 'prompt+', headline: (r) => ({ main: {r.promptId} }), }, 'prompt.aborted': { tone: 'warning', label: 'prompt×', headline: (r) => ({ main: {r.promptId} }), }, 'prompt.completed': { tone: 'turn', label: 'prompt✓', headline: (r) => ({ main: ( {r.promptId} {r.reason} ), }), }, 'prompt.steered': { tone: 'turn', label: 'steer→', headline: (r) => ({ main: → {truncate(firstText(r.content), 80)}, }), }, 'interaction.request': { tone: 'approval', label: 'ask→', headline: (r) => ({ main: ( {r.kind} {r.id} ), }), }, 'interaction.resolved': { tone: 'approval', label: 'ask✓', headline: (r) => ({ main: {r.id} }), }, 'task.started': { tone: 'subagent', label: 'task↻', headline: (r) => ({ main: {r.info.taskId} }), }, 'task.terminated': { tone: 'subagent', label: 'task✓', headline: (r) => ({ main: ( {r.info.taskId} {r.info.status} ), }), }, 'task.waitDelivered': { tone: 'subagent', label: 'task⇢', headline: (r) => ({ main: ( wait delivered · {r.keys.length} task{r.keys.length === 1 ? '' : 's'} ), }), }, 'token_counting.measured': { tone: 'meta', label: 'tokens', headline: (r) => ({ main: context {r.tokens} tok (measured) }), }, 'token_counting.truncated': { tone: 'meta', label: 'tokens', headline: (r) => ({ main: context {r.tokens} tok (truncated @ {r.length}) }), }, 'token_counting.rebased': { tone: 'meta', label: 'tokens', headline: (r) => ({ main: ( context {r.tokens} tok (rebased{r.measured ? ', measured' : ''}) ), }), }, 'token_counting.turn_recorded': { tone: 'meta', label: 'tokens', headline: (r) => ({ main: context {r.tokens} tok (turn {r.turnId}) }), }, 'cron.add': { tone: 'lifecycle', label: 'cron+', headline: (r) => ({ main: ( {r.task.cron} {truncate(r.task.prompt, 60)} ), }), }, 'cron.delete': { tone: 'warning', label: 'cron−', headline: (r) => ({ main: ( {r.ids.length} task{r.ids.length === 1 ? '' : 's'} deleted ), }), }, 'cron.cursor': { tone: 'lifecycle', label: 'cron·fired', headline: (r) => ({ main: ( {r.id} fired {new Date(r.lastFiredAt).toLocaleString()} ), }), }, 'plan.revision': { tone: 'lifecycle', label: 'plan·rev', headline: (r) => ({ main: ( plan {r.id} · v{r.version} {r.bytes}b ), }), }, 'plugin.session_start': { tone: 'meta', label: 'plugin', headline: (r) => ({ main: ( session start{r.content !== null ? `: ${truncate(r.content, 60)}` : ''} ), }), }, 'runtime.set_binding': { tone: 'meta', label: 'runtime', headline: (r) => ({ main: ( {r.runtimeId} workspace {r.workspaceId} ), }), }, 'staleGuard.recorded': { tone: 'meta', label: 'stale', headline: (r) => ({ main: {r.path} }), }, 'staleGuard.cleared': { tone: 'meta', label: 'stale✓', headline: () => ({ main: stale guard cleared }), }, 'interruptionReminder.recorded': { tone: 'meta', label: 'interrupted', headline: (r) => ({ main: interruption reminder · turn {r.turnId} }), }, }; /** Look up a renderer by a runtime `type` string. Returns `undefined` for kinds * outside the known union (best-effort parse of a future/legacy/foreign * protocol), which the callers render via the generic fallback. * * Legacy/foreign runtime-only kinds (e.g. `goal.account_usage`, * `goal.continuation`, `background.stop`) are intentionally NOT given registry * entries: they sit outside the typed `AgentRecord` union, so this returns * `undefined` and they fall back to a readable generic render — `TypeBadge` * shows the raw `type` string (neutral tone, `title` tooltip), the headline * shows `(unknown record type: …)`, and the detail shows the full JSON. That is * legible enough; no friendly-label map is warranted. * * The `as unknown as` widening is the one place we sidestep TypeScript's * correlated-union limitation: each entry's `headline`/`detail` is narrowed to * its own kind, but at dispatch time we only have the union, so we widen the * value to `WireRenderer` (callable with any `AgentRecord`). Safe * because we only ever call it with the matching record. */ export function rendererFor(type: string): WireRenderer | undefined { return (WIRE_RENDERERS as unknown as Record>)[type]; }