permission

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package permission is the capability boundary for human-in-the-loop decisions routed through the inbound platform (tool approval, ask_user, etc.).

Index

Constants

View Source
const DefaultTimeout = 10 * time.Minute

DefaultTimeout is the wait limit when Request.Timeout and Capability.DefaultTimeout are both unset.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowDenyMatch

type AllowDenyMatch struct {
	Allow        bool
	Recognized   bool
	UpdatedInput map[string]any
}

AllowDenyMatch is the parsed allow/deny reply.

type AnswerScope

type AnswerScope string
const (
	ScopeAsker  AnswerScope = "asker"
	ScopeAnyone AnswerScope = "anyone"
)

type Broker

type Broker interface {
	Await(context.Context, Request) (Result, error)
}

type Capability

type Capability struct {
	Interactive    bool
	MultiSelect    bool
	DefaultTimeout time.Duration
	AnswerScope    AnswerScope
}

Capability describes how a platform renders and collects permission replies.

type CapabilityRouter

type CapabilityRouter interface {
	PermissionCapabilityFor(platformID string) Capability
}

CapabilityRouter is implemented by platforms that aggregate multiple leaf platforms.

type Capable

type Capable interface {
	PermissionCapability() Capability
}

Capable is implemented by leaf platforms that can render permission requests.

type Kind

type Kind string
const (
	KindAllowDeny Kind = "allow_deny"
	KindQuestion  Kind = "question"
)

type Option

type Option struct {
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

type Outcome

type Outcome string
const (
	OutcomeResolved   Outcome = "resolved"
	OutcomeTimeout    Outcome = "timeout"
	OutcomeNoHuman    Outcome = "no_human"
	OutcomeCancelled  Outcome = "cancelled"
	OutcomeSuperseded Outcome = "superseded"
)

type Question

type Question struct {
	Prompt      string   `json:"prompt"`
	Header      string   `json:"header,omitempty"`
	Options     []Option `json:"options,omitempty"`
	Default     string   `json:"default,omitempty"`
	MultiSelect bool     `json:"multiSelect,omitempty"`
}

type QuestionResult

type QuestionResult struct {
	Text     string `json:"text,omitempty"`
	Selected []int  `json:"selected,omitempty"`
}

type Reply

type Reply struct {
	RequestID string `json:"requestId"`
	UserID    string `json:"userId,omitempty"`
	// Decision is for KindAllowDeny only ("allow"/"deny", or y/n/yes/no).
	Decision     string         `json:"decision,omitempty"`
	Selected     []int          `json:"selected,omitempty"`
	Text         string         `json:"text,omitempty"`
	UpdatedInput map[string]any `json:"updatedInput,omitempty"`
	Cancelled    bool           `json:"cancelled,omitempty"`
}

Reply is the inbound answer to a permission/request.

Field usage by request Kind:

  • KindAllowDeny: Decision ("allow"/"deny", or y/n/yes/no); Text is a CLI fallback when Decision is empty. UpdatedInput carries human-edited tool arguments. Cancelled means the user explicitly declined.
  • KindQuestion: Text and/or Selected only; do not set Decision.

type Request

type Request struct {
	ID       string             `json:"id"`
	Kind     Kind               `json:"kind"`
	Reason   string             `json:"reason,omitempty"`
	ToolCall *agentkit.ToolCall `json:"toolCall,omitempty"`
	Question *Question          `json:"question,omitempty"`
	Timeout  time.Duration      `json:"timeout,omitempty"`
	AskedBy  string             `json:"askedBy,omitempty"`
}

type RequestPayload

type RequestPayload struct {
	Request
	// Conversation is the Loop history/lock key; platforms echo it on card replies
	// so permission answers route back to the turn that created the pending request.
	Conversation string `json:"conversation,omitempty"`
}

RequestPayload is emitted on permission/request.

type Result

type Result struct {
	ID           string          `json:"id,omitempty"`
	Outcome      Outcome         `json:"outcome"`
	Allow        bool            `json:"allow,omitempty"`
	Answer       *QuestionResult `json:"answer,omitempty"`
	UpdatedInput map[string]any  `json:"updatedInput,omitempty"`
	Reason       string          `json:"reason,omitempty"`
	Guidance     string          `json:"guidance,omitempty"`
}

Result is the outcome of Broker.Await. ID is set on permission/resolved events.

func (Result) Resolved

func (r Result) Resolved() bool

Jump to

Keyboard shortcuts

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