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