Skip to content

mayflower/wasmsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

161 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

wasmsh

Bash-compatible shell runtime in Rust, compiled to WebAssembly. Runs in browsers and inside Pyodide — no server needed.

CI License crates.io npm

What it does

A sandboxed shell with 88 utilities (grep, sed, awk, jq, tar, curl, …), Python 3.13 with pip/micropip for installing pure-Python packages, and a virtual filesystem — all running in-process as WebAssembly. No OS processes, no network access unless explicitly allowed, step budgets to prevent runaway execution.

Two build targets from one codebase:

  • Standalone (wasm32-unknown-unknown) — browser Web Worker
  • Pyodide (wasm32-unknown-emscripten) — shell and Python share the same filesystem

Use with DeepAgents

wasmsh is a sandbox backend for DeepAgents. LLM agents get execute, read_file, write_file, edit_file, ls, grep, glob tools backed by the WASM sandbox.

import { createDeepAgent } from "deepagents";
import { WasmshSandbox } from "@langchain/wasmsh";

const sandbox = await WasmshSandbox.createNode();
const agent = createDeepAgent({ backend: sandbox });
const result = await agent.invoke({
  messages: [{ role: "user", content: "Analyze data.csv and create a summary" }],
});
await sandbox.stop();

Also works in the browser (Web Worker, no backend needed) and from Python (langchain-wasmsh).

Use directly

use wasmsh_runtime::WorkerRuntime;
use wasmsh_protocol::HostCommand;

let mut rt = WorkerRuntime::new();
rt.handle_command(HostCommand::Init { step_budget: 100_000 });
let events = rt.handle_command(HostCommand::Run { input: "echo hello".into() });
// [Stdout(b"hello\n"), Exit(0)]

Install

Registry Package Install
crates.io wasmsh-runtime cargo add wasmsh-runtime
npm @mayflowergmbh/wasmsh-pyodide npm i @mayflowergmbh/wasmsh-pyodide
PyPI wasmsh-pyodide-runtime pip install wasmsh-pyodide-runtime

Pre-built tarballs: GitHub Releases

Build from source

cargo build --workspace && cargo test --workspace   # Rust (1.89+)
just build-standalone                                # standalone wasm
just build-pyodide                                   # Pyodide wasm (needs emcc)

Docs

Tutorials Step-by-step guides to get started
How-to Guides Task-oriented recipes for common operations
Reference Shell syntax, builtins, utilities, protocol
Explanation Architecture, design decisions, trade-offs
ADRs Architectural Decision Records
Supported Features Complete syntax and command matrix
Examples Standalone and TypeScript usage

Acknowledgements

The Pyodide integration would not be possible without the outstanding work of the Pyodide team. They brought CPython to WebAssembly and built an ecosystem that makes running Python in the browser practical and reliable. wasmsh links directly into their Emscripten module, sharing the interpreter and filesystem — a testament to how well-designed their architecture is. Thank you to everyone who contributes to Pyodide.

License

Apache-2.0

About

Browser-first shell runtime in Rust with Bash-compatible syntax, virtual filesystem, pyodide-integration and sandboxed execution

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors