Documentation
¶
Overview ¶
Package agent provides cagent runtime configuration and setup
Package agent provides agent configuration and management functionality ¶
Package agent provides agent configuration and management functionality ¶
Package agent provides model-specific client initialization and management functionality ¶
Package agent provides agent configuration and management functionality
Index ¶
- func CreateDefaultConfig() error
- func CreateDefaultConfigForce() error
- func GenerateCagentYAML(cfg *Config, toolsFile string, ragSources []string, logger *common.Logger) ([]byte, error)
- func GetDefaultConfigYAML() string
- func InitializeModelClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)
- func ProcessRAGSources(ctx context.Context, ragSources map[string]RAGSourceConfig, ...) (map[string]RAGSourceConfig, error)
- func ValidateModelConfig(config ModelConfig, logger *common.Logger) error
- type Agent
- type AgentConfig
- type AgentConfigFile
- type CagentRuntime
- type Config
- type GenericProvider
- type ModelConfig
- type ModelManager
- type ModelProvider
- type OllamaProvider
- type OpenAIProvider
- type RAGChunkingConfig
- type RAGFusionConfig
- type RAGResultsConfig
- type RAGSourceConfig
- type RAGStrategyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDefaultConfig ¶
func CreateDefaultConfig() error
CreateDefaultConfig creates a default agent configuration file if it doesn't exist
func CreateDefaultConfigForce ¶
func CreateDefaultConfigForce() error
CreateDefaultConfigForce creates a default agent configuration file, overwriting if it exists
func GenerateCagentYAML ¶
func GenerateCagentYAML( cfg *Config, toolsFile string, ragSources []string, logger *common.Logger, ) ([]byte, error)
GenerateCagentYAML generates a cagent-compatible YAML configuration from our MCPShell configuration
func GetDefaultConfigYAML ¶
func GetDefaultConfigYAML() string
GetDefaultConfigYAML returns the embedded default configuration as a YAML string
func InitializeModelClient ¶
InitializeModelClient creates and configures the appropriate model client based on the model class
func ProcessRAGSources ¶
func ProcessRAGSources(ctx context.Context, ragSources map[string]RAGSourceConfig, logger *common.Logger) (map[string]RAGSourceConfig, error)
ProcessRAGSources processes RAG document sources (URLs, files, directories) Downloads remote URLs to local cache and scans local files/directories Returns a map of RAG source names to processed configurations with local paths
func ValidateModelConfig ¶
func ValidateModelConfig(config ModelConfig, logger *common.Logger) error
ValidateModelConfig validates the model configuration for the specified model class
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent represents an MCP agent
type AgentConfig ¶
type AgentConfig struct {
ToolsFile string // Path to the YAML configuration file defining available tools
UserPrompt string // Initial user prompt to send to the LLM
Once bool // Whether to run in one-shot mode (exit after first response)
Version string // Version information for the agent
MCPShellBinary string // Path to mcpshell binary (for spawning MCP server subprocess)
ModelConfig // Embedded model configuration (Model, APIKey, APIURL, Prompts)
// RAG configuration
RAGSources []string // Names of RAG sources to use (from config file)
RAGConfig map[string]RAGSourceConfig // RAG source definitions (from config file)
}
AgentConfig holds the configuration for the agent including tools file location, user prompts, execution mode, and embedded model configuration (API keys, model name, etc.)
type AgentConfigFile ¶
type AgentConfigFile struct {
Models []ModelConfig `yaml:"models"` // Legacy: flat list of models
// Role-based configuration for multi-agent system
Orchestrator *ModelConfig `yaml:"orchestrator,omitempty"` // Root agent that plans and orchestrates
ToolRunner *ModelConfig `yaml:"tool-runner,omitempty"` // Sub-agent that executes tools
// RAG configuration
RAG map[string]RAGSourceConfig `yaml:"rag,omitempty"` // Named RAG knowledge sources
}
AgentConfigFile holds the agent configuration from file
type CagentRuntime ¶
type CagentRuntime struct {
// contains filtered or unexported fields
}
CagentRuntime wraps the cagent runtime and session
func CreateCagentRuntime ¶
func CreateCagentRuntime( ctx context.Context, cfg *Config, userPrompt string, logger *common.Logger, ) (*CagentRuntime, error)
CreateCagentRuntime creates and configures a cagent runtime using teamloader This enables full RAG support through cagent's built-in RAG system The MCP server is started as a subprocess, so the srv parameter is not needed
func (*CagentRuntime) ContinueConversation ¶
func (cr *CagentRuntime) ContinueConversation(userMessage string) error
ContinueConversation adds a new user message to the session and continues the conversation
func (*CagentRuntime) RunStream ¶
func (cr *CagentRuntime) RunStream(ctx context.Context) <-chan runtime.Event
RunStream starts the streaming runtime and returns the event channel
func (*CagentRuntime) Runtime ¶
func (cr *CagentRuntime) Runtime() runtime.Runtime
Runtime returns the underlying cagent runtime for advanced operations like Resume
type Config ¶
type Config struct {
Agent AgentConfigFile `yaml:"agent"`
// Runtime fields (not from YAML)
ToolsFile string // Path to tools configuration file
RAGSources []string // Names of RAG sources to use
MCPShellBinary string // Path to mcpshell binary (for spawning MCP server subprocess)
}
Config holds the complete agent configuration
func GetConfig ¶
GetConfig returns the agent configuration from the config file The config file location is determined by: 1. DON_CONFIG environment variable (if set) 2. Default: ~/.don/agent.yaml
func GetDefaultConfig ¶
GetDefaultConfig returns the default agent configuration parsed from the embedded config_sample.yaml
func (*Config) GetDefaultModel ¶
func (c *Config) GetDefaultModel() *ModelConfig
GetDefaultModel returns the model configuration that has default=true If no default is found, returns the first model in the list If no models are configured, returns nil
func (*Config) GetModelByName ¶
func (c *Config) GetModelByName(name string) *ModelConfig
GetModelByName returns the model configuration with the specified name
func (*Config) GetOrchestratorModel ¶
func (c *Config) GetOrchestratorModel() *ModelConfig
GetOrchestratorModel returns the orchestrator model configuration Falls back to default model if orchestrator is not specified
func (*Config) GetToolRunnerModel ¶
func (c *Config) GetToolRunnerModel() *ModelConfig
GetToolRunnerModel returns the tool-runner model configuration Falls back to orchestrator model if tool-runner is not specified
type GenericProvider ¶
type GenericProvider struct {
// contains filtered or unexported fields
}
GenericProvider implements ModelProvider for unknown/generic model types This allows for extensibility with other OpenAI-compatible APIs
func (*GenericProvider) GetProviderName ¶
func (p *GenericProvider) GetProviderName() string
func (*GenericProvider) InitializeClient ¶
func (p *GenericProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)
func (*GenericProvider) ValidateConfig ¶
func (p *GenericProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error
type ModelConfig ¶
type ModelConfig struct {
Model string `yaml:"model"`
Class string `yaml:"class,omitempty"` // Class of the model, e.g., "ollama", "openai", etc.
Name string `yaml:"name,omitempty"` // Name of the model, optional
Default bool `yaml:"default,omitempty"` // Whether this is the default model
APIKey string `yaml:"api-key,omitempty"` // API key, optional
APIURL string `yaml:"api-url,omitempty"` // API URL, optional
Prompts common.PromptsConfig `yaml:"prompts,omitempty"` // Prompts configuration, optional
}
ModelConfig holds configuration for a single model
type ModelManager ¶
type ModelManager struct {
// contains filtered or unexported fields
}
ModelManager manages different model providers and routes requests to the appropriate one
func NewModelManager ¶
func NewModelManager(logger *common.Logger) *ModelManager
NewModelManager creates a new model manager with all supported providers
func (*ModelManager) InitializeClient ¶
func (mm *ModelManager) InitializeClient(config ModelConfig) (*openai.Client, error)
InitializeClient initializes a client for the given model configuration
func (*ModelManager) RegisterProvider ¶
func (mm *ModelManager) RegisterProvider(class string, provider ModelProvider)
RegisterProvider registers a new model provider
func (*ModelManager) ValidateConfig ¶
func (mm *ModelManager) ValidateConfig(config ModelConfig) error
ValidateConfig validates the configuration for the given model class
type ModelProvider ¶
type ModelProvider interface {
// InitializeClient creates and configures the client for this model provider
InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)
// ValidateConfig validates the configuration for this model provider
ValidateConfig(config ModelConfig, logger *common.Logger) error
// GetProviderName returns the human-readable name of the provider
GetProviderName() string
}
ModelProvider defines the interface for different model providers
type OllamaProvider ¶
type OllamaProvider struct{}
OllamaProvider implements ModelProvider for Ollama models
func (*OllamaProvider) GetProviderName ¶
func (p *OllamaProvider) GetProviderName() string
func (*OllamaProvider) InitializeClient ¶
func (p *OllamaProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)
func (*OllamaProvider) ValidateConfig ¶
func (p *OllamaProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error
type OpenAIProvider ¶
type OpenAIProvider struct{}
OpenAIProvider implements ModelProvider for OpenAI models
func (*OpenAIProvider) GetProviderName ¶
func (p *OpenAIProvider) GetProviderName() string
func (*OpenAIProvider) InitializeClient ¶
func (p *OpenAIProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)
func (*OpenAIProvider) ValidateConfig ¶
func (p *OpenAIProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error
type RAGChunkingConfig ¶
type RAGChunkingConfig struct {
Size int `yaml:"size,omitempty"`
Overlap int `yaml:"overlap,omitempty"`
RespectWordBoundaries bool `yaml:"respect_word_boundaries,omitempty"`
}
RAGChunkingConfig holds chunking configuration for RAG strategies
type RAGFusionConfig ¶
type RAGFusionConfig struct {
Strategy string `yaml:"strategy,omitempty"` // Fusion strategy: "rrf", "weighted", "max"
K int `yaml:"k,omitempty"` // RRF parameter k (default: 60)
Weights map[string]float64 `yaml:"weights,omitempty"` // Strategy weights for weighted fusion
}
RAGFusionConfig holds configuration for combining multi-strategy results
type RAGResultsConfig ¶
type RAGResultsConfig struct {
Limit int `yaml:"limit,omitempty"` // Maximum number of results to return
Fusion *RAGFusionConfig `yaml:"fusion,omitempty"` // How to combine results from multiple strategies
Deduplicate bool `yaml:"deduplicate,omitempty"` // Remove duplicate documents
IncludeScore bool `yaml:"include_score,omitempty"` // Include relevance scores
ReturnFullContent bool `yaml:"return_full_content,omitempty"` // Return full document content
}
RAGResultsConfig holds configuration for RAG result processing
type RAGSourceConfig ¶
type RAGSourceConfig struct {
Description string `yaml:"description"`
Docs []string `yaml:"docs,omitempty"` // Shared documents across all strategies
Strategies []RAGStrategyConfig `yaml:"strategies,omitempty"` // Array of strategy configurations
Results *RAGResultsConfig `yaml:"results,omitempty"`
}
RAGSourceConfig holds configuration for a RAG knowledge source
type RAGStrategyConfig ¶
type RAGStrategyConfig struct {
Type string `yaml:"type"` // Strategy type: "chunked-embeddings", "bm25"
Docs []string `yaml:"docs,omitempty"` // Strategy-specific documents
Database string `yaml:"database,omitempty"` // Database path for this strategy
Chunking RAGChunkingConfig `yaml:"chunking,omitempty"` // Chunking configuration
Limit int `yaml:"limit,omitempty"` // Max results from this strategy
// Strategy-specific parameters (e.g., model, threshold, vector_dimensions for chunked-embeddings)
Model string `yaml:"model,omitempty"`
Threshold float64 `yaml:"threshold,omitempty"`
VectorDimensions int `yaml:"vector_dimensions,omitempty"`
SimilarityMetric string `yaml:"similarity_metric,omitempty"`
K1 float64 `yaml:"k1,omitempty"` // BM25 parameter
B float64 `yaml:"b,omitempty"` // BM25 parameter
}
RAGStrategyConfig holds configuration for a single RAG retrieval strategy