@aman_asmuei/amem 0.11.1 → 0.13.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/ann.d.ts +18 -0
- package/dist/ann.js +38 -0
- package/dist/ann.js.map +1 -0
- package/dist/auto-relate.d.ts +14 -0
- package/dist/auto-relate.js +47 -0
- package/dist/auto-relate.js.map +1 -0
- package/dist/cli.js +117 -23
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/dashboard.js +62 -0
- package/dist/dashboard.js.map +1 -1
- package/dist/doctor.d.ts +23 -0
- package/dist/doctor.js +107 -0
- package/dist/doctor.js.map +1 -0
- package/dist/embeddings.d.ts +6 -0
- package/dist/embeddings.js +81 -4
- package/dist/embeddings.js.map +1 -1
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +159 -12
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +3 -0
- package/dist/memory.js +62 -14
- package/dist/memory.js.map +1 -1
- package/dist/memory.test.js +3 -2
- package/dist/memory.test.js.map +1 -1
- package/dist/query-expand.d.ts +9 -0
- package/dist/query-expand.js +71 -0
- package/dist/query-expand.js.map +1 -0
- package/dist/schemas.d.ts +30 -30
- package/dist/sync.d.ts +26 -0
- package/dist/sync.js +82 -0
- package/dist/sync.js.map +1 -1
- package/dist/tools/memory.js +78 -8
- package/dist/tools/memory.js.map +1 -1
- package/package.json +1 -1
package/dist/schemas.d.ts
CHANGED
|
@@ -8,16 +8,16 @@ export declare const StoreResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
8
8
|
total: z.ZodNumber;
|
|
9
9
|
reinforced: z.ZodNumber;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
type: string;
|
|
12
11
|
id: string;
|
|
12
|
+
type: string;
|
|
13
13
|
confidence: number;
|
|
14
14
|
tags: string[];
|
|
15
15
|
action: "stored";
|
|
16
16
|
total: number;
|
|
17
17
|
reinforced: number;
|
|
18
18
|
}, {
|
|
19
|
-
type: string;
|
|
20
19
|
id: string;
|
|
20
|
+
type: string;
|
|
21
21
|
confidence: number;
|
|
22
22
|
tags: string[];
|
|
23
23
|
action: "stored";
|
|
@@ -51,16 +51,16 @@ export declare const RecallResultSchema: z.ZodObject<{
|
|
|
51
51
|
tags: z.ZodArray<z.ZodString, "many">;
|
|
52
52
|
age: z.ZodString;
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
|
-
type: string;
|
|
55
54
|
id: string;
|
|
55
|
+
type: string;
|
|
56
56
|
content: string;
|
|
57
57
|
confidence: number;
|
|
58
58
|
tags: string[];
|
|
59
59
|
score: number;
|
|
60
60
|
age: string;
|
|
61
61
|
}, {
|
|
62
|
-
type: string;
|
|
63
62
|
id: string;
|
|
63
|
+
type: string;
|
|
64
64
|
content: string;
|
|
65
65
|
confidence: number;
|
|
66
66
|
tags: string[];
|
|
@@ -71,8 +71,8 @@ export declare const RecallResultSchema: z.ZodObject<{
|
|
|
71
71
|
query: string;
|
|
72
72
|
total: number;
|
|
73
73
|
memories: {
|
|
74
|
-
type: string;
|
|
75
74
|
id: string;
|
|
75
|
+
type: string;
|
|
76
76
|
content: string;
|
|
77
77
|
confidence: number;
|
|
78
78
|
tags: string[];
|
|
@@ -83,8 +83,8 @@ export declare const RecallResultSchema: z.ZodObject<{
|
|
|
83
83
|
query: string;
|
|
84
84
|
total: number;
|
|
85
85
|
memories: {
|
|
86
|
-
type: string;
|
|
87
86
|
id: string;
|
|
87
|
+
type: string;
|
|
88
88
|
content: string;
|
|
89
89
|
confidence: number;
|
|
90
90
|
tags: string[];
|
|
@@ -147,13 +147,13 @@ export declare const ForgetResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
147
147
|
content: z.ZodString;
|
|
148
148
|
type: z.ZodString;
|
|
149
149
|
}, "strip", z.ZodTypeAny, {
|
|
150
|
-
type: string;
|
|
151
150
|
id: string;
|
|
151
|
+
type: string;
|
|
152
152
|
content: string;
|
|
153
153
|
action: "deleted";
|
|
154
154
|
}, {
|
|
155
|
-
type: string;
|
|
156
155
|
id: string;
|
|
156
|
+
type: string;
|
|
157
157
|
content: string;
|
|
158
158
|
action: "deleted";
|
|
159
159
|
}>, z.ZodObject<{
|
|
@@ -213,15 +213,15 @@ export declare const ExtractResultSchema: z.ZodObject<{
|
|
|
213
213
|
}, "strip", z.ZodTypeAny, {
|
|
214
214
|
content: string;
|
|
215
215
|
action: "stored" | "reinforced";
|
|
216
|
-
type?: string | undefined;
|
|
217
216
|
id?: string | undefined;
|
|
217
|
+
type?: string | undefined;
|
|
218
218
|
similarity?: number | undefined;
|
|
219
219
|
matchedContent?: string | undefined;
|
|
220
220
|
}, {
|
|
221
221
|
content: string;
|
|
222
222
|
action: "stored" | "reinforced";
|
|
223
|
-
type?: string | undefined;
|
|
224
223
|
id?: string | undefined;
|
|
224
|
+
type?: string | undefined;
|
|
225
225
|
similarity?: number | undefined;
|
|
226
226
|
matchedContent?: string | undefined;
|
|
227
227
|
}>, "many">;
|
|
@@ -232,8 +232,8 @@ export declare const ExtractResultSchema: z.ZodObject<{
|
|
|
232
232
|
details: {
|
|
233
233
|
content: string;
|
|
234
234
|
action: "stored" | "reinforced";
|
|
235
|
-
type?: string | undefined;
|
|
236
235
|
id?: string | undefined;
|
|
236
|
+
type?: string | undefined;
|
|
237
237
|
similarity?: number | undefined;
|
|
238
238
|
matchedContent?: string | undefined;
|
|
239
239
|
}[];
|
|
@@ -244,8 +244,8 @@ export declare const ExtractResultSchema: z.ZodObject<{
|
|
|
244
244
|
details: {
|
|
245
245
|
content: string;
|
|
246
246
|
action: "stored" | "reinforced";
|
|
247
|
-
type?: string | undefined;
|
|
248
247
|
id?: string | undefined;
|
|
248
|
+
type?: string | undefined;
|
|
249
249
|
similarity?: number | undefined;
|
|
250
250
|
matchedContent?: string | undefined;
|
|
251
251
|
}[];
|
|
@@ -654,16 +654,16 @@ export declare const TemporalResultSchema: z.ZodObject<{
|
|
|
654
654
|
age: z.ZodString;
|
|
655
655
|
tags: z.ZodArray<z.ZodString, "many">;
|
|
656
656
|
}, "strip", z.ZodTypeAny, {
|
|
657
|
-
type: string;
|
|
658
657
|
id: string;
|
|
658
|
+
type: string;
|
|
659
659
|
content: string;
|
|
660
660
|
confidence: number;
|
|
661
661
|
tags: string[];
|
|
662
662
|
age: string;
|
|
663
663
|
createdAt: number;
|
|
664
664
|
}, {
|
|
665
|
-
type: string;
|
|
666
665
|
id: string;
|
|
666
|
+
type: string;
|
|
667
667
|
content: string;
|
|
668
668
|
confidence: number;
|
|
669
669
|
tags: string[];
|
|
@@ -673,8 +673,8 @@ export declare const TemporalResultSchema: z.ZodObject<{
|
|
|
673
673
|
}, "strip", z.ZodTypeAny, {
|
|
674
674
|
total: number;
|
|
675
675
|
memories: {
|
|
676
|
-
type: string;
|
|
677
676
|
id: string;
|
|
677
|
+
type: string;
|
|
678
678
|
content: string;
|
|
679
679
|
confidence: number;
|
|
680
680
|
tags: string[];
|
|
@@ -686,8 +686,8 @@ export declare const TemporalResultSchema: z.ZodObject<{
|
|
|
686
686
|
}, {
|
|
687
687
|
total: number;
|
|
688
688
|
memories: {
|
|
689
|
-
type: string;
|
|
690
689
|
id: string;
|
|
690
|
+
type: string;
|
|
691
691
|
content: string;
|
|
692
692
|
confidence: number;
|
|
693
693
|
tags: string[];
|
|
@@ -709,17 +709,17 @@ export declare const DetailResultSchema: z.ZodObject<{
|
|
|
709
709
|
age: z.ZodString;
|
|
710
710
|
scope: z.ZodString;
|
|
711
711
|
}, "strip", z.ZodTypeAny, {
|
|
712
|
+
id: string;
|
|
712
713
|
type: string;
|
|
713
714
|
scope: string;
|
|
714
|
-
id: string;
|
|
715
715
|
content: string;
|
|
716
716
|
confidence: number;
|
|
717
717
|
tags: string[];
|
|
718
718
|
age: string;
|
|
719
719
|
}, {
|
|
720
|
+
id: string;
|
|
720
721
|
type: string;
|
|
721
722
|
scope: string;
|
|
722
|
-
id: string;
|
|
723
723
|
content: string;
|
|
724
724
|
confidence: number;
|
|
725
725
|
tags: string[];
|
|
@@ -728,9 +728,9 @@ export declare const DetailResultSchema: z.ZodObject<{
|
|
|
728
728
|
}, "strip", z.ZodTypeAny, {
|
|
729
729
|
total: number;
|
|
730
730
|
memories: {
|
|
731
|
+
id: string;
|
|
731
732
|
type: string;
|
|
732
733
|
scope: string;
|
|
733
|
-
id: string;
|
|
734
734
|
content: string;
|
|
735
735
|
confidence: number;
|
|
736
736
|
tags: string[];
|
|
@@ -740,9 +740,9 @@ export declare const DetailResultSchema: z.ZodObject<{
|
|
|
740
740
|
}, {
|
|
741
741
|
total: number;
|
|
742
742
|
memories: {
|
|
743
|
+
id: string;
|
|
743
744
|
type: string;
|
|
744
745
|
scope: string;
|
|
745
|
-
id: string;
|
|
746
746
|
content: string;
|
|
747
747
|
confidence: number;
|
|
748
748
|
tags: string[];
|
|
@@ -756,13 +756,13 @@ export declare const ReminderSetResultSchema: z.ZodObject<{
|
|
|
756
756
|
dueAt: z.ZodNullable<z.ZodNumber>;
|
|
757
757
|
scope: z.ZodString;
|
|
758
758
|
}, "strip", z.ZodTypeAny, {
|
|
759
|
-
scope: string;
|
|
760
759
|
id: string;
|
|
760
|
+
scope: string;
|
|
761
761
|
content: string;
|
|
762
762
|
dueAt: number | null;
|
|
763
763
|
}, {
|
|
764
|
-
scope: string;
|
|
765
764
|
id: string;
|
|
765
|
+
scope: string;
|
|
766
766
|
content: string;
|
|
767
767
|
dueAt: number | null;
|
|
768
768
|
}>;
|
|
@@ -775,14 +775,14 @@ export declare const ReminderListResultSchema: z.ZodObject<{
|
|
|
775
775
|
completed: z.ZodBoolean;
|
|
776
776
|
scope: z.ZodString;
|
|
777
777
|
}, "strip", z.ZodTypeAny, {
|
|
778
|
-
scope: string;
|
|
779
778
|
id: string;
|
|
779
|
+
scope: string;
|
|
780
780
|
content: string;
|
|
781
781
|
dueAt: number | null;
|
|
782
782
|
completed: boolean;
|
|
783
783
|
}, {
|
|
784
|
-
scope: string;
|
|
785
784
|
id: string;
|
|
785
|
+
scope: string;
|
|
786
786
|
content: string;
|
|
787
787
|
dueAt: number | null;
|
|
788
788
|
completed: boolean;
|
|
@@ -790,8 +790,8 @@ export declare const ReminderListResultSchema: z.ZodObject<{
|
|
|
790
790
|
}, "strip", z.ZodTypeAny, {
|
|
791
791
|
total: number;
|
|
792
792
|
reminders: {
|
|
793
|
-
scope: string;
|
|
794
793
|
id: string;
|
|
794
|
+
scope: string;
|
|
795
795
|
content: string;
|
|
796
796
|
dueAt: number | null;
|
|
797
797
|
completed: boolean;
|
|
@@ -799,8 +799,8 @@ export declare const ReminderListResultSchema: z.ZodObject<{
|
|
|
799
799
|
}, {
|
|
800
800
|
total: number;
|
|
801
801
|
reminders: {
|
|
802
|
-
scope: string;
|
|
803
802
|
id: string;
|
|
803
|
+
scope: string;
|
|
804
804
|
content: string;
|
|
805
805
|
dueAt: number | null;
|
|
806
806
|
completed: boolean;
|
|
@@ -815,14 +815,14 @@ export declare const ReminderCheckResultSchema: z.ZodObject<{
|
|
|
815
815
|
status: z.ZodEnum<["overdue", "today", "upcoming"]>;
|
|
816
816
|
scope: z.ZodString;
|
|
817
817
|
}, "strip", z.ZodTypeAny, {
|
|
818
|
-
scope: string;
|
|
819
818
|
id: string;
|
|
819
|
+
scope: string;
|
|
820
820
|
content: string;
|
|
821
821
|
status: "overdue" | "today" | "upcoming";
|
|
822
822
|
dueAt: number | null;
|
|
823
823
|
}, {
|
|
824
|
-
scope: string;
|
|
825
824
|
id: string;
|
|
825
|
+
scope: string;
|
|
826
826
|
content: string;
|
|
827
827
|
status: "overdue" | "today" | "upcoming";
|
|
828
828
|
dueAt: number | null;
|
|
@@ -830,8 +830,8 @@ export declare const ReminderCheckResultSchema: z.ZodObject<{
|
|
|
830
830
|
}, "strip", z.ZodTypeAny, {
|
|
831
831
|
total: number;
|
|
832
832
|
reminders: {
|
|
833
|
-
scope: string;
|
|
834
833
|
id: string;
|
|
834
|
+
scope: string;
|
|
835
835
|
content: string;
|
|
836
836
|
status: "overdue" | "today" | "upcoming";
|
|
837
837
|
dueAt: number | null;
|
|
@@ -839,8 +839,8 @@ export declare const ReminderCheckResultSchema: z.ZodObject<{
|
|
|
839
839
|
}, {
|
|
840
840
|
total: number;
|
|
841
841
|
reminders: {
|
|
842
|
-
scope: string;
|
|
843
842
|
id: string;
|
|
843
|
+
scope: string;
|
|
844
844
|
content: string;
|
|
845
845
|
status: "overdue" | "today" | "upcoming";
|
|
846
846
|
dueAt: number | null;
|
package/dist/sync.d.ts
CHANGED
|
@@ -56,4 +56,30 @@ export interface SyncResult {
|
|
|
56
56
|
* @param dryRun - preview without writing (default: false)
|
|
57
57
|
*/
|
|
58
58
|
export declare function syncFromClaude(db: AmemDatabase, projectFilter?: string, dryRun?: boolean): Promise<SyncResult>;
|
|
59
|
+
export interface TeamExportOptions {
|
|
60
|
+
userId: string;
|
|
61
|
+
includeTypes?: string[];
|
|
62
|
+
minConfidence?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface TeamImportOptions {
|
|
65
|
+
dryRun?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface TeamImportResult {
|
|
68
|
+
imported: number;
|
|
69
|
+
skipped: number;
|
|
70
|
+
from: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Export shareable memories as a JSON file for team sync.
|
|
74
|
+
* Filters out private/personal memories (type=preference with non-global scope).
|
|
75
|
+
*/
|
|
76
|
+
export declare function exportForTeam(db: AmemDatabase, outputDir: string, options: TeamExportOptions): Promise<{
|
|
77
|
+
file: string;
|
|
78
|
+
count: number;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Import a teammate's exported memory file.
|
|
82
|
+
* Deduplicates by content hash and lowers confidence by 0.1 for second-hand memories.
|
|
83
|
+
*/
|
|
84
|
+
export declare function importFromTeam(db: AmemDatabase, filePath: string, options?: TeamImportOptions): Promise<TeamImportResult>;
|
|
59
85
|
export {};
|
package/dist/sync.js
CHANGED
|
@@ -219,4 +219,86 @@ export async function syncFromClaude(db, projectFilter, dryRun = false) {
|
|
|
219
219
|
}
|
|
220
220
|
return result;
|
|
221
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Export shareable memories as a JSON file for team sync.
|
|
224
|
+
* Filters out private/personal memories (type=preference with non-global scope).
|
|
225
|
+
*/
|
|
226
|
+
export async function exportForTeam(db, outputDir, options) {
|
|
227
|
+
const { userId, includeTypes, minConfidence } = options;
|
|
228
|
+
const allowedTypes = includeTypes ?? ["correction", "decision", "pattern", "topology", "fact"];
|
|
229
|
+
const all = db.getAll();
|
|
230
|
+
const filtered = all.filter((m) => {
|
|
231
|
+
// Filter out private/personal preferences (non-global scope)
|
|
232
|
+
if (m.type === "preference" && m.scope !== "global")
|
|
233
|
+
return false;
|
|
234
|
+
// Only include allowed types
|
|
235
|
+
if (!allowedTypes.includes(m.type))
|
|
236
|
+
return false;
|
|
237
|
+
// Min confidence filter
|
|
238
|
+
if (minConfidence !== undefined && m.confidence < minConfidence)
|
|
239
|
+
return false;
|
|
240
|
+
return true;
|
|
241
|
+
});
|
|
242
|
+
const memories = filtered.map((m) => ({
|
|
243
|
+
content: m.content,
|
|
244
|
+
type: m.type,
|
|
245
|
+
tags: m.tags,
|
|
246
|
+
confidence: m.confidence,
|
|
247
|
+
source: m.source,
|
|
248
|
+
scope: m.scope,
|
|
249
|
+
createdAt: m.createdAt,
|
|
250
|
+
}));
|
|
251
|
+
const exportData = {
|
|
252
|
+
version: 1,
|
|
253
|
+
userId,
|
|
254
|
+
exportedAt: Date.now(),
|
|
255
|
+
memories,
|
|
256
|
+
};
|
|
257
|
+
const timestamp = Date.now();
|
|
258
|
+
const fileName = `amem-team-${userId}-${timestamp}.json`;
|
|
259
|
+
const filePath = path.join(outputDir, fileName);
|
|
260
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
261
|
+
fs.writeFileSync(filePath, JSON.stringify(exportData, null, 2) + "\n");
|
|
262
|
+
return { file: filePath, count: memories.length };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Import a teammate's exported memory file.
|
|
266
|
+
* Deduplicates by content hash and lowers confidence by 0.1 for second-hand memories.
|
|
267
|
+
*/
|
|
268
|
+
export async function importFromTeam(db, filePath, options) {
|
|
269
|
+
const dryRun = options?.dryRun ?? false;
|
|
270
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
271
|
+
const data = JSON.parse(raw);
|
|
272
|
+
const fromUser = data.userId;
|
|
273
|
+
let imported = 0;
|
|
274
|
+
let skipped = 0;
|
|
275
|
+
for (const entry of data.memories) {
|
|
276
|
+
// Dedup: skip if content already exists
|
|
277
|
+
const existing = db.findByContentHash(entry.content);
|
|
278
|
+
if (existing) {
|
|
279
|
+
skipped++;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (dryRun) {
|
|
283
|
+
imported++;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
// Lower confidence by 0.1 for second-hand memories, floor at 0.1
|
|
287
|
+
const confidence = Math.max(0.1, entry.confidence - 0.1);
|
|
288
|
+
// Tag with team-sync and the original userId
|
|
289
|
+
const tags = [...entry.tags, "team-sync", `from:${fromUser}`];
|
|
290
|
+
const embedding = await generateEmbedding(entry.content);
|
|
291
|
+
db.insertMemory({
|
|
292
|
+
content: entry.content,
|
|
293
|
+
type: entry.type,
|
|
294
|
+
tags,
|
|
295
|
+
confidence,
|
|
296
|
+
source: `team-sync:${fromUser}`,
|
|
297
|
+
embedding,
|
|
298
|
+
scope: entry.scope,
|
|
299
|
+
});
|
|
300
|
+
imported++;
|
|
301
|
+
}
|
|
302
|
+
return { imported, skipped, from: fromUser };
|
|
303
|
+
}
|
|
222
304
|
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"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GED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { MemoryType, recallMemories, detectConflict, consolidateMemories, autoExpireContradictions } from "../memory.js";
|
|
2
|
+
import { MemoryType, recallMemories, detectConflict, consolidateMemories, autoExpireContradictions, getANNIndex } from "../memory.js";
|
|
3
3
|
import { generateEmbedding, cosineSimilarity } from "../embeddings.js";
|
|
4
4
|
import { sanitizeContent, loadConfig } from "../config.js";
|
|
5
|
+
import { autoRelateMemory } from "../auto-relate.js";
|
|
5
6
|
import { RecallResultSchema, ContextResultSchema, ExtractResultSchema, StatsResultSchema, ExportResultSchema, InjectResultSchema, ConsolidateResultSchema, DetailResultSchema, } from "../schemas.js";
|
|
6
7
|
import { TYPE_ORDER, MEMORY_TYPES, CHARACTER_LIMIT, shortId, formatAge } from "./helpers.js";
|
|
7
8
|
export function registerMemoryTools(server, db, project, autoScope) {
|
|
@@ -64,14 +65,22 @@ Returns:
|
|
|
64
65
|
continue;
|
|
65
66
|
const sim = cosineSimilarity(embedding, mem.embedding);
|
|
66
67
|
if (sim > 0.85) {
|
|
67
|
-
// Near-duplicate — conflict resolution
|
|
68
|
+
// Near-duplicate — smart conflict resolution
|
|
68
69
|
const conflict = detectConflict(content, mem.content, sim);
|
|
69
70
|
if (conflict.isConflict) {
|
|
71
|
+
// If the new memory is a correction or higher confidence, supersede the old one
|
|
72
|
+
const isSuperseding = type === "correction" || confidence > mem.confidence;
|
|
73
|
+
if (isSuperseding) {
|
|
74
|
+
// Auto-expire the old memory and store the new one
|
|
75
|
+
db.expireMemory(mem.id);
|
|
76
|
+
db.snapshotVersion(mem.id, `superseded by new ${type} memory`);
|
|
77
|
+
break; // Fall through to store the new memory below
|
|
78
|
+
}
|
|
70
79
|
db.updateConfidence(mem.id, Math.max(mem.confidence, confidence));
|
|
71
80
|
return {
|
|
72
81
|
content: [{
|
|
73
82
|
type: "text",
|
|
74
|
-
text: `
|
|
83
|
+
text: `Similar memory exists (${(sim * 100).toFixed(0)}% match):\n OLD: "${mem.content}"\n NEW: "${content}"\n\nUpdated confidence of existing memory. To replace it, store as a correction or with higher confidence. To keep both, rephrase to be more distinct.`,
|
|
75
84
|
}],
|
|
76
85
|
structuredContent: {
|
|
77
86
|
action: "conflict_resolved",
|
|
@@ -90,6 +99,17 @@ Returns:
|
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
const id = db.insertMemory({ content, type: type, tags, confidence, source, embedding, scope: scope ?? autoScope(type) });
|
|
102
|
+
// Keep ANN index in sync
|
|
103
|
+
if (embedding) {
|
|
104
|
+
const annIdx = getANNIndex();
|
|
105
|
+
if (annIdx)
|
|
106
|
+
annIdx.add(id, embedding);
|
|
107
|
+
}
|
|
108
|
+
// Auto-relate to similar existing memories
|
|
109
|
+
const autoRelated = autoRelateMemory(db, id);
|
|
110
|
+
const graphNote = autoRelated.created > 0
|
|
111
|
+
? ` Auto-linked to ${autoRelated.created} related memories.`
|
|
112
|
+
: "";
|
|
93
113
|
// Apply boosts and reinforcements collected in the single pass
|
|
94
114
|
for (const b of toBoostConfidence) {
|
|
95
115
|
db.updateConfidence(b.id, Math.min(1.0, b.confidence + 0.1));
|
|
@@ -102,7 +122,7 @@ Returns:
|
|
|
102
122
|
return {
|
|
103
123
|
content: [{
|
|
104
124
|
type: "text",
|
|
105
|
-
text: `Stored ${type} memory (${shortId(id)}). Confidence: ${confidence}. Tags: [${tags.join(", ")}]. Total memories: ${stats.total}.${evolvedNote}`,
|
|
125
|
+
text: `Stored ${type} memory (${shortId(id)}). Confidence: ${confidence}. Tags: [${tags.join(", ")}]. Total memories: ${stats.total}.${evolvedNote}${graphNote}`,
|
|
106
126
|
}],
|
|
107
127
|
structuredContent: {
|
|
108
128
|
action: "stored",
|
|
@@ -133,11 +153,15 @@ Returns:
|
|
|
133
153
|
};
|
|
134
154
|
}
|
|
135
155
|
const id = db.insertMemory({ content, type: type, tags, confidence, source, embedding, scope: scope ?? autoScope(type) });
|
|
156
|
+
const autoRelated = autoRelateMemory(db, id);
|
|
157
|
+
const graphNote = autoRelated.created > 0
|
|
158
|
+
? ` Auto-linked to ${autoRelated.created} related memories.`
|
|
159
|
+
: "";
|
|
136
160
|
const stats = db.getStats();
|
|
137
161
|
return {
|
|
138
162
|
content: [{
|
|
139
163
|
type: "text",
|
|
140
|
-
text: `Stored ${type} memory (${shortId(id)}). Confidence: ${confidence}. Tags: [${tags.join(", ")}]. Total memories: ${stats.total}
|
|
164
|
+
text: `Stored ${type} memory (${shortId(id)}). Confidence: ${confidence}. Tags: [${tags.join(", ")}]. Total memories: ${stats.total}.${graphNote}`,
|
|
141
165
|
}],
|
|
142
166
|
structuredContent: {
|
|
143
167
|
action: "stored",
|
|
@@ -497,6 +521,10 @@ Error Handling:
|
|
|
497
521
|
};
|
|
498
522
|
}
|
|
499
523
|
db.deleteMemory(fullId);
|
|
524
|
+
// Keep ANN index in sync
|
|
525
|
+
const annIdx = getANNIndex();
|
|
526
|
+
if (annIdx)
|
|
527
|
+
annIdx.remove(fullId);
|
|
500
528
|
return {
|
|
501
529
|
content: [{ type: "text", text: `Deleted memory: "${memory.content}" (${memory.type})` }],
|
|
502
530
|
structuredContent: {
|
|
@@ -536,8 +564,13 @@ Error Handling:
|
|
|
536
564
|
},
|
|
537
565
|
};
|
|
538
566
|
}
|
|
539
|
-
for (const m of matches)
|
|
567
|
+
for (const m of matches) {
|
|
540
568
|
db.deleteMemory(m.id);
|
|
569
|
+
// Keep ANN index in sync
|
|
570
|
+
const annIdx2 = getANNIndex();
|
|
571
|
+
if (annIdx2)
|
|
572
|
+
annIdx2.remove(m.id);
|
|
573
|
+
}
|
|
541
574
|
return {
|
|
542
575
|
content: [{ type: "text", text: `Deleted ${matches.length} memories matching "${query}".` }],
|
|
543
576
|
structuredContent: {
|
|
@@ -662,6 +695,12 @@ Returns:
|
|
|
662
695
|
embedding: pending.embedding,
|
|
663
696
|
scope: autoScope(pending.input.type),
|
|
664
697
|
});
|
|
698
|
+
// Keep ANN index in sync
|
|
699
|
+
if (pending.embedding) {
|
|
700
|
+
const annIdx = getANNIndex();
|
|
701
|
+
if (annIdx)
|
|
702
|
+
annIdx.add(id, pending.embedding);
|
|
703
|
+
}
|
|
665
704
|
stored++;
|
|
666
705
|
details.push(` + Stored [${pending.input.type}]: "${pending.input.content}" (${shortId(id)})`);
|
|
667
706
|
structuredDetails.push({
|
|
@@ -945,11 +984,31 @@ Returns:
|
|
|
945
984
|
};
|
|
946
985
|
}
|
|
947
986
|
// Only touch access for memories actually surfaced to the user
|
|
987
|
+
const injectedIds = new Set();
|
|
948
988
|
for (const r of results) {
|
|
949
989
|
if (r.type === MemoryType.CORRECTION || r.type === MemoryType.DECISION) {
|
|
950
990
|
db.touchAccess(r.id);
|
|
991
|
+
injectedIds.add(r.id);
|
|
951
992
|
}
|
|
952
993
|
}
|
|
994
|
+
// Graph-aware injection: surface 1-hop neighbors of top results
|
|
995
|
+
const graphContext = [];
|
|
996
|
+
const topResults = results.filter(r => r.type === MemoryType.CORRECTION || r.type === MemoryType.DECISION).slice(0, 5);
|
|
997
|
+
for (const r of topResults) {
|
|
998
|
+
const related = db.getRelatedMemories(r.id);
|
|
999
|
+
for (const rel of related.slice(0, 2)) {
|
|
1000
|
+
if (injectedIds.has(rel.id))
|
|
1001
|
+
continue;
|
|
1002
|
+
if (rel.validUntil !== null && rel.validUntil <= Date.now())
|
|
1003
|
+
continue;
|
|
1004
|
+
injectedIds.add(rel.id);
|
|
1005
|
+
graphContext.push(`- [${rel.type}] ${rel.content}`);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (graphContext.length > 0) {
|
|
1009
|
+
context += "\n\n## Related Context (from knowledge graph)\n";
|
|
1010
|
+
context += graphContext.join("\n");
|
|
1011
|
+
}
|
|
953
1012
|
return {
|
|
954
1013
|
content: [{ type: "text", text: context.trim() }],
|
|
955
1014
|
structuredContent: {
|
|
@@ -957,7 +1016,7 @@ Returns:
|
|
|
957
1016
|
corrections,
|
|
958
1017
|
decisions,
|
|
959
1018
|
context: context.trim(),
|
|
960
|
-
memoriesUsed: corrections.length + decisions.length,
|
|
1019
|
+
memoriesUsed: corrections.length + decisions.length + graphContext.length,
|
|
961
1020
|
},
|
|
962
1021
|
};
|
|
963
1022
|
}
|
|
@@ -1133,8 +1192,13 @@ Args:
|
|
|
1133
1192
|
// Regenerate embedding if content changed
|
|
1134
1193
|
if (field === "content" && typeof value === "string") {
|
|
1135
1194
|
const newEmbedding = await generateEmbedding(value);
|
|
1136
|
-
if (newEmbedding)
|
|
1195
|
+
if (newEmbedding) {
|
|
1137
1196
|
db.updateEmbedding(fullId, newEmbedding);
|
|
1197
|
+
// Keep ANN index in sync
|
|
1198
|
+
const annIdx = getANNIndex();
|
|
1199
|
+
if (annIdx)
|
|
1200
|
+
annIdx.add(fullId, newEmbedding);
|
|
1201
|
+
}
|
|
1138
1202
|
}
|
|
1139
1203
|
const displayValue = Array.isArray(value) ? `[${value.join(", ")}]` : String(value);
|
|
1140
1204
|
return {
|
|
@@ -1225,6 +1289,12 @@ Returns:
|
|
|
1225
1289
|
embedding,
|
|
1226
1290
|
scope: autoScope(input.type),
|
|
1227
1291
|
});
|
|
1292
|
+
// Keep ANN index in sync
|
|
1293
|
+
if (embedding) {
|
|
1294
|
+
const annIdx = getANNIndex();
|
|
1295
|
+
if (annIdx)
|
|
1296
|
+
annIdx.add(id, embedding);
|
|
1297
|
+
}
|
|
1228
1298
|
stored++;
|
|
1229
1299
|
details.push({
|
|
1230
1300
|
action: "stored",
|