@tencent-ai/agent-sdk 0.3.116 → 0.3.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/CHANGELOG.md +59 -0
- package/cli/dist/codebuddy-headless.js +177 -263
- package/cli/dist/web-ui/assets/index-BH_HlE2i.css +32 -0
- package/cli/dist/web-ui/assets/{index-KUgjjYF4.js → index-Dofz0a20.js} +188 -164
- package/cli/dist/web-ui/docs/cn/cli/cli-reference.md +1 -1
- package/cli/dist/web-ui/docs/en/cli/best-practices.md +1 -1
- package/cli/dist/web-ui/docs/en/cli/cli-reference.md +1 -1
- package/cli/dist/web-ui/docs/search-index-en.json +1 -1
- package/cli/dist/web-ui/docs/search-index-zh.json +1 -1
- package/cli/dist/web-ui/index.html +6 -2
- package/cli/dist/web-ui/manifest.webmanifest +17 -0
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +19 -2
- package/cli/product.internal.json +37 -2
- package/cli/product.ioa.json +42 -2
- package/cli/product.json +33 -4
- package/cli/product.selfhosted.json +19 -2
- package/lib/query.d.ts.map +1 -1
- package/lib/query.js +6 -3
- package/lib/query.js.map +1 -1
- package/lib/transport/index.d.ts +1 -1
- package/lib/transport/index.d.ts.map +1 -1
- package/lib/transport/process-transport.d.ts +1 -1
- package/lib/transport/process-transport.d.ts.map +1 -1
- package/lib/transport/process-transport.js +5 -1
- package/lib/transport/process-transport.js.map +1 -1
- package/lib/types.d.ts +3 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/cli/dist/web-ui/assets/index-C7MTLJe8.css +0 -32
- package/cli/dist/web-ui/docs/cn/cli/sandboxing.md +0 -316
- package/cli/dist/web-ui/docs/en/cli/sandboxing.md +0 -316
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
# Sandbox 沙箱使用指南 (Beta)
|
|
2
|
-
|
|
3
|
-
> ⚠️ **Beta 功能**: Sandbox 功能目前处于 Beta 阶段,API 和功能可能会有变动。
|
|
4
|
-
|
|
5
|
-
CodeBuddy 支持在隔离的沙箱环境中运行,提供安全的代码执行和项目开发环境。
|
|
6
|
-
|
|
7
|
-
## 🎯 沙箱类型
|
|
8
|
-
|
|
9
|
-
- **Container Sandbox (容器沙箱)**:基于 Docker/Podman 的本地容器环境
|
|
10
|
-
- **E2B Sandbox (云端沙箱)**:基于 E2B 云服务的远程隔离环境
|
|
11
|
-
- **Teleport 模式 (远程连接)**:连接到已部署的远程沙箱服务
|
|
12
|
-
|
|
13
|
-
## 🚀 快速开始
|
|
14
|
-
|
|
15
|
-
### Container Sandbox (容器)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# 基本使用 - 自动挂载当前目录
|
|
19
|
-
codebuddy --sandbox "帮我分析这个项目"
|
|
20
|
-
|
|
21
|
-
# 等价于
|
|
22
|
-
codebuddy --sandbox container "帮我分析这个项目"
|
|
23
|
-
|
|
24
|
-
# 管道模式
|
|
25
|
-
echo "运行测试" | codebuddy --sandbox --print
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**前置要求**:
|
|
29
|
-
- 安装 Docker 或 Podman
|
|
30
|
-
- 确保 Docker daemon 运行中
|
|
31
|
-
|
|
32
|
-
### E2B Sandbox (云端)
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# 设置 E2B API Key
|
|
36
|
-
export E2B_API_KEY=your_api_key
|
|
37
|
-
|
|
38
|
-
# 基本使用 (需要完整的 API URL)
|
|
39
|
-
codebuddy --sandbox https://api.e2b.dev "创建一个 Python web 应用"
|
|
40
|
-
|
|
41
|
-
# 上传当前工作目录
|
|
42
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-upload-dir "分析这个项目"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Teleport 模式 (远程连接)
|
|
46
|
-
|
|
47
|
-
Teleport 模式用于连接到 BGA (Background Agent) 后台已创建的远程沙箱环境。这是一种特殊的连接模式,主要用于云端调度场景。
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
# 使用 teleport 值连接到远程沙箱
|
|
51
|
-
codebuddy --teleport session_abc123XYZ4567890 "连接到远程沙箱"
|
|
52
|
-
|
|
53
|
-
# 自定义请求头 (用于认证或路由)
|
|
54
|
-
codebuddy --teleport session_abc123XYZ4567890 \
|
|
55
|
-
-H "X-Domain: example.com" \
|
|
56
|
-
-H "X-Enterprise-Id: ent123" \
|
|
57
|
-
"执行任务"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**Teleport 值格式**:
|
|
61
|
-
- 格式: `session_{cliSessionId}`
|
|
62
|
-
- `cliSessionId`:唯一的会话标识符
|
|
63
|
-
- 示例: `session_abc123XYZ4567890`
|
|
64
|
-
|
|
65
|
-
**工作原理**:
|
|
66
|
-
1. BGA 后台生成唯一的 `cliSessionId`
|
|
67
|
-
2. BGA 在沙箱中将代码 clone 到 `/workspace/{cliSessionId}` 目录
|
|
68
|
-
3. BGA 生成 teleport 命令: `codebuddy --teleport session_{cliSessionId}`
|
|
69
|
-
4. CLI 解析 teleport 值,连接到指定沙箱并切换到正确的工作目录
|
|
70
|
-
5. 以 `root` 用户身份在沙箱中执行命令
|
|
71
|
-
|
|
72
|
-
**前置要求**:
|
|
73
|
-
- 有效的 teleport 值 (由 BGA 后台生成)
|
|
74
|
-
- 正确的认证凭证 (通过 E2B_API_KEY 或 CODEBUDDY_AUTH_TOKEN)
|
|
75
|
-
- 网络连通性到 BGA 后台服务
|
|
76
|
-
|
|
77
|
-
**特点**:
|
|
78
|
-
- 代码已由 BGA 后台准备,无需上传
|
|
79
|
-
- 自动使用 root 用户执行命令
|
|
80
|
-
- 工作目录自动设置为 `/workspace/{cliSessionId}`
|
|
81
|
-
- 支持自定义 HTTP 请求头进行认证和路由
|
|
82
|
-
|
|
83
|
-
## 📦 沙箱复用机制
|
|
84
|
-
|
|
85
|
-
### 别名系统
|
|
86
|
-
|
|
87
|
-
为用户/项目分配独立沙箱:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
# 使用用户 ID 作为别名
|
|
91
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id user-123 -p "任务"
|
|
92
|
-
|
|
93
|
-
# 使用项目名作为别名
|
|
94
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id project-foo -p "任务"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
别名映射存储在 `~/.codebuddy/sandbox-state.json`,支持自动创建和复用。
|
|
98
|
-
|
|
99
|
-
### 默认行为
|
|
100
|
-
|
|
101
|
-
沙箱自动复用,无需手动指定 ID:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# 第一次 - 创建新沙箱
|
|
105
|
-
$ codebuddy --sandbox https://api.e2b.dev "Hello"
|
|
106
|
-
[Sandbox] Creating new E2B sandbox...
|
|
107
|
-
[Sandbox] Created new sandbox: sb_abc123
|
|
108
|
-
|
|
109
|
-
# 再次启动 - 自动复用
|
|
110
|
-
$ codebuddy --sandbox https://api.e2b.dev "继续工作"
|
|
111
|
-
[Sandbox] Reusing sandbox: sb_abc123
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### 多项目管理
|
|
115
|
-
|
|
116
|
-
一个沙箱可托管多个项目,自动隔离在不同目录:
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
/workspace/
|
|
120
|
-
├── home-user-projectA/
|
|
121
|
-
├── home-user-projectB/
|
|
122
|
-
└── var-www-website/
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## ⚙️ 高级参数
|
|
126
|
-
|
|
127
|
-
### 沙箱创建和连接
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# 强制创建新沙箱 (忽略缓存)
|
|
131
|
-
codebuddy --sandbox --sandbox-new "从头开始"
|
|
132
|
-
|
|
133
|
-
# 连接到指定沙箱 ID (真实 ID)
|
|
134
|
-
codebuddy --sandbox --sandbox-id sb_abc123 "继续上次的工作"
|
|
135
|
-
|
|
136
|
-
# 使用别名 (自定义名称,自动创建和复用)
|
|
137
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id user-123 -p "任务" # 用户ID
|
|
138
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id project-foo -p "任务" # 项目名
|
|
139
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id team-backend -p "任务" # 团队名
|
|
140
|
-
|
|
141
|
-
# 退出时终止沙箱 (默认保持运行以便复用)
|
|
142
|
-
codebuddy --sandbox --sandbox-kill "完成后清理"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### 环境变量配置
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
# E2B 配置
|
|
149
|
-
export E2B_API_KEY=your_api_key # 必需
|
|
150
|
-
export E2B_TEMPLATE=base # 模板名称 (默认: base)
|
|
151
|
-
export E2B_TIMEOUT_MS=3600000 # 超时时间 (默认: 1小时)
|
|
152
|
-
export E2B_ALLOW_INTERNET_ACCESS=true # 允许互联网访问 (默认: true)
|
|
153
|
-
|
|
154
|
-
# Container Sandbox 配置
|
|
155
|
-
export CODEBUDDY_SANDBOX_IMAGE=node:20-alpine # Docker 镜像
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## 📊 沙箱管理
|
|
159
|
-
|
|
160
|
-
### 列出沙箱
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
$ codebuddy sandbox list
|
|
164
|
-
E2B Sandboxes:
|
|
165
|
-
* sb_abc123 (2 projects, last used 2m ago)
|
|
166
|
-
sb_xyz789 (1 project, last used 2h ago)
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### 查看详情
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
# 查看当前沙箱
|
|
173
|
-
$ codebuddy sandbox info
|
|
174
|
-
|
|
175
|
-
# 查看指定沙箱
|
|
176
|
-
$ codebuddy sandbox info sb_xyz789
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### 终止沙箱
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
$ codebuddy sandbox kill sb_abc123
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### 清理失效沙箱
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
$ codebuddy sandbox clean
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## 🔍 工作原理
|
|
192
|
-
|
|
193
|
-
### 项目目录映射
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
本地路径: /Users/yangsubo/projectA
|
|
197
|
-
沙箱路径: /workspace/Users-yangsubo-projectA
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### 状态持久化
|
|
201
|
-
|
|
202
|
-
沙箱状态保存在 `~/.codebuddy/sandbox-state.json`
|
|
203
|
-
|
|
204
|
-
## 💡 最佳实践
|
|
205
|
-
|
|
206
|
-
### 1. 选择合适的沙箱类型
|
|
207
|
-
|
|
208
|
-
```bash
|
|
209
|
-
# 需要本地容器隔离
|
|
210
|
-
codebuddy --sandbox container "本地开发任务"
|
|
211
|
-
|
|
212
|
-
# 云端协作或无本地环境
|
|
213
|
-
codebuddy --sandbox https://api.e2b.dev "云端开发"
|
|
214
|
-
|
|
215
|
-
# 连接到远程部署的沙箱服务
|
|
216
|
-
codebuddy --teleport session_abc123XYZ4567890 "远程开发"
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### 2. 项目隔离
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
cd ~/work/projectA
|
|
223
|
-
codebuddy --sandbox "开发功能 X"
|
|
224
|
-
|
|
225
|
-
cd ~/work/projectB
|
|
226
|
-
codebuddy --sandbox "修复 bug Y"
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### 3. 长期开发
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
# 第一天
|
|
233
|
-
codebuddy --sandbox "搭建开发环境"
|
|
234
|
-
|
|
235
|
-
# 第二天 - 秒级启动,环境保留
|
|
236
|
-
codebuddy --sandbox "继续开发"
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### 4. 临时任务
|
|
240
|
-
|
|
241
|
-
使用 `--sandbox-kill` 自动清理:
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
codebuddy --sandbox --sandbox-kill "快速测试一个想法"
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### 5. 定期清理
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# 查看所有沙箱
|
|
251
|
-
codebuddy sandbox list
|
|
252
|
-
|
|
253
|
-
# 清理失效的
|
|
254
|
-
codebuddy sandbox clean
|
|
255
|
-
|
|
256
|
-
# 手动终止特定沙箱
|
|
257
|
-
codebuddy sandbox kill sb_old123
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## ⚠️ 注意事项
|
|
261
|
-
|
|
262
|
-
### Container Sandbox
|
|
263
|
-
|
|
264
|
-
- **挂载模式**:容器沙箱自动挂载当前目录,文件修改实时同步
|
|
265
|
-
- **网络隔离**: Docker 容器与主机网络隔离
|
|
266
|
-
- **资源限制**:受 Docker 配置限制
|
|
267
|
-
|
|
268
|
-
### E2B Sandbox
|
|
269
|
-
|
|
270
|
-
- **上传延迟**:首次上传项目需要时间,文件越多越慢
|
|
271
|
-
- **文件同步**:不支持自动同步,需要重新上传或手动同步
|
|
272
|
-
- **费用**: E2B 云服务可能产生费用,请查看官方定价
|
|
273
|
-
- **超时**:沙箱有最大运行时间限制 (默认 1 小时)
|
|
274
|
-
|
|
275
|
-
### 交互式命令
|
|
276
|
-
|
|
277
|
-
E2B 和 Container 都支持交互式 PTY:
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
codebuddy --sandbox "用 vim 编辑 main.py"
|
|
281
|
-
codebuddy --sandbox "运行 htop 查看进程"
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## 🔧 故障排查
|
|
285
|
-
|
|
286
|
-
### Docker 未运行
|
|
287
|
-
|
|
288
|
-
```bash
|
|
289
|
-
Error: Neither Docker nor Podman is available
|
|
290
|
-
```
|
|
291
|
-
**解决**:启动 Docker Desktop 或 Podman
|
|
292
|
-
|
|
293
|
-
### E2B API Key 缺失
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
Error: E2B_API_KEY environment variable is required
|
|
297
|
-
```
|
|
298
|
-
**解决**: `export E2B_API_KEY=your_key_here`
|
|
299
|
-
|
|
300
|
-
### 沙箱连接失败
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
Failed to connect to sandbox sb_abc123
|
|
304
|
-
```
|
|
305
|
-
**解决**:沙箱可能已过期,使用 `--sandbox-new` 创建新的
|
|
306
|
-
|
|
307
|
-
### 查看调试日志
|
|
308
|
-
|
|
309
|
-
```bash
|
|
310
|
-
codebuddy --sandbox --debug "测试命令"
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## 📚 相关文档
|
|
314
|
-
|
|
315
|
-
- [CLI 参考](./cli-reference.md) - 完整命令行参数说明
|
|
316
|
-
- [E2B 官方文档](https://e2b.dev/docs) - E2B 云服务文档
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
# Sandbox Usage Guide (Beta)
|
|
2
|
-
|
|
3
|
-
> ⚠️ **Beta Feature**: The Sandbox feature is currently in Beta. APIs and functionality may change.
|
|
4
|
-
|
|
5
|
-
CodeBuddy supports running in isolated sandbox environments, providing secure code execution and project development environments.
|
|
6
|
-
|
|
7
|
-
## 🎯 Sandbox Types
|
|
8
|
-
|
|
9
|
-
- **Container Sandbox**: Local container environment based on Docker/Podman
|
|
10
|
-
- **E2B Sandbox**: Remote isolated environment based on E2B cloud service
|
|
11
|
-
- **Teleport Mode**: Connect to remotely deployed sandbox services
|
|
12
|
-
|
|
13
|
-
## 🚀 Quick Start
|
|
14
|
-
|
|
15
|
-
### Container Sandbox
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Basic usage - automatically mounts current directory
|
|
19
|
-
codebuddy --sandbox "Help me analyze this project"
|
|
20
|
-
|
|
21
|
-
# Equivalent to
|
|
22
|
-
codebuddy --sandbox container "Help me analyze this project"
|
|
23
|
-
|
|
24
|
-
# Pipe mode
|
|
25
|
-
echo "Run tests" | codebuddy --sandbox --print
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**Prerequisites**:
|
|
29
|
-
- Docker or Podman installed
|
|
30
|
-
- Docker daemon running
|
|
31
|
-
|
|
32
|
-
### E2B Sandbox (Cloud)
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# Set E2B API Key
|
|
36
|
-
export E2B_API_KEY=your_api_key
|
|
37
|
-
|
|
38
|
-
# Basic usage (requires full API URL)
|
|
39
|
-
codebuddy --sandbox https://api.e2b.dev "Create a Python web application"
|
|
40
|
-
|
|
41
|
-
# Upload current working directory
|
|
42
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-upload-dir "Analyze this project"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Teleport Mode (Remote Connection)
|
|
46
|
-
|
|
47
|
-
Teleport mode is used to connect to remote sandbox environments created by BGA (Background Agent). This is a special connection mode primarily used for cloud scheduling scenarios.
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
# Connect to remote sandbox using teleport value
|
|
51
|
-
codebuddy --teleport session_abc123XYZ4567890 "Connect to remote sandbox"
|
|
52
|
-
|
|
53
|
-
# Custom headers (for authentication or routing)
|
|
54
|
-
codebuddy --teleport session_abc123XYZ4567890 \
|
|
55
|
-
-H "X-Domain: example.com" \
|
|
56
|
-
-H "X-Enterprise-Id: ent123" \
|
|
57
|
-
"Execute task"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**Teleport Value Format**:
|
|
61
|
-
- Format: `session_{cliSessionId}`
|
|
62
|
-
- `cliSessionId`: Unique session identifier
|
|
63
|
-
- Example: `session_abc123XYZ4567890`
|
|
64
|
-
|
|
65
|
-
**How It Works**:
|
|
66
|
-
1. BGA backend generates a unique `cliSessionId`
|
|
67
|
-
2. BGA clones code to `/workspace/{cliSessionId}` directory in the sandbox
|
|
68
|
-
3. BGA generates teleport command: `codebuddy --teleport session_{cliSessionId}`
|
|
69
|
-
4. CLI parses the teleport value, connects to the specified sandbox and switches to the correct working directory
|
|
70
|
-
5. Executes commands as `root` user in the sandbox
|
|
71
|
-
|
|
72
|
-
**Prerequisites**:
|
|
73
|
-
- Valid teleport value (generated by BGA backend)
|
|
74
|
-
- Correct authentication credentials (via E2B_API_KEY or CODEBUDDY_AUTH_TOKEN)
|
|
75
|
-
- Network connectivity to BGA backend service
|
|
76
|
-
|
|
77
|
-
**Features**:
|
|
78
|
-
- Code is prepared by BGA backend, no upload needed
|
|
79
|
-
- Automatically executes commands as root user
|
|
80
|
-
- Working directory automatically set to `/workspace/{cliSessionId}`
|
|
81
|
-
- Supports custom HTTP headers for authentication and routing
|
|
82
|
-
|
|
83
|
-
## 📦 Sandbox Reuse Mechanism
|
|
84
|
-
|
|
85
|
-
### Alias System
|
|
86
|
-
|
|
87
|
-
Assign independent sandboxes for users/projects:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
# Use user ID as alias
|
|
91
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id user-123 -p "Task"
|
|
92
|
-
|
|
93
|
-
# Use project name as alias
|
|
94
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id project-foo -p "Task"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Alias mappings are stored in `~/.codebuddy/sandbox-state.json`, supporting automatic creation and reuse.
|
|
98
|
-
|
|
99
|
-
### Default Behavior
|
|
100
|
-
|
|
101
|
-
Sandboxes are automatically reused without manually specifying IDs:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# First time - creates new sandbox
|
|
105
|
-
$ codebuddy --sandbox https://api.e2b.dev "Hello"
|
|
106
|
-
[Sandbox] Creating new E2B sandbox...
|
|
107
|
-
[Sandbox] Created new sandbox: sb_abc123
|
|
108
|
-
|
|
109
|
-
# Next launch - automatically reuses
|
|
110
|
-
$ codebuddy --sandbox https://api.e2b.dev "Continue working"
|
|
111
|
-
[Sandbox] Reusing sandbox: sb_abc123
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Multi-Project Management
|
|
115
|
-
|
|
116
|
-
A single sandbox can host multiple projects, automatically isolated in different directories:
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
/workspace/
|
|
120
|
-
├── home-user-projectA/
|
|
121
|
-
├── home-user-projectB/
|
|
122
|
-
└── var-www-website/
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## ⚙️ Advanced Parameters
|
|
126
|
-
|
|
127
|
-
### Sandbox Creation and Connection
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# Force create new sandbox (ignore cache)
|
|
131
|
-
codebuddy --sandbox --sandbox-new "Start from scratch"
|
|
132
|
-
|
|
133
|
-
# Connect to specific sandbox ID (real ID)
|
|
134
|
-
codebuddy --sandbox --sandbox-id sb_abc123 "Continue previous work"
|
|
135
|
-
|
|
136
|
-
# Use aliases (custom names, auto-create and reuse)
|
|
137
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id user-123 -p "Task" # User ID
|
|
138
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id project-foo -p "Task" # Project name
|
|
139
|
-
codebuddy --sandbox https://api.e2b.dev --sandbox-id team-backend -p "Task" # Team name
|
|
140
|
-
|
|
141
|
-
# Terminate sandbox on exit (default keeps running for reuse)
|
|
142
|
-
codebuddy --sandbox --sandbox-kill "Clean up after completion"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Environment Variable Configuration
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
# E2B configuration
|
|
149
|
-
export E2B_API_KEY=your_api_key # Required
|
|
150
|
-
export E2B_TEMPLATE=base # Template name (default: base)
|
|
151
|
-
export E2B_TIMEOUT_MS=3600000 # Timeout (default: 1 hour)
|
|
152
|
-
export E2B_ALLOW_INTERNET_ACCESS=true # Allow internet access (default: true)
|
|
153
|
-
|
|
154
|
-
# Container Sandbox configuration
|
|
155
|
-
export CODEBUDDY_SANDBOX_IMAGE=node:20-alpine # Docker image
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## 📊 Sandbox Management
|
|
159
|
-
|
|
160
|
-
### List Sandboxes
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
$ codebuddy sandbox list
|
|
164
|
-
E2B Sandboxes:
|
|
165
|
-
* sb_abc123 (2 projects, last used 2m ago)
|
|
166
|
-
sb_xyz789 (1 project, last used 2h ago)
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### View Details
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
# View current sandbox
|
|
173
|
-
$ codebuddy sandbox info
|
|
174
|
-
|
|
175
|
-
# View specific sandbox
|
|
176
|
-
$ codebuddy sandbox info sb_xyz789
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Terminate Sandbox
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
$ codebuddy sandbox kill sb_abc123
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Clean Up Invalid Sandboxes
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
$ codebuddy sandbox clean
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## 🔍 How It Works
|
|
192
|
-
|
|
193
|
-
### Project Directory Mapping
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
Local path: /Users/yangsubo/projectA
|
|
197
|
-
Sandbox path: /workspace/Users-yangsubo-projectA
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### State Persistence
|
|
201
|
-
|
|
202
|
-
Sandbox state is saved in `~/.codebuddy/sandbox-state.json`
|
|
203
|
-
|
|
204
|
-
## 💡 Best Practices
|
|
205
|
-
|
|
206
|
-
### 1. Choose the Right Sandbox Type
|
|
207
|
-
|
|
208
|
-
```bash
|
|
209
|
-
# Need local container isolation
|
|
210
|
-
codebuddy --sandbox container "Local development task"
|
|
211
|
-
|
|
212
|
-
# Cloud collaboration or no local environment
|
|
213
|
-
codebuddy --sandbox https://api.e2b.dev "Cloud development"
|
|
214
|
-
|
|
215
|
-
# Connect to remotely deployed sandbox service
|
|
216
|
-
codebuddy --teleport session_abc123XYZ4567890 "Remote development"
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### 2. Project Isolation
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
cd ~/work/projectA
|
|
223
|
-
codebuddy --sandbox "Develop feature X"
|
|
224
|
-
|
|
225
|
-
cd ~/work/projectB
|
|
226
|
-
codebuddy --sandbox "Fix bug Y"
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### 3. Long-term Development
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
# Day one
|
|
233
|
-
codebuddy --sandbox "Set up development environment"
|
|
234
|
-
|
|
235
|
-
# Day two - instant startup, environment preserved
|
|
236
|
-
codebuddy --sandbox "Continue development"
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### 4. Temporary Tasks
|
|
240
|
-
|
|
241
|
-
Use `--sandbox-kill` for automatic cleanup:
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
codebuddy --sandbox --sandbox-kill "Quickly test an idea"
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### 5. Regular Cleanup
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# View all sandboxes
|
|
251
|
-
codebuddy sandbox list
|
|
252
|
-
|
|
253
|
-
# Clean up invalid ones
|
|
254
|
-
codebuddy sandbox clean
|
|
255
|
-
|
|
256
|
-
# Manually terminate specific sandbox
|
|
257
|
-
codebuddy sandbox kill sb_old123
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## ⚠️ Important Notes
|
|
261
|
-
|
|
262
|
-
### Container Sandbox
|
|
263
|
-
|
|
264
|
-
- **Mount Mode**: Container sandbox automatically mounts current directory, file changes sync in real-time
|
|
265
|
-
- **Network Isolation**: Docker container is isolated from host network
|
|
266
|
-
- **Resource Limits**: Subject to Docker configuration limits
|
|
267
|
-
|
|
268
|
-
### E2B Sandbox
|
|
269
|
-
|
|
270
|
-
- **Upload Delay**: Initial project upload takes time, more files means slower upload
|
|
271
|
-
- **File Sync**: Automatic sync not supported, requires re-upload or manual sync
|
|
272
|
-
- **Cost**: E2B cloud service may incur charges, check official pricing
|
|
273
|
-
- **Timeout**: Sandboxes have maximum runtime limits (default: 1 hour)
|
|
274
|
-
|
|
275
|
-
### Interactive Commands
|
|
276
|
-
|
|
277
|
-
Both E2B and Container support interactive PTY:
|
|
278
|
-
|
|
279
|
-
```bash
|
|
280
|
-
codebuddy --sandbox "Edit main.py with vim"
|
|
281
|
-
codebuddy --sandbox "Run htop to view processes"
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## 🔧 Troubleshooting
|
|
285
|
-
|
|
286
|
-
### Docker Not Running
|
|
287
|
-
|
|
288
|
-
```bash
|
|
289
|
-
Error: Neither Docker nor Podman is available
|
|
290
|
-
```
|
|
291
|
-
**Solution**: Start Docker Desktop or Podman
|
|
292
|
-
|
|
293
|
-
### E2B API Key Missing
|
|
294
|
-
|
|
295
|
-
```bash
|
|
296
|
-
Error: E2B_API_KEY environment variable is required
|
|
297
|
-
```
|
|
298
|
-
**Solution**: `export E2B_API_KEY=your_key_here`
|
|
299
|
-
|
|
300
|
-
### Sandbox Connection Failed
|
|
301
|
-
|
|
302
|
-
```bash
|
|
303
|
-
Failed to connect to sandbox sb_abc123
|
|
304
|
-
```
|
|
305
|
-
**Solution**: Sandbox may have expired, use `--sandbox-new` to create a new one
|
|
306
|
-
|
|
307
|
-
### View Debug Logs
|
|
308
|
-
|
|
309
|
-
```bash
|
|
310
|
-
codebuddy --sandbox --debug "Test command"
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## 📚 Related Documentation
|
|
314
|
-
|
|
315
|
-
- [CLI Reference](./cli-reference.md) - Complete command-line parameter documentation
|
|
316
|
-
- [E2B Official Documentation](https://e2b.dev/docs) - E2B cloud service documentation
|