Agent identity
A badge and a card that say which agent this is, how it proves its identity, and whom it acts for.
The answer to "who did this?" wherever an agent appears next to people: comment threads, activity feeds, ticket histories. The pattern has two parts: a badge for a line of text, and a card.
Installation
- CLI
- Manual
The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.
- pnpm
- npm
- yarn
- bun
pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/agent-identity.json
npx shadcn@latest add https://examples.lumoauth.dev/r/agent-identity.json
yarn dlx shadcn@latest add https://examples.lumoauth.dev/r/agent-identity.json
bunx --bun shadcn@latest add https://examples.lumoauth.dev/r/agent-identity.json
Add the shadcn/ui components that the pattern uses.
npx shadcn@latest add badge cardInstall the packages.
npm install lucide-reactCopy the code into your project.
components/agent-identity.tsximport * as React from 'react';import { Bot, CircleHelp, Fingerprint, KeyRound, Server, UserRound } from 'lucide-react';import { Badge } from '@/components/ui/badge';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';import { cn } from '@/lib/utils';/** The identity types of the LumoAuth agent registry. */export type AgentIdentityType = 'workload' | 'aauth' | 'private_key_jwt' | 'client_secret' | 'api_key' | 'custom';export type AgentStatus = 'active' | 'inactive' | 'suspended' | 'revoked';export interface AgentIdentityData {name: string;/** The agent ID, for example `agt_256c6f00137973d2`. */id?: string;identityType?: AgentIdentityType;status?: AgentStatus;/** The person that the agent acts for now, when there is one. */onBehalfOf?: string | null;/** False for an agent that is not in the registry of your organization. */registered?: boolean;capabilities?: string[];}const IDENTITY: Record<AgentIdentityType, { icon: React.ElementType; label: string; text: string }> = {workload: { icon: Server, label: 'Workload', text: 'Proves where it runs. Holds no secret.' },aauth: { icon: Fingerprint, label: 'AAuth key', text: 'Signs each request with its own key.' },private_key_jwt: { icon: KeyRound, label: 'Private key', text: 'Signs in with a key, not a secret.' },client_secret: { icon: KeyRound, label: 'Client secret', text: 'Signs in with a client ID and a secret.' },api_key: { icon: KeyRound, label: 'API key', text: 'Signs in with an API key.' },custom: { icon: CircleHelp, label: 'Custom', text: 'Uses a custom way to prove its identity.' },};const STATUS: Record<AgentStatus, string> = {active: 'border-transparent bg-emerald-500/15 text-emerald-700 dark:text-emerald-400',inactive: 'border-transparent bg-muted text-muted-foreground',suspended: 'border-transparent bg-amber-500/15 text-amber-700 dark:text-amber-400',revoked: 'border-transparent bg-red-500/15 text-red-700 dark:text-red-400',};/** A mark for an agent in a line of text: a feed, a comment, a table cell. */export function AgentBadge({ agent, className }: { agent: AgentIdentityData; className?: string }) {const off = agent.status === 'suspended' || agent.status === 'revoked' || agent.registered === false;return (<spanclassName={cn('inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-1.5 py-0.5 align-middle text-xs font-medium',off && 'text-muted-foreground line-through decoration-muted-foreground/60',className,)}title={agent.onBehalfOf ? `${agent.name}, acting for ${agent.onBehalfOf}` : `${agent.name}, an AI agent`}><Bot className="size-3.5 shrink-0" aria-hidden="true" /><span className="truncate">{agent.name}</span><span className="sr-only">(AI agent)</span>{agent.onBehalfOf && (<span className="flex min-w-0 items-center gap-1 border-l pl-1.5 font-normal text-muted-foreground no-underline"><UserRound className="size-3 shrink-0" aria-hidden="true" /><span className="truncate">{agent.onBehalfOf}</span></span>)}</span>);}export function AgentIdentityCard({ agent, className }: { agent: AgentIdentityData; className?: string }) {const identity = agent.identityType ? IDENTITY[agent.identityType] : null;const IdentityIcon = identity?.icon ?? CircleHelp;const status = agent.registered === false ? null : agent.status ?? 'active';return (<Card className={cn('w-full max-w-sm gap-4', className)}><CardHeader><div className="flex items-start justify-between gap-3"><div className="flex min-w-0 items-center gap-3"><span className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted"><Bot className="size-5" aria-hidden="true" /></span><div className="grid min-w-0 gap-0.5"><CardTitle className="truncate text-base">{agent.name}</CardTitle>{agent.id && <CardDescription className="truncate font-mono text-xs">{agent.id}</CardDescription>}</div></div>{status ? (<Badge className={cn('capitalize', STATUS[status])}>{status}</Badge>) : (<Badge variant="outline">Not registered</Badge>)}</div></CardHeader><CardContent className="grid gap-3 text-sm">{agent.registered === false ? (<p className="text-muted-foreground">This agent is not in the registry of your organization. Treat what it did as the action of an unknown caller.</p>) : (<>{identity && (<div className="flex gap-2.5"><IdentityIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" aria-hidden="true" /><div><p className="font-medium">{identity.label}</p><p className="text-muted-foreground">{identity.text}</p></div></div>)}<div className="flex gap-2.5"><UserRound className="mt-0.5 size-4 shrink-0 text-muted-foreground" aria-hidden="true" /><div className="min-w-0"><p className="font-medium">{agent.onBehalfOf ? 'Acts for a person' : 'Acts for itself'}</p><p className="truncate text-muted-foreground">{agent.onBehalfOf ?? 'No person is behind its actions.'}</p></div></div>{agent.capabilities && agent.capabilities.length > 0 && (<div className="flex flex-wrap gap-1 border-t pt-3">{agent.capabilities.map((capability) => (<Badge key={capability} variant="secondary" className="font-mono font-normal">{capability}</Badge>))}</div>)}</>)}</CardContent></Card>);}Change the import paths if your project keeps its components in another place.
Usage
Use the badge wherever you show the name of an actor, and the card on the page of an agent.
import { AgentBadge, AgentIdentityCard, type AgentIdentityData } from '@/components/agent-identity';
export function ActivityLine({ agent, text }: { agent: AgentIdentityData; text: string }) {
return (
<p>
<AgentBadge agent={agent} /> {text}
</p>
);
}
export function AgentPage({ agent }: { agent: AgentIdentityData }) {
return <AgentIdentityCard agent={agent} />;
}
A struck-through badge marks an agent that is suspended, revoked or not registered. The badge also carries the words "AI agent" for screen readers.
Where the data comes from
| What the pattern shows | Call |
|---|---|
| The agent itself | GET /agents/me, or agent.getCurrentAgent() |
| Its capabilities | agent.capabilities() |
| An agent that called your API | The claims of the verified access token: the agent flag, and act for the person behind it |
| Any agent, for an administrator | Admin API, agents |
States
- Acts for itself, with a workload identity.
- Suspended.
- Revoked.
- Not registered. The card says to treat its actions as those of an unknown caller.
- In a line of text, with and without a person behind the agent.
Props
| Prop | Type | Description |
|---|---|---|
agentrequired | AgentIdentityData | The agent. Both the badge and the card take it. |
className | string | Class name for the root element. |
AgentIdentityData
| Option | Type | Default | Description |
|---|---|---|---|
namerequired | string | The name of the agent. | |
id | string | The agent ID. | |
identityType | 'workload' | 'aauth' | 'private_key_jwt' | 'client_secret' | 'api_key' | 'custom' | How the agent proves its identity. | |
status | 'active' | 'inactive' | 'suspended' | 'revoked' | 'active' | The state of the agent. |
onBehalfOf | string | null | The person that the agent acts for now. | |
registered | boolean | False for an agent that is not in the registry of your organization. | |
capabilities | string[] | Capabilities to list on the card. |