导航
Agent (LLM) → A2UI Generator → Transport (SSE/WS/A2A)
↓
Client (Stream Reader) → Message Parser → Renderer → Native UI

A2UI 定义了一系列描述用户界面的 JSON 消息。在流式传输时,这些消息通常格式为 JSON 行(JSONL), 每行是一个完整的 JSON 对象。
createSurface:创建新 surface 并指定其目录updateComponents:在 surface 中添加或更新 UI 组件updateDataModel: Update 应用状态 statedeleteSurface:移除 UI surface{
"version": "v0.9",
"createSurface": {
"surfaceId": "main",
"catalogId": "<https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json>"
}
}
{
"version": "v0.9",
"updateComponents": {
"surfaceId": "main",
"components": [...]
}
}
{
"version": "v0.9",
"updateDataModel": {
"surfaceId": "main",
"path": "/user",
"value": { "name": "Alice" }
}
}
{
"version": "v0.9",
"createSurface": {
"surfaceId": "booking",
"catalogId": "<https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json>"
}
}
{
"version": "v0.9",
"updateComponents": {
"surfaceId": "booking",
"components": [
{
"id": "root",
"component": "Column",
"children": ["header", "guests-field", "submit-btn"]
},
{
"id": "header",
"component": "Text",
"text": "Confirm Reservation",
"variant": "h1"
},
{
"id": "guests-field",
"component": "TextField",
"label": "Guests",
"value": { "path": "/reservation/guests" }
},
{
"id": "submit-btn",
"component": "Button",
"child": "submit-text",
"variant": "primary",
"action": {
"event": {
"name": "confirm",
"context": {
"details": { "path": "/reservation" }
}
}
}
}
]
}
}
{
"version": "v0.9",
"updateDataModel": {
"surfaceId": "booking",
"path": "/reservation",
"value": {
"datetime": "2025-12-16T19:00:00Z",
"guests": "2"
}
}
}
客户端自动更新 /reservation/guests
{
"version": "v0.9",
"action": {
"name": "confirm",
"surfaceId": "booking",
"context": {
"details": {
"datetime": "2025-12-16T19:00:00Z",
"guests": "3"
}
}
}
}
{
"version": "v0.9",
"deleteSurface": { "surfaceId": "booking" }
}
整个组件结构被设计成更适合 LLM 生成的扁平化 Schema(Flat Schema)
传统的嵌套方法:
A2UI 邻接表:
{
"surfaceUpdate": {
"components": [
{"id": "root", "component": {"Column": {"children": {"explicitList": ["greeting", "buttons"]}}}},
{"id": "greeting", "component": {"Text": {"text": {"literalString": "Hello"}}}},
{"id": "buttons", "component": {"Row": {"children": {"explicitList": ["cancel", "ok"]}}}},
{"id": "cancel", "component": {"Button": { ... }}},
{"id": "ok", "component": {"Button": { ... }}}
]
}
}
组件通过 ID 引用子级,而不是通过嵌套。
每个组件都有:
"welcome-message")。Text, Button, Card)。explicitList)固定的子级 ID 列表。
{"children": {"explicitList": ["back-btn", "title", "menu-btn"]}}
template)从数据数组生成子级。
{"children": {"template": {"dataBinding": "/items", "componentId": "item-template"}}}
对于 /items 中的每个项目,渲染 item-template。
{"text": {"literalString": "Welcome"}}{"text": {"path": "/user/name"}}surfaceUpdate。surfaceUpdate。除了标准目录外,客户端还可以定义自定义组件(图表、地图等)。
想象一个“股票行情追踪”组件。
price: 105.20)。UI 会瞬间平滑更新。把您的数据想象成一个文件系统树。每一条数据都有一个“地址”。
{
"user": { "name": "Alice" },
"cart": { "total": 99.00 }
}
组件不硬编码 “Alice”,而是指向地址 /user/name。
{
"component": {
"Text": {
"text": { "path": "/user/name" }
}
}
}