Skip to main content

Secure runtime for AI agents, and tools -- free and open-source from Celesto AI 🧡

Project description

SmolVM

Secure runtime for AI agents and tools

License Python 3.10+

DocsExamplesGitHub


SmolVM is a lightning-fast, secure microVM runtime designed for high-density isolation. It provides AI agents and tools with a safe, hardware-virtualized environment to execute untrusted code without risking the host system.

✨ Features

  • 🔒 Secure Isolation: Hardware-level virtualization (utilizing Firecracker) for strong sandbox boundaries.
  • ⚡ Blazing Fast: MicroVMs boot in sub-second time with minimal overhead.
  • 🐍 Python Native: Clean, high-level SDK for managing VM lifecycles and command execution.
  • 🌐 Automatic Networking: Built-in NAT, port forwarding, and SSH tunneling.
  • 🛠️ Custom Images: Build specialized Debian-based rootfs images with your own tools.
  • 🧹 Auto-Cleanup: Integrated resource management to keep your host system clean.

🤔 Why SmolVM?

AI agents often need to execute arbitrary code (Python, JS, shell scripts) generated by LLMs. Running this code directly on your host or in standard containers can be risky.

  • MicroVM-based Security: Unlike containers that share the host kernel, SmolVM uses KVM-backed microVMs. This provides a significantly smaller attack surface and stronger hardware-level isolation.
  • Agent-First Design: SmolVM abstracts away the complexity of microVM networking, storage, and TAP devices into a simple, pythonic API.

🚀 Quickstart

1. Prerequisites

  • Linux + Firecracker backend: KVM support (Ubuntu/Debian/Fedora).
  • macOS + QEMU backend: Homebrew and QEMU (qemu-system-*).

2. Installation

# Install the Python package
pip install smolvm

Linux (Firecracker):

sudo ./scripts/system-setup.sh --configure-runtime

macOS (QEMU):

./scripts/system-setup-macos.sh
# Optional explicit backend override:
# export SMOLVM_BACKEND=qemu

3. Basic Usage

Initialize a VM with no arguments for an auto-configured, SSH-ready environment:

from smolvm import VM

# Auto-configures keys, image, and network automatically
with VM() as vm:
    result = vm.run("echo 'Hello from the sandbox!'")
    print(result.output)

Customize auto-config memory and disk size:

from smolvm import VM

with VM(mem_size_mib=2048, disk_size_mib=4096) as vm:
    print(vm.run("free -m").output)

4. Reconnect to an existing VM

You can also reconnect to a running VM by its ID:

from smolvm import VM

# Reconnect to an existing VM
vm = VM.from_id("vm-abcdef12")
print(f"Status: {vm.status}")

5. Port Forwarding

Expose a guest application to your local machine securely. expose_local prefers host-local iptables forwarding and automatically falls back to an SSH tunnel when needed.

from smolvm import VM

with VM() as vm:
    # Example: App in VM listening on port 8080, expose to host port 18080
    host_port = vm.expose_local(guest_port=8080, host_port=18080)
    print(f"App available at http://localhost:{host_port}")

6. Environment Variables

Inject environment variables into a running VM. Variables are persisted in /etc/profile.d/smolvm_env.sh and apply to new SSH/login shell sessions.

from smolvm import VM

with VM() as vm:
    vm.set_env_vars({"API_KEY": "sk-...", "DEBUG": "1"})
    print(vm.list_env_vars())
    print(vm.run("echo $API_KEY").output)

CLI:

smolvm env set <vm_id> API_KEY=sk-... DEBUG=1
smolvm env list <vm_id> --show-values
smolvm env unset <vm_id> DEBUG

📄 License

Apache 2.0 License - see LICENSE for details.


Built with 🧡 by Celesto AI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smolvm-0.0.2.tar.gz (90.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smolvm-0.0.2-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

Details for the file smolvm-0.0.2.tar.gz.

File metadata

  • Download URL: smolvm-0.0.2.tar.gz
  • Upload date:
  • Size: 90.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smolvm-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b2a204caf472f1cda9bd0cf8eec5949a3a78052923e6e9bdcb3815703da8950f
MD5 f806f4c1ad30e0f672bbb957698b6ebe
BLAKE2b-256 dfdfd591859d2eeced967e17c9c6cf6a9d297f0df9d6923ffb6f670e1937ae62

See more details on using hashes here.

Provenance

The following attestation bundles were made for smolvm-0.0.2.tar.gz:

Publisher: publish.yml on CelestoAI/SmolVM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smolvm-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: smolvm-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smolvm-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 357383d9efb02e57b1754f942122e4ff6788ae34b9291656db40e533573e093f
MD5 816ea45433e540a16ca2313bcc0dd71e
BLAKE2b-256 7398f17716e785eb3557e50282fad8216076586dbdc9c3e8e637b843c3cd91e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for smolvm-0.0.2-py3-none-any.whl:

Publisher: publish.yml on CelestoAI/SmolVM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page