feat: sync deployed v1.0.0-rc.38-custom.42

Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
cneicy committed 2026-09-26 04:49:11 +08:00
1 parent aa6c3f50f4
commit ceddfd3d6b
828 files changed
+122253 -13702

No files matched your search

+53 -12
View File
@@ -11,13 +11,16 @@ import (
)
type ChannelSettings struct {
TaskPluginKey string `json:"task_plugin_key,omitempty"`
ForceFormat bool `json:"force_format,omitempty"`
ThinkingToContent bool `json:"thinking_to_content,omitempty"`
Proxy string `json:"proxy"`
PassThroughBodyEnabled bool `json:"pass_through_body_enabled,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
SystemPromptOverride bool `json:"system_prompt_override,omitempty"`
TaskPluginKey string `json:"task_plugin_key,omitempty"`
ForceFormat bool `json:"force_format,omitempty"`
ThinkingToContent bool `json:"thinking_to_content,omitempty"`
Proxy string `json:"proxy"`
PassThroughBodyEnabled bool `json:"pass_through_body_enabled,omitempty"`
ResponsesWebSocketEnabled bool `json:"responses_websocket_enabled,omitempty"`
// Deprecated: retained for stored settings compatibility; tokens control the guard.
ResponsesAstraModelGuard *bool `json:"responses_astra_model_guard,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
SystemPromptOverride bool `json:"system_prompt_override,omitempty"`
// HTTPProtocol controls outbound HTTP version negotiation for this channel.
// Accepted values: "", "auto" (default), "http1".
HTTPProtocol string `json:"http_protocol,omitempty"`
@@ -26,6 +29,10 @@ type ChannelSettings struct {
HTTP2ConnectionShards int `json:"http2_connection_shards,omitempty"`
}
func (s ChannelSettings) AstraModelGuardEnabled() bool {
return s.ResponsesAstraModelGuard == nil || *s.ResponsesAstraModelGuard
}
const (
HTTPProtocolAuto = "auto"
HTTPProtocolHTTP1 = "http1"
@@ -86,6 +93,10 @@ type ChannelOtherSettings struct {
UpstreamModelUpdateLastRemovedModels []string `json:"upstream_model_update_last_removed_models,omitempty"` // 上次检测到的可删除模型
UpstreamModelUpdateIgnoredModels []string `json:"upstream_model_update_ignored_models,omitempty"` // 手动忽略的模型
AdvancedCustom *AdvancedCustomConfig `json:"advanced_custom,omitempty"`
// OllamaOpenAIChat routes Ollama chat completions to the OpenAI-compatible
// /v1/chat/completions endpoint. When unset, chat completions keep using
// the native /api/chat protocol.
OllamaOpenAIChat bool `json:"ollama_openai_chat,omitempty"`
// ToolLossPolicy is a channel-level opt-in for request-phase conversion
// rejection. Empty follows the default allow policy. Accepted values:
// "", "allow", "safe", "strict".
@@ -114,6 +125,7 @@ func (s *ChannelOtherSettings) ValidateToolLossPolicy() error {
}
const (
AdvancedCustomConverterSGLangRerank = "jina_rerank_to_sglang"
advancedCustomConverterNone = "none"
advancedCustomConverterClaudeMessagesToOpenAIChat = "anthropic_messages_to_openai_chat_completions"
advancedCustomConverterOpenAIChatToClaudeMessages = "openai_chat_completions_to_anthropic_messages"
@@ -135,11 +147,22 @@ type AdvancedCustomConfig struct {
}
type AdvancedCustomRoute struct {
IncomingPath string `json:"incoming_path,omitempty"`
UpstreamPath string `json:"upstream_path,omitempty"`
Converter string `json:"converter,omitempty"`
Models []string `json:"models,omitempty"`
Auth *AdvancedCustomRouteAuth `json:"auth,omitempty"`
IncomingPath string `json:"incoming_path,omitempty"`
UpstreamPath string `json:"upstream_path,omitempty"`
Converter string `json:"converter,omitempty"`
Models []string `json:"models,omitempty"`
Auth *AdvancedCustomRouteAuth `json:"auth,omitempty"`
PassThroughBodyEnabled bool `json:"pass_through_body_enabled,omitempty"`
}
// SupportsPassThroughBody reports whether the route converter leaves the request body untouched.
func (r AdvancedCustomRoute) SupportsPassThroughBody() bool {
switch strings.TrimSpace(r.Converter) {
case "", advancedCustomConverterNone, AdvancedCustomConverterSGLangRerank:
return true
default:
return false
}
}
type AdvancedCustomRouteAuth struct {
@@ -171,6 +194,14 @@ const (
AdvancedCustomBalancePath = "/v1/dashboard/billing/credit_grants"
)
// IsNative reports whether the route forwards requests without protocol
// conversion. Validate normalizes an empty converter to none, but callers may
// see configurations that were never saved.
func (r AdvancedCustomRoute) IsNative() bool {
converter := strings.TrimSpace(r.Converter)
return converter == "" || converter == advancedCustomConverterNone
}
// MatchPath returns the first route whose IncomingPath matches requestPath.
// Matching mirrors the relay adaptor: exact match, {model} placeholder, and
// :generateContent <-> :streamGenerateContent equivalence.
@@ -373,6 +404,7 @@ func matchAdvancedCustomIncomingPathTemplate(configuredPath string, requestPath
func IsAdvancedCustomConverterAllowed(converter string) bool {
switch converter {
case advancedCustomConverterNone,
AdvancedCustomConverterSGLangRerank,
advancedCustomConverterClaudeMessagesToOpenAIChat,
advancedCustomConverterOpenAIChatToClaudeMessages,
advancedCustomConverterOpenAIChatToOpenAIResponses,
@@ -438,6 +470,9 @@ func (c *AdvancedCustomConfig) Validate() error {
if strings.Contains(upstreamPath, advancedCustomModelPlaceholder) {
return fmt.Errorf("advanced_custom.advanced_routes[%d].upstream_path must not contain %s for %s", i, advancedCustomModelPlaceholder, managementRouteName)
}
if route.PassThroughBodyEnabled {
return fmt.Errorf("advanced_custom.advanced_routes[%d].pass_through_body_enabled must be false for %s", i, managementRouteName)
}
}
if err := validateAdvancedCustomRouteModels(i, route.IncomingPath, route.Models, paths); err != nil {
return err
@@ -456,6 +491,9 @@ func (c *AdvancedCustomConfig) Validate() error {
if err := validateAdvancedCustomConverterPath(i, route.IncomingPath, route.Converter); err != nil {
return err
}
if route.PassThroughBodyEnabled && !route.SupportsPassThroughBody() {
return fmt.Errorf("advanced_custom.advanced_routes[%d].pass_through_body_enabled requires converter none: %s", i, route.Converter)
}
if err := validateAdvancedCustomRouteAuth(i, route.Auth); err != nil {
return err
}
@@ -556,6 +594,9 @@ func validateAdvancedCustomUpstreamTarget(index int, upstreamPath string) error
}
func validateAdvancedCustomConverterPath(index int, incomingPath string, converter string) error {
if converter == AdvancedCustomConverterSGLangRerank && (incomingPath == "/v1/rerank" || incomingPath == "/rerank") {
return nil
}
if incomingPath == advancedCustomEndpointPathOpenAIAlphaSearch {
if converter == advancedCustomConverterNone {
return nil