@kriston-ai/kst-im-cli
v0.0.9
Published
KST IM CLI 工具
Readme
kst-im-cli
快商通 IM 命令行工具,用于管理渠道账号、网页站点、查询统计看板和历史会话。
安装
npm install -g @kriston-ai/kst-im-cli需要 Node.js >= 18。
快速开始
# 登录
kst-im-cli auth login -k <API_KEY>
# Agent / CI:通过环境变量注入 key,无需 auth login
export KST_ONLINE_CLI_API_KEY=<API_KEY>
kst-im-cli channel type list
# 查看登录状态
kst-im-cli auth status
# 渠道账号
kst-im-cli channel type list
kst-im-cli channel account list --channelKey weixin
# 网页站点
kst-im-cli site list
kst-im-cli site get --siteId 118501
# 统计看板
kst-im-cli stats init
kst-im-cli stats basic-board channel --period today --accounts 101,102
kst-im-cli stats basic-board web --period today --sites 118501,118503
# 历史会话
kst-im-cli history schema
kst-im-cli history web --start "2026-06-01 00:00:00" --end "2026-06-03 23:59:59"
kst-im-cli history channel --start "2026-06-01 00:00:00" --end "2026-06-03 23:59:59"命令列表
| 命令 | 说明 |
|------|------|
| auth login -k <key> | 登录认证 |
| auth logout | 登出 |
| auth status | 查看登录状态 |
| config get <key> | 获取配置项 |
| config set <key> <value> | 设置配置项 |
| channel type list | 列出渠道类型 |
| channel type get --key <key> | 查询单个渠道类型 |
| channel account list [--channelKey <keys>] [--keyword <text>] | 列出渠道账号 |
| channel account get --accountId <id> | 查询单个渠道账号 |
| site list [--with-codes] | 列出网页站点 |
| site get --siteId <id> [--with-codes] | 查询单个站点 |
| stats init | 拉取并缓存统计基础数据 |
| stats basic-board channel | 渠道基础看板 |
| stats basic-board web | 网页站点看板 |
| history schema | 历史记录字段说明 |
| history web --start <time> --end <time> | 查询网页历史会话 |
| history channel --start <time> --end <time> | 查询渠道历史会话 |
输出格式
所有命令支持 --format 选项:
json— JSON 信封(默认):{ ok: true, data: ..., meta: { count: N } }table— 表格pretty— 格式化 JSON
统计看板用法
时间范围
--period 快捷值:today、yesterday、week、last-week
也可用自定义时间:--start "yyyy-MM-dd HH:mm:ss" --end "yyyy-MM-dd HH:mm:ss"
两者互斥。
筛选对象
--accounts <ids>:渠道账号 ID(逗号分隔,来源channel account list)--sites <ids>:站点 ID(逗号分隔,来源site list)
省略则查询全部对象的指标汇总。
历史会话用法
查询前建议先执行 history schema 了解返回字段含义。
kst-im-cli history web \
--start "2026-06-01 00:00:00" \
--end "2026-06-03 23:59:59" \
--site-ids 118501,118504 \
--page 1 --page-size 500--page-size最大 1000,大范围查询请分页- 时间格式固定为
yyyy-MM-dd HH:mm:ss
配置
配置文件位于 ~/.config/.kst-im-cli/config.json,可通过环境变量 KST_IM_CLI_CONFIG_DIR 覆盖路径。
API Key 也可通过环境变量 KST_ONLINE_CLI_API_KEY 注入(优先级高于配置文件),适合 Agent 沙箱场景。
License
ISC
