Documentation
¶
Index ¶
- func IsValidTactic(tacticStr string) bool
- type AuthType
- type DiscoveryResult
- type GroupingStrategy
- type HybridParams
- type HybridTactic
- type IDEAdapter
- type IDESource
- type LoadBalancingTactic
- type OAuthDetail
- type Provider
- type RandomParams
- type RandomTactic
- type RoundRobinParams
- type RoundRobinTactic
- 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 RuleScenario
- type ScanResult
- type ScenarioConfig
- type ScenarioFlags
- type Skill
- type SkillLocation
- type Tactic
- type TacticParams
- func DefaultHybridParams() TacticParams
- func DefaultRandomParams() TacticParams
- func DefaultRoundRobinParams() TacticParams
- func DefaultTokenBasedParams() TacticParams
- func NewHybridParams(requestThreshold, tokenThreshold int64) TacticParams
- func NewRandomParams() TacticParams
- func NewRoundRobinParams(threshold int64) TacticParams
- func NewTokenBasedParams(threshold int64) TacticParams
- type TokenBasedParams
- type TokenBasedTactic
- type ToolInterceptorConfig
- type ToolInterceptorOverride
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidTactic ¶
IsValidTactic checks if the given tactic string is valid
Types ¶
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 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 HybridParams ¶
type HybridParams struct {
RequestThreshold int64 `json:"request_threshold"` // Request threshold for hybrid tactic
TokenThreshold int64 `json:"token_threshold"` // Token threshold for hybrid tactic
}
HybridParams holds parameters for hybrid tactic
func AsHybridParams ¶
func AsHybridParams(p TacticParams) (HybridParams, bool)
type HybridTactic ¶
type HybridTactic struct {
RequestThreshold int64 // Threshold for request count before switching
TokenThreshold int64 // Threshold for token consumption before switching
}
HybridTactic implements a hybrid load balancing strategy
func NewHybridTactic ¶
func NewHybridTactic(requestThreshold, tokenThreshold int64) *HybridTactic
NewHybridTactic creates a new hybrid tactic
func (*HybridTactic) GetName ¶
func (ht *HybridTactic) GetName() string
func (*HybridTactic) GetType ¶
func (ht *HybridTactic) GetType() loadbalance.TacticType
func (*HybridTactic) SelectService ¶
func (ht *HybridTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects service based on both request count and token consumption
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 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 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)
ToolInterceptor *ToolInterceptorConfig `json:"tool_interceptor,omitempty"` // Provider-level tool interceptor config
ToolInterceptorOverride *ToolInterceptorOverride `json:"tool_interceptor_override,omitempty"` // Provider-level override for tool interceptor
}
Provider represents an AI model api key and provider configuration
func (*Provider) GetAccessToken ¶
GetAccessToken returns the access token based on auth type
func (*Provider) GetEffectiveConfig ¶ added in v0.260224.0
func (p *Provider) GetEffectiveConfig(global *ToolInterceptorConfig) (*ToolInterceptorConfig, bool)
GetEffectiveConfig returns the effective tool interceptor config for a provider Global config is used as base, with provider overrides applied
func (*Provider) IsOAuthExpired ¶
IsOAuthExpired checks if the OAuth token is expired (only valid for oauth auth type)
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 RoundRobinParams ¶
type RoundRobinParams struct {
RequestThreshold int64 `json:"request_threshold"` // Number of requests per service before switching
}
RoundRobinParams holds parameters for round-robin tactic
func AsRoundRobinParams ¶
func AsRoundRobinParams(p TacticParams) (RoundRobinParams, bool)
Type assertion helpers for TacticParams
type RoundRobinTactic ¶
type RoundRobinTactic struct {
RequestThreshold int64 // Number of requests per service before switching
}
RoundRobinTactic implements round-robin load balancing based on request count
func NewRoundRobinTactic ¶
func NewRoundRobinTactic(requestThreshold ...int64) *RoundRobinTactic
NewRoundRobinTactic creates a new round-robin tactic with optional threshold parameter
func (*RoundRobinTactic) GetName ¶
func (rr *RoundRobinTactic) GetName() string
func (*RoundRobinTactic) GetType ¶
func (rr *RoundRobinTactic) GetType() loadbalance.TacticType
func (*RoundRobinTactic) SelectService ¶
func (rr *RoundRobinTactic) SelectService(rule *Rule) *loadbalance.Service
SelectService selects the next service based on round-robin with request threshold
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"`
// 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"`
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 RuleScenario ¶
type RuleScenario string
RuleScenario represents the scenario for a routing rule
const ( ScenarioOpenAI RuleScenario = "openai" ScenarioAnthropic RuleScenario = "anthropic" ScenarioClaudeCode RuleScenario = "claude_code" ScenarioOpenCode RuleScenario = "opencode" ScenarioXcode RuleScenario = "xcode" ScenarioGlobal RuleScenario = "_global" // Global flags that apply to all scenarios )
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 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
}
ScenarioFlags represents configuration flags for a scenario
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 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 DefaultHybridParams ¶
func DefaultHybridParams() TacticParams
func DefaultRandomParams ¶
func DefaultRandomParams() TacticParams
func DefaultRoundRobinParams ¶
func DefaultRoundRobinParams() TacticParams
DefaultParams returns default parameters for each tactic type
func DefaultTokenBasedParams ¶
func DefaultTokenBasedParams() TacticParams
func NewHybridParams ¶
func NewHybridParams(requestThreshold, tokenThreshold int64) TacticParams
func NewRandomParams ¶
func NewRandomParams() TacticParams
func NewRoundRobinParams ¶
func NewRoundRobinParams(threshold int64) TacticParams
Helper constructors for creating tactic parameters
func NewTokenBasedParams ¶
func NewTokenBasedParams(threshold int64) TacticParams
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 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 bool `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