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 migrations;
15pub mod storage;
16
17#[cfg(test)]
18mod tests;
19
20/// Model options for the agent
21#[derive(Clone, Debug, Default)]
22pub struct ModelOptions {
23    pub smart_model: Option<LLMModel>,
24    pub eco_model: Option<LLMModel>,
25    pub recovery_model: Option<LLMModel>,
26}
27
28/// Resolved model set with default fallbacks
29#[derive(Clone, Debug)]
30pub struct ModelSet {
31    pub smart_model: LLMModel,
32    pub eco_model: LLMModel,
33    pub recovery_model: LLMModel,
34}
35
36impl ModelSet {
37    /// Get the model for a given agent model type
38    pub fn get_model(&self, agent_model: &AgentModel) -> LLMModel {
39        match agent_model {
40            AgentModel::Smart => self.smart_model.clone(),
41            AgentModel::Eco => self.eco_model.clone(),
42            AgentModel::Recovery => self.recovery_model.clone(),
43        }
44    }
45}
46
47impl From<ModelOptions> for ModelSet {
48    fn from(value: ModelOptions) -> Self {
49        // Default models route through Stakpak provider
50        let smart_model = value
51            .smart_model
52            .unwrap_or_else(|| LLMModel::from("stakpak/anthropic/claude-opus-4-5".to_string()));
53        let eco_model = value
54            .eco_model
55            .unwrap_or_else(|| LLMModel::from("stakpak/anthropic/claude-haiku-4-5".to_string()));
56        let recovery_model = value
57            .recovery_model
58            .unwrap_or_else(|| LLMModel::from("stakpak/openai/gpt-4o".to_string()));
59
60        Self {
61            smart_model,
62            eco_model,
63            recovery_model,
64        }
65    }
66}