@guandata/decidex 0.3.0 → 0.5.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/src/cli.js CHANGED
@@ -42,9 +42,10 @@ Usage:
42
42
  decidex agent file delete ID FILE_ID
43
43
  decidex agent file download ID FILE_ID FILE
44
44
  decidex agent models ID
45
+ decidex agent improvement get|enable|disable AGENT_ID
45
46
  decidex agent run ID (--message TEXT | --input FILE | --attach FILE) [--model-entry-id ID] [--reasoning-effort LEVEL] [--wait] [--follow] [--output FILE] [--timeout SECONDS]
46
47
 
47
- decidex session list [--status all|running|completed] [--query TEXT] [--cursor CURSOR] [--agent-id ID]
48
+ decidex session list [--status all|running|completed] [--query TEXT] [--cursor CURSOR] [--agent-id ID] [--pinned-session-id ID] [--pinned-agent-id ID]
48
49
  decidex session view SESSION_ID [--before CURSOR | --since CURSOR]
49
50
  decidex session send SESSION_ID (--message TEXT | --input FILE) [--wait] [--follow]
50
51
  decidex session stop SESSION_ID
@@ -52,6 +53,7 @@ Usage:
52
53
  decidex session delete SESSION_ID
53
54
  decidex session model SESSION_ID MODEL_ENTRY_ID
54
55
  decidex session fork SESSION_ID RUN_ID
56
+ decidex session collaboration status|activate|continue|stop|task|download ...
55
57
  decidex session queue list SESSION_ID
56
58
  decidex session queue edit SESSION_ID DRAFT_ID (--message TEXT | --input FILE)
57
59
  decidex session queue delete SESSION_ID DRAFT_ID
@@ -107,7 +109,7 @@ Usage:
107
109
  decidex automation run ID [--wait] [--follow] [--output FILE] [--timeout SECONDS]
108
110
  decidex automation runs ID [--cursor CURSOR]
109
111
 
110
- decidex action-task list|get|suggestions|members|create|adopt|reject|complete|cancel ...
112
+ decidex action-task list|get|suggestions|members|create|adopt|reject|complete|cancel|dispatch-info|dispatch|attachment ...
111
113
  decidex tracking list|get|preview|create|lookup|wait|rename|schedule|pause|resume|close|review|reviews|report|retry|delete ...
112
114
  decidex platform list|show|call|coverage ...
113
115
 
@@ -138,6 +140,8 @@ Server >= 0.0.6: DAILY; WEEKLY weekdays:[0..6]; MONTHLY monthDays:[1..31];
138
140
  INTERVAL intervalMinutes:5..2147483647; ONCE runOnceAt:future ISO time.
139
141
  On 0.0.5, one weekday is supported; newer schedules are rejected before writing.
140
142
  Old HOURLY becomes INTERVAL(60) on 0.0.6. server check automation apply shows the protocol.
143
+ Server >= 0.0.7: imPush.channels[].biGroupIds / emailPush.biGroupIds select BI groups.
144
+ Before 0.0.7, include schedule when PATCHing to avoid the server's default schedule reset.
141
145
  --wait --timeout covers start, polling and final reads. A timeout does not cancel the run.`,
142
146
  "action-task": `Usage:
143
147
  decidex action-task list [--status PENDING|ADOPTED|COMPLETED|REJECTED|CANCELED|all] [--query TEXT] [--page N]
@@ -145,11 +149,18 @@ Old HOURLY becomes INTERVAL(60) on 0.0.6. server check automation apply shows th
145
149
  decidex action-task members SESSION_ID [--query TEXT]
146
150
  decidex action-task create SESSION_ID FILE
147
151
  decidex action-task get TASK_ID
152
+ decidex action-task dispatch-info TASK_ID [--bot-id ID]
153
+ decidex action-task dispatch TASK_ID FILE
154
+ decidex action-task attachment TASK_ID EVENT_ID INDEX FILE
148
155
  decidex action-task adopt|complete TASK_ID --version N
149
156
  decidex action-task reject|cancel TASK_ID --version N --note REASON
150
157
 
