A2UI 1.0
Agents emit declarative JSON/JSONL surfaces rendered natively by @hanzo/ui and @hanzo/design tokens — zero eval, zero raw HTML, zero iframes.
import { A2UISurface, A2UIWorkbench, extractA2UIBlocks, formatA2UIActionMessage } from '@hanzo/ui/a2ui'
import { parseA2UI, compileA2UIToJSX, HANZO_A2UI_CATALOG_ID } from '@hanzo/ui/a2ui/protocol'Google A2UI 1.0 separates what an agent proposes from how your app renders it. Instead of streaming brittle HTML or untrusted JavaScript into an iframe, an agent emits declarative JSON or JSONL messages that reference a fixed catalog of trusted native components.
@hanzo/ui/a2ui implements the A2UI 1.0 renderer, 19-component Basic Catalog, interactive <A2UIWorkbench />, and deterministic @hanzo/ui TSX compiler directly on @hanzo/design semantic tokens (var(--*)). Every surface adapts automatically to dark and light themes, works with or without <GuiProvider>, and keeps @hanzo/ui/a2ui/protocol 100% pure TypeScript for server, RSC, CLI, and Node consumers.
Live interactive workbench
Switch presets, edit the A2UI 1.0 JSON live, click an action button to inspect the zero-trust { surfaceId, name, context } payload, or open the @hanzo/ui TSX tab to inspect the compiled component code. See the full A2UI catalog and A2UISurface reference pages.
Install and quick start
pnpm add @hanzo/uiPass any raw JSON/JSONL string, A2UIMessage[], or pre-parsed A2UISurfaceState to <A2UISurface />. When a chat turn mixes prose markdown with fenced ```a2ui blocks, split the turn with extractA2UIBlocks and round-trip clicks back to the agent with formatA2UIActionMessage.
import {
A2UISurface,
extractA2UIBlocks,
formatA2UIActionMessage,
type A2UIActionEvent,
} from '@hanzo/ui/a2ui'
export function AgentTurn({
markdown,
sendMessage,
}: {
markdown: string
sendMessage: (text: string) => void
}) {
const handleAction = (event: A2UIActionEvent) => {
sendMessage(formatA2UIActionMessage(event))
}
return (
<>
{extractA2UIBlocks(markdown).map((seg, i) =>
seg.type === 'a2ui' ? (
<A2UISurface key={i} payload={seg.surfaces} onAction={handleAction} />
) : (
<p key={i}>{seg.content}</p>
),
)}
</>
)
}Protocol primitives
A2UI streams one JSON envelope per line (JSONL) or a JSON array of messages. parseA2UI skips incomplete trailing lines during live streaming and preserves user edits across incoming updates.
| Envelope | Version | Purpose |
|---|---|---|
createSurface | v1.0 | Initialize a surface (surfaceId, catalogId, root, optional inline components and dataModel, sendDataModel). |
updateComponents | v1.0 | Upsert flat component nodes ({ id, component, ...props }) into an existing surface. |
updateDataModel | v1.0 | Patch dataModel at an RFC 6901 path with op: 'replace' | 'add' | 'remove'. |
deleteSurface | v1.0 | Remove a surface by surfaceId. |
surfaceUpdate | v0.9 compat | Upsert nested ({ id, component: { Card: { ... } } }) or flat component nodes. |
dataModelUpdate | v0.9 compat | Apply typed contents arrays (valueString, valueNumber, valueBoolean, valueMap, valueList) or plain objects. |
beginRendering | v0.9 compat | Set root and catalogId on a surface created via surfaceUpdate. |
{"version":"v1.0","createSurface":{"surfaceId":"s1","catalogId":"https://hanzo.ai/a2ui/catalog/v1","root":"card","dataModel":{"date":"2026-12-01"}}}
{"version":"v1.0","updateComponents":{"surfaceId":"s1","components":[{"id":"card","component":"Card","title":"Deploy","children":["d","go"]},{"id":"d","component":"DateTimeInput","label":"Date","value":{"@path":"/date"}},{"id":"go","component":"Button","label":"Schedule","primary":true,"action":{"event":{"name":"schedule","context":{"date":{"@path":"/date"}}}}}]}}
{"version":"v1.0","updateDataModel":{"surfaceId":"s1","path":"/date","value":"2026-12-05","op":"replace"}}Basic Catalog (19 components)
Catalog ID: HANZO_A2UI_CATALOG_ID (https://hanzo.ai/a2ui/catalog/v1). Standard A2UI v1.0 / v0.9 / v0.8 catalog IDs are accepted automatically.
| Category | Component | Key props |
|---|---|---|
| Layout | Card | title, subtitle, child / children |
| Layout | Column | children, gap (none–xl), align, justify |
| Layout | Row | children, gap, align, justify, wrap |
| Layout | List | children (explicit IDs or { template: { componentId, path } }), direction, gap |
| Layout | Tabs | tabItems ([{ value, title, child }]), keyboard arrow navigation |
| Layout | Modal | title, entryPointChild, contentChild, Escape dismissal |
| Layout | Divider | axis (horizontal | vertical) |
| Content | Text | text, usageHint (h1–h5, body, caption, label, code), safe inline bold/code |
| Content | Image | url, alt, usageHint (icon, avatar, smallFeature–largeFeature, header), fit (blocks javascript: / data: URLs) |
| Content | Icon | name (inline Lucide/Material SVG paths, zero remote requests), size |
| Content | Badge | text, variant (default, secondary, outline, success, warning, destructive) |
| Content | Progress | value, max, label |
| Interactive | Button | label or child, variant (outline default; solid primary only when primary: true), action |
| Interactive | TextField | label, value (@path), textFieldType (text, longText, email, number, obscured, date), checks |
| Interactive | DateTimeInput | label, value (@path), enableDate, enableTime, min, max |
| Interactive | CheckBox | label, value (@path), disabled |
| Interactive | Switch | label, value (@path), disabled |
| Interactive | ChoicePicker | label, value / selections (@path), options, selectionMode (single | multiple), variant (select | chips), maxAllowedSelections |
| Interactive | Slider | label, value (@path), min, max, step, unit |
Bindings, @call functions, and zero-trust actions
- Two-way
@pathbindings: RFC 6901 JSON Pointers ({"@path":"/booking/date"}, supporting~1/~0escapes and relative paths insideListtemplates). Pointer writes are immutable and reject__proto__,constructor, andprototypesegments. - Safe
@callcomputed expressions: Evaluate pure allowlisted functions with zeroevalorFunction:formatCurrency,formatDate,formatNumber,join,concat,coalesce,not,eq,neq,gt,gte,lt,lte,and,or,if,len,upper,lower. - Field validation
checks: Input nodes acceptchecks(required,minLength,maxLength,regex,min,max,email) evaluated before non-cancelling actions dispatch. - Zero-trust
action.event.context: Clicking aButtonresolves only the keys explicitly declared inaction.event.context. PrivatedataModelfields (tokens, internal IDs, secrets) never leave the browser unless the surface explicitly setssendDataModel: true.
Workbench and @hanzo/ui TSX codegen
<A2UIWorkbench /> pairs live <A2UISurface /> preview + zero-trust action inspection with editable A2UI JSON diagnostics and deterministic @hanzo/ui TSX compilation via compileA2UIToJSX:
import { A2UIWorkbench } from '@hanzo/ui/a2ui'
import { compileA2UIToJSX, parseA2UI } from '@hanzo/ui/a2ui/protocol'
// Compile any surface to reviewable @hanzo/ui TSX (works in Node, RSC, CLI, or browser)
const [surface] = parseA2UI(jsonlPayload)
const tsx = compileA2UIToJSX(surface, { componentName: 'ReleaseCard' })
export function ReviewSurface({ initialPayload }: { initialPayload: string }) {
return (
<A2UIWorkbench
title="ReleaseCard"
initialPayload={initialPayload}
onSave={(json, generatedTsx) => {
console.log('Saved surface JSON & TSX', json.length, generatedTsx.length)
}}
/>
)
}Extending the catalog and agent integration
Merge domain-specific components on top of defaultA2UICatalog via the catalog prop — unknown component types are ignored safely unless showUnknownFallback is set.
import { A2UISurface, type A2UIComponentRenderProps } from '@hanzo/ui/a2ui'
import { resolveString } from '@hanzo/ui/a2ui/protocol'
function MetricTile({ node, dataModel, basePath }: A2UIComponentRenderProps) {
const label = resolveString(node.props.label, dataModel, basePath)
const value = resolveString(node.props.value, dataModel, basePath)
return (
<div>
<strong>{value}</strong>
<span>{label}</span>
</div>
)
}
export function DomainSurface({ payload }: { payload: string }) {
return <A2UISurface payload={payload} catalog={{ MetricTile }} />
}System prompt & hanzoai/gen MCP tool
HANZO_A2UI_SYSTEM_PROMPTandA2UI_CATALOG_DESCRIPTIONexport the exact catalog ID, envelope schema, component names, and zero-trust action contract to pass directly into any agent’s system prompt.hanzoai/gen(render_uiMCP tool /gen __a2ui) emits A2UI 1.0 JSONL payloads bound toHANZO_A2UI_CATALOG_ID, so agents in Hanzo Chat, Research, Studio, and@hanzo/devrender interactive surfaces through this single canonical subpath.