MCPcopy Create free account
hub / github.com/AI45Lab/Code / load_code_config

Function load_code_config

core/src/agent_api/agent_bootstrap.rs:15–51  ·  view source on GitHub ↗
(config_source: String)

Source from the content-addressed store, hash-verified

13use std::sync::Arc;
14
15pub(super) fn load_code_config(config_source: String) -> Result<CodeConfig> {
16 let expanded = expand_home(&config_source);
17 let path = Path::new(&expanded);
18 let ext = path.extension().and_then(|ext| ext.to_str());
19
20 if matches!(ext, Some("acl")) {
21 if !path.exists() {
22 return Err(CodeError::Config(format!(
23 "Config file not found: {}",
24 path.display()
25 )));
26 }
27
28 return Ok(CodeConfig::from_file(path)
29 .with_context(|| format!("Failed to load config: {}", path.display()))?);
30 }
31
32 if matches!(ext, Some("hcl")) {
33 return Err(CodeError::Config(
34 "HCL config files are not supported in 2.0; rename the file to .acl".into(),
35 ));
36 }
37
38 if config_source.trim().starts_with('{') {
39 return Err(CodeError::Config(
40 "JSON config is not supported; use ACL-compatible .acl config".into(),
41 ));
42 }
43
44 if matches!(ext, Some("json")) {
45 return Err(CodeError::Config(
46 "JSON config files are not supported; use .acl".into(),
47 ));
48 }
49
50 Ok(CodeConfig::from_acl(&config_source).context("Failed to parse config as ACL string")?)
51}
52
53pub(super) async fn build_agent_from_config(config: CodeConfig) -> Result<Agent> {
54 config

Callers 2

newMethod · 0.85

Calls 4

expand_homeFunction · 0.85
with_contextMethod · 0.80
contextMethod · 0.80
existsMethod · 0.45