pawan/tools/
ares_bridge.rs1use super::Tool;
6use crate::{PawanError, Result};
7use async_trait::async_trait;
8use serde_json::Value;
9use std::sync::Arc;
10
11pub struct AresTool {
13 inner: Arc<dyn ares::tools::registry::Tool>,
14}
15
16impl AresTool {
17 pub fn new(tool: Arc<dyn ares::tools::registry::Tool>) -> Self {
18 Self { inner: tool }
19 }
20}
21
22#[async_trait]
23impl Tool for AresTool {
24 fn name(&self) -> &str {
25 self.inner.name()
26 }
27
28 fn description(&self) -> &str {
29 self.inner.description()
30 }
31
32 fn mutating(&self) -> bool {
33 true }
35
36 fn parameters_schema(&self) -> Value {
37 self.inner.parameters_schema()
38 }
39
40 async fn execute(&self, args: Value) -> Result<Value> {
41 self.inner
42 .execute(args)
43 .await
44 .map_err(|e| PawanError::Tool(format!("Ares tool error: {}", e)))
45 }
46}
47
48pub fn bridge_ares_tools(
50 ares_registry: &ares::tools::registry::ToolRegistry,
51 pawan_registry: &mut super::ToolRegistry,
52) -> usize {
53 let ares_defs = ares_registry.get_tool_definitions();
54 let mut count = 0;
55
56 for def in &ares_defs {
57 if let Some(tool) = ares_registry.get(&def.name) {
58 pawan_registry.register(Arc::new(AresTool::new(Arc::clone(tool))));
59 count += 1;
60 }
61 }
62
63 count
64}