diff --git a/src/bridge/effect_adapter.rs b/src/bridge/effect_adapter.rs index 70ea33e1..a1dd4eea 100644 --- a/src/bridge/effect_adapter.rs +++ b/src/bridge/effect_adapter.rs @@ -326,13 +326,27 @@ impl EffectExecutor for EffectBridgeAdapter { ApprovalRequirement::UnlessAutoApproved => { let is_approved = self.auto_approved.read().await.contains(lookup_name); if !is_approved { - return Err(EngineError::LeaseDenied { - reason: format!( - "Tool '{}' requires approval. \ - Use a read-only tool instead, or ask the user to approve this action.", - action_name - ), - }); + // In v2, credential-backed HTTP calls are auto-approved. + // The user authorized by storing the credential — the v1 + // interactive approval flow doesn't exist in v2. + let has_credential_backing = lookup_name == "http" + && self + .tools + .credential_registry() + .is_some_and(|reg| { + crate::tools::builtin::extract_host_from_params(¶meters) + .is_some_and(|host| reg.has_credentials_for_host(&host)) + }); + + if !has_credential_backing { + return Err(EngineError::LeaseDenied { + reason: format!( + "Tool '{}' requires approval. \ + Use a read-only tool instead, or ask the user to approve this action.", + action_name + ), + }); + } } } ApprovalRequirement::Never => {} diff --git a/src/tools/builtin/http.rs b/src/tools/builtin/http.rs index 2f2a08f0..fd9e72cd 100644 --- a/src/tools/builtin/http.rs +++ b/src/tools/builtin/http.rs @@ -366,7 +366,8 @@ fn parse_save_to_param(save_to: Option<&serde_json::Value>) -> Result Option { +/// Extract the host from an HTTP tool's params (for credential registry lookup). +pub fn extract_host_from_params(params: &serde_json::Value) -> Option { params .get("url") .and_then(|u| u.as_str()) diff --git a/src/tools/builtin/mod.rs b/src/tools/builtin/mod.rs index d196b12c..4a990acd 100644 --- a/src/tools/builtin/mod.rs +++ b/src/tools/builtin/mod.rs @@ -23,7 +23,7 @@ pub use extension_tools::{ ToolRemoveTool, ToolSearchTool, ToolUpgradeTool, }; pub use file::{ApplyPatchTool, ListDirTool, ReadFileTool, WriteFileTool}; -pub use http::HttpTool; +pub use http::{HttpTool, extract_host_from_params}; pub use job::{ CancelJobTool, CreateJobTool, JobEventsTool, JobPromptTool, JobStatusTool, ListJobsTool, PromptQueue, SchedulerSlot,