From 538708958e3d3f887ef565b9d743e3119fb142ce Mon Sep 17 00:00:00 2001 From: Nico Arqueros Date: Thu, 9 Jan 2025 13:48:19 -0600 Subject: [PATCH] extend api support --- .../src/network/v2_api/api_v2_commands_vecfs.rs | 4 +++- .../tests/it/utils/shinkai_testing_framework.rs | 5 ++++- shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs | 5 ++++- .../src/shinkai_message/shinkai_message_schemas.rs | 1 + .../shinkai_utils/shinkai_message_builder_bundled_vecfs.rs | 6 +++++- .../shinkai-tools-primitives/src/tools/deno_tools.rs | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_vecfs.rs b/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_vecfs.rs index 6e21ca473..513c51eb1 100644 --- a/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_vecfs.rs +++ b/shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands_vecfs.rs @@ -41,8 +41,10 @@ impl Node { let vr_path = ShinkaiPath::from_string(input_payload.path); + let depth = input_payload.depth.unwrap_or(1); + // Use list_directory_contents_with_depth to get directory contents with depth 1 - let directory_contents = ShinkaiFileManager::list_directory_contents_with_depth(vr_path, &db, 1); + let directory_contents = ShinkaiFileManager::list_directory_contents_with_depth(vr_path, &db, depth); if let Err(e) = directory_contents { let api_error = APIError { diff --git a/shinkai-bin/shinkai-node/tests/it/utils/shinkai_testing_framework.rs b/shinkai-bin/shinkai-node/tests/it/utils/shinkai_testing_framework.rs index 4a1c8eda4..212bcbc11 100644 --- a/shinkai-bin/shinkai-node/tests/it/utils/shinkai_testing_framework.rs +++ b/shinkai-bin/shinkai-node/tests/it/utils/shinkai_testing_framework.rs @@ -208,7 +208,10 @@ impl ShinkaiTestingFramework { /// Retrieves simplified path information and optionally prints it based on `should_print`. pub async fn retrieve_and_print_path_simplified(&self, path: &str, should_print: bool) -> serde_json::Value { - let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() }; + let payload = APIVecFsRetrievePathSimplifiedJson { + path: path.to_string(), + depth: Some(1), + }; let msg = generate_message_with_payload( serde_json::to_string(&payload).unwrap(), MessageSchemaType::VecFsRetrievePathSimplifiedJson, diff --git a/shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs b/shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs index e6a388663..5dd76ee27 100644 --- a/shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs +++ b/shinkai-bin/shinkai-node/tests/it/utils/vecfs_test_utils.rs @@ -134,7 +134,10 @@ pub async fn retrieve_file_info( path: &str, is_simple: bool, ) -> Value { - let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() }; + let payload = APIVecFsRetrievePathSimplifiedJson { + path: path.to_string(), + depth: Some(1), + }; let msg = generate_message_with_payload( serde_json::to_string(&payload).unwrap(), diff --git a/shinkai-libs/shinkai-message-primitives/src/shinkai_message/shinkai_message_schemas.rs b/shinkai-libs/shinkai-message-primitives/src/shinkai_message/shinkai_message_schemas.rs index 6fddcaf12..f38291f57 100644 --- a/shinkai-libs/shinkai-message-primitives/src/shinkai_message/shinkai_message_schemas.rs +++ b/shinkai-libs/shinkai-message-primitives/src/shinkai_message/shinkai_message_schemas.rs @@ -481,6 +481,7 @@ pub struct APIAddAgentRequest { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, ToSchema)] pub struct APIVecFsRetrievePathSimplifiedJson { pub path: String, + pub depth: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, ToSchema)] diff --git a/shinkai-libs/shinkai-message-primitives/src/shinkai_utils/shinkai_message_builder_bundled_vecfs.rs b/shinkai-libs/shinkai-message-primitives/src/shinkai_utils/shinkai_message_builder_bundled_vecfs.rs index 6a15be9a3..356a7e799 100644 --- a/shinkai-libs/shinkai-message-primitives/src/shinkai_utils/shinkai_message_builder_bundled_vecfs.rs +++ b/shinkai-libs/shinkai-message-primitives/src/shinkai_utils/shinkai_message_builder_bundled_vecfs.rs @@ -380,6 +380,7 @@ impl ShinkaiMessageBuilder { #[allow(dead_code)] pub fn vecfs_retrieve_path_simplified( path: &str, + depth: Option, my_encryption_secret_key: EncryptionStaticKey, my_signature_secret_key: SigningKey, receiver_public_key: EncryptionPublicKey, @@ -388,7 +389,10 @@ impl ShinkaiMessageBuilder { node_receiver: ShinkaiNameString, node_receiver_subidentity: ShinkaiNameString, ) -> Result { - let payload = APIVecFsRetrievePathSimplifiedJson { path: path.to_string() }; + let payload = APIVecFsRetrievePathSimplifiedJson { + path: path.to_string(), + depth: depth, + }; Self::create_vecfs_message( payload, 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 13749ebcb..0e7820a39 100644 --- a/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs +++ b/shinkai-libs/shinkai-tools-primitives/src/tools/deno_tools.rs @@ -561,7 +561,7 @@ mod tests { description: "Fetches emails from an IMAP server".to_string(), keywords: vec!["email".to_string(), "imap".to_string()], js_code: "".to_string(), - tools: None, + tools: vec![], config: vec![ ToolConfig::BasicConfig(BasicConfig { key_name: "imap_server".to_string(),