UCloud Sandbox SDK - Cloud sandbox environments for AI agents
Project description
UCloud Sandbox Python SDK
UCloud Sandbox Python SDK 提供云端沙箱环境,用于安全运行 AI 生成的代码。
安装
pip install ucloud_sandbox
快速开始
1. 获取 API Key
- 访问 UCloud Sandbox 注册账号
- 在控制台获取 API Key
- 设置环境变量:
export UCLOUD_SANDBOX_API_KEY=your_api_key
2. 基础沙箱
from ucloud_sandbox import Sandbox
with Sandbox.create() as sandbox:
result = sandbox.commands.run("echo 'Hello, World!'")
print(result.stdout)
3. Code Interpreter(代码解释器)
支持有状态的代码执行,变量在多次调用之间保持:
from ucloud_sandbox.code_interpreter import Sandbox
with Sandbox.create() as sandbox:
sandbox.run_code("x = 1")
execution = sandbox.run_code("x += 1; print(x)")
print(execution.logs.stdout) # ['2']
4. Desktop(桌面环境)
支持鼠标键盘控制、截图、VNC 流媒体:
from ucloud_sandbox.desktop import Sandbox
desktop = Sandbox.create()
# 截图
screenshot = desktop.screenshot()
# 鼠标操作
desktop.left_click(100, 200)
desktop.write("Hello, World!")
# VNC 流
desktop.stream.start()
print(desktop.stream.get_url())
desktop.kill()
文档
TODO 访问 Sandbox 文档 获取更多信息。
致谢
本项目基于 E2B 开源项目开发,感谢 E2B 团队的贡献。
许可证
MIT License - 详见 LICENSE 文件
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ucloud_sandbox-1.0.2.tar.gz
(105.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ucloud_sandbox-1.0.2.tar.gz.
File metadata
- Download URL: ucloud_sandbox-1.0.2.tar.gz
- Upload date:
- Size: 105.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3828886b9eccd196bf567fe11cca1f75e4811af66f2e75db285919720db71682
|
|
| MD5 |
6250ad42b94f6f555ffe25d1a62a6223
|
|
| BLAKE2b-256 |
b0e047033e1824bcb594cfd3715c005983bcb027eb5cfc0618948d9ba1f20104
|
File details
Details for the file ucloud_sandbox-1.0.2-py3-none-any.whl.
File metadata
- Download URL: ucloud_sandbox-1.0.2-py3-none-any.whl
- Upload date:
- Size: 206.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add1b8da6022c090cea2dca3a609a77f10d7692273e5b93c21b586ba6cf52b54
|
|
| MD5 |
c47bdc15de072c45230d90a238eb6a8a
|
|
| BLAKE2b-256 |
e3e051b88f23002105c978f2005d2eb2496ad304e5ed9b9c747386cfe97a9bdf
|