- windsurf_gateway_service: 添加上游延迟/TTFT/错误上下文记录 - endpoint: DeriveUpstreamEndpoint 添加 PlatformWindsurf 分支 - ops_error_logger: guessPlatformFromPath 添加 /windsurf/ 识别
137 lines
5.4 KiB
Go
137 lines
5.4 KiB
Go
package config
|
|
|
|
import "time"
|
|
|
|
type WindsurfConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
FirebaseAPIKey string `mapstructure:"firebase_api_key"`
|
|
Auth1BaseURL string `mapstructure:"auth1_base_url"`
|
|
SeatServiceBaseURL string `mapstructure:"seat_service_base_url"`
|
|
CodeiumRegisterURL string `mapstructure:"codeium_register_url"`
|
|
UserStatusBaseURL string `mapstructure:"user_status_base_url"`
|
|
LSMode string `mapstructure:"ls_mode"`
|
|
RequestTimeout time.Duration `mapstructure:"request_timeout"`
|
|
StartupTimeout time.Duration `mapstructure:"startup_timeout"`
|
|
Docker WindsurfDockerConfig `mapstructure:"docker"`
|
|
Embedded WindsurfEmbeddedConfig `mapstructure:"embedded"`
|
|
External WindsurfExternalConfig `mapstructure:"external"`
|
|
Refresh WindsurfRefreshConfig `mapstructure:"refresh"`
|
|
Probe WindsurfProbeConfig `mapstructure:"probe"`
|
|
Chat WindsurfChatConfig `mapstructure:"chat"`
|
|
Scheduling WindsurfScheduleConfig `mapstructure:"scheduling"`
|
|
}
|
|
|
|
type WindsurfDockerConfig struct {
|
|
Host string `mapstructure:"host"`
|
|
Port int `mapstructure:"port"`
|
|
CSRFToken string `mapstructure:"csrf_token"`
|
|
DiscoverInterval time.Duration `mapstructure:"discover_interval"`
|
|
ProbeInterval time.Duration `mapstructure:"probe_interval"`
|
|
ProbeTimeout time.Duration `mapstructure:"probe_timeout"`
|
|
}
|
|
|
|
type WindsurfEmbeddedConfig struct {
|
|
Binary string `mapstructure:"binary"`
|
|
BasePort int `mapstructure:"base_port"`
|
|
DataDir string `mapstructure:"data_dir"`
|
|
APIServerURL string `mapstructure:"api_server_url"`
|
|
}
|
|
|
|
type WindsurfExternalConfig struct {
|
|
BaseURL string `mapstructure:"base_url"`
|
|
CSRFToken string `mapstructure:"csrf_token"`
|
|
}
|
|
|
|
type WindsurfRefreshConfig struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
TokenScanInterval time.Duration `mapstructure:"token_scan_interval"`
|
|
RefreshBeforeExpiry time.Duration `mapstructure:"refresh_before_expiry"`
|
|
StatusRefreshInterval time.Duration `mapstructure:"status_refresh_interval"`
|
|
StatusLockTTL time.Duration `mapstructure:"status_lock_ttl"`
|
|
WorkerConcurrency int `mapstructure:"worker_concurrency"`
|
|
TempUnschedulableOnNetworkErr time.Duration `mapstructure:"temp_unschedulable_on_network_error"`
|
|
}
|
|
|
|
type WindsurfProbeConfig struct {
|
|
CanaryModels []string `mapstructure:"canary_models"`
|
|
ModelCatalogRefreshInterval time.Duration `mapstructure:"model_catalog_refresh_interval"`
|
|
}
|
|
|
|
type WindsurfChatConfig struct {
|
|
DefaultMode string `mapstructure:"default_mode"`
|
|
LegacyEnumCutoff int32 `mapstructure:"legacy_enum_cutoff"`
|
|
CascadePollInterval time.Duration `mapstructure:"cascade_poll_interval"`
|
|
CascadeIdleGrace time.Duration `mapstructure:"cascade_idle_grace"`
|
|
CascadeTimeout time.Duration `mapstructure:"cascade_timeout"`
|
|
PreflightCapCheck bool `mapstructure:"preflight_capacity_check"`
|
|
AllowModeFallback bool `mapstructure:"allow_mode_fallback"`
|
|
}
|
|
|
|
type WindsurfScheduleConfig struct {
|
|
RPMPro int `mapstructure:"rpm_pro"`
|
|
RPMFree int `mapstructure:"rpm_free"`
|
|
RPMUnknown int `mapstructure:"rpm_unknown"`
|
|
RPMExpired int `mapstructure:"rpm_expired"`
|
|
}
|
|
|
|
func DefaultWindsurfConfig() WindsurfConfig {
|
|
return WindsurfConfig{
|
|
Enabled: false,
|
|
FirebaseAPIKey: "",
|
|
Auth1BaseURL: "https://windsurf.com",
|
|
SeatServiceBaseURL: "https://server.self-serve.windsurf.com/exa.seat_management_pb.SeatManagementService",
|
|
CodeiumRegisterURL: "https://api.codeium.com/register_user/",
|
|
UserStatusBaseURL: "https://server.codeium.com",
|
|
LSMode: "docker",
|
|
RequestTimeout: 60 * time.Second,
|
|
StartupTimeout: 45 * time.Second,
|
|
Docker: WindsurfDockerConfig{
|
|
Host: "windsurf-ls",
|
|
Port: 42099,
|
|
CSRFToken: "",
|
|
DiscoverInterval: 60 * time.Second,
|
|
ProbeInterval: 30 * time.Second,
|
|
ProbeTimeout: 3 * time.Second,
|
|
},
|
|
Embedded: WindsurfEmbeddedConfig{
|
|
Binary: "/opt/windsurf/language_server_linux_x64",
|
|
BasePort: 42100,
|
|
DataDir: "/opt/windsurf/data",
|
|
APIServerURL: "https://server.self-serve.windsurf.com",
|
|
},
|
|
External: WindsurfExternalConfig{},
|
|
Refresh: WindsurfRefreshConfig{
|
|
Enabled: true,
|
|
TokenScanInterval: 5 * time.Minute,
|
|
RefreshBeforeExpiry: 10 * time.Minute,
|
|
StatusRefreshInterval: 15 * time.Minute,
|
|
StatusLockTTL: 2 * time.Minute,
|
|
WorkerConcurrency: 4,
|
|
TempUnschedulableOnNetworkErr: 10 * time.Minute,
|
|
},
|
|
Probe: WindsurfProbeConfig{
|
|
CanaryModels: []string{
|
|
"gpt-4o-mini",
|
|
"gemini-2.5-flash",
|
|
"claude-sonnet-4-6",
|
|
},
|
|
ModelCatalogRefreshInterval: 6 * time.Hour,
|
|
},
|
|
Chat: WindsurfChatConfig{
|
|
DefaultMode: "auto",
|
|
LegacyEnumCutoff: 280,
|
|
CascadePollInterval: 250 * time.Millisecond,
|
|
CascadeIdleGrace: 8 * time.Second,
|
|
CascadeTimeout: 180 * time.Second,
|
|
PreflightCapCheck: true,
|
|
AllowModeFallback: true,
|
|
},
|
|
Scheduling: WindsurfScheduleConfig{
|
|
RPMPro: 60,
|
|
RPMFree: 10,
|
|
RPMUnknown: 20,
|
|
RPMExpired: 0,
|
|
},
|
|
}
|
|
}
|