# Agent fleet

> Every lead agent and its sub-agents in one view: live cost and time, elbow lines to the selected lead’s team, task lists and questions that wait for you.

A fleet of agents at work. Lead agents sit in a column, each with its model, status, task, the tools it uses and a footer that says what needs you, what failed or how many of its sub-agents run. Select a lead and elbow lines draw out to its sub-agents, while the other leads dim; a sub-agent’s own sub-agents hang under it. Hover or focus a sub-agent for its task list with each task’s time. One that needs you has an Answer button that opens its question with Reject and Approve. Cost and time count up live on every running card and in the header.

A React component by Bruno Delorence: https://brunodelorence.com/components/agent-fleet. MIT License, Copyright (c) 2026 Bruno Delorence.

Category: AI.

## Anatomy

1. **Summary**: Agents and sub-agents, how many run, how many need you (left out at zero), and the total cost, ticking.
2. **Lead**: A tab: tile, name, model and status, the task with its tools, then how its sub-agents stand, its cost and its time.
3. **Status pill**: Running turns, Done checks, Needs you shows a clock, Queued a dot, Failed a cross.
4. **Tools**: The tools the agent uses, as small overlapping tiles before its task.
5. **Lines**: Elbows from the selected lead to each of its sub-agents, and from a sub-agent down to its own. They draw themselves in on each selection.
6. **Sub-agent**: The same face as a lead, with its cost and time on the left of the footer and its task count on the right.
7. **Answer**: On a sub-agent that needs you, in place of its task count. Opens its question.

## Properties

### Status (`SubAgent.status`)

1. **Running (default)**: At work: the ring turns, and time and cost count up each second.
2. **Needs you**: Waiting on a question: time counts, cost does not, and Answer replaces the task count. Give it an `ask`.
3. **Done**: Finished: its time and cost hold still.
4. **Queued**: Not started: no time yet, $0.00.
5. **Failed**: Stopped by an error. Its lead’s footer counts it.

Set it from what the agent is doing. A failed task inside a running agent goes in its steps, and the lead says `1 failed` without stopping the agent.

### Layout

1. **Side by side (default)**: Over 540 px: sub-agents in a column beside the leads, centred on the selected one.
2. **Stacked**: At 540 px and under: sub-agents under their lead, 32 px in, the lines dropping from its tile.

Chosen by the component from its own width (a container query), never by a prop.

## When to use

- Several lead agents at work at once, each handing parts of its job to sub-agents, where the reader needs the whole tree in one view.
- A fleet whose cost and running time matter while it works: every card counts both up live.
- Sub-agents that stop to ask, where an Answer button on the card beats a separate inbox.
- A panel or a page about 560 px wide or more; under 540 px the sub-agents stack under their lead.

## When not to use

- One agent with no sub-agents. Use a step list or a progress line in the chat.
- Work over time, where when things happened matters more than who did them. Use a timeline or lanes.
- Dozens of agents. The column gets long and the lines tangle: use a table with status and cost columns, and filters.
- Approvals alone, with nothing else to watch. Use an approval card or an inbox.

### Reading the fleet

- **Left is who leads**, right is who they handed work to; a sub-agent’s own sub-agents hang under it.
- **The footer is the summary**: a lead’s says what needs you first, then what failed, then how many of its sub-agents run.
- **Cost counts up while an agent runs**; the header adds every card. A waiting agent keeps its time running but spends nothing.

### Answers

A sub-agent that needs the reader shows `Needs you` and an Answer button. Its question opens over its task list: Approve takes what it proposes, Reject the other choice, and either way it runs again; `onAnswer` hears which. Ask for a choice the agent can’t make alone, and say in the question what Approve picks.

### Agent fleet vs. task list

**Agent fleet**
- Several leads and the sub-agents under each.
- Shows who does what, what it costs, and who waits on you.

**Task list**
- One agent’s steps in order, with their times.
- Here it is the popover; on its own it suits a chat or a run log.

## Do’s and don’ts

- **Do**: Write the task as a short imperative with its object, so most of it fits on one line.
- **Don’t**: Write a long sentence. The card cuts it with an ellipsis, and the part that tells agents apart is lost.
- **Do**: Put the choice in the question and say what Approve picks.
- **Don’t**: Ask “Should I continue?”. Neither button says what happens next.
- **Do**: Keep a lead to two to five sub-agents, so its column stays level with it.
- **Don’t**: Give a lead seven or more. The column runs far past its lead and the reader scrolls to see who did what.

## Content

Every card has three lines: who it is, what it does, where it stands.

- **Names** are roles: `Researcher`, `Release manager`. The model goes on the line under it.
- **Tasks** start with a verb and say what with: `Reply to 19 questions about invoices`.
- **Steps** in the task list are shorter still: `Tag them by product`. A question is a step that starts with `Ask:`.
- **The question** is one or two sentences: the choice, then what Approve does.

## Installation

Install it with the shadcn CLI, into components/agent-fleet of any React project:

```sh
npx shadcn@latest add https://brunodelorence.com/r/agent-fleet.json
```

Or add the registry to components.json once, as a namespace that coding agents and the shadcn MCP server search by name:

```json
{
  "registries": {
    "@brunodelorence": "https://brunodelorence.com/r/{name}.json"
  }
}
```

```sh
npx shadcn@latest add @brunodelorence/agent-fleet
```

Or copy all the source files below into one folder of your project. Either way it needs React 19 and a bundler with CSS Modules (Next.js, Vite).

It has a dark colour scheme. Its colours are CSS light-dark() pairs, kept inside @supports so that builds which rewrite light-dark() for older browsers leave them alone: it follows your page’s color-scheme (light unless the page sets one) or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

## Usage

```tsx
'use client';

import { AgentFleet, type Lead } from './agent-fleet';

const leads: Lead[] = [
  {
    id: 'docs',
    name: 'Docs lead',
    model: 'Large · v5.5',
    mark: 'petal',
    status: 'running',
    task: 'Update the guides for version 3',
    tools: ['doc', 'chat'],
    cost: 0.12,
    rate: 0.001,
    seconds: 380,
    subs: [
      {
        id: 'editor',
        name: 'Editor',
        model: 'Medium · v5.5',
        mark: 'petal',
        status: 'needs',
        task: 'Rewrite the install guide',
        tools: ['doc'],
        cost: 0.05,
        seconds: 210,
        ask: 'Drop the guide for version 1? Approve to remove it.',
        steps: [
          { label: 'Rewrite the steps', tool: 'doc', status: 'done', seconds: 160 },
          { label: 'Ask: drop the old guide?', tool: 'chat', status: 'needs' },
        ],
      },
    ],
  },
];

export function DocsFleet() {
  return (
    <AgentFleet
      leads={leads}
      onAnswer={(sub, decision) => console.log(sub.id, decision)}
      autoplay={false}
    />
  );
}
```

## States

- **Lead selected**: The first lead is selected: its four sub-agents on the right, a fourth under the coder; the other leads dim.
- **Another lead**: Selecting another lead swaps the column: its cards fade in one after another and the lines draw in.
- **Task list**: Hover, focus or tap a sub-agent: its tasks, how many are done, and how long each took.
- **Question open**: Answer opens what the sub-agent asks, with Reject and Approve, over its task list. Either way it runs again.
- **All done**: A finished lead: every pill Done, the footer says All 3 done, and nothing counts up.
- **Stacked**: At 390 px: the sub-agents hang under their lead, and the leads after it move down to make room.

## How it works

- The fleet is live: a one-second interval, running only while it is on screen, adds a second and the agent’s rate in dollars to every running card; a card that needs you keeps counting time but not money. The header and each lead add up their sub-agents’ costs on render.
- A price that changes fades its changed characters in from 30 % opacity over 0.7 s: the ticker compares the new string with the last one and gives only the changed characters a fresh key, so they remount and replay the animation.
- The sub-agents’ column centres on its lead and is clamped inside the leads’ column: top = clamp(0, lead middle − column height / 2, leads height − column height). The lines are drawn from offsets (offsetLeft/offsetTop up to the board), never from boxes, so the cards’ 4 px entrance lift does not bend them.
- Each line is one SVG path: out of the lead’s right edge at its task line, 25 px to a trunk halfway across the 50 px gap, a 6 px quadratic elbow, down to the sub-agent’s name line, another elbow and in. A sub-agent’s own sub-agents drop from its tile’s centre. Each path has pathLength 1 and draws in by its dash offset over 0.42 s.
- On each selection the sub-agent cards remount: they fade and rise 4 px in 0.24 s, 55 ms apart, with cubic-bezier(0.2, 0.7, 0.3, 1). The leads that are not selected fade their faces to 50 %.
- Under 540 px of width (a container query) the column goes absolute under its lead, 32 px in, and the lead after it gets a top margin as tall as the column, so the rest move down to make room.
- The demo switches to the support lead, opens the triage task list, goes back, answers the writer’s question with Approve, then visits the other two leads. Any input of the reader’s stops it for good.

## API reference

- **leads** (`readonly Lead[]`, default `FLEET`): The lead agents: an id, name, model, mark (petal, rings, diamond), status, task, tools, its own cost and rate in dollars, its seconds of work, and its sub-agents. A sub-agent has the same fields plus its steps, an ask when it needs you, and sub-agents of its own.
- **title** (`string`, default `'Fleet'`): The header’s title.
- **defaultSelected** (`string`): The lead selected on mount, by id; the first one without it.
- **live** (`boolean`, default `true`): Running agents count up their time and cost each second while on screen.
- **onAnswer** (`(sub: SubAgent, decision: 'approve' | 'reject') => void`): Called when the reader approves or rejects what a sub-agent asks.
- **defaultTasks** (`string`): Opens with this sub-agent’s task list showing (its id); turns the demo off.
- **defaultAnswer** (`string`): Opens with this sub-agent’s question showing (its id); turns the demo off.
- **autoplay** (`boolean`, default `true`): While on screen and untouched, a demo pointer shows the fleet at work. Never under reduced motion; the first real input stops it.
- **colorScheme** (`'light' | 'dark' | 'system'`): Light or dark colours, or the reader’s; without it, the page’s color-scheme.
- **className** (`string`): Classes for the stage.

## Accessibility

### Leads and sub-agents

- Leads are vertical tabs in a `tablist`: one Tab stop, arrows move and select, Home and End go to the ends. The sub-agents are its `tabpanel`.
- Each sub-agent is a button named by its name, model, status, task, cost, time and task count. Focus from the keyboard, hover or a tap shows its task list; Escape hides it.
- Status is a word on every pill, never colour alone (WCAG 1.4.1).

### Answers

- Answer is a button named `Answer Writer`, with `aria-haspopup="dialog"` and `aria-expanded`.
- The question opens as a non-modal dialog, named by its title and described by its text; opened by the reader, it moves focus to Approve. Escape closes it and gives focus back to Answer.
- After a decision, focus goes back to the card and the outcome is read out in a polite live region (WCAG 4.1.3).

### Motion

