Files
cnb/agent/routes/workspace/skills.ts
xiongxiao 50332fe2f4 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.
2026-01-27 04:02:34 +08:00

64 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);