agent86_ui/lib.rs
1//! agent86UI's protocol layer: Google's [A2UI](https://a2ui.org) 1.0 for Rust.
2//!
3//! A2UI lets an agent describe UI as declarative JSON that a renderer draws with
4//! its own widgets, from a catalog of components and functions it trusts. This
5//! crate is the agent's side of it, with no dependency on the rest of agent86:
6//!
7//! - [`Catalog`]: a catalog loaded and checked against the specification's
8//! rules, and [`Catalog::basic`], the specification's basic catalog;
9//! - [`AgentMessage`] and [`RendererMessage`]: the messages, typed;
10//! - [`Validator`]: checks what an agent's model wrote, batch by batch, against
11//! the schemas and the rules they cannot express (surfaces, `root`, child
12//! references, composition, function boundaries), with the specification's
13//! error codes and paths, so the problems can go back to the model;
14//! - [`runtime`]: the headless surface runtime a renderer builds on: surfaces'
15//! components and data models, every binding, call, template, and check
16//! resolved for drawing ([`runtime::Runtime::tree`]), user input written back,
17//! and actions dispatched, with the basic catalog's functions (formatting in
18//! `en-US`, the regex dialect and its safety rules) implemented;
19//! - [`SchemaSet`]: the envelope schemas compiled against a catalog, for the
20//! schema half of validation alone;
21//! - [`is_identifier`]: the specification's naming rule.
22//!
23//! The JSON Schemas and the basic catalog are vendored from the specification
24//! (`spec/`, Apache-2.0, upstream commit recorded in `spec/UPSTREAM.md`) and
25//! served from memory: nothing is ever fetched. The tests replay the
26//! specification's schema cases and its shared conformance suites for the
27//! runtime (`conformance/core/` upstream).
28//!
29//! agent86UI is agent86's implementation of A2UI; A2UI is Google's protocol, and
30//! this crate is not affiliated with or endorsed by Google.
31
32mod catalog;
33mod ident;
34mod message;
35pub mod runtime;
36mod schema;
37mod validate;
38
39pub use catalog::{
40 Callers, Catalog, CatalogError, ChildRef, ComponentDef, FunctionDef,
41 ALLOWED_EXTERNAL_REF_TARGETS, BASIC_CATALOG_ID,
42};
43pub use ident::is_identifier;
44pub use message::{
45 Action, AgentMessage, AgentMessageKind, CallAgentFunction, CallRendererFunction, CheckRule,
46 Component, CreateSurface, DeleteSurface, ErrorBody, FunctionCall, FunctionResponse,
47 RendererError, RendererMessage, RendererMessageKind, UpdateComponents, UpdateDataModel,
48};
49pub use schema::{
50 check_agent_capabilities, check_catalog_definition, check_renderer_capabilities,
51 check_renderer_data_model, CompileError, SchemaError, SchemaSet, SPEC_BASE,
52};
53pub use validate::{Code, Problem, Report, Rules, Validator, MAX_CALL_DEPTH, MAX_DEPTH};
54
55/// The A2UI protocol version this crate implements, as messages carry it in
56/// their `version` field.
57pub const PROTOCOL_VERSION: &str = "1.0";
58
59/// The README's example, compiled and run as a doctest so it cannot drift.
60#[doc = include_str!("../README.md")]
61#[cfg(doctest)]
62pub struct ReadmeDoctests;