diff --git a/crates/app/cli/src/agent_manager.rs b/crates/app/cli/src/agent_manager.rs new file mode 100644 index 0000000..5770a0a --- /dev/null +++ b/crates/app/cli/src/agent_manager.rs @@ -0,0 +1,58 @@ +use std::sync::Arc; +use tokio::sync::Mutex; +use crate::state::AppState; +use llm_core::LlmProvider; + +/// Manages the lifecycle and state of the agent +pub struct AgentManager { + client: Arc, + state: Arc>, +} + +impl AgentManager { + /// Create a new AgentManager + pub fn new(client: Arc, state: Arc>) -> Self { + Self { client, state } + } + + /// Get a reference to the LLM client + pub fn client(&self) -> &Arc { + &self.client + } + + /// Get a reference to the shared state + pub fn state(&self) -> &Arc> { + &self.state + } +} + +#[cfg(test)] +mod tests { + use super::*; + use llm_core::{LlmProvider, ChatMessage, ChatOptions, Tool, ChunkStream}; + use async_trait::async_trait; + + struct MockProvider; + #[async_trait] + impl LlmProvider for MockProvider { + fn name(&self) -> &str { "mock" } + fn model(&self) -> &str { "mock" } + async fn chat_stream( + &self, + _messages: &[ChatMessage], + _options: &ChatOptions, + _tools: Option<&[Tool]>, + ) -> Result { + unimplemented!() + } + } + + #[tokio::test] + async fn test_agent_manager_creation() { + let client = Arc::new(MockProvider); + let state = Arc::new(Mutex::new(AppState::new())); + let manager = AgentManager::new(client.clone(), state.clone()); + + assert_eq!(manager.client().name(), "mock"); + } +} diff --git a/crates/app/cli/src/main.rs b/crates/app/cli/src/main.rs index 9a19883..aeff06a 100644 --- a/crates/app/cli/src/main.rs +++ b/crates/app/cli/src/main.rs @@ -2,6 +2,7 @@ mod commands; mod messages; mod engine; mod state; +mod agent_manager; use clap::{Parser, ValueEnum}; use color_eyre::eyre::{Result, eyre};