diff --git a/Cargo.lock b/Cargo.lock index 40c1ea1ec..b01c7004c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6578,7 +6578,7 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shinkai-spreadsheet-llm" -version = "0.9.2" +version = "0.9.3" dependencies = [ "async-trait", "chrono", @@ -6593,7 +6593,7 @@ dependencies = [ [[package]] name = "shinkai_crypto_identities" -version = "0.9.2" +version = "0.9.3" dependencies = [ "chrono", "dashmap", @@ -6609,7 +6609,7 @@ dependencies = [ [[package]] name = "shinkai_http_api" -version = "0.9.2" +version = "0.9.3" dependencies = [ "async-channel 1.9.0", "bytes", @@ -6634,7 +6634,7 @@ dependencies = [ [[package]] name = "shinkai_job_queue_manager" -version = "0.9.2" +version = "0.9.3" dependencies = [ "chrono", "serde", @@ -6648,7 +6648,7 @@ dependencies = [ [[package]] name = "shinkai_message_primitives" -version = "0.9.2" +version = "0.9.3" dependencies = [ "aes-gcm", "async-trait", @@ -6674,14 +6674,14 @@ dependencies = [ [[package]] name = "shinkai_mini_libs" -version = "0.9.2" +version = "0.9.3" dependencies = [ "base64 0.22.1", ] [[package]] name = "shinkai_node" -version = "0.9.2" +version = "0.9.3" dependencies = [ "aes-gcm", "anyhow", @@ -6753,7 +6753,7 @@ dependencies = [ [[package]] name = "shinkai_ocr" -version = "0.9.2" +version = "0.9.3" dependencies = [ "anyhow", "image 0.25.5", @@ -6768,7 +6768,7 @@ dependencies = [ [[package]] name = "shinkai_sheet" -version = "0.9.2" +version = "0.9.3" dependencies = [ "async-channel 1.9.0", "chrono", @@ -6782,7 +6782,7 @@ dependencies = [ [[package]] name = "shinkai_sqlite" -version = "0.9.2" +version = "0.9.3" dependencies = [ "bincode", "blake3", @@ -6813,7 +6813,7 @@ dependencies = [ [[package]] name = "shinkai_tcp_relayer" -version = "0.9.2" +version = "0.9.3" dependencies = [ "chrono", "clap 3.2.25", @@ -6832,7 +6832,7 @@ dependencies = [ [[package]] name = "shinkai_tools_primitives" -version = "0.9.2" +version = "0.9.3" dependencies = [ "anyhow", "regex", @@ -6882,7 +6882,7 @@ dependencies = [ [[package]] name = "shinkai_vector_fs" -version = "0.9.2" +version = "0.9.3" dependencies = [ "bincode", "blake3", @@ -6898,7 +6898,7 @@ dependencies = [ [[package]] name = "shinkai_vector_resources" -version = "0.9.2" +version = "0.9.3" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 234837822..d0802962a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.9.2" +version = "0.9.3" edition = "2021" authors = ["Nico Arqueros "] @@ -57,4 +57,4 @@ uuid = { version = "1.6.1" } rand = "=0.8.5" chrono-tz = "0.5" hex = "=0.4.3" -env_logger = "0.11.5" \ No newline at end of file +env_logger = "0.11.5" diff --git a/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_tools.rs b/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_tools.rs index ee21bf684..cad8bd42a 100644 --- a/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_tools.rs +++ b/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_tools.rs @@ -516,7 +516,7 @@ impl Node { let mut perm_file_path = PathBuf::from(storage_path.clone()); perm_file_path.push(".tools_storage"); perm_file_path.push("tools"); - perm_file_path.push(shinkai_tool.tool_router_key()); + perm_file_path.push(shinkai_tool.tool_router_key_path()); if let Err(err) = std::fs::create_dir_all(&perm_file_path) { let api_error = APIError { code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(), @@ -1543,7 +1543,7 @@ impl Node { let assets = PathBuf::from(&node_env.node_storage_path.unwrap_or_default()) .join(".tools_storage") .join("tools") - .join(tool.tool_router_key()); + .join(tool.tool_router_key_path()); if assets.exists() { for entry in std::fs::read_dir(assets).unwrap() { let entry = entry.unwrap(); @@ -1726,7 +1726,7 @@ impl Node { let mut file_path = PathBuf::from(&node_env.node_storage_path.clone().unwrap_or_default()) .join(".tools_storage") .join("tools") - .join(tool.tool_router_key()); + .join(tool.tool_router_key_path()); if !file_path.exists() { let s = std::fs::create_dir_all(&file_path); if s.is_err() { diff --git a/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs b/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs index 33ca4a0b6..616afcc1f 100644 --- a/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs +++ b/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs @@ -5,6 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use std::{env, thread}; use super::parameters::Parameters; +use super::shinkai_tool::ShinkaiTool; use super::tool_config::{OAuth, ToolConfig}; use super::tool_output_arg::ToolOutputArg; use super::tool_playground::{SqlQuery, SqlTable}; @@ -81,7 +82,7 @@ impl DenoTool { let path = PathBuf::from(&node_storage_path) .join(".tools_storage") .join("tools") - .join(tool_router_key); + .join(ShinkaiTool::convert_to_path(&tool_router_key)); self.assets .clone() .unwrap_or(vec![]) diff --git a/shinkai-libs/shinkai-tools-primitives/src/tools/python_tools.rs b/shinkai-libs/shinkai-tools-primitives/src/tools/python_tools.rs index 03441a3a6..404422a81 100644 --- a/shinkai-libs/shinkai-tools-primitives/src/tools/python_tools.rs +++ b/shinkai-libs/shinkai-tools-primitives/src/tools/python_tools.rs @@ -17,6 +17,7 @@ use tokio::runtime::Runtime; use super::deno_tools::ToolResult; use super::parameters::Parameters; use super::shared_execution::update_result_with_modified_files; +use super::shinkai_tool::ShinkaiTool; use super::tool_config::{OAuth, ToolConfig}; use super::tool_output_arg::ToolOutputArg; use super::tool_playground::{SqlQuery, SqlTable}; @@ -80,7 +81,7 @@ impl PythonTool { let path = PathBuf::from(&node_storage_path) .join(".tools_storage") .join("tools") - .join(tool_router_key); + .join(ShinkaiTool::convert_to_path(&tool_router_key)); self.assets .clone() .unwrap_or(vec![]) @@ -261,7 +262,14 @@ impl PythonTool { if result.is_err() { return result; } - update_result_with_modified_files(result.unwrap(), start_time, &home_path, &logs_path, &node_name, &app_id) + update_result_with_modified_files( + result.unwrap(), + start_time, + &home_path, + &logs_path, + &node_name, + &app_id, + ) }) }) .unwrap() diff --git a/shinkai-libs/shinkai-tools-primitives/src/tools/shinkai_tool.rs b/shinkai-libs/shinkai-tools-primitives/src/tools/shinkai_tool.rs index a60753471..13d2e8d79 100644 --- a/shinkai-libs/shinkai-tools-primitives/src/tools/shinkai_tool.rs +++ b/shinkai-libs/shinkai-tools-primitives/src/tools/shinkai_tool.rs @@ -71,6 +71,26 @@ impl ShinkaiTool { } } + // Return a folder-safe version of the tool_router_key + pub fn tool_router_key_path(&self) -> String { + let path = self.tool_router_key(); + Self::convert_to_path(&path) + } + + pub fn convert_to_path(tool_router_key: &str) -> String { + tool_router_key + .chars() + .map(|c| { + if c.is_ascii_alphanumeric() || c == '-' || c == '_' { + c + } else { + '_' + } + }) + .collect::() + .to_lowercase() + } + /// The key that this tool will be stored under in the tool router pub fn tool_router_key(&self) -> String { match self {