config

package
v0.5.24 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config provides configuration management for the switchAILocal server. It handles loading and parsing YAML configuration files, and provides structured access to application settings including server port, authentication directory, debug settings, proxy configuration, and API keys.

Package config provides configuration management for the switchAILocal server. It handles loading and parsing YAML configuration files, and provides structured access to application settings including server port, authentication directory, debug settings, proxy configuration, and API keys.

Index

Constants

View Source
const (
	// AccessProviderTypeConfigAPIKey is the built-in provider validating inline API keys.
	AccessProviderTypeConfigAPIKey = "config-api-key"

	// DefaultAccessProviderName is applied when no provider name is supplied.
	DefaultAccessProviderName = "config-inline"
)
View Source
const DefaultPanelGitHubRepository = "https://github.com/traylinx/switchAILocal-Management-Center"

Variables

This section is empty.

Functions

func NormalizeCommentIndentation

func NormalizeCommentIndentation(data []byte) []byte

NormalizeCommentIndentation removes indentation from standalone YAML comment lines to keep them left aligned.

func NormalizeExcludedModels

func NormalizeExcludedModels(models []string) []string

NormalizeExcludedModels trims, lowercases, and deduplicates model exclusion patterns. It preserves the order of first occurrences and drops empty entries.

func NormalizeHeaders

func NormalizeHeaders(headers map[string]string) map[string]string

NormalizeHeaders trims header keys and values and removes empty pairs.

func NormalizeOAuthExcludedModels

func NormalizeOAuthExcludedModels(entries map[string][]string) map[string][]string

NormalizeOAuthExcludedModels cleans provider -> excluded models mappings by normalizing provider keys and applying model exclusion normalization to each entry.

func SaveConfigPreserveComments

func SaveConfigPreserveComments(configFile string, cfg *Config) error

SaveConfigPreserveComments writes the config back to YAML while preserving existing comments and key ordering by loading the original file into a yaml.Node tree and updating values in-place.

func SaveConfigPreserveCommentsUpdateNestedScalar

func SaveConfigPreserveCommentsUpdateNestedScalar(configFile string, path []string, value string) error

SaveConfigPreserveCommentsUpdateNestedScalar updates a nested scalar key path like ["a","b"] while preserving comments and positions.

Types

type AccessConfig

type AccessConfig struct {
	// Providers lists configured authentication providers.
	Providers []AccessProvider `yaml:"providers,omitempty" json:"providers,omitempty"`
}

AccessConfig groups request authentication providers.

type AccessProvider

type AccessProvider struct {
	// Name is the instance identifier for the provider.
	Name string `yaml:"name" json:"name"`

	// Type selects the provider implementation registered via the SDK.
	Type string `yaml:"type" json:"type"`

	// SDK optionally names a third-party SDK module providing this provider.
	SDK string `yaml:"sdk,omitempty" json:"sdk,omitempty"`

	// APIKeys lists inline keys for providers that require them.
	APIKeys []string `yaml:"api-keys,omitempty" json:"api-keys,omitempty"`

	// Config passes provider-specific options to the implementation.
	Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
}

AccessProvider describes a request authentication provider entry.

func MakeInlineAPIKeyProvider

func MakeInlineAPIKeyProvider(keys []string) *AccessProvider

MakeInlineAPIKeyProvider constructs an inline API key provider configuration. It returns nil when no keys are supplied.

type AmpCode

type AmpCode struct {
	// UpstreamURL defines the upstream Amp control plane used for non-provider calls.
	UpstreamURL string `yaml:"upstream-url" json:"upstream-url"`

	// UpstreamAPIKey optionally overrides the Authorization header when proxying Amp upstream calls.
	UpstreamAPIKey string `yaml:"upstream-api-key" json:"upstream-api-key"`

	// RestrictManagementToLocalhost restricts Amp management routes (/api/user, /api/threads, etc.)
	// to only accept connections from localhost (127.0.0.1, ::1). When true, prevents drive-by
	// browser attacks and remote access to management endpoints. Default: false (API key auth is sufficient).
	RestrictManagementToLocalhost bool `yaml:"restrict-management-to-localhost" json:"restrict-management-to-localhost"`

	// ModelMappings defines model name mappings for Amp CLI requests.
	// When Amp requests a model that isn't available locally, these mappings
	// allow routing to an alternative model that IS available.
	ModelMappings []AmpModelMapping `yaml:"model-mappings" json:"model-mappings"`

	// ForceModelMappings when true, model mappings take precedence over local API keys.
	// When false (default), local API keys are used first if available.
	ForceModelMappings bool `yaml:"force-model-mappings" json:"force-model-mappings"`
}

AmpCode groups Amp CLI integration settings including upstream routing, optional overrides, management route restrictions, and model fallback mappings.

type AmpModelMapping

type AmpModelMapping struct {
	// From is the model name that Amp CLI requests (e.g., "claude-opus-4.5").
	From string `yaml:"from" json:"from"`

	// To is the target model name to route to (e.g., "claude-sonnet-4").
	// The target model must have available providers in the registry.
	To string `yaml:"to" json:"to"`

	// Regex indicates whether the 'from' field should be interpreted as a regular
	// expression for matching model names. When true, this mapping is evaluated
	// after exact matches and in the order provided. Defaults to false (exact match).
	Regex bool `yaml:"regex,omitempty" json:"regex,omitempty"`
}

AmpModelMapping defines a model name mapping for Amp CLI requests. When Amp requests a model that isn't available locally, this mapping allows routing to an alternative model that IS available.

type AutoAssignConfig

type AutoAssignConfig struct {
	Enabled          bool              `yaml:"enabled" json:"enabled"`
	PreferLocal      bool              `yaml:"prefer-local,omitempty" json:"prefer-local,omitempty"`
	CostOptimization bool              `yaml:"cost-optimization,omitempty" json:"cost-optimization,omitempty"`
	Overrides        map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
}

AutoAssignConfig configures automatic model assignment.

type BillboardConfig

type BillboardConfig struct {
	// Enabled toggles billboard system prompt injection for CLI providers.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// BaseDir is the shared billboard directory path.
	// Default: "~/.switchailocal/billboard"
	BaseDir string `yaml:"base-dir" json:"base-dir"`
}

BillboardConfig configures the shared working directory for CLI provider requests. When enabled, a system prompt is injected into CLI requests instructing the model to use a standard billboard folder for file operations when no specific path is provided.

type CascadeConfig

type CascadeConfig struct {
	Enabled          bool    `yaml:"enabled" json:"enabled"`
	QualityThreshold float64 `yaml:"quality-threshold,omitempty" json:"quality-threshold,omitempty"`
}

CascadeConfig configures model cascading.

type CircuitBreakerConfig

type CircuitBreakerConfig struct {
	// Enabled toggles circuit breaker functionality.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// FailureThreshold is the number of consecutive failures before the circuit opens.
	FailureThreshold int `yaml:"failure-threshold" json:"failure-threshold"`

	// ResetTimeout is the duration to wait before transitioning from Open to Half-Open.
	ResetTimeout time.Duration `yaml:"reset-timeout" json:"reset-timeout"`

	// HalfOpenMax is the maximum number of probe requests allowed in the Half-Open state.
	HalfOpenMax int `yaml:"half-open-max" json:"half-open-max"`
}

CircuitBreakerConfig configures per-provider circuit breakers.

type ClaudeKey

type ClaudeKey struct {
	// APIKey is the authentication key for accessing Claude API services.
	APIKey string `yaml:"api-key" json:"api-key"`

	// Prefix optionally namespaces models for this credential (e.g., "teamA/claude-sonnet-4").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL is the base URL for the Claude API endpoint.
	// If empty, the default Claude API URL will be used.
	BaseURL string `yaml:"base-url" json:"base-url"`

	// ProxyURL overrides the global proxy setting for this API key if provided.
	ProxyURL string `yaml:"proxy-url" json:"proxy-url"`

	// ModelsURL optionally overrides the endpoint used to discover available models.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Models defines upstream model names and aliases for request routing.
	Models []ClaudeModel `yaml:"models" json:"models"`

	// Headers optionally adds extra HTTP headers for requests sent with this key.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// ExcludedModels lists model IDs that should be excluded for this provider.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
}

ClaudeKey represents the configuration for a Claude API key, including the API key itself and an optional base URL for the API endpoint.

type ClaudeModel

type ClaudeModel struct {
	// Name is the upstream model identifier used when issuing requests.
	Name string `yaml:"name" json:"name"`

	// Alias is the client-facing model name that maps to Name.
	Alias string `yaml:"alias" json:"alias"`
}

ClaudeModel describes a mapping between an alias and the actual upstream model name.

type CodexKey

type CodexKey struct {
	// APIKey is the authentication key for accessing Codex API services.
	APIKey string `yaml:"api-key" json:"api-key"`

	// Prefix optionally namespaces models for this credential (e.g., "teamA/gpt-5-codex").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL is the base URL for the Codex API endpoint.
	// If empty, the default Codex API URL will be used.
	BaseURL string `yaml:"base-url" json:"base-url"`

	// ProxyURL overrides the global proxy setting for this API key if provided.
	ProxyURL string `yaml:"proxy-url" json:"proxy-url"`

	// ModelsURL optionally overrides the endpoint used to discover available models.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Headers optionally adds extra HTTP headers for requests sent with this key.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// Models defines upstream model names and aliases for request routing.
	Models []OpenAICompatibilityModel `yaml:"models,omitempty" json:"models,omitempty"`

	// ExcludedModels lists model IDs that should be excluded for this provider.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
}

