Recover lost commits
This commit is contained in:
1
.cnb.yml
1
.cnb.yml
@@ -21,6 +21,7 @@ $:
|
||||
# stages:
|
||||
# - name: pnpm install
|
||||
# script: pnpm install
|
||||
stages: !reference [.dev_tempalte, stages]
|
||||
|
||||
.common_sync_to_gitea: &common_sync_to_gitea
|
||||
- <<: *common_env
|
||||
|
||||
2
.cnb/scripts/init-cube.sh
Normal file
2
.cnb/scripts/init-cube.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
echo "${KUBECONFIG_DATA}" | base64 -d > ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
@@ -38,7 +38,6 @@
|
||||
script: git pull gitea main
|
||||
- name: '提交到原本的origin'
|
||||
script: git push origin main
|
||||
|
||||
# main:
|
||||
# web_trigger_sync_to_gitea:
|
||||
# - <<: *common_sync_to_gitea_template
|
||||
@@ -48,3 +47,69 @@
|
||||
# - <<: *common_sync_to_gitea_template
|
||||
# api_trigger_sync_from_gitea:
|
||||
# - <<: *common_sync_from_gitea_template
|
||||
|
||||
.kubectl_deploy_template: &kubectl_deploy_template
|
||||
services:
|
||||
- docker
|
||||
docker:
|
||||
image: docker.cnb.cool/kevisual/dev-env:latest
|
||||
imports:
|
||||
- https://cnb.cool/kevisual/env/-/blob/main/.env.development
|
||||
stages:
|
||||
- name: '部署k8s模块'
|
||||
script: |
|
||||
echo "${KUBECONFIG_DATA}" | base64 -d > ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
|
||||
# 如果设置了 KUBE_CONTEXT,则切换上下文
|
||||
if [ -n "${KUBE_CONTEXT}" ]; then
|
||||
kubectl config use-context "${KUBE_CONTEXT}"
|
||||
fi
|
||||
export NAMESPACE=${KUBE_NAMESPACE:-default}
|
||||
kubectl rollout restart deployment/${KUBE_DEPLOYMENT} -n ${NAMESPACE}
|
||||
|
||||
.build_images_app_template: &build_images_app_template
|
||||
services:
|
||||
- docker
|
||||
docker:
|
||||
image: docker.cnb.cool/kevisual/dev-env:latest
|
||||
stages:
|
||||
- name: 检查环境是否需要打包
|
||||
script:
|
||||
- |
|
||||
if [ -f "package.json" ]; then
|
||||
echo "📦 开始前端构建流程"
|
||||
pnpm install
|
||||
pnpm run build || echo "⚠️ 构建失败或无 build script"
|
||||
else
|
||||
echo "🔍 非前端项目,跳过打包"
|
||||
fi
|
||||
- name: Docker build
|
||||
script: docker build -t ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest .
|
||||
- name: Docker push
|
||||
script: docker push ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest
|
||||
|
||||
|
||||
|
||||
.dev_tempalte: &dev_tempalte
|
||||
services:
|
||||
- vscode
|
||||
docker:
|
||||
image: docker.cnb.cool/kevisual/dev-env:latest
|
||||
stages:
|
||||
- name: 软链 .env 文件到工作目录(仓库根目录)
|
||||
script: |
|
||||
if [ -e "/root/.cnb/.env" ]; then
|
||||
ln -sf /root/.cnb/.env ./.env
|
||||
else
|
||||
echo "文件不存在"
|
||||
fi
|
||||
init_stages:
|
||||
- name: '安装依赖'
|
||||
script: |
|
||||
pnpm install
|
||||
if [ -e "/root/.cnb/.env" ]; then
|
||||
ln -sf /root/.cnb/.env ./.env
|
||||
else
|
||||
echo "文件不存在"
|
||||
fi
|
||||
|
||||
@@ -4,8 +4,8 @@ branch:
|
||||
- reg: "^main"
|
||||
buttons:
|
||||
- name: 同步代码到gitea
|
||||
desc: 同步代码到gitea
|
||||
description: 同步代码到gitea
|
||||
event: web_trigger_sync_to_gitea
|
||||
- name: 同步gitea代码到当前仓库
|
||||
desc: 同步gitea代码到当前仓库
|
||||
description: 同步gitea代码到当前仓库
|
||||
event: web_trigger_sync_from_gitea
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.env
|
||||
.env.local
|
||||
node_modules
|
||||
.pnpm-store
|
||||
11
agent/app.ts
11
agent/app.ts
@@ -1,14 +1,19 @@
|
||||
import { QueryRouterServer as App } from '@kevisual/router'
|
||||
import { useContextKey } from '@kevisual/context'
|
||||
import { useConfig } from '@kevisual/use-config'
|
||||
import { useConfig, useKey } from '@kevisual/use-config'
|
||||
import { CNB } from '../src/index.ts';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export const config = useConfig()
|
||||
export const cnb = useContextKey<CNB>('cnb', () => {
|
||||
return new CNB({ token: config.CNB_TOKEN, cookie: config.CNB_COOKIE, group: config.CNB_GROUP });
|
||||
const token = useKey('CNB_TOKEN') as string
|
||||
const cookie = useKey('CNB_COOKIE') as string
|
||||
|
||||
return new CNB({ token: token, cookie: cookie });
|
||||
})
|
||||
export const appId = nanoid();
|
||||
export const app = useContextKey<App>('app', () => {
|
||||
return new App()
|
||||
return new App({
|
||||
appId
|
||||
})
|
||||
})
|
||||
@@ -1,8 +1,15 @@
|
||||
import { app, appId } from '@/agent/app.ts';
|
||||
import { app, appId } from '../app.ts';
|
||||
import './user/check.ts'
|
||||
|
||||
import { isEqual } from 'es-toolkit'
|
||||
/**
|
||||
* 验证上下文中的 App ID 是否与指定的 App ID 匹配
|
||||
* @param {any} ctx - 上下文对象,可能包含 appId 属性
|
||||
* @param {string} appId - 需要验证的目标 App ID
|
||||
* @returns {boolean} 如果 ctx 中包含 appId 且匹配则返回 true,否则返回 false
|
||||
* @throws {Error} 如果 ctx 中包含 appId 但不匹配,则抛出 403 错误
|
||||
*/
|
||||
const checkAppId = (ctx: any, appId: string) => {
|
||||
const _appId = ctx?.appId;
|
||||
const _appId = ctx?.app?.appId;
|
||||
if (_appId) {
|
||||
if (_appId !== appId) {
|
||||
ctx.throw(403, 'Invalid App ID');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app, cnb } from '@/agent/app.ts';
|
||||
import { app, cnb } from '../../app.ts';
|
||||
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app, cnb } from '@/agent/app.ts';
|
||||
import { app, cnb } from '../../app.ts';
|
||||
|
||||
|
||||
app.route({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { app, cnb } from '@/agent/app.ts';
|
||||
import { app, cnb } from '../../app.ts';
|
||||
|
||||
app.route({
|
||||
path: 'cnb',
|
||||
|
||||
@@ -38,6 +38,19 @@
|
||||
"baseURL": "https://api.minimaxi.com/anthropic/v1",
|
||||
"apiKey": "{env:MINIMAX_API_KEY}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"custom-doubao": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"name": "国内火山AI",
|
||||
"models": {
|
||||
"ark-code-latest": {
|
||||
"name": "ark-code-latest"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
|
||||
"apiKey": "{env:DOUBAO_API_KEY}"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@
|
||||
"devDependencies": {
|
||||
"@kevisual/context": "^0.0.4",
|
||||
"@kevisual/types": "^0.0.10",
|
||||
"@opencode-ai/plugin": "^1.1.13",
|
||||
"@opencode-ai/plugin": "^1.1.16",
|
||||
"@types/bun": "^1.3.5",
|
||||
"@types/node": "^25.0.6",
|
||||
"@types/node": "^25.0.7",
|
||||
"dotenv": "^17.2.3"
|
||||
},
|
||||
"publishConfig": {
|
||||
@@ -29,8 +29,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@kevisual/query": "^0.0.35",
|
||||
"@kevisual/router": "^0.0.52",
|
||||
"@kevisual/use-config": "^1.0.24",
|
||||
"@kevisual/router": "^0.0.53",
|
||||
"@kevisual/use-config": "^1.0.26",
|
||||
"es-toolkit": "^1.43.0",
|
||||
"nanoid": "^5.1.6"
|
||||
}
|
||||
|
||||
395
pnpm-lock.yaml
generated
395
pnpm-lock.yaml
generated
@@ -12,11 +12,11 @@ importers:
|
||||
specifier: ^0.0.35
|
||||
version: 0.0.35
|
||||
'@kevisual/router':
|
||||
specifier: ^0.0.52
|
||||
version: 0.0.52
|
||||
specifier: ^0.0.53
|
||||
version: 0.0.53
|
||||
'@kevisual/use-config':
|
||||
specifier: ^1.0.24
|
||||
version: 1.0.24(dotenv@17.2.3)
|
||||
specifier: ^1.0.26
|
||||
version: 1.0.26(dotenv@17.2.3)
|
||||
es-toolkit:
|
||||
specifier: ^1.43.0
|
||||
version: 1.43.0
|
||||
@@ -31,14 +31,14 @@ importers:
|
||||
specifier: ^0.0.10
|
||||
version: 0.0.10
|
||||
'@opencode-ai/plugin':
|
||||
specifier: ^1.1.13
|
||||
version: 1.1.13
|
||||
specifier: ^1.1.16
|
||||
version: 1.1.16
|
||||
'@types/bun':
|
||||
specifier: ^1.3.5
|
||||
version: 1.3.5
|
||||
'@types/node':
|
||||
specifier: ^25.0.6
|
||||
version: 25.0.6
|
||||
specifier: ^25.0.7
|
||||
version: 25.0.7
|
||||
dotenv:
|
||||
specifier: ^17.2.3
|
||||
version: 17.2.3
|
||||
@@ -54,196 +54,50 @@ packages:
|
||||
'@kevisual/query@0.0.35':
|
||||
resolution: {integrity: sha512-80dyy2LMCmEC72g+X4QWUKlZErhawQPgnGSBNR4yhrBcFgHIJQ14LR1Z+bS5S1I7db+1PDNpaxBTjIaoYoXunw==}
|
||||
|
||||
'@kevisual/router@0.0.52':
|
||||
resolution: {integrity: sha512-Qiv3P1XjzD813Tm79S+atrDb2eickGCI9tuy/aCu512LcoYYJqZhwwkeT4ES0DinnA13Ckqd43QWBR6UmuYkHQ==}
|
||||
'@kevisual/router@0.0.53':
|
||||
resolution: {integrity: sha512-Bw9xYVWyxRhd230nF1ac7cyvzWDYKI/3V+Fr1Ew1Bfr0Ey8KuWb1MgPPopHkRHCCcUcysLtWXfu/JRiTAoBmGA==}
|
||||
|
||||
'@kevisual/types@0.0.10':
|
||||
resolution: {integrity: sha512-Q73uzzjk9UidumnmCvOpgzqDDvQxsblz22bIFuoiioUFJWwaparx8bpd8ArRyFojicYL1YJoFDzDZ9j9NN8grA==}
|
||||
|
||||
'@kevisual/use-config@1.0.24':
|
||||
resolution: {integrity: sha512-R/NcK7JtJuFuT+kKGpK89EM9oCyQzy+bIoL+hPnzdQv2TuoFULgS+CoxxYBfAjX2kCjELoNFuo9nceWSNcHNMw==}
|
||||
'@kevisual/use-config@1.0.26':
|
||||
resolution: {integrity: sha512-e5jgEALn4Pb5ReXnqVkK0XyQdRXLyciqmLFY7XVDyXCu7ieh6gxDCb41rsSfBj5ofpG8jH6afOlgWqt2A4BcWg==}
|
||||
peerDependencies:
|
||||
dotenv: ^17
|
||||
|
||||
'@noble/hashes@1.4.0':
|
||||
resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==}
|
||||
engines: {node: '>= 16'}
|
||||
'@opencode-ai/plugin@1.1.16':
|
||||
resolution: {integrity: sha512-t+Jg/rGlZkzaMABul1zu7Z7PtsjNh8UVUDc9sYh50YwO4n4ZgcVUoUllJ9AmPKdQ8MDYAFM62V29x2VVWITrwg==}
|
||||
|
||||
'@opencode-ai/plugin@1.1.13':
|
||||
resolution: {integrity: sha512-JcAsVR58EcbrHus9P8zWrhcZPw9BZbP7YYer/hk/mfpBQLLxxBQcBimnRlcRmzhw4fA0sRnwmDBRf45GdANeHQ==}
|
||||
|
||||
'@opencode-ai/sdk@1.1.13':
|
||||
resolution: {integrity: sha512-tZ/mTAHds201ebEWBcpMiqf+MG2Hl1eDpJAcuUo2VZqmWcksdSenhnWNaqU3e/3T5oMuLiAkxXzUi3zQCQONuQ==}
|
||||
|
||||
'@peculiar/asn1-cms@2.6.0':
|
||||
resolution: {integrity: sha512-2uZqP+ggSncESeUF/9Su8rWqGclEfEiz1SyU02WX5fUONFfkjzS2Z/F1Li0ofSmf4JqYXIOdCAZqIXAIBAT1OA==}
|
||||
|
||||
'@peculiar/asn1-csr@2.6.0':
|
||||
resolution: {integrity: sha512-BeWIu5VpTIhfRysfEp73SGbwjjoLL/JWXhJ/9mo4vXnz3tRGm+NGm3KNcRzQ9VMVqwYS2RHlolz21svzRXIHPQ==}
|
||||
|
||||
'@peculiar/asn1-ecc@2.6.0':
|
||||
resolution: {integrity: sha512-FF3LMGq6SfAOwUG2sKpPXblibn6XnEIKa+SryvUl5Pik+WR9rmRA3OCiwz8R3lVXnYnyRkSZsSLdml8H3UiOcw==}
|
||||
|
||||
'@peculiar/asn1-pfx@2.6.0':
|
||||
resolution: {integrity: sha512-rtUvtf+tyKGgokHHmZzeUojRZJYPxoD/jaN1+VAB4kKR7tXrnDCA/RAWXAIhMJJC+7W27IIRGe9djvxKgsldCQ==}
|
||||
|
||||
'@peculiar/asn1-pkcs8@2.6.0':
|
||||
resolution: {integrity: sha512-KyQ4D8G/NrS7Fw3XCJrngxmjwO/3htnA0lL9gDICvEQ+GJ+EPFqldcJQTwPIdvx98Tua+WjkdKHSC0/Km7T+lA==}
|
||||
|
||||
'@peculiar/asn1-pkcs9@2.6.0':
|
||||
resolution: {integrity: sha512-b78OQ6OciW0aqZxdzliXGYHASeCvvw5caqidbpQRYW2mBtXIX2WhofNXTEe7NyxTb0P6J62kAAWLwn0HuMF1Fw==}
|
||||
|
||||
'@peculiar/asn1-rsa@2.6.0':
|
||||
resolution: {integrity: sha512-Nu4C19tsrTsCp9fDrH+sdcOKoVfdfoQQ7S3VqjJU6vedR7tY3RLkQ5oguOIB3zFW33USDUuYZnPEQYySlgha4w==}
|
||||
|
||||
'@peculiar/asn1-schema@2.6.0':
|
||||
resolution: {integrity: sha512-xNLYLBFTBKkCzEZIw842BxytQQATQv+lDTCEMZ8C196iJcJJMBUZxrhSTxLaohMyKK8QlzRNTRkUmanucnDSqg==}
|
||||
|
||||
'@peculiar/asn1-x509-attr@2.6.0':
|
||||
resolution: {integrity: sha512-MuIAXFX3/dc8gmoZBkwJWxUWOSvG4MMDntXhrOZpJVMkYX+MYc/rUAU2uJOved9iJEoiUx7//3D8oG83a78UJA==}
|
||||
|
||||
'@peculiar/asn1-x509@2.6.0':
|
||||
resolution: {integrity: sha512-uzYbPEpoQiBoTq0/+jZtpM6Gq6zADBx+JNFP3yqRgziWBxQ/Dt/HcuvRfm9zJTPdRcBqPNdaRHTVwpyiq6iNMA==}
|
||||
|
||||
'@peculiar/x509@1.14.2':
|
||||
resolution: {integrity: sha512-r2w1Hg6pODDs0zfAKHkSS5HLkOLSeburtcgwvlLLWWCixw+MmW3U6kD5ddyvc2Y2YdbGuVwCF2S2ASoU1cFAag==}
|
||||
engines: {node: '>=22.0.0'}
|
||||
'@opencode-ai/sdk@1.1.16':
|
||||
resolution: {integrity: sha512-J77pyb370VvzycqXQE/kvTs7P+tEb0wfsWZDHScBoqstQOV7Ya9uXp2XSO5aPuzjP9WJGfnNZ8MmUwMfv8vIZQ==}
|
||||
|
||||
'@types/bun@1.3.5':
|
||||
resolution: {integrity: sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w==}
|
||||
|
||||
'@types/node@25.0.6':
|
||||
resolution: {integrity: sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q==}
|
||||
|
||||
asn1js@3.0.7:
|
||||
resolution: {integrity: sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
'@types/node@25.0.7':
|
||||
resolution: {integrity: sha512-C/er7DlIZgRJO7WtTdYovjIFzGsz0I95UlMyR9anTb4aCpBSRWe5Jc1/RvLKUfzmOxHPGjSE5+63HgLtndxU4w==}
|
||||
|
||||
bun-types@1.3.5:
|
||||
resolution: {integrity: sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw==}
|
||||
|
||||
bytestreamjs@2.0.1:
|
||||
resolution: {integrity: sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
||||
debug@4.4.3:
|
||||
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
|
||||
engines: {node: '>=6.0'}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
|
||||
depd@2.0.0:
|
||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
dotenv@17.2.3:
|
||||
resolution: {integrity: sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
encodeurl@2.0.0:
|
||||
resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
es-toolkit@1.43.0:
|
||||
resolution: {integrity: sha512-SKCT8AsWvYzBBuUqMk4NPwFlSdqLpJwmy6AP322ERn8W2YLIB6JBXnwMI2Qsh2gfphT3q7EKAxKb23cvFHFwKA==}
|
||||
|
||||
escape-html@1.0.3:
|
||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||
|
||||
etag@1.8.1:
|
||||
resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
eventemitter3@5.0.1:
|
||||
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
|
||||
|
||||
fresh@2.0.0:
|
||||
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
http-errors@2.0.1:
|
||||
resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
inherits@2.0.4:
|
||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
|
||||
mime-db@1.54.0:
|
||||
resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-types@3.0.2:
|
||||
resolution: {integrity: sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
|
||||
nanoid@5.1.6:
|
||||
resolution: {integrity: sha512-c7+7RQ+dMB5dPwwCp4ee1/iV/q2P6aK1mTZcfr1BTuVlyW9hJYiMPybJCcnBlQtuSmTIWNeazm/zqNoZSSElBg==}
|
||||
engines: {node: ^18 || >=20}
|
||||
hasBin: true
|
||||
|
||||
on-finished@2.4.1:
|
||||
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
path-to-regexp@8.3.0:
|
||||
resolution: {integrity: sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==}
|
||||
|
||||
pkijs@3.3.3:
|
||||
resolution: {integrity: sha512-+KD8hJtqQMYoTuL1bbGOqxb4z+nZkTAwVdNtWwe8Tc2xNbEmdJYIYoc6Qt0uF55e6YW6KuTHw1DjQ18gMhzepw==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
|
||||
pvtsutils@1.3.6:
|
||||
resolution: {integrity: sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==}
|
||||
|
||||
pvutils@1.1.5:
|
||||
resolution: {integrity: sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
|
||||
range-parser@1.2.1:
|
||||
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
reflect-metadata@0.2.2:
|
||||
resolution: {integrity: sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==}
|
||||
|
||||
selfsigned@5.4.0:
|
||||
resolution: {integrity: sha512-Yn8qZOOJv+NhcGY19iC+ngW6hlUCNpvWEkrKllXNhmkLgR9fcErm8EqZ/wev7/tiwjKC9qj17Fa/PtBNzb6q8g==}
|
||||
engines: {node: '>=15.6.0'}
|
||||
|
||||
send@1.2.1:
|
||||
resolution: {integrity: sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==}
|
||||
engines: {node: '>= 18'}
|
||||
|
||||
setprototypeof@1.2.0:
|
||||
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
|
||||
|
||||
statuses@2.0.2:
|
||||
resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
toidentifier@1.0.1:
|
||||
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
tslib@1.14.1:
|
||||
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
||||
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
tsyringe@4.10.0:
|
||||
resolution: {integrity: sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
undici-types@7.16.0:
|
||||
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
|
||||
|
||||
@@ -262,243 +116,44 @@ snapshots:
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@kevisual/router@0.0.52':
|
||||
dependencies:
|
||||
eventemitter3: 5.0.1
|
||||
path-to-regexp: 8.3.0
|
||||
selfsigned: 5.4.0
|
||||
send: 1.2.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
'@kevisual/router@0.0.53': {}
|
||||
|
||||
'@kevisual/types@0.0.10': {}
|
||||
|
||||
'@kevisual/use-config@1.0.24(dotenv@17.2.3)':
|
||||
'@kevisual/use-config@1.0.26(dotenv@17.2.3)':
|
||||
dependencies:
|
||||
'@kevisual/load': 0.0.6
|
||||
dotenv: 17.2.3
|
||||
|
||||
'@noble/hashes@1.4.0': {}
|
||||
|
||||
'@opencode-ai/plugin@1.1.13':
|
||||
'@opencode-ai/plugin@1.1.16':
|
||||
dependencies:
|
||||
'@opencode-ai/sdk': 1.1.13
|
||||
'@opencode-ai/sdk': 1.1.16
|
||||
zod: 4.1.8
|
||||
|
||||
'@opencode-ai/sdk@1.1.13': {}
|
||||
|
||||
'@peculiar/asn1-cms@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
'@peculiar/asn1-x509-attr': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-csr@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-ecc@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-pfx@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-cms': 2.6.0
|
||||
'@peculiar/asn1-pkcs8': 2.6.0
|
||||
'@peculiar/asn1-rsa': 2.6.0
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-pkcs8@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-pkcs9@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-cms': 2.6.0
|
||||
'@peculiar/asn1-pfx': 2.6.0
|
||||
'@peculiar/asn1-pkcs8': 2.6.0
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
'@peculiar/asn1-x509-attr': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-rsa@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-schema@2.6.0':
|
||||
dependencies:
|
||||
asn1js: 3.0.7
|
||||
pvtsutils: 1.3.6
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-x509-attr@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/asn1-x509@2.6.0':
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
asn1js: 3.0.7
|
||||
pvtsutils: 1.3.6
|
||||
tslib: 2.8.1
|
||||
|
||||
'@peculiar/x509@1.14.2':
|
||||
dependencies:
|
||||
'@peculiar/asn1-cms': 2.6.0
|
||||
'@peculiar/asn1-csr': 2.6.0
|
||||
'@peculiar/asn1-ecc': 2.6.0
|
||||
'@peculiar/asn1-pkcs9': 2.6.0
|
||||
'@peculiar/asn1-rsa': 2.6.0
|
||||
'@peculiar/asn1-schema': 2.6.0
|
||||
'@peculiar/asn1-x509': 2.6.0
|
||||
pvtsutils: 1.3.6
|
||||
reflect-metadata: 0.2.2
|
||||
tslib: 2.8.1
|
||||
tsyringe: 4.10.0
|
||||
'@opencode-ai/sdk@1.1.16': {}
|
||||
|
||||
'@types/bun@1.3.5':
|
||||
dependencies:
|
||||
bun-types: 1.3.5
|
||||
|
||||
'@types/node@25.0.6':
|
||||
'@types/node@25.0.7':
|
||||
dependencies:
|
||||
undici-types: 7.16.0
|
||||
|
||||
asn1js@3.0.7:
|
||||
dependencies:
|
||||
pvtsutils: 1.3.6
|
||||
pvutils: 1.1.5
|
||||
tslib: 2.8.1
|
||||
|
||||
bun-types@1.3.5:
|
||||
dependencies:
|
||||
'@types/node': 25.0.6
|
||||
|
||||
bytestreamjs@2.0.1: {}
|
||||
|
||||
debug@4.4.3:
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
|
||||
depd@2.0.0: {}
|
||||
'@types/node': 25.0.7
|
||||
|
||||
dotenv@17.2.3: {}
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
encodeurl@2.0.0: {}
|
||||
|
||||
es-toolkit@1.43.0: {}
|
||||
|
||||
escape-html@1.0.3: {}
|
||||
|
||||
etag@1.8.1: {}
|
||||
|
||||
eventemitter3@5.0.1: {}
|
||||
|
||||
fresh@2.0.0: {}
|
||||
|
||||
http-errors@2.0.1:
|
||||
dependencies:
|
||||
depd: 2.0.0
|
||||
inherits: 2.0.4
|
||||
setprototypeof: 1.2.0
|
||||
statuses: 2.0.2
|
||||
toidentifier: 1.0.1
|
||||
|
||||
inherits@2.0.4: {}
|
||||
|
||||
mime-db@1.54.0: {}
|
||||
|
||||
mime-types@3.0.2:
|
||||
dependencies:
|
||||
mime-db: 1.54.0
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
nanoid@5.1.6: {}
|
||||
|
||||
on-finished@2.4.1:
|
||||
dependencies:
|
||||
ee-first: 1.1.1
|
||||
|
||||
path-to-regexp@8.3.0: {}
|
||||
|
||||
pkijs@3.3.3:
|
||||
dependencies:
|
||||
'@noble/hashes': 1.4.0
|
||||
asn1js: 3.0.7
|
||||
bytestreamjs: 2.0.1
|
||||
pvtsutils: 1.3.6
|
||||
pvutils: 1.1.5
|
||||
tslib: 2.8.1
|
||||
|
||||
pvtsutils@1.3.6:
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
pvutils@1.1.5: {}
|
||||
|
||||
range-parser@1.2.1: {}
|
||||
|
||||
reflect-metadata@0.2.2: {}
|
||||
|
||||
selfsigned@5.4.0:
|
||||
dependencies:
|
||||
'@peculiar/x509': 1.14.2
|
||||
pkijs: 3.3.3
|
||||
|
||||
send@1.2.1:
|
||||
dependencies:
|
||||
debug: 4.4.3
|
||||
encodeurl: 2.0.0
|
||||
escape-html: 1.0.3
|
||||
etag: 1.8.1
|
||||
fresh: 2.0.0
|
||||
http-errors: 2.0.1
|
||||
mime-types: 3.0.2
|
||||
ms: 2.1.3
|
||||
on-finished: 2.4.1
|
||||
range-parser: 1.2.1
|
||||
statuses: 2.0.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
setprototypeof@1.2.0: {}
|
||||
|
||||
statuses@2.0.2: {}
|
||||
|
||||
toidentifier@1.0.1: {}
|
||||
|
||||
tslib@1.14.1: {}
|
||||
|
||||
tslib@2.8.1: {}
|
||||
|
||||
tsyringe@4.10.0:
|
||||
dependencies:
|
||||
tslib: 1.14.1
|
||||
|
||||
undici-types@7.16.0: {}
|
||||
|
||||
zod@4.1.8: {}
|
||||
|
||||
@@ -69,12 +69,12 @@ export class CNBCore {
|
||||
headers: _headers,
|
||||
body: _body,
|
||||
});
|
||||
const res = (data: any, message?: string) => {
|
||||
const res = (data: any, message?: string, code?: number) => {
|
||||
if (useOrigin) {
|
||||
return data;
|
||||
}
|
||||
return {
|
||||
code: 200,
|
||||
code: code ?? 200,
|
||||
message: message || 'success',
|
||||
data,
|
||||
};
|
||||
@@ -83,7 +83,7 @@ export class CNBCore {
|
||||
const errorText = await response.text();
|
||||
if (useOrigin)
|
||||
throw new Error(`Request failed with status ${response.status}: ${errorText}`);
|
||||
return res(null, `Request failed with status ${response.status}: ${errorText}`);
|
||||
return res(null, `Request failed with status ${response.status}: ${errorText}`, response.status);
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
|
||||
47
src/common/cnb-env.ts
Normal file
47
src/common/cnb-env.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
/**
|
||||
* CNB 环境变量配置
|
||||
* 该模块定义了 CNB (Cloud Native Build) 平台提供的所有环境变量
|
||||
* 用于获取当前构建环境、仓库信息、运行器配置等元数据
|
||||
*/
|
||||
import { useKey } from "@kevisual/use-config"
|
||||
|
||||
export const CNB_ENV = {
|
||||
// 仓库相关配置
|
||||
/** 仓库的 HTTPS 地址,如 "https://cnb.cool/kevisual/cnb" */
|
||||
CNB_REPO_URL_HTTPS: useKey('CNB_REPO_URL_HTTPS'),
|
||||
|
||||
// 构建相关配置
|
||||
/** 流水线 ID,唯一标识一次构建流水线,如 "cnb-108-1jer5qekq-001" */
|
||||
CNB_PIPELINE_ID: useKey('CNB_PIPELINE_ID'),
|
||||
/** 构建 ID,与流水线 ID 相关联,如 "cnb-108-1jer5qekq" */
|
||||
CNB_BUILD_ID: useKey('CNB_BUILD_ID'),
|
||||
/** 构建开始时间,ISO 8601 格式,如 "2026-01-13T07:58:41.825Z" */
|
||||
CNB_BUILD_START_TIME: useKey('CNB_BUILD_START_TIME'),
|
||||
/** 构建日志 Web 界面 URL,用于在浏览器中查看构建日志 */
|
||||
CNB_BUILD_WEB_URL: useKey('CNB_BUILD_WEB_URL'),
|
||||
/** 触发构建的事件类型,如 "vscode" 表示由 VS Code 触发 */
|
||||
CNB_EVENT: useKey('CNB_EVENT'),
|
||||
/** 当前构建对应的 Git 提交哈希值 */
|
||||
CNB_COMMIT: useKey('CNB_COMMIT'),
|
||||
|
||||
// VS Code 相关配置
|
||||
/** VS Code Web 界面的访问 URL,用于在浏览器中打开 VS Code */
|
||||
CNB_VSCODE_WEB_URL: useKey('CNB_VSCODE_WEB_URL'),
|
||||
/** VS Code 代理 URI,用于端口转发,{{port}} 会被替换为实际端口号, 例如: "https://1wnts22gq3-{{port}}.cnb.run"*/
|
||||
CNB_VSCODE_PROXY_URI: useKey('CNB_VSCODE_PROXY_URI'),
|
||||
|
||||
// 仓库标识配置
|
||||
/** 仓库标识符,格式为 "组名/仓库名",如 "kevisual/cnb" */
|
||||
CNB_REPO_SLUG: useKey('CNB_REPO_SLUG'),
|
||||
/** 组名/命名空间标识符,如 "kevisual" */
|
||||
CNB_GROUP_SLUG: useKey('CNB_GROUP_SLUG'),
|
||||
|
||||
// 运行器资源配置
|
||||
/** 运行器分配的 CPU 核心数,单位为核, 例如: "8"*/
|
||||
CNB_CPUS: useKey('CNB_CPUS'),
|
||||
/** 运行器分配的内存大小,单位为 GB, 例如: "16"*/
|
||||
CNB_MEMORY: useKey('CNB_MEMORY'),
|
||||
/** 运行器的 IP 地址,用于网络连接和调试 */
|
||||
CNB_RUNNER_IP: useKey('CNB_RUNNER_IP'),
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CNBCore, CNBCoreOptions } from "./cnb-core.ts";
|
||||
import { Workspace } from "./workspace.ts";
|
||||
import { Workspace } from "./workspace/index.ts";
|
||||
import { KnowledgeBase } from "./knowledge/index.ts";
|
||||
import { Repo } from "./repo/index.ts";
|
||||
import { User } from "./user/index.ts";
|
||||
@@ -31,7 +31,6 @@ export class CNB extends CNBCore {
|
||||
const cookie = this.cookie;
|
||||
const options = { token, cookie };
|
||||
this.workspace = new Workspace(options.token);
|
||||
const group = cnbOptions?.group || '';
|
||||
this.knowledgeBase = new KnowledgeBase({ token: options.token, cookie: options.cookie });
|
||||
this.repo = new Repo({ token: options.token, cookie: options.cookie });
|
||||
this.user = new User({ token: options.token, cookie: options.cookie });
|
||||
@@ -39,10 +38,6 @@ export class CNB extends CNBCore {
|
||||
this.issue = new Issue({ token: options.token, cookie: options.cookie });
|
||||
this.mission = new Mission({ token: options.token, cookie: options.cookie });
|
||||
this.ai = new AiBase({ token: options.token, cookie: options.cookie });
|
||||
this.group = group;
|
||||
}
|
||||
setGroup(group: string) {
|
||||
this.group = group;
|
||||
}
|
||||
setToken(token: string) {
|
||||
this.token = token;
|
||||
@@ -64,7 +59,7 @@ export class CNB extends CNBCore {
|
||||
}
|
||||
}
|
||||
|
||||
export * from './workspace.ts'
|
||||
export * from './workspace/index.ts'
|
||||
export * from './cnb-core.ts'
|
||||
export * from './knowledge/index.ts'
|
||||
export * from './repo/index.ts'
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { Result } from "@kevisual/query/query";
|
||||
import { CNBCore } from "./cnb-core.ts";
|
||||
import { CNBCore } from "../cnb-core.ts";
|
||||
|
||||
/**
|
||||
* 工作空间列表查询参数
|
||||
@@ -15,4 +15,4 @@ const main = async () => {
|
||||
console.log("build", build);
|
||||
}
|
||||
|
||||
main()
|
||||
// main()
|
||||
@@ -1,16 +1,18 @@
|
||||
import { CNB } from "../src";
|
||||
import dotenv from "dotenv";
|
||||
import util from 'node:util';
|
||||
dotenv.config();
|
||||
export const token = process.env.CNB_TOKEN || "";
|
||||
export const cookie = process.env.CNB_COOKIE || "";
|
||||
import { useConfig, useKey } from "@kevisual/use-config";
|
||||
const config = useConfig()
|
||||
export const token = useKey("CNB_TOKEN") as string || '';
|
||||
export const cookie = useKey("CNB_COOKIE") as string || '';
|
||||
console.log('token', token)
|
||||
export const cnb = new CNB({ token, cookie });
|
||||
export const showMore = (obj: any) => {
|
||||
return util.inspect(obj, { showHidden: false, depth: null, colors: true });
|
||||
}
|
||||
// const worksaceList = await cnb.workspace.list({ status: 'running' });
|
||||
const worksaceList = await cnb.workspace.list({ status: 'running' });
|
||||
|
||||
// console.log("worksaceList", worksaceList);
|
||||
console.log("worksaceList", showMore(worksaceList));
|
||||
|
||||
// const sn = 'cnb-o18-1jbklfuoh'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user