diff --git a/refact-agent/engine/Cargo.toml b/refact-agent/engine/Cargo.toml index 18d315878..abc2f0690 100644 --- a/refact-agent/engine/Cargo.toml +++ b/refact-agent/engine/Cargo.toml @@ -19,6 +19,7 @@ vecdb = ["sqlite-vec"] shadow-rs = "0.36.0" [dependencies] +astral-tokio-tar = "0.5.2" axum = { version = "0.6.20", features = ["default", "http2"] } async-process = "2.0.1" async-stream = "0.3.5" @@ -77,7 +78,6 @@ tokenizers = "0.21.0" tokio = { version = "1.43.0", features = ["fs", "io-std", "io-util", "macros", "rt-multi-thread", "signal", "process"] } tokio-rusqlite = "0.5.0" tokio-util = { version = "0.7.12", features = ["compat"] } -tokio-tar = "0.3.1" tower = { version = "0.4", features = ["full"] } tower-http = { version = "0.4.0", features = ["cors"] } tower-lsp = "0.20" diff --git a/refact-agent/engine/src/integrations/setting_up_integrations.rs b/refact-agent/engine/src/integrations/setting_up_integrations.rs index 17465ba85..813b26224 100644 --- a/refact-agent/engine/src/integrations/setting_up_integrations.rs +++ b/refact-agent/engine/src/integrations/setting_up_integrations.rs @@ -260,19 +260,41 @@ pub fn read_integrations_d( } // 4. Replace vars in config_unparsed - for rec in &mut result { - if let serde_json::Value::Object(map) = &mut rec.config_unparsed { - for (_key, value) in map.iter_mut() { - if let Some(str_value) = value.as_str() { - let replaced_value = vars_for_replacements.iter().fold(str_value.to_string(), |acc, (var, replacement)| { - acc.replace(&format!("${}", var), replacement) - }); - *value = serde_json::Value::String(replaced_value); + fn replace_string_with_vars(value: &str, vars_for_replacements: &HashMap) -> String { + for (var, replacement) in vars_for_replacements.iter() { + if !value.contains(&format!("${}", var)) { + continue; + } + return value + .split(&format!("${}", var)).map(|s| replace_string_with_vars(s, vars_for_replacements)) + .collect::>() + .join(replacement); + } + value.to_string() + } + fn replace_with_vars(value: &mut serde_json::Value, vars_for_replacements: &HashMap) { + match value { + serde_json::Value::String(str_value) => { + *str_value = replace_string_with_vars(str_value, vars_for_replacements); + } + serde_json::Value::Object(map) => { + for (_key, value) in map.iter_mut() { + replace_with_vars(value, vars_for_replacements); + } + } + serde_json::Value::Array(array) => { + for value in array { + replace_with_vars(value, vars_for_replacements); } } + _ => {} } } + for rec in &mut result { + replace_with_vars(&mut rec.config_unparsed, vars_for_replacements); + } + // 5. Fill on_your_laptop/when_isolated in each record for rec in &mut result { if !rec.integr_config_exists {