Client for interacting with Norns agents.
Sends messages, queries runs, manages conversations.
Usage
client = NornsSdk.Client.new("http://localhost:4000", api_key: "nrn_...")
# Fire and forget
{:ok, %{run_id: 42}} = NornsSdk.Client.send_message(client, "support-bot", "Hello!")
# Block until completion
{:ok, result} = NornsSdk.Client.send_message(client, "support-bot", "Hello!", wait: true)
result.output
Summary
Functions
Send a message and stream the run's events to a subscriber process.
Types
Functions
Send a message and stream the run's events to a subscriber process.
Sends the message (fire-and-forget), then starts a NornsSdk.StreamClient
that joins the run's channel and forwards each event to the subscriber's
mailbox as:
{:norns_event, stream_pid, %NornsSdk.StreamEvent{type: type, data: data}}The terminal events are "completed" and "error"; the stream process stops
after forwarding one. If the socket closes first, the subscriber receives
{:norns_closed, stream_pid, reason}. Returns {:ok, stream_pid}.
Options
:subscriber— pid to receive events (defaults to the calling process).:conversation_key— multi-turn conversation key.
Example
{:ok, _pid} = NornsSdk.Client.stream(client, "support-bot", "Research quantum computing")
receive do
{:norns_event, _pid, %NornsSdk.StreamEvent{type: "completed"} = ev} ->
IO.puts(ev.data["output"])
end