Carries A2UI over AG-UI, the event protocol between agents and their front ends, the way AG-UI's A2UI middleware and the renderers built on it (CopilotKit, assistant-ui) do. A2UI does not define this binding itself.
A surface travels as ACTIVITY_SNAPSHOT events of the activity type
a2ui-surface, whose content holds the surface's A2UI messages under
a2ui_operations. A snapshot replaces the activity it names, so each
one carries every message of its surface so far; snapshots/2 keeps
them per surface:
{events, surfaces} = A2UIAgent.AGUI.snapshots(%{}, messages)
Enum.map(events, &A2UIAgent.AGUI.encode/1)A user's action starts a new run with no new user message; it arrives
in the run's input, under forwardedProps.a2uiAction.userAction, which
user_action/2 reads.
AG-UI carries no renderer capabilities: the agent writes for the
catalogs it is configured with (A2UIAgent.Generator.create_processor/3
with nil capabilities activates them all).
Summary
Types
Messages so far, by surface id.
Functions
The A2UI messages of an event: those of an a2ui-surface activity
snapshot, else nil.
An ACTIVITY_SNAPSHOT event holding messages, the whole state of
the activity message_id.
The activity type of A2UI surfaces: a2ui-surface.
An event as AG-UI's HTTP binding sends it: one server-sent event whose data is the event's JSON.
A RUN_ERROR event, with an optional code.
A RUN_FINISHED event.
A RUN_STARTED event.
Adds messages to surfaces and returns a snapshot for each surface
they touch, in the order first touched, with the activity id
a2ui-surface-<surfaceId>. A surface whose messages end with its
deleteSurface is dropped after its snapshot, so that it starts over
if it is created again. Messages that name no surface are left out.
The events of an assistant message with text: TEXT_MESSAGE_START,
TEXT_MESSAGE_CONTENT and TEXT_MESSAGE_END. Empty text has no
events, since a content event needs a non-empty delta.
The user action a run's input carries, as an A2UI action message of
version, or nil when the run was started otherwise.
Types
Functions
The A2UI messages of an event: those of an a2ui-surface activity
snapshot, else nil.
An ACTIVITY_SNAPSHOT event holding messages, the whole state of
the activity message_id.
iex> A2UIAgent.AGUI.activity_snapshot("a2ui-surface-s1", [])
%{
"type" => "ACTIVITY_SNAPSHOT",
"messageId" => "a2ui-surface-s1",
"activityType" => "a2ui-surface",
"content" => %{"a2ui_operations" => []},
"replace" => true
}
@spec activity_type() :: String.t()
The activity type of A2UI surfaces: a2ui-surface.
An event as AG-UI's HTTP binding sends it: one server-sent event whose data is the event's JSON.
A RUN_ERROR event, with an optional code.
A RUN_FINISHED event.
A RUN_STARTED event.
Adds messages to surfaces and returns a snapshot for each surface
they touch, in the order first touched, with the activity id
a2ui-surface-<surfaceId>. A surface whose messages end with its
deleteSurface is dropped after its snapshot, so that it starts over
if it is created again. Messages that name no surface are left out.
The events of an assistant message with text: TEXT_MESSAGE_START,
TEXT_MESSAGE_CONTENT and TEXT_MESSAGE_END. Empty text has no
events, since a content event needs a non-empty delta.
The user action a run's input carries, as an A2UI action message of
version, or nil when the run was started otherwise.
iex> A2UIAgent.AGUI.user_action(%{"forwardedProps" => %{"a2uiAction" => %{"userAction" =>
...> %{"name" => "book", "surfaceId" => "s", "context" => %{}}}}})
%{"version" => "v1.0", "action" => %{"name" => "book", "surfaceId" => "s", "context" => %{}}}