npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bty/customer-service-cli

v0.6.2

Published

AI Customer Service CLI - Agent friendly

Readme

AI 客服 CLI

供 Agent 调用的 AI 客服命令行工具。所有输出默认为 JSON 格式,便于程序解析。

安装

通过 npm 全局安装(推荐)

npm install -g @bty/customer-service-cli

安装后即可直接使用 cs-cli 命令。

从源码构建

pnpm install
pnpm build

构建产物位于 dist/bin.js,可通过 cs-cli 命令调用。

默认 API 地址

安装后即可使用,无需额外配置 API 地址。内置默认地址:

| 服务 | 默认地址 | | -------------- | --------------------------------------------- | | 客服 API | https://customer-servhub-api.betteryeah.com | | AI API | https://ai-api.betteryeah.com | | Customer Agent | https://customer-agent.bantouyan.com | | Langfuse | http://192.168.40.10:3000 |

AI API 同时服务于登录认证(auth login / auth whoami),不再区分独立的 "认证 API" 字段。

如需覆盖,可通过 cs-cli config set 修改:

cs-cli config set --cs-api https://your-api.example.com

API 地址优先级

每个 API 地址的读取顺序为 环境变量 > config.json > 内置默认值。环境变量为 undefined 或空字符串 "" 都视为未设置,继续向下 fallback。

| 环境变量 | 覆盖字段 | 默认值 | | ----------------------- | ------------------- | --------------------------------------------- | | CS_CS_API_URL | customerServiceApiUrl | https://customer-servhub-api.betteryeah.com | | CS_AI_API_URL | aiApiUrl(同时服务 auth 调用) | https://ai-api.betteryeah.com | | CS_CUSTOMER_AGENT_URL | customerAgentApiUrl | https://customer-agent.bantouyan.com |

快速开始

# 登录
cs-cli auth login --phone 13800000000 --password yourpassword

# 查看当前用户
cs-cli auth whoami

# 设置默认工作空间
cs-cli config set-workspace <workspace_id>

# 列出 Agent
cs-cli agent list

全局选项

| 选项 | 说明 | 默认值 | | ------------------ | ---------------- | ------- | | --table | 以表格形式输出(默认 JSON) | false | | --workspace <id> | 覆盖默认工作空间 ID | 配置文件中的值 | | --timeout <ms> | 请求超时时间(毫秒) | 20000 |

本地配置 (.cs-cli.json)

支持在项目目录下放置 .cs-cli.json 文件,为不同项目配置不同的工作空间。

工作空间优先级

| 优先级 | 来源 | 说明 | | --- | ----------------------- | ---------------------------- | | 0 | CS_WORKSPACE_ID 环境变量 | env lock,最高优先级,override 硬失败(见下方"环境变量锁定") | | 1 | --workspace <id> 参数 | 命令行临时覆盖 | | 2 | .cs-cli.json (本地配置) | 当前目录或祖先目录 | | 3 | ~/.cs-cli/config.json | 全局默认配置 |

使用方式

# 在项目目录下初始化本地配置
cs-cli config init

# 设置工作空间(自动写入本地 .cs-cli.json)
cs-cli config set-workspace <workspace_id>

# 强制写入全局配置
cs-cli config set-workspace <workspace_id> --global

CLI 从当前目录向上查找 .cs-cli.json,找到第一个即使用其中的 workspaceId

.cs-cli.json 格式:

{
  "workspaceId": "ws-abc123",
  "workspaceName": "某客户项目"
}

set-workspace 写入规则

  • 当前目录或祖先目录存在 .cs-cli.json → 写入本地配置
  • 不存在 .cs-cli.json → 写入全局配置
  • 使用 --global → 强制写入全局配置

每次写入后会提示写入的目标路径。

环境变量锁定(sandbox / CI)

当 sandbox、CI 等非交互环境预先注入以下环境变量时,cs-cli 会透明地把 env 作为凭据与上下文来源,并拒绝任何运行时 override(--workspace / --agent / auth login 等),避免下游脚本在上下文被静默切换时产生未定义行为。

| 环境变量 | 作用 | | ----------------- | ------------------------- | | CS_AUTH | 登录凭据(等同 access token)。存在即视为"已锁定" | | CS_WORKSPACE_ID | 锁定工作空间 ID | | CS_AGENT_ID | 锁定默认 agent ID |

处理逻辑:

  1. env 优先:只要环境变量有值,cs-cli 就从 env 读取,忽略本地 credentials.json / .cs-cli.json / 全局配置。
  2. override 硬失败:锁定后如果再通过 --workspace / --agent / auth login / auth logout / config set-workspace 传入不一致的值,cs-cli 立刻报错退出,不会静默覆盖。
  3. 幂等传值:override 与 env 值完全一致时允许通过(便于脚本显式断言)。

使用示例:

export CS_AUTH="<your-access-token>"
export CS_WORKSPACE_ID="ws-abc123"
export CS_AGENT_ID="agent-xyz"

cs-cli agent list     # 直接运行,无需 auth login
cs-cli --workspace ws-other agent list   # ❌ 报错:CS_WORKSPACE_ID 已被锁定

要解除锁定,清空对应环境变量即可(unset CS_AUTH CS_WORKSPACE_ID CS_AGENT_ID)。

命令速查表

认证 (auth)

| 命令 | 说明 | | ------------------------------------------ | -------- | | auth login --phone <手机号> --password <密码> | 登录 | | auth logout | 退出登录 | | auth whoami | 查看当前登录用户 |

配置 (config)

| 命令 | 说明 | | ----------------------------------------------------------- | ---------------------------- | | config set --cs-api <url> --ai-api <url> | 设置 API 地址 | | config get | 查看当前配置(含全局和本地) | | config init | 在当前目录初始化本地配置 (.cs-cli.json) | | config set-workspace <workspace_id> [--global] | 设置默认工作空间 |

工作空间 (workspace)

| 命令 | 说明 | | --- | --- | | workspace list | 列出所有工作空间 | | workspace points-consumes-daily [--start <YYYY-MM-DD>] [--end <YYYY-MM-DD>] | 按天查询工作空间积分消耗(默认最近 30 天) |

workspace points-consumes-daily 需要可用的工作空间上下文(--workspace、本地 .cs-cli.json 或全局 defaultWorkspaceId)。

# 查询最近 30 天(默认)
cs-cli workspace points-consumes-daily

