协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
a2ui-angular【开发与工程】A2UI (Agent-to-User Interface) renderer development for Angular 21.x. Use when building A2UI component renderers, agent-driven UIs, A2UI catalogs, action handlers, or streaming A2UI payloads. Covers protocol implementation, security validation, component mapping, and agent integration.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Tech Stack: Angular 21+, A2UI Protocol v0.8+, TailwindCSS 4.x, daisyUI 5.5.5
A2UI (Agent-to-User Interface) is a declarative protocol by Google that lets AI agents describe rich, interactive UIs as structured JSON data instead of generating executable code. The agent sends a JSON blueprint; the client app renders it using its own native components.
Key principle: UI-as-data, not UI-as-code. Agents never generate HTML/JS — they describe intent via a flat component adjacency list. The client validates against an approved component catalog and renders with native framework components.
A2UI PAYLOADS ARE UNTRUSTED. VALIDATE COMPONENT TYPES AGAINST THE CATALOG ALLOWLIST BEFORE RENDERING. NEVER EXECUTE AGENT-PROVIDED CODE.
Every component from an agent must be validated against the client's approved catalog. Rendering any component type the agent sends, or executing agent-provided scripts, exposes the application to XSS, code injection, and data theft. The catalog allowlist is the security boundary.
For Angular coding conventions, read the
angular-spaskill'sreference/angular-conventions.mdFor A2UI-specific patterns, readreference/a2ui-protocol.md
| Source | URL / Tool | Purpose |
|---|---|---|
| A2UI Spec | https://a2ui.org/ | Protocol specification, component format |
| A2UI GitHub | https://github.com/google/A2UI | Reference implementations, samples |
| A2A Extension | https://a2ui.org/a2a-extension/a2ui/v0.8 | A2A protocol integration (Python ADK) |
| A2UI Composer | https://a2ui.org/composer/ | Visual widget builder — prototype before wiring |
| @a2ui/angular | npm install @a2ui/angular | Official Angular renderer SDK |
| Angular v21 | angular-cli MCP | Workspace-aware help, schematics |
| daisyUI v5 | https://daisyui.com/llms.txt | Component reference for rendering |
| TailwindCSS | Context7 MCP | Utility classes for layout |
reference/a2ui-protocol.md — protocol structure, JSON format, adjacency list, action modelreference/a2ui-renderer-patterns.md — Angular renderer architecture, catalog service, recursive renderingreference/a2ui-security.md — allowlist enforcement, injection prevention, input sanitizationreference/a2ui-component-catalog.md — standard component types, property schemas, action definitionsangular-cli MCP or Context7 MCP before using any Angular APIA2UIRendererComponent that maps A2UI types to Angular/daisyUI componentsng build to ensure no compilation errorsDetailed patterns are in reference/:
a2ui-protocol.md — Protocol specification, JSON format, adjacency list structure, message types, userActiona2ui-protocol-advanced.md — Action model, streaming (JSONL/SSE/WebSocket/REST/A2A), A2A integration, versioninga2ui-security.md — Allowlist enforcement, injection prevention, untrusted payload handlinga2ui-component-catalog.md — Layout (Row, Column) + Display (Text, Image, Icon, Divider) + Interactive (Button, TextField, Checkbox, DateTimeInput) component schemasa2ui-component-containers.md — Container types (Card, Modal, Tabs, List), extended catalog (ChoicePicker, Slider, AudioPlayer, Video), how to add new typesa2ui-functions.md — Full functions reference: validation (required, regex, email), formatting (formatCurrency, formatDate, pluralize), logical (and, or, not), navigation (openUrl) — A2UIFunctionService implementationa2ui-renderer-patterns.md — Architecture overview, file structure, TypeScript models, catalog service, sanitizer service, renderer key patternsa2ui-renderer-template.md — Full A2UIRendererComponent implementation (all 12 @case branches, computed signals, action dispatch)a2ui-chat-template.md — Chat page component, streaming variant (SSE + JSONL), wire format reference with JSON examplesa2ui-renderer-services.md — Official @a2ui/angular SDK setup (A2uiRendererService, SurfaceComponent, A2UI_RENDERER_CONFIG), A2UIAgentService (REST + SSE), unit test templatea2ui-production-architecture.md — Production stack, Domain DSL, Custom Catalog patterns (BoundProperty, BasicCatalogBase, FunctionImplementation), Charts/Dashboard, Testing patterns, Observability metricsa2ui-client-integration.md — agUiResource service pattern, registerHandlers, widget template, demo-only vs production action handler warning, rate limits (surfaces/session, actions/sec, payload size)// ❌ FORBIDDEN: Rendering arbitrary component types from agent
@switch (comp.type) {
@default {
<div [innerHTML]="comp.properties['html']"></div> // XSS vector!
}
}
// ✅ REQUIRED: Validate against catalog, skip unknown types
@switch (comp.type) {
@default {
<!-- Unknown A2UI type silently skipped — not in catalog -->
}
}
// ❌ FORBIDDEN: Executing agent-provided code
eval(comp.properties['script']);
new Function(comp.properties['handler'])();
// ✅ REQUIRED: Declarative action dispatch (v0.8 format)
onAction(comp: A2UIComponent): void {
const action = comp['action'] as { name: string; context?: Array<{ key: string; value: unknown }> };
if (!action?.name) return;
this.actionTriggered.emit({ name: action.name, context: action.context ?? [] });
}
// ❌ FORBIDDEN: Deeply nested JSON tree from agent
{ "children": [{ "children": [{ "children": [...] }] }] }
// ✅ REQUIRED: surfaceUpdate with components as array, root field (A2UI v0.8 protocol)
{
"surfaceUpdate": {
"surfaceId": "main",
"components": [
{ "id": "root", "component": { "type": "Column", "children": {"explicitList": ["btn-1"]} } },
{ "id": "btn-1", "component": { "type": "Button", "primary": true, "action": {"name": "submit"} } }
],
"root": "root"
}
}
// ✅ REQUIRED: userAction — 5th message type, client → agent
{
"userAction": {
"name": "book_hotel",
"surfaceId": "main",
"sourceComponentId": "btn-book",
"timestamp": "2026-03-10T12:00:00Z",
"context": { "hotelId": "H-456" }
}
}
# Generate A2UI feature module
mkdir -p src/app/features/a2ui-chat/{components,services,models}
# Run tests
npx ng test --watch=false
# Build
npx ng build