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

goagentapproval

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package goagentapproval connects goagent approval interruptions to runkit's encrypted, single-lease checkpoint store.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAdapter           = errors.New("invalid goagent approval adapter")
	ErrInvalidPendingCheckpoint = errors.New("invalid pending approval checkpoint")
	ErrInvalidNextCheckpoint    = errors.New("invalid next approval checkpoint")
	ErrCheckpointEncrypt        = errors.New("approval checkpoint encryption failed")
	ErrCheckpointDecrypt        = errors.New("approval checkpoint decryption failed")
	ErrCheckpointDecode         = errors.New("approval checkpoint decoding failed")
	ErrNextCheckpointPersist    = errors.New("next approval checkpoint persistence failed")
	ErrLeaseCompletion          = errors.New("approval checkpoint lease completion failed")
	ErrResumeResultMissing      = errors.New("agent resume returned no result")
)

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter persists interrupted goagent runs and resumes a single leased checkpoint after an authenticated host has recorded approval.

func New

func New(store runkit.CheckpointStore, cipher Cipher, resumer Resumer) (*Adapter, error)

func (*Adapter) ApproveAndResume

func (a *Adapter) ApproveAndResume(ctx context.Context, request ResumeRequest) (*agentcore.RunResult, error)

ApproveAndResume atomically leases a pending checkpoint, resumes it once, and closes the lease. A resumed pause is saved before the old lease is consumed. Any failure after lease acquisition marks the old lease failed, never making it available for automatic replay.

func (*Adapter) Reject

func (a *Adapter) Reject(ctx context.Context, request runkit.ApprovalLeaseRequest) error

Reject records a terminal rejection without decrypting or executing the paused agent state.

func (*Adapter) SavePending

func (a *Adapter) SavePending(ctx context.Context, pending PendingCheckpoint) error

SavePending encrypts and stores an approval interruption. Call it after an agent returns agentcore.ErrApprovalPending and before exposing it to an operator approval queue.

type Cipher

type Cipher interface {
	Encrypt(ctx context.Context, plaintext, aad []byte) ([]byte, error)
	Decrypt(ctx context.Context, ciphertext, aad []byte) ([]byte, error)
}

Cipher is implemented by the host's encryption boundary. It owns key selection, encryption, and decryption; aad authenticates checkpoint identity while runkit receives only opaque bytes.

type NextCheckpoint

type NextCheckpoint struct {
	ID        string
	ExpiresAt time.Time
}

NextCheckpoint is reserved before a resume. It is consumed only if that resume interrupts again, allowing the adapter to persist the new checkpoint before it consumes the old lease.

type PendingCheckpoint

type PendingCheckpoint struct {
	ID             string
	TenantID       string
	DefinitionHash string
	ExpiresAt      time.Time
	Checkpoint     agentcore.RunCheckpoint
}

PendingCheckpoint supplies host-owned identity and retention metadata for a newly interrupted run. The adapter encrypts Checkpoint before storage.

type ResumeRequest

type ResumeRequest struct {
	Approval    runkit.ApprovalLeaseRequest
	Resolutions []agentcore.ToolApprovalResolution
	Next        NextCheckpoint
}

ResumeRequest contains a previously authorized lease request, exact tool decisions, and a host-generated destination for a possible next pause.

type Resumer

type Resumer interface {
	ResumeDetailed(ctx context.Context, checkpoint agentcore.RunCheckpoint, resolutions []agentcore.ToolApprovalResolution) (*agentcore.RunResult, error)
}

Resumer is satisfied by agentcore.Agent. Keeping this interface narrow lets hosts test approval handling without a live model or tool runtime.

Jump to

Keyboard shortcuts

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