use crate::agents::AgentPool; use crate::state::SessionState; use crate::store::JsonFileStore; use crate::workflow::WorkflowState; use poem::http::StatusCode; use std::sync::Arc; #[derive(Clone)] pub struct AppContext { pub state: Arc, pub store: Arc, pub workflow: Arc>, pub agents: Arc, } #[cfg(test)] impl AppContext { pub fn new_test(project_root: std::path::PathBuf) -> Self { let state = SessionState::default(); *state.project_root.lock().unwrap() = Some(project_root.clone()); let store_path = project_root.join(".story_kit_store.json"); Self { state: Arc::new(state), store: Arc::new(JsonFileStore::new(store_path).unwrap()), workflow: Arc::new(std::sync::Mutex::new(WorkflowState::default())), agents: Arc::new(AgentPool::new(3001)), } } } pub type OpenApiResult = poem::Result; pub fn bad_request(message: String) -> poem::Error { poem::Error::from_string(message, StatusCode::BAD_REQUEST) }