CodexKey represents the configuration for a Codex API key, including the API key itself and an optional base URL for the API endpoint.

type ComponentFlags

type ComponentFlags struct {
	// OverwatchEnabled toggles real-time execution monitoring.
	// When false, no process monitoring or silence detection occurs.
	OverwatchEnabled bool `yaml:"overwatch_enabled" json:"overwatch_enabled"`

	// DoctorEnabled toggles AI-powered failure diagnosis.
	// When false, failures are not analyzed and no diagnosis is performed.
	DoctorEnabled bool `yaml:"doctor_enabled" json:"doctor_enabled"`

	// InjectorEnabled toggles autonomous stdin injection.
	// When false, no automatic responses to interactive prompts occur.
	InjectorEnabled bool `yaml:"injector_enabled" json:"injector_enabled"`

	// RecoveryEnabled toggles process restart with corrective flags.
	// When false, failed processes are not automatically restarted.
	RecoveryEnabled bool `yaml:"recovery_enabled" json:"recovery_enabled"`

	// FallbackEnabled toggles intelligent failover routing.
	// When false, no automatic routing to alternative providers occurs.
	FallbackEnabled bool `yaml:"fallback_enabled" json:"fallback_enabled"`

	// SculptorEnabled toggles pre-flight content optimization.
	// When false, no token analysis or content optimization is performed.
	SculptorEnabled bool `yaml:"sculptor_enabled" json:"sculptor_enabled"`
}

ComponentFlags provides fine-grained control over individual Superbrain components. This allows for gradual rollout and independent testing of each capability.

type Config

type Config struct {
	SDKConfig `yaml:",inline"`
	// Host is the network host/interface on which the API server will bind.
	// Default is empty ("") to bind all interfaces (IPv4 + IPv6). Use "127.0.0.1" or "localhost" for local-only access.
	Host string `yaml:"host" json:"-"`
	// Port is the network port on which the API server will listen.
	Port int `yaml:"port" json:"-"`

	// TLS config controls HTTPS server settings.
	TLS TLSConfig `yaml:"tls" json:"tls"`

	// RemoteManagement nests management-related options under 'remote-management'.
	RemoteManagement RemoteManagement `yaml:"remote-management" json:"-"`

	// AuthDir is the directory where authentication token files are stored.
	AuthDir string `yaml:"auth-dir" json:"-"`

	// Debug enables or disables debug-level logging and other debug features.
	Debug bool `yaml:"debug" json:"debug"`

	// LoggingToFile controls whether application logs are written to rotating files or stdout.
	LoggingToFile bool `yaml:"logging-to-file" json:"logging-to-file"`

	// LogsMaxTotalSizeMB limits the total size (in MB) of log files under the logs directory.
	// When exceeded, the oldest log files are deleted until within the limit. Set to 0 to disable.
	LogsMaxTotalSizeMB int `yaml:"logs-max-total-size-mb" json:"logs-max-total-size-mb"`

	// UsageStatisticsEnabled toggles in-memory usage aggregation; when false, usage data is discarded.
	UsageStatisticsEnabled bool `yaml:"usage-statistics-enabled" json:"usage-statistics-enabled"`

	// DisableCooling disables quota cooldown scheduling when true.
	DisableCooling bool `yaml:"disable-cooling" json:"disable-cooling"`

	// RequestRetry defines the retry times when the request failed.
	RequestRetry int `yaml:"request-retry" json:"request-retry"`
	// MaxRetryInterval defines the maximum wait time in seconds before retrying a cooled-down credential.
	MaxRetryInterval int `yaml:"max-retry-interval" json:"max-retry-interval"`

	// QuotaExceeded defines the behavior when a quota is exceeded.
	QuotaExceeded QuotaExceeded `yaml:"quota-exceeded" json:"quota-exceeded"`

	// WebsocketAuth enables or disables authentication for the WebSocket API.
	WebsocketAuth bool `yaml:"ws-auth" json:"ws-auth"`

	// GeminiKey defines Gemini API key configurations with optional routing overrides.
	GeminiKey []GeminiKey `yaml:"gemini-api-key" json:"gemini-api-key"`

	// Codex defines a list of Codex API key configurations as specified in the YAML configuration file.
	CodexKey []CodexKey `yaml:"codex-api-key" json:"codex-api-key"`

	// ClaudeKey defines a list of Claude API key configurations as specified in the YAML configuration file.
	ClaudeKey []ClaudeKey `yaml:"claude-api-key" json:"claude-api-key"`

	// SwitchAIKey defines a list of Traylinx switchAI API key configurations as specified in the YAML configuration file.
	SwitchAIKey []SwitchAIKey `yaml:"switchai-api-key" json:"switchai-api-key"`

	// OpenAICompatibility defines OpenAI API compatibility configurations for external providers.
	OpenAICompatibility []OpenAICompatibility `yaml:"openai-compatibility" json:"openai-compatibility"`

	// VertexCompatAPIKey defines Vertex AI-compatible API key configurations for third-party providers.
	// Used for services that use Vertex AI-style paths but with simple API key authentication.
	VertexCompatAPIKey []VertexCompatKey `yaml:"vertex-api-key" json:"vertex-api-key"`

	// AmpCode contains Amp CLI upstream configuration, management restrictions, and model mappings.
	AmpCode AmpCode `yaml:"ampcode" json:"ampcode"`

	// OAuthExcludedModels defines per-provider global model exclusions applied to OAuth/file-backed auth entries.
	OAuthExcludedModels map[string][]string `yaml:"oauth-excluded-models,omitempty" json:"oauth-excluded-models,omitempty"`

	// Ollama configures the local Ollama server integration.
	Ollama OllamaConfig `yaml:"ollama" json:"ollama"`

	// LMStudio configures the local LM Studio server integration.
	LMStudio LMStudioConfig `yaml:"lmstudio" json:"lmstudio"`

	// OpenCode configures the local OpenCode server integration.
	OpenCode OpenCodeConfig `yaml:"opencode" json:"opencode"`

	// Payload defines default and override rules for provider payload parameters.
	Payload PayloadConfig `yaml:"payload" json:"payload"`

	// Plugin configures the LUA plugin system.
	// This is the core engine that executes user-defined logic.
	Plugin PluginConfig `yaml:"plugin" json:"plugin"`

	// Superbrain configures the intelligent orchestration and self-healing capabilities.
	Superbrain SuperbrainConfig `yaml:"superbrain" json:"superbrain"`

	// Heartbeat configures proactive background monitoring for provider health.
	Heartbeat HeartbeatConfig `yaml:"heartbeat" json:"heartbeat"`

	// Memory configures the memory system for routing decisions and learning.
	Memory MemoryConfig `yaml:"memory" json:"memory"`

	// Steering configures context-aware routing rules.
	Steering SteeringConfig `yaml:"steering" json:"steering"`

	// Hooks configures the event-driven automation system.
	Hooks HooksConfig `yaml:"hooks" json:"hooks"`

	// Billboard configures the shared working directory for CLI provider requests.
	Billboard BillboardConfig `yaml:"billboard" json:"billboard"`

	// Observability configures logging format, metrics export, and request event streaming.
	Observability ObservabilityConfig `yaml:"observability" json:"observability"`

	// Performance configures production performance tuning: rate limiting, circuit breakers,
	// load shedding, and profiling.
	Performance PerformanceConfig `yaml:"performance" json:"performance"`
	// contains filtered or unexported fields
}

Config represents the application's configuration, loaded from a YAML file.

func LoadConfig

func LoadConfig(configFile string) (*Config, error)

LoadConfig reads a YAML configuration file from the given path, unmarshals it into a Config struct, applies environment variable overrides, and returns it.

Parameters:

  • configFile: The path to the YAML configuration file

Returns:

  • *Config: The loaded configuration
  • error: An error if the configuration could not be loaded

func LoadConfigOptional

func LoadConfigOptional(configFile string, optional bool) (*Config, error)

LoadConfigOptional reads YAML from configFile. If optional is true and the file is missing, it returns an empty Config. If optional is true and the file is empty or invalid, it returns an empty Config.

func (*Config) GetHeartbeatInterval

func (cfg *Config) GetHeartbeatInterval() time.Duration

GetHeartbeatInterval returns the heartbeat interval as a time.Duration.

func (*Config) GetHeartbeatRetryDelay

func (cfg *Config) GetHeartbeatRetryDelay() time.Duration

GetHeartbeatRetryDelay returns the heartbeat retry delay as a time.Duration.

func (*Config) GetHeartbeatTimeout

func (cfg *Config) GetHeartbeatTimeout() time.Duration

GetHeartbeatTimeout returns the heartbeat timeout as a time.Duration.

func (*Config) GetProviderHeartbeatInterval

func (cfg *Config) GetProviderHeartbeatInterval(provider string) time.Duration

GetProviderHeartbeatInterval returns the heartbeat interval for a specific provider.

func (*Config) GetProviderHeartbeatTimeout

