@delta-infra/cli 1.0.55 → 1.0.56
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/README.md
CHANGED
|
@@ -174,6 +174,10 @@ delta-cli sandbox run <sandbox_id> \
|
|
|
174
174
|
--command "<命令>" \
|
|
175
175
|
--timeout 3600
|
|
176
176
|
|
|
177
|
+
# v1.0.55+ 默认带 --summary,返回 JSON 中 data.summary 字段已含 stdout 末尾 JSON 提取结果
|
|
178
|
+
# 无需再手动读取 result_file 做二次解析(除非使用了 --no-summary)
|
|
179
|
+
delta-cli sandbox run <sandbox_id> --command "echo '{\"status\":\"ok\",\"result\":\"done\"}'" --timeout 60
|
|
180
|
+
|
|
177
181
|
# 读取结果文件
|
|
178
182
|
delta-cli sandbox read <sandbox_id> --path /workspace/result.json
|
|
179
183
|
|
|
@@ -216,12 +220,12 @@ delta-cli sandbox kill <sandbox_id>
|
|
|
216
220
|
| `delta-cli sandbox status <id>` | 查看 sandbox 状态 |
|
|
217
221
|
| `delta-cli sandbox finish <id>` | 保存结果并销毁 |
|
|
218
222
|
| `delta-cli sandbox kill <id>` | 销毁 sandbox |
|
|
219
|
-
| `delta-cli sandbox run <id> --command "..."` |
|
|
220
|
-
| `delta-cli sandbox run-bg <id> --command "..." [--wait]` |
|
|
221
|
-
| `delta-cli sandbox logs <id> --execution-id <eid
|
|
222
|
-
| `delta-cli sandbox status bg <id> --execution-id <eid>` | 查询后台命令状态 |
|
|
223
|
+
| `delta-cli sandbox run <id> --command "..." [--timeout <秒>] [--summary/--no-summary] [--artifacts]` | 同步运行命令;默认带 `--summary`,返回 JSON 中 `summary` 字段已含 stdout 末尾 JSON 提取结果;`--artifacts` 附带 workspace 产物清单 |
|
|
224
|
+
| `delta-cli sandbox run-bg <id> --command "..." [--timeout <秒>] [--wait] [--summary/--no-summary] [--artifacts]` | 后台运行命令;不加 `--wait` 立即返回 `{execution_id, sandbox_id}`;加 `--wait` 等待完成返回含 `summary` 的完整结果 |
|
|
225
|
+
| `delta-cli sandbox logs <id> --execution-id <eid> [--tail N --grep <pattern> --context N --max-bytes N]` | 查看后台日志;默认返回 `stderr_size + stderr_tail`(避免上下文爆炸);可用 `--tail/--grep` 过滤 |
|
|
223
226
|
| `delta-cli sandbox cancel <id> --execution-id <eid>` | 中断后台命令 |
|
|
224
|
-
| `delta-cli sandbox read <id> --path <path
|
|
227
|
+
| `delta-cli sandbox read <id> --path <path> [--output <本地路径>] [--tail N] [--grep <pattern>] [--offset N] [--limit N] [--context N] [--max-bytes N] [--parse-json]` | 读取容器内文件;`--output <path>` 保存到本地;`--tail/--grep` 过滤;非 UTF-8 文件 CLI 自动走 base64 fallback |
|
|
228
|
+
| `delta-cli sandbox pull <id> --source <沙箱路径> --target <本地路径>` | 从沙箱拉取文件/目录到本地(mirror of `upload`);单文件或递归目录;CLI 端 + 服务端双向 sha1 完整性校验 |
|
|
225
229
|
| `delta-cli sandbox write <id> --path <path> --source <本地路径>` | 写入文件 |
|
|
226
230
|
| `delta-cli sandbox write-multiple <id> --entry <远程路径>=<本地路径>` | 批量写入 |
|
|
227
231
|
| `delta-cli sandbox ls <id> --path <path>` | 列出目录 |
|
package/checksums.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
a24c65027bd2ab44ddae3c1f7d85c324c84817654d83c83f8ac8e77b44c20950 delta-cli-darwin-amd64.tar.gz
|
|
2
|
+
df1f28dd6be4b8ed416143727f420cf42076d0f1e1e1c8866c9a685a750297f5 delta-cli-darwin-arm64.tar.gz
|
|
3
|
+
b27d3928c522a0e07e1eb02080dd5f77091f1413be89c13f2d78c6b22b05564d delta-cli-linux-amd64.tar.gz
|
|
4
|
+
f998e56a7b569d29ae8e32c11361d14b396e6eaf3f255757a5d09e4fda3d624e delta-cli-linux-arm64.tar.gz
|
|
5
|
+
2bae28c9afab6bfbe6f9fad3712076a9bb4762c30fb2f9584dd7618f4d63a4d3 delta-cli-windows-amd64.zip
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: delta-sandbox
|
|
3
|
-
version: 1.
|
|
4
|
-
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON,
|
|
3
|
+
version: 1.3.0
|
|
4
|
+
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON,CLI 反向扫描 stdout 末尾 JSON 自动提取 summary 字段。Planner 调用本 skill 时,请在 plan step 的 required_outputs 中声明 [{kind: 'file', extensions: ['.json']}]。请求中用中性动词(运行/执行)描述命令,只有真的会落盘文件时,才使用创建/写入/保存等动词并带上扩展名。认证/配置/权限错误转 delta-shared。"
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["delta-cli"]
|
|
@@ -41,14 +41,13 @@ metadata:
|
|
|
41
41
|
```bash
|
|
42
42
|
delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> --wait
|
|
43
43
|
```
|
|
44
|
-
CLI 在内部每 5 秒轮询一次 `logs`,直到 `finished=true` 或超时,然后一次性返回 `{execution_id, running, finished, exit_code, content}`。返回的 `execution_id` 可在后续用于 `sandbox logs` / `
|
|
44
|
+
CLI 在内部每 5 秒轮询一次 `logs`,直到 `finished=true` 或超时,然后一次性返回 `{execution_id, running, finished, exit_code, content}`。返回的 `execution_id` 可在后续用于 `sandbox logs` / `cancel`。适合只关心最终结果、不需要查看中间进度的场景。
|
|
45
45
|
|
|
46
46
|
**手动轮询(需要查看中间进度时)**:
|
|
47
47
|
如果不加 `--wait` 或需要查看实时输出,用 `sandbox logs <id> --execution-id <exec_id>` 手动轮询:
|
|
48
48
|
- `finished=true` + `exit_code=0` → 完成
|
|
49
49
|
- `finished=true` + `exit_code!=0` → 失败
|
|
50
50
|
- `running=true` → 仍运行
|
|
51
|
-
快速查询:`sandbox status bg <id> --execution-id <exec_id>`(只含状态,不含日志内容)
|
|
52
51
|
|
|
53
52
|
**故障诊断**:连续 3 次 `running=true` 且 `content`/`cursor` 无变化且距离提交超过 60 秒 → 用 `sandbox status <id>` 检查 sandbox 是否存活。
|
|
54
53
|
|
|
@@ -81,7 +80,7 @@ metadata:
|
|
|
81
80
|
13. **`result.json` 是完成前的必要条件**
|
|
82
81
|
- 在调用 `step_finish` 之前,必须确认:
|
|
83
82
|
1. `delta-cli sandbox run` / `run-bg --wait` 已返回且 `finished=true`;
|
|
84
|
-
2.
|
|
83
|
+
2. (默认)直接复用 `sandbox run` / `run-bg --wait` 返回的 `summary` 字段写入 `result.json`;或(fallback)从 `result_file` 用 `sandbox read` + Python 解析
|
|
85
84
|
3. 已执行 `sandbox kill <id>` 销毁 sandbox;
|
|
86
85
|
4. `final_response` 只有一行 `RESULT: <result_summary>`。
|
|
87
86
|
|
|
@@ -141,13 +140,13 @@ required_outputs:
|
|
|
141
140
|
| 完成 sandbox | `sandbox finish <id> [--results '{...}']` |
|
|
142
141
|
| 销毁 sandbox | `sandbox kill <id>` |
|
|
143
142
|
| **命令执行** | |
|
|
144
|
-
| 同步运行命令(≤60s) | `sandbox run <id> --command "..." [--timeout <秒>]` |
|
|
145
|
-
| 后台运行命令(>60s) | `sandbox run-bg <id> --command "..." [--timeout <秒>] [--wait]` |
|
|
146
|
-
| 查看后台日志 | `sandbox logs <id> --execution-id <exec_id
|
|
147
|
-
| 查询后台状态 | `sandbox status bg <id> --execution-id <exec_id>` |
|
|
143
|
+
| 同步运行命令(≤60s) | `sandbox run <id> --command "..." [--timeout <秒>] [--summary/--no-summary] [--artifacts]` |
|
|
144
|
+
| 后台运行命令(>60s) | `sandbox run-bg <id> --command "..." [--timeout <秒>] [--wait] [--summary/--no-summary] [--artifacts]` |
|
|
145
|
+
| 查看后台日志 | `sandbox logs <id> --execution-id <exec_id> [--tail N --grep <pattern> --context N --max-bytes N]` |
|
|
148
146
|
| 中断后台命令 | `sandbox cancel <id> --execution-id <exec_id>` |
|
|
149
147
|
| **文件操作** | |
|
|
150
|
-
| 读取文件 | `sandbox read <id> --path <path
|
|
148
|
+
| 读取文件 | `sandbox read <id> --path <path> [--output <本地路径> --tail N --grep <pattern> --offset N --limit N --context N --max-bytes N --parse-json]` |
|
|
149
|
+
| 拉取文件/目录 | `sandbox pull <id> --source <本地路径> --target <沙箱路径>` — 单文件或目录递归,含 sha1 校验(mirror of upload) |
|
|
151
150
|
| 写入文件 | `sandbox write <id> --path <path> --source <文件名>`(推荐)|
|
|
152
151
|
| 批量写入 | `sandbox write-multiple <id> --entry <远程路径>=<本地路径> [--entry ...]` |
|
|
153
152
|
| 上传目录 | `sandbox upload <id> --source <本地目录> --target <沙箱路径>` |
|
|
@@ -189,61 +188,84 @@ required_outputs:
|
|
|
189
188
|
- Shell:`bash /workspace/run.sh`
|
|
190
189
|
- **长任务(预计 > 60 秒,如下载模型、训练、编译、大规模数据处理)**:`delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> [--result-file <路径>]` 提交后台任务,获得 `execution_id` 后通过以下命令轮询:
|
|
191
190
|
- `delta-cli sandbox logs <id> --execution-id <execution_id>` — 返回 `cursor`、`running`、`finished`、`exit_code`、`result_file`(完成后)。当 `finished=true` 时认为完成,完整输出需读取 `result_file`。
|
|
192
|
-
- `delta-cli sandbox status bg <id> --execution-id <execution_id>` — 返回 `running`、`finished`、`exit_code`。
|
|
193
191
|
禁止对长任务使用同步 `sandbox run`
|
|
194
192
|
|
|
195
|
-
**推荐实践**:让 sandbox 脚本在 `stdout` 末尾打印一个独立的结构化 JSON 对象(例如 `{"status":"ok", ...}`),
|
|
196
|
-
5.
|
|
197
|
-
- `
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
193
|
+
**推荐实践**:让 sandbox 脚本在 `stdout` 末尾打印一个独立的结构化 JSON 对象(例如 `{"status":"ok", ...}`),CLI 的 `--summary` 默认会自动反向扫描 stdout 末尾 JSON 提取为 `data.summary` 字段。这样即使 `stdout` 前面是大量训练/下载日志,skill 也无需让大模型去“读整段日志再摘要”。
|
|
194
|
+
5. **生成 result.json**(默认路径使用 CLI 返回的 `summary` 字段;fallback 路径用 `sandbox read` + Python 解析):
|
|
195
|
+
- **5a(默认路径,推荐)**:`run` / `run-bg --wait` 已返回 `summary` 字段(CLI 自动 reverse-scan stdout 末尾 JSON)。直接构造 `result.json`:
|
|
196
|
+
```bash
|
|
197
|
+
delta-cli sandbox run <id> --command "..." --timeout 60 > /tmp/_run.json
|
|
198
|
+
```
|
|
199
|
+
```python
|
|
200
|
+
import json, os
|
|
201
|
+
r = json.load(open("/tmp/_run.json"))
|
|
202
|
+
data = r.get("data", {})
|
|
203
|
+
result = {
|
|
204
|
+
"exit_code": data.get("exit_code"),
|
|
205
|
+
"finished": data.get("finished", True),
|
|
206
|
+
"summary": data.get("summary") or {},
|
|
207
|
+
"result_summary": ", ".join(f"{k}={v}" for k,v in (data.get("summary") or {}).items()
|
|
208
|
+
if isinstance(v, (str,int,float,bool)) and len(str(v))<200),
|
|
209
|
+
"error": data.get("error"),
|
|
210
|
+
}
|
|
211
|
+
if not result["result_summary"]:
|
|
212
|
+
result["result_summary"] = f"exit_code={result['exit_code']}, finished={result['finished']}"
|
|
213
|
+
ws = os.environ.get("WORKSPACE_ROOT", ".")
|
|
214
|
+
json.dump(result, open(os.path.join(ws, "result.json"), "w", encoding="utf-8"),
|
|
215
|
+
indent=2, ensure_ascii=False)
|
|
216
|
+
print(result["result_summary"])
|
|
217
|
+
```
|
|
218
|
+
- **5b(fallback,仅当 `--no-summary` 或 `summary` 为 null)**:从 `sandbox run` / `sandbox run-bg --wait` / `sandbox logs` 返回数据中获得 `result_file` 路径,用 `sandbox read` + Python 解析。
|
|
219
|
+
- `sandbox read` 返回的是 CLI 信封 `{"ok":true,"data":{"content":"..."}}`,真实结果 JSON 在 `data.content` 字段里。
|
|
220
|
+
- **不要把 CLI 信封或完整长 `stdout` 原样写入本地 `result.json`**;应该解析后生成一份精简的结构化摘要。
|
|
221
|
+
- **推荐做法(避免 heredoc 引号失败)**:先用 `bash` 把信封写入临时文件,再用 `python3`(或 `python_repl`)读取该文件并生成 `result.json`。**不要**把 `delta-cli sandbox read` 的输出通过管道直接喂给内联 heredoc,管道+heredoc 的组合极易因 Shell 转义/引号问题失败。
|
|
222
|
+
1. `bash` 保存信封:
|
|
223
|
+
```bash
|
|
224
|
+
delta-cli sandbox read <sandbox_id> --path <result_file> > /tmp/_delta_result_envelope.json
|
|
225
|
+
```
|
|
226
|
+
2. `python3` / `python_repl` 生成 `result.json`:
|
|
227
|
+
```python
|
|
228
|
+
import json, os
|
|
229
|
+
|
|
230
|
+
env = json.load(open("/tmp/_delta_result_envelope.json", encoding="utf-8"))
|
|
231
|
+
raw = json.loads(env["data"]["content"])
|
|
232
|
+
|
|
233
|
+
# 精简到用户关心的极简字段,避免 host read_file 预览截断
|
|
234
|
+
concise = {
|
|
235
|
+
"exit_code": raw.get("exit_code"),
|
|
236
|
+
"finished": raw.get("finished"),
|
|
237
|
+
"summary": {},
|
|
238
|
+
"error": raw.get("error"),
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
# 优先提取 stdout 末尾的独立 JSON 对象作为 summary
|
|
242
|
+
stdout = raw.get("stdout", "")
|
|
243
|
+
for line in reversed(stdout.strip().splitlines()):
|
|
244
|
+
s = line.strip()
|
|
245
|
+
if s.startswith("{") and s.endswith("}"):
|
|
246
|
+
try:
|
|
247
|
+
concise["summary"] = json.loads(s)
|
|
248
|
+
break
|
|
249
|
+
except Exception:
|
|
250
|
+
pass
|
|
251
|
+
|
|
252
|
+
# 构造 result_summary:一行字符串,最终回答的 RESULT: 行直接用它
|
|
253
|
+
parts = [f"exit_code={concise['exit_code']}", f"finished={concise['finished']}"]
|
|
254
|
+
for key, value in concise["summary"].items():
|
|
255
|
+
# 避免把长文本塞进 result_summary
|
|
256
|
+
if isinstance(value, (str, int, float, bool)) and len(str(value)) < 200:
|
|
257
|
+
parts.append(f"{key}={value}")
|
|
258
|
+
concise["result_summary"] = ", ".join(parts)
|
|
259
|
+
|
|
260
|
+
ws = os.environ.get("WORKSPACE_ROOT", ".")
|
|
261
|
+
with open(os.path.join(ws, "result.json"), "w", encoding="utf-8") as f:
|
|
262
|
+
json.dump(concise, f, indent=2, ensure_ascii=False)
|
|
263
|
+
print(concise["result_summary"])
|
|
264
|
+
```
|
|
265
|
+
3. 如果当前环境没有 `python3`,用 `jq`、`node` 或任何可解析 JSON 的工具实现**相同逻辑**:1)读取 `/tmp/_delta_result_envelope.json`;2)解开 CLI 信封取 `data.content`;3)解析内部 JSON;4)从 `stdout` 末尾提取 summary JSON;5)生成 `result_summary` 并写入 `result.json`。
|
|
266
|
+
- 如果 `stdout` 非常大(训练日志、下载日志等),不要把整段 `stdout` 写进 `result.json`;只保留关键指标和 preview。
|
|
267
|
+
- 完整原始输出仍保留在 sandbox 的 `result_file` 中,必要时可再次 `sandbox read` 获取。
|
|
268
|
+
- 写入本地副本的目的是让 host 的 deliverable 校验识别到真实的 `.json` 文件;由于校验是“或”语义,`.json` 文件会盖过 `torch.cuda` 等 token 被误判出的 `.cuda` 文件承诺。
|
|
247
269
|
6. **销毁**:`delta-cli sandbox kill <id>`(如需保存结果,用 `sandbox finish --results '{...}'` 替代 kill,finish 会自动销毁 sandbox)
|
|
248
270
|
|
|
249
271
|
详细步骤见 [lifecycle.md](references/lifecycle.md)。
|
|
@@ -285,10 +307,10 @@ required_outputs:
|
|
|
285
307
|
|
|
286
308
|
## 输出阅读与最终回答格式
|
|
287
309
|
|
|
288
|
-
1. **`sandbox run` / `
|
|
289
|
-
2.
|
|
310
|
+
1. **`sandbox run` / `run-bg --wait` 默认带 `--summary`,返回的 JSON 中 `data.summary` 字段已包含 stdout 末尾 JSON 提取结果。也包含 `data.result_file`**(沙箱内结构化结果文件的路径),作为 fallback 路径。
|
|
311
|
+
2. **默认优先用 `data.summary`**;仅当 `summary` 字段为 null(使用了 `--no-summary` 或 stdout 无 JSON)时,再用 `sandbox read <id> --path <result_file>` 读取 result_file 并解析 CLI 信封。
|
|
290
312
|
- 结果文件包含完整 `stdout`、`stderr`、`exit_code`、`finished`、`command`、`error`。
|
|
291
|
-
3.
|
|
313
|
+
3. **生成本地精简 `result.json`**(见“完整生命周期”步骤 5 和“通用结构化输出约定”)。本地副本只应包含关键字段和摘要,**不应包含完整长 `stdout`**。
|
|
292
314
|
4. **最终回答必须且只能是 `RESULT:` 开头的一行。**
|
|
293
315
|
- 优先直接复用 `result.json` 里的 `result_summary` 字段:
|
|
294
316
|
```text
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
|
|
26
26
|
| 命令 | 说明 |
|
|
27
27
|
|------|------|
|
|
28
|
-
| `sandbox run <id> --command "..." [--timeout N]` |
|
|
29
|
-
| `sandbox run-bg <id> --command "..." [--timeout N] [--wait]` |
|
|
30
|
-
| `sandbox logs <id> --execution-id <eid
|
|
31
|
-
| `sandbox status bg <id> --execution-id <eid>` | 查询后台命令状态(不含日志内容) |
|
|
28
|
+
| `sandbox run <id> --command "..." [--timeout N] [--summary/--no-summary] [--artifacts]` | 同步运行命令;默认 `--summary` 开启,返回 JSON 中 `summary` 字段已含 stdout 末尾 JSON 提取结果;`--artifacts` 附带 workspace 产物清单 |
|
|
29
|
+
| `sandbox run-bg <id> --command "..." [--timeout N] [--wait] [--summary/--no-summary] [--artifacts]` | 后台运行命令;不加 `--wait` 立即返回 `{execution_id, sandbox_id}`;加 `--wait` 等待完成返回含 `summary` 的完整结果 |
|
|
30
|
+
| `sandbox logs <id> --execution-id <eid> [--tail N --grep <pattern> --context N --max-bytes N]` | 获取后台命令日志;默认返回 `stderr_size + stderr_tail`(避免上下文爆炸);可用 `--tail/--grep` 过滤 |
|
|
32
31
|
| `sandbox cancel <id> --execution-id <eid>` | 中断正在运行的后台命令 |
|
|
33
32
|
|
|
34
33
|
## 文件操作
|
|
35
34
|
|
|
36
35
|
| 命令 | 说明 |
|
|
37
36
|
|------|------|
|
|
38
|
-
| `sandbox read <id> --path <path
|
|
37
|
+
| `sandbox read <id> --path <path> [--output <本地路径>] [--tail N] [--grep <pattern>] [--offset N] [--limit N] [--context N] [--max-bytes N] [--parse-json]` | 读取文件;返回 `content` + `size` + `content_length`;`--output <path>` 保存到本地;`--tail/--grep` 用于过滤;非 UTF-8 文件 CLI 自动走 base64 fallback |
|
|
39
38
|
| `sandbox write <id> --path <path> --source <文件名>` | 写入文件(推荐,相对路径) |
|
|
40
39
|
| `sandbox write <id> --path <path> --data "..."` | 写入少量内联内容 |
|
|
41
40
|
| `sandbox write-multiple <id> --entry <src=path> [--entry ...]` | 批量写入多个文件 |
|
|
41
|
+
| `sandbox pull <id> --source <本地路径> --target <沙箱路径>` | 拉取文件/目录(mirror of upload);单文件或递归目录;CLI 端 + 服务端双向 sha1 完整性校验 |
|
|
42
42
|
| `sandbox ls <id> --path <path>` | 列出目录内容(默认 `.`) |
|
|
43
43
|
| `sandbox stat <id> --path <path>` | 获取文件元数据(size / mode / owner / group) |
|
|
44
44
|
| `sandbox mv <id> --entry <source=dest> [--entry ...]` | 移动或重命名文件 |
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
3. **创建** `delta-cli sandbox create --image <image> --cpu 4 --memory 16Gi --gpu 1 --gpu-mem 8000 --max-life 120`(创建后立即可用,无需连接;--max-life 指定 sandbox 最大存活时间(分钟),默认 30;这些是 `create` 全部资源参数,不要发明其它 flag。`--provider autodl` 可指定使用 AutoDL 后端。)
|
|
10
10
|
4. **写入代码/数据** `delta-cli sandbox write <id> --path /workspace/<filename> --source <文件名>` — 将本地文件直接写入 sandbox。**必须**使用相对路径(如 `--source infer.py`),禁止使用 `"$WORKSPACE_ROOT/<filename>"`。也可用 `--data "..."` 写入少量内联内容,`--mode 755` 可设置文件权限。写入后返回的 `size` 字段是 stat 验证后的实际磁盘字节数,可确认写入完整。批量写入用 `write-multiple`。文件路径和扩展名由镜像中的运行时决定。
|
|
11
11
|
5. **运行命令** — 根据镜像中的运行时构造命令,常见示例:`python /workspace/train.py`(Python)、`node /workspace/app.js`(Node.js)、`go run /workspace/main.go`(Go)、`bash /workspace/run.sh`(Shell)
|
|
12
|
-
- **短任务 ≤60s**:`delta-cli sandbox run <id> --command "<命令>" --timeout <秒>` 同步执行,返回 `stdout`/`stderr`/`exit_code`
|
|
13
|
-
- **长任务 >60s**:`delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> --wait` 后台执行(推荐),或 `run-bg` + `logs` 手动轮询
|
|
12
|
+
- **短任务 ≤60s**:`delta-cli sandbox run <id> --command "<命令>" --timeout <秒>` 同步执行,返回 `stdout`/`stderr`/`exit_code` (默认带 --summary,返回 JSON data.summary 已含 stdout 末尾 JSON 提取结果)
|
|
13
|
+
- **长任务 >60s**:`delta-cli sandbox run-bg <id> --command "<命令>" --timeout <秒> --wait` 后台执行(推荐),或 `run-bg` + `logs` 手动轮询 (run-bg --wait 默认带 --summary;不加 --wait 立即返回 {execution_id, sandbox_id})
|
|
14
14
|
6. **读取结果** `delta-cli sandbox read <id> --path /workspace/result.json` — 返回 `content`(内容)、`size`(磁盘字节,来自 stat)、`content_length`(字符数)。读不存在的文件返回 error 而非空内容。
|
|
15
15
|
7. **销毁** `delta-cli sandbox kill <id>`(如需保存结果用 finish,finish 会自动销毁)
|
|
16
16
|
|
|
@@ -27,6 +27,8 @@ delta-cli sandbox run-bg <id> --command "<命令>" --timeout 7200 --wait
|
|
|
27
27
|
```
|
|
28
28
|
CLI 内部每 5 秒轮询一次,`finished=true` 时返回,结果中包含 `execution_id`。只消耗 **1 次 tool call**,适合不关心中间进度的场景。
|
|
29
29
|
|
|
30
|
+
> v1.0.55 起 `--wait` 默认带 `--summary`,返回的 JSON `data.summary` 字段已包含 stdout 末尾结构化 JSON 的提取结果。常用场景无需再调 `sandbox read` 二次解析 result_file。
|
|
31
|
+
|
|
30
32
|
### 方式二:手动轮询(需要看实时输出时)
|
|
31
33
|
|
|
32
34
|
```bash
|
|
@@ -34,7 +36,7 @@ CLI 内部每 5 秒轮询一次,`finished=true` 时返回,结果中包含 `e
|
|
|
34
36
|
delta-cli sandbox run-bg <id> --command "<命令>" --timeout 7200
|
|
35
37
|
# ↑ 返回 execution_id
|
|
36
38
|
|
|
37
|
-
# 2.
|
|
39
|
+
# 2. 手动轮询进度(可用 --tail N / --grep <pattern> 过滤大输出)
|
|
38
40
|
delta-cli sandbox logs <id> --execution-id <exec_id>
|
|
39
41
|
# ↑ 返回 {content, cursor, running, finished, exit_code}
|
|
40
42
|
|
|
@@ -62,7 +64,7 @@ delta-cli sandbox kill <id>
|
|
|
62
64
|
1. **`finished=true` + `exit_code=0`** → 正常完成,可以读取结果并销毁 sandbox
|
|
63
65
|
2. **`finished=true` + `exit_code≠0`** → 命令执行失败,查看 stderr/error 信息
|
|
64
66
|
3. **`running=true`** → 任务仍在运行,继续等待(建议每 15-30 秒查询一次)
|
|
65
|
-
4. **连续 3 次 `running=true` 且 `content`/`cursor` 无变化且距离提交超过 60 秒** → 任务可能挂起或无输出,用 `sandbox status <id>` 检查 sandbox
|
|
67
|
+
4. **连续 3 次 `running=true` 且 `content`/`cursor` 无变化且距离提交超过 60 秒** → 任务可能挂起或无输出,用 `sandbox status <id>` 检查 sandbox 是否存活
|
|
66
68
|
5. **`sandbox status` 返回正常但 logs 仍然无变化** → 用 `sandbox run <id> --command "ps aux | grep <进程名>" --timeout 15` 在容器内检查命令是否还在运行
|
|
67
69
|
|
|
68
70
|
**注意**:
|
|
@@ -22,6 +22,8 @@ required_outputs:
|
|
|
22
22
|
{"status":"ok","key_metric_1":"value_1","key_metric_2":123}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
> **v1.0.55 起**:`sandbox run` / `run-bg --wait` 默认带 `--summary`,CLI 会自动 reverse-scan stdout 末尾的 JSON 并填入响应 `data.summary` 字段。脚本作者只需保证 stdout 最后一行是合法 JSON,skill 端无需再做提取。
|
|
26
|
+
|
|
25
27
|
SKILL 会把它提取为 `result.json` 的 `summary`,并生成 `result_summary` 与最终 `RESULT:` 行。
|
|
26
28
|
|
|
27
29
|
**不要**再输出 `FINAL_ANSWER: ...` 这样的标记行,也不要在 JSON 里使用 `final_answer` 字段。summary 里的语义字段(如 `output`、`result`、`generated_text`、`final_accuracy`)已经足够表达结果。
|
|
@@ -122,6 +124,8 @@ SKILL 会把它提取为 `result.json` 的 `summary`,并生成 `result_summary
|
|
|
122
124
|
|
|
123
125
|
## 本地 `result.json` 的内容约定
|
|
124
126
|
|
|
127
|
+
- **v1.0.55+ 默认路径**:`run` / `run-bg --wait` 返回 JSON 的 `data.summary` 字段已含 CLI 提取结果。写本地 `result.json` 时直接复用 `data.summary` 即可,无需再走 `sandbox read` 解析 `result_file`。
|
|
128
|
+
- **fallback 路径**(用 `--no-summary` 时或 `summary` 为 null):保留 `delta-cli sandbox read <id> --path <result_file>` + Python 解析的旧路。
|
|
125
129
|
- 本地 `result.json` 是一份**精简摘要**,用于 host deliverable 校验,不是完整日志存档。
|
|
126
130
|
- 必须包含 `result_summary` 字段,内容与最终 `RESULT:` 行一致,方便 Runner 直接读取结论。
|
|
127
131
|
- 只写入关键字段(`exit_code`、`finished`、`summary`、`result_summary`、`error`)。**不要**额外添加 `final_answer` 等字段。
|