{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-chat-03",
  "title": "Agent canvas",
  "description": "Someone says what should happen, the assistant checks off its work in the chat and three cards type their own fields on a canvas, one after the other, until Run it becomes Live.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chip.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/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/streamed-text.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-03/index.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\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 {\n  ArrowUpIcon,\n  FeatherIcon,\n  LoaderIcon,\n  PlayIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { CanvasCard, type CardStatus } from './cards';\nimport {\n  CARD_ORDER,\n  CHECK_LABELS,\n  LIVE_LINE,\n  PROMPT,\n  READY_LINE,\n  type FieldId,\n} from './data';\nimport {\n  GO_LIVE_MS,\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  type CheckStatus,\n  type LiveStatus,\n} from './session';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nconst RUN_LABELS: Record<MorphState, string> = {\n  idle: 'Run it',\n  busy: 'Going live',\n  done: 'Live',\n};\n\nfunction CheckGlyph({ status }: { status: CheckStatus }) {\n  if (status === 'done') {\n    return <DrawnCheck entrance='draw' />;\n  }\n  return <LoaderIcon className='text-primary-ink size-4 animate-spin' />;\n}\n\nconst CHECK_WORD: Record<CheckStatus, string> = {\n  upcoming: 'Upcoming',\n  running: 'In progress',\n  done: 'Done',\n};\n\nfunction morphStateOf(live: LiveStatus): MorphState {\n  if (live === 'busy') {\n    return 'busy';\n  }\n  if (live === 'done') {\n    return 'done';\n  }\n  return 'idle';\n}\n\nfunction cardStatusOf(\n  index: number,\n  cardsReady: number,\n  live: LiveStatus\n): CardStatus {\n  const isReady = index < cardsReady;\n  if (!isReady) {\n    return 'writing';\n  }\n  if (live === 'done') {\n    return 'live';\n  }\n  return 'draft';\n}\n\nfunction closingLineOf(cardsReady: number, live: LiveStatus) {\n  if (live === 'done') {\n    return LIVE_LINE;\n  }\n  if (cardsReady === 3) {\n    return READY_LINE;\n  }\n  return null;\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 AssistantTile() {\n  return (\n    <span\n      aria-hidden='true'\n      className='gem-plate inline-flex size-7 shrink-0 items-center justify-center rounded-lg [--gem:var(--primary)]'\n    >\n      <FeatherIcon className='size-4' />\n    </span>\n  );\n}\n\nexport default function AgentChat03() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule } = useTimeouts();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const hasAsked = state.ask !== null;\n  const visibleChecks = CHECK_LABELS.filter(\n    (_, index) => state.checks[index] !== 'upcoming'\n  );\n  const cards = CARD_ORDER.slice(0, state.cardsShown);\n  const hasCards = cards.length > 0;\n  const isDrafted = state.cardsReady === 3;\n  const isLocked = state.live !== 'idle';\n  const closingLine = closingLineOf(state.cardsReady, state.live);\n  const message = spokenUnless(isAutoplaying, closingLine ?? '');\n  const canReplay = isFinished && !isAutoplaying;\n\n  function send() {\n    act({ type: 'sent' });\n  }\n\n  function handleKeys(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n    if (!isSendKey(event)) {\n      return;\n    }\n    event.preventDefault();\n    send();\n  }\n\n  function runRule() {\n    act({ type: 'run' });\n    schedule(() => act({ type: 'live' }), GO_LIVE_MS);\n  }\n\n  function edit(id: FieldId, text: string) {\n    act({ type: 'edited', id, text });\n  }\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container min-h-dvh w-full p-3 @3xl:p-6'\n      >\n        <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.02] mx-auto flex max-w-5xl flex-col rounded-2xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <header className='flex h-12 items-center gap-2.5 px-3'>\n            <AssistantTile />\n            <h2 className='text-sm font-medium'>Assistant</h2>\n            <Badge variant='secondary'>Support automations</Badge>\n            <span className='ms-auto'>\n              <ReplayButton isShown={canReplay} onReplay={restart} />\n            </span>\n          </header>\n\n          <div className='flex flex-col gap-3 p-3 pt-0 @3xl:min-h-[34rem] @3xl:flex-row'>\n            <section\n              aria-label='Conversation'\n              className='flex min-w-0 flex-col gap-3 @3xl:w-80 @3xl:shrink-0'\n            >\n              <div className='flex min-h-40 flex-1 flex-col gap-3 px-1 py-2'>\n                {!hasAsked && (\n                  <div className='m-auto flex max-w-xs flex-col items-center gap-3 text-center'>\n                    <p className='text-muted-foreground text-[13px]'>\n                      Say what should happen. The rule, the issue and the post\n                      are drafted on the canvas.\n                    </p>\n                    <Button\n                      type='button'\n                      variant='outline'\n                      onClick={() => act({ type: 'typed', text: PROMPT })}\n                      className='h-auto max-w-full rounded-xl px-3 py-2 text-start whitespace-normal'\n                    >\n                      {PROMPT}\n                    </Button>\n                  </div>\n                )}\n                {hasAsked && (\n                  <p className='bg-foreground/[0.06] max-w-[90%] self-end rounded-2xl rounded-ee-md px-3.5 py-2 text-sm leading-relaxed'>\n                    {state.ask}\n                  </p>\n                )}\n                <ul\n                  aria-label='What the assistant did'\n                  className='flex flex-col'\n                >\n                  <AnimatePresence initial={false}>\n                    {visibleChecks.map((label) => {\n                      const index = CHECK_LABELS.indexOf(label);\n                      const status = state.checks[index];\n                      return (\n                        <motion.li\n                          key={label}\n                          className='overflow-hidden'\n                          {...rowPresence}\n                        >\n                          <div className='flex h-8 items-center gap-2.5 text-[13px]'>\n                            <span className='flex size-[18px] shrink-0 items-center justify-center'>\n                              <Swap swapKey={status}>\n                                <CheckGlyph status={status} />\n                              </Swap>\n                              <span className='sr-only'>\n                                {CHECK_WORD[status]}\n                              </span>\n                            </span>\n                            {label}\n                          </div>\n                        </motion.li>\n                      );\n                    })}\n                  </AnimatePresence>\n                </ul>\n                <AnimatePresence initial={false} mode='popLayout'>\n                  {closingLine && (\n                    <motion.p\n                      key={closingLine}\n                      initial={{ opacity: 0 }}\n                      animate={{ opacity: 1 }}\n                      exit={{ opacity: 0 }}\n                      transition={{ duration: 0.2 }}\n                      className='text-sm leading-relaxed'\n                    >\n                      {closingLine}\n                    </motion.p>\n                  )}\n                </AnimatePresence>\n              </div>\n\n              <div className='bg-background hairline-ring ring-foreground/12 has-[textarea:focus-visible]:ring-ring/25 dark:bg-foreground/[0.04] dark:ring-foreground/15 flex items-end gap-2 rounded-2xl p-2 transition-[box-shadow] duration-150 has-[textarea:focus-visible]:ring-[3px]'>\n                <textarea\n                  value={state.draft}\n                  rows={2}\n                  aria-label='Message to the assistant'\n                  placeholder='Say what should happen'\n                  onChange={(event) =>\n                    act({ type: 'typed', text: event.target.value })\n                  }\n                  onKeyDown={handleKeys}\n                  className='placeholder:text-muted-foreground/75 min-h-12 flex-1 resize-none bg-transparent px-1.5 py-1 text-base leading-normal outline-none md:text-[13px]'\n                />\n                <Button\n                  type='button'\n                  size='icon'\n                  aria-label='Send the message'\n                  disabled={hasAsked}\n                  onClick={send}\n                  className={pressedSolidOf(pressed === 'send')}\n                >\n                  <ArrowUpIcon />\n                </Button>\n              </div>\n            </section>\n\n            <section\n              aria-label='Canvas'\n              className='bg-foreground/[0.03] flex min-w-0 flex-1 flex-col gap-3 rounded-[calc(var(--radius-2xl)-0.75rem)] p-3'\n            >\n              {!hasCards && (\n                <p className='text-muted-foreground m-auto max-w-xs py-10 text-center text-[13px]'>\n                  The canvas is empty. What the assistant drafts is written\n                  here, card by card.\n                </p>\n              )}\n              <ul className='flex flex-col'>\n                <AnimatePresence initial={false}>\n                  {cards.map((card, index) => (\n                    <motion.li\n                      key={card}\n                      className='-mx-1 overflow-hidden px-1'\n                      {...rowPresence}\n                    >\n                      <div className='py-1.5'>\n                        <CanvasCard\n                          card={card}\n                          status={cardStatusOf(\n                            index,\n                            state.cardsReady,\n                            state.live\n                          )}\n                          isActive={isInView}\n                          fields={state.fields}\n                          isLocked={isLocked}\n                          onEdit={edit}\n                        />\n                      </div>\n                    </motion.li>\n                  ))}\n                </AnimatePresence>\n              </ul>\n              {isDrafted && (\n                <div className='mt-auto flex items-center justify-between gap-3 transition-opacity duration-300 starting:opacity-0'>\n                  <span className='text-muted-foreground text-xs'>\n                    Editable until the rule is live\n                  </span>\n                  <MorphButton\n                    type='button'\n                    state={morphStateOf(state.live)}\n                    labels={RUN_LABELS}\n                    idleIcon={<PlayIcon />}\n                    onClick={runRule}\n                    className={cn(pressedSolidOf(pressed === 'run'))}\n                  />\n                </div>\n              )}\n            </section>\n          </div>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-03/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-03/cards.tsx",
      "content": "'use client';\n\nimport { ZapIcon } from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { useRevealedCount } from '@/registry/ndeko/ui/streamed-text';\n\nimport {\n  CARD_FIELDS,\n  FIELD_TEXT,\n  ISSUE_LABELS,\n  typedLengthOf,\n  WORKSPACE,\n  type CardField,\n  type CardId,\n  type FieldId,\n} from './data';\nimport { TYPE_TICK_MS } from './session';\n\nconst CHARS_PER_TICK = 2;\n\nexport type CardStatus = 'writing' | 'draft' | 'live';\n\nconst STATUS_WORD: Record<CardStatus, string> = {\n  writing: 'Writing',\n  draft: 'Draft',\n  live: 'Live',\n};\n\nfunction badgeVariantOf(status: CardStatus) {\n  if (status === 'live') {\n    return 'success';\n  }\n  return 'secondary';\n}\n\ntype TypedPart = {\n  field: CardField;\n  text: string;\n  isCurrent: boolean;\n};\n\n/** The fields of a card are typed one after the other: each takes its share of the characters typed so far. */\nfunction typedPartsOf(card: CardId, count: number): TypedPart[] {\n  const parts: TypedPart[] = [];\n  let start = 0;\n  for (const field of CARD_FIELDS[card]) {\n    const full = FIELD_TEXT[field.id];\n    const end = start + full.length;\n    const available = Math.max(0, count - start);\n    const text = full.slice(0, available);\n    const hasStarted = count >= start;\n    const isCurrent = hasStarted && count < end;\n    parts.push({ field, text, isCurrent });\n    start = end;\n  }\n  return parts;\n}\n\nfunction Caret() {\n  return (\n    <span\n      aria-hidden='true'\n      className='bg-primary ms-px inline-block h-[1em] w-[2px] animate-pulse rounded-full align-[-0.15em]'\n    />\n  );\n}\n\nfunction FieldLabel({ label }: { label: string }) {\n  return (\n    <span className='text-muted-foreground w-16 shrink-0 text-xs leading-7'>\n      {label}\n    </span>\n  );\n}\n\n/** Only this list re-renders while a card writes itself. */\nfunction TypingFields({ card, isActive }: { card: CardId; isActive: boolean }) {\n  const total = typedLengthOf(card);\n  const count = useRevealedCount(total, isActive, TYPE_TICK_MS, CHARS_PER_TICK);\n  const parts = typedPartsOf(card, count);\n\n  return (\n    <div className='flex flex-col'>\n      {parts.map((part) => (\n        <div key={part.field.id} className='flex min-h-7 gap-3'>\n          <FieldLabel label={part.field.label} />\n          <span className='min-w-0 flex-1 text-[13px] leading-7'>\n            {part.text}\n            {part.isCurrent && <Caret />}\n          </span>\n        </div>\n      ))}\n    </div>\n  );\n}\n\ntype FieldsProps = {\n  card: CardId;\n  fields: Record<FieldId, string>;\n  isLocked: boolean;\n  onEdit: (id: FieldId, text: string) => void;\n};\n\nfunction SettledFields({ card, fields, isLocked, onEdit }: FieldsProps) {\n  return (\n    <div className='flex flex-col'>\n      {CARD_FIELDS[card].map((field) => (\n        <label key={field.id} className='flex min-h-7 gap-3'>\n          <FieldLabel label={field.label} />\n          {isLocked && (\n            <span className='min-w-0 flex-1 text-[13px] leading-7'>\n              {fields[field.id]}\n            </span>\n          )}\n          {!isLocked && (\n            <input\n              value={fields[field.id]}\n              onChange={(event) => onEdit(field.id, event.target.value)}\n              className='hover:bg-foreground/[0.04] focus-visible:bg-card focus-visible:ring-ring/25 -mx-1.5 h-7 min-w-0 flex-1 rounded-md bg-transparent px-1.5 text-base transition-[background-color,box-shadow] duration-150 outline-none focus-visible:ring-[3px] md:text-[13px]'\n            />\n          )}\n        </label>\n      ))}\n    </div>\n  );\n}\n\nfunction CardMark({ card }: { card: CardId }) {\n  if (card === 'issue') {\n    return <BrandTile brand='linear' size='lg' />;\n  }\n  if (card === 'post') {\n    return <CompanyMark seed={WORKSPACE.name} size='lg' />;\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      <ZapIcon className='size-3.5' />\n    </span>\n  );\n}\n\nconst CARD_TITLE: Record<CardId, string> = {\n  rule: 'Automation rule',\n  issue: 'Linear issue',\n  post: WORKSPACE.name,\n};\n\nconst CARD_KIND: Record<CardId, string> = {\n  rule: 'Runs on every new message',\n  issue: 'Opened by the rule',\n  post: 'Posted by the rule',\n};\n\ntype CanvasCardProps = FieldsProps & {\n  status: CardStatus;\n  /** False while the block is off screen: the typing holds. */\n  isActive: boolean;\n};\n\nexport function CanvasCard({\n  card,\n  status,\n  isActive,\n  fields,\n  isLocked,\n  onEdit,\n}: CanvasCardProps) {\n  const isWriting = status === 'writing';\n  const showsLabels = card === 'issue' && !isWriting;\n\n  return (\n    <article className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col gap-3 rounded-xl p-3 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n      <header className='flex items-center gap-2.5'>\n        <CardMark card={card} />\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <h3 className='truncate text-sm font-medium'>{CARD_TITLE[card]}</h3>\n          <span className='text-muted-foreground truncate text-xs'>\n            {CARD_KIND[card]}\n          </span>\n        </div>\n        <Badge variant={badgeVariantOf(status)}>\n          <Swap swapKey={status}>{STATUS_WORD[status]}</Swap>\n        </Badge>\n      </header>\n      {isWriting && <TypingFields card={card} isActive={isActive} />}\n      {!isWriting && (\n        <SettledFields\n          card={card}\n          fields={fields}\n          isLocked={isLocked}\n          onEdit={onEdit}\n        />\n      )}\n      {showsLabels && (\n        <ul aria-label='Labels' className='flex flex-wrap gap-1.5 ps-[4.75rem]'>\n          {ISSUE_LABELS.map((label) => (\n            <li\n              key={label.name}\n              className='transition-[opacity,scale] duration-300 ease-(--ease-out-strong) starting:scale-90 starting:opacity-0'\n            >\n              <Chip color={label.color}>{label.name}</Chip>\n            </li>\n          ))}\n        </ul>\n      )}\n    </article>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-03/cards.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-03/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\n\nimport { FIELD_TEXT, PROMPT, type FieldId } from './data';\n\nexport type CheckStatus = 'upcoming' | 'running' | 'done';\n\nexport type LiveStatus = 'idle' | 'busy' | 'done';\n\nexport type CanvasState = {\n  draft: string;\n  ask: string | null;\n  checks: CheckStatus[];\n  cardsShown: number;\n  cardsReady: number;\n  fields: Record<FieldId, string>;\n  live: LiveStatus;\n};\n\nexport type CanvasAction =\n  | { type: 'typed'; text: string }\n  | { type: 'sent' }\n  | { type: 'check'; index: number; status: CheckStatus }\n  | { type: 'card' }\n  | { type: 'ready' }\n  | { type: 'edited'; id: FieldId; text: string }\n  | { type: 'run' }\n  | { type: 'live' }\n  | { type: 'batch'; actions: CanvasAction[] };\n\ntype Step = SessionStep<CanvasState, CanvasAction>;\n\nexport const INITIAL: CanvasState = {\n  draft: '',\n  ask: null,\n  checks: ['upcoming', 'upcoming', 'upcoming'],\n  cardsShown: 0,\n  cardsReady: 0,\n  fields: FIELD_TEXT,\n  live: 'idle',\n};\n\nfunction askOf(draft: string) {\n  const trimmed = draft.trim();\n  if (trimmed === '') {\n    return PROMPT;\n  }\n  return trimmed;\n}\n\nfunction sent(state: CanvasState): CanvasState {\n  if (state.ask !== null) {\n    return state;\n  }\n  return { ...state, draft: '', ask: askOf(state.draft) };\n}\n\nfunction checked(\n  state: CanvasState,\n  index: number,\n  status: CheckStatus\n): CanvasState {\n  const checks = state.checks.map((current, position) => {\n    if (position === index) {\n      return status;\n    }\n    return current;\n  });\n  return { ...state, checks };\n}\n\nfunction ran(state: CanvasState): CanvasState {\n  const isReady = state.cardsReady === 3;\n  const canRun = isReady && state.live === 'idle';\n  if (!canRun) {\n    return state;\n  }\n  return { ...state, live: 'busy' };\n}\n\nfunction wentLive(state: CanvasState): CanvasState {\n  if (state.live !== 'busy') {\n    return state;\n  }\n  return { ...state, live: 'done' };\n}\n\nexport function reducer(state: CanvasState, action: CanvasAction): CanvasState {\n  switch (action.type) {\n    case 'typed':\n      return { ...state, draft: action.text };\n    case 'sent':\n      return sent(state);\n    case 'check':\n      return checked(state, action.index, action.status);\n    case 'card':\n      return { ...state, cardsShown: state.cardsShown + 1 };\n    case 'ready':\n      return { ...state, cardsReady: state.cardsReady + 1 };\n    case 'edited': {\n      const fields = { ...state.fields, [action.id]: action.text };\n      return { ...state, fields };\n    }\n    case 'run':\n      return ran(state);\n    case 'live':\n      return wentLive(state);\n    case 'batch': {\n      let next = state;\n      for (const inner of action.actions) {\n        next = reducer(next, inner);\n      }\n      return next;\n    }\n  }\n}\n\nconst CHUNK = 3;\n\nfunction delayOfChunk(index: number) {\n  if (index === 0) {\n    return 1000;\n  }\n  return 70;\n}\n\nfunction typingSteps(): Step[] {\n  const steps: Step[] = [];\n  const last = PROMPT.length + CHUNK;\n  for (let end = CHUNK; end < last; end += CHUNK) {\n    const text = PROMPT.slice(0, end);\n    const after = delayOfChunk(steps.length);\n    steps.push({ after, by: 'demo', action: { type: 'typed', text } });\n  }\n  return steps;\n}\n\nfunction frame(after: number, actions: CanvasAction[]): Step {\n  return { after, action: { type: 'batch', actions } };\n}\n\nfunction hasAsked(state: CanvasState) {\n  return state.ask !== null;\n}\n\nfunction hasRun(state: CanvasState) {\n  return state.live !== 'idle';\n}\n\n/** Two characters every tick: a card of ninety characters writes itself in under two seconds. */\nexport const TYPE_TICK_MS = 40;\n\nexport const GO_LIVE_MS = 900;\n\n/** A request that waits on a person is answered by the demonstration after this long. */\nconst DECIDE_AFTER_MS = 2500;\n\nexport const SCRIPT: Step[] = [\n  ...typingSteps(),\n  {\n    after: 450,\n    by: 'person',\n    press: 'send',\n    action: { type: 'sent' },\n    isAnswered: hasAsked,\n  },\n  frame(400, [{ type: 'check', index: 0, status: 'running' }]),\n  frame(900, [\n    { type: 'check', index: 0, status: 'done' },\n    { type: 'check', index: 1, status: 'running' },\n  ]),\n  frame(1000, [\n    { type: 'check', index: 1, status: 'done' },\n    { type: 'check', index: 2, status: 'running' },\n    { type: 'card' },\n  ]),\n  frame(2300, [{ type: 'ready' }, { type: 'card' }]),\n  frame(1200, [{ type: 'ready' }, { type: 'card' }]),\n  frame(1500, [{ type: 'ready' }, { type: 'check', index: 2, status: 'done' }]),\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'run',\n    action: { type: 'run' },\n    isAnswered: hasRun,\n  },\n  { after: GO_LIVE_MS, action: { type: 'live' } },\n];\n\nfunction restingOf() {\n  let state = INITIAL;\n  for (const step of SCRIPT) {\n    state = reducer(state, step.action);\n  }\n  return state;\n}\n\nexport const RESTING = restingOf();\n\nexport const LOOP_AFTER_MS = 3200;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-03/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-chat/agent-chat-03/data.ts",
      "content": "export const PROMPT =\n  'When a customer reports a bug, open an issue and tell the support channel';\n\nexport const READY_LINE =\n  'Drafted. Check the three cards, change what you like, then run it.';\n\nexport const LIVE_LINE =\n  'The rule is live. The next bug report opens an issue and posts to #support.';\n\nexport const CHECK_LABELS = [\n  'Understood the request',\n  'Found the Support project',\n  'Drafted the rule',\n];\n\nexport type FieldId =\n  'when' | 'if' | 'then' | 'title' | 'team' | 'channel' | 'post';\n\nexport type CardId = 'rule' | 'issue' | 'post';\n\nexport type CardField = {\n  id: FieldId;\n  label: string;\n};\n\nexport const CARD_ORDER: CardId[] = ['rule', 'issue', 'post'];\n\nexport const CARD_FIELDS: Record<CardId, CardField[]> = {\n  rule: [\n    { id: 'when', label: 'When' },\n    { id: 'if', label: 'If' },\n    { id: 'then', label: 'Then' },\n  ],\n  issue: [\n    { id: 'title', label: 'Title' },\n    { id: 'team', label: 'Team' },\n  ],\n  post: [\n    { id: 'channel', label: 'Channel' },\n    { id: 'post', label: 'Message' },\n  ],\n};\n\nexport const FIELD_TEXT: Record<FieldId, string> = {\n  when: 'A customer reports a bug',\n  if: 'The message describes something broken',\n  then: 'Open an issue and post to #support',\n  title: 'Bug from {customer}: {summary}',\n  team: 'Support',\n  channel: '#support',\n  post: 'New bug from {customer}. Tracked in {issue}.',\n};\n\nexport const ISSUE_LABELS = [\n  { name: 'Bug', color: 'var(--destructive)' },\n  { name: 'From support', color: 'var(--muted-foreground)' },\n];\n\n/** An invented workspace: it has no mark, so it wears a drawn initial. */\nexport const WORKSPACE = { name: 'Harbour chat' };\n\nexport function typedLengthOf(card: CardId) {\n  let total = 0;\n  for (const field of CARD_FIELDS[card]) {\n    total += FIELD_TEXT[field.id].length;\n  }\n  return total;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-chat-03/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-chat"
  ],
  "type": "registry:block"
}