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:
64
agent/routes/workspace/skills.ts
Normal file
64
agent/routes/workspace/skills.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { createSkill, tool } from '@kevisual/router';
|
||||
import { app, cnb } from '../../app.ts';
|
||||
|
||||
// 批量删除已停止的cnb工作空间
|
||||
// app.route({
|
||||
// path: 'cnb',
|
||||
// key: 'clean-closed-workspace-skill',
|
||||
// description: '批量删除已停止的cnb工作空间',
|
||||
// middleware: ['auth'],
|
||||
// metadata: {
|
||||
// tags: ['opencode'],
|
||||
// ...createSkill({
|
||||
// skill: 'clean-closed-workspace-skill',
|
||||
// title: '清理已关闭的cnb工作空间',
|
||||
// summary: '批量删除已停止的cnb工作空间,释放资源',
|
||||
// args: {
|
||||
// question: tool.schema.string().optional().describe('具体的要求的信息'),
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// }).define(async (ctx) => {
|
||||
// const question = ctx.query?.question || '';
|
||||
// let content = `这是一个技能任务, 批量删除已停止的cnb工作空间,释放资源
|
||||
// 执行步骤:
|
||||
// 1. 执行list-workspace,获取状态为 closed 的工作空间列表,提取sn
|
||||
// 2. 执行delete-workspace技能,传入sns列表的数组,批量删除工作空间`
|
||||
// if (question) {
|
||||
// content += `\n注意用户的具体要求是:${question}`;
|
||||
// }
|
||||
// ctx.body = { content }
|
||||
// }).addTo(app);
|
||||
|
||||
// 批量删除已停止的cnb工作空间
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
key: 'clean-closed-workspace',
|
||||
description: '批量删除已停止的cnb工作空间',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
tags: ['opencode'],
|
||||
...createSkill({
|
||||
skill: 'clean-closed-workspace',
|
||||
title: '清理已关闭的cnb工作空间',
|
||||
summary: '批量删除已停止的cnb工作空间,释放资源',
|
||||
})
|
||||
}
|
||||
}).define(async (ctx) => {
|
||||
const closedWorkspaces = await cnb.workspace.list({ status: 'closed' });
|
||||
if (closedWorkspaces.code !== 200) {
|
||||
ctx.throw(500, '获取已关闭工作空间列表失败');
|
||||
}
|
||||
const list = closedWorkspaces.data?.list || [];
|
||||
if (list.length === 0) {
|
||||
ctx.forward({ code: 200, message: '没有已关闭的工作空间需要删除', data: [] });
|
||||
return;
|
||||
}
|
||||
const sns = list.map(ws => ws.sn);
|
||||
const results = [];
|
||||
for (const sn of sns) {
|
||||
const res = await cnb.workspace.deleteWorkspace({ sn });
|
||||
results.push(res);
|
||||
}
|
||||
ctx.forward({ code: 200, message: '已关闭的工作空间删除完成', data: results });
|
||||
}).addTo(app);
|
||||
Reference in New Issue
Block a user