@restregular/dsh-memory 0.9.5 → 0.9.7

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.
@@ -1,297 +1,422 @@
1
- /**
2
- * Memory injection logic (M3) — pure functions, no cordis imports.
3
- *
4
- * Injection shape follows the official docs: a user-role message whose content
5
- * is a single `context` block with `contextForm: 'recall'`, prepended to the
6
- * messages that enter the step via the agent/pre-step waterfall.
7
- */
8
-
9
- import { estimateTokens } from '../provider/rerank.js'
10
- import { normalizeScopeInput } from '../provider/scope.js'
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-                               
20
-                               
21
-
22
-
23
-
24
-
25
- export const defaultInjectConfig = {
26
- enabled: true,
27
- tokenBudget: 500,
28
- topK: 5,
29
- }
30
-
31
- /** 召回注入能用到的那部分 provider 能力。 */
32
-
33
-
34
-
35
-
36
-
37
- /** 宿主里"按会话 id 找 live session"的那一小部分能力(拿不到就不做父会话召回)。 */
38
-
39
-
40
-
41
-
42
- /**
43
- * 把 config.extraScopes 规范化成 scope 键列表;非法项忽略并记一行日志
44
- * (配置写错不该让整个注入半边失效)。
45
- */
46
- export function normalizeExtraScopes(raw , warn = console.warn) {
47
- const out = []
48
- for (const item of raw) {
49
- const normalized = normalizeScopeInput(item)
50
- if (!normalized.ok) {
51
- warn(`[dsh-memory-inject] 忽略非法的 inject.extraScopes 项 ${JSON.stringify(item)}: ${normalized.message}`)
52
- continue
53
- }
54
- if (normalized.scope !== undefined && !out.includes(normalized.scope)) out.push(normalized.scope)
55
- }
56
- return out
57
- }
58
-
59
- /**
60
- * 无显式 scope 时的召回范围:当前会话 + 当前项目 + global(provider 解析)
61
- * + inject.extraScopes + 父会话(fork 时,只读召回)。
62
- * 任何一步拿不到都只降级,绝不抛(注入路径抛错会打断整个 agent 循环)。
63
- */
64
- export function resolveInjectScopes(
65
- memory ,
66
- agent ,
67
- extraScopes ,
68
- sessions ,
69
- ) {
70
- const scopes = []
71
- try {
72
- for (const scope of memory.resolveReadScopes?.(agent) ?? []) {
73
- if (!scopes.includes(scope)) scopes.push(scope)
74
- }
75
- } catch { /* 降级为 extraScopes */ }
76
- for (const scope of extraScopes) if (!scopes.includes(scope)) scopes.push(scope)
77
- // fork 出来的会话:父会话的记忆也值得召回(只读)。父会话可能已不在内存里,拿不到就跳过。
78
- try {
79
- const header = (agent )?.session?.header
80
- const parent = typeof header?.parentSession === 'string' ? header.parentSession : undefined
81
- if (parent !== undefined && header?.origin !== 'subagent') {
82
- if (sessions?.get?.(parent) !== undefined) {
83
- const scope = `session:${parent}`
84
- if (!scopes.includes(scope)) scopes.push(scope)
85
- }
86
- }
87
- } catch { /* 父会话召回是可选增强 */ }
88
- return scopes.length > 0 ? scopes : undefined
89
- }
90
-
91
- /** Minimal structural view of the messages we inspect (role + text blocks). */
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-                          
102
-                     
103
-                                  
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- /**
113
- * Extract the retrieval query: the text of the LAST user message. Synthetic
114
- * context injections (file notices etc.) are user-role too, so scanning from
115
- * the end finds the freshest human-visible input; empty text → no injection.
116
- */
117
- export function pickQueryText(messages ) {
118
- for (let i = messages.length - 1; i >= 0; i--) {
119
- const m = messages[i]
120
- if (m.role !== 'user') continue
121
- const text = (m.content ?? [])
122
- .filter((b) => b.type === 'text' && typeof b.text === 'string')
123
- .map((b) => b.text )
124
- .join(' ')
125
- .trim()
126
- if (text) return text
127
- }
128
- return ''
129
- }
130
-
131
- /**
132
- * 这一步的 messages 里是否已经有一条内容完全相同的召回块。
133
- *
134
- * 正常情况下永远不会命中:一个激活只有一个 MemoryInjector,而它自己用 lastText
135
- * 去重。但只要宿主把这条 entry 应用了两次(热重载/重新启用时旧 fiber 的
136
- * agent/pre-step 监听没被清掉),两个注入器就会各追加一条逐字相同的消息 ——
137
- * 表现在会话轨迹里就是同一轮「上下轮」卡片连着出现两次(2026-10-17 实况)。
138
- * 注入本身是"多一条也无害、少一条也不坏"的提示块,所以这里按内容做一次幂等:
139
- * 另一个实例已经放进去的同一段,就不要再放。
140
- */
141
- export function hasRecallMessage(
142
- messages ,
143
- text ,
144
- ) {
145
- for (const m of messages) {
146
- if (m.role !== 'user') continue
147
- if (m.source?.kind !== 'memory') continue
148
- const joined = (m.content ?? [])
149
- .filter((b) => b.type === 'text' && typeof b.text === 'string')
150
- .map((b) => b.text )
151
- .join('\n')
152
- if (joined === text) return true
153
- }
154
- return false
155
- }
156
-
157
- /** 召回的两种形态:旧的长文(300 字)与新的"印象"(短摘要 + 指路取全文)。 */
158
-
159
-                 
160
-
161
-           
162
-
163
-
164
-
165
- /** Render hits into a recall text block, greedily within the token budget. */
166
- export function renderRecallBlock(
167
- hits ,
168
- cfg ,
169
- options = {},
170
- ) {
171
- if (hits.length === 0) return null
172
- const impression = options.impression === true
173
- const chars = impression ? (options.chars ?? 120) : 300
174
- const header = impression
175
- ? '以下是与你这次请求可能相关的记忆摘要:'
176
- : '以下是与此请求可能相关的长期记忆,供参考(可用 memory_search 核实,用 memory_forget 删除):'
177
- let tokens = estimateTokens(header) + 4
178
- const lines = []
179
- for (const h of hits.slice(0, cfg.topK)) {
180
- const line = `- ${h.record.id.slice(0, 8)} ${h.record.content.replace(/\s+/g, ' ').slice(0, chars)}`
181
- const cost = estimateTokens(line) + 1
182
- if (tokens + cost > cfg.tokenBudget) break
183
- lines.push(line)
184
- tokens += cost
185
- }
186
- if (lines.length === 0) return null
187
- return { text: `${header}\n${lines.join('\n')}`, tokens }
188
- }
189
-
190
- /** The context block we prepend (matches the documented ContextForm 'recall'). */
191
- export function recallText(text ) {
192
- return text
193
- }
194
-
195
- /**
196
- * Turn-agnostic injector: searches memory for the step's query and returns the
197
- * recall text to append. The host middleware (apply.ts) wraps that text into a
198
- * real message via createUserMessage — a bare {role, content} object is NOT a
199
- * message and crashes the loop (see the 2026-10-10 incident below).
200
- *
201
- * Repeated identical injections are suppressed so a multi-step turn does not
202
- * repeat the same block before every model call.
203
- */
204
- /** 配置既可以给静态值,也可以给 getter —— 面板改了设置,下一步就生效。 */
205
-
206
-
207
- export class MemoryInjector {
208
- lastText = ''
209
- search
210
- cfg
211
- renderOptions
212
-
213
- constructor(
214
- search ,
215
- cfg ,
216
- renderOptions = {},
217
- ) {
218
- this.search = search
219
- this.cfg = cfg
220
- this.renderOptions = renderOptions
221
- }
222
-
223
- async maybeInject(
224
- input ,
225
- _decision ,
226
- ) {
227
- const cfg = typeof this.cfg === 'function' ? this.cfg() : this.cfg
228
- if (!cfg.enabled) return undefined
229
- const query = pickQueryText(input.messages)
230
- if (!query) return undefined
231
-
232
- let hits
233
- try {
234
- hits = await this.search(query, input.signal, input.scopes)
235
- } catch {
236
- return undefined // retrieval failure never breaks the agent loop
237
- }
238
-
239
- const options = typeof this.renderOptions === 'function' ? this.renderOptions() : this.renderOptions
240
- const block = renderRecallBlock(hits, cfg, options)
241
- if (!block || block.text === this.lastText) return undefined
242
- this.lastText = block.text
243
-
244
- return block.text
245
- }
246
- }
247
-
248
- /** 从 agent 上取会话 id;取不到就没有"每个会话只发一次摘要"的锚点。 */
249
- export function sessionIdOf(agent ) {
250
- const id = (agent )?.session?.id
251
- return typeof id === 'string' && id.length > 0 ? id : undefined
252
- }
253
-
254
- /** 摘要注入最多记住多少个会话(一个进程里开过的会话上界,防止 Set 无限长)。 */
255
- const MAX_DIGESTED_SESSIONS = 500
256
-
257
- /**
258
- * 会话摘要注入器:一个会话只注入一次"已有哪些记忆"的摘要。
259
- * 检索失败或结果为空也标记为已完成 —— 摘要不是必需品,不能每步重试。
260
- */
261
- export class MemoryDigester {
262
- done = new Set ()
263
- list
264
-
265
- constructor(
266
- list ,
267
- ) {
268
- this.list = list
269
- }
270
-
271
- async maybeDigest(
272
- sessionId ,
273
- scopes ,
274
- render ,
275
- ) {
276
- if (sessionId === undefined || this.done.has(sessionId)) return undefined
277
- this.markDone(sessionId)
278
- let records
279
- try {
280
- records = await this.list(scopes)
281
- } catch {
282
- return undefined
283
- }
284
- return render(records) ?? undefined
285
- }
286
-
287
- markDone(sessionId ) {
288
- this.done.add(sessionId)
289
- if (this.done.size > MAX_DIGESTED_SESSIONS) {
290
- const oldest = this.done.values().next()
291
- if (!oldest.done) this.done.delete(oldest.value)
292
- }
293
- }
294
- }
1
+ /**
2
+ * Memory injection logic (M3) — pure functions, no cordis imports.
3
+ *
4
+ * Injection shape follows the official docs: a user-role message whose content
5
+ * is a single `context` block with `contextForm: 'recall'`, prepended to the
6
+ * messages that enter the step via the agent/pre-step waterfall.
7
+ */
8
+
9
+ import { estimateTokens } from '../provider/rerank.js'
10
+ import { normalizeScopeInput } from '../provider/scope.js'
11
+ import { InjectionState } from './state.js'
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+                               
21
+                               
22
+
23
+
24
+
25
+
26
+ export const defaultInjectConfig = {
27
+ enabled: true,
28
+ tokenBudget: 500,
29
+ topK: 5,
30
+ }
31
+
32
+ /** 召回注入能用到的那部分 provider 能力。 */
33
+
34
+
35
+
36
+                            
37
+
38
+
39
+
40
+ /** 宿主里"按会话 id 找 live session"的那一小部分能力(拿不到就不做父会话召回)。 */
41
+
42
+
43
+
44
+
45
+ /**
46
+ * 把 config.extraScopes 规范化成 scope 键列表;非法项忽略并记一行日志
47
+ * (配置写错不该让整个注入半边失效)。
48
+ */
49
+ export function normalizeExtraScopes(raw , warn = console.warn) {
50
+ const out = []
51
+ for (const item of raw) {
52
+ const normalized = normalizeScopeInput(item)
53
+ if (!normalized.ok) {
54
+ warn(`[dsh-memory-inject] 忽略非法的 inject.extraScopes 项 ${JSON.stringify(item)}: ${normalized.message}`)
55
+ continue
56
+ }
57
+ if (normalized.scope !== undefined && !out.includes(normalized.scope)) out.push(normalized.scope)
58
+ }
59
+ return out
60
+ }
61
+
62
+ /**
63
+ * 无显式 scope 时的召回范围:当前会话 + 当前项目 + global(provider 解析)
64
+ * + inject.extraScopes + 父会话(fork 时,只读召回)。
65
+ * 任何一步拿不到都只降级,绝不抛(注入路径抛错会打断整个 agent 循环)。
66
+ */
67
+ export function resolveInjectScopes(
68
+ memory ,
69
+ agent ,
70
+ extraScopes ,
71
+ sessions ,
72
+ ) {
73
+ const scopes = []
74
+ try {
75
+ for (const scope of memory.resolveReadScopes?.(agent) ?? []) {
76
+ if (!scopes.includes(scope)) scopes.push(scope)
77
+ }
78
+ } catch { /* 降级为 extraScopes */ }
79
+ for (const scope of extraScopes) if (!scopes.includes(scope)) scopes.push(scope)
80
+ // fork 出来的会话:父会话的记忆也值得召回(只读)。父会话可能已不在内存里,拿不到就跳过。
81
+ try {
82
+ const header = (agent )?.session?.header
83
+ const parent = typeof header?.parentSession === 'string' ? header.parentSession : undefined
84
+ if (parent !== undefined && header?.origin !== 'subagent') {
85
+ if (sessions?.get?.(parent) !== undefined) {
86
+ const scope = `session:${parent}`
87
+ if (!scopes.includes(scope)) scopes.push(scope)
88
+ }
89
+ }
90
+ } catch { /* 父会话召回是可选增强 */ }
91
+ return scopes.length > 0 ? scopes : undefined
92
+ }
93
+
94
+ /** Minimal structural view of the messages we inspect (role + text blocks). */
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+                          
105
+                     
106
+                                  
107
+
108
+
109
+                             
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ /**
118
+ * Extract the retrieval query: the text of the LAST user message. Synthetic
119
+ * context injections (file notices etc.) are user-role too, so scanning from
120
+ * the end finds the freshest human-visible input; empty text → no injection.
121
+ */
122
+ export function pickQueryText(messages ) {
123
+ for (let i = messages.length - 1; i >= 0; i--) {
124
+ const m = messages[i]
125
+ if (m.role !== 'user') continue
126
+ const text = (m.content ?? [])
127
+ .filter((b) => b.type === 'text' && typeof b.text === 'string')
128
+ .map((b) => b.text )
129
+ .join(' ')
130
+ .trim()
131
+ if (text) return text
132
+ }
133
+ return ''
134
+ }
135
+
136
+ /**
137
+ * 这一步的 messages 里是否已经有一条内容完全相同的召回块。
138
+ *
139
+ * 正常情况下永远不会命中:一个激活只有一个 MemoryInjector,而它自己用
140
+ * 会话级 lastText 去重。但只要宿主把这条 entry 应用了两次(热重载/重新启用时
141
+ * 旧 fiber 的 agent/pre-step 监听没被清掉),两个注入器就会各追加一条逐字相同的消息 ——
142
+ * 表现在会话轨迹里就是同一轮「上下轮」卡片连着出现两次(2026-10-17 实况)。
143
+ * 注入本身是"多一条也无害、少一条也不坏"的提示块,所以这里按内容做一次幂等:
144
+ * 另一个实例已经放进去的同一段,就不要再放。
145
+ */
146
+ export function hasRecallMessage(
147
+ messages ,
148
+ text ,
149
+ ) {
150
+ for (const m of messages) {
151
+ if (m.role !== 'user') continue
152
+ if (m.source?.kind !== 'memory') continue
153
+ const joined = (m.content ?? [])
154
+ .filter((b) => b.type === 'text' && typeof b.text === 'string')
155
+ .map((b) => b.text )
156
+ .join('\n')
157
+ if (joined === text) return true
158
+ }
159
+ return false
160
+ }
161
+
162
+ /** 召回的两种形态:旧的长文(300 字)与新的"印象"(短摘要 + 指路取全文)。 */
163
+
164
+                 
165
+
166
+           
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+          
179
+
180
+
181
+
182
+
183
+ /** Render hits into a recall text block, greedily within the token budget. */
184
+ export function renderRecallBlock(
185
+ hits ,
186
+ cfg ,
187
+ options = {},
188
+ ) {
189
+ if (hits.length === 0) return null
190
+ const impression = options.impression === true
191
+ const chars = impression ? (options.chars ?? 120) : 300
192
+ const header = impression
193
+ ? '以下是与你这次请求可能相关的记忆摘要:'
194
+ : '以下是与此请求可能相关的长期记忆,供参考(可用 memory_search 核实,用 memory_forget 删除):'
195
+ let tokens = estimateTokens(header) + 4
196
+ const lines = []
197
+ const ids = []
198
+ const omitted = []
199
+ let budgetExhausted = false
200
+ for (const [index, h] of hits.entries()) {
201
+ if (index >= cfg.topK) {
202
+ omitted.push({ id: h.record.id, reason: 'top_k' })
203
+ continue
204
+ }
205
+ if (budgetExhausted) {
206
+ omitted.push({ id: h.record.id, reason: 'budget' })
207
+ continue
208
+ }
209
+ const line = `- ${h.record.id.slice(0, 8)} ${h.record.content.replace(/\s+/g, ' ').slice(0, chars)}`
210
+ const cost = estimateTokens(line) + 1
211
+ if (tokens + cost > cfg.tokenBudget) {
212
+ budgetExhausted = true
213
+ omitted.push({ id: h.record.id, reason: 'budget' })
214
+ continue
215
+ }
216
+ lines.push(line)
217
+ ids.push(h.record.id)
218
+ tokens += cost
219
+ }
220
+ if (lines.length === 0) return null
221
+ return { text: `${header}\n${lines.join('\n')}`, tokens, ids, omitted }
222
+ }
223
+
224
+ /** The context block we prepend (matches the documented ContextForm 'recall'). */
225
+ export function recallText(text ) {
226
+ return text
227
+ }
228
+
229
+ /** 配置既可以给静态值,也可以给 getter —— 面板改了设置,下一步就生效。 */
230
+
231
+
232
+
233
+
234
+                       
235
+
236
+               
237
+
238
+             
239
+
240
+                              
241
+
242
+
243
+
244
+
245
+
246
+        
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ /**
258
+ * Turn-agnostic injector: searches memory for the step's query and returns the
259
+ * recall text to append. The host middleware (apply.ts) wraps that text into a
260
+ * real message via createUserMessage.
261
+ *
262
+ * 去重从 0.9.6 起按 sessionId + 记忆 id/版本管理:
263
+ * - 已注入正文且内容未变 → 跳过;
264
+ * - 只注入过标签 → 允许补正文;
265
+ * - 内容更新 → 重新注入;
266
+ * - 同一段文本 = 最后一道幂等。
267
+ */
268
+ export class MemoryInjector {
269
+ search
270
+ cfg
271
+ renderOptions
272
+ state
273
+
274
+ constructor(
275
+ search ,
276
+ cfg ,
277
+ renderOptions = {},
278
+ state = new InjectionState(),
279
+ ) {
280
+ this.search = search
281
+ this.cfg = cfg
282
+ this.renderOptions = renderOptions
283
+ this.state = state
284
+ }
285
+
286
+ async maybeInject(
287
+ input ,
288
+ _decision ,
289
+ options = {},
290
+ ) {
291
+ const result = await this.maybeInjectDetailed(input, _decision, options)
292
+ return result?.text
293
+ }
294
+
295
+ async maybeInjectDetailed(
296
+ input ,
297
+ _decision ,
298
+ options = {},
299
+ ) {
300
+ const cfg = typeof this.cfg === 'function' ? this.cfg() : this.cfg
301
+ if (!cfg.enabled) return undefined
302
+ const query = options.query ?? pickQueryText(input.messages)
303
+ if (!query) return undefined
304
+ const sessionId = options.sessionId ?? input.sessionId
305
+
306
+ let hits
307
+ try {
308
+ hits = await this.search(query, input.signal, input.scopes)
309
+ } catch {
310
+ // 检索失败不能打断 agent 循环;审计会区分"失败"与"成功但无结果"。
311
+ return {
312
+ ids: [], candidates: 0, dedupSkipped: 0, updated: [], omitted: [], query,
313
+ tokens: 0, retrieval: { ok: false, count: 0, error: 'retrieval_failed' },
314
+ }
315
+ }
316
+ // 成功检索后记住查询(即使没有新正文):同一 query 的后续 step 不再重复全量检索。
317
+ this.state.setLastQuery(sessionId, query)
318
+
319
+ const seenIds = options.excludeIds
320
+ const candidates = seenIds === undefined ? hits : hits.filter((hit) => !seenIds.has(hit.record.id))
321
+ const { fresh, deduplicated, updated } = this.state.filterNewContent(
322
+ sessionId,
323
+ candidates.map((hit) => hit.record),
324
+ )
325
+ const freshIds = new Set(fresh.map((record) => record.id))
326
+ const freshHits = candidates.filter((hit) => freshIds.has(hit.record.id))
327
+ const optionsForRender = typeof this.renderOptions === 'function' ? this.renderOptions() : this.renderOptions
328
+ const block = renderRecallBlock(freshHits, cfg, optionsForRender)
329
+ const base = {
330
+ ids: [], candidates: candidates.length, dedupSkipped: deduplicated.length, updated, omitted: [], query,
331
+ tokens: 0, retrieval: { ok: true, count: hits.length },
332
+ }
333
+ if (!block) return base
334
+ if (block.text === this.state.lastTextOf(sessionId)) {
335
+ return { ...base, ids: block.ids, omitted: block.omitted, tokens: block.tokens, dedupSkipped: deduplicated.length + block.ids.length }
336
+ }
337
+
338
+ this.state.markContent(sessionId, block.ids.map((id) => {
339
+ const record = freshHits.find((hit) => hit.record.id === id) .record
340
+ return { id, updatedAt: record.updatedAt }
341
+ }))
342
+ this.state.setLastText(sessionId, block.text)
343
+ this.state.setLastQuery(sessionId, query)
344
+ return { ...base, text: block.text, ids: block.ids, omitted: block.omitted, tokens: block.tokens }
345
+ }
346
+ }
347
+
348
+ /** 从 agent 上取会话 id;取不到就没有"每个会话只发一次摘要"的锚点。 */
349
+ export function sessionIdOf(agent ) {
350
+ const id = (agent )?.session?.id
351
+ return typeof id === 'string' && id.length > 0 ? id : undefined
352
+ }
353
+
354
+ /** 摘要注入最多记住多少个会话(一个进程里开过的会话上界,防止 Set 无限长)。 */
355
+ const MAX_DIGESTED_SESSIONS = 500
356
+
357
+ /**
358
+ * 会话摘要注入器:一个会话只注入一次"已有哪些记忆"的摘要。
359
+ * 检索失败或结果为空也标记为已完成 —— 摘要不是必需品,不能每步重试。
360
+ */
361
+ export class MemoryDigester {
362
+ done = new Set ()
363
+ list
364
+
365
+ constructor(
366
+ list ,
367
+ ) {
368
+ this.list = list
369
+ }
370
+
371
+ async maybeDigest(
372
+ sessionId ,
373
+ scopes ,
374
+ render ,
375
+ ) {
376
+ if (sessionId === undefined || this.done.has(sessionId)) return undefined
377
+ this.markDone(sessionId)
378
+ let records
379
+ try {
380
+ records = await this.list(scopes)
381
+ } catch {
382
+ return undefined
383
+ }
384
+ return render(records) ?? undefined
385
+ }
386
+
387
+ /**
388
+ * 与 maybeDigest 相同,但把渲染结果原样返回(含统计与 hintIds),
389
+ * 供 apply.ts 写审计、标记 hint/content 状态。
390
+ */
391
+ async maybeDigestDetailed (
392
+ sessionId ,
393
+ scopes ,
394
+ render ,
395
+ ) {
396
+ if (sessionId === undefined || this.done.has(sessionId)) return undefined
397
+ this.markDone(sessionId)
398
+ let records
399
+ try {
400
+ records = await this.list(scopes)
401
+ } catch {
402
+ return undefined
403
+ }
404
+ return render(records) ?? undefined
405
+ }
406
+
407
+ markDone(sessionId ) {
408
+ this.done.add(sessionId)
409
+ if (this.done.size > MAX_DIGESTED_SESSIONS) {
410
+ const oldest = this.done.values().next()
411
+ if (!oldest.done) this.done.delete(oldest.value)
412
+ }
413
+ }
414
+
415
+ /** 上下文被压缩/重建后重新允许摘要评估(旧摘要可能已不在上下文里)。 */
416
+ reset(sessionId ) {
417
+ if (sessionId !== undefined) this.done.delete(sessionId)
418
+ }
419
+ }
295
420
 
296
421
 
297
422
  //# sourceURL=source/memory-inject/src/inject.ts