Documentation
¶
Index ¶
- Constants
- Variables
- func Register(factory func() Interrupt)
- type Interrupt
- type PayloadInitializer
- type PayloadValidator
- type PermissionOption
- type ToolPermissionInterrupt
- func (p *ToolPermissionInterrupt) Error() string
- func (p *ToolPermissionInterrupt) InitFromPayload(payload []byte) error
- func (p *ToolPermissionInterrupt) Return(payload []byte) error
- func (p *ToolPermissionInterrupt) Serialize() ([]byte, error)
- func (p *ToolPermissionInterrupt) TypeName() string
- func (p *ToolPermissionInterrupt) ValidatePayload(payload []byte) error
- type ToolPermissionPayload
- type UserChoice
- type UserSelectionInterrupt
- func (c *UserSelectionInterrupt) Error() string
- func (c *UserSelectionInterrupt) InitFromPayload(payload []byte) error
- func (c *UserSelectionInterrupt) Return(payload []byte) error
- func (c *UserSelectionInterrupt) Serialize() ([]byte, error)
- func (c *UserSelectionInterrupt) TypeName() string
- func (c *UserSelectionInterrupt) ValidatePayload(payload []byte) error
- type UserSelectionPayload
Constants ¶
const ( PermissionAllowOnce = "allow_once" PermissionAllowAlways = "allow_always" PermissionRejectOnce = "reject_once" PermissionRejectAlways = "reject_always" )
ACP PermissionOptionKind values.
Variables ¶
var ( ErrInterruptNotFound = errors.New("interrupt not found") ErrInvalidPayload = errors.New("invalid payload") )
Functions ¶
Types ¶
type Interrupt ¶
type Interrupt interface {
// TypeName returns a stable, unique name for this interrupt type. It is
// used as the JSON discriminator when persisting interrupts to session
// storage and as the lookup key in the interrupt registry.
TypeName() string
// Serialize the interrupt to a byte slice for transmission.
Serialize() ([]byte, error)
// Return the interrupt to the agent workflow with a serialized
// payload of the interrupt result.
Return([]byte) error
// Error makes Interrupt compatible with the error interface.
Error() string
}
Interrupt represents a pending interrupt in an agent workflow requesting the user for additional input or approval. Implementations must also satisfy the error interface so they can be returned from tool handlers and detected via errors.As.
type PayloadInitializer ¶
PayloadInitializer is an optional capability Interrupt types implement to populate themselves from the raw payload provided to RaiseInterrupt.
type PayloadValidator ¶
PayloadValidator is an optional capability for Interrupt types that want to pre-validate the consumer's response payload before it is passed to Return(). Implementations should check field presence, types, and bounds without mutating the Interrupt's internal state (that happens in Return). Detected via type assertion in ReturnInterrupt.
type PermissionOption ¶
type PermissionOption struct {
OptionID string `json:"optionId"`
Name string `json:"name"`
Kind string `json:"kind"`
}
PermissionOption is a single choice offered when a tool requires user approval. Field names match ACP session/request_permission options.
func DefaultPermissionOptions ¶
func DefaultPermissionOptions() []PermissionOption
DefaultPermissionOptions are the standard ACP permission choices.
type ToolPermissionInterrupt ¶
type ToolPermissionInterrupt struct {
ToolName string `json:"toolName,omitempty"`
Title string `json:"title,omitempty"` // human-readable invocation label
Options []PermissionOption `json:"options"`
// Set by Return after the consumer selects an option.
SelectedOptionID string `json:"-"`
SelectedKind string `json:"-"`
Allowed bool `json:"-"`
}
ToolPermissionInterrupt asks the user to approve or reject a tool call.
func (*ToolPermissionInterrupt) Error ¶
func (p *ToolPermissionInterrupt) Error() string
func (*ToolPermissionInterrupt) InitFromPayload ¶
func (p *ToolPermissionInterrupt) InitFromPayload(payload []byte) error
func (*ToolPermissionInterrupt) Return ¶
func (p *ToolPermissionInterrupt) Return(payload []byte) error
func (*ToolPermissionInterrupt) Serialize ¶
func (p *ToolPermissionInterrupt) Serialize() ([]byte, error)
func (*ToolPermissionInterrupt) TypeName ¶
func (p *ToolPermissionInterrupt) TypeName() string
func (*ToolPermissionInterrupt) ValidatePayload ¶
func (p *ToolPermissionInterrupt) ValidatePayload(payload []byte) error
type ToolPermissionPayload ¶
type ToolPermissionPayload struct {
InterruptId string `json:"interruptId,omitempty"`
OptionID string `json:"optionId"`
}
ToolPermissionPayload is the consumer resolution for a tool permission interrupt.
type UserChoice ¶
type UserSelectionInterrupt ¶
type UserSelectionInterrupt struct {
Options []UserChoice `json:"options"`
ConfirmedChoice *UserChoice
}
func (*UserSelectionInterrupt) Error ¶
func (c *UserSelectionInterrupt) Error() string
func (*UserSelectionInterrupt) InitFromPayload ¶
func (c *UserSelectionInterrupt) InitFromPayload(payload []byte) error
func (*UserSelectionInterrupt) Return ¶
func (c *UserSelectionInterrupt) Return(payload []byte) error
func (*UserSelectionInterrupt) Serialize ¶
func (c *UserSelectionInterrupt) Serialize() ([]byte, error)
func (*UserSelectionInterrupt) TypeName ¶
func (c *UserSelectionInterrupt) TypeName() string
func (*UserSelectionInterrupt) ValidatePayload ¶
func (c *UserSelectionInterrupt) ValidatePayload(payload []byte) error