feat: update package dependencies and add new routes for CNB environment management
- Updated package.json and pnpm-lock.yaml with new dependencies and versions. - Removed outdated readme files from requirements. - Enhanced CNB environment configuration in cnb-env.ts with new VS Code remote SSH settings. - Modified KnowledgeBase class to return structured results. - Updated Workspace class to return structured results. - Implemented new routes for managing CNB cookies and VS Code proxy URIs. - Added AI chat functionality for querying knowledge base. - Created skills for cleaning up closed workspaces.
This commit is contained in:
94
agent/routes/cnb-env/vscode.ts
Normal file
94
agent/routes/cnb-env/vscode.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { createSkill, tool } from '@kevisual/router';
|
||||
import { app, cnb } from '../../app.ts';
|
||||
|
||||
import { CNB_ENV } from "@/common/cnb-env.ts";
|
||||
|
||||
// 执行技能 get-cnb-port-uri,端口为4096
|
||||
// 执行技能 get-cnb-port-uri,端口为51515
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
key: 'get-cnb-port-uri',
|
||||
description: '获取当前cnb工作空间的port代理uri',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
skill: 'get-cnb-port-uri',
|
||||
title: '获取当前cnb工作空间的port代理uri',
|
||||
summary: '获取当前cnb工作空间的port代理uri,用于端口转发',
|
||||
args: {
|
||||
port: tool.schema.number().optional().describe('端口号,默认为4096'),
|
||||
}
|
||||
})
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
const port = ctx.query?.port || 4096;
|
||||
const uri = CNB_ENV?.CNB_VSCODE_PROXY_URI as string || '';
|
||||
const finalUri = uri.replace('{{port}}', port.toString());
|
||||
let content = `
|
||||
cnb工作空间的访问uri为:${finalUri}
|
||||
`
|
||||
ctx.body = { content };
|
||||
}).addTo(app);
|
||||
|
||||
// 获取当前cnb工作空间的vscode代理uri,执行技能 get-cnb-vscode-uri
|
||||
// 包括 web 访问uri,vscode 访问uri,codebuddy 访问uri,cursor 访问uri,ssh 连接字符串
|
||||
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
key: 'get-cnb-vscode-uri',
|
||||
description: '获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
skill: 'get-cnb-vscode-uri',
|
||||
title: '获取当前cnb工作空间的编辑器访问地址',
|
||||
summary: '获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh',
|
||||
args: {
|
||||
web: tool.schema.boolean().optional().describe('是否获取vscode web的访问uri,默认为false'),
|
||||
vscode: tool.schema.boolean().optional().describe('是否获取vscode的代理uri,默认为true'),
|
||||
codebuddy: tool.schema.boolean().optional().describe('是否获取codebuddy的代理uri,默认为false'),
|
||||
cursor: tool.schema.boolean().optional().describe('是否获取cursor的代理uri,默认为false'),
|
||||
// trae: tool.schema.boolean().optional().describe('是否获取trae的代理uri,默认为false'),
|
||||
ssh: tool.schema.boolean().optional().describe('是否获取vscode remote ssh的连接字符串,默认为false'),
|
||||
}
|
||||
})
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
const web = ctx.query?.web ?? false;
|
||||
const vscode = ctx.query?.vscode ?? true; // 默认true
|
||||
const codebuddy = ctx.query?.codebuddy ?? false;
|
||||
const cursor = ctx.query?.cursor ?? false;
|
||||
// const trae = ctx.query?.trae ?? false;
|
||||
const ssh = ctx.query?.ssh ?? false;
|
||||
|
||||
const webUri = CNB_ENV?.CNB_VSCODE_WEB_URL as string || '';
|
||||
const vscodeSchma = CNB_ENV?.CNB_VSCODE_REMOTE_SSH_SCHEMA as string || '';
|
||||
let content = `
|
||||
当前的cnb 仓库为:${CNB_ENV?.CNB_REPO_SLUG}
|
||||
|
||||
`
|
||||
if (web) {
|
||||
content += `VS Code Web 访问 URI:${webUri}\n\n`;
|
||||
}
|
||||
if (vscode) {
|
||||
content += `VS Code 访问 URI:${vscodeSchma}\n\n`;
|
||||
}
|
||||
if (codebuddy) {
|
||||
const codebuddyUri = vscodeSchma.replace('vscode://vscode-remote/ssh-remote+', 'codebuddycn://vscode-remote/codebuddy-remote');
|
||||
content += `CodeBuddy 访问 URI:${codebuddyUri}\n\n`;
|
||||
}
|
||||
if (cursor) {
|
||||
const cursorUri = vscodeSchma.replace('vscode://', 'cursor://');
|
||||
content += `Cursor 访问 URI:${cursorUri}\n\n`;
|
||||
}
|
||||
// if (trae) {
|
||||
// const traeUri = vscodeSchma.replace('vscode://vscode-remote/ssh-remote+', 'traecn://ssh-remote+');
|
||||
// content += `Trae 访问 URI:${traeUri}\n\n`;
|
||||
// }
|
||||
if (ssh) {
|
||||
content += `VS Code Remote SSH 连接字符串:ssh ${CNB_ENV.CNB_PIPELINE_ID}.${CNB_ENV.CNB_VSCODE_SSH_TOKEN}@cnb.space`;
|
||||
}
|
||||
ctx.body = { content };
|
||||
}).addTo(app);
|
||||
Reference in New Issue
Block a user