func (cfg *Config) GetProviderHeartbeatTimeout(provider string) time.Duration

GetProviderHeartbeatTimeout returns the heartbeat timeout for a specific provider.

func (*Config) IsProviderHeartbeatEnabled

func (cfg *Config) IsProviderHeartbeatEnabled(provider string) bool

IsProviderHeartbeatEnabled returns whether heartbeat monitoring is enabled for a specific provider.

func (*Config) SanitizeAutoRouting

func (cfg *Config) SanitizeAutoRouting()

SanitizeAutoRouting ensures safe defaults for the Phase 2 Auto-Routing system and auto-migrates the legacy AutoModelPriority list into basic model preferences.

func (*Config) SanitizeClaudeKeys

func (cfg *Config) SanitizeClaudeKeys()

SanitizeClaudeKeys normalizes headers for Claude credentials.

func (*Config) SanitizeCodexKeys

func (cfg *Config) SanitizeCodexKeys()

SanitizeCodexKeys removes Codex API key entries missing a BaseURL. It trims whitespace and preserves order for remaining entries.

func (*Config) SanitizeGeminiKeys

func (cfg *Config) SanitizeGeminiKeys()

SanitizeGeminiKeys deduplicates and normalizes Gemini credentials.

func (*Config) SanitizeHeartbeat

func (cfg *Config) SanitizeHeartbeat()

SanitizeHeartbeat validates and normalizes heartbeat configuration. It ensures intervals and timeouts are valid durations and applies sensible constraints.

func (*Config) SanitizeHooks

func (cfg *Config) SanitizeHooks()

SanitizeHooks validates and normalizes hooks system configuration. It ensures the hooks directory is set and hot-reload is properly configured.

func (*Config) SanitizeMemory

func (cfg *Config) SanitizeMemory()

SanitizeMemory validates and normalizes memory system configuration. It ensures directories are set, retention days are positive, and log sizes are reasonable.

func (*Config) SanitizeOpenAICompatibility

func (cfg *Config) SanitizeOpenAICompatibility()

SanitizeOpenAICompatibility removes OpenAI-compatibility provider entries that are not actionable, specifically those missing a BaseURL. It trims whitespace before evaluation and preserves the relative order of remaining entries.

func (*Config) SanitizeSteering

func (cfg *Config) SanitizeSteering()

SanitizeSteering validates and normalizes steering engine configuration. It ensures the rules directory is set and hot-reload is properly configured.

func (*Config) SanitizeSuperbrain

func (cfg *Config) SanitizeSuperbrain()

SanitizeSuperbrain validates and normalizes Superbrain configuration. It ensures mode values are valid and applies sensible constraints to numeric settings.

func (*Config) SanitizeSwitchAIKeys

func (cfg *Config) SanitizeSwitchAIKeys()

SanitizeSwitchAIKeys normalizes SwitchAI API key entries. It applies the default switchAI BaseURL if none is provided.

func (*Config) SanitizeVertexCompatKeys

func (cfg *Config) SanitizeVertexCompatKeys()

SanitizeVertexCompatKeys deduplicates and normalizes Vertex-compatible API key credentials.

func (*Config) ValidateVirtualModels added in v0.5.18

func (cfg *Config) ValidateVirtualModels() error

ValidateVirtualModels normalizes and validates the virtual-models block.

type ConsensusConfig

type ConsensusConfig struct {
	// Enabled toggles consensus verification. Disabled by default due to added latency and cost.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// VerificationModel is the model used to verify potentially incomplete responses.
	// Default: "gemini-flash".
	VerificationModel string `yaml:"verification_model" json:"verification_model"`

	// TriggerPatterns lists patterns that indicate a response may need verification.
	// Example: ["abrupt_ending", "missing_code_blocks"]
	TriggerPatterns []string `yaml:"trigger_patterns,omitempty" json:"trigger_patterns,omitempty"`
}

ConsensusConfig defines multi-model response verification settings.

type ContextSculptorConfig

type ContextSculptorConfig struct {
	// Enabled toggles pre-flight token analysis and content optimization.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// TokenEstimator selects the token counting method.
	// Valid values: "tiktoken" (accurate), "simple" (fast approximation).
	// Default: "tiktoken".
	TokenEstimator string `yaml:"token_estimator" json:"token_estimator"`

	// PriorityFiles lists file patterns that should always be included when optimizing.
	// Supports glob patterns. Default: ["README.md", "main.go", "index.ts", "package.json"].
	PriorityFiles []string `yaml:"priority_files,omitempty" json:"priority_files,omitempty"`
}

ContextSculptorConfig defines pre-flight content optimization settings.

type DiscoveryConfig

type DiscoveryConfig struct {
	Enabled           bool          `yaml:"enabled" json:"enabled"`
	ProbeOnStartup    bool          `yaml:"probe-on-startup" json:"probe_on_startup"`
	ProbeInterval     time.Duration `yaml:"probe-interval" json:"probe_interval"`
	ProbeTimeout      time.Duration `yaml:"probe-timeout" json:"probe_timeout"`
	PassiveMonitoring bool          `yaml:"passive-monitoring" json:"passive_monitoring"`
	CacheTTL          time.Duration `yaml:"cache-ttl" json:"cache_ttl"`
}

DiscoveryConfig controls active and passive intelligence gathering.

type DoctorConfig

type DoctorConfig struct {
	// Model is the lightweight AI model used for failure diagnosis.
	// Default: "gemini-flash" for fast, cost-effective analysis.
	Model string `yaml:"model" json:"model"`

	// TimeoutMs is the maximum time in milliseconds to wait for diagnosis.
	// If exceeded, falls back to pattern-only diagnosis. Default: 5000 (5 seconds).
	TimeoutMs int64 `yaml:"timeout_ms" json:"timeout_ms"`
}

DoctorConfig defines AI-powered failure diagnosis settings.

type EmbeddingConfig

type EmbeddingConfig struct {
	Enabled bool   `yaml:"enabled" json:"enabled"`
	Model   string `yaml:"model,omitempty" json:"model,omitempty"`
}

EmbeddingConfig configures the embedding engine.

type FallbackConfig

type FallbackConfig struct {
	// Enabled toggles automatic failover to alternative providers.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Providers lists provider names in order of fallback preference.
	// When a provider fails, the next available provider in this list is tried.
	// Example: ["geminicli", "gemini", "ollama"]
	Providers []string `yaml:"providers,omitempty" json:"providers,omitempty"`

	// MinSuccessRate is the minimum historical success rate (0.0-1.0) required
	// for a provider to be considered for fallback routing. Default: 0.5.
	MinSuccessRate float64 `yaml:"min_success_rate" json:"min_success_rate"`
}

FallbackConfig defines intelligent failover routing settings.

type FeatureFlag

type FeatureFlag struct {
	Enabled bool `yaml:"enabled" json:"enabled"`
}

FeatureFlag represents a simple on/off toggle for a feature.

type FeedbackConfig

type FeedbackConfig struct {
	Enabled       bool `yaml:"enabled" json:"enabled"`
	RetentionDays int  `yaml:"retention-days,omitempty" json:"retention-days,omitempty"`
}

FeedbackConfig configures feedback collection.

type GeminiKey

type GeminiKey struct {
	// APIKey is the authentication key for accessing Gemini API services.
	APIKey string `yaml:"api-key" json:"api-key"`

	// Prefix optionally namespaces models for this credential (e.g., "teamA/gemini-3-pro-preview").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL optionally overrides the Gemini API endpoint.
	BaseURL string `yaml:"base-url,omitempty" json:"base-url,omitempty"`

	// ProxyURL optionally overrides the global proxy for this API key.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`

	// ModelsURL optionally overrides the endpoint used to discover available models.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Headers optionally adds extra HTTP headers for requests sent with this key.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// Models defines upstream model names and aliases for request routing.
	Models []OpenAICompatibilityModel `yaml:"models,omitempty" json:"models,omitempty"`

	// ExcludedModels lists model IDs that should be excluded for this provider.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
}

GeminiKey represents the configuration for a Gemini API key, including optional overrides for upstream base URL, proxy routing, and headers.

type HeartbeatConfig

type HeartbeatConfig struct {
	// Enabled toggles the entire heartbeat monitoring system.
	// When false, no background monitoring occurs.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Interval is the time between heartbeat cycles.
	// Default: "5m" (5 minutes). Minimum: "30s" (30 seconds).
	Interval string `yaml:"interval" json:"interval"`

	// Timeout is the maximum time to wait for a single provider check.
	// Default: "5s" (5 seconds). Minimum: "1s" (1 second).
	Timeout string `yaml:"timeout" json:"timeout"`

	// AutoDiscovery enables automatic model discovery for supported providers.
	// When true, new models are discovered without requiring configuration reload.
	AutoDiscovery bool `yaml:"auto-discovery" json:"auto-discovery"`

	// QuotaWarningThreshold triggers warnings when quota usage exceeds this ratio (0.0-1.0).
	// Default: 0.80 (80%). Set to 0 to disable quota monitoring.
	QuotaWarningThreshold float64 `yaml:"quota-warning-threshold" json:"quota-warning-threshold"`

	// QuotaCriticalThreshold triggers critical alerts when quota usage exceeds this ratio (0.0-1.0).
	// Default: 0.95 (95%). Must be greater than QuotaWarningThreshold.
	QuotaCriticalThreshold float64 `yaml:"quota-critical-threshold" json:"quota-critical-threshold"`

	// MaxConcurrentChecks limits the number of simultaneous health checks.
	// Default: 10. Minimum: 1. Maximum: 50.
	MaxConcurrentChecks int `yaml:"max-concurrent-checks" json:"max-concurrent-checks"`

	// RetryAttempts is the number of retries for failed health checks.
	// Default: 2. Minimum: 0. Maximum: 5.
	RetryAttempts int `yaml:"retry-attempts" json:"retry-attempts"`

	// RetryDelay is the delay between retry attempts.
	// Default: "1s" (1 second). Minimum: "100ms".
	RetryDelay string `yaml:"retry-delay" json:"retry-delay"`

	// Providers configures provider-specific heartbeat settings.
	// If not specified, default settings are used for all providers.
	Providers map[string]ProviderHeartbeatConfig `yaml:"providers,omitempty" json:"providers,omitempty"`
}

