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
- func EffectiveTimeout(req Request, cap Capability) time.Duration
- func MarshalReply(reply Reply) json.RawMessage
- func UnrecognizedAllowDenyReason(reply Reply) string
- type AllowDenyMatch
- type AnswerScope
- type Broker
- type Capability
- type CapabilityRouter
- type Capable
- type Kind
- type Option
- type Outcome
- type Question
- type QuestionResult
- type Reply
- type Request
- type RequestPayload
- type Result
Constants ¶
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 ¶
func EffectiveTimeout ¶
func EffectiveTimeout(req Request, cap Capability) time.Duration
EffectiveTimeout resolves the wait limit for an interactive permission request.
func MarshalReply ¶
func MarshalReply(reply Reply) json.RawMessage
func UnrecognizedAllowDenyReason ¶
UnrecognizedAllowDenyReason formats a reason for an unrecognized allow/deny reply.
Types ¶
type AllowDenyMatch ¶
AllowDenyMatch is the parsed allow/deny reply.
func MatchAllowDeny ¶
func MatchAllowDeny(reply Reply) AllowDenyMatch
MatchAllowDeny parses a KindAllowDeny reply. Decision takes precedence; Text is a CLI fallback when Decision is empty.
type AnswerScope ¶
type AnswerScope string
const ( ScopeAsker AnswerScope = "asker" ScopeAnyone AnswerScope = "anyone" )
type Capability ¶
type Capability struct {
Interactive bool
MultiSelect bool
DefaultTimeout time.Duration
AnswerScope AnswerScope
}
Capability describes how a platform renders and collects permission replies.
func CapabilityFrom ¶
func CapabilityFrom(ctx context.Context) Capability
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 QuestionResult ¶
type QuestionResult struct {
Text string `json:"text,omitempty"`
Selected []int `json:"selected,omitempty"`
}
func MatchReply ¶
func MatchReply(reply Reply, q Question) QuestionResult
MatchReply resolves a KindQuestion reply against a question. Uses Selected and Text only; Decision is ignored.
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.
func DecodeReply ¶
func DecodeReply(raw json.RawMessage) (Reply, error)
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
}
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.