Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
fix(web): show the CodeBuddy network environment on runner cards (refs #198) (#233)
fx-kurumibbe979d9d62e
diff --git a/web/app/runners.js b/web/app/runners.jsindex ea6ac59d..9f464dcd 100644--- a/web/app/runners.js+++ b/web/app/runners.js@@ -64,6 +64,16 @@ function runnerPersonalCredentialConfigured(provider){if(provider==='codebuddy')return !!user.codeBuddyApiKeyConfigured;return !!user.agentCliCredentials?.[provider]?.apiKeyConfigured;}+// CodeBuddy on a runner always uses the personal API Key, so the card shows+// the same network environment as 个人配置 → CodeBuddy. An iOA key used with+// the wrong environment fails with 401 on the machine.+function runnerCodeBuddyAuthHTML(credentialReady){+ if(!credentialReady)return '<span class="runner-auth-fixed missing" title="到个人配置补充 CodeBuddy API Key 并选择网络环境">个人凭证(未配置)</span>';+ const user=userById(state.currentUser?.id)||{};+ const raw=String(user.codeBuddyInternetEnvironment||'').trim(),env=codeBuddyEnvironment(raw);+ if(!env)return `<span class="runner-auth-fixed missing" title="网络环境「${escapeHTML(raw)}」无法识别,CodeBuddy 会按国际站连接。到个人配置重新选择网络环境">个人凭证 · 网络环境无法识别</span>`;+ return `<span class="runner-auth-fixed" title="CodeBuddy 使用个人配置中保存的 API Key,网络环境:${escapeHTML(env.label)}">个人凭证 · ${escapeHTML(env.label)}</span>`;+}function runnerLastSeen(value){if(!value)return '尚无心跳';const seconds=Math.max(0,Math.round((Date.now()-new Date(value).getTime())/1000));@@ -133,7 +143,7 @@ function renderRunnersView(){const personalLabel=credentialReady?'个人凭证':'个人凭证(未配置)';const credentialMissing=authMode==='personal'&&!credentialReady;const authControl=rt.provider==='codebuddy'- ?`<span class="runner-auth-fixed ${credentialReady?'':'missing'}" title="CodeBuddy 使用个人配置中保存的 API Key">${personalLabel}</span>`+ ?runnerCodeBuddyAuthHTML(credentialReady):`<select class="runner-auth-select ${credentialMissing?'missing':''}" data-runner-auth="${escapeHTML(r.id)}|${escapeHTML(rt.provider)}" aria-label="${runnerCLILabels[rt.provider]} 认证来源"${credentialMissing?` title="到个人配置补充 ${runnerCLILabels[rt.provider]} API Key"`:''}><option value="local" ${authMode==='local'?'selected':''}>本机登录</option><option value="personal" ${authMode==='personal'?'selected':''}>${personalLabel}</option>diff --git a/webtest/tests/runner-codebuddy-environment.test.mjs b/webtest/tests/runner-codebuddy-environment.test.mjsnew file mode 100644index 00000000..ca40553e--- /dev/null+++ b/webtest/tests/runner-codebuddy-environment.test.mjs@@ -0,0 +1,57 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { loadApp } from '../lib/load-app.mjs';++// #198 item 7: the CodeBuddy row on a runner card shows the same network+// environment as 个人配置 → CodeBuddy, so an iOA key used with the wrong+// environment is visible before the machine answers 401.+function renderCodeBuddyRow(app, user) {+ const runner = {+ id: 'runner-cb', name: 'Laptop', ownerUserId: 1, status: 'online', os: 'linux', arch: 'amd64',+ lastSeenAt: new Date().toISOString(),+ runtimes: [+ { provider: 'codebuddy', status: 'online', authMode: 'personal', version: '2.0' },+ { provider: 'codex', status: 'online', authMode: 'local', version: '1.0' },+ ],+ };+ app.evaluate(`+ state.currentUser={id:1,loginName:'owner'};+ state.data.users=[${JSON.stringify({ id: 1, loginName: 'owner', ...user })}];+ state.runners=[${JSON.stringify(runner)}];state.defaultRunnerId='';state.cloudPool={configured:true,online:1};+ renderRunnersView();+ `);+ const list = app.document.querySelector('#runnersList');+ const fixed = list.querySelectorAll('.runner-auth-fixed');+ assert.equal(fixed.length, 1, 'only the CodeBuddy row has a fixed credential label');+ assert.ok(list.querySelector('[data-runner-auth="runner-cb|codex"]'), 'Codex keeps its auth-source select');+ return fixed[0];+}++test('runner card shows the CodeBuddy network environment from personal config', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ for (const [value, label] of [['', '国际站'], ['internal', '国内站'], ['ioa', 'iOA']]) {+ const el = renderCodeBuddyRow(app, { codeBuddyApiKeyConfigured: true, codeBuddyInternetEnvironment: value });+ assert.equal(el.textContent, `个人凭证 · ${label}`);+ assert.equal(el.classList.contains('missing'), false);+ assert.match(el.getAttribute('title'), new RegExp(`网络环境:${label}`));+ }+});++test('runner card flags an unrecognized CodeBuddy network environment', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ const el = renderCodeBuddyRow(app, { codeBuddyApiKeyConfigured: true, codeBuddyInternetEnvironment: 'china<b>' });+ assert.equal(el.textContent, '个人凭证 · 网络环境无法识别');+ assert.ok(el.classList.contains('missing'));+ assert.match(el.getAttribute('title'), /「china<b>」无法识别,CodeBuddy 会按国际站连接/);+ assert.equal(el.querySelector('b'), null, 'stored value is escaped');+});++test('runner card keeps the missing-key label when CodeBuddy is not configured', async (t) => {+ const app = await loadApp();+ t.after(app.close);+ const el = renderCodeBuddyRow(app, { codeBuddyApiKeyConfigured: false, codeBuddyInternetEnvironment: 'ioa' });+ assert.equal(el.textContent, '个人凭证(未配置)');+ assert.ok(el.classList.contains('missing'));+});