{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-review-04",
  "title": "Computer use session",
  "description": "An agent working in a browser drawn on the page: its named pointer glides from one control to the next, every action is a frame you can scrub back to, you can pause or take over, and the payment waits for your yes.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "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/company-mark.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/status-orb.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-04/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 { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { PauseIcon, PlayIcon, StopIcon } from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { ClockGate, LiveDuration } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { BrowserFrame } from './browser';\nimport { formatPrice, OPERATOR, PERSON, TASK, totalOf } from './data';\nimport {\n  INITIAL,\n  isAgentHeld,\n  liveFrameOf,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  shownFrameOf,\n  type Actor,\n  type ComputerState,\n  type Frame,\n} from './session';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n  holdWhile: isAgentHeld,\n};\n\ntype StatusWord =\n  | 'Working'\n  | 'Waiting on you'\n  | 'You have control'\n  | 'Paused'\n  | 'Done'\n  | 'Stopped';\n\nfunction statusWordOf(state: ComputerState): StatusWord {\n  if (state.status === 'stopped') {\n    return 'Stopped';\n  }\n  if (state.status === 'done') {\n    return 'Done';\n  }\n  if (state.approval === 'pending') {\n    return 'Waiting on you';\n  }\n  if (state.control === 'person') {\n    return 'You have control';\n  }\n  if (state.isPaused) {\n    return 'Paused';\n  }\n  return 'Working';\n}\n\nconst STATUS_VARIANT = {\n  Working: 'default',\n  'Waiting on you': 'warning',\n  'You have control': 'info',\n  Paused: 'secondary',\n  Done: 'success',\n  Stopped: 'destructive',\n} as const;\n\nfunction pauseLabelOf(isPaused: boolean) {\n  if (isPaused) {\n    return 'Resume';\n  }\n  return 'Pause';\n}\n\nfunction controlLabelOf(control: Actor) {\n  if (control === 'person') {\n    return 'Hand back';\n  }\n  return 'Take over';\n}\n\nfunction controlVariantOf(control: Actor) {\n  if (control === 'person') {\n    return 'default';\n  }\n  return 'outline';\n}\n\nfunction pressedOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.94]';\n  }\n  return undefined;\n}\n\nfunction rowToneOf(isShown: boolean) {\n  if (isShown) {\n    return 'bg-primary/10';\n  }\n  return 'hover:bg-foreground/[0.04]';\n}\n\nfunction OperatorTile() {\n  const color = seriesColorOf(OPERATOR.series);\n\n  return (\n    <MeshTile\n      seed={OPERATOR.name}\n      color={color}\n      className='size-6 rounded-md'\n    />\n  );\n}\n\nfunction ActorMark({ actor }: { actor: Actor }) {\n  if (actor === 'agent') {\n    return <OperatorTile />;\n  }\n  return <Avatar className='size-6' seed={PERSON.name} />;\n}\n\ntype ActionLogProps = {\n  frames: Frame[];\n  shownId: number;\n  onView: (index: number) => void;\n};\n\nfunction ActionLog({ frames, shownId, onView }: ActionLogProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n\n  return (\n    <ol aria-label='Actions' className='flex flex-col'>\n      <AnimatePresence initial={false}>\n        {frames.map((frame) => (\n          <motion.li\n            key={frame.id}\n            className='overflow-hidden'\n            {...rowPresence}\n          >\n            <button\n              type='button'\n              aria-current={frame.id === shownId}\n              onClick={() => onView(frame.id)}\n              className={cn(\n                'focus-visible:ring-ring/25 flex min-h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 py-1.5 text-start text-[13px] transition-colors duration-150 outline-none focus-visible:ring-[3px]',\n                rowToneOf(frame.id === shownId)\n              )}\n            >\n              <ActorMark actor={frame.actor} />\n              <span className='min-w-0 flex-1 leading-snug'>{frame.text}</span>\n              <span className='text-muted-foreground w-4 shrink-0 text-end text-xs tabular-nums'>\n                {frame.id + 1}\n              </span>\n            </button>\n          </motion.li>\n        ))}\n      </AnimatePresence>\n    </ol>\n  );\n}\n\nexport default function AgentReview04() {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const live = liveFrameOf(state);\n  const shown = shownFrameOf(state);\n  const lastIndex = state.frames.length - 1;\n  const isFollowing = state.viewed === null;\n  const isRunning = state.status === 'running';\n  const isPending = state.approval === 'pending';\n  const hasControl = state.control === 'person';\n  const isLiveView = isFollowing && isRunning;\n  const canAct = hasControl && isLiveView;\n  const isAgentWaiting = hasControl || state.isPaused;\n  const canPause = isRunning && !hasControl;\n  const statusWord = statusWordOf(state);\n  const amount = formatPrice(totalOf(live.period, live.hasAddon));\n  const isOver = isFinished || !isRunning;\n  const canReplay = isOver && !isAutoplaying;\n  const message = spokenUnless(isAutoplaying, `${statusWord}. ${live.text}`);\n  const clock = {\n    startedAt: state.startedAt ?? undefined,\n    endedAt: state.endedAt ?? undefined,\n  };\n\n  function toggleControl() {\n    if (hasControl) {\n      act({ type: 'handedBack' });\n      return;\n    }\n    act({ type: 'tookOver' });\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='mx-auto flex max-w-5xl flex-col gap-4'>\n          <header className='flex flex-wrap items-center gap-x-3 gap-y-2'>\n            <OperatorTile />\n            <div className='flex min-w-40 flex-1 flex-col leading-tight'>\n              <h1 className='text-sm font-medium'>{TASK}</h1>\n              <span className='text-muted-foreground text-xs'>\n                {OPERATOR.name}, in a browser it controls\n              </span>\n            </div>\n            <Badge variant={STATUS_VARIANT[statusWord]}>\n              <Swap swapKey={statusWord}>{statusWord}</Swap>\n            </Badge>\n            <LiveDuration\n              item={clock}\n              isRunning={isRunning}\n              className='text-muted-foreground w-12 text-end text-[13px]'\n            />\n            {isRunning && (\n              <Button\n                type='button'\n                variant='destructive'\n                size='sm'\n                onClick={() => act({ type: 'stopped' })}\n              >\n                <StopIcon />\n                Stop\n              </Button>\n            )}\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={restart}\n              label='Replay the session'\n            />\n          </header>\n\n          <div className='flex flex-col gap-4 @3xl:flex-row @3xl:items-start'>\n            <section\n              aria-label='Browser'\n              className='flex min-w-0 flex-1 flex-col gap-3'\n            >\n              <BrowserFrame\n                frame={shown}\n                isAgentWaiting={isAgentWaiting}\n                canAct={canAct}\n                isAddonPressed={pressed === 'addon'}\n                onToggleAddon={() => act({ type: 'addon' })}\n                onPeriodChange={(period) => act({ type: 'period', period })}\n              />\n              <div className='flex flex-wrap items-center gap-x-3 gap-y-2'>\n                <label className='flex min-w-48 flex-1 items-center gap-3 text-xs'>\n                  <span className='text-muted-foreground w-24 shrink-0 tabular-nums'>\n                    Frame {shown.id + 1} of {state.frames.length}\n                  </span>\n                  <input\n                    type='range'\n                    min={0}\n                    max={lastIndex}\n                    step={1}\n                    value={shown.id}\n                    aria-label='Frame'\n                    onChange={(event) =>\n                      act({ type: 'viewed', index: Number(event.target.value) })\n                    }\n                    className='accent-primary h-4 min-w-0 flex-1 cursor-pointer'\n                  />\n                </label>\n                {!isFollowing && (\n                  <Button\n                    type='button'\n                    variant='ghost'\n                    size='sm'\n                    onClick={() => act({ type: 'viewed', index: null })}\n                    className='text-primary-ink'\n                  >\n                    Back to live\n                  </Button>\n                )}\n                <Button\n                  type='button'\n                  variant='outline'\n                  size='sm'\n                  disabled={!canPause}\n                  onClick={() => act({ type: 'paused' })}\n                >\n                  <Swap swapKey={String(state.isPaused)}>\n                    {state.isPaused && <PlayIcon />}\n                    {!state.isPaused && <PauseIcon />}\n                  </Swap>\n                  {pauseLabelOf(state.isPaused)}\n                </Button>\n                <Button\n                  type='button'\n                  variant={controlVariantOf(state.control)}\n                  size='sm'\n                  disabled={!isRunning}\n                  onClick={toggleControl}\n                  className={pressedOf(pressed === 'takeover')}\n                >\n                  <Swap swapKey={state.control}>\n                    {controlLabelOf(state.control)}\n                  </Swap>\n                </Button>\n              </div>\n              {hasControl && (\n                <p className='bg-info/10 text-info-foreground rounded-lg px-3 py-2 text-[13px] transition-opacity duration-300 starting:opacity-0'>\n                  You have the controls: change the form in the browser above.{' '}\n                  {OPERATOR.name} waits until you hand back.\n                </p>\n              )}\n            </section>\n\n            <section\n              aria-label='Session log'\n              className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] flex flex-col gap-2 rounded-xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)] @3xl:w-80 @3xl:shrink-0'\n            >\n              <AnimatePresence initial={false}>\n                {isPending && (\n                  <motion.div\n                    key='approval'\n                    className='overflow-hidden'\n                    {...rowPresence}\n                  >\n                    <div className='bg-warning/10 flex flex-col gap-3 rounded-lg p-3'>\n                      <div className='flex items-center gap-2.5'>\n                        <BrandTile brand='visa' size='lg' title='Visa' />\n                        <div className='flex min-w-0 flex-col leading-tight'>\n                          <h2 className='text-sm font-medium'>Pay {amount}</h2>\n                          <span className='text-warning-foreground text-xs'>\n                            Card ending 4242, cannot be undone\n                          </span>\n                        </div>\n                      </div>\n                      <div className='flex items-center justify-end gap-2'>\n                        <Button\n                          type='button'\n                          variant='outline'\n                          size='sm'\n                          onClick={() =>\n                            act({ type: 'decided', decision: 'denied' })\n                          }\n                        >\n                          Deny\n                        </Button>\n                        <Button\n                          type='button'\n                          size='sm'\n                          onClick={() =>\n                            act({ type: 'decided', decision: 'approved' })\n                          }\n                          className={cn(\n                            pressedOf(pressed === 'allow'),\n                            pressed === 'allow' && 'bg-primary/85'\n                          )}\n                        >\n                          Allow the payment\n                        </Button>\n                      </div>\n                    </div>\n                  </motion.div>\n                )}\n              </AnimatePresence>\n              <h2 className='text-muted-foreground px-2 pt-1 text-xs'>\n                Actions, synced to the frames\n              </h2>\n              <ActionLog\n                frames={state.frames}\n                shownId={shown.id}\n                onView={(index) => act({ type: 'viewed', index })}\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-review-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-04/browser.tsx",
      "content": "'use client';\n\nimport { useLayoutEffect, useRef } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport {\n  CheckIcon,\n  LockIcon,\n  MousePointerIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport {\n  ADDON_PRICE,\n  DOMAINS,\n  formatPrice,\n  OPERATOR,\n  PAGE_URL,\n  PRICE_FORMAT,\n  SITE,\n  totalOf,\n  type Period,\n  type PointerTarget,\n} from './data';\nimport type { Frame } from './session';\n\nconst DRAWN_BUTTON =\n  'bg-primary text-primary-foreground inline-flex h-7 items-center rounded-full px-3 font-medium';\n\ntype FormHandlers = {\n  /** True while the person has the controls of the live frame. */\n  canAct: boolean;\n  isAddonPressed: boolean;\n  onToggleAddon: () => void;\n  onPeriodChange: (period: Period) => void;\n};\n\nfunction ListPage() {\n  return (\n    <div className='flex flex-col gap-3'>\n      <h3 className='text-sm font-semibold'>Domains</h3>\n      <ul className='flex flex-col'>\n        {DOMAINS.map((domain) => (\n          <li\n            key={domain.name}\n            data-target={targetOfDomain(domain.isDue)}\n            className='odd:bg-foreground/[0.03] flex h-9 items-center justify-between gap-2 rounded-md px-2'\n          >\n            <span className='truncate font-medium'>{domain.name}</span>\n            {domain.isDue && <Badge variant='warning'>{domain.note}</Badge>}\n            {!domain.isDue && (\n              <span className='text-muted-foreground'>{domain.note}</span>\n            )}\n          </li>\n        ))}\n      </ul>\n    </div>\n  );\n}\n\nfunction targetOfDomain(isDue: boolean): PointerTarget | undefined {\n  if (isDue) {\n    return 'row';\n  }\n  return undefined;\n}\n\nfunction DomainPage() {\n  return (\n    <div className='flex flex-col items-start gap-3'>\n      <h3 className='text-sm font-semibold'>tallis.example</h3>\n      <p className='text-muted-foreground'>\n        Registered until 12 November 2026. Renewal is not automatic.\n      </p>\n      <span data-target='renew' className={DRAWN_BUTTON}>\n        Renew\n      </span>\n    </div>\n  );\n}\n\nfunction periodToneOf(isSelected: boolean) {\n  if (isSelected) {\n    return 'bg-card hairline-ring ring-foreground/15 shadow-[0_1px_2px_rgb(0_0_0/0.06)] dark:bg-foreground/[0.1]';\n  }\n  return 'text-muted-foreground';\n}\n\nfunction boxToneOf(isChecked: boolean) {\n  if (isChecked) {\n    return 'bg-primary text-primary-foreground';\n  }\n  return 'hairline-ring ring-foreground/30';\n}\n\nfunction pressedOf(isPressed: boolean) {\n  if (isPressed) {\n    return 'scale-[0.96] bg-foreground/[0.08]';\n  }\n  return undefined;\n}\n\nconst PERIODS: { period: Period; label: string }[] = [\n  { period: 1, label: '1 year' },\n  { period: 2, label: '2 years' },\n];\n\nfunction RenewPage({\n  frame,\n  canAct,\n  isAddonPressed,\n  onToggleAddon,\n  onPeriodChange,\n}: FormHandlers & { frame: Frame }) {\n  const total = totalOf(frame.period, frame.hasAddon);\n\n  return (\n    <div className='flex flex-col gap-3'>\n      <h3 className='text-sm font-semibold'>Renew tallis.example</h3>\n      <div\n        role='group'\n        aria-label='Period'\n        data-target='period'\n        className='bg-foreground/[0.05] flex w-fit gap-0.5 rounded-lg p-0.5'\n      >\n        {PERIODS.map((option) => (\n          <button\n            key={option.period}\n            type='button'\n            aria-pressed={frame.period === option.period}\n            disabled={!canAct}\n            onClick={() => onPeriodChange(option.period)}\n            className={cn(\n              'focus-visible:ring-ring/25 h-6 rounded-md px-2.5 transition-colors duration-150 outline-none focus-visible:ring-[3px] enabled:cursor-pointer',\n              periodToneOf(frame.period === option.period)\n            )}\n          >\n            {option.label}\n          </button>\n        ))}\n      </div>\n      <button\n        type='button'\n        role='checkbox'\n        aria-checked={frame.hasAddon}\n        disabled={!canAct}\n        onClick={onToggleAddon}\n        className={cn(\n          'focus-visible:ring-ring/25 enabled:hover:bg-foreground/[0.04] -mx-1.5 flex h-8 w-fit items-center gap-2 rounded-md px-1.5 transition-[background-color,scale] duration-150 outline-none focus-visible:ring-[3px] enabled:cursor-pointer',\n          pressedOf(isAddonPressed)\n        )}\n      >\n        <span\n          className={cn(\n            'flex size-4 items-center justify-center rounded-[5px] transition-colors duration-150',\n            boxToneOf(frame.hasAddon)\n          )}\n        >\n          {frame.hasAddon && <CheckIcon className='size-3' strokeWidth={2.5} />}\n        </span>\n        Privacy protection, {formatPrice(ADDON_PRICE)} a year\n      </button>\n      <div className='flex items-end justify-between gap-3'>\n        <div className='flex flex-col'>\n          <span className='text-muted-foreground'>Total, illustrative</span>\n          <MotionNumber\n            value={total}\n            locale='en-IE'\n            format={PRICE_FORMAT}\n            className='text-2xl leading-none font-semibold'\n          />\n        </div>\n        <span data-target='pay' className={DRAWN_BUTTON}>\n          Pay\n        </span>\n      </div>\n    </div>\n  );\n}\n\nfunction DonePage() {\n  return (\n    <div className='m-auto flex flex-col items-center gap-3 text-center'>\n      <StatusOrb tone='success' />\n      <h3 className='text-sm font-semibold'>Renewed until 12 November 2027</h3>\n      <p className='text-muted-foreground'>\n        A receipt was sent to the account email.\n      </p>\n    </div>\n  );\n}\n\nfunction waitingToneOf(isWaiting: boolean) {\n  if (isWaiting) {\n    return 'opacity-40';\n  }\n  return 'opacity-100';\n}\n\nfunction pointerWordOf(isWaiting: boolean) {\n  if (isWaiting) {\n    return `${OPERATOR.name} waits`;\n  }\n  return OPERATOR.name;\n}\n\ntype BrowserFrameProps = FormHandlers & {\n  frame: Frame;\n  /** The agent's pointer dims while it waits for the person. */\n  isAgentWaiting: boolean;\n};\n\nexport function BrowserFrame({\n  frame,\n  isAgentWaiting,\n  ...form\n}: BrowserFrameProps) {\n  const viewportRef = useRef<HTMLDivElement>(null);\n  const pointerRef = useRef<HTMLSpanElement>(null);\n  const gemStyle = {\n    '--gem': seriesColorOf(OPERATOR.series),\n  } as React.CSSProperties;\n  const pointerStyle = { color: seriesColorOf(OPERATOR.series) };\n  const target = frame.pointer;\n  const frameId = frame.id;\n\n  useLayoutEffect(() => {\n    const viewport = viewportRef.current;\n    const pointer = pointerRef.current;\n    if (!viewport || !pointer) {\n      return;\n    }\n    const place = () => {\n      const element = viewport.querySelector(`[data-target='${target}']`);\n      if (!element) {\n        pointer.style.opacity = '0';\n        return;\n      }\n      const bounds = viewport.getBoundingClientRect();\n      const box = element.getBoundingClientRect();\n      const x = box.left - bounds.left + box.width * 0.6;\n      const y = box.top - bounds.top + box.height * 0.55;\n      pointer.style.translate = `${x}px ${y}px`;\n      pointer.style.opacity = '';\n    };\n    place();\n    const observer = new ResizeObserver(place);\n    observer.observe(viewport);\n    return () => observer.disconnect();\n  }, [target, frameId]);\n\n  return (\n    <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n      <div className='bg-foreground/[0.03] flex h-10 items-center gap-2 px-3'>\n        <CompanyMark seed={SITE.name} />\n        <div className='bg-card dark:bg-foreground/[0.05] flex h-6 min-w-0 flex-1 items-center gap-1.5 rounded-full px-2.5 text-xs'>\n          <LockIcon className='text-muted-foreground size-3 shrink-0' />\n          <span className='truncate'>{PAGE_URL[frame.page]}</span>\n        </div>\n      </div>\n      <div\n        ref={viewportRef}\n        aria-label={`Controlled browser, ${SITE.name}`}\n        className='relative flex min-h-[15.5rem] flex-col overflow-hidden p-4 text-xs'\n      >\n        {frame.page === 'blank' && (\n          <p className='text-muted-foreground m-auto'>Opening the browser</p>\n        )}\n        {frame.page === 'list' && <ListPage />}\n        {frame.page === 'domain' && <DomainPage />}\n        {frame.page === 'renew' && <RenewPage frame={frame} {...form} />}\n        {frame.page === 'done' && <DonePage />}\n        <span\n          ref={pointerRef}\n          aria-hidden='true'\n          className={cn(\n            'pointer-events-none absolute top-0 left-0 flex items-start transition-[translate,opacity] duration-500 ease-(--ease-in-out-strong) motion-reduce:transition-none',\n            waitingToneOf(isAgentWaiting)\n          )}\n        >\n          <MousePointerIcon\n            style={pointerStyle}\n            className='size-4 fill-current'\n          />\n          <span\n            style={gemStyle}\n            className='gem-plate mt-3 rounded-full px-1.5 py-0.5 text-[10px] font-medium whitespace-nowrap'\n          >\n            {pointerWordOf(isAgentWaiting)}\n          </span>\n        </span>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-04/browser.tsx"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-04/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\n\nimport {\n  AGENT_MOVES,\n  PAY_MOVE,\n  type PageId,\n  type Period,\n  type PointerTarget,\n} from './data';\n\nexport type Actor = 'agent' | 'person';\n\nexport type Frame = {\n  id: number;\n  actor: Actor;\n  text: string;\n  page: PageId;\n  pointer: PointerTarget | null;\n  period: Period;\n  hasAddon: boolean;\n};\n\nexport type ApprovalStatus = 'none' | 'pending' | 'approved' | 'denied';\n\nexport type SessionStatus = 'running' | 'done' | 'stopped';\n\nexport type ComputerState = {\n  status: SessionStatus;\n  frames: Frame[];\n  movesDone: number;\n  control: Actor;\n  isPaused: boolean;\n  approval: ApprovalStatus;\n  /** The frame being looked at, or null to follow the live one. */\n  viewed: number | null;\n  startedAt: number | null;\n  endedAt: number | null;\n};\n\nexport type ComputerAction =\n  | { type: 'started' }\n  | { type: 'moved' }\n  | { type: 'paused' }\n  | { type: 'tookOver' }\n  | { type: 'handedBack' }\n  | { type: 'addon' }\n  | { type: 'period'; period: Period }\n  | { type: 'decided'; decision: 'approved' | 'denied' }\n  | { type: 'stopped' }\n  | { type: 'viewed'; index: number | null };\n\ntype Step = SessionStep<ComputerState, ComputerAction>;\n\nconst BLANK: Frame = {\n  id: 0,\n  actor: 'agent',\n  text: 'Started a browser',\n  page: 'blank',\n  pointer: null,\n  period: 1,\n  hasAddon: true,\n};\n\nexport const INITIAL: ComputerState = {\n  status: 'running',\n  frames: [BLANK],\n  movesDone: 0,\n  control: 'agent',\n  isPaused: false,\n  approval: 'none',\n  viewed: null,\n  startedAt: null,\n  endedAt: null,\n};\n\nexport function liveFrameOf(state: ComputerState) {\n  const last = state.frames.at(-1);\n  return last ?? BLANK;\n}\n\nexport function shownFrameOf(state: ComputerState) {\n  if (state.viewed === null) {\n    return liveFrameOf(state);\n  }\n  return state.frames[state.viewed] ?? liveFrameOf(state);\n}\n\nexport function isAgentHeld(state: ComputerState) {\n  const isOver = state.status !== 'running';\n  const isWaiting = state.isPaused || state.control === 'person';\n  return isOver || isWaiting;\n}\n\nfunction withFrame(\n  state: ComputerState,\n  patch: Partial<Frame> & Pick<Frame, 'actor' | 'text'>\n): ComputerState {\n  const live = liveFrameOf(state);\n  const frame: Frame = { ...live, ...patch, id: state.frames.length };\n  return { ...state, frames: [...state.frames, frame] };\n}\n\nfunction moved(state: ComputerState, now: number): ComputerState {\n  const move = AGENT_MOVES[state.movesDone];\n  const isWaitingForYes = state.approval === 'pending';\n  const cannotMove = isWaitingForYes || isAgentHeld(state);\n  if (!move) {\n    return state;\n  }\n  if (cannotMove) {\n    return state;\n  }\n  const next = withFrame(state, { actor: 'agent', ...move });\n  const movesDone = state.movesDone + 1;\n  const isPayMove = state.movesDone === PAY_MOVE;\n  if (isPayMove) {\n    return { ...next, movesDone, approval: 'pending' };\n  }\n  const isLast = movesDone === AGENT_MOVES.length;\n  if (isLast) {\n    return { ...next, movesDone, status: 'done', endedAt: now };\n  }\n  return { ...next, movesDone };\n}\n\nfunction personChanged(\n  state: ComputerState,\n  patch: Partial<Frame>,\n  text: string\n): ComputerState {\n  const live = liveFrameOf(state);\n  const isOnForm = live.page === 'renew';\n  const canAct = state.control === 'person' && state.status === 'running';\n  if (!isOnForm || !canAct) {\n    return state;\n  }\n  return withFrame(state, { ...patch, actor: 'person', text, pointer: null });\n}\n\nfunction addonTextOf(hasAddon: boolean) {\n  if (hasAddon) {\n    return 'You added privacy protection';\n  }\n  return 'You removed privacy protection';\n}\n\nfunction periodTextOf(period: Period) {\n  if (period === 1) {\n    return 'You chose 1 year';\n  }\n  return 'You chose 2 years';\n}\n\nfunction decided(\n  state: ComputerState,\n  decision: 'approved' | 'denied',\n  now: number\n): ComputerState {\n  if (state.approval !== 'pending') {\n    return state;\n  }\n  if (decision === 'approved') {\n    return { ...state, approval: 'approved' };\n  }\n  const denied = withFrame(state, {\n    actor: 'person',\n    text: 'You denied the payment. Nothing was charged',\n    pointer: null,\n  });\n  return { ...denied, approval: 'denied', status: 'stopped', endedAt: now };\n}\n\nfunction stopped(state: ComputerState, now: number): ComputerState {\n  if (state.status !== 'running') {\n    return state;\n  }\n  const next = withFrame(state, {\n    actor: 'person',\n    text: 'You stopped the session',\n    pointer: null,\n  });\n  return { ...next, status: 'stopped', approval: 'none', endedAt: now };\n}\n\nfunction viewed(state: ComputerState, index: number | null): ComputerState {\n  const last = state.frames.length - 1;\n  const isLive = index === null || index >= last;\n  if (isLive) {\n    return { ...state, viewed: null };\n  }\n  return { ...state, viewed: Math.max(0, index) };\n}\n\nexport function applyAt(\n  state: ComputerState,\n  action: ComputerAction,\n  now: number\n): ComputerState {\n  switch (action.type) {\n    case 'started':\n      return { ...state, startedAt: now };\n    case 'moved':\n      return moved(state, now);\n    case 'paused':\n      return { ...state, isPaused: !state.isPaused };\n    case 'tookOver':\n      return { ...state, control: 'person', viewed: null };\n    case 'handedBack':\n      return { ...state, control: 'agent' };\n    case 'addon': {\n      const hasAddon = !liveFrameOf(state).hasAddon;\n      return personChanged(state, { hasAddon }, addonTextOf(hasAddon));\n    }\n    case 'period':\n      return personChanged(\n        state,\n        { period: action.period },\n        periodTextOf(action.period)\n      );\n    case 'decided':\n      return decided(state, action.decision, now);\n    case 'stopped':\n      return stopped(state, now);\n    case 'viewed':\n      return viewed(state, action.index);\n  }\n}\n\nexport function reducer(state: ComputerState, action: ComputerAction) {\n  return applyAt(state, action, Date.now());\n}\n\nfunction hasDecided(state: ComputerState) {\n  return state.approval !== 'pending';\n}\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  { after: 500, action: { type: 'started' } },\n  { after: 700, action: { type: 'moved' } },\n  { after: 1600, action: { type: 'moved' } },\n  { after: 1600, action: { type: 'moved' } },\n  { after: 1700, by: 'demo', press: 'takeover', action: { type: 'tookOver' } },\n  { after: 1500, by: 'demo', press: 'addon', action: { type: 'addon' } },\n  {\n    after: 1700,\n    by: 'demo',\n    press: 'takeover',\n    action: { type: 'handedBack' },\n  },\n  { after: 1300, action: { type: 'moved' } },\n  {\n    after: DECIDE_AFTER_MS,\n    by: 'person',\n    press: 'allow',\n    action: { type: 'decided', decision: 'approved' },\n    isAnswered: hasDecided,\n  },\n  { after: 1300, action: { type: 'moved' } },\n];\n\nfunction restingOf() {\n  let state = INITIAL;\n  let now = 1000;\n  for (const step of SCRIPT) {\n    now += step.after;\n    state = applyAt(state, step.action, now);\n  }\n  return state;\n}\n\nexport const RESTING = restingOf();\n\nexport const LOOP_AFTER_MS = 3800;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-04/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/agent-review/agent-review-04/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\n\nexport const TASK = 'Renew tallis.example for one year';\n\nexport const OPERATOR = {\n  name: 'Operator',\n  series: 2 as SeriesSlot,\n};\n\nexport const PERSON = {\n  name: 'Lena Brandt',\n};\n\n/** An invented registrar: it has no mark, so it wears a drawn initial. */\nexport const SITE = { name: 'Northgate Domains' };\n\nexport type PageId = 'blank' | 'list' | 'domain' | 'renew' | 'done';\n\nexport type PointerTarget = 'row' | 'renew' | 'period' | 'pay';\n\nexport type Period = 1 | 2;\n\nexport const PAGE_URL: Record<PageId, string> = {\n  blank: 'about:blank',\n  list: 'northgate.example/domains',\n  domain: 'northgate.example/domains/tallis.example',\n  renew: 'northgate.example/domains/tallis.example/renew',\n  done: 'northgate.example/orders/confirmed',\n};\n\nexport const DOMAINS = [\n  { name: 'tallis.example', note: 'Expires in 12 days', isDue: true },\n  { name: 'okapi.example', note: 'Renews by itself', isDue: false },\n  { name: 'harbourline.example', note: 'Renews by itself', isDue: false },\n];\n\nexport const YEAR_PRICE = 14;\n\nexport const ADDON_PRICE = 9;\n\nexport function totalOf(period: Period, hasAddon: boolean) {\n  const addon = addonOf(hasAddon);\n  const perYear = YEAR_PRICE + addon;\n  return perYear * period;\n}\n\nfunction addonOf(hasAddon: boolean) {\n  if (hasAddon) {\n    return ADDON_PRICE;\n  }\n  return 0;\n}\n\nexport const PRICE_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'EUR',\n  minimumFractionDigits: 2,\n};\n\nconst PRICE = new Intl.NumberFormat('en-IE', PRICE_FORMAT);\n\nexport function formatPrice(amount: number) {\n  return PRICE.format(amount);\n}\n\nexport type AgentMove = {\n  text: string;\n  page: PageId;\n  pointer: PointerTarget | null;\n};\n\n/** What the agent does, in order. Each move becomes a frame the scrubber can go back to. */\nexport const AGENT_MOVES: AgentMove[] = [\n  { text: 'Found tallis.example in the list', page: 'list', pointer: 'row' },\n  { text: 'Opened the domain', page: 'domain', pointer: 'renew' },\n  {\n    text: 'Opened the renewal form and kept 1 year',\n    page: 'renew',\n    pointer: 'period',\n  },\n  { text: 'Moved to Pay and asked you first', page: 'renew', pointer: 'pay' },\n  { text: 'Paid. Renewed until 12 November 2027', page: 'done', pointer: null },\n];\n\n/** The move that spends money: it waits for a person before the next one runs. */\nexport const PAY_MOVE = 3;\n",
      "type": "registry:component",
      "target": "components/blocks/agent-review-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "agent-review"
  ],
  "type": "registry:block"
}