feat: use the same permission flow for enable extensions (#2302)
This commit is contained in:
@@ -3,8 +3,7 @@ use console::style;
|
||||
use goose::agents::extension::ToolInfo;
|
||||
use goose::agents::extension_manager::get_parameter_names;
|
||||
use goose::agents::platform_tools::{
|
||||
PLATFORM_ENABLE_EXTENSION_TOOL_NAME, PLATFORM_LIST_RESOURCES_TOOL_NAME,
|
||||
PLATFORM_READ_RESOURCE_TOOL_NAME,
|
||||
PLATFORM_LIST_RESOURCES_TOOL_NAME, PLATFORM_READ_RESOURCE_TOOL_NAME,
|
||||
};
|
||||
use goose::agents::Agent;
|
||||
use goose::agents::{extension::Envs, ExtensionConfig};
|
||||
@@ -1015,8 +1014,7 @@ pub async fn configure_tool_permissions_dialog() -> Result<(), Box<dyn Error>> {
|
||||
.await
|
||||
.into_iter()
|
||||
.filter(|tool| {
|
||||
tool.name != PLATFORM_ENABLE_EXTENSION_TOOL_NAME
|
||||
&& tool.name != PLATFORM_LIST_RESOURCES_TOOL_NAME
|
||||
tool.name != PLATFORM_LIST_RESOURCES_TOOL_NAME
|
||||
&& tool.name != PLATFORM_READ_RESOURCE_TOOL_NAME
|
||||
})
|
||||
.map(|tool| {
|
||||
|
||||
@@ -17,7 +17,6 @@ use completion::GooseCompleter;
|
||||
use etcetera::choose_app_strategy;
|
||||
use etcetera::AppStrategy;
|
||||
use goose::agents::extension::{Envs, ExtensionConfig};
|
||||
use goose::agents::platform_tools::PLATFORM_ENABLE_EXTENSION_TOOL_NAME;
|
||||
use goose::agents::{Agent, SessionConfig};
|
||||
use goose::config::Config;
|
||||
use goose::message::{Message, MessageContent};
|
||||
@@ -623,29 +622,6 @@ impl Session {
|
||||
principal_type: PrincipalType::Tool,
|
||||
permission,
|
||||
},).await;
|
||||
} else if let Some(MessageContent::ExtensionRequest(enable_extension_request)) = message.content.first() {
|
||||
output::hide_thinking();
|
||||
|
||||
let extension_action = if enable_extension_request.tool_name == PLATFORM_ENABLE_EXTENSION_TOOL_NAME {
|
||||
"enable"
|
||||
} else {
|
||||
"disable"
|
||||
};
|
||||
|
||||
let prompt = format!("Goose would like to {} the following extension, do you approve?", extension_action);
|
||||
let confirmed = cliclack::select(prompt)
|
||||
.item(true, "Yes, for this session", format!("{} the extension for this session", extension_action))
|
||||
.item(false, "No", format!("Do not {} the extension", extension_action))
|
||||
.interact()?;
|
||||
let permission = if confirmed {
|
||||
Permission::AllowOnce
|
||||
} else {
|
||||
Permission::DenyOnce
|
||||
};
|
||||
self.agent.handle_confirmation(enable_extension_request.id.clone(), PermissionConfirmation {
|
||||
principal_type: PrincipalType::Extension,
|
||||
permission,
|
||||
},).await;
|
||||
}
|
||||
// otherwise we have a model/tool to render
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user