Skip to main content

AppState

Struct AppState 

pub struct AppState {
Show 38 fields pub config: LiveConfigHandle, pub config_authority: LiveConfigAuthority, pub agent_lifecycle: AgentLifecycleCoordinator, pub model_provider: Arc<dyn ModelProvider>, pub model: String, pub temperature: Option<f64>, pub mem: Arc<dyn Memory>, pub memory_strategy: Arc<dyn MemoryStrategy>, pub auto_save: bool, pub pairing: Arc<PairingGuard>, pub trust_forwarded_headers: bool, pub rate_limiter: Arc<GatewayRateLimiter>, pub auth_limiter: Arc<AuthRateLimiter>, pub idempotency_store: Arc<IdempotencyStore>, pub gmail_push: Option<Arc<GmailPushChannel>>, pub observer: Arc<dyn Observer>, pub tools_registry: Arc<Vec<ToolSpec>>, pub tools_registry_by_agent: Arc<HashMap<String, Arc<Vec<ToolSpec>>>>, pub cost_tracker: Option<Arc<CostTracker>>, pub event_tx: Sender<Value>, pub event_buffer: Arc<EventBuffer>, pub shutdown_tx: Sender<bool>, pub reload_tx: Option<GatewayReloadControls>, pub node_registry: Arc<NodeRegistry>, pub mdns_peer_registry: MdnsPeerRegistry, pub path_prefix: String, pub web_dist_dir: Option<PathBuf>, pub session_backend: Option<Arc<dyn SessionBackend>>, pub session_queue: Arc<SessionActorQueue>, pub device_registry: Option<Arc<DeviceRegistry>>, pub pending_pairings: Option<Arc<PairingStore>>, pub canvas_store: CanvasStore, pub cancel_tokens: Arc<Mutex<HashMap<String, Arc<CancellationToken>>>>, pub pending_reload: Arc<Atomic<bool>>, pub tui_registry: Option<Arc<TuiRegistry>>, pub sop_engine: Option<Arc<Mutex<SopEngine>>>, pub sop_audit: Option<Arc<SopAuditLogger>>, pub sop_driver_handles: Option<Arc<Mutex<SopDriverRegistry>>>,
}
Expand description

Shared state for all axum handlers

Fields§

§config: LiveConfigHandle

Read-only live config handle: HTTP readers observe the published config and its revision as one pair and cannot bypass publication with a raw write. Mutating handlers admit through AppState::begin_config_commit instead.

§config_authority: LiveConfigAuthority

The live-config authority owning this gateway run’s publication transaction: the process-wide writer mutex, the config-write lifecycle lease, and the published pair. Every HTTP config writer serializes through it before cloning the current config; the irreversible save-and-publish phase of each commit runs retained, so request cancellation cannot abandon a dispatched commit. Mirrors RpcContext::config_authority in the RPC path.

§agent_lifecycle: AgentLifecycleCoordinator§model_provider: Arc<dyn ModelProvider>§model: String§temperature: Option<f64>

None means “let the provider decide” — required for models (e.g. claude-opus-4-7) that reject the field. Always preserve Option<f64> end-to-end; never substitute a hardcoded default.

§mem: Arc<dyn Memory>§memory_strategy: Arc<dyn MemoryStrategy>§auto_save: bool§pairing: Arc<PairingGuard>§trust_forwarded_headers: bool§rate_limiter: Arc<GatewayRateLimiter>§auth_limiter: Arc<AuthRateLimiter>§idempotency_store: Arc<IdempotencyStore>§gmail_push: Option<Arc<GmailPushChannel>>

Gmail Pub/Sub push notification channel

§observer: Arc<dyn Observer>

Observability backend for metrics scraping

§tools_registry: Arc<Vec<ToolSpec>>

Registered tool specs (for web dashboard tools page). This is the default (no ?agent=) listing, seeded from the deterministically smallest enabled agent alias.

§tools_registry_by_agent: Arc<HashMap<String, Arc<Vec<ToolSpec>>>>

Per-agent tool-spec listings keyed by agent alias, powering the agent-aware GET /api/tools?agent=<alias> view so the WebUI Tools page can show each agent’s scoped tool set. Falls back to tools_registry for an unknown or omitted alias.

§cost_tracker: Option<Arc<CostTracker>>

Cost tracker (optional, for web dashboard cost page)

§event_tx: Sender<Value>

SSE broadcast channel for real-time events

§event_buffer: Arc<EventBuffer>

Ring buffer of recent events for history replay

§shutdown_tx: Sender<bool>

Shutdown signal sender for graceful shutdown

§reload_tx: Option<GatewayReloadControls>

Reload signal sender owned by the daemon. /admin/reload writes true here; the daemon’s wait loop reacts and re-instantiates every subsystem in place. None when running standalone (zeroclaw gateway start) — reload then degrades to a 503 with a clear message.

§node_registry: Arc<NodeRegistry>

Registry of dynamically connected nodes

§mdns_peer_registry: MdnsPeerRegistry

LAN-local peer hints discovered by multicast. These are informational only; they never authorize or connect a peer.

§path_prefix: String

Path prefix for reverse-proxy deployments (empty string = no prefix)

§web_dist_dir: Option<PathBuf>

Filesystem path to web/dist/ for serving the dashboard (None = API-only)

§session_backend: Option<Arc<dyn SessionBackend>>

Session backend for persisting gateway WS chat sessions

§session_queue: Arc<SessionActorQueue>

Per-session actor queue for serializing concurrent turns

§device_registry: Option<Arc<DeviceRegistry>>

Device registry for paired device management

§pending_pairings: Option<Arc<PairingStore>>

Pending pairing request store

§canvas_store: CanvasStore

Shared canvas store for Live Canvas (A2UI) system

§cancel_tokens: Arc<Mutex<HashMap<String, Arc<CancellationToken>>>>

Per-session cancellation tokens for aborting in-flight agent responses. Key is session_key (e.g. gw_<session_id>), value is the token for the current turn. Entries are inserted before each turn and removed after completion (normal or cancelled). The outer Arc provides turn identity so late cleanup cannot remove a replacement turn’s token.

§pending_reload: Arc<Atomic<bool>>§tui_registry: Option<Arc<TuiRegistry>>

TUI session registry from the daemon (for /api/tuis endpoint). None when the gateway runs standalone without a daemon.

§sop_engine: Option<Arc<Mutex<SopEngine>>>

Shared SOP engine from the daemon (for WS agent sessions). None when the gateway runs standalone — sessions build their own.

§sop_audit: Option<Arc<SopAuditLogger>>

Shared SOP audit logger from the daemon (for WS agent sessions).

§sop_driver_handles: Option<Arc<Mutex<SopDriverRegistry>>>

Trait Implementations§

Source§

impl Clone for AppState

Source§

fn clone(&self) -> AppState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more