# 指定日期范围(含 start/end)
cs-cli workspace points-consumes-daily --start 2026-04-01 --end 2026-04-23

Agent 管理 (agent)

| 命令 | 说明 | | ---------------------------------------------- | ----------- | | agent list [--page N] [--page-size N] | 列出 Agent 列表 | | agent get <config_id> | 获取 Agent 详情 | | agent update <config_id> --data <json|@file> | 更新 Agent 配置 |

场景动作 (sa)

| 命令 | 说明 | | --- | --- | | sa list --agent <id> [--intent <意图>] [--first-label <标签>] [--second-label <标签>] | 列出场景动作 | | sa search --agent <id> --keyword <关键词> | 搜索场景动作 | | sa create --agent <id> --first-label <一级标签> --second-label <二级标签> --situation <场景> --action <动作> [--transfer] [--intent <意图>] | 创建场景动作 | | sa update --agent <id> --id <SA_ID> --first-label <一级标签> --second-label <二级标签> --situation <场景> --action <动作> [--transfer] | 更新场景动作 | | sa delete --agent <id> --id <SA_ID> --first-label <一级标签> --second-label <二级标签> | 删除场景动作 | | sa versions --agent <id> --id <SA_ID> | 查看修改记录 |

商品管理 (product)

| 命令 | 说明 | | --- | --- | | product list --agent <id> [--keyword <关键词>] [--status <状态>] [--tag <标签>] | 列出商品 | | product get --agent <id> --product-id <商品ID> | 获取商品详情(自动获取 db_id) | | product update --agent <id> --product-id <商品ID> --update <json\|@file> | 更新商品信息 | | product update-sku --agent <id> (--sku <SKU名称> \| --sku-id <id>) --update <json\|@file> | 更新 SKU 信息(--sku-id 优先于 --sku) | | product add --agent <id> --data <json\|@file> [--source <type>] [--no-identify] | 直接传入结构化商品数据(JSON 数组)异步学习(manual / identify 默认开启) | | product learn --agent <id> --url <URL...> [--source <type>] [--no-identify] | 通过商品 URL 异步学习(manual / identify 默认开启) | | product identify-all --agent <id> | 一键增强学习当前 Agent 下所有待增强商品 | | product sync-taobao --agent <id> [--skip-hash-check] [--sync-type <full\|incremental>] | 触发淘宝店铺商品同步 | | product sync-taobao-item --agent <id> --product-id <商品ID> | 触发单个淘宝商品同步 | | product related-knowledge list --agent <id> --product-id <商品ID> | 列出商品详情绑定的 QA / 扩展知识库文件 | | product related-knowledge add --agent <id> --product-id <商品ID> --type <qa\|common> (--file <文件名> \| --file-id <id> --partition-id <id>) | 给商品追加关联知识库文件 | | product related-knowledge remove --agent <id> --product-id <商品ID> --type <qa\|common> --file-id <id> | 移除商品绑定的指定知识库文件 | | product related-knowledge set --agent <id> --product-id <商品ID> --bindings <json\|@file> | 覆盖商品绑定的全部知识库文件 |

product update 支持更新的字段包括:卖点补充知识tag参数轮播图识别结果商品详情页识别结果 等。--update 接受 JSON 字符串或 @文件路径

product addproduct learn 走同一个上传接口(/v1/knowledge/products/upload),区别在于载荷:add 传结构化商品数据 product_items(已抓好的商品详情 JSON 数组),learnproduct_urls(让后端去抓)。--data 接受 JSON 字符串或 @文件路径;传单个对象会自动包成数组,传 JSON 基本类型(数字 / 字符串等)会直接报错;--source 默认 manual--no-identify 关闭自动识别。

product learn 提交商品详情页 URL 进入异步学习队列(/v1/knowledge/products/upload),返回 flow_idknowledge_ids--url 可多值,用空格分隔;--source 默认 manual;传 --no-identify 可关闭自动识别。

product identify-all 对接 POST /v1/knowledge/products/identify/all,会为当前 Agent 一键提交所有“已可用但尚未增强”的商品进入增强学习队列。它不是全量重学;当没有待增强商品时,服务端会返回“暂无需要识图的商品”。

product sync-taobao / product sync-taobao-item 调用 customer-servhub-api 的授权店铺同步接口,要求 --agent 已唯一绑定一个淘宝授权店铺。前者支持 --sync-type full|incremental,默认 full;后者按 product_id 补同步单个淘宝商品。

注意:这两个命令仅对已开通“高级工具”的店铺 Agent 生效。未开通高级工具时,即使 --agent 已绑定淘宝授权店铺,请求也可能在服务端失败。

product related-knowledge 管理商品详情的“关联知识库”文件级绑定。--type qa 对应 FAQ 知识库,--type common 对应扩展知识库。add / remove 会先读取当前绑定,再通过服务端全量替换接口写回;重复添加或移除不存在的文件保持幂等。--file <文件名> 会按当前 Agent 的知识库文件列表做精确匹配;文件名不存在或不唯一时,改用 --file-id + --partition-id 显式模式。

# 更新卖点
cs-cli product update --agent <id> --product-id <商品ID> --update '{"卖点":"新卖点内容"}'

# 更新标签
cs-cli product update --agent <id> --product-id <商品ID> --update '{"tag":"[\"春季新品\",\"热卖\"]"}'

# 添加商品补充知识
cs-cli product update --agent <id> --product-id <商品ID> --update '{"补充知识":"[{\"question\":\"问题\",\"answer\":\"回答\"}]"}'

# 更新 SKU 补充知识(按 SKU 名称定位)
cs-cli product update-sku --agent <id> --sku "颜色分类:粉红" --update '{"补充知识":"说明内容"}'

# 更新 SKU 补充知识(按 sku_id 定位,推荐)
cs-cli product update-sku --agent <id> --sku-id 6072595054179 --update '{"补充知识":"说明内容"}'

# 给商品绑定一个 FAQ 文件
cs-cli product related-knowledge add --agent <id> --product-id <商品ID> --type qa --file "常见问题.xlsx"

# 显式 ID 模式绑定扩展知识文件
cs-cli product related-knowledge add --agent <id> --product-id <商品ID> --type common --file-id 622474 --partition-id 12345 --file-name "售后规则.md"

活动管理 (activity)