HeartbeatConfig holds the heartbeat monitoring configuration. The heartbeat system provides proactive background monitoring of provider health, quota usage, and automatic model discovery to prevent failures before they impact users.

type HooksConfig

type HooksConfig struct {
	Enabled   bool   `yaml:"enabled" json:"enabled"`
	HooksDir  string `yaml:"hooks-dir,omitempty" json:"hooks-dir,omitempty"`
	HotReload bool   `yaml:"hot-reload,omitempty" json:"hot-reload,omitempty"`
}

HooksConfig configures the hook system.

type IntelligenceConfig

type IntelligenceConfig struct {
	// Enabled toggles the intelligent routing feature (master switch).
	// When false, all Phase 2 features are disabled.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// RouterModel is the identifier of the LLM used for classification (e.g., "ollama:qwen:0.5b").
	RouterModel string `yaml:"router-model" json:"router-model"`

	// RouterFallback is the model used if the primary RouterModel fails or returns invalid result.
	RouterFallback string `yaml:"router-fallback" json:"router-fallback"`

	// Matrix defines the intent-to-model mapping patterns.
	// It is used by the Lua scripts to resolve abstract intents to specific models.
	Matrix map[string]string `yaml:"matrix,omitempty" json:"matrix,omitempty"`

	// SkillsPath defines the directory where Agent Skills are stored (SKILL.md).
	SkillsPath string `yaml:"skills-path" json:"skills-path"`

	// Discovery configures model discovery settings.
	Discovery DiscoveryConfig `yaml:"discovery,omitempty" json:"discovery,omitempty"`

	// CapabilityAnalysis enables automatic capability inference from model metadata.
	CapabilityAnalysis FeatureFlag `yaml:"capability-analysis,omitempty" json:"capability-analysis,omitempty"`

	// AutoAssign configures automatic model-to-capability slot assignment.
	AutoAssign AutoAssignConfig `yaml:"auto-assign,omitempty" json:"auto-assign,omitempty"`

	// Skills configures the skill registry.
	Skills SkillsConfig `yaml:"skills,omitempty" json:"skills,omitempty"`

	// Embedding configures the embedding engine.
	Embedding EmbeddingConfig `yaml:"embedding,omitempty" json:"embedding,omitempty"`

	// SemanticTier configures semantic intent matching.
	SemanticTier SemanticTierConfig `yaml:"semantic-tier,omitempty" json:"semantic-tier,omitempty"`

	// SkillMatching configures skill matching behavior.
	SkillMatching SkillMatchingConfig `yaml:"skill-matching,omitempty" json:"skill-matching,omitempty"`

	// SemanticCache configures semantic caching.
	SemanticCache SemanticCacheConfig `yaml:"semantic-cache,omitempty" json:"semantic-cache,omitempty"`

	// Confidence enables confidence scoring for classifications.
	Confidence FeatureFlag `yaml:"confidence,omitempty" json:"confidence,omitempty"`

	// Verification configures classification verification.
	Verification VerificationConfig `yaml:"verification,omitempty" json:"verification,omitempty"`

	// Cascade configures model cascading behavior.
	Cascade CascadeConfig `yaml:"cascade,omitempty" json:"cascade,omitempty"`

	// Feedback configures feedback collection.
	Feedback FeedbackConfig `yaml:"feedback,omitempty" json:"feedback,omitempty"`

	// Steering configures context-aware routing rules.
	Steering SteeringConfig `yaml:"steering,omitempty" json:"steering,omitempty"`

	// Hooks configures the event-driven automation system.
	Hooks HooksConfig `yaml:"hooks,omitempty" json:"hooks,omitempty"`

	// Learning configures the adaptive learning engine.
	Learning LearningConfig `yaml:"learning,omitempty" json:"learning,omitempty"`
}

IntelligenceConfig defines settings for the Intelligent Routing system.

type LMStudioConfig

type LMStudioConfig struct {
	// Enabled toggles LM Studio provider registration.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// BaseURL is the LM Studio API endpoint. Default: http://localhost:1234/v1
	BaseURL string `yaml:"base-url" json:"base-url"`

	// AutoDiscover when true, fetches available models from LM Studio on startup.
	AutoDiscover bool `yaml:"auto-discover" json:"auto-discover"`

	// ProxyURL optionally overrides the global proxy for this provider.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`

	// ModelsURL overrides the default models discovery endpoint.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Headers optionally adds extra HTTP headers for requests.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// ExcludedModels lists model IDs that should be excluded.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`

	// Models defines manual model aliases.
	Models []OpenAICompatibilityModel `yaml:"models,omitempty" json:"models,omitempty"`
}

LMStudioConfig holds local LM Studio server settings.

type LearningConfig

type LearningConfig struct {
	Enabled             bool    `yaml:"enabled" json:"enabled"`
	MinSampleSize       int     `yaml:"min-sample-size,omitempty" json:"min-sample-size,omitempty"`
	ConfidenceThreshold float64 `yaml:"confidence-threshold,omitempty" json:"confidence-threshold,omitempty"`
	AutoApply           bool    `yaml:"auto-apply,omitempty" json:"auto-apply,omitempty"`
	AnalysisInterval    string  `yaml:"analysis-interval,omitempty" json:"analysis-interval,omitempty"`
}

LearningConfig configures the learning engine.

type LoadSheddingConfig

type LoadSheddingConfig struct {
	// Enabled toggles load shedding.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// MaxInFlight is the maximum number of in-flight requests before shedding begins.
	MaxInFlight int `yaml:"max-in-flight" json:"max-in-flight"`

	// RetryAfterSeconds is the Retry-After header value returned with 503 responses.
	RetryAfterSeconds int `yaml:"retry-after-seconds" json:"retry-after-seconds"`
}

LoadSheddingConfig configures graceful load shedding.

type MemoryConfig

type MemoryConfig struct {
	// Enabled toggles the memory system on or off.
	// When false, no routing decisions are recorded.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// BaseDir is the directory where memory data is stored.
	// Default: ".switchailocal/memory"
	BaseDir string `yaml:"base-dir" json:"base-dir"`

	// RetentionDays is the number of days to retain routing decision logs.
	// Older logs are automatically cleaned up. Default: 90 days.
	RetentionDays int `yaml:"retention-days" json:"retention-days"`

	// MaxLogSizeMB is the maximum size in MB for a single log file.
	// When exceeded, the log file is rotated. Default: 100 MB.
	MaxLogSizeMB int `yaml:"max-log-size-mb" json:"max-log-size-mb"`

	// Compression enables gzip compression for rotated log files.
	// Default: true
	Compression bool `yaml:"compression" json:"compression"`
}

MemoryConfig represents configuration for the memory system. The memory system records routing decisions, learns user preferences, and tracks provider quirks.

type MetricsConfig

type MetricsConfig struct {
	// Enabled toggles the Prometheus metrics server.
	Enabled bool `yaml:"enabled" json:"enabled"`
	// Path is the HTTP path to serve metrics on. Default: "/metrics".
	Path string `yaml:"path" json:"path"`
}

MetricsConfig controls the Prometheus /metrics endpoint.

type NativeTool added in v0.5.7

type NativeTool struct {
	// Type is the tool type the upstream model recognises (matches the
	// "type" field of an OpenAI tools[] entry, e.g. "web_search").
	Type string `yaml:"type" json:"type"`
	// Description is a short human-readable sentence for the operator /
	// client UI. Not forwarded to the model.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
	// Params documents per-tool knobs (e.g. force_search, max_keyword).
	// Shape is provider-specific — YAML values are passed through as-is.
	Params map[string]any `yaml:"params,omitempty" json:"params,omitempty"`
}

NativeTool is the YAML-side mirror of registry.NativeTool. Kept in this package to avoid a dependency cycle (registry imports from config is fine; config importing registry would loop).

type NotificationsConfig added in v0.5.0

type NotificationsConfig struct {
	// Telegram configures outbound Telegram bot relays.
	Telegram TelegramNotificationsConfig `yaml:"telegram,omitempty" json:"telegram,omitempty"`
}

NotificationsConfig holds the configuration for the notifications subsystem.

The notifications subsystem lets sandboxed clients (e.g. agents inside network-isolated Tytus pods) send outbound messages to external services like Telegram via the gateway. The gateway holds the upstream credentials server-side so a compromised pod never sees a real bot token. Each channel (telegram today, slack/webhooks tomorrow) gets its own block.