151
158
  Create FILE: {messageId,suggestionId,draft:{title,description,assigneeIds:[USER_ID]}}.
152
159
  Read the current version with get before changing status; 409 requires a new user decision.
160
+ Dispatch and attachment require server >= 0.0.7. INDEX starts at 0.
161
+ Dispatch FILE: {botId,recipientIds:[USER_ID],idempotencyKey,createNativeTask:false}.
162
+ Dispatch sends real notifications; createNativeTask defaults to true. Keep the same key
163
+ for the same dispatch and query dispatch-info after an uncertain response; no automatic retry.
153
164
  Action tasks have no delete API.`,
154
165
  tracking: `Usage:
155
166
  decidex tracking list [--filter all|due] [--page N]
@@ -190,6 +201,7 @@ released minimum versions are checked against the target server.`,
190
201
  decidex agent knowledge list|add|remove ...
191
202
  decidex agent file list|add|delete|download ...
192
203
  decidex agent models AGENT_ID
204
+ decidex agent improvement get|enable|disable AGENT_ID
193
205
  decidex agent run AGENT_ID (--message TEXT | --input FILE) [--wait] [--follow] [--output FILE]`,
194
206
  "agent run": `Usage:
195
207
  decidex agent run AGENT_ID (--message TEXT | --input FILE | --attach FILE) [--model-entry-id ID] [--reasoning-effort LEVEL] [--wait] [--follow] [--output FILE] [--timeout SECONDS]
@@ -201,8 +213,27 @@ to stderr, so stdout or --output remains machine-readable.
201
213
  --attach FILE is repeatable. --context-references FILE and --conversation-references FILE
202
214
  accept JSON arrays. --reasoning-effort null uses the model default.
203
215
  Use agent models AGENT_ID to discover supported catalog entries and efforts.`,
216
+ "agent improvement": `Usage:
217
+ decidex agent improvement get|enable|disable AGENT_ID
218
+
219
+ Requires server >= 0.0.8 and edit permission. Enabling processes new feedback only;
220
+ it does not replay feedback collected while disabled. Generated changes still require review.`,
221
+ "session collaboration": `Usage:
222
+ decidex session collaboration status SESSION_ID
223
+ decidex session collaboration activate SESSION_ID --accept-governance-notice
224
+ decidex session collaboration continue SESSION_ID --submission-id UUID
225
+ decidex session collaboration stop SESSION_ID --epoch N
226
+ decidex session collaboration task SESSION_ID TASK_ID
227
+ decidex session collaboration download SESSION_ID REMOTE_PATH FILE
228
+
229
+ Requires server >= 0.0.8. Only an idle normal Personal Agent user session can activate.
230
+ Experts work with the owner's authority and may consume additional model credits.
231
+ Expert maintainers can review received and shared materials; share only necessary data.
232
+ Read status for the current work epoch before stopping. Keep the same submission UUID
233
+ for the same continuation; after an uncertain response inspect status, do not blindly retry.
234
+ download uses a material path returned by status, not a local path.`,
204
235
  session: `Usage:
205
- decidex session list [--status all|running|completed] [--query TEXT] [--cursor CURSOR] [--agent-id ID]
236
+ decidex session list [--status all|running|completed] [--query TEXT] [--cursor CURSOR] [--agent-id ID] [--pinned-session-id ID] [--pinned-agent-id ID]
206
237
  decidex session view SESSION_ID [--before CURSOR | --since CURSOR]
207
238
  decidex session send SESSION_ID (--message TEXT | --input FILE) [--wait] [--follow]
208
239
  decidex session stop SESSION_ID
@@ -210,6 +241,7 @@ Use agent models AGENT_ID to discover supported catalog entries and efforts.`,
210
241
  decidex session delete SESSION_ID
211
242
  decidex session model SESSION_ID MODEL_ENTRY_ID
212
243
  decidex session fork SESSION_ID RUN_ID
244
+ decidex session collaboration status|activate|continue|stop|task|download ...
213
245
  decidex session queue list SESSION_ID
214
246
  decidex session queue edit SESSION_ID DRAFT_ID (--message TEXT | --input FILE)
215
247
  decidex session queue delete SESSION_ID DRAFT_ID
