Skip to main content

zeph_config/
serve.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! `[serve]` config: settings for the `zeph serve` persistent agent service (spec-068 §9).
5//!
6//! `zeph serve` runs a long-lived process exposing sessions over an HTTP/SSE API and (optionally)
7//! ACP, backed by the same durable JSONL event log as every other channel. This module only
8//! declares the config surface — see `crates/zeph-core` for `SessionActor`/`LiveSessionRegistry`
9//! and `src/serve/` for the HTTP handlers.
10
11use serde::{Deserialize, Serialize};
12
13/// Top-level `[serve]` config block (spec-068 §9).
14///
15/// # Example (TOML)
16///
17/// ```toml
18/// [serve]
19/// http_addr = "127.0.0.1:8420"
20/// require_auth = true
21/// auth_token_vault_key = "ZEPH_SERVE_AUTH_TOKEN"
22/// max_sessions = 50
23/// session_idle_ttl_secs = 1800
24/// max_queued_prompts = 8
25/// ```
26#[derive(Debug, Clone, Deserialize, Serialize)]
27#[serde(default)]
28pub struct ServeConfig {
29    /// Address the HTTP/SSE API binds to. Default: `"127.0.0.1:8420"`.
30    pub http_addr: String,
31    /// Require a bearer token on all `/sessions*` endpoints (`/health` is always
32    /// unauthenticated). Default: `true`.
33    ///
34    /// Per CLAUDE.md's vault-only secrets policy, the token itself is never stored in this
35    /// config file — only the vault key name to resolve it from (`auth_token_vault_key`).
36    pub require_auth: bool,
37    /// Zeph age-vault key name to resolve the bearer token from at startup (spec-068 NFR-S4).
38    /// Default: `"ZEPH_SERVE_AUTH_TOKEN"`.
39    pub auth_token_vault_key: String,
40    /// Maximum number of concurrent live sessions the `LiveSessionRegistry` will hold.
41    /// Default: `50`.
42    pub max_sessions: usize,
43    /// Seconds of no attached broadcast receivers before `serve.evict` shuts down and removes a
44    /// session's `SessionActor` (spec-068 §9.3). Default: `1800` (30 minutes).
45    pub session_idle_ttl_secs: u64,
46    /// Bounded mpsc capacity for a `SessionActor`'s prompt mailbox; a full mailbox returns HTTP
47    /// 429 to the caller rather than blocking (spec-068 §9.2). Default: `8`.
48    pub max_queued_prompts: usize,
49}
50
51impl Default for ServeConfig {
52    fn default() -> Self {
53        Self {
54            http_addr: "127.0.0.1:8420".to_owned(),
55            require_auth: true,
56            auth_token_vault_key: "ZEPH_SERVE_AUTH_TOKEN".to_owned(),
57            max_sessions: 50,
58            session_idle_ttl_secs: 1800,
59            max_queued_prompts: 8,
60        }
61    }
62}