Loading component…
Loading component…
Agents and the tools they call as a living network – a pulse along the link for every call and its answer, and agents that turn amber when they need you.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AgentGraph from ./agent-graph.
import { AgentGraph, type GraphNode, type GraphCall } from "@/components/ui/agent-graph";
const nodes: GraphNode[] = [
{ id: "lead", kind: "agent", name: "Orchestrator", detail: "Opus 5.5", status: "working", lead: true },
{ id: "research", kind: "agent", name: "Researcher", detail: "Sonnet 5.5", status: "working", cost: 0.12 },
{ id: "web", kind: "tool", name: "Web search", short: "Search" },
{ id: "notion", kind: "tool", name: "Notion", icon: <NotionLogo /> },
{ id: "you", kind: "user", name: "You" },
];
// Newest last – every new id sends a pulse; when "pending" turns "ok" or "error" the answer travels back
const calls: GraphCall[] = [
{ id: "c1", from: "lead", to: "research", at: Date.now() - 4000, status: "pending", label: "Compare pricing" },
{ id: "c2", from: "research", to: "web", at: Date.now() - 900, status: "ok", ms: 820, label: "pricing linear.app" },
];
export function Live() {
return <AgentGraph nodes={nodes} calls={calls} edges={[["you", "lead"], ["research", "notion"]]} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| nodes | GraphNode[] | { id, name, kind, short?, icon?, detail?, status?, doing?, cost?, lead? } – every agent, tool and user; pass the whole list each time, ids keep nodes in place and new ids grow in | |
| kind | "agent" \| "tool" \| "user" | Per node – agents sit on the inner orbit (the lead in the middle), tools and you on the outer one, each turned towards the agents it talks to | |
| status | "idle" \| "working" \| "waiting" \| "error" \| "done" | Per node – working agents breathe, waiting turns amber ("Needs you"), error red; waiting and error also show a chip in the bar | |
| short | string | Per node – a shorter label for narrow containers, e.g. "Search" | |
| icon | ReactNode | Per node – a logo or mark; defaults to the initials (a person for the user) | |
| detail / doing | string | Per node – the model or what a tool is (under the agent's name and in its card), and what it is doing right now (in its card) | |
| cost | number | Per node – what it has cost so far; the bar sums all nodes | |
| lead | boolean | first agent | Per node – the agent in the middle |
| calls | GraphCall[] | [] | { id, from, to, at, status?, label?, ms? } – recent calls, newest last. A new id sends a pulse from → to; when its status turns "ok" the answer travels back as a hollow dot, "error" comes back red and flashes the link. Calls also create the links they need |
| edges | [string, string][] | [] | Links that are always there, even before their first call |
| now | number | Date.now() | The clock for calls per minute and link heat – without it the graph ticks every second |
| heatWindow | number | 20000 | How far back (ms) calls count towards a link's thickness – the busiest link is about 4px, a quiet one 1.25px |
| onSelect | (node: GraphNode \| null) => void | A node was clicked (its card opens) – null when the card closes | |
| height | number | fits the width | Fixed height of the graph in px – by default 0.6 × the width (360–520px) when wide, 1.2 × when narrow |
| formatCost | (amount: number) => string | dollars, e.g. "$0.42" | Formats every cost |
| title | string | "Agent graph" | Heading of the bar |
| className | string | Extra class on the root |
The width is measured with a ResizeObserver and the whole layout is computed from it – orbits, node sizes and label room
Below 520px the graph turns taller than wide, nodes get smaller, labels use their short names, the model line is left out and the card docks to the bottom of the graph
Labels and the outer orbit always stay inside the panel – nothing is cut off and nothing scrolls sideways, down to 320px
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"