@@ -274,12 +306,6 @@ Runtime Pod termination details require backend support.`,
274
306
  decidex ontology versions list NETWORK_ID
275
307
  decidex ontology versions get NETWORK_ID VERSION_ID
276
308
  decidex ontology versions create NETWORK_ID [--description TEXT]`,
277
- automation: `Usage:
278
- decidex automation list
279
- decidex automation apply FILE
280
- decidex automation delete ID
281
- decidex automation run ID [--wait] [--follow] [--output FILE] [--timeout SECONDS]
282
- decidex automation runs ID [--cursor CURSOR]`,
283
309
  server: `Usage:
284
310
  decidex server version
285
311
  decidex server check [COMMAND...]
@@ -997,6 +1023,12 @@ async function agentCommand(action, args) {
997
1023
  const result = await request(`/api/personal-agents/${agentId}/sessions`, { values });
998
1024
  return print({ schemaVersion: 1, modelCatalog: result.modelCatalog });
999
1025
  }
1026
+ if (action === "improvement") {
1027
+ expectPositionals(positionals, 2, "agent improvement get|enable|disable AGENT_ID");
1028
+ const [operation, agentId] = positionals;
1029
+ if (!["get", "enable", "disable"].includes(operation)) throw new Error("improvement 只支持 get、enable、disable");
1030
+ return print(await taskApi(`personal-agents.background-improvement.${operation === "get" ? "list" : "put"}`, { agentId }, { body: operation === "get" ? undefined : { enabled: operation === "enable" }, values, deadline: Date.now() + positiveSeconds(values.timeout) * 1000 }));
1031
+ }
1000
1032
  if (action === "get") return print(await request(`/api/personal-agents/${encodeURIComponent(required(positionals[0], "ID"))}`, { values }));
1001
1033
  if (action === "apply") {
1002
1034
  expectPositionals(positionals, 1, "agent apply FILE");
@@ -1004,11 +1036,19 @@ async function agentCommand(action, args) {
1004
1036
  if (!spec || typeof spec !== "object" || Array.isArray(spec)) throw new Error("Agent 文件必须是 JSON 对象");
1005
1037
  const id = spec.id;
1006
1038
  if (id !== undefined && (typeof id !== "string" || !id.trim())) throw new Error("Agent id 必须是非空字符串");
1007
- const allowed = new Set(["id", "name", "description", "instructions", "avatarIcon", "avatarColor", "avatarImageDataUrl", "openingMessage", "presetQuestions", "contextReferences", "bizOntologyBindings", "betaFeatures", "actionSuggestionsEnabled", "biExplorationPolicy", "pluginSelection", "useScope", "sessionDefaultModelCatalogEntryId", "sessionDefaultReasoningEffort", ...(id ? ["builtInInstructions"] : [])]);
1039
+ const allowed = new Set(["id", "name", "description", "instructions", "avatarIcon", "avatarColor", "avatarImageDataUrl", "openingMessage", "presetQuestions", "contextReferences", "bizOntologyBindings", "betaFeatures", "actionSuggestionsEnabled", "biUserPropertiesEnabled", "biUserPropertyKeys", "biExplorationPolicy", "pluginSelection", "useScope", "sessionDefaultModelCatalogEntryId", "sessionDefaultReasoningEffort", ...(id ? ["builtInInstructions"] : [])]);
1008
1040
  const unknown = Object.keys(spec).filter((key) => !allowed.has(key));
1009
1041
  if (unknown.length) throw new Error(`Agent 文件包含不支持的字段:${unknown.join(", ")}`);
1010
1042
  const body = { ...spec };
1011
1043
  delete body.id;
1044
+ if (body.biUserPropertiesEnabled !== undefined || body.biUserPropertyKeys !== undefined) {
1045
+ if (body.biUserPropertiesEnabled !== undefined && typeof body.biUserPropertiesEnabled !== "boolean") throw new Error("biUserPropertiesEnabled 必须是布尔值");
1046
+ if (body.biUserPropertyKeys !== undefined) {
1047
+ if (!Array.isArray(body.biUserPropertyKeys) || body.biUserPropertyKeys.length > 20 || body.biUserPropertyKeys.some((key) => typeof key !== "string" || !key.trim() || key.trim().length > 200)) throw new Error("biUserPropertyKeys 最多 20 项,每项为 1..200 字符的属性 Key");
1048
+ body.biUserPropertyKeys = [...new Set(body.biUserPropertyKeys.map((key) => key.trim()))];
1049
+ }
1050
+ await commandCompatibility("agent apply bi-user-properties", values);
1051
+ }
1012
1052
  return print(
1013
1053
  await request(id ? `/api/personal-agents/${encodeURIComponent(id)}` : "/api/personal-agents", {
1014
1054
  method: id ? "PUT" : "POST",
@@ -1089,6 +1129,11 @@ async function sessionCommand(action, args) {
1089
1129
  const { values, positionals } = commandArgs(args, {
1090
1130
  ...TURN_OPTIONS,
1091
1131
  "agent-id": { type: "string" },
1132
+ "pinned-session-id": { type: "string", multiple: true },
1133
+ "pinned-agent-id": { type: "string", multiple: true },
1134
+ "accept-governance-notice": { type: "boolean", default: false },
1135
+ "submission-id": { type: "string" },
1136
+ epoch: { type: "string" },
1092
1137
  "model-entry-id": { type: "string" },
1093
1138
  before: { type: "string" },
1094
1139
  since: { type: "string" },
@@ -1107,6 +1152,29 @@ async function sessionCommand(action, args) {
1107
1152
  timeout: { type: "string", default: "600" },
1108
1153
  wait: { type: "boolean", default: false },
1109
1154
  });
1155
+ if (action === "collaboration") {
1156
+ const [operation, sessionId, third, fourth] = positionals;
1157
+ if (!["status", "activate", "continue", "stop", "task", "download"].includes(operation)) throw new Error("collaboration 只支持 status、activate、continue、stop、task、download");
1158
+ expectPositionals(positionals, operation === "download" ? 4 : operation === "task" ? 3 : 2, `session collaboration ${operation} SESSION_ID${operation === "download" ? " REMOTE_PATH FILE" : operation === "task" ? " TASK_ID" : ""}`);
1159
+ let body;
1160
+ if (operation === "activate") {
1161
+ if (!values["accept-governance-notice"]) throw new Error("专家使用会话所有者权限并可能增加模型消耗;确认后添加 --accept-governance-notice");
1162
+ body = { action: "activate", acceptGovernanceNotice: true };
1163
+ }
1164
+ if (operation === "continue") {
1165
+ const submissionId = required(values["submission-id"], "--submission-id UUID");
1166
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(submissionId)) throw new Error("--submission-id 必须是 UUID;同一次继续操作保持此值不变");
1167
+ body = { action: "continue", submissionId };
1168
+ }
1169
+ if (operation === "stop") body = { action: "stop", expectedEpoch: positiveInteger(required(values.epoch, "--epoch N"), "epoch") };
1170
+ if (operation === "download" && (!third || third.length > 2048)) throw new Error("REMOTE_PATH 需要 1..2048 字符的远端材料路径");
1171
+ const deadline = Date.now() + positiveSeconds(values.timeout) * 1000;
1172
+ const session = await resolveSession(sessionId, values, deadline);
1173
+ const parameters = { agentId: session.agentId, sessionId, ...(operation === "task" ? { taskId: third } : {}) };
1174
+ const id = operation === "download" ? "materials.list" : operation === "task" ? "tasks.get" : body ? "create" : "list";
1175
+ const result = await taskApi(`personal-agents.sessions.collaboration.${id}`, parameters, { body, query: operation === "download" ? { path: third } : {}, output: operation === "download" ? fourth : undefined, values, deadline });
1176
+ return operation === "download" ? print(result) : emit(result, values.output);
1177
+ }
1110
1178
  if (action === "list") {
1111
1179
  expectPositionals(positionals, 0, "session list");
1112
1180
  if (!new Set(["all", "running", "completed"]).has(values.status)) throw new Error("--status 只支持 all、running、completed");
@@ -1115,6 +1183,12 @@ async function sessionCommand(action, args) {
1115
1183
  if (values.query) query.set("q", values.query);
1116
1184
  if (values.cursor) query.set("cursor", values.cursor);
1117
1185
  if (values["agent-id"]) { query.set("groupMode", "agent"); query.set("agentId", values["agent-id"]); }
1186
+ for (const [flag, parameter] of [["pinned-session-id", "pinnedSessionIds"], ["pinned-agent-id", "pinnedAgentIds"]]) {
1187
+ if (!values[flag]?.length) continue;
1188
+ if (values[flag].some((id) => !id.trim() || id.trim().length > 200)) throw new Error(`--${flag} 需要 1..200 字符的 ID`);
1189
+ await commandCompatibility("session list pinned", values);
1190
+ query.set(parameter, JSON.stringify([...new Set(values[flag].map((id) => id.trim()))]));
1191
+ }
1118
1192
  const result = await request(`/api/agent-sessions?${query}`, { values });
1119
1193
  if (values.status !== "all") result.sessions = (result.sessions ?? []).filter((session) => values.status === "running" ? session.status === "RUNNING" : session.status !== "RUNNING");
1120
1194
  return print(result);
@@ -1744,12 +1818,17 @@ async function automationCommand(action, args) {
1744
1818
  const allowed = new Set(["name", "instructions", "personalAgentId", "schedule", "imPush", "emailPush", ...(id ? ["status"] : ["source"])]);
1745
1819
  const unknown = Object.keys(body).filter((key) => !allowed.has(key));
1746
1820
  if (unknown.length) throw new Error(`定时任务文件包含不支持的字段:${unknown.join(", ")}`);
1821
+ if (body.emailPush?.biGroupIds !== undefined || body.imPush?.channels?.some((channel) => channel.biGroupIds !== undefined)) await commandCompatibility("automation apply bi-groups", values);
1747
1822
  if (body.schedule !== undefined) {
1748
1823
  const compatibility = await commandCompatibility("automation apply", values);
1749
1824
  body.schedule = adaptAutomationSchedule(body.schedule, compatibility.protocol);
1750
1825
  }
1751
1826
  if (body.status !== undefined && !["ACTIVE", "PAUSED"].includes(body.status)) throw new Error("status 只能手动设置 ACTIVE 或 PAUSED;FINISHED 由服务端单次调度写入");
1752
1827
  if (id !== undefined && (typeof id !== "string" || !id.trim())) throw new Error("定时任务 id 必须是非空字符串");
1828
+ if (id && body.schedule === undefined) {
1829
+ const server = await targetVersion(values);
1830
+ if (!resolveCommandCompatibility("automation apply partial", server.version).supported) throw new Error(`目标 ${server.version} 省略 schedule 的更新可能重置计划;请在文件中附上原 schedule,或升级服务端到 >= 0.0.7`);
1831
+ }
1753
1832
  return print(await request(id ? `${base}/${encodeURIComponent(id)}` : base, { method: id ? "PATCH" : "POST", body, values }));
1754
1833
  }
1755
1834
  if (!["delete", "run", "runs"].includes(action)) throw new Error(`未知 automation 命令:${action || "(空)"}`);
@@ -1794,9 +1873,20 @@ async function actionTaskCommand(action, args) {
1794
1873
  const { values, positionals } = commandArgs(args, {
1795
1874
  status: { type: "string", default: "PENDING" }, query: { type: "string" }, page: { type: "string", default: "1" },
1796
1875
  version: { type: "string" }, note: { type: "string" }, "message-id": { type: "string" },
1797
- "run-id": { type: "string" }, output: { type: "string" }, timeout: { type: "string", default: "600" },
1876
+ "run-id": { type: "string" }, "bot-id": { type: "string" }, output: { type: "string" }, timeout: { type: "string", default: "600" },
1798
1877
  });
1799
1878
  const deadline = Date.now() + positiveSeconds(values.timeout) * 1000;
1879
+ if (action === "attachment") {
1880
+ expectPositionals(positionals, 4, "action-task attachment TASK_ID EVENT_ID INDEX FILE");
1881
+ if (!/^\d{1,4}$/.test(positionals[2])) throw new Error("附件 INDEX 必须是 0..9999 的整数(从 0 开始)");
1882
+ return print(await taskApi("action-tasks.events.attachments.get", { taskId: positionals[0], eventId: positionals[1], index: positionals[2] }, { output: positionals[3], values, deadline }));
1883
+ }
1884
+ if (action === "dispatch") {
1885
+ expectPositionals(positionals, 2, "action-task dispatch TASK_ID FILE");
1886
+ const body = await readJsonFile(positionals[1]);
1887
+ if (!body || typeof body !== "object" || Array.isArray(body) || typeof body.idempotencyKey !== "string" || !body.idempotencyKey.trim() || body.idempotencyKey.length > 80) throw new Error("分发文件需要 1..80 字符的 idempotencyKey;同一次分发保持此值不变,超时后先查询 dispatch-info");
1888
+ return emit(await taskApi("action-tasks.dispatch.create", { taskId: positionals[0] }, { body, values, deadline }), values.output);
1889
+ }
1800
1890
  if (action === "list") {
1801
1891
  expectPositionals(positionals, 0, "action-task list");
1802
1892
  if (!["PENDING", "ADOPTED", "COMPLETED", "REJECTED", "CANCELED", "all"].includes(values.status)) throw new Error("--status 不合法");
@@ -1822,6 +1912,7 @@ async function actionTaskCommand(action, args) {
1822
1912
  }
1823
1913
  expectPositionals(positionals, 1, `action-task ${action} TASK_ID`);
1824
1914
  const parameters = { taskId: positionals[0] };
1915
+ if (action === "dispatch-info") return emit(await taskApi("action-tasks.dispatch.list", parameters, { query: values["bot-id"] ? { botId: values["bot-id"] } : {}, values, deadline }), values.output);
1825
1916
  if (action === "get") return emit(await taskApi("action-tasks.get", parameters, { values, deadline }), values.output);
1826
1917
  if (!["adopt", "reject", "complete", "cancel"].includes(action)) throw new Error(`未知 action-task 命令:${action || "(空)"}`);
1827
1918
  if (values.version === undefined || !/^\d+$/.test(values.version) || !Number.isSafeInteger(Number(values.version))) throw new Error("需要 --version 非负整数;从 action-task get 返回值读取,冲突后不要自动重试");
@@ -1,5 +1,5 @@
1
- export const ADAPTED_SERVER_VERSION = "0.0.6";
2
- export const ADAPTED_SERVER_COMMIT = "73901fa03b18d2cb00484ffa951bf99b19af4161";
1
+ export const ADAPTED_SERVER_VERSION = "0.0.8";
2
+ export const ADAPTED_SERVER_COMMIT = "b5cbd94c009dc6099b1957b6c271d4987d7ff003";
3
3
 
4
4
  // Version boundaries must be backed by release tags, not the current main version.
5
5
  // /api/auth/context first appears between tags 0.0.4 and 0.0.5 (a860e97ad).
@@ -10,6 +10,14 @@ export const COMMAND_COMPATIBILITY = {
10
10
  "context show": { protocol: "identity-context", legacy: { before: "0.0.5", protocol: "local-context" } },
11
11
  // 0.0.6 changes the automation schedule contract; 0.0.5 strips unknown fields.
12
12
  "automation apply": { protocol: "schedule-v2", legacy: { before: "0.0.6", protocol: "schedule-v1" } },
13
+ // These fields first appear in the 0.0.7 release; older schemas strip or reject them.
14
+ "agent apply bi-user-properties": { minVersion: "0.0.7" },
15
+ "session list pinned": { minVersion: "0.0.7" },
16
+ "automation apply bi-groups": { minVersion: "0.0.7" },
17
+ "automation apply partial": { minVersion: "0.0.7" },
18
+ // Collaboration routes and the background improvement switch first ship in 0.0.8.
19
+ "session collaboration": { minVersion: "0.0.8" },
20
+ "agent improvement": { minVersion: "0.0.8" },
13
21
  };
14
22
 
15
23
  export function adaptAutomationSchedule(input, protocol, now = Date.now()) {