@kevisual/cnb 0.0.35 → 0.0.37

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.
@@ -0,0 +1,4 @@
1
+ import { app } from './index.ts';
2
+ import { parse } from '@kevisual/router/src/commander.ts';
3
+
4
+ parse({ app: app as any, description: 'CNB控制台命令行工具', parse: true })
@@ -13,7 +13,7 @@ export const execCommand = (command: string, options: { cwd?: string } = {}) =>
13
13
  });
14
14
  };
15
15
  app.route({
16
- path: 'cnb-board',
16
+ path: 'cnb_board',
17
17
  key: 'is-cnb-board',
18
18
  description: '检查是否是 cnb-board 环境',
19
19
  middleware: ['auth-admin']
@@ -28,7 +28,7 @@ app.route({
28
28
 
29
29
 
30
30
  app.route({
31
- path: 'cnb-board',
31
+ path: 'cnb_board',
32
32
  key: 'exit',
33
33
  description: 'cnb的工作环境退出程序',
34
34
  middleware: ['auth-admin'],
@@ -7,7 +7,7 @@ import './cnb-env/index.ts'
7
7
  import './knowledge/index.ts'
8
8
  import './issues/index.ts'
9
9
  import './cnb-board/index.ts';
10
-
10
+ import './share/index.ts';
11
11
  /**
12
12
  * 验证上下文中的 App ID 是否与指定的 App ID 匹配
13
13
  * @param {any} ctx - 上下文对象,可能包含 appId 属性
@@ -0,0 +1,48 @@
1
+ import { useKey } from '@kevisual/context';
2
+ import { app, cnb } from '../../app.ts';
3
+ import z from 'zod';
4
+
5
+ app.route({
6
+ path: 'cnb',
7
+ key: 'get-assistant-url',
8
+ description: '获取cnb工作空间中部署的各个助手的访问地址',
9
+ middleware: ['auth'],
10
+ metadata: {
11
+ args: {
12
+ more: z.boolean().describe('需要更多信息')
13
+ }
14
+ }
15
+ }).define(async (ctx) => {
16
+ const uri = useKey('CNB_VSCODE_PROXY_URI') as string || '';
17
+ const base = {
18
+ base: uri,
19
+ link: uri.replace('{{port}}', '51515'),
20
+ kevisual: uri.replace('{{port}}', '51515'),
21
+ openclaw: uri.replace('{{port}}', '80'),
22
+ opencode: uri.replace('{{port}}', '100'),
23
+ openwebui: uri.replace('{{port}}', '200'),
24
+ note: uri.replace('{{port}}', '3000'),
25
+ uptime: uri.replace('{{port}}', '3001'),
26
+ immich: uri.replace('{{port}}', '2283'),
27
+ nocodb: uri.replace('{{port}}', '4000'),
28
+ openlist: uri.replace('{{port}}', '5244'),
29
+ xiaoyao: uri.replace('{{port}}', '5678'),
30
+ meilisearch: uri.replace('{{port}}', '7700'),
31
+ bark: uri.replace('{{port}}', '9111'),
32
+ vaultwarden: uri.replace('{{port}}', '8180'),
33
+ music: uri.replace('{{port}}', '8096'),
34
+ jellyfin: uri.replace('{{port}}', '8096'),
35
+ homeassistant: uri.replace('{{port}}', '8123'),
36
+ cloudreve: uri.replace('{{port}}', '5212'),
37
+ filebrowser: uri.replace('{{port}}', '8081'),
38
+ // newapi: uri.replace('{{port}}', '8080'),
39
+ vscode: useKey('CNB_VSCODE_WEB_URL') as string || '',
40
+ codeServer: uri.replace('{{port}}', '10000'),
41
+ gitea: uri.replace('{{port}}', '3000'),
42
+ calibre: uri.replace('{{port}}', '8083'),
43
+ searXNG: uri.replace('{{port}}', '8888'),
44
+ }
45
+ ctx.body = {
46
+ ...base,
47
+ }
48
+ }).addTo(app);
@@ -30,21 +30,20 @@ app.route({
30
30
  ctx.throw(401, 'CNB_COOKIE 环境变量无效或已过期,请重新登录获取新的cookie');
31
31
  }
32
32
  const res = await cnb.workspace.getWorkspaceCookie(repo, pipelineId);
33
- let wsUrl = `wss://${pipelineId}.cnb.space:443?skipWebSocketFrames=false`;
34
- let cookie = '';
35
- if (res.code === 200) {
36
- cookie = res.data.value;
37
- console.log(`启动保持工作空间 ${wsUrl} 存活的任务`);
38
- } else {
39
- ctx.throw(500, `获取工作空间访问cookie失败: ${res.message}`);
33
+ if (res.code !== 200 || !res.data?.cookie) {
34
+ ctx.throw(500, `获取工作空间 Cookie 失败: ${res.message}`);
40
35
  }
41
36
 
42
- console.log(`启动保持工作空间 ${wsUrl} 存活的任务`);
37
+ // 添加保活数据
38
+ const liveData = createLiveData({
39
+ repo,
40
+ pipelineId,
41
+ cookie: res.data.cookie
42
+ });
43
+ addKeepAliveData(liveData);
44
+ console.log('已添加 keep-alive 数据');
43
45
 
44
- const config: KeepAliveData = createLiveData({ cookie, repo, pipelineId });
45
- addKeepAliveData(config);
46
-
47
- ctx.body = { content: `已启动保持工作空间 ${wsUrl} 存活的任务`, data: config };
46
+ ctx.body = { content: `已启动保持工作空间 ${repo}/${pipelineId} 存活的任务`, data: liveData };
48
47
  }).addTo(app);
49
48
 
50
49
  // 停止保持工作空间存活技能
package/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ import '../dist/cli.js';
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { };