chatluna-plugin-livingmemory 0.0.7 → 0.0.9
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.
- package/README.md +8 -6
- package/client/locales/en.yml +3 -3
- package/client/locales/zh.yml +3 -3
- package/dist/client.js +1 -1
- package/lib/index.js +91 -101
- package/lib/index.js.map +1 -1
- package/lib/service/conversation_hooks.d.ts +9 -3
- package/lib/service/conversation_hooks.d.ts.map +1 -1
- package/lib/service/logging/logger.d.ts +1 -0
- package/lib/service/logging/logger.d.ts.map +1 -1
- package/lib/service/logging/model_calls.d.ts.map +1 -1
- package/lib/service/prompts/memory_tools.d.ts.map +1 -1
- package/lib/service/user_profile.d.ts +1 -2
- package/lib/service/user_profile.d.ts.map +1 -1
- package/lib/service/workflows/recall/coordinator.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# chatluna-plugin-livingmemory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
LivingSystem 生态下构筑的长期记忆插件,让 bot 的记忆带上生动的人格化色彩。通过异步、非阻塞的记忆召回和记忆整理流程让 bot 记叙共度的时光。
|
|
4
|
+
|
|
5
|
+
LivingMemory 不建议与原生 memory 同时启用,两者各自提取、保存和注入记忆,可能会导致额外的 token 开销与其他未知问题。
|
|
4
6
|
|
|
5
7
|
## 构建
|
|
6
8
|
|
|
@@ -31,10 +33,10 @@ yarn build
|
|
|
31
33
|
| 从聊天中提取记忆的间隔 | `extractionWindowMessages` | `60` | 按未提取的聊天消息条数计算(0—360);`0` 关闭自动提取。 |
|
|
32
34
|
| 允许群友闲聊触发记忆提取 | `extractionIncludeOverheard` | `false` | 开启后,群友闲聊达到设定条数就能触发提取;关闭时,等 bot 回复后再检查。 |
|
|
33
35
|
| 是否在提取新记忆后进行 Dream 整理 | `enableAutoDream` | `true` | 自动提取保存新记忆后,由 Dream 检查是否需要整理。 |
|
|
34
|
-
| 记忆自动召回的间隔 | `recallIntervalMessages` | `20` | bot
|
|
35
|
-
| 用于召回记忆的聊天消息数 | `recallHistoryMessages` | `20` |
|
|
36
|
+
| 记忆自动召回的间隔 | `recallIntervalMessages` | `20` | bot 发完一轮回复后,按新增聊天条数判断是否在后台召回;`0` 关闭自动召回。 |
|
|
37
|
+
| 用于召回记忆的聊天消息数 | `recallHistoryMessages` | `20` | 召回从本轮 bot 的最后一条回复向前读取,包含该回复。画像注入使用相同条数,以本轮唤醒为截止点。 |
|
|
36
38
|
| 记忆快照的使用范围 | `snapshotScope` | `conversation` | 每一个会话拥有独立记忆快照(`conversation`)或所有会话共享一个记忆快照(`preset`)。开启「会话记忆隔离」时使用独立快照。 |
|
|
37
|
-
| 记忆快照的最大行数 | `snapshotMaxLines` | `
|
|
39
|
+
| 记忆快照的最大行数 | `snapshotMaxLines` | `10` | 可设为 5—50 行。 |
|
|
38
40
|
| 会话记忆隔离 | `enableConversationIsolation` | `false` | 召回和检索工具只查当前会话的记忆和全局记忆。 |
|
|
39
41
|
| 向 bot 注入记忆快照 | `enableSnapshotInjection` | `true` | 在对话中提供已召回的记忆。 |
|
|
40
42
|
| 向 bot 注入用户画像 | `enableUserProfileInjection` | `false` | 在对话中提供最近聊天里发言人的已有画像。 |
|
|
@@ -76,7 +78,7 @@ yarn build
|
|
|
76
78
|
| `enableUserProfileGeneration` | boolean | `true` | 提取后生成或更新画像 |
|
|
77
79
|
| `enableDreamUserProfileGeneration` | boolean | `true` | Dream 后生成或更新画像 |
|
|
78
80
|
| `userProfileMinMemoryCount` | number | `3` | 生成画像所需最少活跃记忆数 |
|
|
79
|
-
| `userProfileMemoryLimit` | number | `
|
|
81
|
+
| `userProfileMemoryLimit` | number | `30` | 送入模型的关联记忆上限 |
|
|
80
82
|
|
|
81
83
|
## 命令
|
|
82
84
|
|
|
@@ -89,7 +91,7 @@ yarn build
|
|
|
89
91
|
|
|
90
92
|
在 WebUI 的「能力」中打开 `/livingmemory`,可按预设查看记忆、用户画像、人设卡片、快照和任务,也可以测试召回效果。写操作需要权限等级 4。
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
首次使用可打开「插件配置指南」,按步骤配置模型、设置对话规则,并用一条记忆测试检索。
|
|
93
95
|
|
|
94
96
|
在「记忆」页点「新建记忆」,选择目标预设或输入新的预设 ID。已有条目可点「编辑」修改正文、关联用户、情绪和重要度等内容。
|
|
95
97
|
|
package/client/locales/en.yml
CHANGED
|
@@ -132,7 +132,7 @@ search.scores: 'cosine {cosine} · keywords {keyword} · boosted {boosted}'
|
|
|
132
132
|
preset.actions: Preset actions
|
|
133
133
|
tab.navigation: Memory management
|
|
134
134
|
tab.settings: Plugin configuration
|
|
135
|
-
tab.guide: Plugin guide
|
|
135
|
+
tab.guide: Plugin configuration guide
|
|
136
136
|
guide.start: Getting started
|
|
137
137
|
guide.intro: Choose your models and conversations, then try a search with one memory. The following sections explain when the bot saves and recalls memories, how to use profiles, and how Dream organizes existing memories.
|
|
138
138
|
guide.contents: On this page
|
|
@@ -148,13 +148,13 @@ guide.buffer.title: Check the chat buffer before raising an interval
|
|
|
148
148
|
guide.buffer.text: In ChatLuna, open Plugins → Conversation and routing → @chatluna/chat-observer and adjust the buffer limit. Each channel keeps its latest 200 messages by default. Extraction and recall can only count chats still in that buffer. For example, a 300-message extraction interval can never be reached with a 200-message buffer. Even with a shorter interval, messages evicted between checks cannot be read later.
|
|
149
149
|
guide.context: Snapshots and user profiles
|
|
150
150
|
guide.interval.title: How does the recall interval differ from the history length?
|
|
151
|
-
guide.interval.text: The
|
|
151
|
+
guide.interval.text: The bot checks after it finishes sending a reply. It recalls after the first reply, then waits until enough new messages have accumulated. Set the interval to 0 to disable automatic recall. The history length sets how many messages to read, up to and including the final part of the reply, to prepare a snapshot for future turns. Both default to 20 messages.
|
|
152
152
|
guide.overheard.title: When can chat between group members trigger extraction?
|
|
153
153
|
guide.overheard.text: Overheard extraction is off by default. Group chatter alone will not trigger extraction. Once the bot replies, the plugin counts unprocessed messages up to that reply, including earlier chatter, and starts extraction if the interval has been reached. With overheard extraction on, group members can reach the threshold on their own without calling the bot or waiting for a reply.
|
|
154
154
|
guide.sharing.title: Can two groups using the same preset share a snapshot?
|
|
155
155
|
guide.sharing.text: Each conversation has its own snapshot by default. To share one between two groups using the same preset, select preset sharing in both groups’ conversation rules. The groups share recall results; each still reads its own chat history and tracks its own recall interval. A group with conversation isolation enabled always uses its own snapshot and searches only its own and global memories within the preset.
|
|
156
156
|
guide.profiles.title: How do I use existing user profiles in a chat?
|
|
157
|
-
guide.profiles.text: By default, profiles are updated after extraction or Dream, and each person needs at least three linked active memories. You can change these settings under Plugin configuration. To use existing profiles during a chat, enable profile injection in the conversation rule (off by default). The bot receives profiles for users who spoke in the recent messages
|
|
157
|
+
guide.profiles.text: By default, profiles are updated after extraction or Dream, and each person needs at least three linked active memories. You can change these settings under Plugin configuration. To use existing profiles during a chat, enable profile injection in the conversation rule (off by default). The bot receives profiles for users who spoke in the recent messages leading up to the wake, using the same history length as recall.
|
|
158
158
|
guide.dream: How Dream organizes memories
|
|
159
159
|
guide.dream.intro: Dream uses the main model to compare memories and decide which to keep, update, merge, split, or archive. For example, “I take my coffee without sugar” and “I like unsweetened coffee” can become a single preference. Choose a main model with a context window of at least 200k tokens for Dream.
|
|
160
160
|
guide.dream.auto.title: Automatic runs start with newly extracted memories
|
package/client/locales/zh.yml
CHANGED
|
@@ -18,7 +18,7 @@ empty.noPreset: 还没有预设数据。可以新建第一条记忆,也可以
|
|
|
18
18
|
|
|
19
19
|
tab.entries: 记忆
|
|
20
20
|
tab.settings: 插件配置
|
|
21
|
-
tab.guide:
|
|
21
|
+
tab.guide: 插件配置指南
|
|
22
22
|
guide.start: 第一次使用
|
|
23
23
|
guide.intro: 先配置模型、选好要记录的对话,再用一条记忆试试检索。下面也说明了机器人何时提取记忆、何时想起它,以及 Dream 如何整理已有的记忆。
|
|
24
24
|
guide.contents: 本页目录
|
|
@@ -34,13 +34,13 @@ guide.buffer.title: 调大间隔前,先看聊天缓存
|
|
|
34
34
|
guide.buffer.text: 在 ChatLuna 的「插件 → 对话与路由 → @chatluna/chat-observer → 缓存条数」调整。默认每个频道保留最近 200 条消息,提取和召回都只能统计还在缓存里的聊天。例如,缓存是 200 条,提取间隔设为 300 条,就永远凑不够。即使间隔较小,两次检查之间被挤出缓存的旧消息也不会补读。
|
|
35
35
|
guide.context: 快照与用户画像
|
|
36
36
|
guide.interval.title: 「记忆自动召回的间隔」和「用于召回记忆的聊天消息数」有什么区别?
|
|
37
|
-
guide.interval.text:
|
|
37
|
+
guide.interval.text: bot 发完一轮回复后检查召回间隔。首次直接召回,之后累计够指定条数的新消息才再次召回;设为 0 会关闭自动召回。后者决定从 bot 最后一条回复(含)向前读多少条聊天,为后续对话准备快照。两项默认都是 20 条。
|
|
38
38
|
guide.overheard.title: 群友之间的闲聊什么时候会触发提取?
|
|
39
39
|
guide.overheard.text: 「允许群友闲聊触发记忆提取」默认关闭。等 bot 回复后,插件才检查未提取的消息是否达到设定条数,先前的闲聊也计入条数。开启后,即使 bot 没有参与,群友闲聊达到设定条数也会触发提取。
|
|
40
40
|
guide.sharing.title: 同一预设下的两个群能共用快照吗?
|
|
41
41
|
guide.sharing.text: 默认每个会话各用一份快照。要让同一预设下的两个群共用一份,在适用于这两个群的对话规则中,将「记忆快照的使用范围」设为「所有会话共享一个记忆快照」。两个群共享召回结果,仍各自读取聊天记录、计算召回间隔。开启「会话记忆隔离」后,这份规则涉及的会话各用独立快照。
|
|
42
42
|
guide.profiles.title: 已经生成了用户画像,怎样在聊天中使用?
|
|
43
|
-
guide.profiles.text: 默认在提取或 Dream 整理后更新画像,每位用户至少需要 3 条关联的活跃记忆。这些条件在「插件配置」中调整。要让机器人在聊天中使用已有画像,还需在对话规则中打开「向 bot
|
|
43
|
+
guide.profiles.text: 默认在提取或 Dream 整理后更新画像,每位用户至少需要 3 条关联的活跃记忆。这些条件在「插件配置」中调整。要让机器人在聊天中使用已有画像,还需在对话规则中打开「向 bot 注入用户画像」(默认关闭)。注入哪些人的画像,取决于本轮唤醒时的最近聊天中有哪些用户发过言。
|
|
44
44
|
guide.dream: Dream 如何整理记忆
|
|
45
45
|
guide.dream.intro: Dream 让主模型对照已有的记忆,决定哪些该保留、更新、合并、拆分或归档。例如,“我喝咖啡不加糖”和“我喜欢无糖咖啡”可以合并成一条偏好。使用 Dream 时,请选择上下文窗口至少为 200k tokens 的主模型。
|
|
46
46
|
guide.dream.auto.title: 自动整理:从刚提取的新记忆开始
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={"preset.placeholder":`选择预设`,"nativeMemory.title":`检测到您已同时启动原生 memory 插件`,"nativeMemory.description":`LivingMemory 和原生 memory 插件在功能上较为相似,建议仅启用其中一个。`,"nativeMemory.risk":`否则可能会带来额外的 token 开销或其他未知问题。`,"nativeMemory.close":`本次关闭`,"nativeMemory.neverShow":`我知道了,且以后不再提示`,"preset.actions":`预设操作`,"tab.navigation":`记忆管理`,"transfer.export":`导出记忆`,"transfer.import":`导入记忆`,"transfer.confirmTitle":`导入到「{target}」?`,"transfer.preview":`文件导出自「{source}」,包含 {entries} 条记忆、{profiles} 份画像和 {speakers} 位说话者。`,"transfer.merge":`相同 ID 的记忆和同一说话者的画像会被覆盖,其他记忆保留。`,"transfer.confirm":`确认导入`,"transfer.invalid":`无法识别该文件。请选择 LivingMemory 导出的 JSON 文件(格式版本 1–6)。`,"transfer.imported":`已导入到「{target}」:{entries} 条记忆、{profiles} 份画像、{speakers} 位说话者。`,"empty.noPreset":`还没有预设数据。可以新建第一条记忆,也可以从文件导入。`,"tab.entries":`记忆`,"tab.settings":`插件配置`,"tab.guide":`插件指南`,"guide.start":`第一次使用`,"guide.intro":`先配置模型、选好要记录的对话,再用一条记忆试试检索。下面也说明了机器人何时提取记忆、何时想起它,以及 Dream 如何整理已有的记忆。`,"guide.contents":`本页目录`,"guide.models.title":`配置模型`,"guide.models.text":`在「插件配置 → 模型配置」选择模型。主模型需要支持工具调用,用于提取和整理记忆、更新人物画像和人设卡。召回模型判断当前聊天是否需要查找记忆。嵌入模型将记忆和查询文本转换为向量,供插件比较语义相似度。重排序模型是可选的:它根据查询与每条候选记忆的相关性,重新排列检索结果。点「保存设置」后,这些选择对当前插件实例的所有预设生效。`,"guide.openSettings":`打开插件配置`,"guide.rules.title":`选择在哪些对话中自动提取记忆`,"guide.rules.text":`在「对话规则 → 能力 → LivingMemory」设置「从聊天中提取记忆的间隔」,默认是 60 条聊天消息。要只在某个群自动提取,把全局间隔设为 0,再把该群规则的间隔设为 60。`,"guide.check.title":`用一条记忆试试检索`,"guide.check.text":`在「记忆」页点「新建记忆」,选好预设,写下“我喝咖啡不加糖”并保存。到同一预设的「召回测试」搜索“我喜欢喝什么咖啡”,查看检索结果。测试不会更新快照。实际聊天的快照正文在「快照」页查看,展开「召回详情」可以看到搜索词和命中的记忆。`,"guide.timing":`提取与召回的时机`,"guide.buffer.title":`调大间隔前,先看聊天缓存`,"guide.buffer.text":`在 ChatLuna 的「插件 → 对话与路由 → @chatluna/chat-observer → 缓存条数」调整。默认每个频道保留最近 200 条消息,提取和召回都只能统计还在缓存里的聊天。例如,缓存是 200 条,提取间隔设为 300 条,就永远凑不够。即使间隔较小,两次检查之间被挤出缓存的旧消息也不会补读。`,"guide.context":`快照与用户画像`,"guide.interval.title":`「记忆自动召回的间隔」和「用于召回记忆的聊天消息数」有什么区别?`,"guide.interval.text":`前者决定 bot 被唤醒时,隔多少条新消息召回一次;设为 0 会关闭自动召回。后者决定每次召回向前读多少条聊天。两项默认都是 20 条。`,"guide.overheard.title":`群友之间的闲聊什么时候会触发提取?`,"guide.overheard.text":`「允许群友闲聊触发记忆提取」默认关闭。等 bot 回复后,插件才检查未提取的消息是否达到设定条数,先前的闲聊也计入条数。开启后,即使 bot 没有参与,群友闲聊达到设定条数也会触发提取。`,"guide.sharing.title":`同一预设下的两个群能共用快照吗?`,"guide.sharing.text":`默认每个会话各用一份快照。要让同一预设下的两个群共用一份,在适用于这两个群的对话规则中,将「记忆快照的使用范围」设为「所有会话共享一个记忆快照」。两个群共享召回结果,仍各自读取聊天记录、计算召回间隔。开启「会话记忆隔离」后,这份规则涉及的会话各用独立快照。`,"guide.profiles.title":`已经生成了用户画像,怎样在聊天中使用?`,"guide.profiles.text":`默认在提取或 Dream 整理后更新画像,每位用户至少需要 3 条关联的活跃记忆。这些条件在「插件配置」中调整。要让机器人在聊天中使用已有画像,还需在对话规则中打开「向 bot 注入用户画像」(默认关闭)。注入哪些人的画像,取决于本次召回上下文里有哪些用户发过言。`,"guide.dream":`Dream 如何整理记忆`,"guide.dream.intro":`Dream 让主模型对照已有的记忆,决定哪些该保留、更新、合并、拆分或归档。例如,“我喝咖啡不加糖”和“我喜欢无糖咖啡”可以合并成一条偏好。使用 Dream 时,请选择上下文窗口至少为 200k tokens 的主模型。`,"guide.dream.auto.title":`自动整理:从刚提取的新记忆开始`,"guide.dream.auto.text":`对话规则中的「是否在提取新记忆后进行 Dream 整理」默认开启。每次自动提取保存新记忆后,Dream 会为每条新记忆查找同一预设下相关的活跃旧记忆,放在一起整理。找不到相关旧记忆时,新条目保持原样。`,"guide.dream.manual.title":`手动整理:检查整个预设`,"guide.dream.manual.text":`预设里至少有 30 条活跃记忆时,可以在「记忆」页选择该预设,点「运行 Dream」。Dream 会把活跃记忆按内容相关性分组,逐组检查。30 条的门槛只用于手动整理。`,"guide.dream.result.title":`查看整理结果`,"guide.dream.result.text":`在同一预设的「任务」页查看处理条数、操作统计和失败原因。改动会直接保存到「记忆」页;要查看合并或拆分前的原条目,把状态筛选切到「已归档」。`,"settings.scope":`插件设置对所有预设生效。`,"settings.save":`保存设置`,"settings.discard":`放弃更改`,"settings.saved":`设置已保存`,"settings.noEntry":`当前实例未通过配置文件加载,无法在此编辑。`,"settings.noSchema":`无法读取 LivingMemory 的配置表单。`,"tab.jobs":`任务`,"tab.personas":`人设卡片`,"status.active":`活跃`,"status.archived":`已归档`,"status.all":`全部`,"type.all":`全部类型`,"type.identity":`身份`,"type.preference":`偏好`,"type.fact":`事实`,"type.plan":`计划`,"type.context":`背景`,"type.other":`其他`,"entries.search":`搜索内容、摘要或关键词`,"entries.total":`共 {count} 条`,"entries.empty":`这里还没有记忆`,"entries.edit":`编辑`,"entries.create":`新建记忆`,"entries.editTitle":`编辑记忆`,"entries.created":`已创建记忆`,"entries.saved":`已保存记忆`,"entries.choosePreset":`选择或输入预设 ID`,"entries.noSpeakers":`未关联用户`,"entries.archive":`归档`,"entries.archiveCount":`归档({count})`,"entries.archivedCount":`已归档 {count} 条记忆`,"entries.purge":`彻底删除`,"deletion.selectEntry":`选择记忆:{label}`,"deletion.selectPage":`全选本页`,"deletion.selectAll":`全选`,"deletion.selectMatches":`选择全部 {count} 条结果`,"deletion.selected":`已选 {count} 条`,"deletion.deselect":`清除选择`,"deletion.confirmDelete":`确认彻底删除`,"deletion.entryWarning":`将永久删除预设「{preset}」中的 {count} 条记忆,删除后无法恢复。`,"deletion.deleted":`已删除 {count} 条记忆`,"deletion.clearPreset":`清空预设数据`,"deletion.clearWarning":`预设「{preset}」的数据清空后无法恢复。`,"deletion.typePhrase":`输入以下完整语句以确认清空`,"deletion.phrase":`我确认清空预设 {preset} 的全部记忆、用户画像、人设卡片、快照和任务记录`,"deletion.confirmClear":`确认清空`,"deletion.cleared":`已清空预设「{preset}」的数据`,"field.keywords":`关键词(每行一个,最多 {max} 个)`,"field.preset":`预设`,"field.summary":`摘要`,"field.type":`类型`,"field.status":`状态`,"field.sentiment":`情绪`,"field.importance":`重要度`,"field.speakers":`关联用户`,"field.createdAt":`创建`,"field.updatedAt":`更新`,"field.content":`内容`,"jobs.dream":`运行 Dream`,"jobs.dreamStarted":`「{preset}」的 Dream 已启动`,"jobs.dreamRunning":`「{preset}」已有 Dream 在运行`,"jobs.dreamInsufficient":`「{preset}」可整理的记忆不足`,"jobs.rebuildIndex":`重建向量索引`,"jobs.empty":`还没有任务记录`,"job.kind.extract":`提取`,"job.kind.dream":`Dream`,"job.kind.recall":`召回`,"job.kind.index":`索引`,"job.status.pending":`排队中`,"job.status.running":`运行中`,"job.status.completed":`已完成`,"job.status.partial":`部分完成`,"job.status.failed":`失败`,"personas.empty":`当前预设还没有人设卡片`,"personas.stale":`预设已变更`,"personas.reset":`重新生成`,"personas.hint":`卡片由预设的 system 部分摘录生成;手工保存后不再被自动覆盖。`,"persona.source.generated":`自动生成`,"persona.source.manual":`手工编辑`,"common.save":`保存`,"common.cancel":`取消`,"common.edit":`编辑`,"common.prev":`上一页`,"common.next":`下一页`,"tab.profiles":`用户画像`,"tab.snapshots":`快照`,"profiles.empty":`还没有为这个预设生成过用户画像`,"profiles.hint":`画像由模型从关联记忆提炼;保存后不再被自动生成覆盖。`,"profiles.sourceCount":`关联 {count} 条记忆`,"profiles.regenerate":`重新生成`,"profiles.delete":`删除`,"snapshots.presetShared":`预设共享快照`,"snapshots.empty":`还没有召回快照`,"snapshots.conversation":`会话 {id}`,"snapshots.noContent":`快照内容为空`,"snapshots.details":`召回详情`,"snapshots.searchTexts":`搜索词`,"snapshots.noSearch":`本次没有搜索`,"snapshots.matches":`召回的记忆({count} 条)`,"common.delete":`删除`,"tab.search":`召回测试`,"search.text":`搜索文本(第一人称描述)`,"search.keywords":`关键词(逗号分隔,选填)`,"search.run":`搜索`,"search.empty":`未找到匹配的记忆`,"search.scores":`cosine {cosine} · 关键词 {keyword} · 加权 {boosted}`},t={"preset.placeholder":`Select a preset`,"nativeMemory.title":`The built-in memory plugin is also running`,"nativeMemory.description":`LivingMemory and the built-in memory plugin have similar features. We recommend enabling only one.`,"nativeMemory.risk":`Running both may use extra tokens or cause unexpected issues.`,"nativeMemory.close":`Dismiss for now`,"nativeMemory.neverShow":`Got it, don’t show this again`,"transfer.export":`Export memories`,"transfer.import":`Import memories`,"transfer.confirmTitle":`Import into “{target}”?`,"transfer.preview":`Export from “{source}”: {entries} memories, {profiles} profiles and {speakers} speakers.`,"transfer.merge":`Memories with matching IDs and profiles for the same speaker will be replaced. Other memories are kept.`,"transfer.confirm":`Confirm import`,"transfer.invalid":`Choose a JSON file exported by LivingMemory (format versions 1–6).`,"transfer.imported":`Imported into “{target}”: {entries} memories, {profiles} profiles and {speakers} speakers.`,"empty.noPreset":`No preset data yet. Create your first memory or import a file.`,"tab.entries":`Memories`,"tab.jobs":`Jobs`,"tab.personas":`Personas`,"status.active":`Active`,"status.archived":`Archived`,"status.all":`All`,"type.all":`All types`,"type.identity":`Identity`,"type.preference":`Preference`,"type.fact":`Fact`,"type.plan":`Plan`,"type.context":`Context`,"type.other":`Other`,"entries.search":`Search content, summary or keywords`,"entries.total":`{count} entries`,"entries.empty":`No memories here yet`,"entries.edit":`Edit`,"entries.create":`New memory`,"entries.editTitle":`Edit memory`,"entries.created":`Memory created`,"entries.saved":`Memory saved`,"entries.choosePreset":`Select or enter a preset ID`,"entries.noSpeakers":`No users linked`,"entries.archive":`Archive`,"entries.archiveCount":`Archive ({count})`,"entries.archivedCount":`Archived {count} memories`,"entries.purge":`Delete`,"deletion.selectEntry":`Select memory: {label}`,"deletion.selectPage":`Select this page`,"deletion.selectAll":`Select all`,"deletion.selectMatches":`Select all {count} results`,"deletion.selected":`{count} selected`,"deletion.deselect":`Clear selection`,"deletion.confirmDelete":`Confirm permanent deletion`,"deletion.entryWarning":`Permanently delete {count} memories from “{preset}”? This cannot be undone.`,"deletion.deleted":`Deleted {count} memories`,"deletion.clearPreset":`Clear preset data`,"deletion.clearWarning":`Clearing the data in “{preset}” cannot be undone.`,"deletion.typePhrase":`Type the following sentence to confirm`,"deletion.phrase":`I confirm clearing all memories, user profiles, persona cards, snapshots and job records for preset {preset}`,"deletion.confirmClear":`Confirm clearing`,"deletion.cleared":`Cleared data for “{preset}”`,"field.keywords":`Keywords (one per line, up to {max})`,"field.preset":`Preset`,"field.summary":`Summary`,"field.type":`Type`,"field.status":`Status`,"field.sentiment":`Sentiment`,"field.importance":`Importance`,"field.speakers":`Linked users`,"field.createdAt":`Created`,"field.updatedAt":`Updated`,"field.content":`Content`,"jobs.dream":`Run Dream`,"jobs.dreamStarted":`Dream started for “{preset}”`,"jobs.dreamRunning":`Dream is already running for “{preset}”`,"jobs.dreamInsufficient":`Not enough memories in “{preset}” to run Dream`,"jobs.rebuildIndex":`Rebuild vector index`,"jobs.empty":`No jobs recorded yet`,"job.kind.extract":`Extract`,"job.kind.dream":`Dream`,"job.kind.recall":`Recall`,"job.kind.index":`Index`,"job.status.pending":`Pending`,"job.status.running":`Running`,"job.status.completed":`Completed`,"job.status.partial":`Partial`,"job.status.failed":`Failed`,"personas.empty":`This preset has no persona card yet`,"personas.stale":`Preset changed`,"personas.reset":`Regenerate`,"personas.hint":`The card is distilled from the preset's system section; once saved by hand it is no longer overwritten automatically.`,"persona.source.generated":`Generated`,"persona.source.manual":`Edited by hand`,"common.save":`Save`,"common.cancel":`Cancel`,"common.edit":`Edit`,"common.prev":`Previous`,"common.next":`Next`,"tab.profiles":`Profiles`,"tab.snapshots":`Snapshots`,"profiles.empty":`No user profile has been generated for this preset`,"profiles.hint":`The profile is distilled from linked memories; once saved it is no longer overwritten automatically.`,"profiles.sourceCount":`{count} linked memories`,"profiles.regenerate":`Regenerate`,"profiles.delete":`Delete`,"snapshots.presetShared":`Shared preset snapshot`,"snapshots.empty":`No recall snapshot yet`,"snapshots.conversation":`Conversation {id}`,"snapshots.noContent":`This snapshot is empty`,"snapshots.details":`Recall details`,"snapshots.searchTexts":`Search terms`,"snapshots.noSearch":`No search was made`,"snapshots.matches":`Recalled memories ({count})`,"common.delete":`Delete`,"tab.search":`Recall test`,"search.text":`Search text (first-person description)`,"search.keywords":`Keywords (comma separated, optional)`,"search.run":`Search`,"search.empty":`No memory matched`,"search.scores":`cosine {cosine} · keywords {keyword} · boosted {boosted}`,"preset.actions":`Preset actions`,"tab.navigation":`Memory management`,"tab.settings":`Plugin configuration`,"tab.guide":`Plugin guide`,"guide.start":`Getting started`,"guide.intro":`Choose your models and conversations, then try a search with one memory. The following sections explain when the bot saves and recalls memories, how to use profiles, and how Dream organizes existing memories.`,"guide.contents":`On this page`,"guide.models.title":`Choose your models`,"guide.models.text":`Under Plugin configuration → Model configuration, choose a main model that supports tool calls. It extracts and organizes memories and updates user profiles and persona cards. The recall model decides whether to look up memories. The embedding model converts memories and queries into vectors so the plugin can compare their meanings. An optional reranker reorders the candidate memories by their relevance to the query. Select Save settings to apply these choices to all presets in this plugin instance.`,"guide.openSettings":`Open plugin configuration`,"guide.rules.title":`Choose which conversations use automatic extraction`,"guide.rules.text":`Open Conversation rules → Capabilities → LivingMemory and set the extraction interval. The default is 60 chat messages. To enable automatic extraction in just one group, set the global interval to 0 and that group’s interval to 60.`,"guide.check.title":`Try a search with one memory`,"guide.check.text":`Under Memories, select New memory, choose a preset, and save “I drink my coffee without sugar.” Under Recall test for the same preset, search for “How do I like my coffee?” to see the matches. The test leaves snapshots unchanged. Under Snapshots you can read the snapshot from an actual chat. Expand Recall details to see the search terms and matching memories.`,"guide.timing":`When extraction and recall run`,"guide.buffer.title":`Check the chat buffer before raising an interval`,"guide.buffer.text":`In ChatLuna, open Plugins → Conversation and routing → @chatluna/chat-observer and adjust the buffer limit. Each channel keeps its latest 200 messages by default. Extraction and recall can only count chats still in that buffer. For example, a 300-message extraction interval can never be reached with a 200-message buffer. Even with a shorter interval, messages evicted between checks cannot be read later.`,"guide.context":`Snapshots and user profiles`,"guide.interval.title":`How does the recall interval differ from the history length?`,"guide.interval.text":`The interval tells the bot how many new messages to wait for between recalls when it wakes. Set it to 0 to disable automatic recall. The history length sets how many recent messages the bot reads for each recall. Both default to 20 messages.`,"guide.overheard.title":`When can chat between group members trigger extraction?`,"guide.overheard.text":`Overheard extraction is off by default. Group chatter alone will not trigger extraction. Once the bot replies, the plugin counts unprocessed messages up to that reply, including earlier chatter, and starts extraction if the interval has been reached. With overheard extraction on, group members can reach the threshold on their own without calling the bot or waiting for a reply.`,"guide.sharing.title":`Can two groups using the same preset share a snapshot?`,"guide.sharing.text":`Each conversation has its own snapshot by default. To share one between two groups using the same preset, select preset sharing in both groups’ conversation rules. The groups share recall results; each still reads its own chat history and tracks its own recall interval. A group with conversation isolation enabled always uses its own snapshot and searches only its own and global memories within the preset.`,"guide.profiles.title":`How do I use existing user profiles in a chat?`,"guide.profiles.text":`By default, profiles are updated after extraction or Dream, and each person needs at least three linked active memories. You can change these settings under Plugin configuration. To use existing profiles during a chat, enable profile injection in the conversation rule (off by default). The bot receives profiles for users who spoke in the recent messages covered by the recall history length.`,"guide.dream":`How Dream organizes memories`,"guide.dream.intro":`Dream uses the main model to compare memories and decide which to keep, update, merge, split, or archive. For example, “I take my coffee without sugar” and “I like unsweetened coffee” can become a single preference. Choose a main model with a context window of at least 200k tokens for Dream.`,"guide.dream.auto.title":`Automatic runs start with newly extracted memories`,"guide.dream.auto.text":`Conversation rules enable Dream after extraction by default. For each newly saved memory, Dream looks for related active memories already in the same preset and reviews them together. If it finds no related older memory, the new entry stays as it is.`,"guide.dream.manual.title":`Manual runs review a whole preset`,"guide.dream.manual.text":`Once a preset has at least 30 active memories, select it under Memories and click Run Dream. Dream groups its active memories by similarity and reviews each group in turn. The 30-memory minimum applies only to manual runs.`,"guide.dream.result.title":`See what changed`,"guide.dream.result.text":`Open Jobs for the same preset to see how many memories Dream processed, which operations it performed, and any errors. Changes are saved directly to Memories. To see the original entries after a merge or split, change the status filter to Archived.`,"settings.scope":`Plugin settings apply to all presets.`,"settings.save":`Save settings`,"settings.discard":`Discard changes`,"settings.saved":`Settings saved`,"settings.noEntry":`This instance was not loaded from a configuration file and cannot be edited here.`,"settings.noSchema":`The LivingMemory configuration form is unavailable.`};function n(n){n.locale.register(`livingmemory`,{zh:e,en:t}),n.slots.route({path:`/livingmemory`,page:async()=>(await import(`./page-EGG2hcC3.js`)).LivingMemoryPage,title:`LivingMemory`,icon:`brain`,order:36,group:`capabilities`,groupOrder:36})}export{n as default};
|
|
1
|
+
var e={"preset.placeholder":`选择预设`,"nativeMemory.title":`检测到您已同时启动原生 memory 插件`,"nativeMemory.description":`LivingMemory 和原生 memory 插件在功能上较为相似,建议仅启用其中一个。`,"nativeMemory.risk":`否则可能会带来额外的 token 开销或其他未知问题。`,"nativeMemory.close":`本次关闭`,"nativeMemory.neverShow":`我知道了,且以后不再提示`,"preset.actions":`预设操作`,"tab.navigation":`记忆管理`,"transfer.export":`导出记忆`,"transfer.import":`导入记忆`,"transfer.confirmTitle":`导入到「{target}」?`,"transfer.preview":`文件导出自「{source}」,包含 {entries} 条记忆、{profiles} 份画像和 {speakers} 位说话者。`,"transfer.merge":`相同 ID 的记忆和同一说话者的画像会被覆盖,其他记忆保留。`,"transfer.confirm":`确认导入`,"transfer.invalid":`无法识别该文件。请选择 LivingMemory 导出的 JSON 文件(格式版本 1–6)。`,"transfer.imported":`已导入到「{target}」:{entries} 条记忆、{profiles} 份画像、{speakers} 位说话者。`,"empty.noPreset":`还没有预设数据。可以新建第一条记忆,也可以从文件导入。`,"tab.entries":`记忆`,"tab.settings":`插件配置`,"tab.guide":`插件配置指南`,"guide.start":`第一次使用`,"guide.intro":`先配置模型、选好要记录的对话,再用一条记忆试试检索。下面也说明了机器人何时提取记忆、何时想起它,以及 Dream 如何整理已有的记忆。`,"guide.contents":`本页目录`,"guide.models.title":`配置模型`,"guide.models.text":`在「插件配置 → 模型配置」选择模型。主模型需要支持工具调用,用于提取和整理记忆、更新人物画像和人设卡。召回模型判断当前聊天是否需要查找记忆。嵌入模型将记忆和查询文本转换为向量,供插件比较语义相似度。重排序模型是可选的:它根据查询与每条候选记忆的相关性,重新排列检索结果。点「保存设置」后,这些选择对当前插件实例的所有预设生效。`,"guide.openSettings":`打开插件配置`,"guide.rules.title":`选择在哪些对话中自动提取记忆`,"guide.rules.text":`在「对话规则 → 能力 → LivingMemory」设置「从聊天中提取记忆的间隔」,默认是 60 条聊天消息。要只在某个群自动提取,把全局间隔设为 0,再把该群规则的间隔设为 60。`,"guide.check.title":`用一条记忆试试检索`,"guide.check.text":`在「记忆」页点「新建记忆」,选好预设,写下“我喝咖啡不加糖”并保存。到同一预设的「召回测试」搜索“我喜欢喝什么咖啡”,查看检索结果。测试不会更新快照。实际聊天的快照正文在「快照」页查看,展开「召回详情」可以看到搜索词和命中的记忆。`,"guide.timing":`提取与召回的时机`,"guide.buffer.title":`调大间隔前,先看聊天缓存`,"guide.buffer.text":`在 ChatLuna 的「插件 → 对话与路由 → @chatluna/chat-observer → 缓存条数」调整。默认每个频道保留最近 200 条消息,提取和召回都只能统计还在缓存里的聊天。例如,缓存是 200 条,提取间隔设为 300 条,就永远凑不够。即使间隔较小,两次检查之间被挤出缓存的旧消息也不会补读。`,"guide.context":`快照与用户画像`,"guide.interval.title":`「记忆自动召回的间隔」和「用于召回记忆的聊天消息数」有什么区别?`,"guide.interval.text":`bot 发完一轮回复后检查召回间隔。首次直接召回,之后累计够指定条数的新消息才再次召回;设为 0 会关闭自动召回。后者决定从 bot 最后一条回复(含)向前读多少条聊天,为后续对话准备快照。两项默认都是 20 条。`,"guide.overheard.title":`群友之间的闲聊什么时候会触发提取?`,"guide.overheard.text":`「允许群友闲聊触发记忆提取」默认关闭。等 bot 回复后,插件才检查未提取的消息是否达到设定条数,先前的闲聊也计入条数。开启后,即使 bot 没有参与,群友闲聊达到设定条数也会触发提取。`,"guide.sharing.title":`同一预设下的两个群能共用快照吗?`,"guide.sharing.text":`默认每个会话各用一份快照。要让同一预设下的两个群共用一份,在适用于这两个群的对话规则中,将「记忆快照的使用范围」设为「所有会话共享一个记忆快照」。两个群共享召回结果,仍各自读取聊天记录、计算召回间隔。开启「会话记忆隔离」后,这份规则涉及的会话各用独立快照。`,"guide.profiles.title":`已经生成了用户画像,怎样在聊天中使用?`,"guide.profiles.text":`默认在提取或 Dream 整理后更新画像,每位用户至少需要 3 条关联的活跃记忆。这些条件在「插件配置」中调整。要让机器人在聊天中使用已有画像,还需在对话规则中打开「向 bot 注入用户画像」(默认关闭)。注入哪些人的画像,取决于本轮唤醒时的最近聊天中有哪些用户发过言。`,"guide.dream":`Dream 如何整理记忆`,"guide.dream.intro":`Dream 让主模型对照已有的记忆,决定哪些该保留、更新、合并、拆分或归档。例如,“我喝咖啡不加糖”和“我喜欢无糖咖啡”可以合并成一条偏好。使用 Dream 时,请选择上下文窗口至少为 200k tokens 的主模型。`,"guide.dream.auto.title":`自动整理:从刚提取的新记忆开始`,"guide.dream.auto.text":`对话规则中的「是否在提取新记忆后进行 Dream 整理」默认开启。每次自动提取保存新记忆后,Dream 会为每条新记忆查找同一预设下相关的活跃旧记忆,放在一起整理。找不到相关旧记忆时,新条目保持原样。`,"guide.dream.manual.title":`手动整理:检查整个预设`,"guide.dream.manual.text":`预设里至少有 30 条活跃记忆时,可以在「记忆」页选择该预设,点「运行 Dream」。Dream 会把活跃记忆按内容相关性分组,逐组检查。30 条的门槛只用于手动整理。`,"guide.dream.result.title":`查看整理结果`,"guide.dream.result.text":`在同一预设的「任务」页查看处理条数、操作统计和失败原因。改动会直接保存到「记忆」页;要查看合并或拆分前的原条目,把状态筛选切到「已归档」。`,"settings.scope":`插件设置对所有预设生效。`,"settings.save":`保存设置`,"settings.discard":`放弃更改`,"settings.saved":`设置已保存`,"settings.noEntry":`当前实例未通过配置文件加载,无法在此编辑。`,"settings.noSchema":`无法读取 LivingMemory 的配置表单。`,"tab.jobs":`任务`,"tab.personas":`人设卡片`,"status.active":`活跃`,"status.archived":`已归档`,"status.all":`全部`,"type.all":`全部类型`,"type.identity":`身份`,"type.preference":`偏好`,"type.fact":`事实`,"type.plan":`计划`,"type.context":`背景`,"type.other":`其他`,"entries.search":`搜索内容、摘要或关键词`,"entries.total":`共 {count} 条`,"entries.empty":`这里还没有记忆`,"entries.edit":`编辑`,"entries.create":`新建记忆`,"entries.editTitle":`编辑记忆`,"entries.created":`已创建记忆`,"entries.saved":`已保存记忆`,"entries.choosePreset":`选择或输入预设 ID`,"entries.noSpeakers":`未关联用户`,"entries.archive":`归档`,"entries.archiveCount":`归档({count})`,"entries.archivedCount":`已归档 {count} 条记忆`,"entries.purge":`彻底删除`,"deletion.selectEntry":`选择记忆:{label}`,"deletion.selectPage":`全选本页`,"deletion.selectAll":`全选`,"deletion.selectMatches":`选择全部 {count} 条结果`,"deletion.selected":`已选 {count} 条`,"deletion.deselect":`清除选择`,"deletion.confirmDelete":`确认彻底删除`,"deletion.entryWarning":`将永久删除预设「{preset}」中的 {count} 条记忆,删除后无法恢复。`,"deletion.deleted":`已删除 {count} 条记忆`,"deletion.clearPreset":`清空预设数据`,"deletion.clearWarning":`预设「{preset}」的数据清空后无法恢复。`,"deletion.typePhrase":`输入以下完整语句以确认清空`,"deletion.phrase":`我确认清空预设 {preset} 的全部记忆、用户画像、人设卡片、快照和任务记录`,"deletion.confirmClear":`确认清空`,"deletion.cleared":`已清空预设「{preset}」的数据`,"field.keywords":`关键词(每行一个,最多 {max} 个)`,"field.preset":`预设`,"field.summary":`摘要`,"field.type":`类型`,"field.status":`状态`,"field.sentiment":`情绪`,"field.importance":`重要度`,"field.speakers":`关联用户`,"field.createdAt":`创建`,"field.updatedAt":`更新`,"field.content":`内容`,"jobs.dream":`运行 Dream`,"jobs.dreamStarted":`「{preset}」的 Dream 已启动`,"jobs.dreamRunning":`「{preset}」已有 Dream 在运行`,"jobs.dreamInsufficient":`「{preset}」可整理的记忆不足`,"jobs.rebuildIndex":`重建向量索引`,"jobs.empty":`还没有任务记录`,"job.kind.extract":`提取`,"job.kind.dream":`Dream`,"job.kind.recall":`召回`,"job.kind.index":`索引`,"job.status.pending":`排队中`,"job.status.running":`运行中`,"job.status.completed":`已完成`,"job.status.partial":`部分完成`,"job.status.failed":`失败`,"personas.empty":`当前预设还没有人设卡片`,"personas.stale":`预设已变更`,"personas.reset":`重新生成`,"personas.hint":`卡片由预设的 system 部分摘录生成;手工保存后不再被自动覆盖。`,"persona.source.generated":`自动生成`,"persona.source.manual":`手工编辑`,"common.save":`保存`,"common.cancel":`取消`,"common.edit":`编辑`,"common.prev":`上一页`,"common.next":`下一页`,"tab.profiles":`用户画像`,"tab.snapshots":`快照`,"profiles.empty":`还没有为这个预设生成过用户画像`,"profiles.hint":`画像由模型从关联记忆提炼;保存后不再被自动生成覆盖。`,"profiles.sourceCount":`关联 {count} 条记忆`,"profiles.regenerate":`重新生成`,"profiles.delete":`删除`,"snapshots.presetShared":`预设共享快照`,"snapshots.empty":`还没有召回快照`,"snapshots.conversation":`会话 {id}`,"snapshots.noContent":`快照内容为空`,"snapshots.details":`召回详情`,"snapshots.searchTexts":`搜索词`,"snapshots.noSearch":`本次没有搜索`,"snapshots.matches":`召回的记忆({count} 条)`,"common.delete":`删除`,"tab.search":`召回测试`,"search.text":`搜索文本(第一人称描述)`,"search.keywords":`关键词(逗号分隔,选填)`,"search.run":`搜索`,"search.empty":`未找到匹配的记忆`,"search.scores":`cosine {cosine} · 关键词 {keyword} · 加权 {boosted}`},t={"preset.placeholder":`Select a preset`,"nativeMemory.title":`The built-in memory plugin is also running`,"nativeMemory.description":`LivingMemory and the built-in memory plugin have similar features. We recommend enabling only one.`,"nativeMemory.risk":`Running both may use extra tokens or cause unexpected issues.`,"nativeMemory.close":`Dismiss for now`,"nativeMemory.neverShow":`Got it, don’t show this again`,"transfer.export":`Export memories`,"transfer.import":`Import memories`,"transfer.confirmTitle":`Import into “{target}”?`,"transfer.preview":`Export from “{source}”: {entries} memories, {profiles} profiles and {speakers} speakers.`,"transfer.merge":`Memories with matching IDs and profiles for the same speaker will be replaced. Other memories are kept.`,"transfer.confirm":`Confirm import`,"transfer.invalid":`Choose a JSON file exported by LivingMemory (format versions 1–6).`,"transfer.imported":`Imported into “{target}”: {entries} memories, {profiles} profiles and {speakers} speakers.`,"empty.noPreset":`No preset data yet. Create your first memory or import a file.`,"tab.entries":`Memories`,"tab.jobs":`Jobs`,"tab.personas":`Personas`,"status.active":`Active`,"status.archived":`Archived`,"status.all":`All`,"type.all":`All types`,"type.identity":`Identity`,"type.preference":`Preference`,"type.fact":`Fact`,"type.plan":`Plan`,"type.context":`Context`,"type.other":`Other`,"entries.search":`Search content, summary or keywords`,"entries.total":`{count} entries`,"entries.empty":`No memories here yet`,"entries.edit":`Edit`,"entries.create":`New memory`,"entries.editTitle":`Edit memory`,"entries.created":`Memory created`,"entries.saved":`Memory saved`,"entries.choosePreset":`Select or enter a preset ID`,"entries.noSpeakers":`No users linked`,"entries.archive":`Archive`,"entries.archiveCount":`Archive ({count})`,"entries.archivedCount":`Archived {count} memories`,"entries.purge":`Delete`,"deletion.selectEntry":`Select memory: {label}`,"deletion.selectPage":`Select this page`,"deletion.selectAll":`Select all`,"deletion.selectMatches":`Select all {count} results`,"deletion.selected":`{count} selected`,"deletion.deselect":`Clear selection`,"deletion.confirmDelete":`Confirm permanent deletion`,"deletion.entryWarning":`Permanently delete {count} memories from “{preset}”? This cannot be undone.`,"deletion.deleted":`Deleted {count} memories`,"deletion.clearPreset":`Clear preset data`,"deletion.clearWarning":`Clearing the data in “{preset}” cannot be undone.`,"deletion.typePhrase":`Type the following sentence to confirm`,"deletion.phrase":`I confirm clearing all memories, user profiles, persona cards, snapshots and job records for preset {preset}`,"deletion.confirmClear":`Confirm clearing`,"deletion.cleared":`Cleared data for “{preset}”`,"field.keywords":`Keywords (one per line, up to {max})`,"field.preset":`Preset`,"field.summary":`Summary`,"field.type":`Type`,"field.status":`Status`,"field.sentiment":`Sentiment`,"field.importance":`Importance`,"field.speakers":`Linked users`,"field.createdAt":`Created`,"field.updatedAt":`Updated`,"field.content":`Content`,"jobs.dream":`Run Dream`,"jobs.dreamStarted":`Dream started for “{preset}”`,"jobs.dreamRunning":`Dream is already running for “{preset}”`,"jobs.dreamInsufficient":`Not enough memories in “{preset}” to run Dream`,"jobs.rebuildIndex":`Rebuild vector index`,"jobs.empty":`No jobs recorded yet`,"job.kind.extract":`Extract`,"job.kind.dream":`Dream`,"job.kind.recall":`Recall`,"job.kind.index":`Index`,"job.status.pending":`Pending`,"job.status.running":`Running`,"job.status.completed":`Completed`,"job.status.partial":`Partial`,"job.status.failed":`Failed`,"personas.empty":`This preset has no persona card yet`,"personas.stale":`Preset changed`,"personas.reset":`Regenerate`,"personas.hint":`The card is distilled from the preset's system section; once saved by hand it is no longer overwritten automatically.`,"persona.source.generated":`Generated`,"persona.source.manual":`Edited by hand`,"common.save":`Save`,"common.cancel":`Cancel`,"common.edit":`Edit`,"common.prev":`Previous`,"common.next":`Next`,"tab.profiles":`Profiles`,"tab.snapshots":`Snapshots`,"profiles.empty":`No user profile has been generated for this preset`,"profiles.hint":`The profile is distilled from linked memories; once saved it is no longer overwritten automatically.`,"profiles.sourceCount":`{count} linked memories`,"profiles.regenerate":`Regenerate`,"profiles.delete":`Delete`,"snapshots.presetShared":`Shared preset snapshot`,"snapshots.empty":`No recall snapshot yet`,"snapshots.conversation":`Conversation {id}`,"snapshots.noContent":`This snapshot is empty`,"snapshots.details":`Recall details`,"snapshots.searchTexts":`Search terms`,"snapshots.noSearch":`No search was made`,"snapshots.matches":`Recalled memories ({count})`,"common.delete":`Delete`,"tab.search":`Recall test`,"search.text":`Search text (first-person description)`,"search.keywords":`Keywords (comma separated, optional)`,"search.run":`Search`,"search.empty":`No memory matched`,"search.scores":`cosine {cosine} · keywords {keyword} · boosted {boosted}`,"preset.actions":`Preset actions`,"tab.navigation":`Memory management`,"tab.settings":`Plugin configuration`,"tab.guide":`Plugin configuration guide`,"guide.start":`Getting started`,"guide.intro":`Choose your models and conversations, then try a search with one memory. The following sections explain when the bot saves and recalls memories, how to use profiles, and how Dream organizes existing memories.`,"guide.contents":`On this page`,"guide.models.title":`Choose your models`,"guide.models.text":`Under Plugin configuration → Model configuration, choose a main model that supports tool calls. It extracts and organizes memories and updates user profiles and persona cards. The recall model decides whether to look up memories. The embedding model converts memories and queries into vectors so the plugin can compare their meanings. An optional reranker reorders the candidate memories by their relevance to the query. Select Save settings to apply these choices to all presets in this plugin instance.`,"guide.openSettings":`Open plugin configuration`,"guide.rules.title":`Choose which conversations use automatic extraction`,"guide.rules.text":`Open Conversation rules → Capabilities → LivingMemory and set the extraction interval. The default is 60 chat messages. To enable automatic extraction in just one group, set the global interval to 0 and that group’s interval to 60.`,"guide.check.title":`Try a search with one memory`,"guide.check.text":`Under Memories, select New memory, choose a preset, and save “I drink my coffee without sugar.” Under Recall test for the same preset, search for “How do I like my coffee?” to see the matches. The test leaves snapshots unchanged. Under Snapshots you can read the snapshot from an actual chat. Expand Recall details to see the search terms and matching memories.`,"guide.timing":`When extraction and recall run`,"guide.buffer.title":`Check the chat buffer before raising an interval`,"guide.buffer.text":`In ChatLuna, open Plugins → Conversation and routing → @chatluna/chat-observer and adjust the buffer limit. Each channel keeps its latest 200 messages by default. Extraction and recall can only count chats still in that buffer. For example, a 300-message extraction interval can never be reached with a 200-message buffer. Even with a shorter interval, messages evicted between checks cannot be read later.`,"guide.context":`Snapshots and user profiles`,"guide.interval.title":`How does the recall interval differ from the history length?`,"guide.interval.text":`The bot checks after it finishes sending a reply. It recalls after the first reply, then waits until enough new messages have accumulated. Set the interval to 0 to disable automatic recall. The history length sets how many messages to read, up to and including the final part of the reply, to prepare a snapshot for future turns. Both default to 20 messages.`,"guide.overheard.title":`When can chat between group members trigger extraction?`,"guide.overheard.text":`Overheard extraction is off by default. Group chatter alone will not trigger extraction. Once the bot replies, the plugin counts unprocessed messages up to that reply, including earlier chatter, and starts extraction if the interval has been reached. With overheard extraction on, group members can reach the threshold on their own without calling the bot or waiting for a reply.`,"guide.sharing.title":`Can two groups using the same preset share a snapshot?`,"guide.sharing.text":`Each conversation has its own snapshot by default. To share one between two groups using the same preset, select preset sharing in both groups’ conversation rules. The groups share recall results; each still reads its own chat history and tracks its own recall interval. A group with conversation isolation enabled always uses its own snapshot and searches only its own and global memories within the preset.`,"guide.profiles.title":`How do I use existing user profiles in a chat?`,"guide.profiles.text":`By default, profiles are updated after extraction or Dream, and each person needs at least three linked active memories. You can change these settings under Plugin configuration. To use existing profiles during a chat, enable profile injection in the conversation rule (off by default). The bot receives profiles for users who spoke in the recent messages leading up to the wake, using the same history length as recall.`,"guide.dream":`How Dream organizes memories`,"guide.dream.intro":`Dream uses the main model to compare memories and decide which to keep, update, merge, split, or archive. For example, “I take my coffee without sugar” and “I like unsweetened coffee” can become a single preference. Choose a main model with a context window of at least 200k tokens for Dream.`,"guide.dream.auto.title":`Automatic runs start with newly extracted memories`,"guide.dream.auto.text":`Conversation rules enable Dream after extraction by default. For each newly saved memory, Dream looks for related active memories already in the same preset and reviews them together. If it finds no related older memory, the new entry stays as it is.`,"guide.dream.manual.title":`Manual runs review a whole preset`,"guide.dream.manual.text":`Once a preset has at least 30 active memories, select it under Memories and click Run Dream. Dream groups its active memories by similarity and reviews each group in turn. The 30-memory minimum applies only to manual runs.`,"guide.dream.result.title":`See what changed`,"guide.dream.result.text":`Open Jobs for the same preset to see how many memories Dream processed, which operations it performed, and any errors. Changes are saved directly to Memories. To see the original entries after a merge or split, change the status filter to Archived.`,"settings.scope":`Plugin settings apply to all presets.`,"settings.save":`Save settings`,"settings.discard":`Discard changes`,"settings.saved":`Settings saved`,"settings.noEntry":`This instance was not loaded from a configuration file and cannot be edited here.`,"settings.noSchema":`The LivingMemory configuration form is unavailable.`};function n(n){n.locale.register(`livingmemory`,{zh:e,en:t}),n.slots.route({path:`/livingmemory`,page:async()=>(await import(`./page-EGG2hcC3.js`)).LivingMemoryPage,title:`LivingMemory`,icon:`brain`,order:36,group:`capabilities`,groupOrder:36})}export{n as default};
|
package/lib/index.js
CHANGED
|
@@ -23,10 +23,10 @@ const ROUTE_SCHEMA = Schema$1.object({
|
|
|
23
23
|
extractionWindowMessages: Schema$1.natural().max(360).default(60).label("从聊天中提取记忆的间隔").description("累计多少条消息后从聊天中提取记忆;0 表示关闭记忆提取。"),
|
|
24
24
|
extractionIncludeOverheard: Schema$1.boolean().default(false).label("允许群友闲聊触发记忆提取").description("开启后,bot 未参与的群友闲聊也会触发记忆提取。"),
|
|
25
25
|
enableAutoDream: Schema$1.boolean().default(true).label("是否在提取新记忆后进行 Dream 整理"),
|
|
26
|
-
recallIntervalMessages: Schema$1.natural().max(200).default(20).label("记忆自动召回的间隔").description("
|
|
26
|
+
recallIntervalMessages: Schema$1.natural().max(200).default(20).label("记忆自动召回的间隔").description("bot 发完一轮回复后检查,自上次召回起累计到此条数则自动召回;0 表示关闭记忆召回。"),
|
|
27
27
|
recallHistoryMessages: Schema$1.natural().min(1).max(200).default(20).label("用于召回记忆的聊天消息数").description("使用多少条聊天信息作为上下文来召回记忆,建议与记忆自动召回的间隔保持一致。"),
|
|
28
28
|
snapshotScope: Schema$1.union([Schema$1.const("conversation").description("每一个会话拥有独立记忆快照"), Schema$1.const("preset").description("所有会话共享一个记忆快照")]).default("conversation").label("记忆快照的使用范围").description("开启「会话记忆隔离」时所有会话始终拥有一个独立记忆快照。"),
|
|
29
|
-
snapshotMaxLines: Schema$1.natural().min(5).max(50).default(
|
|
29
|
+
snapshotMaxLines: Schema$1.natural().min(5).max(50).default(10).label("记忆快照的最大行数"),
|
|
30
30
|
enableConversationIsolation: Schema$1.boolean().default(false).label("会话记忆隔离").description("记忆召回与记忆检索工具只检索来源于当前会话的记忆和全局记忆。"),
|
|
31
31
|
enableSnapshotInjection: Schema$1.boolean().default(true).label("向 bot 注入记忆快照"),
|
|
32
32
|
enableUserProfileInjection: Schema$1.boolean().default(false).label("向 bot 注入用户画像")
|
|
@@ -284,8 +284,8 @@ function formatLogJson(value, indent) {
|
|
|
284
284
|
const normalized = normalizeValue(value, "", /* @__PURE__ */ new WeakSet());
|
|
285
285
|
return JSON.stringify(normalized, null, indent);
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
return
|
|
287
|
+
function formatLogBlock({ title, value }) {
|
|
288
|
+
return `------------${title}------------\n${typeof value === "string" ? value : formatLogJson(value, 2)}`;
|
|
289
289
|
}
|
|
290
290
|
var LivingMemoryLogger = class LivingMemoryLogger {
|
|
291
291
|
sink;
|
|
@@ -309,7 +309,7 @@ var LivingMemoryLogger = class LivingMemoryLogger {
|
|
|
309
309
|
try {
|
|
310
310
|
const { event, detail, blocks } = render(this.context);
|
|
311
311
|
let content = detail;
|
|
312
|
-
if (blocks?.length) content += "\n" + blocks.map(
|
|
312
|
+
if (blocks?.length) content += "\n" + blocks.map(formatLogBlock).join("\n\n");
|
|
313
313
|
this.summary(event, content);
|
|
314
314
|
} catch (error) {
|
|
315
315
|
this.reportFailure(error);
|
|
@@ -810,7 +810,7 @@ const snapshotLineSchema = requiredText(`一条完整的记忆内容,使用单
|
|
|
810
810
|
const memoryPassTool = {
|
|
811
811
|
name: "living_memory_pass",
|
|
812
812
|
description: "记忆快照更新跳过工具,当你认为旧快照已经足够应付未来聊天话题,不需要更新时,使用此工具。",
|
|
813
|
-
schema: Schema$1.object({})
|
|
813
|
+
schema: Schema$1.object({ reason: requiredText("本次无需更新记忆快照的简短原因。") })
|
|
814
814
|
};
|
|
815
815
|
const memoryUpdateSnapshotTool = {
|
|
816
816
|
name: "living_memory_update_snapshot",
|
|
@@ -4608,9 +4608,15 @@ var ModelCallLogs = class {
|
|
|
4608
4608
|
...message,
|
|
4609
4609
|
content: message.content.slice(1)
|
|
4610
4610
|
} : message;
|
|
4611
|
+
const entries = message.role === "tool" && (this.stage === "recall" || this.stage === "dream") ? message.content.filter((block) => block.type === "tool-result").map((block) => ({
|
|
4612
|
+
key: `tool-call:${block.toolCallId}`,
|
|
4613
|
+
value: `${block.toolName}(结果已在工具日志中显示)`
|
|
4614
|
+
})) : logMessageParts(visible, displayText).map((value) => ({
|
|
4615
|
+
key: `${message.role}\n${value}`,
|
|
4616
|
+
value
|
|
4617
|
+
}));
|
|
4611
4618
|
const parts = [];
|
|
4612
|
-
for (const value of
|
|
4613
|
-
const key = `${message.role}\n${value}`;
|
|
4619
|
+
for (const { key, value } of entries) {
|
|
4614
4620
|
const count = (current.get(key) ?? 0) + 1;
|
|
4615
4621
|
current.set(key, count);
|
|
4616
4622
|
if (index >= newMessagesFrom || count > (this.previousParts.get(key) ?? 0)) parts.push(value);
|
|
@@ -5067,11 +5073,10 @@ var LivingMemoryRecallCoordinator = class {
|
|
|
5067
5073
|
logger.summary("召回结束", `${formatLogScope(scope)}; 结果:沿用当前快照`);
|
|
5068
5074
|
return;
|
|
5069
5075
|
}
|
|
5070
|
-
logger.summary("召回快照已更新", [
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
].join("\n"));
|
|
5076
|
+
logger.summary("召回快照已更新", [`${formatLogScope(scope)}; 命中记忆:${updatedSnapshot.matchedMemories.length} 条`, formatLogBlock({
|
|
5077
|
+
title: "召回快照",
|
|
5078
|
+
value: renderSnapshotText([updatedSnapshot])
|
|
5079
|
+
})].join("\n"));
|
|
5075
5080
|
} catch (error) {
|
|
5076
5081
|
this.controller.signal.throwIfAborted();
|
|
5077
5082
|
await this.repository.createFailedJob(scope, "recall", input, error, startedAt);
|
|
@@ -6070,9 +6075,6 @@ const normalizeManualUserProfileContent = (content) => {
|
|
|
6070
6075
|
};
|
|
6071
6076
|
/** 送入画像的记忆优先级:重要度降序,同重要度取更新更晚者。 */
|
|
6072
6077
|
const compareEntriesByProfilePriority = (left, right) => (right.importance ?? .5) - (left.importance ?? .5) || +right.updatedAt - +left.updatedAt;
|
|
6073
|
-
const collectUserProfileSpeakerKeys = (messages) => {
|
|
6074
|
-
return [...new Set(messages.filter((message) => message.role === "user").map((message) => message.speakerKey?.trim()).filter((key) => Boolean(key)))];
|
|
6075
|
-
};
|
|
6076
6078
|
var LivingMemoryUserProfileService = class {
|
|
6077
6079
|
ctx;
|
|
6078
6080
|
config;
|
|
@@ -8198,7 +8200,15 @@ var LivingMemoryConversationHooks = class {
|
|
|
8198
8200
|
if (!reply || !sent?.own || !sent.messageIds.length) return;
|
|
8199
8201
|
const state = this.conversations.get(reply.conversationKey);
|
|
8200
8202
|
if (state?.scope.sessionId !== reply.sessionId || state.scope.presetId !== reply.presetId) return;
|
|
8201
|
-
state.deliveries.get(reply.turn)
|
|
8203
|
+
const delivery = state.deliveries.get(reply.turn);
|
|
8204
|
+
if (!delivery) return;
|
|
8205
|
+
const routeId = session.routeId;
|
|
8206
|
+
const id = `${routeId}:${sent.messageIds[0]}`;
|
|
8207
|
+
delivery.pendingMessageIds.add(id);
|
|
8208
|
+
delivery.lastReply = {
|
|
8209
|
+
id,
|
|
8210
|
+
routeId
|
|
8211
|
+
};
|
|
8202
8212
|
}));
|
|
8203
8213
|
this.disposables.push(this.ctx.on("chatluna/agent-turn", ({ agent, reason }) => {
|
|
8204
8214
|
const running = this.turns.get(agent);
|
|
@@ -8221,109 +8231,76 @@ var LivingMemoryConversationHooks = class {
|
|
|
8221
8231
|
isCurrent({ state }) {
|
|
8222
8232
|
return this.active && this.conversations.get(state.scope.conversationId) === state;
|
|
8223
8233
|
}
|
|
8224
|
-
|
|
8234
|
+
onInputQueued(agent, message) {
|
|
8225
8235
|
const key = agent.options.conversationKey;
|
|
8226
8236
|
if (key === void 0) return;
|
|
8227
8237
|
const trigger = findTurnTrigger([message]);
|
|
8228
8238
|
if (!trigger?.wake || this.queued.has(trigger.wake)) return;
|
|
8229
|
-
|
|
8230
|
-
const through = trigger.kind === "notice" ? this.options.history.lastPosition(key) : void 0;
|
|
8231
|
-
return this.captureWindow(agent, key, trigger, through);
|
|
8232
|
-
});
|
|
8233
|
-
this.queued.set(trigger.wake, preparation);
|
|
8234
|
-
await preparation;
|
|
8239
|
+
this.queued.set(trigger.wake, this.captureWindow(agent, key, trigger));
|
|
8235
8240
|
}
|
|
8236
|
-
captureWindow(agent, key, trigger
|
|
8237
|
-
const
|
|
8238
|
-
const observed = trigger?.kind === "chat" ? this.options.history.locateUser(key, trigger, contextStart) : void 0;
|
|
8239
|
-
const position = observed?.position
|
|
8241
|
+
captureWindow(agent, key, trigger) {
|
|
8242
|
+
const revision = this.revisions.get(key);
|
|
8243
|
+
const observed = trigger?.kind === "chat" ? this.options.history.locateUser(key, trigger, revision?.contextStart) : void 0;
|
|
8244
|
+
const position = trigger?.kind === "notice" ? this.options.history.lastPosition(key) : observed?.position;
|
|
8240
8245
|
const routeId = trigger?.kind === "chat" ? observed?.routeId ?? trigger.routeId : agent.options.location?.route;
|
|
8241
8246
|
const noticeSessionId = trigger?.kind === "notice" ? String(agent.session.id) : void 0;
|
|
8242
8247
|
const settings = this.options.settingsOf(key, agent.options.location, routeId, noticeSessionId);
|
|
8243
|
-
const
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
if (needsHistory && position !== void 0) {
|
|
8247
|
-
if (custom && !routeId) this.options.logger.diagnosticSummary(() => ({
|
|
8248
|
-
event: "跳过记忆召回",
|
|
8249
|
-
detail: `会话:${key}; 原因:本次唤醒未指定来源路由,无法确定适用的对话规则`
|
|
8250
|
-
}));
|
|
8251
|
-
else rows = this.options.history.recent({ conversationId: key }, settings.recallHistoryMessages, position, contextStart, custom && settings.enableConversationIsolation ? routeId : void 0);
|
|
8248
|
+
const speakers = /* @__PURE__ */ new Set();
|
|
8249
|
+
if (settings.enableUserProfileInjection && position !== void 0 && (!isCustomConversation(key) || routeId)) {
|
|
8250
|
+
for (const row of this.recentChat(key, settings, position, routeId)) if (row.role === "user" && row.userId !== void 0) speakers.add(createSpeakerKey(row.platform, row.userId));
|
|
8252
8251
|
}
|
|
8253
8252
|
const presetId = this.agentPreset(agent);
|
|
8254
8253
|
return {
|
|
8255
|
-
|
|
8254
|
+
speakerKeys: [...speakers],
|
|
8256
8255
|
settings,
|
|
8257
8256
|
position,
|
|
8258
8257
|
presetId,
|
|
8259
|
-
|
|
8258
|
+
revision,
|
|
8260
8259
|
routeId
|
|
8261
8260
|
};
|
|
8262
8261
|
}
|
|
8262
|
+
recentChat(key, settings, through, routeId) {
|
|
8263
|
+
const isolatedRoute = isCustomConversation(key) && settings.enableConversationIsolation ? routeId : void 0;
|
|
8264
|
+
return this.options.history.recent({ conversationId: key }, settings.recallHistoryMessages, through, this.revisions.get(key)?.contextStart, isolatedRoute);
|
|
8265
|
+
}
|
|
8263
8266
|
agentPreset(agent) {
|
|
8264
8267
|
return this.ctx.get("engines")?.presetOf(agent) ?? agent.options.presetId;
|
|
8265
8268
|
}
|
|
8266
|
-
async
|
|
8269
|
+
async beginTurn(agent, turn, messages) {
|
|
8270
|
+
if (this.turns.get(agent)?.number === turn) return;
|
|
8271
|
+
this.turns.delete(agent);
|
|
8272
|
+
const key = agent.options.conversationKey;
|
|
8273
|
+
if (key === void 0) return;
|
|
8267
8274
|
try {
|
|
8268
|
-
const
|
|
8269
|
-
const
|
|
8275
|
+
const trigger = findTurnTrigger(messages);
|
|
8276
|
+
const window = (trigger?.wake && this.queued.get(trigger.wake)) ?? this.captureWindow(agent, key, trigger);
|
|
8270
8277
|
const head = await this.ctx.conversations.current(key);
|
|
8271
8278
|
if (!head || String(head.sessionId) !== String(agent.session.id)) return;
|
|
8272
|
-
if (!this.active || this.revisions.get(key) !==
|
|
8279
|
+
if (!this.active || this.revisions.get(key) !== window.revision) return;
|
|
8273
8280
|
const presetId = this.agentPreset(agent) ?? head.presetId;
|
|
8274
|
-
if (window.presetId !== void 0 && presetId !== window.presetId) return;
|
|
8275
|
-
if (!presetId) return {
|
|
8276
|
-
kind: "awaiting-preset",
|
|
8277
|
-
window
|
|
8278
|
-
};
|
|
8281
|
+
if (!presetId || window.presetId !== void 0 && presetId !== window.presetId) return;
|
|
8279
8282
|
if (head.presetId && head.presetId !== presetId && this.conversations.get(key)?.scope.presetId !== presetId) return;
|
|
8280
|
-
const { settings, position } = window;
|
|
8283
|
+
const { settings, position, routeId, speakerKeys } = window;
|
|
8281
8284
|
const boundary = position === void 0 ? this.options.history.lastPosition(key) : position - 1;
|
|
8282
8285
|
const state = this.stateOf(key, String(head.sessionId), presetId, boundary);
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8286
|
+
this.turns.set(agent, {
|
|
8287
|
+
state,
|
|
8288
|
+
settings,
|
|
8289
|
+
speakerKeys,
|
|
8290
|
+
routeId,
|
|
8291
|
+
number: turn
|
|
8292
|
+
});
|
|
8293
|
+
state.deliveries.set(turn, {
|
|
8294
|
+
settings,
|
|
8295
|
+
routeId,
|
|
8296
|
+
pendingMessageIds: /* @__PURE__ */ new Set(),
|
|
8297
|
+
drained: false
|
|
8298
|
+
});
|
|
8294
8299
|
} catch (error) {
|
|
8295
|
-
this.options.logger.summary("
|
|
8296
|
-
return;
|
|
8300
|
+
this.options.logger.summary("准备本轮记忆上下文失败", key, "warn", error);
|
|
8297
8301
|
}
|
|
8298
8302
|
}
|
|
8299
|
-
async
|
|
8300
|
-
if (this.turns.get(agent)?.number === turn) return;
|
|
8301
|
-
this.turns.delete(agent);
|
|
8302
|
-
const key = agent.options.conversationKey;
|
|
8303
|
-
if (key === void 0) return;
|
|
8304
|
-
const trigger = findTurnTrigger(messages);
|
|
8305
|
-
const queued = trigger?.wake && this.queued.get(trigger.wake);
|
|
8306
|
-
let prepared;
|
|
8307
|
-
if (queued) {
|
|
8308
|
-
prepared = await queued;
|
|
8309
|
-
if (prepared?.kind === "awaiting-preset") {
|
|
8310
|
-
const { window } = prepared;
|
|
8311
|
-
prepared = await this.prepareTurn(agent, key, () => window);
|
|
8312
|
-
}
|
|
8313
|
-
} else prepared = await this.prepareTurn(agent, key, () => this.captureWindow(agent, key, trigger));
|
|
8314
|
-
if (prepared?.kind !== "ready" || !this.isCurrent(prepared.input)) return;
|
|
8315
|
-
const { input } = prepared;
|
|
8316
|
-
this.turns.set(agent, {
|
|
8317
|
-
...input,
|
|
8318
|
-
number: turn
|
|
8319
|
-
});
|
|
8320
|
-
input.state.deliveries.set(turn, {
|
|
8321
|
-
settings: input.settings,
|
|
8322
|
-
pendingMessageIds: /* @__PURE__ */ new Set(),
|
|
8323
|
-
drained: false
|
|
8324
|
-
});
|
|
8325
|
-
}
|
|
8326
|
-
async renderInjection({ state, chatHistory, settings }) {
|
|
8303
|
+
async renderInjection({ state, speakerKeys, settings }) {
|
|
8327
8304
|
const { scope } = state;
|
|
8328
8305
|
const sections = [];
|
|
8329
8306
|
if (settings.enableSnapshotInjection) {
|
|
@@ -8332,7 +8309,6 @@ var LivingMemoryConversationHooks = class {
|
|
|
8332
8309
|
if (text.length > 0) sections.push(`<memory>\n${text}\n</memory>`);
|
|
8333
8310
|
}
|
|
8334
8311
|
if (settings.enableUserProfileInjection) {
|
|
8335
|
-
const speakerKeys = collectUserProfileSpeakerKeys(chatHistory);
|
|
8336
8312
|
const profiles = await this.options.userProfiles.renderForSpeakers(scope.presetId, speakerKeys);
|
|
8337
8313
|
if (profiles.trim().length > 0) sections.push(`<users_profile>\n${profiles.trim()}\n</users_profile>`);
|
|
8338
8314
|
}
|
|
@@ -8348,7 +8324,7 @@ var LivingMemoryConversationHooks = class {
|
|
|
8348
8324
|
const existing = this.conversations.get(key);
|
|
8349
8325
|
if (!sessionChanged && existing?.scope.sessionId === sessionId && existing.scope.presetId === presetId) return;
|
|
8350
8326
|
const boundary = this.options.history.lastPosition(key);
|
|
8351
|
-
this.reset(key, sessionChanged ? boundary :
|
|
8327
|
+
if (existing || sessionChanged || presetId === void 0) this.reset(key, sessionChanged ? boundary : void 0);
|
|
8352
8328
|
if (presetId !== void 0) this.stateOf(key, sessionId, presetId, boundary);
|
|
8353
8329
|
}
|
|
8354
8330
|
reset(conversationId, contextStart = this.revisions.get(conversationId)?.contextStart ?? -1) {
|
|
@@ -8396,17 +8372,17 @@ var LivingMemoryConversationHooks = class {
|
|
|
8396
8372
|
async onObservedReply(event) {
|
|
8397
8373
|
const key = event.conversationKey;
|
|
8398
8374
|
const state = this.conversations.get(key);
|
|
8399
|
-
|
|
8400
|
-
|
|
8375
|
+
if (!state) return;
|
|
8376
|
+
const { id, routeId } = event.message;
|
|
8401
8377
|
for (const [turn, delivery] of state.deliveries) {
|
|
8402
8378
|
if (!delivery.pendingMessageIds.delete(id)) continue;
|
|
8403
8379
|
const position = this.options.history.locate(key, event.message, state.scope);
|
|
8404
|
-
if (
|
|
8380
|
+
if (delivery.lastReply?.id === id) delivery.lastReply.position = position;
|
|
8381
|
+
if (!delivery.settings.extractionIncludeOverheard && position !== void 0 && (!delivery.extractionEnd || position > delivery.extractionEnd.position)) delivery.extractionEnd = {
|
|
8405
8382
|
position,
|
|
8406
|
-
routeId
|
|
8383
|
+
routeId
|
|
8407
8384
|
};
|
|
8408
|
-
|
|
8409
|
-
await this.finishDeliveryIfReady(state, turn, delivery);
|
|
8385
|
+
await Promise.all([this.finishDeliveryIfReady(state, turn, delivery), delivery.settings.extractionIncludeOverheard && position !== void 0 ? this.queueExtraction(state, delivery.settings, position, routeId) : void 0]);
|
|
8410
8386
|
return;
|
|
8411
8387
|
}
|
|
8412
8388
|
}
|
|
@@ -8426,7 +8402,21 @@ var LivingMemoryConversationHooks = class {
|
|
|
8426
8402
|
async finishDeliveryIfReady(state, turn, delivery) {
|
|
8427
8403
|
if (!delivery.drained || delivery.pendingMessageIds.size > 0) return;
|
|
8428
8404
|
state.deliveries.delete(turn);
|
|
8429
|
-
|
|
8405
|
+
const { settings, extractionEnd } = delivery;
|
|
8406
|
+
await Promise.all([this.queueRecall(state, delivery), extractionEnd && this.queueExtraction(state, settings, extractionEnd.position, extractionEnd.routeId)]);
|
|
8407
|
+
}
|
|
8408
|
+
async queueRecall(state, delivery) {
|
|
8409
|
+
const { lastReply } = delivery;
|
|
8410
|
+
if (lastReply?.position === void 0 || lastReply.position <= state.boundary) return;
|
|
8411
|
+
const { position, routeId } = lastReply;
|
|
8412
|
+
const { scope } = state;
|
|
8413
|
+
const key = scope.conversationId;
|
|
8414
|
+
const settings = isCustomConversation(key) && delivery.routeId !== routeId ? this.options.settingsOf(key, void 0, routeId) : delivery.settings;
|
|
8415
|
+
if (settings.recallIntervalMessages === 0) return;
|
|
8416
|
+
const rows = this.recentChat(key, settings, position, routeId);
|
|
8417
|
+
if (rows.at(-1)?.position !== position) return;
|
|
8418
|
+
const history = toHistoryTranscriptMessages(scope, rows);
|
|
8419
|
+
await this.options.recall.queue(settings, scope, history, position, routeId);
|
|
8430
8420
|
}
|
|
8431
8421
|
async queueExtraction(state, settings, eligiblePosition, routeId) {
|
|
8432
8422
|
if (settings.extractionWindowMessages === 0) return;
|
|
@@ -8439,7 +8429,7 @@ var LivingMemoryConversationHooks = class {
|
|
|
8439
8429
|
}, state.boundary, eligiblePosition);
|
|
8440
8430
|
}
|
|
8441
8431
|
logScheduleError(conversationId, error) {
|
|
8442
|
-
this.options.logger.summary("
|
|
8432
|
+
this.options.logger.summary("记忆任务调度失败", `会话:${conversationId}`, "warn", error);
|
|
8443
8433
|
}
|
|
8444
8434
|
};
|
|
8445
8435
|
function findTurnTrigger(messages) {
|
|
@@ -8493,7 +8483,7 @@ const DEFAULT_CONFIG = {
|
|
|
8493
8483
|
mainModel: "无",
|
|
8494
8484
|
subModel: "无",
|
|
8495
8485
|
userProfileMinMemoryCount: 3,
|
|
8496
|
-
userProfileMemoryLimit:
|
|
8486
|
+
userProfileMemoryLimit: 30,
|
|
8497
8487
|
embeddingModel: "无",
|
|
8498
8488
|
rerankModel: "无",
|
|
8499
8489
|
memorySearchToolMaxResults: 15,
|