feat: add permission field to the list tools response (#2080)

This commit is contained in:
Yingjie He
2025-04-08 09:47:29 -07:00
committed by GitHub
parent 76e2686c74
commit 318f419861
9 changed files with 152 additions and 17 deletions
+10 -2
View File
@@ -9,6 +9,7 @@ use utoipa::ToSchema;
use crate::config;
use crate::config::extensions::name_to_key;
use crate::config::permission::PermissionLevel;
/// Errors from Extension operation
#[derive(Error, Debug)]
@@ -277,19 +278,26 @@ impl ExtensionInfo {
}
/// Information about the tool used for building prompts
#[derive(Clone, Debug, Serialize)]
#[derive(Clone, Debug, Serialize, ToSchema)]
pub struct ToolInfo {
name: String,
description: String,
parameters: Vec<String>,
permission: Option<PermissionLevel>,
}
impl ToolInfo {
pub fn new(name: &str, description: &str, parameters: Vec<String>) -> Self {
pub fn new(
name: &str,
description: &str,
parameters: Vec<String>,
permission: Option<PermissionLevel>,
) -> Self {
Self {
name: name.to_string(),
description: description.to_string(),
parameters,
permission,
}
}
}
+8 -1
View File
@@ -289,7 +289,14 @@ impl Agent for ReferenceAgent {
let tools = capabilities.get_prefixed_tools().await?;
let tools_info = tools
.into_iter()
.map(|tool| ToolInfo::new(&tool.name, &tool.description, get_parameter_names(&tool)))
.map(|tool| {
ToolInfo::new(
&tool.name,
&tool.description,
get_parameter_names(&tool),
None,
)
})
.collect();
let plan_prompt = capabilities.get_planning_prompt(tools_info).await;
+8 -1
View File
@@ -489,7 +489,14 @@ impl Agent for SummarizeAgent {
let tools = capabilities.get_prefixed_tools().await?;
let tools_info = tools
.into_iter()
.map(|tool| ToolInfo::new(&tool.name, &tool.description, get_parameter_names(&tool)))
.map(|tool| {
ToolInfo::new(
&tool.name,
&tool.description,
get_parameter_names(&tool),
None,
)
})
.collect();
let plan_prompt = capabilities.get_planning_prompt(tools_info).await;
+8 -1
View File
@@ -774,7 +774,14 @@ impl Agent for TruncateAgent {
let tools = capabilities.get_prefixed_tools().await?;
let tools_info = tools
.into_iter()
.map(|tool| ToolInfo::new(&tool.name, &tool.description, get_parameter_names(&tool)))
.map(|tool| {
ToolInfo::new(
&tool.name,
&tool.description,
get_parameter_names(&tool),
None,
)
})
.collect();
let plan_prompt = capabilities.get_planning_prompt(tools_info).await;