Behaviour for A2UI message transport.
A transport handles bidirectional communication between a client (LiveView or external) and an agent:
- Client → Agent:
connect/1,send_action/3,send_error/3,disconnect/1 - Agent → Client:
deliver_message/2
On connect/1, the transport creates an A2UI.Connection struct and
registers with the agent. The agent dispatches messages back through
deliver_message/2 using the connection's transport module and ref.
Dispatch Helpers
Instead of calling a specific transport module directly, you can use the dispatch functions on this module:
A2UI.Transport.send_action(transport, action, metadata)These dispatch to the correct implementation based on the transport struct.
Summary
Callbacks
Delivers an A2UI protocol message to the connected client.
Functions
Disconnects the transport. Dispatches based on the struct module.
Sends an action through the transport. Dispatches based on the struct module.
Sends an error through the transport. Dispatches based on the struct module.
Types
@type t() :: struct()
Callbacks
Delivers an A2UI protocol message to the connected client.
Called by A2UI.Agent.send_message/2 using the connection's transport
module and ref. The ref argument is transport-specific — for Local
transport it is the LiveView pid; for SSE it is the handler process pid.
@callback disconnect(t()) :: :ok
@callback send_action(t(), A2UI.Protocol.Messages.Action.t(), metadata :: map()) :: :ok | {:error, any()}
@callback send_error(t(), A2UI.Protocol.Messages.Error.t(), metadata :: map()) :: :ok | {:error, any()}
Functions
@spec disconnect(t()) :: :ok
Disconnects the transport. Dispatches based on the struct module.
@spec send_action(t(), A2UI.Protocol.Messages.Action.t(), map()) :: :ok | {:error, any()}
Sends an action through the transport. Dispatches based on the struct module.
@spec send_error(t(), A2UI.Protocol.Messages.Error.t(), map()) :: :ok | {:error, any()}
Sends an error through the transport. Dispatches based on the struct module.