delegate

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelegateDefinition

func DelegateDefinition(presets *PresetRegistry) tools.Definition

DelegateDefinition returns the tool definition without requiring a live config. presets is optional — when provided, the preset enum is included in the schema.

Types

type DelegateConfig

type DelegateConfig struct {
	Stream        providers.StreamFunc
	Registry      *tools.Registry
	Model         ai.Model
	System        string
	Emit          func(agent.LoopEvent) // optional event emitter for observability
	Presets       *PresetRegistry       // loaded delegate presets (nil = no presets)
	Hooks         *hooks.HookSet        // inherited by delegates (nil = no hooks)
	ToolLifecycle *agent.ToolLifecycle
	SessionRunner SessionRunner // runs delegate work through persistent agent sessions

	// Configurable limits (zero = use defaults).
	MaxConcurrency int           // max parallel delegate goroutines
	DefaultTimeout time.Duration // default delegate wall-clock timeout (0 = 15m)
}

DelegateConfig holds the dependencies needed to spawn delegate loops.

type DelegateFinished

type DelegateFinished struct {
	TaskID   string        `json:"taskId"`
	Duration time.Duration `json:"duration"`
	Error    string        `json:"error,omitempty"`
}

DelegateFinished is emitted when a delegate task completes.

func (DelegateFinished) Kind

func (DelegateFinished) Kind() string

type DelegatePreset

type DelegatePreset struct {
	Name        string        // unique identifier
	Description string        // human-readable description
	System      string        // markdown body = system prompt for the delegate
	Tools       []string      // nil = all tools; empty slice = no tools
	HasTools    bool          // true when tools is explicitly set (even if empty)
	Timeout     time.Duration // wall-clock timeout override; 0 = use global default
	Model       string        // empty = inherit parent model
	FilePath    string        // absolute path to the source .md file
	Source      string        // "project", "agent", "common", or "builtin"
}

DelegatePreset defines a reusable delegate configuration loaded from a markdown file.

func LoadDelegatePresets

func LoadDelegatePresets(cfg LoadDelegatePresetsConfig) []DelegatePreset

LoadDelegatePresets discovers delegate presets in increasing priority order: STELLA_HOME -> agent root -> user root -> project root.

type DelegateStarted

type DelegateStarted struct {
	TaskID string `json:"taskId"`
	Preset string `json:"preset,omitempty"`
}

DelegateStarted is emitted when a delegate task begins execution.

func (DelegateStarted) Kind

func (DelegateStarted) Kind() string

type DelegateTool

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

DelegateTool spawns child loops for bounded subtasks.

func NewDelegateTool

func NewDelegateTool(cfg DelegateConfig) *DelegateTool

NewDelegateTool creates a delegate tool with the given configuration.

func (*DelegateTool) Definition

func (t *DelegateTool) Definition() tools.Definition

func (*DelegateTool) Execute

func (t *DelegateTool) Execute(ctx context.Context, args map[string]any) (string, error)

type LoadDelegatePresetsConfig

type LoadDelegatePresetsConfig struct {
	StellaHome  string // stella home dir (e.g. ~/.stella)
	AgentRoot   string // agent root dir (e.g. ~/.stella/agents/{agentID})
	UserRoot    string // shared user-data root, mounted as /user (e.g. ~/.stella/users/{userID}/data)
	ProjectRoot string // optional project root for local/project-attached runs
}

LoadDelegatePresetsConfig configures the delegate preset discovery paths.

type PresetRegistry

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

PresetRegistry holds loaded delegate presets with O(1) lookup.

func NewPresetRegistry

func NewPresetRegistry(presets []DelegatePreset) *PresetRegistry

NewPresetRegistry creates a registry from a slice of presets.

func (*PresetRegistry) All

func (r *PresetRegistry) All() []DelegatePreset

All returns all loaded presets.

func (*PresetRegistry) Lookup

func (r *PresetRegistry) Lookup(name string) (DelegatePreset, bool)

Lookup returns a preset by name and whether it exists.

func (*PresetRegistry) Names

func (r *PresetRegistry) Names() []string

Names returns all available preset names in load order.

type SessionRunRequest

type SessionRunRequest struct {
	SessionID     string
	Task          string
	Model         string
	System        string
	ExcludedTools []string
	Timeout       time.Duration
	ProjectID     string
}

SessionRunRequest describes a single persisted delegate turn.

type SessionRunResult

type SessionRunResult struct {
	SessionID string
	Output    string
	Complete  bool
}

SessionRunResult is the output from a persisted delegate session.

type SessionRunner

type SessionRunner interface {
	RunDelegateSession(context.Context, SessionRunRequest) (SessionRunResult, error)
}

SessionRunner runs delegate work through the owning agent pool so child transcripts are persisted and resumable like normal sessions.

Jump to

Keyboard shortcuts

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