docs.rs failed to build shinkai_tools_runner-1.0.0
Please check the
build logs for more information.
See
Builds for ideas on how to fix a failed build,
or
Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault,
open an issue.
Shinkai Tools

Shinkai Tools serves as the ecosystem to execute Shinkai tools, provided by the Shinkai team or third-party developers, in a secure environment. It provides a sandboxed space for executing these tools,
ensuring that they run safely and efficiently, while also allowing for seamless integration with Rust code.
This repository is a comprehensive collection of tools and utilities designed to facilitate the integration of JavaScript and Rust code. It provides a framework for executing Deno scripts within a Rust environment, allowing for seamless communication and data exchange between the two languages.
The primary components of this repository include:
libs/shinkai-tools-runner is a Rust library used to execute a tool in a secured and performant Deno environment, providing a safe and efficient way to run tools within the Shinkai ecosystem.
Documentation
More In Depth Codebase Documentation (Mutable.ai): https://wiki.mutable.ai/dcSpark/shinkai-tools
Getting started
Init Typescript side
# In windows admin privileges is required because rquickjs-sys uses a git patch
npm ci
npx nx run-many -t lint
npx nx run-many -t build
npx nx run-many -t test
Example Usage
To call a tool from the Rust side, you can use the following example:
use shinkai_tools_runner::{Tool, CodeFiles};
use serde_json::json;
#[tokio::main]
async fn main() {
let js_code = r#"
function run(configurations, params) {
console.log("Environment variable:", Deno.env.get('SHINKAI_MOUNT')); // rw files /path/to/mount1,/path/to/mount2
console.log("Environment variable:", Deno.env.get('SHINKAI_ASSETS')); // ro files /path/to/asset1,/path/to/asset2
console.log("Environment variable:", Deno.env.get('SHINKAI_HOME')); // rw files /path/to/home
console.log("Environment variable:", Deno.env.get('SHINKAI_NODE_LOCATION')); // https://host.docker.internal:9554 (if it's running in docker) or 127.0.0.2:9554 (if it's running in host)
return { message: `Echoing: ${params.message}` };
}
"#;
let code_files = CodeFiles {
files: std::collections::HashMap::from([("main.ts".to_string(), js_code.to_string())]),
entrypoint: "main.ts".to_string(),
};
let test_file_path = tempfile::NamedTempFile::new().unwrap().into_temp_path();
std::fs::create_dir_all(test_file_path.parent().unwrap()).unwrap();
println!("test file path: {:?}", test_file_path);
std::fs::write(&test_file_path, "1").unwrap();
let tool = Tool::new(
code_files,
json!({}),
Some(DenoRunnerOptions {
context: ExecutionContext {
storage: execution_storage.into(),
context_id: context_id.clone(),
execution_id: execution_id.clone(),
code_id: "js_code1".into(),
mount_files: vec![test_file_path.to_path_buf().clone()],
..Default::default()
},
..Default::default()
});
let result = tool.run(None, json!({"message": "Hello, Shinkai!"}), None).await.unwrap();
println!("Tool output: {:?}", result.data["message"]);
}
This example demonstrates how to set up and call a Shinkai tool from Rust, including how to pass input data and handle the output.