permissions

package
v1.23.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package permissions provides tool permission checking based on configurable Allow/Ask/Deny patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker evaluates tool permissions based on configured patterns

func NewChecker

func NewChecker(cfg *latest.PermissionsConfig) *Checker

NewChecker creates a new permission checker from config

func (*Checker) AllowPatterns added in v1.20.0

func (c *Checker) AllowPatterns() []string

AllowPatterns returns the list of allow patterns.

func (*Checker) AskPatterns added in v1.23.4

func (c *Checker) AskPatterns() []string

AskPatterns returns the list of ask patterns.

func (*Checker) Check

func (c *Checker) Check(toolName string) Decision

Check evaluates the permission for a given tool name without arguments. This is a convenience method that calls CheckWithArgs with nil arguments. Evaluation order: Deny (checked first), then Allow, then Ask (default)

func (*Checker) CheckWithArgs

func (c *Checker) CheckWithArgs(toolName string, args map[string]any) Decision

CheckWithArgs evaluates the permission for a given tool name and its arguments. Evaluation order: Deny (checked first), then Allow, then Ask (explicit), then Ask (default).

The toolName can be a simple name like "shell" or a qualified name like "mcp:github:create_issue".

Patterns support: - Simple tool names: "shell", "read_*" - Argument matching: "shell:cmd=ls*" matches shell tool with cmd argument starting with "ls" - Multiple arguments: "shell:cmd=ls*:cwd=/home/*" matches both conditions - Glob patterns in both tool names and argument values

Returns ForceAsk when an explicit ask pattern matches. ForceAsk means the tool must always be confirmed, even when it would normally be auto-approved (e.g. read-only tools or --yolo mode).

func (*Checker) DenyPatterns added in v1.20.0

func (c *Checker) DenyPatterns() []string

DenyPatterns returns the list of deny patterns.

func (*Checker) IsEmpty

func (c *Checker) IsEmpty() bool

IsEmpty returns true if no permissions are configured

type Decision

type Decision int

Decision represents the permission decision for a tool call

const (
	// Ask means the tool requires user approval (default behavior)
	Ask Decision = iota
	// Allow means the tool is auto-approved without user confirmation
	Allow
	// Deny means the tool is rejected and should not be executed
	Deny
	// ForceAsk means an explicit ask pattern matched; the tool must be
	// confirmed even if it would normally be auto-approved (e.g. read-only).
	ForceAsk
)

func (Decision) String

func (d Decision) String() string

String returns a human-readable representation of the decision

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL