@bty/customer-service-cli 0.1.10 → 0.1.12
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 +4 -1
- package/dist/bin.js +53 -2
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -226,6 +226,7 @@ cs-cli product update-sku --agent <id> --sku "颜色分类:粉红" --update '{"
|
|
|
226
226
|
| -------------------------------------------------------------------------------- | -------- |
|
|
227
227
|
| `conversation list --agent <id> [--user <用户名>] [--start <日期>] [--end <日期>]` | 搜索会话 |
|
|
228
228
|
| `conversation records <conversation_id> [--page-size N] [--direction prev|next]` | 获取会话聊天记录 |
|
|
229
|
+
| `conversation context-search --query <文本> [--start <时间>] [--end <时间>]` | 通过上下文内容模糊搜索对话记录(返回匹配消息详情,时间范围最多 3 天) |
|
|
229
230
|
|
|
230
231
|
|
|
231
232
|
### Agent 调试 (`debug`)
|
|
@@ -387,6 +388,9 @@ cs-cli product update-sku --agent <id> --sku "颜色分类:粉红" --update '{"
|
|
|
387
388
|
# 添加 FAQ
|
|
388
389
|
cs-cli faq add --agent <id> --file "常见问题" --questions "怎么退款,如何退款" --answers "答案=请联系客服处理退款"
|
|
389
390
|
|
|
391
|
+
# 通过上下文内容模糊搜索对话记录(自动使用当前工作空间,查询窗口最多 3 天)
|
|
392
|
+
cs-cli conversation context-search --query "退款问题" --start 2026-03-22T00:00:00 --end 2026-03-22T23:59:59
|
|
393
|
+
|
|
390
394
|
# 重放对话测试 Agent
|
|
391
395
|
cs-cli debug ask --agent <id> --messages @conversation.json
|
|
392
396
|
|
|
@@ -399,4 +403,3 @@ cs-cli repair-record create --issue <issue_id> --agent <agent_id> --action "更
|
|
|
399
403
|
# 更新修复记录状态
|
|
400
404
|
cs-cli repair-record update <record_id> --data '{"repair_status":"success","duration_ms":1200}'
|
|
401
405
|
```
|
|
402
|
-
|
package/dist/bin.js
CHANGED
|
@@ -1065,13 +1065,18 @@ function registerIssueCommand(program2) {
|
|
|
1065
1065
|
process.exit(toExitCode(err));
|
|
1066
1066
|
}
|
|
1067
1067
|
});
|
|
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) => {
|
|
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").option("--conversation-id <id>", "\u5173\u8054\u7684\u4F1A\u8BDD ID").option("--record-id <id>", "\u5173\u8054\u7684\u6D88\u606F\u8BB0\u5F55 ID").option("--workspace-id <id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID\uFF08\u9ED8\u8BA4\u4ECE\u73AF\u5883\u53D8\u91CF\u8BFB\u53D6\uFF09").option("--source-type <type>", "\u6765\u6E90\u7C7B\u578B").option("--source-data <json>", "\u6765\u6E90\u6570\u636E\uFF08JSON \u5B57\u7B26\u4E32\uFF09").action(async (opts) => {
|
|
1069
1069
|
try {
|
|
1070
1070
|
const data = await createIssue({
|
|
1071
1071
|
title: opts.title,
|
|
1072
1072
|
content: opts.content,
|
|
1073
1073
|
priority: opts.priority,
|
|
1074
|
-
tags: opts.tags
|
|
1074
|
+
tags: opts.tags,
|
|
1075
|
+
conversation_id: opts.conversationId,
|
|
1076
|
+
record_id: opts.recordId,
|
|
1077
|
+
workspace_id: opts.workspaceId,
|
|
1078
|
+
source_type: opts.sourceType,
|
|
1079
|
+
source_data: opts.sourceData ? JSON.parse(opts.sourceData) : void 0
|
|
1075
1080
|
});
|
|
1076
1081
|
formatOutput({ success: true, data }, program2.opts().table);
|
|
1077
1082
|
} catch (err) {
|
|
@@ -1242,6 +1247,39 @@ function registerFaqCommand(program2) {
|
|
|
1242
1247
|
}
|
|
1243
1248
|
|
|
1244
1249
|
// src/client/conversation-api.ts
|
|
1250
|
+
var MAX_CONTEXT_SEARCH_RANGE_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
1251
|
+
function parseSearchTime(value, fieldName) {
|
|
1252
|
+
const parsed = new Date(value);
|
|
1253
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
1254
|
+
throw new Error(`${fieldName} \u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u4F7F\u7528 ISO \u65F6\u95F4\uFF0C\u4F8B\u5982 2026-03-22T00:00:00`);
|
|
1255
|
+
}
|
|
1256
|
+
return parsed;
|
|
1257
|
+
}
|
|
1258
|
+
function validateContextSearchRange(startTime, endTime) {
|
|
1259
|
+
if (!startTime || !endTime) return;
|
|
1260
|
+
const start = parseSearchTime(startTime, "\u5F00\u59CB\u65F6\u95F4");
|
|
1261
|
+
const end = parseSearchTime(endTime, "\u7ED3\u675F\u65F6\u95F4");
|
|
1262
|
+
if (end.getTime() < start.getTime()) {
|
|
1263
|
+
throw new Error("\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4");
|
|
1264
|
+
}
|
|
1265
|
+
if (end.getTime() - start.getTime() > MAX_CONTEXT_SEARCH_RANGE_MS) {
|
|
1266
|
+
throw new Error("\u67E5\u8BE2\u65F6\u95F4\u8303\u56F4\u4E0D\u80FD\u8D85\u8FC73\u5929");
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
async function contextSearchRecords(opts) {
|
|
1270
|
+
validateContextSearchRange(opts.startTime, opts.endTime);
|
|
1271
|
+
const wsId = getWorkspaceId(opts.workspaceId);
|
|
1272
|
+
const request = createRequest();
|
|
1273
|
+
return request(getCustomerServiceUrl(), "/v1/chat/records/context-search", {
|
|
1274
|
+
method: "GET",
|
|
1275
|
+
query: {
|
|
1276
|
+
workspace_id: wsId,
|
|
1277
|
+
query_content: opts.queryContent,
|
|
1278
|
+
start_time: opts.startTime,
|
|
1279
|
+
end_time: opts.endTime
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1245
1283
|
async function getConversationRecords(opts) {
|
|
1246
1284
|
const request = createRequest();
|
|
1247
1285
|
return request(getCustomerServiceUrl(), `/v1/chat/${opts.conversationId}/records`, {
|
|
@@ -1303,6 +1341,19 @@ function registerConversationCommand(program2) {
|
|
|
1303
1341
|
process.exit(toExitCode(err));
|
|
1304
1342
|
}
|
|
1305
1343
|
});
|
|
1344
|
+
conversation.command("context-search").description("\u901A\u8FC7\u4E0A\u4E0B\u6587\u5185\u5BB9\u6A21\u7CCA\u641C\u7D22\u5BF9\u8BDD\u8BB0\u5F55\uFF0C\u8FD4\u56DE\u5339\u914D\u6D88\u606F\u8BE6\u60C5\uFF08\u542B conversation_id\u3001record_id\u3001context \u7B49\u5B57\u6BB5\uFF0C\u65F6\u95F4\u8303\u56F4\u6700\u591A 3 \u5929\uFF09").requiredOption("--query <text>", "\u641C\u7D22\u7684\u6587\u672C\u5185\u5BB9\uFF08\u5982 AI \u7684\u9519\u8BEF\u56DE\u7B54\uFF09").option("--start <date>", "\u5F00\u59CB\u65F6\u95F4\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-22T00:00:00\uFF1B\u4E0E\u7ED3\u675F\u65F6\u95F4\u8DE8\u5EA6\u6700\u591A 3 \u5929\uFF09").option("--end <date>", "\u7ED3\u675F\u65F6\u95F4\uFF08ISO \u683C\u5F0F\uFF0C\u5982 2026-03-22T23:59:59\uFF1B\u4E0E\u5F00\u59CB\u65F6\u95F4\u8DE8\u5EA6\u6700\u591A 3 \u5929\uFF09").action(async (opts) => {
|
|
1345
|
+
try {
|
|
1346
|
+
const data = await contextSearchRecords({
|
|
1347
|
+
queryContent: opts.query,
|
|
1348
|
+
startTime: opts.start,
|
|
1349
|
+
endTime: opts.end
|
|
1350
|
+
});
|
|
1351
|
+
formatOutput({ success: true, data }, program2.opts().table);
|
|
1352
|
+
} catch (err) {
|
|
1353
|
+
outputError(err.statusCode ?? 1, err.message);
|
|
1354
|
+
process.exit(toExitCode(err));
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1306
1357
|
}
|
|
1307
1358
|
|
|
1308
1359
|
// src/client/debug-api.ts
|
package/package.json
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bty/customer-service-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "AI Customer Service CLI - Agent friendly",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/bin.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"cs-cli": "
|
|
8
|
+
"cs-cli": "dist/bin.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"/dist"
|
|
12
12
|
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup src/bin.ts --format esm --target node20 --shims",
|
|
15
|
+
"dev": "tsx src/bin.ts",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest"
|
|
18
|
+
},
|
|
13
19
|
"dependencies": {
|
|
14
20
|
"cli-table3": "^0.6.0",
|
|
15
|
-
"commander": "
|
|
16
|
-
"crypto-js": "
|
|
21
|
+
"commander": "catalog:",
|
|
22
|
+
"crypto-js": "catalog:"
|
|
17
23
|
},
|
|
18
24
|
"devDependencies": {
|
|
19
|
-
"@types/crypto-js": "
|
|
20
|
-
"@types/node": "
|
|
25
|
+
"@types/crypto-js": "catalog:",
|
|
26
|
+
"@types/node": "catalog:",
|
|
21
27
|
"tsup": "^8.0.0",
|
|
22
28
|
"tsx": "^4.0.0",
|
|
23
29
|
"vitest": "^2.0.0"
|
|
@@ -28,11 +34,5 @@
|
|
|
28
34
|
},
|
|
29
35
|
"engines": {
|
|
30
36
|
"node": ">=20.0.0"
|
|
31
|
-
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"build": "tsup src/bin.ts --format esm --target node20 --shims",
|
|
34
|
-
"dev": "tsx src/bin.ts",
|
|
35
|
-
"test": "vitest run",
|
|
36
|
-
"test:watch": "vitest"
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
}
|