With reduced motion set, the running rings stop turning, the cards and lines appear without fading or drawing in, and a changed price does not fade. Time and cost still count up, as text. The demo pointer never plays under reduced motion, and the reader’s first input stops it for good (WCAG 2.2.2).

### In this build

- Leads are vertical tabs: one Tab stop, Up and Down (or Left and Right) move and select, Home and End jump to the ends. The sub-agents are the tab panel, labelled by the selected lead.
- Each sub-agent is a button whose name reads its name, model, status, task, cost, time and task count. Keyboard focus, hover or a tap shows its task list; Escape hides it.
- Answer has aria-haspopup="dialog" and aria-expanded. The question is a non-modal dialog named by its title and described by its text; opened by the reader, it takes focus on Approve, and Escape gives focus back to Answer.
- Decisions are read out in a polite live region, and focus goes back to the sub-agent’s card.
- Status is always a word on its pill, never colour alone. Focus shows a 2 px ring.
- Under reduced motion, rings stop turning, cards and lines appear without motion and prices do not fade; the demo never plays.

## Source

### agent-fleet/agent-fleet.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  Fragment,
  useCallback,
  useEffect,
  useEffectEvent,
  useId,
  useLayoutEffect,
  useRef,
  useState,
  type KeyboardEvent as ReactKeyboardEvent,
  type PointerEvent as ReactPointerEvent,
} from 'react';
import { FLEET, type AgentStatus, type Lead, type Step, type SubAgent } from './data';
import { DemoPointer, runDemo, type Point } from './demo-pointer';
import { AgentGlyph, Progress, Sparkle, StatusIcon, ToolGlyph } from './glyphs';
import { useAutoplay } from './use-autoplay';
import styles from './agent-fleet.module.css';

/*
 * Agent fleet: every lead agent and the sub-agents it handed work to, in one view. Leads sit in
 * a column on the left; the selected one draws elbow lines to its sub-agents on the right (and a
 * sub-agent's own sub-agents hang under it), while the others dim. Hover or focus a sub-agent for
 * its task list; one that needs you has an Answer button that opens its question, with Approve
 * and Reject. At 540 px of width and under, the sub-agents stack under their lead instead.
 *
 * - The fleet is live: each second, every running agent adds a second and its rate in dollars;
 *   one that waits for you keeps counting time but not money. A cost's changed digits fade in.
 * - The sub-agents' column centres on its lead, held inside the leads' column, so it sits
 *   level with the lead it belongs to. Their positions are measured by offsets (never boxes, so
 *   the cards' entrance transforms do not bend the lines), and the lines are drawn from them.
 * - Leads are vertical tabs: arrows move and select, the sub-agents are the tab panel.
 * - While on screen and untouched, a demo pointer switches leads, opens a task list and answers
 *   the writer's question. The reader's first real input hands the fleet to them for good.
 */

export type { AgentMark, AgentStatus, Lead, Step, SubAgent, Tool } from './data';

const STATUS_WORD: Record<AgentStatus, string> = {
  running: 'Running',
  needs: 'Needs you',
  done: 'Done',
  queued: 'Queued',
  failed: 'Failed',
};

/** The radius of an elbow, and how far a lead's line runs before it turns: in px. */
const BEND = 6;

function money(value: number) {
  return `$${value.toFixed(2)}`;
}

/** 37s, 7m 00s, 1h 04m. */
function clock(seconds: number) {
  const s = Math.floor(seconds);
  if (s < 60) return `${s}s`;
  if (s < 3600) return `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, '0')}s`;
  return `${Math.floor(s / 3600)}h ${String(Math.floor(s / 60) % 60).padStart(2, '0')}m`;
}

/** A sub-agent and all the ones under it, in reading order. */
function flatten(subs: readonly SubAgent[]): SubAgent[] {
  return subs.flatMap((sub) => [sub, ...flatten(sub.subs ?? [])]);
}

function findSub(leads: readonly Lead[], id: string) {
  for (const lead of leads) {
    const sub = flatten(lead.subs).find((each) => each.id === id);
    if (sub) return { lead, sub };
  }
  return null;
}

function mapSubs(subs: readonly SubAgent[], change: (sub: SubAgent) => SubAgent): SubAgent[] {
  return subs.map((sub) => change(sub.subs ? { ...sub, subs: mapSubs(sub.subs, change) } : sub));
}

/** One second of work: running agents add time and money, waiting ones only time. */
function tick<T extends Lead | SubAgent>(agent: T): T {
  if (agent.status !== 'running' && agent.status !== 'needs') return agent;
  return {
    ...agent,
    seconds: agent.seconds + 1,
    cost: agent.status === 'running' ? agent.cost + (agent.rate ?? 0) : agent.cost,
  };
}

function leadCost(lead: Lead) {
  return flatten(lead.subs).reduce((sum, sub) => sum + sub.cost, lead.cost);
}

/** The lead's footer: who waits on you first, then what failed, then how many run. */
function leadSummary(lead: Lead) {
  const all = flatten(lead.subs);
  const needs = all.filter((sub) => sub.status === 'needs').length;
  const failed =
    all.filter((sub) => sub.status === 'failed').length +
    all.reduce((sum, sub) => sum + sub.steps.filter((step) => step.status === 'failed').length, 0);
  const done = all.filter((sub) => sub.status === 'done').length;
  const running = all.filter((sub) => sub.status === 'running').length;
  const text = needs
    ? `${needs} needs you`
    : failed
      ? `${failed} failed`
      : done === all.length
        ? `All ${all.length} done`
        : `${running}/${all.length} running`;
  return { text, needs: needs > 0, share: all.length ? done / all.length : 0 };
}

/** A price whose changed characters fade in, as a counter that ticks. */
function Ticker({ value }: { value: string }) {
  const [shown, setShown] = useState({ text: value, fresh: [] as number[], n: 0 });
  if (shown.text !== value) {
    const fresh = [...value].flatMap((char, i) => (char !== shown.text[i] ? [i] : []));
    setShown({ text: value, fresh, n: shown.n + 1 });
  }
  return (
    <>
      {[...shown.text].map((char, i) =>
        shown.fresh.includes(i) ? (
          <span key={`${i}-${shown.n}`} className={styles.fresh}>
            {char}
          </span>
        ) : (
          <Fragment key={i}>{char}</Fragment>
        ),
      )}
    </>
  );
}

function Pill({ status }: { status: AgentStatus }) {
  return (
    <span className={styles.pill} data-part="status" data-status={status}>
      <StatusIcon status={status} className={styles.pillIcon} />
      {STATUS_WORD[status]}
    </span>
  );
}

function Tools({ tools }: { tools: SubAgent['tools'] }) {
  return (
    <span className={styles.tools} data-part="tools" aria-hidden="true">
      {tools.map((tool) => (
        <span key={tool} className={styles.toolTile}>
          <ToolGlyph tool={tool} className={styles.tool} />
        </span>
      ))}
    </span>
  );
}

/** The top two rows of a card: tile, name, model, status; then the task with its tools. */
function Face({ agent }: { agent: Lead | SubAgent }) {
  return (
    <>
      <span className={styles.head} data-head="">
        <span className={styles.tile} data-part="tile" data-tile="">
          <AgentGlyph mark={agent.mark} className={styles.mark} />
        </span>
        <span className={styles.who}>
          <span className={styles.name}>{agent.name}</span>
          <span className={styles.model}>{agent.model}</span>
        </span>
        <Pill status={agent.status} />
      </span>
      <span className={styles.task} data-part="task" data-task="">
        <Tools tools={agent.tools} />
        <span className={styles.taskText}>{agent.task}</span>
      </span>
    </>
  );
}

function StepRow({ step }: { step: Step }) {
  return (
    <li className={styles.step} data-status={step.status}>
      <span className={styles.stepTile} aria-hidden="true">
        <ToolGlyph tool={step.tool} className={styles.tool} />
      </span>
      <span className={styles.stepLabel}>{step.label}</span>
      <span className={styles.stepTime}>
        {step.status === 'done' && step.seconds !== undefined
          ? clock(step.seconds)
          : STATUS_WORD[step.status]}
      </span>
    </li>
  );
}

function TaskList({ sub, id }: { sub: SubAgent; id?: string }) {
  const done = sub.steps.filter((step) => step.status === 'done').length;
  return (
    <div id={id} className={styles.taskList} data-part="task-list">
      <p className={styles.listHead}>
        <span className={styles.listTitle}>Tasks</span>
        <span className={styles.listCount}>
          {done}/{sub.steps.length} done
        </span>
      </p>
      <ul className={styles.steps}>
        {sub.steps.map((step) => (
          <StepRow key={step.label} step={step} />
        ))}
      </ul>
    </div>
  );
}

type Tip = { id: string; via: 'pointer' | 'focus' | 'tap' | 'demo' };
type Link = { key: string; d: string };

