Expand description
A2UI protocol envelopes.
A2UI is a stream of JSON objects in two directions. Each object carries a
version discriminator plus exactly one payload key:
| Direction | Payload keys |
|---|---|
| agent → renderer | createSurface, updateComponents, updateDataModel, deleteSurface, callRendererFunction, agentFunctionResponse |
| renderer → agent | action, callAgentFunction, rendererFunctionResponse, error |
§The adjacency-list component model
Components are sent as a flat list. Parent/child links are ID references,
never nesting — a Card names its child by id, a Column holds an array of
ids. The renderer stores every component in a map and rebuilds the tree at
render time, which is what lets the agent stream definitions in any order and
lets the renderer start painting as soon as root arrives.
use ag_ui_a2ui::message::{AgentMessage, Component};
use serde_json::json;
let msg = AgentMessage::update_components(
"profile",
vec![
Component::new("root", "Column").with("children", json!(["name"])),
Component::new("name", "Text").with("text", json!("Ada")),
],
);
let wire = serde_json::to_value(&msg).unwrap();
assert_eq!(wire["version"], "v0.9");
assert_eq!(wire["updateComponents"]["components"][0]["component"], "Column");Structs§
- Action
- Payload of an
actionmessage. - Agent
Message - One agent → renderer message.
- Call
Agent Function - Payload of a
callAgentFunctionmessage. - Call
Renderer Function - Payload of a
callRendererFunctionmessage. - Child
Template - The template form of a
ChildList. - Component
- One node of the flat component adjacency list.
- Create
Surface - Payload of a
createSurfacemessage. - Delete
Surface - Payload of a
deleteSurfacemessage. - Function
Call - A named function invocation, used both in component properties and in the
two
call*Functionmessages. - Function
Response - The result of a
call*Function, sent back by whichever side ran it. - Renderer
Error - Payload of an
errormessage from the renderer. - Renderer
Message - One renderer → agent message.
- Update
Components - Payload of an
updateComponentsmessage. - Update
Data Model - Payload of an
updateDataModelmessage.
Enums§
- Agent
Payload - The payload of an
AgentMessage, externally tagged by its wire key. - Child
List - How a component declares its children.
- Renderer
Payload - The payload of a
RendererMessage, externally tagged by its wire key.
Functions§
- apply_
data_ model_ update - Applies one
updateDataModeloperation tomodel.