diff --git a/libs/service/lib.rs b/libs/service/lib.rs index e82cda1..178fc24 100644 --- a/libs/service/lib.rs +++ b/libs/service/lib.rs @@ -231,6 +231,7 @@ impl AppService { let mut registry = ToolRegistry::new(); git_tools::register_all(&mut registry); file_tools::register_all(&mut registry); + project_tools::register_all(&mut registry); Some(Arc::new( ChatService::new(client).with_tool_registry(registry), )) @@ -289,6 +290,7 @@ impl AppService { let room = RoomService::new( db.clone(), cache.clone(), + config.clone(), message_producer.clone(), room_manager, redis_url, @@ -362,6 +364,7 @@ pub mod git; pub mod git_tools; pub mod issue; pub mod project; +pub mod project_tools; pub mod pull_request; pub mod search; pub mod skill; diff --git a/libs/service/storage.rs b/libs/service/storage.rs index 214f915..197e1bf 100644 --- a/libs/service/storage.rs +++ b/libs/service/storage.rs @@ -57,4 +57,14 @@ impl AppStorage { } Ok(()) } + + /// Read a file by key and return (bytes, content_type). + pub async fn read(&self, key: &str) -> anyhow::Result<(Vec, String)> { + let path = self.base_path.join(key); + let data = tokio::fs::read(&path).await?; + let content_type = mime_guess2::from_path(&path) + .first_or_octet_stream() + .to_string(); + Ok((data, content_type)) + } }