release: v2.2.6 [2026-06-13 20:26:41]

### 新功能
- **翰林院向量化质量升级**:
  - **边界感知切块**:替换四个来源(聊天记录/小说/世界书/手动)的纯字符硬切——优先在段落边界断开,其次句末标点(含中文引号闭合),极端长串才硬切;句子/对话不再被拦腰截断,embedding 质量同步受益。仅影响新录入,已有向量无需重建
  - **注入时序重排**:检索结果注入提示词前按时序重排(聊天记录按楼层、小说按卷/章/节——中文数字章节号可解析),rerank 只决定"选哪些块",不再决定呈现顺序;修复"不打不相识的剧情之后紧跟关系亲密"这类因按相关度排序导致的认知时间错乱
  - **断层提示**:聊天记录相邻块楼层跳跃时自动插入"与上文相隔约 N 楼,并非连续发生"提示行,消除中间剧情缺失造成的割裂感
  - **时间标识**:新录入的聊天记录块在来源标识中带上消息发送时间(ST 向量存储不持久化元数据,时间必须写入块文本才能在检索后取回;旧格式块兼容解析)
- **记忆块工作流(memory-blocks)**:剧情优化新增"自定义记忆块"体系——占位符驱动的并发工作流框架
  - 在剧情优化面板「匹配替换 (sulv)」下方可增删自定义块:每个块定义一个占位符,执行剧情优化时主/拦截提示词中的占位符会被块的产出替换
  - **静态块**:直接输出固定内容;**AI 调用块**:用所选 API 功能槽独立请求一次,把回复(或其中指定 `<标签>` 的内容)作为替换值
  - 原有 sulv1-4 速率占位符迁入同一框架,行为与旧版逐字节一致
  - 块定义为纯 JSON、随设置持久化,为后续导入导出与战斗系统接入预留扩展点
  - 框架层新增**顺序拼接式 Chain**(`composeChain`):与占位符替换并列的第二种组合范式——同链的块并发执行后按 `order` 排序、以 `separator` 拼接并可选 `header/footer` 包裹,产出一个完整注入块;为记忆注入合成块与战斗系统"底部战报块"预留的承载结构,本版本暂无 UI 入口
- **渐进记忆(开发中功能,暂未对外开放)**:主菜单新增独立入口(点击提示"开发中,未来版本开放"),后续完善后放出。当前已落地的设计:
  - 按"近期完整、远期摘要"的时间梯度,从指定表格(默认总结表,行序旧→新)采样历史并注入上下文:最新 X 行全量保留 + 其余历史对半拆分,较近一半等距取 Y 行、较远一半等距取 Z 行(中心对齐等距采样,不随机、不首尾加权,避免内容扎堆或事件结局被规律性忽略)
  - 经 `setExtensionPrompt` 直接注入当回合上下文——内容独立、不写世界书、不随聊天/角色卡导出,生命周期天然跟随会话(区别于超级记忆的世界书条目路线)
  - 注入位置 / 深度 / 角色 / 模板(含 `{{progressive_memory}}` 占位符)均可在面板配置;采样参数 X/Y/Z 默认 5/5/3,全部纯 JSON 持久化
  - 采样器 `sampler.js` 为纯函数,参数结构与 memory-blocks 工作链对齐,后续可平移为 `progressive_sample` 节点
- **超级记忆 · 首行常驻**(表格专属配置新增开关,默认关闭):表格第一行通常是总调/全局定义行(基调、主线目标等),原先与普通行一样走绿灯——没人提到主键就永远不注入;开启后该行详情条目升为蓝灯常驻,切换即时生效
- **API 连接配置**:
  - 角色世界书(cwb)与一键生卡(autoCharCard)纳入旧配置自动迁移:老用户首次加载会把旧 URL / Key / 模型自动迁移为连接配置并分配槽位(一键生卡仅在规划者与执行者配置一致或规划者为空时迁移,避免悄悄改变行为)
  - **profile 已分配时参数控件 informational 化**:主面板 / 并发剧情优化 / 角色世界书 / 术语表的温度、maxTokens 控件在槽位分配 profile 后自动禁用并显示"由连接配置控制"提示,消除"改了没效果"的用户陷阱
  - **profile 状态卡新增"本设备无 Key"警示**:API Key 仅保存在最初填写它的设备/浏览器上(安全设计,不随云端设置同步),换设备后状态卡会直接亮出警示徽标,不必等到调用报错才发现
### 修复
- **独立聊天记忆从摆设变真功能**:此前向量数据"随卡不随聊天"——开启"独立聊天记忆"后录入仍存进角色库、查询却去查一个从未被写入过的聊天集合、计数恒为 0,整体静默失效。现已重构为聊天级分桶:
  - 独立模式下,聊天记录类向量按当前聊天隔离存储与检索,同一张卡开多个聊天(不同剧情线)的记忆互不污染
  - 小说 / 世界书 / 手动录入属于"知识",仍随角色卡跨聊天共享;全局库不受影响
  - 知识管理列表为聊天专属库显示"聊天级"徽标;聊天级库禁止移动到全局
  - 统一模式(默认关闭独立记忆)的存量数据与行为完全不变
  - 已知限制:聊天专属记忆跟随聊天文件,重命名聊天文件会使其失联(与 ST 官方向量扩展同等限制)
- **超级排序截断顺序修正**:开启"超级排序"时,时序重排发生在 top_n 截断之前,导致保留的是"时序最早"而非"最相关"的块,检索结果长期偏向最旧的聊天记录。现改为先按相关度截取 top_n、再做时序排序
- **翰林院向量化失败("向量化块数量不识别"反馈)**:
  - 一次性清洗 profile-sync 历史污染:`retrieval/rerank.apiKey` 中的掩码占位符在持久层根治(此前仅读取侧防御);`apiEndpoint` / `rerank.apiMode` 的非法值(如被旧版写入的空字符串)归一化为 `custom`
  - 修复 `apiEndpoint` 为空/非法时请求被硬定向到 `api.openai.com`、无视用户自定义 URL 的问题(CSP 拦截 / 401 的元凶)
  - 修复**本地代理(LM Studio/Ollama)模式**自始就缺少 URL 分支、同样被错误定向到 openai.com 的问题
  - API 模式下拉补全 `OpenAI 官方` / `Azure` 选项;默认 API 模式改为 `custom`(与默认 URL 配套),新用户不再因选项缺失导致首次保存写入空值
  - profile-sync 给下拉框赋不存在选项值的污染源头修复(影响所有模块面板,不止翰林院)
