interrupt

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionAllowOnce    = "allow_once"
	PermissionAllowAlways  = "allow_always"
	PermissionRejectOnce   = "reject_once"
	PermissionRejectAlways = "reject_always"
)

ACP PermissionOptionKind values.

View Source
const TypeChildWaiting = "child_waiting"

TypeChildWaiting parks a parent spawn_specialist/get_child until the host resumes. The payload is forwarded to the child session; Return is a no-op.

Variables

View Source
var (
	ErrInterruptNotFound = errors.New("interrupt not found")
	ErrInvalidPayload    = errors.New("invalid payload")
)

Functions

func Register

func Register(factory func() Interrupt)

Register adds a factory for an Interrupt type under its TypeName. Call at init for custom interrupts so checkpoints can rehydrate them.

func RegisterDefaults added in v0.2.0

func RegisterDefaults()

RegisterDefaults registers the built-in interrupt types. Safe to call more than once. tacklr.init calls this; New also ensures defaults so checkpoint rehydrate works without importing the root package.

Types

type ChildWaiting added in v0.2.0

type ChildWaiting struct {
	Kind    string `json:"kind"`
	Message string `json:"message,omitempty"`
}

ChildWaiting accepts any resume payload (child HITL forwarded through the parent session).

func (*ChildWaiting) Error added in v0.2.0

func (p *ChildWaiting) Error() string

func (*ChildWaiting) Return added in v0.2.0

func (p *ChildWaiting) Return([]byte) error

func (*ChildWaiting) Serialize added in v0.2.0

func (p *ChildWaiting) Serialize() ([]byte, error)

func (*ChildWaiting) TypeName added in v0.2.0

func (p *ChildWaiting) TypeName() string

func (*ChildWaiting) ValidatePayload added in v0.2.0

func (p *ChildWaiting) ValidatePayload([]byte) error

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.

func Clone

func Clone(intr Interrupt) Interrupt

Clone returns a deep copy via JSON for checkpoint snapshots. Returns nil if the type is unknown or serialization fails (best-effort).

func New

func New(typeName string) (Interrupt, bool)

New returns a fresh Interrupt for a registered type name.

type PayloadInitializer

type PayloadInitializer interface {
	InitFromPayload([]byte) error
}

PayloadInitializer is an optional capability Interrupt types implement to populate themselves from the raw payload provided to Park.

type PayloadValidator

type PayloadValidator interface {
	ValidatePayload([]byte) error
}

PayloadValidator is an optional capability Interrupt types may implement for standalone payload checks. Session Resume calls Return only; types that still need field-presence checks do that inside Return.

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. Checkpointed so a
	// later activity can TakeResolved and see the decision. Serialize omits
	// these so the client park payload stays unresolved.
	SelectedOptionID string `json:"selectedOptionId,omitempty"`
	SelectedKind     string `json:"selectedKind,omitempty"`
	Allowed          bool   `json:"allowed,omitempty"`
}

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 UserChoice struct {
	Title         string `json:"title"`
	Description   string `json:"description"`
	IsRecommended bool   `json:"isRecommended"`
}

type UserSelectionInterrupt

type UserSelectionInterrupt struct {
	Question        string       `json:"question,omitempty"`
	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

type UserSelectionPayload

type UserSelectionPayload struct {
	InterruptId  string `json:"interruptId"`
	SelectionIdx int    `json:"selectionIdx"`
}

Jump to

Keyboard shortcuts

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