export function AgentFleet({
  leads: initialLeads = FLEET,
  title = 'Fleet',
  defaultSelected,
  live = true,
  onAnswer,
  defaultTasks,
  defaultAnswer,
  autoplay = true,
  colorScheme,
  className = '',
}: {
  /** The lead agents, each with its sub-agents (which may have their own). */
  leads?: readonly Lead[];
  /** The header's title. */
  title?: string;
  /** The lead selected on mount (its id); the first one without it. */
  defaultSelected?: string;
  /** Running agents count up their time and cost each second. */
  live?: boolean;
  /** Called when the reader approves or rejects what a sub-agent asks. */
  onAnswer?: (sub: SubAgent, decision: 'approve' | 'reject') => void;
  /** Opens with this sub-agent's task list showing (its id); turns the demo off. */
  defaultTasks?: string;
  /** Opens with this sub-agent's question showing (its id); turns the demo off. */
  defaultAnswer?: string;
  /** While on screen and untouched, a demo pointer shows the fleet at work. */
  autoplay?: boolean;
  /** Light or dark colours, or the reader's ('system'); without it, the page's color-scheme. */
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  const { ref: root, playing, visible, take } = useAutoplay<HTMLDivElement>();
  const demo = autoplay && playing && !defaultTasks && !defaultAnswer;
  const uid = useId();

  const ownerOf = (id: string | undefined, leads: readonly Lead[]) =>
    id ? (findSub(leads, id)?.lead.id ?? null) : null;
  const firstSelected = (leads: readonly Lead[]) =>
    ownerOf(defaultAnswer ?? defaultTasks, leads) ??
    (leads.some((lead) => lead.id === defaultSelected) ? defaultSelected! : leads[0]?.id);

  const [leads, setLeads] = useState<Lead[]>(() => [...initialLeads]);
  const [selected, setSelected] = useState(() => firstSelected(initialLeads));
  const [tip, setTip] = useState<Tip | null>(() =>
    defaultTasks ? { id: defaultTasks, via: 'tap' } : null,
  );
  const [answering, setAnswering] = useState<string | null>(defaultAnswer ?? null);
  const [message, setMessage] = useState('');
  const [demoOver, setDemoOver] = useState<'answer' | 'approve' | null>(null);
  const [fading, setFading] = useState(false);
  const [links, setLinks] = useState<{ paths: Link[]; nodes: Point[] }>({ paths: [], nodes: [] });
  /** The open popover would run off the bottom: it opens above its card. */
  const [flip, setFlip] = useState(false);

  const body = useRef<HTMLDivElement>(null);
  const list = useRef<HTMLDivElement>(null);
  const panel = useRef<HTMLDivElement>(null);
  const pointer = useRef<HTMLSpanElement>(null);
  const popBox = useRef<HTMLDivElement>(null);
  const approveButton = useRef<HTMLButtonElement>(null);
  const tabs = useRef(new Map<string, HTMLButtonElement>());
  const cards = useRef(new Map<string, HTMLButtonElement>());
  const answers = useRef(new Map<string, HTMLButtonElement>());
  /** The reader opened the question: it takes the focus, and gives it back. */
  const answerFocus = useRef(false);

  // New data from the props: start over (set while rendering, so it never shows the old data).
  // Compared by content, so arrays written inline in the caller's JSX do not reset it.
  const givenKey = JSON.stringify(initialLeads);
  const [given, setGiven] = useState(givenKey);
  if (given !== givenKey) {
    setGiven(givenKey);
    setLeads([...initialLeads]);
    setSelected(firstSelected(initialLeads));
    setTip(null);
    setAnswering(null);
  }

  /** Repeats are made to differ, so screen readers announce them again. */
  const announce = (text: string) => setMessage((now) => (now === text ? `${text} ` : text));

  // The clock: one second of work a second, while the fleet is on screen.
  useEffect(() => {
    if (!visible || !live) return;
    const timer = window.setInterval(() => {
      setLeads((all) => all.map((lead) => tick({ ...lead, subs: mapSubs(lead.subs, tick) })));
    }, 1000);
    return () => window.clearInterval(timer);
  }, [visible, live]);

  const current = leads.find((lead) => lead.id === selected) ?? leads[0];
  const allSubs = leads.flatMap((lead) => flatten(lead.subs));
  const running = allSubs.filter((sub) => sub.status === 'running').length;
  const needing = allSubs.filter((sub) => sub.status === 'needs').length;
  const total = leads.reduce((sum, lead) => sum + leadCost(lead), 0);

  // ---- Layout: where the sub-agents sit, and the lines to them ------------------------------

  const currentRef = useRef(current);
  useLayoutEffect(() => {
    currentRef.current = current;
  });

  const layout = useCallback(() => {
    const current = currentRef.current;
    const box = body.current;
    const column = list.current;
    const side = panel.current;
    const lead = current && tabs.current.get(current.id);
    if (!box || !column || !side || !lead) return;
    /** An element's box in the body's px, by offsets: transforms and scaling do not count. */
    const at = (element: HTMLElement) => {
      let x = 0;
      let y = 0;
      let node: HTMLElement | null = element;
      while (node && node !== box) {
        x += node.offsetLeft;
        y += node.offsetTop;
        node = node.offsetParent as HTMLElement | null;
      }
      return { x, y, w: element.offsetWidth, h: element.offsetHeight };
    };
    const part = (element: HTMLElement, name: string) =>
      element.querySelector<HTMLElement>(`[data-${name}]`) ?? element;
    const stacked = getComputedStyle(box).getPropertyValue('--stacked').trim() === '1';
    const l = at(lead);
    const height = side.offsetHeight;
    if (stacked) {
      box.style.setProperty('--offset', `${l.y + l.h + 8}px`);
      box.style.setProperty('--push', `${height + 8}px`);
    } else {
      // Centred on its lead, inside the leads' column when it fits.
      const room = Math.max(0, column.offsetHeight - height);
      const offset = Math.min(room, Math.max(0, l.y + l.h / 2 - height / 2));
      box.style.setProperty('--offset', `${Math.round(offset)}px`);
      box.style.removeProperty('--push');
    }

    const paths: Link[] = [];
    const nodes: Point[] = [];
    const mid = (element: HTMLElement) => {
      const head = at(part(element, 'head'));
      return head.y + head.h / 2;
    };
    const drop = (key: string, from: HTMLElement, to: HTMLElement) => {
      const f = at(from);
      const tile = at(part(from, 'tile'));
      const x = tile.x + tile.w / 2;
      const y0 = f.y + f.h;
      const y1 = mid(to);
      const x1 = at(to).x;
      // Several lines may drop from one card: one node for them all.
      if (!nodes.some((node) => node.x === x && node.y === y0)) nodes.push({ x, y: y0 });
      paths.push({
        key,
        d: `M${x} ${y0}V${y1 - BEND}Q${x} ${y1} ${x + BEND} ${y1}H${x1}`,
      });
    };
    const top = current.subs
      .map((sub) => cards.current.get(sub.id))
      .filter(Boolean) as HTMLElement[];
    if (stacked) {
      top.forEach((card, i) => drop(`${current.subs[i].id}`, lead, card));
    } else {
      const taskRow = at(part(lead, 'task'));
      const x0 = l.x + l.w;
      const y0 = taskRow.y + taskRow.h / 2;
      const trunk = x0 + (at(side).x - x0) / 2;
      nodes.push({ x: x0, y: y0 });
      top.forEach((card, i) => {
        const y1 = mid(card);
        const x1 = at(card).x;
        const dy = y1 - y0;
        const r = Math.min(BEND, Math.abs(dy) / 2);
        const s = Math.sign(dy);
        paths.push({
          key: current.subs[i].id,
          d:
            Math.abs(dy) < 1
              ? `M${x0} ${y0}H${x1}`
              : `M${x0} ${y0}H${trunk - r}Q${trunk} ${y0} ${trunk} ${y0 + s * r}V${y1 - s * r}Q${trunk} ${y1} ${trunk + r} ${y1}H${x1}`,
        });
      });
    }
    // A sub-agent's own sub-agents hang from the bottom of its card.
    const nested = (subs: readonly SubAgent[]) =>
      subs.forEach((sub) => {
        const card = cards.current.get(sub.id);
        sub.subs?.forEach((child) => {
          const to = cards.current.get(child.id);
          if (card && to) drop(child.id, card, to);
        });
        if (sub.subs) nested(sub.subs);
      });
    nested(current.subs);

    setLinks((now) => {
      const same =
        now.paths.length === paths.length &&
        now.paths.every((path, i) => path.d === paths[i].d && path.key === paths[i].key);
      return same ? now : { paths, nodes };
    });
  }, []);

  useLayoutEffect(() => {
    layout();
  });
  useLayoutEffect(() => {
    const box = body.current;
    if (!box) return;
    const observer = new ResizeObserver(() => layout());
    observer.observe(box);
    if (panel.current) observer.observe(panel.current);
    return () => observer.disconnect();
  }, [layout]);

  // The open popover opens above its card when it would run past the stage's foot.
  const open = answering ?? tip?.id ?? null;
  useLayoutEffect(() => {
    const box = popBox.current;
    const stage = root.current;
    const card = open ? cards.current.get(open) : undefined;
    if (!box || !stage || !card || !open) {
      setFlip(false);
      return;
    }
    const s = stage.getBoundingClientRect();
    const c = card.getBoundingClientRect();
    const scale = s.width / stage.offsetWidth || 1;
    const below = (s.bottom - c.bottom) / scale;
    const above = (c.top - s.top) / scale;
    setFlip(below < box.offsetHeight + 14 && above > below);
  }, [open, root]);

  // ---- Actions ------------------------------------------------------------------------------

  const select = (id: string, focus = false) => {
    if (id === selected) return;
    setSelected(id);
    setTip(null);
    setAnswering(null);
    if (focus) tabs.current.get(id)?.focus();
  };

  const openAnswer = (id: string, byReader: boolean) => {
    setTip(null);
    answerFocus.current = byReader;
    setAnswering(id);
  };

  // The question: the reader's focus goes in, Escape or a press outside closes it.
  useEffect(() => {
    if (!answering) return;
    if (answerFocus.current) approveButton.current?.focus();
    const away = (event: PointerEvent) => {
      const target = event.target as Node;
      if (popBox.current?.contains(target) || answers.current.get(answering)?.contains(target))
        return;
      setAnswering(null);
    };
    document.addEventListener('pointerdown', away);
    return () => document.removeEventListener('pointerdown', away);
  }, [answering]);

  const decide = (id: string, decision: 'approve' | 'reject') => {
    const found = findSub(leads, id);
    if (!found) return;
    const reader = answerFocus.current;
    setAnswering(null);
    // Either way the agent goes on: with the drafts it proposed, or with the other choice.
    setLeads((all) =>
      all.map((lead) => ({
        ...lead,
        subs: mapSubs(lead.subs, (sub) =>
          sub.id !== id
            ? sub
            : {
                ...sub,
                status: 'running',
                rate: sub.rate ?? 0.001,
                steps: sub.steps.map((step) =>
                  step.status === 'needs'
                    ? { ...step, status: 'done', seconds: 1 + (sub.seconds % 50) }
                    : step,
                ),
              },
        ),
      })),
    );
    announce(
      decision === 'approve'
        ? `Approved: ${found.sub.name} is running again.`
        : `Rejected: ${found.sub.name} goes on with the other choice.`,
    );
    onAnswer?.(found.sub, decision);
    if (reader) cards.current.get(id)?.focus();
  };

  const onTabKey = (event: ReactKeyboardEvent, index: number) => {
    const last = leads.length - 1;
    const to =
      event.key === 'ArrowDown' || event.key === 'ArrowRight'
        ? index === last
          ? 0
          : index + 1
        : event.key === 'ArrowUp' || event.key === 'ArrowLeft'
          ? index === 0
            ? last
            : index - 1
          : event.key === 'Home'
            ? 0
            : event.key === 'End'
              ? last
              : -1;
    if (to < 0) return;
    event.preventDefault();
    select(leads[to].id, true);
  };

  // ---- The demo ----------------------------------------------------------------------------

  const demoStep = useEffectEvent((step: DemoStep) => {
    switch (step.kind) {
      case 'select':
        select(step.id);
        break;
      case 'tip':
        if (step.id) setTip({ id: step.id, via: 'demo' });
        else setTip((now) => (now?.via === 'demo' ? null : now));
        break;
      case 'over':
        setDemoOver(step.what);
        break;
      case 'answer':
        openAnswer(step.id, false);
        break;
      case 'approve':
        setDemoOver(null);
        decide(step.id, 'approve');
        break;
      case 'fade':
        setFading(step.on);
        break;
      case 'reset':
        setLeads([...initialLeads]);
        setSelected(firstSelected(initialLeads));
        setTip(null);
        setAnswering(null);
        break;
    }
  });

  /** Whether the fleet has moved on from where the demo starts. */
  const dirty = useEffectEvent(
    () =>
      selected !== firstSelected(initialLeads) ||
      flatten(leads.flatMap((lead) => lead.subs)).some(
        (sub) => sub.status !== findSub(initialLeads, sub.id)?.sub.status,
      ),
  );

  useEffect(() => {
    const stage = root.current;
    const arrow = pointer.current;
    if (!demo || !stage || !arrow) return;

    /** A point on an element, in the stage's px: `fx`, `fy` are shares of its box. */
    const on = (element: Element | null | undefined, fx = 0.5, fy = 0.5): Point => {
      const frame = stage.getBoundingClientRect();
      const scale = frame.width / stage.offsetWidth || 1;
      const rect = element?.getBoundingClientRect() ?? frame;
      return {
        x: (rect.left + rect.width * fx - frame.left) / scale,
        y: (rect.top + rect.height * fy - frame.top) / scale,
      };
    };
    const lead = (id: string) => tabs.current.get(id);
    const card = (id: string) => cards.current.get(id);

    const stop = runDemo(stage, arrow, async ({ wait, glide, glyph }) => {
      const pick = async (id: string, fy: number, ms: number, hold: number) => {
        glyph('arrow');
        await glide(on(lead(id), 0.42, fy), ms);
        glyph('hand');
        await wait(180);
        demoStep({ kind: 'select', id });
        await wait(hold);
      };
      const hover = async (id: string, ms: number, hold: number) => {
        glyph('arrow');
        await glide(on(card(id), 0.5, 0.82), ms);
        demoStep({ kind: 'tip', id });
        await wait(hold);
        demoStep({ kind: 'tip', id: null });
      };
      for (;;) {
        if (dirty()) {
          demoStep({ kind: 'fade', on: true });
          await wait(320);
          demoStep({ kind: 'reset' });
          await wait(60);
          demoStep({ kind: 'fade', on: false });
        }
        await wait(500);
        glyph('arrow');
        await glide(on(lead('launch'), 0.5, 0.3), 700);
        await wait(500);
        await pick('support', 0.4, 560, 700);
        await hover('triage', 560, 1500);
        await pick('launch', 0.5, 620, 600);
        // The writer's question, then Approve.
        glyph('arrow');
        await glide(on(answers.current.get('writer'), 0.5, 0.6), 620);
        glyph('hand');
        demoStep({ kind: 'over', what: 'answer' });
        await wait(320);
        demoStep({ kind: 'answer', id: 'writer' });
        demoStep({ kind: 'over', what: null });
        await wait(1100);
        glyph('arrow');
        await glide(on(approveButton.current, 0.45, 0.55), 560);
        glyph('hand');
        demoStep({ kind: 'over', what: 'approve' });
        await wait(380);
        demoStep({ kind: 'approve', id: 'writer' });
        await wait(500);
        await hover('writer', 480, 1300);
        await pick('release', 0.5, 640, 1000);
        await pick('market', 0.5, 520, 1200);
        glyph('arrow');
        await glide(on(stage, 0.86, 0.94), 700);
        await wait(1500);
      }
    });
    return () => {
      stop();
      setDemoOver(null);
      setFading(false);
      setTip((now) => (now?.via === 'demo' ? null : now));
    };
  }, [demo, root]);

  // ---- Drawing -----------------------------------------------------------------------------

  const onCardEnter = (id: string) => (event: ReactPointerEvent) => {
    if (event.pointerType === 'touch' || answering === id) return;
    setTip({ id, via: 'pointer' });
  };
  const onCardLeave = (event: ReactPointerEvent) => {
    if (event.pointerType === 'touch') return;
    setTip((now) => (now?.via === 'pointer' ? null : now));
  };

  const answerSub = answering ? findSub(leads, answering)?.sub : undefined;
  const selectedIndex = leads.findIndex((lead) => lead.id === current?.id);

  const renderSubs = (subs: readonly SubAgent[], depth: number, start: number) => (
    <ul
      className={styles.subs}
      data-depth={depth}
      aria-label={depth === 0 ? `${current?.name}’s sub-agents` : undefined}
    >
      {subs.map((sub, i) => {
        const order = start + i;
        const showTip = tip?.id === sub.id && answering !== sub.id;
        const showAnswer = answering === sub.id && answerSub?.ask;
        const steps = sub.steps.length;
        return (
          <li key={sub.id} className={styles.subItem}>
            <div
              className={styles.slot}
              data-open={showTip || showAnswer ? '' : undefined}
              data-nested={depth > 0 || undefined}
              style={{ animationDelay: `${order * 55}ms` }}
            >
              <button
                type="button"
                ref={(element) => {
                  if (element) cards.current.set(sub.id, element);
                  else cards.current.delete(sub.id);
                }}
                className={styles.card}
                data-part="sub-agent"
                data-status={sub.status}
                aria-expanded={showTip}
                aria-controls={showTip ? `${uid}-tasks` : undefined}
                aria-label={`${sub.name}, ${sub.model}, ${STATUS_WORD[sub.status].toLowerCase()}: ${sub.task}. ${money(sub.cost)}, ${clock(sub.seconds)}, ${steps} ${steps === 1 ? 'task' : 'tasks'}`}
                onPointerEnter={onCardEnter(sub.id)}
                onPointerLeave={onCardLeave}
                onFocus={(event) => {
                  if (event.currentTarget.matches(':focus-visible') && answering !== sub.id)
                    setTip({ id: sub.id, via: 'focus' });
                }}
                onBlur={() => setTip((now) => (now?.via === 'focus' ? null : now))}
                onClick={() =>
                  setTip((now) =>
                    now?.id === sub.id && now.via !== 'pointer' ? null : { id: sub.id, via: 'tap' },
                  )
                }
              >
                <Face agent={sub} />
                <span className={styles.foot}>
                  <span className={styles.spend}>
                    <span className={styles.cost}>
                      <Ticker value={money(sub.cost)} />
                    </span>
                    {sub.seconds > 0 && (
                      <span className={styles.time}> · {clock(sub.seconds)}</span>
                    )}
                  </span>
                  {sub.status !== 'needs' && (
                    <span className={styles.count}>
                      {steps} {steps === 1 ? 'task' : 'tasks'}
                    </span>
                  )}
                </span>
              </button>
              {sub.status === 'needs' && sub.ask && (
                <button
                  type="button"
                  ref={(element) => {
                    if (element) answers.current.set(sub.id, element);
                    else answers.current.delete(sub.id);
                  }}
                  className={styles.answer}
                  data-part="answer"
                  data-over={demoOver === 'answer' || undefined}
                  aria-haspopup="dialog"
                  aria-expanded={answering === sub.id}
                  aria-label={`Answer ${sub.name}`}
                  onClick={() =>
                    answering === sub.id ? setAnswering(null) : openAnswer(sub.id, true)
                  }
                >
                  Answer
                </button>
              )}
              {showTip && (
                <div
                  ref={popBox}
                  className={styles.pop}
                  data-part="popover"
                  data-flip={flip || undefined}
                >
                  <TaskList sub={sub} id={`${uid}-tasks`} />
                </div>
              )}
              {showAnswer && (
                <div
                  ref={popBox}
                  role="dialog"
                  aria-labelledby={`${uid}-ask`}
                  aria-describedby={`${uid}-ask-body`}
                  className={styles.pop}
                  data-part="answer-card"
                  data-kind="answer"
                  data-flip={flip || undefined}
                >
                  <div className={styles.question}>
                    <h3 id={`${uid}-ask`} className={styles.askTitle}>
                      Needs your answer
                    </h3>
                    <p id={`${uid}-ask-body`} className={styles.askBody}>
                      {sub.ask}
                    </p>
                    <div className={styles.actions}>
                      <button
                        type="button"
                        className={styles.reject}
                        data-part="reject"
                        onClick={() => decide(sub.id, 'reject')}
                      >
                        Reject
                      </button>
                      <button
                        ref={approveButton}
                        type="button"
                        className={styles.approve}
                        data-part="approve"
                        data-over={demoOver === 'approve' || undefined}
                        onClick={() => decide(sub.id, 'approve')}
                      >
                        Approve
                      </button>
                    </div>
                  </div>
                  <TaskList sub={sub} />
                </div>
              )}
            </div>
            {sub.subs && sub.subs.length > 0 && renderSubs(sub.subs, depth + 1, order + 1)}
          </li>
        );
      })}
    </ul>
  );

  return (
    <div
      ref={root}
      className={`${styles.root} ${className}`}
      data-part="stage"
      data-color-scheme={colorScheme}
      onPointerDownCapture={take}
      onKeyDownCapture={(event) => {
        take();
        if (event.key === 'Escape') {
          if (answering) {
            const id = answering;
            setAnswering(null);
            answers.current.get(id)?.focus();
          } else setTip(null);
        }
      }}
      onPointerMove={(event) => {
        // The reader's own pointer on the fleet takes over from the demo's.
        if (event.pointerType !== 'touch') take();
      }}
    >
      <section className={styles.fleet} data-part="fleet" aria-labelledby={`${uid}-title`}>
        <header className={styles.header} data-part="header">
          <Sparkle className={styles.sparkle} />
          <h2 id={`${uid}-title`} className={styles.title}>
            {title}
          </h2>
          <p className={styles.summary} data-part="summary">
            <span>
              {leads.length} agents / {allSubs.length} sub-agents
            </span>
            <span>{running} running</span>
            {needing > 0 && <span>{needing} needs you</span>}
            <span className={styles.total} data-part="total">
              <Ticker value={money(total)} />
            </span>
          </p>
        </header>

        <div
          ref={body}
          className={styles.board}
          data-part="board"
          data-fading={fading || undefined}
          data-tail={selectedIndex === leads.length - 1 || undefined}
        >
          <div
            ref={list}
            className={styles.leads}
            role="tablist"
            aria-orientation="vertical"
            aria-label="Lead agents"
          >
            {leads.map((lead, index) => {
              const summary = leadSummary(lead);
              const isSelected = lead.id === current?.id;
              return (
                <button
                  key={lead.id}
                  type="button"
                  role="tab"
                  id={`${uid}-tab-${lead.id}`}
                  ref={(element) => {
                    if (element) tabs.current.set(lead.id, element);
                    else tabs.current.delete(lead.id);
                  }}
                  className={styles.card}
                  data-part="lead"
                  data-lead=""
                  data-after={index === selectedIndex + 1 || undefined}
                  aria-selected={isSelected}
                  aria-controls={`${uid}-panel`}
                  tabIndex={isSelected ? 0 : -1}
                  onClick={() => select(lead.id)}
                  onKeyDown={(event) => onTabKey(event, index)}
                >
                  <Face agent={lead} />
                  <span className={styles.foot}>
                    <span className={styles.summaryLine} data-part="lead-summary">
                      <Progress
                        share={summary.share}
                        waiting={summary.needs}
                        className={styles.footIcon}
                      />
                      {summary.text}
                    </span>
                    <span className={styles.spend}>
                      <span className={styles.cost}>
                        <Ticker value={money(leadCost(lead))} />
                      </span>
                      <span className={styles.time}> · {clock(lead.seconds)}</span>
                    </span>
                  </span>
                </button>
              );
            })}
          </div>

          <div
            ref={panel}
            id={`${uid}-panel`}
            className={styles.panel}
            role="tabpanel"
            aria-labelledby={current ? `${uid}-tab-${current.id}` : undefined}
            data-part="sub-agents"
          >
            {current && <Fragment key={current.id}>{renderSubs(current.subs, 0, 0)}</Fragment>}
          </div>

          <svg className={styles.links} aria-hidden="true" focusable="false" data-part="links">
            <g key={current?.id}>
              {links.paths.map((path) => (
                <path key={path.key} d={path.d} pathLength={1} className={styles.link} />
              ))}
              {links.nodes.map((node) => (
                <circle
                  key={`${node.x}-${node.y}`}
                  cx={node.x}
                  cy={node.y}
                  r={3.2}
                  className={styles.node}
                />
              ))}
            </g>
          </svg>
        </div>
      </section>

      <div className={styles.pointerLayer} aria-hidden="true">
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
      <p className={styles.hidden} role="status">
        {message}
      </p>
    </div>
  );
}

type DemoStep =
  | { kind: 'select'; id: string }
  | { kind: 'tip'; id: string | null }
  | { kind: 'over'; what: 'answer' | 'approve' | null }
  | { kind: 'answer'; id: string }
  | { kind: 'approve'; id: string }
  | { kind: 'fade'; on: boolean }
  | { kind: 'reset' };
```

### agent-fleet/agent-fleet.module.css

```css
/* Agent fleet (agent-fleet.tsx): a quiet grey stage with the fleet in its middle, or at night a
   near-black one. The fleet is laid out for 560 px: a 262 px column of leads, 50 px for the
   lines, then 218 px sub-agent cards (a sub-agent's own ones 29 px further in). At 540 px and
   under, the sub-agents stack under their lead, 32 px in.

   The script sets --offset (where the sub-agents start, in px from the board's top) and, when
   stacked, --push (the room they take under their lead) on .board; the lines are an SVG drawn
   from measured offsets.

   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes
   the color-scheme it inherits from the page (light unless the page says otherwise), or the one
   its colorScheme prop sets (data-color-scheme). */

.root {
  /* The stage, the cards, their edge. */
  --stage: #f7f7f7;
  --card: #fff;
  --card-dim: rgb(255 255 255 / 0.55);
  --edge: #e8e8ea;
  --edge-dim: #efeff0;
  --card-shadow: rgb(0 0 0 / 0.04);
  --card-hover: #fcfcfc;
  /* Text: names, the task line, quiet counts. */
  --ink: #111113;
  --ink-2: #4f4f53;
  --ink-3: #85858a;
  --glyph-ink: #19191b;
  --tile: #fff;
  --tile-edge: #e9e9eb;
  --sparkle: #3d7af9;
  --sparkle-dot: #9dbcf7;
  /* The status pills. */
  --run: #e3f1fd;
  --run-ink: #1569cf;
  --done: #e3f5e7;
  --done-ink: #18803a;
  --needs: #fdecd4;
  --needs-ink: #c04d08;
  --queued: #f0f0f1;
  --queued-ink: #707075;
  --fail: #fbe5e1;
  --fail-ink: #c42f14;
  /* The lines and their nodes. */
  --link: #7cacef;
  /* The popovers: their edge, the inset list and the buttons. */
  --pop: #fff;
  --pop-edge: rgb(0 0 0 / 0.08);
  --pop-shadow: rgb(0 0 0 / 0.09);
  --inset: #f5f5f6;
  --rule: #ececee;
  --button: #fff;
  --button-hover: #f4f4f5;
  --button-edge: #e2e2e4;
  --approve: #18181a;
  --approve-hover: #38383c;
  --approve-ink: #fff;
  /* The same on both schemes: the focus ring, and the demo's pointer, as the system draws it. */
  --focus: #387bff;
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.25);
  --sans: var(--body, Inter, ui-sans-serif, system-ui, sans-serif);

  position: relative;
  container-type: inline-size;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 560px;
  padding: 48px 16px 72px;
  overflow: hidden;
  overflow: clip;
  border-radius: 18px;
  background: var(--stage);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}
