feat: improve logging, tool compatibility, and endpoint configuration

This commit is contained in:
Quorinex
2026-05-13 13:59:52 +08:00
parent 1732b17ff9
commit 0f8035d90e
9 changed files with 506 additions and 94 deletions

View File

@@ -106,15 +106,24 @@ type Config struct {
OpenAIThinkingFormat string `json:"openaiThinkingFormat,omitempty"` // OpenAI output format: "reasoning_content", "thinking", or "think"
ClaudeThinkingFormat string `json:"claudeThinkingFormat,omitempty"` // Claude output format: "reasoning_content", "thinking", or "think"
// Endpoint configuration: "auto", "codewhisperer", or "amazonq"
// Endpoint configuration: "auto", "kiro", "codewhisperer", or "amazonq"
PreferredEndpoint string `json:"preferredEndpoint,omitempty"`
// EndpointFallback controls whether to try other endpoints when the preferred one fails.
// Defaults to true. Set to false to only use the preferred endpoint.
EndpointFallback *bool `json:"endpointFallback,omitempty"`
// Proxy configuration: optional outbound proxy for Kiro API requests
// Format: "socks5://host:port", "socks5://user:pass@host:port",
// "http://host:port", "http://user:pass@host:port"
// Leave empty to connect directly.
ProxyURL string `json:"proxyURL,omitempty"`
// LogLevel controls verbosity of application logs.
// Accepted values: "debug", "info", "warn", "error". Defaults to "info".
// Can be overridden by the LOG_LEVEL environment variable.
LogLevel string `json:"logLevel,omitempty"`
// Global statistics (persisted across restarts)
TotalRequests int `json:"totalRequests,omitempty"` // Total API requests received
SuccessRequests int `json:"successRequests,omitempty"` // Successful requests count
@@ -464,6 +473,24 @@ func UpdatePreferredEndpoint(endpoint string) error {
return Save()
}
// GetEndpointFallback returns whether endpoint fallback is enabled. Defaults to true.
func GetEndpointFallback() bool {
cfgLock.RLock()
defer cfgLock.RUnlock()
if cfg.EndpointFallback == nil {
return true
}
return *cfg.EndpointFallback
}
// UpdateEndpointFallback sets the endpoint fallback switch and persists the change.
func UpdateEndpointFallback(enabled bool) error {
cfgLock.Lock()
defer cfgLock.Unlock()
cfg.EndpointFallback = &enabled
return Save()
}
// GetProxyURL 获取出站代理地址
func GetProxyURL() string {
cfgLock.RLock()
@@ -479,6 +506,24 @@ func UpdateProxySettings(proxyURL string) error {
return Save()
}
// GetLogLevel returns the configured log level (debug/info/warn/error). Defaults to "info".
func GetLogLevel() string {
cfgLock.RLock()
defer cfgLock.RUnlock()
if cfg == nil || cfg.LogLevel == "" {
return "info"
}
return cfg.LogLevel
}
// UpdateLogLevel updates the log level setting and persists the change.
func UpdateLogLevel(level string) error {
cfgLock.Lock()
defer cfgLock.Unlock()
cfg.LogLevel = level
return Save()
}
type KiroClientConfig struct {
KiroVersion string
SystemVersion string