- **Rerank "测试成功但实际请求报 API Key 未提供"(路径分叉根因)**:实际重排调用 `executeRerank(query, docs, settings.rerank)` 直接把 legacy 嵌套设置当连接传入,绕过了 `getRerankSettings()` 的 profile 解析;而「测试连接」传 `null` 会正常解析 profile——于是用 API Profile 配 rerank 的用户测试通过、实际生成时却拿到空 apiKey/stale url 报错。现实际调用点统一走 `getRerankSettings()`(profile 优先、legacy 兜底),与测试路径一致;`enabled / notify / hybrid_alpha` 等行为开关仍读 legacy 设置
- **Rerank "API Key 未提供"报错升级**:当原因是"连接配置在本设备没有可用 Key"时,报错会直接说明 Key 的设备本地性并指引到 API 连接配置重新填写(向量化 Google 直连、获取模型列表同步处理)
- **旧配置迁移**:一键生卡迁移时排除掩码占位符,避免把历史污染的假 Key 迁入新连接配置
- **超级记忆稳定性专项**(针对"工作不大稳定"反馈,4 处根因一次修复):
  - **切聊天竞态污染**:CHAT_CHANGED 时超级记忆立即全量同步,而表格系统延迟 100ms 才加载新聊天的表格,导致【旧聊天】的表格内容被写进【新角色】的记忆世界书;两边表名不同时旧表条目无 GC 兜底会**永久残留**("记忆串台"元凶)。现 CHAT_CHANGED 只确保世界书存在,新状态同步交由 `loadTables()` 完成后的自动推送,单次且时序正确
  - **死代码双轨存储拆除**:`saveStateToMetadata` / `tryRestoreStateFromMetadata` 把表格状态写到 `msg.metadata`——该字段非 ST 持久化位(同 v2.2.5 二次填表修过的坑),写入即蒸发、恢复永远为空,且每次同步还白调一次 `saveChat()`。整条链路删除,表格状态唯一信源为表格系统的 `msg.extra.amily2_tables_data`
  - **`awaitSync()` 穿透**:同步队列正忙时 `pushUpdate` 会用一个立即 resolve 的空 Promise 覆盖 `_syncPromise`,Pipeline Stage 4 等待形同虚设、后续阶段在同步未完成时被放行。现忙时不覆盖,正在运行的 drain 循环自然吃掉新入队项
  - **开关打开不生效**:启动时若总开关为关,初始化早退且不注册监听器;此后在 UI 勾选开关只写设置,超级记忆直到刷新页面前都是死的。现勾选即触发初始化(幂等)
  - 附带:`forceSyncAll` 的表格角色推断改为复用 `events-schema.inferTableRole`,消除两处重复逻辑漂移风险;每次切聊天的双倍全量同步(restore 路径一次 + 显式一次)随死代码移除归一
### 重构
- 表格核心 `manager.js` 瘦身(约 1050 → 600 行):19 个 UI 突变操作拆分至 `actions/ui-mutations.js`,SuperMemory 事件分发拆分至 `events-dispatch.js`;全部经 re-export 保持兼容,外部调用路径零改动
- 角色世界书最后 2 处散乱的厂商 URL 判断迁移至 `detectVendor` 统一入口,业务路径上不再有硬编码的 URL substring 判断
This commit is contained in:
Jenkins CI
2026-06-13 20:26:41 +08:00
parent 0d7e3b799e
commit 2dad292d70
19 changed files with 505 additions and 36 deletions

View File

@@ -110,6 +110,12 @@
- 原有 sulv1-4 速率占位符迁入同一框架,行为与旧版逐字节一致
- 块定义为纯 JSON、随设置持久化为后续导入导出与战斗系统接入预留扩展点
- 框架层新增**顺序拼接式 Chain**`composeChain`):与占位符替换并列的第二种组合范式——同链的块并发执行后按 `order` 排序、以 `separator` 拼接并可选 `header/footer` 包裹,产出一个完整注入块;为记忆注入合成块与战斗系统"底部战报块"预留的承载结构,本版本暂无 UI 入口
- **渐进记忆(开发中功能,暂未对外开放)**:主菜单新增独立入口(点击提示"开发中,未来版本开放"),后续完善后放出。当前已落地的设计:
- 按"近期完整、远期摘要"的时间梯度,从指定表格(默认总结表,行序旧→新)采样历史并注入上下文:最新 X 行全量保留 + 其余历史对半拆分,较近一半等距取 Y 行、较远一半等距取 Z 行(中心对齐等距采样,不随机、不首尾加权,避免内容扎堆或事件结局被规律性忽略)
-`setExtensionPrompt` 直接注入当回合上下文——内容独立、不写世界书、不随聊天/角色卡导出,生命周期天然跟随会话(区别于超级记忆的世界书条目路线)
- 注入位置 / 深度 / 角色 / 模板(含 `{{progressive_memory}}` 占位符)均可在面板配置;采样参数 X/Y/Z 默认 5/5/3全部纯 JSON 持久化
- 采样器 `sampler.js` 为纯函数,参数结构与 memory-blocks 工作链对齐,后续可平移为 `progressive_sample` 节点
- **超级记忆 · 首行常驻**(表格专属配置新增开关,默认关闭):表格第一行通常是总调/全局定义行(基调、主线目标等),原先与普通行一样走绿灯——没人提到主键就永远不注入;开启后该行详情条目升为蓝灯常驻,切换即时生效
- **API 连接配置**
- 角色世界书cwb与一键生卡autoCharCard纳入旧配置自动迁移老用户首次加载会把旧 URL / Key / 模型自动迁移为连接配置并分配槽位(一键生卡仅在规划者与执行者配置一致或规划者为空时迁移,避免悄悄改变行为)
- **profile 已分配时参数控件 informational 化**:主面板 / 并发剧情优化 / 角色世界书 / 术语表的温度、maxTokens 控件在槽位分配 profile 后自动禁用并显示"由连接配置控制"提示,消除"改了没效果"的用户陷阱
@@ -117,7 +123,7 @@
### 修复
- **独立聊天记忆从摆设变真功能(原作遗留坑)**:此前向量数据"随卡不随聊天"——开启"独立聊天记忆"后录入仍存进角色库、查询却去查一个从未被写入过的聊天集合、计数恒为 0整体静默失效。现已重构为聊天级分桶
- **独立聊天记忆从摆设变真功能**:此前向量数据"随卡不随聊天"——开启"独立聊天记忆"后录入仍存进角色库、查询却去查一个从未被写入过的聊天集合、计数恒为 0整体静默失效。现已重构为聊天级分桶
- 独立模式下,聊天记录类向量按当前聊天隔离存储与检索,同一张卡开多个聊天(不同剧情线)的记忆互不污染
- 小说 / 世界书 / 手动录入属于"知识",仍随角色卡跨聊天共享;全局库不受影响
- 知识管理列表为聊天专属库显示"聊天级"徽标;聊天级库禁止移动到全局
@@ -130,6 +136,7 @@
- 修复**本地代理LM Studio/Ollama模式**自始就缺少 URL 分支、同样被错误定向到 openai.com 的问题
- API 模式下拉补全 `OpenAI 官方` / `Azure` 选项;默认 API 模式改为 `custom`(与默认 URL 配套),新用户不再因选项缺失导致首次保存写入空值
- profile-sync 给下拉框赋不存在选项值的污染源头修复(影响所有模块面板,不止翰林院)
- **Rerank "测试成功但实际请求报 API Key 未提供"(路径分叉根因)**:实际重排调用 `executeRerank(query, docs, settings.rerank)` 直接把 legacy 嵌套设置当连接传入,绕过了 `getRerankSettings()` 的 profile 解析;而「测试连接」传 `null` 会正常解析 profile——于是用 API Profile 配 rerank 的用户测试通过、实际生成时却拿到空 apiKey/stale url 报错。现实际调用点统一走 `getRerankSettings()`profile 优先、legacy 兜底),与测试路径一致;`enabled / notify / hybrid_alpha` 等行为开关仍读 legacy 设置
- **Rerank "API Key 未提供"报错升级**:当原因是"连接配置在本设备没有可用 Key"时,报错会直接说明 Key 的设备本地性并指引到 API 连接配置重新填写(向量化 Google 直连、获取模型列表同步处理)
- **旧配置迁移**:一键生卡迁移时排除掩码占位符,避免把历史污染的假 Key 迁入新连接配置
- **超级记忆稳定性专项**(针对"工作不大稳定"反馈4 处根因一次修复):

View File

@@ -0,0 +1,22 @@
import { Module, ModuleBuilder } from './Module.js';
import { bindProgressiveMemoryEvents } from '../../core/progressive-memory/bindings.js';
const builder = new ModuleBuilder()
.name('ProgressiveMemory')
.view('core/progressive-memory/index.html')
.strict(true)
.required(['mount']);
export default class ProgressiveMemoryModule extends Module {
constructor() {
super(builder);
}
async mount() {
if (this.el) {
this.el.id = 'amily2_progressive_memory_panel';
this.el.style.display = 'none';
}
bindProgressiveMemoryEvents();
}
}

