mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Rename alwaysAllow to autoApprove
This commit is contained in:
parent
fc82e95beb
commit
2b32940ca2
8 changed files with 35 additions and 37 deletions
|
|
@ -2489,14 +2489,12 @@ export class Cline {
|
|||
arguments: mcp_arguments,
|
||||
} satisfies ClineAskUseMcpServer)
|
||||
|
||||
const isToolAlwaysAllowed = this.providerRef
|
||||
const isToolAutoApproved = this.providerRef
|
||||
.deref()
|
||||
?.mcpHub?.connections?.find((conn) => conn.server.name === server_name)
|
||||
?.server.tools?.find((tool) => tool.name === tool_name)?.alwaysAllow
|
||||
?.server.tools?.find((tool) => tool.name === tool_name)?.autoApprove
|
||||
|
||||
// console.log("isToolAlwaysAllowed", server_name, tool_name, isToolAlwaysAllowed)
|
||||
|
||||
if (this.shouldAutoApproveTool(block.name) && isToolAlwaysAllowed) {
|
||||
if (this.shouldAutoApproveTool(block.name) && isToolAutoApproved) {
|
||||
this.removeLastPartialMessageIfExistsWithType("ask", "use_mcp_server")
|
||||
await this.say("use_mcp_server", completeMessage, undefined, false)
|
||||
this.consecutiveAutoApprovedRequestsCount++
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ npm run build
|
|||
|
||||
5. Install the MCP Server by adding the MCP server configuration to the settings file located at '${await mcpHub.getMcpSettingsFilePath()}'. The settings file may have other MCP servers already configured, so you would read it first and then add your new server to the existing \`mcpServers\` object.
|
||||
|
||||
IMPORTANT: Regardless of what else you see in the MCP settings file, you must default any new MCP servers you create to disabled=false and alwaysAllow=[].
|
||||
IMPORTANT: Regardless of what else you see in the MCP settings file, you must default any new MCP servers you create to disabled=false and autoApprove=[].
|
||||
|
||||
\`\`\`json
|
||||
{
|
||||
|
|
|
|||
|
|
@ -616,9 +616,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
}
|
||||
break
|
||||
}
|
||||
case "toggleToolAlwaysAllow": {
|
||||
case "toggleToolAutoApprove": {
|
||||
try {
|
||||
await this.mcpHub?.toggleToolAlwaysAllow(message.serverName!, message.toolName!, message.alwaysAllow!)
|
||||
await this.mcpHub?.toggleToolAutoApprove(message.serverName!, message.toolName!, message.autoApprove!)
|
||||
} catch (error) {
|
||||
console.error(`Failed to toggle auto-approve for tool ${message.toolName}:`, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ export type McpConnection = {
|
|||
transport: StdioClientTransport
|
||||
}
|
||||
|
||||
const AlwaysAllowSchema = z.array(z.string()).default([])
|
||||
const AutoApproveSchema = z.array(z.string()).default([])
|
||||
|
||||
// StdioServerParameters
|
||||
const StdioConfigSchema = z.object({
|
||||
command: z.string(),
|
||||
args: z.array(z.string()).optional(),
|
||||
env: z.record(z.string()).optional(),
|
||||
alwaysAllow: AlwaysAllowSchema.optional(),
|
||||
autoApprove: AutoApproveSchema.optional(),
|
||||
disabled: z.boolean().optional(),
|
||||
})
|
||||
|
||||
|
|
@ -283,16 +283,16 @@ export class McpHub {
|
|||
.find((conn) => conn.server.name === serverName)
|
||||
?.client.request({ method: "tools/list" }, ListToolsResultSchema)
|
||||
|
||||
// Get always allow settings
|
||||
// Get autoApprove settings
|
||||
const settingsPath = await this.getMcpSettingsFilePath()
|
||||
const content = await fs.readFile(settingsPath, "utf-8")
|
||||
const config = JSON.parse(content)
|
||||
const alwaysAllowConfig = config.mcpServers[serverName]?.alwaysAllow || []
|
||||
const autoApproveConfig = config.mcpServers[serverName]?.autoApprove || []
|
||||
|
||||
// Mark tools as always allowed based on settings
|
||||
const tools = (response?.tools || []).map((tool) => ({
|
||||
...tool,
|
||||
alwaysAllow: alwaysAllowConfig.includes(tool.name),
|
||||
autoApprove: autoApproveConfig.includes(tool.name),
|
||||
}))
|
||||
|
||||
// console.log(`[MCP] Fetched tools for ${serverName}:`, tools)
|
||||
|
|
@ -496,8 +496,8 @@ export class McpHub {
|
|||
}
|
||||
|
||||
// Ensure required fields exist
|
||||
if (!serverConfig.alwaysAllow) {
|
||||
serverConfig.alwaysAllow = []
|
||||
if (!serverConfig.autoApprove) {
|
||||
serverConfig.autoApprove = []
|
||||
}
|
||||
|
||||
config.mcpServers[serverName] = serverConfig
|
||||
|
|
@ -582,26 +582,26 @@ export class McpHub {
|
|||
)
|
||||
}
|
||||
|
||||
async toggleToolAlwaysAllow(serverName: string, toolName: string, shouldAllow: boolean): Promise<void> {
|
||||
async toggleToolAutoApprove(serverName: string, toolName: string, shouldAllow: boolean): Promise<void> {
|
||||
try {
|
||||
const settingsPath = await this.getMcpSettingsFilePath()
|
||||
const content = await fs.readFile(settingsPath, "utf-8")
|
||||
const config = JSON.parse(content)
|
||||
|
||||
// Initialize alwaysAllow if it doesn't exist
|
||||
if (!config.mcpServers[serverName].alwaysAllow) {
|
||||
config.mcpServers[serverName].alwaysAllow = []
|
||||
// Initialize autoApprove if it doesn't exist
|
||||
if (!config.mcpServers[serverName].autoApprove) {
|
||||
config.mcpServers[serverName].autoApprove = []
|
||||
}
|
||||
|
||||
const alwaysAllow = config.mcpServers[serverName].alwaysAllow
|
||||
const toolIndex = alwaysAllow.indexOf(toolName)
|
||||
const autoApprove = config.mcpServers[serverName].autoApprove
|
||||
const toolIndex = autoApprove.indexOf(toolName)
|
||||
|
||||
if (shouldAllow && toolIndex === -1) {
|
||||
// Add tool to always allow list
|
||||
alwaysAllow.push(toolName)
|
||||
// Add tool to autoApprove list
|
||||
autoApprove.push(toolName)
|
||||
} else if (!shouldAllow && toolIndex !== -1) {
|
||||
// Remove tool from always allow list
|
||||
alwaysAllow.splice(toolIndex, 1)
|
||||
// Remove tool from autoApprove list
|
||||
autoApprove.splice(toolIndex, 1)
|
||||
}
|
||||
|
||||
// Write updated config back to file
|
||||
|
|
@ -614,8 +614,8 @@ export class McpHub {
|
|||
await this.notifyWebviewOfServerChanges()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to update always allow settings:", error)
|
||||
vscode.window.showErrorMessage("Failed to update always allow settings")
|
||||
console.error("Failed to update autoApprove settings:", error)
|
||||
vscode.window.showErrorMessage("Failed to update autoApprove settings")
|
||||
throw error // Re-throw to ensure the error is properly handled
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export interface WebviewMessage {
|
|||
| "taskCompletionViewChanges"
|
||||
| "openAdvisorModelSettings"
|
||||
| "requestVsCodeLmModels"
|
||||
| "toggleToolAlwaysAllow"
|
||||
| "toggleToolAutoApprove"
|
||||
| "toggleMcpServer"
|
||||
// | "relaunchChromeDebugMode"
|
||||
text?: string
|
||||
|
|
@ -52,7 +52,7 @@ export interface WebviewMessage {
|
|||
// For toggleToolAutoApprove
|
||||
serverName?: string
|
||||
toolName?: string
|
||||
alwaysAllow?: boolean
|
||||
autoApprove?: boolean
|
||||
}
|
||||
|
||||
export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export type McpTool = {
|
|||
name: string
|
||||
description?: string
|
||||
inputSchema?: object
|
||||
alwaysAllow?: boolean
|
||||
autoApprove?: boolean
|
||||
}
|
||||
|
||||
export type McpResource = {
|
||||
|
|
|
|||
|
|
@ -718,8 +718,8 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi
|
|||
name: useMcpServer.toolName || "",
|
||||
description:
|
||||
server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.description || "",
|
||||
alwaysAllow:
|
||||
server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.alwaysAllow ||
|
||||
autoApprove:
|
||||
server?.tools?.find((tool) => tool.name === useMcpServer.toolName)?.autoApprove ||
|
||||
false,
|
||||
}}
|
||||
serverName={useMcpServer.serverName}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ type McpToolRowProps = {
|
|||
const McpToolRow = ({ tool, serverName }: McpToolRowProps) => {
|
||||
const { autoApprovalSettings } = useExtensionState()
|
||||
|
||||
const handleAlwaysAllowChange = () => {
|
||||
const handleAutoApproveChange = () => {
|
||||
if (!serverName) return
|
||||
|
||||
vscode.postMessage({
|
||||
type: "toggleToolAlwaysAllow",
|
||||
type: "toggleToolAutoApprove",
|
||||
serverName,
|
||||
toolName: tool.name,
|
||||
alwaysAllow: !tool.alwaysAllow,
|
||||
autoApprove: !tool.autoApprove,
|
||||
})
|
||||
}
|
||||
return (
|
||||
|
|
@ -36,8 +36,8 @@ const McpToolRow = ({ tool, serverName }: McpToolRowProps) => {
|
|||
<span style={{ fontWeight: 500 }}>{tool.name}</span>
|
||||
</div>
|
||||
{serverName && autoApprovalSettings.enabled && autoApprovalSettings.actions.useMcp && (
|
||||
<VSCodeCheckbox checked={tool.alwaysAllow} onChange={handleAlwaysAllowChange} data-tool={tool.name}>
|
||||
Always allow
|
||||
<VSCodeCheckbox checked={tool.autoApprove} onChange={handleAutoApproveChange} data-tool={tool.name}>
|
||||
Auto-approve
|
||||
</VSCodeCheckbox>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue