@bty/customer-service-cli 0.1.8 → 0.1.10
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/dist/bin.js +205 -69
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -66,10 +66,8 @@ function outputInfo(message) {
|
|
|
66
66
|
process.stderr.write(message + "\n");
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// src/
|
|
70
|
-
import
|
|
71
|
-
|
|
72
|
-
// src/utils/credentials.ts
|
|
69
|
+
// src/utils/update-checker.ts
|
|
70
|
+
import https from "https";
|
|
73
71
|
import fs2 from "fs";
|
|
74
72
|
import path2 from "path";
|
|
75
73
|
|
|
@@ -150,13 +148,109 @@ function initLocalConfig() {
|
|
|
150
148
|
return filePath;
|
|
151
149
|
}
|
|
152
150
|
|
|
151
|
+
// src/utils/update-checker.ts
|
|
152
|
+
var CACHE_FILENAME = "update-check.json";
|
|
153
|
+
var CHECK_INTERVAL_MS = 4 * 60 * 60 * 1e3;
|
|
154
|
+
var REQUEST_TIMEOUT_MS = 3e3;
|
|
155
|
+
var PACKAGE_NAME = "@bty/customer-service-cli";
|
|
156
|
+
var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
157
|
+
function getCachePath() {
|
|
158
|
+
return path2.join(getConfigDir(), CACHE_FILENAME);
|
|
159
|
+
}
|
|
160
|
+
function readCache() {
|
|
161
|
+
try {
|
|
162
|
+
const content = fs2.readFileSync(getCachePath(), "utf-8");
|
|
163
|
+
return JSON.parse(content);
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function writeCache(cache) {
|
|
169
|
+
const dir = getConfigDir();
|
|
170
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
171
|
+
fs2.writeFileSync(getCachePath(), JSON.stringify(cache, null, 2));
|
|
172
|
+
}
|
|
173
|
+
function compareSemver(current, latest) {
|
|
174
|
+
const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
|
|
175
|
+
const a = parse(current);
|
|
176
|
+
const b = parse(latest);
|
|
177
|
+
for (let i = 0; i < 3; i++) {
|
|
178
|
+
const av = a[i] ?? 0;
|
|
179
|
+
const bv = b[i] ?? 0;
|
|
180
|
+
if (av < bv) return -1;
|
|
181
|
+
if (av > bv) return 1;
|
|
182
|
+
}
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
function fetchLatestVersion() {
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
const req = https.get(REGISTRY_URL, { timeout: REQUEST_TIMEOUT_MS }, (res) => {
|
|
188
|
+
if (res.statusCode !== 200) {
|
|
189
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
190
|
+
res.resume();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
let body = "";
|
|
194
|
+
res.setEncoding("utf-8");
|
|
195
|
+
res.on("data", (chunk) => {
|
|
196
|
+
body += chunk;
|
|
197
|
+
});
|
|
198
|
+
res.on("end", () => {
|
|
199
|
+
try {
|
|
200
|
+
const data = JSON.parse(body);
|
|
201
|
+
if (data.version) {
|
|
202
|
+
resolve(data.version);
|
|
203
|
+
} else {
|
|
204
|
+
reject(new Error("No version field in response"));
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
reject(new Error("Invalid JSON response"));
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
req.on("error", reject);
|
|
212
|
+
req.on("timeout", () => {
|
|
213
|
+
req.destroy();
|
|
214
|
+
reject(new Error("Request timeout"));
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
async function checkForUpdate(currentVersion) {
|
|
219
|
+
if (process.env.CS_CLI_NO_UPDATE_CHECK === "1") {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const cache = readCache();
|
|
224
|
+
const now = Date.now();
|
|
225
|
+
if (cache && now - cache.lastCheckedAt < CHECK_INTERVAL_MS) {
|
|
226
|
+
return compareSemver(currentVersion, cache.latestVersion) < 0 ? formatUpdateMessage(currentVersion, cache.latestVersion) : null;
|
|
227
|
+
}
|
|
228
|
+
const latestVersion = await fetchLatestVersion();
|
|
229
|
+
writeCache({ latestVersion, lastCheckedAt: now });
|
|
230
|
+
return compareSemver(currentVersion, latestVersion) < 0 ? formatUpdateMessage(currentVersion, latestVersion) : null;
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function formatUpdateMessage(current, latest) {
|
|
236
|
+
return `
|
|
237
|
+
\u26A0 \u53D1\u73B0\u65B0\u7248\u672C ${PACKAGE_NAME}@${latest}\uFF08\u5F53\u524D ${current}\uFF09
|
|
238
|
+
\u8FD0\u884C pnpm add -g ${PACKAGE_NAME} \u5347\u7EA7
|
|
239
|
+
`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/client/auth-api.ts
|
|
243
|
+
import CryptoJS from "crypto-js";
|
|
244
|
+
|
|
153
245
|
// src/utils/credentials.ts
|
|
246
|
+
import fs3 from "fs";
|
|
247
|
+
import path3 from "path";
|
|
154
248
|
function getCredentialsPath() {
|
|
155
|
-
return
|
|
249
|
+
return path3.join(getConfigDir(), "credentials.json");
|
|
156
250
|
}
|
|
157
251
|
function readCredentials() {
|
|
158
252
|
try {
|
|
159
|
-
const content =
|
|
253
|
+
const content = fs3.readFileSync(getCredentialsPath(), "utf-8");
|
|
160
254
|
return JSON.parse(content);
|
|
161
255
|
} catch {
|
|
162
256
|
return null;
|
|
@@ -164,12 +258,12 @@ function readCredentials() {
|
|
|
164
258
|
}
|
|
165
259
|
function writeCredentials(creds) {
|
|
166
260
|
const dir = getConfigDir();
|
|
167
|
-
|
|
168
|
-
|
|
261
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
262
|
+
fs3.writeFileSync(getCredentialsPath(), JSON.stringify(creds, null, 2));
|
|
169
263
|
}
|
|
170
264
|
function clearCredentials() {
|
|
171
265
|
try {
|
|
172
|
-
|
|
266
|
+
fs3.unlinkSync(getCredentialsPath());
|
|
173
267
|
} catch {
|
|
174
268
|
}
|
|
175
269
|
}
|
|
@@ -194,7 +288,7 @@ function toExitCode(err) {
|
|
|
194
288
|
return 1;
|
|
195
289
|
}
|
|
196
290
|
function createRequest(globalTimeout) {
|
|
197
|
-
return async function request(baseUrl,
|
|
291
|
+
return async function request(baseUrl, path4, options) {
|
|
198
292
|
const headers = {
|
|
199
293
|
"Content-Type": "application/json",
|
|
200
294
|
...options.headers
|
|
@@ -215,7 +309,7 @@ function createRequest(globalTimeout) {
|
|
|
215
309
|
if (workspaceId) {
|
|
216
310
|
headers["workspace-id"] = workspaceId;
|
|
217
311
|
}
|
|
218
|
-
let url = `${baseUrl}${
|
|
312
|
+
let url = `${baseUrl}${path4}`;
|
|
219
313
|
if (options.query) {
|
|
220
314
|
const params = new URLSearchParams();
|
|
221
315
|
for (const [key, value] of Object.entries(options.query)) {
|
|
@@ -366,8 +460,8 @@ async function whoami() {
|
|
|
366
460
|
|
|
367
461
|
// src/commands/auth.ts
|
|
368
462
|
function registerAuthCommand(program2) {
|
|
369
|
-
const auth = program2.command("auth").description("\u8BA4\u8BC1\u7BA1\u7406");
|
|
370
|
-
auth.command("login").description("\u767B\u5F55\uFF08\u624B\u673A\u53F7 + \u5BC6\u7801\uFF09").requiredOption("--phone <phone>", "\u624B\u673A\u53F7").requiredOption("--password <password>", "\u5BC6\u7801").action(async (opts) => {
|
|
463
|
+
const auth = program2.command("auth").description("\u8BA4\u8BC1\u7BA1\u7406 \u2014\u2014 \u624B\u673A\u53F7+\u5BC6\u7801\u767B\u5F55\uFF0C\u83B7\u53D6\u8BBF\u95EE\u4EE4\u724C\u3002\u5176\u4ED6\u547D\u4EE4\u4F9D\u8D56\u6B64\u4EE4\u724C");
|
|
464
|
+
auth.command("login").description("\u767B\u5F55\uFF08\u624B\u673A\u53F7 + \u5BC6\u7801\uFF09\uFF0C\u6210\u529F\u540E\u4EE4\u724C\u81EA\u52A8\u6301\u4E45\u5316\u5230\u672C\u5730").requiredOption("--phone <phone>", "\u624B\u673A\u53F7\uFF0811 \u4F4D\uFF09").requiredOption("--password <password>", "\u5BC6\u7801").action(async (opts) => {
|
|
371
465
|
try {
|
|
372
466
|
const result = await login(opts.phone, opts.password);
|
|
373
467
|
formatOutput({ success: true, data: result }, program2.opts().table);
|
|
@@ -380,7 +474,7 @@ function registerAuthCommand(program2) {
|
|
|
380
474
|
clearCredentials();
|
|
381
475
|
formatOutput({ success: true, data: { message: "Logged out" } }, program2.opts().table);
|
|
382
476
|
});
|
|
383
|
-
auth.command("whoami").description("\u67E5\u770B\u5F53\u524D\u767B\u5F55\u7528\u6237\u4FE1\u606F").action(async () => {
|
|
477
|
+
auth.command("whoami").description("\u67E5\u770B\u5F53\u524D\u767B\u5F55\u7528\u6237\u4FE1\u606F\u3002\u9000\u51FA\u7801 2 \u8868\u793A\u672A\u767B\u5F55\u6216\u4EE4\u724C\u8FC7\u671F\uFF0C\u9700\u91CD\u65B0 auth login").action(async () => {
|
|
384
478
|
try {
|
|
385
479
|
const creds = readCredentials();
|
|
386
480
|
if (!creds) {
|
|
@@ -405,7 +499,7 @@ async function listWorkspaces() {
|
|
|
405
499
|
|
|
406
500
|
// src/commands/config.ts
|
|
407
501
|
function registerConfigCommand(program2) {
|
|
408
|
-
const config = program2.command("config").description("\u914D\u7F6E\u7BA1\u7406");
|
|
502
|
+
const config = program2.command("config").description("\u914D\u7F6E\u7BA1\u7406 \u2014\u2014 API \u5730\u5740\u3001\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4\u7B49\u6301\u4E45\u5316\u8BBE\u7F6E\u3002\u652F\u6301\u5168\u5C40\u914D\u7F6E\u548C\u76EE\u5F55\u7EA7\u672C\u5730\u914D\u7F6E\uFF08.cs-cli.json\uFF09");
|
|
409
503
|
config.command("set").description("\u8BBE\u7F6E API \u5730\u5740").option("--cs-api <url>", "\u5BA2\u670D API \u5730\u5740").option("--auth-api <url>", "\u8BA4\u8BC1 API \u5730\u5740").option("--ai-api <url>", "AI API \u5730\u5740").option("--agent-api <url>", "Customer Agent API \u5730\u5740").action((opts) => {
|
|
410
504
|
const updates = {};
|
|
411
505
|
if (opts.csApi) updates.customerServiceApiUrl = opts.csApi;
|
|
@@ -415,7 +509,7 @@ function registerConfigCommand(program2) {
|
|
|
415
509
|
writeConfig(updates);
|
|
416
510
|
formatOutput({ success: true, data: readConfig() }, program2.opts().table);
|
|
417
511
|
});
|
|
418
|
-
config.command("get").description("\u67E5\u770B\u5F53\u524D\u914D\u7F6E").action(() => {
|
|
512
|
+
config.command("get").description("\u67E5\u770B\u5F53\u524D\u914D\u7F6E\uFF08\u5168\u5C40 + \u672C\u5730\u5408\u5E76\u540E\u7684\u7ED3\u679C\uFF09").action(() => {
|
|
419
513
|
const globalCfg = readConfig() ?? {};
|
|
420
514
|
const localCfg = readLocalConfig();
|
|
421
515
|
const localPath = findLocalConfigPath();
|
|
@@ -430,7 +524,7 @@ function registerConfigCommand(program2) {
|
|
|
430
524
|
outputInfo(`\u672C\u5730\u914D\u7F6E\u5DF2\u521D\u59CB\u5316: ${filePath}`);
|
|
431
525
|
formatOutput({ success: true, data: { path: filePath } }, program2.opts().table);
|
|
432
526
|
});
|
|
433
|
-
config.command("set-workspace").description("\u8BBE\u7F6E\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4").argument("<workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--global", "\u5F3A\u5236\u5199\u5165\u5168\u5C40\u914D\u7F6E").action(async (workspaceId, opts) => {
|
|
527
|
+
config.command("set-workspace").description("\u8BBE\u7F6E\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4\u3002\u5927\u591A\u6570\u547D\u4EE4\u4F9D\u8D56\u6B64\u914D\u7F6E\u786E\u5B9A\u64CD\u4F5C\u8303\u56F4\u3002\u6709\u672C\u5730\u914D\u7F6E\u65F6\u4F18\u5148\u5199\u5165\u672C\u5730\uFF0C\u5426\u5219\u5199\u5165\u5168\u5C40").argument("<workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID\uFF08\u4ECE workspace list \u83B7\u53D6\uFF09").option("--global", "\u5F3A\u5236\u5199\u5165\u5168\u5C40\u914D\u7F6E").action(async (workspaceId, opts) => {
|
|
434
528
|
const useLocal = !opts.global && findLocalConfigPath() !== null;
|
|
435
529
|
try {
|
|
436
530
|
const workspaces2 = await listWorkspaces();
|
|
@@ -464,8 +558,8 @@ function registerConfigCommand(program2) {
|
|
|
464
558
|
|
|
465
559
|
// src/commands/workspace.ts
|
|
466
560
|
function registerWorkspaceCommand(program2) {
|
|
467
|
-
const workspace = program2.command("workspace").description("\u5DE5\u4F5C\u7A7A\u95F4\u7BA1\u7406");
|
|
468
|
-
workspace.command("list").description("\u5217\u51FA\u6240\u6709\u5DE5\u4F5C\u7A7A\u95F4").action(async () => {
|
|
561
|
+
const workspace = program2.command("workspace").description("\u5DE5\u4F5C\u7A7A\u95F4\u7BA1\u7406 \u2014\u2014 \u4E00\u4E2A\u5DE5\u4F5C\u7A7A\u95F4\u5BF9\u5E94\u4E00\u4E2A\u5BA2\u6237/\u5E97\u94FA\uFF0C\u5305\u542B\u8BE5\u5BA2\u6237\u7684\u6240\u6709 Agent");
|
|
562
|
+
workspace.command("list").description("\u5217\u51FA\u5F53\u524D\u8D26\u53F7\u53EF\u8BBF\u95EE\u7684\u6240\u6709\u5DE5\u4F5C\u7A7A\u95F4\u3002\u8FD4\u56DE id \u548C name\uFF0C\u7528\u4E8E config set-workspace").action(async () => {
|
|
469
563
|
try {
|
|
470
564
|
const data = await listWorkspaces();
|
|
471
565
|
formatOutput({ success: true, data }, program2.opts().table);
|
|
@@ -495,7 +589,7 @@ async function updateAgent(configId, data) {
|
|
|
495
589
|
}
|
|
496
590
|
|
|
497
591
|
// src/utils/data-parser.ts
|
|
498
|
-
import
|
|
592
|
+
import fs4 from "fs";
|
|
499
593
|
function parseDataOption(value) {
|
|
500
594
|
if (!value) {
|
|
501
595
|
throw new Error("Data option cannot be empty");
|
|
@@ -507,7 +601,7 @@ function parseDataOption(value) {
|
|
|
507
601
|
}
|
|
508
602
|
let content;
|
|
509
603
|
try {
|
|
510
|
-
content =
|
|
604
|
+
content = fs4.readFileSync(filePath, "utf-8");
|
|
511
605
|
} catch {
|
|
512
606
|
throw new Error(`Cannot read file: ${filePath}`);
|
|
513
607
|
}
|
|
@@ -526,8 +620,12 @@ function parseDataOption(value) {
|
|
|
526
620
|
|
|
527
621
|
// src/commands/agent.ts
|
|
528
622
|
function registerAgentCommand(program2) {
|
|
529
|
-
const agent = program2.command("agent").description(
|
|
530
|
-
|
|
623
|
+
const agent = program2.command("agent").description(
|
|
624
|
+
"Agent\uFF08AI \u5BA2\u670D\u673A\u5668\u4EBA\uFF09\u7BA1\u7406 \u2014\u2014 \u6BCF\u4E2A Agent \u7ED1\u5B9A\u4E00\u4E2A\u5E97\u94FA/\u6E20\u9053\uFF0C\u62E5\u6709\u72EC\u7ACB\u7684 SA \u7B56\u7565\u3001\u5546\u54C1\u77E5\u8BC6\u548C FAQ"
|
|
625
|
+
);
|
|
626
|
+
agent.command("list").description(
|
|
627
|
+
"\u5217\u51FA\u5F53\u524D\u5DE5\u4F5C\u7A7A\u95F4\u7684 Agent \u5217\u8868\u3002\u8FD4\u56DE config_id\uFF08\u540E\u7EED\u547D\u4EE4\u7684 --agent \u53C2\u6570\uFF09\u548C config_name"
|
|
628
|
+
).option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
531
629
|
try {
|
|
532
630
|
const data = await listAgents({
|
|
533
631
|
page: Number(opts.page),
|
|
@@ -539,7 +637,9 @@ function registerAgentCommand(program2) {
|
|
|
539
637
|
process.exit(toExitCode(err));
|
|
540
638
|
}
|
|
541
639
|
});
|
|
542
|
-
agent.command("get").description(
|
|
640
|
+
agent.command("get").description(
|
|
641
|
+
"\u83B7\u53D6 Agent \u5B8C\u6574\u914D\u7F6E\u8BE6\u60C5\uFF0C\u542B sub_agents\u3001sop_config\u3001customer_config\u3001forbidden_words\u3001knowledge_base_config \u7B49\u5B57\u6BB5"
|
|
642
|
+
).argument("<config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").action(async (configId) => {
|
|
543
643
|
try {
|
|
544
644
|
const data = await getAgent(configId);
|
|
545
645
|
formatOutput({ success: true, data }, program2.opts().table);
|
|
@@ -548,7 +648,12 @@ function registerAgentCommand(program2) {
|
|
|
548
648
|
process.exit(toExitCode(err));
|
|
549
649
|
}
|
|
550
650
|
});
|
|
551
|
-
agent.command("update").description(
|
|
651
|
+
agent.command("update").description(
|
|
652
|
+
"\u66F4\u65B0 Agent \u914D\u7F6E\uFF08\u5982 customer_config\u3001forbidden_words \u7B49\uFF09\u3002\u5EFA\u8BAE\u5148 agent get \u5BFC\u51FA\u5F53\u524D\u914D\u7F6E\u518D\u4FEE\u6539"
|
|
653
|
+
).argument("<config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption(
|
|
654
|
+
"--data <json>",
|
|
655
|
+
"JSON \u6570\u636E\u6216 @\u6587\u4EF6\u8DEF\u5F84\u3002\u53EF\u66F4\u65B0\u5B57\u6BB5\u5305\u62EC customer_config\u3001forbidden_words\u3001knowledge_base_config \u7B49"
|
|
656
|
+
).action(async (configId, opts) => {
|
|
552
657
|
try {
|
|
553
658
|
const body = parseDataOption(opts.data);
|
|
554
659
|
const data = await updateAgent(configId, body);
|
|
@@ -638,8 +743,10 @@ async function listSituationActionVersions(opts) {
|
|
|
638
743
|
|
|
639
744
|
// src/commands/sa.ts
|
|
640
745
|
function registerSACommand(program2) {
|
|
641
|
-
const sa = program2.command("sa").description(
|
|
642
|
-
|
|
746
|
+
const sa = program2.command("sa").description(
|
|
747
|
+
"SA\uFF08Situation-Action\uFF09\u7B56\u7565\u7BA1\u7406 \u2014\u2014 Agent \u610F\u56FE\u5339\u914D\u548C\u56DE\u590D\u903B\u8F91\u7684\u6838\u5FC3\u914D\u7F6E\u3002\u6BCF\u6761 SA \u5B9A\u4E49\u4E00\u4E2A\u573A\u666F(situation)\u53CA\u5BF9\u5E94\u52A8\u4F5C(action)\uFF0C\u6309\u4E8C\u7EA7\u6807\u7B7E\u4F53\u7CFB\u7EC4\u7EC7\u3002\u4FEE\u590D Issue \u65F6\u6700\u5E38\u64CD\u4F5C\u7684\u8D44\u6E90"
|
|
748
|
+
);
|
|
749
|
+
sa.command("list").description("\u5217\u51FA SA \u7B56\u7565\u6761\u76EE\u3002\u8FD4\u56DE id\u3001event_first_label\u3001event_second_label\u3001situation\u3001action\u3001transfer_to_human \u7B49\u5B57\u6BB5").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--intent <intent>", "\u6309\u5B50\u610F\u56FE\u7B5B\u9009\uFF08\u5982 GENERAL_QA\uFF09\u3002\u4E0D\u4F20\u5219\u8FD4\u56DE\u6240\u6709\u610F\u56FE").option("--first-label <label>", "\u6309\u4E00\u7EA7\u6807\u7B7E\u7B5B\u9009\uFF08\u5982 \u5546\u54C1\u54A8\u8BE2\u3001\u552E\u540E\u54A8\u8BE2\u3001\u53D1\u8D27\u4E0E\u7269\u6D41\u54A8\u8BE2\u3001\u4F18\u60E0\u6D3B\u52A8\u3001\u5546\u54C1\u63A8\u8350\u3001\u552E\u524D\u54A8\u8BE2\u3001\u5176\u4ED6\uFF09").option("--second-label <label>", "\u6309\u4E8C\u7EA7\u6807\u7B7E\u7B5B\u9009\uFF08\u5982 \u5546\u54C1\u5C5E\u6027\u3001\u9000\u6B3E\u3001\u7269\u6D41\u67E5\u8BE2\u7B49\uFF0C\u96B6\u5C5E\u4E8E\u4E00\u7EA7\u6807\u7B7E\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "500").action(async (opts) => {
|
|
643
750
|
try {
|
|
644
751
|
const data = await listSituationActions({
|
|
645
752
|
agentConfigId: opts.agent,
|
|
@@ -655,7 +762,7 @@ function registerSACommand(program2) {
|
|
|
655
762
|
process.exit(toExitCode(err));
|
|
656
763
|
}
|
|
657
764
|
});
|
|
658
|
-
sa.command("search").description("\u641C\u7D22\
|
|
765
|
+
sa.command("search").description("\u6309\u5173\u952E\u8BCD\u6A21\u7CCA\u641C\u7D22 SA \u6761\u76EE\uFF08\u5339\u914D situation \u548C action \u5185\u5BB9\uFF09").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--keyword <text>", '\u641C\u7D22\u5173\u952E\u8BCD\uFF08\u5982"\u9000\u6B3E"\u3001"\u5C3A\u7801"\uFF09').action(async (opts) => {
|
|
659
766
|
try {
|
|
660
767
|
const data = await searchSituationActions({
|
|
661
768
|
agentConfigId: opts.agent,
|
|
@@ -667,7 +774,7 @@ function registerSACommand(program2) {
|
|
|
667
774
|
process.exit(toExitCode(err));
|
|
668
775
|
}
|
|
669
776
|
});
|
|
670
|
-
sa.command("create").description("\u521B\u5EFA\
|
|
777
|
+
sa.command("create").description("\u521B\u5EFA\u65B0\u7684 SA \u7B56\u7565\u6761\u76EE").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--first-label <label>", "\u4E00\u7EA7\u6807\u7B7E\uFF08\u5982 \u5546\u54C1\u54A8\u8BE2\u3001\u552E\u540E\u54A8\u8BE2\u3001\u53D1\u8D27\u4E0E\u7269\u6D41\u54A8\u8BE2\u3001\u4F18\u60E0\u6D3B\u52A8\u3001\u5546\u54C1\u63A8\u8350\u3001\u552E\u524D\u54A8\u8BE2\u3001\u5176\u4ED6\uFF09").requiredOption("--second-label <label>", '\u4E8C\u7EA7\u6807\u7B7E\uFF08\u96B6\u5C5E\u4E8E\u4E00\u7EA7\u6807\u7B7E\uFF0C\u5982"\u5546\u54C1\u5C5E\u6027"\u96B6\u5C5E\u4E8E"\u5546\u54C1\u54A8\u8BE2"\uFF09').requiredOption("--situation <text>", '\u573A\u666F\u63CF\u8FF0 \u2014\u2014 \u5B9A\u4E49\u4F55\u65F6\u89E6\u53D1\u6B64\u7B56\u7565\uFF08\u5982"\u5BA2\u6237\u54A8\u8BE2\u5546\u54C1\u5C3A\u7801\u4FE1\u606F"\uFF09').requiredOption("--action <text>", "\u52A8\u4F5C\u6307\u4EE4 \u2014\u2014 Agent \u5339\u914D\u6B64\u573A\u666F\u65F6\u7684\u56DE\u590D\u903B\u8F91/SOP").option("--transfer", "\u547D\u4E2D\u65F6\u8F6C\u63A5\u4EBA\u5DE5\u5BA2\u670D\uFF08\u9ED8\u8BA4\u4E0D\u8F6C\u63A5\uFF09", false).option("--intent <intent>", "\u5B50\u610F\u56FE\uFF08\u9ED8\u8BA4 GENERAL_QA\uFF09\u3002\u901A\u5E38\u65E0\u9700\u6307\u5B9A").action(async (opts) => {
|
|
671
778
|
try {
|
|
672
779
|
const data = await createSituationAction({
|
|
673
780
|
agentConfigId: opts.agent,
|
|
@@ -684,7 +791,7 @@ function registerSACommand(program2) {
|
|
|
684
791
|
process.exit(toExitCode(err));
|
|
685
792
|
}
|
|
686
793
|
});
|
|
687
|
-
sa.command("update").description("\u66F4\u65B0\
|
|
794
|
+
sa.command("update").description("\u66F4\u65B0\u5DF2\u6709 SA \u7B56\u7565\u6761\u76EE\uFF08\u5168\u91CF\u66F4\u65B0\uFF0C\u6240\u6709\u5B57\u6BB5\u5FC5\u4F20\uFF09").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--id <number>", "SA \u6761\u76EE ID\uFF08\u4ECE sa list \u6216 sa search \u83B7\u53D6\uFF09").requiredOption("--first-label <label>", "\u4E00\u7EA7\u6807\u7B7E\uFF08\u5FC5\u987B\u4E0E\u5DF2\u6709\u6761\u76EE\u4E00\u81F4\u6216\u4E3A\u65B0\u503C\uFF09").requiredOption("--second-label <label>", "\u4E8C\u7EA7\u6807\u7B7E\uFF08\u5FC5\u987B\u4E0E\u5DF2\u6709\u6761\u76EE\u4E00\u81F4\u6216\u4E3A\u65B0\u503C\uFF09").requiredOption("--situation <text>", "\u573A\u666F\u63CF\u8FF0 \u2014\u2014 \u66F4\u65B0\u540E\u7684\u89E6\u53D1\u6761\u4EF6").requiredOption("--action <text>", "\u52A8\u4F5C\u6307\u4EE4 \u2014\u2014 \u66F4\u65B0\u540E\u7684\u56DE\u590D\u903B\u8F91/SOP").option("--transfer", "\u547D\u4E2D\u65F6\u8F6C\u63A5\u4EBA\u5DE5\u5BA2\u670D\uFF08\u9ED8\u8BA4\u4E0D\u8F6C\u63A5\uFF09", false).option("--intent <intent>", "\u5B50\u610F\u56FE\uFF08\u9ED8\u8BA4 GENERAL_QA\uFF09\u3002\u901A\u5E38\u65E0\u9700\u6307\u5B9A").action(async (opts) => {
|
|
688
795
|
try {
|
|
689
796
|
const data = await updateSituationAction({
|
|
690
797
|
agentConfigId: opts.agent,
|
|
@@ -702,7 +809,7 @@ function registerSACommand(program2) {
|
|
|
702
809
|
process.exit(toExitCode(err));
|
|
703
810
|
}
|
|
704
811
|
});
|
|
705
|
-
sa.command("delete").description("\u5220\u9664\
|
|
812
|
+
sa.command("delete").description("\u5220\u9664 SA \u7B56\u7565\u6761\u76EE\u3002--first-label \u548C --second-label \u5FC5\u987B\u4E0E\u8BE5\u6761\u76EE\u5B9E\u9645\u503C\u4E00\u81F4\uFF08\u4ECE sa list \u83B7\u53D6\uFF09").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--id <number>", "SA \u6761\u76EE ID\uFF08\u4ECE sa list \u6216 sa search \u83B7\u53D6\uFF09").requiredOption("--first-label <label>", "\u8BE5\u6761\u76EE\u7684\u4E00\u7EA7\u6807\u7B7E\uFF08\u5FC5\u987B\u4E0E\u5B9E\u9645\u503C\u4E00\u81F4\uFF09").requiredOption("--second-label <label>", "\u8BE5\u6761\u76EE\u7684\u4E8C\u7EA7\u6807\u7B7E\uFF08\u5FC5\u987B\u4E0E\u5B9E\u9645\u503C\u4E00\u81F4\uFF09").action(async (opts) => {
|
|
706
813
|
try {
|
|
707
814
|
const data = await deleteSituationAction({
|
|
708
815
|
agentConfigId: opts.agent,
|
|
@@ -716,7 +823,7 @@ function registerSACommand(program2) {
|
|
|
716
823
|
process.exit(toExitCode(err));
|
|
717
824
|
}
|
|
718
825
|
});
|
|
719
|
-
sa.command("versions").description("\u67E5\u770B\
|
|
826
|
+
sa.command("versions").description("\u67E5\u770B SA \u6761\u76EE\u7684\u5386\u53F2\u4FEE\u6539\u8BB0\u5F55\uFF0C\u7528\u4E8E\u5BA1\u8BA1\u53D8\u66F4").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--id <number>", "SA \u6761\u76EE ID\uFF08\u4ECE sa list \u6216 sa search \u83B7\u53D6\uFF09").action(async (opts) => {
|
|
720
827
|
try {
|
|
721
828
|
const data = await listSituationActionVersions({
|
|
722
829
|
agentConfigId: opts.agent,
|
|
@@ -793,8 +900,10 @@ async function findProduct(agentConfigId, productId) {
|
|
|
793
900
|
return matched;
|
|
794
901
|
}
|
|
795
902
|
function registerProductCommand(program2) {
|
|
796
|
-
const product = program2.command("product").description(
|
|
797
|
-
|
|
903
|
+
const product = program2.command("product").description(
|
|
904
|
+
"\u5546\u54C1\u77E5\u8BC6\u5E93\u7BA1\u7406 \u2014\u2014 Agent \u5173\u8054\u7684\u5546\u54C1\u6570\u636E\uFF08\u5356\u70B9\u3001\u8865\u5145\u77E5\u8BC6\u3001SKU\u3001\u53C2\u6570\u3001\u56FE\u7247\u8BC6\u522B\u7ED3\u679C\u7B49\uFF09\u3002Agent \u56DE\u7B54\u5546\u54C1\u76F8\u5173\u95EE\u9898\u65F6\u4F9D\u8D56\u6B64\u6570\u636E\u6E90"
|
|
905
|
+
);
|
|
906
|
+
product.command("list").description("\u5217\u51FA\u5546\u54C1\u5217\u8868\u3002\u8FD4\u56DE product_id\u3001product_name\u3001status\u3001selling_point_summary\u3001tags \u7B49\u5B57\u6BB5").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--keyword <text>", "\u6309\u5546\u54C1\u540D\u79F0\u641C\u7D22").option("--status <status...>", "\u6309\u72B6\u6001\u7B5B\u9009: available\uFF08\u5DF2\u5C31\u7EEA\uFF09| pending\uFF08\u5904\u7406\u4E2D\uFF09| failed\uFF08\u5904\u7406\u5931\u8D25\uFF09").option("--tag <tags...>", "\u6309\u6807\u7B7E\u7B5B\u9009\uFF08\u591A\u4E2A\u6807\u7B7E\u7A7A\u683C\u5206\u9694\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
798
907
|
try {
|
|
799
908
|
const data = await listProducts({
|
|
800
909
|
agentConfigId: opts.agent,
|
|
@@ -810,7 +919,7 @@ function registerProductCommand(program2) {
|
|
|
810
919
|
process.exit(toExitCode(err));
|
|
811
920
|
}
|
|
812
921
|
});
|
|
813
|
-
product.command("get").description("\u83B7\u53D6\u5546\u54C1\u8BE6\u60C5").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID").requiredOption("--product-id <product_id>", "\u5546\u54C1 ID").action(async (opts) => {
|
|
922
|
+
product.command("get").description("\u83B7\u53D6\u5546\u54C1\u5B8C\u6574\u8BE6\u60C5\uFF0C\u542B\u5356\u70B9\u3001\u8865\u5145\u77E5\u8BC6\u3001\u53C2\u6570\u3001SKU\u3001\u56FE\u7247\u8BC6\u522B\u7ED3\u679C\u7B49\u3002\u5185\u90E8\u81EA\u52A8\u89E3\u6790 database_id").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--product-id <product_id>", "\u5546\u54C1 ID\uFF08\u4ECE product list \u8FD4\u56DE\u7684 product_id \u5B57\u6BB5\u83B7\u53D6\uFF09").action(async (opts) => {
|
|
814
923
|
try {
|
|
815
924
|
const dbId = await getDbId(opts.agent);
|
|
816
925
|
const data = await getProductDetail({
|
|
@@ -824,7 +933,7 @@ function registerProductCommand(program2) {
|
|
|
824
933
|
process.exit(toExitCode(err));
|
|
825
934
|
}
|
|
826
935
|
});
|
|
827
|
-
product.command("update").description("\u66F4\u65B0\u5546\u54C1\u4FE1\u606F\
|
|
936
|
+
product.command("update").description("\u66F4\u65B0\u5546\u54C1\u77E5\u8BC6\u4FE1\u606F\u3002\u53EF\u66F4\u65B0\u5B57\u6BB5: \u5356\u70B9\u3001\u8865\u5145\u77E5\u8BC6\u3001tag\u3001\u53C2\u6570\u3001\u8F6E\u64AD\u56FE\u8BC6\u522B\u7ED3\u679C\u3001\u5546\u54C1\u8BE6\u60C5\u9875\u8BC6\u522B\u7ED3\u679C").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--product-id <product_id>", "\u5546\u54C1 ID\uFF08\u4ECE product list \u8FD4\u56DE\u7684 product_id \u5B57\u6BB5\u83B7\u53D6\uFF09").requiredOption("--update <json>", '\u66F4\u65B0\u5185\u5BB9 JSON \u6216 @\u6587\u4EF6\u8DEF\u5F84\u3002\u793A\u4F8B: {"\u5356\u70B9":"\u65B0\u5356\u70B9"} \u6216 {"\u8865\u5145\u77E5\u8BC6":"[{\\"question\\":\\"Q\\",\\"answer\\":\\"A\\"}]"}').action(async (opts) => {
|
|
828
937
|
try {
|
|
829
938
|
const [dbId, matched] = await Promise.all([
|
|
830
939
|
getDbId(opts.agent),
|
|
@@ -848,7 +957,7 @@ function registerProductCommand(program2) {
|
|
|
848
957
|
process.exit(toExitCode(err));
|
|
849
958
|
}
|
|
850
959
|
});
|
|
851
|
-
product.command("update-sku").description(
|
|
960
|
+
product.command("update-sku").description('\u66F4\u65B0\u6307\u5B9A SKU \u7684\u77E5\u8BC6\u4FE1\u606F\uFF08\u5982\u8865\u5145\u77E5\u8BC6\uFF09\u3002SKU \u540D\u79F0\u9700\u7CBE\u786E\u5339\u914D\uFF08\u5982 "\u989C\u8272\u5206\u7C7B:\u7C89\u7EA2"\uFF09').requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--sku <name>", 'SKU \u540D\u79F0\uFF08\u7CBE\u786E\u5339\u914D\uFF0C\u5982 "\u989C\u8272\u5206\u7C7B:\u7C89\u7EA2"\uFF09').requiredOption("--update <json>", '\u66F4\u65B0\u5185\u5BB9 JSON \u6216 @\u6587\u4EF6\u8DEF\u5F84\u3002\u793A\u4F8B: {"\u8865\u5145\u77E5\u8BC6":"\u7C89\u7EA2\u8272\u4E3A\u6D45\u7C89\u8C03"}').action(async (opts) => {
|
|
852
961
|
try {
|
|
853
962
|
const updateDict = parseDataOption(opts.update);
|
|
854
963
|
const data = await updateSku({
|
|
@@ -924,8 +1033,10 @@ async function getIssueStats(opts) {
|
|
|
924
1033
|
|
|
925
1034
|
// src/commands/issue.ts
|
|
926
1035
|
function registerIssueCommand(program2) {
|
|
927
|
-
const issue = program2.command("issue").description(
|
|
928
|
-
|
|
1036
|
+
const issue = program2.command("issue").description(
|
|
1037
|
+
"\u5DE5\u5355\uFF08Issue\uFF09\u7BA1\u7406 \u2014\u2014 \u8BB0\u5F55 Agent \u56DE\u590D\u5F02\u5E38\u3001\u5BA2\u6237\u6295\u8BC9\u7B49\u5F85\u5904\u7406\u95EE\u9898\u3002\u5DE5\u5355\u662F AI \u4FEE\u590D\u6D41\u7A0B\uFF08issue-repair\uFF09\u7684\u8F93\u5165\u6E90"
|
|
1038
|
+
);
|
|
1039
|
+
issue.command("list").description("\u5217\u51FA\u5DE5\u5355\u3002\u8FD4\u56DE issue_id\u3001title\u3001status\u3001priority\u3001tags\u3001agent_id\u3001created_at \u7B49\u5B57\u6BB5").option("--agent <agent_id>", "\u6309 Agent ID \u7B5B\u9009\uFF08\u4ECE agent list \u83B7\u53D6 config_id\uFF09").option("--status <status...>", "\u6309\u72B6\u6001\u7B5B\u9009: open | closed\uFF08\u591A\u4E2A\u7A7A\u683C\u5206\u9694\uFF09").option("--priority <priority...>", "\u6309\u4F18\u5148\u7EA7\u7B5B\u9009: critical | high | medium | low\uFF08\u591A\u4E2A\u7A7A\u683C\u5206\u9694\uFF09").option("--tags <tags...>", "\u6309\u6807\u7B7E\u7B5B\u9009\uFF08\u591A\u4E2A\u7A7A\u683C\u5206\u9694\uFF09").option("--start <date>", "\u5F00\u59CB\u65E5\u671F\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-05T00:00:00\uFF09").option("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-15T23:59:59\uFF09").option("--sort-by <field>", "\u6392\u5E8F\u5B57\u6BB5: created_at | updated_at", "created_at").option("--sort-order <order>", "\u6392\u5E8F\u65B9\u5411: asc | desc", "desc").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
929
1040
|
try {
|
|
930
1041
|
const data = await listIssues({
|
|
931
1042
|
agentId: opts.agent,
|
|
@@ -945,7 +1056,7 @@ function registerIssueCommand(program2) {
|
|
|
945
1056
|
process.exit(toExitCode(err));
|
|
946
1057
|
}
|
|
947
1058
|
});
|
|
948
|
-
issue.command("get").description("\u83B7\u53D6\u5DE5\u5355\u8BE6\u60C5").argument("<issue_id>", "\u5DE5\u5355 ID").action(async (issueId) => {
|
|
1059
|
+
issue.command("get").description("\u83B7\u53D6\u5DE5\u5355\u5B8C\u6574\u8BE6\u60C5\uFF0C\u542B title\u3001content\u3001status\u3001priority\u3001tags\u3001conversation_id\u3001agent_id \u7B49\u5B57\u6BB5").argument("<issue_id>", "\u5DE5\u5355 ID").action(async (issueId) => {
|
|
949
1060
|
try {
|
|
950
1061
|
const data = await getIssue(issueId);
|
|
951
1062
|
formatOutput({ success: true, data }, program2.opts().table);
|
|
@@ -954,7 +1065,7 @@ function registerIssueCommand(program2) {
|
|
|
954
1065
|
process.exit(toExitCode(err));
|
|
955
1066
|
}
|
|
956
1067
|
});
|
|
957
|
-
issue.command("create").description("\u521B\u5EFA\u5DE5\u5355").requiredOption("--title <title>", "\u5DE5\u5355\u6807\u9898").requiredOption("--content <content>", "\u5DE5\u5355\u5185\u5BB9").option("--priority <priority>", "\u4F18\u5148\u7EA7").option("--tags <tags...>", "\u6807\u7B7E").action(async (opts) => {
|
|
1068
|
+
issue.command("create").description("\u624B\u52A8\u521B\u5EFA\u5DE5\u5355").requiredOption("--title <title>", "\u5DE5\u5355\u6807\u9898\uFF08\u7B80\u8981\u63CF\u8FF0\u95EE\u9898\uFF09").requiredOption("--content <content>", "\u5DE5\u5355\u5185\u5BB9\uFF08\u8BE6\u7EC6\u63CF\u8FF0\u95EE\u9898\u73B0\u8C61\u548C\u671F\u671B\u7ED3\u679C\uFF09").option("--priority <priority>", "\u4F18\u5148\u7EA7: critical | high | medium | low").option("--tags <tags...>", "\u6807\u7B7E\uFF08\u591A\u4E2A\u7A7A\u683C\u5206\u9694\uFF0C\u7528\u4E8E\u5206\u7C7B\u7B5B\u9009\uFF09").action(async (opts) => {
|
|
958
1069
|
try {
|
|
959
1070
|
const data = await createIssue({
|
|
960
1071
|
title: opts.title,
|
|
@@ -968,7 +1079,7 @@ function registerIssueCommand(program2) {
|
|
|
968
1079
|
process.exit(toExitCode(err));
|
|
969
1080
|
}
|
|
970
1081
|
});
|
|
971
|
-
issue.command("update").description("\u66F4\u65B0\u5DE5\u5355").argument("<issue_id>", "\u5DE5\u5355 ID").requiredOption("--data <json>", "JSON \u6570\u636E\u6216 @\u6587\u4EF6\u8DEF\u5F84").action(async (issueId, opts) => {
|
|
1082
|
+
issue.command("update").description("\u66F4\u65B0\u5DE5\u5355\u5B57\u6BB5\uFF08\u5982 status\u3001priority\u3001tags\u3001title\u3001content\uFF09").argument("<issue_id>", "\u5DE5\u5355 ID\uFF08\u4ECE issue list \u83B7\u53D6\uFF09").requiredOption("--data <json>", "JSON \u6570\u636E\u6216 @\u6587\u4EF6\u8DEF\u5F84\u3002\u53EF\u66F4\u65B0: status\uFF08open|closed\uFF09\u3001priority\u3001tags\u3001title\u3001content").action(async (issueId, opts) => {
|
|
972
1083
|
try {
|
|
973
1084
|
const body = parseDataOption(opts.data);
|
|
974
1085
|
const data = await updateIssue(issueId, body);
|
|
@@ -978,7 +1089,7 @@ function registerIssueCommand(program2) {
|
|
|
978
1089
|
process.exit(toExitCode(err));
|
|
979
1090
|
}
|
|
980
1091
|
});
|
|
981
|
-
issue.command("stats").description("\
|
|
1092
|
+
issue.command("stats").description("\u8DE8\u5DE5\u4F5C\u7A7A\u95F4 Issue \u6570\u91CF\u7EDF\u8BA1\uFF0C\u8FD4\u56DE\u6BCF\u4E2A\u5DE5\u4F5C\u7A7A\u95F4\u7684 open/closed/total \u8BA1\u6570").option("--start <date>", "\u5F00\u59CB\u65E5\u671F\uFF08YYYY-MM-DD \u683C\u5F0F\uFF0C\u5982 2026-03-01\uFF09").option("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08YYYY-MM-DD \u683C\u5F0F\uFF0C\u5982 2026-03-23\uFF09").action(async (opts) => {
|
|
982
1093
|
try {
|
|
983
1094
|
const data = await getIssueStats({
|
|
984
1095
|
dateStart: opts.start,
|
|
@@ -990,7 +1101,7 @@ function registerIssueCommand(program2) {
|
|
|
990
1101
|
process.exit(toExitCode(err));
|
|
991
1102
|
}
|
|
992
1103
|
});
|
|
993
|
-
const comment = issue.command("comment").description("\u5DE5\u5355\u8BC4\u8BBA\u7BA1\u7406");
|
|
1104
|
+
const comment = issue.command("comment").description("\u5DE5\u5355\u8BC4\u8BBA\u7BA1\u7406 \u2014\u2014 \u5728\u5DE5\u5355\u4E0B\u6DFB\u52A0\u8BA8\u8BBA\u3001\u4FEE\u590D\u8BB0\u5F55\u7B49\u8BC4\u8BBA");
|
|
994
1105
|
comment.command("list").description("\u5217\u51FA\u5DE5\u5355\u8BC4\u8BBA").argument("<issue_id>", "\u5DE5\u5355 ID").action(async (issueId) => {
|
|
995
1106
|
try {
|
|
996
1107
|
const data = await listIssueComments(issueId);
|
|
@@ -1026,7 +1137,9 @@ async function listChatHistory(opts) {
|
|
|
1026
1137
|
|
|
1027
1138
|
// src/commands/chat-history.ts
|
|
1028
1139
|
function registerChatHistoryCommand(program2) {
|
|
1029
|
-
program2.command("chat-history").description(
|
|
1140
|
+
program2.command("chat-history").description(
|
|
1141
|
+
"\u67E5\u8BE2\u5BA2\u6237\u5BFC\u5165\u7684\u539F\u59CB\u804A\u5929\u8BB0\u5F55\uFF08\u7528\u4E8E\u63D0\u70BC SA \u7B56\u7565\uFF09\u3002\u6CE8\u610F\uFF1A\u8FD9\u4E0D\u662F Agent \u7684\u5BF9\u8BDD\u8BB0\u5F55\uFF0CAgent \u5BF9\u8BDD\u8BF7\u7528 conversation \u547D\u4EE4"
|
|
1142
|
+
).requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
1030
1143
|
try {
|
|
1031
1144
|
const data = await listChatHistory({
|
|
1032
1145
|
agentConfigId: opts.agent,
|
|
@@ -1076,8 +1189,10 @@ async function saveFaqContent(opts) {
|
|
|
1076
1189
|
|
|
1077
1190
|
// src/commands/faq.ts
|
|
1078
1191
|
function registerFaqCommand(program2) {
|
|
1079
|
-
const faq = program2.command("faq").description(
|
|
1080
|
-
|
|
1192
|
+
const faq = program2.command("faq").description(
|
|
1193
|
+
"FAQ \u77E5\u8BC6\u5E93\u7BA1\u7406 \u2014\u2014 Agent \u7684\u95EE\u7B54\u8865\u5145\u77E5\u8BC6\u6E90\uFF0C\u6309\u6587\u4EF6\u7EC4\u7EC7\u3002\u5F53 SA \u7B56\u7565\u672A\u8986\u76D6\u7684\u95EE\u9898\u53EF\u901A\u8FC7 FAQ \u6761\u76EE\u56DE\u7B54"
|
|
1194
|
+
);
|
|
1195
|
+
faq.command("list").description("\u5217\u51FA FAQ \u6587\u4EF6\u3002\u8FD4\u56DE knowledge_id \u548C file_name \u5B57\u6BB5\uFF0Cfile_name \u7528\u4E8E faq add --file \u5339\u914D").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
1081
1196
|
try {
|
|
1082
1197
|
const data = await listFaqFiles({
|
|
1083
1198
|
agentConfigId: opts.agent,
|
|
@@ -1090,7 +1205,7 @@ function registerFaqCommand(program2) {
|
|
|
1090
1205
|
process.exit(toExitCode(err));
|
|
1091
1206
|
}
|
|
1092
1207
|
});
|
|
1093
|
-
faq.command("add").description("\u5411 FAQ \u6587\u4EF6\u6DFB\u52A0\
|
|
1208
|
+
faq.command("add").description("\u5411\u6307\u5B9A FAQ \u6587\u4EF6\u6DFB\u52A0\u95EE\u7B54\u6761\u76EE\u3002\u5148\u7528 faq list \u83B7\u53D6\u6587\u4EF6\u540D").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--file <name>", "FAQ \u6587\u4EF6\u540D\uFF08\u9700\u7CBE\u786E\u5339\u914D faq list \u8FD4\u56DE\u7684 file_name\uFF09").requiredOption("--questions <items>", '\u76F8\u4F3C\u95EE\u9898\u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF0C\u5982 "\u600E\u4E48\u9000\u6B3E,\u5982\u4F55\u9000\u6B3E,\u9000\u6B3E\u6D41\u7A0B"\uFF09').requiredOption("--answers <pairs>", '\u7B54\u6848\uFF08\u683C\u5F0F: \u7B54\u6848=\u5185\u5BB9\u3002\u5982 "\u7B54\u6848=\u8BF7\u8054\u7CFB\u5BA2\u670D\u5904\u7406\u9000\u6B3E"\uFF09').option("--page-size <number>", "\u641C\u7D22\u6587\u4EF6\u65F6\u7684\u6BCF\u9875\u6570\u91CF", "100").action(async (opts) => {
|
|
1094
1209
|
try {
|
|
1095
1210
|
const filesResult = await listFaqFiles({
|
|
1096
1211
|
agentConfigId: opts.agent,
|
|
@@ -1156,8 +1271,10 @@ async function listConversations(opts) {
|
|
|
1156
1271
|
|
|
1157
1272
|
// src/commands/conversation.ts
|
|
1158
1273
|
function registerConversationCommand(program2) {
|
|
1159
|
-
const conversation = program2.command("conversation").description(
|
|
1160
|
-
|
|
1274
|
+
const conversation = program2.command("conversation").description(
|
|
1275
|
+
"\u4F1A\u8BDD\u7BA1\u7406 \u2014\u2014 Agent \u4E0E\u771F\u5B9E\u7528\u6237\u7684\u5BF9\u8BDD\u8BB0\u5F55\u3002\u6CE8\u610F\uFF1A\u8FD9\u662F Agent \u7684\u5B9E\u9645\u5BF9\u8BDD\uFF0C\u4E0D\u662F\u5BA2\u6237\u5BFC\u5165\u7684\u804A\u5929\u8BB0\u5F55\uFF08\u540E\u8005\u7528 chat-history \u547D\u4EE4\uFF09"
|
|
1276
|
+
);
|
|
1277
|
+
conversation.command("list").description("\u6309\u6761\u4EF6\u641C\u7D22\u4F1A\u8BDD\u5217\u8868\u3002\u8FD4\u56DE conversation_id\u3001user_name\u3001created_at \u7B49\u5B57\u6BB5").requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--user <name>", "\u6309\u7528\u6237\u540D\u7B5B\u9009").option("--start <date>", "\u5F00\u59CB\u65E5\u671F\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-22T00:00:00\uFF09").option("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-22T23:59:59\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
1161
1278
|
try {
|
|
1162
1279
|
const data = await listConversations({
|
|
1163
1280
|
agentConfigId: opts.agent,
|
|
@@ -1173,7 +1290,7 @@ function registerConversationCommand(program2) {
|
|
|
1173
1290
|
process.exit(toExitCode(err));
|
|
1174
1291
|
}
|
|
1175
1292
|
});
|
|
1176
|
-
conversation.command("records").description("\u83B7\u53D6\u4F1A\u8BDD\u804A\u5929\u8BB0\u5F55").argument("<conversation_id>", "\u4F1A\u8BDD ID").option("--page-size <number>", "\
|
|
1293
|
+
conversation.command("records").description("\u83B7\u53D6\u6307\u5B9A\u4F1A\u8BDD\u7684\u5B8C\u6574\u804A\u5929\u8BB0\u5F55\uFF08\u6D88\u606F\u5217\u8868\uFF09").argument("<conversation_id>", "\u4F1A\u8BDD ID\uFF08\u4ECE conversation list \u6216 issue get \u4E2D\u83B7\u53D6\uFF09").option("--page-size <number>", "\u8FD4\u56DE\u7684\u6D88\u606F\u6761\u6570", "50").option("--direction <dir>", "\u5206\u9875\u65B9\u5411: prev\uFF08\u66F4\u65E9\u7684\u6D88\u606F\uFF09| next\uFF08\u66F4\u65B0\u7684\u6D88\u606F\uFF09", "prev").action(async (conversationId, opts) => {
|
|
1177
1294
|
try {
|
|
1178
1295
|
const data = await getConversationRecords({
|
|
1179
1296
|
conversationId,
|
|
@@ -1268,8 +1385,15 @@ async function getRecordDebugInfo(recordId) {
|
|
|
1268
1385
|
|
|
1269
1386
|
// src/commands/debug.ts
|
|
1270
1387
|
function registerDebugCommand(program2) {
|
|
1271
|
-
const debug = program2.command("debug").description(
|
|
1272
|
-
|
|
1388
|
+
const debug = program2.command("debug").description(
|
|
1389
|
+
"Agent \u8C03\u8BD5\u6D4B\u8BD5 \u2014\u2014 \u5411 Agent \u53D1\u9001\u6D4B\u8BD5\u6D88\u606F\u5E76\u83B7\u53D6\u56DE\u590D\uFF0C\u662F\u9A8C\u8BC1 Agent \u56DE\u590D\u8D28\u91CF\u7684\u4E3B\u8981\u624B\u6BB5\u3002\u652F\u6301\u5355\u6761\u6D88\u606F\u548C\u591A\u8F6E\u5BF9\u8BDD\u91CD\u653E"
|
|
1390
|
+
);
|
|
1391
|
+
debug.command("ask").description(
|
|
1392
|
+
"\u5411 Agent \u53D1\u9001\u6D88\u606F\u5E76\u7B49\u5F85\u56DE\u590D\u3002\u8FD4\u56DE { conversation_id, reply: [{ record_id, content, ... }] }\u3002record_id \u53EF\u4F20\u7ED9 debug record \u67E5\u770B\u5185\u90E8\u63A8\u7406\u94FE\u8DEF"
|
|
1393
|
+
).requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--text <message>", "\u53D1\u9001\u7684\u6D88\u606F\u5185\u5BB9\uFF08\u4E0E --messages \u4E92\u65A5\uFF0C\u4E8C\u9009\u4E00\uFF09").option(
|
|
1394
|
+
"--messages <json>",
|
|
1395
|
+
'\u5B8C\u6574\u6D88\u606F\u5217\u8868 JSON \u6216 @\u6587\u4EF6\u8DEF\u5F84\uFF0C\u7528\u4E8E\u91CD\u653E\u591A\u8F6E\u5BF9\u8BDD\uFF08\u4E0E --text \u4E92\u65A5\uFF09\u3002\u63A5\u53D7\u4E24\u79CD\u683C\u5F0F\uFF1A(1) JSON \u6570\u7EC4 [{ match_id, content: { text, image_url? }, timestamp, type: "TEXT", role: "user"|"assistant" }, ...] (2) \u542B msg_list \u5B57\u6BB5\u7684\u5BF9\u8C61 { msg_list: [...] }\uFF08conversation records \u7684\u539F\u59CB\u683C\u5F0F\u53EF\u76F4\u63A5\u4F7F\u7528\uFF09'
|
|
1396
|
+
).option("--user <name>", "\u6A21\u62DF\u7684\u7528\u6237\u540D\uFF08\u9ED8\u8BA4\u4F7F\u7528\u767B\u5F55\u7528\u6237\u540D\uFF09").option("--url <image_url>", "\u9644\u5E26\u7684\u56FE\u7247 URL\uFF08\u4EC5 --text \u6A21\u5F0F\u6709\u6548\uFF09").option("--conversation <id>", "\u590D\u7528\u5DF2\u6709\u4F1A\u8BDD ID\uFF0C\u7528\u4E8E\u5728\u540C\u4E00\u4E0A\u4E0B\u6587\u4E2D\u7EE7\u7EED\u5BF9\u8BDD").option("--timeout <seconds>", "\u6700\u5927\u7B49\u5F85\u56DE\u590D\u65F6\u95F4\uFF08\u79D2\uFF09\uFF0C\u590D\u6742 Agent \u5EFA\u8BAE\u8C03\u9AD8", "30").option("--poll-interval <ms>", "\u8F6E\u8BE2\u95F4\u9694\uFF08\u6BEB\u79D2\uFF09", "2000").action(async (opts) => {
|
|
1273
1397
|
try {
|
|
1274
1398
|
if (!opts.text && !opts.messages) {
|
|
1275
1399
|
outputError(1, "\u5FC5\u987B\u6307\u5B9A --text \u6216 --messages \u5176\u4E2D\u4E4B\u4E00");
|
|
@@ -1320,7 +1444,7 @@ function registerDebugCommand(program2) {
|
|
|
1320
1444
|
process.exit(toExitCode(err));
|
|
1321
1445
|
}
|
|
1322
1446
|
});
|
|
1323
|
-
debug.command("record").description("\u83B7\u53D6\
|
|
1447
|
+
debug.command("record").description("\u83B7\u53D6\u67D0\u6761\u56DE\u590D\u7684\u5185\u90E8\u63A8\u7406\u94FE\u8DEF\uFF08flow_info\uFF09\uFF0C\u7528\u4E8E\u8BCA\u65AD Agent \u4E3A\u4F55\u7ED9\u51FA\u7279\u5B9A\u56DE\u590D").argument("<record_id>", "\u56DE\u590D\u8BB0\u5F55 ID\uFF08\u4ECE debug ask \u8FD4\u56DE\u7684 reply[].record_id \u83B7\u53D6\uFF09").action(async (recordId) => {
|
|
1324
1448
|
try {
|
|
1325
1449
|
const data = await getRecordDebugInfo(recordId);
|
|
1326
1450
|
formatOutput({ success: true, data }, program2.opts().table);
|
|
@@ -1653,7 +1777,9 @@ var RESOURCE_NAMES = Object.keys(RESOURCE_DEFS);
|
|
|
1653
1777
|
|
|
1654
1778
|
// src/commands/monitor.ts
|
|
1655
1779
|
function registerMonitorCommand(program2) {
|
|
1656
|
-
const monitor = program2.command("monitor").description(
|
|
1780
|
+
const monitor = program2.command("monitor").description(
|
|
1781
|
+
"\u8FD0\u8425\u76D1\u63A7 \u2014\u2014 Agent \u5065\u5EB7\u5EA6\u3001\u6027\u80FD\u6307\u6807\u3001\u5F02\u5E38\u544A\u8B66\u3001\u8FD0\u8425\u7EDF\u8BA1\u3002\u7528 monitor fields <resource> \u67E5\u770B\u5404\u63A5\u53E3\u8FD4\u56DE\u5B57\u6BB5\u7684\u542B\u4E49"
|
|
1782
|
+
);
|
|
1657
1783
|
monitor.command("fields [resource]").description(`\u67E5\u770B\u63A5\u53E3\u8FD4\u56DE\u5B57\u6BB5\u542B\u4E49\uFF08\u53EF\u9009: ${RESOURCE_NAMES.join(", ")}\uFF09`).action((resource) => {
|
|
1658
1784
|
if (!resource) {
|
|
1659
1785
|
formatOutput({
|
|
@@ -1674,7 +1800,7 @@ function registerMonitorCommand(program2) {
|
|
|
1674
1800
|
}
|
|
1675
1801
|
formatOutput({ success: true, data: def }, program2.opts().table);
|
|
1676
1802
|
});
|
|
1677
|
-
monitor.command("agents").description("Agent \u751F\u547D\u5468\u671F\u5217\u8868").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1803
|
+
monitor.command("agents").description("Agent \u751F\u547D\u5468\u671F\u5217\u8868 \u2014\u2014 \u6784\u5EFA\u8FDB\u5EA6\u3001\u4F1A\u8BDD\u7EDF\u8BA1\u3001\u5546\u54C1\u5B66\u4E60\u72B6\u6001\u7B49").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1678
1804
|
try {
|
|
1679
1805
|
const data = await listAgentLifecycle({
|
|
1680
1806
|
page: Number(opts.page),
|
|
@@ -1686,8 +1812,8 @@ function registerMonitorCommand(program2) {
|
|
|
1686
1812
|
process.exit(toExitCode(err));
|
|
1687
1813
|
}
|
|
1688
1814
|
});
|
|
1689
|
-
const tickets2 = monitor.command("tickets").description("\u76D1\u63A7\u5DE5\u5355");
|
|
1690
|
-
tickets2.command("list").description("\u5217\u51FA\u76D1\u63A7\u5DE5\u5355").option("--agent <config_id>", "Agent ID").option("--status <status>", "\u5DE5\u5355\u72B6\u6001").option("--severity <severity>", "\u4E25\u91CD\u7EA7\u522B: critical | high | medium | low").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1815
|
+
const tickets2 = monitor.command("tickets").description("\u76D1\u63A7\u5DE5\u5355 \u2014\u2014 \u5F02\u5E38\u68C0\u6D4B\u89C4\u5219\u81EA\u52A8\u751F\u6210\u7684\u544A\u8B66\u5DE5\u5355");
|
|
1816
|
+
tickets2.command("list").description("\u5217\u51FA\u76D1\u63A7\u5DE5\u5355\u3002\u8FD4\u56DE ticket_id\u3001title\u3001status\u3001severity\u3001priority\u3001payload \u7B49\u5B57\u6BB5").option("--agent <config_id>", "Agent ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--status <status>", "\u5DE5\u5355\u72B6\u6001: open | closed").option("--severity <severity>", "\u4E25\u91CD\u7EA7\u522B: critical | high | medium | low").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1691
1817
|
try {
|
|
1692
1818
|
const data = await listTickets({
|
|
1693
1819
|
agentId: opts.agent,
|
|
@@ -1711,8 +1837,8 @@ function registerMonitorCommand(program2) {
|
|
|
1711
1837
|
process.exit(toExitCode(err));
|
|
1712
1838
|
}
|
|
1713
1839
|
});
|
|
1714
|
-
const snapshots = monitor.command("snapshots").description("\u76D1\u63A7\u5FEB\u7167");
|
|
1715
|
-
snapshots.command("hourly").description("\u67E5\u8BE2\u5C0F\u65F6\u5FEB\u7167").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <datetime>", "\u5F00\u59CB\u65F6\u95F4 (ISO)").option("--end <datetime>", "\u7ED3\u675F\u65F6\u95F4 (ISO)").option("--page <number>", "\u9875\u7801").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF").action(async (opts) => {
|
|
1840
|
+
const snapshots = monitor.command("snapshots").description("\u76D1\u63A7\u5FEB\u7167 \u2014\u2014 \u6309\u5C0F\u65F6/\u5929\u7C92\u5EA6\u7684 Agent \u6027\u80FD\u6307\u6807\uFF08\u4F1A\u8BDD\u91CF\u3001\u8F6C\u4EBA\u5DE5\u7387\u3001\u54CD\u5E94\u65F6\u95F4\u7B49\uFF09");
|
|
1841
|
+
snapshots.command("hourly").description("\u67E5\u8BE2\u5C0F\u65F6\u7EA7\u6027\u80FD\u5FEB\u7167\uFF08\u7528\u4E8E\u5F02\u5E38\u6392\u67E5\u548C\u7EC6\u7C92\u5EA6\u5206\u6790\uFF09").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <datetime>", "\u5F00\u59CB\u65F6\u95F4 (ISO)").option("--end <datetime>", "\u7ED3\u675F\u65F6\u95F4 (ISO)").option("--page <number>", "\u9875\u7801").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF").action(async (opts) => {
|
|
1716
1842
|
try {
|
|
1717
1843
|
const data = await listHourlySnapshots({
|
|
1718
1844
|
agentId: opts.agent,
|
|
@@ -1728,7 +1854,7 @@ function registerMonitorCommand(program2) {
|
|
|
1728
1854
|
process.exit(toExitCode(err));
|
|
1729
1855
|
}
|
|
1730
1856
|
});
|
|
1731
|
-
snapshots.command("daily").description("\u67E5\u8BE2\u65E5\u5FEB\u7167").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)").action(async (opts) => {
|
|
1857
|
+
snapshots.command("daily").description("\u67E5\u8BE2\u65E5\u7EA7\u6027\u80FD\u5FEB\u7167\uFF08\u7528\u4E8E\u8D8B\u52BF\u5206\u6790\u548C\u65E5\u62A5\uFF09").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)").action(async (opts) => {
|
|
1732
1858
|
try {
|
|
1733
1859
|
const data = await listDailySnapshots({
|
|
1734
1860
|
agentId: opts.agent,
|
|
@@ -1742,7 +1868,7 @@ function registerMonitorCommand(program2) {
|
|
|
1742
1868
|
process.exit(toExitCode(err));
|
|
1743
1869
|
}
|
|
1744
1870
|
});
|
|
1745
|
-
snapshots.command("daily-range").description("\u67E5\u8BE2\u65E5\u5FEB\u7167\uFF08\u8303\u56F4\uFF0C\u542B\u8D8B\u52BF\uFF09").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)").option("--page <number>", "\u9875\u7801").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1871
|
+
snapshots.command("daily-range").description("\u67E5\u8BE2\u65E5\u5FEB\u7167\uFF08\u8303\u56F4\u67E5\u8BE2\uFF0C\u542B\u8D8B\u52BF\u5BF9\u6BD4\u6570\u636E\uFF09").option("--agent <config_id>", "Agent ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)").option("--page <number>", "\u9875\u7801").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").action(async (opts) => {
|
|
1746
1872
|
try {
|
|
1747
1873
|
const data = await listDailySnapshotsRange({
|
|
1748
1874
|
agentId: opts.agent,
|
|
@@ -1758,7 +1884,7 @@ function registerMonitorCommand(program2) {
|
|
|
1758
1884
|
process.exit(toExitCode(err));
|
|
1759
1885
|
}
|
|
1760
1886
|
});
|
|
1761
|
-
monitor.command("statistics").description("Agent \u8FD0\u8425\u7EDF\u8BA1").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (ISO)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (ISO)").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "100").action(async (opts) => {
|
|
1887
|
+
monitor.command("statistics").description("Agent \u8FD0\u8425\u7EDF\u8BA1\uFF08\u805A\u5408\u6307\u6807\uFF1A\u4F1A\u8BDD\u603B\u91CF\u3001\u8F6C\u4EBA\u5DE5\u7387\u3001\u5E73\u5747\u54CD\u5E94\u65F6\u95F4\u7B49\uFF09").option("--start <date>", "\u5F00\u59CB\u65E5\u671F (ISO)").option("--end <date>", "\u7ED3\u675F\u65E5\u671F (ISO)").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "100").action(async (opts) => {
|
|
1762
1888
|
try {
|
|
1763
1889
|
const data = await listAgentStatistics({
|
|
1764
1890
|
startDate: opts.start,
|
|
@@ -1772,7 +1898,7 @@ function registerMonitorCommand(program2) {
|
|
|
1772
1898
|
process.exit(toExitCode(err));
|
|
1773
1899
|
}
|
|
1774
1900
|
});
|
|
1775
|
-
monitor.command("workspaces").description("\u8FD0\u8425\u5DE5\u4F5C\u7A7A\u95F4\u5217\u8868").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").option("--has-agent", "\u4EC5\u663E\u793A\
|
|
1901
|
+
monitor.command("workspaces").description("\u8FD0\u8425\u5DE5\u4F5C\u7A7A\u95F4\u5217\u8868\uFF08\u542B\u5BA2\u6237\u4FE1\u606F\u3001\u5408\u540C\u72B6\u6001\u7B49\uFF09").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "200").option("--has-agent", "\u4EC5\u663E\u793A\u5DF2\u90E8\u7F72 Agent \u7684\u5DE5\u4F5C\u7A7A\u95F4").action(async (opts) => {
|
|
1776
1902
|
try {
|
|
1777
1903
|
const data = await listOperationWorkspaces({
|
|
1778
1904
|
page: Number(opts.page),
|
|
@@ -1825,8 +1951,10 @@ async function updateRepairRecord(recordId, data) {
|
|
|
1825
1951
|
|
|
1826
1952
|
// src/commands/repair-record.ts
|
|
1827
1953
|
function registerRepairRecordCommand(program2) {
|
|
1828
|
-
const repairRecord = program2.command("repair-record").description(
|
|
1829
|
-
|
|
1954
|
+
const repairRecord = program2.command("repair-record").description(
|
|
1955
|
+
"Issue \u4FEE\u590D\u8BB0\u5F55\u7BA1\u7406 \u2014\u2014 AI \u81EA\u52A8\u4FEE\u590D\u6D41\u7A0B\u7684\u5BA1\u8BA1\u8FFD\u8E2A\u3002\u8BB0\u5F55\u6BCF\u6B21\u4FEE\u590D\u7684\u8BCA\u65AD\u63A8\u7406\u3001\u4FEE\u590D\u7B56\u7565\u3001\u53D8\u66F4\u5FEB\u7167\u548C\u9A8C\u8BC1\u7ED3\u679C\uFF0C\u7528\u4E8E\u81EA\u6211\u8FDB\u5316"
|
|
1956
|
+
);
|
|
1957
|
+
repairRecord.command("list").description("\u5217\u51FA\u4FEE\u590D\u8BB0\u5F55\u3002\u8FD4\u56DE record_id\u3001issue_id\u3001agent_id\u3001repair_action\u3001repair_status\u3001repair_result \u7B49\u5B57\u6BB5").option("--issue <issue_id>", "\u6309\u5DE5\u5355 ID \u7B5B\u9009\uFF08\u4ECE issue list \u83B7\u53D6\uFF09").option("--agent <agent_id>", "\u6309 Agent ID \u7B5B\u9009\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--workspace <workspace_id>", "\u6309\u5DE5\u4F5C\u7A7A\u95F4 ID \u7B5B\u9009").option("--page <number>", "\u9875\u7801", "1").option("--page-size <number>", "\u6BCF\u9875\u6570\u91CF", "20").action(async (opts) => {
|
|
1830
1958
|
try {
|
|
1831
1959
|
const data = await listRepairRecords({
|
|
1832
1960
|
issueId: opts.issue,
|
|
@@ -1841,7 +1969,7 @@ function registerRepairRecordCommand(program2) {
|
|
|
1841
1969
|
process.exit(toExitCode(err));
|
|
1842
1970
|
}
|
|
1843
1971
|
});
|
|
1844
|
-
repairRecord.command("create").description("\u521B\u5EFA\u4FEE\u590D\u8BB0\u5F55").requiredOption("--issue <issue_id>", "\u5DE5\u5355 ID").requiredOption("--agent <agent_id>", "Agent ID").requiredOption("--action <repair_action>",
|
|
1972
|
+
repairRecord.command("create").description("\u521B\u5EFA\u4FEE\u590D\u8BB0\u5F55\u3002\u901A\u5E38\u5728 Issue \u4FEE\u590D\u5B8C\u6210\u540E\u8C03\u7528\uFF0C\u8BB0\u5F55\u5B8C\u6574\u7684\u4FEE\u590D\u8FC7\u7A0B").requiredOption("--issue <issue_id>", "\u5173\u8054\u7684\u5DE5\u5355 ID\uFF08\u4ECE issue list \u83B7\u53D6\uFF09").requiredOption("--agent <agent_id>", "\u5173\u8054\u7684 Agent ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").requiredOption("--action <repair_action>", '\u4FEE\u590D\u52A8\u4F5C\u6458\u8981\uFF08\u5982 "\u66F4\u65B0 SA \u7B56\u7565"\u3001"\u65B0\u589E FAQ \u6761\u76EE"\uFF09').option("--agent-name <name>", "Agent \u540D\u79F0\uFF08\u4FBF\u4E8E\u9605\u8BFB\uFF0C\u4E0D\u5F71\u54CD\u5173\u8054\uFF09").option("--type <repair_type>", "\u4FEE\u590D\u7C7B\u578B: update_sa | create_sa | knowledge_update | config_change | prompt_fix | sa_policy_update").option("--status <repair_status>", "\u4FEE\u590D\u72B6\u6001: pending | success | failed | partial").option("--duration <ms>", "\u4FEE\u590D\u8017\u65F6\uFF08\u6BEB\u79D2\uFF09").option("--result <json>", "\u7ED3\u6784\u5316\u4FEE\u590D\u7ED3\u679C\uFF08JSON\uFF09\uFF0C\u542B failure_type\u3001root_component\u3001diagnosis_reasoning\u3001fix_reasoning\u3001changes \u7B49\u5B57\u6BB5").option("--workspace <workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").action(async (opts) => {
|
|
1845
1973
|
try {
|
|
1846
1974
|
const data = await createRepairRecord({
|
|
1847
1975
|
issue_id: opts.issue,
|
|
@@ -1860,7 +1988,7 @@ function registerRepairRecordCommand(program2) {
|
|
|
1860
1988
|
process.exit(toExitCode(err));
|
|
1861
1989
|
}
|
|
1862
1990
|
});
|
|
1863
|
-
repairRecord.command("update").description("\u66F4\u65B0\u4FEE\u590D\u8BB0\u5F55").argument("<record_id>", "\u4FEE\u590D\u8BB0\u5F55 ID").requiredOption("--data <json>", "JSON \u6570\u636E\u6216 @\u6587\u4EF6\u8DEF\u5F84").action(async (recordId, opts) => {
|
|
1991
|
+
repairRecord.command("update").description("\u66F4\u65B0\u4FEE\u590D\u8BB0\u5F55\u7684\u72B6\u6001\u6216\u7ED3\u679C\u3002\u53EF\u66F4\u65B0: repair_action\u3001repair_result\uFF08JSON\uFF09\u3001repair_type\u3001repair_status\u3001duration_ms").argument("<record_id>", "\u4FEE\u590D\u8BB0\u5F55 ID\uFF08\u4ECE repair-record list \u8FD4\u56DE\u7684 record_id \u83B7\u53D6\uFF09").requiredOption("--data <json>", "JSON \u6570\u636E\u6216 @\u6587\u4EF6\u8DEF\u5F84\u3002\u53EF\u66F4\u65B0\u5B57\u6BB5: repair_action\u3001repair_result\uFF08JSON \u5BF9\u8C61\uFF09\u3001repair_type\u3001repair_status\uFF08pending|success|failed|partial\uFF09\u3001duration_ms").action(async (recordId, opts) => {
|
|
1864
1992
|
try {
|
|
1865
1993
|
const body = parseDataOption(opts.data);
|
|
1866
1994
|
const data = await updateRepairRecord(recordId, body);
|
|
@@ -1876,13 +2004,21 @@ function registerRepairRecordCommand(program2) {
|
|
|
1876
2004
|
var require2 = createRequire(import.meta.url);
|
|
1877
2005
|
var { version } = require2("../package.json");
|
|
1878
2006
|
var program = new Command();
|
|
1879
|
-
program.name("cs-cli").description(
|
|
2007
|
+
program.name("cs-cli").description(
|
|
2008
|
+
"BetterYeah AI \u5BA2\u670D\u5E73\u53F0 CLI\u3002\u6838\u5FC3\u6982\u5FF5\uFF1Aworkspace\uFF08\u5DE5\u4F5C\u7A7A\u95F4\uFF09\u2192 agent\uFF08AI \u5BA2\u670D\u673A\u5668\u4EBA\uFF09\u2192 SA/product/FAQ\uFF08\u77E5\u8BC6\u914D\u7F6E\uFF09\u2192 issue\uFF08\u5DE5\u5355\uFF09\u2192 debug\uFF08\u8C03\u8BD5\u9A8C\u8BC1\uFF09\u2192 monitor\uFF08\u8FD0\u8425\u76D1\u63A7\uFF09\u2192 repair-record\uFF08\u4FEE\u590D\u5BA1\u8BA1\uFF09\u3002\u6240\u6709\u547D\u4EE4\u9ED8\u8BA4\u8F93\u51FA JSON\uFF0C\u8FFD\u52A0 --table \u53EF\u5207\u6362\u4E3A\u4EBA\u7C7B\u53EF\u8BFB\u8868\u683C"
|
|
2009
|
+
).version(version).option("--table", "\u4EE5\u8868\u683C\u5F62\u5F0F\u8F93\u51FA\uFF08\u9ED8\u8BA4 JSON\uFF09\u3002\u4EBA\u5DE5\u67E5\u770B\u65F6\u4F7F\u7528", false).option("--workspace <id>", "\u4E34\u65F6\u8986\u76D6\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4 ID\uFF0C\u4E0D\u4FEE\u6539\u6301\u4E45\u5316\u914D\u7F6E").option("--timeout <ms>", "\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C\u590D\u6742 Agent \u56DE\u590D\u5EFA\u8BAE\u8C03\u9AD8", "20000");
|
|
1880
2010
|
program.hook("preAction", (thisCommand) => {
|
|
1881
2011
|
const opts = thisCommand.opts();
|
|
1882
2012
|
if (opts.workspace) {
|
|
1883
2013
|
setRuntimeWorkspaceId(opts.workspace);
|
|
1884
2014
|
}
|
|
1885
2015
|
});
|
|
2016
|
+
program.hook("postAction", async () => {
|
|
2017
|
+
const message = await checkForUpdate(version);
|
|
2018
|
+
if (message) {
|
|
2019
|
+
outputInfo(message);
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
1886
2022
|
registerAuthCommand(program);
|
|
1887
2023
|
registerConfigCommand(program);
|
|
1888
2024
|
registerWorkspaceCommand(program);
|