@bty/customer-service-cli 0.4.2 → 0.4.3

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.
Files changed (3) hide show
  1. package/README.md +6 -0
  2. package/dist/bin.js +48 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -223,11 +223,17 @@ cs-cli workspace points-consumes-daily --start 2026-04-01 --end 2026-04-23
223
223
  | `product update --agent <id> --product-id <商品ID> --update <json\|@file>` | 更新商品信息 |
224
224
  | `product update-sku --agent <id> (--sku <SKU名称> \| --sku-id <id>) --update <json\|@file>` | 更新 SKU 信息(`--sku-id` 优先于 `--sku`) |
225
225
  | `product learn --agent <id> --url <URL...> [--source <type>] [--no-identify]` | 通过商品 URL 异步学习(manual / identify 默认开启) |
226
+ | `product sync-taobao --agent <id> [--skip-hash-check]` | 触发淘宝店铺商品全量同步 |
227
+ | `product sync-taobao-item --agent <id> --product-id <商品ID>` | 触发单个淘宝商品同步 |
226
228
 
227
229
  `product update` 支持更新的字段包括:`卖点`、`补充知识`、`tag`、`参数`、`轮播图识别结果`、`商品详情页识别结果` 等。`--update` 接受 JSON 字符串或 `@文件路径`。
228
230
 
229
231
  `product learn` 提交商品详情页 URL 进入异步学习队列(`/v1/knowledge/products/upload`),返回 `flow_id` 和 `knowledge_ids`。`--url` 可多值,用空格分隔;`--source` 默认 `manual`;传 `--no-identify` 可关闭自动识别。
230
232
 