活动 V2(Issue #34)增删改查 + per-tenant V2 总开关。服务端 customer-servhub-api /v1/activity*;契约详情参见 docs/devkit/specs/2026-05-28-activity-v2-api-reference.md

| 命令 | 说明 | | --- | --- | | activity list --agent <id> [--page N] [--page-size N] [--search <text>] | 列出活动(返回 total / v2_activity_enabled / items[]) | | activity by-product --agent <id> --product-id <id> | 按 product_id 反查当前生效活动(仅 enabled、product_scope='all' 必入) | | activity create --data <json\|@file> | 创建活动(payload 见 IActivityWritePayload) | | activity update <activity_id> --data <json\|@file> | 整体更新活动(products 整组替换,非增量) | | activity set-enabled <activity_id> --enabled <true\|false> | 切换单条活动启用状态(仅写 enabled) | | activity delete <activity_id> | 软删活动 + 级联软删关联 | | activity v2-enabled --agent <id> --enabled <true\|false> | per-tenant 启停 V2 链路 |

  • --agent <id> 对应服务端 customer_agent_config_id(与 sa / product 命令同口径)。
  • activity create / update payload 必填:customer_agent_config_idactivity_nameeffective_typeactivity_ruleeffective_type=time_range 要求 start_time + end_timeproduct_scope='specific'(缺省)要求 products ≥ 1
  • 业务失败(参数非法 / 跨 workspace / 不存在)服务端返 HTTP 200 + code:400,CLI 转为 exit 1 并打印 INVALID_PAYLOAD: …
# 列出活动
cs-cli activity list --agent <cfg_id> --search 返现

# 按商品反查
cs-cli activity by-product --agent <cfg_id> --product-id 914494989518

# 创建活动(从文件读 payload)
cs-cli activity create --data @activity.json

# 整体更新
cs-cli activity update 6 --data @activity.json

# 列表行 toggle 启用
cs-cli activity set-enabled 6 --enabled false

# 软删活动
cs-cli activity delete 6

# 为某 agent 启用 V2 链路
cs-cli activity v2-enabled --agent <cfg_id> --enabled true

节点模板 (node-template)

高级模板(4 真节点提示词 + image_understanding 图片理解方法论伪 stage)操作:编写说明书 + 获取内容 + 改动发布 + 历史/回溯。服务端 customer-servhub-api /v1/customer-agent/{config_id}/customer_config/node-templates*;契约见 docs/devkit/specs/2026-06-08-节点模板-cli-操作面.md节点 stage:planner|composer|qa_inspector|image_understandingtool_selector 暂不放出)。

高级模式开关已改为客户自助(在 cs-client 内开关),CLI 不再提供 enroll / enroll-status 开启路径(已下线)。

| 命令 | 说明 | | --- | --- | | node-template describe [--stage <s>] | 节点编写说明书(AI 编写前必读):每节点职责/可编辑面/输出契约/平台锁定段 + 可 @引用 变量目录;纯静态、无需 --agent | | node-template get --agent <id> [--stage <s>] | 获取内容(不传 stage=全部已开放节点) | | node-template set-draft --agent <id> --stage <s> (--content <t>\|--content-file <p>\|--stdin) | 写单节点草稿(整段覆盖;空串=回落出厂默认) | | node-template publish --agent <id> --stage <s> [--force] | 发布草稿上线(发布前校验 {{}}--force 越过) | | node-template versions --agent <id> --stage <s> | 列该节点历史 | | node-template version --agent <id> --stage <s> --version <n> | 取某版本正文 | | node-template restore --agent <id> --stage <s> --version <n> | 回溯某版本成草稿(需再 publish) |

典型流(该 agent 已由客户在 cs-client 开启高级模式后):get 看现状 → set-draft 改草稿 → publish 上线。publish 会拒绝含非法 {{插值}} 名的草稿(笔误防呆)。

工单管理 (issue)

| 命令 | 说明 | | ------------------------------------------------------------------------------------------ | ------ | | issue list [--agent <id>] [--status <状态>] [--priority <优先级>] [--start <日期>] [--end <日期>] | 列出工单 | | issue get <issue_id> | 获取工单详情 | | issue create --title <标题> --content <内容> [--priority <优先级>] [--tags <标签>] | 单条创建工单 | | issue create --file <path> \| --stdin [--dry-run] [--concurrency <n>] [--yes] | 批量创建工单(JSON 协议见下) | | issue update <issue_id> --data <json|@file> | 单条更新工单 | | issue update --ids <a,b,c> \| --ids-file <path> --data <json|@file> [--dry-run] [--concurrency <n>] [--yes] | 批量更新工单字段(串行 PATCH) | | issue update-owner <issue_id> --owner <user_id\|花名> | 单条改派负责人(花名自动解析) | | issue update-owner --ids <a,b,c> \| --ids-file <path> --owner <user_id\|花名> [--dry-run] [--yes] | 批量改派负责人(走 cs-admin BFF,原子改派 + 自动 Feishu/DingTalk 通知,单批 ≤ 200) | | issue stats [--start <日期>] [--end <日期>] | 各工作空间 Issue 统计(open/closed/total) | | issue comment list <issue_id> | 列出工单评论 | | issue comment add <issue_id> --content <内容> | 添加评论 |

