mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Fix #5300: Implement auto-approval for access_mcp_resource tool
- Add auto-approval logic to Task.ask() method - Check autoApprovalEnabled setting and specific tool permissions - Implement shouldAutoApprove() method to handle different ask types - Fix missing auto-approval for use_mcp_server ask type used by both MCP tools - Ensure access_mcp_resource respects alwaysAllowMcp setting like use_mcp_tool
This commit is contained in:
parent
3a8ba27615
commit
3e478df7e3
1 changed files with 29 additions and 0 deletions
|
|
@ -431,6 +431,16 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
throw new Error(`[RooCode#ask] task ${this.taskId}.${this.instanceId} aborted`)
|
||||
}
|
||||
|
||||
// Check for auto-approval before proceeding with user interaction
|
||||
const state = await this.providerRef.deref()?.getState()
|
||||
if (state?.autoApprovalEnabled) {
|
||||
const shouldAutoApprove = this.shouldAutoApprove(type, state)
|
||||
if (shouldAutoApprove) {
|
||||
// Return immediate approval without user interaction
|
||||
return { response: "yesButtonClicked" }
|
||||
}
|
||||
}
|
||||
|
||||
let askTs: number
|
||||
|
||||
if (partial !== undefined) {
|
||||
|
|
@ -524,6 +534,25 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a request should be auto-approved based on the ask type and current settings
|
||||
*/
|
||||
private shouldAutoApprove(type: ClineAsk, state: any): boolean {
|
||||
switch (type) {
|
||||
case "use_mcp_server":
|
||||
return state.alwaysAllowMcp === true
|
||||
case "command":
|
||||
return state.alwaysAllowExecute === true
|
||||
case "browser_action_launch":
|
||||
return state.alwaysAllowBrowser === true
|
||||
case "tool":
|
||||
// For general tool requests, check if read-only operations are always allowed
|
||||
return state.alwaysAllowReadOnly === true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async handleWebviewAskResponse(askResponse: ClineAskResponse, text?: string, images?: string[]) {
|
||||
this.askResponse = askResponse
|
||||
this.askResponseText = text
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue