Documentation
¶
Overview ¶
Package registry provides multi-agent management for OmniAgent.
Index ¶
- Variables
- func DefaultAgentFactory(cfg *AgentConfig) (*agent.Agent, error)
- type AgentConfig
- type AgentFactory
- type Registry
- func (r *Registry) Clone(ctx context.Context, srcID, newID, newName string) error
- func (r *Registry) Close() error
- func (r *Registry) Count() int
- func (r *Registry) Create(ctx context.Context, cfg *AgentConfig) error
- func (r *Registry) Default() (*agent.Agent, error)
- func (r *Registry) Delete(ctx context.Context, id string) error
- func (r *Registry) Get(id string) (*agent.Agent, error)
- func (r *Registry) GetByModel(modelName string) (*agent.Agent, error)
- func (r *Registry) GetConfig(id string) (*AgentConfig, error)
- func (r *Registry) List() []*AgentConfig
- func (r *Registry) ListEnabled() []*AgentConfig
- func (r *Registry) Load(ctx context.Context) error
- func (r *Registry) Reload(ctx context.Context, id string) error
- func (r *Registry) Update(ctx context.Context, id string, updates *AgentConfig) error
- type RegistryConfig
- type Store
- func (s *Store) ClearCache()
- func (s *Store) Close() error
- func (s *Store) Count(ctx context.Context) (int, error)
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Exists(ctx context.Context, id string) (bool, error)
- func (s *Store) Get(ctx context.Context, id string) (*AgentConfig, error)
- func (s *Store) List(ctx context.Context) ([]*AgentConfig, error)
- func (s *Store) ListEnabled(ctx context.Context) ([]*AgentConfig, error)
- func (s *Store) Save(ctx context.Context, cfg *AgentConfig) error
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
var ErrAgentExists = errors.New("agent already exists")
ErrAgentExists is returned when trying to create an agent that already exists.
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 (*Registry) Create ¶
func (r *Registry) Create(ctx context.Context, cfg *AgentConfig) error
Create adds a new agent to the registry.
func (*Registry) Get ¶
Get retrieves an agent by ID. Returns ErrAgentNotFound if the agent doesn't exist.
func (*Registry) GetByModel ¶
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) ListEnabled ¶
func (r *Registry) ListEnabled() []*AgentConfig
ListEnabled returns configs for enabled agents only.
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 (*Store) ClearCache ¶
func (s *Store) ClearCache()
ClearCache removes all cached configs. This does not delete configs from the backend.
func (*Store) Get ¶
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.
type StoreConfig ¶
StoreConfig configures the agent store.