Skip to main content

Module envelope

Module envelope 

Source
Expand description

The transport envelope: {"a2ui_operations": [...]}.

A2UI itself says nothing about how messages reach the renderer. In practice every toolkit wraps a batch of operations in a single JSON object keyed by A2UI_OPERATIONS_KEY, and the frontend sniffs for exactly that key to decide whether a payload is A2UI. The envelope is emitted as a JSON string because that is what fits in a tool result, an assistant message, or an A2A data part without further wrapping.

Failure is the other shape, and it is a different object rather than an empty envelope: see wrap_error_envelope for why a surface that could not be built must not answer the sniff.

Functionsยง

is_operations_envelope
Whether a value is an A2UI operations envelope.
operations_envelope
The envelope as a Value, for callers that embed it in a larger payload.
unwrap_operations_envelope
Reads operations back out of an envelope.
wrap_as_operations_envelope
Wraps operations in the envelope, as a JSON string ready for transport.
wrap_error_envelope
Builds the payload reporting that a surface could not be produced.