@lsamien/yaoyao 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +6 -6
  2. package/build-info.json +7 -3
  3. package/desktop/main.mjs +2 -59
  4. package/dist/admin/admin.html +2 -2
  5. package/dist/admin/assets/AccountPage-BM-5BzEC.js +2 -0
  6. package/dist/admin/assets/AccountPage-BM-5BzEC.js.map +1 -0
  7. package/dist/admin/assets/AccountPage-DuED6n3Z.css +1 -0
  8. package/dist/admin/assets/{AuditPage-kQHS8ez1.js → AuditPage-BYC3Sj8A.js} +2 -2
  9. package/dist/admin/assets/{AuditPage-kQHS8ez1.js.map → AuditPage-BYC3Sj8A.js.map} +1 -1
  10. package/dist/admin/assets/{DesktopHostSettingsPanel-x8qZaYP_.js → DesktopHostSettingsPanel-va4JiNPy.js} +3 -3
  11. package/dist/admin/assets/{DesktopHostSettingsPanel-x8qZaYP_.js.map → DesktopHostSettingsPanel-va4JiNPy.js.map} +1 -1
  12. package/dist/admin/assets/DevicesPage-D7-OiBsf.js +2 -0
  13. package/dist/admin/assets/DevicesPage-D7-OiBsf.js.map +1 -0
  14. package/dist/admin/assets/{DevicesPage-BYmzYCVl.css → DevicesPage-vlD4SH1G.css} +1 -1
  15. package/dist/admin/assets/{ExecutionPage-MrUVepUz.js → ExecutionPage-yK_unxZe.js} +3 -3
  16. package/dist/admin/assets/{ExecutionPage-MrUVepUz.js.map → ExecutionPage-yK_unxZe.js.map} +1 -1
  17. package/dist/admin/assets/{HermesModelSettingsPanel-DzV-tcHN.js → HermesModelSettingsPanel-DbvAMOaL.js} +4 -4
  18. package/dist/admin/assets/{HermesModelSettingsPanel-DzV-tcHN.js.map → HermesModelSettingsPanel-DbvAMOaL.js.map} +1 -1
  19. package/dist/admin/assets/{LocalVmSettingsPanel-KroYaJcH.js → LocalVmSettingsPanel-Mts0IE2D.js} +2 -2
  20. package/dist/admin/assets/{LocalVmSettingsPanel-KroYaJcH.js.map → LocalVmSettingsPanel-Mts0IE2D.js.map} +1 -1
  21. package/dist/admin/assets/{MemoryPage-CMzoheMD.js → MemoryPage-BbN5Cy7z.js} +2 -2
  22. package/dist/admin/assets/{MemoryPage-CMzoheMD.js.map → MemoryPage-BbN5Cy7z.js.map} +1 -1
  23. package/dist/admin/assets/NetworkPage-CFr7H5d3.css +1 -0
  24. package/dist/admin/assets/{NetworkPage-DXxW3wcm.js → NetworkPage-DJpVHDkh.js} +2 -2
  25. package/dist/admin/assets/NetworkPage-DJpVHDkh.js.map +1 -0
  26. package/dist/admin/assets/{OverviewPage-9Bj0bs6r.js → OverviewPage-COSbych-.js} +2 -2
  27. package/dist/admin/assets/{OverviewPage-9Bj0bs6r.js.map → OverviewPage-COSbych-.js.map} +1 -1
  28. package/dist/admin/assets/{PushPage-Ifc68pyh.js → PushPage-DPIZOOyb.js} +2 -2
  29. package/dist/admin/assets/{PushPage-Ifc68pyh.js.map → PushPage-DPIZOOyb.js.map} +1 -1
  30. package/dist/admin/assets/{RunnerSettingsPanel-CBFh_1xp.js → RunnerSettingsPanel-DVkI577k.js} +3 -3
  31. package/dist/admin/assets/{RunnerSettingsPanel-CBFh_1xp.js.map → RunnerSettingsPanel-DVkI577k.js.map} +1 -1
  32. package/dist/admin/assets/SystemManagementPanel-CPqP2Jjj.js +6 -0
  33. package/dist/admin/assets/{SystemManagementPanel-DYnwEsvo.js.map → SystemManagementPanel-CPqP2Jjj.js.map} +1 -1
  34. package/dist/admin/assets/{UsersPage-DEImZamY.js → UsersPage-BArUB_g5.js} +2 -2
  35. package/dist/admin/assets/{UsersPage-DEImZamY.js.map → UsersPage-BArUB_g5.js.map} +1 -1
  36. package/dist/admin/assets/{VoicePage-I6C1byXU.js → VoicePage-Bt778ia-.js} +2 -2
  37. package/dist/admin/assets/{VoicePage-I6C1byXU.js.map → VoicePage-Bt778ia-.js.map} +1 -1
  38. package/dist/admin/assets/admin-BuMvp0yU.css +1 -0
  39. package/dist/admin/assets/admin-C-rH6P63.js +4 -0
  40. package/dist/admin/assets/admin-C-rH6P63.js.map +1 -0
  41. package/dist/assets/{AboutDialog-hLF4HDDI.js → AboutDialog-CuQClWtI.js} +2 -2
  42. package/dist/assets/{AboutDialog-hLF4HDDI.js.map → AboutDialog-CuQClWtI.js.map} +1 -1
  43. package/dist/assets/BotSettingsDialog-CJbJ-etj.css +1 -0
  44. package/dist/assets/BotSettingsDialog-DeAfjy5V.js +2 -0
  45. package/dist/assets/BotSettingsDialog-DeAfjy5V.js.map +1 -0
  46. package/dist/assets/{ConversationsView-3Gd2atFN.js → ConversationsView-BLo8VLvG.js} +49 -49
  47. package/dist/assets/ConversationsView-BLo8VLvG.js.map +1 -0
  48. package/dist/assets/ConversationsView-Y7Npknvu.css +1 -0
  49. package/dist/assets/TeamAvatar-C5dodifX.js +2 -0
  50. package/dist/assets/{TeamAvatar-CnkDPqYB.js.map → TeamAvatar-C5dodifX.js.map} +1 -1
  51. package/dist/assets/{index-BRikiCOi.css → index-CXNB3OJV.css} +1 -1
  52. package/dist/assets/index-q-PRe7O6.js +3 -0
  53. package/dist/assets/index-q-PRe7O6.js.map +1 -0
  54. package/dist/index.html +3 -3
  55. package/dist-server/server/admin/app.js +14 -46
  56. package/dist-server/server/admin/sessions.js +2 -79
  57. package/dist-server/server/app.js +3 -5
  58. package/dist-server/server/computerControls.js +1 -1
  59. package/dist-server/server/localAuth.js +20 -8
  60. package/dist-server/server/routes.js +4 -4
  61. package/dist-server/server/workspaceRoutes.js +2 -4
  62. package/package.json +1 -1
  63. package/release.json +3 -3
  64. package/dist/admin/assets/AccountPage-B3c7oAur.js +0 -2
  65. package/dist/admin/assets/AccountPage-B3c7oAur.js.map +0 -1
  66. package/dist/admin/assets/AccountPage-CtSyt5Ut.css +0 -1
  67. package/dist/admin/assets/DevicesPage-CygAF7MF.js +0 -2
  68. package/dist/admin/assets/DevicesPage-CygAF7MF.js.map +0 -1
  69. package/dist/admin/assets/NetworkPage-DXxW3wcm.js.map +0 -1
  70. package/dist/admin/assets/NetworkPage-D_7uKgV8.css +0 -1
  71. package/dist/admin/assets/SystemManagementPanel-DYnwEsvo.js +0 -6
  72. package/dist/admin/assets/admin-e1fQJC78.css +0 -1
  73. package/dist/admin/assets/admin-fxq6uao1.js +0 -5
  74. package/dist/admin/assets/admin-fxq6uao1.js.map +0 -1
  75. package/dist/assets/BotSettingsDialog-DSzLNVzl.css +0 -1
  76. package/dist/assets/BotSettingsDialog-Dp_NQ5Kv.js +0 -2
  77. package/dist/assets/BotSettingsDialog-Dp_NQ5Kv.js.map +0 -1
  78. package/dist/assets/ConversationsView-3Gd2atFN.js.map +0 -1
  79. package/dist/assets/ConversationsView-BAilBM3y.css +0 -1
  80. package/dist/assets/TeamAvatar-CnkDPqYB.js +0 -2
  81. package/dist/assets/index-CSZzZB6k.js +0 -3
  82. package/dist/assets/index-CSZzZB6k.js.map +0 -1
  83. package/dist-server/server/admin/totp.js +0 -60