func (*NotificationsConfig) LookupTelegramBot added in v0.5.0

func (n *NotificationsConfig) LookupTelegramBot(name string) (TelegramBot, bool)

LookupTelegramBot returns the bot config for the given name (or "default" if name is empty), and a bool indicating whether a match was found. The match is exact and case-sensitive.

type ObservabilityConfig

type ObservabilityConfig struct {
	// LogFormat sets the global log output format: "text" (default, human-readable) or "json" (structured, for Loki/ELK/Datadog).
	LogFormat string `yaml:"log-format" json:"log-format"`

	// Metrics configures the Prometheus metrics endpoint.
	Metrics MetricsConfig `yaml:"metrics" json:"metrics"`

	// RequestEvents configures structured NDJSON event logging for every proxied request.
	RequestEvents RequestEventsConfig `yaml:"request-events" json:"request-events"`
}

ObservabilityConfig controls logging, metrics, and tracing output for external monitoring tools.

type OllamaConfig

type OllamaConfig struct {
	// Enabled toggles Ollama provider registration.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// BaseURL is the Ollama API endpoint. Default: http://localhost:11434
	BaseURL string `yaml:"base-url" json:"base-url"`

	// AutoDiscover when true, fetches available models from Ollama on startup.
	AutoDiscover bool `yaml:"auto-discover" json:"auto-discover"`

	// ProxyURL optionally overrides the global proxy for this provider.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`

	// ModelsURL overrides the default models discovery endpoint.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Headers optionally adds extra HTTP headers for requests.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// ExcludedModels lists model IDs that should be excluded.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`

	// Models defines manual model aliases.
	Models []OpenAICompatibilityModel `yaml:"models,omitempty" json:"models,omitempty"`
}

OllamaConfig holds local Ollama server settings.

type OpenAICompatibility

type OpenAICompatibility struct {
	// Name is the identifier for this OpenAI compatibility configuration.
	Name string `yaml:"name" json:"name"`

	// Prefix optionally namespaces model aliases for this provider (e.g., "teamA/kimi-k2").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL is the base URL for the external OpenAI-compatible API endpoint.
	BaseURL string `yaml:"base-url" json:"base-url"`

	// ModelsURL optionally overrides the endpoint used to discover available models.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// APIKeyEntries defines API keys with optional per-key proxy configuration.
	APIKeyEntries []OpenAICompatibilityAPIKey `yaml:"api-key-entries,omitempty" json:"api-key-entries,omitempty"`

	// Models defines the model configurations including aliases for routing.
	Models []OpenAICompatibilityModel `yaml:"models" json:"models"`

	// Headers optionally adds extra HTTP headers for requests sent to this provider.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// ExcludedModels lists model IDs that should be excluded for this provider.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`

	// ProxyURL overrides the global proxy setting for this provider.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`

	// KimiHistoryShim toggles a stateless body mutator that injects a
	// non-empty placeholder into reasoning_content on assistant messages
	// that carry tool_calls but lack reasoning_content. Required for Kimi
	// K2.6 (api.kimi.com/coding/v1) with thinking-mode-on used as a
	// failover candidate in heterogeneous aliases — Kimi 400s the
	// multi-turn request "thinking is enabled but reasoning_content is
	// missing in assistant tool call message" otherwise. DeepSeek-V4-Pro
	// has the same failure shape; the shim is harmless on providers that
	// don't require it (MiniMax/OpenAI ignore the field).
	//
	// Pointer semantics: nil → default (enabled), *true → enabled,
	// *false → explicitly disabled. Default-on prevents future operators
	// from recreating the 2026-04-27 outage by enabling Kimi without
	// reading docs.
	KimiHistoryShim *bool `yaml:"kimi-history-shim,omitempty" json:"kimi-history-shim,omitempty"`
}

OpenAICompatibility represents the configuration for OpenAI API compatibility with external providers, allowing model aliases to be routed through OpenAI API format.

func (*OpenAICompatibility) IsKimiHistoryShimEnabled added in v0.5.7

func (o *OpenAICompatibility) IsKimiHistoryShimEnabled() bool

IsKimiHistoryShimEnabled reports whether the reasoning_content placeholder shim should be applied to outbound requests for this provider. Default is enabled (nil pointer); only an explicit *false disables it.

type OpenAICompatibilityAPIKey

type OpenAICompatibilityAPIKey struct {
	// APIKey is the authentication key for accessing the external API services.
	APIKey string `yaml:"api-key" json:"api-key"`

	// ProxyURL overrides the global proxy setting for this API key if provided.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`
}

OpenAICompatibilityAPIKey represents an API key configuration with optional proxy setting.

type OpenAICompatibilityModel

type OpenAICompatibilityModel struct {
	// Name is the actual model name used by the external provider.
	Name string `yaml:"name" json:"name"`

	// Alias is the model name alias that clients will use to reference this model.
	Alias string `yaml:"alias" json:"alias"`

	// Expose controls whether this concrete alias appears in normal public
	// model catalog responses. nil/true keeps legacy public behavior;
	// false keeps the alias routable internally while hiding it from /v1/models.
	Expose *bool `yaml:"expose,omitempty" json:"expose,omitempty"`

	// Visibility is a human-readable catalog visibility hint. "private" hides
	// the concrete alias from normal public model lists.
	Visibility string `yaml:"visibility,omitempty" json:"visibility,omitempty"`

	// ContextLength optionally declares the upstream context window.
	ContextLength int `yaml:"context_length,omitempty" json:"context_length,omitempty"`

	// Capabilities optionally declares explicit model capabilities for
	// /v1/models discovery. Virtual-pool routing uses its own member
	// capabilities; this field is for direct/provider aliases.
	Capabilities VirtualModelCapabilitiesConfig `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`

	// NativeTools declares provider-native tools this model supports out
	// of the box (e.g. MiniMax M2.7's `{"type":"web_search"}`). Surfaced
	// unmodified through /v1/models so agentic callers can discover and
	// splice them into their own caller tools[] at chat-completion time.
	// Empty / absent = no native tools.
	NativeTools []NativeTool `yaml:"native_tools,omitempty" json:"native_tools,omitempty"`
}

OpenAICompatibilityModel represents a model configuration for OpenAI compatibility, including the actual model name and its alias for API routing.

type OpenCodeConfig

type OpenCodeConfig struct {
	// Enabled toggles OpenCode provider integration.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// BaseURL is the OpenCode API endpoint. Default: http://localhost:4096
	BaseURL string `yaml:"base-url" json:"base-url"`

	// DefaultAgent is the default agent to use if no specific model is requested.
	DefaultAgent string `yaml:"default-agent" json:"default-agent"`
}

OpenCodeConfig holds local OpenCode server settings.

type OverwatchConfig

type OverwatchConfig struct {
	// SilenceThresholdMs is the duration in milliseconds of no output before
	// flagging an execution as potentially hung. Default: 30000 (30 seconds).
	SilenceThresholdMs int64 `yaml:"silence_threshold_ms" json:"silence_threshold_ms"`

	// LogBufferSize is the number of recent log lines to retain in the rolling buffer.
	// Default: 50 lines.
	LogBufferSize int `yaml:"log_buffer_size" json:"log_buffer_size"`

	// HeartbeatIntervalMs is the interval in milliseconds for checking process health.
	// Default: 1000 (1 second).
	HeartbeatIntervalMs int64 `yaml:"heartbeat_interval_ms" json:"heartbeat_interval_ms"`

	// MaxRestartAttempts is the maximum number of times to restart a failed process
	// before escalating to fallback routing. Default: 2.
	MaxRestartAttempts int `yaml:"max_restart_attempts" json:"max_restart_attempts"`
}

OverwatchConfig defines real-time execution monitoring parameters.

type PayloadConfig

type PayloadConfig struct {
	// Default defines rules that only set parameters when they are missing in the payload.
	Default []PayloadRule `yaml:"default" json:"default"`
	// Override defines rules that always set parameters, overwriting any existing values.
	Override []PayloadRule `yaml:"override" json:"override"`
}

PayloadConfig defines default and override parameter rules applied to provider payloads.

type PayloadModelRule

type PayloadModelRule struct {
	// Name is the model name or wildcard pattern (e.g., "gpt-*", "*-5", "gemini-*-pro").
	Name string `yaml:"name" json:"name"`
	// Protocol restricts the rule to a specific translator format (e.g., "gemini", "responses").
	Protocol string `yaml:"protocol" json:"protocol"`
}

PayloadModelRule ties a model name pattern to a specific translator protocol.

type PayloadRule

type PayloadRule struct {
	// Models lists model entries with name pattern and protocol constraint.
	Models []PayloadModelRule `yaml:"models" json:"models"`
	// Params maps JSON paths (gjson/sjson syntax) to values written into the payload.
	Params map[string]any `yaml:"params" json:"params"`
}

PayloadRule describes a single rule targeting a list of models with parameter updates.

type PerformanceConfig

