{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-ops-01",
  "title": "Agents overview",
  "description": "A day of agents at a glance: totals that roll between Today and 7 days, requests approved in place, a fleet whose rows unfold their sub-agents, and when the last request leaves a check draws itself where the list was.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/segments.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/index.tsx",
      "content": "'use client';\n\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\nimport { Segments } from '@/registry/ndeko/ui/segments';\n\nimport { MAIN_AGENTS, PERIODS, TEAM_NAME, type Model } from './data';\nimport { Fleet } from './fleet';\nimport { NeedsYou } from './needs-you';\nimport {\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  runningCountOf,\n  SCRIPT,\n  spendOf,\n  totalsOf,\n} from './session';\nimport { SpendByModel } from './spend';\nimport { TotalsBand } from './totals';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nfunction agentsWordOf(count: number) {\n  if (count === 1) {\n    return '1 agent';\n  }\n  return `${count} agents`;\n}\n\nfunction waitingLineOf(waiting: number) {\n  if (waiting === 0) {\n    return 'Nothing waits on you';\n  }\n  if (waiting === 1) {\n    return '1 request waits on you';\n  }\n  return `${waiting} requests wait on you`;\n}\n\nexport default function AgentOps01() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const totals = totalsOf(state);\n  const runningCount = runningCountOf(state);\n  const agentsWord = agentsWordOf(MAIN_AGENTS.length);\n  const waitingLine = waitingLineOf(totals.waiting);\n  const message = spokenUnless(isAutoplaying, waitingLine);\n  const canReplay = isFinished && !isAutoplaying;\n\n  function spendOfModel(model: Model) {\n    return spendOf(state, model.id);\n  }\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container min-h-dvh w-full'\n      >\n        <div className='mx-auto flex max-w-5xl flex-col gap-4 p-4 @3xl:gap-5 @3xl:p-8'>\n          <header className='flex flex-wrap items-center gap-x-3 gap-y-2'>\n            <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n              <h1 className='text-2xl font-semibold text-balance'>Agents</h1>\n              <p className='text-muted-foreground text-xs'>\n                {TEAM_NAME} · {agentsWord} · Illustrative figures\n              </p>\n            </div>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={restart}\n              label='Replay the day'\n            />\n            <Segments\n              value={state.period}\n              segments={PERIODS}\n              onValueChange={(period) => act({ type: 'period', period })}\n              label='Period'\n              className='w-36'\n            />\n          </header>\n\n          <TotalsBand totals={totals} period={state.period} />\n\n          <div className='flex flex-col gap-4 @4xl:flex-row @4xl:items-start @4xl:gap-5'>\n            <div className='flex min-w-0 flex-1 flex-col gap-4 @4xl:gap-5'>\n              <NeedsYou\n                pending={state.pending}\n                pressed={pressed}\n                onDecide={(approvalId, decision) =>\n                  act({ type: 'decided', approvalId, decision })\n                }\n              />\n              <Fleet\n                agents={state.agents}\n                runningCount={runningCount}\n                openId={state.openId}\n                pressed={pressed}\n                onToggle={(id) => act({ type: 'toggled', id })}\n              />\n            </div>\n            <div className='@4xl:w-80 @4xl:shrink-0'>\n              <SpendByModel\n                period={state.period}\n                total={totals.spendUsd}\n                spendOfModel={spendOfModel}\n              />\n            </div>\n          </div>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/totals.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport type { PeriodId } from './data';\nimport type { Totals } from './session';\n\nconst USD: Intl.NumberFormatOptions = { style: 'currency', currency: 'USD' };\n\nconst PERIOD_WORDS: Record<PeriodId, string> = {\n  today: 'today',\n  week: 'this week',\n};\n\nconst PERIOD_IDS: PeriodId[] = ['today', 'week'];\n\nfunction labelOf(subject: string, period: PeriodId) {\n  return `${subject} ${PERIOD_WORDS[period]}`;\n}\n\nfunction labelsOf(subject: string) {\n  return PERIOD_IDS.map((period) => labelOf(subject, period));\n}\n\nfunction waitingToneOf(waiting: number) {\n  if (waiting > 0) {\n    return 'text-warning-foreground';\n  }\n  return 'text-foreground';\n}\n\ntype TotalCellProps = {\n  label: React.ReactNode;\n  className?: string;\n  children: React.ReactNode;\n};\n\nfunction TotalCell({ label, className, children }: TotalCellProps) {\n  return (\n    <div className='flex min-w-0 flex-col gap-1 px-3 py-2.5 @2xl:px-4'>\n      <dt className='text-muted-foreground text-xs'>{label}</dt>\n      <dd\n        className={cn(\n          'text-2xl leading-8 font-semibold transition-colors duration-200',\n          className\n        )}\n      >\n        {children}\n      </dd>\n    </div>\n  );\n}\n\ntype PeriodLabelProps = {\n  subject: string;\n  period: PeriodId;\n};\n\nfunction PeriodLabel({ subject, period }: PeriodLabelProps) {\n  return (\n    <WordRoll text={labelOf(subject, period)} labels={labelsOf(subject)} />\n  );\n}\n\ntype TotalsBandProps = {\n  totals: Totals;\n  period: PeriodId;\n};\n\n/** Waiting on you is what waits now, whatever the period. */\nexport function TotalsBand({ totals, period }: TotalsBandProps) {\n  return (\n    <dl className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] grid grid-cols-2 gap-y-1 rounded-xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @2xl:grid-cols-4'>\n      <TotalCell label={<PeriodLabel subject='Runs' period={period} />}>\n        <MotionNumber value={totals.runs} />\n      </TotalCell>\n      <TotalCell\n        label='Waiting on you'\n        className={waitingToneOf(totals.waiting)}\n      >\n        <MotionNumber value={totals.waiting} />\n      </TotalCell>\n      <TotalCell label={<PeriodLabel subject='Failed' period={period} />}>\n        <MotionNumber value={totals.failed} />\n      </TotalCell>\n      <TotalCell label={<PeriodLabel subject='Spend' period={period} />}>\n        <MotionNumber value={totals.spendUsd} format={USD} />\n      </TotalCell>\n    </dl>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/totals.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/needs-you.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport {\n  EASE_OUT_STRONG,\n  rowPresenceOf,\n} from '@/registry/ndeko/lib/motion-presets';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport { agentOf, APPROVALS, type ApprovalId } from './data';\nimport type { Decision } from './session';\n\nconst CHECK_PATH = 'M5 10.4 8.6 14 15 6.6';\n\nconst DRAW = { duration: 0.5, ease: EASE_OUT_STRONG, delay: 0.12 };\n\nconst SETTLE = { duration: 0.3, ease: EASE_OUT_STRONG };\n\nfunction strokeStartOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return { pathLength: 1 };\n  }\n  return { pathLength: 0 };\n}\n\nfunction markStartOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return { opacity: 0, scale: 1 };\n  }\n  return { opacity: 0, scale: 1.04 };\n}\n\nfunction CalmMark() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.span\n      aria-hidden='true'\n      initial={markStartOf(shouldReduceMotion)}\n      animate={{ opacity: 1, scale: 1 }}\n      transition={SETTLE}\n      className='bg-success/10 text-success-foreground flex size-10 items-center justify-center rounded-full'\n    >\n      <svg viewBox='0 0 20 20' className='size-5'>\n        <motion.path\n          d={CHECK_PATH}\n          fill='none'\n          stroke='currentColor'\n          strokeWidth='1.75'\n          strokeLinecap='round'\n          strokeLinejoin='round'\n          initial={strokeStartOf(shouldReduceMotion)}\n          animate={{ pathLength: 1 }}\n          transition={DRAW}\n        />\n      </svg>\n    </motion.span>\n  );\n}\n\ntype RequestRowProps = {\n  approvalId: ApprovalId;\n  pressed: string | null;\n  onDecide: (approvalId: ApprovalId, decision: Decision) => void;\n};\n\nfunction RequestRow({ approvalId, pressed, onDecide }: RequestRowProps) {\n  const approval = APPROVALS[approvalId];\n  const agent = agentOf(approval.agentId);\n  const isApprovePressed = pressed === `approve-${approvalId}`;\n\n  return (\n    <div className='flex flex-col gap-2.5 px-3 py-2.5 @xl:flex-row @xl:items-center @xl:gap-4'>\n      <div className='flex min-w-0 flex-1 items-start gap-3'>\n        <MeshTile seed={agent.name} size='lg' />\n        <div className='flex min-w-0 flex-col gap-0.5'>\n          <p className='text-[13px] leading-5 font-medium text-pretty'>\n            {approval.title}\n          </p>\n          <p className='text-muted-foreground text-xs'>\n            {agent.name} · {approval.detail}\n          </p>\n        </div>\n      </div>\n      <div className='flex shrink-0 items-center gap-2 ps-10 @xl:ps-0'>\n        <Button\n          type='button'\n          size='sm'\n          aria-label={`Approve: ${approval.title}`}\n          onClick={() => onDecide(approvalId, 'approved')}\n          className={pressedSolidOf(isApprovePressed)}\n        >\n          Approve\n        </Button>\n        <Button\n          type='button'\n          size='sm'\n          variant='outline'\n          aria-label={`Deny: ${approval.title}`}\n          onClick={() => onDecide(approvalId, 'denied')}\n        >\n          Deny\n        </Button>\n      </div>\n    </div>\n  );\n}\n\ntype NeedsYouProps = {\n  pending: ApprovalId[];\n  pressed: string | null;\n  onDecide: (approvalId: ApprovalId, decision: Decision) => void;\n};\n\nexport function NeedsYou({ pending, pressed, onDecide }: NeedsYouProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const isEmpty = pending.length === 0;\n\n  return (\n    <section\n      aria-label='Needs you'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col rounded-xl p-1 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <header className='flex h-9 items-center gap-2 px-3'>\n        <h2 className='text-sm font-medium'>Needs you</h2>\n        <span className='bg-foreground/[0.06] text-muted-foreground inline-flex h-5 min-w-5 items-center justify-center rounded-sm px-1.5 text-xs'>\n          <MotionNumber value={pending.length} />\n        </span>\n      </header>\n      <ul className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {pending.map((approvalId) => (\n            <motion.li\n              key={approvalId}\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <RequestRow\n                approvalId={approvalId}\n                pressed={pressed}\n                onDecide={onDecide}\n              />\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ul>\n      <AnimatePresence initial={false}>\n        {isEmpty && (\n          <motion.div key='empty' className='overflow-hidden' {...rowPresence}>\n            <div className='flex items-center gap-3 px-3 pt-1.5 pb-3'>\n              <CalmMark />\n              <div className='flex flex-col gap-0.5'>\n                <p className='text-[13px] font-medium'>Nothing waits on you</p>\n                <p className='text-muted-foreground text-xs'>\n                  Agents ask here before they send or change anything\n                </p>\n              </div>\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/needs-you.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/fleet.tsx",
      "content": "'use client';\n\nimport { useId } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport {\n  seriesColorOf,\n  type AgentStatus,\n} from '@/registry/ndeko/lib/agent-run';\nimport { CheckIcon, ChevronDownIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport {\n  MAIN_AGENTS,\n  modelOf,\n  subAgentsOf,\n  type Agent,\n  type AgentId,\n  type ModelId,\n} from './data';\nimport type { AgentLive, Decision } from './session';\n\nconst STATUS_WORD: Record<AgentStatus, string> = {\n  idle: 'Stopped',\n  running: 'Running',\n  waiting: 'Waiting on you',\n  failed: 'Failed',\n  done: 'Done',\n};\n\nconst STATUS_WORDS = Object.values(STATUS_WORD);\n\nconst DOT_TONE: Record<AgentStatus, string> = {\n  idle: 'bg-muted-foreground/45',\n  running: 'bg-info',\n  waiting: 'bg-warning',\n  failed: 'bg-destructive',\n  done: 'bg-success',\n};\n\nconst WORD_TONE: Record<AgentStatus, string> = {\n  idle: 'text-muted-foreground',\n  running: 'text-foreground',\n  waiting: 'text-warning-foreground',\n  failed: 'text-destructive-ink',\n  done: 'text-muted-foreground',\n};\n\nconst DECISION_WORD: Record<Decision, string> = {\n  approved: 'Approved by you',\n  denied: 'Denied by you',\n};\n\nconst SMALL_COST: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  minimumFractionDigits: 3,\n  maximumFractionDigits: 3,\n};\n\nconst LARGE_COST: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n};\n\n/** Three decimals under a dollar, two above. */\nfunction costFormatOf(usd: number) {\n  if (usd < 1) {\n    return SMALL_COST;\n  }\n  return LARGE_COST;\n}\n\nfunction isLive(status: AgentStatus) {\n  const isRunning = status === 'running';\n  const isWaiting = status === 'waiting';\n  return isRunning || isWaiting;\n}\n\nfunction chevronTurnOf(isOpen: boolean) {\n  if (isOpen) {\n    return 'rotate-180';\n  }\n  return 'rotate-0';\n}\n\nfunction pressedQuietOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.94] bg-foreground/[0.07] text-foreground';\n  }\n  return undefined;\n}\n\nfunction subAgentsWordOf(count: number) {\n  if (count === 1) {\n    return '1 sub-agent';\n  }\n  return `${count} sub-agents`;\n}\n\nfunction toggleLabelOf(agent: Agent, count: number, isOpen: boolean) {\n  const subAgents = subAgentsWordOf(count);\n  if (isOpen) {\n    return `Hide the ${subAgents} of ${agent.name}`;\n  }\n  return `Show the ${subAgents} of ${agent.name}`;\n}\n\nfunction StatusWord({ status }: { status: AgentStatus }) {\n  return (\n    <span\n      className={cn(\n        'inline-flex items-center gap-1.5 text-xs transition-colors duration-200',\n        WORD_TONE[status]\n      )}\n    >\n      <span\n        aria-hidden='true'\n        className={cn(\n          'size-2 shrink-0 rounded-full transition-colors duration-200',\n          DOT_TONE[status]\n        )}\n      />\n      <WordRoll text={STATUS_WORD[status]} labels={STATUS_WORDS} />\n    </span>\n  );\n}\n\nfunction ModelMark({ modelId }: { modelId: ModelId }) {\n  const model = modelOf(modelId);\n  const dotStyle = { backgroundColor: seriesColorOf(model.series) };\n\n  return (\n    <span className='text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs'>\n      <span\n        aria-hidden='true'\n        style={dotStyle}\n        className='size-2 shrink-0 rounded-full'\n      />\n      <BrandTile brand={model.brand} size='sm' />\n      <span className='truncate'>{model.name}</span>\n    </span>\n  );\n}\n\nfunction DecisionTrace({ decision }: { decision: Decision }) {\n  const isApproved = decision === 'approved';\n\n  return (\n    <p className='text-muted-foreground flex items-center gap-1.5 text-xs transition-opacity duration-300 starting:opacity-0'>\n      {isApproved && (\n        <CheckIcon className='text-success-foreground size-3.5 shrink-0' />\n      )}\n      {!isApproved && (\n        <XIcon className='text-destructive-ink size-3.5 shrink-0' />\n      )}\n      {DECISION_WORD[decision]}\n    </p>\n  );\n}\n\ntype FiguresProps = {\n  live: AgentLive;\n  className?: string;\n};\n\nfunction Figures({ live, className }: FiguresProps) {\n  return (\n    <div className={cn('flex shrink-0 flex-col items-end', className)}>\n      <MotionNumber\n        value={live.costUsd}\n        format={costFormatOf(live.costUsd)}\n        className='text-[13px] leading-5 font-medium'\n      />\n      <LiveDuration\n        item={live}\n        isRunning={isLive(live.status)}\n        className='text-muted-foreground text-xs leading-5'\n      />\n    </div>\n  );\n}\n\ntype SubAgentRowProps = {\n  agent: Agent;\n  live: AgentLive;\n};\n\nfunction SubAgentRow({ agent, live }: SubAgentRowProps) {\n  return (\n    <li className='bg-foreground/[0.03] dark:bg-foreground/[0.05] flex items-start gap-2.5 rounded-lg px-2.5 py-2'>\n      <MeshTile seed={agent.name} className='mt-px' />\n      <div className='flex min-w-0 flex-1 flex-col'>\n        <p className='flex flex-wrap items-center gap-x-2'>\n          <span className='text-[13px] leading-5 font-medium'>\n            {agent.name}\n          </span>\n          <StatusWord status={live.status} />\n        </p>\n        <p className='text-muted-foreground truncate text-xs leading-5'>\n          {live.task}\n        </p>\n      </div>\n      <Figures live={live} className='w-16' />\n    </li>\n  );\n}\n\ntype FleetRowProps = {\n  agent: Agent;\n  agents: Record<AgentId, AgentLive>;\n  isOpen: boolean;\n  isTogglePressed: boolean;\n  onToggle: (id: AgentId) => void;\n};\n\nfunction FleetRow({\n  agent,\n  agents,\n  isOpen,\n  isTogglePressed,\n  onToggle,\n}: FleetRowProps) {\n  const panelId = useId();\n  const live = agents[agent.id];\n  const subAgents = subAgentsOf(agent.id);\n  const hasSubAgents = subAgents.length > 0;\n\n  return (\n    <li className='flex flex-col px-2 py-2'>\n      <div className='flex items-start gap-3'>\n        <MeshTile seed={agent.name} size='lg' />\n        <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n          <p className='flex flex-wrap items-center gap-x-2.5'>\n            <span className='text-[13px] leading-5 font-medium'>\n              {agent.name}\n            </span>\n            <StatusWord status={live.status} />\n          </p>\n          <p className='text-foreground/85 truncate text-xs leading-5'>\n            {live.task}\n          </p>\n          {live.decision && <DecisionTrace decision={live.decision} />}\n          <div className='pt-0.5 @2xl:hidden'>\n            <ModelMark modelId={agent.model} />\n          </div>\n        </div>\n        <div className='hidden w-36 shrink-0 pt-0.5 @2xl:block'>\n          <ModelMark modelId={agent.model} />\n        </div>\n        <Figures live={live} className='w-16' />\n        <span className='flex size-7 shrink-0 items-center justify-center'>\n          {hasSubAgents && (\n            <Button\n              type='button'\n              variant='ghost'\n              size='icon-sm'\n              aria-expanded={isOpen}\n              aria-controls={panelId}\n              aria-label={toggleLabelOf(agent, subAgents.length, isOpen)}\n              onClick={() => onToggle(agent.id)}\n              className={cn(\n                'text-muted-foreground',\n                pressedQuietOf(isTogglePressed)\n              )}\n            >\n              <ChevronDownIcon\n                className={cn(\n                  'transition-transform duration-200 ease-(--ease-out-strong)',\n                  chevronTurnOf(isOpen)\n                )}\n              />\n            </Button>\n          )}\n        </span>\n      </div>\n      {hasSubAgents && (\n        <Fold open={isOpen} id={panelId} className='ps-10'>\n          <ul\n            aria-label={`Sub-agents of ${agent.name}`}\n            className='flex flex-col gap-1 pt-2'\n          >\n            {subAgents.map((subAgent) => (\n              <SubAgentRow\n                key={subAgent.id}\n                agent={subAgent}\n                live={agents[subAgent.id]}\n              />\n            ))}\n          </ul>\n        </Fold>\n      )}\n    </li>\n  );\n}\n\ntype FleetProps = {\n  agents: Record<AgentId, AgentLive>;\n  runningCount: number;\n  openId: AgentId | null;\n  pressed: string | null;\n  onToggle: (id: AgentId) => void;\n};\n\nexport function Fleet({\n  agents,\n  runningCount,\n  openId,\n  pressed,\n  onToggle,\n}: FleetProps) {\n  const isAnyRunning = runningCount > 0;\n\n  return (\n    <section\n      aria-label='Fleet'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col rounded-xl p-1 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <header className='flex h-9 items-center gap-2 px-3'>\n        <h2 className='text-sm font-medium'>Fleet</h2>\n        <span className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n          {isAnyRunning && (\n            <span\n              aria-hidden='true'\n              className='bg-info size-1.5 animate-pulse rounded-full'\n            />\n          )}\n          <MotionNumber value={runningCount} />\n          running\n        </span>\n      </header>\n      <ul className='flex flex-col'>\n        {MAIN_AGENTS.map((agent) => (\n          <FleetRow\n            key={agent.id}\n            agent={agent}\n            agents={agents}\n            isOpen={openId === agent.id}\n            isTogglePressed={pressed === `toggle-${agent.id}`}\n            onToggle={onToggle}\n          />\n        ))}\n      </ul>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/fleet.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/spend.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { springOf } from '@/registry/ndeko/lib/motion-presets';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\n\nimport { MODELS, type Model, type PeriodId } from './data';\n\nconst USD: Intl.NumberFormatOptions = { style: 'currency', currency: 'USD' };\n\nconst PERCENT: Intl.NumberFormatOptions = { maximumFractionDigits: 0 };\n\nconst PERCENT_TEXT = new Intl.NumberFormat('en-US', PERCENT);\n\nexport type ModelSpend = {\n  model: Model;\n  usd: number;\n};\n\nfunction shareOf(usd: number, total: number) {\n  const base = Math.max(total, 0.01);\n  const share = usd / base;\n  return share * 100;\n}\n\n/** Each segment grows by its spend, so the gaps between them never push the last one out. */\nfunction segmentStyleOf(entry: ModelSpend): React.CSSProperties {\n  return {\n    flexGrow: entry.usd,\n    backgroundColor: seriesColorOf(entry.model.series),\n  };\n}\n\nfunction spokenBarOf(entries: ModelSpend[], total: number) {\n  const parts = entries.map((entry) => {\n    const share = shareOf(entry.usd, total);\n    const percent = PERCENT_TEXT.format(share);\n    return `${entry.model.name} ${percent}%`;\n  });\n  return `Spend by model: ${parts.join(', ')}`;\n}\n\ntype StackedBarProps = {\n  entries: ModelSpend[];\n  total: number;\n  period: PeriodId;\n};\n\n/** The segments only measure themselves again when the period changes. */\nfunction StackedBar({ entries, total, period }: StackedBarProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const spring = springOf(shouldReduceMotion);\n\n  return (\n    <div\n      role='img'\n      aria-label={spokenBarOf(entries, total)}\n      className='bg-foreground/[0.05] flex h-2.5 gap-0.5 overflow-hidden rounded-full'\n    >\n      {entries.map((entry) => (\n        <motion.span\n          key={entry.model.id}\n          layout\n          layoutDependency={period}\n          transition={{ layout: spring }}\n          style={segmentStyleOf(entry)}\n          className='h-full min-w-0 basis-0'\n        />\n      ))}\n    </div>\n  );\n}\n\ntype SpendByModelProps = {\n  period: PeriodId;\n  total: number;\n  spendOfModel: (model: Model) => number;\n};\n\nexport function SpendByModel({\n  period,\n  total,\n  spendOfModel,\n}: SpendByModelProps) {\n  const entries = MODELS.map((model) => ({ model, usd: spendOfModel(model) }));\n\n  return (\n    <section\n      aria-label='Spend by model'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col gap-4 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <header className='flex items-center justify-between gap-2'>\n        <h2 className='text-sm font-medium'>Spend by model</h2>\n        <Badge variant='secondary'>Illustrative</Badge>\n      </header>\n      <MotionNumber\n        value={total}\n        format={USD}\n        className='text-2xl leading-8 font-semibold'\n      />\n      <StackedBar entries={entries} total={total} period={period} />\n      <ul className='flex flex-col'>\n        {entries.map((entry) => (\n          <li\n            key={entry.model.id}\n            className='flex h-8 items-center gap-2 text-[13px]'\n          >\n            <span\n              aria-hidden='true'\n              style={{ backgroundColor: seriesColorOf(entry.model.series) }}\n              className='size-2 shrink-0 rounded-full'\n            />\n            <BrandTile brand={entry.model.brand} size='sm' />\n            <span className='min-w-0 flex-1 truncate'>{entry.model.name}</span>\n            <MotionNumber\n              value={shareOf(entry.usd, total)}\n              format={PERCENT}\n              suffix='%'\n              className='text-muted-foreground w-10 justify-end text-xs'\n            />\n            <MotionNumber\n              value={entry.usd}\n              format={USD}\n              className='w-16 justify-end'\n            />\n          </li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/spend.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport type { AgentStatus } from '@/registry/ndeko/lib/agent-run';\n\nimport {\n  agentOf,\n  APPROVALS,\n  MAIN_AGENTS,\n  MODELS,\n  PERIOD_BASE,\n  type AgentId,\n  type ApprovalId,\n  type ModelId,\n  type PeriodId,\n} from './data';\n\nexport type Decision = 'approved' | 'denied';\n\nexport type AgentLive = {\n  status: AgentStatus;\n  task: string;\n  costUsd: number;\n  startedAt?: number;\n  endedAt?: number;\n  /** The trace a person leaves on the row after an approval is handled. */\n  decision?: Decision;\n};\n\nexport type OverviewState = {\n  period: PeriodId;\n  /** Requests that wait on a person, oldest first. */\n  pending: ApprovalId[];\n  agents: Record<AgentId, AgentLive>;\n  /** The main agent whose sub-agents are unfolded. */\n  openId: AgentId | null;\n  finishedRuns: number;\n  failedRuns: number;\n  sessionSpendUsd: Record<ModelId, number>;\n};\n\nexport type OverviewAction =\n  | { type: 'period'; period: PeriodId }\n  | { type: 'toggled'; id: AgentId }\n  | { type: 'spent'; id: AgentId; usd: number }\n  | { type: 'told'; id: AgentId; task: string }\n  | { type: 'finished'; id: AgentId; task: string; usd: number }\n  | { type: 'failed'; id: AgentId; task: string }\n  | { type: 'asked'; approvalId: ApprovalId }\n  | { type: 'decided'; approvalId: ApprovalId; decision: Decision }\n  | { type: 'batch'; actions: OverviewAction[] };\n\ntype Step = SessionStep<OverviewState, OverviewAction>;\n\nconst MINUTE_MS = 60_000;\n\nconst LOADED_AT = Date.now();\n\nfunction since(minutes: number) {\n  return LOADED_AT - minutes * MINUTE_MS;\n}\n\nconst NO_SESSION_SPEND: Record<ModelId, number> = {\n  'claude-sonnet': 0,\n  'claude-haiku': 0,\n  'gpt-mini': 0,\n  'gemini-pro': 0,\n};\n\nexport const INITIAL: OverviewState = {\n  period: 'today',\n  pending: ['send-policy'],\n  openId: null,\n  finishedRuns: 0,\n  failedRuns: 0,\n  sessionSpendUsd: NO_SESSION_SPEND,\n  agents: {\n    planner: {\n      status: 'done',\n      task: 'Planned the autumn catalogue in 6 steps',\n      costUsd: 0.884,\n      startedAt: since(26),\n      endedAt: since(3),\n    },\n    researcher: {\n      status: 'running',\n      task: 'Comparing courier prices for parcels under 2 kg',\n      costUsd: 0.412,\n      startedAt: since(12),\n    },\n    'rate-reader': {\n      status: 'running',\n      task: 'Reading 4 courier rate cards',\n      costUsd: 0.061,\n      startedAt: since(3),\n    },\n    writer: {\n      status: 'running',\n      task: 'Writing product notes for 14 new titles',\n      costUsd: 0.188,\n      startedAt: since(4),\n    },\n    reviewer: {\n      status: 'waiting',\n      task: APPROVALS['send-policy'].waitingTask,\n      costUsd: 0.356,\n      startedAt: since(7),\n    },\n    coder: {\n      status: 'running',\n      task: 'Fixing the checkout rounding error',\n      costUsd: 1.204,\n      startedAt: since(21),\n    },\n    'test-runner': {\n      status: 'running',\n      task: 'Running 41 checkout tests',\n      costUsd: 0.092,\n      startedAt: since(2),\n    },\n    'log-reader': {\n      status: 'done',\n      task: 'Found the rounding in the tax step',\n      costUsd: 0.047,\n      startedAt: since(15),\n      endedAt: since(11),\n    },\n  },\n};\n\nfunction patched(\n  state: OverviewState,\n  id: AgentId,\n  change: (agent: AgentLive) => AgentLive\n): OverviewState {\n  const agent = change(state.agents[id]);\n  return { ...state, agents: { ...state.agents, [id]: agent } };\n}\n\nfunction charged(state: OverviewState, id: AgentId, usd: number) {\n  const modelId = agentOf(id).model;\n  const spentOnModel = state.sessionSpendUsd[modelId] + usd;\n  const sessionSpendUsd = { ...state.sessionSpendUsd, [modelId]: spentOnModel };\n  const withSpend = { ...state, sessionSpendUsd };\n  return patched(withSpend, id, (agent) => ({\n    ...agent,\n    costUsd: agent.costUsd + usd,\n  }));\n}\n\nfunction toggled(state: OverviewState, id: AgentId): OverviewState {\n  if (state.openId === id) {\n    return { ...state, openId: null };\n  }\n  return { ...state, openId: id };\n}\n\nfunction told(state: OverviewState, id: AgentId, task: string) {\n  if (state.agents[id].status !== 'running') {\n    return state;\n  }\n  return patched(state, id, (agent) => ({ ...agent, task }));\n}\n\nfunction finished(\n  state: OverviewState,\n  id: AgentId,\n  task: string,\n  usd: number,\n  now: number\n): OverviewState {\n  if (state.agents[id].status !== 'running') {\n    return state;\n  }\n  const charge = charged(state, id, usd);\n  const done = patched(charge, id, (agent) => ({\n    ...agent,\n    status: 'done',\n    task,\n    endedAt: now,\n  }));\n  return { ...done, finishedRuns: done.finishedRuns + 1 };\n}\n\nfunction failed(\n  state: OverviewState,\n  id: AgentId,\n  task: string,\n  now: number\n): OverviewState {\n  if (state.agents[id].status !== 'running') {\n    return state;\n  }\n  const stopped = patched(state, id, (agent) => ({\n    ...agent,\n    status: 'failed',\n    task,\n    endedAt: now,\n  }));\n  return { ...stopped, failedRuns: stopped.failedRuns + 1 };\n}\n\nfunction asked(state: OverviewState, approvalId: ApprovalId): OverviewState {\n  const approval = APPROVALS[approvalId];\n  const isRunning = state.agents[approval.agentId].status === 'running';\n  const isAlreadyAsked = state.pending.includes(approvalId);\n  if (!isRunning || isAlreadyAsked) {\n    return state;\n  }\n  const waiting = patched(state, approval.agentId, (agent) => ({\n    ...agent,\n    status: 'waiting',\n    task: approval.waitingTask,\n  }));\n  return { ...waiting, pending: [...waiting.pending, approvalId] };\n}\n\nfunction decided(\n  state: OverviewState,\n  approvalId: ApprovalId,\n  decision: Decision,\n  now: number\n): OverviewState {\n  if (!state.pending.includes(approvalId)) {\n    return state;\n  }\n  const approval = APPROVALS[approvalId];\n  const pending = state.pending.filter((id) => id !== approvalId);\n  const handled = { ...state, pending };\n  if (decision === 'approved') {\n    return patched(handled, approval.agentId, (agent) => ({\n      ...agent,\n      status: 'running',\n      task: approval.approvedTask,\n      decision,\n    }));\n  }\n  return patched(handled, approval.agentId, (agent) => ({\n    ...agent,\n    status: 'idle',\n    task: approval.deniedTask,\n    decision,\n    endedAt: now,\n  }));\n}\n\nexport function applyAt(\n  state: OverviewState,\n  action: OverviewAction,\n  now: number\n): OverviewState {\n  switch (action.type) {\n    case 'period':\n      return { ...state, period: action.period };\n    case 'toggled':\n      return toggled(state, action.id);\n    case 'spent':\n      return charged(state, action.id, action.usd);\n    case 'told':\n      return told(state, action.id, action.task);\n    case 'finished':\n      return finished(state, action.id, action.task, action.usd, now);\n    case 'failed':\n      return failed(state, action.id, action.task, now);\n    case 'asked':\n      return asked(state, action.approvalId);\n    case 'decided':\n      return decided(state, action.approvalId, action.decision, now);\n    case 'batch': {\n      let next = state;\n      for (const inner of action.actions) {\n        next = applyAt(next, inner, now);\n      }\n      return next;\n    }\n  }\n}\n\nexport function reducer(state: OverviewState, action: OverviewAction) {\n  return applyAt(state, action, Date.now());\n}\n\nexport type Totals = {\n  runs: number;\n  waiting: number;\n  failed: number;\n  spendUsd: number;\n};\n\nexport function spendOf(state: OverviewState, modelId: ModelId) {\n  const base = PERIOD_BASE[state.period].spendUsd[modelId];\n  return base + state.sessionSpendUsd[modelId];\n}\n\nexport function totalSpendOf(state: OverviewState) {\n  let total = 0;\n  for (const model of MODELS) {\n    total += spendOf(state, model.id);\n  }\n  return total;\n}\n\nexport function totalsOf(state: OverviewState): Totals {\n  const base = PERIOD_BASE[state.period];\n  return {\n    runs: base.runs + state.finishedRuns,\n    waiting: state.pending.length,\n    failed: base.failed + state.failedRuns,\n    spendUsd: totalSpendOf(state),\n  };\n}\n\nexport function runningCountOf(state: OverviewState) {\n  const running = MAIN_AGENTS.filter(\n    (agent) => state.agents[agent.id].status === 'running'\n  );\n  return running.length;\n}\n\nfunction hasDecided(approvalId: ApprovalId) {\n  return (state: OverviewState) => !state.pending.includes(approvalId);\n}\n\n/** A request that waits on a person is answered by the demonstration after this long. */\nconst DECIDE_AFTER_MS = 2500;\n\nconst ARRIVAL: Step[] = [\n  { after: 1300, action: { type: 'spent', id: 'researcher', usd: 0.021 } },\n  {\n    after: 1400,\n    action: {\n      type: 'finished',\n      id: 'writer',\n      task: 'Product notes ready for 14 titles',\n      usd: 0.026,\n    },\n  },\n  {\n    after: 1400,\n    action: {\n      type: 'batch',\n      actions: [\n        {\n          type: 'failed',\n          id: 'test-runner',\n          task: '3 of 41 tests failed on currency rounding',\n        },\n        { type: 'told', id: 'coder', task: 'Reading the 3 failed tests' },\n      ],\n    },\n  },\n  { after: 1500, action: { type: 'asked', approvalId: 'run-migration' } },\n];\n\nexport const SCRIPT: Step[] = [\n  ...ARRIVAL,\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'approve-send-policy',\n    action: {\n      type: 'decided',\n      approvalId: 'send-policy',\n      decision: 'approved',\n    },\n    isAnswered: hasDecided('send-policy'),\n  },\n  {\n    after: 1300,\n    by: 'demo',\n    press: 'toggle-coder',\n    action: { type: 'toggled', id: 'coder' },\n  },\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'approve-run-migration',\n    action: {\n      type: 'decided',\n      approvalId: 'run-migration',\n      decision: 'approved',\n    },\n    isAnswered: hasDecided('run-migration'),\n  },\n  {\n    after: 1600,\n    action: {\n      type: 'finished',\n      id: 'reviewer',\n      task: 'Sent the refund policy update to 212 customers',\n      usd: 0.018,\n    },\n  },\n  { after: 1500, by: 'demo', action: { type: 'period', period: 'week' } },\n  {\n    after: 1700,\n    action: {\n      type: 'finished',\n      id: 'rate-reader',\n      task: 'Read 4 rate cards, 2 prices changed',\n      usd: 0.031,\n    },\n  },\n];\n\n/** Under reduced motion both requests still wait, so the list and its buttons can be read. */\nfunction restingOf() {\n  let state = INITIAL;\n  let now = LOADED_AT;\n  for (const step of ARRIVAL) {\n    now += step.after;\n    state = applyAt(state, step.action, now);\n  }\n  return applyAt(state, { type: 'toggled', id: 'coder' }, now);\n}\n\nexport const RESTING = restingOf();\n\nexport const LOOP_AFTER_MS = 3600;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-ops/agent-ops-01/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport const TEAM_NAME = 'Solway Books';\n\nexport type PeriodId = 'today' | 'week';\n\nexport const PERIODS: { value: PeriodId; label: string }[] = [\n  { value: 'today', label: 'Today' },\n  { value: 'week', label: '7 days' },\n];\n\nexport type ModelId =\n  'claude-sonnet' | 'claude-haiku' | 'gpt-mini' | 'gemini-pro';\n\nexport type Model = {\n  id: ModelId;\n  name: string;\n  brand: BrandSlug;\n  /** Fixed per model, so a colour means the same model in the bar and in the fleet. */\n  series: SeriesSlot;\n};\n\n/** Families without a version number. */\nexport const MODELS: Model[] = [\n  { id: 'claude-sonnet', name: 'Claude Sonnet', brand: 'claude', series: 1 },\n  { id: 'claude-haiku', name: 'Claude Haiku', brand: 'claude', series: 2 },\n  { id: 'gpt-mini', name: 'GPT mini', brand: 'openai', series: 3 },\n  { id: 'gemini-pro', name: 'Gemini Pro', brand: 'gemini', series: 4 },\n];\n\nexport type PeriodBase = {\n  runs: number;\n  failed: number;\n  spendUsd: Record<ModelId, number>;\n};\n\n/** What the period held before this session. Illustrative. */\nexport const PERIOD_BASE: Record<PeriodId, PeriodBase> = {\n  today: {\n    runs: 48,\n    failed: 2,\n    spendUsd: {\n      'claude-sonnet': 8.42,\n      'claude-haiku': 2.16,\n      'gpt-mini': 3.08,\n      'gemini-pro': 4.74,\n    },\n  },\n  week: {\n    runs: 312,\n    failed: 11,\n    spendUsd: {\n      'claude-sonnet': 58.3,\n      'claude-haiku': 14.9,\n      'gpt-mini': 21.2,\n      'gemini-pro': 32.5,\n    },\n  },\n};\n\nexport type AgentId =\n  | 'planner'\n  | 'researcher'\n  | 'rate-reader'\n  | 'writer'\n  | 'reviewer'\n  | 'coder'\n  | 'test-runner'\n  | 'log-reader';\n\nexport type Agent = {\n  id: AgentId;\n  name: string;\n  model: ModelId;\n  parentId?: AgentId;\n};\n\nexport const AGENTS: Agent[] = [\n  { id: 'planner', name: 'Planner', model: 'gemini-pro' },\n  {\n    id: 'researcher',\n    name: 'Researcher',\n    model: 'claude-sonnet',\n  },\n  {\n    id: 'rate-reader',\n    name: 'Rate reader',\n    model: 'claude-haiku',\n    parentId: 'researcher',\n  },\n  { id: 'writer', name: 'Writer', model: 'gpt-mini' },\n  { id: 'reviewer', name: 'Reviewer', model: 'claude-sonnet' },\n  { id: 'coder', name: 'Coder', model: 'claude-sonnet' },\n  {\n    id: 'test-runner',\n    name: 'Test runner',\n    model: 'claude-haiku',\n    parentId: 'coder',\n  },\n  {\n    id: 'log-reader',\n    name: 'Log scanner',\n    model: 'claude-haiku',\n    parentId: 'coder',\n  },\n];\n\nexport type ApprovalId = 'send-policy' | 'run-migration';\n\nexport type Approval = {\n  id: ApprovalId;\n  agentId: AgentId;\n  title: string;\n  detail: string;\n  /** What the agent's row says while it waits, once approved and once denied. */\n  waitingTask: string;\n  approvedTask: string;\n  deniedTask: string;\n};\n\nexport const APPROVALS: Record<ApprovalId, Approval> = {\n  'send-policy': {\n    id: 'send-policy',\n    agentId: 'reviewer',\n    title: 'Send the refund policy update to 212 customers',\n    detail: 'One email from support@solwaybooks.example',\n    waitingTask: 'Waits for your yes before it sends the update',\n    approvedTask: 'Sending the refund policy update',\n    deniedTask: 'Stopped: you denied the send',\n  },\n  'run-migration': {\n    id: 'run-migration',\n    agentId: 'coder',\n    title: 'Run the rounding migration on the staging database',\n    detail: 'Changes 3 columns in orders and can be rolled back',\n    waitingTask: 'Waits for your yes before it touches staging',\n    approvedTask: 'Running the migration on staging',\n    deniedTask: 'Stopped: you denied the migration',\n  },\n};\n\nexport function modelOf(id: ModelId) {\n  const model = MODELS.find((candidate) => candidate.id === id);\n  return model ?? MODELS[0];\n}\n\nexport function agentOf(id: AgentId) {\n  const agent = AGENTS.find((candidate) => candidate.id === id);\n  return agent ?? AGENTS[0];\n}\n\nexport function subAgentsOf(id: AgentId) {\n  return AGENTS.filter((agent) => agent.parentId === id);\n}\n\nexport const MAIN_AGENTS = AGENTS.filter(\n  (agent) => agent.parentId === undefined\n);\n",
      "type": "registry:component",
      "target": "components/blocks/agent-ops-01/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-ops"
  ],
  "type": "registry:block"
}