Skip to content
المشاريع

حول

The microVM sandbox for AI agents. Runs microVMs on Linux, macOS and Windows hosts with no Docker or daemon, GPU through Vulkan, and volumes mounted in. Python, Node.js and Rust.

الأنظمة والبنية التحتية

كيف تُقاس هذه الأرقام

81 نجمة8 التفرعات +4 خلال 24 ساعة

ما يمكنك فعله

  • Keep untrusted code off your machine: every sandbox is a microVM with its own kernel, walled off by the hypervisor, not just by namespaces, and its network can be cut entirely.
  • Boots in milliseconds: a new sandbox is ready to run commands in 35 ms, with 1 vCPU and 128 MB of memory (on an M3 Pro Mac).
  • Bring anything in, run anything inside: an agent in the sandbox can use services on your machine as they are, such as your browser, an Android device or a database. The sandbox reaches only the services you open to it. See a port on local.
  • Optimized for building AI agents: a sandbox is ready for AI agent work, such as RAG, browser use and GUI automation. See the guides for RAG, browser use and GUI programs.

النمو المقاس للنجوم

خلال 24 ساعة
+٤
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

virtx

The microVM sandbox for AI agents.

No Docker, no daemon to set up.

PyPI npm node crates.io

Documentation Discord X

English · 简体中文 · 繁體中文 · 日本語 · 한국어


virtx is a microVM sandbox for AI agents: make sandboxes from your own code, and build apps on them for your users.

A sandbox is a disposable Linux VM, on your machine, on a server you run, or on virtx cloud. Run in it what you'd rather not run on your own machine, such as the commands an AI agent decides to run. Whatever it installs or changes is gone when you remove it, unless it wrote it to a volume you kept.

When you build an app on virtx, its users get sandboxes too. You keep what each user's sandbox is made of as a package in your project, and your app makes each user a sandbox of their own from it, with no backend of yours in between.

The developer keeps a package on virtx and makes the app. Each app user makes a sandbox of the package from the app, and uses their own.

Quickstart

[!TIP] Using a coding agent? Install the virtx skill and let it write this for you:

claude plugin marketplace add brekkylab/virtx && claude plugin install virtx@brekkylab
codex plugin marketplace add brekkylab/virtx && codex plugin add virtx@brekkylab

Each example builds an image with jq in it, boots a sandbox from it, runs a command, and prints its output.

Local

Client.spawn() starts a local server for you.

Python
pip install virtx
import asyncio

from virtx import Client, Recipe


async def main() -> None:
    async with Client.spawn() as client:
        recipe = Recipe("alpine:latest").run("apk add --no-cache jq")
        await client.build_image(recipe, "jq:latest").complete(print=True)

        sandbox = await client.create_sandbox("jq:latest")
        try:
            cmd = ["sh", "-c", """echo '{"hello": "virtx"}' | jq -r .hello"""]
            code = await sandbox.exec(cmd).complete(print=True)
            print("exited", code)
        finally:
            await sandbox.remove()


asyncio.run(main())
Node
npm install @brekkylab/virtx
const { Client, Recipe } = require('@brekkylab/virtx')

async function main() {
  const client = Client.spawn()
  try {
    const recipe = new Recipe('alpine:latest').run('apk add --no-cache jq')
    await client.buildImage(recipe, 'jq:latest').complete({ print: true })

    const sandbox = await client.createSandbox('jq:latest')
    try {
      const cmd = ['sh', '-c', `echo '{"hello": "virtx"}' | jq -r .hello`]
      const code = await sandbox.exec(cmd).complete({ print: true })
      console.log('exited', code)
    } finally {
      await sandbox.remove()
    }
  } finally {
    await client.close()
  }
}

main()
Rust
cargo add virtx
cargo add tokio --features macros,rt-multi-thread
use virtx::{Client, Recipe, SandboxCreateArgs, SandboxExecArgs};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::spawn_virtx([] as [&str; 0]).await?;

    let recipe = Recipe::new("alpine:latest").step("apk add --no-cache jq");
    client.build_image(recipe, "jq:latest").complete(true).await?;

    let sandbox = client
        .create_sandbox(&SandboxCreateArgs::new("jq:latest"))
        .await?;
    let cmd = ["sh", "-c", r#"echo '{"hello": "virtx"}' | jq -r .hello"#];
    let code = sandbox.exec(&SandboxExecArgs::new(cmd)).complete(true).await?;
    println!("exited {code}");
    sandbox.remove().await?;
    Ok(())
}

Remote

Set up virtx-server-tcp on a machine of yours, as Running your own server shows.

Sign in to it once with the virtx command, which uvx or npx runs without installing, and connect with the token it prints in place of Client.spawn(). The rest is the same as the local example.

uvx virtx login https://virtx.example                 # pipx run virtx, without uv

# or

npx -y @brekkylab/virtx login https://virtx.example

To install virtx instead, see CLI.

Python
from virtx import Client, CommandAuth

client = Client.connect(
    "https://virtx.example",
    CommandAuth("uvx", ("virtx", "token", "--json")),
)
Node
const client = Client.connect(
  'https://virtx.example',
  { type: 'command', program: 'npx', args: ['-y', '@brekkylab/virtx', 'token', '--json'] }
)
Rust
use virtx::Auth;