type PerformanceConfig struct {
	// ProfilingEnabled toggles pprof HTTP server on PprofPort.
	ProfilingEnabled bool `yaml:"profiling-enabled" json:"profiling-enabled"`

	// PprofPort is the port for the pprof HTTP server. Default: 6060.
	PprofPort int `yaml:"pprof-port" json:"pprof-port"`

	// RateLimiter configures global and per-key rate limiting.
	RateLimiter RateLimiterConfig `yaml:"rate-limiter" json:"rate-limiter"`

	// CircuitBreaker configures per-provider circuit breaker behavior.
	CircuitBreaker CircuitBreakerConfig `yaml:"circuit-breaker" json:"circuit-breaker"`

	// LoadShedding configures graceful degradation under load.
	LoadShedding LoadSheddingConfig `yaml:"load-shedding" json:"load-shedding"`

	// ProviderTimeouts configures per-provider request timeouts. Keys are provider
	// names (e.g. "openai", "anthropic", "gemini", "ollama") and the special key
	// "default" sets the fallback for providers not listed. Timeouts apply to the
	// entire request — including connection, headers, and body read.
	ProviderTimeouts ProviderTimeoutsConfig `yaml:"provider-timeouts" json:"provider-timeouts"`

	// Streaming configures server-sent-event stream health.
	Streaming StreamHealthConfig `yaml:"streaming" json:"streaming"`
}

PerformanceConfig holds all production performance tuning settings.

func (*PerformanceConfig) SanitizePerformance

func (c *PerformanceConfig) SanitizePerformance()

SanitizePerformance applies safe defaults to performance configuration.

type PluginConfig

type PluginConfig struct {
	// Enabled toggles the LUA plugin system.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// PluginDir is the directory containing LUA scripts.
	PluginDir string `yaml:"plugin-dir" json:"plugin-dir"`

	// EnabledPlugins specifies a list of LUA plugin IDs to load.
	// Only plugins with a matching 'name' variable will be loaded.
	EnabledPlugins []string `yaml:"enabled-plugins" json:"enabled-plugins"`
}

PluginConfig holds LUA plugin system settings.

type ProviderHeartbeatConfig

