#a2ui #catalog #ratatui #agent #model #slint #egui #framework-agnostic

a2ui-base

Framework-agnostic base for A2UI (Agent to UI): protocol, models, and catalog

4 releases

Uses new Rust 2024

0.3.1 Jun 18, 2026
0.3.0 Jun 16, 2026
0.2.1 Jun 15, 2026
0.2.0 Jun 14, 2026

#1500 in GUI

Download history 9/week @ 2026-07-28 23/week @ 2026-08-04 18/week @ 2026-08-11 8/week @ 2026-08-18 14/week @ 2026-08-25 15/week @ 2026-09-01 9/week @ 2026-09-08 24/week @ 2026-09-15 29/week @ 2026-09-22 22/week @ 2026-09-29 24/week @ 2026-10-06 151/week @ 2026-10-13 83/week @ 2026-10-20 57/week @ 2026-10-27 226/week @ 2026-11-03 601/week @ 2026-11-10

987 downloads per month
Used in 15 crates

MIT license

245KB
5K SLoC

a2ui-base

crates.io docs.rs MIT

English | 中文

📦 a2ui crate 生态成员 · 框架无关核心层

本 crate 是 a2ui workspace 的基础子 crate,完整介绍见根目录 README。

A2UI (Agent to UI) v1.0 协议的框架无关核心层:协议类型、组件 / 数据模型、Catalog、消息处理器、能力协商、校验,以及所有 UI 后端共享的交互层。不依赖任何 UI 框架(ratatui / Slint / egui 都不引入),可独立用于其他 backend 或纯协议解析场景。

在生态中的位置

┌───────────────────────────────────────────────────────────────────────┐
│  apps:  a2ui-gallery (TUI)   a2ui-slint-gallery   a2ui-egui-gallery   │
│  umbrella:   a2ui  (re-export core + tui [+ slint] [+ egui])          │
│  backends:   a2ui-tui (ratatui)   a2ui-slint   a2ui-egui              │
├───────────────────────────────────────────────────────────────────────┤
│  ▶ a2ui-base  (框架无关:Protocol / Model / Catalog / Processor)       │
└───────────────────────────────────────────────────────────────────────┘

a2ui-base 是整个 workspace 的地基 —— 三个后端(ratatui / Slint / egui)都建立在它之上。框架无关的交互逻辑(焦点遍历 focus、事件结果应用 interaction、组件行为 components)统一放在这里,保证不同后端在键盘 / 按钮交互上行为一致。

模块

模块 职责
protocol A2UI v1.0 JSON 消息类型(server→client、client→server)
model 运行时组件树、surface、JSON Pointer 数据绑定
catalog Catalog、组件 API、函数实现、schema-only 函数、内联 catalog
message_processor 消息解析 → 状态变更;process_message / parse_jsonl
capabilities ClientCapabilities / ServerCapabilities 协商 + 内联 catalog 解析(UAX#31 校验)
validate 协议校验(ValidationConfig / ValidationReport)
observable 响应式状态管理
focus / interaction / components 后端共享的交互层(焦点遍历、EventResult 应用、组件 handle_event)

用法

cargo add a2ui-base
use a2ui_base::message_processor::MessageProcessor;
use a2ui_base::catalog::Catalog;

let mut processor = MessageProcessor::new(vec![/* catalogs */]);

// 解析并处理一条 JSON 消息
let msg = MessageProcessor::parse_message(r#"{"version":"v1.0",...}"#)?;
processor.process_message(msg)?;

// 读取协议产生的回传消息(functionResponse / actionResponse / ...)
let outgoing = processor.drain_outgoing();

想直接得到一个能渲染的终端 UI?组合 a2ui-tui 一起用;或通过 umbrella a2ui 以 a2ui::core::... 路径访问本 crate。

许可证

MIT

Dependencies

~3.5–6MB
~108K SLoC