@supports (color: light-dark(#fff, #000)) {
  .root {
    --stage: light-dark(#f7f7f7, #1a1a1c);
    --card: light-dark(#fff, #1f1f22);
    --card-dim: light-dark(rgb(255 255 255 / 0.55), rgb(31 31 34 / 0.5));
    --edge: light-dark(#e8e8ea, #2c2c30);
    --edge-dim: light-dark(#efeff0, #252528);
    --card-shadow: light-dark(rgb(0 0 0 / 0.04), rgb(0 0 0 / 0.3));
    --card-hover: light-dark(#fcfcfc, #232326);
    --ink: light-dark(#111113, #ededef);
    --ink-2: light-dark(#4f4f53, #b4b4b9);
    --ink-3: light-dark(#85858a, #8a8a90);
    --glyph-ink: light-dark(#19191b, #e4e4e6);
    --tile: light-dark(#fff, #252528);
    --tile-edge: light-dark(#e9e9eb, #313135);
    --sparkle: light-dark(#3d7af9, #4a82f5);
    --sparkle-dot: light-dark(#9dbcf7, #35548f);
    --run: light-dark(#e3f1fd, #152a42);
    --run-ink: light-dark(#1569cf, #62aefb);
    --done: light-dark(#e3f5e7, #15301d);
    --done-ink: light-dark(#18803a, #4fd17a);
    --needs: light-dark(#fdecd4, #3b2814);
    --needs-ink: light-dark(#c04d08, #f6a25e);
    --queued: light-dark(#f0f0f1, #2a2a2d);
    --queued-ink: light-dark(#707075, #a0a0a5);
    --fail: light-dark(#fbe5e1, #3b1b1b);
    --fail-ink: light-dark(#c42f14, #f8846c);
    --link: light-dark(#7cacef, #4b86d6);
    --pop: light-dark(#fff, #222225);
    --pop-edge: light-dark(rgb(0 0 0 / 0.08), rgb(255 255 255 / 0.08));
    --pop-shadow: light-dark(rgb(0 0 0 / 0.09), rgb(0 0 0 / 0.5));
    --inset: light-dark(#f5f5f6, #1b1b1e);
    --rule: light-dark(#ececee, #2e2e32);
    --button: light-dark(#fff, #2a2a2d);
    --button-hover: light-dark(#f4f4f5, #333337);
    --button-edge: light-dark(#e2e2e4, #3a3a3e);
    --approve: light-dark(#18181a, #ededef);
    --approve-hover: light-dark(#38383c, #fff);
    --approve-ink: light-dark(#fff, #18181a);
  }
}
/* The colorScheme prop. Without it, nothing is set: color-scheme is inherited from the page. */
.root[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root[data-color-scheme='system'] {
  color-scheme: light dark;
}

.root :where(h2, h3, p, ul, li) {
  margin: 0;
  padding: 0;
}
.root :where(ul) {
  list-style: none;
}
.root :where(button) {
  font: inherit;
  color: inherit;
  margin: 0;
}

.fleet {
  position: relative;
  container: fleet / inline-size;
  width: 100%;
  max-width: 560px;
}

/* ---- The header ---------------------------------------------------------------------------- */

.header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px 4px;
}
.sparkle {
  width: 13px;
  height: 13px;
  flex: none;
}
.title {
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: -0.005em;
}
.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 10px;
  margin-left: auto !important;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.total {
  margin-left: 6px;
  color: var(--ink);
  font-weight: 500;
}

/* ---- The board: leads, sub-agents and the lines -------------------------------------------- */

.board {
  --stacked: 0;
  position: relative;
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr);
  column-gap: 50px;
  align-items: start;
  transition: opacity 0.3s ease;
}
.board[data-fading] {
  opacity: 0;
}
.leads {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}
.panel {
  /* No z-index: it makes no stacking context, so an open card can rise over the lines. */
  position: relative;
  top: var(--offset, 0px);
}
.subs {
  display: grid;
  gap: 8px;
}
.subs[data-depth='1'],
.subs[data-depth='2'] {
  margin-top: 8px;
  padding-left: 29px;
}
.subItem {
  min-width: 0;
}
.slot {
  position: relative;
  width: 218px;
  animation: enter 0.24s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.slot[data-open] {
  z-index: 4;
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.links {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.link {
  fill: none;
  stroke: var(--link);
  stroke-width: 1.6;
  stroke-dasharray: 1;
  animation: draw 0.42s cubic-bezier(0.3, 0.6, 0.3, 1) both;
}
@keyframes draw {
  from {
    stroke-dashoffset: 1;
  }
}
.node {
  fill: var(--card);
  stroke: var(--link);
  stroke-width: 1.6;
  animation: appear 0.2s ease-out both;
}
@keyframes appear {
  from {
    opacity: 0;
  }
}

/* Stacked: each lead's sub-agents under it, the leads after it pushed down to make room. */
@container fleet (max-width: 540px) {
  .board {
    --stacked: 1;
    grid-template-columns: minmax(0, 1fr);
  }
  .board[data-tail] {
    padding-bottom: var(--push, 0px);
  }
  .panel {
    position: absolute;
    top: var(--offset, 0px);
    left: 0;
    right: 0;
    padding-left: 32px;
  }
  .card[data-after] {
    margin-top: var(--push, 0px);
  }
  .slot {
    width: 100%;
  }
  .subs[data-depth='1'],
  .subs[data-depth='2'] {
    padding-left: 24px;
  }
}

/* ---- A card: a lead or a sub-agent --------------------------------------------------------- */

.card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  padding: 9px 10px 8px 9px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 1px 2px var(--card-shadow);
  text-align: left;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    margin 0.24s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.card:focus-visible,
.answer:focus-visible,
.reject:focus-visible,
.approve:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* The leads not selected step back: their face fades, the card loses its lift. */
.card[role='tab'][aria-selected='false'] {
  border-color: var(--edge-dim);
  background: var(--card-dim);
  box-shadow: none;
}
.card[role='tab'][aria-selected='false'] > * {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}
@media (hover: hover) {
  .card[role='tab'][aria-selected='false']:hover > * {
    opacity: 0.72;
  }
  .card[data-part='sub-agent']:hover {
    background: var(--card-hover);
  }
}

.head {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.tile {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--tile-edge);
  border-radius: 6px;
  background: var(--tile);
}
.mark {
  width: 12px;
  height: 12px;
}
.who {
  display: grid;
  min-width: 0;
}
.name,
.model,
.taskText {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.name {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 15px;
}
.model {
  color: var(--ink-3);
  font-size: 11px;
  line-height: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  align-self: start;
  gap: 3px;
  height: 17px;
  padding: 0 6px 0 4px;
  border-radius: 5px;
  background: var(--run);
  color: var(--run-ink);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}
.pill[data-status='done'] {
  background: var(--done);
  color: var(--done-ink);
}
.pill[data-status='needs'] {
  background: var(--needs);
  color: var(--needs-ink);
}
.pill[data-status='queued'] {
  background: var(--queued);
  color: var(--queued-ink);
}
.pill[data-status='failed'] {
  background: var(--fail);
  color: var(--fail-ink);
}
.pillIcon {
  width: 11px;
  height: 11px;
  flex: none;
}
.pill[data-status='running'] .pillIcon {
  animation: turn 1.1s linear infinite;
}
@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

.task {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.tools {
  display: flex;
  flex: none;
}
.toolTile,
.stepTile {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--tile-edge);
  border-radius: 5px;
  background: var(--tile);
}
.toolTile + .toolTile {
  margin-left: -3px;
}
.tool {
  width: 10px;
  height: 10px;
}
.taskText {
  min-width: 0;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 16px;
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 19px;
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 15px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.summaryLine {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--ink-3);
}
.footIcon {
  width: 12px;
  height: 12px;
  flex: none;
}
.spend {
  color: var(--ink-3);
}
.cost {
  color: var(--ink);
  font-weight: 500;
}
.count {
  color: var(--ink-3);
}
/* A changed digit comes in faint and darkens, as a meter that ticks. */
.fresh {
  animation: tickIn 0.7s ease-out both;
}
@keyframes tickIn {
  from {
    opacity: 0.3;
  }
}

/* The Answer button, over the right end of the waiting card's footer. */
.answer {
  position: absolute;
  right: 7px;
  bottom: 6px;
  z-index: 1;
  height: 21px;
  padding: 0 8px;
  border: 1px solid var(--button-edge);
  border-radius: 6px;
  background: var(--button);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.04);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.answer::before {
  content: '';
  position: absolute;
  inset: -4px;
}

/* ---- The popovers: a task list, or the question over one ----------------------------------- */

.pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 5;
  width: 284px;
  border: 1px solid var(--pop-edge);
  border-radius: 10px;
  background: var(--pop);
  box-shadow:
    0 10px 28px var(--pop-shadow),
    0 1px 3px var(--pop-shadow);
  animation: pop 0.16s ease-out both;
}
.pop[data-flip] {
  top: auto;
  bottom: calc(100% + 6px);
}
/* A sub-agent's own sub-agent sits further right: its popover hangs from the right edge. */
.slot[data-nested] > .pop {
  left: auto;
  right: 0;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}
@container fleet (max-width: 540px) {
  .pop,
  .slot[data-nested] > .pop {
    left: 0;
    right: 0;
    width: auto;
  }
}

.taskList {
  padding: 9px 6px 6px;
}
.listHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 5px 7px;
}
.listTitle {
  font-size: 13px;
  font-weight: 500;
}
.listCount {
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.steps {
  display: grid;
  padding: 3px 0 !important;
  border-radius: 7px;
  background: var(--inset);
}
.step {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  height: 25px;
  padding: 0 7px !important;
  font-size: 12.5px;
}
.stepLabel {
  overflow: hidden;
  color: var(--ink-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.stepTime {
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.step[data-status='needs'] :is(.stepLabel, .stepTime) {
  color: var(--ink);
  font-weight: 500;
}
.step[data-status='running'] .stepTime {
  color: var(--run-ink);
}
.step[data-status='failed'] .stepTime {
  color: var(--fail-ink);
}
.step[data-status='queued'] .stepLabel {
  color: var(--ink-3);
}

.question {
  padding: 11px 11px 10px;
  border-bottom: 1px solid var(--rule);
}
.askTitle {
  font-size: 13px;
  font-weight: 500;
  line-height: 17px;
}
.askBody {
  margin-top: 4px !important;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.45;
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}
.reject,
.approve {
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.reject {
  border: 1px solid var(--button-edge);
  background: var(--button);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.04);
}
.approve {
  border: 1px solid var(--approve);
  background: var(--approve);
  color: var(--approve-ink);
}
@media (hover: hover) {
  .answer:hover,
  .reject:hover {
    background: var(--button-hover);
  }
  .approve:hover {
    background: var(--approve-hover);
  }
}
.answer[data-over] {
  background: var(--button-hover);
}
.approve[data-over] {
  background: var(--approve-hover);
}

/* ---- The demo's pointer ---------------------------------------------------------------------- */

.pointerLayer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
.pointer {
  width: 22px;
  height: 22px;
}
.hand {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .arrow {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .hand {
  visibility: visible;
}

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .slot,
  .link,
  .node,
  .pop,
  .fresh,
  .pill[data-status='running'] .pillIcon {
    animation: none;
  }
  .card,
  .board,
  .pill {
    transition: none;
  }
}
```

### agent-fleet/data.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The shapes the fleet draws, and the fleet the lab shows: four lead agents, each with the
 * sub-agents it handed work to (one of them with a sub-agent of its own). Times are in seconds
 * of work so far and costs in dollars; while an agent runs, both grow, by one second and by its
 * rate, each second.
 */

/** The tools an agent uses: a small glyph each, drawn in glyphs.tsx. */
export type Tool =
  'chat' | 'doc' | 'code' | 'design' | 'ticket' | 'search' | 'test' | 'ship' | 'mail';

/** An agent's mark on its tile: one per model family. */
export type AgentMark = 'petal' | 'rings' | 'diamond';

/** Where an agent stands, on its status pill. */
export type AgentStatus = 'running' | 'needs' | 'done' | 'queued' | 'failed';

/** One task of a sub-agent, in its task list. */
export type Step = {
  label: string;
  tool: Tool;
  status: 'done' | 'running' | 'needs' | 'failed' | 'queued';
  /** How long it took, once done or failed. */
  seconds?: number;
};

type AgentBase = {
  id: string;
  name: string;
  /** The model it runs on, under its name. */
  model: string;
  mark: AgentMark;
  status: AgentStatus;
  /** What it was asked to do, on one line. */
  task: string;
  tools: readonly Tool[];
  /** Spent so far, in dollars (a lead's own share: its card adds its sub-agents'). */
  cost: number;
  /** Dollars a second while it runs. */
  rate?: number;
  /** Seconds of work so far. */
  seconds: number;
};

export type SubAgent = AgentBase & {
  steps: readonly Step[];
  /** For a sub-agent that needs you: the question, with Approve and Reject. */
  ask?: string;
  /** Sub-agents of its own, drawn under it. */
  subs?: readonly SubAgent[];
};

export type Lead = AgentBase & { subs: readonly SubAgent[] };

const LARGE = 'Large · v5.5';
const MEDIUM = 'Medium · v5.5';
const CORE = 'Core · v6';
const MINI = 'Mini · v6';
const FAST = 'Fast · v3.8';
const DEEP = 'Deep · v3.8';

export const FLEET: readonly Lead[] = [
  {
    id: 'launch',
    name: 'Launch lead',
    model: LARGE,
    mark: 'petal',
    status: 'running',
    task: 'Launch the new pricing page by Friday',
    tools: ['chat', 'doc', 'code'],
    cost: 0.35,
    rate: 0.0016,
    seconds: 841,
    subs: [
      {
        id: 'researcher',
        name: 'Researcher',
        model: MEDIUM,
        mark: 'petal',
        status: 'done',
        task: 'Compare the pricing of five competitors',
        tools: ['doc', 'search'],
        cost: 0.31,
        seconds: 420,
        steps: [
          { label: 'Find the five pricing pages', tool: 'search', status: 'done', seconds: 112 },
          { label: 'Read each plan and its limits', tool: 'doc', status: 'done', seconds: 160 },
          { label: 'Put the prices in one table', tool: 'doc', status: 'done', seconds: 96 },
          { label: 'Mark the cheapest plan of each', tool: 'search', status: 'done', seconds: 52 },
        ],
      },
      {
        id: 'writer',
        name: 'Writer',
        model: MEDIUM,
        mark: 'petal',
        status: 'needs',
        task: 'Write the copy for the three plans',
        tools: ['doc', 'design'],
        cost: 0.18,
        rate: 0.0012,
        seconds: 721,
        ask: 'Formal or friendly plan names? The friendly drafts are in the shared doc – approve to go with those.',
        steps: [
          {
            label: 'Draft names and taglines for the plans',
            tool: 'doc',
            status: 'done',
            seconds: 142,
          },
          {
            label: 'Fit the copy into the page layout',
            tool: 'design',
            status: 'done',
            seconds: 205,
          },
          { label: 'Ask: formal or friendly plan names?', tool: 'chat', status: 'needs' },
        ],
      },
      {
        id: 'coder',
        name: 'Coder',
        model: CORE,
        mark: 'rings',
        status: 'running',
        task: 'Build the page and wire up checkout',
        tools: ['code', 'ship', 'design'],
        cost: 0.74,
        rate: 0.0045,
        seconds: 661,
        steps: [
          { label: 'Lay out the three plan cards', tool: 'design', status: 'done', seconds: 190 },
          { label: 'Wire the buttons to checkout', tool: 'code', status: 'done', seconds: 245 },
          { label: 'Add the yearly price toggle', tool: 'code', status: 'running' },
          { label: 'Check it on small screens', tool: 'design', status: 'queued' },
        ],
        subs: [
          {
            id: 'tester',
            name: 'Tester',
            model: MINI,
            mark: 'rings',
            status: 'running',
            task: 'Run the checkout tests',
            tools: ['test', 'ship'],
            cost: 0.08,
            rate: 0.0011,
            seconds: 181,
            steps: [
              { label: 'Run the unit tests', tool: 'test', status: 'done', seconds: 48 },
              { label: 'Try each plan in checkout', tool: 'ship', status: 'running' },
              { label: 'Report what broke', tool: 'chat', status: 'queued' },
            ],
          },
        ],
      },
    ],
  },
  {
    id: 'support',
    name: 'Support lead',
    model: MEDIUM,
    mark: 'petal',
    status: 'running',
    task: 'Answer the 48 open tickets in the queue',
    tools: ['ticket', 'chat'],
    cost: 0.3,
    rate: 0.0012,
    seconds: 1561,
    subs: [
      {
        id: 'triage',
        name: 'Triage',
        model: FAST,
        mark: 'diamond',
        status: 'done',
        task: 'Sort the tickets by product and urgency',
        tools: ['ticket'],
        cost: 0.04,
        seconds: 300,
        steps: [
          { label: 'Read the 48 new tickets', tool: 'ticket', status: 'done', seconds: 64 },
          { label: 'Tag them by product', tool: 'ticket', status: 'done', seconds: 148 },
          { label: 'Route 19 to billing, 11 to bugs', tool: 'chat', status: 'done', seconds: 88 },
        ],
      },
      {
        id: 'billing',
        name: 'Billing',
        model: MEDIUM,
        mark: 'petal',
        status: 'running',
        task: 'Reply to 19 questions about invoices',
        tools: ['mail', 'ticket'],
        cost: 0.43,
        rate: 0.0032,
        seconds: 1200,
        steps: [
          {
            label: 'Look up each customer’s invoices',
            tool: 'ticket',
            status: 'done',
            seconds: 310,
          },
          { label: 'Answer the 12 refund questions', tool: 'mail', status: 'done', seconds: 545 },
          { label: 'Answer the 7 about tax', tool: 'mail', status: 'running' },
          { label: 'Close the answered tickets', tool: 'ticket', status: 'queued' },
        ],
      },
      {
        id: 'bugs',
        name: 'Bug reports',
        model: MINI,
        mark: 'rings',
        status: 'running',
        task: 'Reproduce and file 11 bug reports',
        tools: ['code', 'ticket'],
        cost: 0.25,
        rate: 0.0024,
        seconds: 1084,
        steps: [
          { label: 'Reproduce the 11 reported bugs', tool: 'code', status: 'done', seconds: 702 },
          { label: 'File them with steps and logs', tool: 'ticket', status: 'running' },
          { label: 'Tell each customer it is filed', tool: 'mail', status: 'queued' },
        ],
      },
      {
        id: 'escalation',
        name: 'Escalation',
        model: MEDIUM,
        mark: 'petal',
        status: 'queued',
        task: 'Hand upset customers to a human',
        tools: ['chat'],
        cost: 0,
        seconds: 0,
        steps: [{ label: 'Pass the 4 angry threads on', tool: 'chat', status: 'queued' }],
      },
    ],
  },
  {
    id: 'release',
    name: 'Release manager',
    model: CORE,
    mark: 'rings',
    status: 'running',
    task: 'Ship version 2.4 to the app stores',
    tools: ['code', 'chat'],
    cost: 0.12,
    rate: 0.0008,
    seconds: 2281,
    subs: [
      {
        id: 'builder',
        name: 'Builder',
        model: CORE,
        mark: 'rings',
        status: 'running',
        task: 'Build and sign the 2.4 release',
        tools: ['code', 'ship'],
        cost: 0.21,
        rate: 0.0016,
        seconds: 1500,
        steps: [
          { label: 'Bump the version to 2.4', tool: 'code', status: 'done', seconds: 40 },
          { label: 'Build for both stores', tool: 'ship', status: 'done', seconds: 540 },
          { label: 'Sign the two builds', tool: 'code', status: 'running' },
        ],
      },
      {
        id: 'screens',
        name: 'Screenshots',
        model: FAST,
        mark: 'diamond',
        status: 'running',
        task: 'Make the store screenshots in 6 sizes',
        tools: ['design', 'ship'],
        cost: 0.12,
        rate: 0.0014,
        seconds: 900,
        steps: [
          { label: 'Capture the six key screens', tool: 'design', status: 'done', seconds: 420 },
          { label: 'Upload them to the stores', tool: 'ship', status: 'failed', seconds: 70 },
          { label: 'Retry the upload, smaller files', tool: 'ship', status: 'running' },
        ],
      },
      {
        id: 'notes',
        name: 'Release notes',
        model: MEDIUM,
        mark: 'petal',
        status: 'running',
        task: 'Write the notes for version 2.4',
        tools: ['doc', 'chat'],
        cost: 0.13,
        rate: 0.001,
        seconds: 600,
        steps: [
          { label: 'List what changed since 2.3', tool: 'search', status: 'done', seconds: 230 },
          { label: 'Write the notes, short and plain', tool: 'doc', status: 'running' },
        ],
      },
    ],
  },
  {
    id: 'market',
    name: 'Market analyst',
    model: DEEP,
    mark: 'diamond',
    status: 'done',
    task: 'Write the weekly competitor report',
    tools: ['doc', 'chat'],
    cost: 0.21,
    seconds: 2520,
    subs: [
      {
        id: 'scraper',
        name: 'Scraper',
        model: FAST,
        mark: 'diamond',
        status: 'done',
        task: 'Read the changelogs of 12 competitors',
        tools: ['search'],
        cost: 0.08,
        seconds: 840,
        steps: [
          { label: 'Fetch the 12 changelogs', tool: 'search', status: 'done', seconds: 310 },
          { label: 'Keep what shipped this week', tool: 'doc', status: 'done', seconds: 530 },
        ],
      },
      {
        id: 'analyst',
        name: 'Analyst',
        model: MEDIUM,
        mark: 'petal',
        status: 'done',
        task: 'Summarize 300 new reviews of each product',
        tools: ['search', 'doc'],
        cost: 0.34,
        seconds: 1380,
        steps: [
          { label: 'Collect the new reviews', tool: 'search', status: 'done', seconds: 420 },
          { label: 'Group them by complaint', tool: 'doc', status: 'done', seconds: 610 },
          { label: 'Pick a quote for each group', tool: 'doc', status: 'done', seconds: 350 },
        ],
      },
      {
        id: 'editor',
        name: 'Editor',
        model: LARGE,
        mark: 'petal',
        status: 'done',
        task: 'Turn the notes into a two-page report',
        tools: ['doc', 'chat'],
        cost: 0.19,
        seconds: 660,
        steps: [
          { label: 'Write the two pages', tool: 'doc', status: 'done', seconds: 480 },
          { label: 'Post it to the team', tool: 'chat', status: 'done', seconds: 180 },
        ],
      },
    ],
  },
];
```

### agent-fleet/glyphs.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The small drawings, on a 16-unit grid and sized by the stylesheet: a glyph for each tool, a
 * mark for each model family's tile, the header's sparkle and the status icons. Ink strokes
 * take --glyph-ink, so they turn light at night; the coloured ones keep their colour on both
 * schemes, which is what tells two tools apart at 11 px.
 */

import type { AgentMark, AgentStatus, Tool } from './data';

const INK = { stroke: 'var(--glyph-ink)' };
const ROUND = { strokeLinecap: 'round', strokeLinejoin: 'round' } as const;

function ToolPath({ tool }: { tool: Tool }) {
  switch (tool) {
    case 'chat':
      return (
        <path
          d="M2.6 4.4c0-1 .8-1.8 1.8-1.8h7.2c1 0 1.8.8 1.8 1.8v4.8c0 1-.8 1.8-1.8 1.8H7.2l-3 2.4v-2.4h0c-.9-.1-1.6-.9-1.6-1.8z"
          fill="#8a6cf2"
        />
      );
    case 'doc':
      return (
        <>
          <path
            d="M3.4 2.2h6.2l3 3v8.6H3.4z"
            fill="none"
            style={INK}
            strokeWidth="1.5"
            {...ROUND}
          />
          <path d="M6 8.2h4M6 10.8h2.8" style={INK} strokeWidth="1.4" {...ROUND} />
        </>
      );
    case 'code':
      return (
        <path
          d="M5.6 4.4L2.4 8l3.2 3.6M10.4 4.4L13.6 8l-3.2 3.6"
          fill="none"
          style={INK}
          strokeWidth="1.8"
          {...ROUND}
        />
      );
    case 'design':
      return (
        <>
          <circle cx="6" cy="6" r="3.6" fill="#f0703c" />
          <rect x="7.4" y="7.4" width="6.4" height="6.4" rx="1.4" fill="#2e8ef0" />
        </>
      );
    case 'ticket':
      return (
        <path d="M2.2 4.6h11.6v2a1.4 1.4 0 000 2.8v2H2.2v-2a1.4 1.4 0 000-2.8z" fill="#ec7a3a" />
      );
    case 'search':
      return (
        <>
          <circle cx="7" cy="7" r="4" fill="none" stroke="#2f7cf6" strokeWidth="2" />
          <path d="M10.2 10.2l3.2 3.2" stroke="#2f7cf6" strokeWidth="2.2" strokeLinecap="round" />
        </>
      );
    case 'test':
      return (
        <>
          <path
            d="M6 2.4h4M6.6 2.6v3.8L3 12.4c-.5.8.1 1.6 1 1.6h8c.9 0 1.5-.8 1-1.6L9.4 6.4V2.6"
            fill="none"
            style={INK}
            strokeWidth="1.4"
            {...ROUND}
          />
          <path d="M4.6 10.4h6.8l1.1 1.9c.3.5-.1 1-.6 1H4.1c-.5 0-.9-.5-.6-1z" fill="#1fa36b" />
        </>
      );
    case 'ship':
      return (
        <>
          <rect x="2.4" y="2.4" width="11.2" height="11.2" rx="2.6" fill="#5a63f0" />
          <path
            d="M8 11.2V5.2M5.4 7.6L8 5l2.6 2.6"
            fill="none"
            stroke="#fff"
            strokeWidth="1.6"
            {...ROUND}
          />
        </>
      );
    case 'mail':
      return (
        <>
          <rect x="2" y="3.6" width="12" height="8.8" rx="1.6" fill="#e3a51c" />
          <path d="M3 5l5 3.6L13 5" fill="none" stroke="#fff" strokeWidth="1.4" {...ROUND} />
        </>
      );
  }
}

export function ToolGlyph({ tool, className }: { tool: Tool; className?: string }) {
  return (
    <svg viewBox="0 0 16 16" className={className} aria-hidden="true" focusable="false">
      <ToolPath tool={tool} />
    </svg>
  );
}

function MarkPath({ mark }: { mark: AgentMark }) {
  switch (mark) {
    case 'petal':
      // Four rounded petals round an open middle, warm orange.
      return (
        <g fill="#de6f46">
          <ellipse cx="8" cy="4.3" rx="2" ry="3" />
          <ellipse cx="8" cy="11.7" rx="2" ry="3" />
          <ellipse cx="4.3" cy="8" rx="3" ry="2" />
          <ellipse cx="11.7" cy="8" rx="3" ry="2" />
        </g>
      );
    case 'rings':
      // Two rings through each other, in ink.
      return (
        <g fill="none" style={INK} strokeWidth="1.6">
          <circle cx="6" cy="8" r="3.8" />
          <circle cx="10" cy="8" r="3.8" />
        </g>
      );
    case 'diamond':
      // A diamond with a hollow core, in blue.
      return (
        <path
          d="M8 1.6L14.4 8 8 14.4 1.6 8zM8 5.8L5.8 8 8 10.2 10.2 8z"
          fill="#3e6ff2"
          fillRule="evenodd"
        />
      );
  }
}

export function AgentGlyph({ mark, className }: { mark: AgentMark; className?: string }) {
  return (
    <svg viewBox="0 0 16 16" className={className} aria-hidden="true" focusable="false">
      <MarkPath mark={mark} />
    </svg>
  );
}

/** The header's mark: a four-point sparkle with a dot under its right arm. */
export function Sparkle({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 16 16" className={className} aria-hidden="true" focusable="false">
      <path
        d="M6.6 1.5c.5 2.7 1.7 3.9 4.4 4.4-2.7.5-3.9 1.7-4.4 4.4-.5-2.7-1.7-3.9-4.4-4.4 2.7-.5 3.9-1.7 4.4-4.4z"
        fill="var(--sparkle)"
      />
      <circle cx="12.2" cy="12.4" r="1.5" fill="var(--sparkle-dot)" />
    </svg>
  );
}

/** The icon on a status pill: a turning ring, a check, a clock, a dot, a cross. */
export function StatusIcon({ status, className }: { status: AgentStatus; className?: string }) {
  return (
    <svg viewBox="0 0 16 16" className={className} aria-hidden="true" focusable="false">
      {status === 'running' && (
        <>
          <circle
            cx="8"
            cy="8"
            r="5.6"
            fill="none"
            stroke="currentColor"
            strokeOpacity="0.25"
            strokeWidth="1.8"
          />
          <path
            d="M8 2.4a5.6 5.6 0 015.6 5.6"
            fill="none"
            stroke="currentColor"
            strokeWidth="1.8"
            strokeLinecap="round"
          />
        </>
      )}
      {status === 'done' && (
        <path
          d="M3.2 8.4l3 3 6.6-6.8"
          fill="none"
          stroke="currentColor"
          strokeWidth="1.8"
          {...ROUND}
        />
      )}
      {status === 'needs' && (
        <>
          <circle cx="8" cy="8" r="5.8" fill="none" stroke="currentColor" strokeWidth="1.6" />
          <path
            d="M8 4.8V8l2.2 1.4"
            fill="none"
            stroke="currentColor"
            strokeWidth="1.6"
            {...ROUND}
          />
        </>
      )}
      {status === 'queued' && <circle cx="8" cy="8" r="2.2" fill="currentColor" />}
      {status === 'failed' && (
        <path
          d="M4.6 4.6l6.8 6.8M11.4 4.6l-6.8 6.8"
          fill="none"
          stroke="currentColor"
          strokeWidth="1.8"
          strokeLinecap="round"
        />
      )}
    </svg>
  );
}

/**
 * The lead's footer icon: a ring whose filled share is the share of its sub-agents that are
 * done, or a clock when one of them waits for the reader.
 */
export function Progress({
  share,
  waiting,
  className,
}: {
  share: number;
  waiting: boolean;
  className?: string;
}) {
  if (waiting) return <StatusIcon status="needs" className={className} />;
  const angle = Math.min(share, 0.9999) * Math.PI * 2;
  const x = 8 + 4 * Math.sin(angle);
  const y = 8 - 4 * Math.cos(angle);
  return (
    <svg viewBox="0 0 16 16" className={className} aria-hidden="true" focusable="false">
      <circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" strokeWidth="1.5" />
      {share > 0 && (
        <path
          d={`M8 8V4A4 4 0 ${angle > Math.PI ? 1 : 0} 1 ${x.toFixed(2)} ${y.toFixed(2)}z`}
          fill="currentColor"
        />
      )}
    </svg>
  );
}
```

### agent-fleet/demo-pointer.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import type { CSSProperties, Ref } from 'react';

/*
 * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or
 * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends
 * the step in progress at once: its promise rejects, which ends the script right there, and the
 * pointer fades out.
 *
 * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame.
 * The points of the flight are handed to whoever wants to move along with it. The arrow and the
 * hand are HTML boxes
 * that swap by their visibility: a change of style inside an SVG would lay the SVG out again.
 */

export type Point = { x: number; y: number };

/** A glide's path and timing, for an animation that plays along with it. */
export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };

export type Demo = {
  /** Resolves after `ms`. */
  wait: (ms: number) => Promise<void>;
  /** Glides the pointer to `to`, in the stage's own px, in `ms`; `along` gets the flight. */
  glide: (to: Point, ms: number, along?: (flight: Flight) => void) => Promise<void>;
  /** Shows the arrow, or the hand a link shows. */
  glyph: (name: 'arrow' | 'hand') => void;
};

/** What a stopped demo's pending step rejects with. */
class Stopped extends Error {}

/** Where the arrow's tip is, as shares of its box: the point the pointer stands on. */
const TIP: Point = { x: 0.15, y: 0.1 };

/** How many points a flight is drawn through. */
const SAMPLES = 24;

/** Plays `script` with the pointer over `stage`; returns the function that stops it. */
export function runDemo(
  stage: HTMLElement,
  pointer: HTMLElement,
  script: (demo: Demo) => Promise<void>,
): () => void {
  let alive = true;
  let flight: Animation | null = null;
  // The stylesheet sizes the pointer from the stage's width; its tip is where it stands.
  const tip = { x: pointer.offsetWidth * TIP.x, y: pointer.offsetHeight * TIP.y };
  const place = ({ x, y }: Point) => `translate(${x - tip.x}px, ${y - tip.y}px)`;
  const timers = new Set<number>();
  const pending = new Set<() => void>();
  // The pointer comes in from the lower right.
  let at: Point = { x: stage.offsetWidth * 0.8, y: stage.offsetHeight * 0.9 };

  /** Settles like `promise`, or rejects as soon as the demo stops. */
  const step = (promise: Promise<unknown>) =>
    new Promise<void>((resolve, reject) => {
      if (!alive) return reject(new Stopped());
      const cancel = () => reject(new Stopped());
      pending.add(cancel);
      promise.then(
        () => {
          pending.delete(cancel);
          if (alive) resolve();
        },
        () => {
          pending.delete(cancel);
          reject(new Stopped());
        },
      );
    });

  const wait = (ms: number) =>
    step(
      new Promise<void>((resolve) => {
        const timer = window.setTimeout(() => {
          timers.delete(timer);
          resolve();
        }, ms);
        timers.add(timer);
      }),
    );

  const glide: Demo['glide'] = (to, ms, along) => {
    const from = at;
    at = to;
    const dx = to.x - from.x;
    const dy = to.y - from.y;
    // A gentle curve, as a hand moves: the control point sits off the straight line.
    const bend = { x: (from.x + to.x) / 2 - dy * 0.18, y: (from.y + to.y) / 2 + dx * 0.18 };
    const points: Point[] = [];
    for (let i = 0; i <= SAMPLES; i += 1) {
      const t = i / SAMPLES;
      const u = 1 - t;
      points.push({
        x: u * u * from.x + 2 * u * t * bend.x + t * t * to.x,
        y: u * u * from.y + 2 * u * t * bend.y + t * t * to.y,
      });
    }
    const timing: KeyframeAnimationOptions = {
      duration: ms,
      easing: 'cubic-bezier(0.45, 0, 0.25, 1)',
    };
    flight?.cancel();
    // Where it rests once the flight is over.
    pointer.style.transform = place(to);
    flight = pointer.animate(
      points.map((point) => ({ transform: place(point) })),
      timing,
    );
    along?.({ points, timing });
    return step(flight.finished);
  };

  const glyph: Demo['glyph'] = (name) => {
    pointer.dataset.glyph = name;
  };

  pointer.dataset.glyph = 'arrow';
  pointer.style.transform = place(at);
  pointer.style.opacity = '1';
  script({ wait, glide, glyph }).catch((error: unknown) => {
    if (!(error instanceof Stopped)) throw error;
  });

  return () => {
    if (!alive) return;
    alive = false;
    timers.forEach((timer) => window.clearTimeout(timer));
    flight?.cancel();
    pending.forEach((cancel) => cancel());
    pointer.style.opacity = '0';
  };
}

/**
 * The pointer's box: it moves, on a layer of its own. Its size comes from its class, its colours
 * from the stage's tokens (agent-fleet.module.css).
 */
const POINTER: CSSProperties = {
  position: 'absolute',
  top: 0,
  left: 0,
  zIndex: 2,
  display: 'block',
  pointerEvents: 'none',
  opacity: 0,
  transition: 'opacity 0.3s ease',
  filter: 'drop-shadow(0 1px 1.5px var(--pointer-shadow))',
  willChange: 'transform',
};

/** One glyph over the other, each filling the box. */
const GLYPH: CSSProperties = { position: 'absolute', inset: 0, display: 'block' };
const DRAWING: CSSProperties = {
  display: 'block',
  width: '100%',
  height: '100%',
  overflow: 'visible',
};
/** The arrow is dark on a white edge, the hand white on a dark one, as the system draws them. */
const ARROW: CSSProperties = { fill: 'var(--pointer)', stroke: 'var(--pointer-edge)' };
const HAND: CSSProperties = { fill: 'var(--pointer-edge)', stroke: 'var(--pointer)' };

/**
 * The pointer the demo moves around: an arrow, or a pointing hand over what it can press. It is
 * decorative: what it does shows on the fleet itself. The stylesheet shows one glyph at a time,
 * from the box's data-glyph.
 */
export function DemoPointer({
  ref,
  className,
  arrowClass,
  handClass,
}: {
  ref: Ref<HTMLSpanElement>;
  className?: string;
  arrowClass?: string;
  handClass?: string;
}) {
  return (
    <span ref={ref} className={className} style={POINTER} aria-hidden="true">
      <span className={arrowClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          <path
            d="M3 2v14.5l3.6-3.3 2.6 5.6 2.4-1.1-2.6-5.5h5.2z"
            style={ARROW}
            strokeWidth="1.3"
            strokeLinejoin="round"
          />
        </svg>
      </span>
      <span className={handClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          {/* The tip of the finger sits where the arrow's tip is. */}
          <path
            d="M6.4 3.3c0-.8.6-1.4 1.3-1.4S9 2.5 9 3.3v5.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.7c.2-.4.6-.7 1.1-.7.7 0 1.2.5 1.2 1.2v3.5c0 2.8-1.9 4.9-4.6 4.9h-1.2c-1.8 0-3.1-.8-4.1-2.3l-2.6-3.9c-.4-.6-.2-1.3.4-1.7.6-.3 1.3-.2 1.7.4l.6.9z"
            style={HAND}
            strokeWidth="1.1"
            strokeLinejoin="round"
            transform="translate(-4.7 0.1)"
          />
        </svg>
      </span>
    </span>
  );
}
```

### agent-fleet/use-autoplay.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useCallback, useEffect, useRef, useState } from 'react';

/*
 * When a demo may play on its own: while part of it is on screen and the tab is visible, never
 * under reduced motion, and never again once the reader has used it. `take()` hands it to the
 * reader for good, until the component mounts again (WCAG 2.2.2).
 */
export function useAutoplay<T extends HTMLElement>() {
  const ref = useRef<T>(null);
  const [visible, setVisible] = useState(false);
  const [reduced, setReduced] = useState(true);
  const [taken, setTaken] = useState(false);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    let onScreen = false;
    const update = () => setVisible(onScreen && !document.hidden);
    const observer = new IntersectionObserver(
      ([entry]) => {
        onScreen = entry.isIntersecting;
        update();
      },
      { threshold: 0.3 },
    );
    observer.observe(element);
    document.addEventListener('visibilitychange', update);
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    const readMotion = () => setReduced(motion.matches);
    readMotion();
    motion.addEventListener('change', readMotion);
    return () => {
      observer.disconnect();
      document.removeEventListener('visibilitychange', update);
      motion.removeEventListener('change', readMotion);
    };
  }, []);

  const take = useCallback(() => setTaken(true), []);

  return { ref, take, visible, reduced, playing: visible && !reduced && !taken };
}
```