Documentation
¶
Overview ¶
Package config provides comprehensive configuration management for AINative Code.
The config package supports loading configuration from multiple sources with proper precedence, validation, and type safety.
Configuration Sources ¶
Configuration is loaded from the following sources in order of precedence:
- Command-line flags (highest priority)
- Environment variables
- Configuration file
- Default values (lowest priority)
Basic Usage ¶
loader := config.NewLoader()
cfg, err := loader.Load()
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
Loading from Specific File ¶
loader := config.NewLoader()
cfg, err := loader.LoadFromFile("/path/to/config.yaml")
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
Custom Loader Options ¶
loader := config.NewLoader(
config.WithConfigName("myconfig"),
config.WithConfigType("yaml"),
config.WithEnvPrefix("MYAPP"),
)
Environment Variables ¶
All configuration values can be set via environment variables using the configured prefix (default: AINATIVE_). Nested keys use underscores:
export AINATIVE_APP_ENVIRONMENT=production export AINATIVE_LLM_DEFAULT_PROVIDER=anthropic export AINATIVE_LLM_ANTHROPIC_API_KEY=sk-ant-...
Validation ¶
All loaded configurations are automatically validated. The validator checks:
- Required fields are present
- Values are within valid ranges
- URLs and paths are properly formatted
- Dependencies between fields are consistent
Example validation error:
Configuration validation failed: - llm.anthropic.api_key: Anthropic API key is required - services.zerodb.endpoint: endpoint is required
Configuration Structure ¶
The configuration is organized into major sections:
- App: General application settings
- LLM: Language model provider configurations
- Platform: AINative platform settings
- Services: External service endpoints
- Tools: Tool-specific configurations
- Performance: Performance optimization settings
- Logging: Logging configuration
- Security: Security settings
LLM Providers ¶
Supported LLM providers:
- Anthropic Claude
- OpenAI
- Google Gemini
- AWS Bedrock
- Azure OpenAI
- Ollama (local models)
Each provider has specific configuration requirements. See the documentation for details on configuring each provider.
Fallback Support ¶
The config package supports automatic fallback to alternative LLM providers:
llm:
default_provider: anthropic
fallback:
enabled: true
providers:
- anthropic
- openai
- ollama
Security Best Practices ¶
- Never commit secrets to configuration files
- Use environment variables for sensitive data
- Enable configuration encryption in production
- Use TLS for network communications
- Implement proper secret rotation
Example Configuration ¶
See examples/config.yaml for a complete configuration example with all available options and detailed comments.
Further Documentation ¶
For detailed configuration documentation, see docs/configuration.md
Index ¶
- func GetMaxThinkingDepth(cfg *Config) int
- func IsExtendedThinkingEnabled(cfg *Config) bool
- func ShouldAutoExpandThinking(cfg *Config) bool
- func ValidateExtendedThinkingConfig(cfg *ExtendedThinkingConfig) error
- func WriteConfig(cfg *Config, filePath string) error
- type AnthropicConfig
- type AppConfig
- type AuthConfig
- type AzureConfig
- type BedrockConfig
- type BrowserToolConfig
- type CacheConfig
- type CircuitBreakerConfig
- type CodeAnalysisToolConfig
- type ConcurrencyConfig
- type Config
- type DesignConfig
- type ExtendedThinkingConfig
- type FallbackConfig
- type FileSystemToolConfig
- type GoogleConfig
- type ImplicitFeedbackConfig
- type LLMConfig
- type Loader
- type LoaderOption
- type LoggingConfig
- type OllamaConfig
- type OpenAIConfig
- type OrgConfig
- type PerformanceConfig
- type PlatformConfig
- type RLHFConfig
- type RateLimitConfig
- type Resolver
- type ResolverOption
- type RetryConfig
- type SecurityConfig
- type ServicesConfig
- type StrapiConfig
- type TerminalToolConfig
- type ToolsConfig
- type Validator
- type ZeroDBConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMaxThinkingDepth ¶
GetMaxThinkingDepth returns the maximum allowed thinking depth
func IsExtendedThinkingEnabled ¶
IsExtendedThinkingEnabled checks if extended thinking is enabled in the configuration
func ShouldAutoExpandThinking ¶
ShouldAutoExpandThinking checks if thinking blocks should be auto-expanded
func ValidateExtendedThinkingConfig ¶
func ValidateExtendedThinkingConfig(cfg *ExtendedThinkingConfig) error
ValidateExtendedThinkingConfig validates extended thinking configuration
func WriteConfig ¶
WriteConfig writes the current configuration to a file
Types ¶
type AnthropicConfig ¶
type AnthropicConfig struct {
APIKey string `mapstructure:"api_key" yaml:"api_key"`
Model string `mapstructure:"model" yaml:"model"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
TopK int `mapstructure:"top_k" yaml:"top_k"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
BaseURL string `mapstructure:"base_url,omitempty" yaml:"base_url,omitempty"`
APIVersion string `mapstructure:"api_version" yaml:"api_version"`
ExtendedThinking *ExtendedThinkingConfig `mapstructure:"extended_thinking,omitempty" yaml:"extended_thinking,omitempty"`
Retry *RetryConfig `mapstructure:"retry,omitempty" yaml:"retry,omitempty"`
}
AnthropicConfig contains Anthropic Claude configuration
func DefaultAnthropicConfig ¶
func DefaultAnthropicConfig() *AnthropicConfig
DefaultAnthropicConfig returns default Anthropic configuration
type AppConfig ¶
type AppConfig struct {
Name string `mapstructure:"name" yaml:"name"`
Version string `mapstructure:"version" yaml:"version"`
Environment string `mapstructure:"environment" yaml:"environment"` // development, staging, production
Debug bool `mapstructure:"debug" yaml:"debug"`
}
AppConfig contains general application settings
func DefaultAppConfig ¶
func DefaultAppConfig() AppConfig
DefaultAppConfig returns default application configuration
type AuthConfig ¶
type AuthConfig struct {
Method string `mapstructure:"method" yaml:"method"` // jwt, api_key, oauth2
APIKey string `mapstructure:"api_key,omitempty" yaml:"api_key,omitempty"`
Token string `mapstructure:"token,omitempty" yaml:"token,omitempty"`
RefreshToken string `mapstructure:"refresh_token,omitempty" yaml:"refresh_token,omitempty"`
ClientID string `mapstructure:"client_id,omitempty" yaml:"client_id,omitempty"`
ClientSecret string `mapstructure:"client_secret,omitempty" yaml:"client_secret,omitempty"`
TokenURL string `mapstructure:"token_url,omitempty" yaml:"token_url,omitempty"`
Scopes []string `mapstructure:"scopes,omitempty" yaml:"scopes,omitempty"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
}
AuthConfig contains authentication settings
func DefaultAuthConfig ¶
func DefaultAuthConfig() AuthConfig
DefaultAuthConfig returns default authentication configuration
type AzureConfig ¶
type AzureConfig struct {
APIKey string `mapstructure:"api_key" yaml:"api_key"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
DeploymentName string `mapstructure:"deployment_name" yaml:"deployment_name"`
APIVersion string `mapstructure:"api_version" yaml:"api_version"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
}
AzureConfig contains Azure OpenAI configuration
func DefaultAzureConfig ¶
func DefaultAzureConfig() *AzureConfig
DefaultAzureConfig returns default Azure OpenAI configuration
type BedrockConfig ¶
type BedrockConfig struct {
Region string `mapstructure:"region" yaml:"region"`
Model string `mapstructure:"model" yaml:"model"`
AccessKeyID string `mapstructure:"access_key_id,omitempty" yaml:"access_key_id,omitempty"`
SecretAccessKey string `mapstructure:"secret_access_key,omitempty" yaml:"secret_access_key,omitempty"`
SessionToken string `mapstructure:"session_token,omitempty" yaml:"session_token,omitempty"`
Profile string `mapstructure:"profile,omitempty" yaml:"profile,omitempty"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
}
BedrockConfig contains AWS Bedrock configuration
func DefaultBedrockConfig ¶
func DefaultBedrockConfig() *BedrockConfig
DefaultBedrockConfig returns default AWS Bedrock configuration
type BrowserToolConfig ¶
type BrowserToolConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Headless bool `mapstructure:"headless" yaml:"headless"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
UserAgent string `mapstructure:"user_agent,omitempty" yaml:"user_agent,omitempty"`
}
BrowserToolConfig contains browser automation tool settings
func DefaultBrowserToolConfig ¶
func DefaultBrowserToolConfig() *BrowserToolConfig
DefaultBrowserToolConfig returns default browser tool configuration
type CacheConfig ¶
type CacheConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Type string `mapstructure:"type" yaml:"type"` // memory, redis, memcached
TTL time.Duration `mapstructure:"ttl" yaml:"ttl"`
MaxSize int64 `mapstructure:"max_size" yaml:"max_size"` // MB
RedisURL string `mapstructure:"redis_url,omitempty" yaml:"redis_url,omitempty"`
MemcachedURL string `mapstructure:"memcached_url,omitempty" yaml:"memcached_url,omitempty"`
}
CacheConfig contains caching settings
func DefaultCacheConfig ¶
func DefaultCacheConfig() CacheConfig
DefaultCacheConfig returns default cache configuration
type CircuitBreakerConfig ¶
type CircuitBreakerConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
FailureThreshold int `mapstructure:"failure_threshold" yaml:"failure_threshold"`
SuccessThreshold int `mapstructure:"success_threshold" yaml:"success_threshold"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
ResetTimeout time.Duration `mapstructure:"reset_timeout" yaml:"reset_timeout"`
}
CircuitBreakerConfig contains circuit breaker settings
func DefaultCircuitBreakerConfig ¶
func DefaultCircuitBreakerConfig() CircuitBreakerConfig
DefaultCircuitBreakerConfig returns default circuit breaker configuration
type CodeAnalysisToolConfig ¶
type CodeAnalysisToolConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Languages []string `mapstructure:"languages" yaml:"languages"`
MaxFileSize int64 `mapstructure:"max_file_size" yaml:"max_file_size"`
IncludeTests bool `mapstructure:"include_tests" yaml:"include_tests"`
}
CodeAnalysisToolConfig contains code analysis tool settings
func DefaultCodeAnalysisToolConfig ¶
func DefaultCodeAnalysisToolConfig() *CodeAnalysisToolConfig
DefaultCodeAnalysisToolConfig returns default code analysis tool configuration
type ConcurrencyConfig ¶
type ConcurrencyConfig struct {
MaxWorkers int `mapstructure:"max_workers" yaml:"max_workers"`
MaxQueueSize int `mapstructure:"max_queue_size" yaml:"max_queue_size"`
WorkerTimeout time.Duration `mapstructure:"worker_timeout" yaml:"worker_timeout"`
}
ConcurrencyConfig contains concurrency settings
func DefaultConcurrencyConfig ¶
func DefaultConcurrencyConfig() ConcurrencyConfig
DefaultConcurrencyConfig returns default concurrency configuration
type Config ¶
type Config struct {
// Application settings
App AppConfig `mapstructure:"app" yaml:"app"`
// LLM Provider configurations
LLM LLMConfig `mapstructure:"llm" yaml:"llm"`
// AINative platform configuration
Platform PlatformConfig `mapstructure:"platform" yaml:"platform"`
// Service endpoints
Services ServicesConfig `mapstructure:"services" yaml:"services"`
// Tool configurations
Tools ToolsConfig `mapstructure:"tools" yaml:"tools"`
// Performance settings
Performance PerformanceConfig `mapstructure:"performance" yaml:"performance"`
// Logging configuration
Logging LoggingConfig `mapstructure:"logging" yaml:"logging"`
// Security settings
Security SecurityConfig `mapstructure:"security" yaml:"security"`
}
Config represents the complete application configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration with sensible defaults
type DesignConfig ¶
type DesignConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
APIKey string `mapstructure:"api_key,omitempty" yaml:"api_key,omitempty"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
}
DesignConfig contains AINative Design service settings
func DefaultDesignConfig ¶
func DefaultDesignConfig() *DesignConfig
DefaultDesignConfig returns default Design service configuration
type ExtendedThinkingConfig ¶
type ExtendedThinkingConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
AutoExpand bool `mapstructure:"auto_expand" yaml:"auto_expand"`
MaxDepth int `mapstructure:"max_depth" yaml:"max_depth"`
}
ExtendedThinkingConfig contains extended thinking visualization settings
func DefaultExtendedThinkingConfig ¶
func DefaultExtendedThinkingConfig() *ExtendedThinkingConfig
DefaultExtendedThinkingConfig returns the default extended thinking configuration
func GetExtendedThinkingConfig ¶
func GetExtendedThinkingConfig(cfg *Config) *ExtendedThinkingConfig
GetExtendedThinkingConfig retrieves extended thinking config or returns defaults
type FallbackConfig ¶
type FallbackConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Providers []string `mapstructure:"providers" yaml:"providers"` // ordered list of fallback providers
MaxRetries int `mapstructure:"max_retries" yaml:"max_retries"`
RetryDelay time.Duration `mapstructure:"retry_delay" yaml:"retry_delay"`
}
FallbackConfig defines fallback provider configuration
func DefaultFallbackConfig ¶
func DefaultFallbackConfig() *FallbackConfig
DefaultFallbackConfig returns default fallback configuration
type FileSystemToolConfig ¶
type FileSystemToolConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
AllowedPaths []string `mapstructure:"allowed_paths" yaml:"allowed_paths"`
BlockedPaths []string `mapstructure:"blocked_paths" yaml:"blocked_paths"`
MaxFileSize int64 `mapstructure:"max_file_size" yaml:"max_file_size"` // bytes
AllowedExtensions []string `mapstructure:"allowed_extensions,omitempty" yaml:"allowed_extensions,omitempty"`
}
FileSystemToolConfig contains filesystem tool settings
func DefaultFileSystemToolConfig ¶
func DefaultFileSystemToolConfig() *FileSystemToolConfig
DefaultFileSystemToolConfig returns default filesystem tool configuration
type GoogleConfig ¶
type GoogleConfig struct {
APIKey string `mapstructure:"api_key" yaml:"api_key"`
Model string `mapstructure:"model" yaml:"model"`
ProjectID string `mapstructure:"project_id,omitempty" yaml:"project_id,omitempty"`
Location string `mapstructure:"location,omitempty" yaml:"location,omitempty"`
BaseURL string `mapstructure:"base_url,omitempty" yaml:"base_url,omitempty"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
TopK int `mapstructure:"top_k" yaml:"top_k"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
SafetySettings map[string]string `mapstructure:"safety_settings,omitempty" yaml:"safety_settings,omitempty"`
Retry *RetryConfig `mapstructure:"retry,omitempty" yaml:"retry,omitempty"`
}
GoogleConfig contains Google (Gemini) configuration
func DefaultGoogleConfig ¶
func DefaultGoogleConfig() *GoogleConfig
DefaultGoogleConfig returns default Google (Gemini) configuration
type ImplicitFeedbackConfig ¶
type ImplicitFeedbackConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
RegenerateScore float64 `mapstructure:"regenerate_score" yaml:"regenerate_score"` // Negative signal
EditResponseScore float64 `mapstructure:"edit_response_score" yaml:"edit_response_score"` // Negative signal
CopyResponseScore float64 `mapstructure:"copy_response_score" yaml:"copy_response_score"` // Positive signal
ContinueScore float64 `mapstructure:"continue_score" yaml:"continue_score"` // Positive signal
}
ImplicitFeedbackConfig contains settings for implicit feedback signals
type LLMConfig ¶
type LLMConfig struct {
DefaultProvider string `mapstructure:"default_provider" yaml:"default_provider"`
Anthropic *AnthropicConfig `mapstructure:"anthropic,omitempty" yaml:"anthropic,omitempty"`
OpenAI *OpenAIConfig `mapstructure:"openai,omitempty" yaml:"openai,omitempty"`
Google *GoogleConfig `mapstructure:"google,omitempty" yaml:"google,omitempty"`
Bedrock *BedrockConfig `mapstructure:"bedrock,omitempty" yaml:"bedrock,omitempty"`
Azure *AzureConfig `mapstructure:"azure,omitempty" yaml:"azure,omitempty"`
Ollama *OllamaConfig `mapstructure:"ollama,omitempty" yaml:"ollama,omitempty"`
Fallback *FallbackConfig `mapstructure:"fallback,omitempty" yaml:"fallback,omitempty"`
}
LLMConfig contains all LLM provider configurations
func DefaultLLMConfig ¶
func DefaultLLMConfig() LLMConfig
DefaultLLMConfig returns default LLM configuration with Anthropic as default provider
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading configuration from multiple sources
func New ¶
func New() *Loader
New is a convenience function for creating a new Loader with default options This is provided for backwards compatibility and testing/benchmarking
func NewLoader ¶
func NewLoader(opts ...LoaderOption) *Loader
NewLoader creates a new configuration loader with options
func (*Loader) GetConfigFilePath ¶
GetConfigFilePath returns the path of the loaded configuration file
func (*Loader) LoadFromFile ¶
LoadFromFile loads configuration from a specific file path
func (*Loader) SetConfigFile ¶
SetConfigFile sets a specific config file path to load from This is useful for testing and when you want to load from a specific file
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption is a functional option for configuring the Loader
func WithConfigName ¶
func WithConfigName(name string) LoaderOption
WithConfigName sets the configuration file name (without extension)
func WithConfigPaths ¶
func WithConfigPaths(paths ...string) LoaderOption
WithConfigPaths sets custom configuration file search paths
func WithConfigType ¶
func WithConfigType(configType string) LoaderOption
WithConfigType sets the configuration file type
func WithEnvPrefix ¶
func WithEnvPrefix(prefix string) LoaderOption
WithEnvPrefix sets the environment variable prefix
func WithResolver ¶
func WithResolver(resolver *Resolver) LoaderOption
WithResolver sets a custom API key resolver
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level" yaml:"level"` // debug, info, warn, error
Format string `mapstructure:"format" yaml:"format"` // json, console
Output string `mapstructure:"output" yaml:"output"` // stdout, file
FilePath string `mapstructure:"file_path,omitempty" yaml:"file_path,omitempty"`
MaxSize int `mapstructure:"max_size" yaml:"max_size"` // MB
MaxBackups int `mapstructure:"max_backups" yaml:"max_backups"`
MaxAge int `mapstructure:"max_age" yaml:"max_age"` // days
Compress bool `mapstructure:"compress" yaml:"compress"`
SensitiveKeys []string `mapstructure:"sensitive_keys,omitempty" yaml:"sensitive_keys,omitempty"`
}
LoggingConfig contains logging configuration
func DefaultLoggingConfig ¶
func DefaultLoggingConfig() LoggingConfig
DefaultLoggingConfig returns default logging configuration
type OllamaConfig ¶
type OllamaConfig struct {
BaseURL string `mapstructure:"base_url" yaml:"base_url"`
Model string `mapstructure:"model" yaml:"model"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
TopK int `mapstructure:"top_k" yaml:"top_k"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
KeepAlive string `mapstructure:"keep_alive" yaml:"keep_alive"`
}
OllamaConfig contains Ollama (local LLM) configuration
func DefaultOllamaConfig ¶
func DefaultOllamaConfig() *OllamaConfig
DefaultOllamaConfig returns default Ollama configuration
type OpenAIConfig ¶
type OpenAIConfig struct {
APIKey string `mapstructure:"api_key" yaml:"api_key"`
Model string `mapstructure:"model" yaml:"model"`
Organization string `mapstructure:"organization,omitempty" yaml:"organization,omitempty"`
MaxTokens int `mapstructure:"max_tokens" yaml:"max_tokens"`
Temperature float64 `mapstructure:"temperature" yaml:"temperature"`
TopP float64 `mapstructure:"top_p" yaml:"top_p"`
FrequencyPenalty float64 `mapstructure:"frequency_penalty" yaml:"frequency_penalty"`
PresencePenalty float64 `mapstructure:"presence_penalty" yaml:"presence_penalty"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
BaseURL string `mapstructure:"base_url,omitempty" yaml:"base_url,omitempty"`
Retry *RetryConfig `mapstructure:"retry,omitempty" yaml:"retry,omitempty"`
}
OpenAIConfig contains OpenAI configuration
func DefaultOpenAIConfig ¶
func DefaultOpenAIConfig() *OpenAIConfig
DefaultOpenAIConfig returns default OpenAI configuration
type OrgConfig ¶
type OrgConfig struct {
ID string `mapstructure:"id" yaml:"id"`
Name string `mapstructure:"name,omitempty" yaml:"name,omitempty"`
Workspace string `mapstructure:"workspace,omitempty" yaml:"workspace,omitempty"`
}
OrgConfig contains organization settings
func DefaultOrgConfig ¶
func DefaultOrgConfig() OrgConfig
DefaultOrgConfig returns default organization configuration
type PerformanceConfig ¶
type PerformanceConfig struct {
Cache CacheConfig `mapstructure:"cache" yaml:"cache"`
RateLimit RateLimitConfig `mapstructure:"rate_limit" yaml:"rate_limit"`
Concurrency ConcurrencyConfig `mapstructure:"concurrency" yaml:"concurrency"`
CircuitBreaker CircuitBreakerConfig `mapstructure:"circuit_breaker" yaml:"circuit_breaker"`
}
PerformanceConfig contains performance-related settings
func DefaultPerformanceConfig ¶
func DefaultPerformanceConfig() PerformanceConfig
DefaultPerformanceConfig returns default performance configuration
type PlatformConfig ¶
type PlatformConfig struct {
Authentication AuthConfig `mapstructure:"authentication" yaml:"authentication"`
Organization OrgConfig `mapstructure:"organization,omitempty" yaml:"organization,omitempty"`
}
PlatformConfig contains AINative platform settings
func DefaultPlatformConfig ¶
func DefaultPlatformConfig() PlatformConfig
DefaultPlatformConfig returns default platform configuration
type RLHFConfig ¶
type RLHFConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
APIKey string `mapstructure:"api_key,omitempty" yaml:"api_key,omitempty"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
ModelID string `mapstructure:"model_id,omitempty" yaml:"model_id,omitempty"`
// Auto-collection settings (TASK-064)
AutoCollect bool `mapstructure:"auto_collect" yaml:"auto_collect"`
OptOut bool `mapstructure:"opt_out" yaml:"opt_out"`
ReviewBeforeSubmit bool `mapstructure:"review_before_submit" yaml:"review_before_submit"`
BatchSize int `mapstructure:"batch_size" yaml:"batch_size"`
BatchInterval time.Duration `mapstructure:"batch_interval" yaml:"batch_interval"`
PromptInterval int `mapstructure:"prompt_interval" yaml:"prompt_interval"` // Prompt after N interactions
ImplicitFeedback *ImplicitFeedbackConfig `mapstructure:"implicit_feedback,omitempty" yaml:"implicit_feedback,omitempty"`
}
RLHFConfig contains RLHF service settings
func DefaultRLHFConfig ¶
func DefaultRLHFConfig() *RLHFConfig
DefaultRLHFConfig returns default RLHF service configuration
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
RequestsPerMinute int `mapstructure:"requests_per_minute" yaml:"requests_per_minute"`
BurstSize int `mapstructure:"burst_size" yaml:"burst_size"`
TimeWindow time.Duration `mapstructure:"time_window" yaml:"time_window"`
PerUser bool `mapstructure:"per_user" yaml:"per_user"`
PerEndpoint bool `mapstructure:"per_endpoint" yaml:"per_endpoint"`
Storage string `mapstructure:"storage" yaml:"storage"` // memory, redis
RedisURL string `mapstructure:"redis_url,omitempty" yaml:"redis_url,omitempty"`
EndpointLimits map[string]int `mapstructure:"endpoint_limits,omitempty" yaml:"endpoint_limits,omitempty"`
SkipPaths []string `mapstructure:"skip_paths,omitempty" yaml:"skip_paths,omitempty"`
IPAllowlist []string `mapstructure:"ip_allowlist,omitempty" yaml:"ip_allowlist,omitempty"`
IPBlocklist []string `mapstructure:"ip_blocklist,omitempty" yaml:"ip_blocklist,omitempty"`
}
RateLimitConfig contains rate limiting settings
func DefaultRateLimitConfig ¶
func DefaultRateLimitConfig() RateLimitConfig
DefaultRateLimitConfig returns default rate limit configuration
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver handles dynamic resolution of API keys and secrets from multiple sources
func NewResolver ¶
func NewResolver(opts ...ResolverOption) *Resolver
NewResolver creates a new API key resolver with default settings
func (*Resolver) Resolve ¶
Resolve dynamically resolves an API key from various sources
Supported formats:
- Direct string: "sk-ant-api-key-123"
- Command execution: "$(pass show anthropic)" or "$(security find-generic-password -s anthropic -w)"
- Environment variable: "${OPENAI_API_KEY}" or "$OPENAI_API_KEY"
- File path: "~/secrets/api-key.txt" or "/path/to/key.txt"
Resolution priority:
- Command execution (if matches pattern)
- Environment variable (if matches pattern)
- File path (if looks like a path)
- Direct string (fallback)
Security features:
- Command execution timeout (default 5 seconds)
- File size limit (1KB max for API keys)
- Path traversal prevention via filepath.Clean and EvalSymlinks
- Null byte injection prevention
- Permission error handling
type ResolverOption ¶
type ResolverOption func(*Resolver)
ResolverOption is a functional option for configuring the Resolver
func WithAllowedCommands ¶
func WithAllowedCommands(commands ...string) ResolverOption
WithAllowedCommands sets a whitelist of allowed commands
func WithCommandExecution ¶
func WithCommandExecution(enabled bool) ResolverOption
WithCommandExecution enables or disables command execution
func WithCommandTimeout ¶
func WithCommandTimeout(timeout time.Duration) ResolverOption
WithCommandTimeout sets the timeout for command execution
type RetryConfig ¶
type RetryConfig struct {
// Basic retry settings (backward compatible)
MaxAttempts int `mapstructure:"max_attempts" yaml:"max_attempts"`
InitialDelay time.Duration `mapstructure:"initial_delay" yaml:"initial_delay"`
MaxDelay time.Duration `mapstructure:"max_delay" yaml:"max_delay"`
Multiplier float64 `mapstructure:"multiplier" yaml:"multiplier"`
// Advanced recovery settings
EnableJitter bool `mapstructure:"enable_jitter" yaml:"enable_jitter"`
EnableAPIKeyResolution bool `mapstructure:"enable_api_key_resolution" yaml:"enable_api_key_resolution"`
EnableTokenReduction bool `mapstructure:"enable_token_reduction" yaml:"enable_token_reduction"`
TokenReductionPercent int `mapstructure:"token_reduction_percent" yaml:"token_reduction_percent"`
EnableTimeoutIncrease bool `mapstructure:"enable_timeout_increase" yaml:"enable_timeout_increase"`
TimeoutIncreasePercent int `mapstructure:"timeout_increase_percent" yaml:"timeout_increase_percent"`
}
RetryConfig contains advanced retry and error recovery configuration for LLM providers
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns default retry configuration
type SecurityConfig ¶
type SecurityConfig struct {
EncryptConfig bool `mapstructure:"encrypt_config" yaml:"encrypt_config"`
EncryptionKey string `mapstructure:"encryption_key,omitempty" yaml:"encryption_key,omitempty"`
AllowedOrigins []string `mapstructure:"allowed_origins" yaml:"allowed_origins"`
TLSEnabled bool `mapstructure:"tls_enabled" yaml:"tls_enabled"`
TLSCertPath string `mapstructure:"tls_cert_path,omitempty" yaml:"tls_cert_path,omitempty"`
TLSKeyPath string `mapstructure:"tls_key_path,omitempty" yaml:"tls_key_path,omitempty"`
SecretRotation time.Duration `mapstructure:"secret_rotation,omitempty" yaml:"secret_rotation,omitempty"`
}
SecurityConfig contains security settings
func DefaultSecurityConfig ¶
func DefaultSecurityConfig() SecurityConfig
DefaultSecurityConfig returns default security configuration
type ServicesConfig ¶
type ServicesConfig struct {
ZeroDB *ZeroDBConfig `mapstructure:"zerodb,omitempty" yaml:"zerodb,omitempty"`
Design *DesignConfig `mapstructure:"design,omitempty" yaml:"design,omitempty"`
Strapi *StrapiConfig `mapstructure:"strapi,omitempty" yaml:"strapi,omitempty"`
RLHF *RLHFConfig `mapstructure:"rlhf,omitempty" yaml:"rlhf,omitempty"`
}
ServicesConfig contains service endpoint configurations
func DefaultServicesConfig ¶
func DefaultServicesConfig() ServicesConfig
DefaultServicesConfig returns default services configuration
type StrapiConfig ¶
type StrapiConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
APIKey string `mapstructure:"api_key,omitempty" yaml:"api_key,omitempty"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
}
StrapiConfig contains Strapi CMS settings
func DefaultStrapiConfig ¶
func DefaultStrapiConfig() *StrapiConfig
DefaultStrapiConfig returns default Strapi configuration
type TerminalToolConfig ¶
type TerminalToolConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
AllowedCommands []string `mapstructure:"allowed_commands" yaml:"allowed_commands"`
BlockedCommands []string `mapstructure:"blocked_commands" yaml:"blocked_commands"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
WorkingDir string `mapstructure:"working_dir,omitempty" yaml:"working_dir,omitempty"`
}
TerminalToolConfig contains terminal tool settings
func DefaultTerminalToolConfig ¶
func DefaultTerminalToolConfig() *TerminalToolConfig
DefaultTerminalToolConfig returns default terminal tool configuration
type ToolsConfig ¶
type ToolsConfig struct {
FileSystem *FileSystemToolConfig `mapstructure:"filesystem,omitempty" yaml:"filesystem,omitempty"`
Terminal *TerminalToolConfig `mapstructure:"terminal,omitempty" yaml:"terminal,omitempty"`
Browser *BrowserToolConfig `mapstructure:"browser,omitempty" yaml:"browser,omitempty"`
CodeAnalysis *CodeAnalysisToolConfig `mapstructure:"code_analysis,omitempty" yaml:"code_analysis,omitempty"`
}
ToolsConfig contains tool-specific configurations
func DefaultToolsConfig ¶
func DefaultToolsConfig() ToolsConfig
DefaultToolsConfig returns default tools configuration
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator provides configuration validation functionality
func NewValidator ¶
NewValidator creates a new configuration validator
type ZeroDBConfig ¶
type ZeroDBConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
ProjectID string `mapstructure:"project_id,omitempty" yaml:"project_id,omitempty"`
ConnectionString string `mapstructure:"connection_string,omitempty" yaml:"connection_string,omitempty"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
Database string `mapstructure:"database" yaml:"database"`
Username string `mapstructure:"username,omitempty" yaml:"username,omitempty"`
Password string `mapstructure:"password,omitempty" yaml:"password,omitempty"`
SSL bool `mapstructure:"ssl" yaml:"ssl"`
SSLMode string `mapstructure:"ssl_mode,omitempty" yaml:"ssl_mode,omitempty"`
MaxConnections int `mapstructure:"max_connections" yaml:"max_connections"`
IdleConnections int `mapstructure:"idle_connections" yaml:"idle_connections"`
ConnMaxLifetime time.Duration `mapstructure:"conn_max_lifetime" yaml:"conn_max_lifetime"`
Timeout time.Duration `mapstructure:"timeout" yaml:"timeout"`
RetryAttempts int `mapstructure:"retry_attempts" yaml:"retry_attempts"`
RetryDelay time.Duration `mapstructure:"retry_delay" yaml:"retry_delay"`
}
ZeroDBConfig contains ZeroDB connection settings
func DefaultZeroDBConfig ¶
func DefaultZeroDBConfig() *ZeroDBConfig
DefaultZeroDBConfig returns default ZeroDB configuration