Skip to main content

smooth_operator_server/
lib.rs

1//! # smooth-operator-server
2//!
3//! The reference WebSocket service for smooth-operator. It speaks the
4//! schema-driven protocol in `smooth-operator/spec/` over a smooth-operator-backed
5//! knowledge-chat runtime, so the generated TypeScript / Go / .NET / Python
6//! clients can connect and drive real LLM turns unmodified.
7//!
8//! ## Pieces
9//!
10//! - [`config`] — env-driven [`ServerConfig`](config::ServerConfig) (gateway URL
11//!   / key / model / limits). The gateway key is optional at startup; without it
12//!   `send_message` returns a clean `error` so protocol conformance is testable
13//!   with zero credentials.
14//! - [`protocol`] — builders for the server→client event envelopes, matched
15//!   field-for-field to `spec/events/*.json`.
16//! - [`state`] — shared [`AppState`](state::AppState): storage adapter + session
17//!   registry.
18//! - [`handler`] — action dispatch (`ping`, `create_conversation_session`,
19//!   `get_session`, `send_message`).
20//! - [`runner`] — the streaming, memory-carrying turn runner over a
21//!   smooth-operator [`Agent`](smooth_operator_core::Agent).
22//! - [`server`] — the axum app + per-connection socket loop. [`server::bind`]
23//!   and [`server::router`] let tests boot the service in-process.
24//! - [`admin`] — the auth-gated admin HTTP API (Phase 12) mounted under
25//!   `/admin`: whoami, chat history, indexing status, document sets. Consumed by
26//!   the Next.js management console (increment 2). See `docs/ADMIN-API.md`.
27//!
28//! ## Env contract (reused by every language's E2E harness)
29//!
30//! See [`config`] for the full table. The load-bearing ones:
31//! `SMOOTH_AGENT_PORT`, `SMOOAI_GATEWAY_URL`, `SMOOAI_GATEWAY_KEY`,
32//! `SMOOTH_AGENT_MODEL`, `SMOOTH_AGENT_SEED_KB`.
33
34pub mod admin;
35pub mod config;
36pub mod embedder;
37pub mod handler;
38pub mod protocol;
39pub mod reranker;
40pub mod runner;
41pub mod server;
42pub mod state;
43
44pub use config::ServerConfig;
45pub use embedder::{build_embedder, EmbedderConfig};
46pub use reranker::{build_reranker, RerankMode, RerankerConfig};
47pub use server::{
48    bind, build_state, build_state_from_env, build_state_from_env_async, router, run, serve_state,
49    serve_state_on,
50};
51pub use state::AppState;