@delta-infra/cli 1.0.56 → 1.0.58
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,7 +174,7 @@ delta-cli sandbox run <sandbox_id> \
|
|
|
174
174
|
--command "<命令>" \
|
|
175
175
|
--timeout 3600
|
|
176
176
|
|
|
177
|
-
# v1.0.55+ 默认带 --summary,返回 JSON 中 data.
|
|
177
|
+
# v1.0.55+ 默认带 --summary,返回 JSON 中 data.result_summary 字段已含 stdout 末尾 JSON 提取结果
|
|
178
178
|
# 无需再手动读取 result_file 做二次解析(除非使用了 --no-summary)
|
|
179
179
|
delta-cli sandbox run <sandbox_id> --command "echo '{\"status\":\"ok\",\"result\":\"done\"}'" --timeout 60
|
|
180
180
|
|
|
@@ -225,7 +225,7 @@ delta-cli sandbox kill <sandbox_id>
|
|
|
225
225
|
| `delta-cli sandbox logs <id> --execution-id <eid> [--tail N --grep <pattern> --context N --max-bytes N]` | 查看后台日志;默认返回 `stderr_size + stderr_tail`(避免上下文爆炸);可用 `--tail/--grep` 过滤 |
|
|
226
226
|
| `delta-cli sandbox cancel <id> --execution-id <eid>` | 中断后台命令 |
|
|
227
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
|
|
228
|
+
| `delta-cli sandbox pull <id> --source <沙箱路径> --target <本地路径> [--recursive] [--pattern <glob>]` | 从沙箱拉取文件/目录到本地(mirror of `upload`,flag 方向相反:source=远程,target=本地);单文件或递归目录;CLI 端 + 服务端双向 sha1 完整性校验 |
|
|
229
229
|
| `delta-cli sandbox write <id> --path <path> --source <本地路径>` | 写入文件 |
|
|
230
230
|
| `delta-cli sandbox write-multiple <id> --entry <远程路径>=<本地路径>` | 批量写入 |
|
|
231
231
|
| `delta-cli sandbox ls <id> --path <path>` | 列出目录 |
|
package/checksums.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
e9cc11880aa4583b0d10a4cd8277ba1f0966c3898f1b1d839dae54f798bdb7cf delta-cli-darwin-amd64.tar.gz
|
|
2
|
+
8d597178dc8ee9888c059f68841c3f987738ee3b452b72a7d369583efda4df50 delta-cli-darwin-arm64.tar.gz
|
|
3
|
+
065078cb310ee321bc2c07968a420ddb73e57253f1a9c38768ad097e45a115ca delta-cli-linux-amd64.tar.gz
|
|
4
|
+
cfbb8d11ac1eae0203c66832bf6af7cb8c9820bb3874cf33219a18e9669a6f6a delta-cli-linux-arm64.tar.gz
|
|
5
|
+
885302f590a808d5c58459c215f316e77b63a09f84aab53a0e253bf9abd3ac31 delta-cli-windows-amd64.zip
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: delta-sandbox
|
|
3
|
-
version: 1.3.
|
|
4
|
-
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON,CLI 反向扫描 stdout 末尾 JSON
|
|
3
|
+
version: 1.3.1
|
|
4
|
+
description: "在 Delta Sandbox Linux 容器中运行任意命令或脚本。适用于训练、推理、编译、数据处理等任意需要 sandbox 的计算任务,支持 Python / Node.js / Go / Java / Rust 等语言。所有任务通用同一套输出约定:命令在 stdout 末尾输出结构化 JSON,CLI 反向扫描 stdout 末尾 JSON 自动提取为 `data.result_summary` 字段。Planner 调用本 skill 时,请在 plan step 的 required_outputs 中声明 [{kind: 'file', extensions: ['.json']}]。请求中用中性动词(运行/执行)描述命令,只有真的会落盘文件时,才使用创建/写入/保存等动词并带上扩展名。认证/配置/权限错误转 delta-shared。"
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["delta-cli"]
|
|
@@ -146,7 +146,7 @@ required_outputs:
|
|
|
146
146
|
| 中断后台命令 | `sandbox cancel <id> --execution-id <exec_id>` |
|
|
147
147
|
| **文件操作** | |
|
|
148
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
|
|
149
|
+
| 拉取文件/目录 | `sandbox pull <id> --source <沙箱路径> --target <本地路径> [--recursive] [--pattern <glob>]` — 单文件或目录递归,含 sha1 校验(mirror of upload,flag 方向与 upload 相反:source=远程,target=本地) |
|
|
150
150
|
| 写入文件 | `sandbox write <id> --path <path> --source <文件名>`(推荐)|
|
|
151
151
|
| 批量写入 | `sandbox write-multiple <id> --entry <远程路径>=<本地路径> [--entry ...]` |
|
|
152
152
|
| 上传目录 | `sandbox upload <id> --source <本地目录> --target <沙箱路径>` |
|
|
@@ -190,9 +190,9 @@ required_outputs:
|
|
|
190
190
|
- `delta-cli sandbox logs <id> --execution-id <execution_id>` — 返回 `cursor`、`running`、`finished`、`exit_code`、`result_file`(完成后)。当 `finished=true` 时认为完成,完整输出需读取 `result_file`。
|
|
191
191
|
禁止对长任务使用同步 `sandbox run`
|
|
192
192
|
|
|
193
|
-
**推荐实践**:让 sandbox 脚本在 `stdout` 末尾打印一个独立的结构化 JSON 对象(例如 `{"status":"ok", ...}`),CLI 的 `--summary` 默认会自动反向扫描 stdout 末尾 JSON 提取为 `data.
|
|
193
|
+
**推荐实践**:让 sandbox 脚本在 `stdout` 末尾打印一个独立的结构化 JSON 对象(例如 `{"status":"ok", ...}`),CLI 的 `--summary` 默认会自动反向扫描 stdout 末尾 JSON 提取为 `data.result_summary` 字段。这样即使 `stdout` 前面是大量训练/下载日志,skill 也无需让大模型去“读整段日志再摘要”。
|
|
194
194
|
5. **生成 result.json**(默认路径使用 CLI 返回的 `summary` 字段;fallback 路径用 `sandbox read` + Python 解析):
|
|
195
|
-
- **5a(默认路径,推荐)**:`run` / `run-bg --wait` 已返回 `
|
|
195
|
+
- **5a(默认路径,推荐)**:`run` / `run-bg --wait` 已返回 `result_summary` 字段(CLI 自动 reverse-scan stdout 末尾 JSON)。直接构造 `result.json`:
|
|
196
196
|
```bash
|
|
197
197
|
delta-cli sandbox run <id> --command "..." --timeout 60 > /tmp/_run.json
|
|
198
198
|
```
|
|
@@ -200,11 +200,13 @@ required_outputs:
|
|
|
200
200
|
import json, os
|
|
201
201
|
r = json.load(open("/tmp/_run.json"))
|
|
202
202
|
data = r.get("data", {})
|
|
203
|
+
# CLI 字段名是 result_summary(不是 summary),是一个对象
|
|
204
|
+
cli_summary = data.get("result_summary") or {}
|
|
203
205
|
result = {
|
|
204
206
|
"exit_code": data.get("exit_code"),
|
|
205
207
|
"finished": data.get("finished", True),
|
|
206
|
-
"summary":
|
|
207
|
-
"result_summary": ", ".join(f"{k}={v}" for k,v in
|
|
208
|
+
"summary": cli_summary,
|
|
209
|
+
"result_summary": ", ".join(f"{k}={v}" for k,v in cli_summary.items()
|
|
208
210
|
if isinstance(v, (str,int,float,bool)) and len(str(v))<200),
|
|
209
211
|
"error": data.get("error"),
|
|
210
212
|
}
|
|
@@ -215,7 +217,7 @@ required_outputs:
|
|
|
215
217
|
indent=2, ensure_ascii=False)
|
|
216
218
|
print(result["result_summary"])
|
|
217
219
|
```
|
|
218
|
-
- **5b(fallback,仅当 `--no-summary` 或 `
|
|
220
|
+
- **5b(fallback,仅当 `--no-summary` 或 `result_summary` 为 null)**:从 `sandbox run` / `sandbox run-bg --wait` / `sandbox logs` 返回数据中获得 `result_file` 路径,用 `sandbox read` + Python 解析。
|
|
219
221
|
- `sandbox read` 返回的是 CLI 信封 `{"ok":true,"data":{"content":"..."}}`,真实结果 JSON 在 `data.content` 字段里。
|
|
220
222
|
- **不要把 CLI 信封或完整长 `stdout` 原样写入本地 `result.json`**;应该解析后生成一份精简的结构化摘要。
|
|
221
223
|
- **推荐做法(避免 heredoc 引号失败)**:先用 `bash` 把信封写入临时文件,再用 `python3`(或 `python_repl`)读取该文件并生成 `result.json`。**不要**把 `delta-cli sandbox read` 的输出通过管道直接喂给内联 heredoc,管道+heredoc 的组合极易因 Shell 转义/引号问题失败。
|
|
@@ -307,8 +309,8 @@ required_outputs:
|
|
|
307
309
|
|
|
308
310
|
## 输出阅读与最终回答格式
|
|
309
311
|
|
|
310
|
-
1. **`sandbox run` / `run-bg --wait` 默认带 `--summary`,返回的 JSON 中 `data.
|
|
311
|
-
2. **默认优先用 `data.
|
|
312
|
+
1. **`sandbox run` / `run-bg --wait` 默认带 `--summary`,返回的 JSON 中 `data.result_summary` 字段已包含 stdout 末尾 JSON 提取结果(注意:这里是 `result_summary`,不是 `summary`)。也包含 `data.result_file`**(沙箱内结构化结果文件的路径),作为 fallback 路径。
|
|
313
|
+
2. **默认优先用 `data.result_summary`**;仅当 `result_summary` 字段为 null(使用了 `--no-summary` 或 stdout 无 JSON)时,再用 `sandbox read <id> --path <result_file>` 读取 result_file 并解析 CLI 信封。
|
|
312
314
|
- 结果文件包含完整 `stdout`、`stderr`、`exit_code`、`finished`、`command`、`error`。
|
|
313
315
|
3. **生成本地精简 `result.json`**(见“完整生命周期”步骤 5 和“通用结构化输出约定”)。本地副本只应包含关键字段和摘要,**不应包含完整长 `stdout`**。
|
|
314
316
|
4. **最终回答必须且只能是 `RESULT:` 开头的一行。**
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
| `sandbox write <id> --path <path> --source <文件名>` | 写入文件(推荐,相对路径) |
|
|
39
39
|
| `sandbox write <id> --path <path> --data "..."` | 写入少量内联内容 |
|
|
40
40
|
| `sandbox write-multiple <id> --entry <src=path> [--entry ...]` | 批量写入多个文件 |
|
|
41
|
-
| `sandbox pull <id> --source
|
|
41
|
+
| `sandbox pull <id> --source <沙箱路径> --target <本地路径> [--recursive] [--pattern <glob>]` | 拉取文件/目录到本地(mirror of `upload`,flag 方向相反:`--source`=远程沙箱路径,`--target`=本地路径);单文件自动识别;目录默认递归;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,7 +9,7 @@
|
|
|
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` (默认带 --summary,返回 JSON data.
|
|
12
|
+
- **短任务 ≤60s**:`delta-cli sandbox run <id> --command "<命令>" --timeout <秒>` 同步执行,返回 `stdout`/`stderr`/`exit_code` (默认带 --summary,返回 JSON data.result_summary 已含 stdout 末尾 JSON 提取结果)
|
|
13
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 会自动销毁)
|
|
@@ -27,7 +27,7 @@ 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
|
-
>
|
|
30
|
+
> `--wait` 默认带 `--summary`,返回的 JSON `data.result_summary` 字段已包含 stdout 末尾结构化 JSON 的提取结果。常用场景无需再调 `sandbox read` 二次解析 result_file。
|
|
31
31
|
|
|
32
32
|
### 方式二:手动轮询(需要看实时输出时)
|
|
33
33
|
|
|
@@ -22,7 +22,7 @@ required_outputs:
|
|
|
22
22
|
{"status":"ok","key_metric_1":"value_1","key_metric_2":123}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
>
|
|
25
|
+
> `sandbox run` / `run-bg --wait` 默认带 `--summary`,CLI 会自动 reverse-scan stdout 末尾的 JSON 并填入响应 `data.result_summary` 字段。脚本作者只需保证 stdout 最后一行是合法 JSON,skill 端无需再做提取。
|
|
26
26
|
|
|
27
27
|
SKILL 会把它提取为 `result.json` 的 `summary`,并生成 `result_summary` 与最终 `RESULT:` 行。
|
|
28
28
|
|
|
@@ -124,7 +124,7 @@ SKILL 会把它提取为 `result.json` 的 `summary`,并生成 `result_summary
|
|
|
124
124
|
|
|
125
125
|
## 本地 `result.json` 的内容约定
|
|
126
126
|
|
|
127
|
-
-
|
|
127
|
+
- **默认路径**:`run` / `run-bg --wait` 返回 JSON 的 `data.result_summary` 字段已含 CLI 提取结果。写本地 `result.json` 时直接复用 `data.result_summary` 即可,无需再走 `sandbox read` 解析 `result_file`。
|
|
128
128
|
- **fallback 路径**(用 `--no-summary` 时或 `summary` 为 null):保留 `delta-cli sandbox read <id> --path <result_file>` + Python 解析的旧路。
|
|
129
129
|
- 本地 `result.json` 是一份**精简摘要**,用于 host deliverable 校验,不是完整日志存档。
|
|
130
130
|
- 必须包含 `result_summary` 字段,内容与最终 `RESULT:` 行一致,方便 Runner 直接读取结论。
|