agent

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentDefinition

func AgentDefinition(presets *PresetRegistry) tools.Definition

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

Types

type AgentConfig

type AgentConfig struct {
	Providers     providers.ProviderGetter
	Registry      *tools.Registry
	Model         ai.Model
	APIKey        string
	BaseURL       string
	System        string
	Emit          func(agent.LoopEvent) // optional event emitter for observability
	Presets       *PresetRegistry       // loaded agent presets (nil = no presets)
	Hooks         *hooks.HookSet        // inherited by subagents (nil = no hooks)
	ToolLifecycle *agent.ToolLifecycle

	// Configurable limits (zero = use defaults).
	MaxTasks       int // max tasks per invocation
	MaxConcurrency int // max parallel subagent goroutines
	MaxResultChars int // max runes in result output
}

AgentConfig holds the dependencies needed to spawn subagent loops.

type AgentPreset

type AgentPreset struct {
	Name        string        // unique identifier
	Description string        // human-readable description
	System      string        // markdown body = system prompt for the subagent
	Tools       []string      // nil = all tools; empty slice = no tools
	HasTools    bool          // true when tools is explicitly set (even if empty)
	MaxTurns    int           // 0 = use global default
	Timeout     time.Duration // 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"
}

AgentPreset defines a reusable subagent configuration loaded from a markdown file.

func LoadAgentPresets

func LoadAgentPresets(cfg LoadAgentPresetsConfig) []AgentPreset

LoadAgentPresets discovers agent presets from multiple directories. Priority order: cwd/.agents/agents/ > workspace/agents/ > ~/.agents/agents/ > builtin

type AgentTool

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

AgentTool spawns child agent loops for bounded subtasks.

func NewAgentTool

func NewAgentTool(cfg AgentConfig) *AgentTool

NewAgentTool creates an agent tool with the given configuration.

func (*AgentTool) Definition

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

func (*AgentTool) Execute

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

type LoadAgentPresetsConfig

type LoadAgentPresetsConfig struct {
	Workspace        string // agent workspace dir (e.g. ~/.anna/workspaces/{agentID})
	Cwd              string // working directory
	BuiltinSkillsDir string // pre-extracted builtin skills directory (caller ensures extraction)
}

LoadAgentPresetsConfig configures the agent preset discovery paths.

type PresetRegistry

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

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

func NewPresetRegistry

func NewPresetRegistry(presets []AgentPreset) *PresetRegistry

NewPresetRegistry creates a registry from a slice of presets.

func (*PresetRegistry) All

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

All returns all loaded presets.

func (*PresetRegistry) Lookup

func (r *PresetRegistry) Lookup(name string) (AgentPreset, 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 SubAgentFinished

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

SubAgentFinished is emitted when a subagent task completes.

func (SubAgentFinished) Kind

func (SubAgentFinished) Kind() string

type SubAgentStarted

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

SubAgentStarted is emitted when a subagent task begins execution.

func (SubAgentStarted) Kind

func (SubAgentStarted) Kind() string

Jump to

Keyboard shortcuts

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