Skip to main content

stakpak_api/local/
mod.rs

1//! Local storage and hook infrastructure
2//!
3//! This module provides:
4//! - Database operations for local session storage
5//! - Lifecycle hooks for context management
6//! - Model configuration types
7
8use stakpak_shared::models::integrations::openai::AgentModel;
9use stakpak_shared::models::llm::LLMModel;
10
11// Sub-modules
12pub(crate) mod context_managers;
13pub mod hooks;
14pub mod storage;
15
16#[cfg(test)]
17mod tests;
18
19/// Model options for the agent
20#[derive(Clone, Debug, Default)]
21pub struct ModelOptions {
22    pub smart_model: Option<LLMModel>,
23    pub eco_model: Option<LLMModel>,
24    pub recovery_model: Option<LLMModel>,
25}
26
27/// Resolved model set with default fallbacks
28#[derive(Clone, Debug)]
29pub struct ModelSet {
30    pub smart_model: LLMModel,
31    pub eco_model: LLMModel,
32    pub recovery_model: LLMModel,
33}
34
35impl ModelSet {
36    /// Get the model for a given agent model type
37    pub fn get_model(&self, agent_model: &AgentModel) -> LLMModel {
38        match agent_model {
39            AgentModel::Smart => self.smart_model.clone(),
40            AgentModel::Eco => self.eco_model.clone(),
41            AgentModel::Recovery => self.recovery_model.clone(),
42        }
43    }
44}
45
46impl From<ModelOptions> for ModelSet {
47    fn from(value: ModelOptions) -> Self {
48        // Default models route through Stakpak provider
49        let smart_model = value
50            .smart_model
51            .unwrap_or_else(|| LLMModel::from("stakpak/anthropic/claude-opus-4-5".to_string()));
52        let eco_model = value
53            .eco_model
54            .unwrap_or_else(|| LLMModel::from("stakpak/anthropic/claude-haiku-4-5".to_string()));
55        let recovery_model = value
56            .recovery_model
57            .unwrap_or_else(|| LLMModel::from("stakpak/openai/gpt-4o".to_string()));
58
59        Self {
60            smart_model,
61            eco_model,
62            recovery_model,
63        }
64    }
65}