@delta-infra/cli 1.0.18 → 1.0.19
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/package.json
CHANGED
|
@@ -36,28 +36,22 @@ metadata:
|
|
|
36
36
|
6. **禁止重复创建**:同一次任务中只允许存在一个活跃 sandbox。若命令失败需要重试,优先复用已创建的 `sandbox_id`;若确实需要重新创建,必须先 `sandbox kill <旧_sandbox_id>`,确认旧实例销毁后再执行新的 `sandbox create`。可用 `delta-cli sandbox list` 查询当前用户的活跃 sandbox,但 **禁止** 用 list 来绕过“同一次任务只保留一个 sandbox”的规则。
|
|
37
37
|
|
|
38
38
|
7. **长任务必须后台执行**:预计执行时间超过 60 秒的任务(例如下载模型、训练、微调、长推理、大规模数据处理),**必须**使用 `delta-cli sandbox run-bg <id> --command "..." --timeout <秒>` 提交为后台任务,禁止使用同步的 `sandbox run`。
|
|
39
|
-
- 命令末尾建议添加完成标记 `&& echo SANDBOX_BACKGROUND_DONE`,便于轮询时判断。
|
|
40
39
|
- 轮询用 `delta-cli sandbox logs <id> --execution-id <exec_id>`,每 15-30 秒一次。
|
|
41
40
|
- 完成判断(按优先级):
|
|
42
41
|
a) `finished=true` + `exit_code=0` → 正常完成
|
|
43
42
|
b) `finished=true` + `exit_code!=0` → 命令执行失败,查看 stderr
|
|
44
43
|
c) `running=true` → 仍在运行,继续等待
|
|
45
|
-
d) 辅助判断:`content` 中出现 `SANDBOX_BACKGROUND_DONE` → 完成;`cursor` 在增长 → 仍在运行
|
|
46
44
|
- 也可用 `delta-cli sandbox status bg <id> --execution-id <exec_id>` 直接查询后台命令的运行状态和退出码。
|
|
47
45
|
- 故障诊断:连续 3 次 `running=true` 且 `content`/`cursor` 无变化且距离提交超过 60 秒 → 用 `sandbox status <id>` 检查 sandbox 是否存活。如果 sandbox 正常但 logs 无输出,用 `sandbox run <id> --command "ps aux" --timeout 15` 在容器内检查进程状态。
|
|
48
46
|
- 后台任务成功后仍需按规则 2/3 销毁 sandbox。
|
|
49
47
|
|
|
50
|
-
8.
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
48
|
+
8. **写入文件禁止使用路径或 Shell 变量,仅允许文件名**:
|
|
49
|
+
- ❌ **禁止**:`--source "$WORKSPACE_ROOT/train.py"`、`--source "$(pwd)/train.py"`(Shell 展开路径 → 空文件或失败)
|
|
50
|
+
- ❌ **禁止**:`--data "大量代码..."`(Shell 转义问题)
|
|
51
|
+
- ✅ **正确**:`delta-cli sandbox write <id> --path /workspace/train.py --source train.py`(仅文件名)
|
|
52
|
+
- 少量配置(< 20 行)可用 `--data "..."`。`--mode 755` 可设置文件权限。
|
|
55
53
|
|
|
56
|
-
9. **每个 `run-bg` 生成独立 `execution_id`**:每次调用 `sandbox run-bg` 都会返回一个唯一的 `execution_id`,多个后台任务之间通过它区分。务必保存每次返回的 `execution_id` 并与任务对应,后续通过 `sandbox logs <id> --execution-id <exec_id>` 分别查询各任务的结果。同步 `sandbox run` 无需 `execution_id
|
|
57
|
-
- 正确:`delta-cli sandbox write <id> --path /workspace/train.py --source train.py`
|
|
58
|
-
- 错误:`delta-cli sandbox write <id> --path /workspace/train.py --data "大量代码..."`(Shell 转义问题)
|
|
59
|
-
- 错误:`delta-cli sandbox write <id> --path /workspace/train.py --source "$WORKSPACE_ROOT/train.py"`(Windows 路径被 Shell 吃掉)
|
|
60
|
-
- 少量配置内容(< 20 行)可以用 `--data "..."`,但需确保内容不含 Shell 特殊字符。`--mode 755` 可设置文件权限(八进制,可选)。
|
|
54
|
+
9. **每个 `run-bg` 生成独立 `execution_id`**:每次调用 `sandbox run-bg` 都会返回一个唯一的 `execution_id`,多个后台任务之间通过它区分。务必保存每次返回的 `execution_id` 并与任务对应,后续通过 `sandbox logs <id> --execution-id <exec_id>` 分别查询各任务的结果。同步 `sandbox run` 无需 `execution_id`,结果直接返回。
|
|
61
55
|
|
|
62
56
|
## 快速路由
|
|
63
57
|
|
|
@@ -90,7 +84,7 @@ metadata:
|
|
|
90
84
|
- Node.js:`node /workspace/app.js`
|
|
91
85
|
- Go:`go run /workspace/main.go`
|
|
92
86
|
- Shell:`bash /workspace/run.sh`
|
|
93
|
-
- **长任务(预计 > 60 秒,如下载模型、训练、编译、大规模数据处理)**:`delta-cli sandbox run-bg <id> --command "<命令>
|
|
87
|
+
- **长任务(预计 > 60 秒,如下载模型、训练、编译、大规模数据处理)**:`delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒>` 提交后台任务,获得 `execution_id` 后通过以下命令轮询:
|
|
94
88
|
- `delta-cli sandbox logs <id> --execution-id <execution_id>` — 返回 `content`、`cursor`、`running`、`finished`、`exit_code`。当 `finished=true` 时认为完成。
|
|
95
89
|
- `delta-cli sandbox status bg <id> --execution-id <execution_id>` — 返回 `running`、`finished`、`exit_code`。
|
|
96
90
|
禁止对长任务使用同步 `sandbox run`
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
# 1. 启动后台命令(立即返回,不阻塞)
|
|
24
|
-
#
|
|
25
|
-
delta-cli sandbox run-bg <id> --command "<命令> && echo SANDBOX_BACKGROUND_DONE" --timeout 7200
|
|
24
|
+
# delta-cli sandbox run-bg <id> --command "<命令>" --timeout 7200
|
|
26
25
|
|
|
27
26
|
# ↑ 返回数据中包含 execution_id,请保存以便后续查询
|
|
28
27
|
|
|
@@ -53,7 +52,6 @@ delta-cli sandbox kill <id>
|
|
|
53
52
|
1. **`finished=true` + `exit_code=0`** → 正常完成,可以读取结果并销毁 sandbox
|
|
54
53
|
2. **`finished=true` + `exit_code≠0`** → 命令执行失败,查看 stderr/error 信息
|
|
55
54
|
3. **`running=true`** → 任务仍在运行,继续等待(建议每 15-30 秒查询一次)
|
|
56
|
-
4. **辅助判断**:`content` 中出现 `SANDBOX_BACKGROUND_DONE` → 完成;`cursor` 在增长 → 仍在运行
|
|
57
55
|
5. **连续 3 次 `running=true` 且 `content`/`cursor` 无变化且距离提交超过 60 秒** → 任务可能挂起或无输出,用 `sandbox status <id>` 检查 sandbox 是否存活;也可用 `sandbox status bg <id> --execution-id <exec_id>` 查后台命令状态
|
|
58
56
|
6. **`sandbox status` 返回正常但 logs 仍然无变化** → 用 `sandbox run <id> --command "ps aux | grep <进程名>" --timeout 15` 在容器内检查命令是否还在运行
|
|
59
57
|
|