Compare commits
7 Commits
f912003ca9
...
f33d4c293d
| Author | SHA1 | Date | |
|---|---|---|---|
| f33d4c293d | |||
| 63edd0fd84 | |||
| 171d01a784 | |||
| 76aeb21a41 | |||
| 786ee80839 | |||
| 34697e07b5 | |||
| d3a9fec698 |
@@ -10,7 +10,7 @@
|
||||
],
|
||||
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
||||
"license": "MIT",
|
||||
"packageManager": "pnpm@10.28.2",
|
||||
"packageManager": "pnpm@10.30.0",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -42,27 +42,27 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@inquirer/prompts": "^8.2.0",
|
||||
"@inquirer/prompts": "^8.2.1",
|
||||
"@kevisual/ai": "^0.0.24",
|
||||
"@kevisual/api": "^0.0.44",
|
||||
"@kevisual/api": "^0.0.51",
|
||||
"@kevisual/load": "^0.0.6",
|
||||
"@kevisual/local-app-manager": "^0.1.32",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/query": "0.0.39",
|
||||
"@kevisual/query": "0.0.44",
|
||||
"@kevisual/query-login": "0.0.7",
|
||||
"@kevisual/router": "^0.0.70",
|
||||
"@kevisual/router": "^0.0.74",
|
||||
"@kevisual/types": "^0.0.12",
|
||||
"@kevisual/use-config": "^1.0.30",
|
||||
"@opencode-ai/plugin": "^1.1.49",
|
||||
"@types/bun": "^1.3.8",
|
||||
"@types/node": "^25.2.0",
|
||||
"@opencode-ai/plugin": "^1.2.6",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/node": "^25.2.3",
|
||||
"@types/send": "^1.2.1",
|
||||
"@types/ws": "^8.18.1",
|
||||
"chalk": "^5.6.2",
|
||||
"commander": "^14.0.3",
|
||||
"cross-env": "^10.1.0",
|
||||
"dayjs": "^1.11.19",
|
||||
"dotenv": "^17.2.3",
|
||||
"dotenv": "^17.3.1",
|
||||
"get-port": "^7.1.0",
|
||||
"nanoid": "^5.1.6",
|
||||
"send": "^1.2.1",
|
||||
@@ -77,15 +77,15 @@
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.981.0",
|
||||
"@aws-sdk/client-s3": "^3.991.0",
|
||||
"@kevisual/js-filter": "^0.0.5",
|
||||
"@kevisual/oss": "^0.0.19",
|
||||
"@kevisual/video-tools": "^0.0.13",
|
||||
"@opencode-ai/sdk": "^1.1.49",
|
||||
"@opencode-ai/sdk": "^1.2.6",
|
||||
"es-toolkit": "^1.44.0",
|
||||
"eventemitter3": "^5.0.4",
|
||||
"lowdb": "^7.0.1",
|
||||
"lru-cache": "^11.2.5",
|
||||
"lru-cache": "^11.2.6",
|
||||
"pm2": "^6.0.14",
|
||||
"unstorage": "^1.17.4",
|
||||
"zod": "^4.3.6"
|
||||
|
||||
@@ -54,15 +54,4 @@ export const simpleRouter = useContextKey('simpleRouter', () => {
|
||||
return new SimpleRouter();
|
||||
});
|
||||
|
||||
app.route({
|
||||
path: 'router',
|
||||
key: 'list',
|
||||
description: '获取路由列表',
|
||||
}).define(async (ctx) => {
|
||||
const list = ctx.app.getList((item) => {
|
||||
if (item?.path?.includes?.('auth') || item?.id?.includes?.('auth')) return false;
|
||||
return true;
|
||||
})
|
||||
console.log('路由列表:', list.length);
|
||||
ctx.body = { list }
|
||||
}).addTo(app);
|
||||
app.createRouteList()
|
||||
@@ -11,7 +11,7 @@ app
|
||||
path: 'ai',
|
||||
key: 'chat',
|
||||
description: '与 AI 进行对话, 调用 GPT 的AI 服务,生成结果,并返回。',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ app.route({
|
||||
path: 'client',
|
||||
key: 'restart',
|
||||
description: '重启客户端',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
|
||||
@@ -5,7 +5,7 @@ app
|
||||
.route({
|
||||
path: 'config',
|
||||
description: '获取配置',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = assistantConfig.getCacheAssistantConfig();
|
||||
@@ -17,7 +17,7 @@ app
|
||||
path: 'config',
|
||||
key: 'set',
|
||||
description: '设置配置',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { data } = ctx.query;
|
||||
|
||||
@@ -118,8 +118,8 @@ app
|
||||
.addTo(app);
|
||||
app
|
||||
.route({
|
||||
path: 'admin-auth',
|
||||
id: 'admin-auth',
|
||||
path: 'auth-admin',
|
||||
id: 'auth-admin',
|
||||
description: '管理员鉴权, 获取用户信息,并验证是否为管理员。',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
|
||||
@@ -8,7 +8,7 @@ app.route({
|
||||
path: 'kevisual',
|
||||
key: ' me',
|
||||
description: '查看 ev cli 是否登录',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
@@ -36,7 +36,7 @@ app.route({
|
||||
path: 'kevisual',
|
||||
key: 'loginByAdmin',
|
||||
description: '通过当前登录用户 ev cli',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
|
||||
@@ -7,7 +7,7 @@ app.route({
|
||||
path: 'kevisual',
|
||||
key: 'deploy',
|
||||
description: '部署一个网页',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
tags: ['kevisual'],
|
||||
...createSkill({
|
||||
|
||||
@@ -5,7 +5,7 @@ import { AssistantApp } from "@/lib.ts";
|
||||
app.route({
|
||||
path: 'remote',
|
||||
key: 'status',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
description: '获取远程app连接状态',
|
||||
}).define(async (ctx) => {
|
||||
const manager = useContextKey('manager') as AssistantApp;
|
||||
@@ -24,7 +24,7 @@ app.route({
|
||||
app.route({
|
||||
path: 'remote',
|
||||
key: 'connect',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
description: '连接远程app',
|
||||
}).define(async (ctx) => {
|
||||
const manager = useContextKey('manager') as AssistantApp;
|
||||
|
||||
@@ -6,7 +6,7 @@ app
|
||||
path: 'shop',
|
||||
key: 'get-registry',
|
||||
description: '获取应用商店注册表信息',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
@@ -23,7 +23,7 @@ app
|
||||
path: 'shop',
|
||||
key: 'list-installed',
|
||||
description: '列出当前已安装的所有应用',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
@@ -41,7 +41,7 @@ app
|
||||
path: 'shop',
|
||||
key: 'install',
|
||||
description: '安装指定的应用,可以指定 id、type、force 和 yes 参数',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
@@ -68,7 +68,7 @@ app
|
||||
path: 'shop',
|
||||
key: 'uninstall',
|
||||
description: '卸载指定的应用,可以指定 id 和 type 参数',
|
||||
middleware: ['admin-auth'],
|
||||
middleware: ['auth-admin'],
|
||||
metadata: {
|
||||
admin: true,
|
||||
}
|
||||
|
||||
@@ -124,42 +124,39 @@ export class AssistantInit extends AssistantConfig {
|
||||
packagePath,
|
||||
`{
|
||||
"name": "assistant-app",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "assistant-app package pnpm, node pkgs projects",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "pm2 start apps/code-center/dist/app.mjs --name code-center",
|
||||
"proxy": "pm2 start apps/page-proxy/dist/app.mjs --name page-proxy",
|
||||
"preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 8686"
|
||||
"preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace/kevisual asst server -s"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.978.0",
|
||||
"@kevisual/oss": "^0.0.16",
|
||||
"@kevisual/query": "^0.0.38",
|
||||
"@aws-sdk/client-s3": "^3.990.0",
|
||||
"@kevisual/oss": "^0.0.19",
|
||||
"@kevisual/query": "^0.0.40",
|
||||
"eventemitter3": "^5.0.4",
|
||||
"@kevisual/router": "^0.0.64",
|
||||
"@kevisual/use-config": "^1.0.28",
|
||||
"ioredis": "^5.9.2",
|
||||
"minio": "^8.0.6",
|
||||
"pg": "^8.17.2",
|
||||
"@kevisual/router": "^0.0.70",
|
||||
"@kevisual/use-config": "^1.0.30",
|
||||
"ioredis": "^5.9.3",
|
||||
"pg": "^8.18.0",
|
||||
"pm2": "^6.0.14",
|
||||
"sequelize": "^6.37.7",
|
||||
"crypto-js": "^4.2.0",
|
||||
"better-sqlite3": "^12.6.2",
|
||||
"unstorage": "^1.17.4",
|
||||
"dayjs": "^1.11.19",
|
||||
"es-toolkit": "^1.44.0",
|
||||
"node-cron": "^4.2.1",
|
||||
"dotenv": "^17.2.3"
|
||||
"dotenv": "^17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/types": "^0.0.12",
|
||||
"@types/bun": "^1.3.8",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/node": "^25.1.0"
|
||||
"@types/node": "^25.2.3"
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
@@ -1,40 +1,37 @@
|
||||
{
|
||||
"name": "assistant-app",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "assistant-app package pnpm, node pkgs projects",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "pm2 start apps/code-center/dist/app.mjs --name code-center",
|
||||
"proxy": "pm2 start apps/page-proxy/dist/app.mjs --name page-proxy",
|
||||
"preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace asst server -s -p 8686"
|
||||
"preview": "pnpm i && ASSISTANT_CONFIG_DIR=/workspace/kevisual asst server -s"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.981.0",
|
||||
"@aws-sdk/client-s3": "^3.990.0",
|
||||
"@kevisual/oss": "^0.0.19",
|
||||
"@kevisual/query": "^0.0.39",
|
||||
"@kevisual/query": "^0.0.40",
|
||||
"eventemitter3": "^5.0.4",
|
||||
"@kevisual/router": "^0.0.70",
|
||||
"@kevisual/use-config": "^1.0.30",
|
||||
"ioredis": "^5.9.2",
|
||||
"minio": "^8.0.6",
|
||||
"ioredis": "^5.9.3",
|
||||
"pg": "^8.18.0",
|
||||
"pm2": "^6.0.14",
|
||||
"sequelize": "^6.37.7",
|
||||
"crypto-js": "^4.2.0",
|
||||
"better-sqlite3": "^12.6.2",
|
||||
"unstorage": "^1.17.4",
|
||||
"dayjs": "^1.11.19",
|
||||
"es-toolkit": "^1.44.0",
|
||||
"node-cron": "^4.2.1",
|
||||
"dotenv": "^17.2.3"
|
||||
"dotenv": "^17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/types": "^0.0.12",
|
||||
"@types/bun": "^1.3.8",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/node": "^25.2.0"
|
||||
"@types/node": "^25.2.3"
|
||||
}
|
||||
}
|
||||
5
keep.json
Normal file
5
keep.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"wss": "wss://cnb-pf8-1jhgvbrkm-001.cnb.space:443/stable-3c0b449c6e6e37b44a8a7938c0d8a3049926a64c?reconnectionToken=3d90027f-b2b1-4c60-a3b4-f061b75ec073&reconnection=false&skipWebSocketFrames=false",
|
||||
"cookie": "orange:workspace:cookie-session:cnb-pf8-1jhgvbrkm-001=9cc870da-d3d5-44ee-afdc-7498e1111186",
|
||||
"url": "https://cnb-pf8-1jhgvbrkm-001.cnb.space/?folder=/workspace"
|
||||
}
|
||||
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/cli",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.5",
|
||||
"description": "envision 命令行工具",
|
||||
"type": "module",
|
||||
"basename": "/root/cli",
|
||||
@@ -30,13 +30,10 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "bun src/run.ts ",
|
||||
"dev:tsx": "tsx src/run.ts ",
|
||||
"dev:server": "cd assistant && bun --watch src/run-server.ts ",
|
||||
"build": "rimraf dist && bun run bun.config.mjs",
|
||||
"deploy": "ev pack -u -p -m no",
|
||||
"pub:me": "npm publish --registry https://npm.xiongxiao.me --tag beta",
|
||||
"postbuild": "cd assistant && pnpm build ",
|
||||
"dts": "dts-bundle-generator --external-inlines=@types/jsonwebtoken src/index.ts -o dist/index.d.ts "
|
||||
"postbuild": "cd assistant && pnpm build "
|
||||
},
|
||||
"keywords": [
|
||||
"kevisual",
|
||||
@@ -44,35 +41,36 @@
|
||||
],
|
||||
"author": "abearxiong",
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^8.2.0",
|
||||
"@inquirer/prompts": "^8.2.1",
|
||||
"@kevisual/app": "^0.0.2",
|
||||
"@kevisual/auth": "^2.0.3",
|
||||
"@kevisual/context": "^0.0.4",
|
||||
"@kevisual/context": "^0.0.6",
|
||||
"@kevisual/use-config": "^1.0.30",
|
||||
"@opencode-ai/sdk": "^1.1.50",
|
||||
"@opencode-ai/sdk": "^1.2.6",
|
||||
"@types/busboy": "^1.5.4",
|
||||
"busboy": "^1.6.0",
|
||||
"eventemitter3": "^5.0.4",
|
||||
"jose": "^6.1.3",
|
||||
"lowdb": "^7.0.1",
|
||||
"lru-cache": "^11.2.5",
|
||||
"lru-cache": "^11.2.6",
|
||||
"micromatch": "^4.0.8",
|
||||
"pm2": "latest",
|
||||
"semver": "^7.7.3",
|
||||
"semver": "^7.7.4",
|
||||
"unstorage": "^1.17.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/api": "^0.0.44",
|
||||
"@kevisual/dts": "^0.0.3",
|
||||
"@kevisual/api": "^0.0.51",
|
||||
"@kevisual/cnb": "^0.0.26",
|
||||
"@kevisual/dts": "^0.0.4",
|
||||
"@kevisual/load": "^0.0.6",
|
||||
"@kevisual/logger": "^0.0.4",
|
||||
"@kevisual/query": "0.0.39",
|
||||
"@kevisual/query": "0.0.44",
|
||||
"@kevisual/query-login": "0.0.7",
|
||||
"@types/bun": "^1.3.8",
|
||||
"@types/bun": "^1.3.9",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/micromatch": "^4.0.10",
|
||||
"@types/node": "^25.2.0",
|
||||
"@types/node": "^25.2.3",
|
||||
"@types/semver": "^7.7.1",
|
||||
"chalk": "^5.6.2",
|
||||
"commander": "^14.0.3",
|
||||
@@ -83,7 +81,7 @@
|
||||
"ignore": "^7.0.5",
|
||||
"jsonwebtoken": "^9.0.3",
|
||||
"pm2": "^6.0.14",
|
||||
"tar": "^7.5.7",
|
||||
"tar": "^7.5.9",
|
||||
"zustand": "^5.0.11"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
1358
pnpm-lock.yaml
generated
1358
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
85
src/command/cnb/index.ts
Normal file
85
src/command/cnb/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { createKeepAlive } from '@kevisual/cnb/keep'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
import { program, Command } from '@/program.ts';
|
||||
|
||||
const cnbCmd = new Command('cnb')
|
||||
.description('CNB 相关命令')
|
||||
.action(async (opts) => {
|
||||
console.log('CNB 命令');
|
||||
});
|
||||
|
||||
// cnb live -j '{"wss":"wss://...","cookie":"...","url":"..."}'
|
||||
// # 或
|
||||
// cnb live --json '{"wss":"wss://...","cookie":"...","url":"..."}'
|
||||
|
||||
const liveCmd = new Command('live')
|
||||
.description('启动 CNB Keep Alive 服务')
|
||||
.option('-j, --json <string>', 'JSON数据')
|
||||
.option('-c, --config <string>', '配置文件路径 (优先级高于 JSON 参数), 默认keep.json')
|
||||
.action(async (opts) => {
|
||||
let config: { wss: string; cookie: string; url?: string };
|
||||
let configPath = opts.config || 'keep.json'
|
||||
if (configPath.startsWith('/')) {
|
||||
configPath = path.resolve(configPath)
|
||||
} else {
|
||||
configPath = path.join(process.cwd(), configPath)
|
||||
}
|
||||
|
||||
try {
|
||||
let jsonString = opts.json;
|
||||
|
||||
if (!jsonString) {
|
||||
jsonString = readFileSync(configPath, 'utf-8').trim();
|
||||
}
|
||||
|
||||
config = JSON.parse(jsonString);
|
||||
} catch (error) {
|
||||
console.error('JSON 解析错误: 请检查输入的 JSON 格式是否正确');
|
||||
process.exit(1);
|
||||
}
|
||||
if (!config.wss || !config.cookie) {
|
||||
console.error('配置错误: 必须包含 wss 和 cookie 字段');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
createKeepAlive({
|
||||
wsUrl: config.wss,
|
||||
cookie: config.cookie,
|
||||
onDisconnect: (code) => {
|
||||
console.log(`与 CNB 服务器断开连接,代码: ${code}`);
|
||||
},
|
||||
debug: true
|
||||
});
|
||||
});
|
||||
|
||||
cnbCmd.addCommand(liveCmd);
|
||||
|
||||
const workspaceCmd = new Command('workspace')
|
||||
.alias('w')
|
||||
.description('工作区live保活,默认执行 ev cnb live -c /workspace/live/keep.json')
|
||||
.action(() => {
|
||||
try {
|
||||
|
||||
const configPath = path.join('/workspace/live/keep.json')
|
||||
const json = readFileSync(configPath, 'utf-8').trim();
|
||||
let config = JSON.parse(json);
|
||||
if (!config.wss || !config.cookie) {
|
||||
console.error('配置错误: 必须包含 wss 和 cookie 字段');
|
||||
process.exit(1);
|
||||
}
|
||||
createKeepAlive({
|
||||
wsUrl: config.wss,
|
||||
cookie: config.cookie,
|
||||
onDisconnect: (code) => {
|
||||
console.log(`与 CNB 服务器断开连接,代码: ${code}`);
|
||||
},
|
||||
debug: true
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('error', e)
|
||||
}
|
||||
})
|
||||
program.addCommand(workspaceCmd)
|
||||
program.addCommand(cnbCmd);
|
||||
@@ -22,6 +22,8 @@ import './command/coding-plan/oc.ts'
|
||||
import './command/docker.ts';
|
||||
import './command/jwks.ts';
|
||||
|
||||
import './command/cnb/index.ts';
|
||||
|
||||
// program.parse(process.argv);
|
||||
|
||||
export const runParser = async (argv: string[]) => {
|
||||
|
||||
Reference in New Issue
Block a user