Agent bridge
In code: AgentBridge
Put it once in the root layout. It makes every Supply UI control usable by an AI agent the person runs in their browser, and shows the dialog that asks before a marked action. Without an agent it does nothing.
Preview
Booked, Friday 09:30
Use
The code of the preview above
import { useState } from 'react';
import { AgentBridge, Badge, Button, Row, Stack, getAgent } from '@/components/ui';
import { Sparkles } from 'lucide-react';
function AgentBridgeDemo() {
const [booked, setBooked] = useState(true);
const askAssistant = () => getAgent().act({ steps: [{ ref: 'Cancel the booking', action: 'press' }] });
return (
<Stack gap={4}>
<AgentBridge />
<Row gap={2}>
<Badge tone={booked ? 'success' : 'outline'} dot={booked}>{booked ? 'Booked, Friday 09:30' : 'Cancelled'}</Badge>
</Row>
<Row gap={2}>
<Button onClick={() => setBooked(false)} disabled={!booked} data-agent-confirm="Cancels Noor Haddad's booking on Friday">Cancel the booking</Button>
<Button variant="ghost" onClick={askAssistant} disabled={!booked}><Sparkles />Ask the assistant to cancel</Button>
</Row>
</Stack>
);
}Options
| Option | Type | What it does |
|---|---|---|
allowLabel | ReactNode | The words on the button that lets the agent go ahead: "Allow" by default. |
refuseLabel | ReactNode | The words on the button that stops it: "Not now" by default. |
title | ReactNode | The question shown when an agent wants to do something marked data-agent-confirm. |
Without React
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/button.csscomponents/card.csscomponents/tabs.csscomponents/dialog.csscomponents/button-group-toggle.csscomponents/tab-bar.csscomponents/prose.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/carousel.cssparts/changed-by-whom.cssparts/board.cssOther parts: states, do and don’t
Parts of a bigger component (a CardBody of a Card, a DialogTitle of a Dialog) and pieces used inside others. Use them inside their component, as its page shows.