diff --git a/apps/shinkai-tool-aave-state/src/index.test.ts b/apps/shinkai-tool-aave-state/src/index.test.ts index 596d289..b9be3ab 100644 --- a/apps/shinkai-tool-aave-state/src/index.test.ts +++ b/apps/shinkai-tool-aave-state/src/index.test.ts @@ -6,7 +6,7 @@ Deno.test({ name: 'echo', sanitizeResources: false, sanitizeOps: false, - ignore: Deno.build.os === 'windows', + ignore: Deno.env.get('CI') === 'true' || Deno.build.os === 'windows', fn: async () => { const result = await run( { diff --git a/libs/shinkai-tools-runner/src/built_in_tools.test.rs b/libs/shinkai-tools-runner/src/built_in_tools.test.rs index 7302454..c084707 100644 --- a/libs/shinkai-tools-runner/src/built_in_tools.test.rs +++ b/libs/shinkai-tools-runner/src/built_in_tools.test.rs @@ -7,32 +7,6 @@ use crate::{ tools::code_files::CodeFiles, }; -#[tokio::test] -async fn get_tools_all_load() { - let _ = env_logger::builder() - .filter_level(log::LevelFilter::Info) - .is_test(true) - .try_init(); - let tools = get_tools(); - for (tool_name, tool_definition) in tools { - println!("creating tool instance for {}", tool_name); - let code_files = CodeFiles { - files: HashMap::from([("main.ts".to_string(), tool_definition.code.unwrap())]), - entrypoint: "main.ts".to_string(), - }; - let tool_instance = crate::tools::tool::Tool::new(code_files, Value::Null, None); - println!("fetching definition for {}", tool_name); - let defintion = tool_instance.definition().await; - println!( - "definition load successfully for {}: {:?}", - tool_name, - defintion.clone().unwrap().id - ); - assert_eq!(defintion.as_ref().unwrap().id, tool_name); - assert!(defintion.is_ok(), "tool {} failed to load", tool_name); - } -} - #[tokio::test] async fn list_tools_count() { assert!(get_tools().len() >= 5); diff --git a/libs/shinkai-tools-runner/src/tools/tool.rs b/libs/shinkai-tools-runner/src/tools/tool.rs index e5021cb..1506a9d 100644 --- a/libs/shinkai-tools-runner/src/tools/tool.rs +++ b/libs/shinkai-tools-runner/src/tools/tool.rs @@ -29,57 +29,6 @@ impl Tool { } } - pub async fn definition(&self) -> Result { - log::info!("preparing to get tool definition from code"); - - let mut deno_runner = DenoRunner::new(self.deno_runner_options.clone()); - - let mut code = self.code.clone(); - let entrypoint_code = code.files.get(&self.code.entrypoint.clone()); - if let Some(entrypoint_code) = entrypoint_code { - let adapted_entrypoint_code = format!( - r#" - {} - console.log(""); - console.log(JSON.stringify(definition)); - console.log(""); - "#, - entrypoint_code - ); - code.files.insert( - self.code.entrypoint.clone(), - adapted_entrypoint_code.clone(), - ); - } - - let result = deno_runner - .run(code, None, None) - .await - .map_err(|e| ExecutionError::new(format!("failed to run deno: {}", e), None))?; - - let result_text = result - .iter() - .skip_while(|line| !line.contains("")) - .skip(1) - .take_while(|line| !line.contains("")) - .map(|s| s.to_string()) - .collect::>() - .join("\n"); - - log::info!("result text: {}", result_text); - - let tool_definition: ToolDefinition = serde_json::from_str(&result_text).map_err(|e| { - log::info!("failed to parse tool definition: {}", e); - ExecutionError::new(format!("failed to parse tool definition: {}", e), None) - })?; - - log::info!( - "successfully retrieved tool definition: {:?}", - tool_definition - ); - Ok(tool_definition) - } - pub async fn check(&self) -> anyhow::Result> { let mut deno_runner = DenoRunner::new(self.deno_runner_options.clone()); let code = self.code.clone(); diff --git a/libs/shinkai-tools-runner/src/tools/tool.test.rs b/libs/shinkai-tools-runner/src/tools/tool.test.rs index 236ec47..5fca3be 100644 --- a/libs/shinkai-tools-runner/src/tools/tool.test.rs +++ b/libs/shinkai-tools-runner/src/tools/tool.test.rs @@ -10,39 +10,6 @@ use crate::tools::{ tool::Tool, }; -#[rstest] -#[case::host(RunnerType::Host)] -#[case::docker(RunnerType::Docker)] -#[tokio::test] -async fn get_tool_definition(#[case] runner_type: RunnerType) { - // Just for a simple test, it could be any tool - let code = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../apps/shinkai-tool-echo/src/index.ts" - )) - .to_string(); - - let code_files = CodeFiles { - files: HashMap::from([("main.ts".to_string(), code.to_string())]), - entrypoint: "main.ts".to_string(), - }; - - let configurations = serde_json::json!({}); - - let tool = Tool::new( - code_files, - configurations, - Some(DenoRunnerOptions { - force_runner_type: Some(runner_type), - ..Default::default() - }), - ); - - let definition = tool.definition().await.unwrap(); - - assert_eq!(definition.id, "shinkai-tool-echo"); -} - #[rstest] #[case::host(RunnerType::Host)] #[case::docker(RunnerType::Docker)]