A2A.Version (A2A v0.3.0)

Copy Markdown View Source

Helpers for the A2A-Version HTTP header (A2A v1.0 spec §3.6).

Versions are negotiated as Major.Minor strings. Patch components are not significant and are stripped during normalization. Per spec §3.6.2 an empty or missing version is interpreted as "0.3".

Summary

Functions

Default version a client sends in the A2A-Version request header.

Normalizes a version string to its Major.Minor form.

Parses a Plug-style header value (list of strings, single string, or nil) into a normalized Major.Minor version. An empty list or missing value becomes "0.3".

Default list of versions a server accepts.

Returns :ok when version is in the supported list, otherwise {:error, version} with the rejected value so the caller can surface it in a VersionNotSupportedError.

Functions

default()

@spec default() :: String.t()

Default version a client sends in the A2A-Version request header.

normalize(version)

@spec normalize(String.t() | nil) :: String.t()

Normalizes a version string to its Major.Minor form.

  • nil and "" → "0.3" (per spec §3.6.2)
  • "1.0.3" → "1.0"
  • " 0.3 " → "0.3"

Values that can't be parsed as Major.Minor are returned trimmed so the caller can include them in an error response.

parse_header(value)

@spec parse_header([String.t()] | String.t() | nil) :: String.t()

Parses a Plug-style header value (list of strings, single string, or nil) into a normalized Major.Minor version. An empty list or missing value becomes "0.3".

supported_default()

@spec supported_default() :: [String.t()]

Default list of versions a server accepts.

validate(version, supported)

@spec validate(String.t(), [String.t()]) :: :ok | {:error, String.t()}

Returns :ok when version is in the supported list, otherwise {:error, version} with the rejected value so the caller can surface it in a VersionNotSupportedError.