@bty/customer-service-cli 0.1.4 → 0.1.6
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 +135 -5
- package/dist/bin.js +655 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,50 @@ cs-cli agent list
|
|
|
65
65
|
| `--timeout <ms>` | 请求超时时间(毫秒) | `20000` |
|
|
66
66
|
|
|
67
67
|
|
|
68
|
+
## 本地配置 (`.cs-cli.json`)
|
|
69
|
+
|
|
70
|
+
支持在项目目录下放置 `.cs-cli.json` 文件,为不同项目配置不同的工作空间。
|
|
71
|
+
|
|
72
|
+
### 工作空间优先级
|
|
73
|
+
|
|
74
|
+
| 优先级 | 来源 | 说明 |
|
|
75
|
+
| --- | ----------------------- | ---------- |
|
|
76
|
+
| 1 | `--workspace <id>` 参数 | 命令行临时覆盖 |
|
|
77
|
+
| 2 | `.cs-cli.json` (本地配置) | 当前目录或祖先目录 |
|
|
78
|
+
| 3 | `~/.cs-cli/config.json` | 全局默认配置 |
|
|
79
|
+
|
|
80
|
+
### 使用方式
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# 在项目目录下初始化本地配置
|
|
84
|
+
cs-cli config init
|
|
85
|
+
|
|
86
|
+
# 设置工作空间(自动写入本地 .cs-cli.json)
|
|
87
|
+
cs-cli config set-workspace <workspace_id>
|
|
88
|
+
|
|
89
|
+
# 强制写入全局配置
|
|
90
|
+
cs-cli config set-workspace <workspace_id> --global
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
CLI 从当前目录向上查找 `.cs-cli.json`,找到第一个即使用其中的 `workspaceId`。
|
|
94
|
+
|
|
95
|
+
`.cs-cli.json` 格式:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"workspaceId": "ws-abc123",
|
|
100
|
+
"workspaceName": "某客户项目"
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `set-workspace` 写入规则
|
|
105
|
+
|
|
106
|
+
- 当前目录或祖先目录存在 `.cs-cli.json` → 写入本地配置
|
|
107
|
+
- 不存在 `.cs-cli.json` → 写入全局配置
|
|
108
|
+
- 使用 `--global` → 强制写入全局配置
|
|
109
|
+
|
|
110
|
+
每次写入后会提示写入的目标路径。
|
|
111
|
+
|
|
68
112
|
## 命令速查表
|
|
69
113
|
|
|
70
114
|
### 认证 (`auth`)
|
|
@@ -80,11 +124,12 @@ cs-cli agent list
|
|
|
80
124
|
### 配置 (`config`)
|
|
81
125
|
|
|
82
126
|
|
|
83
|
-
| 命令 | 说明
|
|
84
|
-
| ----------------------------------------------------------- |
|
|
85
|
-
| `config set --cs-api <url> --auth-api <url> --ai-api <url>` | 设置 API 地址
|
|
86
|
-
| `config get` |
|
|
87
|
-
| `config
|
|
127
|
+
| 命令 | 说明 |
|
|
128
|
+
| ----------------------------------------------------------- | ---------------------------- |
|
|
129
|
+
| `config set --cs-api <url> --auth-api <url> --ai-api <url>` | 设置 API 地址 |
|
|
130
|
+
| `config get` | 查看当前配置(含全局和本地) |
|
|
131
|
+
| `config init` | 在当前目录初始化本地配置 (`.cs-cli.json`) |
|
|
132
|
+
| `config set-workspace <workspace_id> [--global]` | 设置默认工作空间 |
|
|
88
133
|
|
|
89
134
|
|
|
90
135
|
### 工作空间 (`workspace`)
|
|
@@ -193,6 +238,82 @@ cs-cli product update-sku --agent <id> --sku "颜色分类:粉红" --update '{"
|
|
|
193
238
|
|
|
194
239
|
`debug ask` 会自动创建调试会话、发送消息、轮询等待 Agent 回复,默认最大等待 30 秒。支持 `--messages` 传入完整消息列表(JSON 或 @文件)重放 issue 对话。
|
|
195
240
|
|
|
241
|
+
### 修复记录 (`repair-record`)
|
|
242
|
+
|
|
243
|
+
| 命令 | 说明 |
|
|
244
|
+
| --- | --- |
|
|
245
|
+
| `repair-record list [--issue <工单ID>] [--agent <AgentID>] [--workspace <工作空间ID>] [--page N] [--page-size N]` | 列出修复记录 |
|
|
246
|
+
| `repair-record create --issue <工单ID> --agent <AgentID> --action <修复动作> [--agent-name <名称>] [--type <类型>] [--status <状态>] [--duration <毫秒>] [--result <JSON>] [--workspace <工作空间ID>]` | 创建修复记录 |
|
|
247
|
+
| `repair-record update <record_id> --data <json\|@file>` | 更新修复记录 |
|
|
248
|
+
|
|
249
|
+
`--status` 可选值:`pending`、`success`、`failed`、`partial`。
|
|
250
|
+
|
|
251
|
+
`repair-record update` 的 `--data` 支持的字段:`repair_action`、`repair_result`(JSON 对象)、`repair_type`、`repair_status`、`duration_ms`。
|
|
252
|
+
|
|
253
|
+
#### `repair_result` 结构
|
|
254
|
+
|
|
255
|
+
`--result` 或 `--data` 中的 `repair_result` 字段应为结构化 JSON,用于记录 AI 修复的完整推理过程,支持未来 AI 自我进化。
|
|
256
|
+
|
|
257
|
+
| 字段 | 类型 | 说明 |
|
|
258
|
+
| --- | --- | --- |
|
|
259
|
+
| `failure_type` | string | 问题分类: `wrong_answer` / `missing_answer` / `hallucination` / `wrong_routing` / `slow_response` / `other` |
|
|
260
|
+
| `root_component` | string | 归因组件: `sa_policy` / `faq` / `product_knowledge` / `customer_config` / `prompt` / `multiple` / `unknown` |
|
|
261
|
+
| `input` | string | 触发问题的用户输入 |
|
|
262
|
+
| `expected` | string | 期望的正确回复 |
|
|
263
|
+
| `actual` | string | 实际的错误回复 |
|
|
264
|
+
| **`diagnosis_reasoning`** | string | **AI 的诊断推理过程**:排查了什么、怎么定位根因、排除了哪些可能性(最高价值字段) |
|
|
265
|
+
| `diagnosis_confidence` | string | 诊断置信度: `high` / `medium` / `low` |
|
|
266
|
+
| `hypotheses_considered` | array | 考虑过的假设列表,每项含 `hypothesis`、`evidence_for`、`evidence_against`、`verdict` |
|
|
267
|
+
| `fix_strategy` | string | 修复策略: `create_sa` / `update_sa` / `delete_sa` / `update_faq` / `add_faq` / `update_product` / `update_config` / `multi_step` |
|
|
268
|
+
| **`fix_reasoning`** | string | **AI 的修复决策推理**:为什么选这个方案、为什么不选其他方案、预期风险和收益 |
|
|
269
|
+
| `alternatives_rejected` | array | 被否决的方案列表,每项含 `approach`、`reason` |
|
|
270
|
+
| `changes` | array | 变更快照,每项含 `component`、`action`、`target_id`、`before`、`after` |
|
|
271
|
+
| `target_fixed` | boolean | 目标问题是否修复 |
|
|
272
|
+
| `regression_summary` | string | 回归验证结果摘要 |
|
|
273
|
+
| `retry_history` | array | 重试记录,每项含 `round`、`what_failed`、`lesson`、`adjustment` |
|
|
274
|
+
| `duration_ms` | number | 修复总耗时(毫秒) |
|
|
275
|
+
| `repair_status` | string | 最终状态: `success` / `failed` / `partial` |
|
|
276
|
+
| `resolved_date` | string | 修复完成时间(ISO 格式) |
|
|
277
|
+
|
|
278
|
+
**加粗的两个字段**(`diagnosis_reasoning` 和 `fix_reasoning`)是对 AI 自我进化价值最大的:没有它们只能做模式匹配,有了它们才能做推理。
|
|
279
|
+
|
|
280
|
+
### 运营监控 (`monitor`)
|
|
281
|
+
|
|
282
|
+
直接调用 `/v1/operation` 底层接口,返回原始数据,由调用方决定如何聚合统计。
|
|
283
|
+
|
|
284
|
+
#### Agent 生命周期
|
|
285
|
+
|
|
286
|
+
| 命令 | 说明 |
|
|
287
|
+
| --- | --- |
|
|
288
|
+
| `monitor agents [--page N] [--page-size N]` | Agent 生命周期列表(含构建进度、会话统计等原始数据) |
|
|
289
|
+
|
|
290
|
+
#### 监控工单
|
|
291
|
+
|
|
292
|
+
| 命令 | 说明 |
|
|
293
|
+
| --- | --- |
|
|
294
|
+
| `monitor tickets list [--agent <id>] [--status <状态>] [--severity <级别>]` | 列出监控工单 |
|
|
295
|
+
| `monitor tickets delete <ticket_id>` | 删除监控工单 |
|
|
296
|
+
|
|
297
|
+
#### 监控快照
|
|
298
|
+
|
|
299
|
+
| 命令 | 说明 |
|
|
300
|
+
| --- | --- |
|
|
301
|
+
| `monitor snapshots hourly --agent <id> --start <ISO> --end <ISO>` | 查询小时快照 |
|
|
302
|
+
| `monitor snapshots daily --agent <id> --start <日期> --end <日期>` | 查询日快照 |
|
|
303
|
+
| `monitor snapshots daily-range --agent <id> --start <日期> --end <日期>` | 查询日快照范围(含趋势) |
|
|
304
|
+
|
|
305
|
+
#### Agent 运营统计
|
|
306
|
+
|
|
307
|
+
| 命令 | 说明 |
|
|
308
|
+
| --- | --- |
|
|
309
|
+
| `monitor statistics [--start <ISO> --end <ISO>] [--page N] [--page-size N]` | Agent 运营统计(会话量、转人工率、响应时间等) |
|
|
310
|
+
|
|
311
|
+
#### 运营工作空间
|
|
312
|
+
|
|
313
|
+
| 命令 | 说明 |
|
|
314
|
+
| --- | --- |
|
|
315
|
+
| `monitor workspaces [--has-agent] [--page N] [--page-size N]` | 运营工作空间列表(含合同、客户信息) |
|
|
316
|
+
|
|
196
317
|
## 输出格式
|
|
197
318
|
|
|
198
319
|
默认输出 JSON:
|
|
@@ -264,5 +385,14 @@ cs-cli faq add --agent <id> --file "常见问题" --questions "怎么退款,如
|
|
|
264
385
|
|
|
265
386
|
# 重放对话测试 Agent
|
|
266
387
|
cs-cli debug ask --agent <id> --messages @conversation.json
|
|
388
|
+
|
|
389
|
+
# 列出某工单的修复记录
|
|
390
|
+
cs-cli repair-record list --issue <issue_id>
|
|
391
|
+
|
|
392
|
+
# 创建修复记录
|
|
393
|
+
cs-cli repair-record create --issue <issue_id> --agent <agent_id> --action "更新 SA 策略"
|
|
394
|
+
|
|
395
|
+
# 更新修复记录状态
|
|
396
|
+
cs-cli repair-record update <record_id> --data '{"repair_status":"success","duration_ms":1200}'
|
|
267
397
|
```
|
|
268
398
|
|
package/dist/bin.js
CHANGED
|
@@ -61,6 +61,9 @@ function outputError(code, message) {
|
|
|
61
61
|
};
|
|
62
62
|
process.stdout.write(JSON.stringify(response, null, 2));
|
|
63
63
|
}
|
|
64
|
+
function outputInfo(message) {
|
|
65
|
+
process.stderr.write(message + "\n");
|
|
66
|
+
}
|
|
64
67
|
|
|
65
68
|
// src/client/auth-api.ts
|
|
66
69
|
import CryptoJS from "crypto-js";
|
|
@@ -73,6 +76,7 @@ import path2 from "path";
|
|
|
73
76
|
import fs from "fs";
|
|
74
77
|
import path from "path";
|
|
75
78
|
import os from "os";
|
|
79
|
+
var LOCAL_CONFIG_FILENAME = ".cs-cli.json";
|
|
76
80
|
function getConfigDir() {
|
|
77
81
|
return process.env.CS_CLI_HOME || path.join(os.homedir(), ".cs-cli");
|
|
78
82
|
}
|
|
@@ -95,6 +99,55 @@ function writeConfig(config) {
|
|
|
95
99
|
JSON.stringify(merged, null, 2)
|
|
96
100
|
);
|
|
97
101
|
}
|
|
102
|
+
function findLocalConfigPath() {
|
|
103
|
+
let dir = process.cwd();
|
|
104
|
+
const root = path.parse(dir).root;
|
|
105
|
+
while (true) {
|
|
106
|
+
const candidate = path.join(dir, LOCAL_CONFIG_FILENAME);
|
|
107
|
+
if (fs.existsSync(candidate)) {
|
|
108
|
+
return candidate;
|
|
109
|
+
}
|
|
110
|
+
const parent = path.dirname(dir);
|
|
111
|
+
if (parent === dir || parent === root) {
|
|
112
|
+
const rootCandidate = path.join(root, LOCAL_CONFIG_FILENAME);
|
|
113
|
+
if (fs.existsSync(rootCandidate)) {
|
|
114
|
+
return rootCandidate;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
dir = parent;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function readLocalConfig() {
|
|
122
|
+
const configPath = findLocalConfigPath();
|
|
123
|
+
if (!configPath) return null;
|
|
124
|
+
try {
|
|
125
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
126
|
+
return JSON.parse(content);
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function writeLocalConfig(config, targetPath) {
|
|
132
|
+
const filePath = targetPath ?? findLocalConfigPath() ?? path.join(process.cwd(), LOCAL_CONFIG_FILENAME);
|
|
133
|
+
let existing = {};
|
|
134
|
+
try {
|
|
135
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
136
|
+
existing = JSON.parse(content);
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
const merged = { ...existing, ...config };
|
|
140
|
+
fs.writeFileSync(filePath, JSON.stringify(merged, null, 2) + "\n");
|
|
141
|
+
return filePath;
|
|
142
|
+
}
|
|
143
|
+
function initLocalConfig() {
|
|
144
|
+
const filePath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME);
|
|
145
|
+
if (fs.existsSync(filePath)) {
|
|
146
|
+
return filePath;
|
|
147
|
+
}
|
|
148
|
+
fs.writeFileSync(filePath, JSON.stringify({}, null, 2) + "\n");
|
|
149
|
+
return filePath;
|
|
150
|
+
}
|
|
98
151
|
|
|
99
152
|
// src/utils/credentials.ts
|
|
100
153
|
function getCredentialsPath() {
|
|
@@ -214,6 +267,7 @@ function createRequest(globalTimeout) {
|
|
|
214
267
|
var DEFAULT_CS_API_URL = "https://customer-servhub-api.betteryeah.com";
|
|
215
268
|
var DEFAULT_AUTH_API_URL = "https://ai-api.betteryeah.com";
|
|
216
269
|
var DEFAULT_AI_API_URL = "https://ai-api.betteryeah.com";
|
|
270
|
+
var DEFAULT_CUSTOMER_AGENT_API_URL = "https://customer-agent.bantouyan.com";
|
|
217
271
|
function getCustomerServiceUrl() {
|
|
218
272
|
const config = readConfig();
|
|
219
273
|
return config?.customerServiceApiUrl ?? DEFAULT_CS_API_URL;
|
|
@@ -226,13 +280,18 @@ function getAiApiUrl() {
|
|
|
226
280
|
const config = readConfig();
|
|
227
281
|
return config?.aiApiUrl ?? DEFAULT_AI_API_URL;
|
|
228
282
|
}
|
|
229
|
-
function
|
|
283
|
+
function getCustomerAgentUrl() {
|
|
230
284
|
const config = readConfig();
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return
|
|
285
|
+
return config?.customerAgentApiUrl ?? DEFAULT_CUSTOMER_AGENT_API_URL;
|
|
286
|
+
}
|
|
287
|
+
function getWorkspaceId(overrideWorkspaceId) {
|
|
288
|
+
const runtimeId = overrideWorkspaceId ?? getRuntimeWorkspaceId();
|
|
289
|
+
if (runtimeId) return runtimeId;
|
|
290
|
+
const localConfig = readLocalConfig();
|
|
291
|
+
if (localConfig?.workspaceId) return localConfig.workspaceId;
|
|
292
|
+
const globalConfig = readConfig();
|
|
293
|
+
if (globalConfig?.defaultWorkspaceId) return globalConfig.defaultWorkspaceId;
|
|
294
|
+
throw new APIError(1, "\u672A\u8BBE\u7F6E\u5DE5\u4F5C\u7A7A\u95F4\uFF0C\u8BF7\u8FD0\u884C: cs-cli config set-workspace <id>");
|
|
236
295
|
}
|
|
237
296
|
|
|
238
297
|
// src/client/auth-api.ts
|
|
@@ -337,27 +396,56 @@ async function listWorkspaces() {
|
|
|
337
396
|
// src/commands/config.ts
|
|
338
397
|
function registerConfigCommand(program2) {
|
|
339
398
|
const config = program2.command("config").description("\u914D\u7F6E\u7BA1\u7406");
|
|
340
|
-
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").action((opts) => {
|
|
399
|
+
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) => {
|
|
341
400
|
const updates = {};
|
|
342
401
|
if (opts.csApi) updates.customerServiceApiUrl = opts.csApi;
|
|
343
402
|
if (opts.authApi) updates.authApiUrl = opts.authApi;
|
|
344
403
|
if (opts.aiApi) updates.aiApiUrl = opts.aiApi;
|
|
404
|
+
if (opts.agentApi) updates.customerAgentApiUrl = opts.agentApi;
|
|
345
405
|
writeConfig(updates);
|
|
346
406
|
formatOutput({ success: true, data: readConfig() }, program2.opts().table);
|
|
347
407
|
});
|
|
348
408
|
config.command("get").description("\u67E5\u770B\u5F53\u524D\u914D\u7F6E").action(() => {
|
|
349
|
-
const
|
|
350
|
-
|
|
409
|
+
const globalCfg = readConfig() ?? {};
|
|
410
|
+
const localCfg = readLocalConfig();
|
|
411
|
+
const localPath = findLocalConfigPath();
|
|
412
|
+
const data = {
|
|
413
|
+
global: globalCfg,
|
|
414
|
+
local: localCfg ? { path: localPath, config: localCfg } : null
|
|
415
|
+
};
|
|
416
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
417
|
+
});
|
|
418
|
+
config.command("init").description("\u5728\u5F53\u524D\u76EE\u5F55\u521D\u59CB\u5316\u672C\u5730\u914D\u7F6E (.cs-cli.json)").action(() => {
|
|
419
|
+
const filePath = initLocalConfig();
|
|
420
|
+
outputInfo(`\u672C\u5730\u914D\u7F6E\u5DF2\u521D\u59CB\u5316: ${filePath}`);
|
|
421
|
+
formatOutput({ success: true, data: { path: filePath } }, program2.opts().table);
|
|
351
422
|
});
|
|
352
|
-
config.command("set-workspace").description("\u8BBE\u7F6E\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4").argument("<workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").action(async (workspaceId) => {
|
|
423
|
+
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) => {
|
|
424
|
+
const useLocal = !opts.global && findLocalConfigPath() !== null;
|
|
353
425
|
try {
|
|
354
|
-
const
|
|
355
|
-
const matched =
|
|
426
|
+
const workspaces2 = await listWorkspaces();
|
|
427
|
+
const matched = workspaces2.find((ws) => ws.id === workspaceId);
|
|
356
428
|
const name = matched?.name;
|
|
357
|
-
|
|
358
|
-
|
|
429
|
+
if (useLocal) {
|
|
430
|
+
const writtenPath = writeLocalConfig({ workspaceId, workspaceName: name });
|
|
431
|
+
outputInfo(`\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u8BBE\u7F6E: ${name ?? workspaceId}
|
|
432
|
+
\u2192 \u5199\u5165: ${writtenPath}`);
|
|
433
|
+
} else {
|
|
434
|
+
writeConfig({ defaultWorkspaceId: workspaceId, defaultWorkspaceName: name });
|
|
435
|
+
outputInfo(`\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u8BBE\u7F6E: ${name ?? workspaceId}
|
|
436
|
+
\u2192 \u5199\u5165: \u5168\u5C40\u914D\u7F6E`);
|
|
437
|
+
}
|
|
438
|
+
formatOutput({ success: true, data: { workspaceId, workspaceName: name ?? "(unknown)", target: useLocal ? "local" : "global" } }, program2.opts().table);
|
|
359
439
|
} catch (err) {
|
|
360
|
-
|
|
440
|
+
if (useLocal) {
|
|
441
|
+
const writtenPath = writeLocalConfig({ workspaceId });
|
|
442
|
+
outputInfo(`\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u8BBE\u7F6E: ${workspaceId}
|
|
443
|
+
\u2192 \u5199\u5165: ${writtenPath}`);
|
|
444
|
+
} else {
|
|
445
|
+
writeConfig({ defaultWorkspaceId: workspaceId });
|
|
446
|
+
outputInfo(`\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u8BBE\u7F6E: ${workspaceId}
|
|
447
|
+
\u2192 \u5199\u5165: \u5168\u5C40\u914D\u7F6E`);
|
|
448
|
+
}
|
|
361
449
|
outputError(err.statusCode ?? 1, err.message);
|
|
362
450
|
process.exit(toExitCode(err));
|
|
363
451
|
}
|
|
@@ -1206,6 +1294,556 @@ function registerDebugCommand(program2) {
|
|
|
1206
1294
|
});
|
|
1207
1295
|
}
|
|
1208
1296
|
|
|
1297
|
+
// src/client/monitor-api.ts
|
|
1298
|
+
var MONITOR_PATH_PREFIX = "/v1/operation";
|
|
1299
|
+
async function listAgentLifecycle(opts) {
|
|
1300
|
+
const request = createRequest();
|
|
1301
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/agent-lifecycle`, {
|
|
1302
|
+
method: "GET",
|
|
1303
|
+
query: { page: opts.page ?? 1, page_size: opts.pageSize ?? 200 }
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
async function listTickets(opts) {
|
|
1307
|
+
const request = createRequest();
|
|
1308
|
+
const query = {
|
|
1309
|
+
page: opts.page ?? 1,
|
|
1310
|
+
page_size: opts.pageSize ?? 200
|
|
1311
|
+
};
|
|
1312
|
+
if (opts.status) query.status = opts.status;
|
|
1313
|
+
if (opts.severity) query.severity = opts.severity;
|
|
1314
|
+
if (opts.agentId) query.config_id = opts.agentId;
|
|
1315
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/tickets`, {
|
|
1316
|
+
method: "GET",
|
|
1317
|
+
query
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
async function deleteTicket(ticketId) {
|
|
1321
|
+
const request = createRequest();
|
|
1322
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/tickets/${ticketId}`, {
|
|
1323
|
+
method: "DELETE"
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
async function listHourlySnapshots(opts) {
|
|
1327
|
+
const request = createRequest();
|
|
1328
|
+
const query = {};
|
|
1329
|
+
if (opts.workspaceId) query.workspace_id = opts.workspaceId;
|
|
1330
|
+
if (opts.agentId) query.agent_id = opts.agentId;
|
|
1331
|
+
if (opts.startTime) query.start_time = opts.startTime;
|
|
1332
|
+
if (opts.endTime) query.end_time = opts.endTime;
|
|
1333
|
+
if (opts.page) query.page = opts.page;
|
|
1334
|
+
if (opts.pageSize) query.page_size = opts.pageSize;
|
|
1335
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/snapshots/hourly`, {
|
|
1336
|
+
method: "GET",
|
|
1337
|
+
query
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
async function listDailySnapshots(opts) {
|
|
1341
|
+
const request = createRequest();
|
|
1342
|
+
const query = {};
|
|
1343
|
+
if (opts.workspaceId) query.workspace_id = opts.workspaceId;
|
|
1344
|
+
if (opts.agentId) query.agent_id = opts.agentId;
|
|
1345
|
+
if (opts.startDate) query.start_date = opts.startDate;
|
|
1346
|
+
if (opts.endDate) query.end_date = opts.endDate;
|
|
1347
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/snapshots/daily`, {
|
|
1348
|
+
method: "GET",
|
|
1349
|
+
query
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
async function listDailySnapshotsRange(opts) {
|
|
1353
|
+
const request = createRequest();
|
|
1354
|
+
const query = {};
|
|
1355
|
+
if (opts.workspaceId) query.workspace_id = opts.workspaceId;
|
|
1356
|
+
if (opts.agentId) query.agent_id = opts.agentId;
|
|
1357
|
+
if (opts.startDate) query.start_date = opts.startDate;
|
|
1358
|
+
if (opts.endDate) query.end_date = opts.endDate;
|
|
1359
|
+
if (opts.page) query.page = opts.page;
|
|
1360
|
+
if (opts.pageSize) query.page_size = opts.pageSize ?? 200;
|
|
1361
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/snapshots/daily/range`, {
|
|
1362
|
+
method: "GET",
|
|
1363
|
+
query
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
async function listAgentStatistics(opts) {
|
|
1367
|
+
const request = createRequest();
|
|
1368
|
+
const query = {
|
|
1369
|
+
page: opts.page ?? 1,
|
|
1370
|
+
page_size: opts.pageSize ?? 100
|
|
1371
|
+
};
|
|
1372
|
+
if (opts.startDate) query.start_date = opts.startDate;
|
|
1373
|
+
if (opts.endDate) query.end_date = opts.endDate;
|
|
1374
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/customer-agents/statistics`, {
|
|
1375
|
+
method: "GET",
|
|
1376
|
+
query
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
async function listOperationWorkspaces(opts) {
|
|
1380
|
+
const request = createRequest();
|
|
1381
|
+
const query = {
|
|
1382
|
+
page: opts.page ?? 1,
|
|
1383
|
+
page_size: opts.pageSize ?? 200
|
|
1384
|
+
};
|
|
1385
|
+
if (opts.hasAgent !== void 0) query.has_agent = String(opts.hasAgent);
|
|
1386
|
+
return request(getCustomerServiceUrl(), `${MONITOR_PATH_PREFIX}/workspaces/list`, {
|
|
1387
|
+
method: "GET",
|
|
1388
|
+
query
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/lib/monitor-field-defs.ts
|
|
1393
|
+
var agents = {
|
|
1394
|
+
resource: "agents",
|
|
1395
|
+
command: "monitor agents",
|
|
1396
|
+
apiPath: "/v1/operation/agent-lifecycle",
|
|
1397
|
+
description: "Agent \u751F\u547D\u5468\u671F\u5217\u8868\uFF0C\u5305\u542B\u6784\u5EFA\u8FDB\u5EA6\u3001\u4F1A\u8BDD\u7EDF\u8BA1\u3001\u5546\u54C1\u5B66\u4E60\u72B6\u6001\u7B49\u5168\u91CF\u6570\u636E",
|
|
1398
|
+
fields: [
|
|
1399
|
+
{ field: "config_id", type: "string", description: "Agent \u914D\u7F6E ID" },
|
|
1400
|
+
{ field: "config_name", type: "string", description: "Agent \u540D\u79F0" },
|
|
1401
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1402
|
+
{ field: "workspace.workspace_name", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u540D\u79F0" },
|
|
1403
|
+
{ field: "workspace.user_name", type: "string", description: "\u7528\u6237\u540D" },
|
|
1404
|
+
{ field: "workspace.phone", type: "string", description: "\u624B\u673A\u53F7" },
|
|
1405
|
+
{ field: "workspace.industry", type: "string", description: "\u884C\u4E1A" },
|
|
1406
|
+
{ field: "workspace.shop_name", type: "string", description: "\u5E97\u94FA\u540D" },
|
|
1407
|
+
{ field: "workspace.expired_time", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u8FC7\u671F\u65F6\u95F4" },
|
|
1408
|
+
{ field: "workspace.activate_time", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u6FC0\u6D3B\u65F6\u95F4" },
|
|
1409
|
+
{ field: "workspace.status", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u72B6\u6001" },
|
|
1410
|
+
{ field: "workspace.sales_channel", type: "string", description: "\u9500\u552E\u6E20\u9053" },
|
|
1411
|
+
{ field: "channel", type: "string", description: "\u63A5\u5165\u6E20\u9053\uFF08qianniu/pinduoduo/jingdong/douyin\uFF09" },
|
|
1412
|
+
{ field: "industry", type: "string", description: "\u884C\u4E1A\u5206\u7C7B\uFF08fashion/digital/home/baby/health/sports \u7B49\uFF09" },
|
|
1413
|
+
{ field: "current_phase", type: "string", description: "\u5F53\u524D\u751F\u547D\u5468\u671F\u9636\u6BB5\uFF08agent_creation/learning/plugin_sync/evaluation/operating\uFF09" },
|
|
1414
|
+
{ field: "phase_status", type: "string", description: "\u9636\u6BB5\u72B6\u6001\uFF08success/failed/processing/pending\uFF09" },
|
|
1415
|
+
{ field: "phase_entered_at", type: "string", description: "\u8FDB\u5165\u5F53\u524D\u9636\u6BB5\u7684\u65F6\u95F4" },
|
|
1416
|
+
{ field: "created_at", type: "string", description: "Agent \u521B\u5EFA\u65F6\u95F4" },
|
|
1417
|
+
{ field: "updated_at", type: "string", description: "\u6700\u540E\u66F4\u65B0\u65F6\u95F4" },
|
|
1418
|
+
{ field: "stats_synced_at", type: "string", description: "\u7EDF\u8BA1\u6570\u636E\u540C\u6B65\u65F6\u95F4" },
|
|
1419
|
+
{ field: "chat_history_stats.has_chat_history", type: "boolean", description: "\u662F\u5426\u5DF2\u5BFC\u5165\u804A\u5929\u8BB0\u5F55" },
|
|
1420
|
+
{ field: "chat_history_stats.latest_chat_record_count", type: "number", description: "\u5BFC\u5165\u7684\u804A\u5929\u8BB0\u5F55\u6570\u91CF" },
|
|
1421
|
+
{ field: "product_stats.total_count", type: "number", description: "\u5546\u54C1\u603B\u6570" },
|
|
1422
|
+
{ field: "product_stats.basic_count", type: "number", description: "\u57FA\u7840\u5B66\u4E60\u5B8C\u6210\u7684\u5546\u54C1\u6570" },
|
|
1423
|
+
{ field: "product_stats.deep_count", type: "number", description: "\u6DF1\u5EA6\u5B66\u4E60\u5B8C\u6210\u7684\u5546\u54C1\u6570" },
|
|
1424
|
+
{ field: "product_stats.failed_count", type: "number", description: "\u5B66\u4E60\u5931\u8D25\u7684\u5546\u54C1\u6570" },
|
|
1425
|
+
{ field: "product_stats.has_product", type: "boolean", description: "\u662F\u5426\u6709\u5546\u54C1\u6570\u636E" },
|
|
1426
|
+
{ field: "situation_action_stats.count", type: "number", description: "\u573A\u666F\u52A8\u4F5C(SA)\u6570\u91CF" },
|
|
1427
|
+
{ field: "qa_stats.segment_count", type: "number", description: "FAQ \u6761\u76EE\u6570\u91CF" },
|
|
1428
|
+
{ field: "chat_conversation_stats.total_conversations", type: "number", description: "\u7D2F\u8BA1\u4F1A\u8BDD\u603B\u6570" },
|
|
1429
|
+
{ field: "chat_conversation_stats.daily_avg_conversations", type: "number", description: "\u4ECA\u65E5\u4F1A\u8BDD\u6570" },
|
|
1430
|
+
{ field: "chat_conversation_stats.manual_takeover_rate", type: "number", description: "\u8F6C\u4EBA\u5DE5\u7387\uFF080~1 \u7684\u6BD4\u7387\uFF09" },
|
|
1431
|
+
{ field: "chat_record_stats.agent_response_count", type: "number", description: "Agent \u56DE\u590D\u6D88\u606F\u603B\u6570" },
|
|
1432
|
+
{ field: "issue_stats.total_count", type: "number", description: "\u5DE5\u5355\u603B\u6570" },
|
|
1433
|
+
{ field: "issue_stats.open_count", type: "number", description: "\u672A\u5173\u95ED\u5DE5\u5355\u6570" },
|
|
1434
|
+
{ field: "issue_stats.latest_created_at", type: "string|null", description: "\u6700\u65B0\u5DE5\u5355\u521B\u5EFA\u65F6\u95F4" },
|
|
1435
|
+
{ field: "robot_stats.robot_count", type: "number", description: "\u673A\u5668\u4EBA\u603B\u6570" },
|
|
1436
|
+
{ field: "robot_stats.running_count", type: "number", description: "\u8FD0\u884C\u4E2D\u7684\u673A\u5668\u4EBA\u6570" },
|
|
1437
|
+
{ field: "shop_id", type: "string", description: "\u5E97\u94FA ID" },
|
|
1438
|
+
{ field: "return_phase", type: "string|null", description: "\u56DE\u9000\u9636\u6BB5\uFF08\u5982\u6709\uFF09" },
|
|
1439
|
+
{ field: "phase_enter_counts", type: "object", description: "\u5404\u9636\u6BB5\u8FDB\u5165\u6B21\u6570\uFF08key \u4E3A\u9636\u6BB5\u540D\uFF0Cvalue \u4E3A\u6B21\u6570\uFF09" },
|
|
1440
|
+
{ field: "checkpoints", type: "object", description: "\u5404\u9636\u6BB5\u68C0\u67E5\u70B9\u72B6\u6001\uFF08\u542B last_status/ticket_emitted \u7B49\uFF09" }
|
|
1441
|
+
]
|
|
1442
|
+
};
|
|
1443
|
+
var tickets = {
|
|
1444
|
+
resource: "tickets",
|
|
1445
|
+
command: "monitor tickets list",
|
|
1446
|
+
apiPath: "/v1/operation/tickets",
|
|
1447
|
+
description: "\u76D1\u63A7\u5DE5\u5355\u5217\u8868\uFF0C\u7531\u5F02\u5E38\u68C0\u6D4B\u89C4\u5219\u81EA\u52A8\u751F\u6210",
|
|
1448
|
+
fields: [
|
|
1449
|
+
{ field: "ticket_id", type: "string", description: "\u5DE5\u5355 ID" },
|
|
1450
|
+
{ field: "id", type: "number", description: "\u5DE5\u5355\u5E8F\u53F7" },
|
|
1451
|
+
{ field: "config_id", type: "string", description: "Agent \u914D\u7F6E ID" },
|
|
1452
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1453
|
+
{ field: "title", type: "string", description: "\u5DE5\u5355\u6807\u9898" },
|
|
1454
|
+
{ field: "status", type: "string", description: "\u72B6\u6001\uFF08open/in_progress/resolved/closed\uFF09" },
|
|
1455
|
+
{ field: "priority", type: "string", description: "\u4F18\u5148\u7EA7\uFF08P0/P1/P2/P3\uFF09" },
|
|
1456
|
+
{ field: "phase", type: "string", description: "\u6240\u5C5E\u9636\u6BB5" },
|
|
1457
|
+
{ field: "phase_status", type: "string|null", description: "\u9636\u6BB5\u72B6\u6001" },
|
|
1458
|
+
{ field: "assignee", type: "string|null", description: "\u6307\u6D3E\u4EBA" },
|
|
1459
|
+
{ field: "assignee_type", type: "string|null", description: "\u6307\u6D3E\u4EBA\u7C7B\u578B" },
|
|
1460
|
+
{ field: "solution", type: "string|null", description: "\u89E3\u51B3\u65B9\u6848" },
|
|
1461
|
+
{ field: "created_at", type: "string", description: "\u521B\u5EFA\u65F6\u95F4" },
|
|
1462
|
+
{ field: "updated_at", type: "string", description: "\u66F4\u65B0\u65F6\u95F4" },
|
|
1463
|
+
{ field: "expected_completion_time", type: "string|null", description: "\u9884\u8BA1\u5B8C\u6210\u65F6\u95F4" },
|
|
1464
|
+
{ field: "actual_completion_time", type: "string|null", description: "\u5B9E\u9645\u5B8C\u6210\u65F6\u95F4" },
|
|
1465
|
+
{ field: "payload.category", type: "string", description: "\u5DE5\u5355\u5206\u7C7B\uFF08\u6784\u5EFA\u671F/\u8FD0\u8425\u671F\uFF09" },
|
|
1466
|
+
{ field: "payload.severity", type: "string", description: "\u4E25\u91CD\u7EA7\u522B\uFF08critical/high/medium/low\uFF09" },
|
|
1467
|
+
{ field: "payload.ticket_key", type: "string", description: "\u5DE5\u5355\u53BB\u91CD key" },
|
|
1468
|
+
{ field: "payload.checks", type: "array", description: "\u89E6\u53D1\u7684\u68C0\u67E5\u9879\u5217\u8868" },
|
|
1469
|
+
{ field: "payload.agent", type: "object", description: "\u5173\u8054\u7684 Agent \u5FEB\u7167\u4FE1\u606F" }
|
|
1470
|
+
]
|
|
1471
|
+
};
|
|
1472
|
+
var statistics = {
|
|
1473
|
+
resource: "statistics",
|
|
1474
|
+
command: "monitor statistics",
|
|
1475
|
+
apiPath: "/v1/operation/customer-agents/statistics",
|
|
1476
|
+
description: "Agent \u8FD0\u8425\u7EDF\u8BA1\uFF0C\u542B\u4F1A\u8BDD\u91CF\u3001\u8F6C\u4EBA\u5DE5\u7387\u3001\u54CD\u5E94\u65F6\u95F4\u7B49\u6838\u5FC3\u6307\u6807",
|
|
1477
|
+
fields: [
|
|
1478
|
+
{ field: "config_id", type: "string", description: "Agent \u914D\u7F6E ID" },
|
|
1479
|
+
{ field: "config_name", type: "string", description: "Agent \u540D\u79F0" },
|
|
1480
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1481
|
+
{ field: "workspace_name", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u540D\u79F0" },
|
|
1482
|
+
{ field: "total_conversations", type: "number", description: "\u65F6\u95F4\u8303\u56F4\u5185\u603B\u4F1A\u8BDD\u6570" },
|
|
1483
|
+
{ field: "manual_takeover_conversations", type: "number", description: "\u8F6C\u4EBA\u5DE5\u4F1A\u8BDD\u6570" },
|
|
1484
|
+
{ field: "manual_takeover_rate", type: "number", description: "\u8F6C\u4EBA\u5DE5\u7387\uFF080~1\uFF09" },
|
|
1485
|
+
{ field: "avg_response_time", type: "number", description: "\u5E73\u5747\u54CD\u5E94\u65F6\u95F4\uFF08\u79D2\uFF09" },
|
|
1486
|
+
{ field: "chat_record_count", type: "number", description: "\u804A\u5929\u8BB0\u5F55\u6570" },
|
|
1487
|
+
{ field: "avg_conversation_rounds", type: "number", description: "\u5E73\u5747\u5BF9\u8BDD\u8F6E\u6B21" },
|
|
1488
|
+
{ field: "issue_count", type: "number", description: "\u5DE5\u5355\u603B\u6570" },
|
|
1489
|
+
{ field: "issue_resolved_count", type: "number", description: "\u5DF2\u89E3\u51B3\u5DE5\u5355\u6570" },
|
|
1490
|
+
{ field: "issue_unresolved_count", type: "number", description: "\u672A\u89E3\u51B3\u5DE5\u5355\u6570" },
|
|
1491
|
+
{ field: "exist_chat_history", type: "boolean", description: "\u662F\u5426\u6709\u804A\u5929\u8BB0\u5F55" },
|
|
1492
|
+
{ field: "exist_product_deep", type: "boolean", description: "\u662F\u5426\u6709\u6DF1\u5EA6\u5B66\u4E60\u5546\u54C1" },
|
|
1493
|
+
{ field: "exist_robot", type: "boolean", description: "\u662F\u5426\u914D\u7F6E\u4E86\u673A\u5668\u4EBA" },
|
|
1494
|
+
{ field: "exist_running_robot", type: "boolean", description: "\u662F\u5426\u6709\u8FD0\u884C\u4E2D\u7684\u673A\u5668\u4EBA" },
|
|
1495
|
+
{ field: "run_mode", type: "string", description: "\u8FD0\u884C\u6A21\u5F0F" },
|
|
1496
|
+
{ field: "robot_stats.robot_count", type: "number", description: "\u673A\u5668\u4EBA\u603B\u6570" },
|
|
1497
|
+
{ field: "robot_stats.running_count", type: "number", description: "\u8FD0\u884C\u4E2D\u673A\u5668\u4EBA\u6570" },
|
|
1498
|
+
{ field: "robot_stats.robots", type: "array", description: "\u673A\u5668\u4EBA\u8BE6\u60C5\u5217\u8868" },
|
|
1499
|
+
{ field: "icon", type: "string", description: "Agent \u56FE\u6807 URL" },
|
|
1500
|
+
{ field: "created_at", type: "string", description: "\u521B\u5EFA\u65F6\u95F4" }
|
|
1501
|
+
]
|
|
1502
|
+
};
|
|
1503
|
+
var hourly = {
|
|
1504
|
+
resource: "hourly",
|
|
1505
|
+
command: "monitor snapshots hourly",
|
|
1506
|
+
apiPath: "/v1/operation/snapshots/hourly",
|
|
1507
|
+
description: "\u5C0F\u65F6\u7EA7\u76D1\u63A7\u5FEB\u7167\uFF0C\u8BB0\u5F55\u6BCF\u5C0F\u65F6\u7684\u4F1A\u8BDD\u91CF\u3001\u8F6C\u4EBA\u5DE5\u3001\u9519\u8BEF\u7B49\u6307\u6807",
|
|
1508
|
+
fields: [
|
|
1509
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1510
|
+
{ field: "agent_id", type: "string", description: "Agent ID" },
|
|
1511
|
+
{ field: "hour_start", type: "string", description: "\u5C0F\u65F6\u8D77\u59CB\u65F6\u95F4\uFF08ISO\uFF09" },
|
|
1512
|
+
{ field: "session_count", type: "number", description: "\u8BE5\u5C0F\u65F6\u4F1A\u8BDD\u6570" },
|
|
1513
|
+
{ field: "active_user_count", type: "number|null", description: "\u6D3B\u8DC3\u7528\u6237\u6570" },
|
|
1514
|
+
{ field: "agent_reply_count", type: "number", description: "Agent \u56DE\u590D\u6570" },
|
|
1515
|
+
{ field: "transfer_to_human_count", type: "number", description: "\u8F6C\u4EBA\u5DE5\u6B21\u6570" },
|
|
1516
|
+
{ field: "transfer_to_human_rate", type: "number", description: "\u8F6C\u4EBA\u5DE5\u7387\uFF080~1\uFF09" },
|
|
1517
|
+
{ field: "fallback_count", type: "number|null", description: "\u515C\u5E95\u56DE\u590D\u6B21\u6570" },
|
|
1518
|
+
{ field: "fallback_rate", type: "number|null", description: "\u515C\u5E95\u7387\uFF080~1\uFF09" },
|
|
1519
|
+
{ field: "avg_turns", type: "number", description: "\u5E73\u5747\u5BF9\u8BDD\u8F6E\u6B21" },
|
|
1520
|
+
{ field: "error_count", type: "number", description: "\u9519\u8BEF\u6B21\u6570" },
|
|
1521
|
+
{ field: "avg_response_time_ms", type: "number", description: "\u5E73\u5747\u54CD\u5E94\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09" },
|
|
1522
|
+
{ field: "timeout_count", type: "number", description: "\u8D85\u65F6\u6B21\u6570" },
|
|
1523
|
+
{ field: "data_completeness", type: "number", description: "\u6570\u636E\u5B8C\u6574\u5EA6\uFF080~1\uFF09" }
|
|
1524
|
+
]
|
|
1525
|
+
};
|
|
1526
|
+
var daily = {
|
|
1527
|
+
resource: "daily",
|
|
1528
|
+
command: "monitor snapshots daily",
|
|
1529
|
+
apiPath: "/v1/operation/snapshots/daily",
|
|
1530
|
+
description: "\u65E5\u7EA7\u76D1\u63A7\u5FEB\u7167\uFF0C\u805A\u5408\u6BCF\u65E5\u6307\u6807\u5E76\u8BA1\u7B97\u5065\u5EB7\u5206\u6570\u548C\u8D8B\u52BF",
|
|
1531
|
+
fields: [
|
|
1532
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1533
|
+
{ field: "agent_id", type: "string", description: "Agent ID" },
|
|
1534
|
+
{ field: "date", type: "string", description: "\u65E5\u671F\uFF08YYYY-MM-DD\uFF09" },
|
|
1535
|
+
{ field: "daily_session_count", type: "number", description: "\u5F53\u65E5\u4F1A\u8BDD\u603B\u6570" },
|
|
1536
|
+
{ field: "daily_active_users", type: "number|null", description: "\u5F53\u65E5\u6D3B\u8DC3\u7528\u6237\u6570" },
|
|
1537
|
+
{ field: "daily_agent_reply_count", type: "number", description: "\u5F53\u65E5 Agent \u56DE\u590D\u6570" },
|
|
1538
|
+
{ field: "daily_transfer_count", type: "number", description: "\u5F53\u65E5\u8F6C\u4EBA\u5DE5\u6B21\u6570" },
|
|
1539
|
+
{ field: "daily_transfer_rate", type: "number", description: "\u5F53\u65E5\u8F6C\u4EBA\u5DE5\u7387\uFF080~1\uFF09" },
|
|
1540
|
+
{ field: "daily_error_count", type: "number", description: "\u5F53\u65E5\u9519\u8BEF\u6B21\u6570" },
|
|
1541
|
+
{ field: "daily_avg_turns", type: "number", description: "\u5F53\u65E5\u5E73\u5747\u5BF9\u8BDD\u8F6E\u6B21" },
|
|
1542
|
+
{ field: "daily_avg_response_ms", type: "number", description: "\u5F53\u65E5\u5E73\u5747\u54CD\u5E94\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09" },
|
|
1543
|
+
{ field: "daily_new_issue_count", type: "number|null", description: "\u5F53\u65E5\u65B0\u589E\u5DE5\u5355\u6570" },
|
|
1544
|
+
{ field: "daily_resolved_issue_count", type: "number|null", description: "\u5F53\u65E5\u89E3\u51B3\u5DE5\u5355\u6570" },
|
|
1545
|
+
{ field: "open_issue_count", type: "number|null", description: "\u5F53\u65E5\u672A\u5173\u95ED\u5DE5\u5355\u6570" },
|
|
1546
|
+
{ field: "peak_hour_sessions", type: "number|null", description: "\u5CF0\u503C\u5C0F\u65F6\u4F1A\u8BDD\u6570" },
|
|
1547
|
+
{ field: "zero_session_hours", type: "number|null", description: "\u96F6\u4F1A\u8BDD\u5C0F\u65F6\u6570" },
|
|
1548
|
+
{ field: "consecutive_zero_days", type: "number|null", description: "\u8FDE\u7EED\u96F6\u4F1A\u8BDD\u5929\u6570" },
|
|
1549
|
+
{ field: "daily_health_score", type: "number|null", description: "\u5F53\u65E5\u5065\u5EB7\u5206\u6570\uFF080~100\uFF09" },
|
|
1550
|
+
{ field: "health_grade", type: "string|null", description: "\u5065\u5EB7\u7B49\u7EA7\uFF08A/B/C/D/F\uFF09" },
|
|
1551
|
+
{ field: "health_analysis_summary", type: "string|null", description: "LLM \u751F\u6210\u7684\u5065\u5EB7\u5206\u6790\u6458\u8981" },
|
|
1552
|
+
{ field: "session_change_vs_yesterday", type: "number|null", description: "\u4F1A\u8BDD\u91CF\u65E5\u73AF\u6BD4\u53D8\u5316\u7387" },
|
|
1553
|
+
{ field: "transfer_rate_change_vs_yesterday", type: "number|null", description: "\u8F6C\u4EBA\u5DE5\u7387\u65E5\u73AF\u6BD4\u53D8\u5316\u7387" },
|
|
1554
|
+
{ field: "session_change_vs_last_week", type: "number|null", description: "\u4F1A\u8BDD\u91CF\u5468\u73AF\u6BD4\u53D8\u5316\u7387" },
|
|
1555
|
+
{ field: "transfer_rate_change_vs_last_week", type: "number|null", description: "\u8F6C\u4EBA\u5DE5\u7387\u5468\u73AF\u6BD4\u53D8\u5316\u7387" },
|
|
1556
|
+
{ field: "session_ma7", type: "number|null", description: "7 \u65E5\u4F1A\u8BDD\u79FB\u52A8\u5E73\u5747" },
|
|
1557
|
+
{ field: "session_ma30", type: "number|null", description: "30 \u65E5\u4F1A\u8BDD\u79FB\u52A8\u5E73\u5747" },
|
|
1558
|
+
{ field: "trend_direction", type: "string|null", description: "\u8D8B\u52BF\u65B9\u5411\uFF08up/down/stable\uFF09" },
|
|
1559
|
+
{ field: "data_quality_flag", type: "string", description: "\u6570\u636E\u8D28\u91CF\u6807\u8BB0" }
|
|
1560
|
+
]
|
|
1561
|
+
};
|
|
1562
|
+
var workspaces = {
|
|
1563
|
+
resource: "workspaces",
|
|
1564
|
+
command: "monitor workspaces",
|
|
1565
|
+
apiPath: "/v1/operation/workspaces/list",
|
|
1566
|
+
description: "\u8FD0\u8425\u5DE5\u4F5C\u7A7A\u95F4\u5217\u8868\uFF0C\u542B\u5BA2\u6237\u4FE1\u606F\u3001\u5408\u540C\u72B6\u6001\u3001\u76D1\u63A7\u9608\u503C\u914D\u7F6E",
|
|
1567
|
+
fields: [
|
|
1568
|
+
{ field: "workspace_id", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4 ID" },
|
|
1569
|
+
{ field: "workspace_name", type: "string", description: "\u5DE5\u4F5C\u7A7A\u95F4\u540D\u79F0" },
|
|
1570
|
+
{ field: "user_id", type: "string", description: "\u7528\u6237 ID" },
|
|
1571
|
+
{ field: "user_name", type: "string", description: "\u7528\u6237\u540D" },
|
|
1572
|
+
{ field: "phone", type: "string", description: "\u624B\u673A\u53F7" },
|
|
1573
|
+
{ field: "industry", type: "string", description: "\u884C\u4E1A" },
|
|
1574
|
+
{ field: "shop_name", type: "string", description: "\u5E97\u94FA\u540D" },
|
|
1575
|
+
{ field: "status", type: "string", description: "\u72B6\u6001" },
|
|
1576
|
+
{ field: "account_id", type: "string", description: "\u8D26\u6237 ID" },
|
|
1577
|
+
{ field: "account_type", type: "string", description: "\u8D26\u6237\u7C7B\u578B" },
|
|
1578
|
+
{ field: "activate_time", type: "string", description: "\u6FC0\u6D3B\u65F6\u95F4" },
|
|
1579
|
+
{ field: "expired_time", type: "string", description: "\u8FC7\u671F\u65F6\u95F4" },
|
|
1580
|
+
{ field: "sales_channel", type: "string", description: "\u9500\u552E\u6E20\u9053" },
|
|
1581
|
+
{ field: "agent_count", type: "number", description: "Agent \u6570\u91CF" },
|
|
1582
|
+
{ field: "customer_agent_count", type: "number", description: "\u5BA2\u670D Agent \u6570\u91CF" },
|
|
1583
|
+
{ field: "customer_name", type: "string|null", description: "\u5BA2\u6237\u540D\u79F0" },
|
|
1584
|
+
{ field: "customer_level", type: "string|null", description: "\u5BA2\u6237\u7B49\u7EA7" },
|
|
1585
|
+
{ field: "customer_description", type: "string|null", description: "\u5BA2\u6237\u63CF\u8FF0" },
|
|
1586
|
+
{ field: "customer_detail", type: "string|null", description: "\u5BA2\u6237\u8BE6\u60C5" },
|
|
1587
|
+
{ field: "customer_staff_count", type: "number|null", description: "\u5BA2\u6237\u5458\u5DE5\u6570" },
|
|
1588
|
+
{ field: "customer_platforms", type: "array", description: "\u5BA2\u6237\u4F7F\u7528\u7684\u5E73\u53F0\u5217\u8868" },
|
|
1589
|
+
{ field: "contract_status", type: "string|null", description: "\u5408\u540C\u72B6\u6001" },
|
|
1590
|
+
{ field: "contract_sign_date", type: "string|null", description: "\u5408\u540C\u7B7E\u7EA6\u65E5\u671F" },
|
|
1591
|
+
{ field: "contract_expire_time", type: "string|null", description: "\u5408\u540C\u5230\u671F\u65F6\u95F4" },
|
|
1592
|
+
{ field: "contract_amount", type: "number|null", description: "\u5408\u540C\u91D1\u989D" },
|
|
1593
|
+
{ field: "contract_renewal_risk", type: "string|null", description: "\u7EED\u7EA6\u98CE\u9669" },
|
|
1594
|
+
{ field: "service_team_info", type: "object|null", description: "\u670D\u52A1\u56E2\u961F\u4FE1\u606F" },
|
|
1595
|
+
{ field: "workspace_config.monitor_v6_thresholds.transfer_rate_warn", type: "number", description: "\u8F6C\u4EBA\u5DE5\u7387\u9884\u8B66\u9608\u503C\uFF080~1\uFF09" },
|
|
1596
|
+
{ field: "workspace_config.monitor_v6_thresholds.transfer_rate_alert", type: "number", description: "\u8F6C\u4EBA\u5DE5\u7387\u544A\u8B66\u9608\u503C\uFF080~1\uFF09" },
|
|
1597
|
+
{ field: "workspace_config.monitor_v6_thresholds.transfer_rate_trial_warn", type: "number", description: "\u8BD5\u7528\u671F\u8F6C\u4EBA\u5DE5\u7387\u9884\u8B66\u9608\u503C" },
|
|
1598
|
+
{ field: "workspace_config.monitor_v6_thresholds.session_drop_warn", type: "number", description: "\u4F1A\u8BDD\u91CF\u4E0B\u964D\u9884\u8B66\u9608\u503C" },
|
|
1599
|
+
{ field: "workspace_config.monitor_v6_thresholds.min_valid_sessions", type: "number", description: "\u6700\u5C0F\u6709\u6548\u4F1A\u8BDD\u6570\uFF08\u4F4E\u4E8E\u6B64\u503C\u4E0D\u89E6\u53D1\u89C4\u5219\uFF09" },
|
|
1600
|
+
{ field: "workspace_config.monitor_v6_thresholds.zero_session_alert_days", type: "number", description: "\u96F6\u4F1A\u8BDD\u5929\u6570\u544A\u8B66\u9608\u503C" },
|
|
1601
|
+
{ field: "workspace_config.monitor_v6_thresholds.no_session_alert_days", type: "number", description: "\u4ECE\u672A\u6709\u4F1A\u8BDD\u544A\u8B66\u5929\u6570" },
|
|
1602
|
+
{ field: "workspace_config.monitor_v6_thresholds.issue_close_rate_warn", type: "number", description: "Issue \u5173\u95ED\u7387\u9884\u8B66\u9608\u503C" },
|
|
1603
|
+
{ field: "workspace_config.monitor_v6_thresholds.auto_calibrate_enabled", type: "boolean", description: "\u662F\u5426\u5F00\u542F\u81EA\u52A8\u9608\u503C\u6821\u51C6" },
|
|
1604
|
+
{ field: "workspace_config.monitor_v6_thresholds.config_source", type: "string", description: "\u9608\u503C\u6765\u6E90\uFF08default/industry/manual/auto\uFF09" }
|
|
1605
|
+
]
|
|
1606
|
+
};
|
|
1607
|
+
var RESOURCE_DEFS = {
|
|
1608
|
+
agents,
|
|
1609
|
+
tickets,
|
|
1610
|
+
statistics,
|
|
1611
|
+
hourly,
|
|
1612
|
+
daily,
|
|
1613
|
+
workspaces
|
|
1614
|
+
};
|
|
1615
|
+
var RESOURCE_NAMES = Object.keys(RESOURCE_DEFS);
|
|
1616
|
+
|
|
1617
|
+
// src/commands/monitor.ts
|
|
1618
|
+
function registerMonitorCommand(program2) {
|
|
1619
|
+
const monitor = program2.command("monitor").description("\u8FD0\u8425\u76D1\u63A7\uFF08/v1/operation \u63A5\u53E3\uFF09");
|
|
1620
|
+
monitor.command("fields [resource]").description(`\u67E5\u770B\u63A5\u53E3\u8FD4\u56DE\u5B57\u6BB5\u542B\u4E49\uFF08\u53EF\u9009: ${RESOURCE_NAMES.join(", ")}\uFF09`).action((resource) => {
|
|
1621
|
+
if (!resource) {
|
|
1622
|
+
formatOutput({
|
|
1623
|
+
success: true,
|
|
1624
|
+
data: Object.values(RESOURCE_DEFS).map((r) => ({
|
|
1625
|
+
resource: r.resource,
|
|
1626
|
+
command: r.command,
|
|
1627
|
+
description: r.description,
|
|
1628
|
+
fieldCount: r.fields.length
|
|
1629
|
+
}))
|
|
1630
|
+
}, program2.opts().table);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const def = RESOURCE_DEFS[resource];
|
|
1634
|
+
if (!def) {
|
|
1635
|
+
outputError(1, `\u672A\u77E5\u8D44\u6E90: ${resource}\uFF0C\u53EF\u9009: ${RESOURCE_NAMES.join(", ")}`);
|
|
1636
|
+
process.exit(1);
|
|
1637
|
+
}
|
|
1638
|
+
formatOutput({ success: true, data: def }, program2.opts().table);
|
|
1639
|
+
});
|
|
1640
|
+
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) => {
|
|
1641
|
+
try {
|
|
1642
|
+
const data = await listAgentLifecycle({
|
|
1643
|
+
page: Number(opts.page),
|
|
1644
|
+
pageSize: Number(opts.pageSize)
|
|
1645
|
+
});
|
|
1646
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1647
|
+
} catch (err) {
|
|
1648
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1649
|
+
process.exit(toExitCode(err));
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
const tickets2 = monitor.command("tickets").description("\u76D1\u63A7\u5DE5\u5355");
|
|
1653
|
+
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) => {
|
|
1654
|
+
try {
|
|
1655
|
+
const data = await listTickets({
|
|
1656
|
+
agentId: opts.agent,
|
|
1657
|
+
status: opts.status,
|
|
1658
|
+
severity: opts.severity,
|
|
1659
|
+
page: Number(opts.page),
|
|
1660
|
+
pageSize: Number(opts.pageSize)
|
|
1661
|
+
});
|
|
1662
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1665
|
+
process.exit(toExitCode(err));
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
tickets2.command("delete <ticket_id>").description("\u5220\u9664\u76D1\u63A7\u5DE5\u5355").action(async (ticketId) => {
|
|
1669
|
+
try {
|
|
1670
|
+
const data = await deleteTicket(ticketId);
|
|
1671
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1672
|
+
} catch (err) {
|
|
1673
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1674
|
+
process.exit(toExitCode(err));
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
const snapshots = monitor.command("snapshots").description("\u76D1\u63A7\u5FEB\u7167");
|
|
1678
|
+
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) => {
|
|
1679
|
+
try {
|
|
1680
|
+
const data = await listHourlySnapshots({
|
|
1681
|
+
agentId: opts.agent,
|
|
1682
|
+
workspaceId: opts.workspaceId,
|
|
1683
|
+
startTime: opts.start,
|
|
1684
|
+
endTime: opts.end,
|
|
1685
|
+
page: opts.page ? Number(opts.page) : void 0,
|
|
1686
|
+
pageSize: opts.pageSize ? Number(opts.pageSize) : void 0
|
|
1687
|
+
});
|
|
1688
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1689
|
+
} catch (err) {
|
|
1690
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1691
|
+
process.exit(toExitCode(err));
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
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) => {
|
|
1695
|
+
try {
|
|
1696
|
+
const data = await listDailySnapshots({
|
|
1697
|
+
agentId: opts.agent,
|
|
1698
|
+
workspaceId: opts.workspaceId,
|
|
1699
|
+
startDate: opts.start,
|
|
1700
|
+
endDate: opts.end
|
|
1701
|
+
});
|
|
1702
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1703
|
+
} catch (err) {
|
|
1704
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1705
|
+
process.exit(toExitCode(err));
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
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) => {
|
|
1709
|
+
try {
|
|
1710
|
+
const data = await listDailySnapshotsRange({
|
|
1711
|
+
agentId: opts.agent,
|
|
1712
|
+
workspaceId: opts.workspaceId,
|
|
1713
|
+
startDate: opts.start,
|
|
1714
|
+
endDate: opts.end,
|
|
1715
|
+
page: opts.page ? Number(opts.page) : void 0,
|
|
1716
|
+
pageSize: Number(opts.pageSize)
|
|
1717
|
+
});
|
|
1718
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1719
|
+
} catch (err) {
|
|
1720
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1721
|
+
process.exit(toExitCode(err));
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
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) => {
|
|
1725
|
+
try {
|
|
1726
|
+
const data = await listAgentStatistics({
|
|
1727
|
+
startDate: opts.start,
|
|
1728
|
+
endDate: opts.end,
|
|
1729
|
+
page: Number(opts.page),
|
|
1730
|
+
pageSize: Number(opts.pageSize)
|
|
1731
|
+
});
|
|
1732
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1733
|
+
} catch (err) {
|
|
1734
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1735
|
+
process.exit(toExitCode(err));
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
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\u6709 Agent \u7684\u5DE5\u4F5C\u7A7A\u95F4").action(async (opts) => {
|
|
1739
|
+
try {
|
|
1740
|
+
const data = await listOperationWorkspaces({
|
|
1741
|
+
page: Number(opts.page),
|
|
1742
|
+
pageSize: Number(opts.pageSize),
|
|
1743
|
+
hasAgent: opts.hasAgent ?? void 0
|
|
1744
|
+
});
|
|
1745
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1746
|
+
} catch (err) {
|
|
1747
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1748
|
+
process.exit(toExitCode(err));
|
|
1749
|
+
}
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
// src/client/repair-record-api.ts
|
|
1754
|
+
var PATH_PREFIX = "/api/repair-records";
|
|
1755
|
+
function buildCookieHeaders() {
|
|
1756
|
+
const creds = readCredentials();
|
|
1757
|
+
if (!creds) throw new APIError(2, "\u672A\u767B\u5F55\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
|
|
1758
|
+
if (isTokenExpired(creds.expiresAt)) {
|
|
1759
|
+
clearCredentials();
|
|
1760
|
+
throw new APIError(2, "Token \u5DF2\u8FC7\u671F\uFF0C\u8BF7\u8FD0\u884C: cs-cli auth login");
|
|
1761
|
+
}
|
|
1762
|
+
return { Cookie: `auth_token=${creds.accessToken}` };
|
|
1763
|
+
}
|
|
1764
|
+
async function listRepairRecords(opts) {
|
|
1765
|
+
const request = createRequest();
|
|
1766
|
+
const query = {};
|
|
1767
|
+
if (opts.issueId) query.issue_id = opts.issueId;
|
|
1768
|
+
if (opts.agentId) query.agent_id = opts.agentId;
|
|
1769
|
+
if (opts.workspaceId) query.workspace_id = opts.workspaceId;
|
|
1770
|
+
if (opts.page) query.page = opts.page;
|
|
1771
|
+
if (opts.pageSize) query.page_size = opts.pageSize;
|
|
1772
|
+
return request(getCustomerAgentUrl(), PATH_PREFIX, {
|
|
1773
|
+
method: "GET",
|
|
1774
|
+
query,
|
|
1775
|
+
headers: buildCookieHeaders(),
|
|
1776
|
+
skipAuth: true
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
async function createRepairRecord(data) {
|
|
1780
|
+
const request = createRequest();
|
|
1781
|
+
return request(getCustomerAgentUrl(), PATH_PREFIX, {
|
|
1782
|
+
method: "POST",
|
|
1783
|
+
body: data,
|
|
1784
|
+
headers: buildCookieHeaders(),
|
|
1785
|
+
skipAuth: true
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
async function updateRepairRecord(recordId, data) {
|
|
1789
|
+
const request = createRequest();
|
|
1790
|
+
return request(getCustomerAgentUrl(), `${PATH_PREFIX}/${recordId}`, {
|
|
1791
|
+
method: "PUT",
|
|
1792
|
+
body: data,
|
|
1793
|
+
headers: buildCookieHeaders(),
|
|
1794
|
+
skipAuth: true
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
// src/commands/repair-record.ts
|
|
1799
|
+
function registerRepairRecordCommand(program2) {
|
|
1800
|
+
const repairRecord = program2.command("repair-record").description("Issue \u4FEE\u590D\u8BB0\u5F55\u7BA1\u7406");
|
|
1801
|
+
repairRecord.command("list").description("\u5217\u51FA\u4FEE\u590D\u8BB0\u5F55").option("--issue <issue_id>", "\u6309\u5DE5\u5355 ID \u7B5B\u9009").option("--agent <agent_id>", "\u6309 Agent ID \u7B5B\u9009").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) => {
|
|
1802
|
+
try {
|
|
1803
|
+
const data = await listRepairRecords({
|
|
1804
|
+
issueId: opts.issue,
|
|
1805
|
+
agentId: opts.agent,
|
|
1806
|
+
workspaceId: opts.workspace,
|
|
1807
|
+
page: Number(opts.page),
|
|
1808
|
+
pageSize: Number(opts.pageSize)
|
|
1809
|
+
});
|
|
1810
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1811
|
+
} catch (err) {
|
|
1812
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1813
|
+
process.exit(toExitCode(err));
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
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>", "\u4FEE\u590D\u52A8\u4F5C\u63CF\u8FF0").option("--agent-name <name>", "Agent \u540D\u79F0").option("--type <repair_type>", "\u4FEE\u590D\u7C7B\u578B").option("--status <repair_status>", "\u4FEE\u590D\u72B6\u6001: pending | success | failed | partial").option("--duration <ms>", "\u8017\u65F6\uFF08\u6BEB\u79D2\uFF09").option("--result <json>", "\u4FEE\u590D\u7ED3\u679C\uFF08JSON\uFF09").option("--workspace <workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID").action(async (opts) => {
|
|
1817
|
+
try {
|
|
1818
|
+
const data = await createRepairRecord({
|
|
1819
|
+
issue_id: opts.issue,
|
|
1820
|
+
agent_id: opts.agent,
|
|
1821
|
+
repair_action: opts.action,
|
|
1822
|
+
agent_name: opts.agentName,
|
|
1823
|
+
repair_type: opts.type,
|
|
1824
|
+
repair_status: opts.status,
|
|
1825
|
+
duration_ms: opts.duration ? Number(opts.duration) : void 0,
|
|
1826
|
+
repair_result: opts.result ? JSON.parse(opts.result) : void 0,
|
|
1827
|
+
workspace_id: opts.workspace
|
|
1828
|
+
});
|
|
1829
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1830
|
+
} catch (err) {
|
|
1831
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1832
|
+
process.exit(toExitCode(err));
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
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) => {
|
|
1836
|
+
try {
|
|
1837
|
+
const body = parseDataOption(opts.data);
|
|
1838
|
+
const data = await updateRepairRecord(recordId, body);
|
|
1839
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1840
|
+
} catch (err) {
|
|
1841
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1842
|
+
process.exit(toExitCode(err));
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1209
1847
|
// src/bin.ts
|
|
1210
1848
|
var program = new Command();
|
|
1211
1849
|
program.name("cs-cli").description("AI \u5BA2\u670D CLI - Agent \u53CB\u597D").version("0.1.0").option("--table", "\u4EE5\u8868\u683C\u5F62\u5F0F\u8F93\u51FA\uFF08\u9ED8\u8BA4 JSON\uFF09", false).option("--workspace <id>", "\u8986\u76D6\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4 ID").option("--timeout <ms>", "\u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09", "20000");
|
|
@@ -1226,6 +1864,8 @@ registerChatHistoryCommand(program);
|
|
|
1226
1864
|
registerFaqCommand(program);
|
|
1227
1865
|
registerConversationCommand(program);
|
|
1228
1866
|
registerDebugCommand(program);
|
|
1867
|
+
registerMonitorCommand(program);
|
|
1868
|
+
registerRepairRecordCommand(program);
|
|
1229
1869
|
process.on("uncaughtException", (err) => {
|
|
1230
1870
|
outputError(3, err.message);
|
|
1231
1871
|
process.exit(3);
|