@kevisual/cnb 0.0.44 → 0.0.46
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/agent/modules/cnb-manager.ts +5 -3
- package/agent/routes/cnb-board/live/live-content.ts +1 -1
- package/agent/routes/cnb-manager/test.ts +6 -0
- package/dist/cli.js +628 -12958
- package/dist/keep.js +16 -34
- package/dist/opencode.js +2988 -15318
- package/dist/routes.js +585 -12915
- package/package.json +3 -3
- package/src/issue/npc/env.ts +7 -0
|
@@ -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
|
|
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;
|
|
@@ -10,7 +10,7 @@ export const getLiveMdContent = (opts?: { more?: boolean }) => {
|
|
|
10
10
|
const token = useKey('CNB_TOKEN') || ''
|
|
11
11
|
const openclawPort = useKey('OPENCLAW_PORT') || '80'
|
|
12
12
|
const openclawUrl = url.replace('{{port}}', openclawPort)
|
|
13
|
-
const openclawUrlSecret = openclawUrl + '/openclaw
|
|
13
|
+
const openclawUrlSecret = openclawUrl + '/openclaw#token=' + token
|
|
14
14
|
|
|
15
15
|
const opencodePort = useKey('OPENCODE_PORT') || '100'
|
|
16
16
|
const opencodeUrl = url.replace('{{port}}', opencodePort)
|
|
@@ -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)
|