weekly icon indicating copy to clipboard operation
weekly copied to clipboard

【开源自荐】BoxLite — 为 AI Agent 打造的嵌入式微型虚拟机运行时

Open DorianZheng opened this issue 2 months ago • 1 comments

项目介绍

BoxLite 是一个可嵌入的微型虚拟机运行时,专为 AI Agent 安全执行环境设计。

遵循 SQLite 的设计哲学:"小巧、快速、可靠",BoxLite 让你在轻量级 VM 中运行容器,提供硬件级隔离——无需守护进程。

解决的问题

AI Agent 在拥有完全自由时最强大——可以写代码、安装包、修改文件、访问网络。但这种自由在宿主机上很危险。

现有方案的困境:

方案 问题
Docker 容器 共享宿主内核,隔离不彻底
传统虚拟机 太重、启动慢、难以编排
云端沙箱 延迟高、成本高、厂商锁定

BoxLite 的方案:VM 级安全 + 容器级简单

核心特性

  • 🔒 硬件级隔离 — 每个 Box 是独立 VM,有自己的内核
  • 📦 嵌入式设计 — 无守护进程,无需 root,直接作为库嵌入应用
  • 🐳 OCI 兼容 — 支持任何 Docker 镜像 (python:slim, node:alpine 等)
  • 🍎 跨平台 — macOS (Apple Silicon) + Linux (x86_64, ARM64)
  • 🐍 Python SDKpip install boxlite 即可使用

快速体验

import asyncio
import boxlite

async def main():
    async with boxlite.SimpleBox(image="python:slim") as box:
        result = await box.exec("python", "-c", "print('Hello from BoxLite!')")
        print(result.stdout)

asyncio.run(main())

使用场景

  • AI Agent 沙箱 — 让 AI 自由探索,同时保护你的系统安全
  • 多租户 AI 托管 — 按需为每个用户的 AI 创建隔离环境
  • 本地开发 — 在 macOS 上获得一致的 Linux 环境,无需 Docker Desktop

技术栈

  • 核心: Rust
  • 虚拟化: Linux 基于 KVM ,macOS 基于 Hypervisor.framework
  • 网络: gvisor-tap-vsock
  • SDK: Python (PyO3), Node.js / Go (即将推出)

链接

  • GitHub: https://github.com/boxlite-labs/boxlite
  • PyPI: https://pypi.org/project/boxlite/

架构图

┌─────────────────────────────────────────────────────────────┐
│  Your Application                                           │
│  ┌──────────────────────────────────────────────────────┐   │
│  │  BoxLite Runtime (embedded library)                  │   │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐   │   │
│  │  │   Box A     │  │   Box B     │  │   Box C     │   │   │
│  │  │  (micro-VM) │  │  (micro-VM) │  │  (micro-VM) │   │   │
│  │  └─────────────┘  └─────────────┘  └─────────────┘   │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
                    Hardware Virtualization
                  (KVM / Hypervisor.framework)

开源协议: Apache 2.0

DorianZheng avatar Dec 22 '25 02:12 DorianZheng

@ruanyf 阮老师好,拜托帮忙看看。这个项目对于AI Agent来说还是很有价值的,希望能够让更太多的开发者看到,帮助更多的开发者🙏

DorianZheng avatar Dec 24 '25 01:12 DorianZheng