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

permission

package
v0.0.0-...-62a010e Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 7 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 Handler

type Handler func(ctx context.Context, req PermissionRequest) bool

Handler 是宿主注入的权限委托:把权限请求交给外部策略 / UI 决策。

返回 true 表示允许,false 表示拒绝;ctx 用于取消等待。 为 nil 时回退到「阻塞等待人工 Grant / Deny」的交互式流程(如 TUI)。

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(ctx context.Context, opts CreatePermissionRequest) bool
	AutoApproveSession(sessionID string)
}

func NewPermissionService

func NewPermissionService(handler Handler) Service

NewPermissionService 创建权限服务;handler 为宿主注入的委托(可为 nil)。

Jump to

Keyboard shortcuts

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