agent

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package agent provides agent configuration and management functionality

Package agent provides model-specific client initialization and management functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultConfig added in v0.1.6

func CreateDefaultConfig() error

CreateDefaultConfig creates a default agent configuration file if it doesn't exist

func CreateDefaultConfigForce added in v0.1.6

func CreateDefaultConfigForce() error

CreateDefaultConfigForce creates a default agent configuration file, overwriting if it exists

func GetDefaultConfigYAML added in v0.1.6

func GetDefaultConfigYAML() string

GetDefaultConfigYAML returns the embedded default configuration as a YAML string

func InitializeModelClient added in v0.1.6

func InitializeModelClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)

InitializeModelClient creates and configures the appropriate model client based on the model class

func ValidateModelConfig added in v0.1.6

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

func New

func New(cfg AgentConfig, logger *common.Logger) *Agent

New creates a new agent instance

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, userInput chan string, agentOutput chan string) error

Run executes the agent

func (*Agent) Validate

func (a *Agent) Validate() error

Validate checks if the configuration is valid

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
	ModelConfig        // Embedded model configuration (Model, APIKey, APIURL, Prompts)
}

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 added in v0.1.6

type AgentConfigFile struct {
	Models []ModelConfig `yaml:"models"`
}

AgentConfigFile holds the agent configuration from file

type Config added in v0.1.6

type Config struct {
	Agent AgentConfigFile `yaml:"agent"`
}

Config holds the complete agent configuration

func GetConfig added in v0.1.6

func GetConfig() (*Config, error)

GetConfig returns the agent configuration from the config file The config file is located at ~/.mcpshell/agent.yaml

func GetDefaultConfig added in v0.1.6

func GetDefaultConfig() (*Config, error)

GetDefaultConfig returns the default agent configuration parsed from the embedded config_sample.yaml

func (*Config) GetDefaultModel added in v0.1.6

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 added in v0.1.6

func (c *Config) GetModelByName(name string) *ModelConfig

GetModelByName returns the model configuration with the specified name

type GenericProvider added in v0.1.6

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 added in v0.1.6

func (p *GenericProvider) GetProviderName() string

func (*GenericProvider) InitializeClient added in v0.1.6

func (p *GenericProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)

func (*GenericProvider) ValidateConfig added in v0.1.6

func (p *GenericProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error

type ModelConfig added in v0.1.6

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 added in v0.1.6

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

ModelManager manages different model providers and routes requests to the appropriate one

func NewModelManager added in v0.1.6

func NewModelManager(logger *common.Logger) *ModelManager

NewModelManager creates a new model manager with all supported providers

func (*ModelManager) InitializeClient added in v0.1.6

func (mm *ModelManager) InitializeClient(config ModelConfig) (*openai.Client, error)

InitializeClient initializes a client for the given model configuration

func (*ModelManager) RegisterProvider added in v0.1.6

func (mm *ModelManager) RegisterProvider(class string, provider ModelProvider)

RegisterProvider registers a new model provider

func (*ModelManager) ValidateConfig added in v0.1.6

func (mm *ModelManager) ValidateConfig(config ModelConfig) error

ValidateConfig validates the configuration for the given model class

type ModelProvider added in v0.1.6

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 added in v0.1.6

type OllamaProvider struct{}

OllamaProvider implements ModelProvider for Ollama models

func (*OllamaProvider) GetProviderName added in v0.1.6

func (p *OllamaProvider) GetProviderName() string

func (*OllamaProvider) InitializeClient added in v0.1.6

func (p *OllamaProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)

func (*OllamaProvider) ValidateConfig added in v0.1.6

func (p *OllamaProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error

type OpenAIProvider added in v0.1.6

type OpenAIProvider struct{}

OpenAIProvider implements ModelProvider for OpenAI models

func (*OpenAIProvider) GetProviderName added in v0.1.6

func (p *OpenAIProvider) GetProviderName() string

func (*OpenAIProvider) InitializeClient added in v0.1.6

func (p *OpenAIProvider) InitializeClient(config ModelConfig, logger *common.Logger) (*openai.Client, error)

func (*OpenAIProvider) ValidateConfig added in v0.1.6

func (p *OpenAIProvider) ValidateConfig(config ModelConfig, logger *common.Logger) error

Jump to

Keyboard shortcuts

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