feat(cnb-board): add cnb-dev-env routes and related functionalities

- Implemented routes for cnb-board to fetch live environment configurations, repository info, build info, pull request info, NPC info, and comment info.
- Created a utility function to execute shell commands.
- Added a check to determine if the environment is a CNB environment.
- Introduced a method to retrieve live markdown content with detailed service access information.
- Enhanced system information retrieval with CPU, memory, and disk usage metrics.
- Established a module structure for better organization of cnb-board related functionalities.
This commit is contained in:
2026-03-06 02:26:13 +08:00
parent 5043392939
commit 841ed6ffa7
12 changed files with 932 additions and 225 deletions

View File

@@ -1,6 +1,7 @@
import { tool } from '@kevisual/router';
import { app, cnb } from '../../app.ts';
import { addKeepAliveData, KeepAliveData, removeKeepAliveData, createLiveData } from '../../../src/workspace/keep-file-live.ts';
import { useKey } from '@kevisual/context';
// 保持工作空间存活技能
app.route({
@@ -75,3 +76,23 @@ app.route({
app.route({
path: 'cnb',
key: 'keep-alive-current-workspace',
description: '保持当前工作空间存活技能',
middleware: ['admin-auth'],
metadata: {
tags: ['opencode'],
skill: 'keep-alive-current-workspace',
title: '保持当前工作空间存活',
summary: '保持当前工作空间存活,防止被关闭或释放资源',
}
}).define(async (ctx) => {
const pipelineId = useKey('CNB_PIPELINE_ID');
const repo = useKey('CNB_REPO_SLUG_LOWERCASE');
if (!pipelineId || !repo) {
ctx.throw(400, '当前环境缺少 CNB_PIPELINE_ID 或 CNB_REPO_SLUG_LOWERCASE 环境变量,无法保持工作空间存活');
}
const res = await app.run({ path: 'cnb', key: 'keep-workspace-alive', payload: { repo, pipelineId } }, ctx);
ctx.forward(res);
}).addTo(app);