feat: 添加新的分享路由以获取cnb工作空间中助手的访问地址

This commit is contained in:
2026-03-07 01:50:50 +08:00
parent 2eecbe273e
commit dd5331bbaa
7 changed files with 105 additions and 31 deletions

4
agent/command.ts Normal file
View File

@@ -0,0 +1,4 @@
import { app } from './index.ts';
import { parse } from '@kevisual/router/src/commander.ts';
parse({ app: app as any, description: 'CNB控制台命令行工具', parse: true })

View File

@@ -7,7 +7,7 @@ import './cnb-env/index.ts'
import './knowledge/index.ts' import './knowledge/index.ts'
import './issues/index.ts' import './issues/index.ts'
import './cnb-board/index.ts'; import './cnb-board/index.ts';
import './share/index.ts';
/** /**
* 验证上下文中的 App ID 是否与指定的 App ID 匹配 * 验证上下文中的 App ID 是否与指定的 App ID 匹配
* @param {any} ctx - 上下文对象,可能包含 appId 属性 * @param {any} ctx - 上下文对象,可能包含 appId 属性

View File

@@ -0,0 +1,48 @@
import { useKey } from '@kevisual/context';
import { app, cnb } from '../../app.ts';
import z from 'zod';
app.route({
path: 'cnb',
key: 'get-assistant-url',
description: '获取cnb工作空间中部署的各个助手的访问地址',
middleware: ['auth'],
metadata: {
args: {
more: z.boolean().describe('需要更多信息')
}
}
}).define(async (ctx) => {
const uri = useKey('CNB_VSCODE_PROXY_URI') as string || '';
const base = {
base: uri,
link: uri.replace('{{port}}', '51515'),
kevisual: uri.replace('{{port}}', '51515'),
openclaw: uri.replace('{{port}}', '80'),
opencode: uri.replace('{{port}}', '100'),
openwebui: uri.replace('{{port}}', '200'),
note: uri.replace('{{port}}', '3000'),
uptime: uri.replace('{{port}}', '3001'),
immich: uri.replace('{{port}}', '2283'),
nocodb: uri.replace('{{port}}', '4000'),
openlist: uri.replace('{{port}}', '5244'),
xiaoyao: uri.replace('{{port}}', '5678'),
meilisearch: uri.replace('{{port}}', '7700'),
bark: uri.replace('{{port}}', '9111'),
vaultwarden: uri.replace('{{port}}', '8180'),
music: uri.replace('{{port}}', '8096'),
jellyfin: uri.replace('{{port}}', '8096'),
homeassistant: uri.replace('{{port}}', '8123'),
cloudreve: uri.replace('{{port}}', '5212'),
filebrowser: uri.replace('{{port}}', '8081'),
// newapi: uri.replace('{{port}}', '8080'),
vscode: useKey('CNB_VSCODE_PROXY_URI') as string || '',
codeServer: uri.replace('{{port}}', '10000'),
gitea: uri.replace('{{port}}', '3000'),
calibre: uri.replace('{{port}}', '8083'),
searXNG: uri.replace('{{port}}', '8888'),
}
ctx.body = {
...base,
}
}).addTo(app);

2
bin/index.js Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bun
import '../dist/cli.js';

View File

@@ -1,4 +1,6 @@
import { buildWithBun } from '@kevisual/code-builder' import { buildWithBun } from '@kevisual/code-builder'
await buildWithBun({ naming: 'opencode', entry: 'agent/opencode.ts', dts: true }); await buildWithBun({ naming: 'opencode', entry: 'agent/opencode.ts', dts: true });
await buildWithBun({ naming: 'keep', entry: 'src/keep.ts', dts: true, target: 'node' }); await buildWithBun({ naming: 'keep', entry: 'src/keep.ts', dts: true, target: 'node' });
await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true }); await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true });
await buildWithBun({ naming: 'cli', entry: 'agent/command.ts', dts: true, target: 'node' });

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/cnb", "name": "@kevisual/cnb",
"version": "0.0.35", "version": "0.0.36",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -8,6 +8,9 @@
"flow": "ev npm patch && pnpm build && ev npm publish npm -p" "flow": "ev npm patch && pnpm build && ev npm publish npm -p"
}, },
"keywords": [], "keywords": [],
"bin": {
"cnb": "./bin/index.js"
},
"files": [ "files": [
"dist", "dist",
"src", "src",
@@ -21,13 +24,14 @@
"devDependencies": { "devDependencies": {
"@kevisual/ai": "^0.0.26", "@kevisual/ai": "^0.0.26",
"@kevisual/code-builder": "^0.0.6", "@kevisual/code-builder": "^0.0.6",
"@kevisual/dts": "^0.0.4",
"@kevisual/context": "^0.0.8", "@kevisual/context": "^0.0.8",
"@kevisual/dts": "^0.0.4",
"@kevisual/types": "^0.0.12", "@kevisual/types": "^0.0.12",
"@opencode-ai/plugin": "^1.2.16", "@opencode-ai/plugin": "^1.2.20",
"@types/bun": "^1.3.10", "@types/bun": "^1.3.10",
"@types/node": "^25.3.3", "@types/node": "^25.3.5",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"commander": "^14.0.3",
"dayjs": "^1.11.19", "dayjs": "^1.11.19",
"dotenv": "^17.3.1" "dotenv": "^17.3.1"
}, },
@@ -38,8 +42,8 @@
"zod": "^4.3.6" "zod": "^4.3.6"
}, },
"dependencies": { "dependencies": {
"@kevisual/query": "^0.0.52", "@kevisual/query": "^0.0.53",
"@kevisual/router": "^0.0.85", "@kevisual/router": "^0.0.88",
"@kevisual/use-config": "^1.0.30", "@kevisual/use-config": "^1.0.30",
"es-toolkit": "^1.45.1", "es-toolkit": "^1.45.1",
"nanoid": "^5.1.6", "nanoid": "^5.1.6",

60
pnpm-lock.yaml generated
View File

@@ -12,11 +12,11 @@ importers:
.: .:
dependencies: dependencies:
'@kevisual/query': '@kevisual/query':
specifier: ^0.0.52 specifier: ^0.0.53
version: 0.0.52 version: 0.0.53
'@kevisual/router': '@kevisual/router':
specifier: ^0.0.85 specifier: ^0.0.88
version: 0.0.85 version: 0.0.88
'@kevisual/use-config': '@kevisual/use-config':
specifier: ^1.0.30 specifier: ^1.0.30
version: 1.0.30(dotenv@17.3.1) version: 1.0.30(dotenv@17.3.1)
@@ -52,17 +52,20 @@ importers:
specifier: ^0.0.12 specifier: ^0.0.12
version: 0.0.12 version: 0.0.12
'@opencode-ai/plugin': '@opencode-ai/plugin':
specifier: ^1.2.16 specifier: ^1.2.20
version: 1.2.16 version: 1.2.20
'@types/bun': '@types/bun':
specifier: ^1.3.10 specifier: ^1.3.10
version: 1.3.10 version: 1.3.10
'@types/node': '@types/node':
specifier: ^25.3.3 specifier: ^25.3.5
version: 25.3.3 version: 25.3.5
'@types/ws': '@types/ws':
specifier: ^8.18.1 specifier: ^8.18.1
version: 8.18.1 version: 8.18.1
commander:
specifier: ^14.0.3
version: 14.0.3
dayjs: dayjs:
specifier: ^1.11.19 specifier: ^1.11.19
version: 1.11.19 version: 1.11.19
@@ -109,8 +112,11 @@ packages:
'@kevisual/query@0.0.52': '@kevisual/query@0.0.52':
resolution: {integrity: sha512-m1UbyDTIxtfAQXM+EqhXA4ytE2V8rV8mXTZVBwzfW9O6+gtvAcRY7K1YYxfewTSXLVh9nwvfHe0KQ8MDL5ukyw==} resolution: {integrity: sha512-m1UbyDTIxtfAQXM+EqhXA4ytE2V8rV8mXTZVBwzfW9O6+gtvAcRY7K1YYxfewTSXLVh9nwvfHe0KQ8MDL5ukyw==}
'@kevisual/router@0.0.85': '@kevisual/query@0.0.53':
resolution: {integrity: sha512-ihSzPXHOMSOnZD/+Eso4yZMt4MoUXyLdfRHhXJGg90+sJBr/BjsmgAokit4pI9gWU+Rs/3JqQ2/aqA43FHtGoA==} resolution: {integrity: sha512-PAhpCLBr0emz0lGNlTVHMbJiC5wrtGLbInPddRzgKE35fiyNt+SWSsUWABiD0DeNrLN/OxWyAFobt880Z/e5MQ==}
'@kevisual/router@0.0.88':
resolution: {integrity: sha512-T8kEbxyTGxZpbxAKDplDjZMIY+HCnXOeEdjwQ11AQetrLuqLFDZS5PnaWdVAHnONUDLhYoftkNj7bGWLtyQDlg==}
'@kevisual/types@0.0.12': '@kevisual/types@0.0.12':
resolution: {integrity: sha512-zJXH2dosir3jVrQ6QG4i0+iLQeT9gJ3H+cKXs8ReWboxBSYzUZO78XssVeVrFPsJ33iaAqo4q3DWbSS1dWGn7Q==} resolution: {integrity: sha512-zJXH2dosir3jVrQ6QG4i0+iLQeT9gJ3H+cKXs8ReWboxBSYzUZO78XssVeVrFPsJ33iaAqo4q3DWbSS1dWGn7Q==}
@@ -124,11 +130,11 @@ packages:
resolution: {integrity: sha512-jLsL80wBBKkrJZrfk3SQpJ9JA/zREdlUROj7eCkmzqduAWKSI0wVcXuCKf+mLFCHB0Q0Tkh2rgzjSlurt3JQgw==} resolution: {integrity: sha512-jLsL80wBBKkrJZrfk3SQpJ9JA/zREdlUROj7eCkmzqduAWKSI0wVcXuCKf+mLFCHB0Q0Tkh2rgzjSlurt3JQgw==}
engines: {node: '>=10.0.0'} engines: {node: '>=10.0.0'}
'@opencode-ai/plugin@1.2.16': '@opencode-ai/plugin@1.2.20':
resolution: {integrity: sha512-9Kb7BQIC2P3oKCvI8K3thP5YP0vE7yLvcmBmgyACUIqc3e5UL6U+4umLpTvgQa2eQdjxtOXznuGTNwgcGMHUHg==} resolution: {integrity: sha512-BE6TOXVxgF24g5QgtlogSY5B+/AmZJ3cYaVjHZhUVuAli9JEg4RblrbrK2rfgbyZBoZDpjBLGTYtIRTVmOccEA==}
'@opencode-ai/sdk@1.2.16': '@opencode-ai/sdk@1.2.20':
resolution: {integrity: sha512-y9ae9VnCcuog0GaI4DveX1HB6DBoZgGN3EuJVlRFbBCPwhzkls6fCfHSb5+VnTS6Fy0OWFUL28VBCmixL/D+/Q==} resolution: {integrity: sha512-U5ROpG21D8jg9rkc1IgKAk1g5dn6X/rkOBfveupd0peSDO9n6VM9aikYccVLaMObxVqdjtG08IeQOFTPVS8ySQ==}
'@rollup/plugin-commonjs@29.0.0': '@rollup/plugin-commonjs@29.0.0':
resolution: {integrity: sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==} resolution: {integrity: sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==}
@@ -314,8 +320,8 @@ packages:
'@types/estree@1.0.8': '@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
'@types/node@25.3.3': '@types/node@25.3.5':
resolution: {integrity: sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==} resolution: {integrity: sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==}
'@types/resolve@1.20.2': '@types/resolve@1.20.2':
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
@@ -334,6 +340,10 @@ packages:
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
engines: {node: '>= 20.19.0'} engines: {node: '>= 20.19.0'}
commander@14.0.3:
resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==}
engines: {node: '>=20'}
commondir@1.0.1: commondir@1.0.1:
resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==}
@@ -603,7 +613,9 @@ snapshots:
'@kevisual/query@0.0.52': {} '@kevisual/query@0.0.52': {}
'@kevisual/router@0.0.85': '@kevisual/query@0.0.53': {}
'@kevisual/router@0.0.88':
dependencies: dependencies:
es-toolkit: 1.45.1 es-toolkit: 1.45.1
@@ -616,12 +628,12 @@ snapshots:
'@kevisual/ws@8.19.0': {} '@kevisual/ws@8.19.0': {}
'@opencode-ai/plugin@1.2.16': '@opencode-ai/plugin@1.2.20':
dependencies: dependencies:
'@opencode-ai/sdk': 1.2.16 '@opencode-ai/sdk': 1.2.20
zod: 4.3.6 zod: 4.3.6
'@opencode-ai/sdk@1.2.16': {} '@opencode-ai/sdk@1.2.20': {}
'@rollup/plugin-commonjs@29.0.0(rollup@4.57.1)': '@rollup/plugin-commonjs@29.0.0(rollup@4.57.1)':
dependencies: dependencies:
@@ -743,7 +755,7 @@ snapshots:
'@types/estree@1.0.8': {} '@types/estree@1.0.8': {}
'@types/node@25.3.3': '@types/node@25.3.5':
dependencies: dependencies:
undici-types: 7.18.2 undici-types: 7.18.2
@@ -751,7 +763,7 @@ snapshots:
'@types/ws@8.18.1': '@types/ws@8.18.1':
dependencies: dependencies:
'@types/node': 25.3.3 '@types/node': 25.3.5
anymatch@3.1.3: anymatch@3.1.3:
dependencies: dependencies:
@@ -760,12 +772,14 @@ snapshots:
bun-types@1.3.10: bun-types@1.3.10:
dependencies: dependencies:
'@types/node': 25.3.3 '@types/node': 25.3.5
chokidar@5.0.0: chokidar@5.0.0:
dependencies: dependencies:
readdirp: 5.0.0 readdirp: 5.0.0
commander@14.0.3: {}
commondir@1.0.1: {} commondir@1.0.1: {}
cookie-es@1.2.2: {} cookie-es@1.2.2: {}