Skip to main content

Module message

Module message 

Source
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:

DirectionPayload keys
agent → renderercreateSurface, updateComponents, updateDataModel, deleteSurface, callRendererFunction, agentFunctionResponse
renderer → agentaction, 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 action message.
AgentMessage
One agent → renderer message.
CallAgentFunction
Payload of a callAgentFunction message.
CallRendererFunction
Payload of a callRendererFunction message.
ChildTemplate
The template form of a ChildList.
Component
One node of the flat component adjacency list.
CreateSurface
Payload of a createSurface message.
DeleteSurface
Payload of a deleteSurface message.
FunctionCall
A named function invocation, used both in component properties and in the two call*Function messages.
FunctionResponse
The result of a call*Function, sent back by whichever side ran it.
RendererError
Payload of an error message from the renderer.
RendererMessage
One renderer → agent message.
UpdateComponents
Payload of an updateComponents message.
UpdateDataModel
Payload of an updateDataModel message.

Enums§

AgentPayload
The payload of an AgentMessage, externally tagged by its wire key.
ChildList
How a component declares its children.
RendererPayload
The payload of a RendererMessage, externally tagged by its wire key.

Functions§

apply_data_model_update
Applies one updateDataModel operation to model.