feat: restructure command for Claude models and add new remote routes
- Deleted the old cc.ts command and created a new cc.ts under src/command/claude for better organization. - Added support for a new model 'bailian' in the command. - Implemented remote app connection status and connection routes in assistant/src/routes/remote/index.ts. - Updated index.ts to reflect the new path for the cc command. - Added a placeholder for future management of plugin operations in src/command/opencode/plugin.ts.
This commit is contained in:
@@ -10,10 +10,12 @@ import './call/index.ts'
|
||||
// TODO: 移除
|
||||
// import './hot-api/key-sender/index.ts';
|
||||
import './opencode/index.ts';
|
||||
import './remote/index.ts';
|
||||
|
||||
import os from 'node:os';
|
||||
import { authCache } from '@/module/cache/auth.ts';
|
||||
import { createSkill } from '@kevisual/router';
|
||||
import { logger } from '@/module/logger.ts';
|
||||
const getTokenUser = async (token: string) => {
|
||||
const query = assistantConfig.query
|
||||
const res = await query.post({
|
||||
@@ -41,7 +43,7 @@ export const checkAuth = async (ctx: any, isAdmin = false) => {
|
||||
const config = assistantConfig.getConfig();
|
||||
const { auth = {} } = config;
|
||||
const token = ctx.query.token;
|
||||
console.log('checkAuth', ctx.query, { token });
|
||||
logger.debug('checkAuth', ctx.query, { token });
|
||||
if (!token) {
|
||||
return {
|
||||
code: 401,
|
||||
@@ -120,7 +122,7 @@ app
|
||||
description: '管理员鉴权, 获取用户信息,并验证是否为管理员。',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
console.log('query', ctx.query);
|
||||
logger.debug('query', ctx.query);
|
||||
if (!ctx.query?.token && ctx.appId === app.appId) {
|
||||
return;
|
||||
}
|
||||
|
||||
54
assistant/src/routes/remote/index.ts
Normal file
54
assistant/src/routes/remote/index.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { useContextKey } from "@kevisual/context";
|
||||
import { app } from "../../app.ts";
|
||||
import { AssistantApp } from "@/lib.ts";
|
||||
|
||||
app.route({
|
||||
path: 'remote',
|
||||
key: 'status',
|
||||
middleware: ['admin-auth'],
|
||||
description: '获取远程app连接状态',
|
||||
}).define(async (ctx) => {
|
||||
const manager = useContextKey('manager') as AssistantApp;
|
||||
if (manager?.remoteApp?.isConnect()) {
|
||||
const url = manager.remoteUrl || ''
|
||||
ctx.body = {
|
||||
content: `远程app已经链接, 访问地址:${url}`,
|
||||
}
|
||||
} else {
|
||||
ctx.body = {
|
||||
content: '远程app未连接',
|
||||
}
|
||||
}
|
||||
}).addTo(app);
|
||||
|
||||
app.route({
|
||||
path: 'remote',
|
||||
key: 'connect',
|
||||
middleware: ['admin-auth'],
|
||||
description: '连接远程app',
|
||||
}).define(async (ctx) => {
|
||||
const manager = useContextKey('manager') as AssistantApp;
|
||||
if (!manager) {
|
||||
ctx.body = {
|
||||
content: '远程app管理器未初始化',
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (manager?.remoteApp?.isConnect()) {
|
||||
const url = manager.remoteUrl || ''
|
||||
ctx.body = {
|
||||
content: `远程app已经链接, 访问地址:${url}`,
|
||||
}
|
||||
return;
|
||||
}
|
||||
await manager.initRemoteApp({ enabled: true, token: ctx.query?.token }).then(() => {
|
||||
ctx.body = {
|
||||
content: '远程app连接成功',
|
||||
}
|
||||
}).catch((err) => {
|
||||
ctx.body = {
|
||||
content: `远程app连接失败: ${err.message}`,
|
||||
}
|
||||
});
|
||||
|
||||
}).addTo(app);
|
||||
Reference in New Issue
Block a user