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,33 +1,31 @@
import { createSkill, tool } from '@kevisual/router'
import { app } from '../../app.ts'
if (!app.hasRoute('call')) {
// "调用 path: cnb key: list-repos"
app.route({
path: 'call',
key: '',
description: '调用',
middleware: ['admin-auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'call-app',
title: '调用app应用',
summary: '调用router的应用, 参数path, key, payload',
args: {
path: tool.schema.string().describe('应用路径,例如 cnb'),
key: tool.schema.string().optional().describe('应用key例如 list-repos'),
payload: tool.schema.object({}).optional().describe('调用参数'),
}
})
},
}).define(async (ctx) => {
const { path, key } = ctx.query;
console.log('call app', ctx.query);
if (!path) {
ctx.throw('路径path不能为空');
}
const res = await ctx.run({ path, key, payload: ctx.query.payload || {} });
ctx.forward(res);
}).addTo(app)
}
// "调用 path: cnb key: list-repos"
app.route({
path: 'call',
key: '',
description: '调用',
middleware: ['admin-auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'call-app',
title: '调用app应用',
summary: '调用router的应用, 参数path, key, payload',
args: {
path: tool.schema.string().describe('应用路径,例如 cnb'),
key: tool.schema.string().optional().describe('应用key,例如 list-repos'),
payload: tool.schema.object({}).optional().describe('调用参数'),
}
})
},
}).define(async (ctx) => {
const { path, key } = ctx.query;
console.log('call app', ctx.query);
if (!path) {
ctx.throw('路径path不能为空');
}
const res = await ctx.run({ path, key, payload: ctx.query.payload || {} });
ctx.forward(res);
}).addTo(app, { overwrite: false })