affectUI › Components › Agents

Threat Model

Where an agent's data goes, as a data-flow diagram with trust boundaries – every flow says what it carries, and personal data leaving unredacted turns red with its fix.

Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/threat-model.json · Import from @/components/ui/threat-model

When to use

  • Showing where an agent's data goes – who and what it talks to, and which flows leave your cloud
  • Security and privacy reviews of an agent: every flow says what it carries, whether it's encrypted and whether personal data is redacted
  • Looking at one part on its own – click a card for everything that goes in and out of it
  • Pointing at the risky flows – a red square with the risk and its fix, and Mark fixed once it's dealt with

When not to use

  • The steps of one run over time – use Trace Waterfall or Agent Timing
  • Which MCP servers and tools an agent can reach – use Agent Graph
  • Policies an agent's actions are checked against – use Guardrail Funnel

Usage

import { ThreatModel, type ThreatBoundary, type ThreatFlow, type ThreatNode } from "@/components/ui/threat-model";

const nodes: ThreatNode[] = [
  { id: "customer", name: "Customer", kind: "person", col: 0, row: 0, photo: "/customer.jpg" },
  { id: "support-agent", name: "Support agent", kind: "agent", col: 1, row: 0 },
  { id: "orders", name: "Customers", detail: "Postgres", kind: "store", col: 1, row: 1 },
  { id: "model", name: "Claude", detail: "Model provider", kind: "service", col: 2, row: 0, logo: <ClaudeLogo /> },
];

const boundaries: ThreatBoundary[] = [
  { id: "cloud", label: "Your cloud", nodes: ["support-agent", "orders"] },
  { id: "vendor", label: "Model provider", nodes: ["model"] },
];

const flows: ThreatFlow[] = [
  { id: "chat", from: "customer", to: "support-agent", label: "Chat message", data: "pii", encrypted: true },
  { id: "lookup", from: "support-agent", to: "orders", label: "Order lookup", data: "pii", encrypted: true },
  {
    id: "prompt", from: "support-agent", to: "model", label: "Prompt + order", data: "pii", encrypted: true,
    risk: { level: "high", title: "Customer PII sent to the model unredacted", fix: "Redact emails and addresses first" },
  },
];

export function SupportAgentModel() {
  return <ThreatModel name="Support agent" nodes={nodes} boundaries={boundaries} flows={flows} />;
}

Props

NameTypeDefaultDescription
namestringWhat's modelled – names the diagram for screen readers
nodesThreatNode[]{ id, name, detail?, kind, col, row, photo?, logo?, color?, tags? } – white cards on a grid (halves are fine), each with a small tile: kind "person" shows the photo or a letter, "agent" the agent's pixel mark in color, "service" its logo, "store" a database glyph (or a logo); detail is the line under the name; the lower row shows tags (up to three short facts like "eu-west-1" or "PCI DSS"), PII when personal data reaches it, and how many flows touch it – or its open risks in red or amber
boundariesThreatBoundary[]{ id, label, nodes } – trust boundaries, drawn as quiet gray areas around their nodes with the label as a tag on top. A flow between two boundaries crosses them – its card says which
flowsThreatFlow[]{ id, from, to, label, data?, encrypted?, redacted?, risk? } – soft connectors with a port at each end and an icon on a small filled square in the middle – a lock when encrypted, a warning when it's a risk – whose label shows as a tooltip on hover or focus. data is "pii", "secret", "internal" (default) or "public"; encrypted adds a lock; risk { level: "high" | "medium", title, fix? } turns the square red or amber and shows the risk and its fix in the card
tracestring[]Flow ids in the order a request takes them – traced one by one, again and again. Default: every flow in order
pacenumberMilliseconds per flow while tracing – default 1300 (500–4000)
onResolve(flowId: string) => voidCalled when a risk is marked fixed in its card
classNamestringExtra class on the root – set the color variables on it, e.g. --ui-tm-bad

Keyboard

  • Tab: Moves through the cards, then the flows' squares – each square shows its label as a tooltip
  • Enter / Space: On a card: opens its card below it – boundary, personal data, facts and every flow in and out, each opening that flow. On a square: opens the flow's card – route, boundary, encryption, personal data, the risk with its fix and Mark fixed. Opened by keyboard, the focus moves into the card, so Tab reaches its rows and buttons next
  • Esc: Closes the open card and puts the focus back on the card or square that opened it

Accessibility

  • Every flow's square is a button that reads what travels, from where to where, and its risk
  • Every card is a button that reads its name, what it is, how many flows touch it and its open risks
  • The info cards are dialogs labelled with the card or flow; the tracing holds while one is open
  • A polite live region (not shown) says which flow is being traced and its risk
  • Focus rings show for the keyboard only (:focus-visible); after Mark fixed the focus stays in the card
  • Names in any script keep their own direction – the route always reads sender → receiver, also in RTL

Responsive

  • The diagram sits right on the page – no frame around it – drawn at its own size and zoomed to the width (never larger); below 62% it scrolls sideways, with a soft fade on the side that has more to show; an open card closes as you scroll
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Agent Graph – 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
  • Guardrail Funnel – The guardrails an agent's traffic passes through, as a funnel – input check, PII redaction, tool allowlist, output check – with how many each stage stopped and what it caught
  • Petri Net – Agents working in parallel and waiting on each other, as a Petri net – tokens in places, steps that fire only when every input is ready, a person's step waiting for approval
  • Trace Waterfall – Where the time and money of an agent run go – every LLM call, tool call and sub-agent as a bar on a live timeline, with cost per step and the slowest call marked