{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-console",
  "title": "Relay, AI agent control room",
  "description": "Supervise a coding agent and its subagents: set its autonomy, balance effort between subagents, hold the dead man's switch, and lift the cover to ship. A whole screen for a Next.js app, at /agent-console.",
  "dependencies": [],
  "registryDependencies": [
    "https://bevel-ui.vercel.app/r/bevel.json",
    "https://bevel-ui.vercel.app/r/annunciator.json",
    "https://bevel-ui.vercel.app/r/engine-telegraph.json",
    "https://bevel-ui.vercel.app/r/guarded-switch.json",
    "https://bevel-ui.vercel.app/r/mixer-strip.json",
    "https://bevel-ui.vercel.app/r/push-to-talk.json",
    "https://bevel-ui.vercel.app/r/task-plan.json",
    "https://bevel-ui.vercel.app/r/vigilance.json"
  ],
  "files": [
    {
      "path": "registry/bevel/blocks/agent-console/relay/relay-app.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  Annunciator,\n  AnnunciatorAcknowledge,\n  AnnunciatorPanel,\n  AnnunciatorTile,\n} from \"@/components/ui/annunciator\"\nimport {\n  EngineTelegraph,\n  EngineTelegraphDial,\n  EngineTelegraphOrder,\n  EngineTelegraphOrders,\n  EngineTelegraphStatus,\n} from \"@/components/ui/engine-telegraph\"\nimport {\n  GuardedSwitch,\n  GuardedSwitchControl,\n  GuardedSwitchLabel,\n  GuardedSwitchStatus,\n} from \"@/components/ui/guarded-switch\"\nimport {\n  Mixer,\n  MixerStrip,\n  MixerStripFader,\n  MixerStripMute,\n  MixerStripName,\n  MixerStripSolo,\n} from \"@/components/ui/mixer-strip\"\nimport { PushToTalk, PushToTalkKey, PushToTalkStatus } from \"@/components/ui/push-to-talk\"\nimport {\n  TaskPlan,\n  TaskPlanHeader,\n  TaskPlanProgress,\n  TaskPlanStep,\n  TaskPlanSteps,\n  TaskPlanTitle,\n} from \"@/components/ui/task-plan\"\nimport { Vigilance, VigilanceButton, VigilanceLamps, VigilanceTimer } from \"@/components/ui/vigilance\"\nimport { cn } from \"@/lib/utils\"\nimport { demoMilestone } from \"../shared/events\"\nimport { Legend, PanelKey, Screws, StatusStrip } from \"../shared/environment\"\nimport { consoleFace } from \"../shared/fonts\"\nimport { baseSeconds, channelOf, currentIndex, initialRun, runReducer, voiceNotes, type Phase } from \"./run\"\n\ntype Autonomy = \"stop\" | \"plan\" | \"ask\" | \"act\" | \"auto\"\n\nconst autonomyMeaning: Record<Autonomy, string> = {\n  stop: \"The agent holds where it is and changes nothing.\",\n  plan: \"The agent reads and plans, but holds before changing any files.\",\n  ask: \"The agent asks you before each step that changes files or runs tests.\",\n  act: \"The agent works through the plan on its own. Merging is still yours.\",\n  auto: \"The agent works faster and doesn't stop to explain. Merging is still yours.\",\n}\n\ntype Channel = { name: string; share: number; by: string; muted: boolean }\n\nconst startChannels: Channel[] = [\n  { name: \"Explore\", share: 70, by: \"Lead\", muted: false },\n  { name: \"Code\", share: 40, by: \"Lead\", muted: false },\n  { name: \"Tests\", share: 20, by: \"Lead\", muted: false },\n  { name: \"Docs\", share: 15, by: \"Lead\", muted: false },\n]\n\n/** Effort above this, summed across subagents, is over the run's budget. */\nconst BUDGET = 220\nconst CHECK_IN_MS = 30000\nconst SUPERVISOR = \"Mara Okafor\"\n\nconst needsApproval = (phase: Phase) => phase === \"code\" || phase === \"tests\" || phase === \"you\"\n\n/** Relay: one person supervising a coding agent and its subagents through a run. */\nexport function RelayApp() {\n  // A new run starts everything over.\n  const [runKey, setRunKey] = React.useState(0)\n  return <RelayRun key={runKey} onNewRun={() => setRunKey((k) => k + 1)} />\n}\n\nfunction RelayRun({ onNewRun }: { onNewRun: () => void }) {\n  const [run, dispatch] = React.useReducer(runReducer, initialRun)\n  const [order, setOrder] = React.useState<Autonomy>(\"ask\")\n  const [autonomy, setAutonomy] = React.useState<Autonomy>(\"ask\")\n  const [paused, setPaused] = React.useState(false)\n  const [channels, setChannels] = React.useState(startChannels)\n  const [solo, setSolo] = React.useState<string | null>(null)\n  const [talking, setTalking] = React.useState(false)\n  const [seconds, setSeconds] = React.useState(0)\n  const [voiceLog, setVoiceLog] = React.useState<string[]>([])\n  const [shipNote, setShipNote] = React.useState(\"\")\n\n  const at = currentIndex(run)\n  const step = run.steps[at]\n  const done = run.steps.filter((s) => s.status === \"done\").length\n  const channelName = step ? channelOf[step.phase] : null\n  const channel = channels.find((c) => c.name === channelName)\n  const isRunning = (c: Channel) => !c.muted && (solo === null || solo === c.name) && !paused\n  const totalEffort = channels.reduce((sum, c) => sum + (c.muted ? 0 : c.share), 0)\n\n  // Why the agent isn't working on the current step, if it isn't.\n  const hold = (() => {\n    if (run.shipped) return \"Merged.\"\n    if (!step) return \"Nothing left in the plan.\"\n    if (paused) return \"Paused: nobody checked in.\"\n    if (autonomy === \"stop\") return \"Holding: autonomy is at Stop.\"\n    if (step.phase === \"ship\") return run.testsFailing ? \"Holding: tests are failing.\" : \"Waiting for you to merge.\"\n    if (autonomy === \"plan\" && step.phase !== \"research\") return \"Holding: autonomy is at Plan, so no file changes.\"\n    if (channel && channel.muted) return `Holding: ${channel.name} is muted.`\n    if (channel && solo !== null && solo !== channel.name) return `Holding: ${solo} is soloed, so ${channel.name} waits.`\n    if (autonomy === \"ask\" && needsApproval(step.phase) && !step.approved) return \"Waiting for your approval.\"\n    return null\n  })()\n  const working = hold === null\n  const awaitingApproval = hold === \"Waiting for your approval.\"\n  const readyToShip = !!step && step.phase === \"ship\" && !run.testsFailing && !paused && autonomy !== \"stop\"\n\n  /* The agent answers an order once it's between actions. Stop is always answered; others wait out a pause. */\n  React.useEffect(() => {\n    if (order === autonomy) return\n    if (paused && order !== \"stop\") return\n    const timer = setTimeout(() => setAutonomy(order), order === \"stop\" ? 900 : 1800)\n    return () => clearTimeout(timer)\n  }, [order, autonomy, paused])\n\n  /* Work the current step. More effort on its subagent, sooner it's done. */\n  const pace = React.useRef(1)\n  const share = channel?.share ?? 50\n  pace.current = Math.min(3, Math.max(0.5, 55 / Math.max(share, 5))) * (autonomy === \"auto\" ? 0.65 : 1)\n  const phase = step?.phase\n  React.useEffect(() => {\n    if (!working || !phase) return\n    const tick = 500\n    const timer = setInterval(() => {\n      dispatch({ type: \"advance\", amount: tick / (baseSeconds[phase] * 1000 * pace.current) })\n    }, tick)\n    return () => clearInterval(timer)\n  }, [working, phase])\n\n  /* The lead agent rebalances toward what the plan needs now and next. Faders you took stay yours. */\n  const nextPhase = run.steps.find((s, j) => j > at && s.status === \"pending\")?.phase\n  const leadActive = !paused && autonomy !== \"stop\" && !run.shipped\n  React.useEffect(() => {\n    if (!leadActive) return\n    const now = phase ? channelOf[phase] : null\n    const next = nextPhase ? channelOf[nextPhase] : null\n    const rebalance = () =>\n      setChannels((all) =>\n        all.map((c) => {\n          if (c.by !== \"Lead\") return c\n          const target = c.name === now ? 70 : c.name === next ? 40 : 15\n          const jitter = Math.round((Math.random() - 0.5) * 2) * 5\n          const share = Math.min(100, Math.max(5, target + jitter))\n          return share === c.share ? c : { ...c, share }\n        })\n      )\n    rebalance()\n    const timer = setInterval(rebalance, 3200)\n    return () => clearInterval(timer)\n  }, [leadActive, phase, nextPhase])\n\n  /* Push to talk: time the hold, and turn what you said into an instruction in the plan. */\n  const heldSince = React.useRef(0)\n  const onTalkingChange = (next: boolean) => {\n    setTalking(next)\n    if (next) {\n      heldSince.current = Date.now()\n      return\n    }\n    const held = (Date.now() - heldSince.current) / 1000\n    if (held < 0.6) {\n      setVoiceLog((log) => [...log.slice(-2), \"Too short to hear. Hold the key while you speak.\"])\n      return\n    }\n    const text = voiceNotes[run.notes % voiceNotes.length]!\n    dispatch({ type: \"note\", text })\n    setVoiceLog((log) => [...log.slice(-2), `${held.toFixed(1)}s: “${text}”, added to the plan`])\n  }\n  React.useEffect(() => {\n    if (!talking) return\n    const started = Date.now()\n    const timer = setInterval(() => setSeconds((Date.now() - started) / 1000), 100)\n    return () => {\n      clearInterval(timer)\n      setSeconds(0)\n    }\n  }, [talking])\n\n  /* The dead man's switch counts only while the agent could act. Coming back from Stop starts a fresh window. */\n  const supervised = !run.shipped && autonomy !== \"stop\"\n  const [window_, setWindow] = React.useState(0)\n  const wasSupervised = React.useRef(supervised)\n  React.useEffect(() => {\n    if (supervised && !wasSupervised.current) setWindow((w) => w + 1)\n    wasSupervised.current = supervised\n  }, [supervised])\n  const onTrip = React.useCallback(() => setPaused(true), [])\n  const onResume = React.useCallback(() => setPaused(false), [])\n\n  const onShip = (on: boolean) => {\n    if (!on || run.shipped) return\n    if (readyToShip) {\n      dispatch({ type: \"ship\" })\n      demoMilestone(\"relay\", \"merge\")\n      setShipNote(\"\")\n      return\n    }\n    setShipNote(`Not merged. ${shipBlock}`)\n  }\n  const shipBlock = run.shipped\n    ? `Merged into main by ${SUPERVISOR}.`\n    : run.testsFailing\n      ? \"Blocked: tests are failing.\"\n      : paused\n        ? \"Blocked: the run is paused.\"\n        : autonomy === \"stop\"\n          ? \"Blocked: autonomy is at Stop.\"\n          : step?.phase !== \"ship\"\n            ? `Blocked: the plan isn't finished (${done} of ${run.steps.length} done).`\n            : \"Ready. Lift the cover and flip the switch to merge #482.\"\n\n  // A refusal note is about the moment you tried; drop it once things change.\n  React.useEffect(() => setShipNote(\"\"), [shipBlock])\n\n  const runStatus = run.shipped\n    ? \"Shipped\"\n    : paused\n      ? \"Paused\"\n      : working\n        ? \"Running\"\n        : awaitingApproval || step?.phase === \"ship\"\n          ? \"Waiting for you\"\n          : \"Holding\"\n\n  return (\n    <div\n      className={cn(\n        consoleFace.variable,\n        \"relay-room min-h-svh bg-[#27313B] font-[family-name:var(--font-console)] text-[#E3E8EC]\",\n        // The room is lit from above; the console catches most of it.\n        \"bg-[radial-gradient(ellipse_70%_55%_at_50%_0%,rgb(255_255_255/0.09),transparent_70%)]\",\n        \"[--foreground:#E9EDF0] [--muted-foreground:#A3ADB5] [--legend:#B9C2C9]\"\n      )}\n    >\n      <header className=\"mx-auto flex max-w-[1360px] flex-wrap items-baseline gap-x-6 gap-y-1 px-4 pt-5 pb-4 sm:px-8\">\n        <p className=\"text-2xl font-bold tracking-wide\">Relay</p>\n        <p className=\"text-lg text-[#A3ADB5]\">Run 1184 on tidewater/gateway, {runStatus.toLowerCase()}</p>\n        <p className=\"ml-auto text-lg text-[#A3ADB5]\">{SUPERVISOR} on duty</p>\n      </header>\n\n      <main className=\"mx-auto max-w-[1360px] px-2 pb-10 sm:px-8\">\n        {/* The console: one slab of gunmetal, everything mounted in it. */}\n        <div className=\"bevel-metal relative rounded-[28px] p-4 shadow-(--bevel-depth-object) [--bevel-material:#4E565E] [--bevel-material-edge:#2C3238] sm:p-8 lg:p-10\">\n          <Screws inset=\"4\" />\n\n          <div className=\"grid gap-x-10 gap-y-9 lg:grid-cols-12 [&>*]:min-w-0\">\n            {/* Name plate and the status strip. */}\n            <div className=\"flex flex-col gap-4 lg:col-span-12 lg:flex-row lg:items-stretch\">\n              <h1 className=\"bevel-metal relative rounded-(--bevel-radius-sm) px-6 py-3 text-[26px] leading-tight font-bold tracking-wide text-[#3A2E10] shadow-(--bevel-depth-raised) [--bevel-material:#CDB06A] [--bevel-material-edge:#8C7536] [text-shadow:0_1px_0_rgb(255_255_255/0.35)] lg:w-[46%]\">\n                Fix burst 429s in the rate limiter\n              </h1>\n              <StatusStrip className=\"flex-1 self-center lg:self-stretch lg:py-0 lg:[&>p]:leading-[52px]\">\n                {hold ?? `Working: ${step?.text ?? \"plan complete\"}.`}\n              </StatusStrip>\n            </div>\n\n            {/* The lamps run the width of the console. */}\n            <section aria-labelledby=\"relay-alerts\" className=\"flex flex-col gap-3 lg:col-span-12\">\n              <Legend id=\"relay-alerts\">Alerts</Legend>\n              <Annunciator aria-label=\"Run alerts\" className=\"max-w-none flex-row items-center gap-4 p-3\">\n                <AnnunciatorPanel className=\"flex-1 grid-cols-3 sm:grid-cols-6\">\n                  <AnnunciatorTile id=\"paused\" tone=\"red\" active={paused}>\n                    Run paused\n                  </AnnunciatorTile>\n                  <AnnunciatorTile id=\"budget\" tone=\"red\" active={!paused && totalEffort > BUDGET}>\n                    Over budget\n                  </AnnunciatorTile>\n                  <AnnunciatorTile id=\"tests\" tone=\"amber\" active={run.testsFailing}>\n                    Tests failing\n                  </AnnunciatorTile>\n                  <AnnunciatorTile id=\"hold\" tone=\"amber\" active={!paused && !run.shipped && !working && !awaitingApproval && step?.phase !== \"ship\"}>\n                    Agent holding\n                  </AnnunciatorTile>\n                  <AnnunciatorTile id=\"approval\" tone=\"white\" active={awaitingApproval}>\n                    Needs approval\n                  </AnnunciatorTile>\n                  <AnnunciatorTile id=\"ship\" tone=\"green\" active={readyToShip}>\n                    Ready to merge\n                  </AnnunciatorTile>\n                </AnnunciatorPanel>\n                <AnnunciatorAcknowledge className=\"hidden self-auto sm:flex\" />\n              </Annunciator>\n            </section>\n\n            {/* The plan, clipped to the console. */}\n            <section aria-labelledby=\"relay-plan\" className=\"flex flex-col gap-3 lg:col-span-4\">\n              <Legend id=\"relay-plan\">Plan</Legend>\n              <div className=\"relative pt-4\">\n                <span aria-hidden className=\"bevel-metal absolute top-0 left-1/2 z-10 h-7 w-28 -translate-x-1/2 rounded-(--bevel-radius-sm) [--bevel-material:#9AA3AA]\" />\n                <TaskPlan className=\"max-w-none\">\n                  <TaskPlanHeader>\n                    <TaskPlanTitle>Issue #217</TaskPlanTitle>\n                    <TaskPlanProgress value={done} max={run.steps.length} />\n                  </TaskPlanHeader>\n                  <TaskPlanSteps>\n                    {run.steps.map((s) => (\n                      <TaskPlanStep key={s.id} status={s.status}>\n                        {s.text}\n                      </TaskPlanStep>\n                    ))}\n                  </TaskPlanSteps>\n                </TaskPlan>\n              </div>\n            </section>\n\n            {/* The hero: the order telegraph. */}\n            <section aria-labelledby=\"relay-autonomy\" className=\"flex flex-col items-center gap-3 lg:col-span-5\">\n              <Legend id=\"relay-autonomy\" className=\"self-start lg:self-center\">\n                Autonomy\n              </Legend>\n              <EngineTelegraph\n                aria-label=\"Agent autonomy\"\n                value={order}\n                onValueChange={(v) => setOrder(v as Autonomy)}\n                confirmed={autonomy}\n                className=\"max-w-[460px]\"\n              >\n                <EngineTelegraphDial />\n                <EngineTelegraphOrders>\n                  <EngineTelegraphOrder value=\"stop\">Stop</EngineTelegraphOrder>\n                  <EngineTelegraphOrder value=\"plan\">Plan</EngineTelegraphOrder>\n                  <EngineTelegraphOrder value=\"ask\">Ask</EngineTelegraphOrder>\n                  <EngineTelegraphOrder value=\"act\">Act</EngineTelegraphOrder>\n                  <EngineTelegraphOrder value=\"auto\">Auto</EngineTelegraphOrder>\n                </EngineTelegraphOrders>\n                <EngineTelegraphStatus className=\"text-base\" />\n              </EngineTelegraph>\n              <p className=\"max-w-[46ch] text-center text-[17px] text-[#A3ADB5]\">{autonomyMeaning[autonomy]}</p>\n            </section>\n\n            {/* Check in, approve, merge. */}\n            <div className=\"grid content-start gap-9 sm:grid-cols-2 lg:col-span-3 lg:grid-cols-1\">\n              <section aria-labelledby=\"relay-checkin\" className=\"flex flex-col gap-3\">\n                <Legend id=\"relay-checkin\">Check in every {CHECK_IN_MS / 1000}s</Legend>\n                <Vigilance\n                  key={window_}\n                  aria-label=\"Supervision\"\n                  interval={CHECK_IN_MS}\n                  running={supervised}\n                  onTrip={onTrip}\n                  onResume={onResume}\n                  className=\"max-w-full\"\n                >\n                  <VigilanceLamps />\n                  <VigilanceTimer />\n                  <VigilanceButton />\n                </Vigilance>\n              </section>\n              <section aria-labelledby=\"relay-merge\" className=\"flex flex-col items-start gap-3\">\n                <Legend id=\"relay-merge\">Merge #482</Legend>\n                <div className=\"flex items-end gap-5\">\n                  <GuardedSwitch\n                    checked={run.shipped}\n                    onCheckedChange={onShip}\n                    safeOnClose={!run.shipped}\n                    aria-describedby=\"relay-merge-why\"\n                  >\n                    <GuardedSwitchLabel>Merge</GuardedSwitchLabel>\n                    <GuardedSwitchControl />\n                    <GuardedSwitchStatus />\n                  </GuardedSwitch>\n                  <div className=\"flex flex-col gap-3 pb-1\">\n                    {awaitingApproval && (\n                      <PanelKey tone=\"go\" onClick={() => dispatch({ type: \"approve\" })}>\n                        Approve step\n                      </PanelKey>\n                    )}\n                    {run.shipped && <PanelKey onClick={onNewRun}>New run</PanelKey>}\n                  </div>\n                </div>\n                <p id=\"relay-merge-why\" className=\"text-[17px] leading-snug text-[#A3ADB5]\">\n                  {shipNote && !run.shipped ? shipNote : shipBlock}\n                </p>\n              </section>\n            </div>\n\n            {/* The desk: subagent faders, and the talk key beside them. */}\n            <section aria-labelledby=\"relay-subagents\" className=\"flex min-w-0 flex-col gap-3 lg:col-span-8\">\n              <div className=\"flex flex-wrap items-baseline justify-between gap-3\">\n                <Legend id=\"relay-subagents\">Subagents</Legend>\n                <p className=\"text-[17px] text-[#A3ADB5]\">\n                  {paused ? \"All paused\" : `Effort ${totalEffort} of ${BUDGET}`}\n                  {channels.some((c) => c.by === \"You\") && (\n                    <button\n                      type=\"button\"\n                      onClick={() => setChannels((all) => all.map((c) => ({ ...c, by: \"Lead\" })))}\n                      className=\"ml-4 rounded-sm underline underline-offset-4 outline-none hover:text-[#E9EDF0] focus-visible:ring-2 focus-visible:ring-[#E9D28A]\"\n                    >\n                      Hand back to the lead\n                    </button>\n                  )}\n                </p>\n              </div>\n              <div className=\"rounded-(--bevel-radius-md) bg-[#3B4248] p-3 shadow-(--bevel-depth-recessed)\">\n                <Mixer aria-label=\"Subagent effort\" className=\"justify-between sm:justify-around\">\n                  {channels.map((c) => (\n                    <MixerStrip key={c.name} name={c.name} muted={!isRunning(c)} className=\"w-[4.5rem] sm:w-24\">\n                      <MixerStripName />\n                      <MixerStripMute\n                        pressed={c.muted}\n                        onPressedChange={(muted) =>\n                          setChannels((all) => all.map((x) => (x.name === c.name ? { ...x, muted } : x)))\n                        }\n                      />\n                      <MixerStripSolo pressed={solo === c.name} onPressedChange={(on) => setSolo(on ? c.name : null)} />\n                      <MixerStripFader\n                        value={c.share}\n                        changedBy={c.by}\n                        format={(v) => `${v}%`}\n                        onValueChange={(share) =>\n                          setChannels((all) => all.map((x) => (x.name === c.name ? { ...x, share, by: \"You\" } : x)))\n                        }\n                      />\n                    </MixerStrip>\n                  ))}\n                </Mixer>\n              </div>\n            </section>\n\n            <section aria-labelledby=\"relay-talk\" className=\"flex flex-col gap-3 lg:col-span-4\">\n              <Legend id=\"relay-talk\">Talk to the agent</Legend>\n              <div className=\"flex flex-wrap items-start gap-6\">\n                <PushToTalk talking={talking} onTalkingChange={onTalkingChange} disabled={run.shipped}>\n                  <PushToTalkKey>Hold to talk</PushToTalkKey>\n                  <PushToTalkStatus idle={run.shipped ? \"Run finished\" : \"Hold Space, or the key\"} />\n                  <span aria-hidden className=\"h-4 text-sm tabular-nums opacity-70\">\n                    {talking ? `${seconds.toFixed(1)}s` : \"\"}\n                  </span>\n                </PushToTalk>\n                <ul aria-label=\"Voice notes\" className=\"flex min-w-0 flex-1 flex-col gap-2 text-[17px] leading-snug text-[#A3ADB5]\">\n                  {voiceLog.length ? voiceLog.map((line, i) => <li key={i}>{line}</li>) : <li>Your instructions join the plan as the next step.</li>}\n                </ul>\n              </div>\n            </section>\n          </div>\n        </div>\n      </main>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/bevel-demos/relay/relay-app.tsx"
    },
    {
      "path": "registry/bevel/blocks/agent-console/relay/run.ts",
      "content": "import type { TaskPlanStatus } from \"@/components/ui/task-plan\"\n\n/** The simulated run: a plan, how far into the current step the agent is, and what the tests said. */\n\nexport type Phase = \"research\" | \"code\" | \"tests\" | \"docs\" | \"you\" | \"ship\"\n\nexport type Step = {\n  id: string\n  text: string\n  phase: Phase\n  status: TaskPlanStatus\n  /** The first run of the suite fails: a flaky clock in a test. */\n  failsOnce?: boolean\n  /** Passing this step clears the failing tests. */\n  clearsTests?: boolean\n  /** Approved by you, for when autonomy is at Ask. */\n  approved?: boolean\n}\n\nexport type Run = {\n  steps: Step[]\n  /** 0 to 1 through the current step. */\n  progress: number\n  testsFailing: boolean\n  shipped: boolean\n  notes: number\n}\n\nexport const initialRun: Run = {\n  steps: [\n    { id: \"read\", text: \"Read issue #217: bursts get 429s after a deploy\", phase: \"research\", status: \"done\" },\n    { id: \"trace\", text: \"Trace the token bucket in gateway/limiter\", phase: \"research\", status: \"current\" },\n    { id: \"patch\", text: \"Refill the bucket from a monotonic clock\", phase: \"code\", status: \"pending\" },\n    { id: \"test\", text: \"Add a regression test for the burst case\", phase: \"tests\", status: \"pending\" },\n    { id: \"suite\", text: \"Run the full suite\", phase: \"tests\", status: \"pending\", failsOnce: true },\n    { id: \"docs\", text: \"Update the limiter section of the docs\", phase: \"docs\", status: \"pending\" },\n    { id: \"pr\", text: \"Open pull request #482\", phase: \"docs\", status: \"pending\" },\n    { id: \"ship\", text: \"Merge #482 into main (yours to approve)\", phase: \"ship\", status: \"pending\" },\n  ],\n  progress: 0.3,\n  testsFailing: false,\n  shipped: false,\n  notes: 0,\n}\n\n/** Seconds a step takes at an even share of effort. */\nexport const baseSeconds: Record<Phase, number> = {\n  research: 7,\n  code: 9,\n  tests: 7,\n  docs: 6,\n  you: 6,\n  ship: 0,\n}\n\n/** Which subagent does each kind of step. */\nexport const channelOf: Record<Phase, string | null> = {\n  research: \"Explore\",\n  code: \"Code\",\n  you: \"Code\",\n  tests: \"Tests\",\n  docs: \"Docs\",\n  ship: null,\n}\n\nexport const voiceNotes = [\n  \"Keep the public limiter API unchanged\",\n  \"Add a changelog entry\",\n  \"Leave the billing routes alone\",\n  \"Log the refill rate at debug level\",\n]\n\nexport type RunAction =\n  | { type: \"advance\"; amount: number }\n  | { type: \"approve\" }\n  | { type: \"note\"; text: string }\n  | { type: \"ship\" }\n\nexport const currentIndex = (run: Run) => run.steps.findIndex((s) => s.status === \"current\")\n\nfunction nextPending(steps: Step[], after: number) {\n  const i = steps.findIndex((s, j) => j > after && s.status === \"pending\")\n  return i === -1 ? steps : steps.map((s, j) => (j === i ? { ...s, status: \"current\" as const } : s))\n}\n\nexport function runReducer(run: Run, action: RunAction): Run {\n  const at = currentIndex(run)\n  switch (action.type) {\n    case \"advance\": {\n      const step = run.steps[at]\n      if (!step || step.phase === \"ship\") return run\n      const progress = run.progress + action.amount\n      if (progress < 1) return { ...run, progress }\n      if (step.failsOnce) {\n        const steps = [...run.steps]\n        steps[at] = { ...step, status: \"error\", text: \"Run the full suite: 2 failed in limiter.test.ts\" }\n        steps.splice(\n          at + 1,\n          0,\n          { id: \"fix\", text: \"Fix the flaky clock in limiter.test.ts\", phase: \"code\", status: \"current\" },\n          { id: \"rerun\", text: \"Run the full suite again\", phase: \"tests\", status: \"pending\", clearsTests: true }\n        )\n        return { ...run, steps, progress: 0, testsFailing: true }\n      }\n      const done = run.steps.map((s, j) => (j === at ? { ...s, status: \"done\" as const } : s))\n      return {\n        ...run,\n        steps: nextPending(done, at),\n        progress: 0,\n        testsFailing: step.clearsTests ? false : run.testsFailing,\n      }\n    }\n    case \"approve\":\n      if (at === -1) return run\n      return { ...run, steps: run.steps.map((s, j) => (j === at ? { ...s, approved: true } : s)) }\n    case \"note\": {\n      if (at === -1 || run.shipped) return run\n      const steps = [...run.steps]\n      // An instruction goes next, ahead of the merge.\n      const where = run.steps[at]!.phase === \"ship\" ? at : at + 1\n      steps.splice(where, 0, {\n        id: `note-${run.notes}`,\n        text: `From you: ${action.text}`,\n        phase: \"you\",\n        status: \"pending\",\n      })\n      // If the merge was waiting, the instruction comes first.\n      if (run.steps[at]!.phase === \"ship\") {\n        steps[where] = { ...steps[where]!, status: \"current\" }\n        steps[where + 1] = { ...steps[where + 1]!, status: \"pending\" }\n      }\n      return { ...run, steps, notes: run.notes + 1 }\n    }\n    case \"ship\":\n      return {\n        ...run,\n        shipped: true,\n        steps: run.steps.map((s) => (s.phase === \"ship\" ? { ...s, status: \"done\" } : s)),\n      }\n  }\n}\n",
      "type": "registry:component",
      "target": "components/bevel-demos/relay/run.ts"
    },
    {
      "path": "registry/bevel/blocks/agent-console/shared/environment.tsx",
      "content": "import * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n/**\n * Pieces of the physical environments the demos are set in. Each demo\n * mounts Bevel components on a surface; these are the surface's own parts.\n */\n\n/** A legend engraved into the surface: names the control below it. */\nexport function Legend({ className, ...props }: React.ComponentProps<\"p\">) {\n  return (\n    <p\n      className={cn(\n        \"text-[15px] leading-none font-semibold tracking-wide text-(--legend) [text-shadow:0_-1px_0_rgb(0_0_0/0.45),0_1px_0_rgb(255_255_255/0.08)]\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/** A slotted screw head, for panel corners. */\nexport function Screw({ className, angle = 30 }: { className?: string; angle?: number }) {\n  return (\n    <span\n      aria-hidden\n      className={cn(\"bevel-metal absolute size-3.5 rounded-full shadow-(--bevel-depth-raised)\", className)}\n    >\n      <span className=\"absolute inset-x-0.5 top-1/2 h-px -translate-y-1/2 bg-black/50\" style={{ rotate: `${angle}deg` }} />\n    </span>\n  )\n}\n\n/** Four screws, one in each corner of a positioned panel. */\nconst screwCorners = {\n  \"2\": [\"top-2 left-2\", \"top-2 right-2\", \"bottom-2 left-2\", \"bottom-2 right-2\"],\n  \"3\": [\"top-3 left-3\", \"top-3 right-3\", \"bottom-3 left-3\", \"bottom-3 right-3\"],\n  \"4\": [\"top-4 left-4\", \"top-4 right-4\", \"bottom-4 left-4\", \"bottom-4 right-4\"],\n} as const\n\nexport function Screws({ inset = \"3\" }: { inset?: keyof typeof screwCorners }) {\n  return (\n    <>\n      {screwCorners[inset].map((c, i) => (\n        <Screw key={c} className={c} angle={[20, 75, 130, 160][i]} />\n      ))}\n    </>\n  )\n}\n\n/** A physical key: a raised plastic button that goes down when pressed. */\nexport function PanelKey({ className, tone = \"plain\", ...props }: React.ComponentProps<\"button\"> & { tone?: \"plain\" | \"go\" }) {\n  return (\n    <button\n      type=\"button\"\n      data-tone={tone}\n      className={cn(\n        \"bevel-raised inline-flex h-11 items-center whitespace-nowrap justify-center rounded-(--bevel-radius-sm) px-5 text-[15px] font-semibold outline-none select-none\",\n        \"[--bevel-material:#5B636B] text-[#EEF1F3] data-[tone=go]:[--bevel-material:#C9A44A] data-[tone=go]:text-[#2A2208]\",\n        \"transition-[translate,box-shadow] duration-(--bevel-duration-press) active:translate-y-0.5 active:bevel-pressed\",\n        \"focus-visible:ring-3 focus-visible:ring-[#E9D28A]/60 disabled:opacity-50\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/** A backlit status strip: one line of glowing text behind glass. */\nexport function StatusStrip({ className, children }: { className?: string; children: React.ReactNode }) {\n  return (\n    <div\n      className={cn(\n        \"relative overflow-hidden rounded-(--bevel-radius-sm) bg-[#0E1A17] px-4 py-3 shadow-(--bevel-depth-recessed)\",\n        className\n      )}\n    >\n      <p className=\"text-[17px] sm:truncate tracking-wide text-[#8FF0CF] [text-shadow:0_0_8px_rgb(143_240_207/0.55)]\">{children}</p>\n      <span aria-hidden className=\"bevel-glass absolute inset-0\" />\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/bevel-demos/shared/environment.tsx"
    },
    {
      "path": "registry/bevel/blocks/agent-console/shared/events.ts",
      "content": "/**\n * Announces a milestone in a demo (a merge, a top-up) as a DOM event. It\n * does nothing on its own; a page that wants to count milestones listens\n * for \"bevel:demo\". The Bevel site forwards them to its analytics.\n */\nexport function demoMilestone(demo: string, action: string) {\n  if (typeof window === \"undefined\") return\n  window.dispatchEvent(new CustomEvent(\"bevel:demo\", { detail: { demo, action } }))\n}\n",
      "type": "registry:component",
      "target": "components/bevel-demos/shared/events.ts"
    },
    {
      "path": "registry/bevel/blocks/agent-console/shared/fonts.ts",
      "content": "import { Barlow_Condensed, Libre_Caslon_Text, Overpass, Source_Serif_4 } from \"next/font/google\"\n\n/** Each demo product has its own type voice, drawn from its world. */\n\n/** Relay: console legends, the condensed grotesk of control-room engraving. */\nexport const consoleFace = Barlow_Condensed({ subsets: [\"latin\"], weight: [\"500\", \"600\", \"700\"], variable: \"--font-console\" })\n\n/** Meterline: a ledger serif, for a desk where money is written down. */\nexport const ledgerFace = Libre_Caslon_Text({ subsets: [\"latin\"], weight: [\"400\", \"700\"], variable: \"--font-ledger\" })\n\n/** Shipyard: highway-sign lettering, for a board read from across a room. */\nexport const signFace = Overpass({ subsets: [\"latin\"], weight: [\"400\", \"600\", \"800\"], variable: \"--font-sign\" })\n\n/** Casefile: a document serif, for papers on a desk. */\nexport const documentFace = Source_Serif_4({ subsets: [\"latin\"], weight: [\"400\", \"600\", \"700\"], variable: \"--font-document\" })\n",
      "type": "registry:component",
      "target": "components/bevel-demos/shared/fonts.ts"
    },
    {
      "path": "registry/bevel/blocks/agent-console/page.tsx",
      "content": "import { RelayApp } from \"@/components/bevel-demos/relay/relay-app\"\n\nexport default function Page() {\n  return <RelayApp />\n}\n",
      "type": "registry:page",
      "target": "app/agent-console/page.tsx"
    }
  ],
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}