diff --git a/core/core.ts b/core/core.ts index daba8ffaa..aba458327 100644 --- a/core/core.ts +++ b/core/core.ts @@ -1050,7 +1050,15 @@ export class Core { on( "tools/evaluatePolicy", - async ({ data: { toolName, basePolicy, parsedArgs, processedArgs } }) => { + async ({ + data: { + toolName, + basePolicy, + parsedArgs, + processedArgs, + fullAccessMode, + }, + }) => { const { config } = await this.configHandler.loadConfig(); if (!config) { throw new Error("Config not loaded"); @@ -1067,6 +1075,10 @@ export class Core { displayValue = parsedArgs.command as string; } + if (fullAccessMode && basePolicy !== "disabled") { + return { policy: "allowedWithoutPermission", displayValue }; + } + if (tool.evaluateToolCallPolicy) { const evaluatedPolicy = tool.evaluateToolCallPolicy( basePolicy, diff --git a/core/protocol/core.ts b/core/protocol/core.ts index da752c27b..cf37c7082 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -315,6 +315,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { basePolicy: ToolPolicy; parsedArgs: Record; processedArgs?: Record; + fullAccessMode?: boolean; }, { policy: ToolPolicy; displayValue?: string }, ]; diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 6fb35c7dd..167945c4b 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.3.39", + "version": "1.3.40", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.3.39", + "version": "1.3.40", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "file:../../packages/config-types", diff --git a/gui/src/pages/config/sections/ToolsSection.tsx b/gui/src/pages/config/sections/ToolsSection.tsx index 7a07aae52..2fec9b95a 100644 --- a/gui/src/pages/config/sections/ToolsSection.tsx +++ b/gui/src/pages/config/sections/ToolsSection.tsx @@ -30,6 +30,7 @@ import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { updateConfig } from "../../../redux/slices/configSlice"; +import { setFullAccessMode } from "../../../redux/slices/uiSlice"; import { ConfigHeader } from "../components/ConfigHeader"; import { ToolPoliciesGroup } from "../components/ToolPoliciesGroup"; @@ -406,6 +407,8 @@ function MCPServerPreview({ export function ToolsSection() { const availableTools = useAppSelector((state) => state.config.config.tools); + const fullAccessMode = useAppSelector((state) => state.ui.fullAccessMode); + const dispatch = useAppDispatch(); const mode = useAppSelector((store) => store.session.mode); const servers = useAppSelector( @@ -481,6 +484,24 @@ export function ToolsSection() { )} +
+ +
+ + {fullAccessMode + ? "Full Access is enabled. Continue will auto-approve all non-excluded tools, including terminal commands, without asking again." + : "Full Access is disabled. Automatic tools can still be escalated back to Ask First by internal safety checks."} + + +
+
+
) => { state.showDialog = action.payload; }, + setFullAccessMode: (state, action: PayloadAction) => { + state.fullAccessMode = action.payload; + }, setIsExploreDialogOpen: ( state, action: PayloadAction, @@ -156,6 +161,7 @@ export const { setOnboardingCard, setDialogMessage, setShowDialog, + setFullAccessMode, setIsExploreDialogOpen, toggleToolSetting, setToolPolicy, diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index 0f91b0597..a9267bd7d 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -53,6 +53,7 @@ const saveSubsetFilters = [ ]), createFilter("config", []), createFilter("ui", [ + "fullAccessMode", "toolSettings", "toolGroupSettings", "ruleSettings", diff --git a/gui/src/redux/thunks/evaluateToolPolicies.ts b/gui/src/redux/thunks/evaluateToolPolicies.ts index 7874edabd..9e6d041fd 100644 --- a/gui/src/redux/thunks/evaluateToolPolicies.ts +++ b/gui/src/redux/thunks/evaluateToolPolicies.ts @@ -21,18 +21,23 @@ async function evaluateToolPolicy( activeTools: Tool[], toolCallState: ToolCallState, toolPolicies: ToolPolicies, + fullAccessMode: boolean, ): Promise { // allow edit tool calls without permission if (isEditTool(toolCallState.toolCall.function.name)) { return { policy: "allowedWithoutPermission", toolCallState }; } - const basePolicy = + const resolvedBasePolicy = toolPolicies[toolCallState.toolCall.function.name] ?? activeTools.find( (tool) => tool.function.name === toolCallState.toolCall.function.name, )?.defaultToolPolicy ?? DEFAULT_TOOL_SETTING; + const basePolicy = + fullAccessMode && resolvedBasePolicy !== "disabled" + ? "allowedWithoutPermission" + : resolvedBasePolicy; const toolName = toolCallState.toolCall.function.name; const result = await ideMessenger.request("tools/evaluatePolicy", { @@ -40,6 +45,7 @@ async function evaluateToolPolicy( basePolicy, parsedArgs: toolCallState.parsedArgs, processedArgs: toolCallState.processedArgs, + fullAccessMode, }); // Evaluate the policy dynamically @@ -77,6 +83,7 @@ export async function evaluateToolPolicies( activeTools: Tool[], generatedToolCalls: ToolCallState[], toolPolicies: ToolPolicies, + fullAccessMode: boolean, ): Promise { // Check if ALL tool calls are auto-approved using dynamic evaluation const policyResults = await Promise.all( @@ -86,6 +93,7 @@ export async function evaluateToolPolicies( activeTools, toolCallState, toolPolicies, + fullAccessMode, ), ), ); diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 23429852d..a94979612 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -315,12 +315,14 @@ export const streamNormalInput = createAsyncThunk< } const generatedCalls3 = selectPendingToolCalls(state3); const toolPolicies = state3.ui.toolSettings; + const fullAccessMode = state3.ui.fullAccessMode; const policies = await evaluateToolPolicies( dispatch, extra.ideMessenger, activeTools, generatedCalls3, toolPolicies, + fullAccessMode, ); const autoApprovedPolicies = policies.filter( ({ policy }) => policy === "allowedWithoutPermission", diff --git a/gui/src/redux/thunks/streamResponse_toolCalls.test.ts b/gui/src/redux/thunks/streamResponse_toolCalls.test.ts index 590d6f0fa..8c2673b71 100644 --- a/gui/src/redux/thunks/streamResponse_toolCalls.test.ts +++ b/gui/src/redux/thunks/streamResponse_toolCalls.test.ts @@ -1961,6 +1961,7 @@ describe("streamResponseThunk - tool calls", () => { toolName: terminalName, basePolicy: "allowedWithoutPermission", parsedArgs: { command: "echo hello" }, + fullAccessMode: false, }), ); @@ -1971,6 +1972,91 @@ describe("streamResponseThunk - tool calls", () => { ); }); + it("should force auto-approval in full access mode", async () => { + const initialState = getRootStateWithClaude(); + initialState.session.history = [ + { + message: { id: "1", role: "user", content: "Run npm install" }, + contextItems: [], + }, + ]; + initialState.ui.fullAccessMode = true; + initialState.ui.toolSettings = { + [terminalName]: "allowedWithPermission", + }; + initialState.config.config.tools = [terminalTool]; + const mockStore = createMockStore(initialState); + const mockIdeMessenger = mockStore.mockIdeMessenger; + const requestSpy = vi.spyOn(mockIdeMessenger, "request"); + + mockIdeMessenger.responseHandlers["tools/evaluatePolicy"] = async ( + data, + ) => { + expect(data.fullAccessMode).toBe(true); + expect(data.basePolicy).toBe("allowedWithoutPermission"); + return { policy: "allowedWithoutPermission" }; + }; + mockIdeMessenger.responseHandlers["tools/call"] = async () => { + return { contextItems: [] }; + }; + mockIdeMessenger.responses["llm/compileChat"] = { + compiledChatMessages: [{ role: "user", content: "Run npm install" }], + didPrune: false, + contextPercentage: 0.5, + }; + + async function* mockStreamWithInstall(): AsyncGenerator< + AssistantChatMessage[], + PromptLog + > { + const toolId = `tool-install-${Date.now()}`; + yield [ + { + role: "assistant", + content: "", + toolCalls: [ + { + id: toolId, + type: "function", + function: { + name: terminalName, + arguments: JSON.stringify({ command: "npm install" }), + }, + }, + ], + }, + ]; + return { + prompt: "Run npm install", + completion: "", + modelProvider: "anthropic", + modelTitle: "Claude 3.5 Sonnet", + }; + } + + mockIdeMessenger.llmStreamChat = vi + .fn() + .mockReturnValue(mockStreamWithInstall()); + + await mockStore.dispatch( + streamResponseThunk({ + editorState: mockEditorState, + modifiers: mockModifiers, + }) as any, + ); + + expect(requestSpy).toHaveBeenCalledWith( + "tools/call", + expect.objectContaining({ + toolCall: expect.objectContaining({ + function: expect.objectContaining({ + name: terminalName, + }), + }), + }), + ); + }); + it("should respect disabled policy", async () => { const initialState = getRootStateWithClaude(); initialState.session.history = [