Expand description
Unprivileged Linux sandbox for AI agents.
AgentCell stacks user/mount/pid/net namespaces, Landlock, seccomp-BPF
and cgroup v2 — the same isolation as the sand CLI — behind a small
C ABI. This crate compiles that ABI (libagentcell) and wraps it.
Linux only. On other OSes the crate compiles so workspaces and
cargo publish work; Config::spawn returns Error::Unsupported.
§Example
use agentcell::{Config, Stdio};
let mut child = Config::new()
.mem_bytes(512 * 1024 * 1024)
.cpu_cores(1.0)
.pids(32)
.stdout(Stdio::Piped)
.spawn(["sh", "-c", "echo hi-from-rust; exit 7"])?;
let mut out = String::new();
std::io::Read::read_to_string(child.stdout.as_mut().unwrap(), &mut out)?;
let status = child.wait()?;
assert_eq!(status.code(), Some(7));Spawns are serialized internally: the C library is not thread-safe.
Modules§
- ffi
- Raw C ABI (
agentcell.h). Linux only.
Structs§
- Child
- A live jail. Dropping it SIGKILLs if still running, then releases cgroup / veth / LSM state.
- Config
- Builder for one jail. Reusable:
Config::spawnborrowsself. - Output
- Captured stdio + wait status. See
Child::wait_with_output. - Status
- Wait-status of a jailed process (
waitpidraw status).
Enums§
- Error
- Errors from config, stdio setup, or the C ABI.
- Net
- How the jail’s network namespace is set up.
- Stdio
- Stdio for the jailed process. Same idea as
std::process::Stdio.
Functions§
- version
- Library version string from
libagentcell, or a stub off Linux.
Type Aliases§
- Result
- Crate-level result.