A2UIAgent.A2A (A2UIAgent v0.1.1)

Copy Markdown View Source

The A2UI extension of the A2A protocol: extension URIs and their negotiation, and A2UI messages carried in A2A parts.

Parts are the JSON objects of A2A's JSON-RPC binding:

%{"kind" => "text", "text" => "Here is your form."}
%{"kind" => "data", "data" => message, "metadata" => %{"mimeType" => "application/a2ui+json"}}

Each A2UI message travels in a data part of its own, the shape the reference SDKs, sample agents and clients exchange. a2ui_messages/1 also reads a data part whose data is a list of messages, the shape the extension specification describes.

A2UIAgent.A2A.Server answers A2A requests with these helpers, and A2UIAgent.A2A.Plug serves them over HTTP.

Summary

Types

An A2A part, as a JSON object.

Functions

The A2UI messages that parts carry, in order. A data part may hold one message or a list of them.

A data part holding data (an A2UI message, or a list of them), marked with the MIME type of version (see mime_type/1).

Whether part is a data part marked as A2UI, with either MIME type in its metadata.

Activates the newest A2UI extension that is both requested and advertised: {:ok, uri, version}, or :none.

The A2UI extension URIs an agent card advertises.

The A2UI entry for an agent card's capabilities.extensions.

Reads the next chunk of a streamed response with parser and returns the A2A parts it completes, with the parser to read the next chunk.

The URI every A2UI extension URI starts with.

The extension URI of a version, for example "https://a2ui.org/a2a-extension/a2ui/v1.0" for "1.0" or "v1.0".

The version an A2UI extension URI names, or nil for any other URI.

The MIME type that marks a data part as A2UI.

The MIME type for parts of a protocol version: "application/a2ui+json" from v0.9.1 on, the older "application/json+a2ui" before it and when the version is unknown (nil).

The A2UI extension URIs among values: extension URIs, or comma-separated lists of them as the X-A2A-Extensions header carries.

Parses a complete model response with parser (a format parser, see A2UIAgent.RequestProcessor.parser/1) into A2A parts.

The newest extension URI that is both requested and advertised, or nil. Versions compare as SemVer, so v1.10.0 is newer than v1.2.0.

A text part.

The A2A parts for parsed response parts ({:text, text} and {:a2ui, messages}): a text part for each non-empty text and a data part for each message.

Types

part()

(since 0.1.0)
@type part() :: %{required(String.t()) => term()}

An A2A part, as a JSON object.

Functions

a2ui_messages(parts)

(since 0.1.0)
@spec a2ui_messages([term()]) :: [map()]

The A2UI messages that parts carry, in order. A data part may hold one message or a list of them.

The MIME type may also be a property of the part itself rather than of its metadata, as some sample clients send it.

a2ui_part(data, version)

(since 0.1.0)
@spec a2ui_part(map() | [map()], String.t() | nil) :: part()

A data part holding data (an A2UI message, or a list of them), marked with the MIME type of version (see mime_type/1).

a2ui_part?(part)

(since 0.1.0)
@spec a2ui_part?(term()) :: boolean()

Whether part is a data part marked as A2UI, with either MIME type in its metadata.

activate(requested, advertised)

(since 0.1.0)
@spec activate([String.t()], [String.t()]) :: {:ok, String.t(), String.t()} | :none

Activates the newest A2UI extension that is both requested and advertised: {:ok, uri, version}, or :none.

advertised_extensions(arg1)

(since 0.1.0)
@spec advertised_extensions(map()) :: [String.t()]

The A2UI extension URIs an agent card advertises.

agent_extension(version, options \\ [])

(since 0.1.0)
@spec agent_extension(String.t(), keyword()) :: map()

The A2UI entry for an agent card's capabilities.extensions.

Options: :accepts_inline_catalogs (default false) and :supported_catalog_ids (default []). Each appears in params only when it differs from its default, and params only when it is not empty.

chunk_parts(parser, chunk, version)

(since 0.1.0)
@spec chunk_parts(struct(), String.t(), String.t() | nil) ::
  {:ok, struct(), [part()]} | {:error, A2UICore.Error.t()}

Reads the next chunk of a streamed response with parser and returns the A2A parts it completes, with the parser to read the next chunk.

extension_base_uri()

(since 0.1.0)
@spec extension_base_uri() :: String.t()

The URI every A2UI extension URI starts with.

extension_uri(version)

(since 0.1.0)
@spec extension_uri(String.t()) :: String.t()

The extension URI of a version, for example "https://a2ui.org/a2a-extension/a2ui/v1.0" for "1.0" or "v1.0".

extension_version(arg1)

(since 0.1.0)
@spec extension_version(String.t()) :: String.t() | nil

The version an A2UI extension URI names, or nil for any other URI.

mime_type()

(since 0.1.0)
@spec mime_type() :: String.t()

The MIME type that marks a data part as A2UI.

mime_type(version)

(since 0.1.0)
@spec mime_type(String.t() | nil) :: String.t()

The MIME type for parts of a protocol version: "application/a2ui+json" from v0.9.1 on, the older "application/json+a2ui" before it and when the version is unknown (nil).

requested_extensions(values)

(since 0.1.0)
@spec requested_extensions([term()]) :: [String.t()]

The A2UI extension URIs among values: extension URIs, or comma-separated lists of them as the X-A2A-Extensions header carries.

response_parts(parser, content, version, options \\ [])

(since 0.1.0)
@spec response_parts(struct(), String.t(), String.t() | nil, keyword()) :: [part()]

Parses a complete model response with parser (a format parser, see A2UIAgent.RequestProcessor.parser/1) into A2A parts.

A response that does not parse is logged and yields no parts. Option: :fallback_text — the text part to answer with when there are no parts, for example the response itself.

select_newest(requested, advertised)

(since 0.1.0)
@spec select_newest([String.t()], [String.t()]) :: String.t() | nil

The newest extension URI that is both requested and advertised, or nil. Versions compare as SemVer, so v1.10.0 is newer than v1.2.0.

text_part(text)

(since 0.1.0)
@spec text_part(String.t()) :: part()

A text part.

to_parts(parsed, version)

(since 0.1.0)
@spec to_parts([text: String.t(), a2ui: [map()]], String.t() | nil) :: [part()]

The A2A parts for parsed response parts ({:text, text} and {:a2ui, messages}): a text part for each non-empty text and a data part for each message.