Per-external-id GenServer driving one turn at a time through ReqManagedAgents.Session.run/2.
Fresh (Locator has no session_id for this external id): opens with no :session_id
opt; the provider mints one and Session.run/2 returns it, which is persisted into a
Locator.Record. Reattach (Locator already has a session_id): passes it back in as
:session_id, so the provider consolidates into the existing upstream session and the
request_response reattach seam delivers the message as a fresh user.message rather than a
new kickoff. Either way a turn is exactly one Session.run/2 call — no Client, no
hand-sent events.
Idle for config.idle_timeout_ms after replying to a turn: stops normally. The Locator
row (and thus the upstream session id) survives the stop — the next deliver/2 for the same
external id starts a fresh server and reattaches instead of minting a new upstream session.
Summary
Types
@type t() :: %ReqManagedAgents.Host.SessionServer{ config: ReqManagedAgents.Host.Config.t(), external_id: ReqManagedAgents.Host.Locator.external_id(), idle_ref: reference() | nil }
Functions
@spec deliver(GenServer.server(), String.t()) :: {:ok, ReqManagedAgents.SessionResult.t()} | {:error, term()}
Run one turn: deliver message and block for the resulting SessionResult.
@spec start_link( {ReqManagedAgents.Host.Locator.external_id(), ReqManagedAgents.Host.Config.t()} ) :: GenServer.on_start()
Start the server for external_id, registered under via/1.
@spec via(ReqManagedAgents.Host.Locator.external_id()) :: {:via, Registry, {module(), ReqManagedAgents.Host.Locator.external_id()}}
The Registry-backed name a server for external_id runs under.