mirror of
https://github.com/aljazceru/goose.git
synced 2026-02-11 17:44:24 +01:00
fix: filter out the enable extension tool in the ui as it should always ask for permission (#2186)
This commit is contained in:
@@ -32,6 +32,7 @@ use mcp_core::{
|
||||
prompt::Prompt, protocol::GetPromptResult, tool::Tool, Content, ToolError, ToolResult,
|
||||
};
|
||||
|
||||
use super::platform_tools;
|
||||
use super::tool_execution::{
|
||||
ExtensionInstallResult, ToolFuture, CHAT_MODE_TOOL_SKIPPED_RESPONSE, DECLINED_RESPONSE,
|
||||
};
|
||||
@@ -272,10 +273,22 @@ impl Agent {
|
||||
|
||||
pub async fn list_tools(&self) -> Vec<Tool> {
|
||||
let extension_manager = self.extension_manager.lock().await;
|
||||
extension_manager
|
||||
let mut prefixed_tools = extension_manager
|
||||
.get_prefixed_tools()
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_default();
|
||||
|
||||
// Add platform tools
|
||||
prefixed_tools.push(platform_tools::search_available_extensions_tool());
|
||||
prefixed_tools.push(platform_tools::enable_extension_tool());
|
||||
|
||||
// Add resource tools if supported
|
||||
if extension_manager.supports_resources() {
|
||||
prefixed_tools.push(platform_tools::read_resource_tool());
|
||||
prefixed_tools.push(platform_tools::list_resources_tool());
|
||||
}
|
||||
|
||||
prefixed_tools
|
||||
}
|
||||
|
||||
pub async fn remove_extension(&mut self, name: &str) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::agents::platform_tools;
|
||||
use crate::message::{Message, MessageContent, ToolRequest};
|
||||
use crate::providers::base::{Provider, ProviderUsage};
|
||||
use crate::providers::errors::ProviderError;
|
||||
@@ -20,19 +18,8 @@ impl Agent {
|
||||
pub(crate) async fn prepare_tools_and_prompt(
|
||||
&self,
|
||||
) -> anyhow::Result<(Vec<Tool>, Vec<Tool>, String)> {
|
||||
let extension_manager = self.extension_manager.lock().await;
|
||||
// Get tools from extension manager
|
||||
let mut tools = extension_manager.get_prefixed_tools().await?;
|
||||
|
||||
// Add resource tools if supported
|
||||
if extension_manager.supports_resources() {
|
||||
tools.push(platform_tools::read_resource_tool());
|
||||
tools.push(platform_tools::list_resources_tool());
|
||||
}
|
||||
|
||||
// Add platform tools
|
||||
tools.push(platform_tools::search_available_extensions_tool());
|
||||
tools.push(platform_tools::enable_extension_tool());
|
||||
let mut tools = self.list_tools().await;
|
||||
|
||||
// Add frontend tools
|
||||
for frontend_tool in self.frontend_tools.values() {
|
||||
@@ -40,6 +27,7 @@ impl Agent {
|
||||
}
|
||||
|
||||
// Prepare system prompt
|
||||
let extension_manager = self.extension_manager.lock().await;
|
||||
let extensions_info = extension_manager.get_extensions_info().await;
|
||||
let mut system_prompt = self
|
||||
.prompt_manager
|
||||
|
||||
@@ -32,7 +32,10 @@ export default function PermissionModal({ extensionName, onClose }: PermissionMo
|
||||
if (response.error) {
|
||||
console.error('Failed to get tools');
|
||||
} else {
|
||||
setTools(response.data || []);
|
||||
const filteredTools = (response.data || []).filter(
|
||||
(tool) => tool.name !== 'platform__enable_extension'
|
||||
);
|
||||
setTools(filteredTools);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching tools:', err);
|
||||
|
||||
Reference in New Issue
Block a user