MCPcopy Create free account
hub / github.com/astercloud/aster / LoadAgentConfig

Method LoadAgentConfig

pkg/config/loader.go:67–89  ·  view source on GitHub ↗

LoadAgentConfig 从文件加载 AgentConfig

(path string)

Source from the content-addressed store, hash-verified

65
66// LoadAgentConfig 从文件加载 AgentConfig
67func (l *Loader) LoadAgentConfig(path string) (*types.AgentConfig, error) {
68 content, err := os.ReadFile(path)
69 if err != nil {
70 return nil, fmt.Errorf("read config file: %w", err)
71 }
72
73 // 展开环境变量
74 if l.expandEnv {
75 content = []byte(l.expandVariables(string(content)))
76 }
77
78 var config types.AgentConfig
79 if err := yaml.Unmarshal(content, &config); err != nil {
80 return nil, fmt.Errorf("parse yaml config: %w", err)
81 }
82
83 // 验证配置
84 if err := l.validateAgentConfig(&config); err != nil {
85 return nil, fmt.Errorf("validate config: %w", err)
86 }
87
88 return &config, nil
89}
90
91// LoadModelConfig 从文件加载 ModelConfig
92func (l *Loader) LoadModelConfig(path string) (*types.ModelConfig, error) {

Callers 7

TestLoadAgentConfigFunction · 0.95
LoadDefaultFunction · 0.95
MustLoadFunction · 0.95

Implementers 1

Managerpkg/memory/rules/manager.go

Calls 3

expandVariablesMethod · 0.95
validateAgentConfigMethod · 0.95
ReadFileMethod · 0.45