type ProviderHeartbeatConfig struct {
	// Enabled toggles heartbeat monitoring for this specific provider.
	// Default: true (inherits from global Enabled setting).
	Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`

	// Interval overrides the global interval for this provider.
	// Some providers may benefit from more or less frequent checks.
	Interval string `yaml:"interval,omitempty" json:"interval,omitempty"`

	// Timeout overrides the global timeout for this provider.
	// Some providers may be slower and need longer timeouts.
	Timeout string `yaml:"timeout,omitempty" json:"timeout,omitempty"`

	// QuotaMonitoring enables quota monitoring for this provider.
	// Default: true for providers that support it.
	QuotaMonitoring *bool `yaml:"quota-monitoring,omitempty" json:"quota-monitoring,omitempty"`

	// AutoDiscovery enables model auto-discovery for this provider.
	// Default: true for providers that support it (Ollama, LM Studio).
	AutoDiscovery *bool `yaml:"auto-discovery,omitempty" json:"auto-discovery,omitempty"`

	// HealthEndpoint overrides the default health check endpoint for this provider.
	// Only applicable for providers that support custom health endpoints.
	HealthEndpoint string `yaml:"health-endpoint,omitempty" json:"health-endpoint,omitempty"`

	// Headers adds custom headers for health check requests to this provider.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
}

ProviderHeartbeatConfig holds provider-specific heartbeat settings.

type ProviderTimeoutsConfig added in v0.2.0

type ProviderTimeoutsConfig struct {
	// Default is the fallback timeout used when a provider has no explicit entry.
	Default time.Duration `yaml:"default" json:"default"`

	// PerProvider maps provider-name → timeout. Case-sensitive, lowercase preferred.
	PerProvider map[string]time.Duration `yaml:"per-provider" json:"per-provider"`
}

ProviderTimeoutsConfig holds per-provider and default request timeouts. Use Resolve(provider) to look up the effective timeout for a given provider name.

func (ProviderTimeoutsConfig) Resolve added in v0.2.0

func (p ProviderTimeoutsConfig) Resolve(provider string) time.Duration

Resolve returns the effective timeout for a given provider. Unknown providers fall back to Default. If both are zero, returns 0 (caller must interpret as "no timeout configured" and apply its own hard default).

type QuotaExceeded

type QuotaExceeded struct {
	// SwitchProject indicates whether to automatically switch to another project when a quota is exceeded.
	SwitchProject bool `yaml:"switch-project" json:"switch-project"`

	// SwitchPreviewModel indicates whether to automatically switch to a preview model when a quota is exceeded.
	SwitchPreviewModel bool `yaml:"switch-preview-model" json:"switch-preview-model"`
}

QuotaExceeded defines the behavior when API quota limits are exceeded. It provides configuration options for automatic failover mechanisms.

type RateLimiterConfig

type RateLimiterConfig struct {
	// Enabled toggles the rate limiter.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// GlobalRequestsPerSecond is the maximum sustained request rate across all keys.
	GlobalRequestsPerSecond float64 `yaml:"global-requests-per-second" json:"global-requests-per-second"`

	// GlobalBurst is the maximum burst size for the global limiter.
	GlobalBurst int `yaml:"global-burst" json:"global-burst"`

	// PerKeyRequestsPerSecond is the maximum sustained request rate per API key.
	PerKeyRequestsPerSecond float64 `yaml:"per-key-requests-per-second" json:"per-key-requests-per-second"`

	// PerKeyBurst is the maximum burst size per API key.
	PerKeyBurst int `yaml:"per-key-burst" json:"per-key-burst"`
}

RateLimiterConfig configures the token-bucket rate limiter.

type RemoteManagement

type RemoteManagement struct {
	// AllowRemote toggles remote (non-localhost) access to management API.
	AllowRemote bool `yaml:"allow-remote"`
	// SecretKey is the management key (plaintext or bcrypt hashed). YAML key intentionally 'secret-key'.
	SecretKey string `yaml:"secret-key"`
	// DisableControlPanel skips serving and syncing the bundled management UI when true.
	DisableControlPanel bool `yaml:"disable-control-panel"`
	// PanelGitHubRepository overrides the GitHub repository used to fetch the management panel asset.
	// Accepts either a repository URL (https://github.com/org/repo) or an API releases endpoint.
	PanelGitHubRepository string `yaml:"panel-github-repository"`
}

RemoteManagement holds management API configuration under 'remote-management'.

type RequestEventsConfig

type RequestEventsConfig struct {
	// Enabled toggles structured request event logging.
	Enabled bool `yaml:"enabled" json:"enabled"`
	// Output destination: "stdout" or "file".
	Output string `yaml:"output" json:"output"`
	// FilePath is the path for NDJSON event logs when Output is "file".
	FilePath string `yaml:"file-path" json:"file-path"`
	// IncludeBody includes request/response bodies in events (warning: large).
	IncludeBody bool `yaml:"include-body" json:"include-body"`
}

RequestEventsConfig controls structured per-request event logging.

type RoutingConfig

type RoutingConfig struct {
	// Strategy selects the credential selection strategy.
	// Supported values: "round-robin" (default), "fill-first".
	Strategy string `yaml:"strategy,omitempty" json:"strategy,omitempty"`

	// AutoModelPriority defines a prioritized list of model IDs to use when "auto" is requested.
	// The server will pick the first available model from this list.
	// If none are available, it falls back to the default timestamp-based selection.
	AutoModelPriority []string `yaml:"auto-model-priority,omitempty" json:"auto-model-priority,omitempty"`
}

type SDKConfig

type SDKConfig struct {
	// ProxyURL is the URL of an optional proxy server to use for outbound requests.
	ProxyURL string `yaml:"proxy-url" json:"proxy-url"`

	// ForceModelPrefix requires explicit model prefixes (e.g., "teamA/gemini-3-pro-preview")
	// to target prefixed credentials. When false, unprefixed model requests may use prefixed
	// credentials as well.
	ForceModelPrefix bool `yaml:"force-model-prefix" json:"force-model-prefix"`

	// RequestLog enables or disables detailed request logging functionality.
	RequestLog bool `yaml:"request-log" json:"request-log"`

	// APIKeys is a list of keys for authenticating clients to this proxy server.
	APIKeys []string `yaml:"api-keys" json:"api-keys"`

	// Access holds request authentication provider configuration.
	Access AccessConfig `yaml:"auth,omitempty" json:"auth,omitempty"`

	// Streaming configures server-side streaming behavior (keep-alives and safe bootstrap retries).
	Streaming StreamingConfig `yaml:"streaming" json:"streaming"`

	// Intelligence configures the "Cortex" engine for model: "auto" routing.
	// It relies on the Plugin system and a specialized Router Model.
	Intelligence IntelligenceConfig `yaml:"intelligence" json:"intelligence"`

	// Routing controls credential selection behavior and auto-resolver priority.
	Routing RoutingConfig `yaml:"routing,omitempty" json:"routing,omitempty"`

	// AutoRouting configures the Phase 2 intelligent routing system.
	AutoRouting autoroute.Config `yaml:"auto-routing,omitempty" json:"auto-routing,omitempty"`

	// VirtualModels defines public model IDs backed by one or more concrete
	// provider/model members. These are routed by capability instead of by
	// provider-name inference (for example: ail-compound).
	VirtualModels map[string]VirtualModelConfig `yaml:"virtual-models,omitempty" json:"virtual_models,omitempty"`

	// Notifications configures the outbound notifications relay subsystem
	// (e.g. /v1/notifications/telegram/sendMessage). Lets sandboxed clients
	// emit messages to external services without ever holding the credentials.
	//
	// The yaml tag intentionally omits "omitempty": SaveConfigPreserveComments
	// round-trips the in-memory Config whenever legacy-migration fires, and
	// a zero-value Notifications struct with omitempty would silently drop the
	// block from disk — subsequent boots would then see telegram disabled even
	// though the template had enabled: true. Always emitting the block keeps
	// the on-disk state stable and makes "telegram_disabled" mean an operator
	// explicitly turned it off, not a serialisation artefact.
	Notifications NotificationsConfig `yaml:"notifications" json:"notifications"`
}

SDKConfig represents the application's configuration, loaded from a YAML file.

func (*SDKConfig) ConfigAPIKeyProvider

func (c *SDKConfig) ConfigAPIKeyProvider() *AccessProvider

ConfigAPIKeyProvider returns the first inline API key provider if present.

func (*SDKConfig) SanitizeIntelligence

func (c *SDKConfig) SanitizeIntelligence()

SanitizeIntelligence normalizes the intelligence routing configuration.

type SecurityConfig

type SecurityConfig struct {
	// AuditLogEnabled toggles audit logging of all autonomous actions.
	AuditLogEnabled bool `yaml:"audit_log_enabled" json:"audit_log_enabled"`

	// AuditLogPath is the file path for the audit log.
	// Default: "./logs/superbrain_audit.log"
	AuditLogPath string `yaml:"audit_log_path" json:"audit_log_path"`

	// ForbiddenOperations lists operation types that require human approval
	// and should never be performed autonomously, even in autopilot mode.
	// Example: ["file_delete", "system_command"]
	ForbiddenOperations []string `yaml:"forbidden_operations,omitempty" json:"forbidden_operations,omitempty"`
}

SecurityConfig defines audit logging and safety control settings.

type SemanticCacheConfig

type SemanticCacheConfig struct {
	Enabled             bool    `yaml:"enabled" json:"enabled"`
	SimilarityThreshold float64 `yaml:"similarity-threshold,omitempty" json:"similarity-threshold,omitempty"`
	MaxSize             int     `yaml:"max-size,omitempty" json:"max-size,omitempty"`
}

SemanticCacheConfig configures semantic caching.

type SemanticTierConfig

type SemanticTierConfig struct {
	Enabled             bool    `yaml:"enabled" json:"enabled"`
	ConfidenceThreshold float64 `yaml:"confidence-threshold,omitempty" json:"confidence-threshold,omitempty"`
}

SemanticTierConfig configures semantic intent matching.

type SkillMatchingConfig

type SkillMatchingConfig struct {
	Enabled             bool    `yaml:"enabled" json:"enabled"`
	ConfidenceThreshold float64 `yaml:"confidence-threshold,omitempty" json:"confidence-threshold,omitempty"`
}

SkillMatchingConfig configures skill matching behavior.

type SkillsConfig

type SkillsConfig struct {
	Enabled   bool   `yaml:"enabled" json:"enabled"`
	Directory string `yaml:"directory,omitempty" json:"directory,omitempty"`
}

SkillsConfig configures the skill registry.

type StdinInjectionConfig

type StdinInjectionConfig struct {
	// Mode controls stdin injection behavior.
	// Valid values:
	//   - "disabled": Never inject stdin responses
	//   - "conservative": Only inject for explicitly whitelisted safe patterns
	//   - "autopilot": Automatically inject for all safe patterns
	Mode string `yaml:"mode" json:"mode"`

	// CustomPatterns defines additional prompt patterns to recognize and respond to.
	// Each pattern should include: name, regex, response, is_safe, description.
	CustomPatterns []StdinPattern `yaml:"custom_patterns,omitempty" json:"custom_patterns,omitempty"`

	// ForbiddenPatterns lists regex patterns that should never trigger automatic responses,
	// regardless of mode. Used to prevent dangerous operations like file deletion.
	ForbiddenPatterns []string `yaml:"forbidden_patterns,omitempty" json:"forbidden_patterns,omitempty"`
}

StdinInjectionConfig defines autonomous input injection settings.

type StdinPattern

type StdinPattern struct {
	// Name is a unique identifier for this pattern.
	Name string `yaml:"name" json:"name"`

	// Regex is the regular expression pattern to match in process output.
	Regex string `yaml:"regex" json:"regex"`

	// Response is the text to inject into stdin when the pattern is matched.
	Response string `yaml:"response" json:"response"`

	// IsSafe indicates whether this pattern is safe for automatic injection in autopilot mode.
	IsSafe bool `yaml:"is_safe" json:"is_safe"`

	// Description provides human-readable context about what this pattern matches.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
}

StdinPattern defines a recognizable prompt pattern and its automatic response.

type SteeringConfig

type SteeringConfig struct {
	Enabled     bool   `yaml:"enabled" json:"enabled"`
	SteeringDir string `yaml:"steering-dir,omitempty" json:"steering-dir,omitempty"`
	RulesDir    string `yaml:"rules-dir,omitempty" json:"rules-dir,omitempty"` // Alias for SteeringDir
	HotReload   bool   `yaml:"hot-reload,omitempty" json:"hot-reload,omitempty"`
}

SteeringConfig configures the steering engine.

type StreamHealthConfig added in v0.2.0

type StreamHealthConfig struct {
	// FirstByteTimeout is the max time to wait for the first byte from upstream
	// before classifying the request as stalled. Pre-first-byte stalls are
	// transparently recoverable (nothing has been flushed to the client yet).
	//
	// Used as the global default; per-provider overrides live in PerProvider.
	FirstByteTimeout time.Duration `yaml:"first-byte-timeout" json:"first-byte-timeout"`

	// StallTimeout is the max gap between SSE chunks before we classify the stream
	// as stalled and cancel it. Post-first-chunk stalls CANNOT be transparently
	// recovered — we terminate with an SSE error event.
	StallTimeout time.Duration `yaml:"stall-timeout" json:"stall-timeout"`

	// PerProvider maps provider-name → first-byte timeout override. Use this
	// to give specific providers more headroom when their upstream is known
	// to be slow on first-byte (e.g. cold-start or large-context requests).
	// Case-sensitive; lowercase preferred (matches the provider `name` field
	// in openai-compatibility providers). Unknown providers fall back to
	// FirstByteTimeout.
	PerProvider map[string]time.Duration `yaml:"per-provider" json:"per-provider"`
}

StreamHealthConfig controls server-sent-event stream health and stall detection.

func (StreamHealthConfig) ResolveFirstByte added in v0.5.22

func (s StreamHealthConfig) ResolveFirstByte(provider string) time.Duration

ResolveFirstByte returns the effective first-byte timeout for the named provider. Unknown providers fall back to the global FirstByteTimeout. A zero entry in PerProvider is treated as "use the global default".

type StreamingConfig

type StreamingConfig struct {
	// KeepAliveSeconds controls how often the server emits SSE heartbeats (": keep-alive\n\n").
	// nil means default (15 seconds). <= 0 disables keep-alives.
	KeepAliveSeconds *int `yaml:"keepalive-seconds,omitempty" json:"keepalive-seconds,omitempty"`

	// BootstrapRetries controls how many times the server may retry a streaming request before any bytes are sent,
	// to allow auth rotation / transient recovery.
	// nil means default (2). 0 disables bootstrap retries.
	BootstrapRetries *int `yaml:"bootstrap-retries,omitempty" json:"bootstrap-retries,omitempty"`
}

StreamingConfig holds server streaming behavior configuration.

type SuperbrainConfig

type SuperbrainConfig struct {
	// Enabled toggles the entire Superbrain system. When false, the gateway operates
	// in legacy pass-through mode with no monitoring or healing.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Mode controls the operational mode of the Superbrain system.
	// Valid values:
	//   - "disabled": Superbrain is completely disabled (same as Enabled: false)
	//   - "observe": Monitor and log but take no autonomous actions
	//   - "diagnose": Diagnose failures and log proposed actions without executing them
	//   - "human-in-the-loop": Diagnose and queue actions for operator approval
	//   - "conservative": Enable autonomous healing for whitelisted safe actions only
	//   - "autopilot": Enable all autonomous healing capabilities
	Mode string `yaml:"mode" json:"mode"`

	// ComponentFlags provides fine-grained control over individual Superbrain components.
	// Each component can be independently enabled or disabled for gradual rollout.
	// When a component is disabled, its functionality is completely bypassed.
	ComponentFlags ComponentFlags `yaml:"component_flags" json:"component_flags"`

	// Overwatch configures real-time execution monitoring.
	Overwatch OverwatchConfig `yaml:"overwatch" json:"overwatch"`

	// Doctor configures AI-powered failure diagnosis.
	Doctor DoctorConfig `yaml:"doctor" json:"doctor"`

	// StdinInjection configures autonomous input injection for interactive prompts.
	StdinInjection StdinInjectionConfig `yaml:"stdin_injection" json:"stdin_injection"`

	// ContextSculptor configures pre-flight content optimization.
	ContextSculptor ContextSculptorConfig `yaml:"context_sculptor" json:"context_sculptor"`

	// Fallback configures intelligent failover routing.
	Fallback FallbackConfig `yaml:"fallback" json:"fallback"`

	// Consensus configures multi-model response verification.
	Consensus ConsensusConfig `yaml:"consensus" json:"consensus"`

	// Security configures audit logging and safety controls.
	Security SecurityConfig `yaml:"security" json:"security"`
}

SuperbrainConfig holds the intelligent orchestration and self-healing configuration. The Superbrain transforms switchAILocal from a passive proxy into an autonomous, self-healing AI gateway with real-time monitoring, failure diagnosis, and recovery.

type SwitchAIKey

type SwitchAIKey struct {
	// APIKey is the authentication key for accessing switchAI API services.
	APIKey string `yaml:"api-key" json:"api-key"`

	// Prefix optionally namespaces models for this credential (e.g., "teamA/deepseek").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL is the base URL for the switchAI API endpoint.
	// Default: https://switchai.traylinx.com/v1
	BaseURL string `yaml:"base-url" json:"base-url"`

	// ProxyURL overrides the global proxy setting for this API key if provided.
	ProxyURL string `yaml:"proxy-url" json:"proxy-url"`

	// ModelsURL optionally overrides the endpoint used to discover available models.
	ModelsURL string `yaml:"models-url,omitempty" json:"models-url,omitempty"`

	// Models defines upstream model names and aliases for request routing.
	Models []SwitchAIModel `yaml:"models" json:"models"`

	// Headers optionally adds extra HTTP headers for requests sent with this key.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// ExcludedModels lists model IDs that should be excluded for this provider.
	ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
}

SwitchAIKey represents the configuration for a Traylinx switchAI API key, including the API key itself and an optional base URL for the API endpoint.

type SwitchAIModel

type SwitchAIModel struct {
	// Name is the upstream model identifier used when issuing requests.
	Name string `yaml:"name" json:"name"`

	// Alias is the client-facing model name that maps to Name.
	Alias string `yaml:"alias" json:"alias"`
}

SwitchAIModel describes a mapping between an alias and the actual upstream model name.

type TLSConfig

type TLSConfig struct {
	// Enable toggles HTTPS server mode.
	Enable bool `yaml:"enable" json:"enable"`
	// Cert is the path to the TLS certificate file.
	Cert string `yaml:"cert" json:"cert"`
	// Key is the path to the TLS private key file.
	Key string `yaml:"key" json:"key"`
}

TLSConfig holds HTTPS server settings.

type TelegramBot added in v0.5.0

type TelegramBot struct {
	// Name is the logical identifier callers use to select this bot.
	// The reserved name "default" is used when a request omits the bot field.
	Name string `yaml:"name" json:"name"`

	// Token is the bot HTTP API token from BotFather (e.g. "1234567890:AA...").
	// Server-side only — never echoed in responses or logs.
	Token string `yaml:"token" json:"token"`

	// AllowedChatIDs optionally restricts which chat_ids this bot will message.
	// Empty = allow any chat_id (the bot's own anti-spam still applies upstream).
	// Non-empty = explicit allowlist; requests for other chat_ids return 403.
	AllowedChatIDs []int64 `yaml:"allowed-chat-ids,omitempty" json:"allowed-chat-ids,omitempty"`
}

TelegramBot is a single named Telegram bot configuration entry.

func (TelegramBot) IsChatAllowed added in v0.5.0

func (b TelegramBot) IsChatAllowed(chatID int64) bool

IsChatAllowed reports whether the given chat_id is permitted for this bot. An empty AllowedChatIDs list means any chat_id is permitted.

type TelegramNotificationsConfig added in v0.5.0

type TelegramNotificationsConfig struct {
	// Enabled toggles the entire /v1/notifications/telegram/* endpoint family.
	// Default: derived from len(Bots) > 0. When false (or no bots configured),
	// the endpoint returns 503 with a clear "telegram notifications not configured"
	// message — never silently accepts requests.
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Bots is the list of named Telegram bots the gateway can relay through.
	// Callers reference a bot by name; tokens are never exposed to clients.
	// At least one bot with name "default" is the convention; additional named
	// bots let one switchAILocal serve multiple Tytus pods with distinct bots.
	Bots []TelegramBot `yaml:"bots,omitempty" json:"bots,omitempty"`
}

TelegramNotificationsConfig holds Telegram-specific notification settings.

type VerificationConfig

type VerificationConfig struct {
	Enabled                 bool    `yaml:"enabled" json:"enabled"`
	ConfidenceThresholdLow  float64 `yaml:"confidence-threshold-low,omitempty" json:"confidence-threshold-low,omitempty"`
	ConfidenceThresholdHigh float64 `yaml:"confidence-threshold-high,omitempty" json:"confidence-threshold-high,omitempty"`
}

VerificationConfig configures classification verification.

type VertexCompatKey

type VertexCompatKey struct {
	// APIKey is the authentication key for accessing the Vertex-compatible API.
	// Maps to the x-goog-api-key header.
	APIKey string `yaml:"api-key" json:"api-key"`

	// Prefix optionally namespaces model aliases for this credential (e.g., "teamA/vertex-pro").
	Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`

	// BaseURL is the base URL for the Vertex-compatible API endpoint.
	// The executor will append "/v1/publishers/google/models/{model}:action" to this.
	// Example: "https://zenmux.ai/api" becomes "https://zenmux.ai/api/v1/publishers/google/models/..."
	BaseURL string `yaml:"base-url,omitempty" json:"base-url,omitempty"`

	// ProxyURL optionally overrides the global proxy for this API key.
	ProxyURL string `yaml:"proxy-url,omitempty" json:"proxy-url,omitempty"`

	// Headers optionally adds extra HTTP headers for requests sent with this key.
	// Commonly used for cookies, user-agent, and other authentication headers.
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// Models defines the model configurations including aliases for routing.
	Models []VertexCompatModel `yaml:"models,omitempty" json:"models,omitempty"`
}

