feat(service): register project_tools in chat service, add AppStorage::read method

This commit is contained in:
ZhenYi 2026-04-20 19:32:29 +08:00
parent b23c6a03c3
commit 33a4a5c6c9
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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<u8>, 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))
}
}