批量写约定(update / update-owner / create --file

  • --ids "a,b,c"--ids-file path.txt(一行一个 id,# 注释、空行忽略)互斥;与单条 <issue_id> 互斥。
  • --owner 同时接受 user_id(≤ 7 位纯数字)和工程师花名。花名经 cs-admin /api/account-roles 解析(KA + SMB 合并去重,5 分钟内存 cache),同名 / 模糊歧义会报错列 candidates。--owner 拒绝 11 位手机号(Issue #49,老 --owner-phone 0.5.0 起硬删)。
  • --dry-run 在所有批量子命令上都不会调写接口;create --file --dry-run 会真跑 user_name → conversation_id 反查,以便提前发现 NOT_FOUND / AMBIGUOUS
  • N ≥ 20 且 stdout 是 TTY 时弹二次确认(输入 yes);非 TTY 必须显式 --yes,否则拒收。
  • 末尾报告统一 schema:{version:"1", total, success_count, failed_count, skipped_count, aborted, success_ids[], failed[{id,code,msg}], skipped[{id,reason}]}。退出码:0 全成功 / 1 全失败 / 2 部分失败 / 130 SIGINT。
  • update-owner --ids 走 cs-admin BFF POST /api/workbench/issues/batch-owner 单次调用(原子),返回 {updated, skipped:[{issueId, reason}], notify[]},与 update 的 runBatch 报告 schema 不同(保留 BFF 原样)。
  • 双后端单 token:servhub Bearer JWT 同时通过 cs-admin BFF 鉴权(实测验证),无需额外登录。

issue create --file JSON 协议

文件解析交给上游(LLM/Agent/脚本)整理成下面这份结构化 JSON,CLI 只做校验 + 反查 + 拼装 + 批量创建。

{
  "version": "1",
  "workspace_id": "ws_xxx",          // 顶层,对所有 issue 生效;缺省时落到默认 workspace
  "issues": [
    {
      "title": "客户反馈:A 问题答非所问",   // 必填
      "priority": "high",              // 必填,critical|high|medium|low
      "expected": "应该回答 X",          // 必填,CLI 把它写进 content 的 ## Expected 段
      "description": "上下文描述",       // 可选,拼在 expected 前面
      "conversation_id": "conv_xxx",   // 与 user_name 二选一
      "user_name": "张三",              // 仅给昵称时,CLI 调 /v1/chat/conversations?user_name= 反查
      "tags": ["badcase"],             // 可选
      "source_type": "manual_review",  // 可选
      "source_data": {"reviewer": "..."} // 可选
    }
  ]
}

CLI 把 description + expected 拼成 content

{description}(如有)

## Expected
{expected}

user_name 反查规则(5 分钟内存 cache,key = ${workspaceId}|${userName}):

  • 1 条命中 → 用其 conversation_id
  • 0 条 → 该 issue 标记 NOT_FOUND,整批拒收(防止半批进创建)
  • 多条 → 该 issue 标记 AMBIGUOUS,提示改传显式 conversation_id

priority 不在枚举内、title/expected 缺失等 → 客户端直接拒收(不打任何接口)。

聊天记录 (chat-history)

查询客户导入的聊天记录,用于 SA(场景动作)清洗,非 Agent 自身的对话记录。

| 命令 | 说明 | | ------------------------------------------------------ | --------------- | | chat-history --agent <id> [--page N] [--page-size N] | 查询客户导入的聊天记录 |

FAQ 知识库 (faq)

| 命令 | 说明 | | ---------------------------------------------------------------------------- | --------- | | faq list --agent <id> | 列出 FAQ 文件 | | faq content --agent <id> --file <文件名> [--keyword <词>] [--page-size <n>] [--next-group-id <id>] | 列出文件内答案组(含 answer_group_id / 问题 / 答案) | | faq add --agent <id> --file <文件名> --questions <问题1,问题2> --answers <答案=xxx> | 添加 FAQ 内容 | | faq update --agent <id> --file <文件名> --group-id <id> [--questions <...>] [--answers <...>] [--delete-chunks <id1,id2>] | 更新已有 FAQ 答案组(--questions / --answers / --delete-chunks 至少一个) | | faq delete --agent <id> --file <文件名> --group-id <id> | 删除 FAQ 答案组 | | faq bind-products list --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) | 列出 FAQ 文件绑定的商品 | | faq bind-products add --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 给 FAQ 文件追加绑定商品 | | faq bind-products remove --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 从 FAQ 文件移除绑定商品 | | faq bind-products set --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 覆盖 FAQ 文件绑定的全部商品 |

faq contentGET /mebsuta/api/v1/dataset/{knowledge_id}/faq_contents,列出文件内的答案组及其 answer_group_id,是 faq update / faq delete--group-id 的来源(faq list 只给文件,文件内的 group-id 要靠这条命令查)。支持 --keyword 搜索、--page-size 分页、--next-group-id 游标续翻。

faq updateanswer_group_id 定位目标组,POST 同一个 faq_contents/save 接口完成字段替换、问题替换与 chunk 级删除。faq deleteDELETE /faq_contents/{group_id} 整组删除。

faq bind-products 固定写入 knowledge_type=qa 的商品绑定关系,适合从 FAQ 文件视角批量维护关联商品。--file 为精确文件名匹配;文件名不唯一时请传 --file-id--partition-id

扩展知识库 (knowledge)

Agent 关联的通用规则知识库(suffix_type=_common),与 FAQ / 商品知识并列的第三类知识源,支持段落(chunk)级 CRUD,统一走 /mebsuta/api/v1/dataset/{id}/contents/perform-operations

| 命令 | 说明 | | --- | --- | | knowledge list --agent <id> [--page N] [--page-size N] | 列出 Agent 关联的扩展知识库文件 | | knowledge content list --knowledge-id <id> [--page-size N] [--direction up\|down] | 列出段落(chunk) | | knowledge content add --knowledge-id <id> --content <text\|@file> [--keyword <k...>] [--after <chunk_id>] | 新增段落 | | knowledge content update --knowledge-id <id> --chunk-id <id> [--content <text\|@file>] [--keyword <k...>] [--enable \| --disable] | 更新段落(四个变更字段至少一个;未指定 --enable / --disable 时自动保留当前启停状态,避免后端 enable 必填校验失败) | | knowledge content delete --knowledge-id <id> --chunk-id <id> | 删除段落 | | knowledge bind-products list --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) | 列出扩展知识文件绑定的商品 | | knowledge bind-products add --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 给扩展知识文件追加绑定商品 | | knowledge bind-products remove --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 从扩展知识文件移除绑定商品 | | knowledge bind-products set --agent <id> (--file <文件名> \| --file-id <id> --partition-id <id>) --product-id <商品ID...> | 覆盖扩展知识文件绑定的全部商品 |

knowledge content add / update--content 支持 @路径 前缀从文件读取纯文本(不是 JSON)。--keyword 为 variadic 选项,空格分隔多个关键词。

knowledge bind-products 固定写入 knowledge_type=common 的商品绑定关系,适合从扩展知识文件视角批量维护关联商品。add / remove 会 read-modify-replace,重复添加或移除不存在的商品保持幂等。

会话管理 (conversation)

| 命令 | 说明 | | -------------------------------------------------------------------------------- | -------- | | conversation list [--agent <id>] [--equipment-id <设备ID>] [--user <用户名>] [--start <日期>] [--end <日期>] | 搜索会话 | | conversation records <conversation_id> [--page-size N] [--direction prev|next] | 获取会话聊天记录 | | conversation context-search --query <文本> [--start <时间>] [--end <时间>] | 通过上下文内容模糊搜索对话记录(返回匹配消息详情,时间范围最多 3 天) | | conversation transfer-human --agent <customer_agent_config_id> --start <时间> --end <时间> [--page N] | 查询转人工会话及对应转人工消息记录(时间范围最多 7 天,分页大小固定 100) |

Agent 调试 (debug)

| 命令 | 说明 | | ----------------------------------------------------------------------------------------------------------- | -------------------- | | debug ask --agent <id> --text <消息> [--user <用户名>] [--url <图片URL>] [--conversation <会话ID>] [--timeout <秒>] | 向 Agent 发送消息并等待回复 | | debug reproduce <record_id> [--agent <id>] [--timeout <秒>] [--dry-run] | 根据 record_id 复现 Agent 回复(自动获取上下文) | | debug record <record_id> | 获取记录的调试信息(flow_info),返回中包含 trace_id | | debug trace <trace_id> [--env <dev\|prod>] | 根据 Langfuse Trace ID 获取完整 Trace 详情(经服务端代理,默认 prod) |

debug ask 会自动创建调试会话、发送消息、轮询等待 Agent 回复,默认最大等待 30 秒。支持 --messages 传入完整消息列表(JSON 或 @文件)重放 issue 对话。

debug reproduce 根据一条回复记录自动复现 Agent 回复:通过 recordId 获取关联会话和 Agent 配置,拉取完整会话记录并截取目标 record 之前的上下文,使用原始用户名创建新 debug 会话并发送。--agent 可指定另一个 Agent 复现同一段上下文(A/B 对比),--dry-run 仅输出上下文不发送。

debug trace(v0.4.0 起,行为变更)不再由 CLI 直连 Langfuse REST API,改为请求 customer-servhub-api 的 GET /v1/debug/langfuse/trace/{trace_id}?env=<env>,走 CLI 标准 Bearer 鉴权,由服务端按 env 选择 Langfuse 凭据并代理拉取 Trace。Trace ID 从 debug record 返回的 trace_id 字段获取。

工作空间 (workspace)

| 命令 | 说明 | | --- | --- | | workspace list | 列出当前账号可访问的工作空间 | | workspace points-consumes [--page <n>] [--page-size <n>] | 分页查询积分账户消耗流水,固定返回 extra 调试字段 | | workspace points-consumes-daily [--start <YYYY-MM-DD>] [--end <YYYY-MM-DD>] | 按天查询积分消耗趋势 |

  • --env <dev|prod>:指定 Langfuse 环境,默认 prod。只接受 dev / prod,传其它值命令直接报错并以非 0 退出(不发请求)。
# 默认 prod 环境
cs-cli debug trace <trace_id>

# 指定 dev 环境
cs-cli debug trace <trace_id> --env dev

迁移(v0.4.0 BREAKING)config set --langfuse-host / --langfuse-public-key / --langfuse-secret-keyCLIConfig.langfuseHost / langfusePublicKey / langfuseSecretKey 已移除;环境变量 LANGFUSE_BASE_URL / LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY 在 CLI 侧不再被读取。~/.cs-cli/config.json 中相关字段可直接删除。Langfuse 连接信息(含 dev/prod 双环境凭据)现由 customer-servhub-api 服务端的 system_configlangfuse_config 行统一管理(不再读服务端环境变量 / 内置常量),CLI 侧无需也无法再配置。

修复记录 (repair-record)

| 命令 | 说明 | | --- | --- | | repair-record list [--issue <工单ID>] [--agent <AgentID>] [--workspace <工作空间ID>] [--page N] [--page-size N] | 列出修复记录 | | repair-record create --issue <工单ID> --agent <AgentID> --action <修复动作> [--agent-name <名称>] [--type <类型>] [--status <状态>] [--duration <毫秒>] [--result <JSON>] [--workspace <工作空间ID>] | 创建修复记录 | | repair-record update <record_id> --data <json\|@file> | 更新修复记录 |

--status 可选值:pendingsuccessfailedpartial

repair-record update--data 支持的字段:repair_actionrepair_result(JSON 对象)、repair_typerepair_statusduration_ms

repair_result 结构

--result--data 中的 repair_result 字段应为结构化 JSON,用于记录 AI 修复的完整推理过程,支持未来 AI 自我进化。

| 字段 | 类型 | 说明 | | --- | --- | --- | | failure_type | string | 问题分类: wrong_answer / missing_answer / hallucination / wrong_routing / slow_response / other | | root_component | string | 归因组件: sa_policy / faq / product_knowledge / customer_config / prompt / multiple / unknown | | input | string | 触发问题的用户输入 | | expected | string | 期望的正确回复 | | actual | string | 实际的错误回复 | | diagnosis_reasoning | string | AI 的诊断推理过程:排查了什么、怎么定位根因、排除了哪些可能性(最高价值字段) | | diagnosis_confidence | string | 诊断置信度: high / medium / low | | hypotheses_considered | array | 考虑过的假设列表,每项含 hypothesisevidence_forevidence_againstverdict | | fix_strategy | string | 修复策略: create_sa / update_sa / delete_sa / update_faq / add_faq / update_product / update_config / multi_step | | fix_reasoning | string | AI 的修复决策推理:为什么选这个方案、为什么不选其他方案、预期风险和收益 | | alternatives_rejected | array | 被否决的方案列表,每项含 approachreason | | changes | array | 变更快照,每项含 componentactiontarget_idbeforeafter | | target_fixed | boolean | 目标问题是否修复 | | regression_summary | string | 回归验证结果摘要 | | retry_history | array | 重试记录,每项含 roundwhat_failedlessonadjustment | | duration_ms | number | 修复总耗时(毫秒) | | repair_status | string | 最终状态: success / failed / partial | | resolved_date | string | 修复完成时间(ISO 格式) |

加粗的两个字段diagnosis_reasoningfix_reasoning)是对 AI 自我进化价值最大的:没有它们只能做模式匹配,有了它们才能做推理。

