@bty/customer-service-cli 0.6.11 → 0.6.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/CHANGELOG.md +4 -0
- package/dist/bin.js +49 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.12 (2026-08-31)
|
|
4
|
+
|
|
5
|
+
- `channel-metric query` 新增 `--format json|markdown|table`(默认 json):markdown 输出适合贴文档/群消息,table 输出终端表格;json 保持原结构不变。
|
|
6
|
+
|
|
3
7
|
## 0.6.11 (2026-08-27)
|
|
4
8
|
|
|
5
9
|
- `workspace points-consumes` 改用 `customer-observability-api` 备库 Cursor 接口,支持 `--cursor`、`--start`、`--end`、`--limit`,可继续读取超过 10000 条的历史积分流水。
|
package/dist/bin.js
CHANGED
|
@@ -1159,11 +1159,42 @@ function renderGroupedTable(groups) {
|
|
|
1159
1159
|
\u5171 ${total} \u6761\u8BB0\u5F55
|
|
1160
1160
|
`);
|
|
1161
1161
|
}
|
|
1162
|
+
function renderMarkdownTable(groups) {
|
|
1163
|
+
let total = 0;
|
|
1164
|
+
const escape = (value) => value.replace(/\|/g, "\\|");
|
|
1165
|
+
for (const group of groups) {
|
|
1166
|
+
process.stdout.write(`
|
|
1167
|
+
### ${group.stat_date} \xB7 ${group.channel}\uFF08${group.items.length} \u4E2A\u8D26\u53F7\uFF09
|
|
1168
|
+
|
|
1169
|
+
`);
|
|
1170
|
+
const first = group.items[0];
|
|
1171
|
+
const headers = (first?.metrics_json ?? []).map((field) => field.label);
|
|
1172
|
+
const headCells = ["account_id", ...headers].map(escape);
|
|
1173
|
+
process.stdout.write(`| ${headCells.join(" | ")} |
|
|
1174
|
+
`);
|
|
1175
|
+
process.stdout.write(`| ${headCells.map(() => "---").join(" | ")} |
|
|
1176
|
+
`);
|
|
1177
|
+
for (const row of group.items) {
|
|
1178
|
+
const cells = [
|
|
1179
|
+
String(row.account_id),
|
|
1180
|
+
...row.metrics_json.map(
|
|
1181
|
+
(field) => field.value === void 0 || field.value === null ? "-" : escape(String(field.value))
|
|
1182
|
+
)
|
|
1183
|
+
];
|
|
1184
|
+
process.stdout.write(`| ${cells.join(" | ")} |
|
|
1185
|
+
`);
|
|
1186
|
+
}
|
|
1187
|
+
total += group.items.length;
|
|
1188
|
+
}
|
|
1189
|
+
process.stdout.write(`
|
|
1190
|
+
\u5171 ${total} \u6761\u8BB0\u5F55
|
|
1191
|
+
`);
|
|
1192
|
+
}
|
|
1162
1193
|
function registerChannelMetricCommand(program2) {
|
|
1163
1194
|
const channelMetric = program2.command("channel-metric").description("\u6E20\u9053\u76D1\u63A7\u6307\u6807\u67E5\u8BE2 \u2014\u2014 \u67E5\u8BE2\u5343\u725B\u7B49\u6E20\u9053\u5E97\u94FA\u5BA2\u670D\u7684\u6BCF\u65E5\u6392\u884C\u6307\u6807\uFF08channel_metric_snapshot\uFF09");
|
|
1164
1195
|
channelMetric.command("query").description(
|
|
1165
1196
|
"\u6309 workspace + \u65E5\u671F\u533A\u95F4\uFF08+ \u53EF\u9009 agent / \u6E20\u9053\uFF09\u67E5\u8BE2\u6307\u6807\uFF0C\u6309\u65E5\u671F\xD7\u6E20\u9053\u5206\u7EC4\u8F93\u51FA\u3002\u4E0D\u4F20 --agent \u8F93\u51FA\u8BE5 workspace \u4E0B\u5168\u90E8 agent\uFF0C\u4E0D\u4F20 --platform \u8F93\u51FA\u5168\u90E8\u6E20\u9053"
|
|
1166
|
-
).requiredOption("--workspace-id <workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID\uFF08\u5FC5\u4F20\uFF0C\u4E0E\u670D\u52A1\u7AEF\u5F52\u5C5E\u6821\u9A8C\u4E00\u81F4\uFF09").option("--agent <agent_id>", "Agent \u914D\u7F6E ID\uFF1B\u7F3A\u7701\u67E5\u8BE2\u8BE5 workspace \u4E0B\u5168\u90E8 agent").requiredOption("--start <date>", "\u8D77\u59CB\u65E5\u671F\uFF08YYYY-MM-DD\uFF09").requiredOption("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08YYYY-MM-DD\uFF09").option("--platform <channel>", "\u6E20\u9053\uFF08platform\uFF09\uFF0C\u5982 qianniu\uFF1B\u7F3A\u7701\u67E5\u8BE2\u5168\u90E8\u6E20\u9053").action(async (opts) => {
|
|
1197
|
+
).requiredOption("--workspace-id <workspace_id>", "\u5DE5\u4F5C\u7A7A\u95F4 ID\uFF08\u5FC5\u4F20\uFF0C\u4E0E\u670D\u52A1\u7AEF\u5F52\u5C5E\u6821\u9A8C\u4E00\u81F4\uFF09").option("--agent <agent_id>", "Agent \u914D\u7F6E ID\uFF1B\u7F3A\u7701\u67E5\u8BE2\u8BE5 workspace \u4E0B\u5168\u90E8 agent").requiredOption("--start <date>", "\u8D77\u59CB\u65E5\u671F\uFF08YYYY-MM-DD\uFF09").requiredOption("--end <date>", "\u7ED3\u675F\u65E5\u671F\uFF08YYYY-MM-DD\uFF09").option("--platform <channel>", "\u6E20\u9053\uFF08platform\uFF09\uFF0C\u5982 qianniu\uFF1B\u7F3A\u7701\u67E5\u8BE2\u5168\u90E8\u6E20\u9053").option("--format <format>", "\u8F93\u51FA\u683C\u5F0F\uFF1Ajson\uFF08\u9ED8\u8BA4\uFF09/ markdown / table", "json").action(async (opts) => {
|
|
1167
1198
|
try {
|
|
1168
1199
|
setRuntimeWorkspaceId(opts.workspaceId);
|
|
1169
1200
|
const data = await queryChannelMetrics({
|
|
@@ -1174,11 +1205,24 @@ function registerChannelMetricCommand(program2) {
|
|
|
1174
1205
|
channel: opts.platform
|
|
1175
1206
|
});
|
|
1176
1207
|
const groups = data?.groups ?? [];
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1208
|
+
switch (opts.format) {
|
|
1209
|
+
case "markdown":
|
|
1210
|
+
if (groups.length === 0) {
|
|
1211
|
+
process.stdout.write("(empty)\n");
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
renderMarkdownTable(groups);
|
|
1215
|
+
break;
|
|
1216
|
+
case "table":
|
|
1217
|
+
if (groups.length === 0) {
|
|
1218
|
+
process.stdout.write("(empty)\n");
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
renderGroupedTable(groups);
|
|
1222
|
+
break;
|
|
1223
|
+
default:
|
|
1224
|
+
formatOutput({ success: true, data }, false);
|
|
1180
1225
|
}
|
|
1181
|
-
renderGroupedTable(groups);
|
|
1182
1226
|
} catch (err) {
|
|
1183
1227
|
reportCaughtError(err);
|
|
1184
1228
|
process.exit(toExitCode(err));
|