pub struct LocalServerBuilder { /* private fields */ }Expand description
Builder for the local deployment flavor: a fully in-memory, auth-off, single-process server, embeddable in-process.
All knobs are optional — LocalServer::builder().spawn().await boots the
default flavor (in-memory everything, loopback :8787, no auth, no seed).
Construct with LocalServer::builder.
Implementations§
Source§impl LocalServerBuilder
impl LocalServerBuilder
Sourcepub fn addr(self, addr: SocketAddr) -> Self
pub fn addr(self, addr: SocketAddr) -> Self
Bind on the given address instead of the default 127.0.0.1:8787.
Use port 0 for an ephemeral port (read the real one back from
LocalServer::addr after spawn).
Sourcepub fn seed_kb(self, seed: bool) -> Self
pub fn seed_kb(self, seed: bool) -> Self
Seed the knowledge base with the demo docs on boot (default false).
Handy for an embedded demo / smoke test with grounded answers.
Sourcepub fn auth(self, auth: Arc<dyn AuthVerifier>) -> Self
pub fn auth(self, auth: Arc<dyn AuthVerifier>) -> Self
Install a custom AuthVerifier for the local flavor.
Without this, the local flavor runs auth-off (NoAuthVerifier) — fine
for pure loopback. Pass a
LocalTokenVerifier to gate
stray local processes with a shared secret (recommended when binding
beyond loopback, e.g. over a tailnet).
Sourcepub fn tools(self, provider: Arc<dyn ToolProvider>) -> Self
pub fn tools(self, provider: Arc<dyn ToolProvider>) -> Self
Install a host ToolProvider so the runner merges its per-turn tools
into every turn alongside the built-ins (the #68 injection seam). The
local flavor uses this to add an OS-sandboxed shell + egress-routed tools
— the isolation the cloud flavor gets from its container/network sandbox
instead.
Sourcepub fn serve_widget(self, token: Option<String>) -> Self
pub fn serve_widget(self, token: Option<String>) -> Self
Serve the official @smooai/smooth-operator widget from this server: a
host page at / and the bundle at /chat-widget.iife.js. token is
injected into the page so the widget connects to this server’s
/ws?token=… (pair it with a matching auth verifier);
pass None for a no-auth local server.
Sourcepub fn persona(self, persona: impl Into<String>) -> Self
pub fn persona(self, persona: impl Into<String>) -> Self
Set the default agent persona (system prompt) for every turn that has
no per-org override. A single-tenant host (the local daemon) uses this to
give the agent its own personality instead of the built-in customer-support
prompt. Threads to AppState::default_persona.
Unset → the built-in const prompt (unchanged).
Sourcepub fn serve_spa(self, spa: Router) -> Self
pub fn serve_spa(self, spa: Router) -> Self
Serve a host-supplied SPA (e.g. the smooth-web dashboard) at this
server’s own origin, as the router fallback. The operator’s explicit routes
(/ws, /health, /admin/*) still win; everything else (/, hashed
asset paths, SPA client routes) is served by spa. Use this INSTEAD of
serve_widget when the host wants its own UI at /
— the endpoint is then simply http://<addr>/ with no ?api/?token
query string (the host injects the token into the SPA’s index.html
itself, so the operator-server stays agnostic to the SPA’s auth wiring).
Sourcepub fn serve_routes(self, routes: Router) -> Self
pub fn serve_routes(self, routes: Router) -> Self
Merge host-supplied real routes into the operator’s own router, so they
sit alongside /ws, /health, and /admin/* as first-class routes (NOT a
fallback like serve_spa). The daemon uses this to add
its own endpoints — e.g. the @-mention GET /search the web composer
calls — to the operator origin without the operator-server knowing about
them.
The supplied routes get the same permissive CORS as /admin so the
cross-origin dev SPA (the Vite origin http://localhost:3100) can call them
in the browser. The host is responsible for any auth on these routes; the
operator merges them verbatim. A route here MUST NOT collide with an
existing operator path (/ws, /health, /admin/*) — axum panics on a
duplicate route at merge time.
Sourcepub fn strict_auth(self, strict: bool) -> Self
pub fn strict_auth(self, strict: bool) -> Self
Enable strict auth: reject /ws connections with a missing/invalid
token (HTTP 401) instead of degrading to an anonymous connection. Pair
with auth — recommended whenever the server is reachable
beyond loopback (e.g. a tailnet), so a tokenless peer can’t drive the
agent. Off by default.
Sourcepub fn storage(self, storage: Arc<dyn StorageAdapter>) -> Self
pub fn storage(self, storage: Arc<dyn StorageAdapter>) -> Self
Install a durable storage adapter, replacing the default in-memory
store. This is the seam an always-on, self-hosted deployment (the local
daemon) uses to persist conversations/sessions/checkpoints across
restarts without standing up Postgres — the embedder supplies any
StorageAdapter (e.g. a local sqlite/dolt one). Unset → in-memory.
Sourcepub fn config(self, config: ServerConfig) -> Self
pub fn config(self, config: ServerConfig) -> Self
Override the full ServerConfig (e.g. to point at a gateway / model).
The local flavor still forces in-memory storage and the caller’s bind addr regardless of what this config says — the storage/bind fields are overwritten — so the “no external services” guarantee always holds. Use this to set the gateway URL / key / model / limits for live turns.
Sourcepub async fn spawn(self) -> Result<LocalServer>
pub async fn spawn(self) -> Result<LocalServer>
Bind and spawn the server in a background task, returning a LocalServer
handle carrying the real bound address (resolved even for port 0)
and a graceful-shutdown switch.
§Errors
Returns an error if binding the TCP listener fails (e.g. the port is in use). Serving errors after a successful bind surface when the handle is awaited / shut down.
Trait Implementations§
Source§impl Clone for LocalServerBuilder
impl Clone for LocalServerBuilder
Source§fn clone(&self) -> LocalServerBuilder
fn clone(&self) -> LocalServerBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LocalServerBuilder
impl Debug for LocalServerBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for LocalServerBuilder
impl !UnwindSafe for LocalServerBuilder
impl Freeze for LocalServerBuilder
impl Send for LocalServerBuilder
impl Sync for LocalServerBuilder
impl Unpin for LocalServerBuilder
impl UnsafeUnpin for LocalServerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request