@guandata/decidex 0.1.0
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 +198 -0
- package/package.json +24 -0
- package/src/cli.js +1162 -0
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Decidex CLI
|
|
2
|
+
|
|
3
|
+
基于 Decidex 当前 HTTP API 的零依赖 Node.js CLI。要求 Node.js 22+。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm link
|
|
7
|
+
decidex version --json
|
|
8
|
+
decidex auth login --base-url https://decidex.example.com
|
|
9
|
+
decidex auth status
|
|
10
|
+
decidex context show
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`auth login` 会打开一个 CLI 专用 Chrome Profile;在浏览器完成密码、企业 OIDC 或 Galaxy OIDC 登录后,CLI 通过 Chrome DevTools 读取 HttpOnly `decidex_session` 并保存到 `~/.config/decidex/config.json`(权限 `0600`)。后续登录会复用这个专用 Profile。
|
|
14
|
+
|
|
15
|
+
也可以从浏览器开发者工具复制 Cookie header,通过 stdin 导入,避免把凭据写进 shell history:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pbpaste | decidex auth import --base-url https://decidex.example.com
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Agent
|
|
22
|
+
|
|
23
|
+
创建 `agent.json`:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"name": "经营分析助手",
|
|
28
|
+
"description": "回答经营问题",
|
|
29
|
+
"instructions": "优先基于已绑定的业务本体回答。",
|
|
30
|
+
"openingMessage": "想分析什么?",
|
|
31
|
+
"presetQuestions": ["本月收入如何?"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
创建后,把响应里的 `agent.id` 写回文件顶层即可执行更新:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
decidex agent apply agent.json
|
|
39
|
+
decidex agent export AGENT_ID agent.zip
|
|
40
|
+
decidex agent import agent.zip
|
|
41
|
+
decidex agent publish AGENT_ID --email user@example.com
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`agent.json` 也可以直接声明本体、BI 资产、Skill、默认模型和推理强度:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"name": "经营分析助手",
|
|
49
|
+
"instructions": "优先基于已绑定的业务本体回答。",
|
|
50
|
+
"bizOntologyBindings": [{ "networkId": "NETWORK_ID", "versionId": "VERSION_ID" }],
|
|
51
|
+
"contextReferences": [],
|
|
52
|
+
"pluginSelection": { "enabledPluginIdentities": ["personal:ORG_ID:SKILL_ID"] },
|
|
53
|
+
"sessionDefaultModelCatalogEntryId": "MODEL_ENTRY_ID",
|
|
54
|
+
"sessionDefaultReasoningEffort": "medium"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
上传参考文件和执行冒烟问题:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
decidex agent file add AGENT_ID references/*.md
|
|
62
|
+
decidex agent file list AGENT_ID
|
|
63
|
+
decidex agent models AGENT_ID
|
|
64
|
+
decidex agent run AGENT_ID --message "分析本月销售异常" --wait
|
|
65
|
+
decidex agent run AGENT_ID --input smoke.md --wait --follow --output smoke-result.json
|
|
66
|
+
printf '%s' '分析本月销售异常' | decidex agent run AGENT_ID --input - --wait
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`--follow` 只把状态和工作轨迹写入 stderr;最终 JSON 仍可稳定写入文件:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"schemaVersion": 1,
|
|
74
|
+
"sessionId": "SESSION_ID",
|
|
75
|
+
"runId": "RUN_ID",
|
|
76
|
+
"status": "SUCCEEDED",
|
|
77
|
+
"error": null,
|
|
78
|
+
"answer": "销售异常主要来自转化率下降。",
|
|
79
|
+
"artifacts": [
|
|
80
|
+
{ "name": "结果.xlsx", "path": "artifacts/结果.xlsx", "sizeBytes": 39775 }
|
|
81
|
+
],
|
|
82
|
+
"startedAt": "2026-09-02T01:00:00.000Z",
|
|
83
|
+
"finishedAt": "2026-09-02T01:02:00.000Z",
|
|
84
|
+
"durationMs": 120000
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
运行后可以直接列出、批量下载产物并诊断 Run:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
decidex session list --status running
|
|
92
|
+
decidex session view SESSION_ID
|
|
93
|
+
decidex session send SESSION_ID --message "继续拆解渠道" --wait --follow
|
|
94
|
+
decidex session stop SESSION_ID
|
|
95
|
+
decidex session artifacts list SESSION_ID
|
|
96
|
+
decidex session artifacts download SESSION_ID --all --dir ./artifacts
|
|
97
|
+
decidex run diagnose RUN_ID --session-id SESSION_ID --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`session send --wait` 要求消息立即启动;会话正忙时服务端会在入队前返回冲突,避免 CLI 假失败后重试造成重复入队。不带 `--wait` 时结果可能是 `kind=direct` 或 `kind=queued`。
|
|
101
|
+
|
|
102
|
+
下载默认拒绝覆盖已有文件,也拒绝通过符号链接写出目标目录;确认覆盖普通文件时加 `--overwrite`。`run diagnose` 未显式传 `--session-id` 时会使用最近 50 条本地 Run 映射;若本地配置不可写,远端 Run 仍会继续,CLI 会先输出 Session/Run ID,之后可用显式 ID 恢复诊断。当前后端未向用户 API 暴露 Runner 的 Pod termination reason 和资源指标,结果会将这两项标记为 `not_exposed`。
|
|
103
|
+
|
|
104
|
+
## Skill
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
decidex skill list
|
|
108
|
+
decidex skill upload skill.zip
|
|
109
|
+
decidex skill update SKILL_ID skill.zip
|
|
110
|
+
decidex skill download SKILL_ID skill.zip
|
|
111
|
+
decidex skill delete SKILL_ID
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`skill update` 会先读取线上 fingerprint,再执行乐观锁更新,避免覆盖并发修改。
|
|
115
|
+
|
|
116
|
+
## Evaluation
|
|
117
|
+
|
|
118
|
+
评测案例文件可以是数组,也可以使用 `{ "cases": [...] }`:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"cases": [
|
|
123
|
+
{
|
|
124
|
+
"task": "本月销售下滑来自流量、转化率还是客单价?",
|
|
125
|
+
"rubric": "必须给出时间范围、指标证据和拆解过程;证据不足时降低结论强度。"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
先查看差异,再同步:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
decidex eval cases plan AGENT_ID cases.json
|
|
135
|
+
decidex eval cases apply AGENT_ID cases.json
|
|
136
|
+
|
|
137
|
+
# 显式删除线上文件中不存在的案例
|
|
138
|
+
decidex eval cases plan AGENT_ID cases.json --prune
|
|
139
|
+
decidex eval cases apply AGENT_ID cases.json --prune
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
同步以 `task` 为稳定键;本地或线上存在重复 task 时会停止。`apply` 先新增和更新,最后才执行 `--prune` 删除。当前后端没有案例版本号或幂等键:同一个 Agent 的评测案例只能由一个写入者同步,禁止并发执行 `apply`/`--prune`。
|
|
143
|
+
|
|
144
|
+
评测运行文件复用服务端契约:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"caseIds": ["CASE_ID"],
|
|
149
|
+
"targetModelSelection": { "modelEntryId": "MODEL_ENTRY_ID", "reasoningEffort": "medium" },
|
|
150
|
+
"judgeModelSelection": { "modelEntryId": "MODEL_ENTRY_ID", "reasoningEffort": "medium" }
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
decidex eval run AGENT_ID eval-run.json --cases all --wait --output eval-result.json
|
|
156
|
+
decidex eval stop AGENT_ID RUN_ID
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
CLI 按最新 `origin/main` 校验该文件:只接受 `caseIds`、`targetModelSelection` 和 `judgeModelSelection`。使用 `--cases all` 时由 CLI 获取并覆盖 `caseIds`;Agent 没有评测案例时会在本地停止。
|
|
160
|
+
|
|
161
|
+
## 组织
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
decidex org use ORGANIZATION_ID
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Galaxy 模式的组织由 BI 租户登录态决定,服务端会拒绝手动切换。
|
|
168
|
+
|
|
169
|
+
## 业务本体
|
|
170
|
+
|
|
171
|
+
本体构建复用 Decidex 的完整导出/导入契约,避免 CLI 重复维护对象、属性、关系、行动、风险等子资源 schema:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
decidex ontology export ONTOLOGY_ID ontology.json
|
|
175
|
+
decidex ontology plan ontology.json --name 新本体
|
|
176
|
+
decidex ontology apply ontology.json --name 新本体
|
|
177
|
+
|
|
178
|
+
# 覆盖已有本体:plan 默认不写入,apply 会先由服务端预检并创建备份版本
|
|
179
|
+
decidex ontology plan ontology.json --network-id ONTOLOGY_ID
|
|
180
|
+
decidex ontology apply ontology.json --network-id ONTOLOGY_ID
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
未封装的接口可直接调用:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
decidex api GET /api/personal-agents
|
|
187
|
+
decidex api PATCH /api/auth/active-organization --data organization.json
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
CI 中可使用 `DECIDEX_BASE_URL` 和 `DECIDEX_SESSION`,无需写本地配置。非本机 HTTP 地址默认被拒绝,确有可信内网明文部署时需设置 `DECIDEX_ALLOW_INSECURE_HTTP=1`。
|
|
191
|
+
|
|
192
|
+
`DECIDEX_BASE_URL` 与 `DECIDEX_SESSION` 必须成对提供。CLI 不会把配置文件中保存的 Cookie 复用到另一个 `--base-url`;切换环境时请重新执行 `auth login`/`auth import`。
|
|
193
|
+
|
|
194
|
+
## 当前边界
|
|
195
|
+
|
|
196
|
+
- CLI 已覆盖交互登录、Agent/本体/Skill 构建、会话续问与停止、产物下载、评测案例同步和评测运行。
|
|
197
|
+
- 当前上传与下载会整包载入内存,适合常规场景包和产物;超大文件需要后续增加流式传输。
|
|
198
|
+
- 组织列表与服务端已验证身份、评测案例并发版本控制、Runner Pod/OOM/资源诊断、长期机器凭据仍需要后端接口支持。
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guandata/decidex",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for building and operating Decidex ontologies, agents, skills, sessions, and evaluations.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"src/cli.js",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"decidex": "src/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "node --test"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org"
|
|
23
|
+
}
|
|
24
|
+
}
|