delegation

package
v0.6.0-alpha Latest Latest
Warning

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

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

Documentation

Overview

Package delegation defines credential-free, scoped child execution contracts.

Index

Constants

View Source
const (
	StartMethod   = "child.start"
	ReadMethod    = "child.read"
	CancelMethod  = "child.cancel"
	SteerMethod   = "child.steer"
	ReleaseMethod = "child.lease.release"
)

Variables

This section is empty.

Functions

func Admit

func Admit(ctx context.Context) error

Admit is called after identity persistence, before any runner/provider effects.

func Decode

func Decode(data []byte, target any) error

Decode rejects unknown fields, null options and trailing data at the runner boundary. Nested ExecutionOptions perform their own strict validation.

func ValidID

func ValidID(id string) bool

ValidID accepts an opaque conversation/run/request identifier, not a path.

func WithAdmission

func WithAdmission(ctx context.Context, admit func() error) context.Context

WithAdmission connects durable chat initialization to registry admission.

func WithPrepare

func WithPrepare(ctx context.Context, prepare Prepare) context.Context

Types

type Event

type Event struct {
	Sequence   uint64 `json:"sequence"`
	Kind       string `json:"kind"`
	Text       string `json:"text,omitempty"`
	ToolName   string `json:"toolName,omitempty"`
	ToolCallID string `json:"toolCallId,omitempty"`
	Input      string `json:"input,omitempty"`
	ToolOutput string `json:"toolOutput,omitempty"`
	Success    *bool  `json:"success,omitempty"`
	Error      string `json:"error,omitempty"`
}

type Identity

type Identity struct {
	RunnerID             string `json:"runnerId,omitempty"`
	HostInstanceID       string `json:"hostInstanceId,omitempty"`
	ConversationID       string `json:"conversationId"`
	RunID                string `json:"runId"`
	ParentConversationID string `json:"parentConversationId"`
	ParentRunID          string `json:"parentRunId"`
	ExtensionID          string `json:"extensionId"`
	Profile              string `json:"profile"`
}

type Params

type Params struct {
	RunID       string  `json:"runId"`
	ToolCallID  string  `json:"toolCallId,omitempty"`
	ExtensionID string  `json:"extensionId"`
	Generation  uint64  `json:"generation"`
	Request     Request `json:"request,omitempty"`
	ChildID     string  `json:"childId,omitempty"`
	ChildRunID  string  `json:"childRunId,omitempty"`
	Message     string  `json:"message,omitempty"`
	RequestID   string  `json:"requestId,omitempty"`
	LeaseID     string  `json:"leaseId,omitempty"`
	After       uint64  `json:"after,omitempty"`
}

Params is sent only on the authenticated runner connection.

type Prepare

type Prepare func(context.Context, Request, Preset, Identity) (Run, error)

Prepare validates and freezes configuration before any child is admitted. Run executes the existing persisted chat path, not a second agent loop.

func PrepareFromContext

func PrepareFromContext(ctx context.Context) Prepare

type Preset

type Preset struct {
	Profile
	ExtensionID string `json:"extensionId"`
	Generation  uint64 `json:"generation"`
}

Preset is the runner-resolved snapshot advertised with its environment.

type Profile

type Profile struct {
	Name             string                     `json:"name"`
	Options          *llmtypes.ExecutionOptions `json:"options,omitempty"`
	SystemPromptPath string                     `json:"systemPromptPath,omitempty"`
	SystemPrompt     string                     `json:"systemPrompt,omitempty"`
}

Profile is owned by one extension process, never a daemon profile or Config.

func (Profile) Validate

func (p Profile) Validate() error

type Request

type Request struct {
	ContextMode  string                     `json:"contextMode,omitempty"`
	Resume       string                     `json:"resume,omitempty"`
	RequestID    string                     `json:"requestId"`
	Profile      string                     `json:"profile"`
	Message      string                     `json:"message"`
	Options      *llmtypes.ExecutionOptions `json:"options,omitempty"`
	SystemPrompt string                     `json:"systemPrompt,omitempty"`
	CWD          string                     `json:"cwd,omitempty"`
	LeaseID      string                     `json:"leaseId,omitempty"`
}

Request accepts only an owned child resume target, never an arbitrary source, provider credentials, or an endpoint. Fork always means the live parent.

func (Request) Validate

func (r Request) Validate() error

type Result

type Result struct {
	Identity
	Done      bool    `json:"done"`
	Cancelled bool    `json:"cancelled,omitempty"`
	Error     string  `json:"error,omitempty"`
	Output    string  `json:"output,omitempty"`
	Events    []Event `json:"events,omitempty"`
}

type Run

type Run func(context.Context, func(Event)) error

Prepare validates and freezes configuration before any child is admitted. Run executes the existing persisted chat path, not a second agent loop.

type SteerResult

type SteerResult struct {
	Outcome string `json:"outcome"`
	Reason  string `json:"reason,omitempty"`
}

Jump to

Keyboard shortcuts

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