VertexCompatKey represents the configuration for Vertex AI-compatible API keys. This supports third-party services that use Vertex AI-style endpoint paths (/publishers/google/models/{model}:streamGenerateContent) but authenticate with simple API keys instead of Google Cloud service account credentials.

Example services: zenmux.ai and similar Vertex-compatible providers.

type VertexCompatModel

type VertexCompatModel struct {
	// Name is the actual model name used by the external provider.
	Name string `yaml:"name" json:"name"`

	// Alias is the model name alias that clients will use to reference this model.
	Alias string `yaml:"alias" json:"alias"`
}

VertexCompatModel represents a model configuration for Vertex compatibility, including the actual model name and its alias for API routing.

type VirtualModelCapabilitiesConfig added in v0.5.18

type VirtualModelCapabilitiesConfig struct {
	Operations        []string `yaml:"operations,omitempty" json:"operations,omitempty"`
	Input             []string `yaml:"input,omitempty" json:"input,omitempty"`
	Output            []string `yaml:"output,omitempty" json:"output,omitempty"`
	Tools             bool     `yaml:"tools,omitempty" json:"tools,omitempty"`
	Context           int      `yaml:"context,omitempty" json:"context,omitempty"`
	ProofRequiredFor  []string `yaml:"proof_required_for,omitempty" json:"proof_required_for,omitempty"`
	AgenticSafe       bool     `yaml:"agentic_safe,omitempty" json:"agentic_safe,omitempty"`
	AgenticSafeAfter  string   `yaml:"agentic_safe_after,omitempty" json:"agentic_safe_after,omitempty"`
	ToolHistoryReplay bool     `yaml:"tool_history_replay,omitempty" json:"tool_history_replay,omitempty"`
}

VirtualModelCapabilitiesConfig is explicit capability metadata for virtual pool selection. It is intentionally config-local to avoid registry/config package cycles.

type VirtualModelConfig added in v0.5.18

type VirtualModelConfig struct {
	Description   string                     `yaml:"description,omitempty" json:"description,omitempty"`
	Expose        bool                       `yaml:"expose,omitempty" json:"expose,omitempty"`
	Strategy      string                     `yaml:"strategy,omitempty" json:"strategy,omitempty"`
	Fallback      bool                       `yaml:"fallback,omitempty" json:"fallback,omitempty"`
	ResponseModel string                     `yaml:"response_model,omitempty" json:"response_model,omitempty"`
	Members       []VirtualModelMemberConfig `yaml:"members" json:"members"`
}

VirtualModelConfig describes a public model ID that routes to eligible provider+native-model members.

type VirtualModelMemberConfig added in v0.5.18

type VirtualModelMemberConfig struct {
	ID           string                         `yaml:"id" json:"id"`
	Provider     string                         `yaml:"provider" json:"provider"`
	Model        string                         `yaml:"model" json:"model"`
	Enabled      *bool                          `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Weight       int                            `yaml:"weight,omitempty" json:"weight,omitempty"`
	Capabilities VirtualModelCapabilitiesConfig `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`
	Visibility   string                         `yaml:"visibility,omitempty" json:"visibility,omitempty"`
	Proof        []string                       `yaml:"proof,omitempty" json:"proof,omitempty"`
}

VirtualModelMemberConfig describes one concrete provider+model backend in a virtual model pool.

Jump to

Keyboard shortcuts

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