A2uiTranslation

class A2uiTranslation(val catalogIds: (String) -> String = ::upstreamCatalogIds, val defaultCatalogId: String = AguiA2ui.V10_BASIC_CATALOG_ID)

Turns what upstream puts on the wire into the v1.0 messages a2ui-core parses.

Upstream's toolkit and middleware emit A2UI v0.9 envelopes; a2ui-core implements v1.0 and refuses any other version outright. Between the two, for the four messages upstream emits, the wire difference is mechanical -- read off the specification's own evolution guide, and checked here against recorded traffic:

  • version is "v0.9" and must read "v1.0";

  • createSurface.theme is gone, and createSurface.attachDataModel became sendDataModel;

  • updateDataModel.value became required, with null meaning delete -- so an omitted value is sent as null, which is the nearest v1.0 has to what v0.9 let an agent leave out;

  • the flat component format, {"path": ...} bindings and children: {componentId, path} templates are the same shape in both.

What is not mechanical is the catalog id. Upstream names v0_9/basic_catalog.json -- a string that is not even the v0.9 specification's id for that catalog -- and a2ui-compose registers the v1.0 one, so a surface that named the upstream id would resolve to no catalog and draw its root alone. catalogIds is where that mapping lives, and upstreamCatalogIds is the default: the three upstream spellings of "basic" become the v1.0 basic catalog and everything else passes through, because a custom catalog's id is the host's own and this module has no business renaming it.

The rewrite is JSON to JSON and happens before parsing, on purpose: a2ui-core's parser is the one place the v1.0 rules are enforced, and a translation that built its messages by hand would be a second, weaker parser.

Parameters

catalogIds

what a catalogId on the wire becomes. Applied to createSurface only; a v0.9 component carries no catalog of its own.

defaultCatalogId

the catalog a rendered surface is bound to. A render_a2ui call names no catalog -- the host chooses -- so this is that choice.

Constructors

Link copied to clipboard
constructor(catalogIds: (String) -> String = ::upstreamCatalogIds, defaultCatalogId: String = AguiA2ui.V10_BASIC_CATALOG_ID)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun message(envelope: JsonObject): AgentToRendererMessage

One envelope -- v0.9 or already v1.0 -- as the message it names.

Link copied to clipboard
fun operations(operations: JsonArray): List<AgentToRendererMessage>

An a2ui_operations array as messages, in order.

Link copied to clipboard
fun rendered(arguments: JsonObject): AgentToRendererMessage

A completed render_a2ui call's arguments as the one v1.0 message they amount to.