View File

@@ -19,6 +19,7 @@ import WorldEditorModule from './WorldEditorModule.js';
import GlossaryModule from './GlossaryModule.js';
import RendererModule from './RendererModule.js';
import SuperMemoryModule from './SuperMemoryModule.js';
import ProgressiveMemoryModule from './ProgressiveMemoryModule.js';
import ApiConfigModule from './ApiConfigModule.js';
import RuleConfigModule from './RuleConfigModule.js';
import SfiGenModule from './SfiGenModule.js';
@@ -34,6 +35,7 @@ export function registerAllModules() {
registry.register('Glossary', () => new GlossaryModule());
registry.register('Renderer', () => new RendererModule());
registry.register('SuperMemory', () => new SuperMemoryModule());
registry.register('ProgressiveMemory', () => new ProgressiveMemoryModule());
registry.register('ApiConfig', () => new ApiConfigModule());
registry.register('RuleConfig', () => new RuleConfigModule());
registry.register('SfiGen', () => new SfiGenModule());

View File

@@ -237,6 +237,9 @@
<button id="amily2_open_super_memory" class="menu_button wide_button"><i class="fas fa-brain"></i> 超级记忆</button>
<button id="amily2_open_auto_char_card" class="menu_button wide_button"><i class="fas fa-robot"></i> 一键生卡</button>
</div>
<div class="button-group" style="display: flex; justify-content: space-between; gap: 8px; margin-top: 8px;">
<button id="amily2_open_progressive_memory" class="menu_button wide_button"><i class="fas fa-layer-group"></i> 渐进记忆</button>
</div>
</fieldset>
<fieldset class="settings-group">

View File

@@ -0,0 +1,88 @@
/**
* core/progressive-memory/bindings.js
*
* 渐进记忆面板的 UI 事件绑定与设置回填。
* 设置统一存 extension_settings[extensionName].progressive_memory纯 JSON
*/
import { extension_settings } from "/scripts/extensions.js";
import { saveSettingsDebounced } from "/script.js";
import { extensionName } from "../../utils/settings.js";
import { progressiveMemoryDefaults } from "./engine.js";
function getStore() {
if (!extension_settings[extensionName]) extension_settings[extensionName] = {};
const root = extension_settings[extensionName];
if (!root.progressive_memory) {
root.progressive_memory = structuredClone(progressiveMemoryDefaults.progressive_memory);
}
// 补齐缺失键(旧存档或部分写入)
root.progressive_memory = {
...structuredClone(progressiveMemoryDefaults.progressive_memory),
...root.progressive_memory,
injection: {
...progressiveMemoryDefaults.progressive_memory.injection,
...(root.progressive_memory.injection || {}),
},
};
return root.progressive_memory;
}
export function bindProgressiveMemoryEvents() {
const panel = $('#amily2_progressive_memory_panel');
if (panel.length === 0) return;
panel.on('change', '#pm-enabled', function () {
getStore().enabled = this.checked;
saveSettingsDebounced();
});
panel.on('change', '#pm-target-table', function () {
getStore().targetTable = this.value.trim() || '总结表';
saveSettingsDebounced();
});
const numMap = {
'pm-recent': 'recentCount',
'pm-mid': 'midCount',
'pm-far': 'farCount',
};
panel.on('change', '#pm-recent, #pm-mid, #pm-far', function () {
getStore()[numMap[this.id]] = Math.max(0, parseInt(this.value, 10) || 0);
saveSettingsDebounced();
});
panel.on('change', '#pm-inj-position', function () {
getStore().injection.position = Math.max(0, parseInt(this.value, 10) || 0);
saveSettingsDebounced();
});
panel.on('change', '#pm-inj-depth', function () {
getStore().injection.depth = Math.max(0, parseInt(this.value, 10) || 0);
saveSettingsDebounced();
});
panel.on('change', '#pm-inj-role', function () {
getStore().injection.role = parseInt(this.value, 10) || 0;
saveSettingsDebounced();
});
panel.on('change', '#pm-template', function () {
getStore().template = this.value;
saveSettingsDebounced();
});
loadProgressiveMemorySettings();
console.log('[Amily2-渐进记忆] 事件绑定完成。');
}
function loadProgressiveMemorySettings() {
const s = getStore();
$('#pm-enabled').prop('checked', s.enabled === true);
$('#pm-target-table').val(s.targetTable);
$('#pm-recent').val(s.recentCount);
$('#pm-mid').val(s.midCount);
$('#pm-far').val(s.farCount);
$('#pm-inj-position').val(s.injection.position);
$('#pm-inj-depth').val(s.injection.depth);
$('#pm-inj-role').val(String(s.injection.role));
$('#pm-template').val(s.template);
}

View File

@@ -0,0 +1,141 @@
/**
* core/progressive-memory/engine.js
*
* 渐进记忆(内测)注入引擎。
*
* 与超级记忆(写世界书条目)不同,本模块通过 setExtensionPrompt 直接把采样结果
* 注入到当回合上下文——内容独立、不落世界书、不随聊天/角色卡导出,生命周期天然
* 跟随会话。数据源为某张追加式表格(默认「总结表」),按时间梯度采样:
* 最新 X 行全量 + 历史对半拆,较近一半等距取 Y 行、较远一半等距取 Z 行。
*
* 权限开发中功能plugin_user_type >= 3 方可生效(未来版本对外开放)。
*
* 设计为纯数据驱动:所有参数存 extension_settings[extensionName].progressive_memory
* 采样逻辑委托 sampler.js纯函数后续可平移为 memory-blocks 工作链节点。
*/
import { setExtensionPrompt } from "/script.js";
import { extension_settings, getContext } from "/scripts/extensions.js";
import { extensionName } from "../../utils/settings.js";
import { getMemoryState } from "../table-system/manager.js";
import { sampleProgressive } from "./sampler.js";
const INJECTION_KEY = "AMILY2_PROGRESSIVE_MEMORY";
const PLACEHOLDER = "{{progressive_memory}}";
export const progressiveMemoryDefaults = {
progressive_memory: {
enabled: false,
targetTable: "总结表",
recentCount: 5,
midCount: 5,
farCount: 3,
// 注入模板:占位符 {{progressive_memory}} 处填入采样后的行文本
template:
"##以下是按时间梯度回顾的历史记忆(近期完整、远期摘要,时间从旧到新),作为后续剧情的连续性参考:\n{{progressive_memory}}",
injection: { position: 1, depth: 0, role: 0 },
},
};
function getSettings() {
const root = extension_settings[extensionName] || {};
return { ...progressiveMemoryDefaults.progressive_memory, ...(root.progressive_memory || {}) };
}
function isAuthorized() {
return parseInt(localStorage.getItem("plugin_user_type") || "0") >= 3;
}
/** 把单行渲染为 `- 列名: 值` 块,与超级记忆详情条目格式一致,便于 AI 解析。 */
function renderRow(row, headers, tableName) {
let finalHeaders = headers;
if (!finalHeaders || finalHeaders.length < row.length) {
finalHeaders = [];
for (let i = 0; i < row.length; i++) {
finalHeaders.push((headers && headers[i]) ? headers[i] : `Col_${i}`);
}
}
let out = `${tableName} · ${row[0] || "?"}\n`;
for (let i = 0; i < row.length; i++) {
out += `- ${finalHeaders[i] || `Col_${i}`}: ${row[i] ?? ""}\n`;
}
return out.trim();
}
/**
* 构建注入文本。返回 '' 表示无需注入(未启用 / 无权限 / 无数据)。
*/
export function buildProgressiveInjection() {
if (!isAuthorized()) return "";
const s = getSettings();
if (!s.enabled) return "";
const tables = getMemoryState();
if (!Array.isArray(tables) || tables.length === 0) return "";
const table = tables.find(t => t.name === s.targetTable);
if (!table || !Array.isArray(table.rows) || table.rows.length === 0) return "";
const headers = table.headers || [];
const rowStatuses = table.rowStatuses || [];
// 候选行:有主键、非删除中
const candidates = [];
table.rows.forEach((row, index) => {
if (!row || row.length === 0) return;
const primary = row[0];
if (primary === undefined || primary === null || String(primary).trim() === "") return;
if (rowStatuses[index] === "pending-deletion") return;
candidates.push(row);
});
if (candidates.length === 0) return "";
const picked = sampleProgressive(candidates.length, {
recentCount: s.recentCount,
midCount: s.midCount,
farCount: s.farCount,
});
if (picked.length === 0) return "";
const body = picked.map(pos => renderRow(candidates[pos], headers, s.targetTable)).join("\n\n");
const template = s.template || PLACEHOLDER;
return template.includes(PLACEHOLDER) ? template.replace(PLACEHOLDER, body) : `${template}\n${body}`;
}
/**
* 执行注入。由统一注入周期executeAmily2Injection调用。
* @param {string} [type] 'quiet' 时跳过(与表格注入器一致)
*/
export function injectProgressiveMemory(type) {
try {
if (type === "quiet") return;
const content = buildProgressiveInjection();
if (!content) {
setExtensionPrompt(INJECTION_KEY, "", 0, 0, false, 0);
return;
}
const s = getSettings();
const inj = s.injection || {};
setExtensionPrompt(
INJECTION_KEY,
content,
parseInt(inj.position ?? 1, 10),
parseInt(inj.depth ?? 0, 10),
false,
parseInt(inj.role ?? 0, 10),
);
console.log(`[Amily2-渐进记忆] 已注入 (position:${inj.position}, depth:${inj.depth}, role:${inj.role})。`);
} catch (error) {
console.error("[Amily2-渐进记忆] 注入失败:", error);
}
}
export function clearProgressiveMemoryInjection() {
try {
setExtensionPrompt(INJECTION_KEY, "", 0, 0, false, 0);
} catch { /* ST 未就绪时静默 */ }
}

View File

@@ -0,0 +1,76 @@
<div class="amily2-header">
<div class="additional-features-title interactable" title="Amily2 渐进记忆(内测)">
<i class="fas fa-layer-group"></i> 渐进记忆 <span style="font-size: 0.6em; color: #ffc107; vertical-align: super;">BETA</span>
</div>
<button id="amily2_back_to_main_from_progressive_memory" class="menu_button secondary small_button interactable">
返回主殿 <i class="fas fa-arrow-right"></i>
</button>
</div>
<hr class="header-divider">
<div id="pm-modal-container">
<div class="sm-intro-box">
<h3><i class="fas fa-layer-group"></i> 渐进记忆 (Progressive Memory)</h3>
<p>按"近期完整、远期摘要"的时间梯度,从指定表格采样历史并注入上下文——模拟人类记忆衰减,在有限 Token 内兼顾最近连贯与长期回顾。</p>
<p style="color: #ffc107; font-size: 0.9em;"><i class="fas fa-flask"></i> 内测功能:注入内容直达上下文、不写世界书、不随聊天导出,仅当回合生效。</p>
</div>
<fieldset class="sm-settings-group">
<legend><i class="fas fa-cogs"></i> 基础设置</legend>
<div class="sm-control-block">
<label>启用渐进记忆 (总开关):</label>
<label class="sm-toggle-switch">
<input type="checkbox" id="pm-enabled">
<span class="sm-slider"></span>
</label>
</div>
<div class="sm-control-block">
<label title="作为采样数据源的表格名称,需为追加式表格(行序从旧到新),推荐总结表">数据源表格:</label>
<input type="text" id="pm-target-table" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px;" value="总结表">
</div>
</fieldset>
<fieldset class="sm-settings-group">
<legend><i class="fas fa-sliders-h"></i> 采样参数</legend>
<div class="sm-control-block">
<label title="最新 N 行全量保留(最近发生的事,完整保真)">近期全量行数 (X):</label>
<input type="number" id="pm-recent" min="0" step="1" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 80px;" value="5">
</div>
<div class="sm-control-block">
<label title="除近期外的历史对半拆分,较近的一半(中区)等距取 N 行">中区采样行数 (Y):</label>
<input type="number" id="pm-mid" min="0" step="1" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 80px;" value="5">
</div>
<div class="sm-control-block">
<label title="历史较远的一半(远区)等距取 N 行">远区采样行数 (Z):</label>
<input type="number" id="pm-far" min="0" step="1" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 80px;" value="3">
</div>
<small style="color: #888; font-size: 0.8em; display: block; margin-top: -5px; margin-bottom: 10px; padding-left: 5px;">
行序按时间从旧到新:最新 X 行全量;其余历史对半拆,较近一半等距取 Y 行、较远一半等距取 Z 行(中心对齐等距采样,不随机、不首尾加权,避免内容扎堆或事件结局被规律性忽略)。
</small>
</fieldset>
<fieldset class="sm-settings-group">
<legend><i class="fas fa-syringe"></i> 注入设置</legend>
<div class="sm-control-block">
<label title="注入位置0=系统提示前1=系统提示后(@D 注入用深度控制)">注入位置 (position):</label>
<input type="number" id="pm-inj-position" min="0" max="1" step="1" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 80px;" value="1">
</div>
<div class="sm-control-block">
<label title="注入深度楼层0 = 最底部">注入深度 (depth):</label>
<input type="number" id="pm-inj-depth" min="0" step="1" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 80px;" value="0">
</div>
<div class="sm-control-block">
<label title="注入角色0=系统1=用户2=AI">注入角色 (role):</label>
<select id="pm-inj-role" class="text_pole" style="background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; width: 100px;">
<option value="0">系统</option>
<option value="1">用户</option>
<option value="2">AI</option>
</select>
</div>
<div class="sm-control-block" style="display: block;">
<label title="占位符 {{progressive_memory}} 会被替换为采样后的行文本">注入模板:</label>
<textarea id="pm-template" rows="4" style="width: 100%; margin-top: 5px; background: rgba(0, 0, 0, 0.3); border: 1px solid #444; color: #e0e0e0; padding: 5px; border-radius: 4px; box-sizing: border-box;"></textarea>
<small style="color: #888; font-size: 0.8em; display: block; margin-top: 3px;">必须包含占位符 <code>{{progressive_memory}}</code>;缺失时采样内容会追加到模板末尾。</small>
</div>
</fieldset>
</div>

View File

@@ -0,0 +1,69 @@
/**
* core/progressive-memory/sampler.js
*
* 渐进式记忆采样(梯度记忆):行序假定为 旧 → 新(追加式表格,如总结表)。
*
* [───── 远区(历史前 50%)─────][───── 中区(历史后 50%)─────][最新 recentCount 行]
* 等距取 farCount 行 等距取 midCount 行 全量保留
*
* 设计约束(与用户确认):
* - 不随机、不首尾加权——等距(中心对齐)抽样,时间分布均匀、结果可预期,
* 避免内容扎堆在某段时期或事件结局被采样规律性忽略。
* - 参数为纯 JSONrecentCount / midCount / farCount后续可直接作为
* memory-blocks 工作链的 progressive_sample 节点参数平移。
*
* 本模块只做"选哪些行"的纯计算,不涉及渲染与世界书写入。
*/
/**
* 中心对齐等距抽样:从长度 length 的区间内取 count 个索引。
* 取样点 = floor((i + 0.5) * length / count),使样本落在各等分段的中点,
* 避免"恒取区间开头/结尾"造成的边界偏置。
*
* @param {number} length 区间长度
* @param {number} count 期望取样数
* @returns {number[]} 升序、去重后的区间内偏移索引0-based
*/
export function evenIndices(length, count) {
if (length <= 0 || count <= 0) return [];
if (count >= length) return Array.from({ length }, (_, i) => i);
const out = new Set();
for (let i = 0; i < count; i++) {
out.add(Math.floor((i + 0.5) * length / count));
}
return [...out].sort((a, b) => a - b);
}
/**
* 渐进式采样主入口。
*
* @param {number} totalCount 候选行总数(已过滤掉删除中/无主键的行之后)
* @param {{ recentCount?: number, midCount?: number, farCount?: number }} [params]
* @returns {number[]} 升序的入选行索引相对候选序列0 = 最旧)
*/
export function sampleProgressive(totalCount, params = {}) {
const recentCount = Math.max(0, params.recentCount ?? 5);
const midCount = Math.max(0, params.midCount ?? 5);
const farCount = Math.max(0, params.farCount ?? 3);
if (totalCount <= 0) return [];
const picked = new Set();
// 最新 recentCount 行全量
const recent = Math.min(recentCount, totalCount);
const recentStart = totalCount - recent;
for (let i = recentStart; i < totalCount; i++) picked.add(i);
// 历史区 [0, recentStart),对半拆:前半=远区,后半=中区(更靠近现在)
const histLen = recentStart;
if (histLen > 0) {
const farLen = Math.floor(histLen / 2);
const midLen = histLen - farLen;
for (const offset of evenIndices(midLen, midCount)) picked.add(farLen + offset);
for (const offset of evenIndices(farLen, farCount)) picked.add(offset);
}
return [...picked].sort((a, b) => a - b);
}

View File

@@ -21,6 +21,7 @@ import {
fetchEmbeddingModels as apiFetchEmbeddingModels,
fetchRerankModels as apiFetchRerankModels,
executeRerank,
getRerankSettings,
testApiConnection as apiTestApiConnection
} from './rag-api.js';
import { superSort } from './super-sorter.js';
@@ -1535,7 +1536,13 @@ async function rerankResults(allResults, queryText, settings) {
console.log('[翰林院-Rerank] 开始外部API重排序...');
try {
const documentsToRerank = allResults.map(res => res.text);
const rerankedData = await executeRerank(queryText, documentsToRerank, settings.rerank);
// 【修复】实际重排必须走 getRerankSettings() 解析连接profile 优先、legacy 兜底),
// 与「测试连接」路径一致。旧代码直接传 settings.reranklegacy 嵌套对象),
// 在用户用 API Profile 配 rerank 时其 apiKey/url/model 是空/stale 的——
// 导致测试连接成功、实际请求却报「Rerank API Key 未提供」。
// enabled / notify / hybrid_alpha 等行为开关仍读 legacy settings.rerank。
const rerankConn = await getRerankSettings();
const rerankedData = await executeRerank(queryText, documentsToRerank, rerankConn);
const indexedResults = allResults.map((res, index) => ({ ...res, original_index: index }));
processedResults = indexedResults.map(result => {

View File

@@ -1,7 +1,7 @@
import { extensionName } from "../../utils/settings.js";
import { extension_settings } from "/scripts/extensions.js";
import { saveSettingsDebounced } from "/script.js";
import { initializeSuperMemory, purgeSuperMemory } from "./manager.js";
import { initializeSuperMemory, purgeSuperMemory, forceSyncAll } from "./manager.js";
import { defaultSettings as ragDefaultSettings } from "../rag-settings.js";
import { getMemoryState } from "../table-system/manager.js";
@@ -116,7 +116,7 @@ export function bindSuperMemoryEvents() {
}
const tableName = $(this).data('table');
const type = $(this).data('type'); // 'sync' or 'constant'
const type = $(this).data('type'); // 'sync' | 'constant' | 'pinFirstRow'
const checked = this.checked;
if (!extension_settings[extensionName].superMemory_tableSettings[tableName]) {
@@ -125,6 +125,8 @@ export function bindSuperMemoryEvents() {
extension_settings[extensionName].superMemory_tableSettings[tableName][type] = checked;
saveSettingsDebounced();
// 立即应用:首行常驻切换需要把该行详情条目在 蓝灯/绿灯 之间重写
forceSyncAll();
console.log(`[Amily2-SuperMemory] Table setting updated: ${tableName}.${type} = ${checked}`);
});
@@ -150,9 +152,10 @@ function renderTableSettingsList() {
const tableName = table.name;
const tableConfig = settings[tableName] || {};
// Default values: Sync=True, Constant=True
const isSyncEnabled = tableConfig.sync !== false;
// Default values: Sync=True, Constant=True; PinFirstRow=False
const isSyncEnabled = tableConfig.sync !== false;
const isConstant = tableConfig.constant !== false;
const isPinFirstRow = tableConfig.pinFirstRow === true;
html += `
<div class="sm-control-block" style="border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; margin-bottom: 10px;">
@@ -173,6 +176,15 @@ function renderTableSettingsList() {
<span style="font-size: 0.9em; color: #ccc;">索引绿灯(常驻)</span>
</div>
</div>
<div style="display: flex; justify-content: flex-start; margin-top: 5px;">
<div style="display: flex; align-items: center;">
<label class="sm-toggle-switch" style="transform: scale(0.8); margin-right: 5px;">
<input type="checkbox" class="sm-table-setting-check" data-table="${tableName}" data-type="pinFirstRow" ${isPinFirstRow ? 'checked' : ''}>
<span class="sm-slider"></span>
</label>
<span style="font-size: 0.9em; color: #ccc;" title="第一行通常是总调/全局定义行,开启后升为常驻注入,不再依赖关键词触发">首行常驻</span>
</div>
</div>
</div>
`;
});

View File

@@ -35,8 +35,19 @@ async function _doEnsureBook(bookName) {
}
}
export async function syncToLorebook(tableName, data, indexText, role, headers, rowStatuses, depth = 100, isIndexConstant = true) {
console.log(`[Amily2-Bridge] 开始同步表格: ${tableName} (Depth: ${depth}, IndexConstant: ${isIndexConstant})`);
/**
* @param {Object} [opts]
* @param {number} [opts.depth=100] 详情条目的注入深度
* @param {boolean} [opts.isIndexConstant=true] 索引条目是否常驻(蓝灯)
* @param {boolean} [opts.pinFirstRow=false] 首行详情条目升为常驻(总调/全局定义行)
*/
export async function syncToLorebook(tableName, data, indexText, role, headers, rowStatuses, opts = {}) {
const {
depth = 100,
isIndexConstant = true,
pinFirstRow = false,
} = opts;
console.log(`[Amily2-Bridge] 开始同步表格: ${tableName} (Depth: ${depth}, IndexConstant: ${isIndexConstant}, PinFirstRow: ${pinFirstRow})`);
return withLoreLock(`syncToLorebook(${tableName})`, async () => {
await _doEnsureBook(getMemoryBookName());
@@ -133,34 +144,19 @@ export async function syncToLorebook(tableName, data, indexText, role, headers,
processEntry(indexComment, indexKey, indexContent, indexType, true, true, 0, 0);
}
data.forEach((row, index) => {
if (!row || row.length === 0) return;
const rawVal = row[0];
if (rawVal === undefined || rawVal === null) return;
const settings = extension_settings[extensionName] || {};
const optimizationEnabled = settings.context_optimization_enabled !== false;
const primaryVal = String(rawVal).trim();
if (primaryVal === '') return;
const isPendingDeletion = rowStatuses && rowStatuses[index] === 'pending-deletion';
const isEnabled = !isPendingDeletion;
const triggerKeys = [primaryVal];
const entryComment = `[Amily2] Detail: ${tableName} - ${primaryVal}`;
const renderRowContent = (row) => {
let finalHeaders = headers;
if (!finalHeaders || finalHeaders.length < row.length) {
finalHeaders = [];
for(let i=0; i<row.length; i++) {
for (let i = 0; i < row.length; i++) {
finalHeaders.push((headers && headers[i]) ? headers[i] : `Col_${i}`);
}
}
const settings = extension_settings[extensionName] || {};
const optimizationEnabled = settings.context_optimization_enabled !== false;
let entryContent;
if (optimizationEnabled) {
const primaryVal = row[0] || 'Unknown';
entryContent = `${tableName}档案: ${primaryVal}\n`;
@@ -178,13 +174,34 @@ export async function syncToLorebook(tableName, data, indexText, role, headers,
}
entryContent = textContent.trim();
}
return entryContent.trim();
};
processEntry(entryComment, triggerKeys, entryContent.trim(), 'selective', isEnabled);
data.forEach((row, index) => {
if (!row || row.length === 0) return;
const rawVal = row[0];
if (rawVal === undefined || rawVal === null) return;
const primaryVal = String(rawVal).trim();
if (primaryVal === '') return;
const isPendingDeletion = rowStatuses && rowStatuses[index] === 'pending-deletion';
const isEnabled = !isPendingDeletion;
const triggerKeys = [primaryVal];
const entryComment = `[Amily2] Detail: ${tableName} - ${primaryVal}`;
// 首行常驻:第一行通常是总调/全局定义(基调、主线目标等),
// 绿灯模式下没人提到其主键就永远不注入;开启后升为蓝灯常驻。
const entryType = (pinFirstRow && index === 0) ? 'constant' : 'selective';
processEntry(entryComment, triggerKeys, renderRowContent(row), entryType, isEnabled);
});
const entriesToDelete = [];
const tablePrefix = `[Amily2] Detail: ${tableName} -`;
const activeKeys = new Set();
for(const row of data) {
if(row && row.length > 0) {

View File

@@ -178,12 +178,16 @@ async function processUpdateTask(task) {
const activeData = data.filter((_, i) => !rowStatuses || rowStatuses[i] !== 'pending-deletion');
const indexText = generateIndex(activeData, headers, role, tableName);
const allTables = getMemoryState();
const tableIndex = allTables.findIndex(t => t.name === tableName);
const depth = 8001 + (tableIndex >= 0 ? tableIndex : 99);
await syncToLorebook(tableName, data, indexText, role, headers, rowStatuses, depth, isIndexConstant);
await syncToLorebook(tableName, data, indexText, role, headers, rowStatuses, {
depth,
isIndexConstant,
pinFirstRow: tableSettings.pinFirstRow === true,
});
if (hint) {
console.log(`[Amily2-SuperMemory] 应用主动记忆提示: ${hint}`);

View File

@@ -23,6 +23,7 @@ export { characters, this_chid, eventSource, event_types, saveSettingsDebounced
// Core Systems
export { injectTableData, generateTableContent } from "./core/table-system/injector.js";
export { injectProgressiveMemory, clearProgressiveMemoryInjection } from "./core/progressive-memory/engine.js";
export { initialize as initializeRagProcessor } from "./core/rag-processor.js";
export { loadSettingsToUI as loadHanlinyuanSettingsToUI } from "./ui/hanlinyuan-bindings.js";
export { loadTables, clearHighlights, rollbackAndRefill, rollbackState, commitPendingDeletions, saveStateToMessage, getMemoryState, clearUpdatedTables } from './core/table-system/manager.js';

View File

@@ -7,6 +7,7 @@ import {
getContext, extension_settings,
characters, this_chid, eventSource, event_types, saveSettingsDebounced,
injectTableData, generateTableContent,
injectProgressiveMemory,
initializeRagProcessor,
loadHanlinyuanSettingsToUI,
loadTables, clearHighlights, rollbackAndRefill, rollbackState, commitPendingDeletions, saveStateToMessage, getMemoryState, clearUpdatedTables,
@@ -751,6 +752,12 @@ async function executeAmily2Injection(...args) {
} catch (error) {
console.error('[Amily2-内存储司] 表格注入失败:', error);
}
try {
// 渐进记忆内测type2 门槛由引擎内部判定args[3] = type'quiet' 时跳过)
injectProgressiveMemory(args[3]);
} catch (error) {
console.error('[Amily2-渐进记忆] 注入失败:', error);
}
if (window.hanlinyuanRagProcessor && typeof window.hanlinyuanRagProcessor.rearrangeChat === 'function') {
try {
console.log('[Amily2-核心引擎] 执行内置RAG注入。');

View File

@@ -808,7 +808,7 @@ export function bindModalEvents() {
container
.off("click.amily2.chamber_nav")
.on("click.amily2.chamber_nav",
"#amily2_open_text_optimization, #amily2_open_plot_optimization, #amily2_open_additional_features, #amily2_open_rag_palace, #amily2_open_memorisation_forms, #amily2_open_character_world_book, #amily2_open_world_editor, #amily2_open_glossary, #amily2_open_renderer, #amily2_open_super_memory, #amily2_open_auto_char_card, #amily2_open_api_config, #amily2_open_rule_config, #amily2_open_sfigen, #amily2_open_preset_editor, #amily2_back_to_main_settings, #amily2_back_to_main_from_hanlinyuan, #amily2_back_to_main_from_forms, #amily2_back_to_main_from_optimization, #amily2_back_to_main_from_text_optimization, #amily2_back_to_main_from_cwb, #amily2_back_to_main_from_world_editor, #amily2_back_to_main_from_glossary, #amily2_renderer_back_button, #amily2_back_to_main_from_super_memory, #amily2_back_to_main_from_api_config, #amily2_back_to_main_from_rule_config, #amily2_sfigen_back_to_main", function () {
"#amily2_open_text_optimization, #amily2_open_plot_optimization, #amily2_open_additional_features, #amily2_open_rag_palace, #amily2_open_memorisation_forms, #amily2_open_character_world_book, #amily2_open_world_editor, #amily2_open_glossary, #amily2_open_renderer, #amily2_open_super_memory, #amily2_open_progressive_memory, #amily2_open_auto_char_card, #amily2_open_api_config, #amily2_open_rule_config, #amily2_open_sfigen, #amily2_open_preset_editor, #amily2_back_to_main_settings, #amily2_back_to_main_from_hanlinyuan, #amily2_back_to_main_from_forms, #amily2_back_to_main_from_optimization, #amily2_back_to_main_from_text_optimization, #amily2_back_to_main_from_cwb, #amily2_back_to_main_from_world_editor, #amily2_back_to_main_from_glossary, #amily2_renderer_back_button, #amily2_back_to_main_from_super_memory, #amily2_back_to_main_from_progressive_memory, #amily2_back_to_main_from_api_config, #amily2_back_to_main_from_rule_config, #amily2_sfigen_back_to_main", function () {
if (!pluginAuthStatus.authorized) return;
const mainPanel = container.find('.plugin-features');
@@ -822,6 +822,7 @@ export function bindModalEvents() {
const glossaryPanel = container.find('#amily2_glossary_panel');
const rendererPanel = container.find('#amily2_renderer_panel');
const superMemoryPanel = container.find('#amily2_super_memory_panel');
const progressiveMemoryPanel = container.find('#amily2_progressive_memory_panel');
const apiConfigPanel = container.find('#amily2_api_config_panel');
const ruleConfigPanel = container.find('#amily2_rule_config_panel');
const sfigenPanel = container.find('#amily2_sfigen_panel');
@@ -837,6 +838,7 @@ export function bindModalEvents() {
glossaryPanel.hide();
rendererPanel.hide();
superMemoryPanel.hide();
progressiveMemoryPanel.hide();
apiConfigPanel.hide();
ruleConfigPanel.hide();
sfigenPanel.hide();
@@ -854,6 +856,16 @@ export function bindModalEvents() {
}
superMemoryPanel.show();
break;
case 'amily2_open_progressive_memory': {
const pmUserType = parseInt(localStorage.getItem("plugin_user_type") || "0");
if (pmUserType < 3) {
toastr.info("该功能正在开发中,将于未来版本开放,敬请期待。", "开发中功能");
mainPanel.show();
return;
}
progressiveMemoryPanel.show();
break;
}
case 'amily2_open_auto_char_card':
openAutoCharCardWindow();
// 自动构建器是独立窗口,不需要隐藏主面板,或者根据需求决定
@@ -910,6 +922,7 @@ export function bindModalEvents() {
case 'amily2_back_to_main_from_glossary':
case 'amily2_renderer_back_button':
case 'amily2_back_to_main_from_super_memory':
case 'amily2_back_to_main_from_progressive_memory':
case 'amily2_back_to_main_from_api_config':
case 'amily2_back_to_main_from_rule_config':
case 'amily2_sfigen_back_to_main':

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
function a0_0x1ca1(_0x46399e,_0x66fd4){_0x46399e=_0x46399e-0x86;const _0x5bcf85=a0_0x5bcf();let _0x1ca11e=_0x5bcf85[_0x46399e];if(a0_0x1ca1['ZeSPpf']===undefined){var _0x15bd39=function(_0x4dd439){const _0x5559b0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x33da08='',_0x6d106e='';for(let _0x52978f=0x0,_0x5e35d0,_0x1ae72f,_0x4f6482=0x0;_0x1ae72f=_0x4dd439['charAt'](_0x4f6482++);~_0x1ae72f&&(_0x5e35d0=_0x52978f%0x4?_0x5e35d0*0x40+_0x1ae72f:_0x1ae72f,_0x52978f++%0x4)?_0x33da08+=String['fromCharCode'](0xff&_0x5e35d0>>(-0x2*_0x52978f&0x6)):0x0){_0x1ae72f=_0x5559b0['indexOf'](_0x1ae72f);}for(let _0x3ed355=0x0,_0x3dc241=_0x33da08['length'];_0x3ed355<_0x3dc241;_0x3ed355++){_0x6d106e+='%'+('00'+_0x33da08['charCodeAt'](_0x3ed355)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x6d106e);};const _0x2318aa=function(_0x2e81db,_0x5956ef){let _0x386508=[],_0x25f0c8=0x0,_0x40976f,_0x73638c='';_0x2e81db=_0x15bd39(_0x2e81db);let _0x339feb;for(_0x339feb=0x0;_0x339feb<0x100;_0x339feb++){_0x386508[_0x339feb]=_0x339feb;}for(_0x339feb=0x0;_0x339feb<0x100;_0x339feb++){_0x25f0c8=(_0x25f0c8+_0x386508[_0x339feb]+_0x5956ef['charCodeAt'](_0x339feb%_0x5956ef['length']))%0x100,_0x40976f=_0x386508[_0x339feb],_0x386508[_0x339feb]=_0x386508[_0x25f0c8],_0x386508[_0x25f0c8]=_0x40976f;}_0x339feb=0x0,_0x25f0c8=0x0;for(let _0x477851=0x0;_0x477851<_0x2e81db['length'];_0x477851++){_0x339feb=(_0x339feb+0x1)%0x100,_0x25f0c8=(_0x25f0c8+_0x386508[_0x339feb])%0x100,_0x40976f=_0x386508[_0x339feb],_0x386508[_0x339feb]=_0x386508[_0x25f0c8],_0x386508[_0x25f0c8]=_0x40976f,_0x73638c+=String['fromCharCode'](_0x2e81db['charCodeAt'](_0x477851)^_0x386508[(_0x386508[_0x339feb]+_0x386508[_0x25f0c8])%0x100]);}return _0x73638c;};a0_0x1ca1['IlZMfe']=_0x2318aa,a0_0x1ca1['PdqjtX']={},a0_0x1ca1['ZeSPpf']=!![];}const _0x51a749=_0x5bcf85[0x0],_0x5109ef=_0x46399e+_0x51a749,_0x277900=a0_0x1ca1['PdqjtX'][_0x5109ef];return!_0x277900?(a0_0x1ca1['XqOMoC']===undefined&&(a0_0x1ca1['XqOMoC']=!![]),_0x1ca11e=a0_0x1ca1['IlZMfe'](_0x1ca11e,_0x66fd4),a0_0x1ca1['PdqjtX'][_0x5109ef]=_0x1ca11e):_0x1ca11e=_0x277900,_0x1ca11e;}function a0_0x5bcf(){const _0x322e6c=['xmkJWPDPoSo+rCojjhu','kmkfyWTGWQNcJmoBW5hcICodxZa','WP04B8oRt8oYW5FcJmkrW6K9wW','x3bsoSk/WOtdMJSAWPy','W7FdSmoXWONdGwVdJ8k7W4Gx','pmkVrmkdWOrVisK','W6S2wN8+W5m','WOynWOPCbu4lW7i','amktWOFcPXpcPmkUzG','sCkyjbddPZxcM0/cJqiD','lIhdT8kudttdHueskq','W7NdRstdIeNcVCoAdmk4WQBcINJdUG','cmkbW6JdOmkGh8ovbuCc','zXelW4uVW5qoxCkjWOJcKmoeu8o4','WQZcOSkUW4ZcSINcKCkYW4uDomorW4e','qCkLW5hdLhuCWP0LwHu','dCoWoCkFuaZcMXJdStpdGCoF','W4X4o8kffSk3W67cLCk7W6uR','vXe2cmoFWR03','dmkqWRdcGJ3cMmkxEW','WONcVmk+k1iGnCkxmSoomW','W4GFWPNcUZpdRLBdS8oXqudcH8k+pq','W7Drm8oBl8oXW4hcJIiss2ftWO8','xJidnSougr4eWQazWP/cICku','t8kAnmo4W5TmuG','c8otDutcLHlcHKRcIqG','W59JnSkUomk3W7pcLCkXW7a7CLBcLG','W4JdOSoIBY0hnCkgmmosktRdQsldTmoyWR4Ym2ldMmoqz8k5','wZqamCouhrjPWQ8vWRtcR8k4WRq','WPO4BmoQi8kIW7lcKmkdW4K'];a0_0x5bcf=function(){return _0x322e6c;};return a0_0x5bcf();}const a0_0x433226=a0_0x1ca1;(function(_0x1a5ae3,_0x525a4e){const _0x3b67df=a0_0x1ca1,_0xd7bbcd=_0x1a5ae3();while(!![]){try{const _0x4781f0=parseInt(_0x3b67df(0xa2,'0b5$'))/0x1*(parseInt(_0x3b67df(0x8e,'RjV@'))/0x2)+-parseInt(_0x3b67df(0x9a,'E!0I'))/0x3+parseInt(_0x3b67df(0x97,'0b5$'))/0x4*(parseInt(_0x3b67df(0x9f,'%&$K'))/0x5)+parseInt(_0x3b67df(0x86,'4mUY'))/0x6+-parseInt(_0x3b67df(0x9d,'enAc'))/0x7*(parseInt(_0x3b67df(0xa1,'SGaL'))/0x8)+parseInt(_0x3b67df(0x9b,'s7Qx'))/0x9*(parseInt(_0x3b67df(0x98,'bW!)'))/0xa)+-parseInt(_0x3b67df(0x87,'nTnW'))/0xb;if(_0x4781f0===_0x525a4e)break;else _0xd7bbcd['push'](_0xd7bbcd['shift']());}catch(_0x500414){_0xd7bbcd['push'](_0xd7bbcd['shift']());}}}(a0_0x5bcf,0xdd0f2));export const SENSITIVE_KEYS=new Set([a0_0x433226(0x95,'^Iyd'),a0_0x433226(0x8b,'RjV@'),a0_0x433226(0x8c,'WVYj'),a0_0x433226(0x93,'enAc'),a0_0x433226(0x9e,'Jj2V'),a0_0x433226(0x99,'uyFr'),a0_0x433226(0xa0,'RjV@'),a0_0x433226(0x8a,'bW!)')]);
function a0_0x4c31(_0x4bee5f,_0x496717){_0x4bee5f=_0x4bee5f-0x16d;const _0x388542=a0_0x3885();let _0x4c3149=_0x388542[_0x4bee5f];if(a0_0x4c31['ZDMnSF']===undefined){var _0x23d44d=function(_0x1d8643){const _0x127b22='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2ad9dd='',_0x158ce3='';for(let _0x2912d0=0x0,_0x4789ba,_0x582c8e,_0x1b92c0=0x0;_0x582c8e=_0x1d8643['charAt'](_0x1b92c0++);~_0x582c8e&&(_0x4789ba=_0x2912d0%0x4?_0x4789ba*0x40+_0x582c8e:_0x582c8e,_0x2912d0++%0x4)?_0x2ad9dd+=String['fromCharCode'](0xff&_0x4789ba>>(-0x2*_0x2912d0&0x6)):0x0){_0x582c8e=_0x127b22['indexOf'](_0x582c8e);}for(let _0x402384=0x0,_0x4e4818=_0x2ad9dd['length'];_0x402384<_0x4e4818;_0x402384++){_0x158ce3+='%'+('00'+_0x2ad9dd['charCodeAt'](_0x402384)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x158ce3);};const _0x145b18=function(_0x246448,_0x11912a){let _0x12e36a=[],_0x56c407=0x0,_0x18865e,_0x2fca19='';_0x246448=_0x23d44d(_0x246448);let _0x320ce0;for(_0x320ce0=0x0;_0x320ce0<0x100;_0x320ce0++){_0x12e36a[_0x320ce0]=_0x320ce0;}for(_0x320ce0=0x0;_0x320ce0<0x100;_0x320ce0++){_0x56c407=(_0x56c407+_0x12e36a[_0x320ce0]+_0x11912a['charCodeAt'](_0x320ce0%_0x11912a['length']))%0x100,_0x18865e=_0x12e36a[_0x320ce0],_0x12e36a[_0x320ce0]=_0x12e36a[_0x56c407],_0x12e36a[_0x56c407]=_0x18865e;}_0x320ce0=0x0,_0x56c407=0x0;for(let _0x30f34e=0x0;_0x30f34e<_0x246448['length'];_0x30f34e++){_0x320ce0=(_0x320ce0+0x1)%0x100,_0x56c407=(_0x56c407+_0x12e36a[_0x320ce0])%0x100,_0x18865e=_0x12e36a[_0x320ce0],_0x12e36a[_0x320ce0]=_0x12e36a[_0x56c407],_0x12e36a[_0x56c407]=_0x18865e,_0x2fca19+=String['fromCharCode'](_0x246448['charCodeAt'](_0x30f34e)^_0x12e36a[(_0x12e36a[_0x320ce0]+_0x12e36a[_0x56c407])%0x100]);}return _0x2fca19;};a0_0x4c31['acniYk']=_0x145b18,a0_0x4c31['JEEKRR']={},a0_0x4c31['ZDMnSF']=!![];}const _0x6ec022=_0x388542[0x0],_0x154932=_0x4bee5f+_0x6ec022,_0x1a588f=a0_0x4c31['JEEKRR'][_0x154932];return!_0x1a588f?(a0_0x4c31['YHeDZF']===undefined&&(a0_0x4c31['YHeDZF']=!![]),_0x4c3149=a0_0x4c31['acniYk'](_0x4c3149,_0x496717),a0_0x4c31['JEEKRR'][_0x154932]=_0x4c3149):_0x4c3149=_0x1a588f,_0x4c3149;}const a0_0x16cc87=a0_0x4c31;(function(_0xd51fb6,_0x7b0f19){const _0x2b4e00=a0_0x4c31,_0xa7de71=_0xd51fb6();while(!![]){try{const _0x15978a=parseInt(_0x2b4e00(0x171,'@bOT'))/0x1*(-parseInt(_0x2b4e00(0x174,'xH1['))/0x2)+-parseInt(_0x2b4e00(0x179,'Qn8O'))/0x3+-parseInt(_0x2b4e00(0x176,'ZgZG'))/0x4+-parseInt(_0x2b4e00(0x184,'NNwJ'))/0x5+-parseInt(_0x2b4e00(0x183,'aUBI'))/0x6*(parseInt(_0x2b4e00(0x18a,'5n2T'))/0x7)+parseInt(_0x2b4e00(0x177,'014B'))/0x8*(-parseInt(_0x2b4e00(0x185,'jX1y'))/0x9)+parseInt(_0x2b4e00(0x189,'!OzC'))/0xa*(parseInt(_0x2b4e00(0x17e,'2pJk'))/0xb);if(_0x15978a===_0x7b0f19)break;else _0xa7de71['push'](_0xa7de71['shift']());}catch(_0x322320){_0xa7de71['push'](_0xa7de71['shift']());}}}(a0_0x3885,0x42fa0));export const SENSITIVE_KEYS=new Set([a0_0x16cc87(0x186,'NNwJ'),a0_0x16cc87(0x178,'v(4z'),a0_0x16cc87(0x188,'PZ7o'),a0_0x16cc87(0x17c,'2pJk'),a0_0x16cc87(0x187,'aUBI'),a0_0x16cc87(0x180,'82%$'),a0_0x16cc87(0x17a,'YPyP'),a0_0x16cc87(0x17b,'vE4D')]);function a0_0x3885(){const _0x2c73e8=['W4ypW5XcW7nzW6vlA8o+W5pcPLO','W4ldVuNcO8oXWOrZWQ97W7Whm8k8','WPvlWO0/WQav','W5mLW6zUW7rZmSoxWR/dNW','fCksiCkFWQnfW78qW43dMgVdRHnsBmkmm1lcMHS4W4dcGe8','WQOjDuldG8olW6O/B8khW5SuWQC9','WOmNjrf6pHBdS0hdLCo0WOu','o8oPpCk5FfDhFCkZbmkFW6XH','jIqUzmkbWQ0KW70','o8oTpCk8Evngs8klhSk/W5rG','WOqHt0SkysJdQW','c8kuWPBcIeeEpLWfBq','FCoSDr1ZCqVcRG','bCkue8oYW6HBWQtcOc7cLYlcLq','gmo4W7xcLeZdVmkQW6i','A1m9qCoqWOlcMGPDWQm','W7PAWQ9wnSoEW5uGdCooWO3dKq','C8k9s3/cRCohWPK','WOVcGSkyaSopW6pdRmomibVdRSoahZO','afGbW5tdMsddNSkYW7LidSkz','khzSW7RdSfj5W5SDW67dHG','l2mHWPjMW7JcIGCAW44','W5RcIr/cVSkmxCoEWO7cRs0','WQ0hFKBdGSocWR1wvSkdW7mM','WOxdNYhcOSkmq8oNWOq','W4ucW5zfW7vuW6W/tComW7VcRMzy','W7FcO0LoWOCjdSoaW6rv','DCkVW5JcVSkIAqZcGdRdUMBdTq','WOZcMbdcRmkMBSo+','WO52W4fLW55knmoD'];a0_0x3885=function(){return _0x2c73e8;};return a0_0x3885();}