permission

package
v0.246.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorPermissionDenied = errors.New("permission denied")

Functions

This section is empty.

Types

type CreatePermissionRequest

type CreatePermissionRequest struct {
	SessionID   string `json:"session_id"`
	ToolName    string `json:"tool_name"`
	Description string `json:"description"`
	Action      string `json:"action"`
	Params      any    `json:"params"`
	Path        string `json:"path"`
}

type PermissionRequest

type PermissionRequest struct {
	ID          string `json:"id"`
	SessionID   string `json:"session_id"`
	ToolName    string `json:"tool_name"`
	Description string `json:"description"`
	Action      string `json:"action"`
	Params      any    `json:"params"`
	Path        string `json:"path"`
}

type Service

type Service interface {
	pubsub.Suscriber[PermissionRequest]
	GrantPersistant(permission PermissionRequest)
	Grant(permission PermissionRequest)
	Deny(permission PermissionRequest)
	Request(opts CreatePermissionRequest) bool
	AutoApproveSession(sessionID string)
	RemoveAutoApproveSession(sessionID string)
	SetGlobalAutoApprove(enabled bool)
	// RegisterSessionHandler installs a custom approval function for a specific session.
	// When set, this handler is called instead of the TUI dialog for that session.
	// The handler receives the full CreatePermissionRequest and returns true to approve.
	RegisterSessionHandler(sessionID string, handler func(req CreatePermissionRequest) bool)
	// UnregisterSessionHandler removes the custom handler for a session.
	UnregisterSessionHandler(sessionID string)
}

func NewPermissionService

func NewPermissionService() Service

Jump to

Keyboard shortcuts

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