@guandata/decidex 0.1.0 → 0.1.2
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 +28 -1
- package/package.json +1 -1
- package/src/cli.js +219 -17
package/README.md
CHANGED
|
@@ -94,12 +94,14 @@ decidex session send SESSION_ID --message "继续拆解渠道" --wait --follow
|
|
|
94
94
|
decidex session stop SESSION_ID
|
|
95
95
|
decidex session artifacts list SESSION_ID
|
|
96
96
|
decidex session artifacts download SESSION_ID --all --dir ./artifacts
|
|
97
|
+
decidex session evidence list SESSION_ID
|
|
98
|
+
decidex session evidence download SESSION_ID --all --dir ./evidence
|
|
97
99
|
decidex run diagnose RUN_ID --session-id SESSION_ID --json
|
|
98
100
|
```
|
|
99
101
|
|
|
100
102
|
`session send --wait` 要求消息立即启动;会话正忙时服务端会在入队前返回冲突,避免 CLI 假失败后重试造成重复入队。不带 `--wait` 时结果可能是 `kind=direct` 或 `kind=queued`。
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
`session evidence` 通过服务端会话文件索引发现实际 `.boe` 文件;证据文件位于 `workspace/analysis/biz-ontology-evidence/`,不会混入普通产物列表。下载默认拒绝覆盖已有文件,也拒绝通过符号链接写出目标目录;确认覆盖普通文件时加 `--overwrite`。`run diagnose` 未显式传 `--session-id` 时会使用最近 50 条本地 Run 映射;若本地配置不可写,远端 Run 仍会继续,CLI 会先输出 Session/Run ID,之后可用显式 ID 恢复诊断。当前后端未向用户 API 暴露 Runner 的 Pod termination reason 和资源指标,结果会将这两项标记为 `not_exposed`。
|
|
103
105
|
|
|
104
106
|
## Skill
|
|
105
107
|
|
|
@@ -158,6 +160,31 @@ decidex eval stop AGENT_ID RUN_ID
|
|
|
158
160
|
|
|
159
161
|
CLI 按最新 `origin/main` 校验该文件:只接受 `caseIds`、`targetModelSelection` 和 `judgeModelSelection`。使用 `--cases all` 时由 CLI 获取并覆盖 `caseIds`;Agent 没有评测案例时会在本地停止。
|
|
160
162
|
|
|
163
|
+
查询、接管或批量监控已经启动的评测:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
decidex eval runs list AGENT_ID
|
|
167
|
+
decidex eval runs get AGENT_ID RUN_ID
|
|
168
|
+
decidex eval runs wait AGENT_ID RUN_ID --follow --output result.json
|
|
169
|
+
decidex eval runs watch evaluation-runs.json --parallel 3 --follow --output summary.json
|
|
170
|
+
decidex eval evidence download AGENT_ID RUN_ID --all --dir ./evidence
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`evaluation-runs.json`:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"runs": [
|
|
178
|
+
{ "label": "A/S07", "agentId": "AGENT_ID", "runId": "RUN_ID" },
|
|
179
|
+
{ "label": "B/S07", "agentId": "AGENT_ID", "runId": "RUN_ID" }
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
`watch` 只在状态或计数变化时向 stderr 输出进度,最终 JSON 保留每个 Run 的完整 Case 结果;任一 Run 失败、停止或监控出错时退出码为 1。
|
|
185
|
+
|
|
186
|
+
`eval evidence download` 按 Case 分目录下载评测会话中的 `.boe`。该命令要求服务端评测详情返回 `targetSessionId`;旧版服务端会给出明确升级提示。
|
|
187
|
+
|
|
161
188
|
## 组织
|
|
162
189
|
|
|
163
190
|
```bash
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { parseArgs } from "node:util";
|
|
|
9
9
|
|
|
10
10
|
const COOKIE_NAME = "decidex_session";
|
|
11
11
|
const DEFAULT_CONFIG_PATH = join(homedir(), ".config", "decidex", "config.json");
|
|
12
|
+
const BIZ_ONTOLOGY_EVIDENCE_DIR = "workspace/analysis/biz-ontology-evidence/";
|
|
12
13
|
|
|
13
14
|
const HELP = `decidex - Decidex command line client
|
|
14
15
|
|
|
@@ -40,6 +41,8 @@ Usage:
|
|
|
40
41
|
decidex session stop SESSION_ID
|
|
41
42
|
decidex session artifacts list SESSION_ID
|
|
42
43
|
decidex session artifacts download SESSION_ID --all --dir DIR [--overwrite]
|
|
44
|
+
decidex session evidence list SESSION_ID
|
|
45
|
+
decidex session evidence download SESSION_ID --all --dir DIR [--overwrite]
|
|
43
46
|
decidex run diagnose RUN_ID [--session-id ID] [--agent-id ID] --json
|
|
44
47
|
|
|
45
48
|
decidex skill list
|
|
@@ -52,7 +55,12 @@ Usage:
|
|
|
52
55
|
decidex eval cases export AGENT_ID FILE
|
|
53
56
|
decidex eval cases plan AGENT_ID FILE [--prune]
|
|
54
57
|
decidex eval cases apply AGENT_ID FILE [--prune]
|
|
55
|
-
decidex eval run AGENT_ID FILE [--cases all] [--wait] [--output FILE] [--timeout SECONDS]
|
|
58
|
+
decidex eval run AGENT_ID FILE [--cases all] [--wait] [--follow] [--output FILE] [--timeout SECONDS]
|
|
59
|
+
decidex eval runs list AGENT_ID [--cursor CURSOR]
|
|
60
|
+
decidex eval runs get AGENT_ID RUN_ID
|
|
61
|
+
decidex eval runs wait AGENT_ID RUN_ID [--follow] [--output FILE] [--timeout SECONDS]
|
|
62
|
+
decidex eval runs watch FILE [--parallel N] [--follow] [--output FILE] [--timeout SECONDS]
|
|
63
|
+
decidex eval evidence download AGENT_ID RUN_ID --all --dir DIR [--overwrite]
|
|
56
64
|
decidex eval stop AGENT_ID RUN_ID
|
|
57
65
|
|
|
58
66
|
decidex ontology list
|
|
@@ -92,12 +100,16 @@ to stderr, so stdout or --output remains machine-readable.`,
|
|
|
92
100
|
decidex session send SESSION_ID (--message TEXT | --input FILE) [--wait] [--follow]
|
|
93
101
|
decidex session stop SESSION_ID
|
|
94
102
|
decidex session artifacts ...
|
|
103
|
+
decidex session evidence ...
|
|
95
104
|
|
|
96
105
|
With --wait, the message must start immediately; a busy session returns a conflict instead
|
|
97
106
|
of queuing an untrackable run. Without --wait, the result can be kind=direct or kind=queued.`,
|
|
98
107
|
"session artifacts": `Usage:
|
|
99
108
|
decidex session artifacts list SESSION_ID
|
|
100
109
|
decidex session artifacts download SESSION_ID --all --dir DIR [--overwrite]`,
|
|
110
|
+
"session evidence": `Usage:
|
|
111
|
+
decidex session evidence list SESSION_ID
|
|
112
|
+
decidex session evidence download SESSION_ID --all --dir DIR [--overwrite]`,
|
|
101
113
|
"run diagnose": `Usage:
|
|
102
114
|
decidex run diagnose RUN_ID [--session-id ID] [--agent-id ID] --json
|
|
103
115
|
|
|
@@ -111,13 +123,22 @@ Runtime Pod termination details require backend support.`,
|
|
|
111
123
|
decidex skill delete ID`,
|
|
112
124
|
eval: `Usage:
|
|
113
125
|
decidex eval cases list|export|plan|apply ...
|
|
114
|
-
decidex eval run AGENT_ID FILE [--cases all] [--wait] [--output FILE]
|
|
126
|
+
decidex eval run AGENT_ID FILE [--cases all] [--wait] [--follow] [--output FILE]
|
|
127
|
+
decidex eval runs list|get|wait|watch ...
|
|
128
|
+
decidex eval evidence download AGENT_ID RUN_ID --all --dir DIR [--overwrite]
|
|
115
129
|
decidex eval stop AGENT_ID RUN_ID`,
|
|
116
130
|
"eval cases": `Usage:
|
|
117
131
|
decidex eval cases list AGENT_ID
|
|
118
132
|
decidex eval cases export AGENT_ID FILE
|
|
119
133
|
decidex eval cases plan AGENT_ID FILE [--prune]
|
|
120
134
|
decidex eval cases apply AGENT_ID FILE [--prune]`,
|
|
135
|
+
"eval runs": `Usage:
|
|
136
|
+
decidex eval runs list AGENT_ID [--cursor CURSOR]
|
|
137
|
+
decidex eval runs get AGENT_ID RUN_ID
|
|
138
|
+
decidex eval runs wait AGENT_ID RUN_ID [--follow] [--output FILE] [--timeout SECONDS]
|
|
139
|
+
decidex eval runs watch FILE [--parallel N] [--follow] [--output FILE] [--timeout SECONDS]`,
|
|
140
|
+
"eval evidence": `Usage:
|
|
141
|
+
decidex eval evidence download AGENT_ID RUN_ID --all --dir DIR [--overwrite]`,
|
|
121
142
|
ontology: `Usage:
|
|
122
143
|
decidex ontology list|get|export|plan|apply ...`,
|
|
123
144
|
api: `Usage:
|
|
@@ -435,13 +456,25 @@ async function listSessionArtifacts(agentId, sessionId, values) {
|
|
|
435
456
|
return (result.files ?? []).filter((file) => file.relativePath?.startsWith("artifacts/"));
|
|
436
457
|
}
|
|
437
458
|
|
|
438
|
-
function
|
|
439
|
-
const
|
|
459
|
+
async function listSessionEvidence(agentId, sessionId, values) {
|
|
460
|
+
const result = await request(`${sessionPath(agentId, sessionId)}/files?force=1&evidence=1`, { values });
|
|
461
|
+
return (result.files ?? []).filter((file) => {
|
|
462
|
+
const name = file.relativePath?.slice(BIZ_ONTOLOGY_EVIDENCE_DIR.length);
|
|
463
|
+
return file.relativePath?.startsWith(BIZ_ONTOLOGY_EVIDENCE_DIR) && name && !name.includes("/") && name.toLowerCase().endsWith(".boe");
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function safeRelativeDestination(root, outputPath) {
|
|
468
|
+
const destination = resolve(root, outputPath);
|
|
440
469
|
const child = relative(root, destination);
|
|
441
|
-
if (!child || child.startsWith("..") || isAbsolute(child)) throw new Error(
|
|
470
|
+
if (!child || child.startsWith("..") || isAbsolute(child)) throw new Error(`非法输出路径:${outputPath}`);
|
|
442
471
|
return destination;
|
|
443
472
|
}
|
|
444
473
|
|
|
474
|
+
function safeDestination(root, artifactPath) {
|
|
475
|
+
return safeRelativeDestination(root, artifactPath.replace(/^artifacts\//, ""));
|
|
476
|
+
}
|
|
477
|
+
|
|
445
478
|
async function assertSafeArtifactTarget(root, destination, overwrite) {
|
|
446
479
|
let current = root;
|
|
447
480
|
for (const part of relative(root, dirname(destination)).split(sep).filter((item) => item && item !== ".")) {
|
|
@@ -808,6 +841,35 @@ async function sessionCommand(action, args) {
|
|
|
808
841
|
if (values.query) query.set("q", values.query);
|
|
809
842
|
return print(await request(`/api/agent-sessions?${query}`, { values }));
|
|
810
843
|
}
|
|
844
|
+
if (action === "evidence") {
|
|
845
|
+
const [evidenceAction, sessionIdValue] = positionals;
|
|
846
|
+
expectPositionals(positionals, 2, `session evidence ${evidenceAction || "COMMAND"} SESSION_ID`);
|
|
847
|
+
const sessionId = required(sessionIdValue, "SESSION_ID");
|
|
848
|
+
const session = await resolveSession(sessionId, values);
|
|
849
|
+
const evidence = await listSessionEvidence(session.agentId, sessionId, values);
|
|
850
|
+
if (evidenceAction === "list") {
|
|
851
|
+
return print({ schemaVersion: 1, sessionId, agentId: session.agentId, evidence });
|
|
852
|
+
}
|
|
853
|
+
if (evidenceAction === "download") {
|
|
854
|
+
if (!values.all) throw new Error("evidence download 需要 --all");
|
|
855
|
+
const directory = resolve(required(values.dir, "--dir DIR"));
|
|
856
|
+
await mkdir(directory, { recursive: true });
|
|
857
|
+
const root = await realpath(directory);
|
|
858
|
+
const targets = evidence.map((item) => ({ item, destination: safeRelativeDestination(root, item.name) }));
|
|
859
|
+
for (const { destination } of targets) await assertSafeArtifactTarget(root, destination, values.overwrite);
|
|
860
|
+
const downloaded = [];
|
|
861
|
+
for (const { item, destination } of targets) {
|
|
862
|
+
const bytes = await request(`${sessionPath(session.agentId, sessionId)}/files/content?path=${encodeURIComponent(item.relativePath)}&download=1`, {
|
|
863
|
+
returnBytes: true,
|
|
864
|
+
values,
|
|
865
|
+
});
|
|
866
|
+
await writeArtifact(root, destination, bytes, values.overwrite);
|
|
867
|
+
downloaded.push({ ...item, path: destination });
|
|
868
|
+
}
|
|
869
|
+
return print({ schemaVersion: 1, sessionId, directory, downloaded });
|
|
870
|
+
}
|
|
871
|
+
throw new Error(`未知 session evidence 命令:${evidenceAction || "(空)"}`);
|
|
872
|
+
}
|
|
811
873
|
if (action !== "artifacts") {
|
|
812
874
|
expectPositionals(positionals, 1, `session ${action || "COMMAND"} SESSION_ID`);
|
|
813
875
|
const sessionId = required(positionals[0], "SESSION_ID");
|
|
@@ -1035,10 +1097,161 @@ function evaluationRunSpec(value) {
|
|
|
1035
1097
|
return value;
|
|
1036
1098
|
}
|
|
1037
1099
|
|
|
1100
|
+
function evaluationRunPath(agentId, runId) {
|
|
1101
|
+
return `/api/personal-agents/${encodeURIComponent(agentId)}/evaluation-runs/${encodeURIComponent(runId)}`;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
function evaluationProgress(run, label) {
|
|
1105
|
+
const counts = run.counts ?? {};
|
|
1106
|
+
return `[${label}] ${run.status} evaluated=${counts.evaluated ?? 0}/${counts.total ?? run.caseCount ?? "?"} passed=${counts.passed ?? 0} notPassed=${counts.notPassed ?? 0} failed=${counts.evaluationFailed ?? 0}`;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
async function waitEvaluationRun(agentId, runId, values, label = runId) {
|
|
1110
|
+
let lastProgress;
|
|
1111
|
+
try {
|
|
1112
|
+
return await poll(
|
|
1113
|
+
(deadline) => request(evaluationRunPath(agentId, runId), { deadline, values }),
|
|
1114
|
+
(result) => ["COMPLETED", "STOPPED", "FAILED"].includes(result.run.status),
|
|
1115
|
+
positiveSeconds(values.timeout),
|
|
1116
|
+
values.follow
|
|
1117
|
+
? (result) => {
|
|
1118
|
+
const progress = evaluationProgress(result.run, label);
|
|
1119
|
+
if (progress !== lastProgress) process.stderr.write(`[decidex] ${progress}\n`);
|
|
1120
|
+
lastProgress = progress;
|
|
1121
|
+
}
|
|
1122
|
+
: undefined,
|
|
1123
|
+
);
|
|
1124
|
+
} catch (error) {
|
|
1125
|
+
error.message = `${error.message}; agentId=${agentId}; runId=${runId}; 可运行 decidex eval stop ${agentId} ${runId}`;
|
|
1126
|
+
throw error;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
function evaluationRunTargets(value) {
|
|
1131
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some((key) => key !== "runs") || !Array.isArray(value.runs) || value.runs.length === 0) {
|
|
1132
|
+
throw new Error("watch 文件必须是包含非空 runs 数组的 JSON 对象");
|
|
1133
|
+
}
|
|
1134
|
+
const seen = new Set();
|
|
1135
|
+
return value.runs.map((item, index) => {
|
|
1136
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) throw new Error(`runs[${index}] 必须是对象`);
|
|
1137
|
+
if (Object.keys(item).some((key) => !new Set(["label", "agentId", "runId"]).has(key))) throw new Error(`runs[${index}] 包含不支持的字段`);
|
|
1138
|
+
for (const field of ["agentId", "runId"]) if (typeof item[field] !== "string" || !item[field].trim()) throw new Error(`runs[${index}].${field} 不能为空`);
|
|
1139
|
+
if (item.label !== undefined && (typeof item.label !== "string" || !item.label.trim())) throw new Error(`runs[${index}].label 不能为空`);
|
|
1140
|
+
const key = `${item.agentId}\0${item.runId}`;
|
|
1141
|
+
if (seen.has(key)) throw new Error(`watch 文件包含重复 Run:${item.agentId}/${item.runId}`);
|
|
1142
|
+
seen.add(key);
|
|
1143
|
+
return { label: item.label ?? item.runId, agentId: item.agentId, runId: item.runId };
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function positiveInteger(value, name) {
|
|
1148
|
+
const number = Number(value);
|
|
1149
|
+
if (!Number.isInteger(number) || number <= 0) throw new Error(`${name} 必须是正整数`);
|
|
1150
|
+
return number;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
async function evalRunsCommand(args) {
|
|
1154
|
+
const { values, positionals } = commandArgs(args, {
|
|
1155
|
+
cursor: { type: "string" },
|
|
1156
|
+
follow: { type: "boolean", default: false },
|
|
1157
|
+
output: { type: "string" },
|
|
1158
|
+
parallel: { type: "string", default: "3" },
|
|
1159
|
+
timeout: { type: "string", default: "1800" },
|
|
1160
|
+
});
|
|
1161
|
+
const [action, agentId, runId] = positionals;
|
|
1162
|
+
if (action === "list") {
|
|
1163
|
+
expectPositionals(positionals, 2, "eval runs list AGENT_ID");
|
|
1164
|
+
const query = values.cursor ? `?cursor=${encodeURIComponent(values.cursor)}` : "";
|
|
1165
|
+
return print(await request(`/api/personal-agents/${encodeURIComponent(agentId)}/evaluation-runs${query}`, { values }));
|
|
1166
|
+
}
|
|
1167
|
+
if (action === "get") {
|
|
1168
|
+
expectPositionals(positionals, 3, "eval runs get AGENT_ID RUN_ID");
|
|
1169
|
+
return print(await request(evaluationRunPath(agentId, runId), { values }));
|
|
1170
|
+
}
|
|
1171
|
+
if (action === "wait") {
|
|
1172
|
+
expectPositionals(positionals, 3, "eval runs wait AGENT_ID RUN_ID");
|
|
1173
|
+
const result = await waitEvaluationRun(agentId, runId, values);
|
|
1174
|
+
await emit({ schemaVersion: 1, agentId, runId, run: result.run }, values.output);
|
|
1175
|
+
if (result.run.status !== "COMPLETED") process.exitCode = 1;
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (action === "watch") {
|
|
1179
|
+
expectPositionals(positionals, 2, "eval runs watch FILE");
|
|
1180
|
+
const targets = evaluationRunTargets(await readJsonFile(required(agentId, "FILE")));
|
|
1181
|
+
const parallel = Math.min(positiveInteger(values.parallel, "parallel"), targets.length);
|
|
1182
|
+
const results = new Array(targets.length);
|
|
1183
|
+
let nextIndex = 0;
|
|
1184
|
+
async function worker() {
|
|
1185
|
+
while (nextIndex < targets.length) {
|
|
1186
|
+
const index = nextIndex++;
|
|
1187
|
+
const target = targets[index];
|
|
1188
|
+
try {
|
|
1189
|
+
const result = await waitEvaluationRun(target.agentId, target.runId, values, target.label);
|
|
1190
|
+
results[index] = { ...target, run: result.run, monitorError: null };
|
|
1191
|
+
} catch (error) {
|
|
1192
|
+
results[index] = { ...target, run: null, monitorError: error.message };
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
await Promise.all(Array.from({ length: parallel }, worker));
|
|
1197
|
+
const summary = {
|
|
1198
|
+
total: results.length,
|
|
1199
|
+
completed: results.filter((item) => item.run?.status === "COMPLETED").length,
|
|
1200
|
+
stopped: results.filter((item) => item.run?.status === "STOPPED").length,
|
|
1201
|
+
failed: results.filter((item) => item.run?.status === "FAILED").length,
|
|
1202
|
+
errors: results.filter((item) => item.monitorError).length,
|
|
1203
|
+
};
|
|
1204
|
+
await emit({ schemaVersion: 1, summary, runs: results }, values.output);
|
|
1205
|
+
if (summary.completed !== summary.total) process.exitCode = 1;
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
throw new Error(`未知 eval runs 命令:${action || "(空)"}`);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
async function evalEvidenceCommand(args) {
|
|
1212
|
+
const { values, positionals } = commandArgs(args, {
|
|
1213
|
+
all: { type: "boolean", default: false },
|
|
1214
|
+
dir: { type: "string" },
|
|
1215
|
+
overwrite: { type: "boolean", default: false },
|
|
1216
|
+
});
|
|
1217
|
+
const [action, agentId, runId] = positionals;
|
|
1218
|
+
if (action !== "download") throw new Error(`未知 eval evidence 命令:${action || "(空)"}`);
|
|
1219
|
+
expectPositionals(positionals, 3, "eval evidence download AGENT_ID RUN_ID");
|
|
1220
|
+
if (!values.all) throw new Error("eval evidence download 需要 --all");
|
|
1221
|
+
const result = await request(evaluationRunPath(agentId, runId), { values });
|
|
1222
|
+
const runCases = result.run?.cases ?? [];
|
|
1223
|
+
if (runCases.some((runCase) => !Object.hasOwn(runCase, "targetSessionId"))) {
|
|
1224
|
+
throw new Error("Decidex 服务端未返回评测 Case 的 targetSessionId;请先升级服务端");
|
|
1225
|
+
}
|
|
1226
|
+
const evidence = (await Promise.all(runCases.map(async (runCase, index) => {
|
|
1227
|
+
if (!runCase.targetSessionId) return [];
|
|
1228
|
+
const files = await listSessionEvidence(agentId, runCase.targetSessionId, values);
|
|
1229
|
+
return files.map((file) => ({ ...file, caseId: runCase.id, casePosition: runCase.position, sessionId: runCase.targetSessionId, outputDirectory: `case-${index + 1}` }));
|
|
1230
|
+
}))).flat();
|
|
1231
|
+
const directory = resolve(required(values.dir, "--dir DIR"));
|
|
1232
|
+
await mkdir(directory, { recursive: true });
|
|
1233
|
+
const root = await realpath(directory);
|
|
1234
|
+
const targets = evidence.map((item) => ({ item, destination: safeRelativeDestination(root, join(item.outputDirectory, item.name)) }));
|
|
1235
|
+
for (const { destination } of targets) await assertSafeArtifactTarget(root, destination, values.overwrite);
|
|
1236
|
+
const downloaded = [];
|
|
1237
|
+
for (const { item, destination } of targets) {
|
|
1238
|
+
const bytes = await request(`${sessionPath(agentId, item.sessionId)}/files/content?path=${encodeURIComponent(item.relativePath)}&download=1`, {
|
|
1239
|
+
returnBytes: true,
|
|
1240
|
+
values,
|
|
1241
|
+
});
|
|
1242
|
+
await writeArtifact(root, destination, bytes, values.overwrite);
|
|
1243
|
+
downloaded.push({ caseId: item.caseId, casePosition: item.casePosition, sessionId: item.sessionId, name: item.name, relativePath: item.relativePath, path: destination });
|
|
1244
|
+
}
|
|
1245
|
+
return print({ schemaVersion: 1, agentId, runId, directory, downloaded });
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1038
1248
|
async function evalCommand(action, args) {
|
|
1039
1249
|
if (action === "cases") return evalCasesCommand(args);
|
|
1250
|
+
if (action === "runs") return evalRunsCommand(args);
|
|
1251
|
+
if (action === "evidence") return evalEvidenceCommand(args);
|
|
1040
1252
|
const { values, positionals } = commandArgs(args, {
|
|
1041
1253
|
cases: { type: "string" },
|
|
1254
|
+
follow: { type: "boolean", default: false },
|
|
1042
1255
|
output: { type: "string" },
|
|
1043
1256
|
timeout: { type: "string", default: "1800" },
|
|
1044
1257
|
wait: { type: "boolean", default: false },
|
|
@@ -1058,19 +1271,8 @@ async function evalCommand(action, args) {
|
|
|
1058
1271
|
}
|
|
1059
1272
|
const started = await request(`/api/personal-agents/${agentId}/evaluation-runs`, { method: "POST", body: evaluationRunSpec(body), values });
|
|
1060
1273
|
if (!values.wait) return emit(started, values.output);
|
|
1061
|
-
const runId = encodeURIComponent(started.run.id);
|
|
1062
1274
|
process.stderr.write(`[decidex] evaluation run=${started.run.id}\n`);
|
|
1063
|
-
|
|
1064
|
-
try {
|
|
1065
|
-
finished = await poll(
|
|
1066
|
-
(deadline) => request(`/api/personal-agents/${agentId}/evaluation-runs/${runId}`, { deadline, values }),
|
|
1067
|
-
(result) => ["COMPLETED", "STOPPED", "FAILED"].includes(result.run.status),
|
|
1068
|
-
positiveSeconds(values.timeout),
|
|
1069
|
-
);
|
|
1070
|
-
} catch (error) {
|
|
1071
|
-
error.message = `${error.message}; runId=${started.run.id}; 可运行 decidex eval stop ${positionals[0]} ${started.run.id}`;
|
|
1072
|
-
throw error;
|
|
1073
|
-
}
|
|
1275
|
+
const finished = await waitEvaluationRun(positionals[0], started.run.id, values);
|
|
1074
1276
|
await emit(finished, values.output);
|
|
1075
1277
|
if (finished.run.status !== "COMPLETED") process.exitCode = 1;
|
|
1076
1278
|
}
|