@@ -1 +1 @@
1
- {"version":3,"file":"HermesModelSettingsPanel-DzV-tcHN.js","names":[],"sources":["../../../src/client/utils/modelCatalogEvents.ts","../../../src/client/components/app/ModelServicesPanel.vue","../../../src/client/components/app/ModelServicesPanel.vue","../../../src/client/api/hermesAdmin.ts","../../../src/client/components/app/HermesModelSettingsPanel.vue","../../../src/client/components/app/HermesModelSettingsPanel.vue"],"sourcesContent":["export const MODEL_CATALOG_CHANGED_EVENT = 'hermes-yaoyao:model-catalog-changed'\n\nexport function notifyModelCatalogChanged(profile: string): void {\n window.dispatchEvent(new CustomEvent(MODEL_CATALOG_CHANGED_EVENT, { detail: { profile } }))\n}\n\nexport function modelCatalogChangedProfile(event: Event): string {\n return event instanceof CustomEvent && typeof event.detail?.profile === 'string' ? event.detail.profile : ''\n}\n","<script setup lang=\"ts\">\nimport { computed, onMounted, ref, watch } from 'vue'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport {\n activateModelService,\n deleteModelService,\n listLegacyModelServices,\n listModelCatalog,\n listModelServices,\n saveLegacyModelService,\n saveModelService,\n saveProfileDefaultModel,\n validateModelService,\n type CustomModelService,\n type CustomModelServiceInput,\n type LegacyModelService,\n type ModelCatalogProvider,\n} from '@/api/agentManagement'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\nconst props = defineProps<{ profile: string }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\ninterface Draft {\n source: 'managed' | 'legacy'\n id: string\n name: string\n baseUrl: string\n apiKey: string\n apiKeyTouched: boolean\n clearApiKey: boolean\n model: string\n modelsText: string\n contextLength: string\n discoverModels: boolean\n makeDefault: boolean\n hasApiKey: boolean\n canEditApiKey: boolean\n}\n\nconst services = ref<CustomModelService[]>([])\nconst legacyServices = ref<LegacyModelService[]>([])\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst loading = ref(false)\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\nconst draft = ref<Draft | null>(null)\nconst draftBaseline = ref('')\nconst query = ref('')\nconst defaultModelKey = ref('')\nconst defaultModelBaseline = ref('')\n\nfunction modelKey(provider: string, model: string): string {\n return JSON.stringify([provider, model])\n}\n\nfunction modelSelection(key: string): { provider: string; model: string } | undefined {\n try {\n const value = JSON.parse(key)\n if (Array.isArray(value) && value.length === 2 && value.every(item => typeof item === 'string' && item.trim())) {\n return { provider: value[0], model: value[1] }\n }\n } catch { /* Invalid selections are rejected before saving. */ }\n return undefined\n}\n\nfunction emptyDraft(): Draft {\n return { source: 'managed', id: '', name: '', baseUrl: '', apiKey: '', apiKeyTouched: false, clearApiKey: false, model: '', modelsText: '', contextLength: '', discoverModels: true, makeDefault: false, hasApiKey: false, canEditApiKey: true }\n}\n\nfunction draftSnapshot(value: Draft): string {\n return JSON.stringify(value)\n}\n\nconst draftDirty = computed(() => Boolean(draft.value) && draftSnapshot(draft.value!) !== draftBaseline.value)\nconst defaultModelDirty = computed(() => Boolean(defaultModelKey.value) && defaultModelKey.value !== defaultModelBaseline.value)\nconst panelDirty = computed(() => draftDirty.value || defaultModelDirty.value)\n\nfunction replaceDraft(next: Draft): boolean {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return false\n draft.value = next\n draftBaseline.value = draftSnapshot(next)\n return true\n}\n\nfunction beginCreate() {\n replaceDraft(emptyDraft())\n}\n\nfunction closeEditor() {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return\n draft.value = null\n draftBaseline.value = ''\n}\n\nfunction edit(service: CustomModelService | LegacyModelService) {\n const next: Draft = {\n source: service.source === 'legacy' ? 'legacy' : 'managed',\n id: service.id,\n name: service.name,\n baseUrl: service.base_url,\n apiKey: '',\n apiKeyTouched: false,\n clearApiKey: false,\n model: service.model,\n modelsText: service.models.join('\\n'),\n contextLength: service.context_length ? String(service.context_length) : '',\n discoverModels: service.discover_models,\n makeDefault: service.is_current,\n hasApiKey: service.has_api_key,\n canEditApiKey: !('can_edit_api_key' in service) || service.can_edit_api_key,\n }\n if (!replaceDraft(next)) return\n error.value = ''\n notice.value = ''\n}\n\nasync function load(preserveDefaultDraft = false) {\n const selectedDefault = defaultModelKey.value\n const preserveSelection = preserveDefaultDraft && defaultModelDirty.value\n loading.value = true\n error.value = ''\n try {\n const [managed, legacy, available] = await Promise.all([\n listModelServices(props.profile),\n listLegacyModelServices(props.profile),\n listModelCatalog(props.profile),\n ])\n services.value = managed.endpoints || []\n legacyServices.value = legacy\n catalog.value = available\n const current = available.find(provider => provider.isCurrent && provider.currentModel)\n const key = current?.currentModel ? modelKey(current.slug, current.currentModel) : ''\n defaultModelBaseline.value = key\n defaultModelKey.value = preserveSelection ? selectedDefault : key\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务加载失败'\n } finally {\n loading.value = false\n }\n}\n\nasync function saveDefaultModel() {\n const selection = modelSelection(defaultModelKey.value)\n if (!selection) { error.value = '请选择默认 Provider 与模型'; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await saveProfileDefaultModel(props.profile, selection.provider, selection.model)\n await load()\n notifyModelCatalogChanged(props.profile)\n notice.value = `默认全局模型已更新为 ${selection.provider} / ${selection.model},仅影响新会话`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '默认全局模型保存失败'\n } finally {\n busy.value = false\n }\n}\n\nconst providerGroups = computed(() => {\n const editable = new Map<string, CustomModelService | LegacyModelService>()\n for (const service of [...services.value, ...legacyServices.value]) editable.set(service.id.toLocaleLowerCase(), service)\n const groups = catalog.value.map(provider => {\n const service = editable.get(provider.slug.toLocaleLowerCase())\n if (service) editable.delete(provider.slug.toLocaleLowerCase())\n return { provider, service, models: provider.models.length ? provider.models : service?.models || [] }\n })\n for (const service of editable.values()) {\n groups.push({\n provider: { slug: service.id, name: service.name, models: service.models, isCurrent: service.is_current },\n service,\n models: service.models,\n })\n }\n return groups\n})\n\nconst filteredProviderGroups = computed(() => {\n const needle = query.value.trim().toLocaleLowerCase()\n if (!needle) return providerGroups.value\n return providerGroups.value.filter(group => [\n group.provider.name,\n group.provider.slug,\n group.service?.base_url || '',\n ...group.models,\n ].some(value => value.toLocaleLowerCase().includes(needle)))\n})\n\nfunction inputFor(current: Draft): CustomModelServiceInput {\n const models = [...new Set(current.modelsText.split(/\\r?\\n|,/).map(value => value.trim()).filter(Boolean))]\n const contextLength = Number(current.contextLength)\n const input: CustomModelServiceInput = {\n ...(current.id ? { id: current.id } : {}),\n name: current.name.trim(),\n base_url: current.baseUrl.trim().replace(/\\/$/, ''),\n model: current.model.trim(),\n models: [...new Set([...models, current.model.trim()].filter(Boolean))],\n discover_models: current.discoverModels,\n make_default: current.makeDefault,\n ...(Number.isInteger(contextLength) && contextLength > 0 ? { context_length: contextLength } : {}),\n }\n if (current.clearApiKey) input.api_key = ''\n else if (current.apiKeyTouched && current.apiKey.trim()) input.api_key = current.apiKey.trim()\n return input\n}\n\nfunction validateDraft(): string {\n const value = draft.value\n if (!value?.name.trim()) return '请输入服务名称'\n if (!/^https?:\\/\\//i.test(value.baseUrl.trim())) return 'Base URL 必须以 http:// 或 https:// 开头'\n if (!value.model.trim()) return '请输入默认模型'\n if (value.contextLength && (!Number.isInteger(Number(value.contextLength)) || Number(value.contextLength) <= 0)) return '上下文长度必须是正整数'\n return ''\n}\n\nasync function probe() {\n const value = draft.value\n if (!value) return\n if (value.hasApiKey && !value.apiKeyTouched && !value.clearApiKey) {\n error.value = '服务端不会向浏览器回传已保存密钥;请重新输入 API Key 后再测试'\n return\n }\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n const result = await validateModelService(inputFor(value))\n if (!result.ok) throw new Error(result.message || '连接测试失败')\n const models = [...new Set(result.models.map(item => item.trim()).filter(Boolean))]\n if (models.length) {\n value.modelsText = models.join('\\n')\n if (!models.includes(value.model)) value.model = models[0]!\n }\n notice.value = models.length ? `连接正常,发现 ${models.length} 个模型` : '连接正常,未返回模型列表'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '连接测试失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function save() {\n const value = draft.value\n if (!value) return\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n if (value.source === 'legacy') await saveLegacyModelService(props.profile, value.id, inputFor(value))\n else await saveModelService(props.profile, inputFor(value))\n draft.value = null\n draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = 'Provider 与模型已保存并刷新目录'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务保存失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function activate(service: CustomModelService) {\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await activateModelService(props.profile, service.id)\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已设为当前机器人的默认模型服务`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '设为默认失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function remove(service: CustomModelService) {\n const suffix = service.is_current ? ',当前默认绑定也会被解除' : ''\n if (!window.confirm(`删除模型服务“${service.name}”及其模型${suffix}?`)) return\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await deleteModelService(props.profile, service.id)\n if (draft.value?.id === service.id) draft.value = null\n if (!draft.value) draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已删除`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '删除模型服务失败'\n } finally {\n busy.value = false\n }\n}\n\nwatch(() => props.profile, () => { draft.value = null; draftBaseline.value = ''; defaultModelKey.value = ''; defaultModelBaseline.value = ''; void load() })\nwatch(panelDirty, value => emit('dirty-change', value), { immediate: true })\nonMounted(() => { void load() })\n</script>\n\n<template>\n <section class=\"management-panel\" aria-label=\"模型服务\">\n <div class=\"panel-context\"><strong>Provider 与模型</strong><span>全部来自当前机器人:<b>{{ profile }}</b></span></div>\n <form class=\"default-model-card\" @submit.prevent=\"saveDefaultModel\">\n <label><strong>默认全局模型</strong><small>仅用于之后新建的会话,已有会话保持原模型。</small></label>\n <select v-model=\"defaultModelKey\" aria-label=\"默认全局模型\" :disabled=\"busy || loading\">\n <option value=\"\" disabled>请选择 Provider 与模型</option>\n <optgroup v-for=\"provider in catalog\" :key=\"provider.slug\" :label=\"provider.name\">\n <option v-for=\"model in provider.models\" :key=\"modelKey(provider.slug, model)\" :value=\"modelKey(provider.slug, model)\">{{ provider.slug }} / {{ model }}</option>\n </optgroup>\n </select>\n <button class=\"primary-button\" type=\"submit\" :disabled=\"busy || loading || !defaultModelDirty\">保存默认模型</button>\n </form>\n <div class=\"panel-heading\"><label class=\"provider-search\"><AppIcon name=\"search\" :size=\"18\" /><input v-model=\"query\" type=\"search\" placeholder=\"搜索 Provider 或模型\" aria-label=\"搜索 Provider 或模型\" /></label><button class=\"primary-button\" type=\"button\" :disabled=\"busy || loading\" @click=\"beginCreate\"><AppIcon name=\"plus\" :size=\"15\" />新增服务</button></div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-else-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n <p v-if=\"loading\" class=\"panel-empty\">正在读取 Provider 与模型…</p>\n <div v-else-if=\"filteredProviderGroups.length\" class=\"service-list\">\n <article v-for=\"group in filteredProviderGroups\" :key=\"group.provider.slug\" class=\"service-card\">\n <div class=\"service-main\"><div class=\"service-title\"><strong>{{ group.provider.name }}</strong><em v-if=\"group.provider.isCurrent || group.service?.is_current\">当前默认</em><em>{{ group.service ? '可编辑' : '只读' }}</em></div><small>{{ group.provider.slug }}<template v-if=\"group.service?.base_url\"> · {{ group.service.base_url }}</template></small><div class=\"model-chips\"><span v-for=\"model in group.models\" :key=\"model\" :class=\"{ current: group.provider.isCurrent && model === group.provider.currentModel }\">{{ model }}</span></div></div>\n <div v-if=\"group.service\" class=\"card-actions\"><button type=\"button\" :disabled=\"busy\" @click=\"edit(group.service)\">编辑</button><button v-if=\"group.service.source !== 'legacy' && !group.service.is_current\" type=\"button\" :disabled=\"busy\" @click=\"activate(group.service)\">设为默认</button><button v-if=\"group.service.source !== 'legacy'\" class=\"danger\" type=\"button\" :disabled=\"busy\" @click=\"remove(group.service)\">删除</button></div>\n </article>\n </div>\n <p v-else-if=\"!loading\" class=\"panel-empty\">{{ query.trim() ? '没有匹配的 Provider 或模型。' : '内置 Hermes 当前没有可用 Provider 或模型。' }}</p>\n <p v-if=\"!loading\" class=\"catalog-note\">完整目录来自内置 Hermes;仅支持的自定义服务可编辑。</p>\n\n <form v-if=\"draft\" class=\"service-editor\" :aria-busy=\"busy\" @submit.prevent=\"save\">\n <header><strong>{{ draft.id ? `编辑 ${draft.id}` : '新增模型服务' }}</strong><button type=\"button\" aria-label=\"关闭编辑\" :disabled=\"busy\" @click=\"closeEditor\"><AppIcon name=\"close\" :size=\"15\" /></button></header>\n <div class=\"form-grid\"><label>名称<input v-model=\"draft.name\" :disabled=\"busy || draft.source === 'legacy'\" maxlength=\"100\" autocomplete=\"off\" /></label><label>Base URL<input v-model=\"draft.baseUrl\" :disabled=\"busy\" placeholder=\"https://example.com/v1\" autocomplete=\"url\" /></label></div>\n <div class=\"form-grid\"><label>默认模型<input v-model=\"draft.model\" :disabled=\"busy\" placeholder=\"model-id\" autocomplete=\"off\" /></label><label>上下文长度(可选)<input v-model=\"draft.contextLength\" :disabled=\"busy\" inputmode=\"numeric\" placeholder=\"例如 131072\" /></label></div>\n <label v-if=\"draft.canEditApiKey\">API Key<input v-model=\"draft.apiKey\" type=\"password\" :disabled=\"busy\" :placeholder=\"draft.hasApiKey && !draft.clearApiKey ? '已保存;留空保持不变' : '可选'\" autocomplete=\"new-password\" @input=\"draft.apiKeyTouched = Boolean(draft.apiKey.trim()); draft.clearApiKey = false\" /></label>\n <p v-else class=\"editor-hint\">该 Provider 的密钥不由 Hermes 环境变量管理,因此这里只编辑 URL 和模型。</p>\n <button v-if=\"draft.canEditApiKey && draft.hasApiKey && !draft.clearApiKey\" class=\"text-button danger\" type=\"button\" :disabled=\"busy\" @click=\"draft.apiKey = ''; draft.apiKeyTouched = false; draft.clearApiKey = true\">清除已保存密钥</button><button v-else-if=\"draft.canEditApiKey && draft.clearApiKey\" class=\"text-button\" type=\"button\" :disabled=\"busy\" @click=\"draft.clearApiKey = false\">取消清除密钥</button>\n <label>模型列表(每行一个)<textarea v-model=\"draft.modelsText\" rows=\"5\" :disabled=\"busy\" placeholder=\"连接测试后自动填充,也可手动输入\" /></label>\n <label class=\"check-row\"><input v-model=\"draft.discoverModels\" type=\"checkbox\" :disabled=\"busy\" />允许 Hermes 自动发现模型</label><label v-if=\"draft.source === 'managed'\" class=\"check-row\"><input v-model=\"draft.makeDefault\" type=\"checkbox\" :disabled=\"busy\" />保存后设为当前机器人默认服务</label>\n <small class=\"editor-hint\">{{ draft.source === 'legacy' ? '保存后模型列表按当前内容更新;当前默认 Provider 会同步新的 URL 与默认模型。' : 'Hermes 会保留服务中已有的模型条目;删除整项服务会一并移除它们。' }}</small>\n <footer><button class=\"quiet-button\" type=\"button\" :disabled=\"busy\" @click=\"probe\">测试连接</button><button class=\"primary-button\" type=\"submit\" :disabled=\"busy\">{{ busy ? '处理中…' : '保存模型服务' }}</button></footer>\n </form>\n </section>\n</template>\n\n<style scoped>\n.management-panel{display:grid;gap:16px}.panel-context{display:flex;align-items:center;justify-content:space-between;gap:12px;color:var(--text-secondary)}.panel-context strong{font-size:14px}.panel-context span{color:var(--text-muted);font-size:12px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:40px}.provider-search{display:flex;min-width:0;min-height:44px;flex:1;align-items:center;gap:9px;padding:0 12px;border:1px solid var(--line);border-radius:9px;color:var(--text-muted);background:var(--surface-raised)}.provider-search:focus-within{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.provider-search input{min-width:0;flex:1;border:0;outline:0;background:transparent;color:var(--text-primary);font:14px var(--font-ui)}.primary-button,.quiet-button{display:inline-flex;min-height:40px;align-items:center;justify-content:center;gap:7px;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}.primary-button{background:var(--accent);color:var(--text-on-solid)}.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}button:disabled{cursor:wait;opacity:.5}.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}.panel-empty{color:var(--text-muted);background:var(--surface-soft)}.service-list{display:grid;border-top:1px solid var(--line)}.service-card{display:flex;align-items:center;gap:14px;padding:18px 12px;border:0;border-bottom:1px solid var(--line)}.service-main{display:grid;min-width:0;flex:1;gap:8px}.service-title{display:flex;flex-wrap:wrap;align-items:center;gap:7px}.service-card strong{font-size:16px}.service-card small{color:var(--text-muted);font:12px var(--font-code);overflow-wrap:anywhere}.service-card em{padding:3px 7px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text-muted);font:normal 11px var(--font-ui)}.model-chips{display:flex;flex-wrap:wrap;gap:8px}.model-chips span{max-width:100%;padding:6px 9px;overflow:hidden;border-radius:7px;background:var(--surface-soft);color:var(--text-secondary);font:11px var(--font-code);text-overflow:ellipsis;white-space:nowrap}.model-chips span.current{background:color-mix(in srgb,var(--accent) 9%,var(--surface-soft));color:var(--accent)}.card-actions{display:flex;flex:0 0 auto;gap:7px}.card-actions button,.service-editor header button,.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px}.card-actions button:hover,.text-button:hover{background:var(--surface-soft)}.card-actions .danger,.text-button.danger{color:var(--danger)}.catalog-note{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}.service-editor{display:grid;gap:14px;padding:18px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface-soft)}.service-editor header{display:flex;align-items:center;justify-content:space-between}.service-editor header strong{font-size:15px}.service-editor header button{display:grid;width:36px;height:36px;place-items:center}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.service-editor label{display:grid;gap:7px;color:var(--text-secondary);font-size:13px;font-weight:650}.service-editor input:not([type=checkbox]),.service-editor textarea{width:100%;box-sizing:border-box;padding:10px 11px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}.service-editor input:not([type=checkbox]){height:42px}.service-editor input:focus,.service-editor textarea:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.service-editor textarea{resize:vertical;font-family:var(--font-code);line-height:1.5}.check-row{display:flex!important;align-items:center;gap:8px!important;font-weight:500!important}.text-button{justify-self:start;padding-inline:0}.editor-hint{margin:0;color:var(--text-muted);font-size:11px}.service-editor footer{display:flex;justify-content:flex-end;gap:9px}@media(max-width:600px){.panel-heading{align-items:stretch;flex-direction:column;gap:10px}.panel-heading .primary-button{width:100%}.panel-context{align-items:flex-start;flex-direction:column}.service-card{align-items:flex-start;flex-direction:column}.card-actions{width:100%;justify-content:flex-end}.form-grid{grid-template-columns:1fr}}\n.default-model-card{display:grid;grid-template-columns:minmax(180px,1fr) minmax(240px,2fr) auto;align-items:end;gap:12px;padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--surface-soft)}\n.default-model-card label{display:grid;gap:4px;color:var(--text-secondary)}\n.default-model-card label small{color:var(--text-muted);font-size:11px;font-weight:400}\n.default-model-card select{min-width:0;height:40px;padding:0 10px;border:1px solid var(--line);border-radius:9px;background:var(--surface-raised);color:var(--text-primary);font:12px var(--font-code)}\n@media(max-width:600px){.default-model-card{grid-template-columns:1fr}.default-model-card .primary-button{width:100%}}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, onMounted, ref, watch } from 'vue'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport {\n activateModelService,\n deleteModelService,\n listLegacyModelServices,\n listModelCatalog,\n listModelServices,\n saveLegacyModelService,\n saveModelService,\n saveProfileDefaultModel,\n validateModelService,\n type CustomModelService,\n type CustomModelServiceInput,\n type LegacyModelService,\n type ModelCatalogProvider,\n} from '@/api/agentManagement'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\nconst props = defineProps<{ profile: string }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\ninterface Draft {\n source: 'managed' | 'legacy'\n id: string\n name: string\n baseUrl: string\n apiKey: string\n apiKeyTouched: boolean\n clearApiKey: boolean\n model: string\n modelsText: string\n contextLength: string\n discoverModels: boolean\n makeDefault: boolean\n hasApiKey: boolean\n canEditApiKey: boolean\n}\n\nconst services = ref<CustomModelService[]>([])\nconst legacyServices = ref<LegacyModelService[]>([])\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst loading = ref(false)\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\nconst draft = ref<Draft | null>(null)\nconst draftBaseline = ref('')\nconst query = ref('')\nconst defaultModelKey = ref('')\nconst defaultModelBaseline = ref('')\n\nfunction modelKey(provider: string, model: string): string {\n return JSON.stringify([provider, model])\n}\n\nfunction modelSelection(key: string): { provider: string; model: string } | undefined {\n try {\n const value = JSON.parse(key)\n if (Array.isArray(value) && value.length === 2 && value.every(item => typeof item === 'string' && item.trim())) {\n return { provider: value[0], model: value[1] }\n }\n } catch { /* Invalid selections are rejected before saving. */ }\n return undefined\n}\n\nfunction emptyDraft(): Draft {\n return { source: 'managed', id: '', name: '', baseUrl: '', apiKey: '', apiKeyTouched: false, clearApiKey: false, model: '', modelsText: '', contextLength: '', discoverModels: true, makeDefault: false, hasApiKey: false, canEditApiKey: true }\n}\n\nfunction draftSnapshot(value: Draft): string {\n return JSON.stringify(value)\n}\n\nconst draftDirty = computed(() => Boolean(draft.value) && draftSnapshot(draft.value!) !== draftBaseline.value)\nconst defaultModelDirty = computed(() => Boolean(defaultModelKey.value) && defaultModelKey.value !== defaultModelBaseline.value)\nconst panelDirty = computed(() => draftDirty.value || defaultModelDirty.value)\n\nfunction replaceDraft(next: Draft): boolean {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return false\n draft.value = next\n draftBaseline.value = draftSnapshot(next)\n return true\n}\n\nfunction beginCreate() {\n replaceDraft(emptyDraft())\n}\n\nfunction closeEditor() {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return\n draft.value = null\n draftBaseline.value = ''\n}\n\nfunction edit(service: CustomModelService | LegacyModelService) {\n const next: Draft = {\n source: service.source === 'legacy' ? 'legacy' : 'managed',\n id: service.id,\n name: service.name,\n baseUrl: service.base_url,\n apiKey: '',\n apiKeyTouched: false,\n clearApiKey: false,\n model: service.model,\n modelsText: service.models.join('\\n'),\n contextLength: service.context_length ? String(service.context_length) : '',\n discoverModels: service.discover_models,\n makeDefault: service.is_current,\n hasApiKey: service.has_api_key,\n canEditApiKey: !('can_edit_api_key' in service) || service.can_edit_api_key,\n }\n if (!replaceDraft(next)) return\n error.value = ''\n notice.value = ''\n}\n\nasync function load(preserveDefaultDraft = false) {\n const selectedDefault = defaultModelKey.value\n const preserveSelection = preserveDefaultDraft && defaultModelDirty.value\n loading.value = true\n error.value = ''\n try {\n const [managed, legacy, available] = await Promise.all([\n listModelServices(props.profile),\n listLegacyModelServices(props.profile),\n listModelCatalog(props.profile),\n ])\n services.value = managed.endpoints || []\n legacyServices.value = legacy\n catalog.value = available\n const current = available.find(provider => provider.isCurrent && provider.currentModel)\n const key = current?.currentModel ? modelKey(current.slug, current.currentModel) : ''\n defaultModelBaseline.value = key\n defaultModelKey.value = preserveSelection ? selectedDefault : key\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务加载失败'\n } finally {\n loading.value = false\n }\n}\n\nasync function saveDefaultModel() {\n const selection = modelSelection(defaultModelKey.value)\n if (!selection) { error.value = '请选择默认 Provider 与模型'; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await saveProfileDefaultModel(props.profile, selection.provider, selection.model)\n await load()\n notifyModelCatalogChanged(props.profile)\n notice.value = `默认全局模型已更新为 ${selection.provider} / ${selection.model},仅影响新会话`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '默认全局模型保存失败'\n } finally {\n busy.value = false\n }\n}\n\nconst providerGroups = computed(() => {\n const editable = new Map<string, CustomModelService | LegacyModelService>()\n for (const service of [...services.value, ...legacyServices.value]) editable.set(service.id.toLocaleLowerCase(), service)\n const groups = catalog.value.map(provider => {\n const service = editable.get(provider.slug.toLocaleLowerCase())\n if (service) editable.delete(provider.slug.toLocaleLowerCase())\n return { provider, service, models: provider.models.length ? provider.models : service?.models || [] }\n })\n for (const service of editable.values()) {\n groups.push({\n provider: { slug: service.id, name: service.name, models: service.models, isCurrent: service.is_current },\n service,\n models: service.models,\n })\n }\n return groups\n})\n\nconst filteredProviderGroups = computed(() => {\n const needle = query.value.trim().toLocaleLowerCase()\n if (!needle) return providerGroups.value\n return providerGroups.value.filter(group => [\n group.provider.name,\n group.provider.slug,\n group.service?.base_url || '',\n ...group.models,\n ].some(value => value.toLocaleLowerCase().includes(needle)))\n})\n\nfunction inputFor(current: Draft): CustomModelServiceInput {\n const models = [...new Set(current.modelsText.split(/\\r?\\n|,/).map(value => value.trim()).filter(Boolean))]\n const contextLength = Number(current.contextLength)\n const input: CustomModelServiceInput = {\n ...(current.id ? { id: current.id } : {}),\n name: current.name.trim(),\n base_url: current.baseUrl.trim().replace(/\\/$/, ''),\n model: current.model.trim(),\n models: [...new Set([...models, current.model.trim()].filter(Boolean))],\n discover_models: current.discoverModels,\n make_default: current.makeDefault,\n ...(Number.isInteger(contextLength) && contextLength > 0 ? { context_length: contextLength } : {}),\n }\n if (current.clearApiKey) input.api_key = ''\n else if (current.apiKeyTouched && current.apiKey.trim()) input.api_key = current.apiKey.trim()\n return input\n}\n\nfunction validateDraft(): string {\n const value = draft.value\n if (!value?.name.trim()) return '请输入服务名称'\n if (!/^https?:\\/\\//i.test(value.baseUrl.trim())) return 'Base URL 必须以 http:// 或 https:// 开头'\n if (!value.model.trim()) return '请输入默认模型'\n if (value.contextLength && (!Number.isInteger(Number(value.contextLength)) || Number(value.contextLength) <= 0)) return '上下文长度必须是正整数'\n return ''\n}\n\nasync function probe() {\n const value = draft.value\n if (!value) return\n if (value.hasApiKey && !value.apiKeyTouched && !value.clearApiKey) {\n error.value = '服务端不会向浏览器回传已保存密钥;请重新输入 API Key 后再测试'\n return\n }\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n const result = await validateModelService(inputFor(value))\n if (!result.ok) throw new Error(result.message || '连接测试失败')\n const models = [...new Set(result.models.map(item => item.trim()).filter(Boolean))]\n if (models.length) {\n value.modelsText = models.join('\\n')\n if (!models.includes(value.model)) value.model = models[0]!\n }\n notice.value = models.length ? `连接正常,发现 ${models.length} 个模型` : '连接正常,未返回模型列表'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '连接测试失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function save() {\n const value = draft.value\n if (!value) return\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n if (value.source === 'legacy') await saveLegacyModelService(props.profile, value.id, inputFor(value))\n else await saveModelService(props.profile, inputFor(value))\n draft.value = null\n draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = 'Provider 与模型已保存并刷新目录'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务保存失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function activate(service: CustomModelService) {\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await activateModelService(props.profile, service.id)\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已设为当前机器人的默认模型服务`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '设为默认失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function remove(service: CustomModelService) {\n const suffix = service.is_current ? ',当前默认绑定也会被解除' : ''\n if (!window.confirm(`删除模型服务“${service.name}”及其模型${suffix}?`)) return\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await deleteModelService(props.profile, service.id)\n if (draft.value?.id === service.id) draft.value = null\n if (!draft.value) draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已删除`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '删除模型服务失败'\n } finally {\n busy.value = false\n }\n}\n\nwatch(() => props.profile, () => { draft.value = null; draftBaseline.value = ''; defaultModelKey.value = ''; defaultModelBaseline.value = ''; void load() })\nwatch(panelDirty, value => emit('dirty-change', value), { immediate: true })\nonMounted(() => { void load() })\n</script>\n\n<template>\n <section class=\"management-panel\" aria-label=\"模型服务\">\n <div class=\"panel-context\"><strong>Provider 与模型</strong><span>全部来自当前机器人:<b>{{ profile }}</b></span></div>\n <form class=\"default-model-card\" @submit.prevent=\"saveDefaultModel\">\n <label><strong>默认全局模型</strong><small>仅用于之后新建的会话,已有会话保持原模型。</small></label>\n <select v-model=\"defaultModelKey\" aria-label=\"默认全局模型\" :disabled=\"busy || loading\">\n <option value=\"\" disabled>请选择 Provider 与模型</option>\n <optgroup v-for=\"provider in catalog\" :key=\"provider.slug\" :label=\"provider.name\">\n <option v-for=\"model in provider.models\" :key=\"modelKey(provider.slug, model)\" :value=\"modelKey(provider.slug, model)\">{{ provider.slug }} / {{ model }}</option>\n </optgroup>\n </select>\n <button class=\"primary-button\" type=\"submit\" :disabled=\"busy || loading || !defaultModelDirty\">保存默认模型</button>\n </form>\n <div class=\"panel-heading\"><label class=\"provider-search\"><AppIcon name=\"search\" :size=\"18\" /><input v-model=\"query\" type=\"search\" placeholder=\"搜索 Provider 或模型\" aria-label=\"搜索 Provider 或模型\" /></label><button class=\"primary-button\" type=\"button\" :disabled=\"busy || loading\" @click=\"beginCreate\"><AppIcon name=\"plus\" :size=\"15\" />新增服务</button></div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-else-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n <p v-if=\"loading\" class=\"panel-empty\">正在读取 Provider 与模型…</p>\n <div v-else-if=\"filteredProviderGroups.length\" class=\"service-list\">\n <article v-for=\"group in filteredProviderGroups\" :key=\"group.provider.slug\" class=\"service-card\">\n <div class=\"service-main\"><div class=\"service-title\"><strong>{{ group.provider.name }}</strong><em v-if=\"group.provider.isCurrent || group.service?.is_current\">当前默认</em><em>{{ group.service ? '可编辑' : '只读' }}</em></div><small>{{ group.provider.slug }}<template v-if=\"group.service?.base_url\"> · {{ group.service.base_url }}</template></small><div class=\"model-chips\"><span v-for=\"model in group.models\" :key=\"model\" :class=\"{ current: group.provider.isCurrent && model === group.provider.currentModel }\">{{ model }}</span></div></div>\n <div v-if=\"group.service\" class=\"card-actions\"><button type=\"button\" :disabled=\"busy\" @click=\"edit(group.service)\">编辑</button><button v-if=\"group.service.source !== 'legacy' && !group.service.is_current\" type=\"button\" :disabled=\"busy\" @click=\"activate(group.service)\">设为默认</button><button v-if=\"group.service.source !== 'legacy'\" class=\"danger\" type=\"button\" :disabled=\"busy\" @click=\"remove(group.service)\">删除</button></div>\n </article>\n </div>\n <p v-else-if=\"!loading\" class=\"panel-empty\">{{ query.trim() ? '没有匹配的 Provider 或模型。' : '内置 Hermes 当前没有可用 Provider 或模型。' }}</p>\n <p v-if=\"!loading\" class=\"catalog-note\">完整目录来自内置 Hermes;仅支持的自定义服务可编辑。</p>\n\n <form v-if=\"draft\" class=\"service-editor\" :aria-busy=\"busy\" @submit.prevent=\"save\">\n <header><strong>{{ draft.id ? `编辑 ${draft.id}` : '新增模型服务' }}</strong><button type=\"button\" aria-label=\"关闭编辑\" :disabled=\"busy\" @click=\"closeEditor\"><AppIcon name=\"close\" :size=\"15\" /></button></header>\n <div class=\"form-grid\"><label>名称<input v-model=\"draft.name\" :disabled=\"busy || draft.source === 'legacy'\" maxlength=\"100\" autocomplete=\"off\" /></label><label>Base URL<input v-model=\"draft.baseUrl\" :disabled=\"busy\" placeholder=\"https://example.com/v1\" autocomplete=\"url\" /></label></div>\n <div class=\"form-grid\"><label>默认模型<input v-model=\"draft.model\" :disabled=\"busy\" placeholder=\"model-id\" autocomplete=\"off\" /></label><label>上下文长度(可选)<input v-model=\"draft.contextLength\" :disabled=\"busy\" inputmode=\"numeric\" placeholder=\"例如 131072\" /></label></div>\n <label v-if=\"draft.canEditApiKey\">API Key<input v-model=\"draft.apiKey\" type=\"password\" :disabled=\"busy\" :placeholder=\"draft.hasApiKey && !draft.clearApiKey ? '已保存;留空保持不变' : '可选'\" autocomplete=\"new-password\" @input=\"draft.apiKeyTouched = Boolean(draft.apiKey.trim()); draft.clearApiKey = false\" /></label>\n <p v-else class=\"editor-hint\">该 Provider 的密钥不由 Hermes 环境变量管理,因此这里只编辑 URL 和模型。</p>\n <button v-if=\"draft.canEditApiKey && draft.hasApiKey && !draft.clearApiKey\" class=\"text-button danger\" type=\"button\" :disabled=\"busy\" @click=\"draft.apiKey = ''; draft.apiKeyTouched = false; draft.clearApiKey = true\">清除已保存密钥</button><button v-else-if=\"draft.canEditApiKey && draft.clearApiKey\" class=\"text-button\" type=\"button\" :disabled=\"busy\" @click=\"draft.clearApiKey = false\">取消清除密钥</button>\n <label>模型列表(每行一个)<textarea v-model=\"draft.modelsText\" rows=\"5\" :disabled=\"busy\" placeholder=\"连接测试后自动填充,也可手动输入\" /></label>\n <label class=\"check-row\"><input v-model=\"draft.discoverModels\" type=\"checkbox\" :disabled=\"busy\" />允许 Hermes 自动发现模型</label><label v-if=\"draft.source === 'managed'\" class=\"check-row\"><input v-model=\"draft.makeDefault\" type=\"checkbox\" :disabled=\"busy\" />保存后设为当前机器人默认服务</label>\n <small class=\"editor-hint\">{{ draft.source === 'legacy' ? '保存后模型列表按当前内容更新;当前默认 Provider 会同步新的 URL 与默认模型。' : 'Hermes 会保留服务中已有的模型条目;删除整项服务会一并移除它们。' }}</small>\n <footer><button class=\"quiet-button\" type=\"button\" :disabled=\"busy\" @click=\"probe\">测试连接</button><button class=\"primary-button\" type=\"submit\" :disabled=\"busy\">{{ busy ? '处理中…' : '保存模型服务' }}</button></footer>\n </form>\n </section>\n</template>\n\n<style scoped>\n.management-panel{display:grid;gap:16px}.panel-context{display:flex;align-items:center;justify-content:space-between;gap:12px;color:var(--text-secondary)}.panel-context strong{font-size:14px}.panel-context span{color:var(--text-muted);font-size:12px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:40px}.provider-search{display:flex;min-width:0;min-height:44px;flex:1;align-items:center;gap:9px;padding:0 12px;border:1px solid var(--line);border-radius:9px;color:var(--text-muted);background:var(--surface-raised)}.provider-search:focus-within{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.provider-search input{min-width:0;flex:1;border:0;outline:0;background:transparent;color:var(--text-primary);font:14px var(--font-ui)}.primary-button,.quiet-button{display:inline-flex;min-height:40px;align-items:center;justify-content:center;gap:7px;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}.primary-button{background:var(--accent);color:var(--text-on-solid)}.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}button:disabled{cursor:wait;opacity:.5}.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}.panel-empty{color:var(--text-muted);background:var(--surface-soft)}.service-list{display:grid;border-top:1px solid var(--line)}.service-card{display:flex;align-items:center;gap:14px;padding:18px 12px;border:0;border-bottom:1px solid var(--line)}.service-main{display:grid;min-width:0;flex:1;gap:8px}.service-title{display:flex;flex-wrap:wrap;align-items:center;gap:7px}.service-card strong{font-size:16px}.service-card small{color:var(--text-muted);font:12px var(--font-code);overflow-wrap:anywhere}.service-card em{padding:3px 7px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text-muted);font:normal 11px var(--font-ui)}.model-chips{display:flex;flex-wrap:wrap;gap:8px}.model-chips span{max-width:100%;padding:6px 9px;overflow:hidden;border-radius:7px;background:var(--surface-soft);color:var(--text-secondary);font:11px var(--font-code);text-overflow:ellipsis;white-space:nowrap}.model-chips span.current{background:color-mix(in srgb,var(--accent) 9%,var(--surface-soft));color:var(--accent)}.card-actions{display:flex;flex:0 0 auto;gap:7px}.card-actions button,.service-editor header button,.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px}.card-actions button:hover,.text-button:hover{background:var(--surface-soft)}.card-actions .danger,.text-button.danger{color:var(--danger)}.catalog-note{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}.service-editor{display:grid;gap:14px;padding:18px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface-soft)}.service-editor header{display:flex;align-items:center;justify-content:space-between}.service-editor header strong{font-size:15px}.service-editor header button{display:grid;width:36px;height:36px;place-items:center}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.service-editor label{display:grid;gap:7px;color:var(--text-secondary);font-size:13px;font-weight:650}.service-editor input:not([type=checkbox]),.service-editor textarea{width:100%;box-sizing:border-box;padding:10px 11px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}.service-editor input:not([type=checkbox]){height:42px}.service-editor input:focus,.service-editor textarea:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.service-editor textarea{resize:vertical;font-family:var(--font-code);line-height:1.5}.check-row{display:flex!important;align-items:center;gap:8px!important;font-weight:500!important}.text-button{justify-self:start;padding-inline:0}.editor-hint{margin:0;color:var(--text-muted);font-size:11px}.service-editor footer{display:flex;justify-content:flex-end;gap:9px}@media(max-width:600px){.panel-heading{align-items:stretch;flex-direction:column;gap:10px}.panel-heading .primary-button{width:100%}.panel-context{align-items:flex-start;flex-direction:column}.service-card{align-items:flex-start;flex-direction:column}.card-actions{width:100%;justify-content:flex-end}.form-grid{grid-template-columns:1fr}}\n.default-model-card{display:grid;grid-template-columns:minmax(180px,1fr) minmax(240px,2fr) auto;align-items:end;gap:12px;padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--surface-soft)}\n.default-model-card label{display:grid;gap:4px;color:var(--text-secondary)}\n.default-model-card label small{color:var(--text-muted);font-size:11px;font-weight:400}\n.default-model-card select{min-width:0;height:40px;padding:0 10px;border:1px solid var(--line);border-radius:9px;background:var(--surface-raised);color:var(--text-primary);font:12px var(--font-code)}\n@media(max-width:600px){.default-model-card{grid-template-columns:1fr}.default-model-card .primary-button{width:100%}}\n</style>\n","import { apiRequest } from './client'\n\nexport interface HermesCredential {\n key: string\n isSet: boolean\n preview: string | null\n description: string\n url: string | null\n category: string\n secret: boolean\n advanced: boolean\n provider: string\n providerLabel: string\n custom: boolean\n readonly: boolean\n}\n\nexport interface AuxiliaryTask {\n task: string\n provider: string\n model: string\n base_url?: string\n label?: string\n hint?: string\n}\n\nexport interface AuxiliaryModels {\n tasks: AuxiliaryTask[]\n main?: { provider?: string; model?: string }\n providers?: Array<{ id: string; label: string }>\n}\n\nexport interface OAuthProvider {\n id: string\n name: string\n flow: string\n web_flow?: string\n cli_command?: string | null\n docs_url?: string | null\n disconnectable?: boolean\n disconnect_hint?: string | null\n status?: { logged_in?: boolean; source_label?: string | null; token_preview?: string | null }\n}\n\nexport interface OAuthSession {\n session_id: string\n status?: string\n flow?: string\n user_code?: string\n verification_url?: string\n expires_in?: number\n error_message?: string | null\n}\n\nconst query = (profile: string) => profile && profile !== 'default' ? `?profile=${encodeURIComponent(profile)}` : ''\n\nexport async function listHermesCredentials(profile: string): Promise<HermesCredential[]> {\n return (await apiRequest<{ variables: HermesCredential[] }>(`/api/app/admin/hermes/credentials${query(profile)}`)).variables ?? []\n}\n\nexport async function saveHermesCredential(profile: string, key: string, value: string): Promise<void> {\n await apiRequest('/api/app/admin/hermes/credentials', { method: 'PUT', body: { profile, key, value } })\n}\n\nexport async function deleteHermesCredential(profile: string, key: string): Promise<void> {\n await apiRequest('/api/app/admin/hermes/credentials', { method: 'DELETE', body: { profile, key } })\n}\n\nexport async function getAuxiliaryModels(profile: string): Promise<AuxiliaryModels> {\n return apiRequest<AuxiliaryModels>(`/api/app/admin/hermes/auxiliary${query(profile)}`)\n}\n\nexport async function setAuxiliaryModel(profile: string, task: string, provider: string, model: string): Promise<AuxiliaryModels> {\n return apiRequest<AuxiliaryModels>('/api/app/admin/hermes/auxiliary', { method: 'PUT', body: { profile, task, provider, model } })\n}\n\nexport async function listOAuthProviders(profile: string): Promise<OAuthProvider[]> {\n return (await apiRequest<{ providers?: OAuthProvider[] }>(`/api/app/admin/hermes/oauth${query(profile)}`)).providers ?? []\n}\n\nconst oauthPath = (provider: string, action = '') => `/api/app/admin/hermes/oauth/${encodeURIComponent(provider)}${action ? `/${action}` : ''}`\n\nexport async function startOAuth(profile: string, provider: string): Promise<OAuthSession> {\n return apiRequest<OAuthSession>(oauthPath(provider, 'start'), { method: 'POST', body: { profile } })\n}\n\nexport async function pollOAuth(profile: string, provider: string, sessionId: string): Promise<OAuthSession> {\n return apiRequest<OAuthSession>(oauthPath(provider, 'poll'), { method: 'POST', body: { profile, sessionId } })\n}\n\nexport async function cancelOAuth(profile: string, provider: string, sessionId: string): Promise<void> {\n await apiRequest(oauthPath(provider, 'cancel'), { method: 'POST', body: { profile, sessionId } })\n}\n\nexport async function submitOAuthToken(profile: string, provider: string, token: string): Promise<void> {\n await apiRequest(oauthPath(provider, 'token'), { method: 'POST', body: { profile, token } })\n}\n\nexport async function disconnectOAuth(profile: string, provider: string): Promise<void> {\n await apiRequest(oauthPath(provider), { method: 'DELETE', body: { profile } })\n}\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport type { Profile } from '@shared/types'\nimport ModelServicesPanel from './ModelServicesPanel.vue'\nimport { listModelCatalog, type ModelCatalogProvider } from '@/api/agentManagement'\nimport {\n cancelOAuth, deleteHermesCredential, disconnectOAuth, getAuxiliaryModels, listHermesCredentials, listOAuthProviders,\n pollOAuth, saveHermesCredential, setAuxiliaryModel, startOAuth, submitOAuthToken,\n type AuxiliaryModels, type AuxiliaryTask, type HermesCredential, type OAuthProvider, type OAuthSession,\n} from '@/api/hermesAdmin'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\ntype Tab = 'models' | 'accounts' | 'keys' | 'auxiliary'\nconst props = defineProps<{ profiles?: Profile[] }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\nconst tabs: Array<{ id: Tab; label: string }> = [\n { id: 'models', label: '供应商与模型' },\n { id: 'accounts', label: '账号登录' },\n { id: 'keys', label: '密钥与变量' },\n { id: 'auxiliary', label: '辅助模型' },\n]\nconst tab = ref<Tab>('models')\nconst profile = ref('default')\nconst profileOptions = computed(() => {\n const names = new Set(['default', ...(props.profiles ?? []).map(item => item.name).filter(Boolean)])\n return [...names]\n})\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\n\nasync function run(work: () => Promise<void>, success = '') {\n if (busy.value) return\n busy.value = true; error.value = ''; notice.value = ''\n try { await work(); if (success) notice.value = success }\n catch (cause) { error.value = cause instanceof Error ? cause.message : '操作失败' }\n finally { busy.value = false }\n}\n\n// ── 密钥与变量 ───────────────────────────────────────────────────────────────\nconst credentials = ref<HermesCredential[]>([])\nconst keyQuery = ref('')\nconst showAdvanced = ref(false)\nconst editingKey = ref('')\nconst editingValue = ref('')\nconst customKey = ref('')\nconst customValue = ref('')\nconst CATEGORY_LABELS: Record<string, string> = { provider: '模型供应商', tool: '工具', skill: '技能', setting: '设置', custom: '自定义' }\nconst CATEGORY_ORDER = ['provider', 'tool', 'skill', 'setting', 'custom']\nconst credentialGroups = computed(() => {\n const query = keyQuery.value.trim().toLocaleLowerCase()\n const rows = credentials.value.filter(row => (showAdvanced.value || !row.advanced || row.isSet || query)\n && (!query || `${row.key} ${row.description} ${row.providerLabel}`.toLocaleLowerCase().includes(query)))\n const groups = new Map<string, HermesCredential[]>()\n for (const row of rows) groups.set(row.category, [...(groups.get(row.category) ?? []), row])\n return [...groups.entries()]\n .sort(([a], [b]) => (CATEGORY_ORDER.indexOf(a) + 1 || 99) - (CATEGORY_ORDER.indexOf(b) + 1 || 99))\n .map(([category, items]) => ({ category, label: CATEGORY_LABELS[category] ?? category, items: items.sort((a, b) => Number(b.isSet) - Number(a.isSet) || a.key.localeCompare(b.key)) }))\n})\nasync function loadCredentials() { credentials.value = await listHermesCredentials(profile.value) }\nfunction editCredential(row: HermesCredential) { editingKey.value = row.key; editingValue.value = '' }\nfunction saveCredential(key: string, value: string) {\n return run(async () => {\n await saveHermesCredential(profile.value, key, value)\n editingKey.value = ''; editingValue.value = ''; customKey.value = ''; customValue.value = ''\n await loadCredentials(); notifyModelCatalogChanged(profile.value)\n }, `已保存 ${key}`)\n}\nfunction clearCredential(row: HermesCredential) {\n if (!window.confirm(`清除 ${row.key}?`)) return\n return run(async () => { await deleteHermesCredential(profile.value, row.key); await loadCredentials(); notifyModelCatalogChanged(profile.value) }, `已清除 ${row.key}`)\n}\n\n// ── 账号登录 ────────────────────────────────────────────────────────────────\nconst oauthProviders = ref<OAuthProvider[]>([])\nconst login = ref<{ provider: string; session: OAuthSession } | null>(null)\nconst tokenProvider = ref('')\nconst tokenValue = ref('')\nlet pollTimer: ReturnType<typeof setTimeout> | undefined\nasync function loadOAuth() { oauthProviders.value = await listOAuthProviders(profile.value) }\nfunction loginFlow(provider: OAuthProvider): 'device' | 'token' | 'external' {\n const flow = provider.web_flow || provider.flow\n if (flow === 'paste_token') return 'token'\n if (flow === 'device_code' || flow === 'process') return 'device'\n return 'external'\n}\nfunction stopPolling() { if (pollTimer) clearTimeout(pollTimer); pollTimer = undefined }\nfunction schedulePoll() {\n stopPolling()\n pollTimer = setTimeout(async () => {\n const current = login.value\n if (!current) return\n try {\n const result = await pollOAuth(profile.value, current.provider, current.session.session_id)\n if (login.value?.session.session_id !== current.session.session_id) return\n login.value = { provider: current.provider, session: { ...current.session, ...result } }\n if (!result.status || result.status === 'pending') { schedulePoll(); return }\n if (result.status === 'approved') { notice.value = '登录成功'; login.value = null; await loadOAuth(); notifyModelCatalogChanged(profile.value) }\n else error.value = result.error_message || ({ denied: '登录被拒绝', expired: '登录已过期,请重新开始' } as Record<string, string>)[result.status] || '登录失败'\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '登录状态查询失败' }\n }, 3000)\n}\nfunction beginLogin(provider: OAuthProvider) {\n if (loginFlow(provider) === 'token') { tokenProvider.value = provider.id; tokenValue.value = ''; return }\n return run(async () => {\n const session = await startOAuth(profile.value, provider.id)\n login.value = { provider: provider.id, session }\n schedulePoll()\n })\n}\nfunction cancelLogin() {\n const current = login.value\n stopPolling(); login.value = null\n if (current) void cancelOAuth(profile.value, current.provider, current.session.session_id).catch(() => undefined)\n}\nfunction submitToken() {\n return run(async () => {\n await submitOAuthToken(profile.value, tokenProvider.value, tokenValue.value)\n tokenProvider.value = ''; tokenValue.value = ''\n await loadOAuth(); notifyModelCatalogChanged(profile.value)\n }, '凭据已保存')\n}\nfunction logout(provider: OAuthProvider) {\n if (!window.confirm(`退出 ${provider.name}?`)) return\n return run(async () => { await disconnectOAuth(profile.value, provider.id); await loadOAuth(); notifyModelCatalogChanged(profile.value) }, `已退出 ${provider.name}`)\n}\n\n// ── 辅助模型 ────────────────────────────────────────────────────────────────\nconst AUX_LABELS: Record<string, [string, string]> = {\n vision: ['视觉识别', '图片理解与截图分析'],\n compression: ['上下文压缩', '长对话接近上限时整理历史'],\n approval: ['审批判断', '自动审批模式下判断命令风险'],\n mcp: ['MCP 工具', 'MCP 工具的辅助调用'],\n title_generation: ['标题生成', '为会话生成标题'],\n review: ['复核', '回合结束后的记忆与技能复核'],\n voice_chat: ['语音对话', '语音模式下的快速回复'],\n triage_specifier: ['任务分诊', '拆解并细化任务说明'],\n kanban_decomposer: ['任务拆解', '把目标拆成可执行步骤'],\n profile_describer: ['Profile 描述', '生成 Profile 简介'],\n curator: ['技能整理', '后台整理与维护技能'],\n session_search: ['会话搜索', '总结检索到的历史会话'],\n web_extract: ['网页提取', '总结抓取的网页内容'],\n}\nconst auxiliary = ref<AuxiliaryTask[]>([])\nconst auxMain = ref('')\nconst auxDrafts = ref<Record<string, { provider: string; model: string }>>({})\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst allProviders = ref<Array<{ id: string; label: string }>>([])\n/** Providers with a loaded model list first, then the rest of Hermes's providers. */\nconst auxProviders = computed(() => {\n const seen = new Set(catalog.value.map(item => item.slug))\n return [...catalog.value.map(item => ({ id: item.slug, label: item.name })), ...allProviders.value.filter(item => !seen.has(item.id))]\n})\nfunction auxLabel(task: AuxiliaryTask): [string, string] { return AUX_LABELS[task.task] ?? [task.label || task.task, task.hint || ''] }\nfunction modelsFor(provider: string) { return catalog.value.find(item => item.slug === provider)?.models ?? [] }\nfunction applyAuxiliary(value: AuxiliaryModels) {\n auxiliary.value = value.tasks ?? []\n if (value.providers?.length) allProviders.value = value.providers\n auxMain.value = value.main?.model ? `${value.main.provider || ''} / ${value.main.model}` : '未设置'\n auxDrafts.value = Object.fromEntries(auxiliary.value.map(task => [task.task, { provider: task.provider || 'auto', model: task.model || '' }]))\n}\nasync function loadAuxiliary() {\n const [value, providers] = await Promise.all([getAuxiliaryModels(profile.value), listModelCatalog(profile.value).catch(() => [])])\n catalog.value = providers\n applyAuxiliary(value)\n}\nconst auxDirty = computed(() => auxiliary.value.some(task => {\n const draft = auxDrafts.value[task.task]\n return draft && (draft.provider !== (task.provider || 'auto') || (draft.provider !== 'auto' && draft.model !== (task.model || '')))\n}))\nfunction saveAuxiliary(task: AuxiliaryTask) {\n const draft = auxDrafts.value[task.task]\n if (!draft) return\n if (draft.provider !== 'auto' && !draft.model.trim()) { error.value = '请填写模型名称'; return }\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, task.task, draft.provider, draft.model.trim())), `已保存「${auxLabel(task)[0]}」`)\n}\nfunction resetAuxiliary() {\n if (!window.confirm('把全部辅助模型恢复为自动?')) return\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, '__reset__', 'auto', '')), '已全部恢复为自动')\n}\n\n// ── 加载 ───────────────────────────────────────────────────────────────────\nconst modelsDirty = ref(false)\nconst dirty = computed(() => (tab.value === 'models' && modelsDirty.value) || (tab.value === 'auxiliary' && auxDirty.value) || !!editingKey.value || !!customValue.value || !!tokenValue.value)\nwatch(dirty, value => emit('dirty-change', value), { immediate: true })\n\nasync function load() {\n stopPolling(); login.value = null; editingKey.value = ''; tokenProvider.value = ''\n error.value = ''; notice.value = ''\n if (tab.value === 'models') return\n busy.value = true\n try {\n if (tab.value === 'keys') await loadCredentials()\n else if (tab.value === 'accounts') await loadOAuth()\n else await loadAuxiliary()\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '读取失败' }\n finally { busy.value = false }\n}\nfunction selectTab(next: Tab) {\n if (next === tab.value) return\n if (dirty.value && !window.confirm('放弃当前未保存的更改?')) return\n modelsDirty.value = false\n tab.value = next\n}\nwatch([tab, profile], () => { void load() }, { immediate: true })\nonBeforeUnmount(stopPolling)\n</script>\n\n<template>\n <section class=\"hermes-settings\" aria-label=\"模型服务\">\n <p class=\"intro\">Hermes 已内置在夭夭服务中,这里替代原来的 Hermes Dashboard:配置模型供应商、账号登录、API Key 和辅助模型。Bot 使用所选 Profile 的这些配置。</p>\n <div class=\"toolbar\">\n <div class=\"tabs\" role=\"tablist\" aria-label=\"模型服务分类\">\n <button v-for=\"item in tabs\" :key=\"item.id\" type=\"button\" role=\"tab\" :aria-selected=\"tab === item.id\" :class=\"{ active: tab === item.id }\" @click=\"selectTab(item.id)\">{{ item.label }}</button>\n </div>\n <label v-if=\"profileOptions.length > 1\" class=\"profile-select\">Profile\n <select v-model=\"profile\" :disabled=\"busy || dirty\"><option v-for=\"name in profileOptions\" :key=\"name\" :value=\"name\">{{ name === 'default' ? 'default(系统)' : name }}</option></select>\n </label>\n </div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n\n <ModelServicesPanel v-if=\"tab === 'models'\" :key=\"profile\" :profile=\"profile\" @dirty-change=\"modelsDirty = $event\" />\n\n <template v-else-if=\"tab === 'accounts'\">\n <p class=\"hint\">适用于用订阅账号或设备码登录的供应商;普通 API Key 请在「密钥与变量」中填写。</p>\n <p v-if=\"busy && !oauthProviders.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"provider in oauthProviders\" :key=\"provider.id\">\n <div class=\"row-main\">\n <strong>{{ provider.name }}</strong>\n <small :class=\"{ ok: provider.status?.logged_in }\">{{ provider.status?.logged_in ? `已登录${provider.status.source_label ? ` · ${provider.status.source_label}` : ''}${provider.status.token_preview ? ` · …${provider.status.token_preview}` : ''}` : '未登录' }}</small>\n <small v-if=\"loginFlow(provider) === 'external' && !provider.status?.logged_in\" class=\"muted\">需要在服务器上运行 <code>{{ provider.cli_command }}</code> 登录。</small>\n </div>\n <div class=\"row-actions\">\n <a v-if=\"provider.docs_url\" :href=\"provider.docs_url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-button\">说明</a>\n <button v-if=\"provider.status?.logged_in && provider.disconnectable\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"logout(provider)\">退出</button>\n <button v-else-if=\"!provider.status?.logged_in && loginFlow(provider) !== 'external'\" type=\"button\" class=\"quiet-button\" :disabled=\"busy || !!login\" @click=\"beginLogin(provider)\">登录</button>\n </div>\n <div v-if=\"login?.provider === provider.id\" class=\"flow-box\">\n <p>在浏览器打开 <a :href=\"login.session.verification_url\" target=\"_blank\" rel=\"noopener noreferrer\">{{ login.session.verification_url }}</a>,输入代码:</p>\n <code class=\"user-code\">{{ login.session.user_code }}</code>\n <p class=\"muted\">完成后这里会自动更新。</p>\n <button type=\"button\" class=\"text-button\" @click=\"cancelLogin\">取消</button>\n </div>\n <form v-if=\"tokenProvider === provider.id\" class=\"flow-box\" @submit.prevent=\"submitToken\">\n <label>粘贴 API Key 或 setup-token<input v-model=\"tokenValue\" type=\"password\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"tokenProvider = ''; tokenValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !tokenValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </template>\n\n <template v-else-if=\"tab === 'keys'\">\n <div class=\"filter-row\">\n <input v-model=\"keyQuery\" type=\"search\" placeholder=\"搜索变量名、说明或供应商\" aria-label=\"搜索变量\">\n <label class=\"check\"><input v-model=\"showAdvanced\" type=\"checkbox\">显示高级项</label>\n </div>\n <p class=\"hint\">值只保存在服务器的 Hermes 数据目录,保存后不会再回传到浏览器。</p>\n <p v-if=\"busy && !credentials.length\" class=\"panel-empty\">正在读取…</p>\n <p v-else-if=\"!credentialGroups.length\" class=\"panel-empty\">没有匹配的变量。</p>\n <section v-for=\"group in credentialGroups\" :key=\"group.category\" class=\"group\">\n <h4>{{ group.label }}</h4>\n <ul class=\"rows\">\n <li v-for=\"row in group.items\" :key=\"row.key\">\n <div class=\"row-main\">\n <strong class=\"mono\">{{ row.key }}</strong>\n <small v-if=\"row.description || row.providerLabel\" class=\"muted\">{{ row.providerLabel && !row.description.includes(row.providerLabel) ? `${row.providerLabel} · ` : '' }}{{ row.description }}<a v-if=\"row.url\" :href=\"row.url\" target=\"_blank\" rel=\"noopener noreferrer\"> 获取</a></small>\n <small :class=\"{ ok: row.isSet }\">{{ row.isSet ? `已设置${row.preview ? ` · ${row.preview}` : ''}` : '未设置' }}</small>\n </div>\n <div class=\"row-actions\">\n <span v-if=\"row.readonly\" class=\"muted\">由运行环境管理</span>\n <template v-else>\n <button v-if=\"row.isSet\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"clearCredential(row)\">清除</button>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"editCredential(row)\">{{ row.isSet ? '修改' : '设置' }}</button>\n </template>\n </div>\n <form v-if=\"editingKey === row.key\" class=\"flow-box\" @submit.prevent=\"saveCredential(row.key, editingValue)\">\n <label>{{ row.key }}<input v-model=\"editingValue\" :type=\"row.secret ? 'password' : 'text'\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"editingKey = ''; editingValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !editingValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </section>\n <form class=\"flow-box custom\" @submit.prevent=\"saveCredential(customKey.trim(), customValue)\">\n <strong>添加自定义变量</strong>\n <div class=\"form-grid\">\n <label>变量名<input v-model=\"customKey\" pattern=\"[A-Za-z_][A-Za-z0-9_]*\" placeholder=\"MY_API_KEY\" autocomplete=\"off\" :disabled=\"busy\"></label>\n <label>值<input v-model=\"customValue\" type=\"password\" autocomplete=\"off\" :disabled=\"busy\"></label>\n </div>\n <div class=\"row-actions\"><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !customKey.trim() || !customValue.trim()\">添加</button></div>\n </form>\n </template>\n\n <template v-else>\n <p class=\"hint\">辅助模型负责压缩、视觉、标题等后台任务。选「自动」时使用主模型(当前:{{ auxMain }})或 Hermes 自动选择的可用模型。</p>\n <p v-if=\"busy && !auxiliary.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"task in auxiliary\" :key=\"task.task\" class=\"aux-row\">\n <div class=\"row-main\"><strong>{{ auxLabel(task)[0] }}</strong><small class=\"muted\">{{ auxLabel(task)[1] }}</small></div>\n <div v-if=\"auxDrafts[task.task]\" class=\"aux-fields\">\n <select v-model=\"auxDrafts[task.task].provider\" :aria-label=\"`${auxLabel(task)[0]} Provider`\" :disabled=\"busy\">\n <option value=\"auto\">自动</option>\n <option v-if=\"task.provider && task.provider !== 'auto' && !auxProviders.some(item => item.id === task.provider)\" :value=\"task.provider\">{{ task.provider }}</option>\n <option v-for=\"item in auxProviders\" :key=\"item.id\" :value=\"item.id\">{{ item.label }}</option>\n </select>\n <input v-if=\"auxDrafts[task.task].provider !== 'auto'\" v-model=\"auxDrafts[task.task].model\" :list=\"`aux-models-${task.task}`\" placeholder=\"模型名称\" :aria-label=\"`${auxLabel(task)[0]} 模型`\" :disabled=\"busy\">\n <datalist :id=\"`aux-models-${task.task}`\"><option v-for=\"model in modelsFor(auxDrafts[task.task].provider)\" :key=\"model\" :value=\"model\" /></datalist>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"saveAuxiliary(task)\">保存</button>\n </div>\n </li>\n </ul>\n <div v-if=\"auxiliary.length\" class=\"row-actions\"><button type=\"button\" class=\"text-button\" :disabled=\"busy\" @click=\"resetAuxiliary\">全部恢复为自动</button></div>\n </template>\n </section>\n</template>\n\n<style scoped>\n.hermes-settings{display:grid;gap:16px}\n.intro,.hint{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}\n.toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}\n.tabs{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft)}\n.tabs button{min-height:34px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:13px;font-weight:600}\n.tabs button.active{background:var(--surface-raised);color:var(--text-primary);box-shadow:0 1px 2px rgb(0 0 0 / 8%)}\n.profile-select{display:flex;align-items:center;gap:8px;color:var(--text-secondary);font-size:13px}\nselect,input:not([type=checkbox]){min-width:0;height:38px;box-sizing:border-box;padding:0 10px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}\nselect:focus,input:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}\n.rows{display:grid;margin:0;padding:0;list-style:none;border-top:1px solid var(--line)}\n.rows li{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;padding:14px 4px;border-bottom:1px solid var(--line)}\n.row-main{display:grid;min-width:0;flex:1;gap:4px}\n.row-main strong{font-size:14px}\n.row-main small{color:var(--text-secondary);font-size:12px;overflow-wrap:anywhere}\n.row-main small.ok{color:var(--success,#21845b)}\n.muted{color:var(--text-muted)!important;font-size:12px}\n.mono{font-family:var(--font-code);font-size:13px!important}\n.row-actions{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-end;gap:8px}\n.flow-box{display:grid;flex-basis:100%;gap:10px;padding:14px;border:1px solid var(--line-strong);border-radius:11px;background:var(--surface-soft)}\n.flow-box p{margin:0;font-size:13px}\n.flow-box label{display:grid;gap:6px;color:var(--text-secondary);font-size:13px;font-weight:600}\n.user-code{justify-self:start;padding:8px 14px;border-radius:8px;background:var(--surface-raised);font:600 20px var(--font-code);letter-spacing:.12em}\n.custom{flex-basis:auto}\n.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.group h4{margin:8px 0;color:var(--text-secondary);font-size:13px}\n.filter-row{display:flex;align-items:center;gap:12px}\n.filter-row input[type=search]{flex:1}\n.check{display:flex;align-items:center;gap:6px;color:var(--text-secondary);font-size:13px;white-space:nowrap}\n.aux-fields{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.aux-fields select{width:170px}.aux-fields input{width:220px}\n.primary-button,.quiet-button{display:inline-flex;min-height:36px;align-items:center;justify-content:center;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}\n.primary-button{background:var(--accent);color:var(--text-on-solid)}\n.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}\n.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px;text-decoration:none;display:inline-flex;align-items:center}\n.text-button:hover{background:var(--surface-soft)}.text-button.danger{color:var(--danger)}\nbutton:disabled{cursor:wait;opacity:.5}\n.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}\n.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}\n.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}\n.panel-empty{color:var(--text-muted);background:var(--surface-soft)}\ncode{font-family:var(--font-code)}\n@media(max-width:600px){.form-grid{grid-template-columns:1fr}.aux-fields,.aux-fields select,.aux-fields input{width:100%}.filter-row{flex-direction:column;align-items:stretch}.rows li{align-items:flex-start}.row-actions{width:100%}}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport type { Profile } from '@shared/types'\nimport ModelServicesPanel from './ModelServicesPanel.vue'\nimport { listModelCatalog, type ModelCatalogProvider } from '@/api/agentManagement'\nimport {\n cancelOAuth, deleteHermesCredential, disconnectOAuth, getAuxiliaryModels, listHermesCredentials, listOAuthProviders,\n pollOAuth, saveHermesCredential, setAuxiliaryModel, startOAuth, submitOAuthToken,\n type AuxiliaryModels, type AuxiliaryTask, type HermesCredential, type OAuthProvider, type OAuthSession,\n} from '@/api/hermesAdmin'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\ntype Tab = 'models' | 'accounts' | 'keys' | 'auxiliary'\nconst props = defineProps<{ profiles?: Profile[] }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\nconst tabs: Array<{ id: Tab; label: string }> = [\n { id: 'models', label: '供应商与模型' },\n { id: 'accounts', label: '账号登录' },\n { id: 'keys', label: '密钥与变量' },\n { id: 'auxiliary', label: '辅助模型' },\n]\nconst tab = ref<Tab>('models')\nconst profile = ref('default')\nconst profileOptions = computed(() => {\n const names = new Set(['default', ...(props.profiles ?? []).map(item => item.name).filter(Boolean)])\n return [...names]\n})\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\n\nasync function run(work: () => Promise<void>, success = '') {\n if (busy.value) return\n busy.value = true; error.value = ''; notice.value = ''\n try { await work(); if (success) notice.value = success }\n catch (cause) { error.value = cause instanceof Error ? cause.message : '操作失败' }\n finally { busy.value = false }\n}\n\n// ── 密钥与变量 ───────────────────────────────────────────────────────────────\nconst credentials = ref<HermesCredential[]>([])\nconst keyQuery = ref('')\nconst showAdvanced = ref(false)\nconst editingKey = ref('')\nconst editingValue = ref('')\nconst customKey = ref('')\nconst customValue = ref('')\nconst CATEGORY_LABELS: Record<string, string> = { provider: '模型供应商', tool: '工具', skill: '技能', setting: '设置', custom: '自定义' }\nconst CATEGORY_ORDER = ['provider', 'tool', 'skill', 'setting', 'custom']\nconst credentialGroups = computed(() => {\n const query = keyQuery.value.trim().toLocaleLowerCase()\n const rows = credentials.value.filter(row => (showAdvanced.value || !row.advanced || row.isSet || query)\n && (!query || `${row.key} ${row.description} ${row.providerLabel}`.toLocaleLowerCase().includes(query)))\n const groups = new Map<string, HermesCredential[]>()\n for (const row of rows) groups.set(row.category, [...(groups.get(row.category) ?? []), row])\n return [...groups.entries()]\n .sort(([a], [b]) => (CATEGORY_ORDER.indexOf(a) + 1 || 99) - (CATEGORY_ORDER.indexOf(b) + 1 || 99))\n .map(([category, items]) => ({ category, label: CATEGORY_LABELS[category] ?? category, items: items.sort((a, b) => Number(b.isSet) - Number(a.isSet) || a.key.localeCompare(b.key)) }))\n})\nasync function loadCredentials() { credentials.value = await listHermesCredentials(profile.value) }\nfunction editCredential(row: HermesCredential) { editingKey.value = row.key; editingValue.value = '' }\nfunction saveCredential(key: string, value: string) {\n return run(async () => {\n await saveHermesCredential(profile.value, key, value)\n editingKey.value = ''; editingValue.value = ''; customKey.value = ''; customValue.value = ''\n await loadCredentials(); notifyModelCatalogChanged(profile.value)\n }, `已保存 ${key}`)\n}\nfunction clearCredential(row: HermesCredential) {\n if (!window.confirm(`清除 ${row.key}?`)) return\n return run(async () => { await deleteHermesCredential(profile.value, row.key); await loadCredentials(); notifyModelCatalogChanged(profile.value) }, `已清除 ${row.key}`)\n}\n\n// ── 账号登录 ────────────────────────────────────────────────────────────────\nconst oauthProviders = ref<OAuthProvider[]>([])\nconst login = ref<{ provider: string; session: OAuthSession } | null>(null)\nconst tokenProvider = ref('')\nconst tokenValue = ref('')\nlet pollTimer: ReturnType<typeof setTimeout> | undefined\nasync function loadOAuth() { oauthProviders.value = await listOAuthProviders(profile.value) }\nfunction loginFlow(provider: OAuthProvider): 'device' | 'token' | 'external' {\n const flow = provider.web_flow || provider.flow\n if (flow === 'paste_token') return 'token'\n if (flow === 'device_code' || flow === 'process') return 'device'\n return 'external'\n}\nfunction stopPolling() { if (pollTimer) clearTimeout(pollTimer); pollTimer = undefined }\nfunction schedulePoll() {\n stopPolling()\n pollTimer = setTimeout(async () => {\n const current = login.value\n if (!current) return\n try {\n const result = await pollOAuth(profile.value, current.provider, current.session.session_id)\n if (login.value?.session.session_id !== current.session.session_id) return\n login.value = { provider: current.provider, session: { ...current.session, ...result } }\n if (!result.status || result.status === 'pending') { schedulePoll(); return }\n if (result.status === 'approved') { notice.value = '登录成功'; login.value = null; await loadOAuth(); notifyModelCatalogChanged(profile.value) }\n else error.value = result.error_message || ({ denied: '登录被拒绝', expired: '登录已过期,请重新开始' } as Record<string, string>)[result.status] || '登录失败'\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '登录状态查询失败' }\n }, 3000)\n}\nfunction beginLogin(provider: OAuthProvider) {\n if (loginFlow(provider) === 'token') { tokenProvider.value = provider.id; tokenValue.value = ''; return }\n return run(async () => {\n const session = await startOAuth(profile.value, provider.id)\n login.value = { provider: provider.id, session }\n schedulePoll()\n })\n}\nfunction cancelLogin() {\n const current = login.value\n stopPolling(); login.value = null\n if (current) void cancelOAuth(profile.value, current.provider, current.session.session_id).catch(() => undefined)\n}\nfunction submitToken() {\n return run(async () => {\n await submitOAuthToken(profile.value, tokenProvider.value, tokenValue.value)\n tokenProvider.value = ''; tokenValue.value = ''\n await loadOAuth(); notifyModelCatalogChanged(profile.value)\n }, '凭据已保存')\n}\nfunction logout(provider: OAuthProvider) {\n if (!window.confirm(`退出 ${provider.name}?`)) return\n return run(async () => { await disconnectOAuth(profile.value, provider.id); await loadOAuth(); notifyModelCatalogChanged(profile.value) }, `已退出 ${provider.name}`)\n}\n\n// ── 辅助模型 ────────────────────────────────────────────────────────────────\nconst AUX_LABELS: Record<string, [string, string]> = {\n vision: ['视觉识别', '图片理解与截图分析'],\n compression: ['上下文压缩', '长对话接近上限时整理历史'],\n approval: ['审批判断', '自动审批模式下判断命令风险'],\n mcp: ['MCP 工具', 'MCP 工具的辅助调用'],\n title_generation: ['标题生成', '为会话生成标题'],\n review: ['复核', '回合结束后的记忆与技能复核'],\n voice_chat: ['语音对话', '语音模式下的快速回复'],\n triage_specifier: ['任务分诊', '拆解并细化任务说明'],\n kanban_decomposer: ['任务拆解', '把目标拆成可执行步骤'],\n profile_describer: ['Profile 描述', '生成 Profile 简介'],\n curator: ['技能整理', '后台整理与维护技能'],\n session_search: ['会话搜索', '总结检索到的历史会话'],\n web_extract: ['网页提取', '总结抓取的网页内容'],\n}\nconst auxiliary = ref<AuxiliaryTask[]>([])\nconst auxMain = ref('')\nconst auxDrafts = ref<Record<string, { provider: string; model: string }>>({})\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst allProviders = ref<Array<{ id: string; label: string }>>([])\n/** Providers with a loaded model list first, then the rest of Hermes's providers. */\nconst auxProviders = computed(() => {\n const seen = new Set(catalog.value.map(item => item.slug))\n return [...catalog.value.map(item => ({ id: item.slug, label: item.name })), ...allProviders.value.filter(item => !seen.has(item.id))]\n})\nfunction auxLabel(task: AuxiliaryTask): [string, string] { return AUX_LABELS[task.task] ?? [task.label || task.task, task.hint || ''] }\nfunction modelsFor(provider: string) { return catalog.value.find(item => item.slug === provider)?.models ?? [] }\nfunction applyAuxiliary(value: AuxiliaryModels) {\n auxiliary.value = value.tasks ?? []\n if (value.providers?.length) allProviders.value = value.providers\n auxMain.value = value.main?.model ? `${value.main.provider || ''} / ${value.main.model}` : '未设置'\n auxDrafts.value = Object.fromEntries(auxiliary.value.map(task => [task.task, { provider: task.provider || 'auto', model: task.model || '' }]))\n}\nasync function loadAuxiliary() {\n const [value, providers] = await Promise.all([getAuxiliaryModels(profile.value), listModelCatalog(profile.value).catch(() => [])])\n catalog.value = providers\n applyAuxiliary(value)\n}\nconst auxDirty = computed(() => auxiliary.value.some(task => {\n const draft = auxDrafts.value[task.task]\n return draft && (draft.provider !== (task.provider || 'auto') || (draft.provider !== 'auto' && draft.model !== (task.model || '')))\n}))\nfunction saveAuxiliary(task: AuxiliaryTask) {\n const draft = auxDrafts.value[task.task]\n if (!draft) return\n if (draft.provider !== 'auto' && !draft.model.trim()) { error.value = '请填写模型名称'; return }\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, task.task, draft.provider, draft.model.trim())), `已保存「${auxLabel(task)[0]}」`)\n}\nfunction resetAuxiliary() {\n if (!window.confirm('把全部辅助模型恢复为自动?')) return\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, '__reset__', 'auto', '')), '已全部恢复为自动')\n}\n\n// ── 加载 ───────────────────────────────────────────────────────────────────\nconst modelsDirty = ref(false)\nconst dirty = computed(() => (tab.value === 'models' && modelsDirty.value) || (tab.value === 'auxiliary' && auxDirty.value) || !!editingKey.value || !!customValue.value || !!tokenValue.value)\nwatch(dirty, value => emit('dirty-change', value), { immediate: true })\n\nasync function load() {\n stopPolling(); login.value = null; editingKey.value = ''; tokenProvider.value = ''\n error.value = ''; notice.value = ''\n if (tab.value === 'models') return\n busy.value = true\n try {\n if (tab.value === 'keys') await loadCredentials()\n else if (tab.value === 'accounts') await loadOAuth()\n else await loadAuxiliary()\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '读取失败' }\n finally { busy.value = false }\n}\nfunction selectTab(next: Tab) {\n if (next === tab.value) return\n if (dirty.value && !window.confirm('放弃当前未保存的更改?')) return\n modelsDirty.value = false\n tab.value = next\n}\nwatch([tab, profile], () => { void load() }, { immediate: true })\nonBeforeUnmount(stopPolling)\n</script>\n\n<template>\n <section class=\"hermes-settings\" aria-label=\"模型服务\">\n <p class=\"intro\">Hermes 已内置在夭夭服务中,这里替代原来的 Hermes Dashboard:配置模型供应商、账号登录、API Key 和辅助模型。Bot 使用所选 Profile 的这些配置。</p>\n <div class=\"toolbar\">\n <div class=\"tabs\" role=\"tablist\" aria-label=\"模型服务分类\">\n <button v-for=\"item in tabs\" :key=\"item.id\" type=\"button\" role=\"tab\" :aria-selected=\"tab === item.id\" :class=\"{ active: tab === item.id }\" @click=\"selectTab(item.id)\">{{ item.label }}</button>\n </div>\n <label v-if=\"profileOptions.length > 1\" class=\"profile-select\">Profile\n <select v-model=\"profile\" :disabled=\"busy || dirty\"><option v-for=\"name in profileOptions\" :key=\"name\" :value=\"name\">{{ name === 'default' ? 'default(系统)' : name }}</option></select>\n </label>\n </div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n\n <ModelServicesPanel v-if=\"tab === 'models'\" :key=\"profile\" :profile=\"profile\" @dirty-change=\"modelsDirty = $event\" />\n\n <template v-else-if=\"tab === 'accounts'\">\n <p class=\"hint\">适用于用订阅账号或设备码登录的供应商;普通 API Key 请在「密钥与变量」中填写。</p>\n <p v-if=\"busy && !oauthProviders.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"provider in oauthProviders\" :key=\"provider.id\">\n <div class=\"row-main\">\n <strong>{{ provider.name }}</strong>\n <small :class=\"{ ok: provider.status?.logged_in }\">{{ provider.status?.logged_in ? `已登录${provider.status.source_label ? ` · ${provider.status.source_label}` : ''}${provider.status.token_preview ? ` · …${provider.status.token_preview}` : ''}` : '未登录' }}</small>\n <small v-if=\"loginFlow(provider) === 'external' && !provider.status?.logged_in\" class=\"muted\">需要在服务器上运行 <code>{{ provider.cli_command }}</code> 登录。</small>\n </div>\n <div class=\"row-actions\">\n <a v-if=\"provider.docs_url\" :href=\"provider.docs_url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-button\">说明</a>\n <button v-if=\"provider.status?.logged_in && provider.disconnectable\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"logout(provider)\">退出</button>\n <button v-else-if=\"!provider.status?.logged_in && loginFlow(provider) !== 'external'\" type=\"button\" class=\"quiet-button\" :disabled=\"busy || !!login\" @click=\"beginLogin(provider)\">登录</button>\n </div>\n <div v-if=\"login?.provider === provider.id\" class=\"flow-box\">\n <p>在浏览器打开 <a :href=\"login.session.verification_url\" target=\"_blank\" rel=\"noopener noreferrer\">{{ login.session.verification_url }}</a>,输入代码:</p>\n <code class=\"user-code\">{{ login.session.user_code }}</code>\n <p class=\"muted\">完成后这里会自动更新。</p>\n <button type=\"button\" class=\"text-button\" @click=\"cancelLogin\">取消</button>\n </div>\n <form v-if=\"tokenProvider === provider.id\" class=\"flow-box\" @submit.prevent=\"submitToken\">\n <label>粘贴 API Key 或 setup-token<input v-model=\"tokenValue\" type=\"password\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"tokenProvider = ''; tokenValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !tokenValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </template>\n\n <template v-else-if=\"tab === 'keys'\">\n <div class=\"filter-row\">\n <input v-model=\"keyQuery\" type=\"search\" placeholder=\"搜索变量名、说明或供应商\" aria-label=\"搜索变量\">\n <label class=\"check\"><input v-model=\"showAdvanced\" type=\"checkbox\">显示高级项</label>\n </div>\n <p class=\"hint\">值只保存在服务器的 Hermes 数据目录,保存后不会再回传到浏览器。</p>\n <p v-if=\"busy && !credentials.length\" class=\"panel-empty\">正在读取…</p>\n <p v-else-if=\"!credentialGroups.length\" class=\"panel-empty\">没有匹配的变量。</p>\n <section v-for=\"group in credentialGroups\" :key=\"group.category\" class=\"group\">\n <h4>{{ group.label }}</h4>\n <ul class=\"rows\">\n <li v-for=\"row in group.items\" :key=\"row.key\">\n <div class=\"row-main\">\n <strong class=\"mono\">{{ row.key }}</strong>\n <small v-if=\"row.description || row.providerLabel\" class=\"muted\">{{ row.providerLabel && !row.description.includes(row.providerLabel) ? `${row.providerLabel} · ` : '' }}{{ row.description }}<a v-if=\"row.url\" :href=\"row.url\" target=\"_blank\" rel=\"noopener noreferrer\"> 获取</a></small>\n <small :class=\"{ ok: row.isSet }\">{{ row.isSet ? `已设置${row.preview ? ` · ${row.preview}` : ''}` : '未设置' }}</small>\n </div>\n <div class=\"row-actions\">\n <span v-if=\"row.readonly\" class=\"muted\">由运行环境管理</span>\n <template v-else>\n <button v-if=\"row.isSet\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"clearCredential(row)\">清除</button>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"editCredential(row)\">{{ row.isSet ? '修改' : '设置' }}</button>\n </template>\n </div>\n <form v-if=\"editingKey === row.key\" class=\"flow-box\" @submit.prevent=\"saveCredential(row.key, editingValue)\">\n <label>{{ row.key }}<input v-model=\"editingValue\" :type=\"row.secret ? 'password' : 'text'\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"editingKey = ''; editingValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !editingValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </section>\n <form class=\"flow-box custom\" @submit.prevent=\"saveCredential(customKey.trim(), customValue)\">\n <strong>添加自定义变量</strong>\n <div class=\"form-grid\">\n <label>变量名<input v-model=\"customKey\" pattern=\"[A-Za-z_][A-Za-z0-9_]*\" placeholder=\"MY_API_KEY\" autocomplete=\"off\" :disabled=\"busy\"></label>\n <label>值<input v-model=\"customValue\" type=\"password\" autocomplete=\"off\" :disabled=\"busy\"></label>\n </div>\n <div class=\"row-actions\"><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !customKey.trim() || !customValue.trim()\">添加</button></div>\n </form>\n </template>\n\n <template v-else>\n <p class=\"hint\">辅助模型负责压缩、视觉、标题等后台任务。选「自动」时使用主模型(当前:{{ auxMain }})或 Hermes 自动选择的可用模型。</p>\n <p v-if=\"busy && !auxiliary.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"task in auxiliary\" :key=\"task.task\" class=\"aux-row\">\n <div class=\"row-main\"><strong>{{ auxLabel(task)[0] }}</strong><small class=\"muted\">{{ auxLabel(task)[1] }}</small></div>\n <div v-if=\"auxDrafts[task.task]\" class=\"aux-fields\">\n <select v-model=\"auxDrafts[task.task].provider\" :aria-label=\"`${auxLabel(task)[0]} Provider`\" :disabled=\"busy\">\n <option value=\"auto\">自动</option>\n <option v-if=\"task.provider && task.provider !== 'auto' && !auxProviders.some(item => item.id === task.provider)\" :value=\"task.provider\">{{ task.provider }}</option>\n <option v-for=\"item in auxProviders\" :key=\"item.id\" :value=\"item.id\">{{ item.label }}</option>\n </select>\n <input v-if=\"auxDrafts[task.task].provider !== 'auto'\" v-model=\"auxDrafts[task.task].model\" :list=\"`aux-models-${task.task}`\" placeholder=\"模型名称\" :aria-label=\"`${auxLabel(task)[0]} 模型`\" :disabled=\"busy\">\n <datalist :id=\"`aux-models-${task.task}`\"><option v-for=\"model in modelsFor(auxDrafts[task.task].provider)\" :key=\"model\" :value=\"model\" /></datalist>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"saveAuxiliary(task)\">保存</button>\n </div>\n </li>\n </ul>\n <div v-if=\"auxiliary.length\" class=\"row-actions\"><button type=\"button\" class=\"text-button\" :disabled=\"busy\" @click=\"resetAuxiliary\">全部恢复为自动</button></div>\n </template>\n </section>\n</template>\n\n<style scoped>\n.hermes-settings{display:grid;gap:16px}\n.intro,.hint{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}\n.toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}\n.tabs{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft)}\n.tabs button{min-height:34px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:13px;font-weight:600}\n.tabs button.active{background:var(--surface-raised);color:var(--text-primary);box-shadow:0 1px 2px rgb(0 0 0 / 8%)}\n.profile-select{display:flex;align-items:center;gap:8px;color:var(--text-secondary);font-size:13px}\nselect,input:not([type=checkbox]){min-width:0;height:38px;box-sizing:border-box;padding:0 10px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}\nselect:focus,input:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}\n.rows{display:grid;margin:0;padding:0;list-style:none;border-top:1px solid var(--line)}\n.rows li{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;padding:14px 4px;border-bottom:1px solid var(--line)}\n.row-main{display:grid;min-width:0;flex:1;gap:4px}\n.row-main strong{font-size:14px}\n.row-main small{color:var(--text-secondary);font-size:12px;overflow-wrap:anywhere}\n.row-main small.ok{color:var(--success,#21845b)}\n.muted{color:var(--text-muted)!important;font-size:12px}\n.mono{font-family:var(--font-code);font-size:13px!important}\n.row-actions{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-end;gap:8px}\n.flow-box{display:grid;flex-basis:100%;gap:10px;padding:14px;border:1px solid var(--line-strong);border-radius:11px;background:var(--surface-soft)}\n.flow-box p{margin:0;font-size:13px}\n.flow-box label{display:grid;gap:6px;color:var(--text-secondary);font-size:13px;font-weight:600}\n.user-code{justify-self:start;padding:8px 14px;border-radius:8px;background:var(--surface-raised);font:600 20px var(--font-code);letter-spacing:.12em}\n.custom{flex-basis:auto}\n.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.group h4{margin:8px 0;color:var(--text-secondary);font-size:13px}\n.filter-row{display:flex;align-items:center;gap:12px}\n.filter-row input[type=search]{flex:1}\n.check{display:flex;align-items:center;gap:6px;color:var(--text-secondary);font-size:13px;white-space:nowrap}\n.aux-fields{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.aux-fields select{width:170px}.aux-fields input{width:220px}\n.primary-button,.quiet-button{display:inline-flex;min-height:36px;align-items:center;justify-content:center;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}\n.primary-button{background:var(--accent);color:var(--text-on-solid)}\n.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}\n.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px;text-decoration:none;display:inline-flex;align-items:center}\n.text-button:hover{background:var(--surface-soft)}.text-button.danger{color:var(--danger)}\nbutton:disabled{cursor:wait;opacity:.5}\n.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}\n.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}\n.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}\n.panel-empty{color:var(--text-muted);background:var(--surface-soft)}\ncode{font-family:var(--font-code)}\n@media(max-width:600px){.form-grid{grid-template-columns:1fr}.aux-fields,.aux-fields select,.aux-fields input{width:100%}.filter-row{flex-direction:column;align-items:stretch}.rows li{align-items:flex-start}.row-actions{width:100%}}\n</style>\n"],"mappings":"oaAAA,IAAa,EAA8B,sCAE3C,SAAgB,EAA0B,EAAuB,CAC/D,OAAO,cAAc,IAAI,YAAY,EAA6B,CAAE,OAAQ,CAAE,SAAQ,CAAE,CAAC,CAAC,CAC5F,wlCCgBA,IAAM,EAAQ,EACR,GAAO,EAmBP,GAAW,EAA0B,CAAC,CAAC,EACvC,GAAiB,EAA0B,CAAC,CAAC,EAC7C,EAAU,EAA4B,CAAC,CAAC,EACxC,EAAU,EAAI,EAAK,EACnB,EAAO,EAAI,EAAK,EAChB,EAAQ,EAAI,EAAE,EACd,EAAS,EAAI,EAAE,EACf,EAAQ,EAAkB,IAAI,EAC9B,EAAgB,EAAI,EAAE,EACtB,EAAQ,EAAI,EAAE,EACd,EAAkB,EAAI,EAAE,EACxB,EAAuB,EAAI,EAAE,EAEnC,SAAS,EAAS,EAAkB,EAAuB,CACzD,OAAO,KAAK,UAAU,CAAC,EAAU,CAAK,CAAC,CACzC,CAEA,SAAS,GAAe,EAA8D,CACpF,GAAI,CACF,IAAM,EAAQ,KAAK,MAAM,CAAG,EAC5B,GAAI,MAAM,QAAQ,CAAK,GAAK,EAAM,SAAW,GAAK,EAAM,MAAM,GAAQ,OAAO,GAAS,UAAY,EAAK,KAAK,CAAC,EAC3G,MAAO,CAAE,SAAU,EAAM,GAAI,MAAO,EAAM,EAAG,CAEjD,MAAQ,CAAuD,CAEjE,CAEA,SAAS,IAAoB,CAC3B,MAAO,CAAE,OAAQ,UAAW,GAAI,GAAI,KAAM,GAAI,QAAS,GAAI,OAAQ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AAA,CAAA,GAAA,EAAA,GAAA,EAAA"}
1
+ {"version":3,"file":"HermesModelSettingsPanel-DbvAMOaL.js","names":[],"sources":["../../../src/client/utils/modelCatalogEvents.ts","../../../src/client/components/app/ModelServicesPanel.vue","../../../src/client/components/app/ModelServicesPanel.vue","../../../src/client/api/hermesAdmin.ts","../../../src/client/components/app/HermesModelSettingsPanel.vue","../../../src/client/components/app/HermesModelSettingsPanel.vue"],"sourcesContent":["export const MODEL_CATALOG_CHANGED_EVENT = 'hermes-yaoyao:model-catalog-changed'\n\nexport function notifyModelCatalogChanged(profile: string): void {\n window.dispatchEvent(new CustomEvent(MODEL_CATALOG_CHANGED_EVENT, { detail: { profile } }))\n}\n\nexport function modelCatalogChangedProfile(event: Event): string {\n return event instanceof CustomEvent && typeof event.detail?.profile === 'string' ? event.detail.profile : ''\n}\n","<script setup lang=\"ts\">\nimport { computed, onMounted, ref, watch } from 'vue'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport {\n activateModelService,\n deleteModelService,\n listLegacyModelServices,\n listModelCatalog,\n listModelServices,\n saveLegacyModelService,\n saveModelService,\n saveProfileDefaultModel,\n validateModelService,\n type CustomModelService,\n type CustomModelServiceInput,\n type LegacyModelService,\n type ModelCatalogProvider,\n} from '@/api/agentManagement'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\nconst props = defineProps<{ profile: string }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\ninterface Draft {\n source: 'managed' | 'legacy'\n id: string\n name: string\n baseUrl: string\n apiKey: string\n apiKeyTouched: boolean\n clearApiKey: boolean\n model: string\n modelsText: string\n contextLength: string\n discoverModels: boolean\n makeDefault: boolean\n hasApiKey: boolean\n canEditApiKey: boolean\n}\n\nconst services = ref<CustomModelService[]>([])\nconst legacyServices = ref<LegacyModelService[]>([])\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst loading = ref(false)\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\nconst draft = ref<Draft | null>(null)\nconst draftBaseline = ref('')\nconst query = ref('')\nconst defaultModelKey = ref('')\nconst defaultModelBaseline = ref('')\n\nfunction modelKey(provider: string, model: string): string {\n return JSON.stringify([provider, model])\n}\n\nfunction modelSelection(key: string): { provider: string; model: string } | undefined {\n try {\n const value = JSON.parse(key)\n if (Array.isArray(value) && value.length === 2 && value.every(item => typeof item === 'string' && item.trim())) {\n return { provider: value[0], model: value[1] }\n }\n } catch { /* Invalid selections are rejected before saving. */ }\n return undefined\n}\n\nfunction emptyDraft(): Draft {\n return { source: 'managed', id: '', name: '', baseUrl: '', apiKey: '', apiKeyTouched: false, clearApiKey: false, model: '', modelsText: '', contextLength: '', discoverModels: true, makeDefault: false, hasApiKey: false, canEditApiKey: true }\n}\n\nfunction draftSnapshot(value: Draft): string {\n return JSON.stringify(value)\n}\n\nconst draftDirty = computed(() => Boolean(draft.value) && draftSnapshot(draft.value!) !== draftBaseline.value)\nconst defaultModelDirty = computed(() => Boolean(defaultModelKey.value) && defaultModelKey.value !== defaultModelBaseline.value)\nconst panelDirty = computed(() => draftDirty.value || defaultModelDirty.value)\n\nfunction replaceDraft(next: Draft): boolean {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return false\n draft.value = next\n draftBaseline.value = draftSnapshot(next)\n return true\n}\n\nfunction beginCreate() {\n replaceDraft(emptyDraft())\n}\n\nfunction closeEditor() {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return\n draft.value = null\n draftBaseline.value = ''\n}\n\nfunction edit(service: CustomModelService | LegacyModelService) {\n const next: Draft = {\n source: service.source === 'legacy' ? 'legacy' : 'managed',\n id: service.id,\n name: service.name,\n baseUrl: service.base_url,\n apiKey: '',\n apiKeyTouched: false,\n clearApiKey: false,\n model: service.model,\n modelsText: service.models.join('\\n'),\n contextLength: service.context_length ? String(service.context_length) : '',\n discoverModels: service.discover_models,\n makeDefault: service.is_current,\n hasApiKey: service.has_api_key,\n canEditApiKey: !('can_edit_api_key' in service) || service.can_edit_api_key,\n }\n if (!replaceDraft(next)) return\n error.value = ''\n notice.value = ''\n}\n\nasync function load(preserveDefaultDraft = false) {\n const selectedDefault = defaultModelKey.value\n const preserveSelection = preserveDefaultDraft && defaultModelDirty.value\n loading.value = true\n error.value = ''\n try {\n const [managed, legacy, available] = await Promise.all([\n listModelServices(props.profile),\n listLegacyModelServices(props.profile),\n listModelCatalog(props.profile),\n ])\n services.value = managed.endpoints || []\n legacyServices.value = legacy\n catalog.value = available\n const current = available.find(provider => provider.isCurrent && provider.currentModel)\n const key = current?.currentModel ? modelKey(current.slug, current.currentModel) : ''\n defaultModelBaseline.value = key\n defaultModelKey.value = preserveSelection ? selectedDefault : key\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务加载失败'\n } finally {\n loading.value = false\n }\n}\n\nasync function saveDefaultModel() {\n const selection = modelSelection(defaultModelKey.value)\n if (!selection) { error.value = '请选择默认 Provider 与模型'; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await saveProfileDefaultModel(props.profile, selection.provider, selection.model)\n await load()\n notifyModelCatalogChanged(props.profile)\n notice.value = `默认全局模型已更新为 ${selection.provider} / ${selection.model},仅影响新会话`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '默认全局模型保存失败'\n } finally {\n busy.value = false\n }\n}\n\nconst providerGroups = computed(() => {\n const editable = new Map<string, CustomModelService | LegacyModelService>()\n for (const service of [...services.value, ...legacyServices.value]) editable.set(service.id.toLocaleLowerCase(), service)\n const groups = catalog.value.map(provider => {\n const service = editable.get(provider.slug.toLocaleLowerCase())\n if (service) editable.delete(provider.slug.toLocaleLowerCase())\n return { provider, service, models: provider.models.length ? provider.models : service?.models || [] }\n })\n for (const service of editable.values()) {\n groups.push({\n provider: { slug: service.id, name: service.name, models: service.models, isCurrent: service.is_current },\n service,\n models: service.models,\n })\n }\n return groups\n})\n\nconst filteredProviderGroups = computed(() => {\n const needle = query.value.trim().toLocaleLowerCase()\n if (!needle) return providerGroups.value\n return providerGroups.value.filter(group => [\n group.provider.name,\n group.provider.slug,\n group.service?.base_url || '',\n ...group.models,\n ].some(value => value.toLocaleLowerCase().includes(needle)))\n})\n\nfunction inputFor(current: Draft): CustomModelServiceInput {\n const models = [...new Set(current.modelsText.split(/\\r?\\n|,/).map(value => value.trim()).filter(Boolean))]\n const contextLength = Number(current.contextLength)\n const input: CustomModelServiceInput = {\n ...(current.id ? { id: current.id } : {}),\n name: current.name.trim(),\n base_url: current.baseUrl.trim().replace(/\\/$/, ''),\n model: current.model.trim(),\n models: [...new Set([...models, current.model.trim()].filter(Boolean))],\n discover_models: current.discoverModels,\n make_default: current.makeDefault,\n ...(Number.isInteger(contextLength) && contextLength > 0 ? { context_length: contextLength } : {}),\n }\n if (current.clearApiKey) input.api_key = ''\n else if (current.apiKeyTouched && current.apiKey.trim()) input.api_key = current.apiKey.trim()\n return input\n}\n\nfunction validateDraft(): string {\n const value = draft.value\n if (!value?.name.trim()) return '请输入服务名称'\n if (!/^https?:\\/\\//i.test(value.baseUrl.trim())) return 'Base URL 必须以 http:// 或 https:// 开头'\n if (!value.model.trim()) return '请输入默认模型'\n if (value.contextLength && (!Number.isInteger(Number(value.contextLength)) || Number(value.contextLength) <= 0)) return '上下文长度必须是正整数'\n return ''\n}\n\nasync function probe() {\n const value = draft.value\n if (!value) return\n if (value.hasApiKey && !value.apiKeyTouched && !value.clearApiKey) {\n error.value = '服务端不会向浏览器回传已保存密钥;请重新输入 API Key 后再测试'\n return\n }\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n const result = await validateModelService(inputFor(value))\n if (!result.ok) throw new Error(result.message || '连接测试失败')\n const models = [...new Set(result.models.map(item => item.trim()).filter(Boolean))]\n if (models.length) {\n value.modelsText = models.join('\\n')\n if (!models.includes(value.model)) value.model = models[0]!\n }\n notice.value = models.length ? `连接正常,发现 ${models.length} 个模型` : '连接正常,未返回模型列表'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '连接测试失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function save() {\n const value = draft.value\n if (!value) return\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n if (value.source === 'legacy') await saveLegacyModelService(props.profile, value.id, inputFor(value))\n else await saveModelService(props.profile, inputFor(value))\n draft.value = null\n draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = 'Provider 与模型已保存并刷新目录'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务保存失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function activate(service: CustomModelService) {\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await activateModelService(props.profile, service.id)\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已设为当前机器人的默认模型服务`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '设为默认失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function remove(service: CustomModelService) {\n const suffix = service.is_current ? ',当前默认绑定也会被解除' : ''\n if (!window.confirm(`删除模型服务“${service.name}”及其模型${suffix}?`)) return\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await deleteModelService(props.profile, service.id)\n if (draft.value?.id === service.id) draft.value = null\n if (!draft.value) draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已删除`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '删除模型服务失败'\n } finally {\n busy.value = false\n }\n}\n\nwatch(() => props.profile, () => { draft.value = null; draftBaseline.value = ''; defaultModelKey.value = ''; defaultModelBaseline.value = ''; void load() })\nwatch(panelDirty, value => emit('dirty-change', value), { immediate: true })\nonMounted(() => { void load() })\n</script>\n\n<template>\n <section class=\"management-panel\" aria-label=\"模型服务\">\n <div class=\"panel-context\"><strong>Provider 与模型</strong><span>全部来自当前机器人:<b>{{ profile }}</b></span></div>\n <form class=\"default-model-card\" @submit.prevent=\"saveDefaultModel\">\n <label><strong>默认全局模型</strong><small>仅用于之后新建的会话,已有会话保持原模型。</small></label>\n <select v-model=\"defaultModelKey\" aria-label=\"默认全局模型\" :disabled=\"busy || loading\">\n <option value=\"\" disabled>请选择 Provider 与模型</option>\n <optgroup v-for=\"provider in catalog\" :key=\"provider.slug\" :label=\"provider.name\">\n <option v-for=\"model in provider.models\" :key=\"modelKey(provider.slug, model)\" :value=\"modelKey(provider.slug, model)\">{{ provider.slug }} / {{ model }}</option>\n </optgroup>\n </select>\n <button class=\"primary-button\" type=\"submit\" :disabled=\"busy || loading || !defaultModelDirty\">保存默认模型</button>\n </form>\n <div class=\"panel-heading\"><label class=\"provider-search\"><AppIcon name=\"search\" :size=\"18\" /><input v-model=\"query\" type=\"search\" placeholder=\"搜索 Provider 或模型\" aria-label=\"搜索 Provider 或模型\" /></label><button class=\"primary-button\" type=\"button\" :disabled=\"busy || loading\" @click=\"beginCreate\"><AppIcon name=\"plus\" :size=\"15\" />新增服务</button></div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-else-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n <p v-if=\"loading\" class=\"panel-empty\">正在读取 Provider 与模型…</p>\n <div v-else-if=\"filteredProviderGroups.length\" class=\"service-list\">\n <article v-for=\"group in filteredProviderGroups\" :key=\"group.provider.slug\" class=\"service-card\">\n <div class=\"service-main\"><div class=\"service-title\"><strong>{{ group.provider.name }}</strong><em v-if=\"group.provider.isCurrent || group.service?.is_current\">当前默认</em><em>{{ group.service ? '可编辑' : '只读' }}</em></div><small>{{ group.provider.slug }}<template v-if=\"group.service?.base_url\"> · {{ group.service.base_url }}</template></small><div class=\"model-chips\"><span v-for=\"model in group.models\" :key=\"model\" :class=\"{ current: group.provider.isCurrent && model === group.provider.currentModel }\">{{ model }}</span></div></div>\n <div v-if=\"group.service\" class=\"card-actions\"><button type=\"button\" :disabled=\"busy\" @click=\"edit(group.service)\">编辑</button><button v-if=\"group.service.source !== 'legacy' && !group.service.is_current\" type=\"button\" :disabled=\"busy\" @click=\"activate(group.service)\">设为默认</button><button v-if=\"group.service.source !== 'legacy'\" class=\"danger\" type=\"button\" :disabled=\"busy\" @click=\"remove(group.service)\">删除</button></div>\n </article>\n </div>\n <p v-else-if=\"!loading\" class=\"panel-empty\">{{ query.trim() ? '没有匹配的 Provider 或模型。' : '内置 Hermes 当前没有可用 Provider 或模型。' }}</p>\n <p v-if=\"!loading\" class=\"catalog-note\">完整目录来自内置 Hermes;仅支持的自定义服务可编辑。</p>\n\n <form v-if=\"draft\" class=\"service-editor\" :aria-busy=\"busy\" @submit.prevent=\"save\">\n <header><strong>{{ draft.id ? `编辑 ${draft.id}` : '新增模型服务' }}</strong><button type=\"button\" aria-label=\"关闭编辑\" :disabled=\"busy\" @click=\"closeEditor\"><AppIcon name=\"close\" :size=\"15\" /></button></header>\n <div class=\"form-grid\"><label>名称<input v-model=\"draft.name\" :disabled=\"busy || draft.source === 'legacy'\" maxlength=\"100\" autocomplete=\"off\" /></label><label>Base URL<input v-model=\"draft.baseUrl\" :disabled=\"busy\" placeholder=\"https://example.com/v1\" autocomplete=\"url\" /></label></div>\n <div class=\"form-grid\"><label>默认模型<input v-model=\"draft.model\" :disabled=\"busy\" placeholder=\"model-id\" autocomplete=\"off\" /></label><label>上下文长度(可选)<input v-model=\"draft.contextLength\" :disabled=\"busy\" inputmode=\"numeric\" placeholder=\"例如 131072\" /></label></div>\n <label v-if=\"draft.canEditApiKey\">API Key<input v-model=\"draft.apiKey\" type=\"password\" :disabled=\"busy\" :placeholder=\"draft.hasApiKey && !draft.clearApiKey ? '已保存;留空保持不变' : '可选'\" autocomplete=\"new-password\" @input=\"draft.apiKeyTouched = Boolean(draft.apiKey.trim()); draft.clearApiKey = false\" /></label>\n <p v-else class=\"editor-hint\">该 Provider 的密钥不由 Hermes 环境变量管理,因此这里只编辑 URL 和模型。</p>\n <button v-if=\"draft.canEditApiKey && draft.hasApiKey && !draft.clearApiKey\" class=\"text-button danger\" type=\"button\" :disabled=\"busy\" @click=\"draft.apiKey = ''; draft.apiKeyTouched = false; draft.clearApiKey = true\">清除已保存密钥</button><button v-else-if=\"draft.canEditApiKey && draft.clearApiKey\" class=\"text-button\" type=\"button\" :disabled=\"busy\" @click=\"draft.clearApiKey = false\">取消清除密钥</button>\n <label>模型列表(每行一个)<textarea v-model=\"draft.modelsText\" rows=\"5\" :disabled=\"busy\" placeholder=\"连接测试后自动填充,也可手动输入\" /></label>\n <label class=\"check-row\"><input v-model=\"draft.discoverModels\" type=\"checkbox\" :disabled=\"busy\" />允许 Hermes 自动发现模型</label><label v-if=\"draft.source === 'managed'\" class=\"check-row\"><input v-model=\"draft.makeDefault\" type=\"checkbox\" :disabled=\"busy\" />保存后设为当前机器人默认服务</label>\n <small class=\"editor-hint\">{{ draft.source === 'legacy' ? '保存后模型列表按当前内容更新;当前默认 Provider 会同步新的 URL 与默认模型。' : 'Hermes 会保留服务中已有的模型条目;删除整项服务会一并移除它们。' }}</small>\n <footer><button class=\"quiet-button\" type=\"button\" :disabled=\"busy\" @click=\"probe\">测试连接</button><button class=\"primary-button\" type=\"submit\" :disabled=\"busy\">{{ busy ? '处理中…' : '保存模型服务' }}</button></footer>\n </form>\n </section>\n</template>\n\n<style scoped>\n.management-panel{display:grid;gap:16px}.panel-context{display:flex;align-items:center;justify-content:space-between;gap:12px;color:var(--text-secondary)}.panel-context strong{font-size:14px}.panel-context span{color:var(--text-muted);font-size:12px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:40px}.provider-search{display:flex;min-width:0;min-height:44px;flex:1;align-items:center;gap:9px;padding:0 12px;border:1px solid var(--line);border-radius:9px;color:var(--text-muted);background:var(--surface-raised)}.provider-search:focus-within{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.provider-search input{min-width:0;flex:1;border:0;outline:0;background:transparent;color:var(--text-primary);font:14px var(--font-ui)}.primary-button,.quiet-button{display:inline-flex;min-height:40px;align-items:center;justify-content:center;gap:7px;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}.primary-button{background:var(--accent);color:var(--text-on-solid)}.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}button:disabled{cursor:wait;opacity:.5}.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}.panel-empty{color:var(--text-muted);background:var(--surface-soft)}.service-list{display:grid;border-top:1px solid var(--line)}.service-card{display:flex;align-items:center;gap:14px;padding:18px 12px;border:0;border-bottom:1px solid var(--line)}.service-main{display:grid;min-width:0;flex:1;gap:8px}.service-title{display:flex;flex-wrap:wrap;align-items:center;gap:7px}.service-card strong{font-size:16px}.service-card small{color:var(--text-muted);font:12px var(--font-code);overflow-wrap:anywhere}.service-card em{padding:3px 7px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text-muted);font:normal 11px var(--font-ui)}.model-chips{display:flex;flex-wrap:wrap;gap:8px}.model-chips span{max-width:100%;padding:6px 9px;overflow:hidden;border-radius:7px;background:var(--surface-soft);color:var(--text-secondary);font:11px var(--font-code);text-overflow:ellipsis;white-space:nowrap}.model-chips span.current{background:color-mix(in srgb,var(--accent) 9%,var(--surface-soft));color:var(--accent)}.card-actions{display:flex;flex:0 0 auto;gap:7px}.card-actions button,.service-editor header button,.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px}.card-actions button:hover,.text-button:hover{background:var(--surface-soft)}.card-actions .danger,.text-button.danger{color:var(--danger)}.catalog-note{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}.service-editor{display:grid;gap:14px;padding:18px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface-soft)}.service-editor header{display:flex;align-items:center;justify-content:space-between}.service-editor header strong{font-size:15px}.service-editor header button{display:grid;width:36px;height:36px;place-items:center}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.service-editor label{display:grid;gap:7px;color:var(--text-secondary);font-size:13px;font-weight:650}.service-editor input:not([type=checkbox]),.service-editor textarea{width:100%;box-sizing:border-box;padding:10px 11px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}.service-editor input:not([type=checkbox]){height:42px}.service-editor input:focus,.service-editor textarea:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.service-editor textarea{resize:vertical;font-family:var(--font-code);line-height:1.5}.check-row{display:flex!important;align-items:center;gap:8px!important;font-weight:500!important}.text-button{justify-self:start;padding-inline:0}.editor-hint{margin:0;color:var(--text-muted);font-size:11px}.service-editor footer{display:flex;justify-content:flex-end;gap:9px}@media(max-width:600px){.panel-heading{align-items:stretch;flex-direction:column;gap:10px}.panel-heading .primary-button{width:100%}.panel-context{align-items:flex-start;flex-direction:column}.service-card{align-items:flex-start;flex-direction:column}.card-actions{width:100%;justify-content:flex-end}.form-grid{grid-template-columns:1fr}}\n.default-model-card{display:grid;grid-template-columns:minmax(180px,1fr) minmax(240px,2fr) auto;align-items:end;gap:12px;padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--surface-soft)}\n.default-model-card label{display:grid;gap:4px;color:var(--text-secondary)}\n.default-model-card label small{color:var(--text-muted);font-size:11px;font-weight:400}\n.default-model-card select{min-width:0;height:40px;padding:0 10px;border:1px solid var(--line);border-radius:9px;background:var(--surface-raised);color:var(--text-primary);font:12px var(--font-code)}\n@media(max-width:600px){.default-model-card{grid-template-columns:1fr}.default-model-card .primary-button{width:100%}}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, onMounted, ref, watch } from 'vue'\nimport AppIcon from '@/components/common/AppIcon.vue'\nimport {\n activateModelService,\n deleteModelService,\n listLegacyModelServices,\n listModelCatalog,\n listModelServices,\n saveLegacyModelService,\n saveModelService,\n saveProfileDefaultModel,\n validateModelService,\n type CustomModelService,\n type CustomModelServiceInput,\n type LegacyModelService,\n type ModelCatalogProvider,\n} from '@/api/agentManagement'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\nconst props = defineProps<{ profile: string }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\ninterface Draft {\n source: 'managed' | 'legacy'\n id: string\n name: string\n baseUrl: string\n apiKey: string\n apiKeyTouched: boolean\n clearApiKey: boolean\n model: string\n modelsText: string\n contextLength: string\n discoverModels: boolean\n makeDefault: boolean\n hasApiKey: boolean\n canEditApiKey: boolean\n}\n\nconst services = ref<CustomModelService[]>([])\nconst legacyServices = ref<LegacyModelService[]>([])\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst loading = ref(false)\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\nconst draft = ref<Draft | null>(null)\nconst draftBaseline = ref('')\nconst query = ref('')\nconst defaultModelKey = ref('')\nconst defaultModelBaseline = ref('')\n\nfunction modelKey(provider: string, model: string): string {\n return JSON.stringify([provider, model])\n}\n\nfunction modelSelection(key: string): { provider: string; model: string } | undefined {\n try {\n const value = JSON.parse(key)\n if (Array.isArray(value) && value.length === 2 && value.every(item => typeof item === 'string' && item.trim())) {\n return { provider: value[0], model: value[1] }\n }\n } catch { /* Invalid selections are rejected before saving. */ }\n return undefined\n}\n\nfunction emptyDraft(): Draft {\n return { source: 'managed', id: '', name: '', baseUrl: '', apiKey: '', apiKeyTouched: false, clearApiKey: false, model: '', modelsText: '', contextLength: '', discoverModels: true, makeDefault: false, hasApiKey: false, canEditApiKey: true }\n}\n\nfunction draftSnapshot(value: Draft): string {\n return JSON.stringify(value)\n}\n\nconst draftDirty = computed(() => Boolean(draft.value) && draftSnapshot(draft.value!) !== draftBaseline.value)\nconst defaultModelDirty = computed(() => Boolean(defaultModelKey.value) && defaultModelKey.value !== defaultModelBaseline.value)\nconst panelDirty = computed(() => draftDirty.value || defaultModelDirty.value)\n\nfunction replaceDraft(next: Draft): boolean {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return false\n draft.value = next\n draftBaseline.value = draftSnapshot(next)\n return true\n}\n\nfunction beginCreate() {\n replaceDraft(emptyDraft())\n}\n\nfunction closeEditor() {\n if (draftDirty.value && !window.confirm('放弃当前模型服务未保存的更改?')) return\n draft.value = null\n draftBaseline.value = ''\n}\n\nfunction edit(service: CustomModelService | LegacyModelService) {\n const next: Draft = {\n source: service.source === 'legacy' ? 'legacy' : 'managed',\n id: service.id,\n name: service.name,\n baseUrl: service.base_url,\n apiKey: '',\n apiKeyTouched: false,\n clearApiKey: false,\n model: service.model,\n modelsText: service.models.join('\\n'),\n contextLength: service.context_length ? String(service.context_length) : '',\n discoverModels: service.discover_models,\n makeDefault: service.is_current,\n hasApiKey: service.has_api_key,\n canEditApiKey: !('can_edit_api_key' in service) || service.can_edit_api_key,\n }\n if (!replaceDraft(next)) return\n error.value = ''\n notice.value = ''\n}\n\nasync function load(preserveDefaultDraft = false) {\n const selectedDefault = defaultModelKey.value\n const preserveSelection = preserveDefaultDraft && defaultModelDirty.value\n loading.value = true\n error.value = ''\n try {\n const [managed, legacy, available] = await Promise.all([\n listModelServices(props.profile),\n listLegacyModelServices(props.profile),\n listModelCatalog(props.profile),\n ])\n services.value = managed.endpoints || []\n legacyServices.value = legacy\n catalog.value = available\n const current = available.find(provider => provider.isCurrent && provider.currentModel)\n const key = current?.currentModel ? modelKey(current.slug, current.currentModel) : ''\n defaultModelBaseline.value = key\n defaultModelKey.value = preserveSelection ? selectedDefault : key\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务加载失败'\n } finally {\n loading.value = false\n }\n}\n\nasync function saveDefaultModel() {\n const selection = modelSelection(defaultModelKey.value)\n if (!selection) { error.value = '请选择默认 Provider 与模型'; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await saveProfileDefaultModel(props.profile, selection.provider, selection.model)\n await load()\n notifyModelCatalogChanged(props.profile)\n notice.value = `默认全局模型已更新为 ${selection.provider} / ${selection.model},仅影响新会话`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '默认全局模型保存失败'\n } finally {\n busy.value = false\n }\n}\n\nconst providerGroups = computed(() => {\n const editable = new Map<string, CustomModelService | LegacyModelService>()\n for (const service of [...services.value, ...legacyServices.value]) editable.set(service.id.toLocaleLowerCase(), service)\n const groups = catalog.value.map(provider => {\n const service = editable.get(provider.slug.toLocaleLowerCase())\n if (service) editable.delete(provider.slug.toLocaleLowerCase())\n return { provider, service, models: provider.models.length ? provider.models : service?.models || [] }\n })\n for (const service of editable.values()) {\n groups.push({\n provider: { slug: service.id, name: service.name, models: service.models, isCurrent: service.is_current },\n service,\n models: service.models,\n })\n }\n return groups\n})\n\nconst filteredProviderGroups = computed(() => {\n const needle = query.value.trim().toLocaleLowerCase()\n if (!needle) return providerGroups.value\n return providerGroups.value.filter(group => [\n group.provider.name,\n group.provider.slug,\n group.service?.base_url || '',\n ...group.models,\n ].some(value => value.toLocaleLowerCase().includes(needle)))\n})\n\nfunction inputFor(current: Draft): CustomModelServiceInput {\n const models = [...new Set(current.modelsText.split(/\\r?\\n|,/).map(value => value.trim()).filter(Boolean))]\n const contextLength = Number(current.contextLength)\n const input: CustomModelServiceInput = {\n ...(current.id ? { id: current.id } : {}),\n name: current.name.trim(),\n base_url: current.baseUrl.trim().replace(/\\/$/, ''),\n model: current.model.trim(),\n models: [...new Set([...models, current.model.trim()].filter(Boolean))],\n discover_models: current.discoverModels,\n make_default: current.makeDefault,\n ...(Number.isInteger(contextLength) && contextLength > 0 ? { context_length: contextLength } : {}),\n }\n if (current.clearApiKey) input.api_key = ''\n else if (current.apiKeyTouched && current.apiKey.trim()) input.api_key = current.apiKey.trim()\n return input\n}\n\nfunction validateDraft(): string {\n const value = draft.value\n if (!value?.name.trim()) return '请输入服务名称'\n if (!/^https?:\\/\\//i.test(value.baseUrl.trim())) return 'Base URL 必须以 http:// 或 https:// 开头'\n if (!value.model.trim()) return '请输入默认模型'\n if (value.contextLength && (!Number.isInteger(Number(value.contextLength)) || Number(value.contextLength) <= 0)) return '上下文长度必须是正整数'\n return ''\n}\n\nasync function probe() {\n const value = draft.value\n if (!value) return\n if (value.hasApiKey && !value.apiKeyTouched && !value.clearApiKey) {\n error.value = '服务端不会向浏览器回传已保存密钥;请重新输入 API Key 后再测试'\n return\n }\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n const result = await validateModelService(inputFor(value))\n if (!result.ok) throw new Error(result.message || '连接测试失败')\n const models = [...new Set(result.models.map(item => item.trim()).filter(Boolean))]\n if (models.length) {\n value.modelsText = models.join('\\n')\n if (!models.includes(value.model)) value.model = models[0]!\n }\n notice.value = models.length ? `连接正常,发现 ${models.length} 个模型` : '连接正常,未返回模型列表'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '连接测试失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function save() {\n const value = draft.value\n if (!value) return\n const validationError = validateDraft()\n if (validationError) { error.value = validationError; return }\n busy.value = true; error.value = ''; notice.value = ''\n try {\n if (value.source === 'legacy') await saveLegacyModelService(props.profile, value.id, inputFor(value))\n else await saveModelService(props.profile, inputFor(value))\n draft.value = null\n draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = 'Provider 与模型已保存并刷新目录'\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '模型服务保存失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function activate(service: CustomModelService) {\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await activateModelService(props.profile, service.id)\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已设为当前机器人的默认模型服务`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '设为默认失败'\n } finally {\n busy.value = false\n }\n}\n\nasync function remove(service: CustomModelService) {\n const suffix = service.is_current ? ',当前默认绑定也会被解除' : ''\n if (!window.confirm(`删除模型服务“${service.name}”及其模型${suffix}?`)) return\n busy.value = true; error.value = ''; notice.value = ''\n try {\n await deleteModelService(props.profile, service.id)\n if (draft.value?.id === service.id) draft.value = null\n if (!draft.value) draftBaseline.value = ''\n await load(true)\n notifyModelCatalogChanged(props.profile)\n notice.value = `“${service.name}”已删除`\n } catch (cause) {\n error.value = cause instanceof Error ? cause.message : '删除模型服务失败'\n } finally {\n busy.value = false\n }\n}\n\nwatch(() => props.profile, () => { draft.value = null; draftBaseline.value = ''; defaultModelKey.value = ''; defaultModelBaseline.value = ''; void load() })\nwatch(panelDirty, value => emit('dirty-change', value), { immediate: true })\nonMounted(() => { void load() })\n</script>\n\n<template>\n <section class=\"management-panel\" aria-label=\"模型服务\">\n <div class=\"panel-context\"><strong>Provider 与模型</strong><span>全部来自当前机器人:<b>{{ profile }}</b></span></div>\n <form class=\"default-model-card\" @submit.prevent=\"saveDefaultModel\">\n <label><strong>默认全局模型</strong><small>仅用于之后新建的会话,已有会话保持原模型。</small></label>\n <select v-model=\"defaultModelKey\" aria-label=\"默认全局模型\" :disabled=\"busy || loading\">\n <option value=\"\" disabled>请选择 Provider 与模型</option>\n <optgroup v-for=\"provider in catalog\" :key=\"provider.slug\" :label=\"provider.name\">\n <option v-for=\"model in provider.models\" :key=\"modelKey(provider.slug, model)\" :value=\"modelKey(provider.slug, model)\">{{ provider.slug }} / {{ model }}</option>\n </optgroup>\n </select>\n <button class=\"primary-button\" type=\"submit\" :disabled=\"busy || loading || !defaultModelDirty\">保存默认模型</button>\n </form>\n <div class=\"panel-heading\"><label class=\"provider-search\"><AppIcon name=\"search\" :size=\"18\" /><input v-model=\"query\" type=\"search\" placeholder=\"搜索 Provider 或模型\" aria-label=\"搜索 Provider 或模型\" /></label><button class=\"primary-button\" type=\"button\" :disabled=\"busy || loading\" @click=\"beginCreate\"><AppIcon name=\"plus\" :size=\"15\" />新增服务</button></div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-else-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n <p v-if=\"loading\" class=\"panel-empty\">正在读取 Provider 与模型…</p>\n <div v-else-if=\"filteredProviderGroups.length\" class=\"service-list\">\n <article v-for=\"group in filteredProviderGroups\" :key=\"group.provider.slug\" class=\"service-card\">\n <div class=\"service-main\"><div class=\"service-title\"><strong>{{ group.provider.name }}</strong><em v-if=\"group.provider.isCurrent || group.service?.is_current\">当前默认</em><em>{{ group.service ? '可编辑' : '只读' }}</em></div><small>{{ group.provider.slug }}<template v-if=\"group.service?.base_url\"> · {{ group.service.base_url }}</template></small><div class=\"model-chips\"><span v-for=\"model in group.models\" :key=\"model\" :class=\"{ current: group.provider.isCurrent && model === group.provider.currentModel }\">{{ model }}</span></div></div>\n <div v-if=\"group.service\" class=\"card-actions\"><button type=\"button\" :disabled=\"busy\" @click=\"edit(group.service)\">编辑</button><button v-if=\"group.service.source !== 'legacy' && !group.service.is_current\" type=\"button\" :disabled=\"busy\" @click=\"activate(group.service)\">设为默认</button><button v-if=\"group.service.source !== 'legacy'\" class=\"danger\" type=\"button\" :disabled=\"busy\" @click=\"remove(group.service)\">删除</button></div>\n </article>\n </div>\n <p v-else-if=\"!loading\" class=\"panel-empty\">{{ query.trim() ? '没有匹配的 Provider 或模型。' : '内置 Hermes 当前没有可用 Provider 或模型。' }}</p>\n <p v-if=\"!loading\" class=\"catalog-note\">完整目录来自内置 Hermes;仅支持的自定义服务可编辑。</p>\n\n <form v-if=\"draft\" class=\"service-editor\" :aria-busy=\"busy\" @submit.prevent=\"save\">\n <header><strong>{{ draft.id ? `编辑 ${draft.id}` : '新增模型服务' }}</strong><button type=\"button\" aria-label=\"关闭编辑\" :disabled=\"busy\" @click=\"closeEditor\"><AppIcon name=\"close\" :size=\"15\" /></button></header>\n <div class=\"form-grid\"><label>名称<input v-model=\"draft.name\" :disabled=\"busy || draft.source === 'legacy'\" maxlength=\"100\" autocomplete=\"off\" /></label><label>Base URL<input v-model=\"draft.baseUrl\" :disabled=\"busy\" placeholder=\"https://example.com/v1\" autocomplete=\"url\" /></label></div>\n <div class=\"form-grid\"><label>默认模型<input v-model=\"draft.model\" :disabled=\"busy\" placeholder=\"model-id\" autocomplete=\"off\" /></label><label>上下文长度(可选)<input v-model=\"draft.contextLength\" :disabled=\"busy\" inputmode=\"numeric\" placeholder=\"例如 131072\" /></label></div>\n <label v-if=\"draft.canEditApiKey\">API Key<input v-model=\"draft.apiKey\" type=\"password\" :disabled=\"busy\" :placeholder=\"draft.hasApiKey && !draft.clearApiKey ? '已保存;留空保持不变' : '可选'\" autocomplete=\"new-password\" @input=\"draft.apiKeyTouched = Boolean(draft.apiKey.trim()); draft.clearApiKey = false\" /></label>\n <p v-else class=\"editor-hint\">该 Provider 的密钥不由 Hermes 环境变量管理,因此这里只编辑 URL 和模型。</p>\n <button v-if=\"draft.canEditApiKey && draft.hasApiKey && !draft.clearApiKey\" class=\"text-button danger\" type=\"button\" :disabled=\"busy\" @click=\"draft.apiKey = ''; draft.apiKeyTouched = false; draft.clearApiKey = true\">清除已保存密钥</button><button v-else-if=\"draft.canEditApiKey && draft.clearApiKey\" class=\"text-button\" type=\"button\" :disabled=\"busy\" @click=\"draft.clearApiKey = false\">取消清除密钥</button>\n <label>模型列表(每行一个)<textarea v-model=\"draft.modelsText\" rows=\"5\" :disabled=\"busy\" placeholder=\"连接测试后自动填充,也可手动输入\" /></label>\n <label class=\"check-row\"><input v-model=\"draft.discoverModels\" type=\"checkbox\" :disabled=\"busy\" />允许 Hermes 自动发现模型</label><label v-if=\"draft.source === 'managed'\" class=\"check-row\"><input v-model=\"draft.makeDefault\" type=\"checkbox\" :disabled=\"busy\" />保存后设为当前机器人默认服务</label>\n <small class=\"editor-hint\">{{ draft.source === 'legacy' ? '保存后模型列表按当前内容更新;当前默认 Provider 会同步新的 URL 与默认模型。' : 'Hermes 会保留服务中已有的模型条目;删除整项服务会一并移除它们。' }}</small>\n <footer><button class=\"quiet-button\" type=\"button\" :disabled=\"busy\" @click=\"probe\">测试连接</button><button class=\"primary-button\" type=\"submit\" :disabled=\"busy\">{{ busy ? '处理中…' : '保存模型服务' }}</button></footer>\n </form>\n </section>\n</template>\n\n<style scoped>\n.management-panel{display:grid;gap:16px}.panel-context{display:flex;align-items:center;justify-content:space-between;gap:12px;color:var(--text-secondary)}.panel-context strong{font-size:14px}.panel-context span{color:var(--text-muted);font-size:12px}.panel-heading{display:flex;align-items:center;justify-content:space-between;gap:40px}.provider-search{display:flex;min-width:0;min-height:44px;flex:1;align-items:center;gap:9px;padding:0 12px;border:1px solid var(--line);border-radius:9px;color:var(--text-muted);background:var(--surface-raised)}.provider-search:focus-within{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.provider-search input{min-width:0;flex:1;border:0;outline:0;background:transparent;color:var(--text-primary);font:14px var(--font-ui)}.primary-button,.quiet-button{display:inline-flex;min-height:40px;align-items:center;justify-content:center;gap:7px;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}.primary-button{background:var(--accent);color:var(--text-on-solid)}.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}button:disabled{cursor:wait;opacity:.5}.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}.panel-empty{color:var(--text-muted);background:var(--surface-soft)}.service-list{display:grid;border-top:1px solid var(--line)}.service-card{display:flex;align-items:center;gap:14px;padding:18px 12px;border:0;border-bottom:1px solid var(--line)}.service-main{display:grid;min-width:0;flex:1;gap:8px}.service-title{display:flex;flex-wrap:wrap;align-items:center;gap:7px}.service-card strong{font-size:16px}.service-card small{color:var(--text-muted);font:12px var(--font-code);overflow-wrap:anywhere}.service-card em{padding:3px 7px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text-muted);font:normal 11px var(--font-ui)}.model-chips{display:flex;flex-wrap:wrap;gap:8px}.model-chips span{max-width:100%;padding:6px 9px;overflow:hidden;border-radius:7px;background:var(--surface-soft);color:var(--text-secondary);font:11px var(--font-code);text-overflow:ellipsis;white-space:nowrap}.model-chips span.current{background:color-mix(in srgb,var(--accent) 9%,var(--surface-soft));color:var(--accent)}.card-actions{display:flex;flex:0 0 auto;gap:7px}.card-actions button,.service-editor header button,.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px}.card-actions button:hover,.text-button:hover{background:var(--surface-soft)}.card-actions .danger,.text-button.danger{color:var(--danger)}.catalog-note{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}.service-editor{display:grid;gap:14px;padding:18px;border:1px solid var(--line-strong);border-radius:12px;background:var(--surface-soft)}.service-editor header{display:flex;align-items:center;justify-content:space-between}.service-editor header strong{font-size:15px}.service-editor header button{display:grid;width:36px;height:36px;place-items:center}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.service-editor label{display:grid;gap:7px;color:var(--text-secondary);font-size:13px;font-weight:650}.service-editor input:not([type=checkbox]),.service-editor textarea{width:100%;box-sizing:border-box;padding:10px 11px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}.service-editor input:not([type=checkbox]){height:42px}.service-editor input:focus,.service-editor textarea:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}.service-editor textarea{resize:vertical;font-family:var(--font-code);line-height:1.5}.check-row{display:flex!important;align-items:center;gap:8px!important;font-weight:500!important}.text-button{justify-self:start;padding-inline:0}.editor-hint{margin:0;color:var(--text-muted);font-size:11px}.service-editor footer{display:flex;justify-content:flex-end;gap:9px}@media(max-width:600px){.panel-heading{align-items:stretch;flex-direction:column;gap:10px}.panel-heading .primary-button{width:100%}.panel-context{align-items:flex-start;flex-direction:column}.service-card{align-items:flex-start;flex-direction:column}.card-actions{width:100%;justify-content:flex-end}.form-grid{grid-template-columns:1fr}}\n.default-model-card{display:grid;grid-template-columns:minmax(180px,1fr) minmax(240px,2fr) auto;align-items:end;gap:12px;padding:14px;border:1px solid var(--line);border-radius:11px;background:var(--surface-soft)}\n.default-model-card label{display:grid;gap:4px;color:var(--text-secondary)}\n.default-model-card label small{color:var(--text-muted);font-size:11px;font-weight:400}\n.default-model-card select{min-width:0;height:40px;padding:0 10px;border:1px solid var(--line);border-radius:9px;background:var(--surface-raised);color:var(--text-primary);font:12px var(--font-code)}\n@media(max-width:600px){.default-model-card{grid-template-columns:1fr}.default-model-card .primary-button{width:100%}}\n</style>\n","import { apiRequest } from './client'\n\nexport interface HermesCredential {\n key: string\n isSet: boolean\n preview: string | null\n description: string\n url: string | null\n category: string\n secret: boolean\n advanced: boolean\n provider: string\n providerLabel: string\n custom: boolean\n readonly: boolean\n}\n\nexport interface AuxiliaryTask {\n task: string\n provider: string\n model: string\n base_url?: string\n label?: string\n hint?: string\n}\n\nexport interface AuxiliaryModels {\n tasks: AuxiliaryTask[]\n main?: { provider?: string; model?: string }\n providers?: Array<{ id: string; label: string }>\n}\n\nexport interface OAuthProvider {\n id: string\n name: string\n flow: string\n web_flow?: string\n cli_command?: string | null\n docs_url?: string | null\n disconnectable?: boolean\n disconnect_hint?: string | null\n status?: { logged_in?: boolean; source_label?: string | null; token_preview?: string | null }\n}\n\nexport interface OAuthSession {\n session_id: string\n status?: string\n flow?: string\n user_code?: string\n verification_url?: string\n expires_in?: number\n error_message?: string | null\n}\n\nconst query = (profile: string) => profile && profile !== 'default' ? `?profile=${encodeURIComponent(profile)}` : ''\n\nexport async function listHermesCredentials(profile: string): Promise<HermesCredential[]> {\n return (await apiRequest<{ variables: HermesCredential[] }>(`/api/app/admin/hermes/credentials${query(profile)}`)).variables ?? []\n}\n\nexport async function saveHermesCredential(profile: string, key: string, value: string): Promise<void> {\n await apiRequest('/api/app/admin/hermes/credentials', { method: 'PUT', body: { profile, key, value } })\n}\n\nexport async function deleteHermesCredential(profile: string, key: string): Promise<void> {\n await apiRequest('/api/app/admin/hermes/credentials', { method: 'DELETE', body: { profile, key } })\n}\n\nexport async function getAuxiliaryModels(profile: string): Promise<AuxiliaryModels> {\n return apiRequest<AuxiliaryModels>(`/api/app/admin/hermes/auxiliary${query(profile)}`)\n}\n\nexport async function setAuxiliaryModel(profile: string, task: string, provider: string, model: string): Promise<AuxiliaryModels> {\n return apiRequest<AuxiliaryModels>('/api/app/admin/hermes/auxiliary', { method: 'PUT', body: { profile, task, provider, model } })\n}\n\nexport async function listOAuthProviders(profile: string): Promise<OAuthProvider[]> {\n return (await apiRequest<{ providers?: OAuthProvider[] }>(`/api/app/admin/hermes/oauth${query(profile)}`)).providers ?? []\n}\n\nconst oauthPath = (provider: string, action = '') => `/api/app/admin/hermes/oauth/${encodeURIComponent(provider)}${action ? `/${action}` : ''}`\n\nexport async function startOAuth(profile: string, provider: string): Promise<OAuthSession> {\n return apiRequest<OAuthSession>(oauthPath(provider, 'start'), { method: 'POST', body: { profile } })\n}\n\nexport async function pollOAuth(profile: string, provider: string, sessionId: string): Promise<OAuthSession> {\n return apiRequest<OAuthSession>(oauthPath(provider, 'poll'), { method: 'POST', body: { profile, sessionId } })\n}\n\nexport async function cancelOAuth(profile: string, provider: string, sessionId: string): Promise<void> {\n await apiRequest(oauthPath(provider, 'cancel'), { method: 'POST', body: { profile, sessionId } })\n}\n\nexport async function submitOAuthToken(profile: string, provider: string, token: string): Promise<void> {\n await apiRequest(oauthPath(provider, 'token'), { method: 'POST', body: { profile, token } })\n}\n\nexport async function disconnectOAuth(profile: string, provider: string): Promise<void> {\n await apiRequest(oauthPath(provider), { method: 'DELETE', body: { profile } })\n}\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport type { Profile } from '@shared/types'\nimport ModelServicesPanel from './ModelServicesPanel.vue'\nimport { listModelCatalog, type ModelCatalogProvider } from '@/api/agentManagement'\nimport {\n cancelOAuth, deleteHermesCredential, disconnectOAuth, getAuxiliaryModels, listHermesCredentials, listOAuthProviders,\n pollOAuth, saveHermesCredential, setAuxiliaryModel, startOAuth, submitOAuthToken,\n type AuxiliaryModels, type AuxiliaryTask, type HermesCredential, type OAuthProvider, type OAuthSession,\n} from '@/api/hermesAdmin'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\ntype Tab = 'models' | 'accounts' | 'keys' | 'auxiliary'\nconst props = defineProps<{ profiles?: Profile[] }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\nconst tabs: Array<{ id: Tab; label: string }> = [\n { id: 'models', label: '供应商与模型' },\n { id: 'accounts', label: '账号登录' },\n { id: 'keys', label: '密钥与变量' },\n { id: 'auxiliary', label: '辅助模型' },\n]\nconst tab = ref<Tab>('models')\nconst profile = ref('default')\nconst profileOptions = computed(() => {\n const names = new Set(['default', ...(props.profiles ?? []).map(item => item.name).filter(Boolean)])\n return [...names]\n})\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\n\nasync function run(work: () => Promise<void>, success = '') {\n if (busy.value) return\n busy.value = true; error.value = ''; notice.value = ''\n try { await work(); if (success) notice.value = success }\n catch (cause) { error.value = cause instanceof Error ? cause.message : '操作失败' }\n finally { busy.value = false }\n}\n\n// ── 密钥与变量 ───────────────────────────────────────────────────────────────\nconst credentials = ref<HermesCredential[]>([])\nconst keyQuery = ref('')\nconst showAdvanced = ref(false)\nconst editingKey = ref('')\nconst editingValue = ref('')\nconst customKey = ref('')\nconst customValue = ref('')\nconst CATEGORY_LABELS: Record<string, string> = { provider: '模型供应商', tool: '工具', skill: '技能', setting: '设置', custom: '自定义' }\nconst CATEGORY_ORDER = ['provider', 'tool', 'skill', 'setting', 'custom']\nconst credentialGroups = computed(() => {\n const query = keyQuery.value.trim().toLocaleLowerCase()\n const rows = credentials.value.filter(row => (showAdvanced.value || !row.advanced || row.isSet || query)\n && (!query || `${row.key} ${row.description} ${row.providerLabel}`.toLocaleLowerCase().includes(query)))\n const groups = new Map<string, HermesCredential[]>()\n for (const row of rows) groups.set(row.category, [...(groups.get(row.category) ?? []), row])\n return [...groups.entries()]\n .sort(([a], [b]) => (CATEGORY_ORDER.indexOf(a) + 1 || 99) - (CATEGORY_ORDER.indexOf(b) + 1 || 99))\n .map(([category, items]) => ({ category, label: CATEGORY_LABELS[category] ?? category, items: items.sort((a, b) => Number(b.isSet) - Number(a.isSet) || a.key.localeCompare(b.key)) }))\n})\nasync function loadCredentials() { credentials.value = await listHermesCredentials(profile.value) }\nfunction editCredential(row: HermesCredential) { editingKey.value = row.key; editingValue.value = '' }\nfunction saveCredential(key: string, value: string) {\n return run(async () => {\n await saveHermesCredential(profile.value, key, value)\n editingKey.value = ''; editingValue.value = ''; customKey.value = ''; customValue.value = ''\n await loadCredentials(); notifyModelCatalogChanged(profile.value)\n }, `已保存 ${key}`)\n}\nfunction clearCredential(row: HermesCredential) {\n if (!window.confirm(`清除 ${row.key}?`)) return\n return run(async () => { await deleteHermesCredential(profile.value, row.key); await loadCredentials(); notifyModelCatalogChanged(profile.value) }, `已清除 ${row.key}`)\n}\n\n// ── 账号登录 ────────────────────────────────────────────────────────────────\nconst oauthProviders = ref<OAuthProvider[]>([])\nconst login = ref<{ provider: string; session: OAuthSession } | null>(null)\nconst tokenProvider = ref('')\nconst tokenValue = ref('')\nlet pollTimer: ReturnType<typeof setTimeout> | undefined\nasync function loadOAuth() { oauthProviders.value = await listOAuthProviders(profile.value) }\nfunction loginFlow(provider: OAuthProvider): 'device' | 'token' | 'external' {\n const flow = provider.web_flow || provider.flow\n if (flow === 'paste_token') return 'token'\n if (flow === 'device_code' || flow === 'process') return 'device'\n return 'external'\n}\nfunction stopPolling() { if (pollTimer) clearTimeout(pollTimer); pollTimer = undefined }\nfunction schedulePoll() {\n stopPolling()\n pollTimer = setTimeout(async () => {\n const current = login.value\n if (!current) return\n try {\n const result = await pollOAuth(profile.value, current.provider, current.session.session_id)\n if (login.value?.session.session_id !== current.session.session_id) return\n login.value = { provider: current.provider, session: { ...current.session, ...result } }\n if (!result.status || result.status === 'pending') { schedulePoll(); return }\n if (result.status === 'approved') { notice.value = '登录成功'; login.value = null; await loadOAuth(); notifyModelCatalogChanged(profile.value) }\n else error.value = result.error_message || ({ denied: '登录被拒绝', expired: '登录已过期,请重新开始' } as Record<string, string>)[result.status] || '登录失败'\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '登录状态查询失败' }\n }, 3000)\n}\nfunction beginLogin(provider: OAuthProvider) {\n if (loginFlow(provider) === 'token') { tokenProvider.value = provider.id; tokenValue.value = ''; return }\n return run(async () => {\n const session = await startOAuth(profile.value, provider.id)\n login.value = { provider: provider.id, session }\n schedulePoll()\n })\n}\nfunction cancelLogin() {\n const current = login.value\n stopPolling(); login.value = null\n if (current) void cancelOAuth(profile.value, current.provider, current.session.session_id).catch(() => undefined)\n}\nfunction submitToken() {\n return run(async () => {\n await submitOAuthToken(profile.value, tokenProvider.value, tokenValue.value)\n tokenProvider.value = ''; tokenValue.value = ''\n await loadOAuth(); notifyModelCatalogChanged(profile.value)\n }, '凭据已保存')\n}\nfunction logout(provider: OAuthProvider) {\n if (!window.confirm(`退出 ${provider.name}?`)) return\n return run(async () => { await disconnectOAuth(profile.value, provider.id); await loadOAuth(); notifyModelCatalogChanged(profile.value) }, `已退出 ${provider.name}`)\n}\n\n// ── 辅助模型 ────────────────────────────────────────────────────────────────\nconst AUX_LABELS: Record<string, [string, string]> = {\n vision: ['视觉识别', '图片理解与截图分析'],\n compression: ['上下文压缩', '长对话接近上限时整理历史'],\n approval: ['审批判断', '自动审批模式下判断命令风险'],\n mcp: ['MCP 工具', 'MCP 工具的辅助调用'],\n title_generation: ['标题生成', '为会话生成标题'],\n review: ['复核', '回合结束后的记忆与技能复核'],\n voice_chat: ['语音对话', '语音模式下的快速回复'],\n triage_specifier: ['任务分诊', '拆解并细化任务说明'],\n kanban_decomposer: ['任务拆解', '把目标拆成可执行步骤'],\n profile_describer: ['Profile 描述', '生成 Profile 简介'],\n curator: ['技能整理', '后台整理与维护技能'],\n session_search: ['会话搜索', '总结检索到的历史会话'],\n web_extract: ['网页提取', '总结抓取的网页内容'],\n}\nconst auxiliary = ref<AuxiliaryTask[]>([])\nconst auxMain = ref('')\nconst auxDrafts = ref<Record<string, { provider: string; model: string }>>({})\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst allProviders = ref<Array<{ id: string; label: string }>>([])\n/** Providers with a loaded model list first, then the rest of Hermes's providers. */\nconst auxProviders = computed(() => {\n const seen = new Set(catalog.value.map(item => item.slug))\n return [...catalog.value.map(item => ({ id: item.slug, label: item.name })), ...allProviders.value.filter(item => !seen.has(item.id))]\n})\nfunction auxLabel(task: AuxiliaryTask): [string, string] { return AUX_LABELS[task.task] ?? [task.label || task.task, task.hint || ''] }\nfunction modelsFor(provider: string) { return catalog.value.find(item => item.slug === provider)?.models ?? [] }\nfunction applyAuxiliary(value: AuxiliaryModels) {\n auxiliary.value = value.tasks ?? []\n if (value.providers?.length) allProviders.value = value.providers\n auxMain.value = value.main?.model ? `${value.main.provider || ''} / ${value.main.model}` : '未设置'\n auxDrafts.value = Object.fromEntries(auxiliary.value.map(task => [task.task, { provider: task.provider || 'auto', model: task.model || '' }]))\n}\nasync function loadAuxiliary() {\n const [value, providers] = await Promise.all([getAuxiliaryModels(profile.value), listModelCatalog(profile.value).catch(() => [])])\n catalog.value = providers\n applyAuxiliary(value)\n}\nconst auxDirty = computed(() => auxiliary.value.some(task => {\n const draft = auxDrafts.value[task.task]\n return draft && (draft.provider !== (task.provider || 'auto') || (draft.provider !== 'auto' && draft.model !== (task.model || '')))\n}))\nfunction saveAuxiliary(task: AuxiliaryTask) {\n const draft = auxDrafts.value[task.task]\n if (!draft) return\n if (draft.provider !== 'auto' && !draft.model.trim()) { error.value = '请填写模型名称'; return }\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, task.task, draft.provider, draft.model.trim())), `已保存「${auxLabel(task)[0]}」`)\n}\nfunction resetAuxiliary() {\n if (!window.confirm('把全部辅助模型恢复为自动?')) return\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, '__reset__', 'auto', '')), '已全部恢复为自动')\n}\n\n// ── 加载 ───────────────────────────────────────────────────────────────────\nconst modelsDirty = ref(false)\nconst dirty = computed(() => (tab.value === 'models' && modelsDirty.value) || (tab.value === 'auxiliary' && auxDirty.value) || !!editingKey.value || !!customValue.value || !!tokenValue.value)\nwatch(dirty, value => emit('dirty-change', value), { immediate: true })\n\nasync function load() {\n stopPolling(); login.value = null; editingKey.value = ''; tokenProvider.value = ''\n error.value = ''; notice.value = ''\n if (tab.value === 'models') return\n busy.value = true\n try {\n if (tab.value === 'keys') await loadCredentials()\n else if (tab.value === 'accounts') await loadOAuth()\n else await loadAuxiliary()\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '读取失败' }\n finally { busy.value = false }\n}\nfunction selectTab(next: Tab) {\n if (next === tab.value) return\n if (dirty.value && !window.confirm('放弃当前未保存的更改?')) return\n modelsDirty.value = false\n tab.value = next\n}\nwatch([tab, profile], () => { void load() }, { immediate: true })\nonBeforeUnmount(stopPolling)\n</script>\n\n<template>\n <section class=\"hermes-settings\" aria-label=\"模型服务\">\n <p class=\"intro\">Hermes 已内置在夭夭服务中,这里替代原来的 Hermes Dashboard:配置模型供应商、账号登录、API Key 和辅助模型。Bot 使用所选 Profile 的这些配置。</p>\n <div class=\"toolbar\">\n <div class=\"tabs\" role=\"tablist\" aria-label=\"模型服务分类\">\n <button v-for=\"item in tabs\" :key=\"item.id\" type=\"button\" role=\"tab\" :aria-selected=\"tab === item.id\" :class=\"{ active: tab === item.id }\" @click=\"selectTab(item.id)\">{{ item.label }}</button>\n </div>\n <label v-if=\"profileOptions.length > 1\" class=\"profile-select\">Profile\n <select v-model=\"profile\" :disabled=\"busy || dirty\"><option v-for=\"name in profileOptions\" :key=\"name\" :value=\"name\">{{ name === 'default' ? 'default(系统)' : name }}</option></select>\n </label>\n </div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n\n <ModelServicesPanel v-if=\"tab === 'models'\" :key=\"profile\" :profile=\"profile\" @dirty-change=\"modelsDirty = $event\" />\n\n <template v-else-if=\"tab === 'accounts'\">\n <p class=\"hint\">适用于用订阅账号或设备码登录的供应商;普通 API Key 请在「密钥与变量」中填写。</p>\n <p v-if=\"busy && !oauthProviders.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"provider in oauthProviders\" :key=\"provider.id\">\n <div class=\"row-main\">\n <strong>{{ provider.name }}</strong>\n <small :class=\"{ ok: provider.status?.logged_in }\">{{ provider.status?.logged_in ? `已登录${provider.status.source_label ? ` · ${provider.status.source_label}` : ''}${provider.status.token_preview ? ` · …${provider.status.token_preview}` : ''}` : '未登录' }}</small>\n <small v-if=\"loginFlow(provider) === 'external' && !provider.status?.logged_in\" class=\"muted\">需要在服务器上运行 <code>{{ provider.cli_command }}</code> 登录。</small>\n </div>\n <div class=\"row-actions\">\n <a v-if=\"provider.docs_url\" :href=\"provider.docs_url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-button\">说明</a>\n <button v-if=\"provider.status?.logged_in && provider.disconnectable\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"logout(provider)\">退出</button>\n <button v-else-if=\"!provider.status?.logged_in && loginFlow(provider) !== 'external'\" type=\"button\" class=\"quiet-button\" :disabled=\"busy || !!login\" @click=\"beginLogin(provider)\">登录</button>\n </div>\n <div v-if=\"login?.provider === provider.id\" class=\"flow-box\">\n <p>在浏览器打开 <a :href=\"login.session.verification_url\" target=\"_blank\" rel=\"noopener noreferrer\">{{ login.session.verification_url }}</a>,输入代码:</p>\n <code class=\"user-code\">{{ login.session.user_code }}</code>\n <p class=\"muted\">完成后这里会自动更新。</p>\n <button type=\"button\" class=\"text-button\" @click=\"cancelLogin\">取消</button>\n </div>\n <form v-if=\"tokenProvider === provider.id\" class=\"flow-box\" @submit.prevent=\"submitToken\">\n <label>粘贴 API Key 或 setup-token<input v-model=\"tokenValue\" type=\"password\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"tokenProvider = ''; tokenValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !tokenValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </template>\n\n <template v-else-if=\"tab === 'keys'\">\n <div class=\"filter-row\">\n <input v-model=\"keyQuery\" type=\"search\" placeholder=\"搜索变量名、说明或供应商\" aria-label=\"搜索变量\">\n <label class=\"check\"><input v-model=\"showAdvanced\" type=\"checkbox\">显示高级项</label>\n </div>\n <p class=\"hint\">值只保存在服务器的 Hermes 数据目录,保存后不会再回传到浏览器。</p>\n <p v-if=\"busy && !credentials.length\" class=\"panel-empty\">正在读取…</p>\n <p v-else-if=\"!credentialGroups.length\" class=\"panel-empty\">没有匹配的变量。</p>\n <section v-for=\"group in credentialGroups\" :key=\"group.category\" class=\"group\">\n <h4>{{ group.label }}</h4>\n <ul class=\"rows\">\n <li v-for=\"row in group.items\" :key=\"row.key\">\n <div class=\"row-main\">\n <strong class=\"mono\">{{ row.key }}</strong>\n <small v-if=\"row.description || row.providerLabel\" class=\"muted\">{{ row.providerLabel && !row.description.includes(row.providerLabel) ? `${row.providerLabel} · ` : '' }}{{ row.description }}<a v-if=\"row.url\" :href=\"row.url\" target=\"_blank\" rel=\"noopener noreferrer\"> 获取</a></small>\n <small :class=\"{ ok: row.isSet }\">{{ row.isSet ? `已设置${row.preview ? ` · ${row.preview}` : ''}` : '未设置' }}</small>\n </div>\n <div class=\"row-actions\">\n <span v-if=\"row.readonly\" class=\"muted\">由运行环境管理</span>\n <template v-else>\n <button v-if=\"row.isSet\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"clearCredential(row)\">清除</button>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"editCredential(row)\">{{ row.isSet ? '修改' : '设置' }}</button>\n </template>\n </div>\n <form v-if=\"editingKey === row.key\" class=\"flow-box\" @submit.prevent=\"saveCredential(row.key, editingValue)\">\n <label>{{ row.key }}<input v-model=\"editingValue\" :type=\"row.secret ? 'password' : 'text'\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"editingKey = ''; editingValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !editingValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </section>\n <form class=\"flow-box custom\" @submit.prevent=\"saveCredential(customKey.trim(), customValue)\">\n <strong>添加自定义变量</strong>\n <div class=\"form-grid\">\n <label>变量名<input v-model=\"customKey\" pattern=\"[A-Za-z_][A-Za-z0-9_]*\" placeholder=\"MY_API_KEY\" autocomplete=\"off\" :disabled=\"busy\"></label>\n <label>值<input v-model=\"customValue\" type=\"password\" autocomplete=\"off\" :disabled=\"busy\"></label>\n </div>\n <div class=\"row-actions\"><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !customKey.trim() || !customValue.trim()\">添加</button></div>\n </form>\n </template>\n\n <template v-else>\n <p class=\"hint\">辅助模型负责压缩、视觉、标题等后台任务。选「自动」时使用主模型(当前:{{ auxMain }})或 Hermes 自动选择的可用模型。</p>\n <p v-if=\"busy && !auxiliary.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"task in auxiliary\" :key=\"task.task\" class=\"aux-row\">\n <div class=\"row-main\"><strong>{{ auxLabel(task)[0] }}</strong><small class=\"muted\">{{ auxLabel(task)[1] }}</small></div>\n <div v-if=\"auxDrafts[task.task]\" class=\"aux-fields\">\n <select v-model=\"auxDrafts[task.task].provider\" :aria-label=\"`${auxLabel(task)[0]} Provider`\" :disabled=\"busy\">\n <option value=\"auto\">自动</option>\n <option v-if=\"task.provider && task.provider !== 'auto' && !auxProviders.some(item => item.id === task.provider)\" :value=\"task.provider\">{{ task.provider }}</option>\n <option v-for=\"item in auxProviders\" :key=\"item.id\" :value=\"item.id\">{{ item.label }}</option>\n </select>\n <input v-if=\"auxDrafts[task.task].provider !== 'auto'\" v-model=\"auxDrafts[task.task].model\" :list=\"`aux-models-${task.task}`\" placeholder=\"模型名称\" :aria-label=\"`${auxLabel(task)[0]} 模型`\" :disabled=\"busy\">\n <datalist :id=\"`aux-models-${task.task}`\"><option v-for=\"model in modelsFor(auxDrafts[task.task].provider)\" :key=\"model\" :value=\"model\" /></datalist>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"saveAuxiliary(task)\">保存</button>\n </div>\n </li>\n </ul>\n <div v-if=\"auxiliary.length\" class=\"row-actions\"><button type=\"button\" class=\"text-button\" :disabled=\"busy\" @click=\"resetAuxiliary\">全部恢复为自动</button></div>\n </template>\n </section>\n</template>\n\n<style scoped>\n.hermes-settings{display:grid;gap:16px}\n.intro,.hint{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}\n.toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}\n.tabs{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft)}\n.tabs button{min-height:34px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:13px;font-weight:600}\n.tabs button.active{background:var(--surface-raised);color:var(--text-primary);box-shadow:0 1px 2px rgb(0 0 0 / 8%)}\n.profile-select{display:flex;align-items:center;gap:8px;color:var(--text-secondary);font-size:13px}\nselect,input:not([type=checkbox]){min-width:0;height:38px;box-sizing:border-box;padding:0 10px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}\nselect:focus,input:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}\n.rows{display:grid;margin:0;padding:0;list-style:none;border-top:1px solid var(--line)}\n.rows li{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;padding:14px 4px;border-bottom:1px solid var(--line)}\n.row-main{display:grid;min-width:0;flex:1;gap:4px}\n.row-main strong{font-size:14px}\n.row-main small{color:var(--text-secondary);font-size:12px;overflow-wrap:anywhere}\n.row-main small.ok{color:var(--success,#21845b)}\n.muted{color:var(--text-muted)!important;font-size:12px}\n.mono{font-family:var(--font-code);font-size:13px!important}\n.row-actions{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-end;gap:8px}\n.flow-box{display:grid;flex-basis:100%;gap:10px;padding:14px;border:1px solid var(--line-strong);border-radius:11px;background:var(--surface-soft)}\n.flow-box p{margin:0;font-size:13px}\n.flow-box label{display:grid;gap:6px;color:var(--text-secondary);font-size:13px;font-weight:600}\n.user-code{justify-self:start;padding:8px 14px;border-radius:8px;background:var(--surface-raised);font:600 20px var(--font-code);letter-spacing:.12em}\n.custom{flex-basis:auto}\n.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.group h4{margin:8px 0;color:var(--text-secondary);font-size:13px}\n.filter-row{display:flex;align-items:center;gap:12px}\n.filter-row input[type=search]{flex:1}\n.check{display:flex;align-items:center;gap:6px;color:var(--text-secondary);font-size:13px;white-space:nowrap}\n.aux-fields{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.aux-fields select{width:170px}.aux-fields input{width:220px}\n.primary-button,.quiet-button{display:inline-flex;min-height:36px;align-items:center;justify-content:center;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}\n.primary-button{background:var(--accent);color:var(--text-on-solid)}\n.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}\n.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px;text-decoration:none;display:inline-flex;align-items:center}\n.text-button:hover{background:var(--surface-soft)}.text-button.danger{color:var(--danger)}\nbutton:disabled{cursor:wait;opacity:.5}\n.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}\n.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}\n.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}\n.panel-empty{color:var(--text-muted);background:var(--surface-soft)}\ncode{font-family:var(--font-code)}\n@media(max-width:600px){.form-grid{grid-template-columns:1fr}.aux-fields,.aux-fields select,.aux-fields input{width:100%}.filter-row{flex-direction:column;align-items:stretch}.rows li{align-items:flex-start}.row-actions{width:100%}}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport type { Profile } from '@shared/types'\nimport ModelServicesPanel from './ModelServicesPanel.vue'\nimport { listModelCatalog, type ModelCatalogProvider } from '@/api/agentManagement'\nimport {\n cancelOAuth, deleteHermesCredential, disconnectOAuth, getAuxiliaryModels, listHermesCredentials, listOAuthProviders,\n pollOAuth, saveHermesCredential, setAuxiliaryModel, startOAuth, submitOAuthToken,\n type AuxiliaryModels, type AuxiliaryTask, type HermesCredential, type OAuthProvider, type OAuthSession,\n} from '@/api/hermesAdmin'\nimport { notifyModelCatalogChanged } from '@/utils/modelCatalogEvents'\n\ntype Tab = 'models' | 'accounts' | 'keys' | 'auxiliary'\nconst props = defineProps<{ profiles?: Profile[] }>()\nconst emit = defineEmits<{ 'dirty-change': [dirty: boolean] }>()\n\nconst tabs: Array<{ id: Tab; label: string }> = [\n { id: 'models', label: '供应商与模型' },\n { id: 'accounts', label: '账号登录' },\n { id: 'keys', label: '密钥与变量' },\n { id: 'auxiliary', label: '辅助模型' },\n]\nconst tab = ref<Tab>('models')\nconst profile = ref('default')\nconst profileOptions = computed(() => {\n const names = new Set(['default', ...(props.profiles ?? []).map(item => item.name).filter(Boolean)])\n return [...names]\n})\nconst busy = ref(false)\nconst error = ref('')\nconst notice = ref('')\n\nasync function run(work: () => Promise<void>, success = '') {\n if (busy.value) return\n busy.value = true; error.value = ''; notice.value = ''\n try { await work(); if (success) notice.value = success }\n catch (cause) { error.value = cause instanceof Error ? cause.message : '操作失败' }\n finally { busy.value = false }\n}\n\n// ── 密钥与变量 ───────────────────────────────────────────────────────────────\nconst credentials = ref<HermesCredential[]>([])\nconst keyQuery = ref('')\nconst showAdvanced = ref(false)\nconst editingKey = ref('')\nconst editingValue = ref('')\nconst customKey = ref('')\nconst customValue = ref('')\nconst CATEGORY_LABELS: Record<string, string> = { provider: '模型供应商', tool: '工具', skill: '技能', setting: '设置', custom: '自定义' }\nconst CATEGORY_ORDER = ['provider', 'tool', 'skill', 'setting', 'custom']\nconst credentialGroups = computed(() => {\n const query = keyQuery.value.trim().toLocaleLowerCase()\n const rows = credentials.value.filter(row => (showAdvanced.value || !row.advanced || row.isSet || query)\n && (!query || `${row.key} ${row.description} ${row.providerLabel}`.toLocaleLowerCase().includes(query)))\n const groups = new Map<string, HermesCredential[]>()\n for (const row of rows) groups.set(row.category, [...(groups.get(row.category) ?? []), row])\n return [...groups.entries()]\n .sort(([a], [b]) => (CATEGORY_ORDER.indexOf(a) + 1 || 99) - (CATEGORY_ORDER.indexOf(b) + 1 || 99))\n .map(([category, items]) => ({ category, label: CATEGORY_LABELS[category] ?? category, items: items.sort((a, b) => Number(b.isSet) - Number(a.isSet) || a.key.localeCompare(b.key)) }))\n})\nasync function loadCredentials() { credentials.value = await listHermesCredentials(profile.value) }\nfunction editCredential(row: HermesCredential) { editingKey.value = row.key; editingValue.value = '' }\nfunction saveCredential(key: string, value: string) {\n return run(async () => {\n await saveHermesCredential(profile.value, key, value)\n editingKey.value = ''; editingValue.value = ''; customKey.value = ''; customValue.value = ''\n await loadCredentials(); notifyModelCatalogChanged(profile.value)\n }, `已保存 ${key}`)\n}\nfunction clearCredential(row: HermesCredential) {\n if (!window.confirm(`清除 ${row.key}?`)) return\n return run(async () => { await deleteHermesCredential(profile.value, row.key); await loadCredentials(); notifyModelCatalogChanged(profile.value) }, `已清除 ${row.key}`)\n}\n\n// ── 账号登录 ────────────────────────────────────────────────────────────────\nconst oauthProviders = ref<OAuthProvider[]>([])\nconst login = ref<{ provider: string; session: OAuthSession } | null>(null)\nconst tokenProvider = ref('')\nconst tokenValue = ref('')\nlet pollTimer: ReturnType<typeof setTimeout> | undefined\nasync function loadOAuth() { oauthProviders.value = await listOAuthProviders(profile.value) }\nfunction loginFlow(provider: OAuthProvider): 'device' | 'token' | 'external' {\n const flow = provider.web_flow || provider.flow\n if (flow === 'paste_token') return 'token'\n if (flow === 'device_code' || flow === 'process') return 'device'\n return 'external'\n}\nfunction stopPolling() { if (pollTimer) clearTimeout(pollTimer); pollTimer = undefined }\nfunction schedulePoll() {\n stopPolling()\n pollTimer = setTimeout(async () => {\n const current = login.value\n if (!current) return\n try {\n const result = await pollOAuth(profile.value, current.provider, current.session.session_id)\n if (login.value?.session.session_id !== current.session.session_id) return\n login.value = { provider: current.provider, session: { ...current.session, ...result } }\n if (!result.status || result.status === 'pending') { schedulePoll(); return }\n if (result.status === 'approved') { notice.value = '登录成功'; login.value = null; await loadOAuth(); notifyModelCatalogChanged(profile.value) }\n else error.value = result.error_message || ({ denied: '登录被拒绝', expired: '登录已过期,请重新开始' } as Record<string, string>)[result.status] || '登录失败'\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '登录状态查询失败' }\n }, 3000)\n}\nfunction beginLogin(provider: OAuthProvider) {\n if (loginFlow(provider) === 'token') { tokenProvider.value = provider.id; tokenValue.value = ''; return }\n return run(async () => {\n const session = await startOAuth(profile.value, provider.id)\n login.value = { provider: provider.id, session }\n schedulePoll()\n })\n}\nfunction cancelLogin() {\n const current = login.value\n stopPolling(); login.value = null\n if (current) void cancelOAuth(profile.value, current.provider, current.session.session_id).catch(() => undefined)\n}\nfunction submitToken() {\n return run(async () => {\n await submitOAuthToken(profile.value, tokenProvider.value, tokenValue.value)\n tokenProvider.value = ''; tokenValue.value = ''\n await loadOAuth(); notifyModelCatalogChanged(profile.value)\n }, '凭据已保存')\n}\nfunction logout(provider: OAuthProvider) {\n if (!window.confirm(`退出 ${provider.name}?`)) return\n return run(async () => { await disconnectOAuth(profile.value, provider.id); await loadOAuth(); notifyModelCatalogChanged(profile.value) }, `已退出 ${provider.name}`)\n}\n\n// ── 辅助模型 ────────────────────────────────────────────────────────────────\nconst AUX_LABELS: Record<string, [string, string]> = {\n vision: ['视觉识别', '图片理解与截图分析'],\n compression: ['上下文压缩', '长对话接近上限时整理历史'],\n approval: ['审批判断', '自动审批模式下判断命令风险'],\n mcp: ['MCP 工具', 'MCP 工具的辅助调用'],\n title_generation: ['标题生成', '为会话生成标题'],\n review: ['复核', '回合结束后的记忆与技能复核'],\n voice_chat: ['语音对话', '语音模式下的快速回复'],\n triage_specifier: ['任务分诊', '拆解并细化任务说明'],\n kanban_decomposer: ['任务拆解', '把目标拆成可执行步骤'],\n profile_describer: ['Profile 描述', '生成 Profile 简介'],\n curator: ['技能整理', '后台整理与维护技能'],\n session_search: ['会话搜索', '总结检索到的历史会话'],\n web_extract: ['网页提取', '总结抓取的网页内容'],\n}\nconst auxiliary = ref<AuxiliaryTask[]>([])\nconst auxMain = ref('')\nconst auxDrafts = ref<Record<string, { provider: string; model: string }>>({})\nconst catalog = ref<ModelCatalogProvider[]>([])\nconst allProviders = ref<Array<{ id: string; label: string }>>([])\n/** Providers with a loaded model list first, then the rest of Hermes's providers. */\nconst auxProviders = computed(() => {\n const seen = new Set(catalog.value.map(item => item.slug))\n return [...catalog.value.map(item => ({ id: item.slug, label: item.name })), ...allProviders.value.filter(item => !seen.has(item.id))]\n})\nfunction auxLabel(task: AuxiliaryTask): [string, string] { return AUX_LABELS[task.task] ?? [task.label || task.task, task.hint || ''] }\nfunction modelsFor(provider: string) { return catalog.value.find(item => item.slug === provider)?.models ?? [] }\nfunction applyAuxiliary(value: AuxiliaryModels) {\n auxiliary.value = value.tasks ?? []\n if (value.providers?.length) allProviders.value = value.providers\n auxMain.value = value.main?.model ? `${value.main.provider || ''} / ${value.main.model}` : '未设置'\n auxDrafts.value = Object.fromEntries(auxiliary.value.map(task => [task.task, { provider: task.provider || 'auto', model: task.model || '' }]))\n}\nasync function loadAuxiliary() {\n const [value, providers] = await Promise.all([getAuxiliaryModels(profile.value), listModelCatalog(profile.value).catch(() => [])])\n catalog.value = providers\n applyAuxiliary(value)\n}\nconst auxDirty = computed(() => auxiliary.value.some(task => {\n const draft = auxDrafts.value[task.task]\n return draft && (draft.provider !== (task.provider || 'auto') || (draft.provider !== 'auto' && draft.model !== (task.model || '')))\n}))\nfunction saveAuxiliary(task: AuxiliaryTask) {\n const draft = auxDrafts.value[task.task]\n if (!draft) return\n if (draft.provider !== 'auto' && !draft.model.trim()) { error.value = '请填写模型名称'; return }\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, task.task, draft.provider, draft.model.trim())), `已保存「${auxLabel(task)[0]}」`)\n}\nfunction resetAuxiliary() {\n if (!window.confirm('把全部辅助模型恢复为自动?')) return\n return run(async () => applyAuxiliary(await setAuxiliaryModel(profile.value, '__reset__', 'auto', '')), '已全部恢复为自动')\n}\n\n// ── 加载 ───────────────────────────────────────────────────────────────────\nconst modelsDirty = ref(false)\nconst dirty = computed(() => (tab.value === 'models' && modelsDirty.value) || (tab.value === 'auxiliary' && auxDirty.value) || !!editingKey.value || !!customValue.value || !!tokenValue.value)\nwatch(dirty, value => emit('dirty-change', value), { immediate: true })\n\nasync function load() {\n stopPolling(); login.value = null; editingKey.value = ''; tokenProvider.value = ''\n error.value = ''; notice.value = ''\n if (tab.value === 'models') return\n busy.value = true\n try {\n if (tab.value === 'keys') await loadCredentials()\n else if (tab.value === 'accounts') await loadOAuth()\n else await loadAuxiliary()\n } catch (cause) { error.value = cause instanceof Error ? cause.message : '读取失败' }\n finally { busy.value = false }\n}\nfunction selectTab(next: Tab) {\n if (next === tab.value) return\n if (dirty.value && !window.confirm('放弃当前未保存的更改?')) return\n modelsDirty.value = false\n tab.value = next\n}\nwatch([tab, profile], () => { void load() }, { immediate: true })\nonBeforeUnmount(stopPolling)\n</script>\n\n<template>\n <section class=\"hermes-settings\" aria-label=\"模型服务\">\n <p class=\"intro\">Hermes 已内置在夭夭服务中,这里替代原来的 Hermes Dashboard:配置模型供应商、账号登录、API Key 和辅助模型。Bot 使用所选 Profile 的这些配置。</p>\n <div class=\"toolbar\">\n <div class=\"tabs\" role=\"tablist\" aria-label=\"模型服务分类\">\n <button v-for=\"item in tabs\" :key=\"item.id\" type=\"button\" role=\"tab\" :aria-selected=\"tab === item.id\" :class=\"{ active: tab === item.id }\" @click=\"selectTab(item.id)\">{{ item.label }}</button>\n </div>\n <label v-if=\"profileOptions.length > 1\" class=\"profile-select\">Profile\n <select v-model=\"profile\" :disabled=\"busy || dirty\"><option v-for=\"name in profileOptions\" :key=\"name\" :value=\"name\">{{ name === 'default' ? 'default(系统)' : name }}</option></select>\n </label>\n </div>\n <p v-if=\"error\" class=\"panel-error\" role=\"alert\">{{ error }}</p>\n <p v-if=\"notice\" class=\"panel-notice\" role=\"status\">{{ notice }}</p>\n\n <ModelServicesPanel v-if=\"tab === 'models'\" :key=\"profile\" :profile=\"profile\" @dirty-change=\"modelsDirty = $event\" />\n\n <template v-else-if=\"tab === 'accounts'\">\n <p class=\"hint\">适用于用订阅账号或设备码登录的供应商;普通 API Key 请在「密钥与变量」中填写。</p>\n <p v-if=\"busy && !oauthProviders.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"provider in oauthProviders\" :key=\"provider.id\">\n <div class=\"row-main\">\n <strong>{{ provider.name }}</strong>\n <small :class=\"{ ok: provider.status?.logged_in }\">{{ provider.status?.logged_in ? `已登录${provider.status.source_label ? ` · ${provider.status.source_label}` : ''}${provider.status.token_preview ? ` · …${provider.status.token_preview}` : ''}` : '未登录' }}</small>\n <small v-if=\"loginFlow(provider) === 'external' && !provider.status?.logged_in\" class=\"muted\">需要在服务器上运行 <code>{{ provider.cli_command }}</code> 登录。</small>\n </div>\n <div class=\"row-actions\">\n <a v-if=\"provider.docs_url\" :href=\"provider.docs_url\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"text-button\">说明</a>\n <button v-if=\"provider.status?.logged_in && provider.disconnectable\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"logout(provider)\">退出</button>\n <button v-else-if=\"!provider.status?.logged_in && loginFlow(provider) !== 'external'\" type=\"button\" class=\"quiet-button\" :disabled=\"busy || !!login\" @click=\"beginLogin(provider)\">登录</button>\n </div>\n <div v-if=\"login?.provider === provider.id\" class=\"flow-box\">\n <p>在浏览器打开 <a :href=\"login.session.verification_url\" target=\"_blank\" rel=\"noopener noreferrer\">{{ login.session.verification_url }}</a>,输入代码:</p>\n <code class=\"user-code\">{{ login.session.user_code }}</code>\n <p class=\"muted\">完成后这里会自动更新。</p>\n <button type=\"button\" class=\"text-button\" @click=\"cancelLogin\">取消</button>\n </div>\n <form v-if=\"tokenProvider === provider.id\" class=\"flow-box\" @submit.prevent=\"submitToken\">\n <label>粘贴 API Key 或 setup-token<input v-model=\"tokenValue\" type=\"password\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"tokenProvider = ''; tokenValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !tokenValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </template>\n\n <template v-else-if=\"tab === 'keys'\">\n <div class=\"filter-row\">\n <input v-model=\"keyQuery\" type=\"search\" placeholder=\"搜索变量名、说明或供应商\" aria-label=\"搜索变量\">\n <label class=\"check\"><input v-model=\"showAdvanced\" type=\"checkbox\">显示高级项</label>\n </div>\n <p class=\"hint\">值只保存在服务器的 Hermes 数据目录,保存后不会再回传到浏览器。</p>\n <p v-if=\"busy && !credentials.length\" class=\"panel-empty\">正在读取…</p>\n <p v-else-if=\"!credentialGroups.length\" class=\"panel-empty\">没有匹配的变量。</p>\n <section v-for=\"group in credentialGroups\" :key=\"group.category\" class=\"group\">\n <h4>{{ group.label }}</h4>\n <ul class=\"rows\">\n <li v-for=\"row in group.items\" :key=\"row.key\">\n <div class=\"row-main\">\n <strong class=\"mono\">{{ row.key }}</strong>\n <small v-if=\"row.description || row.providerLabel\" class=\"muted\">{{ row.providerLabel && !row.description.includes(row.providerLabel) ? `${row.providerLabel} · ` : '' }}{{ row.description }}<a v-if=\"row.url\" :href=\"row.url\" target=\"_blank\" rel=\"noopener noreferrer\"> 获取</a></small>\n <small :class=\"{ ok: row.isSet }\">{{ row.isSet ? `已设置${row.preview ? ` · ${row.preview}` : ''}` : '未设置' }}</small>\n </div>\n <div class=\"row-actions\">\n <span v-if=\"row.readonly\" class=\"muted\">由运行环境管理</span>\n <template v-else>\n <button v-if=\"row.isSet\" type=\"button\" class=\"text-button danger\" :disabled=\"busy\" @click=\"clearCredential(row)\">清除</button>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"editCredential(row)\">{{ row.isSet ? '修改' : '设置' }}</button>\n </template>\n </div>\n <form v-if=\"editingKey === row.key\" class=\"flow-box\" @submit.prevent=\"saveCredential(row.key, editingValue)\">\n <label>{{ row.key }}<input v-model=\"editingValue\" :type=\"row.secret ? 'password' : 'text'\" autocomplete=\"off\" required :disabled=\"busy\"></label>\n <div class=\"row-actions\"><button type=\"button\" class=\"text-button\" @click=\"editingKey = ''; editingValue = ''\">取消</button><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !editingValue.trim()\">保存</button></div>\n </form>\n </li>\n </ul>\n </section>\n <form class=\"flow-box custom\" @submit.prevent=\"saveCredential(customKey.trim(), customValue)\">\n <strong>添加自定义变量</strong>\n <div class=\"form-grid\">\n <label>变量名<input v-model=\"customKey\" pattern=\"[A-Za-z_][A-Za-z0-9_]*\" placeholder=\"MY_API_KEY\" autocomplete=\"off\" :disabled=\"busy\"></label>\n <label>值<input v-model=\"customValue\" type=\"password\" autocomplete=\"off\" :disabled=\"busy\"></label>\n </div>\n <div class=\"row-actions\"><button type=\"submit\" class=\"primary-button\" :disabled=\"busy || !customKey.trim() || !customValue.trim()\">添加</button></div>\n </form>\n </template>\n\n <template v-else>\n <p class=\"hint\">辅助模型负责压缩、视觉、标题等后台任务。选「自动」时使用主模型(当前:{{ auxMain }})或 Hermes 自动选择的可用模型。</p>\n <p v-if=\"busy && !auxiliary.length\" class=\"panel-empty\">正在读取…</p>\n <ul class=\"rows\">\n <li v-for=\"task in auxiliary\" :key=\"task.task\" class=\"aux-row\">\n <div class=\"row-main\"><strong>{{ auxLabel(task)[0] }}</strong><small class=\"muted\">{{ auxLabel(task)[1] }}</small></div>\n <div v-if=\"auxDrafts[task.task]\" class=\"aux-fields\">\n <select v-model=\"auxDrafts[task.task].provider\" :aria-label=\"`${auxLabel(task)[0]} Provider`\" :disabled=\"busy\">\n <option value=\"auto\">自动</option>\n <option v-if=\"task.provider && task.provider !== 'auto' && !auxProviders.some(item => item.id === task.provider)\" :value=\"task.provider\">{{ task.provider }}</option>\n <option v-for=\"item in auxProviders\" :key=\"item.id\" :value=\"item.id\">{{ item.label }}</option>\n </select>\n <input v-if=\"auxDrafts[task.task].provider !== 'auto'\" v-model=\"auxDrafts[task.task].model\" :list=\"`aux-models-${task.task}`\" placeholder=\"模型名称\" :aria-label=\"`${auxLabel(task)[0]} 模型`\" :disabled=\"busy\">\n <datalist :id=\"`aux-models-${task.task}`\"><option v-for=\"model in modelsFor(auxDrafts[task.task].provider)\" :key=\"model\" :value=\"model\" /></datalist>\n <button type=\"button\" class=\"quiet-button\" :disabled=\"busy\" @click=\"saveAuxiliary(task)\">保存</button>\n </div>\n </li>\n </ul>\n <div v-if=\"auxiliary.length\" class=\"row-actions\"><button type=\"button\" class=\"text-button\" :disabled=\"busy\" @click=\"resetAuxiliary\">全部恢复为自动</button></div>\n </template>\n </section>\n</template>\n\n<style scoped>\n.hermes-settings{display:grid;gap:16px}\n.intro,.hint{margin:0;color:var(--text-muted);font-size:12px;line-height:1.6}\n.toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}\n.tabs{display:flex;flex-wrap:wrap;gap:4px;padding:3px;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft)}\n.tabs button{min-height:34px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:13px;font-weight:600}\n.tabs button.active{background:var(--surface-raised);color:var(--text-primary);box-shadow:0 1px 2px rgb(0 0 0 / 8%)}\n.profile-select{display:flex;align-items:center;gap:8px;color:var(--text-secondary);font-size:13px}\nselect,input:not([type=checkbox]){min-width:0;height:38px;box-sizing:border-box;padding:0 10px;border:1px solid var(--line);border-radius:9px;outline:0;background:var(--surface-raised);color:var(--text-primary);font:13px var(--font-ui)}\nselect:focus,input:focus{border-color:var(--line-strong);box-shadow:0 0 0 3px var(--focus-ring)}\n.rows{display:grid;margin:0;padding:0;list-style:none;border-top:1px solid var(--line)}\n.rows li{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;padding:14px 4px;border-bottom:1px solid var(--line)}\n.row-main{display:grid;min-width:0;flex:1;gap:4px}\n.row-main strong{font-size:14px}\n.row-main small{color:var(--text-secondary);font-size:12px;overflow-wrap:anywhere}\n.row-main small.ok{color:var(--success,#21845b)}\n.muted{color:var(--text-muted)!important;font-size:12px}\n.mono{font-family:var(--font-code);font-size:13px!important}\n.row-actions{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-end;gap:8px}\n.flow-box{display:grid;flex-basis:100%;gap:10px;padding:14px;border:1px solid var(--line-strong);border-radius:11px;background:var(--surface-soft)}\n.flow-box p{margin:0;font-size:13px}\n.flow-box label{display:grid;gap:6px;color:var(--text-secondary);font-size:13px;font-weight:600}\n.user-code{justify-self:start;padding:8px 14px;border-radius:8px;background:var(--surface-raised);font:600 20px var(--font-code);letter-spacing:.12em}\n.custom{flex-basis:auto}\n.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}\n.group h4{margin:8px 0;color:var(--text-secondary);font-size:13px}\n.filter-row{display:flex;align-items:center;gap:12px}\n.filter-row input[type=search]{flex:1}\n.check{display:flex;align-items:center;gap:6px;color:var(--text-secondary);font-size:13px;white-space:nowrap}\n.aux-fields{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.aux-fields select{width:170px}.aux-fields input{width:220px}\n.primary-button,.quiet-button{display:inline-flex;min-height:36px;align-items:center;justify-content:center;padding:0 14px;border:0;border-radius:9px;cursor:pointer;font-size:13px;font-weight:600}\n.primary-button{background:var(--accent);color:var(--text-on-solid)}\n.quiet-button{border:1px solid var(--line);background:var(--surface-raised);color:var(--text-secondary)}\n.text-button{min-height:32px;padding:0 7px;border:0;border-radius:7px;background:transparent;color:var(--text-secondary);cursor:pointer;font-size:12px;text-decoration:none;display:inline-flex;align-items:center}\n.text-button:hover{background:var(--surface-soft)}.text-button.danger{color:var(--danger)}\nbutton:disabled{cursor:wait;opacity:.5}\n.panel-error,.panel-notice,.panel-empty{margin:0;padding:11px 12px;border-radius:9px;font-size:13px}\n.panel-error{background:color-mix(in srgb,var(--danger) 8%,transparent);color:var(--danger)}\n.panel-notice{background:color-mix(in srgb,var(--success,#21845b) 9%,transparent);color:var(--success,#21845b)}\n.panel-empty{color:var(--text-muted);background:var(--surface-soft)}\ncode{font-family:var(--font-code)}\n@media(max-width:600px){.form-grid{grid-template-columns:1fr}.aux-fields,.aux-fields select,.aux-fields input{width:100%}.filter-row{flex-direction:column;align-items:stretch}.rows li{align-items:flex-start}.row-actions{width:100%}}\n</style>\n"],"mappings":"oaAAA,IAAa,EAA8B,sCAE3C,SAAgB,EAA0B,EAAuB,CAC/D,OAAO,cAAc,IAAI,YAAY,EAA6B,CAAE,OAAQ,CAAE,SAAQ,CAAE,CAAC,CAAC,CAC5F,wlCCgBA,IAAM,EAAQ,EACR,GAAO,EAmBP,GAAW,EAA0B,CAAC,CAAC,EACvC,GAAiB,EAA0B,CAAC,CAAC,EAC7C,EAAU,EAA4B,CAAC,CAAC,EACxC,EAAU,EAAI,EAAK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