{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "onboarding-03",
  "title": "New workspace with a first agent",
  "description": "A new workspace in four steps on one card: tools go from Connect to Connecting to Connected, addresses become chips, the agent gets a name, a model and a job, and each finished step folds into one line under a check that draws itself, until the first run ticks through its plan and two tool calls and its result lands.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/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/field.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/label.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/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/radio-group.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/run-session.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/index.tsx",
      "content": "'use client';\n\nimport { useCallback } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  pressedSolidOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport {\n  indexOfPhase,\n  modelOf,\n  PHASES,\n  toolOf,\n  WORKSPACE,\n  type ModelId,\n  type PhaseId,\n  type ToolId,\n} from './data';\nimport { FirstRun } from './first-run';\nimport { AgentStep, TeamStep, ToolsStep } from './phase-forms';\nimport { PhaseRow, type PhaseStatus } from './phase-row';\nimport { isRunDone, type Run } from './run';\nimport {\n  CONNECT_MS,\n  connectedToolsOf,\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  TOTAL,\n  type TextField,\n  type WorkspaceAction,\n  type WorkspaceState,\n} from './session';\nimport { useRunClock } from './use-run-clock';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nconst LAST_INDEX = PHASES.length - 1;\n\nfunction phaseStatusOf(index: number, currentIndex: number): PhaseStatus {\n  if (index < currentIndex) {\n    return 'done';\n  }\n  if (index === currentIndex) {\n    return 'current';\n  }\n  return 'upcoming';\n}\n\nfunction hasRunEnded(run: Run | null) {\n  if (!run) {\n    return false;\n  }\n  return isRunDone(run);\n}\n\nfunction markerOf(status: PhaseStatus, isOver: boolean): PhaseStatus {\n  if (isOver) {\n    return 'done';\n  }\n  return status;\n}\n\nfunction doneCountOf(currentIndex: number, isLastStepOver: boolean) {\n  if (isLastStepOver) {\n    return currentIndex + 1;\n  }\n  return currentIndex;\n}\n\nfunction bodyIf(isCurrent: boolean, body: React.ReactNode) {\n  if (isCurrent) {\n    return body;\n  }\n  return null;\n}\n\nfunction continueLabelOf(phase: PhaseId) {\n  if (phase === 'agent') {\n    return 'Create agent';\n  }\n  return 'Continue';\n}\n\n/** Linear, Linear and GitHub, Notion, Linear and GitHub. */\nfunction listOf(names: string[]) {\n  if (names.length < 2) {\n    return names.join('');\n  }\n  const head = names.slice(0, -1);\n  const last = names[names.length - 1];\n  return `${head.join(', ')} and ${last}`;\n}\n\nfunction peopleLineOf(count: number) {\n  if (count === 1) {\n    return '1 person invited';\n  }\n  return `${count} people invited`;\n}\n\nfunction summaryOf(phase: PhaseId, state: WorkspaceState) {\n  if (phase === 'tools') {\n    const connected = connectedToolsOf(state);\n    const names = connected.map((id) => toolOf(id).name);\n    return `${listOf(names)} connected`;\n  }\n  if (phase === 'team') {\n    return peopleLineOf(state.invites.length);\n  }\n  if (phase === 'agent') {\n    const model = modelOf(state.model).name;\n    return `${state.agentName.trim()} on ${model}`;\n  }\n  return 'First job done';\n}\n\nexport default function Onboarding03() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule, clearAll } = useTimeouts();\n  const tickRun = useCallback(() => act({ type: 'runTicked' }), [act]);\n  useRunClock(state.run, isInView, tickRun);\n  const { run } = state;\n  const currentIndex = indexOfPhase(state.phase);\n  const isWatching = state.phase === 'watch';\n  const isRunOver = hasRunEnded(run);\n  const isLastStepOver = isWatching && isRunOver;\n  const doneCount = doneCountOf(currentIndex, isLastStepOver);\n  const hasMoved = state.moves > 0;\n  const message = spokenUnless(isAutoplaying, state.spoken);\n  const canReplay = isFinished && !isAutoplaying;\n\n  function focusLater(selector: string) {\n    requestAnimationFrame(() => {\n      const target = ref.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  /**\n   * Works out where an action leads before it is sent: a step that changes takes the focus to its\n   * heading, an entry that is refused takes it to what has to change.\n   */\n  function actAndFollow(action: WorkspaceAction) {\n    const after = reducer(state, action);\n    act(action);\n    if (after.phase !== state.phase) {\n      focusLater('[data-phase-heading]');\n      return;\n    }\n    const wasRefused = after.attempts !== state.attempts;\n    const refusal = after.hint;\n    if (wasRefused && refusal) {\n      focusLater(`[data-field=\"${refusal.field}\"]`);\n    }\n  }\n\n  /** The tool answers on its own a moment after the press, whoever pressed. */\n  function connect(tool: ToolId) {\n    act({ type: 'connectPressed', tool });\n    schedule(() => act({ type: 'connected', tool }), CONNECT_MS);\n  }\n\n  /** The button that disconnects leaves with the connection, so the focus goes back to Connect. */\n  function disconnect(tool: ToolId) {\n    act({ type: 'disconnected', tool });\n    focusLater(`[data-connect=\"${tool}\"]`);\n  }\n\n  function typeText(field: TextField, value: string) {\n    act({ type: 'typed', field, value });\n  }\n\n  function commitInvites() {\n    actAndFollow({ type: 'inviteCommitted' });\n  }\n\n  /** The chip takes its button with it, so the focus goes back to the address box. */\n  function removeInvite(address: string) {\n    act({ type: 'inviteRemoved', address });\n    focusLater('[data-field=\"invites\"]');\n  }\n\n  function pickModel(model: ModelId) {\n    act({ type: 'modelPicked', model });\n  }\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    actAndFollow({ type: 'continued' });\n  }\n\n  function edit(phase: PhaseId) {\n    actAndFollow({ type: 'edited', phase });\n  }\n\n  /** Run again leaves with the result it sat in, so the focus goes to the heading of the step. */\n  function runAgain() {\n    act({ type: 'ranAgain' });\n    focusLater('[data-phase-heading]');\n  }\n\n  /** A tool that is still connecting belongs to the round it was pressed in. */\n  function replay() {\n    clearAll();\n    restart();\n  }\n\n  function currentBody() {\n    if (isWatching) {\n      if (!run) {\n        return null;\n      }\n      return (\n        <FirstRun\n          run={run}\n          agentName={state.agentName}\n          model={state.model}\n          onRunAgain={runAgain}\n        />\n      );\n    }\n    return (\n      <form noValidate onSubmit={submit} className='flex flex-col gap-4'>\n        {state.phase === 'tools' && (\n          <ToolsStep\n            tools={state.tools}\n            hint={state.hint}\n            attempts={state.attempts}\n            pressed={pressed}\n            onConnect={connect}\n            onDisconnect={disconnect}\n          />\n        )}\n        {state.phase === 'team' && (\n          <TeamStep\n            invites={state.invites}\n            draft={state.inviteDraft}\n            hint={state.hint}\n            attempts={state.attempts}\n            pressed={pressed}\n            onType={typeText}\n            onCommit={commitInvites}\n            onRemove={removeInvite}\n          />\n        )}\n        {state.phase === 'agent' && (\n          <AgentStep\n            agentName={state.agentName}\n            model={state.model}\n            job={state.job}\n            hint={state.hint}\n            attempts={state.attempts}\n            onType={typeText}\n            onPickModel={pickModel}\n          />\n        )}\n        <div className='flex justify-end'>\n          <Button\n            type='submit'\n            className={pressedSolidOf(pressed === 'continue')}\n          >\n            {continueLabelOf(state.phase)}\n          </Button>\n        </div>\n      </form>\n    );\n  }\n\n  const body = currentBody();\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container flex min-h-dvh w-full flex-col items-center p-4 @2xl:p-8'\n      >\n        <div className='flex w-full max-w-xl flex-col gap-5 @2xl:pt-4'>\n          <header className='flex items-center gap-3'>\n            <CompanyMark seed={WORKSPACE.name} size='lg' />\n            <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n              <h1 className='truncate text-lg font-semibold'>\n                Set up {WORKSPACE.name}\n              </h1>\n              <p className='text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1 text-xs'>\n                <span className='flex items-baseline gap-1 tabular-nums'>\n                  <MotionNumber value={doneCount} />\n                  of {TOTAL} steps done\n                </span>\n                <Badge variant='secondary'>Illustrative</Badge>\n              </p>\n            </div>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={replay}\n              label='Replay'\n            />\n          </header>\n\n          <section\n            aria-label='Workspace setup'\n            className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] @container rounded-xl px-4 py-2.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @md:px-5'\n          >\n            <ol aria-label='Setup steps' className='flex flex-col'>\n              {PHASES.map((phase, index) => {\n                const status = phaseStatusOf(index, currentIndex);\n                const isCurrent = status === 'current';\n                const isLast = index === LAST_INDEX;\n                const showsEndedCheck = isLast && isLastStepOver;\n                return (\n                  <PhaseRow\n                    key={phase.id}\n                    phase={phase}\n                    number={index + 1}\n                    status={status}\n                    marker={markerOf(status, showsEndedCheck)}\n                    summary={summaryOf(phase.id, state)}\n                    body={bodyIf(isCurrent, body)}\n                    hasMoved={hasMoved}\n                    onEdit={edit}\n                  />\n                );\n              })}\n            </ol>\n          </section>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/phase-row.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\n\nimport type { Phase, PhaseId } from './data';\n\nexport type PhaseStatus = 'done' | 'current' | 'upcoming';\n\nconst NUMBER =\n  'inline-flex size-[18px] items-center justify-center rounded-full text-[11px] leading-none font-medium tabular-nums';\n\nconst STATUS_WORD: Record<PhaseStatus, string> = {\n  done: 'Done',\n  current: 'Current step',\n  upcoming: 'Upcoming',\n};\n\n/** A summary that arrives after the first move fades in. Nothing fades when the page loads. */\nfunction arrivalOf(hasMoved: boolean) {\n  if (hasMoved) {\n    return 'transition-opacity duration-300 starting:opacity-0';\n  }\n  return undefined;\n}\n\ntype MarkerProps = {\n  status: PhaseStatus;\n  number: number;\n};\n\n/** The number turns into a check that draws itself when its step is done. A step done when the page loads shows its check at once. */\nfunction Marker({ status, number }: MarkerProps) {\n  return (\n    <Swap swapKey={status} className='size-[18px] shrink-0 justify-center'>\n      {status === 'done' && (\n        <DrawnCheck tone='success' entrance='draw' pace='calm' />\n      )}\n      {status === 'current' && (\n        <span className={cn(NUMBER, 'bg-primary text-primary-foreground')}>\n          {number}\n        </span>\n      )}\n      {status === 'upcoming' && (\n        <span\n          className={cn(NUMBER, 'bg-foreground/[0.06] text-muted-foreground')}\n        >\n          {number}\n        </span>\n      )}\n    </Swap>\n  );\n}\n\nexport type PhaseRowProps = {\n  phase: Phase;\n  number: number;\n  status: PhaseStatus;\n  /** The mark beside the step. The last step stays open on its result and shows its check once its run is over. */\n  marker: PhaseStatus;\n  /** What a step that is done left behind, said in one line. */\n  summary: string;\n  /** What the step asks for, while it is the current one. */\n  body: React.ReactNode;\n  /** True once the session moved between steps at least once. */\n  hasMoved: boolean;\n  onEdit: (phase: PhaseId) => void;\n};\n\n/**\n * One step of the setup. Done, it folds into a single line that says what it left behind, with the\n * way back to it; current, it opens under its heading; upcoming, it waits in the faint ink.\n */\nexport function PhaseRow({\n  phase,\n  number,\n  status,\n  marker,\n  summary,\n  body,\n  hasMoved,\n  onEdit,\n}: PhaseRowProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = rowPresenceOf(shouldReduceMotion);\n  const isDone = status === 'done';\n  const isCurrent = status === 'current';\n  const isUpcoming = status === 'upcoming';\n\n  return (\n    <li className='flex flex-col'>\n      <div className='flex min-h-10 items-center gap-3'>\n        <Marker status={marker} number={number} />\n        {isDone && (\n          <p\n            className={cn(\n              'flex min-w-0 flex-1 items-baseline gap-2',\n              arrivalOf(hasMoved)\n            )}\n          >\n            <span className='text-muted-foreground shrink-0 text-xs'>\n              <span className='sr-only'>{STATUS_WORD.done}: </span>\n              {phase.label}\n            </span>\n            <span className='min-w-0 truncate text-[13px]'>{summary}</span>\n          </p>\n        )}\n        {isCurrent && (\n          <h2\n            data-phase-heading\n            tabIndex={-1}\n            className='focus-visible:ring-ring/25 min-w-0 flex-1 rounded-sm text-sm font-medium text-balance outline-none focus-visible:ring-[3px]'\n          >\n            <span className='sr-only'>{STATUS_WORD.current}: </span>\n            {phase.title}\n          </h2>\n        )}\n        {isUpcoming && (\n          <p className='text-muted-foreground min-w-0 flex-1 truncate text-[13px]'>\n            <span className='sr-only'>{STATUS_WORD.upcoming}: </span>\n            {phase.title}\n          </p>\n        )}\n        {isDone && (\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            aria-label={`Edit ${phase.label}`}\n            onClick={() => onEdit(phase.id)}\n            className='text-muted-foreground -me-1.5 shrink-0'\n          >\n            Edit\n          </Button>\n        )}\n      </div>\n      <AnimatePresence initial={false}>\n        {isCurrent && (\n          <motion.div\n            key='body'\n            className='-mx-1 overflow-hidden px-1'\n            {...presence}\n          >\n            <div className='flex flex-col gap-4 pt-0.5 pb-4 @md:ps-[1.875rem]'>\n              <p className='text-muted-foreground text-xs leading-5 text-pretty'>\n                {phase.lead}\n              </p>\n              {body}\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </li>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/phase-row.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/phase-forms.tsx",
      "content": "'use client';\n\nimport { useId } from 'react';\n\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { MailIcon, PlugIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Field,\n  FieldDescription,\n  FieldError,\n  FieldLabel,\n} from '@/registry/ndeko/ui/field';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { Label, LABEL_RECIPE } from '@/registry/ndeko/ui/label';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { RadioGroup, RadioGroupItem } from '@/registry/ndeko/ui/radio-group';\n\nimport {\n  AGENT_SEED,\n  AGENT_SERIES,\n  JOB_MAX_LENGTH,\n  MODELS,\n  TOOLS,\n  type ModelId,\n  type Tool,\n  type ToolId,\n} from './data';\nimport { ENDS_AN_ADDRESS } from './invites';\nimport type { ConnectStatus, Hint, HintField, TextField } from './session';\n\nconst CONNECT_STATE: Record<ConnectStatus, MorphState> = {\n  idle: 'idle',\n  connecting: 'busy',\n  connected: 'done',\n};\n\nconst CONNECT_LABELS: Record<MorphState, string> = {\n  idle: 'Connect',\n  busy: 'Connecting',\n  done: 'Connected',\n};\n\n/** A tray inside the card. A connected tool takes the tint of what went well. */\nconst TOOL_ROW =\n  'flex items-center gap-3 rounded-lg p-2.5 transition-colors duration-200';\n\n/** A tray inside the card, tinted when its model is the one picked. The whole tray answers the press. */\nconst MODEL_CHOICE =\n  'bg-foreground/[0.04] has-data-checked:bg-primary/[0.08] relative flex items-center gap-3 rounded-lg p-3 transition-colors duration-150';\n\n/** Someone invited has not joined yet: a dashed slot with an envelope, since nobody is there. */\nconst INVITED =\n  'hairline-border border-foreground/25 flex h-7 max-w-full items-center gap-1.5 rounded-full border-dashed ps-2.5 pe-0.5 text-xs transition-opacity duration-200 starting:opacity-0';\n\nconst REMOVE =\n  'focus-visible:ring-ring/25 hover:bg-foreground/[0.08] text-muted-foreground hover:text-foreground flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150 outline-none focus-visible:ring-[3px]';\n\nconst LONE_HINT =\n  'text-destructive-ink text-xs transition-[opacity,translate] duration-200 ease-(--ease-out-strong) starting:-translate-y-0.5 starting:opacity-0';\n\n/** The hint of one field, when the last refusal was about it. */\nfunction hintFor(hint: Hint | null, field: HintField) {\n  if (hint?.field === field) {\n    return hint;\n  }\n  return null;\n}\n\nfunction describedByOf(hint: Hint | null, hintId: string) {\n  if (hint) {\n    return hintId;\n  }\n  return undefined;\n}\n\nfunction toolToneOf(isConnected: boolean) {\n  if (isConnected) {\n    return 'bg-success/[0.08]';\n  }\n  return 'bg-foreground/[0.04]';\n}\n\n/** Connect Notion, Connecting Notion, Notion connected: the name says which tool the button is for. */\nfunction connectLabelOf(status: ConnectStatus, name: string) {\n  if (status === 'connected') {\n    return `${name} connected`;\n  }\n  const morph = CONNECT_STATE[status];\n  const word = CONNECT_LABELS[morph];\n  return `${word} ${name}`;\n}\n\n/** The first tool takes the focus when Continue finds nothing connected, and says the hint. */\nfunction fieldMarkOf(isFirst: boolean) {\n  if (isFirst) {\n    return 'tools';\n  }\n  return undefined;\n}\n\nfunction firstOnlyOf(isFirst: boolean, id: string | undefined) {\n  if (isFirst) {\n    return id;\n  }\n  return undefined;\n}\n\ntype ToolRowProps = {\n  tool: Tool;\n  status: ConnectStatus;\n  isFirst: boolean;\n  /** The id of the hint of the step, while it shows. */\n  shownHintId: string | undefined;\n  isPressed: boolean;\n  onConnect: (tool: ToolId) => void;\n  onDisconnect: (tool: ToolId) => void;\n};\n\nfunction ToolRow({\n  tool,\n  status,\n  isFirst,\n  shownHintId,\n  isPressed,\n  onConnect,\n  onDisconnect,\n}: ToolRowProps) {\n  const isConnected = status === 'connected';\n  const describedBy = firstOnlyOf(isFirst, shownHintId);\n\n  return (\n    <li className={cn(TOOL_ROW, toolToneOf(isConnected))}>\n      <BrandTile brand={tool.brand} size='lg' />\n      <div className='flex min-w-0 flex-1 flex-col'>\n        <p className='truncate text-[13px] font-medium'>{tool.name}</p>\n        <p className='text-muted-foreground truncate text-xs'>{tool.shares}</p>\n      </div>\n      <MorphButton\n        type='button'\n        size='sm'\n        variant='outline'\n        data-connect={tool.id}\n        data-field={fieldMarkOf(isFirst)}\n        aria-label={connectLabelOf(status, tool.name)}\n        aria-describedby={describedBy}\n        state={CONNECT_STATE[status]}\n        labels={CONNECT_LABELS}\n        idleIcon={<PlugIcon />}\n        onClick={() => onConnect(tool.id)}\n        className={pressedQuietOf(isPressed)}\n      />\n      <span className='flex size-7 shrink-0 items-center justify-center'>\n        {isConnected && (\n          <Button\n            type='button'\n            variant='ghost'\n            size='icon-sm'\n            aria-label={`Disconnect ${tool.name}`}\n            onClick={() => onDisconnect(tool.id)}\n            className='text-muted-foreground transition-[opacity,color,background-color,scale] duration-200 starting:opacity-0'\n          >\n            <XIcon />\n          </Button>\n        )}\n      </span>\n    </li>\n  );\n}\n\nexport type ToolsStepProps = {\n  tools: Record<ToolId, ConnectStatus>;\n  hint: Hint | null;\n  /** Counts the refused entries: a hint that comes back after a new try arrives again. */\n  attempts: number;\n  pressed: string | null;\n  onConnect: (tool: ToolId) => void;\n  onDisconnect: (tool: ToolId) => void;\n};\n\nexport function ToolsStep({\n  tools,\n  hint,\n  attempts,\n  pressed,\n  onConnect,\n  onDisconnect,\n}: ToolsStepProps) {\n  const hintId = useId();\n  const toolsHint = hintFor(hint, 'tools');\n  const shownHintId = describedByOf(toolsHint, hintId);\n\n  return (\n    <div className='flex flex-col gap-2'>\n      <ul aria-label='Tools' className='flex flex-col gap-1.5'>\n        {TOOLS.map((tool, index) => (\n          <ToolRow\n            key={tool.id}\n            tool={tool}\n            status={tools[tool.id]}\n            isFirst={index === 0}\n            shownHintId={shownHintId}\n            isPressed={pressed === `connect-${tool.id}`}\n            onConnect={onConnect}\n            onDisconnect={onDisconnect}\n          />\n        ))}\n      </ul>\n      {toolsHint && (\n        <p key={attempts} id={hintId} className={LONE_HINT}>\n          {toolsHint.message}\n        </p>\n      )}\n    </div>\n  );\n}\n\nexport type TeamStepProps = {\n  invites: string[];\n  draft: string;\n  hint: Hint | null;\n  attempts: number;\n  pressed: string | null;\n  onType: (field: TextField, value: string) => void;\n  onCommit: () => void;\n  onRemove: (address: string) => void;\n};\n\nexport function TeamStep({\n  invites,\n  draft,\n  hint,\n  attempts,\n  pressed,\n  onType,\n  onCommit,\n  onRemove,\n}: TeamStepProps) {\n  const invitesHint = hintFor(hint, 'invites');\n  const hasInvites = invites.length > 0;\n\n  function typeAddress(value: string) {\n    onType('inviteDraft', value);\n    if (ENDS_AN_ADDRESS.test(value)) {\n      onCommit();\n    }\n  }\n\n  /** Enter adds what the box holds. On an empty box it is left alone, and the step goes on. */\n  function addOnEnter(event: React.KeyboardEvent<HTMLInputElement>) {\n    const isBoxEmpty = draft.trim() === '';\n    if (event.key !== 'Enter' || isBoxEmpty) {\n      return;\n    }\n    event.preventDefault();\n    onCommit();\n  }\n\n  return (\n    <div className='flex flex-col gap-3'>\n      <Field invalid={Boolean(invitesHint)}>\n        <FieldLabel>Email addresses</FieldLabel>\n        <div className='flex items-center gap-2'>\n          <Input\n            data-field='invites'\n            inputMode='email'\n            autoComplete='off'\n            autoCapitalize='none'\n            spellCheck={false}\n            placeholder='name@company.com'\n            value={draft}\n            onChange={(event) => typeAddress(event.target.value)}\n            onKeyDown={addOnEnter}\n          />\n          <Button\n            type='button'\n            variant='outline'\n            onClick={onCommit}\n            className={cn('shrink-0', pressedQuietOf(pressed === 'add-invite'))}\n          >\n            Add\n          </Button>\n        </div>\n        {invitesHint && (\n          <FieldError key={attempts} match>\n            {invitesHint.message}\n          </FieldError>\n        )}\n        {!invitesHint && (\n          <FieldDescription>\n            Press Enter after each address, or paste several at once\n          </FieldDescription>\n        )}\n      </Field>\n      <div className='flex min-h-7 items-center'>\n        {!hasInvites && (\n          <p className='text-muted-foreground text-xs'>Nobody is invited yet</p>\n        )}\n        {hasInvites && (\n          <ul\n            aria-label='People to invite'\n            className='flex min-w-0 flex-wrap gap-1.5'\n          >\n            {invites.map((address) => (\n              <li key={address} className={INVITED}>\n                <MailIcon\n                  aria-hidden='true'\n                  className='text-muted-foreground size-3.5 shrink-0'\n                />\n                <span className='min-w-0 truncate'>{address}</span>\n                <button\n                  type='button'\n                  aria-label={`Remove ${address}`}\n                  onClick={() => onRemove(address)}\n                  className={REMOVE}\n                >\n                  <XIcon className='size-3.5' />\n                </button>\n              </li>\n            ))}\n          </ul>\n        )}\n      </div>\n    </div>\n  );\n}\n\nexport type AgentStepProps = {\n  agentName: string;\n  model: ModelId;\n  job: string;\n  hint: Hint | null;\n  attempts: number;\n  onType: (field: TextField, value: string) => void;\n  onPickModel: (model: ModelId) => void;\n};\n\nexport function AgentStep({\n  agentName,\n  model,\n  job,\n  hint,\n  attempts,\n  onType,\n  onPickModel,\n}: AgentStepProps) {\n  const modelsId = useId();\n  const nameHint = hintFor(hint, 'agentName');\n  const jobHint = hintFor(hint, 'job');\n\n  function pick(value: unknown) {\n    const picked = MODELS.find((candidate) => candidate.id === value);\n    if (picked) {\n      onPickModel(picked.id);\n    }\n  }\n\n  return (\n    <div className='flex flex-col gap-4'>\n      <Field invalid={Boolean(nameHint)}>\n        <FieldLabel>Name</FieldLabel>\n        <div className='flex items-center gap-2'>\n          <MeshTile\n            seed={AGENT_SEED}\n            color={seriesColorOf(AGENT_SERIES)}\n            size='lg'\n          />\n          <Input\n            data-field='agentName'\n            autoComplete='off'\n            placeholder='What your team will call it'\n            value={agentName}\n            onChange={(event) => onType('agentName', event.target.value)}\n          />\n        </div>\n        {nameHint && (\n          <FieldError key={attempts} match>\n            {nameHint.message}\n          </FieldError>\n        )}\n      </Field>\n      <div className='flex flex-col gap-1.5'>\n        <p id={modelsId} className={LABEL_RECIPE}>\n          Model\n        </p>\n        <RadioGroup\n          aria-labelledby={modelsId}\n          value={model}\n          onValueChange={pick}\n          className='grid-cols-1 gap-2 @md:grid-cols-3'\n        >\n          {MODELS.map((candidate) => {\n            const itemId = `${modelsId}-${candidate.id}`;\n            return (\n              <div key={candidate.id} className={MODEL_CHOICE}>\n                <RadioGroupItem\n                  id={itemId}\n                  value={candidate.id}\n                  className='order-1 after:absolute after:inset-0 after:rounded-lg'\n                />\n                <BrandTile brand={candidate.brand} size='lg' />\n                <div className='flex min-w-0 flex-1 flex-col gap-1'>\n                  <Label htmlFor={itemId}>{candidate.name}</Label>\n                  <p className='text-muted-foreground truncate text-xs'>\n                    {candidate.maker}\n                  </p>\n                </div>\n              </div>\n            );\n          })}\n        </RadioGroup>\n      </div>\n      <Field invalid={Boolean(jobHint)}>\n        <FieldLabel>Its job</FieldLabel>\n        <Input\n          data-field='job'\n          autoComplete='off'\n          maxLength={JOB_MAX_LENGTH}\n          placeholder='One sentence, the way you would ask a teammate'\n          value={job}\n          onChange={(event) => onType('job', event.target.value)}\n        />\n        {jobHint && (\n          <FieldError key={attempts} match>\n            {jobHint.message}\n          </FieldError>\n        )}\n        {!jobHint && (\n          <FieldDescription>\n            It runs once with your tools as soon as it is created\n          </FieldDescription>\n        )}\n      </Field>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/phase-forms.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/first-run.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  seriesColorOf,\n  type PlanStep,\n  type StepStatus,\n  type ToolCall,\n} from '@/registry/ndeko/lib/agent-run';\nimport {\n  CircleCheckIcon,\n  LoaderIcon,\n  RotateCcwIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { EASE_OUT_STRONG } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { CallStatusMark } from '@/registry/ndeko/ui/call-status';\nimport { Fold, Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport { AGENT_SEED, AGENT_SERIES, modelOf, type ModelId } from './data';\nimport {\n  callsOf,\n  isRunDone,\n  planOf,\n  resultOf,\n  runTimesOf,\n  tasksOf,\n  type Run,\n  type RunTask,\n} from './run';\n\nconst STEP_WORD: Record<StepStatus, string> = {\n  upcoming: 'Upcoming',\n  running: 'Running',\n  done: 'Done',\n  failed: 'Failed',\n  skipped: 'Skipped',\n};\n\nconst DURATION = 'text-muted-foreground w-12 shrink-0 text-end text-xs';\n\nconst LAND = { duration: 0.3, ease: EASE_OUT_STRONG };\n\nconst LEAVE = { opacity: 0, transition: { duration: 0.12 } };\n\nconst LANDING = { opacity: 0, scale: 1.04 };\n\nconst LANDED = { opacity: 1, scale: 1 };\n\nconst FADING_IN = { opacity: 0 };\n\nconst FADED_IN = { opacity: 1 };\n\n/** The result settles from a slightly larger size. Reduced motion keeps the fade. */\nfunction landingOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return FADING_IN;\n  }\n  return LANDING;\n}\n\nfunction landedOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return FADED_IN;\n  }\n  return LANDED;\n}\n\nfunction runWordOf(isDone: boolean) {\n  if (isDone) {\n    return 'Done';\n  }\n  return 'Running';\n}\n\nfunction stepInkOf(status: StepStatus) {\n  if (status === 'upcoming') {\n    return 'text-muted-foreground';\n  }\n  return 'text-foreground';\n}\n\nfunction StepGlyph({ status }: { status: StepStatus }) {\n  if (status === 'done') {\n    return <DrawnCheck tone='success' entrance='draw' pace='calm' />;\n  }\n  if (status === 'running') {\n    return <LoaderIcon className='text-primary-ink size-4 animate-spin' />;\n  }\n  return (\n    <span className='hairline-ring ring-foreground/25 size-3.5 rounded-full' />\n  );\n}\n\nfunction PlanRow({ step }: { step: PlanStep }) {\n  return (\n    <li className='flex h-7 items-center gap-2.5 text-[13px]'>\n      <span className='flex size-[18px] shrink-0 items-center justify-center'>\n        <Swap swapKey={step.status}>\n          <StepGlyph status={step.status} />\n        </Swap>\n      </span>\n      <span\n        className={cn(\n          'min-w-0 flex-1 truncate transition-colors duration-200',\n          stepInkOf(step.status)\n        )}\n      >\n        <span className='sr-only'>{STEP_WORD[step.status]}: </span>\n        {step.title}\n      </span>\n    </li>\n  );\n}\n\ntype CallRowProps = {\n  call: ToolCall;\n  task: RunTask;\n};\n\n/** What the call found unfolds under it once it is done. The time sits in a box of its own width. */\nfunction CallRow({ call, task }: CallRowProps) {\n  const isRunning = call.status === 'running';\n  const isDone = call.status === 'done';\n  const hasStarted = call.startedAt !== undefined;\n\n  return (\n    <li className='flex items-start gap-2.5'>\n      <BrandTile brand={task.tool.brand} size='lg' />\n      <div className='flex min-w-0 flex-1 flex-col'>\n        <p className='py-1 text-[13px] leading-5 text-pretty'>{call.label}</p>\n        <Fold open={isDone}>\n          <p className='text-muted-foreground pb-0.5 text-xs text-pretty'>\n            {task.task.finding}\n          </p>\n        </Fold>\n      </div>\n      <span className='flex h-7 shrink-0 items-center gap-2'>\n        <span className={DURATION}>\n          {hasStarted && <LiveDuration item={call} isRunning={isRunning} />}\n        </span>\n        <CallStatusMark status={call.status} />\n      </span>\n    </li>\n  );\n}\n\ntype ResultCardProps = {\n  run: Run;\n  onRunAgain: () => void;\n};\n\nfunction ResultCard({ run, onRunAgain }: ResultCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.section\n      aria-label='Result of the first run'\n      initial={landingOf(shouldReduceMotion)}\n      animate={landedOf(shouldReduceMotion)}\n      exit={LEAVE}\n      transition={LAND}\n      className='bg-success/10 flex flex-col gap-2 rounded-lg p-3.5'\n    >\n      <div className='flex items-center gap-2'>\n        <CircleCheckIcon className='text-success-foreground size-4 shrink-0' />\n        <h3 className='min-w-0 flex-1 truncate text-[13px] font-medium'>\n          First job done\n        </h3>\n        <Button\n          type='button'\n          variant='ghost'\n          size='sm'\n          data-run-again\n          onClick={onRunAgain}\n          className='-my-1 -me-1.5'\n        >\n          <RotateCcwIcon />\n          Run again\n        </Button>\n      </div>\n      <p className='text-[13px] leading-relaxed text-pretty'>{resultOf(run)}</p>\n    </motion.section>\n  );\n}\n\nexport type FirstRunProps = {\n  run: Run;\n  agentName: string;\n  model: ModelId;\n  onRunAgain: () => void;\n};\n\n/**\n * The first job of the agent as it happens: the plan ticks, two tools are called and the result\n * lands under them. The tray wears the ink of a run in progress while it lasts.\n */\nexport function FirstRun({ run, agentName, model, onRunAgain }: FirstRunProps) {\n  const isDone = isRunDone(run);\n  const isRunning = !isDone;\n  const plan = planOf(run);\n  const calls = callsOf(run);\n  const tasks = tasksOf(run.tools);\n  const picked = modelOf(model);\n  const runWord = runWordOf(isDone);\n\n  return (\n    <div className='flex flex-col gap-3'>\n      <div className='bg-foreground/[0.04] relative isolate flex flex-col gap-3 rounded-lg p-3'>\n        <Wash color='var(--info)' isShown={isRunning} />\n        <div className='flex items-center gap-2.5'>\n          <MeshTile\n            seed={AGENT_SEED}\n            color={seriesColorOf(AGENT_SERIES)}\n            size='lg'\n          />\n          <div className='flex min-w-0 flex-1 flex-col'>\n            <p className='truncate text-[13px] font-medium'>\n              {agentName.trim()}\n            </p>\n            <p className='text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs'>\n              <BrandTile brand={picked.brand} size='sm' />\n              <span className='truncate'>{picked.name}</span>\n            </p>\n          </div>\n          <div className='flex shrink-0 flex-col items-end text-xs'>\n            <Swap swapKey={runWord} className='font-medium'>\n              {runWord}\n            </Swap>\n            <LiveDuration\n              item={runTimesOf(run)}\n              isRunning={isRunning}\n              className='text-muted-foreground w-12 text-end'\n            />\n          </div>\n        </div>\n        <ol aria-label='Plan' className='flex flex-col'>\n          {plan.map((step) => (\n            <PlanRow key={step.id} step={step} />\n          ))}\n        </ol>\n        <ul aria-label='Tool calls' className='flex flex-col gap-2'>\n          {calls.map((call, index) => (\n            <CallRow key={call.id} call={call} task={tasks[index]} />\n          ))}\n        </ul>\n      </div>\n      <AnimatePresence initial={false}>\n        {isDone && (\n          <ResultCard key={run.startedAt} run={run} onRunAgain={onRunAgain} />\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/first-run.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/use-run-clock.ts",
      "content": "'use client';\n\nimport { useEffect, useRef } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\n\nimport { isRunDone, TICK_DELAYS_MS, type Run } from './run';\n\ntype Pending = {\n  key: string;\n  remaining: number;\n  scheduledAt: number;\n};\n\n/** A run and the moment it waits for: a new run or a new moment starts a new wait. */\nfunction waitKeyOf(run: Run | null) {\n  if (!run) {\n    return '';\n  }\n  return `${run.startedAt}:${run.tick}`;\n}\n\nfunction delayOf(run: Run | null) {\n  if (!run) {\n    return 0;\n  }\n  return TICK_DELAYS_MS[run.tick] ?? 0;\n}\n\nfunction hasMomentsLeft(run: Run | null) {\n  if (!run) {\n    return false;\n  }\n  return !isRunDone(run);\n}\n\nfunction remainingOf(saved: Pending | null, key: string, delay: number) {\n  if (saved?.key === key) {\n    return saved.remaining;\n  }\n  return delay;\n}\n\n/**\n * Plays a first run one moment at a time, for the demonstration and for a person alike: it asks for\n * the next moment once the one before had its time. Off screen and in a hidden tab it keeps what\n * was left of the wait, so a run never moves while nobody looks.\n */\nexport function useRunClock(\n  run: Run | null,\n  isOnScreen: boolean,\n  onTick: () => void\n) {\n  const isVisible = useDocumentVisible();\n  const pending = useRef<Pending | null>(null);\n  const key = waitKeyOf(run);\n  const delay = delayOf(run);\n  const isDue = hasMomentsLeft(run);\n  const isPlaying = isOnScreen && isVisible && isDue;\n\n  useEffect(() => {\n    if (!isPlaying) {\n      return;\n    }\n    const remaining = remainingOf(pending.current, key, delay);\n    pending.current = { key, remaining, scheduledAt: Date.now() };\n    const timer = setTimeout(() => {\n      pending.current = null;\n      onTick();\n    }, remaining);\n    return () => {\n      clearTimeout(timer);\n      const saved = pending.current;\n      if (!saved) {\n        return;\n      }\n      const spent = Date.now() - saved.scheduledAt;\n      const left = Math.max(0, saved.remaining - spent);\n      pending.current = { ...saved, remaining: left };\n    };\n  }, [isPlaying, key, delay, onTick]);\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/use-run-clock.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/run.ts",
      "content": "import type {\n  CallStatus,\n  PlanStep,\n  StepStatus,\n  ToolCall,\n} from '@/registry/ndeko/lib/agent-run';\n\nimport { toolOf, type Tool, type ToolId, type ToolTask } from './data';\n\n/**\n * A first run as a short film of five moments. A moment starts or ends a step of the plan or a\n * call to a tool; what is on screen is worked out from how many moments have passed and when.\n */\nexport type Run = {\n  /** The tools the run works with: the first two that are connected. */\n  tools: ToolId[];\n  startedAt: number;\n  /** How many moments the run has been through. */\n  tick: number;\n  /** When each moment happened. */\n  stamps: number[];\n};\n\nexport const RUN_TICKS = 5;\n\n/** The wait before each moment, the first one included. */\nexport const TICK_DELAYS_MS = [700, 1100, 1500, 1400, 1600];\n\nfunction sumOf(values: number[]) {\n  let total = 0;\n  for (const value of values) {\n    total += value;\n  }\n  return total;\n}\n\nexport const RUN_MS = sumOf(TICK_DELAYS_MS);\n\n/** The moment something starts at and the moment it ends at. */\ntype Span = {\n  from: number;\n  to: number;\n};\n\nconst PLAN_SPANS: Span[] = [\n  { from: 1, to: 2 },\n  { from: 2, to: 4 },\n  { from: 4, to: 5 },\n];\n\nconst CALL_SPANS: Span[] = [\n  { from: 2, to: 3 },\n  { from: 3, to: 4 },\n];\n\nexport function newRun(tools: ToolId[], now: number): Run {\n  return { tools, startedAt: now, tick: 0, stamps: [] };\n}\n\nexport function isRunDone(run: Run) {\n  return run.tick >= RUN_TICKS;\n}\n\nexport function tickedRun(run: Run, now: number): Run {\n  if (isRunDone(run)) {\n    return run;\n  }\n  return { ...run, tick: run.tick + 1, stamps: [...run.stamps, now] };\n}\n\nfunction hasReached(run: Run, moment: number) {\n  return run.tick >= moment;\n}\n\nfunction stepStatusOf(run: Run, span: Span): StepStatus {\n  if (hasReached(run, span.to)) {\n    return 'done';\n  }\n  if (hasReached(run, span.from)) {\n    return 'running';\n  }\n  return 'upcoming';\n}\n\nfunction callStatusOf(run: Run, span: Span): CallStatus {\n  if (hasReached(run, span.to)) {\n    return 'done';\n  }\n  if (hasReached(run, span.from)) {\n    return 'running';\n  }\n  return 'queued';\n}\n\n/** Moments are counted from one, their times are kept from zero. A moment not reached yet has no time. */\nfunction timesOf(run: Run, span: Span) {\n  return {\n    startedAt: run.stamps[span.from - 1],\n    endedAt: run.stamps[span.to - 1],\n  };\n}\n\nexport type RunTask = {\n  tool: Tool;\n  task: ToolTask;\n};\n\n/** Two things to do: one in each of two tools, or two in the same one when it is the only one. */\nexport function tasksOf(tools: ToolId[]): RunTask[] {\n  const [firstId, secondId] = tools;\n  if (firstId === undefined) {\n    return [];\n  }\n  const first = toolOf(firstId);\n  if (secondId === undefined) {\n    return [\n      { tool: first, task: first.tasks[0] },\n      { tool: first, task: first.tasks[1] },\n    ];\n  }\n  const second = toolOf(secondId);\n  return [\n    { tool: first, task: first.tasks[0] },\n    { tool: second, task: second.tasks[0] },\n  ];\n}\n\n/** Linear and GitHub, or Linear when both tasks are in it. */\nexport function toolNamesOf(tools: ToolId[]) {\n  const names = tools.map((id) => toolOf(id).name);\n  return names.join(' and ');\n}\n\nconst PLAN_IDS = ['read', 'gather', 'write'];\n\nfunction planTitlesOf(run: Run) {\n  return [\n    'Read the job',\n    `Gather from ${toolNamesOf(run.tools)}`,\n    'Write the summary',\n  ];\n}\n\nexport function planOf(run: Run): PlanStep[] {\n  const titles = planTitlesOf(run);\n  return PLAN_SPANS.map((span, index) => ({\n    id: PLAN_IDS[index],\n    title: titles[index],\n    status: stepStatusOf(run, span),\n    ...timesOf(run, span),\n  }));\n}\n\nexport function callsOf(run: Run): ToolCall[] {\n  const tasks = tasksOf(run.tools);\n  return tasks.map((entry, index) => {\n    const span = CALL_SPANS[index];\n    return {\n      id: `call-${index}`,\n      tool: entry.tool.id,\n      label: entry.task.label,\n      status: callStatusOf(run, span),\n      output: entry.task.finding,\n      ...timesOf(run, span),\n    };\n  });\n}\n\n/** What the agent hands back: where it looked, then what it found there. */\nexport function resultOf(run: Run) {\n  const tasks = tasksOf(run.tools);\n  const findings = tasks.map((entry) => `${entry.task.finding}.`);\n  const sentences = [`Looked at ${toolNamesOf(run.tools)}.`, ...findings];\n  return sentences.join(' ');\n}\n\n/** The run from its start to its last moment, for the clock that times it. */\nexport function runTimesOf(run: Run) {\n  return {\n    startedAt: run.startedAt,\n    endedAt: run.stamps[RUN_TICKS - 1],\n  };\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/run.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/invites.ts",
      "content": "const SEPARATORS = /[\\s,;]+/;\n\n/** A space, a comma or a semicolon ends an address as it is typed. */\nexport const ENDS_AN_ADDRESS = /[\\s,;]$/;\n\n/**\n * One @ with something before it, and a dot inside what follows. Read by hand, piece by piece,\n * so a long pasted text can never make the check slow.\n */\nfunction isEmail(text: string) {\n  const at = text.indexOf('@');\n  const hasOneAt = at > 0 && at === text.lastIndexOf('@');\n  if (!hasOneAt) {\n    return false;\n  }\n  const domain = text.slice(at + 1);\n  const dot = domain.lastIndexOf('.');\n  const lastPlace = domain.length - 1;\n  return dot > 0 && dot < lastPlace;\n}\n\nexport type Committed = {\n  invites: string[];\n  /** What could not be read as an address stays in the box. */\n  draft: string;\n  error?: string;\n};\n\nfunction notAnAddressLineOf(rejected: string[]) {\n  const [first] = rejected;\n  if (rejected.length === 1) {\n    return `${first} is not an email address`;\n  }\n  return `${first} and ${rejected.length - 1} more are not email addresses`;\n}\n\n/**\n * Turns what the address box holds into addresses: several can be pasted at once, separated by\n * spaces, commas or semicolons. One that is already invited is not added twice.\n */\nexport function committedInvites(current: string[], draft: string): Committed {\n  const pieces = draft.split(SEPARATORS);\n  const typed = pieces.filter((piece) => piece !== '');\n  const invites = [...current];\n  const rejected: string[] = [];\n  for (const piece of typed) {\n    const address = piece.toLowerCase();\n    if (!isEmail(address)) {\n      rejected.push(piece);\n      continue;\n    }\n    if (!invites.includes(address)) {\n      invites.push(address);\n    }\n  }\n  if (rejected.length === 0) {\n    return { invites, draft: '' };\n  }\n  return {\n    invites,\n    draft: rejected.join(' '),\n    error: notAnAddressLineOf(rejected),\n  };\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/invites.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/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';\n\nimport {\n  indexOfPhase,\n  modelOf,\n  phaseOf,\n  PHASES,\n  toolOf,\n  TOOLS,\n  type ModelId,\n  type PhaseId,\n  type ToolId,\n} from './data';\nimport { committedInvites } from './invites';\nimport {\n  isRunDone,\n  newRun,\n  resultOf,\n  RUN_MS,\n  tickedRun,\n  TICK_DELAYS_MS,\n  type Run,\n} from './run';\n\nexport type ConnectStatus = 'idle' | 'connecting' | 'connected';\n\n/** What a hint is about, which is also where the focus goes when an entry is refused. */\nexport type HintField = 'tools' | 'invites' | 'agentName' | 'job';\n\nexport type Hint = {\n  field: HintField;\n  message: string;\n};\n\nexport type TextField = 'inviteDraft' | 'agentName' | 'job';\n\nexport type WorkspaceState = {\n  phase: PhaseId;\n  tools: Record<ToolId, ConnectStatus>;\n  invites: string[];\n  /** What the address box holds before it becomes a chip. */\n  inviteDraft: string;\n  agentName: string;\n  model: ModelId;\n  job: string;\n  hint: Hint | null;\n  /** Counts the refused entries, so a hint that comes back arrives again. */\n  attempts: number;\n  /** Counts the changes of step. The first step is there when the page loads; the next ones fade in. */\n  moves: number;\n  run: Run | null;\n  spoken: string;\n};\n\nexport type WorkspaceAction =\n  | { type: 'connectPressed'; tool: ToolId }\n  | { type: 'connected'; tool: ToolId }\n  | { type: 'disconnected'; tool: ToolId }\n  | { type: 'typed'; field: TextField; value: string }\n  | { type: 'inviteCommitted' }\n  | { type: 'inviteRemoved'; address: string }\n  | { type: 'modelPicked'; model: ModelId }\n  | { type: 'continued' }\n  | { type: 'edited'; phase: PhaseId }\n  | { type: 'runTicked' }\n  | { type: 'ranAgain' };\n\ntype Step = SessionStep<WorkspaceState, WorkspaceAction>;\n\nexport const TOTAL = PHASES.length;\n\nexport const INITIAL: WorkspaceState = {\n  phase: 'tools',\n  tools: {\n    notion: 'idle',\n    linear: 'idle',\n    github: 'idle',\n    googledrive: 'idle',\n  },\n  invites: [],\n  inviteDraft: '',\n  agentName: '',\n  model: 'claude',\n  job: '',\n  hint: null,\n  attempts: 0,\n  moves: 0,\n  run: null,\n  spoken: '',\n};\n\nexport function connectedToolsOf(state: WorkspaceState) {\n  const connected = TOOLS.filter(\n    (tool) => state.tools[tool.id] === 'connected'\n  );\n  return connected.map((tool) => tool.id);\n}\n\nfunction isConnecting(state: WorkspaceState) {\n  return TOOLS.some((tool) => state.tools[tool.id] === 'connecting');\n}\n\nfunction withTool(\n  state: WorkspaceState,\n  tool: ToolId,\n  status: ConnectStatus\n): WorkspaceState {\n  return { ...state, tools: { ...state.tools, [tool]: status } };\n}\n\nfunction hintCleared(state: WorkspaceState, field: HintField): WorkspaceState {\n  if (state.hint?.field !== field) {\n    return state;\n  }\n  return { ...state, hint: null };\n}\n\nfunction connectPressed(state: WorkspaceState, tool: ToolId): WorkspaceState {\n  if (state.tools[tool] !== 'idle') {\n    return state;\n  }\n  const next = withTool(state, tool, 'connecting');\n  return hintCleared(next, 'tools');\n}\n\nfunction connected(state: WorkspaceState, tool: ToolId): WorkspaceState {\n  if (state.tools[tool] !== 'connecting') {\n    return state;\n  }\n  const next = withTool(state, tool, 'connected');\n  const cleared = hintCleared(next, 'tools');\n  const name = toolOf(tool).name;\n  return { ...cleared, spoken: `${name} connected` };\n}\n\nfunction disconnected(state: WorkspaceState, tool: ToolId): WorkspaceState {\n  if (state.tools[tool] !== 'connected') {\n    return state;\n  }\n  const next = withTool(state, tool, 'idle');\n  return { ...next, spoken: `${toolOf(tool).name} disconnected` };\n}\n\nconst HINT_OF_FIELD: Record<TextField, HintField> = {\n  inviteDraft: 'invites',\n  agentName: 'agentName',\n  job: 'job',\n};\n\nfunction typed(\n  state: WorkspaceState,\n  field: TextField,\n  value: string\n): WorkspaceState {\n  const next = { ...state, [field]: value };\n  return hintCleared(next, HINT_OF_FIELD[field]);\n}\n\nfunction refused(state: WorkspaceState, hint: Hint): WorkspaceState {\n  return {\n    ...state,\n    hint,\n    attempts: state.attempts + 1,\n    spoken: hint.message,\n  };\n}\n\n/** What the address box holds becomes addresses. What cannot be one stays in the box, with the reason. */\nfunction inviteCommitted(state: WorkspaceState): WorkspaceState {\n  const committed = committedInvites(state.invites, state.inviteDraft);\n  const next = {\n    ...state,\n    invites: committed.invites,\n    inviteDraft: committed.draft,\n  };\n  if (committed.error !== undefined) {\n    return refused(next, { field: 'invites', message: committed.error });\n  }\n  return hintCleared(next, 'invites');\n}\n\nfunction inviteRemoved(state: WorkspaceState, address: string): WorkspaceState {\n  const invites = state.invites.filter((candidate) => candidate !== address);\n  return { ...state, invites };\n}\n\nfunction entered(state: WorkspaceState, phase: PhaseId): WorkspaceState {\n  const index = indexOfPhase(phase);\n  const title = phaseOf(phase).title;\n  return {\n    ...state,\n    phase,\n    hint: null,\n    moves: state.moves + 1,\n    spoken: `Step ${index + 1} of ${TOTAL}: ${title}`,\n  };\n}\n\nfunction toolsContinued(state: WorkspaceState): WorkspaceState {\n  if (isConnecting(state)) {\n    const message = 'Wait for the connection to finish';\n    return refused(state, { field: 'tools', message });\n  }\n  const connectedTools = connectedToolsOf(state);\n  if (connectedTools.length === 0) {\n    const message = 'Connect at least one tool to continue';\n    return refused(state, { field: 'tools', message });\n  }\n  return entered(state, 'team');\n}\n\n/** An address still in the box is read first, so nobody has to press Add before Continue. */\nfunction teamContinued(state: WorkspaceState): WorkspaceState {\n  const committed = inviteCommitted(state);\n  const hasBadAddress = committed.hint?.field === 'invites';\n  if (hasBadAddress) {\n    return committed;\n  }\n  if (committed.invites.length === 0) {\n    const message = 'Add at least one address to continue';\n    return refused(committed, { field: 'invites', message });\n  }\n  return entered(committed, 'agent');\n}\n\n/** The agent is created and starts its first job at once, with the first two tools that are connected. */\nfunction agentContinued(state: WorkspaceState, now: number): WorkspaceState {\n  if (state.agentName.trim() === '') {\n    const message = 'Give the agent a name';\n    return refused(state, { field: 'agentName', message });\n  }\n  if (state.job.trim() === '') {\n    const message = 'Say what its job is, in one sentence';\n    return refused(state, { field: 'job', message });\n  }\n  const connected = connectedToolsOf(state);\n  const tools = connected.slice(0, 2);\n  const next = entered(state, 'watch');\n  const model = modelOf(state.model).name;\n  const name = state.agentName.trim();\n  const spoken = `${name} is created on ${model} and starts its first job`;\n  return { ...next, run: newRun(tools, now), spoken };\n}\n\nfunction continued(state: WorkspaceState, now: number): WorkspaceState {\n  if (state.phase === 'tools') {\n    return toolsContinued(state);\n  }\n  if (state.phase === 'team') {\n    return teamContinued(state);\n  }\n  if (state.phase === 'agent') {\n    return agentContinued(state, now);\n  }\n  return state;\n}\n\n/** Edit goes back to a step that is done. The first run belongs to the agent as it was: it leaves. */\nfunction edited(state: WorkspaceState, phase: PhaseId): WorkspaceState {\n  const isBehind = indexOfPhase(phase) < indexOfPhase(state.phase);\n  if (!isBehind) {\n    return state;\n  }\n  return entered({ ...state, run: null }, phase);\n}\n\nfunction runTicked(state: WorkspaceState, now: number): WorkspaceState {\n  const run = state.run;\n  if (!run || isRunDone(run)) {\n    return state;\n  }\n  const next = tickedRun(run, now);\n  if (!isRunDone(next)) {\n    return { ...state, run: next };\n  }\n  return { ...state, run: next, spoken: `First run done. ${resultOf(next)}` };\n}\n\nfunction ranAgain(state: WorkspaceState, now: number): WorkspaceState {\n  const run = state.run;\n  if (!run || !isRunDone(run)) {\n    return state;\n  }\n  const again = newRun(run.tools, now);\n  return { ...state, run: again, spoken: 'The run starts again' };\n}\n\nexport function applyAt(\n  state: WorkspaceState,\n  action: WorkspaceAction,\n  now: number\n): WorkspaceState {\n  switch (action.type) {\n    case 'connectPressed':\n      return connectPressed(state, action.tool);\n    case 'connected':\n      return connected(state, action.tool);\n    case 'disconnected':\n      return disconnected(state, action.tool);\n    case 'typed':\n      return typed(state, action.field, action.value);\n    case 'inviteCommitted':\n      return inviteCommitted(state);\n    case 'inviteRemoved':\n      return inviteRemoved(state, action.address);\n    case 'modelPicked':\n      return { ...state, model: action.model };\n    case 'continued':\n      return continued(state, now);\n    case 'edited':\n      return edited(state, action.phase);\n    case 'runTicked':\n      return runTicked(state, now);\n    case 'ranAgain':\n      return ranAgain(state, now);\n  }\n}\n\n/** Times are stamped when an action lands, as a backend would stream them. */\nexport function reducer(state: WorkspaceState, action: WorkspaceAction) {\n  return applyAt(state, action, Date.now());\n}\n\n/** How long a tool takes to connect. */\nexport const CONNECT_MS = 1100;\n\nconst KEY_MS = 34;\n\nconst FIRST_ADDRESS = 'ines@solwaybooks.example';\n\nconst SECOND_ADDRESS = 'tomas@solwaybooks.example';\n\nconst AGENT_NAME = 'Morning digest';\n\nconst JOB = 'Tell the team what changed overnight';\n\nfunction typingSteps(\n  field: TextField,\n  text: string,\n  startAfter: number\n): Step[] {\n  const prefixes = prefixesOf(text);\n  return prefixes.map((value, index) => ({\n    after: keyDelayOf(index, startAfter, KEY_MS),\n    by: 'demo',\n    action: { type: 'typed', field, value },\n  }));\n}\n\n/** The demonstration presses Connect; the tool then connects on its own, whoever pressed. */\nfunction connects(after: number, tool: ToolId): Step[] {\n  return [\n    {\n      after,\n      by: 'demo',\n      press: `connect-${tool}`,\n      action: { type: 'connectPressed', tool },\n    },\n    { after: CONNECT_MS, action: { type: 'connected', tool } },\n  ];\n}\n\nfunction continues(after: number): Step {\n  return {\n    after,\n    by: 'demo',\n    press: 'continue',\n    action: { type: 'continued' },\n  };\n}\n\nfunction adds(after: number): Step {\n  return {\n    after,\n    by: 'demo',\n    press: 'add-invite',\n    action: { type: 'inviteCommitted' },\n  };\n}\n\n/**\n * A person does every step, so they are the demonstration's: two tools are connected, two people\n * are invited, the agent gets its name and its job and is created. The first run that follows is\n * not in the script: it plays from its own clock, for the demonstration and for a person alike.\n */\nexport const SCRIPT: Step[] = [\n  ...connects(1300, 'linear'),\n  ...connects(700, 'github'),\n  continues(900),\n  ...typingSteps('inviteDraft', FIRST_ADDRESS, 900),\n  adds(350),\n  ...typingSteps('inviteDraft', SECOND_ADDRESS, 500),\n  adds(350),\n  continues(800),\n  ...typingSteps('agentName', AGENT_NAME, 900),\n  ...typingSteps('job', JOB, 600),\n  continues(800),\n];\n\n/** The script ends as the first run starts. The run is then taken through its five moments. */\nfunction finishedOf(state: WorkspaceState) {\n  let finished = state;\n  let now = state.run?.startedAt ?? 0;\n  for (const delay of TICK_DELAYS_MS) {\n    now += delay;\n    finished = applyAt(finished, { type: 'runTicked' }, now);\n  }\n  return finished;\n}\n\nconst CREATED = restingOf(INITIAL, SCRIPT, applyAt);\n\n/** Under reduced motion the three steps are done and the first run has ended on its result. */\nexport const RESTING: WorkspaceState = { ...finishedOf(CREATED), spoken: '' };\n\n/** A round ends once the first run has played and its result has been left to read. */\nexport const LOOP_AFTER_MS = RUN_MS + 4200;\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-03/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\n/** An invented workspace on its first day. */\nexport const WORKSPACE = { name: 'Solway Books' };\n\nexport type PhaseId = 'tools' | 'team' | 'agent' | 'watch';\n\nexport type Phase = {\n  id: PhaseId;\n  /** The name of the step in its summary row. */\n  label: string;\n  /** The heading of the step, which takes the focus when the step opens. */\n  title: string;\n  lead: string;\n};\n\nexport const PHASES: Phase[] = [\n  {\n    id: 'tools',\n    label: 'Tools',\n    title: 'Connect your tools',\n    lead: 'An agent only reads what you connect. One tool is enough to start',\n  },\n  {\n    id: 'team',\n    label: 'Team',\n    title: 'Invite your team',\n    lead: 'They see what the agent does and can approve what it asks for',\n  },\n  {\n    id: 'agent',\n    label: 'Agent',\n    title: 'Create your first agent',\n    lead: 'A name, a model and one job, said in a sentence',\n  },\n  {\n    id: 'watch',\n    label: 'First run',\n    title: 'Watch it do its first job',\n    lead: 'It works with the tools you connected. Nothing is changed in them',\n  },\n];\n\nexport function phaseOf(id: PhaseId) {\n  const phase = PHASES.find((candidate) => candidate.id === id);\n  return phase ?? PHASES[0];\n}\n\nexport function indexOfPhase(id: PhaseId) {\n  return PHASES.findIndex((candidate) => candidate.id === id);\n}\n\nexport type ToolId = 'notion' | 'linear' | 'github' | 'googledrive';\n\n/** What an agent does in a tool, said in plain words, and what it finds in this invented workspace. */\nexport type ToolTask = {\n  label: string;\n  finding: string;\n};\n\nexport type Tool = {\n  id: ToolId;\n  name: string;\n  brand: BrandSlug;\n  shares: string;\n  /** The first task is the one a run starts with. The second is used when no other tool is connected. */\n  tasks: [ToolTask, ToolTask];\n};\n\n/** Known products, under their own name and mark. The findings are invented and belong to the sample workspace. */\nexport const TOOLS: Tool[] = [\n  {\n    id: 'notion',\n    name: 'Notion',\n    brand: 'notion',\n    shares: 'Pages and databases',\n    tasks: [\n      {\n        label: 'Find the pages edited since yesterday',\n        finding: '3 pages were edited since yesterday',\n      },\n      {\n        label: 'Read the launch notes',\n        finding: 'The launch notes gained 2 open questions',\n      },\n    ],\n  },\n  {\n    id: 'linear',\n    name: 'Linear',\n    brand: 'linear',\n    shares: 'Issues and projects',\n    tasks: [\n      {\n        label: 'List the open issues',\n        finding: '12 issues are open, 3 of them due this week',\n      },\n      {\n        label: 'Read the issues due this week',\n        finding: '2 of the 3 issues due this week have no owner',\n      },\n    ],\n  },\n  {\n    id: 'github',\n    name: 'GitHub',\n    brand: 'github',\n    shares: 'Repositories and pull requests',\n    tasks: [\n      {\n        label: 'List the pull requests waiting for review',\n        finding: '4 pull requests wait for a review',\n      },\n      {\n        label: 'Read the oldest pull request',\n        finding: 'The oldest one has been open for 6 days',\n      },\n    ],\n  },\n  {\n    id: 'googledrive',\n    name: 'Google Drive',\n    brand: 'googledrive',\n    shares: 'Files and folders',\n    tasks: [\n      {\n        label: 'Find the files changed since yesterday',\n        finding: '5 files changed since yesterday',\n      },\n      {\n        label: 'Read the planning sheet',\n        finding: 'The planning sheet has 14 new rows',\n      },\n    ],\n  },\n];\n\nexport function toolOf(id: ToolId) {\n  const tool = TOOLS.find((candidate) => candidate.id === id);\n  return tool ?? TOOLS[0];\n}\n\nexport type ModelId = 'claude' | 'gpt' | 'gemini';\n\nexport type Model = {\n  id: ModelId;\n  /** The name of the model family, without a version. */\n  name: string;\n  maker: string;\n  brand: BrandSlug;\n};\n\nexport const MODELS: Model[] = [\n  { id: 'claude', name: 'Claude', maker: 'Anthropic', brand: 'claude' },\n  { id: 'gpt', name: 'GPT', maker: 'OpenAI', brand: 'openai' },\n  { id: 'gemini', name: 'Gemini', maker: 'Google', brand: 'gemini' },\n];\n\nexport function modelOf(id: ModelId) {\n  const model = MODELS.find((candidate) => candidate.id === id);\n  return model ?? MODELS[0];\n}\n\n/** The picture of the first agent is drawn from this, not from its name, which a person can change. */\nexport const AGENT_SEED = 'first-agent';\n\nexport const AGENT_SERIES: SeriesSlot = 1;\n\nexport const JOB_MAX_LENGTH = 120;\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "onboarding"
  ],
  "type": "registry:block"
}