@restregular/dsh-memory 0.14.7 → 0.15.1

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.
@@ -781,6 +781,12 @@ export class MemoryStore {
781
781
  rec.accessCount += 1
782
782
  rec.importance = Math.max(rec.importance, input.importance ?? defaults.importance)
783
783
  if (input.supersedes) rec.supersedes = input.supersedes
784
+ // 同一内容重写 = 刷新状态:TLL 重新计时;显式去掉过期时间时一并清掉。
785
+ if (input.expiredAt !== undefined) rec.expiredAt = input.expiredAt
786
+ else delete rec.expiredAt
787
+ // 流程触发词是可编辑元数据:重写同一条流程时跟着更新。
788
+ const triggers = (input ).triggers
789
+ if (Array.isArray(triggers)) (rec ).triggers = triggers.map(String)
784
790
  s.insert(rec) // 去重命中的也是一次写:进增量,flush 时落盘
785
791
  return { record: rec, deduped: true }
786
792
  }
@@ -800,6 +806,13 @@ export class MemoryStore {
800
806
  importance: input.importance ?? defaults.importance,
801
807
  ...(input.supersedes ? { supersedes: input.supersedes } : {}),
802
808
  ...(input.expiredAt ? { expiredAt: input.expiredAt } : {}),
809
+ ...(Array.isArray((input ).triggers)
810
+ ? { triggers: ((input ).triggers ).map(String) }
811
+ : {}),
812
+ }
813
+ if (record.kind === 'state' && record.expiredAt === undefined) {
814
+ // provider 已经按默认 TTL 算出 expiredAt;这里只兜底直接调 store 的调用方。
815
+ record.expiredAt = now + 7 * 86_400_000
803
816
  }
804
817
  s.insert(record)
805
818
  return { record, deduped: false }
@@ -151,6 +151,12 @@ function resolveScope(
151
151
 
152
152
 
153
153
 
154
+                          
155
+
156
+                       
157
+
158
+                             
159
+
154
160
 
155
161
 
156
162
 
@@ -177,15 +183,18 @@ function resolveWorkspacePath(raw , agent ) {
177
183
  export function memorySaveTool(opts ) {
178
184
  return {
179
185
  name: 'memory_save',
180
- description: 'Save a durable memory (fact, decision, preference, procedure, rule) for future sessions.',
186
+ description: 'Save a durable memory (fact, decision, preference, procedure, rule, state) for future sessions.',
181
187
  parameters: {
182
188
  content: { type: 'string', description: 'Self-contained declarative sentence, readable without context', required: true },
183
189
  scope: { type: 'string', description: `${SCOPE_DESCRIPTION};配合 path 时表示该工作区作用域的显示名(别名)` },
184
190
  path: { type: 'string', description: '工作区目录路径;给出后写入 project:<路径>,此时 scope 用作该作用域的显示名(别名,可省略 = 用路径本身)' },
185
- kind: { type: 'string', enum: ['fact', 'decision', 'preference', 'procedure', 'note', 'rule'] },
191
+ kind: { type: 'string', enum: ['fact', 'decision', 'preference', 'procedure', 'note', 'rule', 'state'] },
186
192
  tags: { type: 'array', items: { type: 'string' } },
187
193
  importance: { type: 'number', description: '0~1, higher = more important' },
188
194
  supersedes: { type: 'string', description: 'Record id this corrects/replaces' },
195
+ expiresAt: { type: 'number', description: '过期时间(毫秒时间戳)。kind=state 不传时按设置里的默认 TTL(7 天)' },
196
+ ttlMs: { type: 'number', description: '相对有效期(毫秒)。与 expiresAt 二选一,expiresAt 优先' },
197
+ triggers: { type: 'array', items: { type: 'string' }, description: '流程触发词(kind=procedure):工具名/关键词/路径;缺省用 tags' },
189
198
  },
190
199
  async execute(args , exec ) {
191
200
  const service = svc(opts)
@@ -233,6 +242,9 @@ export function memorySaveTool(opts )
233
242
  ...(args.tags ? { tags: args.tags } : {}),
234
243
  ...(args.importance !== undefined ? { importance: args.importance } : {}),
235
244
  ...(args.supersedes ? { supersedes: args.supersedes } : {}),
245
+ ...(typeof args.expiresAt === 'number' ? { expiresAt: args.expiresAt } : {}),
246
+ ...(typeof args.ttlMs === 'number' ? { ttlMs: args.ttlMs } : {}),
247
+ ...(Array.isArray(args.triggers) ? { triggers: args.triggers.map(String) } : {}),
236
248
  source: { origin: 'explicit' },
237
249
  })
238
250
  return { id: record.id, scope: record.scope, ...(alias !== undefined ? { scopeName: alias } : {}), deduped: false }
@@ -247,6 +259,8 @@ export function memorySaveTool(opts )
247
259
 
248
260
 
249
261
 
262
+                         
263
+
250
264
 
251
265
 
252
266
 
@@ -270,6 +284,7 @@ export function memorySearchTool(opts )
270
284
  query: { type: 'string', required: true },
271
285
  scope: { type: 'string', description: SCOPE_DESCRIPTION },
272
286
  topK: { type: 'number', description: '1~20' },
287
+ includeSuperseded: { type: 'boolean', description: '默认 false;true 时把已被 supersede 的旧版本也返回(历史核对)' },
273
288
  },
274
289
  async execute(args , exec ) {
275
290
  const service = svc(opts)
@@ -292,6 +307,7 @@ export function memorySearchTool(opts )
292
307
  ...(resolved.scope !== undefined ? { scope: resolved.scope } : {}),
293
308
  ...(scopes !== undefined ? { scopes } : {}),
294
309
  ...(args.topK !== undefined ? { topK: args.topK } : {}),
310
+ ...(args.includeSuperseded === true ? { includeSuperseded: true } : {}),
295
311
  })
296
312
  return {
297
313
  records: hits.map((h) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.14.7",
3
+ "version": "0.15.1",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",