Skip to main content

codetether_agent/tool/
alias.rs

1//! Compatibility aliases for renamed tools.
2
3use std::sync::Arc;
4
5use anyhow::Result;
6use async_trait::async_trait;
7use serde_json::Value;
8
9use super::{Tool, ToolResult};
10
11pub struct AliasTool {
12    id: String,
13    name: String,
14    inner: Arc<dyn Tool>,
15}
16
17impl AliasTool {
18    pub fn new(id: impl Into<String>, inner: Arc<dyn Tool>) -> Self {
19        Self {
20            id: id.into(),
21            name: inner.name().to_string(),
22            inner,
23        }
24    }
25}
26
27#[async_trait]
28impl Tool for AliasTool {
29    fn id(&self) -> &str {
30        &self.id
31    }
32
33    fn name(&self) -> &str {
34        &self.name
35    }
36
37    fn description(&self) -> &str {
38        self.inner.description()
39    }
40
41    fn parameters(&self) -> Value {
42        self.inner.parameters()
43    }
44
45    async fn execute(&self, args: Value) -> Result<ToolResult> {
46        self.inner.execute(args).await
47    }
48}