vbash
A virtual bash environment for AI agents. Runs bash scripts in-process with an in-memory filesystem. No real shell, no real files unless you opt in.
Inspired by just-bash by Vercel Labs.
use Shell;
let mut shell = builder
.file
.build;
let result = shell.exec.unwrap;
assert_eq!;
What's included
Bash syntax: variables, arrays, pipes, redirections, loops, conditionals, functions, subshells, arithmetic, globs, heredocs, brace expansion, and more.
115+ built-in commands including full sed, awk, and jq interpreters,
plus grep, sort, find, tar, curl (behind feature flag), and the
usual coreutils.
What's not included
selectandcoprocstatements- Background jobs run synchronously
- Some
jqedge cases may differ from the C implementation
Custom commands
use ;
use HashMap;
let mut shell = builder.command.build;
shell.exec.unwrap;
You can also call shell.register_command("name", func) after building.
Filesystem backends
By default everything lives in memory. You can also read from a real directory (writes still stay in memory), or go full read-write on the host filesystem.
use ;
let shell = builder
.fs
.build;
| Backend | Reads from | Writes to | Typical use |
|---|---|---|---|
InMemoryFs |
Memory | Memory | Testing, sandboxing |
OverlayFs |
Disk, then memory | Memory | Read real files safely |
ReadWriteFs |
Disk | Disk | Full host access |
MountableFs |
Routed | Routed | Mix backends per path |
Limits
Scripts run inside configurable limits. If any limit is exceeded the call returns an error.
use ;
let mut shell = builder
.limits
.build;
Cancellation
Cancel a running script from another thread, or set a timeout:
use Shell;
use Duration;
let mut shell = new;
let r = shell.exec_with_timeout;
assert!;
Network access
Disabled by default. Enable with the network feature flag and configure
which URLs are allowed:
use ;
let mut shell = builder
.network_policy
.build;
Private IPs are blocked by default. Redirect targets are re-validated.