@hanzo/ui

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.

ReleaseScheduler
1 surface · 10 nodes
Schedule Release
Card + DateTimeInput + ChoicePicker + Button · undeclared dataModel keys stay private.
@hanzo/ui@8.35.1CI Green
Target Environment
// Trigger an action button to inspect the scoped { surfaceId, name, context } event.
// Undeclared dataModel keys stay private in the browser.
Local dataModel keys: releaseTag, deployDate, targetEnv, canaryOnly, internalDeployToken

Install and quick start

pnpm add @hanzo/ui

Pass 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.

AgentTurn.tsx
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.

EnvelopeVersionPurpose
createSurfacev1.0Initialize a surface (surfaceId, catalogId, root, optional inline components and dataModel, sendDataModel).
updateComponentsv1.0Upsert flat component nodes ({ id, component, ...props }) into an existing surface.
updateDataModelv1.0Patch dataModel at an RFC 6901 path with op: 'replace' | 'add' | 'remove'.
deleteSurfacev1.0Remove a surface by surfaceId.
surfaceUpdatev0.9 compatUpsert nested ({ id, component: { Card: { ... } } }) or flat component nodes.
dataModelUpdatev0.9 compatApply typed contents arrays (valueString, valueNumber, valueBoolean, valueMap, valueList) or plain objects.
beginRenderingv0.9 compatSet 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.

CategoryComponentKey props
LayoutCardtitle, subtitle, child / children
LayoutColumnchildren, gap (none–xl), align, justify
LayoutRowchildren, gap, align, justify, wrap
LayoutListchildren (explicit IDs or { template: { componentId, path } }), direction, gap
LayoutTabstabItems ([{ value, title, child }]), keyboard arrow navigation
LayoutModaltitle, entryPointChild, contentChild, Escape dismissal
LayoutDivideraxis (horizontal | vertical)
ContentTexttext, usageHint (h1–h5, body, caption, label, code), safe inline bold/code
ContentImageurl, alt, usageHint (icon, avatar, smallFeature–largeFeature, header), fit (blocks javascript: / data: URLs)
ContentIconname (inline Lucide/Material SVG paths, zero remote requests), size
ContentBadgetext, variant (default, secondary, outline, success, warning, destructive)
ContentProgressvalue, max, label
InteractiveButtonlabel or child, variant (outline default; solid primary only when primary: true), action
InteractiveTextFieldlabel, value (@path), textFieldType (text, longText, email, number, obscured, date), checks
InteractiveDateTimeInputlabel, value (@path), enableDate, enableTime, min, max
InteractiveCheckBoxlabel, value (@path), disabled
InteractiveSwitchlabel, value (@path), disabled
InteractiveChoicePickerlabel, value / selections (@path), options, selectionMode (single | multiple), variant (select | chips), maxAllowedSelections
InteractiveSliderlabel, value (@path), min, max, step, unit

Bindings, @call functions, and zero-trust actions

  • Two-way @path bindings: RFC 6901 JSON Pointers ({"@path":"/booking/date"}, supporting ~1 / ~0 escapes and relative paths inside List templates). Pointer writes are immutable and reject __proto__, constructor, and prototype segments.
  • Safe @call computed expressions: Evaluate pure allowlisted functions with zero eval or Function: formatCurrency, formatDate, formatNumber, join, concat, coalesce, not, eq, neq, gt, gte, lt, lte, and, or, if, len, upper, lower.
  • Field validation checks: Input nodes accept checks (required, minLength, maxLength, regex, min, max, email) evaluated before non-cancelling actions dispatch.
  • Zero-trust action.event.context: Clicking a Button resolves only the keys explicitly declared in action.event.context. Private dataModel fields (tokens, internal IDs, secrets) never leave the browser unless the surface explicitly sets sendDataModel: 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:

ReviewSurface.tsx
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.

CustomCatalog.tsx
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_PROMPT and A2UI_CATALOG_DESCRIPTION export 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_ui MCP tool / gen __a2ui) emits A2UI 1.0 JSONL payloads bound to HANZO_A2UI_CATALOG_ID, so agents in Hanzo Chat, Research, Studio, and @hanzo/dev render interactive surfaces through this single canonical subpath.