{
  "schemaVersion": 1,
  "target": "react",
  "name": "agent-state",
  "version": "0.1.0",
  "category": "agent",
  "title": "Agent State",
  "description": "A calm pill with a small animated dot mark and a verb, for what an agent is doing right now: thinking, searching, working, planning, listening, or shaping.",
  "tags": [
    "agent",
    "status",
    "loading",
    "activity",
    "animation",
    "ai"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {},
  "registryDependencies": [],
  "docsPath": "/components/agent-state",
  "props": [
    {
      "name": "activity",
      "type": "\"thinking\" | \"searching\" | \"working\" | \"planning\" | \"listening\" | \"shaping\"",
      "default": "\"thinking\"",
      "description": "Picks the mark (dot sphere, scanning globe, constellation, sparse spinner, dotted ring, dotted triangle) and the default verb."
    },
    {
      "name": "label",
      "type": "ReactNode",
      "description": "Replaces the verb, for example \"Reading the docs\". While active an ellipsis follows it."
    },
    {
      "name": "phase",
      "type": "\"active\" | \"idle\" | \"waiting\" | \"done\" | \"failed\" | \"cancelled\"",
      "default": "\"active\"",
      "description": "active animates the mark; waiting holds it still; idle, done, failed, and cancelled swap it for a still glyph."
    },
    {
      "name": "size",
      "type": "\"sm\" | \"md\" | \"lg\"",
      "default": "\"md\"",
      "description": "24, 32, or 44px tall, with 14, 18, or 26px marks."
    },
    {
      "name": "variant",
      "type": "\"pill\" | \"plain\"",
      "default": "\"pill\"",
      "description": "pill draws the rounded hairline container; plain is the mark and verb alone, for rows and inline use."
    },
    {
      "name": "status",
      "type": "boolean",
      "default": "false",
      "description": "Makes the pill a polite live region (role=\"status\") so label changes are announced."
    },
    {
      "name": "OrbMark, ScanMark, ConstellationMark, SparkMark, RingMark, PrismMark",
      "type": "({ size?, paused?, className? }) => JSX",
      "description": "The marks on their own. They draw in currentColor, so set the color with a text class. AgentMark picks one by activity."
    }
  ],
  "accessibility": [
    "Marks are decorative (aria-hidden); the verb is real text. The ellipsis is generated content, so the label text stays exactly what you pass.",
    "With status set, the pill is a polite live region and announces the new verb when the activity changes.",
    "Under reduced motion every mark renders one still frame; the verb and phase glyphs still change.",
    "Marks pause when scrolled out of view or when the tab is hidden, and stop all work when unmounted.",
    "Settled phases add a shape as well as color: a check for done, an x for failed, a slash for cancelled, a dashed circle for idle."
  ],
  "states": [
    "active",
    "idle",
    "waiting",
    "done",
    "failed",
    "cancelled"
  ],
  "files": [
    {
      "path": "agent/agent-state.tsx",
      "content": "\"use client\";\n\nimport { type ComponentProps, type ReactNode, useEffect, useRef } from \"react\";\n\n/*\n * Agent state: a calm pill with a small animated mark and a verb (\"Searching…\").\n *\n * Each mark is a few dozen dots and hairlines drawn on a tiny canvas in `currentColor`,\n * so it follows light and dark themes. All marks share one requestAnimationFrame loop;\n * a mark only draws while it is on screen, the tab is visible, and motion is allowed.\n * Under reduced motion each mark renders one still frame.\n */\n\nexport type AgentActivity = \"thinking\" | \"searching\" | \"working\" | \"planning\" | \"listening\" | \"shaping\";\nexport type AgentPhase = \"active\" | \"idle\" | \"waiting\" | \"done\" | \"failed\" | \"cancelled\";\nexport type AgentStateSize = \"sm\" | \"md\" | \"lg\";\n\nexport const agentActivities: AgentActivity[] = [\"thinking\", \"searching\", \"working\", \"planning\", \"listening\", \"shaping\"];\n\nconst verbs: Record<AgentActivity, string> = {\n  thinking: \"Thinking\",\n  searching: \"Searching\",\n  working: \"Working\",\n  planning: \"Planning\",\n  listening: \"Listening\",\n  shaping: \"Shaping\",\n};\n\nconst phaseLabels: Record<Exclude<AgentPhase, \"active\">, string> = {\n  idle: \"Queued\",\n  waiting: \"Waiting\",\n  done: \"Done\",\n  failed: \"Failed\",\n  cancelled: \"Cancelled\",\n};\n\n// ---------------------------------------------------------------------------\n// Frame loop and canvas plumbing\n\ntype Paint = (ctx: CanvasRenderingContext2D, t: number, size: number) => void;\n\nconst loops = new Set<(now: number) => void>();\nlet frame = 0;\n\nfunction tick(now: number) {\n  frame = 0;\n  for (const loop of loops) loop(now);\n  if (loops.size) frame = requestAnimationFrame(tick);\n}\n\nfunction addLoop(loop: (now: number) => void) {\n  loops.add(loop);\n  if (!frame) frame = requestAnimationFrame(tick);\n}\n\nfunction removeLoop(loop: (now: number) => void) {\n  loops.delete(loop);\n  if (!loops.size && frame) {\n    cancelAnimationFrame(frame);\n    frame = 0;\n  }\n}\n\nexport interface MarkProps extends Omit<ComponentProps<\"canvas\">, \"children\" | \"width\" | \"height\"> {\n  /** Width and height in CSS pixels. */\n  size?: number;\n  /** Holds the current frame instead of animating. */\n  paused?: boolean;\n}\n\nfunction useMarkCanvas(paint: Paint, size: number, still: number, paused: boolean) {\n  const ref = useRef<HTMLCanvasElement>(null);\n  // The last drawn time, so pausing holds the pose instead of jumping to the still frame.\n  const lastT = useRef<number | null>(null);\n\n  useEffect(() => {\n    const canvas = ref.current;\n    const ctx = canvas?.getContext(\"2d\");\n    if (!canvas || !ctx) return;\n\n    const dpr = Math.min(window.devicePixelRatio || 1, 3);\n    canvas.width = Math.round(size * dpr);\n    canvas.height = Math.round(size * dpr);\n\n    let color = \"\";\n    let colorCheckedAt = -Infinity;\n    let visible = true;\n    let running = false;\n    let watcher: ReturnType<typeof setInterval> | undefined;\n    const motion = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n\n    const readColor = () => {\n      const next = getComputedStyle(canvas).color;\n      const changed = next !== color;\n      color = next;\n      return changed;\n    };\n    const draw = (t: number) => {\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n      ctx.clearRect(0, 0, size, size);\n      ctx.fillStyle = color;\n      ctx.strokeStyle = color;\n      ctx.globalAlpha = 1;\n      paint(ctx, t, size);\n      ctx.globalAlpha = 1;\n    };\n    const stillTime = () => (motion.matches ? still : (lastT.current ?? still));\n\n    const loop = (now: number) => {\n      // Theme switches change currentColor; checking twice a second is plenty.\n      if (now - colorCheckedAt > 500) {\n        readColor();\n        colorCheckedAt = now;\n      }\n      const t = now / 1000;\n      lastT.current = t;\n      draw(t);\n    };\n\n    const update = () => {\n      const animate = visible && !document.hidden && !motion.matches && !paused;\n      if (animate && !running) {\n        running = true;\n        readColor();\n        colorCheckedAt = performance.now();\n        addLoop(loop);\n      } else if (!animate && running) {\n        running = false;\n        removeLoop(loop);\n      }\n      clearInterval(watcher);\n      watcher = undefined;\n      if (!animate) {\n        readColor();\n        draw(stillTime());\n        // A still mark still follows theme changes while it is on screen.\n        if (visible && !document.hidden) {\n          watcher = setInterval(() => {\n            if (readColor()) draw(stillTime());\n          }, 600);\n        }\n      }\n    };\n\n    readColor();\n    draw(stillTime());\n\n    const observer = typeof IntersectionObserver === \"undefined\"\n      ? null\n      : new IntersectionObserver((entries) => {\n          visible = entries.some((entry) => entry.isIntersecting);\n          update();\n        });\n    observer?.observe(canvas);\n    document.addEventListener(\"visibilitychange\", update);\n    motion.addEventListener(\"change\", update);\n    update();\n\n    return () => {\n      running = false;\n      removeLoop(loop);\n      clearInterval(watcher);\n      observer?.disconnect();\n      document.removeEventListener(\"visibilitychange\", update);\n      motion.removeEventListener(\"change\", update);\n    };\n  }, [paint, size, still, paused]);\n\n  return ref;\n}\n\nfunction createMark(name: string, paint: Paint, still: number) {\n  function Mark({ size = 18, paused = false, className, style, ...props }: MarkProps) {\n    const ref = useMarkCanvas(paint, size, still, paused);\n    return (\n      <canvas\n        ref={ref}\n        aria-hidden=\"true\"\n        data-mark={name}\n        className={[\"shrink-0\", className].filter(Boolean).join(\" \")}\n        style={{ width: size, height: size, ...style }}\n        {...props}\n      />\n    );\n  }\n  Mark.displayName = name;\n  return Mark;\n}\n\n// ---------------------------------------------------------------------------\n// Geometry helpers\n\nconst TAU = Math.PI * 2;\ntype Point = [number, number, number];\n\nfunction dot(ctx: CanvasRenderingContext2D, x: number, y: number, r: number, alpha: number) {\n  ctx.globalAlpha = Math.max(0, Math.min(1, alpha));\n  ctx.beginPath();\n  ctx.arc(x, y, r, 0, TAU);\n  ctx.fill();\n}\n\n/** Rotates around the vertical axis by `yaw`, then tilts toward the viewer by `pitch`. */\nfunction rotate([x, y, z]: Point, yaw: number, pitch: number): Point {\n  const cy = Math.cos(yaw);\n  const sy = Math.sin(yaw);\n  const x1 = x * cy + z * sy;\n  const z1 = -x * sy + z * cy;\n  const cp = Math.cos(pitch);\n  const sp = Math.sin(pitch);\n  return [x1, y * cp - z1 * sp, y * sp + z1 * cp];\n}\n\nconst memo = new Map<string, Point[]>();\nfunction cached(key: string, build: () => Point[]): Point[] {\n  let points = memo.get(key);\n  if (!points) {\n    points = build();\n    memo.set(key, points);\n  }\n  return points;\n}\n\n/** Evenly spread points on a unit sphere (golden-angle spiral). */\nfunction sphere(count: number): Point[] {\n  return cached(`sphere:${count}`, () => {\n    const golden = Math.PI * (3 - Math.sqrt(5));\n    return Array.from({ length: count }, (_, i) => {\n      const y = 1 - (i / (count - 1)) * 2;\n      const r = Math.sqrt(1 - y * y);\n      return [Math.cos(golden * i) * r, y, Math.sin(golden * i) * r] as Point;\n    });\n  });\n}\n\n/** Dots laid out on latitude rings, like a wire globe. */\nfunction globe(rows: number): Point[] {\n  return cached(`globe:${rows}`, () => {\n    const points: Point[] = [];\n    for (let i = 1; i <= rows; i++) {\n      const lat = -Math.PI / 2 + (Math.PI * i) / (rows + 1);\n      const ring = Math.cos(lat);\n      const count = Math.max(4, Math.round(ring * rows * 2.3));\n      for (let j = 0; j < count; j++) {\n        const lon = (TAU * j) / count + ((i % 2) * Math.PI) / count;\n        points.push([Math.cos(lon) * ring, Math.sin(lat), Math.sin(lon) * ring]);\n      }\n    }\n    return points;\n  });\n}\n\n/** Dot radius that stays visible at small sizes without turning into blobs at large ones. */\nconst dotRadius = (size: number) => Math.max(0.6, size * 0.034);\n\n// ---------------------------------------------------------------------------\n// Marks\n\n/** A dot sphere turning slowly, nearer dots brighter and larger. A soft ripple drifts over it. */\nexport const OrbMark = createMark(\n  \"OrbMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const R = s * 0.42;\n    const count = Math.round(Math.min(140, Math.max(36, s * s * 0.2)));\n    const yaw = t * 1.05;\n    const pitch = 0.38 + Math.sin(t * 0.7) * 0.08;\n    const base = dotRadius(s);\n    for (const point of sphere(count)) {\n      const [x, y, z] = rotate(point, yaw, pitch);\n      const depth = (z + 1) / 2;\n      const ripple = 0.78 + 0.22 * Math.sin(point[1] * 3.2 - t * 2.4);\n      dot(ctx, c + x * R, c + y * R, base * (0.5 + 0.7 * depth), (0.08 + 0.92 * depth * depth) * ripple);\n    }\n  },\n  0.6,\n);\n\n/** A globe of latitude rings with a bright band sweeping up and down, like a scan. */\nexport const ScanMark = createMark(\n  \"ScanMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const R = s * 0.42;\n    const rows = s < 22 ? 7 : s < 34 ? 9 : 11;\n    const band = Math.sin(t * 1.6) * 0.82;\n    const base = dotRadius(s) * 0.9;\n    // A hairline chord marks where the scan is.\n    const half = Math.sqrt(Math.max(0, 1 - band * band)) * R;\n    ctx.globalAlpha = 0.22;\n    ctx.fillRect(c - half, c + band * R - 0.25, half * 2, 0.5);\n    for (const point of globe(rows)) {\n      const [x, y, z] = rotate(point, t * 0.7, 0.24);\n      const depth = (z + 1) / 2;\n      const glow = Math.exp(-((y - band) ** 2) / 0.03);\n      const alpha = 0.06 + 0.36 * depth + glow * (0.35 + 0.6 * depth);\n      dot(ctx, c + x * R, c + y * R, base * (0.6 + 0.4 * depth) * (1 + 0.5 * glow), alpha);\n    }\n  },\n  0.35,\n);\n\nconst constellation = cached(\"constellation\", () =>\n  sphere(14).map(([x, y, z], i) => {\n    // Deterministic jitter so the nodes read as scattered, not as a grid.\n    const j = Math.sin(i * 12.9898) * 43758.5453;\n    const k = (j - Math.floor(j) - 0.5) * 0.5;\n    const len = Math.hypot(x + k, y - k * 0.6, z + k * 0.4) || 1;\n    return [(x + k) / len, (y - k * 0.6) / len, (z + k * 0.4) / len] as Point;\n  }),\n);\n\nconst links: [number, number][] = (() => {\n  const pairs = new Set<string>();\n  constellation.forEach((a, i) => {\n    constellation\n      .map((b, j) => ({ j, d: Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]) }))\n      .filter(({ j }) => j !== i)\n      .sort((p, q) => p.d - q.d)\n      .slice(0, 2)\n      .forEach(({ j }) => pairs.add(i < j ? `${i}-${j}` : `${j}-${i}`));\n  });\n  return [...pairs].map((pair) => pair.split(\"-\").map(Number) as [number, number]);\n})();\n\n/** Scattered nodes joined by hairlines, turning in space; a signal hops from link to link. */\nexport const ConstellationMark = createMark(\n  \"ConstellationMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const R = s * 0.4;\n    const yaw = t * 0.8;\n    const pitch = 0.5 + Math.sin(t * 0.5) * 0.15;\n    const projected = constellation.map((point) => rotate(point, yaw, pitch));\n    const base = dotRadius(s);\n\n    ctx.lineWidth = Math.max(0.5, s * 0.022);\n    for (const [a, b] of links) {\n      const p = projected[a]!;\n      const q = projected[b]!;\n      ctx.globalAlpha = 0.08 + 0.3 * ((p[2] + q[2] + 2) / 4);\n      ctx.beginPath();\n      ctx.moveTo(c + p[0] * R, c + p[1] * R);\n      ctx.lineTo(c + q[0] * R, c + q[1] * R);\n      ctx.stroke();\n    }\n    for (const [x, y, z] of projected) {\n      const depth = (z + 1) / 2;\n      dot(ctx, c + x * R, c + y * R, base * 1.1 * (0.6 + 0.6 * depth), 0.25 + 0.75 * depth);\n    }\n    // The signal eases along one link, then moves to the next.\n    const step = t * 1.2;\n    const [a, b] = links[Math.floor(step) % links.length]!;\n    const p = projected[a]!;\n    const q = projected[b]!;\n    const f = step - Math.floor(step);\n    const e = f * f * (3 - 2 * f);\n    const depth = (p[2] + (q[2] - p[2]) * e + 1) / 2;\n    dot(ctx, c + (p[0] + (q[0] - p[0]) * e) * R, c + (p[1] + (q[1] - p[1]) * e) * R, base * 1.5, 0.55 + 0.45 * depth);\n  },\n  1.1,\n);\n\n/** A dotted ring whose dots lift and brighten unevenly, like a voice level. */\nexport const RingMark = createMark(\n  \"RingMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const count = s < 22 ? 12 : 16;\n    const R = s * 0.34;\n    const base = dotRadius(s) * 1.05;\n    for (let i = 0; i < count; i++) {\n      const angle = (TAU * i) / count + t * 0.5;\n      const level = (Math.sin(t * 3.1 + i * 1.3) * Math.sin(t * 1.7 + i * 0.7) + 1) / 2;\n      const r = R + level * s * 0.07;\n      dot(ctx, c + Math.cos(angle) * r, c + Math.sin(angle) * r, base * (0.75 + 0.6 * level), 0.22 + 0.78 * level);\n    }\n  },\n  1.2,\n);\n\n/** Sparse dots on two radii; a light sweeps around them and leaves a fading trail. */\nexport const SparkMark = createMark(\n  \"SparkMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const count = 10;\n    const head = t * 2.2;\n    const base = dotRadius(s) * 1.1;\n    for (let i = 0; i < count; i++) {\n      const angle = (TAU * i) / count - Math.PI / 2;\n      const behind = (((head - angle) % TAU) + TAU) % TAU;\n      const lit = Math.exp(-behind * 0.8);\n      const r = (i % 2 ? 0.25 : 0.4) * s * (1 + 0.06 * lit);\n      dot(ctx, c + Math.cos(angle) * r, c + Math.sin(angle) * r, base * (0.85 + 0.65 * lit), 0.22 + 0.78 * lit);\n    }\n  },\n  0.9,\n);\n\n/** A dotted triangle that turns gently while light travels along its edges. */\nexport const PrismMark = createMark(\n  \"PrismMark\",\n  (ctx, t, s) => {\n    const c = s / 2;\n    const R = s * 0.42;\n    const perEdge = s < 22 ? 5 : 7;\n    const turn = Math.cos(Math.sin(t * 0.9) * 0.55);\n    // Lower the centroid slightly so the triangle looks centered, not top heavy.\n    const cy = c + s * 0.05;\n    const corners = [-Math.PI / 2, Math.PI / 6, (5 * Math.PI) / 6].map((angle) => [c + Math.cos(angle) * R * turn, cy + Math.sin(angle) * R]);\n    const headU = (t * 0.28) % 1;\n    const base = dotRadius(s);\n    for (let edge = 0; edge < 3; edge++) {\n      const [ax, ay] = corners[edge]!;\n      const [bx, by] = corners[(edge + 1) % 3]!;\n      for (let m = 0; m < perEdge; m++) {\n        const f = m / perEdge;\n        const u = (edge + f) / 3;\n        const d = Math.min(Math.abs(u - headU), 1 - Math.abs(u - headU));\n        const glow = Math.exp(-(d * d) / 0.006);\n        const corner = m === 0 ? 0.18 : 0;\n        dot(ctx, ax! + (bx! - ax!) * f, ay! + (by! - ay!) * f, base * (0.9 + 0.7 * glow + corner * 2), 0.32 + corner + 0.68 * glow);\n      }\n    }\n  },\n  0.8,\n);\n\nexport type MarkComponent = typeof OrbMark;\n\n/** The mark drawn for each activity. */\nexport const agentMarks: Record<AgentActivity, MarkComponent> = {\n  thinking: OrbMark,\n  searching: ScanMark,\n  working: ConstellationMark,\n  planning: SparkMark,\n  listening: RingMark,\n  shaping: PrismMark,\n};\n\n/** The mark for an activity on its own, e.g. inline after streaming text. */\nexport function AgentMark({ activity = \"thinking\", ...props }: MarkProps & { activity?: AgentActivity }) {\n  const Mark = agentMarks[activity];\n  return <Mark {...props} />;\n}\n\n// ---------------------------------------------------------------------------\n// The pill\n\nconst sizes: Record<AgentStateSize, { mark: number; pill: string; plain: string }> = {\n  sm: { mark: 14, pill: \"h-6 gap-1.5 pr-2.5 pl-2 text-xs\", plain: \"gap-1.5 text-xs\" },\n  md: { mark: 18, pill: \"h-8 gap-2 pr-3.5 pl-2.5 text-[13px]\", plain: \"gap-2 text-[13px]\" },\n  lg: { mark: 26, pill: \"h-11 gap-2.5 pr-5 pl-3 text-[15px]\", plain: \"gap-2.5 text-[15px]\" },\n};\n\nconst labelTone: Record<AgentPhase, string> = {\n  active: \"text-zinc-600 dark:text-zinc-400\",\n  idle: \"text-zinc-500\",\n  waiting: \"text-amber-700 dark:text-amber-400\",\n  done: \"text-zinc-600 dark:text-zinc-400\",\n  // The red x carries the failure; the text stays readable rather than shouting.\n  failed: \"text-zinc-600 dark:text-zinc-400\",\n  cancelled: \"text-zinc-500\",\n};\n\nconst swap =\n  \"transition-[opacity,scale,filter] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] starting:scale-90 starting:opacity-0 starting:blur-[2px] motion-reduce:transition-none\";\n\nexport interface AgentStateProps extends Omit<ComponentProps<\"span\">, \"children\" | \"role\"> {\n  /** What the agent is doing; picks the mark and the default verb. */\n  activity?: AgentActivity;\n  /** Replaces the verb, e.g. \"Reading the docs\". While active an ellipsis follows it. */\n  label?: ReactNode;\n  /**\n   * active animates the mark; waiting holds it still; idle, done, failed, and cancelled\n   * replace it with a still glyph. Defaults to active.\n   */\n  phase?: AgentPhase;\n  size?: AgentStateSize;\n  /** pill draws the rounded hairline container; plain is the mark and verb alone. */\n  variant?: \"pill\" | \"plain\";\n  /** Makes it a polite live region (role=\"status\") so changes to the label are announced. */\n  status?: boolean;\n}\n\n/** A rounded pill with an animated mark and a verb, for what an agent is doing right now. */\nexport function AgentState({\n  activity = \"thinking\",\n  label,\n  phase = \"active\",\n  size = \"md\",\n  variant = \"pill\",\n  status = false,\n  className,\n  ...props\n}: AgentStateProps) {\n  const config = sizes[size];\n  const text = label ?? (phase === \"active\" ? verbs[activity] : phaseLabels[phase]);\n  const active = phase === \"active\";\n  // The ellipsis is generated content, so the element's text stays exactly the label.\n  const ellipsis = active && !(typeof text === \"string\" && /(…|\\.\\.\\.)$/.test(text));\n\n  return (\n    <span\n      role={status ? \"status\" : undefined}\n      data-activity={activity}\n      data-phase={phase}\n      className={[\n        \"inline-flex max-w-full items-center leading-none whitespace-nowrap select-none\",\n        variant === \"pill\"\n          ? [\n              config.pill,\n              \"rounded-full border border-zinc-950/10 bg-zinc-950/[0.015] shadow-[0_1px_2px_rgb(0_0_0/0.04)]\",\n              \"dark:border-white/10 dark:bg-white/[0.03] dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]\",\n            ].join(\" \")\n          : config.plain,\n        className,\n      ]\n        .filter(Boolean)\n        .join(\" \")}\n      {...props}\n    >\n      <span key={`${phase}-${activity}`} aria-hidden=\"true\" className={`inline-flex shrink-0 ${swap}`}>\n        {active || phase === \"waiting\" ? (\n          <AgentMark\n            activity={activity}\n            size={config.mark}\n            paused={!active}\n            className={active ? \"text-zinc-950 dark:text-white\" : \"text-zinc-950/45 dark:text-white/45\"}\n          />\n        ) : (\n          <PhaseGlyph phase={phase} size={config.mark} />\n        )}\n      </span>\n      <span\n        key={typeof text === \"string\" ? text : undefined}\n        className={[\n          \"min-w-0 truncate py-0.5\",\n          labelTone[phase],\n          ellipsis ? \"after:content-['…']\" : \"\",\n          \"transition-[opacity,filter,translate] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] starting:translate-y-[3px] starting:opacity-0 starting:blur-[2px] motion-reduce:transition-none\",\n        ].join(\" \")}\n      >\n        {text}\n      </span>\n    </span>\n  );\n}\n\n/** Still glyphs for settled phases, scaled to the mark size so the pill keeps its width. */\nfunction PhaseGlyph({ phase, size }: { phase: Exclude<AgentPhase, \"active\" | \"waiting\">; size: number }) {\n  const tone =\n    phase === \"done\" ? \"text-emerald-600 dark:text-emerald-400\" : phase === \"failed\" ? \"text-red-600 dark:text-red-400\" : \"text-zinc-400 dark:text-zinc-500\";\n  return (\n    <svg\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={size >= 24 ? 1.1 : 1.5}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className={`shrink-0 ${tone}`}\n      style={{ width: size, height: size }}\n    >\n      {phase === \"done\" ? (\n        <path\n          d=\"m4.25 8.4 2.5 2.45 5-5.6\"\n          pathLength={1}\n          strokeDasharray=\"1\"\n          className=\"[stroke-dashoffset:0] transition-[stroke-dashoffset] delay-75 duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] starting:[stroke-dashoffset:1] motion-reduce:transition-none\"\n        />\n      ) : phase === \"failed\" ? (\n        <path d=\"m5 5 6 6m0-6-6 6\" />\n      ) : phase === \"cancelled\" ? (\n        <>\n          <circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeOpacity=\"0.6\" />\n          <path d=\"m5.6 10.4 4.8-4.8\" />\n        </>\n      ) : (\n        <circle cx=\"8\" cy=\"8\" r=\"5.5\" strokeDasharray=\"1.6 2.2\" />\n      )}\n    </svg>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "import { AgentState } from \"@/components/shaken/agent/agent-state\";\n\nexport default function AgentStateExample() {\n  return (\n    <div className=\"flex flex-wrap items-center justify-center gap-3\">\n      <AgentState activity=\"thinking\" status />\n      <AgentState activity=\"searching\" label=\"Searching the docs\" />\n      <AgentState activity=\"working\" phase=\"done\" label=\"Opened a pull request\" />\n    </div>\n  );\n}\n"
  }
}
