{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "application-06",
  "title": "Agent workspace",
  "description": "A Ferrowick agent workspace: sessions grouped by day with a search that go into a sheet on phones, a thread where thinking, tool calls that open to their input and result, result cards and a request waiting for Allow or Deny arrive as the agent works, and a composer that takes photos and files, tools and skills, queues what you write while the agent answers and sets how hard it thinks on a ramp of five dots you tap or drag. Plug your agent into onSend, onApprove and onDeny.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.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/call-status.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/inline-sheet.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/kbd.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/run-session.json",
    "https://ui.ndekocode.dev/r/spinner.json",
    "https://ui.ndekocode.dev/r/streamed-text.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-follow-bottom.json",
    "https://ui.ndekocode.dev/r/use-is-narrow.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",
    "https://ui.ndekocode.dev/r/wash.json",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/index.tsx",
      "content": "'use client';\n\nimport { useIsNarrow } from '@/registry/ndeko/hooks/use-is-narrow';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { InlineSheet } from '@/registry/ndeko/ui/inline-sheet';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { Composer, ReadOnlyNote } from './composer';\nimport {\n  BRAND,\n  DECLINED_LINE,\n  LIVE_ID,\n  LIVE_TITLE,\n  NEW_ID,\n  NEW_SESSION_TITLE,\n  pastSessionOf,\n  UNPAID_TOTAL,\n  type Attachment,\n} from './data';\nimport {\n  INITIAL,\n  isBusy,\n  isReadOnly,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  sendableTextOf,\n  type Decision,\n  type WorkspaceState,\n} from './session';\nimport { SessionHeader, statusWordOf } from './session-header';\nimport { rowsOf, SessionsSidebar } from './sessions-sidebar';\nimport { Thread } from './thread';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\n/** The width of the `@3xl` container variant: under it the sessions live in a sheet. */\nconst SHEET_BELOW_REM = 48;\n\nfunction titleOf(state: WorkspaceState) {\n  if (state.activeId === LIVE_ID) {\n    if (state.turns.length === 0) {\n      return NEW_SESSION_TITLE;\n    }\n    return LIVE_TITLE;\n  }\n  if (state.activeId === NEW_ID) {\n    return NEW_SESSION_TITLE;\n  }\n  return pastSessionOf(state.activeId).title;\n}\n\nfunction placeholderOf(state: WorkspaceState) {\n  const last = state.turns.at(-1);\n  if (state.activeId === NEW_ID || !last) {\n    return 'Describe the work';\n  }\n  if (last.stage === 'asking') {\n    return 'Allow or deny the request above, or queue a follow-up';\n  }\n  if (isBusy(state)) {\n    return 'Write a follow-up. It waits until the agent is done';\n  }\n  return 'Ask for something else';\n}\n\nfunction announcementOf(state: WorkspaceState) {\n  const last = state.turns.at(-1);\n  if (!last) {\n    return '';\n  }\n  if (last.stage === 'asking') {\n    return `Operator asks to send ${UNPAID_TOTAL.count} reminders on WhatsApp. Allow or deny it`;\n  }\n  if (last.stage === 'declined') {\n    return DECLINED_LINE;\n  }\n  if (last.stage === 'done') {\n    return 'Operator is done';\n  }\n  return '';\n}\n\n/**\n * Nothing calls a network. A real agent plugs in here: each message a person sends (also one that\n * waits in the queue), and their answer to a request that waits on them.\n */\nexport type Application06Props = {\n  onSend?: (text: string) => void;\n  onApprove?: () => void;\n  onDeny?: () => void;\n};\n\nexport default function Application06({\n  onSend,\n  onApprove,\n  onDeny,\n}: Application06Props) {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const hasSheet = useIsNarrow(ref, SHEET_BELOW_REM);\n  const last = state.turns.at(-1);\n  const sendableText = sendableTextOf(state);\n  const canSend = sendableText !== null;\n  const canReplay = isFinished && !isAutoplaying;\n  const isSheetShown = hasSheet && state.isSidebarOpen;\n  const message = spokenUnless(isAutoplaying, announcementOf(state));\n\n  function focusLater(selector: string) {\n    requestAnimationFrame(() => {\n      const target = ref.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  function send() {\n    if (sendableText === null) {\n      return;\n    }\n    act({ type: 'sent' });\n    onSend?.(sendableText);\n  }\n\n  /** The two buttons leave with the request, so the focus goes to what replaces them: the line that says what was decided. */\n  function decide(decision: Decision) {\n    act({ type: 'decided', decision });\n    focusLater('[data-request]');\n    if (decision === 'denied') {\n      onDeny?.();\n      return;\n    }\n    onApprove?.();\n  }\n\n  function openSessions() {\n    act({ type: 'sidebar', isOpen: true });\n    focusLater('[data-sheet-close=\"sessions\"]');\n  }\n\n  function closeSessions() {\n    act({ type: 'sidebar', isOpen: false });\n    focusLater('[data-sidebar-open]');\n  }\n\n  function openSession(id: string) {\n    act({ type: 'sessionOpened', id });\n    focusLater('[data-composer-field]');\n  }\n\n  function startNewSession() {\n    act({ type: 'newSession' });\n    focusLater('[data-composer-field]');\n  }\n\n  const sidebar = {\n    rows: rowsOf(state),\n    activeId: state.activeId,\n    search: state.search,\n    onSearch: (text: string) => act({ type: 'searched', text }),\n    onOpen: openSession,\n    onNewSession: startNewSession,\n  };\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-sidebar text-foreground @container min-h-dvh w-full'\n      >\n        <div className='relative flex h-dvh min-h-[40rem] overflow-hidden'>\n          <div inert={isSheetShown} className='flex min-w-0 flex-1 @3xl:p-2'>\n            <aside\n              aria-label='Sessions'\n              className='hidden w-64 shrink-0 pe-2 @3xl:flex'\n            >\n              {!hasSheet && <SessionsSidebar {...sidebar} />}\n            </aside>\n            <main className='bg-background @3xl:hairline-ring @3xl:ring-border flex min-w-0 flex-1 flex-col overflow-clip @3xl:rounded-xl @3xl:shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n              <SessionHeader\n                title={titleOf(state)}\n                turn={last}\n                statusWord={statusWordOf(last)}\n                costUsd={state.costUsd}\n                hasSheet={hasSheet}\n                canReplay={canReplay}\n                onReplay={restart}\n                onOpenSessions={openSessions}\n              />\n              <Thread\n                state={state}\n                pressed={pressed}\n                isActive={isInView}\n                onDecide={decide}\n              />\n              <div className='mx-auto w-full max-w-2xl shrink-0 px-4 pb-4'>\n                {isReadOnly(state) && (\n                  <ReadOnlyNote onNewSession={startNewSession} />\n                )}\n                {!isReadOnly(state) && (\n                  <Composer\n                    draft={state.draft}\n                    placeholder={placeholderOf(state)}\n                    canSend={canSend}\n                    isBusy={isBusy(state)}\n                    attachments={state.attachments}\n                    toolIds={state.toolIds}\n                    skillIds={state.skillIds}\n                    effort={state.effort}\n                    queue={state.queue}\n                    hint={state.hint}\n                    refusals={state.refusals}\n                    pressed={pressed}\n                    onDraftChange={(text) => act({ type: 'typed', text })}\n                    onSend={send}\n                    onAttach={(attachments: Attachment[]) =>\n                      act({ type: 'attached', attachments })\n                    }\n                    onDetach={(id) => act({ type: 'detached', id })}\n                    onToggleTool={(id) => act({ type: 'toolToggled', id })}\n                    onToggleSkill={(id) => act({ type: 'skillToggled', id })}\n                    onEffortChange={(effort) =>\n                      act({ type: 'effortSet', effort })\n                    }\n                    onRemoveQueued={(id) => act({ type: 'queueRemoved', id })}\n                  />\n                )}\n              </div>\n            </main>\n          </div>\n\n          <InlineSheet\n            name='sessions'\n            label={`${BRAND.name} sessions`}\n            closeLabel='Close the sessions'\n            side='start'\n            isOpen={isSheetShown}\n            className='@3xl:hidden'\n            panelClassName='bg-sidebar gap-1 p-3'\n            onClose={closeSessions}\n          >\n            {hasSheet && <SessionsSidebar {...sidebar} />}\n          </InlineSheet>\n          <LiveRegion message={message} />\n        </div>\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/index.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/agent-turn.tsx",
      "content": "'use client';\n\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport { StreamedText } from '@/registry/ndeko/ui/streamed-text';\n\nimport { ApprovalCard, requestViewOf } from './approval-card';\nimport { CallRow } from './call-row';\nimport { OPERATOR, seedOf, stepSeedOf, type ResultKind } from './data';\nimport { ResultCard } from './result-cards';\nimport {\n  ANSWER_WORD_MS,\n  type Decision,\n  type StepRun,\n  type Turn,\n} from './session';\nimport { ThinkingRow } from './thinking-row';\n\nexport function OperatorTile() {\n  const color = seriesColorOf(OPERATOR.series);\n\n  return <MeshTile seed={OPERATOR.name} color={color} size='lg' />;\n}\n\nfunction resultKindOf(run: StepRun): ResultKind | null {\n  if (run.status !== 'done') {\n    return null;\n  }\n  return stepSeedOf(run.id).result ?? null;\n}\n\ntype AgentTurnProps = {\n  turn: Turn;\n  pressed: string | null;\n  isActive: boolean;\n  onDecide: (decision: Decision) => void;\n};\n\nexport function AgentTurn({\n  turn,\n  pressed,\n  isActive,\n  onDecide,\n}: AgentTurnProps) {\n  const seed = seedOf(turn.seedId);\n  const requestView = requestViewOf(turn);\n  const lastIndex = turn.steps.length - 1;\n  const isAnswering = turn.stage === 'answering';\n  const hasAnswer = isAnswering || turn.stage === 'done';\n  const isCanned = turn.seedId === 'canned';\n\n  return (\n    <div className='flex items-start gap-2.5'>\n      <OperatorTile />\n      <div className='flex min-w-0 flex-1 flex-col gap-3 pt-1'>\n        <span className='sr-only'>{OPERATOR.name}</span>\n        {seed.thought !== undefined && (\n          <ThinkingRow\n            text={seed.thought}\n            stage={turn.stage}\n            effort={turn.effort}\n            isActive={isActive}\n            startedAt={turn.startedAt}\n            thoughtEndedAt={turn.thoughtEndedAt}\n          />\n        )}\n        {turn.steps.length > 0 && (\n          <ol aria-label='What the agent did' className='flex flex-col'>\n            {turn.steps.map((run, index) => {\n              const kind = resultKindOf(run);\n              return (\n                <CallRow key={run.id} run={run} isLast={index === lastIndex}>\n                  {kind && <ResultCard kind={kind} />}\n                </CallRow>\n              );\n            })}\n          </ol>\n        )}\n        {requestView !== 'none' && (\n          <ApprovalCard\n            view={requestView}\n            pressed={pressed}\n            onDecide={onDecide}\n          />\n        )}\n        {hasAnswer && isCanned && (\n          <p className='text-muted-foreground text-sm leading-relaxed'>\n            {seed.answer}\n          </p>\n        )}\n        {hasAnswer && !isCanned && (\n          <p className='text-sm leading-relaxed'>\n            <StreamedText\n              text={seed.answer}\n              isStreaming={isAnswering}\n              isActive={isActive}\n              wordMs={ANSWER_WORD_MS}\n            />\n          </p>\n        )}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/agent-turn.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/approval-card.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { CircleXIcon } from '@/registry/ndeko/lib/icons';\nimport { fadePresence } from '@/registry/ndeko/lib/motion-presets';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\nimport { Spinner } from '@/registry/ndeko/ui/spinner';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport {\n  DECLINED_LINE,\n  REMINDER_PREVIEW,\n  REQUEST_RECIPIENTS,\n  SENT_LINE,\n  UNPAID_TOTAL,\n} from './data';\nimport type { Decision, Turn } from './session';\n\nexport type RequestView = 'none' | 'asking' | 'sending' | 'sent' | 'denied';\n\nexport function requestViewOf(turn: Turn): RequestView {\n  if (turn.stage === 'asking') {\n    return 'asking';\n  }\n  if (turn.decision === 'denied') {\n    return 'denied';\n  }\n  if (turn.decision === 'approved') {\n    const run = turn.steps.find((candidate) => candidate.id === 'reminders');\n    if (run?.status === 'done') {\n      return 'sent';\n    }\n    return 'sending';\n  }\n  return 'none';\n}\n\ntype RequestBodyProps = {\n  pressed: string | null;\n  onDecide: (decision: Decision) => void;\n};\n\nfunction RequestBody({ pressed, onDecide }: RequestBodyProps) {\n  const titleId = useId();\n  const keysId = useId();\n  const others = UNPAID_TOTAL.count - REQUEST_RECIPIENTS.length;\n\n  function allow() {\n    onDecide('approved');\n  }\n\n  function deny() {\n    onDecide('denied');\n  }\n\n  function decideFromKeys(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      deny();\n      return;\n    }\n    const isOnCard = event.target === event.currentTarget;\n    const isEnter = event.key === 'Enter';\n    if (isEnter && isOnCard) {\n      event.preventDefault();\n      allow();\n    }\n  }\n\n  return (\n    <div\n      role='group'\n      tabIndex={0}\n      aria-labelledby={titleId}\n      aria-describedby={keysId}\n      onKeyDown={decideFromKeys}\n      className='focus-visible:ring-ring/25 relative isolate flex flex-col gap-3 rounded-xl p-3 outline-none focus-visible:ring-[3px] focus-visible:ring-inset'\n    >\n      <Wash color='var(--warning)' />\n      <div className='flex items-center gap-2.5'>\n        <BrandTile brand='whatsapp' size='lg' title='WhatsApp' />\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <h2 id={titleId} className='text-sm font-medium'>\n            Send {UNPAID_TOTAL.count} reminders on WhatsApp\n          </h2>\n          <span className='text-muted-foreground truncate text-xs'>\n            One message to each customer\n          </span>\n        </div>\n        <Badge variant='warning' className='hidden @md:inline-flex'>\n          Waiting on you\n        </Badge>\n      </div>\n      <div className='bg-foreground/[0.04] flex flex-col gap-2 rounded-lg p-2.5 text-xs'>\n        <p className='flex items-center gap-1.5'>\n          <span className='flex items-center -space-x-1.5'>\n            {REQUEST_RECIPIENTS.map((person) => (\n              <Avatar\n                key={person.name}\n                seed={person.name}\n                className='ring-card size-5 ring-2'\n              />\n            ))}\n          </span>\n          <span className='text-muted-foreground min-w-0 truncate'>\n            {REQUEST_RECIPIENTS[0].name}, {REQUEST_RECIPIENTS[1].name} and{' '}\n            {others} more\n          </span>\n        </p>\n        <p className='leading-relaxed'>{REMINDER_PREVIEW}</p>\n      </div>\n      <div className='flex flex-wrap items-center gap-2'>\n        <Button\n          type='button'\n          size='sm'\n          onClick={allow}\n          className={pressedSolidOf(pressed === 'allow')}\n        >\n          Allow\n          <Kbd className='ms-0.5'>Enter</Kbd>\n        </Button>\n        <Button type='button' size='sm' variant='outline' onClick={deny}>\n          Deny\n          <Kbd className='ms-0.5'>Esc</Kbd>\n        </Button>\n        <span id={keysId} className='sr-only'>\n          Enter allows, Escape denies\n        </span>\n      </div>\n    </div>\n  );\n}\n\nfunction ResultGlyph({ view }: { view: RequestView }) {\n  if (view === 'sending') {\n    return <Spinner aria-hidden='true' />;\n  }\n  if (view === 'denied') {\n    return <CircleXIcon className='text-muted-foreground size-4 shrink-0' />;\n  }\n  return <DrawnCheck tone='success' entrance='draw' />;\n}\n\nfunction resultLineOf(view: RequestView) {\n  if (view === 'sending') {\n    return `Sending ${UNPAID_TOTAL.count} reminders`;\n  }\n  if (view === 'denied') {\n    return DECLINED_LINE;\n  }\n  return SENT_LINE;\n}\n\nfunction ResultLine({ view }: { view: RequestView }) {\n  return (\n    <div className='flex min-h-11 items-start gap-2.5 p-3 text-[13px] leading-5'>\n      <Swap swapKey={view} className='mt-px'>\n        <ResultGlyph view={view} />\n      </Swap>\n      <p\n        key={view}\n        className='min-w-0 transition-opacity duration-300 starting:opacity-0'\n      >\n        {resultLineOf(view)}\n      </p>\n    </div>\n  );\n}\n\nfunction viewKeyOf(isAsking: boolean) {\n  if (isAsking) {\n    return 'request';\n  }\n  return 'result';\n}\n\ntype ApprovalCardProps = RequestBodyProps & {\n  view: RequestView;\n};\n\nexport function ApprovalCard({ view, pressed, onDecide }: ApprovalCardProps) {\n  const fade = fadePresence();\n  const isAsking = view === 'asking';\n\n  return (\n    <section\n      data-request\n      tabIndex={-1}\n      aria-label='Request to send the reminders'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-opacity duration-300 outline-none starting:opacity-0'\n    >\n      <AnimatedSize>\n        <AnimatePresence initial={false} mode='popLayout'>\n          <motion.div key={viewKeyOf(isAsking)} {...fade}>\n            {isAsking && <RequestBody pressed={pressed} onDecide={onDecide} />}\n            {!isAsking && <ResultLine view={view} />}\n          </motion.div>\n        </AnimatePresence>\n      </AnimatedSize>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/approval-card.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/call-row.tsx",
      "content": "'use client';\n\nimport { useId, useState } from 'react';\n\nimport { elapsedOf, formatDuration } from '@/registry/ndeko/lib/agent-run';\nimport {\n  ChevronDownIcon,\n  MinusIcon,\n  WandIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { CallStatusMark } from '@/registry/ndeko/ui/call-status';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\n\nimport { stepSeedOf, type StepKind, type StepSeed } from './data';\nimport type { StepRun, StepStatus } from './session';\n\nconst KIND_WORD: Record<StepKind, string> = {\n  tool: 'Tool',\n  skill: 'Skill',\n};\n\nfunction StepTile({ seed }: { seed: StepSeed }) {\n  if (seed.brand) {\n    return <BrandTile brand={seed.brand} size='lg' title={seed.product} />;\n  }\n\n  return (\n    <span\n      aria-hidden='true'\n      className='keycap-3d text-muted-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md'\n    >\n      <WandIcon className='size-3.5' />\n    </span>\n  );\n}\n\nfunction StepMark({ status }: { status: StepStatus }) {\n  if (status === 'skipped') {\n    return (\n      <span className='inline-flex size-4 shrink-0 items-center justify-center'>\n        <MinusIcon className='text-muted-foreground size-4' />\n        <span className='sr-only'>Not run</span>\n      </span>\n    );\n  }\n  return <CallStatusMark status={status} />;\n}\n\nfunction StepClock({ run }: { run: StepRun }) {\n  if (run.status === 'running') {\n    return (\n      <LiveDuration\n        item={run}\n        isRunning\n        className='text-muted-foreground w-10 shrink-0 text-end text-xs'\n      />\n    );\n  }\n  if (run.status === 'done') {\n    const elapsed = elapsedOf(run, run.endedAt ?? 0);\n    return (\n      <span className='text-muted-foreground w-10 shrink-0 text-end text-xs tabular-nums'>\n        {formatDuration(elapsed)}\n      </span>\n    );\n  }\n  return null;\n}\n\nfunction sublineOf(seed: StepSeed, status: StepStatus) {\n  if (status === 'done') {\n    return seed.doneSummary;\n  }\n  if (status === 'skipped') {\n    return 'Nothing was sent';\n  }\n  return seed.detail;\n}\n\nfunction chevronTurnOf(isOpen: boolean) {\n  if (isOpen) {\n    return 'rotate-180';\n  }\n  return 'rotate-0';\n}\n\ntype CallRowProps = {\n  run: StepRun;\n  isLast: boolean;\n  children?: React.ReactNode;\n};\n\nexport function CallRow({ run, isLast, children }: CallRowProps) {\n  const [isOpen, setIsOpen] = useState(false);\n  const detailsId = useId();\n  const seed = stepSeedOf(run.id);\n\n  function toggle() {\n    setIsOpen((current) => !current);\n  }\n\n  return (\n    <li className='relative flex gap-2.5 pb-3 transition-[opacity,translate] duration-300 ease-(--ease-out-strong) last:pb-0 starting:translate-y-1 starting:opacity-0'>\n      {!isLast && (\n        <span\n          aria-hidden='true'\n          className='bg-border absolute start-3.5 top-8 bottom-1 w-px'\n        />\n      )}\n      <StepTile seed={seed} />\n      <div className='flex min-w-0 flex-1 flex-col'>\n        <button\n          type='button'\n          aria-expanded={isOpen}\n          aria-controls={detailsId}\n          onClick={toggle}\n          className='hover:bg-foreground/[0.04] focus-visible:ring-ring/25 -mx-1.5 flex cursor-pointer flex-col rounded-md px-1.5 text-start outline-none focus-visible:ring-[3px]'\n        >\n          <span className='flex h-7 items-center gap-2 text-[13px]'>\n            <span className='min-w-0 truncate font-medium'>{seed.title}</span>\n            <StepMark status={run.status} />\n            <StepClock run={run} />\n            <ChevronDownIcon\n              className={cn(\n                'text-muted-foreground size-3.5 shrink-0 transition-transform duration-200 ease-(--ease-out-strong)',\n                chevronTurnOf(isOpen)\n              )}\n            />\n          </span>\n          <span className='text-muted-foreground min-h-5 text-xs leading-5'>\n            <span className='text-foreground/70'>{KIND_WORD[seed.kind]}</span>\n            <span aria-hidden='true'> · </span>\n            <span\n              key={run.status}\n              className='transition-opacity duration-300 starting:opacity-0'\n            >\n              {sublineOf(seed, run.status)}\n            </span>\n          </span>\n        </button>\n        <Fold open={isOpen} id={detailsId}>\n          <dl className='bg-foreground/[0.03] dark:bg-foreground/[0.05] mt-1.5 flex flex-col gap-1 rounded-lg p-2.5 font-mono text-xs leading-relaxed'>\n            <div className='flex gap-1.5'>\n              <dt className='text-muted-foreground shrink-0'>Input</dt>\n              <dd className='min-w-0 break-words'>{seed.input}</dd>\n            </div>\n            <div className='flex gap-1.5'>\n              <dt className='text-muted-foreground shrink-0'>Result</dt>\n              <dd className='min-w-0 break-words'>{seed.output}</dd>\n            </div>\n          </dl>\n        </Fold>\n        {children}\n      </div>\n    </li>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/call-row.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/chips.tsx",
      "content": "'use client';\n\nimport {\n  FileTextIcon,\n  ImageIcon,\n  WandIcon,\n  XIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\n\nimport {\n  skillOf,\n  toolOf,\n  type Attachment,\n  type SkillId,\n  type ToolId,\n} from './data';\n\nconst KILOBYTE = 1024;\n\nconst MEGABYTE = KILOBYTE * KILOBYTE;\n\n/** 48 KB, 1.2 MB. */\nexport function formatBytes(bytes: number) {\n  if (bytes < MEGABYTE) {\n    const rounded = Math.round(bytes / KILOBYTE);\n    const kilobytes = Math.max(1, rounded);\n    return `${kilobytes} KB`;\n  }\n  const megabytes = bytes / MEGABYTE;\n  return `${megabytes.toFixed(1)} MB`;\n}\n\nconst CHIP =\n  'bg-foreground/[0.05] flex h-7 max-w-full items-center gap-1.5 rounded-lg ps-1.5 pe-1 text-xs transition-[opacity,scale] duration-200 ease-(--ease-out-strong) starting:scale-95 starting:opacity-0';\n\nconst REMOVE =\n  'text-muted-foreground hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-ring/25 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-md outline-none focus-visible:ring-[3px] active:scale-[0.97]';\n\ntype RemoveProps = {\n  label: string;\n  onRemove: () => void;\n};\n\nfunction RemoveButton({ label, onRemove }: RemoveProps) {\n  return (\n    <button\n      type='button'\n      aria-label={label}\n      onClick={onRemove}\n      className={REMOVE}\n    >\n      <XIcon className='size-3' />\n    </button>\n  );\n}\n\ntype AttachmentChipProps = {\n  attachment: Attachment;\n  /** Left out on a message that was already sent: its files can no longer change. */\n  onRemove?: (id: string) => void;\n};\n\nexport function AttachmentChip({ attachment, onRemove }: AttachmentChipProps) {\n  const isPhoto = attachment.kind === 'photo';\n\n  function remove() {\n    onRemove?.(attachment.id);\n  }\n\n  return (\n    <li className={CHIP}>\n      {isPhoto && (\n        <ImageIcon className='text-muted-foreground size-3.5 shrink-0' />\n      )}\n      {!isPhoto && (\n        <FileTextIcon className='text-muted-foreground size-3.5 shrink-0' />\n      )}\n      <span className='min-w-0 truncate'>{attachment.name}</span>\n      <span className='text-muted-foreground shrink-0 tabular-nums'>\n        {formatBytes(attachment.bytes)}\n      </span>\n      {onRemove && (\n        <RemoveButton label={`Remove ${attachment.name}`} onRemove={remove} />\n      )}\n    </li>\n  );\n}\n\ntype ToolChipProps = {\n  toolId: ToolId;\n  onRemove: (id: ToolId) => void;\n};\n\nexport function ToolChip({ toolId, onRemove }: ToolChipProps) {\n  const tool = toolOf(toolId);\n\n  function remove() {\n    onRemove(toolId);\n  }\n\n  return (\n    <li className={cn(CHIP, 'ps-1')}>\n      <BrandTile brand={tool.brand} size='sm' />\n      <span className='min-w-0 truncate'>{tool.name}</span>\n      <RemoveButton label={`Turn off ${tool.name}`} onRemove={remove} />\n    </li>\n  );\n}\n\ntype SkillChipProps = {\n  skillId: SkillId;\n  onRemove: (id: SkillId) => void;\n};\n\nexport function SkillChip({ skillId, onRemove }: SkillChipProps) {\n  const skill = skillOf(skillId);\n\n  function remove() {\n    onRemove(skillId);\n  }\n\n  return (\n    <li className={cn(CHIP, 'ps-1')}>\n      <span\n        aria-hidden='true'\n        className='keycap-3d text-muted-foreground inline-flex size-4 shrink-0 items-center justify-center rounded-[4px]'\n      >\n        <WandIcon className='size-2.5' />\n      </span>\n      <span className='min-w-0 truncate'>{skill.name}</span>\n      <RemoveButton label={`Turn off ${skill.name}`} onRemove={remove} />\n    </li>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/chips.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/composer.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\nimport { useId, useRef } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  pressedQuietOf,\n  pressedSolidOf,\n} from '@/registry/ndeko/lib/demonstration';\nimport {\n  ArrowUpIcon,\n  HourglassIcon,\n  PaperclipIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport { AttachmentChip, SkillChip, ToolChip } from './chips';\nimport {\n  FULL_HINT,\n  QUEUE_FULL_HINT,\n  type Attachment,\n  type AttachmentKind,\n  type Effort,\n  type SkillId,\n  type ToolId,\n} from './data';\nimport { EffortRamp } from './effort-ramp';\nimport { QueueTray } from './queue-tray';\nimport type { Hint, Outgoing } from './session';\nimport { ToolsMenu } from './tools-menu';\n\nconst HINT_TEXT: Record<Hint, string> = {\n  none: '',\n  attachments: FULL_HINT,\n  queue: QUEUE_FULL_HINT,\n};\n\nconst NUDGE = { x: [0, -4, 4, 0] };\n\nconst STILL = { x: 0 };\n\nfunction nudgeOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return STILL;\n  }\n  return NUDGE;\n}\n\nfunction kindOf(file: File): AttachmentKind {\n  if (file.type.startsWith('image/')) {\n    return 'photo';\n  }\n  return 'file';\n}\n\nfunction describedByOf(hasHint: boolean, hintId: string) {\n  if (hasHint) {\n    return hintId;\n  }\n  return undefined;\n}\n\nfunction isSendKey(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n  const isPlainEnter = event.key === 'Enter' && !event.shiftKey;\n  return isPlainEnter && !event.nativeEvent.isComposing;\n}\n\nfunction sendLabelOf(isBusy: boolean) {\n  if (isBusy) {\n    return 'Queue the message';\n  }\n  return 'Send the message';\n}\n\nfunction sendKeyOf(isBusy: boolean) {\n  if (isBusy) {\n    return 'queue';\n  }\n  return 'send';\n}\n\ntype ComposerProps = {\n  draft: string;\n  placeholder: string;\n  canSend: boolean;\n  isBusy: boolean;\n  attachments: Attachment[];\n  toolIds: ToolId[];\n  skillIds: SkillId[];\n  effort: Effort;\n  queue: Outgoing[];\n  hint: Hint;\n  refusals: number;\n  pressed: string | null;\n  onDraftChange: (text: string) => void;\n  onSend: () => void;\n  onAttach: (attachments: Attachment[]) => void;\n  onDetach: (id: string) => void;\n  onToggleTool: (id: ToolId) => void;\n  onToggleSkill: (id: SkillId) => void;\n  onEffortChange: (effort: Effort) => void;\n  onRemoveQueued: (id: string) => void;\n};\n\n/** Nothing is uploaded here: a picked file is only listed, by its name and its size. */\nexport function Composer({\n  draft,\n  placeholder,\n  canSend,\n  isBusy,\n  attachments,\n  toolIds,\n  skillIds,\n  effort,\n  queue,\n  hint,\n  refusals,\n  pressed,\n  onDraftChange,\n  onSend,\n  onAttach,\n  onDetach,\n  onToggleTool,\n  onToggleSkill,\n  onEffortChange,\n  onRemoveQueued,\n}: ComposerProps) {\n  const hintId = useId();\n  const pickerRef = useRef<HTMLInputElement>(null);\n  const pickedCount = useRef(0);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const hasHint = hint !== 'none';\n  const hasQueue = queue.length > 0;\n  const chipCount = attachments.length + toolIds.length + skillIds.length;\n  const hasChips = chipCount > 0;\n\n  function sendFromKeys(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n    if (!isSendKey(event)) {\n      return;\n    }\n    event.preventDefault();\n    if (canSend) {\n      onSend();\n    }\n  }\n\n  function openPicker() {\n    pickerRef.current?.click();\n  }\n\n  function attachmentOf(file: File): Attachment {\n    pickedCount.current += 1;\n    const id = `picked-${pickedCount.current}`;\n    return { id, kind: kindOf(file), name: file.name, bytes: file.size };\n  }\n\n  function attachPicked(event: React.ChangeEvent<HTMLInputElement>) {\n    const picked = event.target.files ?? [];\n    const files = Array.from(picked);\n    event.target.value = '';\n    if (files.length === 0) {\n      return;\n    }\n    onAttach(files.map(attachmentOf));\n  }\n\n  return (\n    <div className='bg-card hairline-ring ring-foreground/12 has-[textarea:focus-visible]:ring-ring/25 dark:bg-foreground/[0.04] dark:ring-foreground/15 relative flex flex-col rounded-2xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.05)] transition-[box-shadow] duration-150 has-[textarea:focus-visible]:ring-[3px]'>\n      <AnimatedSize>\n        {hasQueue && <QueueTray queue={queue} onRemove={onRemoveQueued} />}\n      </AnimatedSize>\n      <AnimatedSize>\n        {hasChips && (\n          <ul\n            aria-label='Added to this message'\n            className='flex flex-wrap gap-1.5 pb-2'\n          >\n            {attachments.map((attachment) => (\n              <AttachmentChip\n                key={attachment.id}\n                attachment={attachment}\n                onRemove={onDetach}\n              />\n            ))}\n            {toolIds.map((id) => (\n              <ToolChip key={id} toolId={id} onRemove={onToggleTool} />\n            ))}\n            {skillIds.map((id) => (\n              <SkillChip key={id} skillId={id} onRemove={onToggleSkill} />\n            ))}\n          </ul>\n        )}\n      </AnimatedSize>\n      <textarea\n        data-composer-field\n        value={draft}\n        rows={2}\n        aria-label='Message to the agent'\n        aria-invalid={hasHint}\n        aria-describedby={describedByOf(hasHint, hintId)}\n        placeholder={placeholder}\n        onChange={(event) => onDraftChange(event.target.value)}\n        onKeyDown={sendFromKeys}\n        className='placeholder:text-muted-foreground/75 field-sizing-content max-h-[8lh] min-h-[2lh] resize-none bg-transparent px-1.5 py-1 text-base leading-normal outline-none md:text-[13px]'\n      />\n      <div className='flex flex-wrap items-center gap-1 pt-2'>\n        <Button\n          type='button'\n          variant='ghost'\n          size='icon-sm'\n          aria-label='Attach photos or files'\n          onClick={openPicker}\n          className={cn(\n            'text-muted-foreground',\n            pressedQuietOf(pressed === 'attach')\n          )}\n        >\n          <PaperclipIcon />\n        </Button>\n        <input\n          ref={pickerRef}\n          type='file'\n          multiple\n          tabIndex={-1}\n          aria-hidden='true'\n          onChange={attachPicked}\n          className='sr-only'\n        />\n        <ToolsMenu\n          toolIds={toolIds}\n          skillIds={skillIds}\n          isPressed={pressed === 'tools'}\n          onToggleTool={onToggleTool}\n          onToggleSkill={onToggleSkill}\n        />\n        <EffortRamp\n          value={effort}\n          isPressed={pressed === 'effort'}\n          onValueChange={onEffortChange}\n        />\n        <Button\n          type='button'\n          size='icon'\n          aria-label={sendLabelOf(isBusy)}\n          disabled={!canSend}\n          onClick={onSend}\n          className={cn('ms-auto', pressedSolidOf(pressed === 'send'))}\n        >\n          <Swap swapKey={sendKeyOf(isBusy)}>\n            {isBusy && <HourglassIcon />}\n            {!isBusy && <ArrowUpIcon />}\n          </Swap>\n        </Button>\n      </div>\n      {hasHint && (\n        <motion.p\n          key={refusals}\n          id={hintId}\n          animate={nudgeOf(shouldReduceMotion)}\n          transition={{ duration: 0.28 }}\n          className='text-destructive-ink px-1.5 pt-2 text-xs'\n        >\n          {HINT_TEXT[hint]}\n        </motion.p>\n      )}\n    </div>\n  );\n}\n\ntype ReadOnlyNoteProps = {\n  onNewSession: () => void;\n};\n\nexport function ReadOnlyNote({ onNewSession }: ReadOnlyNoteProps) {\n  return (\n    <div className='bg-foreground/[0.04] flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-2xl px-3 py-2 text-[13px]'>\n      <p className='text-muted-foreground min-w-0 flex-1'>\n        This session is read only. Start a new one to write.\n      </p>\n      <Button type='button' size='sm' variant='outline' onClick={onNewSession}>\n        New session\n      </Button>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/composer.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\nimport { wordsOf } from '@/registry/ndeko/lib/words';\n\nexport const BRAND = { name: 'Ferrowick' };\n\nexport type Agent = {\n  name: string;\n  series: SeriesSlot;\n};\n\nexport const OPERATOR: Agent = { name: 'Operator', series: 4 };\n\nexport const LIVE_ID = 'live';\n\nexport const LIVE_TITLE = 'Unpaid invoices, March';\n\nexport const NEW_SESSION_TITLE = 'New session';\n\nexport type Day = 'Today' | 'Yesterday' | 'Earlier this week';\n\nexport const DAYS: Day[] = ['Today', 'Yesterday', 'Earlier this week'];\n\nexport type PastSession = {\n  id: string;\n  day: Day;\n  title: string;\n  prompt: string;\n  summary: string;\n};\n\n/** Invented sessions of an invented company. They open as read-only summaries. */\nexport const PAST_SESSIONS: PastSession[] = [\n  {\n    id: 'stock',\n    day: 'Today',\n    title: 'Stock count, Kinshasa depot',\n    prompt:\n      'Compare this week stock count with last week for the Kinshasa depot.',\n    summary:\n      'Eleven items moved by more than 5%. Cooking oil and rice account for most of it, and both match a delivery on Tuesday.',\n  },\n  {\n    id: 'drafts',\n    day: 'Today',\n    title: 'Reminder drafts',\n    prompt: 'Draft a polite reminder for a customer who is 10 days late.',\n    summary:\n      'The draft is short, names the invoice and offers two ways to pay. It is saved in Notion under Templates.',\n  },\n  {\n    id: 'goma',\n    day: 'Yesterday',\n    title: 'Goma supplier call notes',\n    prompt: 'Turn my notes from the Goma supplier call into three actions.',\n    summary:\n      'Confirm the November price, ask for the delivery calendar and send the signed order by Friday.',\n  },\n  {\n    id: 'prices',\n    day: 'Yesterday',\n    title: 'Price list for Lubumbashi',\n    prompt: 'Update the Lubumbashi price list with the new rice price.',\n    summary:\n      'Rice is now 38 USD for a 25 kg bag. The sheet marks the change and keeps the old price in a note.',\n  },\n  {\n    id: 'close',\n    day: 'Earlier this week',\n    title: 'Quarter close checklist',\n    prompt: 'Build a checklist for closing the quarter in all three depots.',\n    summary:\n      'Nine steps, grouped by depot. Each has an owner and a date, and the last one is the review on 30 November.',\n  },\n  {\n    id: 'onboarding',\n    day: 'Earlier this week',\n    title: 'Onboarding emails',\n    prompt: 'Rewrite the three onboarding emails so each asks for one thing.',\n    summary:\n      'Each email now asks for one action: confirm the account, add a depot, invite a colleague.',\n  },\n  {\n    id: 'trucks',\n    day: 'Earlier this week',\n    title: 'Truck maintenance schedule',\n    prompt: 'List which trucks are due for maintenance this month.',\n    summary:\n      'Four of the nine trucks are due. Two are at the Lubumbashi depot, and the oldest is 6,000 km past its service.',\n  },\n];\n\nconst FALLBACK_SESSION = PAST_SESSIONS[0];\n\nexport function pastSessionOf(id: string) {\n  const session = PAST_SESSIONS.find((candidate) => candidate.id === id);\n  return session ?? FALLBACK_SESSION;\n}\n\nexport type Effort = 1 | 2 | 3 | 4 | 5;\n\nexport const EFFORTS: Effort[] = [1, 2, 3, 4, 5];\n\nexport const EFFORT_WORD: Record<Effort, string> = {\n  1: 'Minimal',\n  2: 'Low',\n  3: 'Medium',\n  4: 'High',\n  5: 'Maximum',\n};\n\nexport const EFFORT_WORDS = EFFORTS.map((level) => EFFORT_WORD[level]);\n\nexport const STARTING_EFFORT: Effort = 3;\n\nexport type ToolId = 'googledrive' | 'notion' | 'whatsapp' | 'gmail' | 'linear';\n\nexport type ToolOption = {\n  id: ToolId;\n  name: string;\n  brand: BrandSlug;\n};\n\nexport const TOOLS: ToolOption[] = [\n  { id: 'googledrive', name: 'Google Drive', brand: 'googledrive' },\n  { id: 'notion', name: 'Notion', brand: 'notion' },\n  { id: 'whatsapp', name: 'WhatsApp', brand: 'whatsapp' },\n  { id: 'gmail', name: 'Gmail', brand: 'gmail' },\n  { id: 'linear', name: 'Linear', brand: 'linear' },\n];\n\nconst FALLBACK_TOOL = TOOLS[0];\n\nexport function toolOf(id: ToolId) {\n  const tool = TOOLS.find((candidate) => candidate.id === id);\n  return tool ?? FALLBACK_TOOL;\n}\n\nexport type SkillId = 'reconcile' | 'polite' | 'summarise';\n\nexport type SkillOption = {\n  id: SkillId;\n  name: string;\n  hint: string;\n};\n\nexport const SKILLS: SkillOption[] = [\n  {\n    id: 'reconcile',\n    name: 'Reconcile payments',\n    hint: 'Match payments to invoices',\n  },\n  { id: 'polite', name: 'Polite tone', hint: 'Short, warm, no pressure' },\n  { id: 'summarise', name: 'Summarise a thread', hint: 'Keep decisions only' },\n];\n\nconst FALLBACK_SKILL = SKILLS[0];\n\nexport function skillOf(id: SkillId) {\n  const skill = SKILLS.find((candidate) => candidate.id === id);\n  return skill ?? FALLBACK_SKILL;\n}\n\nexport const DEMO_TOOLS: ToolId[] = ['googledrive', 'notion', 'whatsapp'];\n\nexport const DEMO_SKILL: SkillId = 'reconcile';\n\nexport const DEMO_EFFORT: Effort = 4;\n\nexport type AttachmentKind = 'photo' | 'file';\n\nexport type Attachment = {\n  id: string;\n  kind: AttachmentKind;\n  name: string;\n  bytes: number;\n};\n\nexport const DEMO_PHOTO: Attachment = {\n  id: 'demo-photo',\n  kind: 'photo',\n  name: 'depot-whiteboard.jpg',\n  bytes: 1_800_000,\n};\n\nexport const DEMO_FILE: Attachment = {\n  id: 'demo-file',\n  kind: 'file',\n  name: 'invoices-march.csv',\n  bytes: 48_200,\n};\n\nexport const MAX_ATTACHMENTS = 4;\n\nexport const MAX_QUEUED = 3;\n\nexport const FULL_HINT = `${MAX_ATTACHMENTS} files fit in one message. Remove one to add another`;\n\nexport const QUEUE_FULL_HINT = `${MAX_QUEUED} messages are already waiting. Remove one to queue another`;\n\nexport const QUESTION =\n  'Which invoices from the Kinshasa and Goma depots are still unpaid? Draft a reminder for each customer.';\n\nexport const FOLLOW_UP = 'Share the list with the finance team';\n\nexport const FOLLOW_UP_REPLY =\n  'This demonstration plays one scripted session. Replay it to watch it again.';\n\nexport const THOUGHT =\n  'I need the March invoices, the payments that came in and a contact for each customer. A reminder is a message to a customer, so I will ask before anything is sent.';\n\nexport const THOUGHT_WORDS = wordsOf(THOUGHT);\n\nexport type SeedId = 'unpaid' | 'share' | 'canned';\n\nexport type StepId = 'invoices' | 'match' | 'contacts' | 'reminders' | 'share';\n\nexport type StepKind = 'tool' | 'skill';\n\nexport type ResultKind = 'invoices' | 'shared';\n\nexport type StepSeed = {\n  id: StepId;\n  kind: StepKind;\n  title: string;\n  detail: string;\n  doneSummary: string;\n  brand?: BrandSlug;\n  product?: string;\n  input: string;\n  output: string;\n  usd: number;\n  result?: ResultKind;\n  needsApproval?: boolean;\n};\n\nexport type TurnSeed = {\n  id: SeedId;\n  thought?: string;\n  steps: StepSeed[];\n  answer: string;\n};\n\nconst UNPAID_STEPS: StepSeed[] = [\n  {\n    id: 'invoices',\n    kind: 'tool',\n    title: 'Read invoices-march.csv',\n    detail: 'Three depots, one row per invoice',\n    doneSummary: '212 invoices read',\n    brand: 'googledrive',\n    product: 'Google Drive',\n    input: 'file: invoices-march.csv',\n    output: '212 rows, 3 depots, 5 columns',\n    usd: 0.011,\n  },\n  {\n    id: 'match',\n    kind: 'skill',\n    title: 'Match payments to invoices',\n    detail: 'Reconcile payments skill',\n    doneSummary: '7 invoices have no payment',\n    input: 'skill: Reconcile payments',\n    output: '205 matched, 7 unpaid, 4,310 USD',\n    usd: 0.016,\n    result: 'invoices',\n  },\n  {\n    id: 'contacts',\n    kind: 'tool',\n    title: 'Look up the customers',\n    detail: 'The customer contacts page',\n    doneSummary: '7 contacts found',\n    brand: 'notion',\n    product: 'Notion',\n    input: 'page: Customer contacts',\n    output: '7 numbers, 7 preferred names',\n    usd: 0.009,\n  },\n  {\n    id: 'reminders',\n    kind: 'tool',\n    title: 'Send the reminders',\n    detail: 'Seven messages, one per customer',\n    doneSummary: '7 reminders sent',\n    brand: 'whatsapp',\n    product: 'WhatsApp',\n    input: 'messages: 7',\n    output: '7 delivered',\n    usd: 0.007,\n    needsApproval: true,\n  },\n];\n\nconst SHARE_STEPS: StepSeed[] = [\n  {\n    id: 'share',\n    kind: 'tool',\n    title: 'Share unpaid-march.xlsx',\n    detail: 'With the finance team',\n    doneSummary: 'Shared with 3 people',\n    brand: 'googledrive',\n    product: 'Google Drive',\n    input: 'file: unpaid-march.xlsx, people: 3',\n    output: '3 invitations sent, comment access',\n    usd: 0.006,\n    result: 'shared',\n  },\n];\n\nconst UNPAID_ANSWER =\n  '7 invoices from Kinshasa and Goma are still unpaid, 4,310 USD in total. I sent each customer a reminder on WhatsApp and kept the list in the card above.';\n\nconst SHARE_ANSWER =\n  'The list is shared with the finance team. They can comment on it, and the reminders stay with you.';\n\nconst UNPAID_SEED: TurnSeed = {\n  id: 'unpaid',\n  thought: THOUGHT,\n  steps: UNPAID_STEPS,\n  answer: UNPAID_ANSWER,\n};\n\nconst SHARE_SEED: TurnSeed = {\n  id: 'share',\n  steps: SHARE_STEPS,\n  answer: SHARE_ANSWER,\n};\n\nconst CANNED_SEED: TurnSeed = {\n  id: 'canned',\n  steps: [],\n  answer: FOLLOW_UP_REPLY,\n};\n\nconst SEEDS: TurnSeed[] = [UNPAID_SEED, SHARE_SEED, CANNED_SEED];\n\nexport function seedOf(id: SeedId) {\n  const seed = SEEDS.find((candidate) => candidate.id === id);\n  return seed ?? CANNED_SEED;\n}\n\nconst FALLBACK_STEP = UNPAID_STEPS[0];\n\nexport function stepSeedOf(id: StepId) {\n  for (const seed of SEEDS) {\n    const step = seed.steps.find((candidate) => candidate.id === id);\n    if (step) {\n      return step;\n    }\n  }\n  return FALLBACK_STEP;\n}\n\nexport const THOUGHT_USD = 0.004;\n\nexport const ANSWER_USD = 0.005;\n\n/** Thinking harder costs more: the price of a step follows the effort it was asked at. */\nexport const EFFORT_RATE: Record<Effort, number> = {\n  1: 0.5,\n  2: 0.75,\n  3: 1,\n  4: 1.4,\n  5: 1.9,\n};\n\nexport const NEW_ID = 'new';\n\nexport type Person = {\n  name: string;\n  role: string;\n};\n\nexport type Invoice = {\n  id: string;\n  customer: string;\n  depot: string;\n  amountUsd: number;\n  daysLate: number;\n};\n\n/** Invented customers and amounts. The figures are illustrative. */\nexport const UNPAID: Invoice[] = [\n  {\n    id: 'inv-2041',\n    customer: 'Patrick Mbuyi',\n    depot: 'Kinshasa',\n    amountUsd: 640,\n    daysLate: 12,\n  },\n  {\n    id: 'inv-2057',\n    customer: 'Chantal Kabeya',\n    depot: 'Goma',\n    amountUsd: 415,\n    daysLate: 9,\n  },\n  {\n    id: 'inv-2063',\n    customer: 'Joël Mukendi',\n    depot: 'Kinshasa',\n    amountUsd: 1280,\n    daysLate: 21,\n  },\n];\n\nexport const UNPAID_TOTAL = { count: 7, usd: 4310 };\n\nexport const FINANCE_TEAM: Person[] = [\n  { name: 'Amani Tshibola', role: 'Finance lead, Kinshasa' },\n  { name: 'Odette Banza', role: 'Accounts, Lubumbashi' },\n  { name: 'Reuben Kalala', role: 'Accounts, Goma' },\n];\n\nexport const REMINDER_PREVIEW =\n  'Hello Patrick, invoice 2041 for 640 USD is 12 days past its date. You can settle it by mobile money or at the depot. Thank you.';\n\nexport const REQUEST_RECIPIENTS: Person[] = [\n  { name: 'Patrick Mbuyi', role: 'Kinshasa' },\n  { name: 'Chantal Kabeya', role: 'Goma' },\n];\n\nexport const DECLINED_LINE =\n  'Nothing was sent. The list of unpaid invoices stays above';\n\nexport const SENT_LINE = '7 reminders sent on WhatsApp';\n",
      "type": "registry:component",
      "target": "components/templates/application-06/data.ts"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/effort-ramp.tsx",
      "content": "'use client';\n\nimport { useRef, type CSSProperties } from 'react';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { EFFORT_WORD, EFFORT_WORDS, EFFORTS, type Effort } from './data';\n\nconst CELL_PX = 16;\n\nconst PAD_PX = 4;\n\nconst RING_PX = 20;\n\nconst DOT_SIZE: Record<Effort, string> = {\n  1: 'size-1',\n  2: 'size-1.5',\n  3: 'size-2',\n  4: 'size-2.5',\n  5: 'size-3',\n};\n\ntype RampStyle = CSSProperties & { '--ring-x': string };\n\nfunction effortOf(position: number): Effort {\n  const rounded = Math.round(position);\n  const bounded = Math.min(EFFORTS.length, Math.max(1, rounded));\n  return EFFORTS[bounded - 1];\n}\n\nfunction isRtl(element: HTMLElement) {\n  return getComputedStyle(element).direction === 'rtl';\n}\n\nfunction effortAtPointer(element: HTMLElement, clientX: number) {\n  const rect = element.getBoundingClientRect();\n  let offset = clientX - rect.left;\n  if (isRtl(element)) {\n    offset = rect.right - clientX;\n  }\n  const position = (offset - PAD_PX) / CELL_PX + 0.5;\n  return effortOf(position);\n}\n\nfunction forwardKeyOf(isFlipped: boolean) {\n  if (isFlipped) {\n    return 'ArrowLeft';\n  }\n  return 'ArrowRight';\n}\n\nfunction backKeyOf(isFlipped: boolean) {\n  if (isFlipped) {\n    return 'ArrowRight';\n  }\n  return 'ArrowLeft';\n}\n\nfunction effortAfterKey(\n  event: React.KeyboardEvent<HTMLElement>,\n  current: Effort\n): Effort | null {\n  const isFlipped = isRtl(event.currentTarget);\n  const forwardKey = forwardKeyOf(isFlipped);\n  const backKey = backKeyOf(isFlipped);\n  if (event.key === forwardKey || event.key === 'ArrowUp') {\n    return effortOf(current + 1);\n  }\n  if (event.key === backKey || event.key === 'ArrowDown') {\n    return effortOf(current - 1);\n  }\n  if (event.key === 'Home') {\n    return effortOf(1);\n  }\n  if (event.key === 'End') {\n    return effortOf(EFFORTS.length);\n  }\n  return null;\n}\n\nfunction dotToneOf(isFilled: boolean) {\n  if (isFilled) {\n    return 'bg-primary';\n  }\n  return 'bg-foreground/20';\n}\n\nfunction dotScaleOf(isCurrent: boolean) {\n  if (isCurrent) {\n    return 'scale-125';\n  }\n  return undefined;\n}\n\nfunction ringStyleOf(effort: Effort) {\n  const cellStart = PAD_PX + (effort - 1) * CELL_PX;\n  const centring = (CELL_PX - RING_PX) / 2;\n  const x = cellStart + centring;\n  const style: RampStyle = { '--ring-x': `${x}px` };\n  return style;\n}\n\ntype EffortRampProps = {\n  value: Effort;\n  isPressed: boolean;\n  onValueChange: (effort: Effort) => void;\n};\n\nexport function EffortRamp({\n  value,\n  isPressed,\n  onValueChange,\n}: EffortRampProps) {\n  const isDragging = useRef(false);\n  const word = EFFORT_WORD[value];\n\n  function change(next: Effort) {\n    if (next !== value) {\n      onValueChange(next);\n    }\n  }\n\n  function startDrag(event: React.PointerEvent<HTMLDivElement>) {\n    event.currentTarget.setPointerCapture(event.pointerId);\n    isDragging.current = true;\n    change(effortAtPointer(event.currentTarget, event.clientX));\n  }\n\n  function drag(event: React.PointerEvent<HTMLDivElement>) {\n    if (!isDragging.current) {\n      return;\n    }\n    change(effortAtPointer(event.currentTarget, event.clientX));\n  }\n\n  function endDrag() {\n    isDragging.current = false;\n  }\n\n  function changeFromKeys(event: React.KeyboardEvent<HTMLDivElement>) {\n    const next = effortAfterKey(event, value);\n    if (next === null) {\n      return;\n    }\n    event.preventDefault();\n    change(next);\n  }\n\n  return (\n    <div className='flex items-center gap-1'>\n      <div\n        role='slider'\n        tabIndex={0}\n        aria-label='Effort'\n        aria-valuemin={1}\n        aria-valuemax={EFFORTS.length}\n        aria-valuenow={value}\n        aria-valuetext={word}\n        data-effort\n        onPointerDown={startDrag}\n        onPointerMove={drag}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n        onKeyDown={changeFromKeys}\n        style={ringStyleOf(value)}\n        className={cn(\n          'focus-visible:ring-ring/25 relative flex h-7 cursor-pointer touch-none items-center rounded-full px-1 transition-[scale,background-color] duration-150 outline-none select-none focus-visible:ring-[3px]',\n          pressedQuietOf(isPressed)\n        )}\n      >\n        <span\n          aria-hidden='true'\n          className='ring-primary/35 pointer-events-none absolute start-0 top-1/2 -mt-2.5 size-5 translate-x-(--ring-x) rounded-full ring-2 transition-[translate] duration-200 ease-(--ease-out-strong) rtl:-translate-x-(--ring-x)'\n        />\n        {EFFORTS.map((level) => (\n          <span\n            key={level}\n            aria-hidden='true'\n            className='relative flex h-7 w-4 items-center justify-center'\n          >\n            <span\n              className={cn(\n                'rounded-full transition-[background-color,scale] duration-150 ease-(--ease-out-strong)',\n                DOT_SIZE[level],\n                dotToneOf(level <= value),\n                dotScaleOf(level === value)\n              )}\n            />\n          </span>\n        ))}\n      </div>\n      <span\n        aria-hidden='true'\n        className='text-muted-foreground hidden text-xs @md:inline'\n      >\n        <WordRoll text={word} labels={EFFORT_WORDS} />\n      </span>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/effort-ramp.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/queue-tray.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { XIcon } from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { countOf } from '@/registry/ndeko/lib/words';\n\nimport type { Outgoing } from './session';\n\ntype QueueRowProps = {\n  item: Outgoing;\n  position: number;\n  onRemove: (id: string) => void;\n};\n\nfunction QueueRow({ item, position, onRemove }: QueueRowProps) {\n  function remove() {\n    onRemove(item.id);\n  }\n\n  return (\n    <div className='flex h-8 items-center gap-2 ps-2 pe-1 text-[13px]'>\n      <span className='text-muted-foreground w-3 shrink-0 text-xs tabular-nums'>\n        {position}\n      </span>\n      <span className='min-w-0 flex-1 truncate'>{item.text}</span>\n      <button\n        type='button'\n        aria-label={`Remove from the queue: ${item.text}`}\n        onClick={remove}\n        className='text-muted-foreground hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-ring/25 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md outline-none focus-visible:ring-[3px] active:scale-[0.97]'\n      >\n        <XIcon className='size-3.5' />\n      </button>\n    </div>\n  );\n}\n\ntype QueueTrayProps = {\n  queue: Outgoing[];\n  onRemove: (id: string) => void;\n};\n\nexport function QueueTray({ queue, onRemove }: QueueTrayProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n\n  return (\n    <section\n      aria-label='Queued messages'\n      className='bg-foreground/[0.04] mb-2 flex flex-col rounded-xl p-1'\n    >\n      <h3 className='text-muted-foreground flex items-center gap-1.5 px-2 pt-1 pb-0.5 text-xs'>\n        Up next\n        <span className='tabular-nums'>{countOf(queue.length, 'message')}</span>\n      </h3>\n      <ul className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {queue.map((item, index) => (\n            <motion.li\n              key={item.id}\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <QueueRow item={item} position={index + 1} onRemove={onRemove} />\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ul>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/queue-tray.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/result-cards.tsx",
      "content": "'use client';\n\nimport { FileSpreadsheetIcon, ShareIcon } from '@/registry/ndeko/lib/icons';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\n\nimport {\n  FINANCE_TEAM,\n  UNPAID,\n  UNPAID_TOTAL,\n  type Invoice,\n  type ResultKind,\n} from './data';\n\nconst CARD =\n  'bg-card hairline-ring ring-border dark:bg-foreground/[0.04] mt-2 overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-[opacity,scale] duration-300 ease-(--ease-out-strong) starting:scale-[1.02] starting:opacity-0';\n\nconst USD = new Intl.NumberFormat('en-US', {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n});\n\nfunction InvoiceRow({ invoice }: { invoice: Invoice }) {\n  return (\n    <li className='flex items-center gap-2.5 py-1.5'>\n      <Avatar seed={invoice.customer} className='size-6' />\n      <span className='flex min-w-0 flex-1 flex-col leading-tight'>\n        <span className='truncate text-[13px]'>{invoice.customer}</span>\n        <span className='text-muted-foreground truncate text-xs'>\n          {invoice.depot}, {invoice.daysLate} days late\n        </span>\n      </span>\n      <span className='shrink-0 text-[13px] font-medium tabular-nums'>\n        {USD.format(invoice.amountUsd)}\n      </span>\n    </li>\n  );\n}\n\nfunction InvoicesCard() {\n  const hidden = UNPAID_TOTAL.count - UNPAID.length;\n\n  return (\n    <section aria-label='Unpaid invoices' className={CARD}>\n      <header className='flex items-center gap-2.5 p-3 pb-1.5'>\n        <span\n          aria-hidden='true'\n          className='keycap-3d text-muted-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md'\n        >\n          <FileSpreadsheetIcon className='size-3.5' />\n        </span>\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <h3 className='truncate text-sm font-medium'>\n            Unpaid invoices, March\n          </h3>\n          <span className='text-muted-foreground truncate text-xs'>\n            Kinshasa and Goma\n          </span>\n        </div>\n        <Badge variant='secondary'>Illustrative</Badge>\n      </header>\n      <ul aria-label='Largest unpaid invoices' className='flex flex-col px-3'>\n        {UNPAID.map((invoice) => (\n          <InvoiceRow key={invoice.id} invoice={invoice} />\n        ))}\n      </ul>\n      <p className='bg-foreground/[0.04] mt-1.5 flex items-center justify-between gap-2 px-3 py-2 text-xs'>\n        <span className='text-muted-foreground'>{hidden} more invoices</span>\n        <span className='tabular-nums'>\n          {UNPAID_TOTAL.count} unpaid,{' '}\n          <span className='font-medium'>{USD.format(UNPAID_TOTAL.usd)}</span>\n        </span>\n      </p>\n    </section>\n  );\n}\n\nfunction SharedCard() {\n  return (\n    <section aria-label='Shared list' className={CARD}>\n      <header className='flex items-center gap-2.5 p-3 pb-1.5'>\n        <span\n          aria-hidden='true'\n          className='keycap-3d text-muted-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md'\n        >\n          <ShareIcon className='size-3.5' />\n        </span>\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <h3 className='truncate font-mono text-[13px] font-medium'>\n            unpaid-march.xlsx\n          </h3>\n          <span className='text-muted-foreground truncate text-xs'>\n            Shared with the finance team\n          </span>\n        </div>\n        <Badge variant='success'>Can comment</Badge>\n      </header>\n      <ul aria-label='People with access' className='flex flex-col px-3 pb-2'>\n        {FINANCE_TEAM.map((person) => (\n          <li key={person.name} className='flex items-center gap-2.5 py-1.5'>\n            <Avatar seed={person.name} className='size-6' />\n            <span className='min-w-0 flex-1 truncate text-[13px]'>\n              {person.name}\n            </span>\n            <span className='text-muted-foreground shrink-0 text-xs'>\n              {person.role}\n            </span>\n          </li>\n        ))}\n      </ul>\n    </section>\n  );\n}\n\ntype ResultCardProps = {\n  kind: ResultKind;\n};\n\nexport function ResultCard({ kind }: ResultCardProps) {\n  if (kind === 'invoices') {\n    return <InvoicesCard />;\n  }\n  return <SharedCard />;\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/result-cards.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/session-header.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport { MenuIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { stepSeedOf } from './data';\nimport type { Turn, TurnStage } from './session';\n\n/** Under a dollar a cost keeps three decimals, as in the rest of the kit. */\nconst COST_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  minimumFractionDigits: 3,\n  maximumFractionDigits: 3,\n};\n\nconst STAGE_WORD: Record<Exclude<TurnStage, 'working'>, string> = {\n  thinking: 'Thinking',\n  asking: 'Waiting on you',\n  answering: 'Answering',\n  done: 'Done',\n  declined: 'Done',\n};\n\nconst FIXED_WORDS = ['Ready', 'Working', ...Object.values(STAGE_WORD)];\n\nconst LIVE_STAGES: TurnStage[] = ['thinking', 'working', 'answering'];\n\nfunction runningTitleOf(turn: Turn) {\n  const running = turn.steps.find((run) => run.status === 'running');\n  if (!running) {\n    return 'Working';\n  }\n  return stepSeedOf(running.id).title;\n}\n\nexport function statusWordOf(turn: Turn | undefined) {\n  if (!turn) {\n    return 'Ready';\n  }\n  if (turn.stage === 'working') {\n    return runningTitleOf(turn);\n  }\n  return STAGE_WORD[turn.stage];\n}\n\nfunction dotToneOf(turn: Turn | undefined) {\n  if (!turn) {\n    return 'bg-muted-foreground/45';\n  }\n  if (turn.stage === 'asking') {\n    return 'bg-warning';\n  }\n  if (turn.stage === 'done' || turn.stage === 'declined') {\n    return 'bg-success';\n  }\n  return 'bg-info';\n}\n\nfunction pulseOf(turn: Turn | undefined) {\n  if (!turn) {\n    return undefined;\n  }\n  if (LIVE_STAGES.includes(turn.stage)) {\n    return 'animate-pulse';\n  }\n  return undefined;\n}\n\ntype SessionHeaderProps = {\n  title: string;\n  turn: Turn | undefined;\n  statusWord: string;\n  costUsd: number;\n  hasSheet: boolean;\n  canReplay: boolean;\n  onReplay: () => void;\n  onOpenSessions: () => void;\n};\n\nexport function SessionHeader({\n  title,\n  turn,\n  statusWord,\n  costUsd,\n  hasSheet,\n  canReplay,\n  onReplay,\n  onOpenSessions,\n}: SessionHeaderProps) {\n  const words = [...FIXED_WORDS, statusWord];\n\n  return (\n    <header className='flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2.5 @xl:px-4'>\n      <div className='flex min-w-40 flex-1 items-center gap-2'>\n        {hasSheet && (\n          <Button\n            type='button'\n            variant='ghost'\n            size='icon-sm'\n            data-sidebar-open\n            aria-label='Open the sessions'\n            aria-haspopup='dialog'\n            onClick={onOpenSessions}\n            className='text-muted-foreground'\n          >\n            <MenuIcon />\n          </Button>\n        )}\n        <div className='flex min-w-0 flex-col leading-tight'>\n          <h1 className='truncate text-sm font-medium'>{title}</h1>\n          <p className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n            <span\n              aria-hidden='true'\n              className={cn(\n                'size-1.5 shrink-0 rounded-full transition-colors duration-200',\n                dotToneOf(turn),\n                pulseOf(turn)\n              )}\n            />\n            <WordRoll text={statusWord} labels={words} />\n          </p>\n        </div>\n      </div>\n      <div className='flex flex-wrap items-center gap-2'>\n        <ReplayButton isShown={canReplay} onReplay={onReplay} label='Replay' />\n        <span className='flex items-center gap-1.5 text-xs'>\n          <span className='sr-only'>Cost of this session</span>\n          <MotionNumber\n            value={costUsd}\n            format={COST_FORMAT}\n            className='font-medium'\n          />\n          <Badge variant='secondary'>Illustrative</Badge>\n        </span>\n      </div>\n    </header>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/session-header.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport { keyDelayOf, prefixesOf } from '@/registry/ndeko/lib/demonstration';\nimport { restingOf } from '@/registry/ndeko/lib/run-session';\nimport { wordsOf } from '@/registry/ndeko/lib/words';\n\nimport {\n  ANSWER_USD,\n  DEMO_EFFORT,\n  DEMO_FILE,\n  DEMO_PHOTO,\n  DEMO_SKILL,\n  DEMO_TOOLS,\n  EFFORT_RATE,\n  FOLLOW_UP,\n  LIVE_ID,\n  MAX_ATTACHMENTS,\n  MAX_QUEUED,\n  NEW_ID,\n  QUESTION,\n  seedOf,\n  STARTING_EFFORT,\n  stepSeedOf,\n  THOUGHT_USD,\n  THOUGHT_WORDS,\n  type Attachment,\n  type Effort,\n  type SeedId,\n  type SkillId,\n  type StepId,\n  type ToolId,\n} from './data';\n\nexport type TurnStage =\n  'thinking' | 'working' | 'asking' | 'answering' | 'done' | 'declined';\n\nexport type Decision = 'approved' | 'denied';\n\nexport type StepStatus = 'running' | 'waiting' | 'done' | 'skipped';\n\nexport type StepRun = {\n  id: StepId;\n  status: StepStatus;\n  startedAt: number;\n  endedAt?: number;\n};\n\nexport type Turn = {\n  id: string;\n  seedId: SeedId;\n  text: string;\n  attachments: Attachment[];\n  toolIds: ToolId[];\n  skillIds: SkillId[];\n  effort: Effort;\n  stage: TurnStage;\n  steps: StepRun[];\n  decision: Decision | null;\n  startedAt: number;\n  thoughtEndedAt?: number;\n  endedAt?: number;\n};\n\n/** What a message carries when it leaves the composer: settings change after it, so it keeps its own copy. */\nexport type Outgoing = {\n  id: string;\n  text: string;\n  attachments: Attachment[];\n  toolIds: ToolId[];\n  skillIds: SkillId[];\n  effort: Effort;\n};\n\nexport type Hint = 'none' | 'attachments' | 'queue';\n\nexport type WorkspaceState = {\n  activeId: string;\n  draft: string;\n  attachments: Attachment[];\n  toolIds: ToolId[];\n  skillIds: SkillId[];\n  effort: Effort;\n  queue: Outgoing[];\n  turns: Turn[];\n  newLines: string[];\n  sentCount: number;\n  hint: Hint;\n  refusals: number;\n  costUsd: number;\n  isSidebarOpen: boolean;\n  search: string;\n};\n\nexport type WorkspaceAction =\n  | { type: 'typed'; text: string }\n  | { type: 'attached'; attachments: Attachment[] }\n  | { type: 'detached'; id: string }\n  | { type: 'toolToggled'; id: ToolId }\n  | { type: 'skillToggled'; id: SkillId }\n  | { type: 'effortSet'; effort: Effort }\n  | { type: 'sent' }\n  | { type: 'queueRemoved'; id: string }\n  | { type: 'thoughtDone'; turn: number }\n  | { type: 'stepStarted'; turn: number; id: StepId }\n  | { type: 'stepDone'; turn: number; id: StepId }\n  | { type: 'asked'; turn: number }\n  | { type: 'decided'; decision: Decision }\n  | { type: 'answering'; turn: number }\n  | { type: 'answered'; turn: number }\n  | { type: 'sidebar'; isOpen: boolean }\n  | { type: 'searched'; text: string }\n  | { type: 'sessionOpened'; id: string }\n  | { type: 'newSession' }\n  | { type: 'batch'; actions: WorkspaceAction[] };\n\ntype Step = SessionStep<WorkspaceState, WorkspaceAction>;\n\nexport const INITIAL: WorkspaceState = {\n  activeId: LIVE_ID,\n  draft: '',\n  attachments: [],\n  toolIds: [],\n  skillIds: [],\n  effort: STARTING_EFFORT,\n  queue: [],\n  turns: [],\n  newLines: [],\n  sentCount: 0,\n  hint: 'none',\n  refusals: 0,\n  costUsd: 0,\n  isSidebarOpen: false,\n  search: '',\n};\n\nconst BUSY_STAGES: TurnStage[] = ['thinking', 'working', 'asking', 'answering'];\n\nconst WRITABLE_SESSIONS = [LIVE_ID, NEW_ID];\n\nexport function isTurnBusy(turn: Turn | undefined) {\n  if (!turn) {\n    return false;\n  }\n  return BUSY_STAGES.includes(turn.stage);\n}\n\nexport function isBusy(state: WorkspaceState) {\n  return isTurnBusy(state.turns.at(-1));\n}\n\nexport function isReadOnly(state: WorkspaceState) {\n  return !WRITABLE_SESSIONS.includes(state.activeId);\n}\n\n/**\n * What Send would post now. A person who takes over halfway through the first question sends the\n * whole question, not the half that was typed. Null when there is nothing to send.\n */\nexport function sendableTextOf(state: WorkspaceState) {\n  if (isReadOnly(state)) {\n    return null;\n  }\n  const trimmed = state.draft.trim();\n  if (trimmed === '') {\n    return null;\n  }\n  const isFirst = state.turns.length === 0;\n  const isLive = state.activeId === LIVE_ID;\n  const isUnfinishedDemo = QUESTION.startsWith(trimmed);\n  if (isFirst && isLive && isUnfinishedDemo) {\n    return QUESTION;\n  }\n  return trimmed;\n}\n\nfunction seedIdFor(turns: Turn[], text: string): SeedId {\n  if (turns.length === 0) {\n    return 'unpaid';\n  }\n  const trimmed = text.trim();\n  const typed = trimmed.toLowerCase();\n  const followUp = FOLLOW_UP.toLowerCase();\n  const isFollowUp = typed === followUp;\n  const hasShared = turns.some((turn) => turn.seedId === 'share');\n  if (isFollowUp && !hasShared) {\n    return 'share';\n  }\n  return 'canned';\n}\n\nfunction openingStageOf(seedId: SeedId): TurnStage {\n  const seed = seedOf(seedId);\n  if (seed.thought !== undefined) {\n    return 'thinking';\n  }\n  if (seed.steps.length > 0) {\n    return 'working';\n  }\n  return 'done';\n}\n\nfunction startTurn(\n  state: WorkspaceState,\n  outgoing: Outgoing,\n  now: number\n): WorkspaceState {\n  const seedId = seedIdFor(state.turns, outgoing.text);\n  const stage = openingStageOf(seedId);\n  const turn: Turn = {\n    id: `turn-${state.turns.length + 1}`,\n    seedId,\n    text: outgoing.text,\n    attachments: outgoing.attachments,\n    toolIds: outgoing.toolIds,\n    skillIds: outgoing.skillIds,\n    effort: outgoing.effort,\n    stage,\n    steps: [],\n    decision: null,\n    startedAt: now,\n  };\n  if (stage === 'done') {\n    turn.endedAt = now;\n  }\n  return { ...state, turns: [...state.turns, turn] };\n}\n\n/** A turn that ends hands the floor to the first message that waited for it. */\nfunction drainQueue(state: WorkspaceState, now: number): WorkspaceState {\n  let next = state;\n  while (next.queue.length > 0 && !isBusy(next)) {\n    const [head, ...rest] = next.queue;\n    next = startTurn({ ...next, queue: rest }, head, now);\n  }\n  return next;\n}\n\nfunction refused(state: WorkspaceState, hint: Hint): WorkspaceState {\n  const refusals = state.refusals + 1;\n  return { ...state, hint, refusals };\n}\n\nfunction outgoingOf(state: WorkspaceState, text: string): Outgoing {\n  return {\n    id: `message-${state.sentCount + 1}`,\n    text,\n    attachments: state.attachments,\n    toolIds: state.toolIds,\n    skillIds: state.skillIds,\n    effort: state.effort,\n  };\n}\n\nfunction cleared(state: WorkspaceState): WorkspaceState {\n  const sentCount = state.sentCount + 1;\n  return { ...state, draft: '', attachments: [], hint: 'none', sentCount };\n}\n\nfunction sent(state: WorkspaceState, now: number): WorkspaceState {\n  const text = sendableTextOf(state);\n  if (text === null) {\n    return state;\n  }\n  if (state.activeId === NEW_ID) {\n    const newLines = [...state.newLines, text];\n    return { ...cleared(state), newLines };\n  }\n  const outgoing = outgoingOf(state, text);\n  if (!isBusy(state)) {\n    return startTurn(cleared(state), outgoing, now);\n  }\n  if (state.queue.length >= MAX_QUEUED) {\n    return refused(state, 'queue');\n  }\n  return { ...cleared(state), queue: [...state.queue, outgoing] };\n}\n\nfunction attached(state: WorkspaceState, added: Attachment[]): WorkspaceState {\n  const room = MAX_ATTACHMENTS - state.attachments.length;\n  const accepted = added.slice(0, room);\n  const attachments = [...state.attachments, ...accepted];\n  const hasOverflow = added.length > room;\n  if (hasOverflow) {\n    return refused({ ...state, attachments }, 'attachments');\n  }\n  return { ...state, attachments, hint: 'none' };\n}\n\nfunction toggled<Id extends string>(ids: Id[], id: Id) {\n  if (ids.includes(id)) {\n    return ids.filter((candidate) => candidate !== id);\n  }\n  return [...ids, id];\n}\n\nfunction patchedTurn(\n  state: WorkspaceState,\n  index: number,\n  change: (turn: Turn) => Turn\n): WorkspaceState {\n  const turn = state.turns[index];\n  if (!turn) {\n    return state;\n  }\n  const turns = state.turns.map((candidate, position) => {\n    if (position !== index) {\n      return candidate;\n    }\n    return change(candidate);\n  });\n  return { ...state, turns };\n}\n\nfunction patchedSteps(\n  turn: Turn,\n  id: StepId,\n  change: (run: StepRun) => StepRun\n) {\n  return turn.steps.map((run) => {\n    if (run.id !== id) {\n      return run;\n    }\n    return change(run);\n  });\n}\n\nfunction stepOf(turn: Turn, id: StepId) {\n  return turn.steps.find((run) => run.id === id);\n}\n\nfunction costOf(usd: number, effort: Effort) {\n  return usd * EFFORT_RATE[effort];\n}\n\nfunction withCost(state: WorkspaceState, usd: number): WorkspaceState {\n  return { ...state, costUsd: state.costUsd + usd };\n}\n\nfunction thoughtDone(\n  state: WorkspaceState,\n  index: number,\n  now: number\n): WorkspaceState {\n  const turn = state.turns[index];\n  if (turn?.stage !== 'thinking') {\n    return state;\n  }\n  const moved = patchedTurn(state, index, (current) => ({\n    ...current,\n    stage: 'working',\n    thoughtEndedAt: now,\n  }));\n  return withCost(moved, costOf(THOUGHT_USD, turn.effort));\n}\n\nfunction stepStarted(\n  state: WorkspaceState,\n  index: number,\n  id: StepId,\n  now: number\n): WorkspaceState {\n  const turn = state.turns[index];\n  if (turn?.stage !== 'working') {\n    return state;\n  }\n  const seed = seedOf(turn.seedId);\n  const belongs = seed.steps.some((step) => step.id === id);\n  const isKnown = stepOf(turn, id) !== undefined;\n  if (!belongs || isKnown) {\n    return state;\n  }\n  return patchedTurn(state, index, (current) => {\n    const run: StepRun = { id, status: 'running', startedAt: now };\n    return { ...current, steps: [...current.steps, run] };\n  });\n}\n\nfunction stepDone(\n  state: WorkspaceState,\n  index: number,\n  id: StepId,\n  now: number\n): WorkspaceState {\n  const turn = state.turns[index];\n  const isLive = turn?.stage === 'working' || turn?.stage === 'answering';\n  const run = turn && stepOf(turn, id);\n  if (!isLive || run?.status !== 'running') {\n    return state;\n  }\n  const moved = patchedTurn(state, index, (current) => ({\n    ...current,\n    steps: patchedSteps(current, id, (candidate) => ({\n      ...candidate,\n      status: 'done',\n      endedAt: now,\n    })),\n  }));\n  return withCost(moved, costOf(stepSeedOf(id).usd, turn.effort));\n}\n\nfunction asked(state: WorkspaceState, index: number): WorkspaceState {\n  const turn = state.turns[index];\n  const run = turn && stepOf(turn, 'reminders');\n  if (turn?.stage !== 'working' || run?.status !== 'running') {\n    return state;\n  }\n  return patchedTurn(state, index, (current) => ({\n    ...current,\n    stage: 'asking',\n    steps: patchedSteps(current, 'reminders', (candidate) => ({\n      ...candidate,\n      status: 'waiting',\n    })),\n  }));\n}\n\nfunction askingIndexOf(state: WorkspaceState) {\n  return state.turns.findIndex((turn) => turn.stage === 'asking');\n}\n\nfunction decided(\n  state: WorkspaceState,\n  decision: Decision,\n  now: number\n): WorkspaceState {\n  const index = askingIndexOf(state);\n  if (index < 0) {\n    return state;\n  }\n  if (decision === 'approved') {\n    return patchedTurn(state, index, (current) => ({\n      ...current,\n      stage: 'working',\n      decision,\n      steps: patchedSteps(current, 'reminders', (candidate) => ({\n        ...candidate,\n        status: 'running',\n      })),\n    }));\n  }\n  const declined = patchedTurn(state, index, (current) => ({\n    ...current,\n    stage: 'declined',\n    decision,\n    endedAt: now,\n    steps: patchedSteps(current, 'reminders', (candidate) => ({\n      ...candidate,\n      status: 'skipped',\n      endedAt: now,\n    })),\n  }));\n  return drainQueue(declined, now);\n}\n\nfunction answering(state: WorkspaceState, index: number): WorkspaceState {\n  const turn = state.turns[index];\n  if (turn?.stage !== 'working') {\n    return state;\n  }\n  return patchedTurn(state, index, (current) => ({\n    ...current,\n    stage: 'answering',\n  }));\n}\n\nfunction answered(\n  state: WorkspaceState,\n  index: number,\n  now: number\n): WorkspaceState {\n  const turn = state.turns[index];\n  if (turn?.stage !== 'answering') {\n    return state;\n  }\n  const moved = patchedTurn(state, index, (current) => ({\n    ...current,\n    stage: 'done',\n    endedAt: now,\n  }));\n  const paid = withCost(moved, costOf(ANSWER_USD, turn.effort));\n  return drainQueue(paid, now);\n}\n\nfunction newSessionTarget(state: WorkspaceState) {\n  if (state.turns.length === 0) {\n    return LIVE_ID;\n  }\n  return NEW_ID;\n}\n\nfunction sessionOpened(state: WorkspaceState, id: string): WorkspaceState {\n  return { ...state, activeId: id, isSidebarOpen: false };\n}\n\nexport function applyAt(\n  state: WorkspaceState,\n  action: WorkspaceAction,\n  now: number\n): WorkspaceState {\n  switch (action.type) {\n    case 'typed':\n      return { ...state, draft: action.text, hint: 'none' };\n    case 'attached':\n      return attached(state, action.attachments);\n    case 'detached': {\n      const attachments = state.attachments.filter(\n        (file) => file.id !== action.id\n      );\n      return { ...state, attachments, hint: 'none' };\n    }\n    case 'toolToggled':\n      return { ...state, toolIds: toggled(state.toolIds, action.id) };\n    case 'skillToggled':\n      return { ...state, skillIds: toggled(state.skillIds, action.id) };\n    case 'effortSet':\n      return { ...state, effort: action.effort };\n    case 'sent':\n      return sent(state, now);\n    case 'queueRemoved': {\n      const queue = state.queue.filter((item) => item.id !== action.id);\n      return { ...state, queue, hint: 'none' };\n    }\n    case 'thoughtDone':\n      return thoughtDone(state, action.turn, now);\n    case 'stepStarted':\n      return stepStarted(state, action.turn, action.id, now);\n    case 'stepDone':\n      return stepDone(state, action.turn, action.id, now);\n    case 'asked':\n      return asked(state, action.turn);\n    case 'decided':\n      return decided(state, action.decision, now);\n    case 'answering':\n      return answering(state, action.turn);\n    case 'answered':\n      return answered(state, action.turn, now);\n    case 'sidebar':\n      return { ...state, isSidebarOpen: action.isOpen };\n    case 'searched':\n      return { ...state, search: action.text };\n    case 'sessionOpened':\n      return sessionOpened(state, action.id);\n    case 'newSession':\n      return sessionOpened(state, newSessionTarget(state));\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: WorkspaceState, action: WorkspaceAction) {\n  return applyAt(state, action, Date.now());\n}\n\nfunction hasStarted(state: WorkspaceState) {\n  return state.turns.length > 0;\n}\n\nfunction hasDecided(state: WorkspaceState) {\n  return askingIndexOf(state) < 0;\n}\n\nexport const WORD_MS = 55;\n\nexport const ANSWER_WORD_MS = 45;\n\n/** A stream is given a little longer than its words need, so its last word lands before the next step. */\nconst STREAM_MARGIN_MS = 200;\n\nconst KEY_MS = 40;\n\nconst DEMO_DECIDES_AFTER_MS = 2500;\n\nexport const THOUGHT_MS = THOUGHT_WORDS.length * WORD_MS + STREAM_MARGIN_MS;\n\nfunction streamMsOf(text: string) {\n  const count = wordsOf(text).length;\n  return count * ANSWER_WORD_MS + STREAM_MARGIN_MS;\n}\n\nfunction typingSteps(text: string, startAfter: number): Step[] {\n  const prefixes = prefixesOf(text);\n  return prefixes.map((typed, index) => ({\n    after: keyDelayOf(index, startAfter, KEY_MS),\n    by: 'demo',\n    action: { type: 'typed', text: typed },\n  }));\n}\n\nfunction frame(after: number, actions: WorkspaceAction[]): Step {\n  return { after, action: { type: 'batch', actions } };\n}\n\nfunction started(turn: number, id: StepId): WorkspaceAction {\n  return { type: 'stepStarted', turn, id };\n}\n\nfunction done(turn: number, id: StepId): WorkspaceAction {\n  return { type: 'stepDone', turn, id };\n}\n\nfunction demoStep(\n  after: number,\n  action: WorkspaceAction,\n  press?: string\n): Step {\n  return { after, by: 'demo', action, press };\n}\n\nfunction toolSteps(): Step[] {\n  return DEMO_TOOLS.map((id, index) => {\n    const after = keyDelayOf(index, 800, 450);\n    const press = pressOf(index);\n    return demoStep(after, { type: 'toolToggled', id }, press);\n  });\n}\n\nfunction pressOf(index: number) {\n  if (index === 0) {\n    return 'tools';\n  }\n  return undefined;\n}\n\nconst EFFORT_DRAG: Step[] = [\n  demoStep(800, { type: 'effortSet', effort: 4 }, 'effort'),\n  demoStep(260, { type: 'effortSet', effort: 5 }),\n  demoStep(700, { type: 'effortSet', effort: DEMO_EFFORT }),\n];\n\nconst OPENING: Step[] = [\n  ...typingSteps(QUESTION, 900),\n  demoStep(700, { type: 'attached', attachments: [DEMO_PHOTO] }, 'attach'),\n  demoStep(900, { type: 'attached', attachments: [DEMO_FILE] }, 'attach'),\n  ...toolSteps(),\n  demoStep(500, { type: 'skillToggled', id: DEMO_SKILL }),\n  ...EFFORT_DRAG,\n  {\n    after: 900,\n    by: 'person',\n    press: 'send',\n    action: { type: 'sent' },\n    isAnswered: hasStarted,\n  },\n  frame(THOUGHT_MS, [{ type: 'thoughtDone', turn: 0 }, started(0, 'invoices')]),\n  frame(1100, [done(0, 'invoices'), started(0, 'match')]),\n  ...typingSteps(FOLLOW_UP, 500),\n  demoStep(600, { type: 'sent' }, 'send'),\n  frame(500, [done(0, 'match'), started(0, 'contacts')]),\n  frame(1000, [\n    done(0, 'contacts'),\n    started(0, 'reminders'),\n    { type: 'asked', turn: 0 },\n  ]),\n];\n\nconst UNPAID_ANSWER_MS = streamMsOf(seedOf('unpaid').answer);\n\nconst SHARE_ANSWER_MS = streamMsOf(seedOf('share').answer);\n\nconst CLOSING: Step[] = [\n  {\n    after: DEMO_DECIDES_AFTER_MS,\n    by: 'person',\n    press: 'allow',\n    action: { type: 'decided', decision: 'approved' },\n    isAnswered: hasDecided,\n  },\n  frame(1400, [done(0, 'reminders'), { type: 'answering', turn: 0 }]),\n  frame(UNPAID_ANSWER_MS, [{ type: 'answered', turn: 0 }]),\n  frame(700, [started(1, 'share')]),\n  frame(1200, [done(1, 'share'), { type: 'answering', turn: 1 }]),\n  frame(SHARE_ANSWER_MS, [{ type: 'answered', turn: 1 }]),\n];\n\nexport const SCRIPT: Step[] = [...OPENING, ...CLOSING];\n\nconst ASKED = restingOf(INITIAL, OPENING, applyAt);\n\n/** Under reduced motion the agent waits on its request, with the composer filled in and a follow-up in the queue. */\nexport const RESTING: WorkspaceState = {\n  ...ASKED,\n  isSidebarOpen: false,\n};\n\nexport const LOOP_AFTER_MS = 3600;\n",
      "type": "registry:component",
      "target": "components/templates/application-06/session.ts"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/sessions-sidebar.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { PlusIcon, SearchIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { wordsOf } from '@/registry/ndeko/lib/words';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { Input } from '@/registry/ndeko/ui/input';\n\nimport {\n  BRAND,\n  DAYS,\n  LIVE_ID,\n  LIVE_TITLE,\n  NEW_ID,\n  PAST_SESSIONS,\n  type Day,\n} from './data';\nimport type { TurnStage, WorkspaceState } from './session';\n\nconst TITLE_WORDS = 5;\n\nconst RUNNING_STAGES: TurnStage[] = ['thinking', 'working', 'answering'];\n\nexport type RowStatus = 'running' | 'waiting';\n\nexport type SessionRow = {\n  id: string;\n  title: string;\n  day: Day;\n  status?: RowStatus;\n};\n\nfunction shortTitleOf(text: string) {\n  const words = wordsOf(text);\n  const kept = words.slice(0, TITLE_WORDS);\n  return kept.join(' ');\n}\n\nfunction liveStatusOf(state: WorkspaceState): RowStatus | undefined {\n  const last = state.turns.at(-1);\n  if (last?.stage === 'asking') {\n    return 'waiting';\n  }\n  if (last && RUNNING_STAGES.includes(last.stage)) {\n    return 'running';\n  }\n  return undefined;\n}\n\n/** The session the person works in sits first of its day: a new one, then the one that holds the run, then the older ones. */\nexport function rowsOf(state: WorkspaceState): SessionRow[] {\n  const rows: SessionRow[] = [];\n  if (state.newLines.length > 0) {\n    const title = shortTitleOf(state.newLines[0]);\n    rows.push({ id: NEW_ID, title, day: 'Today' });\n  }\n  if (state.turns.length > 0) {\n    const status = liveStatusOf(state);\n    rows.push({ id: LIVE_ID, title: LIVE_TITLE, day: 'Today', status });\n  }\n  for (const session of PAST_SESSIONS) {\n    rows.push({ id: session.id, title: session.title, day: session.day });\n  }\n  return rows;\n}\n\nfunction needleOf(query: string) {\n  const trimmed = query.trim();\n  return trimmed.toLowerCase();\n}\n\nfunction matchesQuery(title: string, query: string) {\n  const needle = needleOf(query);\n  if (needle === '') {\n    return true;\n  }\n  const lowered = title.toLowerCase();\n  return lowered.includes(needle);\n}\n\nfunction HighlightedTitle({ title, query }: { title: string; query: string }) {\n  const needle = needleOf(query);\n  const lowered = title.toLowerCase();\n  const index = lowered.indexOf(needle);\n  const hasMatch = needle !== '' && index >= 0;\n  if (!hasMatch) {\n    return <>{title}</>;\n  }\n  const end = index + needle.length;\n\n  return (\n    <>\n      {title.slice(0, index)}\n      <mark className='bg-primary/15 rounded-[3px] text-inherit'>\n        {title.slice(index, end)}\n      </mark>\n      {title.slice(end)}\n    </>\n  );\n}\n\nconst ROW =\n  'hover:bg-foreground/5 focus-visible:ring-ring/25 flex h-8 w-full min-w-0 cursor-pointer items-center gap-2 rounded-md px-2 text-start text-[13px] outline-none transition-colors duration-150 focus-visible:ring-[3px] focus-visible:ring-inset';\n\nfunction rowToneOf(isActive: boolean) {\n  if (isActive) {\n    return 'bg-foreground/[0.07] font-medium';\n  }\n  return undefined;\n}\n\nfunction currentOf(isActive: boolean): 'page' | undefined {\n  if (isActive) {\n    return 'page';\n  }\n  return undefined;\n}\n\nconst STATUS_DOT: Record<RowStatus, string> = {\n  running: 'bg-info animate-pulse',\n  waiting: 'bg-warning',\n};\n\nconst STATUS_WORD: Record<RowStatus, string> = {\n  running: 'Running',\n  waiting: 'Waiting on you',\n};\n\ntype SessionButtonProps = {\n  row: SessionRow;\n  query: string;\n  isActive: boolean;\n  onOpen: (id: string) => void;\n};\n\nfunction SessionButton({ row, query, isActive, onOpen }: SessionButtonProps) {\n  function open() {\n    onOpen(row.id);\n  }\n\n  return (\n    <button\n      type='button'\n      aria-current={currentOf(isActive)}\n      onClick={open}\n      className={cn(ROW, rowToneOf(isActive))}\n    >\n      <span className='min-w-0 flex-1 truncate'>\n        <HighlightedTitle title={row.title} query={query} />\n      </span>\n      {row.status && (\n        <span className='flex shrink-0 items-center'>\n          <span\n            aria-hidden='true'\n            className={cn('size-1.5 rounded-full', STATUS_DOT[row.status])}\n          />\n          <span className='sr-only'>{STATUS_WORD[row.status]}</span>\n        </span>\n      )}\n    </button>\n  );\n}\n\ntype SearchFieldProps = {\n  value: string;\n  onChange: (text: string) => void;\n};\n\nfunction SearchField({ value, onChange }: SearchFieldProps) {\n  const hasQuery = value !== '';\n\n  function clear() {\n    onChange('');\n  }\n\n  /** The first Escape empties the field. A second one is left to the sheet, which closes. */\n  function clearFromKeys(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key !== 'Escape' || !hasQuery) {\n      return;\n    }\n    event.stopPropagation();\n    clear();\n  }\n\n  return (\n    <div className='relative'>\n      <SearchIcon\n        aria-hidden='true'\n        className='text-muted-foreground pointer-events-none absolute start-2.5 top-1/2 size-3.5 -translate-y-1/2'\n      />\n      <Input\n        type='search'\n        size='sm'\n        aria-label='Search sessions'\n        placeholder='Search sessions'\n        value={value}\n        onChange={(event) => onChange(event.target.value)}\n        onKeyDown={clearFromKeys}\n        className='ps-8 pe-7'\n      />\n      {hasQuery && (\n        <button\n          type='button'\n          aria-label='Clear the search'\n          onClick={clear}\n          className='text-muted-foreground hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-ring/25 absolute end-1.5 top-1/2 flex size-5 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md outline-none focus-visible:ring-[3px]'\n        >\n          <XIcon className='size-3' />\n        </button>\n      )}\n    </div>\n  );\n}\n\ntype SessionsSidebarProps = {\n  rows: SessionRow[];\n  activeId: string;\n  search: string;\n  onSearch: (text: string) => void;\n  onOpen: (id: string) => void;\n  onNewSession: () => void;\n  className?: string;\n};\n\nexport function SessionsSidebar({\n  rows,\n  activeId,\n  search,\n  onSearch,\n  onOpen,\n  onNewSession,\n  className,\n}: SessionsSidebarProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const shown = rows.filter((row) => matchesQuery(row.title, search));\n  const hasNoMatch = shown.length === 0;\n\n  function clearSearch() {\n    onSearch('');\n  }\n\n  return (\n    <div className={cn('flex min-h-0 w-full flex-col gap-3', className)}>\n      <div className='flex flex-col gap-2'>\n        <div className='flex h-9 items-center gap-2 px-1.5'>\n          <CompanyMark seed={BRAND.name} className='size-6 rounded-md' />\n          <span className='text-[13px] font-semibold'>{BRAND.name}</span>\n        </div>\n        <Button\n          type='button'\n          variant='outline'\n          data-new-session\n          onClick={onNewSession}\n          className='w-full justify-start'\n        >\n          <PlusIcon />\n          New session\n        </Button>\n        <SearchField value={search} onChange={onSearch} />\n      </div>\n      <nav\n        aria-label='Sessions'\n        className='-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-1'\n      >\n        {DAYS.map((day) => {\n          const ofDay = shown.filter((row) => row.day === day);\n          if (ofDay.length === 0) {\n            return null;\n          }\n          return (\n            <section key={day} className='flex flex-col gap-0.5'>\n              <h2 className='text-muted-foreground flex h-6 items-center px-2 text-xs font-medium'>\n                {day}\n              </h2>\n              <ul className='flex flex-col'>\n                <AnimatePresence initial={false}>\n                  {ofDay.map((row) => (\n                    <motion.li\n                      key={row.id}\n                      className='-mx-1 overflow-hidden px-1'\n                      {...rowPresence}\n                    >\n                      <SessionButton\n                        row={row}\n                        query={search}\n                        isActive={row.id === activeId}\n                        onOpen={onOpen}\n                      />\n                    </motion.li>\n                  ))}\n                </AnimatePresence>\n              </ul>\n            </section>\n          );\n        })}\n        {hasNoMatch && (\n          <div className='flex flex-col items-start gap-1.5 px-2 text-xs'>\n            <p className='text-muted-foreground'>\n              No session matches &quot;{search.trim()}&quot;\n            </p>\n            <Button\n              type='button'\n              variant='link'\n              size='sm'\n              onClick={clearSearch}\n              className='h-6 px-0'\n            >\n              Clear the search\n            </Button>\n          </div>\n        )}\n      </nav>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/sessions-sidebar.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/thinking-row.tsx",
      "content": "'use client';\n\nimport { useId, useState } from 'react';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { elapsedOf, formatDuration } from '@/registry/ndeko/lib/agent-run';\nimport { BrainIcon, ChevronDownIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Fold } from '@/registry/ndeko/ui/chat-motion';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\nimport { StreamedText } from '@/registry/ndeko/ui/streamed-text';\n\nimport { EFFORT_WORD, type Effort } from './data';\nimport { WORD_MS, type TurnStage } from './session';\n\nfunction headlineOf(isThinking: boolean, duration: string, effort: Effort) {\n  if (isThinking) {\n    return 'Thinking';\n  }\n  const word = EFFORT_WORD[effort].toLowerCase();\n  return `Thought for ${duration}, ${word} effort`;\n}\n\nfunction chevronTurnOf(isOpen: boolean) {\n  if (isOpen) {\n    return 'rotate-180';\n  }\n  return 'rotate-0';\n}\n\ntype ThinkingRowProps = {\n  text: string;\n  stage: TurnStage;\n  effort: Effort;\n  isActive: boolean;\n  startedAt: number;\n  thoughtEndedAt?: number;\n};\n\nexport function ThinkingRow({\n  text,\n  stage,\n  effort,\n  isActive,\n  startedAt,\n  thoughtEndedAt,\n}: ThinkingRowProps) {\n  const [openChoice, setOpenChoice] = useState<boolean | null>(null);\n  const [wasThinking, setWasThinking] = useState(stage === 'thinking');\n  const panelId = useId();\n  const isThinking = stage === 'thinking';\n  const span = { startedAt, endedAt: thoughtEndedAt };\n  const elapsed = elapsedOf(span, thoughtEndedAt ?? 0);\n  const duration = formatDuration(elapsed);\n  const headline = headlineOf(isThinking, duration, effort);\n\n  if (wasThinking !== isThinking) {\n    setWasThinking(isThinking);\n    setOpenChoice(null);\n  }\n\n  const isOpen = openChoice ?? isThinking;\n\n  function toggle() {\n    setOpenChoice(!isOpen);\n  }\n\n  return (\n    <div className='bg-foreground/[0.03] dark:bg-foreground/[0.05] rounded-xl p-1.5'>\n      <button\n        type='button'\n        aria-expanded={isOpen}\n        aria-controls={panelId}\n        onClick={toggle}\n        className='hover:bg-foreground/[0.04] focus-visible:ring-ring/25 flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-start text-[13px] outline-none focus-visible:ring-[3px]'\n      >\n        <BrainIcon className='text-muted-foreground size-4 shrink-0' />\n        <span className='min-w-0 truncate font-medium'>\n          <WordRoll text={headline} />\n        </span>\n        {isThinking && (\n          <LiveDuration\n            item={span}\n            isRunning\n            className='text-muted-foreground w-10 text-xs'\n          />\n        )}\n        <ChevronDownIcon\n          className={cn(\n            'text-muted-foreground ms-auto size-3.5 shrink-0 transition-transform duration-200 ease-(--ease-out-strong)',\n            chevronTurnOf(isOpen)\n          )}\n        />\n      </button>\n      <Fold open={isOpen} id={panelId}>\n        <p className='text-muted-foreground px-2 pt-1.5 pb-2 text-[13px] leading-relaxed'>\n          <StreamedText\n            text={text}\n            isStreaming={isThinking}\n            isActive={isActive}\n            wordMs={WORD_MS}\n          />\n        </p>\n      </Fold>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/thinking-row.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/thread.tsx",
      "content": "'use client';\n\nimport { useFollowBottom } from '@/registry/ndeko/hooks/use-follow-bottom';\n\nimport { AgentTurn, OperatorTile } from './agent-turn';\nimport { AttachmentChip } from './chips';\nimport {\n  EFFORT_WORD,\n  FOLLOW_UP_REPLY,\n  LIVE_ID,\n  NEW_ID,\n  pastSessionOf,\n  skillOf,\n  toolOf,\n} from './data';\nimport type { Decision, Turn, WorkspaceState } from './session';\n\nfunction PersonBubble({ text }: { text: string }) {\n  return (\n    <p className='bg-foreground/[0.06] max-w-[85%] self-end rounded-2xl rounded-ee-md px-3.5 py-2 text-sm leading-relaxed'>\n      {text}\n    </p>\n  );\n}\n\nfunction settingsLineOf(turn: Turn) {\n  const effort = `${EFFORT_WORD[turn.effort]} effort`;\n  const tools = turn.toolIds.map((id) => toolOf(id).name);\n  const skills = turn.skillIds.map((id) => skillOf(id).name);\n  return [effort, ...tools, ...skills].join(', ');\n}\n\nfunction PersonMessage({ turn }: { turn: Turn }) {\n  const hasFiles = turn.attachments.length > 0;\n\n  return (\n    <div className='flex max-w-[85%] flex-col items-end gap-1.5 self-end'>\n      {hasFiles && (\n        <ul\n          aria-label='Sent with this message'\n          className='flex flex-wrap justify-end gap-1.5'\n        >\n          {turn.attachments.map((attachment) => (\n            <AttachmentChip key={attachment.id} attachment={attachment} />\n          ))}\n        </ul>\n      )}\n      <p className='bg-foreground/[0.06] rounded-2xl rounded-ee-md px-3.5 py-2 text-sm leading-relaxed'>\n        {turn.text}\n      </p>\n      <p className='text-muted-foreground text-end text-xs'>\n        {settingsLineOf(turn)}\n      </p>\n    </div>\n  );\n}\n\nfunction CannedReply({ text }: { text: string }) {\n  return (\n    <>\n      <PersonBubble text={text} />\n      <div className='flex items-start gap-2.5'>\n        <OperatorTile />\n        <p className='text-muted-foreground min-w-0 flex-1 pt-1 text-sm leading-relaxed'>\n          {FOLLOW_UP_REPLY}\n        </p>\n      </div>\n    </>\n  );\n}\n\nfunction EmptySession() {\n  return (\n    <div className='m-auto flex w-full max-w-sm flex-col items-center gap-1.5 py-6 text-center'>\n      <h2 className='text-base font-semibold text-balance'>\n        Describe the work\n      </h2>\n      <p className='text-muted-foreground text-[13px] leading-relaxed text-balance'>\n        Attach a photo or a file, switch on the tools it may use and set how\n        hard it thinks. Each step shows here as it happens.\n      </p>\n    </div>\n  );\n}\n\nfunction PastSummary({ id }: { id: string }) {\n  const session = pastSessionOf(id);\n\n  return (\n    <>\n      <PersonBubble text={session.prompt} />\n      <div className='flex items-start gap-2.5'>\n        <OperatorTile />\n        <div className='flex min-w-0 flex-1 flex-col gap-2 pt-1'>\n          <p className='text-sm leading-relaxed'>{session.summary}</p>\n          <p className='text-muted-foreground text-xs'>\n            A summary of an earlier session. It cannot be continued here.\n          </p>\n        </div>\n      </div>\n    </>\n  );\n}\n\ntype TurnViewProps = {\n  turn: Turn;\n  pressed: string | null;\n  isActive: boolean;\n  onDecide: (decision: Decision) => void;\n};\n\nfunction TurnView({ turn, pressed, isActive, onDecide }: TurnViewProps) {\n  return (\n    <>\n      <PersonMessage turn={turn} />\n      <AgentTurn\n        turn={turn}\n        pressed={pressed}\n        isActive={isActive}\n        onDecide={onDecide}\n      />\n    </>\n  );\n}\n\ntype ThreadProps = {\n  state: WorkspaceState;\n  pressed: string | null;\n  isActive: boolean;\n  onDecide: (decision: Decision) => void;\n};\n\nexport function Thread({ state, pressed, isActive, onDecide }: ThreadProps) {\n  const { scrollerRef, contentRef, updatePinned } = useFollowBottom();\n  const { activeId, turns, newLines } = state;\n  const isLive = activeId === LIVE_ID;\n  const isNew = activeId === NEW_ID;\n  const isPast = !isLive && !isNew;\n  const hasTurns = turns.length > 0;\n  const hasNewLines = newLines.length > 0;\n\n  return (\n    <div\n      ref={scrollerRef}\n      onScroll={updatePinned}\n      className='min-h-0 flex-1 overflow-y-auto'\n    >\n      <div\n        ref={contentRef}\n        className='mx-auto flex min-h-full w-full max-w-2xl flex-col gap-5 px-4 py-5'\n      >\n        {isLive && !hasTurns && <EmptySession />}\n        {isLive &&\n          turns.map((turn) => (\n            <TurnView\n              key={turn.id}\n              turn={turn}\n              pressed={pressed}\n              isActive={isActive}\n              onDecide={onDecide}\n            />\n          ))}\n        {isNew && !hasNewLines && <EmptySession />}\n        {isNew &&\n          newLines.map((text, index) => (\n            <CannedReply key={index} text={text} />\n          ))}\n        {isPast && <PastSummary id={activeId} />}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/thread.tsx"
    },
    {
      "path": "registry/ndeko/templates/agent-workspaces/application-06/tools-menu.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { PlugIcon, WandIcon } 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 {\n  DropdownMenu,\n  DropdownMenuCheckboxItem,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuGroupLabel,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\n\nimport { SKILLS, TOOLS, type SkillId, type ToolId } from './data';\n\ntype ToolsMenuProps = {\n  toolIds: ToolId[];\n  skillIds: SkillId[];\n  isPressed: boolean;\n  onToggleTool: (id: ToolId) => void;\n  onToggleSkill: (id: SkillId) => void;\n};\n\n/** The menu belongs to a person. The demonstration switches the tools on, and their chips arrive in the composer. */\nexport function ToolsMenu({\n  toolIds,\n  skillIds,\n  isPressed,\n  onToggleTool,\n  onToggleSkill,\n}: ToolsMenuProps) {\n  const count = toolIds.length + skillIds.length;\n  const hasCount = count > 0;\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        render={\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            aria-label={`Tools and skills, ${count} on`}\n            className={cn(\n              'text-muted-foreground gap-1.5 px-2',\n              pressedQuietOf(isPressed)\n            )}\n          />\n        }\n      >\n        <PlugIcon />\n        <span className='sr-only @md:not-sr-only'>Tools</span>\n        {hasCount && (\n          <span className='bg-primary/10 text-primary-ink inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] leading-none font-medium'>\n            <MotionNumber value={count} />\n          </span>\n        )}\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-64'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Tools</DropdownMenuGroupLabel>\n          {TOOLS.map((tool) => (\n            <DropdownMenuCheckboxItem\n              key={tool.id}\n              checked={toolIds.includes(tool.id)}\n              onCheckedChange={() => onToggleTool(tool.id)}\n            >\n              <BrandTile brand={tool.brand} size='sm' />\n              {tool.name}\n            </DropdownMenuCheckboxItem>\n          ))}\n        </DropdownMenuGroup>\n        <DropdownMenuSeparator />\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Skills</DropdownMenuGroupLabel>\n          {SKILLS.map((skill) => (\n            <DropdownMenuCheckboxItem\n              key={skill.id}\n              checked={skillIds.includes(skill.id)}\n              onCheckedChange={() => onToggleSkill(skill.id)}\n              className='h-auto items-start py-1.5'\n            >\n              <WandIcon className='mt-0.5' />\n              <span className='flex min-w-0 flex-col'>\n                <span>{skill.name}</span>\n                <span className='text-muted-foreground text-xs'>\n                  {skill.hint}\n                </span>\n              </span>\n            </DropdownMenuCheckboxItem>\n          ))}\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-06/tools-menu.tsx"
    }
  ],
  "categories": [
    "templates",
    "agent-workspaces"
  ],
  "type": "registry:block"
}