233
+ `product sync-taobao` / `product sync-taobao-item` 调用 customer-servhub-api 的授权店铺同步接口,要求 `--agent` 已唯一绑定一个淘宝授权店铺。前者触发店铺商品全量同步,后者按 `product_id` 补同步单个淘宝商品。
234
+
235
+ 注意:这两个命令仅对已开通“高级工具”的店铺 Agent 生效。未开通高级工具时,即使 `--agent` 已绑定淘宝授权店铺,请求也可能在服务端失败。
236
+
231
237
  ```bash
232
238
  # 更新卖点
233
239
  cs-cli product update --agent <id> --product-id <商品ID> --update '{"卖点":"新卖点内容"}'
package/dist/bin.js CHANGED
@@ -2847,6 +2847,26 @@ async function updateSku(opts) {
2847
2847
  }
2848
2848
  });
2849
2849
  }
2850
+ async function syncTaobaoProducts(opts) {
2851
+ const request = createRequest();
2852
+ return request(getCustomerServiceUrl(), "/v1/authorized-shop/sync-taobao-products", {
2853
+ method: "POST",
2854
+ body: {
2855
+ customer_agent_config_id: opts.agentConfigId,
2856
+ skip_hash_check: opts.skipHashCheck ?? false
2857
+ }
2858
+ });
2859
+ }
2860
+ async function syncSingleTaobaoProduct(opts) {
2861
+ const request = createRequest();
2862
+ return request(getCustomerServiceUrl(), "/v1/authorized-shop/sync-single-product", {
2863
+ method: "POST",
2864
+ body: {
2865
+ customer_agent_config_id: opts.agentConfigId,
2866
+ product_id: opts.productId
2867
+ }
2868
+ });
2869
+ }
2850
2870
 
2851
2871
  // src/commands/product.ts
2852
2872
  async function getDbId(agentConfigId) {
@@ -2956,6 +2976,34 @@ function registerProductCommand(program2) {
2956
2976
  process.exit(toExitCode(err));
2957
2977
  }
2958
2978
  });
2979
+ product.command("sync-taobao").description(
2980
+ "\u89E6\u53D1\u6DD8\u5B9D\u5E97\u94FA\u5546\u54C1\u5168\u91CF\u540C\u6B65\u3002\u8C03\u7528 customer-servhub-api \u7684\u6388\u6743\u5E97\u94FA\u540C\u6B65\u63A5\u53E3\uFF0C\u6309 Agent \u914D\u7F6E\u627E\u5230\u552F\u4E00\u7ED1\u5B9A\u5E97\u94FA\u540E\u5F02\u6B65\u542F\u52A8\u540C\u6B65\u4EFB\u52A1"
2981
+ ).requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u5FC5\u987B\u5DF2\u552F\u4E00\u7ED1\u5B9A\u4E00\u4E2A\u6DD8\u5B9D\u6388\u6743\u5E97\u94FA\uFF09").option("--skip-hash-check", "\u8DF3\u8FC7\u54C8\u5E0C\u6821\u9A8C\uFF0C\u5F3A\u5236\u91CD\u65B0\u540C\u6B65\u5546\u54C1").action(async (opts) => {
2982
+ try {
2983
+ const data = await syncTaobaoProducts({
2984
+ agentConfigId: opts.agent,
2985
+ skipHashCheck: Boolean(opts.skipHashCheck)
2986
+ });
2987
+ formatOutput({ success: true, data }, program2.opts().table);
2988
+ } catch (err) {
2989
+ reportCaughtError(err);
2990
+ process.exit(toExitCode(err));
2991
+ }
2992
+ });
2993
+ product.command("sync-taobao-item").description(
2994
+ "\u89E6\u53D1\u5355\u4E2A\u6DD8\u5B9D\u5546\u54C1\u540C\u6B65\u3002\u8C03\u7528 customer-servhub-api \u7684\u5355\u5546\u54C1\u540C\u6B65\u63A5\u53E3\uFF0C\u9002\u5408\u8865\u5B66\u6307\u5B9A product_id"
2995
+ ).requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u5FC5\u987B\u5DF2\u552F\u4E00\u7ED1\u5B9A\u4E00\u4E2A\u6DD8\u5B9D\u6388\u6743\u5E97\u94FA\uFF09").requiredOption("--product-id <product_id>", "\u6DD8\u5B9D\u5546\u54C1 ID").action(async (opts) => {
2996
+ try {
2997
+ const data = await syncSingleTaobaoProduct({
2998
+ agentConfigId: opts.agent,
2999
+ productId: opts.productId
3000
+ });
3001
+ formatOutput({ success: true, data }, program2.opts().table);
3002
+ } catch (err) {
3003
+ reportCaughtError(err);
3004
+ process.exit(toExitCode(err));
3005
+ }
3006
+ });
2959
3007
  product.command("update-sku").description(
2960
3008
  "\u66F4\u65B0\u6307\u5B9A SKU \u7684\u77E5\u8BC6\u4FE1\u606F\uFF08\u5982\u8865\u5145\u77E5\u8BC6\uFF09\u3002\u652F\u6301\u901A\u8FC7 SKU \u540D\u79F0\u6216 sku_id \u5B9A\u4F4D\uFF0C\u540C\u65F6\u63D0\u4F9B\u65F6\u4F18\u5148\u4F7F\u7528 sku_id"
2961
3009
  ).requiredOption("--agent <config_id>", "Agent \u914D\u7F6E ID\uFF08\u4ECE agent list \u83B7\u53D6\uFF09").option("--sku <name>", 'SKU \u540D\u79F0\uFF08\u7CBE\u786E\u5339\u914D\uFF0C\u5982 "\u989C\u8272\u5206\u7C7B:\u7C89\u7EA2"\uFF09').option("--sku-id <id>", "SKU ID\uFF08\u5168\u5C40\u552F\u4E00\uFF0C\u4F18\u5148\u4E8E --sku\uFF09").requiredOption(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bty/customer-service-cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "AI Customer Service CLI - Agent friendly",
5
5
  "type": "module",
6
6
  "main": "./dist/bin.js",