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//! - [`local`] — the **local deployment flavor** (the third target alongside
25//! `deploy/k8s` and `deploy/sst`): an embeddable, fully in-memory, auth-off
26//! server. [`local::serve_local`] runs it to completion;
27//! [`local::LocalServer::builder`] boots it in-process with a shutdown handle.
28//! - [`admin`] — the auth-gated admin HTTP API (Phase 12) mounted under
29//! `/admin`: whoami, chat history, indexing status, document sets. Consumed by
30//! the Next.js management console (increment 2). See `docs/ADMIN-API.md`.
31//!
32//! ## Env contract (reused by every language's E2E harness)
33//!
34//! See [`config`] for the full table. The load-bearing ones:
35//! `SMOOTH_AGENT_PORT`, `SMOOAI_GATEWAY_URL`, `SMOOAI_GATEWAY_KEY`,
36//! `SMOOTH_AGENT_MODEL`, `SMOOTH_AGENT_SEED_KB`.
37
38pub mod admin;
39pub mod config;
40pub mod embedder;
41pub mod handler;
42pub mod local;
43pub mod protocol;
44pub mod reranker;
45pub mod runner;
46pub mod server;
47pub mod state;
48
49pub use config::ServerConfig;
50pub use embedder::{build_embedder, EmbedderConfig};
51pub use local::{serve_local, LocalServer, LocalServerBuilder, DEFAULT_LOCAL_ADDR};
52pub use reranker::{build_reranker, RerankMode, RerankerConfig};
53pub use server::{
54 bind, build_state, build_state_from_env, build_state_from_env_async, router, run, serve_state,
55 serve_state_on,
56};
57pub use state::AppState;