pub struct AppState {
pub storage: Arc<dyn StorageAdapter>,
pub config: Arc<ServerConfig>,
pub auth: Arc<dyn AuthVerifier>,
pub indexing: Arc<dyn IndexingStore>,
pub connector_configs: Arc<dyn ConnectorConfigStore>,
pub settings: Arc<dyn SettingsStore>,
pub widget_auth: Arc<dyn WidgetAuthProvider>,
pub backplane: Arc<dyn Backplane>,
/* private fields */
}Expand description
Shared, cloneable application state handed to every WebSocket connection + every admin HTTP request.
Fields§
§storage: Arc<dyn StorageAdapter>The single storage seam (conversations / participants / messages / sessions / checkpoints / knowledge).
config: Arc<ServerConfig>Resolved server configuration (gateway, model, limits).
auth: Arc<dyn AuthVerifier>The configured auth verifier (jwt / smoo / none). Used by the admin API’s
require_role extractor to turn a bearer token into a Principal.
indexing: Arc<dyn IndexingStore>Indexing-run status store, surfaced by GET /admin/indexing/runs.
connector_configs: Arc<dyn ConnectorConfigStore>Connector-configuration store, CRUD’d by the admin write API
(/admin/connectors). Org-scoped; holds an auth_ref (secret name), not
the secret itself.
settings: Arc<dyn SettingsStore>Per-org agent settings store, read/written by /admin/settings.
widget_auth: Arc<dyn WidgetAuthProvider>Embeddable-widget auth hook: resolves an agent’s origin-allowlist +
public-key policy for <smooth-agent-chat> connections. Defaults to
PermissiveWidgetAuth (no enforcement) until a host installs a real
provider via with_widget_auth.
backplane: Arc<dyn Backplane>Connection backplane: per-pod sink registry + cross-pod event delivery.
Defaults to InMemoryBackplane (single-process); a host installs a
Redis/NATS impl via with_backplane to scale out
and to let non-AI publishers push realtime events to connected clients.
Implementations§
Source§impl AppState
impl AppState
Sourcepub fn new(storage: Arc<dyn StorageAdapter>, config: ServerConfig) -> Self
pub fn new(storage: Arc<dyn StorageAdapter>, config: ServerConfig) -> Self
Construct shared state over a storage adapter and config.
Defaults the admin-API collaborators: a NoAuthVerifier (overridden via
with_auth) and an empty InMemoryIndexingStore
(overridden via with_indexing). The /ws path
uses none of these, so existing callers are unaffected.
Sourcepub fn with_auth(self, auth: Arc<dyn AuthVerifier>) -> Self
pub fn with_auth(self, auth: Arc<dyn AuthVerifier>) -> Self
Install the configured auth verifier (builder).
Sourcepub fn with_indexing(self, indexing: Arc<dyn IndexingStore>) -> Self
pub fn with_indexing(self, indexing: Arc<dyn IndexingStore>) -> Self
Install the indexing store (builder).
Sourcepub fn with_connector_configs(
self,
store: Arc<dyn ConnectorConfigStore>,
) -> Self
pub fn with_connector_configs( self, store: Arc<dyn ConnectorConfigStore>, ) -> Self
Install the connector-configuration store (builder).
Sourcepub fn with_settings(self, store: Arc<dyn SettingsStore>) -> Self
pub fn with_settings(self, store: Arc<dyn SettingsStore>) -> Self
Install the agent-settings store (builder).
Sourcepub fn with_widget_auth(self, provider: Arc<dyn WidgetAuthProvider>) -> Self
pub fn with_widget_auth(self, provider: Arc<dyn WidgetAuthProvider>) -> Self
Install the embeddable-widget auth provider (builder). A host backs this with its agent store so embed origins + public keys are enforced.
Sourcepub fn with_backplane(self, backplane: Arc<dyn Backplane>) -> Self
pub fn with_backplane(self, backplane: Arc<dyn Backplane>) -> Self
Install the connection backplane (builder). A host installs a Redis/NATS
impl to scale the WS service horizontally and to let other services push
realtime events to connected clients via Backplane::publish.
Sourcepub fn insert_session(&self, session: Session)
pub fn insert_session(&self, session: Session)
Register a freshly created session.
Sourcepub fn get_session(&self, session_id: &str) -> Option<Session>
pub fn get_session(&self, session_id: &str) -> Option<Session>
Look up a session by id.
Sourcepub fn record_document_set(
&self,
org_id: impl Into<String>,
set: impl Into<String>,
)
pub fn record_document_set( &self, org_id: impl Into<String>, set: impl Into<String>, )
Record that a document was added to a named document set within an org
(increments its count). Used by seeding + the ingest path so
GET /admin/document-sets can report set names + counts despite the
in-memory backend dropping document metadata. Org-scoped so org A’s sets
are never reported to an org-B caller.
Sourcepub fn document_sets(&self, org_id: &str) -> Vec<(String, usize)>
pub fn document_sets(&self, org_id: &str) -> Vec<(String, usize)>
Snapshot one org’s document-set registry as (name, count) pairs,
sorted by name for a stable response. Never returns another org’s sets.
Sourcepub fn record_connector(
&self,
org_id: impl Into<String>,
name: impl Into<String>,
)
pub fn record_connector( &self, org_id: impl Into<String>, name: impl Into<String>, )
Record a connector (within an org) whose indexing runs should be listed
(idempotent). Org-scoped so a same-named connector in two orgs records
separately and GET /admin/indexing/runs only lists the caller’s org’s.
Sourcepub fn connectors(&self, org_id: &str) -> Vec<String>
pub fn connectors(&self, org_id: &str) -> Vec<String>
Snapshot one org’s recorded connector names (sorted, stable). Never returns another org’s connectors.
Trait Implementations§
Source§impl<const MIN: u8> FromRequestParts<AppState> for RequireRole<MIN>
impl<const MIN: u8> FromRequestParts<AppState> for RequireRole<MIN>
Auto Trait Implementations§
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Freeze for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
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