Help us shape the future of Go! Take the 2026 Go Developer Survey

permissions

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extension

func Extension(policy *Policy, settings *config.SettingsManager, parent extensions.Context) extensions.Factory

Extension requires an explicit policy; child agents may share their parent policy.

func SandboxMode

func SandboxMode(settings *config.SettingsManager) (sandbox.Mode, error)

SandboxMode is a host constraint, independent of extension enablement.

Types

type Action

type Action string

Action is the ecosystem-standard three-state permission result.

const (
	Allow Action = "allow"
	Deny  Action = "deny"
	Ask   Action = "ask"
)

type Decision

type Decision struct {
	Time       int64  `json:"time"`
	Tool       string `json:"tool"`
	Action     Action `json:"action"`
	Resolved   Action `json:"resolved"`
	Mode       string `json:"mode"`
	Rule       int    `json:"rule,omitempty"`
	Matcher    string `json:"matcher,omitempty"`
	Input      string `json:"input,omitempty"`
	Resolution string `json:"resolution,omitempty"`
}

Decision records the matched policy and its runtime resolution.

type Policy

type Policy struct {
	// Sandbox is selected by native hosts; SDK callers attach native.ToolOptions
	// explicitly or supply their own contained tool operations.
	Sandbox     sandbox.Mode `json:"sandbox,omitempty"`
	Mode        string       `json:"mode,omitempty"`
	AskFallback Action       `json:"askFallback,omitempty"`
	Rules       []Rule       `json:"rules,omitempty"`

	Authorizer func(context.Context, ToolCallInfo) (Action, error) `json:"-"`
	// Guards are hard deny-only constraints: any non-empty reason denies,
	// even in log mode.
	Guards []func(context.Context, ToolCallInfo) string `json:"-"`
	// contains filtered or unexported fields
}

Policy is constructible by SDK embedders and shared with in-process children. Configure fields before attaching; SetMode is the only concurrent mutation API.

func FromSettings

func FromSettings(value map[string]any) (*Policy, error)

func (*Policy) Evaluate

func (policy *Policy) Evaluate(ctx context.Context, info ToolCallInfo) Decision

Evaluate applies the authorizer, deny-only guards, then last-match-wins rules.

func (*Policy) SetMode

func (policy *Policy) SetMode(mode string)

type Rule

type Rule struct {
	Tool    string `json:"tool,omitempty"`
	Command string `json:"command,omitempty"`
	Path    string `json:"path,omitempty"`
	Action  Action `json:"action"`
}

Rule is one ordered permission rule. Empty Tool means "*".

type ToolCallInfo

type ToolCallInfo struct {
	Tool      string
	Args      any
	CWD       string
	SessionID string
}

ToolCallInfo is the low-level SDK authorization input.

Directories

Path Synopsis
Package native attaches filesystem containment to local tool operations.
Package native attaches filesystem containment to local tool operations.

Jump to

Keyboard shortcuts

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