release: v2.2.5 [2026-06-10 12:41:11]

### 修复
- **翰林院(RAG)API Key 污染**:
  - 修复 `saveSettingsFromUI` 无差别遍历翰林院面板内全部 `[data-setting-key]` 输入(包含被 `profile-sync` 接管隐藏的字段),导致掩码占位符 `••••••••` 被当作真值写回 `settings.rerank.apiKey` / `settings.retrieval.apiKey`,URL / model 也被 Profile 值覆盖到 legacy 字段。修复后会跳过祖先带 `data-profile-hidden` 的输入
  - `getRerankSettings` / `getEmbedRetrievalSettings` 同时加入防御性还原:识别历史污染留下的 `••••••••` 时归为空字符串,避免取消 Profile 分配后实际请求带占位符 token 被 401
---
This commit is contained in:
Jenkins CI
2026-06-10 12:41:11 +08:00
parent 347016d5ac
commit 1a4a10d42d
15 changed files with 412 additions and 25 deletions

View File

@@ -0,0 +1,63 @@
/**
* core/memory-blocks/registry.js
*
* BlockDefinition 的注册中心。所有块共享同一个全局 Map。
*
* 调用方:
* - 内置块builtin-blocks.js 在 bootstrap 时注册
* - 用户块:未来 UI / JSON 导入注册
* - 插件块:战斗系统等外部模块注册
*
* 字段校验只做最小必填检查,避免后续扩展时频繁报错。
*/
const blocks = new Map();
function validate(def) {
if (!def || typeof def !== 'object') throw new Error('[MemoryBlocks] BlockDefinition 必须是对象。');
if (!def.id) throw new Error('[MemoryBlocks] BlockDefinition.id 必填。');
if (!def.placeholder) throw new Error(`[MemoryBlocks] BlockDefinition[${def.id}].placeholder 必填。`);
if (!def.context) throw new Error(`[MemoryBlocks] BlockDefinition[${def.id}].context 必填。`);
if (!def.generator?.type) throw new Error(`[MemoryBlocks] BlockDefinition[${def.id}].generator.type 必填。`);
}
export function register(def) {
validate(def);
blocks.set(def.id, { enabled: true, ...def });
}
export function unregister(id) {
return blocks.delete(id);
}
export function getById(id) {
return blocks.get(id) ?? null;
}
export function listByContext(context) {
const out = [];
for (const b of blocks.values()) {
if (b.context === context && b.enabled !== false) out.push(b);
}
out.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
return out;
}
export function listAll() {
return [...blocks.values()];
}
export function clear() {
blocks.clear();
}
/** 批量替换(用于 JSON 导入时整体覆盖某 context 下的块) */
export function replaceContextBlocks(context, defs) {
for (const [id, b] of blocks) {
if (b.context === context) blocks.delete(id);
}
for (const d of defs) {
if (d.context !== context) continue; // 防止越界注册
register(d);
}
}