{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-presence",
  "title": "AgentPresence",
  "description": "The person's always-visible sign of which of their agents are listening to something on their behalf, such as a meeting, with Stop one click away.",
  "registryDependencies": [
    "@ouro/avatar",
    "@ouro/ax-component",
    "@ouro/button",
    "@ouro/lib-announce",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-focus-handoff",
    "@ouro/lib-refs",
    "@ouro/lib-use-dev-messages",
    "@ouro/popover"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/agent-presence/agent-presence-styles.ts",
      "content": "export { agentPresenceAx, agentPresenceSizes, doingClass, unreadDotClass };\n\n// Class strings, values and the agent side for AgentPresence, apart from the component so its\n// file exports only components (React Fast Refresh). Class strings are literal so the app's\n// Tailwind finds them when it compiles.\n\nimport { defineComponentAx } from \"@/registry/ouro/ax/component\";\n\n/** The chip's sizes, which are Button's. @internal */\nconst agentPresenceSizes = [\"sm\", \"md\", \"lg\"] as const;\n\n/**\n * The unread dot: a small dot in the primary colour, CanvasText under forced colours. @internal\n * @claim \"The unread dot: a small dot\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > shows a dot when an agent left something, and says so in the chip's name)\n */\nconst unreadDotClass = \"inline-block size-2 shrink-0 rounded-full bg-primary forced-colors:bg-[CanvasText]\";\n\n/** What an agent listens for, under its name: the muted foreground mixed toward the foreground, as on a muted surface. @internal */\nconst doingClass = \"text-sm text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))]\";\n\n/**\n * AgentPresence's agent side, declared with Ouro AX's `defineComponentAx`. Agents may read which\n * of the person's agents are listening and what each listens for. An agent may stop only its own\n * listening, its own row: `stop` is `scope: \"self\"`, so its twin says who is calling\n * (`--agent <me>`) and the kit refuses a call on any other agent's row, with the reason. Another\n * agent's Stop and Stop all are the person's, since the person asked those agents to listen.\n * Nothing here starts listening: that stays the person's, from the app.\n *\n * @example\n * agentPresenceAx.actions.map((action) => action.id); // [\"stop\", \"stop-all\"]\n * @claim \"Agents may read which of the\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n * @claim \"An agent may stop only its own\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > through an app's stop twin, which the kit scopes to the calling agent's row > lets an agent stop its own row)\n * @claim \"the kit refuses a call on any other agent's row, with the reason\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > through an app's stop twin, which the kit scopes to the calling agent's row > refuses an agent on another agent's row, with the reason, and leaves the row)\n * @claim \"its twin says who is calling\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > binds stop to a twin that says who is calling, and Stop all to words that refuse)\n * @claim \"Another agent's Stop and Stop all are the person's\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n * @claim \"Nothing here starts listening\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n */\nconst agentPresenceAx = defineComponentAx({\n  component: \"AgentPresence\",\n  reads: [\n    {\n      id: \"listening\",\n      summary: \"Which of the person's agents are listening, and what each listens for.\",\n      fields: [\"agent\", \"doing\"],\n      consent: \"none\",\n    },\n  ],\n  actions: [\n    { id: \"stop\", summary: \"Stop your own listening for the person: your row only, never another agent's.\", effect: \"private\", agent: true, scope: \"self\" },\n    { id: \"stop-all\", summary: \"Stop every agent listening for the person.\", effect: \"private\", personOnly: \"You can't stop every agent; only the person can. Stop your own listening with stop.\" },\n  ],\n});\n",
      "type": "registry:ui",
      "target": "@components/ouro/agent-presence/agent-presence-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/agent-presence/agent-presence.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useMemo, useRef, useState, type JSX, type Ref } from \"react\";\nimport { agentPresenceSizes, doingClass, unreadDotClass } from \"@/registry/ouro/components/ouro/agent-presence/agent-presence-styles\";\nimport { Avatar } from \"@/registry/ouro/components/ouro/avatar/avatar\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Popover } from \"@/registry/ouro/components/ouro/popover/popover\";\nimport { announce } from \"@/registry/ouro/lib/ouro/announce\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { handOffFocus, useFocusHandoff } from \"@/registry/ouro/lib/ouro/focus-handoff\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** One agent listening for the person. */\nexport interface ListeningAgent {\n  /** Stays the same while the agent listens; `onStop` gets it back. */\n  id: string;\n  /** What the person calls the agent, by its role: \"inbox agent\". */\n  name: string;\n  /** What it listens for, in a few words: \"listening for your name, and anything about the empty state\". */\n  doing?: string | undefined;\n}\n\n/**\n * The words AgentPresence says, for apps in other languages.\n *\n * @claim \"The words AgentPresence says, for apps\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > takes its words in another language)\n */\nexport interface AgentPresenceLabels {\n  /** The chip for one agent. @default (name) => `${name} listening` */\n  one?: ((name: string) => string) | undefined;\n  /** The chip for several. @default (count) => `${count} agents listening` */\n  many?: ((count: number) => string) | undefined;\n  /** Said once when an agent starts listening. @default (name) => `${name} is now listening` */\n  started?: ((name: string) => string) | undefined;\n  /** Said once when an agent stops, whoever stopped it. @default (name) => `${name} stopped` */\n  stopped?: ((name: string) => string) | undefined;\n  /**\n   * Each agent's Stop button. Screen readers hear the agent's name after it. @default \"Stop\"\n   * @claim \"Each agent's Stop button.\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > opens a popover named by its label, with each agent, what it listens for and a Stop)\n   */\n  stop?: string | undefined;\n  /**\n   * The button that stops every agent. @default \"Stop all\"\n   * @claim \"The button that stops every agent.\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > stops every agent with Stop all, which shows only with two or more)\n   */\n  stopAll?: string | undefined;\n  /** What screen readers hear for the unread dot. @default \"Something new from your agents\" */\n  unread?: string | undefined;\n  /** The popover's close button, which shows when it has keyboard focus. @default \"Close\" */\n  close?: string | undefined;\n}\n\n/** Props for {@link AgentPresence}. */\nexport interface AgentPresenceProps {\n  /**\n   * The agents listening now. With none, AgentPresence renders nothing; keep it mounted, so it\n   * can say when an agent stops or starts.\n   * @claim \"With none, AgentPresence renders nothing;\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > renders nothing while no agent listens, and comes back when one does)\n   */\n  agents: readonly ListeningAgent[];\n  /**\n   * Names the list of agents: the popover's title, \"Agents listening\". It is always required.\n   * @claim \"It is always required.\" registry/ouro/components/ouro/agent-presence/agent-presence.test-d.ts verify:fileLine(registry/ouro/components/ouro/agent-presence/agent-presence.test-d.ts, /expectTypeOf<\\{ agents: ListeningAgent\\[\\]; onStop: \\(id: string\\) => void \\}>\\(\\)\\.not\\.toExtend<AgentPresenceProps>/)\n   * @claim \"Names the list of agents: the\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > opens a popover named by its label, with each agent, what it listens for and a Stop)\n   */\n  label: string;\n  /**\n   * Called with an agent's `id` when the person presses its Stop. Stop the agent and drop it\n   * from `agents`; AgentPresence says \"inbox agent stopped\" once it has gone. The person may stop\n   * any agent here.\n   * @claim \"Called with an agent's `id` when\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > stops one agent, says so once it has gone, and keeps focus in the list)\n   * @claim \"The person may stop any agent here.\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > through an app's stop twin, which the kit scopes to the calling agent's row > lets the person stop any agent's row)\n   */\n  onStop: (id: string) => void;\n  /**\n   * Called when the person presses Stop all, which shows with two agents or more. Without it,\n   * Stop all calls `onStop` for each agent.\n   * @claim \"Called when the person presses Stop\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > stops every agent with Stop all, which shows only with two or more)\n   * @claim \"Without it, Stop all calls `onStop`\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > calls onStop for each agent from Stop all when there is no onStopAll)\n   */\n  onStopAll?: (() => void) | undefined;\n  /**\n   * The chip's size, Button's sizes. @default \"sm\"\n   * @claim \"The chip's size, Button's sizes.\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > is as tall as a Button of its size, sm by default)\n   */\n  size?: \"sm\" | \"md\" | \"lg\" | (string & { 'Use \"sm\", \"md\" or \"lg\"': never }) | undefined;\n  /**\n   * Only the sparkle and a count, for a tight bar or a floating mini-window. Its name still\n   * says who is listening.\n   * @claim \"Only the sparkle and a count, for\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > shows only the sparkle and the count when compact, and its name still says who)\n   */\n  compact?: boolean | undefined;\n  /**\n   * Shows a dot on the chip: an agent left something for the person. AgentPresence opens\n   * nothing for it; the app shows what was left where it belongs.\n   * @claim \"Shows a dot on the chip: an\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > shows a dot when an agent left something, and says so in the chip's name)\n   */\n  unread?: boolean | undefined;\n  /** The words it says, for other languages. */\n  labels?: AgentPresenceLabels | undefined;\n  /** Layout only: margins, placement (`ms-auto`). Appearance classes warn in development; use `size`. */\n  className?: string | undefined;\n  ref?: Ref<HTMLSpanElement> | undefined;\n\n  /** Not a prop. The agents are `agents`: `<AgentPresence agents={[{ id: \"inbox\", name: \"inbox agent\" }]}>`. */\n  listeners?: { 'Use agents={[{ id, name, doing }]}': never };\n  /** Not a prop. Ouro UI says `onStop`, called with the agent's id: `<AgentPresence onStop={(id) => stop(id)}>`. */\n  onRemove?: { 'Use onStop={(id) => stop(id)}': never };\n  /**\n   * Not a prop. AgentPresence never hides while an agent listens; it renders nothing only when `agents` is empty.\n   * @claim \"AgentPresence never hides while an agent\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > never hides itself while an agent listens: not in a narrow bar, not after its popover closes, not as time passes)\n   * @claim \"AgentPresence never hides while an agent\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > renders nothing while no agent listens, and comes back when one does)\n   */\n  autoHide?: { 'AgentPresence never hides while an agent listens; pass agents={[]} when none does': never };\n  /** Not a prop. The small form is `compact`: `<AgentPresence compact>`. */\n  variant?: { 'Use compact for the sparkle and a count': never };\n}\n\ntype Size = (typeof agentPresenceSizes)[number];\ntype Words = { [Key in keyof AgentPresenceLabels]-?: NonNullable<AgentPresenceLabels[Key]> };\n\nconst words: Words = {\n  one: (name) => `${name} listening`,\n  many: (count) => `${count} agents listening`,\n  started: (name) => `${name} is now listening`,\n  stopped: (name) => `${name} stopped`,\n  stop: \"Stop\",\n  stopAll: \"Stop all\",\n  unread: \"Something new from your agents\",\n  close: \"Close\",\n};\n\n/** The agent sparkle, in the chip's own colour. */\nfunction Sparkle(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 12 12\" data-ouro-agent-presence-sparkle=\"\" className=\"size-[1.1em] shrink-0\">\n      <path d=\"M6 0Q6.7 5.3 12 6 6.7 6.7 6 12 5.3 6.7 0 6 5.3 5.3 6 0Z\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n\n/**\n * The person's always-visible sign of which of their agents are listening to something on their\n * behalf, such as a meeting, with Stop one click away. A chip with the agent sparkle says\n * \"inbox agent listening\", or \"2 agents listening\"; it opens a popover that lists each agent, what\n * it listens for and a Stop, plus Stop all with two or more. It never hides itself while an agent\n * listens (no fading, no collapsing), and renders nothing when none does. `compact` shows only the\n * sparkle and a count, and `unread` a dot when an agent left something for the person.\n *\n * The chip is a button named by the count and the names (\"2 agents listening: inbox agent,\n * research agent\"). When an agent starts or stops listening, screen readers hear it once,\n * politely (\"inbox agent is now listening\", \"inbox agent stopped\"). When a Stop goes with its\n * agent, focus moves to the next Stop, and when the last agent goes, to the control after the\n * chip.\n *\n * Its agent side, `agentPresenceAx` in `agent-presence-styles.ts`, lets agents read who is\n * listening and what for (consent `none`). An agent may stop only its own listening: `stop` is\n * `scope: \"self\"`, so Ouro AX refuses an agent's call on another agent's row. Stop on another\n * agent's row and Stop all are the person's, because the person asked those agents to listen. It\n * offers no way to start listening: that stays the person's.\n *\n * Use `Avatar` or `Badge` instead to show who is present in a conversation, and `toast()` for\n * a one-off notice.\n *\n * @claim \"The person's always-visible sign of which\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > never hides itself while an agent listens: not in a narrow bar, not after its popover closes, not as time passes)\n * @claim \"A chip with the agent sparkle says\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > is a chip that names one agent, or counts several)\n * @claim \"it opens a popover that lists each\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > opens a popover named by its label, with each agent, what it listens for and a Stop)\n * @claim \"It never hides itself while an agent\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > never hides itself while an agent listens: not in a narrow bar, not after its popover closes, not as time passes)\n * @claim \"It never hides itself while an agent\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > renders nothing while no agent listens, and comes back when one does)\n * @claim \"The chip is a button named by\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > is a chip that names one agent, or counts several)\n * @claim \"When an agent starts or stops listening,\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > says once, politely, when an agent starts or stops listening)\n * @claim \"When a Stop goes with its agent,\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > stops one agent, says so once it has gone, and keeps focus in the list)\n * @claim \"When a Stop goes with its agent,\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence > moves focus to the control after the chip when the last agent goes)\n * @claim \"Its agent side, `agentPresenceAx` in `agent-presence-styles.ts`,\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n * @claim \"An agent may stop only its own listening\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > through an app's stop twin, which the kit scopes to the calling agent's row > lets an agent stop its own row)\n * @claim \"so Ouro AX refuses an agent's call on another agent's row\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > through an app's stop twin, which the kit scopes to the calling agent's row > refuses an agent on another agent's row, with the reason, and leaves the row)\n * @claim \"Stop on another agent's row and Stop\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n * @claim \"It offers no way to start listening\" registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx verify:testExists(registry/ouro/components/ouro/agent-presence/agent-presence.test.tsx::AgentPresence agent side > declares one read, a stop an agent takes only on its own row, and Stop all as the person's, each on a control that names it, and nothing that starts listening)\n * @group Feedback\n * @see https://ui.ouroboros.bot/docs/agent-presence\n *\n * @example\n * <AgentPresence\n *   label=\"Agents listening\"\n *   agents={[{ id: \"inbox\", name: \"inbox agent\", doing: \"listening for your name\" }]}\n *   onStop={(id) => stopListening(id)}\n * />\n * <AgentPresence label=\"Agents listening\" agents={agents} onStop={stop} onStopAll={stopAll} compact unread />\n */\nexport function AgentPresence(props: AgentPresenceProps): JSX.Element | null {\n  const {\n    agents,\n    label,\n    onStop,\n    onStopAll,\n    size: sizeProp = \"sm\",\n    compact = false,\n    unread = false,\n    labels,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    listeners,\n    onRemove,\n    autoHide,\n    variant,\n  } = props;\n  const size: Size = (agentPresenceSizes as readonly string[]).includes(sizeProp) ? (sizeProp as Size) : \"sm\";\n  // Merged once per labels object, so an app that keeps its labels in a constant merges them once.\n  const text = useMemo(() => ({ ...words, ...Object.fromEntries(Object.entries(labels ?? {}).filter(([, value]) => value !== undefined)) }) as Words, [labels]);\n\n  useAppearanceClassNameCheck(\n    \"AgentPresence\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; AgentPresence takes its look from the theme, and its height from size`\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"AgentPresence\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => {\n          const seen = new Set<string>();\n          const twice = agents.find((agent) => seen.size === seen.add(agent.id).size);\n          return [\n            !label && [\"label is required; it names the list of agents for screen readers\", '<AgentPresence label=\"Agents listening\">'],\n            size !== sizeProp && [`size=\"${String(sizeProp)}\" is not a size; use \"sm\", \"md\" or \"lg\"`, '<AgentPresence size=\"sm\">'],\n            twice !== undefined && [`two agents share the id \"${twice.id}\", so Stop cannot tell them apart`, `<AgentPresence agents={[{ id: \"${twice.id}-2\", name: \"${twice.name}\" }]}>`],\n            listeners !== undefined && [\"listeners is not a prop\", '<AgentPresence agents={[{ id: \"inbox\", name: \"inbox agent\" }]}>'],\n            onRemove !== undefined && [\"onRemove is not a prop\", \"<AgentPresence onStop={(id) => stop(id)}>\"],\n            autoHide !== undefined && [\"autoHide is not a prop; AgentPresence never hides while an agent listens\", \"<AgentPresence agents={listening}>\"],\n            variant !== undefined && [\"variant is not a prop\", \"<AgentPresence compact>\"],\n          ];\n        }\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const [open, setOpen] = useState(false);\n  // With no agent the popover closes, so it never reopens on its own when one comes back.\n  if (agents.length === 0 && open) setOpen(false);\n\n  // Said once when an agent starts or stops listening; the agents on first render are no news.\n  const previous = useRef<ReadonlyMap<string, string> | null>(null);\n  const who = JSON.stringify(agents.map((agent) => [agent.id, agent.name]));\n  useEffect(() => {\n    const now = new Map(agents.map((agent) => [agent.id, agent.name]));\n    const before = previous.current;\n    previous.current = now;\n    if (before === null) return;\n    const news = [\n      ...[...before].filter(([id]) => !now.has(id)).map(([, name]) => text.stopped(name)),\n      ...[...now].filter(([id]) => !before.has(id)).map(([, name]) => text.started(name)),\n    ];\n    if (news.length > 0) announce(news.join(\". \"));\n    // Who listens is the news; new words for the same agents are not.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [who]);\n\n  const chip = useRef<HTMLButtonElement>(null);\n  const list = useRef<HTMLDivElement>(null);\n  // When the chip goes with the last agent, focus moves to the control after it, from the\n  // popover too: React detaches the root's ref before its children's, while the chip is still\n  // there and the popover still holds focus.\n  const [leave] = useState(() => (element: HTMLSpanElement) => () => {\n    if (list.current?.contains(element.ownerDocument.activeElement)) chip.current!.focus();\n    handOffFocus(element);\n  });\n  const rootRef = useMergedRef(ref, leave);\n  // A row or Stop all that goes while it holds focus hands it to the next Stop, else the one\n  // before it. Every agent left has a Stop, so the search never leaves the popover; with no agent\n  // left, the chip goes too and `leave` moves focus on.\n  const handoff = useFocusHandoff<HTMLElement>();\n\n  if (agents.length === 0) return null;\n\n  const names = agents.map((agent) => agent.name);\n  const several = agents.length > 1;\n  const said = several ? text.many(agents.length) : text.one(names[0]!);\n  const spoken = [several ? `${said}: ${names.join(\", \")}` : said, unread && text.unread].filter(Boolean).join(\". \");\n  const stopAll = onStopAll ?? (() => agents.forEach((agent) => onStop(agent.id)));\n\n  return (\n    <span ref={rootRef} data-ouro=\"agent-presence\" className={cn(\"inline-flex min-w-0\", className)}>\n      <Button\n        ref={chip}\n        data-ouro-control=\"agent-presence\"\n        data-ouro-part=\"trigger\"\n        variant=\"soft\"\n        tone=\"primary\"\n        size={size}\n        aria-label={spoken}\n        aria-haspopup=\"dialog\"\n        aria-expanded={open}\n        onClick={() => setOpen((was) => !was)}\n      >\n        <Sparkle />\n        {compact ? <span className=\"tabular-nums\">{agents.length}</span> : <span>{said}</span>}\n        {unread && <span aria-hidden=\"true\" data-ouro-agent-presence-unread=\"\" className={unreadDotClass} />}\n      </Button>\n      <Popover title={label} closeLabel={text.close} open={open} onOpenChange={setOpen} anchor={chip} align=\"start\">\n        <div ref={list} className=\"grid gap-3\">\n          <ul className=\"m-0 grid list-none gap-3 p-0\">\n            {agents.map((agent) => (\n              <li key={agent.id} ref={handoff} className=\"flex items-center gap-3\">\n                <Avatar name={agent.name} alt=\"\" shape=\"agent\" size=\"sm\" />\n                <span className=\"grid min-w-0 flex-1 gap-0.5\">\n                  <span className=\"text-sm font-medium text-foreground\">{agent.name}</span>\n                  {agent.doing ? <span className={doingClass}>{agent.doing}</span> : null}\n                </span>\n                <Button\n                  data-ouro-control=\"agent-presence\"\n                  data-ouro-part=\"stop\"\n                  data-ax-action=\"stop\"\n                  size=\"sm\"\n                  variant=\"outline\"\n                  tone=\"secondary\"\n                  aria-label={`${text.stop} ${agent.name}`}\n                  onClick={() => onStop(agent.id)}\n                >\n                  {text.stop}\n                </Button>\n              </li>\n            ))}\n          </ul>\n          {several && (\n            <div ref={handoff} className=\"grid\">\n              <Button data-ouro-control=\"agent-presence\" data-ouro-part=\"stop-all\" data-ax-action=\"stop-all\" size=\"sm\" variant=\"soft\" tone=\"destructive\" fullWidth onClick={stopAll}>\n                {text.stopAll}\n              </Button>\n            </div>\n          )}\n        </div>\n      </Popover>\n    </span>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/agent-presence/agent-presence.tsx"
    }
  ],
  "docs": "The person's always-visible sign of which of their agents are listening to something on their behalf, such as a meeting, with Stop one click away. Import: import { AgentPresence } from \"@/components/ouro/agent-presence/agent-presence\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: avatar, ax-component, ax-effects, button, popover, sheet, skeleton, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/agent-presence.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}