registry

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package registry provides multi-agent management for OmniAgent.

Index

Constants

This section is empty.

Variables

View Source
var ErrAgentExists = errors.New("agent already exists")

ErrAgentExists is returned when trying to create an agent that already exists.

View Source
var ErrAgentNotFound = errors.New("agent not found")

ErrAgentNotFound is returned when an agent is not found.

Functions

func DefaultAgentFactory

func DefaultAgentFactory(cfg *AgentConfig) (*agent.Agent, error)

DefaultAgentFactory creates an agent using the standard agent.New function.

Types

type AgentConfig

type AgentConfig struct {
	// ID is the unique identifier for the agent (used as model name).
	ID string `json:"id" yaml:"id"`

	// Name is the human-readable display name.
	Name string `json:"name" yaml:"name"`

	// Description provides additional context about the agent's purpose.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Provider is the LLM provider (e.g., "anthropic", "openai").
	Provider string `json:"provider" yaml:"provider"`

	// Model is the LLM model to use (e.g., "claude-sonnet-4-20250514").
	Model string `json:"model" yaml:"model"`

	// APIKey is the API key for the provider (optional, can use env var).
	APIKey string `json:"api_key,omitempty" yaml:"api_key,omitempty"` //nolint:gosec // G101: API key intentionally stored

	// BaseURL is an optional custom base URL for the provider.
	BaseURL string `json:"base_url,omitempty" yaml:"base_url,omitempty"`

	// Temperature controls randomness (0.0-2.0).
	Temperature float64 `json:"temperature,omitempty" yaml:"temperature,omitempty"`

	// MaxTokens limits the response length.
	MaxTokens int `json:"max_tokens,omitempty" yaml:"max_tokens,omitempty"`

	// SystemPrompt is the system message for the agent.
	SystemPrompt string `json:"system_prompt,omitempty" yaml:"system_prompt,omitempty"`

	// AllowedTools limits which tools this agent can use (empty = all).
	AllowedTools []string `json:"allowed_tools,omitempty" yaml:"allowed_tools,omitempty"`

	// DeniedTools excludes specific tools from this agent.
	DeniedTools []string `json:"denied_tools,omitempty" yaml:"denied_tools,omitempty"`

	// Enabled determines if the agent is active. Defaults to true.
	Enabled *bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`

	// CreatedAt is when the agent was created.
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`

	// UpdatedAt is when the agent was last modified.
	UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
}

AgentConfig defines configuration for a single agent.

func (*AgentConfig) Clone

func (c *AgentConfig) Clone() *AgentConfig

Clone creates a deep copy of the config.

func (*AgentConfig) IsEnabled

func (c *AgentConfig) IsEnabled() bool

IsEnabled returns whether the agent is enabled. Defaults to true if Enabled is nil.

func (*AgentConfig) Merge

func (c *AgentConfig) Merge(other *AgentConfig)

Merge applies non-zero values from other to this config.

type AgentFactory

type AgentFactory func(cfg *AgentConfig) (*agent.Agent, error)

AgentFactory creates an agent from a config. This allows customization of agent creation (e.g., adding tools, skills).

type Registry

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

Registry manages multiple agent instances.

func New

func New(cfg RegistryConfig) *Registry

New creates a new agent registry.

func (*Registry) Clone

func (r *Registry) Clone(ctx context.Context, srcID, newID, newName string) error

Clone duplicates an existing agent with a new ID and name.

func (*Registry) Close

func (r *Registry) Close() error

Close closes all agents.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of agents.

func (*Registry) Create

func (r *Registry) Create(ctx context.Context, cfg *AgentConfig) error

Create adds a new agent to the registry.

func (*Registry) Default

func (r *Registry) Default() (*agent.Agent, error)

Default returns the default agent.

func (*Registry) Delete

func (r *Registry) Delete(ctx context.Context, id string) error

Delete removes an agent from the registry.

func (*Registry) Get

func (r *Registry) Get(id string) (*agent.Agent, error)

Get retrieves an agent by ID. Returns ErrAgentNotFound if the agent doesn't exist.

func (*Registry) GetByModel

func (r *Registry) GetByModel(modelName string) (*agent.Agent, error)

GetByModel retrieves an agent by model name. Supports exact ID match, case-insensitive name match, and "omniagent" default.

func (*Registry) GetConfig

func (r *Registry) GetConfig(id string) (*AgentConfig, error)

GetConfig retrieves an agent's config by ID.

func (*Registry) List

func (r *Registry) List() []*AgentConfig

List returns all agent configs.

func (*Registry) ListEnabled

func (r *Registry) ListEnabled() []*AgentConfig

ListEnabled returns configs for enabled agents only.

func (*Registry) Load

func (r *Registry) Load(ctx context.Context) error

Load loads all agents from the store.

func (*Registry) Reload

func (r *Registry) Reload(ctx context.Context, id string) error

Reload recreates an agent from its current config. Use this to apply config changes to a running agent.

func (*Registry) Update

func (r *Registry) Update(ctx context.Context, id string, updates *AgentConfig) error

Update modifies an existing agent's config. Note: This does not recreate the agent, only updates the stored config. Call Reload to apply changes to the running agent.

type RegistryConfig

type RegistryConfig struct {
	// Store is the persistent storage for agent configs.
	Store *Store

	// Defaults provides fallback values for new agents.
	Defaults *AgentConfig

	// Factory creates agents from configs. If nil, uses DefaultAgentFactory.
	Factory AgentFactory

	// Logger for registry operations.
	Logger *slog.Logger
}

RegistryConfig configures the registry.

type Store

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

Store manages persistent agent configuration storage.

func NewStore

func NewStore(config StoreConfig) *Store

NewStore creates a new agent config store.

func (*Store) ClearCache

func (s *Store) ClearCache()

ClearCache removes all cached configs. This does not delete configs from the backend.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying backend.

func (*Store) Count

func (s *Store) Count(ctx context.Context) (int, error)

Count returns the number of agent configs.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes an agent config.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, id string) (bool, error)

Exists checks if an agent with the given ID exists.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*AgentConfig, error)

Get retrieves an agent config by ID. Returns ErrAgentNotFound if the agent doesn't exist.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*AgentConfig, error)

List returns all agent configs. This requires the backend to implement kvs.ListableStore.

func (*Store) ListEnabled

func (s *Store) ListEnabled(ctx context.Context) ([]*AgentConfig, error)

ListEnabled returns all enabled agent configs.

func (*Store) Save

func (s *Store) Save(ctx context.Context, cfg *AgentConfig) error

Save persists an agent config to storage.

type StoreConfig

type StoreConfig struct {
	// Backend is the KVS storage backend.
	Backend kvs.Store
}

StoreConfig configures the agent store.

Jump to

Keyboard shortcuts

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