@guandata/decidex 0.1.1 → 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 +6 -1
- package/package.json +1 -1
- package/src/cli.js +93 -3
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
|
|
|
@@ -165,6 +167,7 @@ decidex eval runs list AGENT_ID
|
|
|
165
167
|
decidex eval runs get AGENT_ID RUN_ID
|
|
166
168
|
decidex eval runs wait AGENT_ID RUN_ID --follow --output result.json
|
|
167
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
|
|
168
171
|
```
|
|
169
172
|
|
|
170
173
|
`evaluation-runs.json`:
|
|
@@ -180,6 +183,8 @@ decidex eval runs watch evaluation-runs.json --parallel 3 --follow --output summ
|
|
|
180
183
|
|
|
181
184
|
`watch` 只在状态或计数变化时向 stderr 输出进度,最终 JSON 保留每个 Run 的完整 Case 结果;任一 Run 失败、停止或监控出错时退出码为 1。
|
|
182
185
|
|
|
186
|
+
`eval evidence download` 按 Case 分目录下载评测会话中的 `.boe`。该命令要求服务端评测详情返回 `targetSessionId`;旧版服务端会给出明确升级提示。
|
|
187
|
+
|
|
183
188
|
## 组织
|
|
184
189
|
|
|
185
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
|
|
@@ -57,6 +60,7 @@ Usage:
|
|
|
57
60
|
decidex eval runs get AGENT_ID RUN_ID
|
|
58
61
|
decidex eval runs wait AGENT_ID RUN_ID [--follow] [--output FILE] [--timeout SECONDS]
|
|
59
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]
|
|
60
64
|
decidex eval stop AGENT_ID RUN_ID
|
|
61
65
|
|
|
62
66
|
decidex ontology list
|
|
@@ -96,12 +100,16 @@ to stderr, so stdout or --output remains machine-readable.`,
|
|
|
96
100
|
decidex session send SESSION_ID (--message TEXT | --input FILE) [--wait] [--follow]
|
|
97
101
|
decidex session stop SESSION_ID
|
|
98
102
|
decidex session artifacts ...
|
|
103
|
+
decidex session evidence ...
|
|
99
104
|
|
|
100
105
|
With --wait, the message must start immediately; a busy session returns a conflict instead
|
|
101
106
|
of queuing an untrackable run. Without --wait, the result can be kind=direct or kind=queued.`,
|
|
102
107
|
"session artifacts": `Usage:
|
|
103
108
|
decidex session artifacts list SESSION_ID
|
|
104
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]`,
|
|
105
113
|
"run diagnose": `Usage:
|
|
106
114
|
decidex run diagnose RUN_ID [--session-id ID] [--agent-id ID] --json
|
|
107
115
|
|
|
@@ -117,6 +125,7 @@ Runtime Pod termination details require backend support.`,
|
|
|
117
125
|
decidex eval cases list|export|plan|apply ...
|
|
118
126
|
decidex eval run AGENT_ID FILE [--cases all] [--wait] [--follow] [--output FILE]
|
|
119
127
|
decidex eval runs list|get|wait|watch ...
|
|
128
|
+
decidex eval evidence download AGENT_ID RUN_ID --all --dir DIR [--overwrite]
|
|
120
129
|
decidex eval stop AGENT_ID RUN_ID`,
|
|
121
130
|
"eval cases": `Usage:
|
|
122
131
|
decidex eval cases list AGENT_ID
|
|
@@ -128,6 +137,8 @@ Runtime Pod termination details require backend support.`,
|
|
|
128
137
|
decidex eval runs get AGENT_ID RUN_ID
|
|
129
138
|
decidex eval runs wait AGENT_ID RUN_ID [--follow] [--output FILE] [--timeout SECONDS]
|
|
130
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]`,
|
|
131
142
|
ontology: `Usage:
|
|
132
143
|
decidex ontology list|get|export|plan|apply ...`,
|
|
133
144
|
api: `Usage:
|
|
@@ -445,13 +456,25 @@ async function listSessionArtifacts(agentId, sessionId, values) {
|
|
|
445
456
|
return (result.files ?? []).filter((file) => file.relativePath?.startsWith("artifacts/"));
|
|
446
457
|
}
|
|
447
458
|
|
|
448
|
-
function
|
|
449
|
-
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);
|
|
450
469
|
const child = relative(root, destination);
|
|
451
|
-
if (!child || child.startsWith("..") || isAbsolute(child)) throw new Error(
|
|
470
|
+
if (!child || child.startsWith("..") || isAbsolute(child)) throw new Error(`非法输出路径:${outputPath}`);
|
|
452
471
|
return destination;
|
|
453
472
|
}
|
|
454
473
|
|
|
474
|
+
function safeDestination(root, artifactPath) {
|
|
475
|
+
return safeRelativeDestination(root, artifactPath.replace(/^artifacts\//, ""));
|
|
476
|
+
}
|
|
477
|
+
|
|
455
478
|
async function assertSafeArtifactTarget(root, destination, overwrite) {
|
|
456
479
|
let current = root;
|
|
457
480
|
for (const part of relative(root, dirname(destination)).split(sep).filter((item) => item && item !== ".")) {
|
|
@@ -818,6 +841,35 @@ async function sessionCommand(action, args) {
|
|
|
818
841
|
if (values.query) query.set("q", values.query);
|
|
819
842
|
return print(await request(`/api/agent-sessions?${query}`, { values }));
|
|
820
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
|
+
}
|
|
821
873
|
if (action !== "artifacts") {
|
|
822
874
|
expectPositionals(positionals, 1, `session ${action || "COMMAND"} SESSION_ID`);
|
|
823
875
|
const sessionId = required(positionals[0], "SESSION_ID");
|
|
@@ -1156,9 +1208,47 @@ async function evalRunsCommand(args) {
|
|
|
1156
1208
|
throw new Error(`未知 eval runs 命令:${action || "(空)"}`);
|
|
1157
1209
|
}
|
|
1158
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
|
+
|
|
1159
1248
|
async function evalCommand(action, args) {
|
|
1160
1249
|
if (action === "cases") return evalCasesCommand(args);
|
|
1161
1250
|
if (action === "runs") return evalRunsCommand(args);
|
|
1251
|
+
if (action === "evidence") return evalEvidenceCommand(args);
|
|
1162
1252
|
const { values, positionals } = commandArgs(args, {
|
|
1163
1253
|
cases: { type: "string" },
|
|
1164
1254
|
follow: { type: "boolean", default: false },
|