Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyToolInterceptorDefaults(config *ToolInterceptorConfig)
- func CanBindRulesToScenario(scenario RuleScenario) bool
- func CanUseScenarioInPath(scenario RuleScenario) bool
- func IsProfiledScenario(raw RuleScenario) bool
- func IsValidRecordingMode(mode string) bool
- func IsValidTactic(tacticStr string) bool
- func RegisterScenario(descriptor ScenarioDescriptor) error
- type AdaptiveParams
- type AdaptiveTactic
- type AuthType
- type DiscoveryResult
- type FlexibleBool
- type GroupingStrategy
- type HealthFilter
- func (hf *HealthFilter) Filter(services []*loadbalance.Service) []*loadbalance.Service
- func (hf *HealthFilter) FilterWithFallback(services []*loadbalance.Service) []*loadbalance.Service
- func (hf *HealthFilter) GetHealthMonitor() *loadbalance.HealthMonitor
- func (hf *HealthFilter) IsHealthy(serviceID string) bool
- type IDEAdapter
- type IDESource
- type LatencyBasedParams
- type LatencyBasedTactic
- type LoadBalancingTactic
- type OAuthDetail
- type ProfileMeta
- type Provider
- type RandomParams
- type RandomTactic
- type RecordingMode
- type Rule
- func (r *Rule) GetActiveServices() []*loadbalance.Service
- func (r *Rule) GetCurrentService() *loadbalance.Service
- func (r *Rule) GetCurrentServiceID() string
- func (r *Rule) GetDefaultModel() string
- func (r *Rule) GetDefaultProvider() string
- func (r *Rule) GetScenario() RuleScenario
- func (r *Rule) GetServices() []*loadbalance.Service
- func (r *Rule) GetTacticType() loadbalance.TacticType
- func (r *Rule) GetUUID() string
- func (r *Rule) SetCurrentServiceID(serviceID string)
- func (r *Rule) ToJSON() interface{}
- type RuleFlags
- type RuleScenario
- type ScanResult
- type ScenarioConfig
- type ScenarioDescriptor
- type ScenarioFlags
- type ScenarioTransport
- type Skill
- type SkillLocation
- type SpeedBasedParams
- type SpeedBasedTactic
- type Tactic
- type TacticParams
- func DefaultAdaptiveParams() TacticParams
- func DefaultHybridParams() TacticParams
- func DefaultLatencyBasedParams() TacticParams
- func DefaultRandomParams() TacticParams
- func DefaultRoundRobinParams() TacticParams
- func DefaultSpeedBasedParams() TacticParams
- func DefaultTokenBasedParams() TacticParams
- func NewAdaptiveParams(latencyWeight, tokenWeight, speedWeight, healthWeight float64, ...) TacticParams
- func NewHybridParams(requestThreshold, tokenThreshold int64) TacticParams
- func NewLatencyBasedParams(latencyThresholdMs int64, sampleWindowSize int, percentile float64, ...) TacticParams
- func NewRandomParams() TacticParams
- func NewSpeedBasedParams(minSamplesRequired int, speedThresholdTps float64, sampleWindowSize int) TacticParams
- func NewTokenBasedParams(threshold int64) TacticParams
- type ThinkingEffortLevel
- type ThinkingMode
- type TokenBasedParams
- type TokenBasedTactic
- type ToolInterceptorConfig
- type ToolInterceptorOverride
Constants ¶
const ProfileSeparator = ":"
ProfileSeparator is used to split "scenario:profile_id" strings.
Variables ¶
var ThinkingBudgetMapping = map[ThinkingEffortLevel]int64{ ThinkingEffortDefault: 31999, ThinkingEffortLow: 1024, ThinkingEffortMedium: 5120, ThinkingEffortHigh: 20480, ThinkingEffortMax: 31999, }
ThinkingBudgetMapping defines budget_tokens for each effort level Note: Default max is 31,999 tokens per Claude Code documentation
Functions ¶
func ApplyToolInterceptorDefaults ¶ added in v0.260305.1400
func ApplyToolInterceptorDefaults(config *ToolInterceptorConfig)
ApplyToolInterceptorDefaults applies default values to tool interceptor config
func CanBindRulesToScenario ¶ added in v0.260331.0
func CanBindRulesToScenario(scenario RuleScenario) bool
func CanUseScenarioInPath ¶ added in v0.260331.0
func CanUseScenarioInPath(scenario RuleScenario) bool
func IsProfiledScenario ¶ added in v0.260331.0
func IsProfiledScenario(raw RuleScenario) bool
IsProfiledScenario returns true if the scenario string contains a profile suffix.
func IsValidRecordingMode ¶ added in v0.260324.0
IsValidRecordingMode checks if the given string is a valid recording mode
func IsValidTactic ¶
IsValidTactic checks if the given tactic string is valid
func RegisterScenario ¶ added in v0.260331.0
func RegisterScenario(descriptor ScenarioDescriptor) error
Types ¶
type AdaptiveParams ¶ added in v0.260331.0
type AdaptiveParams struct {
LatencyWeight float64 `json:"latency_weight"` // Weight for latency (0-1)
TokenWeight float64 `json:"token_weight"` // Weight for token usage (0-1)
SpeedWeight float64 `json:"speed_weight"` // Weight for token speed (0-1)
HealthWeight float64 `json:"health_weight"` // Weight for health status (0-1)
MaxLatencyMs int64 `json:"max_latency_ms"` // Maximum acceptable latency
MaxTokenUsage int64 `json:"max_token_usage"` // Maximum acceptable token usage
MinSpeedTps float64 `json:"min_speed_tps"` // Minimum acceptable tokens per second
ScoringMode string `json:"scoring_mode"` // "weighted_sum", "multiplicative", "rank_based"
}
AdaptiveParams holds parameters for adaptive multi-dimensional tactic
func AsAdaptiveParams ¶ added in v0.260331.0
func AsAdaptiveParams(p TacticParams) (AdaptiveParams, bool)
type AdaptiveTactic ¶ added in v0.260331.0
type AdaptiveTactic struct {
LatencyWeight float64 // Weight for latency (0-1)
TokenWeight float64 // Weight for token usage (0-1)
SpeedWeight float64 // Weight for token speed (0-1)
HealthWeight float64 // Weight for health status (0-1)
MaxLatencyMs int64 // Maximum acceptable latency for normalization
MaxTokenUsage int64 // Maximum acceptable token usage for normalization
MinSpeedTps float64 // Minimum acceptable tokens per second for normalization
ScoringMode string // "weighted_sum", "multiplicative", "rank_based"
}
AdaptiveTactic implements composite multi-dimensional routing
func NewAdaptiveTactic ¶ added in v0.260331.0
func NewAdaptiveTactic(latencyWeight, tokenWeight, speedWeight, healthWeight float64, maxLatencyMs int64, maxTokenUsage int64, minSpeedTps float64, scoringMode string) *AdaptiveTactic
NewAdaptiveTactic creates a new adaptive multi-dimensional tactic
func (*AdaptiveTactic) GetName ¶ added in v0.260331.0
func (at *AdaptiveTactic) GetName() string
func (*AdaptiveTactic) GetType ¶ added in v0.260331.0
func (at *AdaptiveTactic) GetType() loadbalance.TacticType
func (*AdaptiveTactic) SelectService ¶ added in v0.260331.0
func (at *AdaptiveTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects service based on composite multi-dimensional scoring
type DiscoveryResult ¶ added in v0.260204.1200
type DiscoveryResult struct {
TotalIdesScanned int `json:"total_ides_scanned"`
IdesFound []IDESource `json:"ides_found"`
SkillsFound int `json:"skills_found"`
Locations []SkillLocation `json:"locations"`
}
DiscoveryResult represents the result of IDE discovery
type FlexibleBool ¶ added in v0.260305.1400
type FlexibleBool bool
FlexibleBool is a boolean type that can unmarshal from both bool and int (0/1) This handles cases where JSON data may contain numeric values instead of booleans
func (FlexibleBool) MarshalJSON ¶ added in v0.260305.1400
func (fb FlexibleBool) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler for FlexibleBool
func (*FlexibleBool) UnmarshalJSON ¶ added in v0.260305.1400
func (fb *FlexibleBool) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for FlexibleBool
type GroupingStrategy ¶ added in v0.260204.1200
type GroupingStrategy struct {
// Mode: "flat" (no grouping), "auto" (automatic based on file count), "pattern" (by pattern)
Mode string `json:"mode"`
// GroupPattern: pattern for grouping when mode="pattern", e.g., "skills" groups by skills directory
// The pattern is searched in the file path, and everything up to (and including) the match becomes the group key
GroupPattern string `json:"group_pattern,omitempty"`
// MinFilesForSplit: minimum files before splitting a group (only for auto mode)
MinFilesForSplit int `json:"min_files_for_split,omitempty"`
}
GroupingStrategy defines how skills should be grouped in the UI
type HealthFilter ¶ added in v0.260305.1400
type HealthFilter struct {
// contains filtered or unexported fields
}
HealthFilter filters services based on their health status
func NewHealthFilter ¶ added in v0.260305.1400
func NewHealthFilter(monitor *loadbalance.HealthMonitor) *HealthFilter
NewHealthFilter creates a new health filter with the given health monitor
func (*HealthFilter) Filter ¶ added in v0.260305.1400
func (hf *HealthFilter) Filter(services []*loadbalance.Service) []*loadbalance.Service
Filter filters out unhealthy services from the given list Returns only healthy services. If no healthy services are found, returns an empty slice (not nil).
func (*HealthFilter) FilterWithFallback ¶ added in v0.260305.1400
func (hf *HealthFilter) FilterWithFallback(services []*loadbalance.Service) []*loadbalance.Service
FilterWithFallback filters services and returns healthy ones. If no healthy services are found, returns all services as a fallback. This is useful when you want to avoid complete failure even if all services are marked unhealthy.
func (*HealthFilter) GetHealthMonitor ¶ added in v0.260305.1400
func (hf *HealthFilter) GetHealthMonitor() *loadbalance.HealthMonitor
GetHealthMonitor returns the underlying health monitor
func (*HealthFilter) IsHealthy ¶ added in v0.260305.1400
func (hf *HealthFilter) IsHealthy(serviceID string) bool
IsHealthy checks if a specific service is healthy
type IDEAdapter ¶ added in v0.260204.1200
type IDEAdapter struct {
Key IDESource `json:"key"`
DisplayName string `json:"display_name"`
RelativeDetectDir string `json:"relative_detect_dir"`
Icon string `json:"icon"`
SupportsSymlink bool `json:"supports_symlink"`
// ScanPatterns defines glob patterns for finding skill files (e.g., ["*.md", "skill/*.md"])
// Patterns are relative to the detected IDE base directory (relative_detect_dir).
// If empty, defaults to ["**/*.md"]
ScanPatterns []string `json:"scan_patterns,omitempty"`
// GroupingStrategy defines how skills should be grouped in the UI
GroupingStrategy *GroupingStrategy `json:"grouping_strategy,omitempty"`
}
IDEAdapter defines the configuration for an IDE adapter
type IDESource ¶ added in v0.260204.1200
type IDESource string
IDESource represents the type of IDE/source for skills
const ( IDESourceClaudeCode IDESource = "claude-code" IDESourceOpenCode IDESource = "opencode" IDESourceVSCode IDESource = "vscode" IDESourceCursor IDESource = "cursor" IDESourceCodex IDESource = "codex" IDESourceAntigravity IDESource = "antigravity" IDESourceAmp IDESource = "amp" IDESourceKiloCode IDESource = "kilo-code" IDESourceRooCode IDESource = "roo-code" IDESourceGoose IDESource = "goose" IDESourceGeminiCLI IDESource = "gemini-cli" IDESourceGitHubCopilot IDESource = "github-copilot" IDESourceClawdbot IDESource = "clawdbot" IDESourceDroid IDESource = "droid" IDESourceWindsurf IDESource = "windsurf" IDESourceCustom IDESource = "custom" )
type LatencyBasedParams ¶ added in v0.260331.0
type LatencyBasedParams struct {
LatencyThresholdMs int64 `json:"latency_threshold_ms"` // Switch if latency exceeds this (ms)
SampleWindowSize int `json:"sample_window_size"` // Number of samples to keep
Percentile float64 `json:"percentile"` // Which percentile to use (0.5 = p50, 0.95 = p95, 0.99 = p99)
ComparisonMode string `json:"comparison_mode"` // "avg", "p50", "p95", "p99"
}
LatencyBasedParams holds parameters for latency-based tactic
func AsLatencyBasedParams ¶ added in v0.260331.0
func AsLatencyBasedParams(p TacticParams) (LatencyBasedParams, bool)
type LatencyBasedTactic ¶ added in v0.260331.0
type LatencyBasedTactic struct {
LatencyThresholdMs int64 // Switch if latency exceeds this (ms)
SampleWindowSize int // Number of samples to keep
Percentile float64 // Which percentile to use
ComparisonMode string // "avg", "p50", "p95", "p99"
}
LatencyBasedTactic implements load balancing based on response latency
func NewLatencyBasedTactic ¶ added in v0.260331.0
func NewLatencyBasedTactic(latencyThresholdMs int64, sampleWindowSize int, percentile float64, comparisonMode string) *LatencyBasedTactic
NewLatencyBasedTactic creates a new latency-based tactic
func (*LatencyBasedTactic) GetName ¶ added in v0.260331.0
func (lt *LatencyBasedTactic) GetName() string
func (*LatencyBasedTactic) GetType ¶ added in v0.260331.0
func (lt *LatencyBasedTactic) GetType() loadbalance.TacticType
func (*LatencyBasedTactic) SelectService ¶ added in v0.260331.0
func (lt *LatencyBasedTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects service based on latency
type LoadBalancingTactic ¶
type LoadBalancingTactic interface {
SelectService(rule *Rule) *loadbalance.Service
GetName() string
GetType() loadbalance.TacticType
}
LoadBalancingTactic defines the interface for load balancing strategies
func CreateTacticWithTypedParams ¶
func CreateTacticWithTypedParams(tacticType loadbalance.TacticType, params TacticParams) LoadBalancingTactic
func GetDefaultTactic ¶
func GetDefaultTactic(tType loadbalance.TacticType) LoadBalancingTactic
type OAuthDetail ¶
type OAuthDetail struct {
AccessToken string `json:"access_token"` // OAuth access token
ProviderType string `json:"provider_type"` // anthropic, google, etc. for token manager lookup
UserID string `json:"user_id"` // OAuth user identifier
RefreshToken string `json:"refresh_token"` // Token for refreshing access token
ExpiresAt string `json:"expires_at"` // Token expiration time (RFC3339)
ExtraFields map[string]interface{} `json:"extra_fields"` // Any extra field for some special clients
}
OAuthDetail contains OAuth-specific authentication information
func (*OAuthDetail) IsExpired ¶
func (o *OAuthDetail) IsExpired() bool
IsExpired checks if the OAuth token is expired
type ProfileMeta ¶ added in v0.260331.0
type ProfileMeta struct {
ID string `json:"id" yaml:"id"` // Profile ID (e.g. "p1")
Name string `json:"name" yaml:"name"` // Human-readable name (unique within base scenario)
}
ProfileMeta stores metadata for a scenario profile. Profiles allow multiple Rule + ScenarioFlags configurations per base scenario. A profile is identified by a short service-generated ID (e.g. "p1", "p2").
type Provider ¶
type Provider struct {
UUID string `json:"uuid"`
Name string `json:"name"`
APIBase string `json:"api_base"`
APIStyle protocol.APIStyle `json:"api_style"` // "openai" or "anthropic", defaults to "openai"
Token string `json:"token"` // API key for api_key auth type
NoKeyRequired bool `json:"no_key_required"`
Enabled bool `json:"enabled"`
ProxyURL string `json:"proxy_url"` // HTTP or SOCKS proxy URL (e.g., "http://127.0.0.1:7890" or "socks5://127.0.0.1:1080")
Timeout int64 `json:"timeout,omitempty"` // Request timeout in seconds (default: 1800 = 30 minutes)
Tags []string `json:"tags,omitempty"` // Provider tags for categorization
Models []string `json:"models,omitempty"` // Available models for this provider (cached)
LastUpdated string `json:"last_updated,omitempty"` // Last update timestamp
// Auth configuration
AuthType AuthType `json:"auth_type"` // api_key or oauth
OAuthDetail *OAuthDetail `json:"oauth_detail,omitempty"` // OAuth credentials (only for oauth auth type)
}
Provider represents an AI model api key and provider configuration
func (*Provider) GetAccessToken ¶
GetAccessToken returns the access token based on auth type
func (*Provider) IsClaudeCodeProvider ¶ added in v0.260324.0
IsClaudeCodeProvider checks if this provider is using Claude Code OAuth
func (*Provider) IsOAuthExpired ¶
IsOAuthExpired checks if the OAuth token is expired (only valid for oauth auth type)
func (*Provider) IsOAuthToken ¶ added in v0.260324.0
IsOAuthToken checks if the current access token is an OAuth token by detecting the sk-ant-oat prefix. This provides runtime detection independent of the AuthType field.
type RandomParams ¶
type RandomParams struct{}
RandomParams represents parameters for random tactic (currently empty but extensible)
func AsRandomParams ¶
func AsRandomParams(p TacticParams) (RandomParams, bool)
type RandomTactic ¶
type RandomTactic struct{}
RandomTactic implements random selection with weighted probability
func NewRandomTactic ¶
func NewRandomTactic() *RandomTactic
NewRandomTactic creates a new random tactic
func (*RandomTactic) GetName ¶
func (rt *RandomTactic) GetName() string
func (*RandomTactic) GetType ¶
func (rt *RandomTactic) GetType() loadbalance.TacticType
func (*RandomTactic) SelectService ¶
func (rt *RandomTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects a service randomly based on weights
type RecordingMode ¶ added in v0.260324.0
type RecordingMode string
RecordingMode represents the recording mode for scenario recording
const ( RecordingModeDisabled RecordingMode = "" // Recording disabled (default) RecordingModeRequest RecordingMode = "request" // Record request only RecordingModeResponse RecordingMode = "response" // Record response only RecordingModeRequestResponse RecordingMode = "request_response" // Record both request and response )
type Rule ¶
type Rule struct {
UUID string `json:"uuid"`
Scenario RuleScenario `json:"scenario,required" yaml:"scenario"` // openai, anthropic, claude_code; defaults to openai
RequestModel string `json:"request_model" yaml:"request_model"`
ResponseModel string `json:"response_model" yaml:"response_model"`
Description string `json:"description"`
Services []*loadbalance.Service `json:"services" yaml:"services"`
// Per-rule feature flags (e.g. cursor_compat / cursor_compat_auto).
Flags RuleFlags `json:"flags,omitempty" yaml:"flags,omitempty"`
// CurrentServiceID is persisted to SQLite, not JSON (provider:model format)
// This identifies the current service for round-robin load balancing
CurrentServiceID string `json:"-" yaml:"-"`
// Unified Tactic Configuration
LBTactic Tactic `json:"lb_tactic" yaml:"lb_tactic"`
Active bool `json:"active" yaml:"active"`
// Smart Routing Configuration
SmartEnabled bool `json:"smart_enabled" yaml:"smart_enabled"`
SmartAffinity bool `json:"smart_affinity,omitempty" yaml:"smart_affinity,omitempty"`
SmartRouting []smartrouting.SmartRouting `json:"smart_routing,omitempty" yaml:"smart_routing,omitempty"`
}
Rule represents a request/response configuration with load balancing support
func (*Rule) GetActiveServices ¶
func (r *Rule) GetActiveServices() []*loadbalance.Service
GetActiveServices returns all active services with initialized stats
func (*Rule) GetCurrentService ¶
func (r *Rule) GetCurrentService() *loadbalance.Service
GetCurrentService returns the current active service based on CurrentServiceID
func (*Rule) GetCurrentServiceID ¶ added in v0.260204.1200
GetCurrentServiceID returns the current service ID
func (*Rule) GetDefaultModel ¶
GetDefaultModel returns the model from the currently selected service using load balancing tactic
func (*Rule) GetDefaultProvider ¶
GetDefaultProvider returns the provider from the currently selected service using load balancing tactic
func (*Rule) GetScenario ¶
func (r *Rule) GetScenario() RuleScenario
GetScenario returns the scenario, defaulting to openai if empty
func (*Rule) GetServices ¶
func (r *Rule) GetServices() []*loadbalance.Service
GetServices returns the services to use for this rule
func (*Rule) GetTacticType ¶
func (r *Rule) GetTacticType() loadbalance.TacticType
GetTacticType returns the load balancing tactic type
func (*Rule) SetCurrentServiceID ¶ added in v0.260204.1200
SetCurrentServiceID sets the current service ID (used by RuleStateStore hydration)
type RuleFlags ¶ added in v0.260324.0
type RuleFlags struct {
// CursorCompat enables Cursor compatibility handling (rich content normalization, stream usage stripping, tool gating).
CursorCompat bool `json:"cursor_compat,omitempty" yaml:"cursor_compat,omitempty"`
// CursorCompatAuto enables Cursor auto-detection based on request headers.
CursorCompatAuto bool `json:"cursor_compat_auto,omitempty" yaml:"cursor_compat_auto,omitempty"`
}
RuleFlags represents per-rule feature flags.
type RuleScenario ¶
type RuleScenario string
RuleScenario represents the scenario for a routing rule
const ( ScenarioOpenAI RuleScenario = "openai" ScenarioAnthropic RuleScenario = "anthropic" ScenarioAgent RuleScenario = "agent" ScenarioCodex RuleScenario = "codex" ScenarioClaudeCode RuleScenario = "claude_code" ScenarioOpenCode RuleScenario = "opencode" ScenarioXcode RuleScenario = "xcode" ScenarioVSCode RuleScenario = "vscode" ScenarioSmartGuide RuleScenario = "_smart_guide" ScenarioGlobal RuleScenario = "_global" // Global flags that apply to all scenarios )
func BuiltinScenarios ¶ added in v0.260331.0
func BuiltinScenarios() []RuleScenario
func ParseScenarioProfile ¶ added in v0.260331.0
func ParseScenarioProfile(raw RuleScenario) (base RuleScenario, profileID string)
ParseScenarioProfile splits "claude_code:p1" into base scenario and profile ID. "claude_code" returns ("claude_code", "").
func ProfiledScenarioName ¶ added in v0.260331.0
func ProfiledScenarioName(base RuleScenario, profileID string) RuleScenario
ProfiledScenarioName combines base scenario and profile ID into "base:profileID".
type ScanResult ¶ added in v0.260204.1200
type ScanResult struct {
LocationID string `json:"location_id"`
Skills []Skill `json:"skills"`
Error string `json:"error,omitempty"`
}
ScanResult represents the result of scanning a location
type ScenarioConfig ¶
type ScenarioConfig struct {
Scenario RuleScenario `json:"scenario" yaml:"scenario"`
Flags ScenarioFlags `json:"flags" yaml:"flags"` // Scenario configuration flags
Extensions map[string]interface{} `json:"extensions,omitempty" yaml:"extensions,omitempty"` // Reserved for future extensions
}
ScenarioConfig represents configuration for a specific scenario
func (*ScenarioConfig) GetDefaultFlags ¶
func (sc *ScenarioConfig) GetDefaultFlags() ScenarioFlags
GetDefaultFlags returns default flags for a scenario
type ScenarioDescriptor ¶ added in v0.260331.0
type ScenarioDescriptor struct {
// ID is the stable scenario identifier stored on rules and scenario configs.
ID RuleScenario `json:"id" yaml:"id"`
// SupportedTransport declares which protocol surfaces may resolve rules bound to this scenario.
SupportedTransport []ScenarioTransport `json:"supported_transport" yaml:"supported_transport"`
// AllowRuleBinding controls whether API/CLI callers may create or update rules under this scenario.
AllowRuleBinding bool `json:"allow_rule_binding" yaml:"allow_rule_binding"`
// AllowDirectPathUse controls whether scenario-scoped HTTP paths like /openai/{scenario}/... are valid.
AllowDirectPathUse bool `json:"allow_direct_path_use" yaml:"allow_direct_path_use"`
}
func BuiltinScenarioDescriptors ¶ added in v0.260331.0
func BuiltinScenarioDescriptors() []ScenarioDescriptor
func GetScenarioDescriptor ¶ added in v0.260331.0
func GetScenarioDescriptor(scenario RuleScenario) (ScenarioDescriptor, bool)
func RegisteredScenarioDescriptors ¶ added in v0.260331.0
func RegisteredScenarioDescriptors() []ScenarioDescriptor
type ScenarioFlags ¶
type ScenarioFlags struct {
Unified bool `json:"unified" yaml:"unified"` // Single configuration for all models
Separate bool `json:"separate" yaml:"separate"` // Separate configuration for each model
Smart bool `json:"smart" yaml:"smart"` // Smart mode with automatic optimization
// Experimental feature flags (scenario-based opt-in)
SmartCompact bool `json:"smart_compact,omitempty" yaml:"smart_compact,omitempty"` // Enable smart compact (remove thinking blocks)
Recording bool `json:"recording,omitempty" yaml:"recording,omitempty"` // Enable scenario recording (legacy boolean flag)
RecordV2 RecordingMode `json:"record_v2,omitempty" yaml:"record_v2,omitempty"` // Enable scenario recording V2 (request/response/request_response)
Beta bool `json:"anthropic_beta,omitempty" yaml:"anthropic_beta,omitempty"` // Enable Anthropic beta features (e.g. extended thinking)
// Stream configuration flags
DisableStreamUsage bool `json:"disable_stream_usage,omitempty" yaml:"disable_stream_usage,omitempty"` // Don't include usage in streaming chunks (for incompatible clients like xcode)
// Thinking effort level (empty string = use model default)
ThinkingEffort ThinkingEffortLevel `json:"thinking_effort,omitempty" yaml:"thinking_effort,omitempty"`
// Thinking mode for claude_code scenario (default/adaptive/force)
// Using string directly instead of ThinkingMode type to avoid naming conflicts
ThinkingMode string `json:"thinking_mode,omitempty" yaml:"thinking_mode,omitempty"`
CleanHeader bool `json:"clean_header,omitempty" yaml:"clean_header,omitempty"` // Remove billing header from system messages (Claude Code only)
}
ScenarioFlags represents configuration flags for a scenario
type ScenarioTransport ¶ added in v0.260331.0
type ScenarioTransport string
const ( TransportOpenAI ScenarioTransport = "openai" TransportAnthropic ScenarioTransport = "anthropic" )
type Skill ¶ added in v0.260204.1200
type Skill struct {
ID string `json:"id"`
Name string `json:"name"`
Filename string `json:"filename"`
Path string `json:"path"`
LocationID string `json:"location_id"`
FileType string `json:"file_type"`
Description string `json:"description,omitempty"`
ContentHash string `json:"content_hash,omitempty"`
Size int64 `json:"size,omitempty"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
Content string `json:"content,omitempty"`
}
Skill represents a single skill file
type SkillLocation ¶ added in v0.260204.1200
type SkillLocation struct {
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
IDESource IDESource `json:"ide_source"`
SkillCount int `json:"skill_count"`
Icon string `json:"icon,omitempty"`
IsAutoDiscovered bool `json:"is_auto_discovered,omitempty"`
IsInstalled bool `json:"is_installed,omitempty"`
LastScannedAt time.Time `json:"last_scanned_at,omitempty"`
// GroupingStrategy: optional override for this specific location
GroupingStrategy *GroupingStrategy `json:"grouping_strategy,omitempty"`
}
SkillLocation represents a skill location (directory)
type SpeedBasedParams ¶ added in v0.260331.0
type SpeedBasedParams struct {
MinSamplesRequired int `json:"min_samples_required"` // Minimum samples before making decisions
SpeedThresholdTps float64 `json:"speed_threshold_tps"` // Minimum acceptable tokens per second
SampleWindowSize int `json:"sample_window_size"` // Number of speed samples to keep
}
SpeedBasedParams holds parameters for speed-based tactic
func AsSpeedBasedParams ¶ added in v0.260331.0
func AsSpeedBasedParams(p TacticParams) (SpeedBasedParams, bool)
type SpeedBasedTactic ¶ added in v0.260331.0
type SpeedBasedTactic struct {
MinSamplesRequired int // Minimum samples before making decisions
SpeedThresholdTps float64 // Minimum acceptable tokens per second
SampleWindowSize int // Number of speed samples to keep
}
SpeedBasedTactic implements load balancing based on token generation speed
func NewSpeedBasedTactic ¶ added in v0.260331.0
func NewSpeedBasedTactic(minSamplesRequired int, speedThresholdTps float64, sampleWindowSize int) *SpeedBasedTactic
NewSpeedBasedTactic creates a new speed-based tactic
func (*SpeedBasedTactic) GetName ¶ added in v0.260331.0
func (st *SpeedBasedTactic) GetName() string
func (*SpeedBasedTactic) GetType ¶ added in v0.260331.0
func (st *SpeedBasedTactic) GetType() loadbalance.TacticType
func (*SpeedBasedTactic) SelectService ¶ added in v0.260331.0
func (st *SpeedBasedTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects service based on token generation speed
type Tactic ¶
type Tactic struct {
Type loadbalance.TacticType `json:"type" yaml:"type"`
Params TacticParams `json:"params" yaml:"params"`
}
Tactic bundles the strategy type and its parameters together
func ParseTacticFromMap ¶
func ParseTacticFromMap(tacticType loadbalance.TacticType, params map[string]interface{}) Tactic
ParseTacticFromMap creates a Tactic from a tactic type and parameter map. This is useful for parsing API request parameters into a Tactic configuration.
func (*Tactic) Instantiate ¶
func (tc *Tactic) Instantiate() LoadBalancingTactic
Instantiate converts the configuration into functional logic
func (*Tactic) UnmarshalJSON ¶
UnmarshalJSON handles the polymorphic decoding of TacticParams
type TacticParams ¶
type TacticParams interface {
// contains filtered or unexported methods
}
TacticParams represents parameters for different load balancing tactics This is a sealed type that can only be one of the specific tactic parameter types
func DefaultAdaptiveParams ¶ added in v0.260331.0
func DefaultAdaptiveParams() TacticParams
func DefaultHybridParams ¶
func DefaultHybridParams() TacticParams
func DefaultLatencyBasedParams ¶ added in v0.260331.0
func DefaultLatencyBasedParams() TacticParams
func DefaultRandomParams ¶
func DefaultRandomParams() TacticParams
func DefaultRoundRobinParams ¶
func DefaultRoundRobinParams() TacticParams
DefaultParams returns default parameters for each tactic type
func DefaultSpeedBasedParams ¶ added in v0.260331.0
func DefaultSpeedBasedParams() TacticParams
func DefaultTokenBasedParams ¶
func DefaultTokenBasedParams() TacticParams
func NewAdaptiveParams ¶ added in v0.260331.0
func NewHybridParams ¶
func NewHybridParams(requestThreshold, tokenThreshold int64) TacticParams
func NewLatencyBasedParams ¶ added in v0.260331.0
func NewLatencyBasedParams(latencyThresholdMs int64, sampleWindowSize int, percentile float64, comparisonMode string) TacticParams
func NewRandomParams ¶
func NewRandomParams() TacticParams
func NewSpeedBasedParams ¶ added in v0.260331.0
func NewSpeedBasedParams(minSamplesRequired int, speedThresholdTps float64, sampleWindowSize int) TacticParams
func NewTokenBasedParams ¶
func NewTokenBasedParams(threshold int64) TacticParams
Helper constructors for creating tactic parameters
type ThinkingEffortLevel ¶ added in v0.260307.0
type ThinkingEffortLevel = string
ThinkingEffortLevel represents the thinking effort level for extended thinking
const ( ThinkingEffortLow ThinkingEffortLevel = "low" ThinkingEffortMedium ThinkingEffortLevel = "medium" ThinkingEffortHigh ThinkingEffortLevel = "high" ThinkingEffortMax ThinkingEffortLevel = "max" ThinkingEffortDefault ThinkingEffortLevel = "" // Use model default )
type ThinkingMode ¶ added in v0.260324.0
type ThinkingMode string
ThinkingMode represents the thinking mode for extended thinking
const ( ThinkingModeDefault ThinkingMode = "default" // Use model default ThinkingModeAdaptive ThinkingMode = "adaptive" // Model decides when to use ThinkingModeForce ThinkingMode = "force" // Force for all requests )
type TokenBasedParams ¶
type TokenBasedParams struct {
TokenThreshold int64 `json:"token_threshold"` // Threshold for token consumption before switching
}
TokenBasedParams holds parameters for token-based tactic
func AsTokenBasedParams ¶
func AsTokenBasedParams(p TacticParams) (TokenBasedParams, bool)
Type assertion helpers for TacticParams
type TokenBasedTactic ¶
type TokenBasedTactic struct {
TokenThreshold int64 // Threshold for token consumption before switching
}
TokenBasedTactic implements load balancing based on token consumption
func NewTokenBasedTactic ¶
func NewTokenBasedTactic(tokenThreshold int64) *TokenBasedTactic
NewTokenBasedTactic creates a new token-based tactic
func (*TokenBasedTactic) GetName ¶
func (tb *TokenBasedTactic) GetName() string
func (*TokenBasedTactic) GetType ¶
func (tb *TokenBasedTactic) GetType() loadbalance.TacticType
func (*TokenBasedTactic) SelectService ¶
func (tb *TokenBasedTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects service based on token consumption thresholds
type ToolInterceptorConfig ¶ added in v0.260224.0
type ToolInterceptorConfig struct {
PreferLocalSearch FlexibleBool `json:"prefer_local_search,omitempty"` // Prefer local tool interception even if provider has built-in search
SearchAPI string `json:"search_api,omitempty"` // "brave" or "google"
SearchKey string `json:"search_key,omitempty"` // API key for search service
MaxResults int `json:"max_results,omitempty"` // Max search results to return (default: 10)
// Proxy configuration
ProxyURL string `json:"proxy_url,omitempty"` // HTTP proxy URL (e.g., "http://127.0.0.1:7897")
// Fetch configuration
MaxFetchSize int64 `json:"max_fetch_size,omitempty"` // Max content size for fetch in bytes (default: 1MB)
FetchTimeout int64 `json:"fetch_timeout,omitempty"` // Fetch timeout in seconds (default: 30)
MaxURLLength int `json:"max_url_length,omitempty"` // Max URL length (default: 2000)
}
ToolInterceptorConfig contains configuration for tool interceptor (search & fetch)
type ToolInterceptorOverride ¶ added in v0.260224.0
type ToolInterceptorOverride struct {
// Disabled allows provider to explicitly disable when globally enabled
Disabled bool `json:"disabled,omitempty"`
// MaxResults override for this specific provider
MaxResults *int `json:"max_results,omitempty"`
}
ToolInterceptorOverride contains provider-level overrides for tool interceptor