a2ui

a2ui-projectApache-2.0活跃维护

开源生成式 UI 框架:智能体以流式输出布局数据,应用用 React、Angular、Flutter、SwiftUI 等原生组件实时渲染界面。

Open-source generative UI framework: agents stream layout data, and apps render it with native components in React, Angular, Lit, Flutter, SwiftUI and Jetpack Compose.

python/a2ui-core/v0.5.0发布于 2026-11-02 02:38 UTC17,039star +34 / 7 天1,377fork同步于 2026-11-10 11:25 UTC

怎么上手

由 README 提炼,执行前请确认
npm install @a2ui/react
# 或 Flutter:flutter pub add a2ui_flutter a2ui_core
硬件要求按 README 说明

README 未说明;仅要求宿主应用基于受支持框架(当前为 Web 或 Flutter),示例需 Node.js 18+ 与 Gemini API key。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

让 Agent 用声明式 JSON 描述界面,客户端用原生组件安全渲染的生成式 UI 框架

开源生成式 UI 框架:智能体以流式输出布局数据,应用用 React、Angular、Flutter、SwiftUI 等原生组件实时渲染界面。

核心能力

  • Agent 发送声明式 JSON 描述 UI 意图,不传可执行代码
  • 客户端从预审组件目录中映射到原生组件渲染
  • 扁平组件列表加 ID 引用,便于 LLM 增量生成与渐进渲染
  • 同一份 JSON 可跨 React、Angular、Lit、Flutter、SwiftUI、Compose 渲染
  • 提供开放注册机制,把自定义组件接入数据绑定与事件系统

容易踩的坑

