Ask separately for confirmation (#6949)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ use goose::config::ExtensionEntry;
|
||||
use goose::conversation::Conversation;
|
||||
use goose::dictation::download_manager::{DownloadProgress, DownloadStatus};
|
||||
use goose::model::ModelConfig;
|
||||
use goose::permission::permission_confirmation::PrincipalType;
|
||||
use goose::permission::permission_confirmation::{Permission, PrincipalType};
|
||||
use goose::providers::base::{ConfigKey, ModelInfo, ProviderMetadata, ProviderType};
|
||||
use goose::session::{Session, SessionInsights, SessionType, SystemInfo};
|
||||
use rmcp::model::{
|
||||
@@ -498,6 +498,7 @@ derive_utoipa!(Icon as IconSchema);
|
||||
ToolAnnotationsSchema,
|
||||
ToolInfo,
|
||||
PermissionLevel,
|
||||
Permission,
|
||||
PrincipalType,
|
||||
ModelInfo,
|
||||
ModelConfig,
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct ConfirmToolActionRequest {
|
||||
id: String,
|
||||
#[serde(default = "default_principal_type")]
|
||||
principal_type: PrincipalType,
|
||||
action: String,
|
||||
action: Permission,
|
||||
session_id: String,
|
||||
}
|
||||
|
||||
@@ -37,19 +37,13 @@ pub async fn confirm_tool_action(
|
||||
Json(request): Json<ConfirmToolActionRequest>,
|
||||
) -> Result<Json<Value>, ErrorResponse> {
|
||||
let agent = state.get_agent_for_route(request.session_id).await?;
|
||||
let permission = match request.action.as_str() {
|
||||
"always_allow" => Permission::AlwaysAllow,
|
||||
"allow_once" => Permission::AllowOnce,
|
||||
"deny" => Permission::DenyOnce,
|
||||
_ => Permission::DenyOnce,
|
||||
};
|
||||
|
||||
agent
|
||||
.handle_confirmation(
|
||||
request.id.clone(),
|
||||
PermissionConfirmation {
|
||||
principal_type: request.principal_type,
|
||||
permission,
|
||||
permission: request.action,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
@@ -91,7 +85,7 @@ mod tests {
|
||||
serde_json::to_string(&ConfirmToolActionRequest {
|
||||
id: "test-id".to_string(),
|
||||
principal_type: PrincipalType::Tool,
|
||||
action: "allow_once".to_string(),
|
||||
action: Permission::AllowOnce,
|
||||
session_id: "test-session".to_string(),
|
||||
})
|
||||
.unwrap(),
|
||||
|
||||
Reference in New Issue
Block a user