Documentation
¶
Overview ¶
Package permissions implements the opt-in tool permission policy: a set of allow/ask/deny rules matched on a tool call's name and one primary argument (a shell command, a path, or a URL host). It is a declarative guardrail, not a security boundary; containment stays with --sandbox and containers.
The policy is pure: it matches calls and returns decisions. Answering an "ask" is the caller's job (a terminal prompt, an ACP request_permission, or a headless fallback), which keeps this package free of I/O.
Index ¶
Constants ¶
const ( SourceRule = "rule" SourceDefault = "default" SourceUser = "user" SourceSession = "session" SourceNonInteractive = "non_interactive" )
Sources for a decision's Result.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Answer ¶
type Answer struct {
Decision Decision // allow or deny
Always bool // allow this tool and argument for the rest of the run
Reason string // deny reason shown to the model
Channel string // terminal, acp, or "" for the permission event
}
Answer is a person's (or the non-interactive fallback's) answer to an ask.
type Call ¶
type Call struct {
Tool string
Command string // bash / start_process / command tool argv joined
Paths []string // file tool paths (relative to the working directory)
Host string // web_fetch URL host (lowercased, no port)
}
Call is one tool call to evaluate. The fields hold the call's primary argument(s) by family; a rule only reads the field its matcher names.
type Policy ¶
type Policy struct {
Default Decision
NonInteractive Decision
// contains filtered or unexported fields
}
Policy is a compiled permission policy. A nil *Policy enforces nothing.
func New ¶
func New(cfg config.Permissions) (*Policy, error)
New compiles cfg into a policy. It returns nil when cfg has no rules and no settings, so a config without a permissions key enforces nothing. Errors name the rule index, like config validation.
func (*Policy) Rules ¶
func (p *Policy) Rules() []config.PermissionRule
Rules returns the configured rules (patterns are config data, not secrets).
type Request ¶
type Request struct {
Tool string
ToolCallID string
Rule int
Argument string // the primary argument, already secret-redacted
Subagent string
}
Request describes an ask the caller must answer.