use std::sync::Arc;
use slave_framework::auth::Auth;
use slave_framework::database::Db;
use super::config::Config;
/// State shared by every MCP tool and the health check.
///
/// Services are built from it per call through `FromRef`, so this type
/// never needs to know about individual domain modules.
#[derive(Debug, Clone)]
pub struct AppState {
pub config: Arc<Config>,
/// The SurrealDB connection; clones share it.
pub db: Db,
/// Sign-in: codes by email, passkeys, sessions.
pub auth: Auth,
}
impl AppState {
pub fn new(config: Config, db: Db) -> slave_framework::Result<Self> {
Ok(Self {
auth: Auth::from_env(db.clone(), &config.name)?,
config: Arc::new(config),
db,
})
}
}