mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-08-10 08:04:02 +08:00
fix(channels): 同步契约按内核源码逐条核对并修正
对照 OpenClaw(zod-schema.core.ts / model-ref-shared.ts)与 Hermes (config.py / auth.py / model_normalize.py)内核源码验证同步写入契约, 修正三处不一致: - OpenClaw 模型条目恒写含 id/name 的完整对象(内核 strict schema 两字段必填,裸字符串有被拒风险),name 缺省回退为模型 ID; 模型引用按第一个 / 切分已确认正确,含斜杠模型 ID 无需处理 - Hermes model.default 改写纯模型 ID:内核不解析 "provider/model" 前缀(provider 由 model.provider 单独指定),原先拼接前缀会写出 内核不认识的模型名 - Hermes 回退 provider 按注册表真实 id 匹配:OpenAI 兼容 → 'custom' (注册表无独立 'openai' API-Key id),Gemini → 'gemini'(内核经 OpenAI 兼容端点接入,按 transport 匹配会误判为不支持); 自定义 Base URL 仅对 OpenAI 兼容渠道写入,避免破坏 anthropic/gemini 的专用端点格式 另:渠道编辑器新增「可同步到」实时适配提示(切换 API 类型即显示 OpenClaw / Hermes / 助手的支持情况);测试断言更新为核对后的契约 (428 通过)。发现的存量问题已记录:最新内核 api 枚举中 openai-codex-responses 已改名,共享 API_TYPES 需对照推荐稳定版处理。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,20 @@ function apiTypeLabel(value) {
|
||||
return API_TYPES.find(item => item.value === value)?.label || value
|
||||
}
|
||||
|
||||
// 编辑器内的内核适配性提示:该 API 类型能同步到哪些目标
|
||||
function renderCompatHint(apiType) {
|
||||
const fake = { apiType }
|
||||
const targets = [
|
||||
{ label: t('modelChannels.targetOpenclaw'), ok: true, hint: '' },
|
||||
{ label: t('modelChannels.targetHermes'), ok: hermesSyncSupported(fake), hint: t('modelChannels.syncHermesUnsupported') },
|
||||
{ label: t('modelChannels.targetAssistant'), ok: assistantSyncSupported(fake), hint: t('modelChannels.syncAssistantUnsupported') },
|
||||
]
|
||||
const parts = targets.map(item => item.ok
|
||||
? `<span style="color:var(--success)">✓ ${esc(item.label)}</span>`
|
||||
: `<span style="color:var(--text-tertiary)" title="${attr(item.hint)}">— ${esc(item.label)}</span>`)
|
||||
return `${esc(t('modelChannels.compatLabel'))}: ${parts.join(' · ')}`
|
||||
}
|
||||
|
||||
export async function render() {
|
||||
const page = document.createElement('div')
|
||||
page.className = 'page channels-hub-page'
|
||||
@@ -231,6 +245,7 @@ function renderEditor(state) {
|
||||
<select class="form-input" id="mch-api-type">
|
||||
${API_TYPES.map(item => `<option value="${attr(item.value)}" ${item.value === draft.apiType ? 'selected' : ''}>${esc(item.label)}</option>`).join('')}
|
||||
</select>
|
||||
<div class="form-hint" id="mch-compat">${renderCompatHint(draft.apiType)}</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="mch-api-key">${t('modelChannels.apiKey')}</label>
|
||||
@@ -294,8 +309,15 @@ function bindEvents(page, state) {
|
||||
if (apiTypeSelect && preset.api) apiTypeSelect.value = preset.api
|
||||
const nameInput = page.querySelector('#mch-name')
|
||||
if (nameInput && !nameInput.value.trim()) nameInput.value = preset.label
|
||||
const compat = page.querySelector('#mch-compat')
|
||||
if (compat && preset.api) compat.innerHTML = renderCompatHint(preset.api)
|
||||
}
|
||||
}
|
||||
// API 类型变化 → 实时刷新内核适配性提示
|
||||
if (event.target.id === 'mch-api-type' && state.editing) {
|
||||
const compat = page.querySelector('#mch-compat')
|
||||
if (compat) compat.innerHTML = renderCompatHint(event.target.value)
|
||||
}
|
||||
})
|
||||
|
||||
// 模型列表变化时同步默认模型下拉选项
|
||||
|
||||
Reference in New Issue
Block a user