a2ui_agent library
The A2UI agent SDK: capability negotiation, prompting and response parsing for agents that generate A2UI.
Implements protocols v0.9 and v1.0 in two inference formats: direct JSON and Express, both of which can be read as they stream. The protocol version is the one the active catalogs target, which the agent negotiates with each renderer.
Classes
- A2uiGenerator
- The long-lived entry point to the agent SDK.
- A2uiPart
- A2UI messages compiled from one payload block of an LLM response, ready to deliver to a renderer.
- A2uiRequestProcessor
- The per-request facade: the catalogs negotiated with one renderer, the prompt snippet describing them, and parsing of the LLM's response.
-
AnswerErrorPart<
T extends ComponentApi> - A block the answer rejected, where the model wrote it.
-
AnswerPart<
T extends ComponentApi> - A part of a StreamedAnswer: its text, a surface it created, or a block it rejected.
-
AnswerSurfacePart<
T extends ComponentApi> - A surface the answer created, where the model wrote it.
-
AnswerTextPart<
T extends ComponentApi> - Text the model wrote between two surfaces, or before or after them.
- CatalogConfig
-
A catalog the agent supports, registered with an
A2uiGenerator, and the transformers applied to it. - CatalogProvider
- Turns a catalog document into a catalog an agent can register.
- CatalogTransformer
- A rule applied to a catalog before the catalog reaches a prompt or a validator.
- ComponentPruningTransformer
- Keeps only the components named in allowedComponents.
- DirectJsonContinuingResponseStream
- Reads one streamed direct JSON response, reading past a rejected block.
- DirectJsonFormat
- The direct JSON format bound to the catalogs of one request.
- DirectJsonFormatFactory
-
The direct JSON format: A2UI messages written as JSON inside
<a2ui-json>tags, which can be read while the response streams. - DirectJsonParser
-
Reads A2UI messages written as JSON inside
<a2ui-json>tags, from a complete response or as it streams. - DirectJsonPromptGenerator
-
Renders the system prompt snippet teaching a model to write A2UI messages
as JSON inside
<a2ui-json>tags. - DirectJsonResponseStream
- Reads one streamed direct JSON response.
- ErrorPart
- A block that a response stream rejected and read past, in place of the block.
- ExpressCompiler
- Compiles Express blocks into A2UI messages of the protocol version the catalogs target.
- ExpressContinuingResponseStream
- Reads one streamed Express response, reading past a rejected block.
- ExpressDecompiler
- Writes messages of the protocol version the catalogs target in Express notation: the inverse of the compiler.
- ExpressFormat
- The Express format bound to the catalogs of one request.
- ExpressFormatFactory
-
The Express format: a compact DSL enclosed in
<a2ui>tags, compiled into A2UI messages after the response is complete. - ExpressParser
- Reads Express blocks from an LLM response and compiles them into messages of the protocol version the catalogs target.
- ExpressPromptGenerator
- Renders the system prompt snippet teaching a model to write Express for catalogs.
- ExpressResponseStream
- Reads one streamed Express response chunk by chunk.
- FileSystemCatalogProvider
- Loads a catalog from a JSON document on the file system.
- FunctionPruningTransformer
- Keeps only the functions named in allowedFunctions.
- InferenceFormat
- One inference format bound to the catalogs of one request: the prompt that teaches the LLM the format, and the parser that reads what the LLM wrote.
- InferenceFormatFactory
- Selects the notation the LLM writes A2UI payloads in.
- InMemoryCatalogProvider
- Loads a catalog from a decoded JSON document.
- Parser
- Reads an LLM response written in one inference format.
- PromptGenerator
- Renders the system prompt snippet teaching an LLM one inference format.
- RawA2uiPart
- The content of one payload block of an LLM response, without its sentinel tags, before it is compiled.
- RawResponsePart
- A slice of an LLM response before its payloads are compiled: TextPart or RawA2uiPart.
- RendererState
- The agent's mirror of the surfaces a renderer holds.
- ResponsePart
- A slice of a parsed LLM response: TextPart or A2uiPart.
-
ResponseReader<
P extends StreamPart> - Reads one streamed LLM response, chunk by chunk.
-
StreamedAnswer<
T extends ComponentApi> - One model answer, read as it streams, for an app that is both the agent and the renderer.
- StreamPart
- A slice of a streamed LLM response: a ResponsePart, or an ErrorPart in place of a block the stream rejected.
- TextPart
- Conversational text from an LLM response, for display to the user.
Extensions
- A2uiErrorPartialResults on A2uiError
- The parts a response stream made ready before it threw an error.
Constants
-
defaultExpressProgressiveKeys
→ const Set<
String> -
Default property keys whose open string literals are healed progressively
while streaming an
<a2ui>Express block.
Functions
-
resolveCatalogs(
List< CatalogConfig> catalogs, A2uiRendererCapabilities? rendererCapabilities, {bool acceptsInlineCatalogs = false}) → List<CatalogApi> - Negotiates the catalogs the agent registered against the capabilities a renderer declared, and returns the catalogs active for the session.
-
validatePayload(
List< CatalogApi> catalogs, Iterable<AgentToRendererMessage> payload) → void -
Checks
payloadthe way a renderer holdingcatalogswould.
Typedefs
-
ContinuingResponseStream
= ResponseReader<
StreamPart> - A stream that reads past a rejected block, returning an ErrorPart in its place.
-
ResponseStream
= ResponseReader<
ResponsePart> - A stream that ends at the first rejected block, and so returns only ResponseParts.