@bty/customer-service-cli 0.2.1 → 0.3.0
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 +18 -7
- package/dist/bin.js +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,13 +26,14 @@ pnpm build
|
|
|
26
26
|
安装后即可使用,无需额外配置 API 地址。内置默认地址:
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
| 服务
|
|
30
|
-
|
|
|
31
|
-
| 客服 API
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
| Langfuse
|
|
29
|
+
| 服务 | 默认地址 |
|
|
30
|
+
| -------------- | --------------------------------------------- |
|
|
31
|
+
| 客服 API | `https://customer-servhub-api.betteryeah.com` |
|
|
32
|
+
| AI API | `https://ai-api.betteryeah.com` |
|
|
33
|
+
| Customer Agent | `https://customer-agent.bantouyan.com` |
|
|
34
|
+
| Langfuse | `http://192.168.40.10:3000` |
|
|
35
35
|
|
|
36
|
+
> AI API 同时服务于登录认证(`auth login` / `auth whoami`),不再区分独立的 "认证 API" 字段。
|
|
36
37
|
|
|
37
38
|
如需覆盖,可通过 `cs-cli config set` 修改:
|
|
38
39
|
|
|
@@ -40,6 +41,16 @@ pnpm build
|
|
|
40
41
|
cs-cli config set --cs-api https://your-api.example.com
|
|
41
42
|
```
|
|
42
43
|
|
|
44
|
+
### API 地址优先级
|
|
45
|
+
|
|
46
|
+
每个 API 地址的读取顺序为 `环境变量 > config.json > 内置默认值`。环境变量为 `undefined` 或空字符串 `""` 都视为未设置,继续向下 fallback。
|
|
47
|
+
|
|
48
|
+
| 环境变量 | 覆盖字段 | 默认值 |
|
|
49
|
+
| ----------------------- | ------------------- | --------------------------------------------- |
|
|
50
|
+
| `CS_CS_API_URL` | `customerServiceApiUrl` | `https://customer-servhub-api.betteryeah.com` |
|
|
51
|
+
| `CS_AI_API_URL` | `aiApiUrl`(同时服务 auth 调用) | `https://ai-api.betteryeah.com` |
|
|
52
|
+
| `CS_CUSTOMER_AGENT_URL` | `customerAgentApiUrl` | `https://customer-agent.bantouyan.com` |
|
|
53
|
+
|
|
43
54
|
## 快速开始
|
|
44
55
|
|
|
45
56
|
```bash
|
|
@@ -157,7 +168,7 @@ cs-cli --workspace ws-other agent list # ❌ 报错:CS_WORKSPACE_ID 已被
|
|
|
157
168
|
|
|
158
169
|
| 命令 | 说明 |
|
|
159
170
|
| ----------------------------------------------------------- | ---------------------------- |
|
|
160
|
-
| `config set --cs-api <url> --
|
|
171
|
+
| `config set --cs-api <url> --ai-api <url>` | 设置 API 地址 |
|
|
161
172
|
| `config get` | 查看当前配置(含全局和本地) |
|
|
162
173
|
| `config init` | 在当前目录初始化本地配置 (`.cs-cli.json`) |
|
|
163
174
|
| `config set-workspace <workspace_id> [--global]` | 设置默认工作空间 |
|
package/dist/bin.js
CHANGED
|
@@ -428,25 +428,26 @@ function isTokenExpired(expiresAt) {
|
|
|
428
428
|
|
|
429
429
|
// src/client/helpers.ts
|
|
430
430
|
var DEFAULT_CS_API_URL = "https://customer-servhub-api.betteryeah.com";
|
|
431
|
-
var DEFAULT_AUTH_API_URL = "https://ai-api.betteryeah.com";
|
|
432
431
|
var DEFAULT_AI_API_URL = "https://ai-api.betteryeah.com";
|
|
433
432
|
var DEFAULT_CUSTOMER_AGENT_API_URL = "https://customer-agent.bantouyan.com";
|
|
434
433
|
var DEFAULT_LANGFUSE_HOST = "http://192.168.40.10:3000";
|
|
435
434
|
var DEFAULT_LANGFUSE_PUBLIC_KEY = "pk-lf-1b3aece4-021a-4a81-be4a-abd6334c5929";
|
|
436
435
|
var DEFAULT_LANGFUSE_SECRET_KEY = "sk-lf-edc22ac8-5d0a-4f72-b285-6556adfa8f71";
|
|
437
436
|
function getCustomerServiceUrl() {
|
|
437
|
+
const envUrl = process.env.CS_CS_API_URL;
|
|
438
|
+
if (envUrl) return envUrl;
|
|
438
439
|
const config = readConfig();
|
|
439
440
|
return config?.customerServiceApiUrl ?? DEFAULT_CS_API_URL;
|
|
440
441
|
}
|
|
441
|
-
function getAuthUrl() {
|
|
442
|
-
const config = readConfig();
|
|
443
|
-
return config?.authApiUrl ?? DEFAULT_AUTH_API_URL;
|
|
444
|
-
}
|
|
445
442
|
function getAiApiUrl() {
|
|
443
|
+
const envUrl = process.env.CS_AI_API_URL;
|
|
444
|
+
if (envUrl) return envUrl;
|
|
446
445
|
const config = readConfig();
|
|
447
446
|
return config?.aiApiUrl ?? DEFAULT_AI_API_URL;
|
|
448
447
|
}
|
|
449
448
|
function getCustomerAgentUrl() {
|
|
449
|
+
const envUrl = process.env.CS_CUSTOMER_AGENT_URL;
|
|
450
|
+
if (envUrl) return envUrl;
|
|
450
451
|
const config = readConfig();
|
|
451
452
|
return config?.customerAgentApiUrl ?? DEFAULT_CUSTOMER_AGENT_API_URL;
|
|
452
453
|
}
|
|
@@ -599,7 +600,7 @@ function encryptPassword(password) {
|
|
|
599
600
|
return CryptoJS.enc.Base64.stringify(result);
|
|
600
601
|
}
|
|
601
602
|
async function login(phone, password) {
|
|
602
|
-
const authApiUrl =
|
|
603
|
+
const authApiUrl = getAiApiUrl();
|
|
603
604
|
const encryptedPassword = encryptPassword(password);
|
|
604
605
|
const formData = new FormData();
|
|
605
606
|
formData.append("phone", phone);
|
|
@@ -644,7 +645,7 @@ async function login(phone, password) {
|
|
|
644
645
|
}
|
|
645
646
|
async function whoami() {
|
|
646
647
|
const request = createRequest();
|
|
647
|
-
return request(
|
|
648
|
+
return request(getAiApiUrl(), "/v1/users/me", { method: "GET" });
|
|
648
649
|
}
|
|
649
650
|
|
|
650
651
|
// src/commands/auth.ts
|
|
@@ -731,10 +732,9 @@ function registerConfigCommand(program2) {
|
|
|
731
732
|
const config = program2.command("config").description(
|
|
732
733
|
"\u914D\u7F6E\u7BA1\u7406 \u2014\u2014 API \u5730\u5740\u3001\u9ED8\u8BA4\u5DE5\u4F5C\u7A7A\u95F4\u7B49\u6301\u4E45\u5316\u8BBE\u7F6E\u3002\u652F\u6301\u5168\u5C40\u914D\u7F6E\u548C\u76EE\u5F55\u7EA7\u672C\u5730\u914D\u7F6E\uFF08.cs-cli.json\uFF09"
|
|
733
734
|
);
|
|
734
|
-
config.command("set").description("\u8BBE\u7F6E API \u5730\u5740").option("--cs-api <url>", "\u5BA2\u670D API \u5730\u5740").option("--
|
|
735
|
+
config.command("set").description("\u8BBE\u7F6E API \u5730\u5740").option("--cs-api <url>", "\u5BA2\u670D API \u5730\u5740").option("--ai-api <url>", "AI API \u5730\u5740").option("--agent-api <url>", "Customer Agent API \u5730\u5740").option("--langfuse-host <url>", "Langfuse \u5730\u5740").option("--langfuse-public-key <key>", "Langfuse Public Key").option("--langfuse-secret-key <key>", "Langfuse Secret Key").action((opts) => {
|
|
735
736
|
const updates = {};
|
|
736
737
|
if (opts.csApi) updates.customerServiceApiUrl = opts.csApi;
|
|
737
|
-
if (opts.authApi) updates.authApiUrl = opts.authApi;
|
|
738
738
|
if (opts.aiApi) updates.aiApiUrl = opts.aiApi;
|
|
739
739
|
if (opts.agentApi) updates.customerAgentApiUrl = opts.agentApi;
|
|
740
740
|
if (opts.langfuseHost) updates.langfuseHost = opts.langfuseHost;
|