A2UICore.Schema.Source (A2UICore v0.1.1)

Copy Markdown View Source

Loads the A2UI protocol's own JSON Schema documents — vendored under priv/ from a pinned revision of the specification — plus the shipped basic catalogs.

Documents are read once and cached in :persistent_term (they are immutable, process-free data). The vendored copies are the single source of truth for envelope validation.

Layout

priv/schemas/v0_9/*.json       v0.9 wire schemas (server_to_client, …)
priv/schemas/v0_9_1/*.json     v0.9.1 wire schemas
priv/schemas/v1_0/*.json       v1.0 wire schemas (agent_to_renderer, …)
priv/catalogs/basic_v0_9_1.json    basic catalog, protocol version 0.9
priv/catalogs/basic_v1_0.json      basic catalog, protocol version 1.0
priv/catalogs/testing_v1_0.json    upstream `testing_catalog.json`
priv/catalogs/mcp_v0_9.json        MCP catalog, protocol version 0.9
priv/catalogs/mcp_v1_0.json        MCP catalog, protocol version 1.0

Summary

Functions

Loads a shipped catalog by protocol version.

Loads a wire-schema document by version and logical name.

Like catalog/2, decoded with its key order (Jason.OrderedObjects), which orders the components and functions of a catalog built from it (A2UICore.Catalog.from_json/2). Not cached.

Like document/2, decoded with its key order (Jason.OrderedObjects), for writing the document out in the order it is published in.

Returns the priv directory holding the vendored documents.

Types

document()

(since 0.1.0)
@type document() :: A2UICore.Schema.schema()

Functions

catalog(version, kind)

(since 0.1.0)
@spec catalog(
  A2UICore.Version.protocol_version() | String.t(),
  :basic | :testing | :mcp
) ::
  document() | nil

Loads a shipped catalog by protocol version.

:basic      the basic catalog for the given protocol line
:testing    the upstream spec-test catalog (v1.0 only)
:mcp        the MCP catalog for the given protocol line

document(version, name)

(since 0.1.0)
@spec document(A2UICore.Version.protocol_version() | String.t(), atom() | String.t()) ::
  document() | nil

Loads a wire-schema document by version and logical name.

Logical names normalize the v0.9/v1.0 file renames:

:agent_to_renderer   v0.9.x -> server_to_client.json
                    v1.0   -> agent_to_renderer.json
:renderer_to_agent   v0.9.x -> client_to_server.json
                    v1.0   -> renderer_to_agent.json
:common_types        common_types.json
:capabilities        v0.9.x -> server_capabilities.json (agent side)
                    v1.0   -> agent_capabilities.json
:renderer_capabilities  v0.9.x -> client_capabilities.json
                        v1.0   -> renderer_capabilities.json
:data_model          v0.9.x -> client_data_model.json
                    v1.0   -> renderer_data_model.json
:list                v0.9.x -> server_to_client_list.json
                    v1.0   -> agent_to_renderer_list.json
:wrapper             v0.9.x -> server_to_client_list_wrapper.json
                    v1.0   -> agent_to_renderer_list_wrapper.json
:catalog_definition  v1.0   -> catalog_definition.json (nil for v0.9.x)

Any concrete file name (e.g. "sample.json") is loaded verbatim.

ordered_catalog(version, kind)

(since 0.1.0)
@spec ordered_catalog(
  A2UICore.Version.protocol_version() | String.t(),
  :basic | :testing | :mcp
) ::
  Jason.OrderedObject.t() | nil

Like catalog/2, decoded with its key order (Jason.OrderedObjects), which orders the components and functions of a catalog built from it (A2UICore.Catalog.from_json/2). Not cached.

ordered_document(version, name)

(since 0.1.0)
@spec ordered_document(
  A2UICore.Version.protocol_version() | String.t(),
  atom() | String.t()
) ::
  Jason.OrderedObject.t() | nil

Like document/2, decoded with its key order (Jason.OrderedObjects), for writing the document out in the order it is published in.

priv_dir()

(since 0.1.0)
@spec priv_dir() :: Path.t()

Returns the priv directory holding the vendored documents.