Skip to main content

acosmi/skills/
tools.rs

1//! 统一工具(Unified Tools)业务方法。端口自 `skills/tools.ts`
2//! (declaration-merging → 此处 `impl Client` 块)。
3
4use super::types::{ToolListResponse, ToolView};
5use crate::billing::entitlements::urlencoding;
6use crate::core::client::Client;
7use crate::shared::Result;
8use tokio_util::sync::CancellationToken;
9
10impl Client {
11    /// 获取当前用户租户下的所有工具(Skill 优先 + Plugin 兜底)。对应 TS `listTools`。
12    pub async fn list_tools(&self, signal: Option<CancellationToken>) -> Result<Vec<ToolView>> {
13        let resp: ToolListResponse = self.billing_get("/tools", signal).await?;
14        Ok(resp.skills)
15    }
16
17    /// 获取单个工具详情。对应 TS `getTool`。
18    pub async fn get_tool(
19        &self,
20        tool_id: &str,
21        signal: Option<CancellationToken>,
22    ) -> Result<ToolView> {
23        self.billing_get(&format!("/tools/{}", urlencoding(tool_id)), signal)
24            .await
25    }
26}