AIO Sandbox,开发者的完美沙箱 / ai #77

Words
245
Reading
2 min
11m
Listen to this post
~2 min

在试用过OpenSandbox、DaytonaSandbox后,总感觉差了点意思。OpenSandbox是经常拉不起服务、总报错。DaytonaSandbox虽可以一键集成,但是没法查看后端,定制化要差了点。沙箱环境无非就是一个隔离的代码环境, 就算是有恶意注入也不危及主环境。而这个理想的沙箱就是AIO Sandbox !

aiosandbox.jpg
https://sandbox.agent-infra.com/zh/

首先值得肯定的就是有全中文文档!并且很易读。 开发Agent需要的环境它都有,而且全部都预制好了,开箱即用!

一条命令拉起服务

docker run --security-opt seccomp=unconfined --rm -it \
  -e SANDBOX_API_KEY=your-secret-key \
  -p 127.0.0.1:8080:8080 ghcr.io/agent-infra/sandbox:latest

docker拉起服务后,即可访问!用curl -H "X-AIO-API-Key: your-secret-key" http://localhost:8080/v1/shell/sessions 可以稍加测试。

简洁的SDK

uv add agent-sandbox
# pip install agent-sandbox

from agent_sandbox import Sandbox

# 你设置了 SANDBOX_API_KEY,通过 X-AIO-API-Key 头传递
sandbox = Sandbox(
    base_url="http://localhost:8080",  
    headers={"X-AIO-API-Key": "your-secret-key"}  
)

# Shell
result = sandbox.shell.exec_command(command="ls -la", timeout=30)
print(result.data)

# 代码执行(Python / Node.js)
resp = sandbox.jupyter.execute_code(code="print(1+1)")
print(resp.data)

# 浏览器
img = sandbox.browser.screenshot()
open("shot.png", "wb").write(img.read())

集成的SDK也很简洁,连上服务后,也就基本是一条代码拉起服务!

AIO Sandbox确实不错,容易集成,灵活度又高。平时开发、测试都极为方便的。