Agent bridge
Let an AI agent read the components on your page and change them through their own APIs, with your app approving each step.
The agent item connects an AI agent to the components on the page. The agent reads each one's name, state and what it can do, then changes it through the component's own API, the way a person's click or key would. It doesn't take screenshots, guess at the page or simulate the pointer, so a task like "rename the project and turn off weekly emails" takes one or two calls.
Kino's controls are built on ui-sdk, so the bridge lists each one on the page. Each component's and block's page ends with For agents: what the bridge lists on its first example, with each one's name, state and actions.
npx shadcn@latest add https://kinoui.com/r/agent.jsonIt adds lib/agent.tsx and installs ui-sdk's packages. The bridge itself is ui-sdk's, and its agent guide, which ships in the package at node_modules/@ui-sdk/react/docs/agents.md, covers every option.
Render the bridge
Render AgentBridge once, near the root of your app. In Next.js, in the root layout:
import { AgentBridge } from '@/lib/agent'export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang='en'> <body> <AgentBridge /> {children} </body> </html> )}It renders nothing. The first time it mounts, it creates the page's one bridge, which finds the components already on the page and every one that comes later.
Hand the tools to your model
The bridge has three tools: snapshot lists the components, act runs steps on them in order, and query finds the choices in a list. agentTools describes them with a name, a description and a JSON Schema, the shape model APIs take:
import { agentTools, getAgent } from '@/lib/agent'const tools = agentTools.map(({ name, description, inputSchema }) => ({ name, description, input_schema: inputSchema,}))async function runTool(name: string, input: unknown) { const agent = getAgent() if (!agent) throw new Error('The agent bridge has not mounted yet.') if (name === 'snapshot') return agent.snapshot() if (name === 'query') return agent.query(input as Parameters<typeof agent.query>[0]) return agent.act(input as Parameters<typeof agent.act>[0])}Send tools with your request, run each tool call the model makes with runTool, and send its result back. A step names a component by the words on the page:
{ "steps": [{ "ref": "Project name", "action": "setValue", "args": ["Atlas"] }] }What the tools return comes from the page, such as a name a user typed, so their descriptions tell the model to treat it as data.
Approve each step
allow decides every step an agent asks for, before it changes anything. Return true to let it run, or false, or a promise of either, to refuse it:
<AgentBridge allow={(step) => step.component !== 'dialog'} />allow is read once, when the bridge is created. A change an agent makes also reaches the component's change callback, as a person's does, with details.source set to 'agent', so the callback can refuse it with details.cancel().
Mark what needs a person
A control that deletes, pays or sends carries data-agent-confirm, with a sentence that says what it does:
<Button data-agent-confirm='Charges $20 to your card for 1,000 credits'> Buy credits</Button>The agent sees the sentence before it tries. Without an allow, a step on the control fails with "Needs a person", and the agent asks the person to press it themselves. With one, the step carries the sentence as step.confirm: show it to the person and return their answer. An allow that returns true without reading step.confirm answers yes for them.
data-agent-secret keeps a value from the agent: it can still fill the field, and reads "[redacted]". Password, card and one-time-code fields are secret without it. data-agent-hidden leaves a whole region out.
The browser's own agent
Where the browser can host an agent's tools through WebMCP, the bridge registers its three tools with the browser, so an agent built into the browser can use your page too. Its steps go through the same allow as your model's, and the components' change callbacks apply to them too. Without an allow, its step on a control marked data-agent-confirm is refused, and the person presses it themselves. In a browser without WebMCP, nothing is registered.