fix(config): resolve upstream conflicts for config and zh readme

This commit is contained in:
sky5454 2026-02-20 15:11:48 +08:00
parent 6a5e1bea6d
commit 37834314fa
2 changed files with 5 additions and 15 deletions

View file

@ -748,3 +748,4 @@ Discord: [https://discord.gg/V4sAZ9XWpN](https://discord.gg/V4sAZ9XWpN)
| **智谱 (Zhipu)** | 200K tokens/月 | 最适合中国用户 | | **智谱 (Zhipu)** | 200K tokens/月 | 最适合中国用户 |
| **Brave Search** | 2000 次查询/月 | 网络搜索功能 | | **Brave Search** | 2000 次查询/月 | 网络搜索功能 |
| **Groq** | 提供免费层级 | 极速推理 (Llama, Mixtral) | | **Groq** | 提供免费层级 | 极速推理 (Llama, Mixtral) |
| **Cerebras** | 提供免费层级 | 极速推理 (Llama, Qwen 等) |

View file

@ -6,7 +6,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"sync" "sync/atomic"
"github.com/caarlos0/env/v11" "github.com/caarlos0/env/v11"
"github.com/go-viper/mapstructure/v2" "github.com/go-viper/mapstructure/v2"
@ -56,9 +56,11 @@ type Config struct {
Tools ToolsConfig `json:"tools"` Tools ToolsConfig `json:"tools"`
Heartbeat HeartbeatConfig `json:"heartbeat"` Heartbeat HeartbeatConfig `json:"heartbeat"`
Devices DevicesConfig `json:"devices"` Devices DevicesConfig `json:"devices"`
mu sync.RWMutex
} }
// rrCounter is reserved for round-robin model selection compatibility.
var rrCounter atomic.Uint64
var configFileNames = []string{ var configFileNames = []string{
"config.json", "config.json",
"config.yaml", "config.yaml",
@ -523,9 +525,6 @@ func LoadConfig(path string) (*Config, error) {
} }
func SaveConfig(path string, cfg *Config) error { func SaveConfig(path string, cfg *Config) error {
cfg.mu.RLock()
defer cfg.mu.RUnlock()
ext := filepath.Ext(path) ext := filepath.Ext(path)
var configType string var configType string
switch ext { switch ext {
@ -587,14 +586,10 @@ func ResolveConfigPath(home string) string {
} }
func (c *Config) WorkspacePath() string { func (c *Config) WorkspacePath() string {
c.mu.RLock()
defer c.mu.RUnlock()
return expandHome(c.Agents.Defaults.Workspace) return expandHome(c.Agents.Defaults.Workspace)
} }
func (c *Config) GetAPIKey() string { func (c *Config) GetAPIKey() string {
c.mu.RLock()
defer c.mu.RUnlock()
if c.Providers.OpenRouter.APIKey != "" { if c.Providers.OpenRouter.APIKey != "" {
return c.Providers.OpenRouter.APIKey return c.Providers.OpenRouter.APIKey
} }
@ -623,8 +618,6 @@ func (c *Config) GetAPIKey() string {
} }
func (c *Config) GetAPIBase() string { func (c *Config) GetAPIBase() string {
c.mu.RLock()
defer c.mu.RUnlock()
if c.Providers.OpenRouter.APIKey != "" { if c.Providers.OpenRouter.APIKey != "" {
if c.Providers.OpenRouter.APIBase != "" { if c.Providers.OpenRouter.APIBase != "" {
return c.Providers.OpenRouter.APIBase return c.Providers.OpenRouter.APIBase
@ -648,8 +641,6 @@ type ModelConfig struct {
// GetModelConfig returns the text model configuration with fallbacks. // GetModelConfig returns the text model configuration with fallbacks.
func (c *Config) GetModelConfig() ModelConfig { func (c *Config) GetModelConfig() ModelConfig {
c.mu.RLock()
defer c.mu.RUnlock()
return ModelConfig{ return ModelConfig{
Primary: c.Agents.Defaults.Model, Primary: c.Agents.Defaults.Model,
Fallbacks: c.Agents.Defaults.ModelFallbacks, Fallbacks: c.Agents.Defaults.ModelFallbacks,
@ -658,8 +649,6 @@ func (c *Config) GetModelConfig() ModelConfig {
// GetImageModelConfig returns the image model configuration with fallbacks. // GetImageModelConfig returns the image model configuration with fallbacks.
func (c *Config) GetImageModelConfig() ModelConfig { func (c *Config) GetImageModelConfig() ModelConfig {
c.mu.RLock()
defer c.mu.RUnlock()
return ModelConfig{ return ModelConfig{
Primary: c.Agents.Defaults.ImageModel, Primary: c.Agents.Defaults.ImageModel,
Fallbacks: c.Agents.Defaults.ImageModelFallbacks, Fallbacks: c.Agents.Defaults.ImageModelFallbacks,