A2UI v0.9 基础 Catalog 组件
基础 Catalog 定义 Agent 可以请求的组件类型和属性。v0.9 的每个组件都是扁平对象,包含 id、字符串类型的 component 判别字段以及组件专属属性。具体定义应以 Catalog Schema 为准。
布局
Row 和 Column 通过 ID 引用子组件。固定子组件使用数组;数据驱动的子项可使用 ChildList 定义的模板形式。
{"id":"root","component":"Column","children":["heading","actions"],"justify":"start","align":"stretch"}
{"id":"actions","component":"Row","children":["cancel","save"],"justify":"end","align":"center"}
justify 与 align 的允许值由 Catalog 限制,不能内联声明完整子组件。
文本与媒体
Text 接受字面字符串或数据模型路径等动态值。variant 是语义提示,可使用 h1 到 h5、body 或 caption。
{"id":"heading","component":"Text","text":"确认订单","variant":"h2"}
{"id":"status","component":"Text","text":{"path":"/order/status"}}
Image 使用 url,并可带无障碍 description、fit 与尺寸样式 variant。宿主仍需执行 URL 策略和安全加载。
{"id":"photo","component":"Image","url":"https://images.example.com/item.webp","description":"蓝色陶瓷杯","fit":"cover","variant":"mediumFeature"}
Icon 只能使用 Catalog 允许的名称或 SVG 路径对象。纯图标控件仍需可访问名称,任意 SVG 或 URL 不能默认视为可信。
输入与 Action
TextField 使用 label、可选的数据绑定 value,以及 shortText、longText、number 或 obscured 等 variant。
{"id":"email","component":"TextField","label":"邮箱","value":{"path":"/contact/email"},"variant":"shortText"}
Button 引用一个子组件,并且必须提供 action。服务端事件需要放在 action.event 内。
{"id":"save-label","component":"Text","text":"保存"}
{"id":"save","component":"Button","child":"save-label","variant":"primary","action":{"event":{"name":"saveOrder","context":{"orderId":{"path":"/order/id"}}}}}
Action 只是事件请求,不代表权限。宿主和服务端必须校验名称与上下文、检查用户权限,并防止高影响操作重复提交。
容器
Card 只接受一个子组件 ID;需要多个元素时先用 Row 或 Column 包装。
{"id":"card","component":"Card","child":"card-content"}
Modal 分别指定触发组件和内容组件:
{"id":"details","component":"Modal","trigger":"open-details","content":"details-content"}
基础 Catalog 还包含其他展示、媒体、选择和输入组件。使用属性前应核对准确的v0.9.1 基础 Catalog Schema。自定义 Catalog 可以增加、删除或限制组件,因此必须按客户端协商的实际 Catalog 校验。