Package-level declarations

Types

Link copied to clipboard
object A2ui

A2UI protocol constants.

Link copied to clipboard
data class A2uiAction(val surfaceId: String, val name: String, val sourceComponentId: String, val context: JsonObject, val userMessage: String? = null, val timestamp: String = Instant.now().toString(), val dataModel: JsonElement? = null)

A user action on a surface, as the A2UI renderer-to-agent action message (toMessage).

Link copied to clipboard
@Immutable
class A2uiCatalog(val id: String, val components: Map<String, A2uiComponent>, val functions: Map<String, A2uiFunction>, val protocolVersion: String = A2ui.VERSION)

A component catalog (A2UI §"The component catalog"): the component types and functions a surface may use, rendered natively. Basic is the A2UI Basic Catalog; extend adds or replaces components and functions — your design system's components, under your own catalog id.

Link copied to clipboard
fun interface A2uiComponent

Renders one component type of a catalog.

Link copied to clipboard

A data model write that cannot apply (e.g. through a primitive value).

Link copied to clipboard
fun interface A2uiEffects

Side effects functions may ask the host for (only openUrl in the Basic Catalog).

Link copied to clipboard

An expression that cannot be evaluated (unknown function, disallowed URL…).

Link copied to clipboard
class A2uiFunction(val callableByAgent: Boolean = false, val agentOnly: Boolean = false, val invoke: (args: JsonObject, context: DataContext?) -> JsonElement?)

A catalog function. invoke gets resolved args (formatString gets them raw, to interpolate itself) and the calling scope (null when the agent calls it via callRendererFunction).

Link copied to clipboard

A formatString template that does not parse.

Link copied to clipboard
@Stable
class A2uiState(val catalog: A2uiCatalog = A2uiCatalog.Basic, catalogs: List<A2uiCatalog> = emptyList())

The renderer side of an A2UI session: feed it agent-to-renderer messages (process), render its surfaces with A2uiSurfaceView. Messages it must answer (function responses, errors) come back from process as renderer-to-agent messages for the transport to send.

Link copied to clipboard
@Stable
class A2uiSurface

One A2UI surface: its components (an adjacency list keyed by id; root mounts first) and its data model. Both are Compose state, so a surface re-renders as messages arrive and as inputs write through two-way bindings.

Link copied to clipboard

The A2UI Basic Catalog in Material 3, per the basic catalog implementation guide: invisible containers add no spacing, leaves and outlined containers carry a uniform LeafMargin, colours come from the theme (LocalContentColor), cards are outlined so nesting stays readable.

Link copied to clipboard

The Basic Catalog's renderer-side functions (A2UI v1.0 basic catalog implementation guide).

Link copied to clipboard
@Immutable
class ChildRef

A child to place: its component and the data scope it renders in.

Link copied to clipboard
@Stable
class ComponentScope

What a component renderer sees: its properties resolved in its data scope, its children, two-way binding writes and action dispatch.

Link copied to clipboard

Where a component evaluates its dynamic values (A2UI "evaluation scope"): absolute paths resolve from the surface's data model; relative paths from base, the item a list template is rendering (at index). Resolves Dynamic* values: literals, {"path": …} bindings and {"call": …} function calls, including formatString ${…} interpolation.

Functions

Link copied to clipboard
fun a2uiRenderer(catalog: A2uiCatalog = A2uiCatalog.Basic, catalogs: List<A2uiCatalog> = emptyList(), capacity: Int = 32, onAction: (A2uiAction) -> Unit): DataRenderer

Renders the chat's A2UI parts (DataPart.A2UI, whatever transport brought them) natively. Register it with AiElementsRenderers(data = mapOf(DataPart.A2UI to a2uiRenderer { chat.send(it) })).

Link copied to clipboard
@Composable
fun A2uiSurfaceView(surface: A2uiSurface, modifier: Modifier = Modifier, catalog: A2uiCatalog = A2uiCatalog.Basic, onAction: (A2uiAction) -> Unit = {}, catalogs: List<A2uiCatalog> = emptyList())

Renders an A2UI surface natively with catalog (default: the Basic Catalog); nothing until its root component arrives. onAction receives the user's actions as renderer-to-agent messages (A2uiAction.toMessage) for the transport to send back; links open through LocalUriHandler.

Link copied to clipboard

Send a user's A2UI action to the agent, as a user turn the transports map onto their A2UI binding (AG-UI forwardedProps.a2uiAction, an A2A application/a2ui+json part, an AI SDK data-a2ui part). Its text is the action's userMessage, else its name.

Link copied to clipboard

This action as the data parts of a user turn: the A2UI action message (DataPart.A2UI) and, when the surface asked for it, its data model (DataPart.A2UI_DATA_MODEL).