Files
cnb/agent/app.ts
xiongxiao 38ee73e48f feat: update package version to 0.0.42 and add CNB version fetching functionality
- Updated package version in package.json from 0.0.40 to 0.0.42.
- Added getCNBVersion function to fetch CNB version information from the API.
- Enhanced Issue class with methods for managing comments (list, create, get, update).
- Introduced new NPC and comment environment hooks for better context management.
- Implemented Docker image synchronization route for CNB.
- Added tests for version fetching and issue comment functionalities.
2026-03-10 03:45:02 +08:00

34 lines
1.1 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 { QueryRouterServer as App } from '@kevisual/router'
import { useContextKey } from '@kevisual/context'
import { useKey } from '@kevisual/use-config'
import { CNB } from '../src/index.ts';
import { CNBManager } from './modules/cnb-manager.ts'
export const cnbManager = new CNBManager()
// CNB_TOKEN是降级兼容变量推荐使用CNB_API_KEY
// CNB_TOKEN 是流水线自己就有的变量,但是权限比较小
const token = useKey('CNB_API_KEY') as string || useKey('CNB_TOKEN') as string
// cookie 变量是可选的
const cookie = useKey('CNB_COOKIE') as string
try {
cnbManager.addCNB({
username: 'default',
token: token,
cookie: cookie,
cnb: new CNB({ token: token, cookie: cookie })
})
} catch (error) {
}
export const cnb = (await cnbManager.getCNB({ username: 'default' })).cnb
export const app = await useContextKey<App>('app', () => {
return new App({})
})
export const notCNBCheck = (ctx: any) => {
const isCNB = useKey('CNB');
if (!isCNB) {
ctx.throw(400, '当前环境非 cnb-board 环境,无法获取 live 内容');
}
return false;
}