Expand description
The axum WebSocket server: one /ws endpoint, one task per connection.
Per connection we split the socket and run two tasks joined by an
UnboundedSender<serde_json::Value> outbound sink:
- a writer that drains the sink and writes each event as a JSON text frame, and
- a reader that reads inbound frames and dispatches them via
crate::handler::handle_frame, passing the sink so handlers (including the streamingsend_message) can emit events as they happen.
Using a sink channel (instead of writing directly from the handler) is what
lets a streaming turn fire many stream_token events from inside the agent
loop while the connection is still reading.
Constants§
- SEED_
ORG_ ID - The org the seeded demo docs + their document-set registry entries belong to.
Mirrors the org
handler::handle_create_sessionstamps onto reference conversations, so the seeded sets show up for the reference org’s admin caller (and ONLY that org — cross-org scoping).
Functions§
- bind
- Bind on
<SMOOTH_AGENT_BIND>:<port>(default loopback) and serve until the process is killed. Returns the boundTcpListener+ the router, used by both the binary and tests (tests bind port 0 for an ephemeral port). - build_
state - Build an
AppStateover a fresh in-memory adapter, seeding the knowledge base whenconfig.seed_kbis set. Exposed for tests + the binary. - build_
state_ from_ env - Build an
AppStatewith the env-configured auth verifier (secure by default — seesmooth_operator::auth::AuthConfig). Used by the binary. - build_
state_ from_ env_ async - Build an
AppStateselecting the storage backend (and the matching durable admin stores) fromconfig.storage, then installing the env-configured auth verifier. - router
- Build the axum
Routerfor the given application state. Exposed so tests can boot the server in-process. Serves the WebSocket/wsendpoint plus the auth-gated admin HTTP API under/admin(seecrate::admin). - run
- Run the server to completion (blocks). Logs a single listening line.
- seed_
knowledge - Seed a couple of distinctive demo docs so knowledge-grounded E2E is
deterministic. The 17-day return window is deliberately unusual so an
ungrounded answer can’t accidentally match it. Both docs are tagged into the
policiesdocument set so the admin API can report it. - serve_
state - Serve a pre-built
AppStateto completion (blocks), binding onstate.config.bind:state.config.port. - serve_
state_ on - Serve a pre-built
AppStateon an already-boundTcpListener(blocks).