React 渲染器依赖 @a2ui/web_core,直接引用消息处理器或基础目录时需显式安装;跑示例需自备 GEMINI_API_KEY 并启用 Corepack;macOS Homebrew 用户需先 brew unlink yarn pnpm 再装 Corepack 以免版本冲突

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本python/a2ui-core/v0.5.0
  1. docs-assetsDocumentation Media Assets (Do Not Delete)pre-release2026-11-09 · 2026-11-09 05:46 UTC
    查看更新说明

    Immutable, content-addressed media assets referenced by docs/site/assets-manifest.json.

  2. python/a2ui-adk/v0.2.0a2ui-adk 0.2.02026-11-02 · 2026-11-02 02:38 UTC
    查看更新说明
    • BREAKING CHANGE: GenAIFileResolver is removed, along with the FileResolver it extended in a2ui-agent-sdk. #3731
    • BREAKING CHANGE: SendA2uiToClientToolset(a2ui_enabled, a2ui_processor) takes the request's A2uiRequestProcessor, or an A2uiProcessorProvider that returns it per context, instead of catalogs and examples. The processor holds the catalogs, the example turns, the inference format and, for a canvas agent, the bound RendererState. A2uiCatalogsProvider and A2uiExamplesProvider are removed; markdown examples are no longer accepted, so pass example turns to A2uiGenerator or A2uiRequestProcessor. To migrate, put generator.create_processor(capabilities) in an A2uiProcessorStore and pass A2uiProcessorStore.get as the provider. A canvas agent binds its RendererState to the processor it puts there. #3299
    • BREAKING CHANGE: The tool reads its argument, renamed from a2ui_json to a2ui_payload, in the processor's inference format (Express by default) instead of always reading JSON. It compiles the payload with the format's parser, no longer with parse_and_fix, validates it against the processor's bound state or, without one, with validate_payload, and still returns A2UI JSON messages for the part converter. The prompt it adds comes from the format's prompt generator, and it skips each section (rules, catalogs, examples) that the agent's system instruction already holds, such as when the instruction includes processor.prompt_snippet. #3299
    • BREAKING CHANGE: A2uiPartConverter takes the processor, plus the keyword arguments bypass_tool_check and fallback_text, instead of catalogs, parser, version and state. It reads text-based A2UI with the processor's parser and checks it against the processor's bound state, as a response that shows new UI when there is none, so a response that updates a surface it does not create is then rejected and logged. Each part is labeled with its message's protocol version. #3299
    • BREAKING CHANGE: A2uiEventConverter takes the request's processor, or a provider that returns it or None, in the required keyword argument a2ui_processor, instead of reading catalogs from session state. Its catalogs_key argument and the system:a2ui_catalogs key are removed. When the processor's format can stream, it opens one ResponseStream per response, feeds it each partial ADK event, and closes it on the final event. A response is keyed by its invocation and its event's branch or author, so the sub-agents of a ParallelAgent don't share a stream. A stream that gets no event for stream_idle_timeout seconds (600 by default), as when a run is cancelled, is dropped. #3299
    • A2uiProcessorStore keeps each session's request processor in memory, since ADK's persistent session services save state as JSON and can't hold one. Its get and is_enabled methods are providers for SendA2uiToClientToolset and A2uiEventConverter. #3299
    • SendA2uiToClientToolset and A2uiEventConverter log a warning when they get one processor for every request with a RendererState bound to it, since every conversation would share that state. #3299
    • A2uiEventConverter now streams responses in the default ExpressFormat incrementally as statements and progressive strings arrive, rather than waiting for the closing </a2ui> tag. #3712
    • Tool and parse errors, which may quote the A2UI payload, are logged by type at warning level and in full only at debug level. [#3299
  3. python/a2ui-a2a/v0.2.0a2ui-a2a 0.2.02026-11-02 · 2026-11-02 02:38 UTC
    查看更新说明
    • create_a2ui_part labels a part with the message's own version field when no version is passed, so a v0.9.1 or v1.0 message gets the current A2UI MIME type. #3299
    • parse_content_to_parts logs a parse error, which may quote the response, by type at warning level and in full only at debug level. #3299

    Published to PyPI: a2ui-a2a 0.2.0

    pip install a2ui-a2a==0.2.0
    
  4. python/a2ui-agent-sdk/v0.10.0a2ui-agent-sdk 0.10.02026-11-02 · 2026-11-02 02:38 UTC
    查看更新说明
    • Add incremental streaming support for the Express inference format via ExpressResponseStream (ExpressFormat.supports_streaming and ExpressParser.supports_streaming now return True). ExpressFormatFactory, ExpressFormat, and ExpressParser accept progressive_keys (defaulting to DEFAULT_EXPRESS_PROGRESSIVE_KEYS = frozenset({"text"})) to heal unclosed string literals in matching component properties and data path assignments as chunks arrive, while gating initial createSurface emission on root = ... for new surfaces, emitting delta updateComponents and per-path updateDataModel messages on subsequent chunks, and holding statements with unresolved value variables until defined (#2896).
    • BREAKING CHANGE: Use '1.0' (without a 'v' prefix) as the version field on v1.0 protocol messages and capabilities in inference format compilers, parsers, decompilers, builders (a2ui.builder.v1_0), RendererState, resolve_catalogs, and prompt examples. #3097, #3726
    • BREAKING CHANGE: The a2ui.extensions.file_resolve module (FileResolver, FileResolverSecurityError and ResolvedFileConverter) is removed, and the package no longer depends on httpx. File pointers are not part of the A2UI protocol, so resolving them is left to the agent. #3731
    • Add ComponentBuilderNode.metadata, ComponentBuilderNode.with_extension(namespace, value), and set_surface_extensions(messages, *, surface_id=..., extensions=...) in a2ui.builder.v1_0 with UAX 31 extension key validation, and support the reserved extensions= keyword argument on surface(...) and component calls in v1.0 A2UI Express (ExpressCompiler and ExpressParser.decompile) (#3708, #3757).
    • BREAKING: In Express (ExpressCompiler), data path assignments ($/... = ...) in surface-updating scopes (scopes that do not create a surface with root or carry update=true) now emit one targeted updateDataModel message per assigned path at its JSON Pointer path instead of folding all assignments into a single root updateDataModel with path: "/" (which overwrote the entire surface data model on the renderer). Surface-creating scopes continue to fold data path assignments into a single root data model and now support list element traversal, canonical numeric-segment list auto-vivification, and full root replacement via $/ = {...} (#3677).
    • BREAKING CHANGE: When ResponseStream.feed or close raises an A2uiError, its partial_results holds the parts the call made ready before the failure, as for parse_response, and they stay applied to the stream's RendererState. Before, a chunk that finished a block and then failed in the next one raised without those parts and rolled them back. Recommended migration: show error.partial_results before ending the stream. #3597
    • BREAKING CHANGE: ResponseStream is generic in the parts it returns (ResponseStream[ResponsePart] by default, ResponseStream[StreamPart] for a stream that reads past rejected blocks) and has an abstract is_in_block property, so a subclass must implement it and an annotation must name the part type. #3597
    • BREAKING CHANGE: DirectJsonPromptGenerator.generate_base_rules() now returns the workflow rules followed by the protocol schemas (agent-to-renderer and pruned common types) and accepts allowed_messages, while generate_catalog_instructions() returns only the catalog schemas and drops allowed_messages ([#3526](https://github.com/a2ui-project/a2ui/i
  5. python/a2ui-core/v0.5.0a2ui-core 0.5.0最新正式版2026-11-02 · 2026-11-02 02:38 UTC
    • BREAKING CHANGE: DataContext refuses a function whose allowed_callers is agentOnly, before running it, so a binding, check or function call action that calls one reports an EXPRESSION_ERROR instead of running it, as the v1.0 specification requires. RpcHandler still runs such a function for an agent's callRendererFunction. Recommended migration: set allowed_callers to rendererOrAgent on a function both the renderer and the agent call (#3483, #3773).
    • From v0.9, a component its catalog declares with no ComponentId or ChildList property has no child references. Previously any of its string properties that named a component on the surface, such as an Icon named mail inside the Row whose id is mail, was read as one, so a valid surface could fail topology checks as a cycle. A property declared as a plain string is read as text, as the protocol's catalog rules require. v0.8 catalogs, and components a catalog does not declare, still infer references from property names and values.
    • BREAKING CHANGE: Unify the v1.0 protocol version wire value on '1.0' (without a 'v' prefix) across message envelopes, capability objects, and catalog documents (ProtocolVersion.V1_0.value is now '1.0'), while continuing to accept 'v1.0' in Catalog.from_json. Catalog.protocol_version is typed as ProtocolVersion | str. #3097, #3726
    • BREAKING CHANGE: validate_composition_constraints and SurfaceComponentsModel.validate_components_update apply the "Surface" allowedParents rule only to the surface's root component (root_id, "root" by default), even when another component also references it, and check every parent of a component that has several, not only the last one in surface order. A non-root component that nothing references is no longer checked against "Surface"; the topology checks report it as an orphan, or allow it. This matches the specification and the TypeScript, Dart and Swift SDKs, and changes which payloads are accepted. (#3354, #3360)
    • BREAKING CHANGE: A MessageProcessor without a validation_config, as a renderer has by default, checks each updateComponents against the allowedParents and allowedChildren rules of its catalogs, as the TypeScript and Dart SDKs do. Before, it checked nothing, so a payload that breaks those rules is now rejected. The check is skipped when no catalog of the surface's components declares such rules. #3360
    • Add extension metadata APIs across SurfaceModel (metadata, extensions, on_metadata_changed, set_extension, remove_extension, and dispatch_action(..., metadata=...)), ComponentModel (metadata, extensions, on_metadata_changed, set_extension, remove_extension), ComponentNode (metadata and on_metadata_changed), ComponentContext and GenericBinder (metadata, extensions, and optional metadata on bound action closures), and ComponentApi (metadata parsed and serialized in Catalog.from_json() and Catalog.to_json()). Fix MessageProcessor to store component metadata on ComponentModel.metadata outside ComponentModel.properties and validate UAX 31 extension keys on component creation as well as updates, and fix Pydantic code generation to emit a distinct ActionMetadata wrapper model instead of colliding with Extensions (#3103, #3468, #3560, #3708, [#3757](http

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    A2UI: Agent-to-User Interface

    A2UI is an open-source generative UI framework, complete with a format optimized for representing updatable agent-generated UIs and an initial set of renderers, that allows agents to generate or populate rich user interfaces.

    A gallery of A2UI rendered cards, showing a variety of UI compositions that A2UI can achieve.

    Summary

    Generative AI excels at creating text and code, but agents can struggle to present rich, interactive interfaces to users, especially when those agents are remote or running across trust boundaries.

    A2UI is an open standard and set of libraries that allows agents to "speak UI." Agents send a declarative JSON format describing the intent of the UI. The client application then renders this using its own native component library (Flutter, Angular, Lit, etc.).

    This approach ensures that agent-generated UIs are safe like data, but expressive like code.

    When to use A2UI

    • Use A2UI when you need agent-generated UI on Flutter, Angular, SwiftUI / Jetpack Compose, or more than one platform from the same agent.
    • Use A2UI when the agent is remote, third-party, or across a trust boundary and must not send executable code to your renderer.
    • Use A2UI on Flutter with a2ui_flutter: flutter pub add a2ui_flutter a2ui_core. It replaces the genui package.
    • You may not need A2UI for a React-only chat that renders tool results as your own components; an LLM toolkit alone may be enough. A2UI fits once you add platforms or remote agents.

    Install the renderer for your framework, for example npm install @a2ui/react (or @a2ui/angular, @a2ui/lit). It depends on @a2ui/web_core; add @a2ui/web_core explicitly too if your app imports from it directly (e.g. the message processor or basic catalog). See the Client Setup guide for each platform.

    High-level philosophy

    A2UI was designed to address the specific challenges of interoperable, cross-platform, generative or template-based UI responses from agents.

    The project's core philosophies:

    • Security first: Running arbitrary code generated by an LLM may present a security risk. A2UI is a declarative data format, not executable code. Your client application maintains a "catalog" of trusted, pre-approved UI components (e.g., Card, Button, TextField), and the agent can only request to render components from that catalog.
    • LLM-friendly and incrementally updatable: The UI is represented as a flat list of components with ID references which is easy for LLMs to generate incrementally, allowing for progressive rendering and a responsive user experience. An agent can efficiently make incremental changes to the UI based on new user requests as the conversation progresses.
    • Framework-agnostic and portable: A2UI separates the UI structure from the UI implementation. The agent sends a description of the component tree and its associated data model. Your client application is responsible for mapping these abstract descriptions to its native widgets—be it web components, Flutter widgets, React components, SwiftUI views or something else entirely. The same A2UI JSON payload from an agent can be rendered on multiple different clients built on top of different frameworks.
    • Flexibility: A2UI also features an open registry pattern that allows developers to map server-side types to custom client implementations, from native mobile widgets to React components. By registering a "Smart Wrapper," you can connect any existing UI component—including secure iframe containers for legacy content—to A2UI's data binding and event system. Crucially, this places security firmly in the developer's hands, enabling them to enforce strict sandboxing policies and "trust ladders" directly within their custom component logic rather than relying solely on the core system.

    Use cases

    Some of the use cases include:

    • Dynamic Data Collection: An agent generates a bespoke form (date pickers, sliders, inputs) based on the specific context of a conversation (e.g., booking a specialized reservation).
    • Remote Sub-Agents: An orchestrator agent delegates a task to a remote specialized agent (e.g., a travel booking agent) which returns a UI payload to be rendered inside the main chat window.
    • Adaptive Workflows: Enterprise agents that generate approval dashboards or data visualizations on the fly based on the user's query.

    Architecture

    The A2UI flow disconnects the generation of UI from the execution of UI:

    1. Generation: An Agent (using Gemini or another LLM) generates or uses a pre-generated A2UI Response, a JSON payload describing the composition of UI components and their properties.
    2. Transport: This message is sent to the client application (via A2A, AG-UI, etc.).
    3. Resolution: The Client's A2UI Renderer parses the JSON.
    4. Rendering: The Renderer maps the abstract components (e.g., type: 'text-field') to the concrete implementation in the client's codebase.

    Dependencies

    A2UI is designed to be a lightweight format, but it fits into a larger ecosystem:

    • Transports: Compatible with A2A Protocol and AG-UI.
    • LLMs: Can be generated by any model capable of generating JSON output.
    • Host Frameworks: Requires a host application built in a supported framework (currently: Web or Flutter).

    Getting started

    Pick the path that matches where you want to start:

    PathWhat you getTime
    🍜 Quickstart Restaurant Finder DemoFull-stack A2UI running locally with a Gemini powered ADK agent and Lit renderer. Learn A2UI end-to-end and customize to your use case.~5 min
    ⚛️ Use A2UI with Any Agent Framework & HarnessScaffold an AG-UI app or harness for your framework of choice, then enable A2UI rendering over AG-UI.~5 min
    🎨 A2UI ComposerGenerate A2UI JSON from a visual editor and paste it into any agent prompt — no install required.~1 min
    🎬 A2UI TheaterStep through pre-built A2UI streaming scenarios across Lit, React, and Angular renderers — no install required.~1 min

    Restaurant Finder demo — Summary

    Prerequisites: Node.js 18+ (with Corepack enabled), uv, and a Gemini API key.

    git clone https://github.com/a2ui-project/a2ui.git
    cd a2ui
    export GEMINI_API_KEY="your_gemini_api_key"
    
    # Enable Corepack (macOS Homebrew users: see tip below)
    corepack enable
    
    yarn install
    cd samples/client/lit
    yarn demo:restaurant
    

    [!TIP] macOS Homebrew Users: If you previously installed standalone package managers, unlink conflicts before installing Corepack so Corepack can manage versions per-project:

    brew unlink yarn pnpm
    brew install corepack
    corepack enable
    

    These commands install dependencies across workspaces, build the renderers, start the Python agent, and open the client at http://localhost:5173. For step-by-step instructions, alternative demos, and troubleshooting see the full Quickstart.

    Use A2UI with Any Agent Framework & Harness — Summary

    npx create-ag-ui-app@latest
    

    Use the AG-UI CLI with your framework or harness of choice (Google Chat, ADK, LangGraph, CrewAI, Mastra, Strands, Slack, Teams, etc.), then follow the AG-UI guide to enable A2UI rendering. Some scaffold paths use CopilotKit's A2UI runtime with Next.js under the hood, but the setup surface is AG-UI-first.

    Other renderers

    For Flutter, check out the GenUI SDK, which uses A2UI under the hood. See docs/public/reference/renderers.md for the full list of client implementations.

    Packages

    These packages are developed in this repository. Packages marked "Not published yet" can be used from source.

    Python

    PackageDescriptionVersion
    a2ui-coreProtocol messages, data model, data binding and catalog validation.PyPI
    a2ui-agent-sdkAgent SDK: teaches the LLM a catalog and parses its response into A2UI messages.PyPI
    a2ui-a2aConnects the agent SDK to the Agent-to-Agent (A2A) protocol.Not published yet
    a2ui-adkConnects the agent SDK to the Agent Development Kit (ADK).Not published yet

    TypeScript

    PackageDescriptionVersion
    @a2ui/web_coreProtocol messages, state management and catalogs shared by the web renderers.npm
    @a2ui/litLit (web components) renderer.npm
    @a2ui/angularAngular renderer.npm
    @a2ui/reactReact renderer.npm
    @a2ui/markdown-itMarkdown rendering with markdown-it and DOMPurify, shared by the web renderers.npm
    @a2ui/agentAgent SDK for TypeScript and Node.js.Not published yet

    Dart and Flutter

    PackageDescriptionVersion
    a2ui_coreProtocol messages, data model, data binding and expressions for renderers and agents.pub
    a2ui_agentAgent SDK: teaches the LLM a catalog and parses its response into A2UI messages.pub
    a2ui_flutterFlutter renderer.Not published yet
    a2ui_cliDeveloper tool that generates typesafe component code from a catalog.Not published yet

    Swift

    The Swift libraries are built by the Package.swift at the root of this repository.

    PackageDescriptionVersion
    A2UISwiftCore, BasicCatalogMessage processor, data model and basic catalog definitions.Not published yet
    A2UISwiftUI, BasicCatalogSwiftUISwiftUI renderer and basic catalog views.Not published yet

    Roadmap

    We hope to work with the community on the following:

    • Spec stabilization: Moving towards a v1.0 specification.
    • More renderers: Adding official support for React, Jetpack Compose, iOS (SwiftUI), and more.
    • Additional transports: Support for REST and more.
    • Additional Agent frameworks: Genkit, LangGraph, and more.

    Contribute

    A2UI is an Apache 2.0 licensed project. We believe the future of UI is agentic, and we want to work with you to help build it.

    See CONTRIBUTING.md for details on how to get started.