运维操作记录 (ops-record)

| 命令 | 说明 | | --- | --- | | ops-record list [--workspace <工作空间ID>] [--agent <AgentID>] [--page N] [--page-size N] | 列出运维操作记录 | | ops-record get <record_id> | 获取运维操作记录详情 | | ops-record create --workspace <工作空间ID> --agent <AgentID> [--workspace-name <名称>] [--agent-name <名称>] [--path <文件路径>] [--remark <备注>] | 创建运维操作记录 | | ops-record update <record_id> --data <json\|@file> | 更新运维操作记录 | | ops-record delete <record_id> | 删除运维操作记录(软删除) |

ops-record update--data 支持的字段:workspace_nameagent_namepathremark

创建记录时 operator_idoperator_name 自动从当前登录用户获取,无需手动指定。

商品变更事件消费 (change-consumer)

客服运维助手订阅并消费商品变更事件(pull 模式)。后端走 /v1/change-consumers/*,CLI 标准 Bearer 鉴权。默认 consumer_key=ops_agent_assistant

标准工作流:sub create 创建订阅 → delivery list 轮询待消费项 → delivery claim 认领 → 处理 → delivery complete 回写。

| 命令 | 说明 | | --- | --- | | change-consumer sub create --workspace-id <id> [--agent-config <id>] [--events <list>] [--resource-type product] [--consumer-key <key>] [--consumer-name <名称>] [--disabled] [--data <json\|@file>] | 创建订阅(最简只需 --workspace-id--agent-config 缺省表示该工作空间全部商品事件) | | change-consumer sub list [--workspace-id <id>] [--agent-config <id>] [--consumer-key <key>] [--enabled <true\|false>] [--page N] [--page-size N] | 查询订阅列表 | | change-consumer sub update <subscription_id> --data <json\|@file> | 更新订阅(enabled / events / filters / consumer_name) | | change-consumer delivery list [--workspace-id <id>] [--agent-config <id>] [--consumer-key <key>] [--statuses <list>] [--cursor-created-at <iso>] [--cursor-delivery-id <id>] [--limit N] | 查询待消费项(不传 --statuses 时后端默认返回 pending/claimed/failed;--cursor-* 做增量拉取) | | change-consumer delivery claim <delivery_id> --claimed-by <id> [--consumer-key <key>] [--lease-seconds N] | 认领待消费项(已被其他实例认领且未过期时认领失败) | | change-consumer delivery complete <delivery_id> --status <completed\|ignored\|failed> [--result-action <action>] [--result-note <note>] [--last-error <error>] [--consumer-key <key>] [--data <json\|@file>] | 回写处理结果 |

  • sub create 默认 --events product.updated,product.deleted--resource-type product--disabled 创建为停用态(默认启用)。
  • delivery complete--status 仅接受 completed / ignored / failed,其它值直接报错退出;不要长时间停留在 claimed 不回写。
  • --result-action 建议值:supplemental_knowledge / product_association / rerun_product_study / refresh_recommended_qa / ignore_change / manual_follow_up
  • 各子命令 --data <json|@file> 为高级用法,提供时覆盖对应结构化选项。
# 1. 创建订阅(该工作空间全部商品 更新/删除 事件)
cs-cli change-consumer sub create --workspace-id <ws> --events product.updated,product.deleted

# 2. 轮询待消费项
cs-cli change-consumer delivery list --workspace-id <ws> --statuses pending

# 3. 认领
cs-cli change-consumer delivery claim <delivery_id> --claimed-by ops-assistant-1

# 4. 处理后回写
cs-cli change-consumer delivery complete <delivery_id> --status completed \
  --result-action supplemental_knowledge --result-note "已补充商品知识"

运营监控 (monitor)

直接调用 /v1/operation 底层接口,返回原始数据,由调用方决定如何聚合统计。

Agent 生命周期

| 命令 | 说明 | | --- | --- | | monitor agents [--page N] [--page-size N] | Agent 生命周期列表(含构建进度、会话统计等原始数据) |

监控工单

| 命令 | 说明 | | --- | --- | | monitor tickets list [--agent <id>] [--status <状态>] [--severity <级别>] | 列出监控工单 | | monitor tickets delete <ticket_id> | 删除监控工单 |

监控快照

| 命令 | 说明 | | --- | --- | | monitor snapshots hourly --agent <id> --start <ISO> --end <ISO> | 查询小时快照 | | monitor snapshots daily --agent <id> --start <日期> --end <日期> | 查询日快照 | | monitor snapshots daily-range --agent <id> --start <日期> --end <日期> | 查询日快照范围(含趋势) |

Agent 运营统计

| 命令 | 说明 | | --- | --- | | monitor statistics [--start <ISO> --end <ISO>] [--page N] [--page-size N] | Agent 运营统计(会话量、转人工率、响应时间等) |

运营工作空间

| 命令 | 说明 | | --- | --- | | monitor workspaces [--has-agent] [--page N] [--page-size N] | 运营工作空间列表(含合同、客户信息) |

测试集 (testset)

测试集驱动 Agent 回归验证:测试集(testset)下挂多条用例(case),执行后产生批次(batch)。CLI 让上层 Agent / 工程师本地 debug 无需开浏览器即可走完「触发 → 拉结果 → 改用例 → 重跑」闭环。所有测试集相关命令收敛在 testset 主语下(ADR-001b)。

测试集 CRUD

| 命令 | 说明 | | --- | --- | | testset list --customer-agent-config-id <id> | 列出测试集(分页,Agent ID 必填) | | testset create --customer-agent-config-id <id> --file <cases.xlsx> [--name ...] [--description ...] [--use-type ...] | 通过 xlsx 模板上传创建测试集 | | testset show <id> | 测试集详情 | | testset update <id> [--name ...] [--description ...] [--data @file.json] | 更新测试集元数据(至少一项) | | testset delete <id> | 软删除测试集 | | testset copy <id> [--name <副本名>] | 克隆测试集(含用例,不带历史批次) | | testset get-eval-prompt <id> [--raw] | 查看评估 Prompt;--raw 输出裸文本到 stdout | | testset set-eval-prompt <id> --prompt <s\|@file> | 设置评估 Prompt(@file 读纯文本,不 JSON.parse) |

用例(testset case,全部必填 --testset

| 命令 | 说明 | | --- | --- | | testset case list --testset <id> | 列出测试集下用例(分页) | | testset case show <case_id> --testset <id> | 查看单条用例(内部翻页 + 本地 filter) | | testset case create --testset <id> --data @file.json | 新增用例(case_content 必填,至少 1 条对话) | | testset case update <case_id> --testset <id> --data @file.json | 更新用例 | | testset case delete <case_id> --testset <id> | 软删除用例 |

批次只读(testset batch

| 命令 | 说明 | | --- | --- | | testset batch list [--testset <id>] [--status <s>] | 列出批次(缺 --testset 时列全 workspace) | | testset batch show <batch_id> | 批次详情(含执行记录) | | testset batch status <batch_id> | 轻量批次状态(含 is_terminal / total_count / pass_count / fail_count) |

触发命令(testset run / run-case / export

| 命令 | 说明 | | --- | --- | | testset run --testset <id> --agent <id> [--wait] [--timeout <sec>] | 触发整批回归。默认异步立刻返回 batch_id--wait 切同步阻塞 poll 到终态 | | testset run-case --batch <id> --case <id> | 单跑用例(覆盖写回该批次) | | testset export --testset <id> --batch <id> --output <path> | 导出批次为 xlsx 落盘 |

⚠️ run --wait 协议(详见 ADR-002)

  • Poll 间隔 3000ms,默认超时 600 秒;--timeout <sec> 覆盖(单位是秒,与全局 --request-timeout 的毫秒严格区分
  • 终态判定锚定后端 is_terminal 字段(不枚举 status 字面量,避免后端新增字面量时 CLI 卡死)
  • 退出码中立:批次 pass_count=0、status=failed、超时未完成全部 exit 0;只有 CLI 自身失败(鉴权 / 网络 / 参数错误 / poll 连续 3 次失败)才非 0
  • Poll 单次失败容错:连续 < 3 次抛错继续,3 次中断;中断时 lastErrorAPIError(2/401)exit 2,否则 exit 3
  • 超时仍 exit 0 + 输出 {success:true, data:{batch_id, status:<最后状态>, is_terminal:false, timeout:true, elapsed_sec, ...}},调用方判 is_terminal 而非 status 字面量

长文本输入:所有可能超过命令行长度的字段统一 @文件路径 前缀(沿用现有 @file 约定,详见 ADR-003)。例如 case create --data @case.json 走 JSON 解析;testset set-eval-prompt --prompt @prompt.md 走纯文本。

xlsx 二进制输出export --output <path> 必填路径,stdout 仅承载 JSON 报告 {success:true, data:{path, bytes}},不支持 stdout pipe(避免与 JSON-by-default 冲突)。

数据看板 (dashboard)

转人工率 / 接待量 / AI 回复量等运营指标。数据 T+1--end 不能晚于昨天,否则后端返回 400);--start / --end闭区间。渠道枚举:qianniu(千牛/淘宝)/ jingdong / pinduoduo / douyin。CLI 只产结构化数据,运营报告由上层(如 LLM)按场景加工。

| 命令 | 说明 | | --- | --- | | dashboard summary [--config-id <id>] [--start <d>] [--end <d>] [--channel <c>] | 全局或单店 KPI 汇总 + 环比(不传 --config-id 为全店铺聚合) | | dashboard trend [--config-id <id>] [--start <d>] [--end <d>] [--granularity day/week/month] [--channel <c>] | 趋势(每日/周/月接待客户数、转人工数、转人工率),--granularity 默认 day | | dashboard shops [--start <d>] [--end <d>] [--channel <c>] | 全部店铺统计列表(默认按转人工客户数降序),用于横向对比 | | dashboard export --start <d> --end <d> [--config-id <id> ...] [--channel <c>] [--out <path>] | 店铺维度每日明细。默认解析为 JSON 行;--out 落盘原始 CSV。--config-id 可重复传,不传=全部店铺 | | dashboard intent --config-id <id> [--start <d>] [--end <d>] | 单店各意图(一级/二级标签)消息级转人工统计,默认按转人工消息数降序 | | dashboard intent-conversations --config-id <id> --event-one <l> --event-two <l> [--start <d>] [--end <d>] [--page <n>] [--page-size <n>] | 某意图下会话列表下钻 |

口径要点

  • summary / trend / shops / intent 直接透传后端 JSON(total_customers / transfer_rate / avg_* 等英文 key)。
  • export 把 CSV 表头映射为稳定英文 key:date / shop_name / channel / customers / ai_independent_customers / ai_independent_rate / transfer_customers / transfer_rate / ai_reply_messages;计数字段转 number,比率字段保留原始字符串(如 "46.0%")。
  • 接待客户数(customers) 按客户去重,是看板口径的"会话/接待量";AI 回复消息数(ai_reply_messages) 是真实 AI 回复条数;对话轮次 ≈ ai_reply_messages / customers
  • dashboard export --out <path> 落盘原始 CSV 时,stdout 仅返回 {path, bytes, count}

输出格式

默认输出 JSON:

{
  "success": true,
  "data": { ... }
}

错误时:

{
  "success": false,
  "error": { "code": 1, "message": "错误信息" }
}

使用 --table 选项可以表格形式输出。

退出码

| 退出码 | 含义 | | --- | ------------------- | | 0 | 成功 | | 1 | 业务错误 / 批量全部失败 | | 2 | 认证错误(未登录或 Token 过期) / 批量部分失败 | | 3 | 网络/服务器错误 | | 130 | 批量执行中收到 SIGINT,等飞行中请求结束后退出 |

使用示例

# 测试 Agent 回复
cs-cli debug ask --agent a0901fe383064c2abefb0bf1cd52988e --text "你好"

# 获取调试信息(返回 flow_info 和 trace_id)
cs-cli debug record <record_id>

# 根据 trace_id 查询 Langfuse Trace 详情
cs-cli debug trace <trace_id>

# 各工作空间 Issue 统计
cs-cli issue stats --start 2026-03-01 --end 2026-03-23

# 列出工单(按日期筛选)
cs-cli issue list --agent <id> --start 2026-03-01T00:00:00 --end 2026-03-22T23:59:59

# 批量改派(花名 → user_id 自动解析,走 cs-admin BFF 原子改派 + 飞书通知)
cs-cli issue update-owner --ids iss-1,iss-2,iss-3 --owner xinghe --yes

# 批量改派 dry-run(不写):仅解析 owner + 列出 ID
cs-cli issue update-owner --ids iss-1,iss-2 --owner xinghe --dry-run

# pipe-first:先 list 拿 id,再 xargs 批量改派
cs-cli issue list --status open --priority high \
  | jq -r '.data.items[].issue_id' | tr '\n' ',' \
  | xargs -I{} cs-cli issue update-owner --ids "{}" --owner xinghe --yes

# 批量关闭工单(串行 PATCH,部分失败末尾报告)
cs-cli issue update --ids iss-1,iss-2,iss-3 --data '{"status":"closed"}' --yes

# 从文件批量创建工单(user_name 反查 + content 拼装在 CLI 完成)
cs-cli issue create --file ./issues.json --dry-run    # 先预览,发现 NOT_FOUND/AMBIGUOUS
cs-cli issue create --file ./issues.json --yes        # 确认 → 实际创建

# 上游 LLM 直接 pipe 进 stdin
cat meeting-notes.md \
  | <llm-extract-issues> \
  | cs-cli issue create --stdin --yes

# 搜索场景动作
cs-cli sa search --agent <id> --keyword "退款"

# 创建场景动作
cs-cli sa create --agent <id> --first-label "售后咨询" --second-label "退款" --situation "用户要求退款" --action "引导用户提交退款申请"

# 查看场景动作修改记录
cs-cli sa versions --agent <id> --id 3

# 使用 JSON 文件更新 Agent
cs-cli agent update <config_id> --data @config.json

# 更新商品卖点
cs-cli product update --agent <id> --product-id 977691714398 --update '{"卖点":"新卖点"}'

# 更新商品标签
cs-cli product update --agent <id> --product-id 977691714398 --update '{"tag":"春季新品,热卖"}'

# 更新 SKU 补充知识(按 sku_id 定位,推荐)
cs-cli product update-sku --agent <id> --sku-id 6072595054179 --update '{"补充知识":"粉红色为浅粉调"}'

# 添加 FAQ
cs-cli faq add --agent <id> --file "常见问题" --questions "怎么退款,如何退款" --answers "答案=请联系客服处理退款"

# 列出文件内答案组(拿 answer_group_id,供下面 update/delete 用)
cs-cli faq content --agent <id> --file "常见问题" --keyword 退款

# 更新已有 FAQ 组答案
cs-cli faq update --agent <id> --file "常见问题" --group-id 2 --answers "答案=请通过订单页面申请退款"

# 更新 FAQ 组问题 + 删除旧 chunk
cs-cli faq update --agent <id> --file "常见问题" --group-id 2 --questions "如何退款,怎么申请退款" --delete-chunks 3,5

# 删除整个 FAQ 答案组
cs-cli faq delete --agent <id> --file "常见问题" --group-id 2

# 列出 Agent 的扩展知识库
cs-cli knowledge list --agent <id>

# 列出某扩展知识库的段落
cs-cli knowledge content list --knowledge-id 622474

# 新增段落(插入到末尾)
cs-cli knowledge content add --knowledge-id 622474 --content "退换货需保留商品吊牌" --keyword 退换货 吊牌

# 用文件内容作为段落
cs-cli knowledge content add --knowledge-id 622474 --content @./rules.txt

# 修改段落内容并重设关键词
cs-cli knowledge content update --knowledge-id 622474 --chunk-id 2 --content "新的规则说明" --keyword 规则 说明

# 停用某段落
cs-cli knowledge content update --knowledge-id 622474 --chunk-id 2 --disable

# 删除段落
cs-cli knowledge content delete --knowledge-id 622474 --chunk-id 2

# 商品 URL 异步学习
cs-cli product learn --agent <id> --url https://detail.tmall.com/item.htm?id=997678657962

# 多个 URL 一次提交,且跳过自动识别
cs-cli product learn --agent <id> --url https://a.example/1 https://a.example/2 --no-identify

# 直接传入结构化商品数据(JSON 数组),或从文件读取
cs-cli product add --agent <id> --data '[{"title":"商品A","price":99}]'
cs-cli product add --agent <id> --data @products.json --source batch --no-identify

# 通过上下文内容模糊搜索对话记录(自动使用当前工作空间,查询窗口最多 3 天)
cs-cli conversation context-search --query "退款问题" --start 2026-03-22T00:00:00 --end 2026-03-22T23:59:59

# 查询转人工会话及对应转人工消息记录(按 MANUAL_TAKEOVER_REQUIRED 事件时间过滤,查询窗口最多 7 天)
cs-cli conversation transfer-human --agent <customer_agent_config_id> --start 2026-05-24T00:00:00 --end 2026-05-24T23:59:59

# 查询第 2 页转人工会话
cs-cli conversation transfer-human --agent <customer_agent_config_id> --start 2026-05-24T00:00:00 --end 2026-05-24T23:59:59 --page 2

# 复现某条回复(自动获取上下文、原始用户名、Agent 配置)
cs-cli debug reproduce <record_id>

# 用另一个 Agent 复现同一段上下文(A/B 对比)
cs-cli debug reproduce <record_id> --agent <other_config_id>

# 仅查看截断后的上下文,不实际发送
cs-cli debug reproduce <record_id> --dry-run

# 重放对话测试 Agent
cs-cli debug ask --agent <id> --messages @conversation.json

# 列出某工单的修复记录
cs-cli repair-record list --issue <issue_id>

# 创建修复记录
cs-cli repair-record create --issue <issue_id> --agent <agent_id> --action "更新 SA 策略"

# 更新修复记录状态
cs-cli repair-record update <record_id> --data '{"repair_status":"success","duration_ms":1200}'

# 列出运维操作记录
cs-cli ops-record list --workspace <workspace_id> --agent <agent_id>

# 创建运维操作记录
cs-cli ops-record create --workspace <workspace_id> --agent <agent_id> --remark "更新配置文件"

# 更新运维操作记录
cs-cli ops-record update <record_id> --data '{"remark":"已完成配置更新","path":"/data/config"}'

# 删除运维操作记录
cs-cli ops-record delete <record_id>

Ops Agent (ops-agent)

| 命令 | 说明 | | --- | --- | | ops-agent conversations [--agent-id <id>] [--customer-id <id>] [--page N] [--page-size N] | 查询客服助手会话列表 |

ops-agent conversations 对接 customer-servhub-api /v1/ops-agent/conversations,返回字段固定为 workspace_idcustomer_idtitleagent_idcreated_atupdated_at。命令会自动带当前 workspace-id--agent-id 对应 Ops Agent 配置 ID(customer_agent_config_id),--customer-id 可选。

# 查询当前 workspace 下某个客服运维助手的会话
cs-cli ops-agent conversations --agent-id <customer_agent_config_id>

# 按 customer 进一步过滤
cs-cli ops-agent conversations --agent-id <customer_agent_config_id> --customer-id <customer_id>