feat(gui): add full access auto-approve mode
Some checks failed
Main Branch Build / republish-pr-artifacts (Linux) (push) Has been cancelled
Main Branch Build / republish-pr-artifacts (macOS) (push) Has been cancelled
PR Checks / track-rerun (push) Has been cancelled
PR Checks / prettier-check (push) Has been cancelled
PR Checks / core-checks (push) Has been cancelled
PR Checks / gui-checks (push) Has been cancelled
PR Checks / binary-checks (push) Has been cancelled
PR Checks / vscode-checks (push) Has been cancelled
PR Checks / get-packages-matrix (push) Has been cancelled
PR Checks / vscode-get-test-file-matrix (push) Has been cancelled
PR Checks / vscode-package-extension-linux (push) Has been cancelled
PR Checks / jetbrains-tests (push) Has been cancelled
Submit Gradle Dependency Graph For Dependabot / dependency-submission (push) Has been cancelled
PR Checks / packages-checks (push) Has been cancelled
PR Checks / unknown () (push) Has been cancelled
PR Checks / require-all-checks-to-pass (push) Has been cancelled
Some checks failed
Main Branch Build / republish-pr-artifacts (Linux) (push) Has been cancelled
Main Branch Build / republish-pr-artifacts (macOS) (push) Has been cancelled
PR Checks / track-rerun (push) Has been cancelled
PR Checks / prettier-check (push) Has been cancelled
PR Checks / core-checks (push) Has been cancelled
PR Checks / gui-checks (push) Has been cancelled
PR Checks / binary-checks (push) Has been cancelled
PR Checks / vscode-checks (push) Has been cancelled
PR Checks / get-packages-matrix (push) Has been cancelled
PR Checks / vscode-get-test-file-matrix (push) Has been cancelled
PR Checks / vscode-package-extension-linux (push) Has been cancelled
PR Checks / jetbrains-tests (push) Has been cancelled
Submit Gradle Dependency Graph For Dependabot / dependency-submission (push) Has been cancelled
PR Checks / packages-checks (push) Has been cancelled
PR Checks / unknown () (push) Has been cancelled
PR Checks / require-all-checks-to-pass (push) Has been cancelled
This commit is contained in:
parent
5522c6f44c
commit
b275cafed9
9 changed files with 141 additions and 4 deletions
14
core/core.ts
14
core/core.ts
|
|
@ -1050,7 +1050,15 @@ export class Core {
|
||||||
|
|
||||||
on(
|
on(
|
||||||
"tools/evaluatePolicy",
|
"tools/evaluatePolicy",
|
||||||
async ({ data: { toolName, basePolicy, parsedArgs, processedArgs } }) => {
|
async ({
|
||||||
|
data: {
|
||||||
|
toolName,
|
||||||
|
basePolicy,
|
||||||
|
parsedArgs,
|
||||||
|
processedArgs,
|
||||||
|
fullAccessMode,
|
||||||
|
},
|
||||||
|
}) => {
|
||||||
const { config } = await this.configHandler.loadConfig();
|
const { config } = await this.configHandler.loadConfig();
|
||||||
if (!config) {
|
if (!config) {
|
||||||
throw new Error("Config not loaded");
|
throw new Error("Config not loaded");
|
||||||
|
|
@ -1067,6 +1075,10 @@ export class Core {
|
||||||
displayValue = parsedArgs.command as string;
|
displayValue = parsedArgs.command as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fullAccessMode && basePolicy !== "disabled") {
|
||||||
|
return { policy: "allowedWithoutPermission", displayValue };
|
||||||
|
}
|
||||||
|
|
||||||
if (tool.evaluateToolCallPolicy) {
|
if (tool.evaluateToolCallPolicy) {
|
||||||
const evaluatedPolicy = tool.evaluateToolCallPolicy(
|
const evaluatedPolicy = tool.evaluateToolCallPolicy(
|
||||||
basePolicy,
|
basePolicy,
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
||||||
basePolicy: ToolPolicy;
|
basePolicy: ToolPolicy;
|
||||||
parsedArgs: Record<string, unknown>;
|
parsedArgs: Record<string, unknown>;
|
||||||
processedArgs?: Record<string, unknown>;
|
processedArgs?: Record<string, unknown>;
|
||||||
|
fullAccessMode?: boolean;
|
||||||
},
|
},
|
||||||
{ policy: ToolPolicy; displayValue?: string },
|
{ policy: ToolPolicy; displayValue?: string },
|
||||||
];
|
];
|
||||||
|
|
|
||||||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "continue",
|
"name": "continue",
|
||||||
"version": "1.3.39",
|
"version": "1.3.40",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "continue",
|
"name": "continue",
|
||||||
"version": "1.3.39",
|
"version": "1.3.40",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@continuedev/config-types": "file:../../packages/config-types",
|
"@continuedev/config-types": "file:../../packages/config-types",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import { useAuth } from "../../../context/Auth";
|
||||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||||
import { updateConfig } from "../../../redux/slices/configSlice";
|
import { updateConfig } from "../../../redux/slices/configSlice";
|
||||||
|
import { setFullAccessMode } from "../../../redux/slices/uiSlice";
|
||||||
import { ConfigHeader } from "../components/ConfigHeader";
|
import { ConfigHeader } from "../components/ConfigHeader";
|
||||||
import { ToolPoliciesGroup } from "../components/ToolPoliciesGroup";
|
import { ToolPoliciesGroup } from "../components/ToolPoliciesGroup";
|
||||||
|
|
||||||
|
|
@ -406,6 +407,8 @@ function MCPServerPreview({
|
||||||
|
|
||||||
export function ToolsSection() {
|
export function ToolsSection() {
|
||||||
const availableTools = useAppSelector((state) => state.config.config.tools);
|
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 mode = useAppSelector((store) => store.session.mode);
|
||||||
const servers = useAppSelector(
|
const servers = useAppSelector(
|
||||||
|
|
@ -481,6 +484,24 @@ export function ToolsSection() {
|
||||||
</Alert>
|
</Alert>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div className="mb-4">
|
||||||
|
<Alert type={fullAccessMode ? "warning" : "info"} size="sm">
|
||||||
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<span className="text-2xs italic">
|
||||||
|
{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."}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant={fullAccessMode ? "outline" : "primary"}
|
||||||
|
size="sm"
|
||||||
|
onClick={() => dispatch(setFullAccessMode(!fullAccessMode))}
|
||||||
|
>
|
||||||
|
{fullAccessMode ? "Disable Full Access" : "Enable Full Access"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
<div className="mb-4 space-y-6">
|
<div className="mb-4 space-y-6">
|
||||||
<ToolPoliciesGroup
|
<ToolPoliciesGroup
|
||||||
showIcon={false}
|
showIcon={false}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ type UIState = {
|
||||||
isExploreDialogOpen: boolean;
|
isExploreDialogOpen: boolean;
|
||||||
hasDismissedExploreDialog: boolean;
|
hasDismissedExploreDialog: boolean;
|
||||||
shouldAddFileForEditing: boolean;
|
shouldAddFileForEditing: boolean;
|
||||||
|
fullAccessMode: boolean;
|
||||||
toolSettings: ToolPolicies;
|
toolSettings: ToolPolicies;
|
||||||
toolGroupSettings: ToolGroupPolicies;
|
toolGroupSettings: ToolGroupPolicies;
|
||||||
ruleSettings: RulePolicies;
|
ruleSettings: RulePolicies;
|
||||||
|
|
@ -42,6 +43,7 @@ export const DEFAULT_UI_SLICE: UIState = {
|
||||||
hasDismissedExploreDialog:
|
hasDismissedExploreDialog:
|
||||||
getLocalStorage(LocalStorageKey.HasDismissedExploreDialog) ?? false,
|
getLocalStorage(LocalStorageKey.HasDismissedExploreDialog) ?? false,
|
||||||
shouldAddFileForEditing: false,
|
shouldAddFileForEditing: false,
|
||||||
|
fullAccessMode: false,
|
||||||
ttsActive: false,
|
ttsActive: false,
|
||||||
toolSettings: {},
|
toolSettings: {},
|
||||||
toolGroupSettings: {
|
toolGroupSettings: {
|
||||||
|
|
@ -70,6 +72,9 @@ export const uiSlice = createSlice({
|
||||||
setShowDialog: (state, action: PayloadAction<UIState["showDialog"]>) => {
|
setShowDialog: (state, action: PayloadAction<UIState["showDialog"]>) => {
|
||||||
state.showDialog = action.payload;
|
state.showDialog = action.payload;
|
||||||
},
|
},
|
||||||
|
setFullAccessMode: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.fullAccessMode = action.payload;
|
||||||
|
},
|
||||||
setIsExploreDialogOpen: (
|
setIsExploreDialogOpen: (
|
||||||
state,
|
state,
|
||||||
action: PayloadAction<UIState[LocalStorageKey.IsExploreDialogOpen]>,
|
action: PayloadAction<UIState[LocalStorageKey.IsExploreDialogOpen]>,
|
||||||
|
|
@ -156,6 +161,7 @@ export const {
|
||||||
setOnboardingCard,
|
setOnboardingCard,
|
||||||
setDialogMessage,
|
setDialogMessage,
|
||||||
setShowDialog,
|
setShowDialog,
|
||||||
|
setFullAccessMode,
|
||||||
setIsExploreDialogOpen,
|
setIsExploreDialogOpen,
|
||||||
toggleToolSetting,
|
toggleToolSetting,
|
||||||
setToolPolicy,
|
setToolPolicy,
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ const saveSubsetFilters = [
|
||||||
]),
|
]),
|
||||||
createFilter("config", []),
|
createFilter("config", []),
|
||||||
createFilter("ui", [
|
createFilter("ui", [
|
||||||
|
"fullAccessMode",
|
||||||
"toolSettings",
|
"toolSettings",
|
||||||
"toolGroupSettings",
|
"toolGroupSettings",
|
||||||
"ruleSettings",
|
"ruleSettings",
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,23 @@ async function evaluateToolPolicy(
|
||||||
activeTools: Tool[],
|
activeTools: Tool[],
|
||||||
toolCallState: ToolCallState,
|
toolCallState: ToolCallState,
|
||||||
toolPolicies: ToolPolicies,
|
toolPolicies: ToolPolicies,
|
||||||
|
fullAccessMode: boolean,
|
||||||
): Promise<EvaluatedPolicy> {
|
): Promise<EvaluatedPolicy> {
|
||||||
// allow edit tool calls without permission
|
// allow edit tool calls without permission
|
||||||
if (isEditTool(toolCallState.toolCall.function.name)) {
|
if (isEditTool(toolCallState.toolCall.function.name)) {
|
||||||
return { policy: "allowedWithoutPermission", toolCallState };
|
return { policy: "allowedWithoutPermission", toolCallState };
|
||||||
}
|
}
|
||||||
|
|
||||||
const basePolicy =
|
const resolvedBasePolicy =
|
||||||
toolPolicies[toolCallState.toolCall.function.name] ??
|
toolPolicies[toolCallState.toolCall.function.name] ??
|
||||||
activeTools.find(
|
activeTools.find(
|
||||||
(tool) => tool.function.name === toolCallState.toolCall.function.name,
|
(tool) => tool.function.name === toolCallState.toolCall.function.name,
|
||||||
)?.defaultToolPolicy ??
|
)?.defaultToolPolicy ??
|
||||||
DEFAULT_TOOL_SETTING;
|
DEFAULT_TOOL_SETTING;
|
||||||
|
const basePolicy =
|
||||||
|
fullAccessMode && resolvedBasePolicy !== "disabled"
|
||||||
|
? "allowedWithoutPermission"
|
||||||
|
: resolvedBasePolicy;
|
||||||
|
|
||||||
const toolName = toolCallState.toolCall.function.name;
|
const toolName = toolCallState.toolCall.function.name;
|
||||||
const result = await ideMessenger.request("tools/evaluatePolicy", {
|
const result = await ideMessenger.request("tools/evaluatePolicy", {
|
||||||
|
|
@ -40,6 +45,7 @@ async function evaluateToolPolicy(
|
||||||
basePolicy,
|
basePolicy,
|
||||||
parsedArgs: toolCallState.parsedArgs,
|
parsedArgs: toolCallState.parsedArgs,
|
||||||
processedArgs: toolCallState.processedArgs,
|
processedArgs: toolCallState.processedArgs,
|
||||||
|
fullAccessMode,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Evaluate the policy dynamically
|
// Evaluate the policy dynamically
|
||||||
|
|
@ -77,6 +83,7 @@ export async function evaluateToolPolicies(
|
||||||
activeTools: Tool[],
|
activeTools: Tool[],
|
||||||
generatedToolCalls: ToolCallState[],
|
generatedToolCalls: ToolCallState[],
|
||||||
toolPolicies: ToolPolicies,
|
toolPolicies: ToolPolicies,
|
||||||
|
fullAccessMode: boolean,
|
||||||
): Promise<EvaluatedPolicy[]> {
|
): Promise<EvaluatedPolicy[]> {
|
||||||
// Check if ALL tool calls are auto-approved using dynamic evaluation
|
// Check if ALL tool calls are auto-approved using dynamic evaluation
|
||||||
const policyResults = await Promise.all(
|
const policyResults = await Promise.all(
|
||||||
|
|
@ -86,6 +93,7 @@ export async function evaluateToolPolicies(
|
||||||
activeTools,
|
activeTools,
|
||||||
toolCallState,
|
toolCallState,
|
||||||
toolPolicies,
|
toolPolicies,
|
||||||
|
fullAccessMode,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -315,12 +315,14 @@ export const streamNormalInput = createAsyncThunk<
|
||||||
}
|
}
|
||||||
const generatedCalls3 = selectPendingToolCalls(state3);
|
const generatedCalls3 = selectPendingToolCalls(state3);
|
||||||
const toolPolicies = state3.ui.toolSettings;
|
const toolPolicies = state3.ui.toolSettings;
|
||||||
|
const fullAccessMode = state3.ui.fullAccessMode;
|
||||||
const policies = await evaluateToolPolicies(
|
const policies = await evaluateToolPolicies(
|
||||||
dispatch,
|
dispatch,
|
||||||
extra.ideMessenger,
|
extra.ideMessenger,
|
||||||
activeTools,
|
activeTools,
|
||||||
generatedCalls3,
|
generatedCalls3,
|
||||||
toolPolicies,
|
toolPolicies,
|
||||||
|
fullAccessMode,
|
||||||
);
|
);
|
||||||
const autoApprovedPolicies = policies.filter(
|
const autoApprovedPolicies = policies.filter(
|
||||||
({ policy }) => policy === "allowedWithoutPermission",
|
({ policy }) => policy === "allowedWithoutPermission",
|
||||||
|
|
|
||||||
|
|
@ -1961,6 +1961,7 @@ describe("streamResponseThunk - tool calls", () => {
|
||||||
toolName: terminalName,
|
toolName: terminalName,
|
||||||
basePolicy: "allowedWithoutPermission",
|
basePolicy: "allowedWithoutPermission",
|
||||||
parsedArgs: { command: "echo hello" },
|
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 () => {
|
it("should respect disabled policy", async () => {
|
||||||
const initialState = getRootStateWithClaude();
|
const initialState = getRootStateWithClaude();
|
||||||
initialState.session.history = [
|
initialState.session.history = [
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue