Skip to content

Commit e75c177

Browse files
committed
remove json validation
1 parent d1a2a88 commit e75c177

File tree

9 files changed

+18
-84
lines changed

9 files changed

+18
-84
lines changed

.refact/integrations.d/cmdline_cargo_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55
- name: "additional_params"
66
description: "Additional parameters for cargo check, such as --workspace or --all-features"
77
- name: "project_path"
8-
description: "absolute path to the project"
8+
description: "Absolute path to the project, the rust stuff is at refact/refact-agent/engine/Cargo.toml for the Refact project, so use ../refact/refact-agent/engine"
99
timeout: "60"
1010
output_filter:
1111
limit_lines: 100

refact-agent/engine/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ uuid = { version = "1", features = ["v4", "serde"] }
9696
walkdir = "2.3"
9797
which = "7.0.1"
9898
zerocopy = "0.8.14"
99-
jsonschema = "0.28.3"
10099

101100
# There you can use a local copy:
102101
mcp_client_rs = { git = "https://github.com/smallcloudai/mcp_client_rust.git" }

refact-agent/engine/src/files_blocklist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub async fn reload_indexing_everywhere_if_needed(gcx: Arc<ARwLock<GlobalContext
198198

199199
pub fn is_blocklisted(indexing_settings: &IndexingSettings, path: &PathBuf) -> bool {
200200
let block = any_glob_matches_path(&indexing_settings.blocklist, &path);
201-
tracing::info!("is_blocklisted {:?} {:?} block={}", indexing_settings, path, block);
201+
// tracing::info!("is_blocklisted {:?} {:?} block={}", indexing_settings, path, block);
202202
block
203203
}
204204

refact-agent/engine/src/http/routers/v1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::http::routers::v1::system_prompt::handle_v1_prepend_system_prompt_and
4343
use crate::http::routers::v1::vecdb::{handle_v1_vecdb_search, handle_v1_vecdb_status};
4444
#[cfg(feature="vecdb")]
4545
use crate::http::routers::v1::handlers_memdb::{handle_mem_add, handle_mem_erase, handle_mem_update_used, handle_mem_block_until_vectorized};
46-
use crate::http::routers::v1::v1_integrations::{handle_v1_integration_get, handle_v1_integration_icon, handle_v1_integration_save, handle_v1_integration_delete, handle_v1_integrations, handle_v1_integrations_filtered, handle_v1_integration_json_schema};
46+
use crate::http::routers::v1::v1_integrations::{handle_v1_integration_get, handle_v1_integration_icon, handle_v1_integration_save, handle_v1_integration_delete, handle_v1_integrations, handle_v1_integrations_filtered};
4747
use crate::agent_db::db_cthread::{handle_db_v1_cthread_update, handle_db_v1_cthreads_sub};
4848
use crate::agent_db::db_cmessage::{handle_db_v1_cmessages_update, handle_db_v1_cmessages_sub};
4949
use crate::agent_db::db_chore::{handle_db_v1_chore_update, handle_db_v1_chore_event_update, handle_db_v1_chores_sub};
@@ -137,7 +137,6 @@ pub fn make_v1_router() -> Router {
137137
.route("/integration-save", telemetry_post!(handle_v1_integration_save))
138138
.route("/integration-delete", delete(handle_v1_integration_delete))
139139
.route("/integration-icon/:icon_name", get(handle_v1_integration_icon))
140-
.route("/integration-json-schema", get(handle_v1_integration_json_schema))
141140

142141
.route("/docker-container-list", telemetry_post!(handle_v1_docker_container_list))
143142
.route("/docker-container-action", telemetry_post!(handle_v1_docker_container_action))

refact-agent/engine/src/http/routers/v1/v1_integrations.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use axum::extract::Query;
1111
use rust_embed::RustEmbed;
1212
use crate::custom_error::ScratchError;
1313
use crate::global_context::GlobalContext;
14-
use crate::integrations::json_schema::INTEGRATION_JSON_SCHEMA;
1514
use crate::integrations::setting_up_integrations::split_path_into_project_and_integration;
1615

1716

@@ -189,14 +188,3 @@ pub async fn handle_v1_integration_delete(
189188
.body(Body::from("{}"))
190189
.unwrap())
191190
}
192-
193-
pub async fn handle_v1_integration_json_schema() -> axum::response::Result<Response<Body>, ScratchError> {
194-
let schema_string = serde_json::to_string_pretty(&*INTEGRATION_JSON_SCHEMA).map_err(|e| {
195-
ScratchError::new(StatusCode::INTERNAL_SERVER_ERROR, format!("Failed to serialize JSON schema: {}", e))
196-
})?;
197-
198-
Ok(Response::builder()
199-
.header("Content-Type", "application/json")
200-
.body(Body::from(schema_string))
201-
.unwrap())
202-
}

refact-agent/engine/src/integrations/integr_cmdline.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,16 @@ fn powershell_escape(s: &str) -> String {
148148
pub fn replace_args(x: &str, args_str: &HashMap<String, String>) -> String {
149149
let mut result = x.to_string();
150150
for (key, value) in args_str {
151-
#[cfg(target_os = "windows")]
152-
let escaped_value = powershell_escape(value);
153-
#[cfg(not(target_os = "windows"))]
154-
let escaped_value = escape(Cow::from(value.as_str())).to_string();
151+
let escaped_value = if value == "" {
152+
// special case for an empty paramter, we want it empty as replacement, rather than escaped empty string ""
153+
"".to_string()
154+
} else {
155+
#[cfg(target_os = "windows")]
156+
let x = powershell_escape(value);
157+
#[cfg(not(target_os = "windows"))]
158+
let x = escape(Cow::from(value.as_str())).to_string();
159+
x
160+
};
155161
result = result.replace(&format!("%{}%", key), &escaped_value);
156162
}
157163
result
@@ -257,7 +263,7 @@ pub async fn execute_blocking_command(
257263
}
258264
}
259265

260-
fn parse_command_args(args: &HashMap<String, serde_json::Value>, cfg: &CmdlineToolConfig) -> Result<(String, String), String>
266+
fn _parse_command_args(args: &HashMap<String, serde_json::Value>, cfg: &CmdlineToolConfig) -> Result<(String, String), String>
261267
{
262268
let mut args_str: HashMap<String, String> = HashMap::new();
263269
let valid_params: Vec<String> = cfg.parameters.iter().map(|p| p.name.clone()).collect();
@@ -293,7 +299,7 @@ impl Tool for ToolCmdline {
293299
tool_call_id: &String,
294300
args: &HashMap<String, serde_json::Value>,
295301
) -> Result<(bool, Vec<ContextEnum>), String> {
296-
let (command, workdir) = parse_command_args(args, &self.cfg)?;
302+
let (command, workdir) = _parse_command_args(args, &self.cfg)?;
297303

298304
let gcx = ccx.lock().await.global_context.clone();
299305
let mut error_log = Vec::<YamlError>::new();
@@ -335,7 +341,7 @@ impl Tool for ToolCmdline {
335341
&self,
336342
args: &HashMap<String, serde_json::Value>,
337343
) -> Result<String, String> {
338-
let (command, _workdir) = parse_command_args(args, &self.cfg)?;
344+
let (command, _workdir) = _parse_command_args(args, &self.cfg)?;
339345
return Ok(command);
340346
}
341347

refact-agent/engine/src/integrations/json_schema.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

refact-agent/engine/src/integrations/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub mod yaml_schema;
2929
pub mod setting_up_integrations;
3030
pub mod running_integrations;
3131
pub mod utils;
32-
pub mod json_schema;
3332

3433
use integr_abstract::IntegrationTrait;
3534

refact-agent/engine/src/integrations/setting_up_integrations.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use serde_json::{json, Value};
88
use tokio::sync::RwLock as ARwLock;
99
use tokio::fs as async_fs;
1010
use tokio::io::AsyncWriteExt;
11-
use jsonschema;
1211
use crate::global_context::GlobalContext;
13-
use crate::integrations::json_schema::INTEGRATION_JSON_SCHEMA;
1412
// use crate::tools::tools_description::Tool;
1513
// use crate::yaml_configs::create_configs::{integrations_enabled_cfg, read_yaml_into_value};
1614

@@ -32,16 +30,6 @@ impl From<(&str, &serde_yaml::Error)> for YamlError {
3230
}
3331
}
3432

35-
impl From<(&str, &jsonschema::ValidationError<'_>)> for YamlError {
36-
fn from((path, err): (&str, &jsonschema::ValidationError)) -> Self {
37-
YamlError {
38-
integr_config_path: path.to_string(),
39-
error_line: 0, // ValidationError doesn't provide line numbers
40-
error_msg: format!("Schema validation error: {}", err),
41-
}
42-
}
43-
}
44-
4533
#[derive(Serialize, Default, Debug, Clone)]
4634
pub struct IntegrationRecord {
4735
pub project_path: String,
@@ -79,11 +67,7 @@ fn get_array_of_str_or_empty(val: &serde_json::Value, path: &str) -> Vec<String>
7967
fn parse_and_validate_yaml(path: &str, content: &String) -> Result<serde_json::Value, YamlError> {
8068
let value_yaml = serde_yaml::from_str::<serde_yaml::Value>(&content)
8169
.map_err(|e| YamlError::from((path, &e)))?;
82-
8370
let json_value = serde_json::to_value(value_yaml.clone()).unwrap();
84-
if let Err(err) = jsonschema::validate(&INTEGRATION_JSON_SCHEMA, &json_value) {
85-
return Err(YamlError::from((path, &err)));
86-
}
8771
Ok(json_value)
8872
}
8973

@@ -103,7 +87,7 @@ pub fn read_integrations_d(
10387

10488
// 1. Read and parse integrations.yaml (Optional, used for testing)
10589
// This reads the file to be used by (2) and (3), it does not create the records yet.
106-
// --integrations-yaml flag disables global config dir, except for integrations
90+
// --integrations-yaml flag disables global config dir, except for integrations
10791
// in `globally_allowed_integrations` list in this yaml file
10892
let mut integrations_yaml_value = None;
10993
let mut globally_allowed_integration_list = if integrations_yaml_path.is_empty() {
@@ -184,7 +168,7 @@ pub fn read_integrations_d(
184168
}
185169

186170
for (path_str, integr_name, project_path) in files_to_read {
187-
// If --integrations-yaml is set, ignore the global config folder
171+
// If --integrations-yaml is set, ignore the global config folder
188172
// except for the list of integrations specified as `globally_allowed_integrations`.
189173
if let Some(allowed_integr_list) = &globally_allowed_integration_list {
190174
if project_path.is_empty() && !allowed_integr_list.contains(&integr_name) {

0 commit comments

Comments
 (0)