let client = Client::connect(
    "https://virtx.example",
    Auth::Command { program: "uvx".into(), args: vec!["virtx".into(), "token".into(), "--json".into()] },
    None,
)?;

Features

  • Keep untrusted code off your machine: every sandbox is a microVM with its own kernel, walled off by the hypervisor, not just by namespaces, and its network can be cut entirely.
  • Boots in milliseconds: a new sandbox is ready to run commands in 35 ms, with 1 vCPU and 128 MB of memory (on an M3 Pro Mac).
  • Bring anything in, run anything inside: an agent in the sandbox can use services on your machine as they are, such as your browser, an Android device or a database. The sandbox reaches only the services you open to it. See a port on local.
  • Optimized for building AI agents: a sandbox is ready for AI agent work, such as RAG, browser use and GUI automation. See the guides for RAG, browser use and GUI programs.
  • Bring in outside context: mount Notion, Google Drive or OneDrive in a sandbox as plain files.
  • Use the GPU: the host's GPU is paravirtualized on Linux, macOS and Windows, so a sandbox can run deep learning models and graphics workloads on it.
  • Run anywhere: any client works with any server on any host, and moving from a local server to a remote one or the cloud changes one line.
    • Clients: Python · Node · Rust
    • Servers: 💻 local (stdio) · 🖥️ remote (tcp) · ☁️ cloud
    • Hosts: Linux · macOS · Windows
  • Ship your agent as an app: build an app on virtx and give it to your users, and each of them gets a sandbox of their own, with no backend to run. See building an app.
  • Minimal setup: install the package and you are ready to run, with no Docker and no daemon to set up.
  • Works with any agent framework: a sandbox is a tool like any other, so any framework or coding agent can drive it. Ailoy, an open-source agent SDK, is one that does.

Requirements

Client

Pick the one for the language you use.

  • Python: 3.11 or later.
  • Node: 22 or later.
  • Rust: 1.89 or later.

Server

These apply to the machine that runs the virtx server. Guests are always Linux.

Hypervisor

  • Linux: a kernel with KVM support, /dev/kvm accessible to your user, and hardware virtualization enabled in the firmware. KVM is built into most modern kernels, so nothing usually needs installing.

  • macOS: Apple silicon only. The VM runs on Hypervisor.framework, which is built in, so nothing needs installing or turning on.

  • Windows: Windows 11 or later, x86_64 only. The VM runs on the Windows Hypervisor Platform. If it is off, run this in an administrator PowerShell and restart:

    Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform
    

(Optional) GPU

Only for sandboxes that use the GPU: a Vulkan loader on the host. The guest's half of Vulkan comes with every sandbox, so the image needs none. See Using GPUs.

How it works

Client-server model

virtx follows a client-server model. Your code, the client, tells a virtx server what to run, and the server runs it in a VM and sends the results back.

A virtx client reaches a server that is local, on the client machine; remote, on another machine; or in the cloud, hosted by virtx.

The server can be one you run yourself, on the same machine as your code or on another one, or virtx cloud, hosted for you. Either way, client and server speak the same plain HTTP protocol; only the transport differs.

Local Remote Cloud
Server virtx-stdio virtx-server-tcp virtx cloud
Where it runs Child process of client process Daemon on another machine, separate from the client virtx's own machines, hosted for you
Transport HTTP over stdio HTTP over TCP HTTPS
Setup None: nothing to install or keep running Run the server, and give each user a token Sign in and create an API key
Use it for Running VMs on the machine you work on A bigger machine, or one host shared by a team Running VMs without hardware of your own

Each VM is a libkrun-based microVM: a Linux guest with its own kernel, on the host's hardware virtualization (KVM on Linux, Hypervisor.framework on macOS, the Windows Hypervisor Platform on Windows). Code in it is separated from your machine by a hypervisor, not just by namespaces as in a container, and a microVM boots in a fraction of the time a full VM takes, since there is no firmware or emulated hardware to bring up.

Core concepts

The main resource is the sandbox: a VM you run commands in.

A user sends commands to a sandbox and reads its output; the sandbox is made from a writable layer over a read-only image, and a volume is mounted into it.

A sandbox's root filesystem is an overlay of two layers: an image below, read-only, and a writable layer above, where its writes go.

The image is what every sandbox on it starts from. Images are OCI images, the format Docker uses, so alpine:latest or any image from a registry works.

The writable layer is where a sandbox's changes pile up. Each sandbox has its own, which starts empty and goes when the sandbox is removed.

When a sandbox needs storage apart from its root filesystem, use a volume. Unlike the writable layer, a volume is mounted at a path, read-write or read-only, and can be mounted into several sandboxes at once. It stays when they are removed, and its files can be read and written from your code without a sandbox at all. Remote stores such as Notion, Google Drive and OneDrive can be mounted inside a volume too, read-only, so a sandbox sees them as files.

Documentation

See the documentation for guides and the API reference. Rust's API is on docs.rs too.

Building from source

See Building from source in AGENTS.md.

Contributing

Bug reports, ideas and pull requests are welcome. CONTRIBUTING.md covers how to open a PR. For a suspected vulnerability, please follow SECURITY.md instead of opening a public issue. Questions and show-and-tell go on Discord.

License

Apache-2.0. See LICENSE.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…