A2UI.Plug.SSE (A2UI v0.3.0)

Copy Markdown View Source

SSE connection handler for A2UI.

Streams A2UI protocol messages from an agent to a client as Server-Sent Events. Called by A2UI.Plug when a client opens GET /sse.

Event Format

The first event contains the connection ID for use in JSON-RPC calls:

id: 0
data: {"connectionId":"abc123"}

Subsequent events contain A2UI protocol messages:

id: 1
data: {"version":"v0.9","createSurface":{"surfaceId":"main"}}

Keep-alive comments are sent every 30 seconds:

: ping

Summary

Functions

Starts an SSE stream for the given agent.

Functions

stream(conn, agent, registry \\ ConnectionRegistry)

@spec stream(Plug.Conn.t(), GenServer.server(), atom()) :: Plug.Conn.t()

Starts an SSE stream for the given agent.

Creates a Connection, registers it, connects to the agent, and enters a blocking receive loop that streams messages as SSE events.