Skip to content

distrihub/js-sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distri JS Sandbox

Distri JS Sandbox enables you to register LLM function definitions and runs them in a sandbox. This utility is designed to let LLMs (Large Language Models) generate plans in code format and execute them primarily designed for distri Code Agent.

✨ Features

  • LLM-Driven Execution: Designed for scenarios where LLMs generate code plans that need to be executed in a controlled, sandboxed environment.
  • Sandboxed & Safe: Built on top of rustyscript and Deno for secure, isolated execution.

🚀 Example Usage

#[tokio::main]
async fn main() {
    let executor = EchoExecutor::default();
    let worker = JsWorker::new(JsWorkerOptions {
        timeout: std::time::Duration::from_secs(1),
        functions: vec![FunctionDefinition {
            name: "echo".to_string(),
            description: Some("Echo a message".to_string()),
            parameters: serde_json::json!({}),
            returns: Some("The echoed message".to_string()),
        }],
        executor: Arc::new(executor),
    }).unwrap();

    let result: Value = worker.execute("echo('Hello, world!');").unwrap();
    println!("{}", result); // Output: "Hello, world!"
}

📦 Built With

  • rustyscript — Rust bindings for Deno, enabling JS execution.
  • Deno — Secure JavaScript/TypeScript runtime.
  • tokio — Async runtime for Rust.

🔗 See Also

  • distri — The broader project for Agent building & orchestration..

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages