npm install @capsule-run/bash @capsule-run/bash-wasmRun it:
import { Bash } from "@capsule-run/bash";
import { WasmRuntime } from "@capsule-run/bash-wasm";
const bash = new Bash({ runtime: new WasmRuntime() });
const result = await bash.run("mkdir src && touch src/index.ts");
console.log(result);
/*
{
stdout: "Folder created ✔\nFile created ✔",
stderr: "",
diff: { created: ['src', 'src/index.ts'], modified: [], deleted: [] },
duration: 10,
exitCode: 0,
}
*/{
"mcpServers": {
"capsule": {
"command": "npx",
"args": ["-y", "@capsule-run/bash-mcp"]
}
}
}See the MCP Readme for configuration details.
Clone the repository, then run from the project root:
pnpm -s bash-wasm-shellImportant
Python and pip are required to compile the Python sandbox. Both sandboxes (JS and Python) are needed to run the shell.
Capsule Bash is built around three ideas:
Bash commands are reimplemented in TypeScript and each one runs inside a sandbox, isolating the host system from anything the agent executes. The sandbox layer is modular. Plug in any runtime that implements the interface. The default WasmRuntime uses Capsule to run commands inside WebAssembly.
Note
Not all bash commands are implemented yet. See packages/bash/src/commands/ for the current list.
Traditional bash treats silence as success. In an agentic context, that forces a second call just to confirm the first one worked. Capsule Bash returns structured output for every command. Exit code, stdout, stderr, and a diff of filesystem changes.
The agent operates in a mounted workspace directory (.capsule/session/workspace by default). Your host filesystem does not exist from the agent's perspective. You get full visibility into what the agent does without exposing your system.
WasmRuntime runs in Node.js only. So, browser environments are not supported with the existing runtime yet.
Contributions are welcome, whether it's documentation, new commands, or bug reports.
Commands live in packages/bash/src/commands/. To contribute:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-command - Add or update your command in
packages/bash/src/commands/ - Add unit tests
- Open a pull request
Apache License 2.0. See LICENSE for details.
