@kevisual/cnb 0.0.44 → 0.0.45

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.
@@ -4,7 +4,9 @@ import { useKey } from '@kevisual/context';
4
4
  import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
5
5
  export const getConfig = async (opts: { token?: string }) => {
6
6
  const kevisualEnv = useKey('KEVISUAL_ENV')
7
- const baseUrl = kevisualEnv === 'production' ? 'https://kevisual.cn/api/router' : 'https://kevisual.xiongxiao.me/api/router';
7
+ const isCNB = useKey('CNB');
8
+ let isProduction = kevisualEnv !== 'development' || (isCNB && !kevisualEnv);
9
+ const baseUrl = isProduction ? 'https://kevisual.cn/api/router' : 'https://kevisual.xiongxiao.me/api/router';
8
10
  const res = await fetch(baseUrl, {
9
11
  method: 'POST',
10
12
  body: JSON.stringify({
@@ -67,10 +69,11 @@ export class CNBManager {
67
69
  if (res.code === 200) {
68
70
  const cookie = res.data?.data?.CNB_COOKIE
69
71
  const token = res.data?.data?.CNB_API_KEY
70
- console.log('从配置中心获取 CNB 配置', { cookie, token })
71
72
  if (token) {
72
73
  return this.addCNB({ username, token, cookie })
73
74
  }
75
+ } else {
76
+ console.error('获取 CNB 配置失败', username, res)
74
77
  }
75
78
  return null
76
79
  }
@@ -95,7 +98,6 @@ export class CNBManager {
95
98
  const kevisualToken = ctx.query?.token;
96
99
  const item = await this.getCNB({ username, kevisualToken });
97
100
  if (!item) {
98
- console.error('CNB 配置项不存在', username, item)
99
101
  ctx.throw(400, '不存在的 CNB 配置项,请检查 登录 Token 是否正确,或添加 CNB 配置')
100
102
  }
101
103
  return item;
@@ -0,0 +1,6 @@
1
+ const token = 'st_logh1b3ozq2resntxlnk4bccao0bon8e'
2
+ import { CNBManager } from "../../modules/cnb-manager.ts"
3
+ const cnbManager = new CNBManager()
4
+
5
+ const cnbItem = await cnbManager.getCNB({ username: 'root', kevisualToken: token });
6
+ console.log('cnbItem', cnbItem)
package/dist/cli.js CHANGED
@@ -45978,7 +45978,9 @@ function createOpenAICompatible(options) {
45978
45978
  // agent/modules/cnb-manager.ts
45979
45979
  var getConfig2 = async (opts) => {
45980
45980
  const kevisualEnv = useKey("KEVISUAL_ENV");
45981
- const baseUrl = kevisualEnv === "production" ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
45981
+ const isCNB = useKey("CNB");
45982
+ let isProduction = kevisualEnv !== "development" || isCNB && !kevisualEnv;
45983
+ const baseUrl = isProduction ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
45982
45984
  const res = await fetch(baseUrl, {
45983
45985
  method: "POST",
45984
45986
  body: JSON.stringify({
@@ -46021,10 +46023,11 @@ class CNBManager {
46021
46023
  if (res.code === 200) {
46022
46024
  const cookie = res.data?.data?.CNB_COOKIE;
46023
46025
  const token = res.data?.data?.CNB_API_KEY;
46024
- console.log("从配置中心获取 CNB 配置", { cookie, token });
46025
46026
  if (token) {
46026
46027
  return this.addCNB({ username, token, cookie });
46027
46028
  }
46029
+ } else {
46030
+ console.error("获取 CNB 配置失败", username, res);
46028
46031
  }
46029
46032
  return null;
46030
46033
  }
@@ -46044,7 +46047,6 @@ class CNBManager {
46044
46047
  const kevisualToken = ctx.query?.token;
46045
46048
  const item = await this.getCNB({ username, kevisualToken });
46046
46049
  if (!item) {
46047
- console.error("CNB 配置项不存在", username, item);
46048
46050
  ctx.throw(400, "不存在的 CNB 配置项,请检查 登录 Token 是否正确,或添加 CNB 配置");
46049
46051
  }
46050
46052
  return item;
package/dist/opencode.js CHANGED
@@ -43885,7 +43885,9 @@ function createOpenAICompatible(options) {
43885
43885
  // agent/modules/cnb-manager.ts
43886
43886
  var getConfig2 = async (opts) => {
43887
43887
  const kevisualEnv = useKey("KEVISUAL_ENV");
43888
- const baseUrl = kevisualEnv === "production" ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
43888
+ const isCNB = useKey("CNB");
43889
+ let isProduction = kevisualEnv !== "development" || isCNB && !kevisualEnv;
43890
+ const baseUrl = isProduction ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
43889
43891
  const res = await fetch(baseUrl, {
43890
43892
  method: "POST",
43891
43893
  body: JSON.stringify({
@@ -43928,10 +43930,11 @@ class CNBManager {
43928
43930
  if (res.code === 200) {
43929
43931
  const cookie = res.data?.data?.CNB_COOKIE;
43930
43932
  const token = res.data?.data?.CNB_API_KEY;
43931
- console.log("从配置中心获取 CNB 配置", { cookie, token });
43932
43933
  if (token) {
43933
43934
  return this.addCNB({ username, token, cookie });
43934
43935
  }
43936
+ } else {
43937
+ console.error("获取 CNB 配置失败", username, res);
43935
43938
  }
43936
43939
  return null;
43937
43940
  }
@@ -43951,7 +43954,6 @@ class CNBManager {
43951
43954
  const kevisualToken = ctx.query?.token;
43952
43955
  const item = await this.getCNB({ username, kevisualToken });
43953
43956
  if (!item) {
43954
- console.error("CNB 配置项不存在", username, item);
43955
43957
  ctx.throw(400, "不存在的 CNB 配置项,请检查 登录 Token 是否正确,或添加 CNB 配置");
43956
43958
  }
43957
43959
  return item;
package/dist/routes.js CHANGED
@@ -43885,7 +43885,9 @@ function createOpenAICompatible(options) {
43885
43885
  // agent/modules/cnb-manager.ts
43886
43886
  var getConfig2 = async (opts) => {
43887
43887
  const kevisualEnv = useKey("KEVISUAL_ENV");
43888
- const baseUrl = kevisualEnv === "production" ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
43888
+ const isCNB = useKey("CNB");
43889
+ let isProduction = kevisualEnv !== "development" || isCNB && !kevisualEnv;
43890
+ const baseUrl = isProduction ? "https://kevisual.cn/api/router" : "https://kevisual.xiongxiao.me/api/router";
43889
43891
  const res = await fetch(baseUrl, {
43890
43892
  method: "POST",
43891
43893
  body: JSON.stringify({
@@ -43928,10 +43930,11 @@ class CNBManager {
43928
43930
  if (res.code === 200) {
43929
43931
  const cookie = res.data?.data?.CNB_COOKIE;
43930
43932
  const token = res.data?.data?.CNB_API_KEY;
43931
- console.log("从配置中心获取 CNB 配置", { cookie, token });
43932
43933
  if (token) {
43933
43934
  return this.addCNB({ username, token, cookie });
43934
43935
  }
43936
+ } else {
43937
+ console.error("获取 CNB 配置失败", username, res);
43935
43938
  }
43936
43939
  return null;
43937
43940
  }
@@ -43951,7 +43954,6 @@ class CNBManager {
43951
43954
  const kevisualToken = ctx.query?.token;
43952
43955
  const item = await this.getCNB({ username, kevisualToken });
43953
43956
  if (!item) {
43954
- console.error("CNB 配置项不存在", username, item);
43955
43957
  ctx.throw(400, "不存在的 CNB 配置项,请检查 登录 Token 是否正确,或添加 CNB 配置");
43956
43958
  }
43957
43959
  return item;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "basename": "/root/cnb",