From 21ba07e55ba7cf20b29ce463b66badd20e3064e6 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sat, 7 Mar 2026 02:19:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E5=AD=98=E6=B4=BB=E6=8A=80?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=B9=B6=E6=B7=BB=E5=8A=A0=E4=BF=9D=E6=B4=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/routes/workspace/keep.ts | 23 +++++++++++------------ package.json | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/agent/routes/workspace/keep.ts b/agent/routes/workspace/keep.ts index 8ff5a88..4f8cf4f 100644 --- a/agent/routes/workspace/keep.ts +++ b/agent/routes/workspace/keep.ts @@ -30,21 +30,20 @@ app.route({ ctx.throw(401, 'CNB_COOKIE 环境变量无效或已过期,请重新登录获取新的cookie'); } const res = await cnb.workspace.getWorkspaceCookie(repo, pipelineId); - let wsUrl = `wss://${pipelineId}.cnb.space:443?skipWebSocketFrames=false`; - let cookie = ''; - if (res.code === 200) { - cookie = res.data.value; - console.log(`启动保持工作空间 ${wsUrl} 存活的任务`); - } else { - ctx.throw(500, `获取工作空间访问cookie失败: ${res.message}`); + if (res.code !== 200 || !res.data?.cookie) { + ctx.throw(500, `获取工作空间 Cookie 失败: ${res.message}`); } - console.log(`启动保持工作空间 ${wsUrl} 存活的任务`); + // 添加保活数据 + const liveData = createLiveData({ + repo, + pipelineId, + cookie: res.data.cookie + }); + addKeepAliveData(liveData); + console.log('已添加 keep-alive 数据'); - const config: KeepAliveData = createLiveData({ cookie, repo, pipelineId }); - addKeepAliveData(config); - - ctx.body = { content: `已启动保持工作空间 ${wsUrl} 存活的任务`, data: config }; + ctx.body = { content: `已启动保持工作空间 ${repo}/${pipelineId} 存活的任务`, data: liveData }; }).addTo(app); // 停止保持工作空间存活技能 diff --git a/package.json b/package.json index 2e1baae..53b3bda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/cnb", - "version": "0.0.36", + "version": "0.0.37", "description": "", "main": "index.js", "scripts": {