1 - 介绍
介绍
opensource self-hosted ai agent sandboxes.
开源的自托管 AI 代理沙箱。
MicroSandbox 是一个开源的 AI 代理沙箱,它可以让您在本地运行 AI 代理,而无需担心数据泄露或安全问题。
Microsandbox 的介绍:
Microsandbox makes it easy to run untrusted workloads within a hardware-isolated and fast startup execution environment.
在硬件隔离和快速启动执行环境中轻松运行不受信任的工作负载。
Running untrusted code securely is hard. Traditional solutions—containers, VMs, or cloud sandboxes—each trade off speed, isolation, or control. Microsandbox aims to give the best of all worlds.
运行不受信任的代码安全是困难的。传统解决方案——容器、虚拟机或云沙盒——每个都权衡了速度、隔离或控制。Microsandbox 旨在给最好的世界。
主要特性
-
强隔离: 用 microVM 实现的硬件级别的虚拟机隔离。
-
即时启动: 启动时间低于 200 毫秒。
-
OCI 兼容: 运行标准容器镜像。
-
自托管: 在您的基础设施中部署,具有自主性。
-
AI-Ready: 与 MCP 无缝集成,与代理和 AI 工作流无缝集成。
Microsandbox 旨在成为代理网络的执行 backbone——快速、安全、灵活。
基本信息
2 - 安装
安装
curl -sSL https://get.microsandbox.dev | sh
输出为:
:: Starting microsandbox installation...
:: Creating installation directories...
:: Downloading microsandbox 0.2.6 for linux-x86_64...
######################################################################## 100.0%
:: Verifying checksum...
:: Extracting files...
:: Installing executables...
:: Installing libraries...
:: Configuring detected shells...
:: Setting up bash configuration...
:: Setting up zsh configuration...
:: Setting up sh configuration...
:: All detected shell environments configured. Please restart your shell or source your shell's config file
:: Installation completed successfully!
:: Executables installed to: /home/sky/.local/bin
:: - msb: main microsandbox command
:: - msbrun: microsandbox runtime executable
:: - msbserver: microsandbox server executable
:: - msr: alias for 'msb run'
:: - msx: alias for 'msb exe'
:: - msi: alias for 'msb install'
:: Libraries installed to: /home/sky/.local/lib
:: Please restart your shell or source your shell's config file to use microsandbox
:: Cleaning up temporary files...
安装完成后:
source ~/.zshrc
然后检查安装情况:
$ which msb
/home/sky/.local/bin/msb
$ msb --version
v0.2.6
3 - 文档
https://docs.microsandbox.dev/
用虚拟机级别的隔离和闪电般的启动速度运行不受信任的代码。为 AI Agent、开发人员和任何需要安全执行代码而不牺牲速度或安全性的人构建。
为什么使用 microsandbox?
你是否需要运行你不完全信任的代码?无论是 AI 生成的代码、用户提交的代码还是实验性代码,传统的选项都有严重的缺点:
- 在本地运行 - 一个恶意脚本就会让你的整个系统被破坏
- 使用容器 - 共享内核意味着复杂的攻击仍然可以突破
- 传统虚拟机 - 等待 10 秒以上才能启动虚拟机,严重影响生产力和性能
- 云解决方案 - 昂贵,并且受云提供商的控制
microsandbox 结合了所有最好的特性:
- 强大的安全性 - 用分离的内核实现真正的虚拟机隔离
- 即时启动 - 启动时间低于 200 毫秒,而不是 10 秒以上
- 您的基础设施 - 自托管,完全控制
- OCI 兼容 - 与标准容器镜像兼容
- AI-Ready - 内置 MCP 服务器,无缝集成 AI
快速运行
安装
注意:我在 debian13 下遇到问题,如果用普通帐号如我一般用的 sky 用户,无法正常启动 microvm。暂时先用 root 用户安装和运行 msb server 来绕来这个问题。
curl -sSL https://get.microsandbox.dev | sh
启动
msb server start --dev
执行
客户端可以用普通帐号如我一般用的 sky 用户,无需 root 权限。
在新的终端下执行:
mkdir -p ~/work/code/microsandbox/quickstart-python
cd ~/work/code/microsandbox/quickstart-python
pip install microsandbox
新建一个 python 文件:
vi quickstart.py
内容为:
import asyncio
from microsandbox import PythonSandbox
async def main():
async with PythonSandbox.create(name="demo") as sb:
exec = await sb.run("print('🚀 Secure execution!')")
print(await exec.output())
asyncio.run(main())
执行:
python quickstart.py
输出为:
🚀 Secure execution!