permission

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode string

Mode represents the permission mode for tool execution.

const (
	// ModeInteractive asks the user for each permission request.
	ModeInteractive Mode = "interactive"
	// ModeAutoAllow automatically approves all permission requests.
	ModeAutoAllow Mode = "auto_allow"
	// ModeAutoDeny automatically denies all permission requests.
	ModeAutoDeny Mode = "auto_deny"
)

type Request

type Request struct {
	SessionID   string          `json:"session_id"`
	ToolName    string          `json:"tool_name"`
	Action      string          `json:"action"`
	Description string          `json:"description"`
	Params      json.RawMessage `json:"params"`
}

Request represents a permission request from a tool.

type Response

type Response struct {
	Allowed  bool `json:"allowed"`
	Remember bool `json:"remember"` // true = grant for rest of session
}

Response represents the user's response to a permission request.

type Service

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

Service manages tool permissions for the agent.

func NewService

func NewService(mode Mode, allowedTools []string) *Service

NewService creates a new permission service.

func (*Service) Grant

func (s *Service) Grant(sessionID, toolName, action string)

Grant records a permission grant for the current session.

func (*Service) IsAllowed

func (s *Service) IsAllowed(sessionID, toolName, action string) bool

IsAllowed checks if a tool/action is currently allowed without prompting.

func (*Service) Mode

func (s *Service) Mode() Mode

Mode returns the current permission mode.

func (*Service) Request

func (s *Service) Request(ctx context.Context, req Request) (Response, error)

Request checks if a tool action is allowed. In auto_allow mode, always returns allowed. In auto_deny mode, always returns denied. In interactive mode, checks grants first, then returns pending. The caller (agent loop) handles the actual user interaction.

func (*Service) Revoke

func (s *Service) Revoke(sessionID, toolName, action string)

Revoke removes a permission grant.

func (*Service) SetMode

func (s *Service) SetMode(mode Mode)

SetMode changes the permission mode.

Jump to

Keyboard shortcuts

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