@aman_asmuei/amem 0.2.0 → 0.4.0

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/dist/memory.js CHANGED
@@ -30,14 +30,23 @@ export function detectConflict(newContent, existingContent, similarity) {
30
30
  };
31
31
  }
32
32
  export function recallMemories(db, options) {
33
- const { query, queryEmbedding, limit, type, tag, minConfidence } = options;
33
+ const { query, queryEmbedding, limit, type, tag, minConfidence, scope } = options;
34
34
  const now = Date.now();
35
35
  let candidates;
36
36
  if (type) {
37
37
  candidates = db.searchByType(type);
38
+ if (scope) {
39
+ candidates = candidates.filter(m => m.scope === "global" || m.scope === scope);
40
+ }
38
41
  }
39
42
  else if (tag) {
40
43
  candidates = db.searchByTag(tag);
44
+ if (scope) {
45
+ candidates = candidates.filter(m => m.scope === "global" || m.scope === scope);
46
+ }
47
+ }
48
+ else if (scope) {
49
+ candidates = db.getAllForProject(scope);
41
50
  }
42
51
  else {
43
52
  candidates = db.getAll();
@@ -74,4 +83,92 @@ export function recallMemories(db, options) {
74
83
  scored.sort((a, b) => b.score - a.score);
75
84
  return scored.slice(0, limit);
76
85
  }
86
+ export function consolidateMemories(db, cosineSim, options) {
87
+ const now = Date.now();
88
+ const msPerDay = 1000 * 60 * 60 * 24;
89
+ const allMemories = db.getAllWithEmbeddings();
90
+ const all = db.getAll();
91
+ const beforeTotal = all.length;
92
+ const actions = [];
93
+ const toDelete = new Set();
94
+ let promoted = 0;
95
+ // 1. MERGE: find near-duplicate pairs (>0.85 similarity)
96
+ for (let i = 0; i < allMemories.length; i++) {
97
+ if (toDelete.has(allMemories[i].id))
98
+ continue;
99
+ if (!allMemories[i].embedding)
100
+ continue;
101
+ for (let j = i + 1; j < allMemories.length; j++) {
102
+ if (toDelete.has(allMemories[j].id))
103
+ continue;
104
+ if (!allMemories[j].embedding)
105
+ continue;
106
+ const sim = cosineSim(allMemories[i].embedding, allMemories[j].embedding);
107
+ if (sim > 0.85) {
108
+ const [keep, discard] = allMemories[i].confidence >= allMemories[j].confidence
109
+ ? [allMemories[i], allMemories[j]]
110
+ : [allMemories[j], allMemories[i]];
111
+ if (!options.dryRun) {
112
+ db.updateConfidence(keep.id, Math.min(1.0, keep.confidence + 0.1));
113
+ db.deleteMemory(discard.id);
114
+ }
115
+ toDelete.add(discard.id);
116
+ actions.push({
117
+ action: "merged",
118
+ memoryIds: [keep.id, discard.id],
119
+ description: `Merged "${discard.content}" into "${keep.content}" (${(sim * 100).toFixed(0)}% similar)`,
120
+ });
121
+ }
122
+ }
123
+ }
124
+ // 2. PRUNE: stale, low-confidence, rarely-accessed (NEVER corrections)
125
+ for (const mem of all) {
126
+ if (toDelete.has(mem.id))
127
+ continue;
128
+ if (mem.type === "correction")
129
+ continue;
130
+ const daysSinceAccess = (now - mem.lastAccessed) / msPerDay;
131
+ if (daysSinceAccess > options.maxStaleDays &&
132
+ mem.confidence < options.minConfidence &&
133
+ mem.accessCount < options.minAccessCount) {
134
+ if (!options.dryRun) {
135
+ db.deleteMemory(mem.id);
136
+ }
137
+ toDelete.add(mem.id);
138
+ actions.push({
139
+ action: "pruned",
140
+ memoryIds: [mem.id],
141
+ description: `Pruned "${mem.content}" (${daysSinceAccess.toFixed(0)}d stale, ${(mem.confidence * 100).toFixed(0)}% confidence, ${mem.accessCount} accesses)`,
142
+ });
143
+ }
144
+ }
145
+ // 3. PROMOTE: frequently-accessed memories with low confidence
146
+ for (const mem of all) {
147
+ if (toDelete.has(mem.id))
148
+ continue;
149
+ if (mem.accessCount >= 5 && mem.confidence < 0.8) {
150
+ if (!options.dryRun) {
151
+ db.updateConfidence(mem.id, 0.9);
152
+ }
153
+ promoted++;
154
+ actions.push({
155
+ action: "promoted",
156
+ memoryIds: [mem.id],
157
+ description: `Promoted "${mem.content}" to 90% confidence (accessed ${mem.accessCount} times)`,
158
+ });
159
+ }
160
+ }
161
+ const afterTotal = beforeTotal - toDelete.size;
162
+ const signalCount = all.filter(m => !toDelete.has(m.id) && (m.confidence >= 0.8 || m.type === "correction")).length;
163
+ const healthScore = afterTotal === 0 ? 100 : Math.round((signalCount / afterTotal) * 100);
164
+ return {
165
+ merged: actions.filter(a => a.action === "merged").length,
166
+ pruned: actions.filter(a => a.action === "pruned").length,
167
+ promoted,
168
+ actions,
169
+ healthScore,
170
+ before: { total: beforeTotal },
171
+ after: { total: afterTotal },
172
+ };
173
+ }
77
174
  //# sourceMappingURL=memory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;CACJ,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAoC;IACjE,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,GAAG;CACV,CAAC;AAuBF,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACzE,CAAC;AAOD,MAAM,UAAU,cAAc,CAC5B,UA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OAAO,iCAAiC,GAAG,CAAC,WAAW,SAAS;aAC/F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC/C,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC;IACpH,MAAM,WAAW,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;IAE1F,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;QACzD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM;QACzD,QAAQ;QACR,OAAO;QACP,WAAW;QACX,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;QAC9B,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;KAC7B,CAAC;AACJ,CAAC"}
package/dist/schemas.d.ts CHANGED
@@ -9,18 +9,18 @@ export declare const StoreResultSchema: z.ZodUnion<[z.ZodObject<{
9
9
  reinforced: z.ZodNumber;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  type: string;
12
- action: "stored";
13
- id: string;
14
12
  confidence: number;
15
13
  tags: string[];
14
+ action: "stored";
15
+ id: string;
16
16
  total: number;
17
17
  reinforced: number;
18
18
  }, {
19
19
  type: string;
20
- action: "stored";
21
- id: string;
22
20
  confidence: number;
23
21
  tags: string[];
22
+ action: "stored";
23
+ id: string;
24
24
  total: number;
25
25
  reinforced: number;
26
26
  }>, z.ZodObject<{
@@ -52,18 +52,18 @@ export declare const RecallResultSchema: z.ZodObject<{
52
52
  age: z.ZodString;
53
53
  }, "strip", z.ZodTypeAny, {
54
54
  type: string;
55
- id: string;
55
+ content: string;
56
56
  confidence: number;
57
57
  tags: string[];
58
- content: string;
58
+ id: string;
59
59
  score: number;
60
60
  age: string;
61
61
  }, {
62
62
  type: string;
63
- id: string;
63
+ content: string;
64
64
  confidence: number;
65
65
  tags: string[];
66
- content: string;
66
+ id: string;
67
67
  score: number;
68
68
  age: string;
69
69
  }>, "many">;
@@ -72,10 +72,10 @@ export declare const RecallResultSchema: z.ZodObject<{
72
72
  total: number;
73
73
  memories: {
74
74
  type: string;
75
- id: string;
75
+ content: string;
76
76
  confidence: number;
77
77
  tags: string[];
78
- content: string;
78
+ id: string;
79
79
  score: number;
80
80
  age: string;
81
81
  }[];
@@ -84,10 +84,10 @@ export declare const RecallResultSchema: z.ZodObject<{
84
84
  total: number;
85
85
  memories: {
86
86
  type: string;
87
- id: string;
87
+ content: string;
88
88
  confidence: number;
89
89
  tags: string[];
90
- content: string;
90
+ id: string;
91
91
  score: number;
92
92
  age: string;
93
93
  }[];
@@ -100,23 +100,23 @@ export declare const ContextResultSchema: z.ZodObject<{
100
100
  content: z.ZodString;
101
101
  confidence: z.ZodNumber;
102
102
  }, "strip", z.ZodTypeAny, {
103
- confidence: number;
104
103
  content: string;
105
- }, {
106
104
  confidence: number;
105
+ }, {
107
106
  content: string;
107
+ confidence: number;
108
108
  }>, "many">;
109
109
  }, "strip", z.ZodTypeAny, {
110
110
  type: string;
111
111
  memories: {
112
- confidence: number;
113
112
  content: string;
113
+ confidence: number;
114
114
  }[];
115
115
  }, {
116
116
  type: string;
117
117
  memories: {
118
- confidence: number;
119
118
  content: string;
119
+ confidence: number;
120
120
  }[];
121
121
  }>, "many">;
122
122
  memoriesUsed: z.ZodNumber;
@@ -125,8 +125,8 @@ export declare const ContextResultSchema: z.ZodObject<{
125
125
  groups: {
126
126
  type: string;
127
127
  memories: {
128
- confidence: number;
129
128
  content: string;
129
+ confidence: number;
130
130
  }[];
131
131
  }[];
132
132
  memoriesUsed: number;
@@ -135,8 +135,8 @@ export declare const ContextResultSchema: z.ZodObject<{
135
135
  groups: {
136
136
  type: string;
137
137
  memories: {
138
- confidence: number;
139
138
  content: string;
139
+ confidence: number;
140
140
  }[];
141
141
  }[];
142
142
  memoriesUsed: number;
@@ -148,14 +148,14 @@ export declare const ForgetResultSchema: z.ZodUnion<[z.ZodObject<{
148
148
  type: z.ZodString;
149
149
  }, "strip", z.ZodTypeAny, {
150
150
  type: string;
151
+ content: string;
151
152
  action: "deleted";
152
153
  id: string;
153
- content: string;
154
154
  }, {
155
155
  type: string;
156
+ content: string;
156
157
  action: "deleted";
157
158
  id: string;
158
- content: string;
159
159
  }>, z.ZodObject<{
160
160
  action: z.ZodLiteral<"preview">;
161
161
  query: z.ZodString;
@@ -164,27 +164,27 @@ export declare const ForgetResultSchema: z.ZodUnion<[z.ZodObject<{
164
164
  id: z.ZodString;
165
165
  content: z.ZodString;
166
166
  }, "strip", z.ZodTypeAny, {
167
- id: string;
168
167
  content: string;
169
- }, {
170
168
  id: string;
169
+ }, {
171
170
  content: string;
171
+ id: string;
172
172
  }>, "many">;
173
173
  }, "strip", z.ZodTypeAny, {
174
174
  query: string;
175
175
  action: "preview";
176
176
  total: number;
177
177
  previewed: {
178
- id: string;
179
178
  content: string;
179
+ id: string;
180
180
  }[];
181
181
  }, {
182
182
  query: string;
183
183
  action: "preview";
184
184
  total: number;
185
185
  previewed: {
186
- id: string;
187
186
  content: string;
187
+ id: string;
188
188
  }[];
189
189
  }>, z.ZodObject<{
190
190
  action: z.ZodLiteral<"bulk_deleted">;
@@ -211,15 +211,15 @@ export declare const ExtractResultSchema: z.ZodObject<{
211
211
  matchedContent: z.ZodOptional<z.ZodString>;
212
212
  similarity: z.ZodOptional<z.ZodNumber>;
213
213
  }, "strip", z.ZodTypeAny, {
214
- action: "stored" | "reinforced";
215
214
  content: string;
215
+ action: "stored" | "reinforced";
216
216
  type?: string | undefined;
217
217
  id?: string | undefined;
218
218
  similarity?: number | undefined;
219
219
  matchedContent?: string | undefined;
220
220
  }, {
221
- action: "stored" | "reinforced";
222
221
  content: string;
222
+ action: "stored" | "reinforced";
223
223
  type?: string | undefined;
224
224
  id?: string | undefined;
225
225
  similarity?: number | undefined;
@@ -230,8 +230,8 @@ export declare const ExtractResultSchema: z.ZodObject<{
230
230
  total: number;
231
231
  reinforced: number;
232
232
  details: {
233
- action: "stored" | "reinforced";
234
233
  content: string;
234
+ action: "stored" | "reinforced";
235
235
  type?: string | undefined;
236
236
  id?: string | undefined;
237
237
  similarity?: number | undefined;
@@ -242,8 +242,8 @@ export declare const ExtractResultSchema: z.ZodObject<{
242
242
  total: number;
243
243
  reinforced: number;
244
244
  details: {
245
- action: "stored" | "reinforced";
246
245
  content: string;
246
+ action: "stored" | "reinforced";
247
247
  type?: string | undefined;
248
248
  id?: string | undefined;
249
249
  similarity?: number | undefined;
@@ -336,3 +336,361 @@ export declare const InjectResultSchema: z.ZodObject<{
336
336
  decisions: string[];
337
337
  context: string;
338
338
  }>;
339
+ export declare const ConsolidateResultSchema: z.ZodObject<{
340
+ merged: z.ZodNumber;
341
+ pruned: z.ZodNumber;
342
+ promoted: z.ZodNumber;
343
+ healthScore: z.ZodNumber;
344
+ before: z.ZodObject<{
345
+ total: z.ZodNumber;
346
+ }, "strip", z.ZodTypeAny, {
347
+ total: number;
348
+ }, {
349
+ total: number;
350
+ }>;
351
+ after: z.ZodObject<{
352
+ total: z.ZodNumber;
353
+ }, "strip", z.ZodTypeAny, {
354
+ total: number;
355
+ }, {
356
+ total: number;
357
+ }>;
358
+ actions: z.ZodArray<z.ZodObject<{
359
+ action: z.ZodEnum<["merged", "pruned", "promoted"]>;
360
+ memoryIds: z.ZodArray<z.ZodString, "many">;
361
+ description: z.ZodString;
362
+ }, "strip", z.ZodTypeAny, {
363
+ action: "merged" | "pruned" | "promoted";
364
+ memoryIds: string[];
365
+ description: string;
366
+ }, {
367
+ action: "merged" | "pruned" | "promoted";
368
+ memoryIds: string[];
369
+ description: string;
370
+ }>, "many">;
371
+ }, "strip", z.ZodTypeAny, {
372
+ merged: number;
373
+ pruned: number;
374
+ promoted: number;
375
+ healthScore: number;
376
+ before: {
377
+ total: number;
378
+ };
379
+ after: {
380
+ total: number;
381
+ };
382
+ actions: {
383
+ action: "merged" | "pruned" | "promoted";
384
+ memoryIds: string[];
385
+ description: string;
386
+ }[];
387
+ }, {
388
+ merged: number;
389
+ pruned: number;
390
+ promoted: number;
391
+ healthScore: number;
392
+ before: {
393
+ total: number;
394
+ };
395
+ after: {
396
+ total: number;
397
+ };
398
+ actions: {
399
+ action: "merged" | "pruned" | "promoted";
400
+ memoryIds: string[];
401
+ description: string;
402
+ }[];
403
+ }>;
404
+ export declare const PatchResultSchema: z.ZodUnion<[z.ZodObject<{
405
+ action: z.ZodLiteral<"patched">;
406
+ id: z.ZodString;
407
+ field: z.ZodString;
408
+ previousContent: z.ZodString;
409
+ reason: z.ZodString;
410
+ versionSaved: z.ZodBoolean;
411
+ }, "strip", z.ZodTypeAny, {
412
+ action: "patched";
413
+ id: string;
414
+ field: string;
415
+ previousContent: string;
416
+ reason: string;
417
+ versionSaved: boolean;
418
+ }, {
419
+ action: "patched";
420
+ id: string;
421
+ field: string;
422
+ previousContent: string;
423
+ reason: string;
424
+ versionSaved: boolean;
425
+ }>, z.ZodObject<{
426
+ action: z.ZodLiteral<"not_found">;
427
+ id: z.ZodString;
428
+ }, "strip", z.ZodTypeAny, {
429
+ action: "not_found";
430
+ id: string;
431
+ }, {
432
+ action: "not_found";
433
+ id: string;
434
+ }>]>;
435
+ export declare const LogAppendResultSchema: z.ZodObject<{
436
+ id: z.ZodString;
437
+ sessionId: z.ZodString;
438
+ role: z.ZodString;
439
+ appended: z.ZodBoolean;
440
+ }, "strip", z.ZodTypeAny, {
441
+ role: string;
442
+ id: string;
443
+ sessionId: string;
444
+ appended: boolean;
445
+ }, {
446
+ role: string;
447
+ id: string;
448
+ sessionId: string;
449
+ appended: boolean;
450
+ }>;
451
+ export declare const LogRecallResultSchema: z.ZodObject<{
452
+ query: z.ZodOptional<z.ZodString>;
453
+ sessionId: z.ZodOptional<z.ZodString>;
454
+ total: z.ZodNumber;
455
+ entries: z.ZodArray<z.ZodObject<{
456
+ id: z.ZodString;
457
+ role: z.ZodString;
458
+ content: z.ZodString;
459
+ timestamp: z.ZodNumber;
460
+ age: z.ZodString;
461
+ project: z.ZodString;
462
+ }, "strip", z.ZodTypeAny, {
463
+ content: string;
464
+ role: string;
465
+ id: string;
466
+ age: string;
467
+ timestamp: number;
468
+ project: string;
469
+ }, {
470
+ content: string;
471
+ role: string;
472
+ id: string;
473
+ age: string;
474
+ timestamp: number;
475
+ project: string;
476
+ }>, "many">;
477
+ }, "strip", z.ZodTypeAny, {
478
+ entries: {
479
+ content: string;
480
+ role: string;
481
+ id: string;
482
+ age: string;
483
+ timestamp: number;
484
+ project: string;
485
+ }[];
486
+ total: number;
487
+ query?: string | undefined;
488
+ sessionId?: string | undefined;
489
+ }, {
490
+ entries: {
491
+ content: string;
492
+ role: string;
493
+ id: string;
494
+ age: string;
495
+ timestamp: number;
496
+ project: string;
497
+ }[];
498
+ total: number;
499
+ query?: string | undefined;
500
+ sessionId?: string | undefined;
501
+ }>;
502
+ export declare const RelateResultSchema: z.ZodUnion<[z.ZodObject<{
503
+ action: z.ZodLiteral<"related">;
504
+ relationId: z.ZodString;
505
+ fromId: z.ZodString;
506
+ toId: z.ZodString;
507
+ type: z.ZodString;
508
+ strength: z.ZodNumber;
509
+ }, "strip", z.ZodTypeAny, {
510
+ type: string;
511
+ action: "related";
512
+ relationId: string;
513
+ fromId: string;
514
+ toId: string;
515
+ strength: number;
516
+ }, {
517
+ type: string;
518
+ action: "related";
519
+ relationId: string;
520
+ fromId: string;
521
+ toId: string;
522
+ strength: number;
523
+ }>, z.ZodObject<{
524
+ action: z.ZodLiteral<"unrelated">;
525
+ relationId: z.ZodString;
526
+ }, "strip", z.ZodTypeAny, {
527
+ action: "unrelated";
528
+ relationId: string;
529
+ }, {
530
+ action: "unrelated";
531
+ relationId: string;
532
+ }>, z.ZodObject<{
533
+ action: z.ZodLiteral<"graph">;
534
+ memoryId: z.ZodString;
535
+ relations: z.ZodArray<z.ZodObject<{
536
+ relatedId: z.ZodString;
537
+ direction: z.ZodEnum<["outgoing", "incoming"]>;
538
+ type: z.ZodString;
539
+ strength: z.ZodNumber;
540
+ content: z.ZodOptional<z.ZodString>;
541
+ }, "strip", z.ZodTypeAny, {
542
+ type: string;
543
+ strength: number;
544
+ relatedId: string;
545
+ direction: "outgoing" | "incoming";
546
+ content?: string | undefined;
547
+ }, {
548
+ type: string;
549
+ strength: number;
550
+ relatedId: string;
551
+ direction: "outgoing" | "incoming";
552
+ content?: string | undefined;
553
+ }>, "many">;
554
+ }, "strip", z.ZodTypeAny, {
555
+ action: "graph";
556
+ memoryId: string;
557
+ relations: {
558
+ type: string;
559
+ strength: number;
560
+ relatedId: string;
561
+ direction: "outgoing" | "incoming";
562
+ content?: string | undefined;
563
+ }[];
564
+ }, {
565
+ action: "graph";
566
+ memoryId: string;
567
+ relations: {
568
+ type: string;
569
+ strength: number;
570
+ relatedId: string;
571
+ direction: "outgoing" | "incoming";
572
+ content?: string | undefined;
573
+ }[];
574
+ }>]>;
575
+ export declare const VersionResultSchema: z.ZodUnion<[z.ZodObject<{
576
+ action: z.ZodLiteral<"history">;
577
+ memoryId: z.ZodString;
578
+ currentContent: z.ZodString;
579
+ versions: z.ZodArray<z.ZodObject<{
580
+ versionId: z.ZodString;
581
+ content: z.ZodString;
582
+ confidence: z.ZodNumber;
583
+ editedAt: z.ZodNumber;
584
+ age: z.ZodString;
585
+ reason: z.ZodString;
586
+ }, "strip", z.ZodTypeAny, {
587
+ content: string;
588
+ confidence: number;
589
+ age: string;
590
+ reason: string;
591
+ versionId: string;
592
+ editedAt: number;
593
+ }, {
594
+ content: string;
595
+ confidence: number;
596
+ age: string;
597
+ reason: string;
598
+ versionId: string;
599
+ editedAt: number;
600
+ }>, "many">;
601
+ }, "strip", z.ZodTypeAny, {
602
+ action: "history";
603
+ memoryId: string;
604
+ currentContent: string;
605
+ versions: {
606
+ content: string;
607
+ confidence: number;
608
+ age: string;
609
+ reason: string;
610
+ versionId: string;
611
+ editedAt: number;
612
+ }[];
613
+ }, {
614
+ action: "history";
615
+ memoryId: string;
616
+ currentContent: string;
617
+ versions: {
618
+ content: string;
619
+ confidence: number;
620
+ age: string;
621
+ reason: string;
622
+ versionId: string;
623
+ editedAt: number;
624
+ }[];
625
+ }>, z.ZodObject<{
626
+ action: z.ZodLiteral<"restored">;
627
+ memoryId: z.ZodString;
628
+ restoredContent: z.ZodString;
629
+ versionId: z.ZodString;
630
+ }, "strip", z.ZodTypeAny, {
631
+ action: "restored";
632
+ memoryId: string;
633
+ versionId: string;
634
+ restoredContent: string;
635
+ }, {
636
+ action: "restored";
637
+ memoryId: string;
638
+ versionId: string;
639
+ restoredContent: string;
640
+ }>]>;
641
+ export declare const TemporalResultSchema: z.ZodObject<{
642
+ from: z.ZodOptional<z.ZodString>;
643
+ to: z.ZodOptional<z.ZodString>;
644
+ total: z.ZodNumber;
645
+ memories: z.ZodArray<z.ZodObject<{
646
+ id: z.ZodString;
647
+ content: z.ZodString;
648
+ type: z.ZodString;
649
+ confidence: z.ZodNumber;
650
+ createdAt: z.ZodNumber;
651
+ age: z.ZodString;
652
+ tags: z.ZodArray<z.ZodString, "many">;
653
+ }, "strip", z.ZodTypeAny, {
654
+ type: string;
655
+ content: string;
656
+ confidence: number;
657
+ tags: string[];
658
+ id: string;
659
+ age: string;
660
+ createdAt: number;
661
+ }, {
662
+ type: string;
663
+ content: string;
664
+ confidence: number;
665
+ tags: string[];
666
+ id: string;
667
+ age: string;
668
+ createdAt: number;
669
+ }>, "many">;
670
+ }, "strip", z.ZodTypeAny, {
671
+ total: number;
672
+ memories: {
673
+ type: string;
674
+ content: string;
675
+ confidence: number;
676
+ tags: string[];
677
+ id: string;
678
+ age: string;
679
+ createdAt: number;
680
+ }[];
681
+ from?: string | undefined;
682
+ to?: string | undefined;
683
+ }, {
684
+ total: number;
685
+ memories: {
686
+ type: string;
687
+ content: string;
688
+ confidence: number;
689
+ tags: string[];
690
+ id: string;
691
+ age: string;
692
+ createdAt: number;
693
+ }[];
694
+ from?: string | undefined;
695
+ to?: string | undefined;
696
+ }>;