Streams a run's events to a subscriber process over the Norns agent socket.
You normally start this via NornsSdk.Client.stream/4 rather than directly.
It joins the agent:<id> channel for a run and forwards each event to the
subscriber's mailbox as it arrives:
{:norns_event, stream_pid, %NornsSdk.StreamEvent{type: type, data: data}}The two terminal events are "completed" and "error"; after forwarding one
of them the process stops normally. If the socket closes before a terminal
event (disconnect, timeout, join failure), the subscriber receives:
{:norns_closed, stream_pid, reason}so it never blocks forever. The process also stops if the subscriber exits.
Example
{:ok, _pid} = NornsSdk.Client.stream(client, "support-bot", "Hello!")
def handle_info({:norns_event, _pid, %{type: "completed"} = ev}, state) do
IO.puts(ev.data["output"])
{:noreply, state}
end
Summary
Functions
Start streaming events for run_id on agent:<agent_id>.
Functions
Start streaming events for run_id on agent:<agent_id>.
Options:
:base_url(required) — the Norns HTTP base URL.:agent_id(required) — the agent to stream from.:run_id(required) — the run to stream.:subscriber— pid to deliver events to (defaults to the caller).:api_key— bearer token for the socket connection.