Elffuss BraidHub

kikocis/continue public

main · 3.1 KiBSourceRawPermalink

Tool Permissions System

The tool permissions system allows you to control which tools the AI can use and how it can use them. There are three permission levels:

Default Policies

The system comes with sensible default policies:

How It Works

1. Tool Filtering (Exclude Policy)

Tools with "exclude" permission are filtered out before being sent to the AI model. This means the AI won't even know these tools exist.

2. Permission Checking (Ask Policy)

When the AI tries to use a tool with "ask" permission, the system will:

  1. Display a permission request in the UI
  2. Wait for user approval (y/n)
  3. Execute the tool if approved, or return an error if denied

3. Automatic Execution (Allow Policy)

Tools with "allow" permission are executed immediately without user intervention.

Architecture

Core Components

Data Flow

  1. Tool Loading: getAllTools() in streamChatResponse.ts filters out excluded tools
  2. Tool Execution: Before executing each tool call, permissions are checked
  3. User Interaction: For "ask" policies, UI displays permission request
  4. Execution: Tool is executed or denied based on permission result

UI Integration

The permission system integrates with the existing chat UI:

Future Enhancements

The system is designed to be extensible for future features like:

Example Usage

// Check permission for a tool call
const result = checkToolPermission({
  name: "writeFile",
  arguments: { path: "/important.txt", content: "data" },
});

if (result.permission === "ask") {
  // Request user permission
}

// Filter excluded tools
const allowedTools = filterExcludedTools([
  "readFile",
  "dangerousTool",
  "writeFile",
]);