Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion refact-agent/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
38 changes: 30 additions & 8 deletions refact-agent/engine/src/integrations/setting_up_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, String>) -> 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::<Vec<String>>()
.join(replacement);
}
value.to_string()
}
fn replace_with_vars(value: &mut serde_json::Value, vars_for_replacements: &HashMap<String, String>) {
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 {
Expand Down