Skip to main content

brainos_core/
lib.rs

1//! # Brain Core
2//!
3//! Orchestrator that wires all brain subsystems together.
4//!
5//! Provides:
6//! - Configuration management (figment + YAML)
7//! - Subsystem initialization and dependency injection
8//! - Message pipeline: Thalamus → Hippocampus → Cortex → Response
9//! - Error handling and graceful degradation
10
11pub mod auth;
12pub mod config;
13pub mod cors;
14pub mod metrics;
15
16pub use auth::{check_auth, AuthResult};
17pub use config::{AccessConfig, ApiKeyConfig, BrainConfig, DeliveryConfig};
18
19/// Standard timeout constants for HTTP clients across Brain OS.
20pub mod timeouts {
21    use std::time::Duration;
22
23    pub const EMBEDDING_OLLAMA: Duration = Duration::from_secs(120);
24    pub const EMBEDDING_OPENAI: Duration = Duration::from_secs(60);
25    pub const LLM_GENERATE: Duration = Duration::from_secs(300);
26    pub const HEALTH_CHECK: Duration = Duration::from_secs(2);
27    pub const DAEMON_SETUP: Duration = Duration::from_secs(30);
28    pub const STATUS_CHECK: Duration = Duration::from_secs(2);
29}
30
31/// Normalize a keyword for matching: trim non-alphanumeric edges, lowercase.
32pub fn normalize_keyword(word: &str) -> String {
33    word.trim_matches(|c: char| !c.is_alphanumeric())
34        .to_lowercase()
35}