@furongjun1999/dsh-memory 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks.js +8 -1
- package/package.json +1 -1
- package/src/hooks.ts +9 -1
package/lib/hooks.js
CHANGED
|
@@ -86,8 +86,12 @@ export function installMemoryHooks(ctx, bridge, opts) {
|
|
|
86
86
|
ctx.on('session/event', (_session, event) => {
|
|
87
87
|
if (event.type === 'user/message' && opts.userMessage) {
|
|
88
88
|
// 只记真实用户输入(kind='user'),跳过插件注入/系统上下文
|
|
89
|
-
if (event.data.source?.kind !== 'user')
|
|
89
|
+
if (event.data.source?.kind !== 'user') {
|
|
90
|
+
// T4 诊断(2026-08-30):dsh 端对话零写入排查——记录被滤事件的实际
|
|
91
|
+
// source.kind(若 dsh 新版改了 kind 值,此处日志可定位)
|
|
92
|
+
ctx.logger.info(`dsh-memory: user/message 事件被滤(source.kind=${event.data.source?.kind ?? 'undefined'})`);
|
|
90
93
|
return;
|
|
94
|
+
}
|
|
91
95
|
const text = extractText(event.data.content);
|
|
92
96
|
if (!text)
|
|
93
97
|
return;
|
|
@@ -95,6 +99,9 @@ export function installMemoryHooks(ctx, bridge, opts) {
|
|
|
95
99
|
if (safe === null)
|
|
96
100
|
return;
|
|
97
101
|
memorize('remember', { content: safe, importance: opts.importance, tags: ['dsh', 'user'] });
|
|
102
|
+
// T4:用用户消息做一次语义召回——触发灵枢 _note_reuse 落库(复用观测),
|
|
103
|
+
// 召回结果同时预热灵枢检索缓存(timeline 只读不触发复用统计)
|
|
104
|
+
memorize('recall', { query: safe.slice(0, 200), limit: 3 });
|
|
98
105
|
}
|
|
99
106
|
else if (event.type === 'assistant/message' && opts.assistantMessage) {
|
|
100
107
|
const text = extractText(event.data.message.content);
|
package/package.json
CHANGED
package/src/hooks.ts
CHANGED
|
@@ -114,12 +114,20 @@ export function installMemoryHooks(ctx: Context, bridge: LingshuBridge, opts: Me
|
|
|
114
114
|
ctx.on('session/event', (_session, event: SessionEvent) => {
|
|
115
115
|
if (event.type === 'user/message' && opts.userMessage) {
|
|
116
116
|
// 只记真实用户输入(kind='user'),跳过插件注入/系统上下文
|
|
117
|
-
if (event.data.source?.kind !== 'user')
|
|
117
|
+
if (event.data.source?.kind !== 'user') {
|
|
118
|
+
// T4 诊断(2026-08-30):dsh 端对话零写入排查——记录被滤事件的实际
|
|
119
|
+
// source.kind(若 dsh 新版改了 kind 值,此处日志可定位)
|
|
120
|
+
ctx.logger.info(`dsh-memory: user/message 事件被滤(source.kind=${event.data.source?.kind ?? 'undefined'})`)
|
|
121
|
+
return
|
|
122
|
+
}
|
|
118
123
|
const text = extractText(event.data.content)
|
|
119
124
|
if (!text) return
|
|
120
125
|
const safe = sanitize(text) // 脱敏:纯凭据消息 → null → 跳过写入
|
|
121
126
|
if (safe === null) return
|
|
122
127
|
memorize('remember', { content: safe, importance: opts.importance, tags: ['dsh', 'user'] })
|
|
128
|
+
// T4:用用户消息做一次语义召回——触发灵枢 _note_reuse 落库(复用观测),
|
|
129
|
+
// 召回结果同时预热灵枢检索缓存(timeline 只读不触发复用统计)
|
|
130
|
+
memorize('recall', { query: safe.slice(0, 200), limit: 3 })
|
|
123
131
|
} else if (event.type === 'assistant/message' && opts.assistantMessage) {
|
|
124
132
|
const text = extractText(event.data.message.content)
|
|
125
133
|
if (!text) return
|