From 6e39a8084fdec9a411d219c2b2d949f8b61cba52 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Fri, 7 Aug 2026 12:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BC=E4=BD=88=200.1.6=EF=BC=9A=E9=80=9F?= =?UTF-8?q?=E5=BA=A6=E5=9B=BA=E5=AE=9A=20Fast=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E9=81=B8=E9=A0=85=E8=88=87=20footer=20=E9=A1=AF=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 摘要: 速度(service tier)固定為 priority(Fast 1.5x):表單移除速度下拉、 footer 不再顯示 Fast 字樣;舊設定檔存空值也會矯正回 priority。 Co-Authored-By: Claude Fable 5 --- package.json | 2 +- src/bot.js | 9 ++------- src/config.js | 7 +++++-- src/registry.js | 5 ++--- src/web/public/index.html | 36 ++++++++---------------------------- 5 files changed, 18 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 3e4aebe..b6d602e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram-codex-bot", - "version": "0.1.5", + "version": "0.1.6", "description": "Telegram bot powered by the local Codex CLI — zero-dependency, pm2-managed, with a built-in PM2 web viewer", "license": "MIT", "type": "commonjs", diff --git a/src/bot.js b/src/bot.js index 9f0c7f5..67bd5e6 100644 --- a/src/bot.js +++ b/src/bot.js @@ -32,7 +32,7 @@ function loadCodexDefaults() { } } -// — ✅ 16:06:32 | ctx 24% +1.2k | gpt-5.6-sol / high / Fast +// — ✅ 16:06:32 | ctx 24% +1.2k | gpt-5.6-sol / high function buildFooter(config, usage, modelMeta, codexDefaults) { const time = new Date().toLocaleTimeString('zh-TW', { hour12: false }); const parts = [`— ✅ ${time}`]; @@ -50,12 +50,7 @@ function buildFooter(config, usage, modelMeta, codexDefaults) { if (model) { const effort = config.reasoningEffort || codexDefaults.effort || meta?.default_reasoning_level || ''; - const tier = config.serviceTier || codexDefaults.tier || ''; - // 顯示速度層級的名稱(priority → Fast),對照模型快取 - const tierName = tier - ? (meta?.service_tiers?.find((t) => t.id === tier)?.name || tier) - : ''; - parts.push([model, effort, tierName].filter(Boolean).join(' / ')); + parts.push(effort ? `${model} / ${effort}` : model); } return `\n\n${parts.join(' | ')}`; } diff --git a/src/config.js b/src/config.js index d8800b8..0035876 100644 --- a/src/config.js +++ b/src/config.js @@ -18,8 +18,8 @@ const DEFAULTS = { model: '', // 推理強度(low/medium/high/xhigh/max/ultra…依模型而定);空字串 = codex 預設 reasoningEffort: '', - // 速度(service tier,如 priority = Fast 1.5x);空字串 = codex 預設 - serviceTier: '', + // 速度固定 Fast(priority = 1.5x);要改只能手動編輯設定檔 + serviceTier: 'priority', // 單次回應逾時(分鐘) timeoutMinutes: 30, // pm2 程序名稱(web 檢視工具會叫 -web) @@ -80,6 +80,9 @@ function loadConfig(explicitPath) { } cfg.web.port = port; } + // 速度政策固定 Fast:舊設定檔存了空值也矯正回 priority + if (!cfg.serviceTier) cfg.serviceTier = 'priority'; + const minutes = Number(cfg.timeoutMinutes); if (!(minutes > 0)) throw new Error(`timeoutMinutes 必須是正數:${cfg.timeoutMinutes}`); cfg.timeoutMinutes = minutes; diff --git a/src/registry.js b/src/registry.js index b5e3911..31c829f 100644 --- a/src/registry.js +++ b/src/registry.js @@ -112,7 +112,7 @@ function validateBotInput({ name, token, workDir, sandbox }, { isCreate }) { } } -async function createBot({ name, token, workDir, sandbox, model, reasoningEffort, serviceTier, timeoutMinutes }) { +async function createBot({ name, token, workDir, sandbox, model, reasoningEffort, timeoutMinutes }) { validateBotInput({ name, token, workDir, sandbox }, { isCreate: true }); const reg = loadRegistry(); if (reg.bots[name]) throw new Error(`已有同名 bot:${name}`); @@ -128,7 +128,7 @@ async function createBot({ name, token, workDir, sandbox, model, reasoningEffort sandbox: sandbox || 'workspace-write', model: model || '', reasoningEffort: reasoningEffort || '', - serviceTier: serviceTier || '', + serviceTier: 'priority', // 速度固定 Fast 1.5x timeoutMinutes: Number(timeoutMinutes) || 30, pm2Name: name, // UI 建的 bot 不各自開 web,統一由控制台管理 @@ -158,7 +158,6 @@ async function updateBot(name, patch) { } if (patch.model !== undefined) raw.model = patch.model; if (patch.reasoningEffort !== undefined) raw.reasoningEffort = patch.reasoningEffort; - if (patch.serviceTier !== undefined) raw.serviceTier = patch.serviceTier; if (patch.timeoutMinutes !== undefined && Number(patch.timeoutMinutes) > 0) { raw.timeoutMinutes = Number(patch.timeoutMinutes); } diff --git a/src/web/public/index.html b/src/web/public/index.html index 55c5ac6..0c98de2 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -217,10 +217,7 @@
-
-
- - +
速度固定為 Fast(1.5x)
@@ -314,7 +311,7 @@ async function loadModels() { } catch { modelsCache = []; } } // 下拉沒有「預設」空選項:直接把真實預設值選起來 -function populateModelSelects(selModel, selEffort, selTier) { +function populateModelSelects(selModel, selEffort) { const mSel = document.getElementById('f-model'); let opts = modelsCache.map(m => '').join(''); // 設定檔裡有但快取沒有的模型(手填過的)也要能顯示 @@ -326,9 +323,9 @@ function populateModelSelects(selModel, selEffort, selTier) { const wanted = selModel || modelDefaults.model; mSel.value = wanted; if (mSel.value !== wanted || !mSel.value) mSel.selectedIndex = 0; - syncEffortTier(selEffort, selTier); + syncEffortTier(selEffort); } -function syncEffortTier(selEffort, selTier) { +function syncEffortTier(selEffort) { const slug = document.getElementById('f-model').value; const m = modelsCache.find(x => x.slug === slug); let efforts = m ? m.efforts.slice() : ['low', 'medium', 'high', 'xhigh', 'max']; @@ -341,22 +338,6 @@ function syncEffortTier(selEffort, selTier) { : efforts.includes(modelDefaults.effort) ? modelDefaults.effort : (m && efforts.includes(m.defaultEffort)) ? m.defaultEffort : efforts[0]; - - const tiers = m ? m.tiers.slice() : []; - const tSel = document.getElementById('f-tier'); - const prevT = (selTier !== undefined && selTier !== '') ? selTier : tSel.value; - if (!tiers.length) { - tSel.innerHTML = ''; - tSel.value = ''; - } else { - // 模型快取只列「額外」的速度層級,補一個標準選項在前面 - tSel.innerHTML = '' + - tiers.map(t => '').join(''); - tSel.value = tiers.some(t => t.id === prevT) ? prevT - : tiers.some(t => t.id === modelDefaults.tier) ? modelDefaults.tier - : tiers.some(t => t.id === (m && m.defaultTier)) ? m.defaultTier - : ''; - } } // ---------- Bot 管理 ---------- @@ -393,8 +374,8 @@ function renderBots(bots) { '' + statusBadge(b.status) + '' + '' + esc(shortPath(b.workDir)) + '' + '' + esc(b.sandbox || '-') + - ((b.model || b.reasoningEffort || b.serviceTier) - ? '
' + esc([b.model, b.reasoningEffort, b.serviceTier].filter(Boolean).join(' / ')) + '' + ((b.model || b.reasoningEffort) + ? '
' + esc([b.model, b.reasoningEffort].filter(Boolean).join(' / ')) + '' : '') + '' + '' + esc(b.tokenMasked || '-') + '' + '' + fmtBytes(b.memory) + '' + @@ -462,7 +443,7 @@ function openCreate() { document.getElementById('f-token-hint').textContent = '跟 @BotFather 申請;儲存時會自動驗證'; document.getElementById('f-workdir').value = ''; document.getElementById('f-sandbox').value = 'workspace-write'; - populateModelSelects('', '', ''); + populateModelSelects('', ''); document.getElementById('f-timeout').value = '30'; document.getElementById('f-autostart-wrap').style.display = ''; document.getElementById('f-autostart').checked = true; @@ -483,7 +464,7 @@ function openEdit(name) { document.getElementById('f-token-hint').textContent = '留空表示沿用現有 token'; document.getElementById('f-workdir').value = b.workDir || ''; document.getElementById('f-sandbox').value = b.sandbox || 'workspace-write'; - populateModelSelects(b.model || '', b.reasoningEffort || '', b.serviceTier || ''); + populateModelSelects(b.model || '', b.reasoningEffort || ''); document.getElementById('f-timeout').value = b.timeoutMinutes || 30; document.getElementById('f-autostart-wrap').style.display = 'none'; document.getElementById('bot-modal').classList.add('show'); @@ -504,7 +485,6 @@ async function saveBot() { sandbox: document.getElementById('f-sandbox').value, model: document.getElementById('f-model').value, reasoningEffort: document.getElementById('f-effort').value, - serviceTier: document.getElementById('f-tier').value, timeoutMinutes: document.getElementById('f-timeout').value, }; try {