client library

Browser/Flutter-safe client helpers for consuming an A2UI-enabled Genkit agent.

This library has no server-only dependencies (no dart:io). Pull A2UI envelopes off each streamed chunk's content with a2uiEnvelopesFromParts and feed them to your renderer (e.g. genui's SurfaceController). Send surface actions back to the agent as the next turn with actionToMessage.

Classes

A2uiClientAction
A client -> server user action reported by a rendered surface (e.g. a button press). Sent back to the agent as the next turn's input.

Constants

a2uiMimeType → const String
The MIME type that identifies an A2UI payload. This is stamped onto the metadata.mimeType of the Genkit data part that carries A2UI envelopes, matching the A2A binding of the A2UI spec exactly.
a2uiVersion → const String
The default A2UI protocol version stamped on emitted envelopes.
basicCatalogId → const String
The catalog id of the A2UI "Basic Catalog" (v0.9). Surfaces created with the basic catalog reference this id, and the client renderer registers a catalog under the same id.

Functions

a2uiEnvelopesFromParts(List<Part>? parts) List<A2uiEnvelope>
Extracts all A2UI envelopes carried by the given parts.
a2uiPart(List<A2uiEnvelope> envelopes) → DataPart
Builds an a2ui data part wrapping the given envelopes.
actionToMessage(A2uiClientAction action) → Message
Builds the agent input message for sending a rendered surface's user action back to the agent as the next turn.
isA2uiPart(Part part) bool
Whether the given part is an a2ui data part.

Typedefs

A2uiComponent = Map<String, dynamic>
A single component entry in an A2UI adjacency list, in its raw JSON shape.
A2uiEnvelope = Map<String, dynamic>
A single server -> client A2UI envelope message, in its raw JSON shape.