mem0ai 2.4.6 → 3.0.0-beta.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.
@@ -46,17 +46,6 @@ interface LLMConfig {
46
46
  model?: string | any;
47
47
  modelProperties?: Record<string, any>;
48
48
  }
49
- interface Neo4jConfig {
50
- url: string;
51
- username: string;
52
- password: string;
53
- }
54
- interface GraphStoreConfig {
55
- provider: string;
56
- config: Neo4jConfig;
57
- llm?: LLMConfig;
58
- customPrompt?: string;
59
- }
60
49
  interface MemoryConfig {
61
50
  version?: string;
62
51
  embedder: {
@@ -74,9 +63,7 @@ interface MemoryConfig {
74
63
  historyStore?: HistoryStoreConfig;
75
64
  disableHistory?: boolean;
76
65
  historyDbPath?: string;
77
- customPrompt?: string;
78
- graphStore?: GraphStoreConfig;
79
- enableGraph?: boolean;
66
+ customInstructions?: string;
80
67
  }
81
68
  interface MemoryItem {
82
69
  id: string;
@@ -88,14 +75,13 @@ interface MemoryItem {
88
75
  metadata?: Record<string, any>;
89
76
  }
90
77
  interface SearchFilters {
91
- userId?: string;
92
- agentId?: string;
93
- runId?: string;
78
+ user_id?: string;
79
+ agent_id?: string;
80
+ run_id?: string;
94
81
  [key: string]: any;
95
82
  }
96
83
  interface SearchResult {
97
84
  results: MemoryItem[];
98
- relations?: any[];
99
85
  }
100
86
  interface VectorStoreResult {
101
87
  id: string;
@@ -229,59 +215,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
229
215
  };
230
216
  }>;
231
217
  historyDbPath: z.ZodOptional<z.ZodString>;
232
- customPrompt: z.ZodOptional<z.ZodString>;
233
- enableGraph: z.ZodOptional<z.ZodBoolean>;
234
- graphStore: z.ZodOptional<z.ZodObject<{
235
- provider: z.ZodString;
236
- config: z.ZodObject<{
237
- url: z.ZodString;
238
- username: z.ZodString;
239
- password: z.ZodString;
240
- }, "strip", z.ZodTypeAny, {
241
- url: string;
242
- username: string;
243
- password: string;
244
- }, {
245
- url: string;
246
- username: string;
247
- password: string;
248
- }>;
249
- llm: z.ZodOptional<z.ZodObject<{
250
- provider: z.ZodString;
251
- config: z.ZodRecord<z.ZodString, z.ZodAny>;
252
- }, "strip", z.ZodTypeAny, {
253
- provider: string;
254
- config: Record<string, any>;
255
- }, {
256
- provider: string;
257
- config: Record<string, any>;
258
- }>>;
259
- customPrompt: z.ZodOptional<z.ZodString>;
260
- }, "strip", z.ZodTypeAny, {
261
- provider: string;
262
- config: {
263
- url: string;
264
- username: string;
265
- password: string;
266
- };
267
- llm?: {
268
- provider: string;
269
- config: Record<string, any>;
270
- } | undefined;
271
- customPrompt?: string | undefined;
272
- }, {
273
- provider: string;
274
- config: {
275
- url: string;
276
- username: string;
277
- password: string;
278
- };
279
- llm?: {
280
- provider: string;
281
- config: Record<string, any>;
282
- } | undefined;
283
- customPrompt?: string | undefined;
284
- }>>;
218
+ customInstructions: z.ZodOptional<z.ZodString>;
285
219
  historyStore: z.ZodOptional<z.ZodObject<{
286
220
  provider: z.ZodString;
287
221
  config: z.ZodRecord<z.ZodString, z.ZodAny>;
@@ -328,21 +262,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
328
262
  };
329
263
  version?: string | undefined;
330
264
  historyDbPath?: string | undefined;
331
- customPrompt?: string | undefined;
332
- enableGraph?: boolean | undefined;
333
- graphStore?: {
334
- provider: string;
335
- config: {
336
- url: string;
337
- username: string;
338
- password: string;
339
- };
340
- llm?: {
341
- provider: string;
342
- config: Record<string, any>;
343
- } | undefined;
344
- customPrompt?: string | undefined;
345
- } | undefined;
265
+ customInstructions?: string | undefined;
346
266
  historyStore?: {
347
267
  provider: string;
348
268
  config: Record<string, any>;
@@ -383,21 +303,7 @@ declare const MemoryConfigSchema: z.ZodObject<{
383
303
  };
384
304
  version?: string | undefined;
385
305
  historyDbPath?: string | undefined;
386
- customPrompt?: string | undefined;
387
- enableGraph?: boolean | undefined;
388
- graphStore?: {
389
- provider: string;
390
- config: {
391
- url: string;
392
- username: string;
393
- password: string;
394
- };
395
- llm?: {
396
- provider: string;
397
- config: Record<string, any>;
398
- } | undefined;
399
- customPrompt?: string | undefined;
400
- } | undefined;
306
+ customInstructions?: string | undefined;
401
307
  historyStore?: {
402
308
  provider: string;
403
309
  config: Record<string, any>;
@@ -415,30 +321,31 @@ interface AddMemoryOptions extends Entity {
415
321
  filters?: SearchFilters;
416
322
  infer?: boolean;
417
323
  }
418
- interface SearchMemoryOptions extends Entity {
419
- limit?: number;
324
+ interface SearchMemoryOptions {
325
+ topK?: number;
420
326
  filters?: SearchFilters;
327
+ threshold?: number;
421
328
  }
422
- interface GetAllMemoryOptions extends Entity {
423
- limit?: number;
329
+ interface GetAllMemoryOptions {
330
+ topK?: number;
331
+ filters?: SearchFilters;
424
332
  }
425
333
  interface DeleteAllMemoryOptions extends Entity {
426
334
  }
427
335
 
428
336
  declare class Memory {
429
337
  private config;
430
- private customPrompt;
338
+ private customInstructions;
431
339
  private embedder;
432
340
  private vectorStore;
433
341
  private llm;
434
342
  private db;
435
343
  private collectionName;
436
344
  private apiVersion;
437
- private graphMemory?;
438
- private enableGraph;
439
345
  telemetryId: string;
440
346
  private _initPromise;
441
347
  private _initError?;
348
+ private _entityStore?;
442
349
  constructor(config?: Partial<MemoryConfig>);
443
350
  /**
444
351
  * If no explicit dimension was provided, runs a probe embedding to
@@ -451,6 +358,8 @@ declare class Memory {
451
358
  * If a previous init attempt failed, retries automatically.
452
359
  */
453
360
  private _ensureInitialized;
361
+ private getEntityStore;
362
+ private buildSessionScope;
454
363
  private _initializeTelemetry;
455
364
  private _getTelemetryId;
456
365
  private _captureEvent;
@@ -474,6 +383,15 @@ declare class Memory {
474
383
  private createMemory;
475
384
  private updateMemory;
476
385
  private deleteMemory;
386
+ /**
387
+ * Check if filters contain advanced operators that need special processing.
388
+ */
389
+ private _hasAdvancedOperators;
390
+ /**
391
+ * Process enhanced metadata filters and convert them to vector store compatible format.
392
+ * Converts AND/OR/NOT to $or/$not format that vector stores can interpret.
393
+ */
394
+ private _processMetadataFilters;
477
395
  }
478
396
 
479
397
  interface Embedder {
@@ -647,12 +565,13 @@ declare class LangchainLLM implements LLM {
647
565
 
648
566
  interface VectorStore {
649
567
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
650
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
568
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
569
+ keywordSearch?(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
651
570
  get(vectorId: string): Promise<VectorStoreResult | null>;
652
571
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
653
572
  delete(vectorId: string): Promise<void>;
654
573
  deleteCol(): Promise<void>;
655
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
574
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
656
575
  getUserId(): Promise<string>;
657
576
  setUserId(userId: string): Promise<void>;
658
577
  initialize(): Promise<void>;
@@ -665,14 +584,25 @@ declare class MemoryVectorStore implements VectorStore {
665
584
  constructor(config: VectorStoreConfig);
666
585
  private init;
667
586
  private cosineSimilarity;
587
+ /**
588
+ * Check if a single field condition matches the payload.
589
+ * Supports comparison operators: eq, ne, gt, gte, lt, lte, in, nin, contains, icontains
590
+ */
591
+ private matchFieldCondition;
592
+ /**
593
+ * Filter a vector by the given filters.
594
+ * Supports logical operators (AND, OR, NOT) and comparison operators.
595
+ */
668
596
  private filterVector;
669
597
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
670
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
598
+ private tokenize;
599
+ keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
600
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
671
601
  get(vectorId: string): Promise<VectorStoreResult | null>;
672
602
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
673
603
  delete(vectorId: string): Promise<void>;
674
604
  deleteCol(): Promise<void>;
675
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
605
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
676
606
  getUserId(): Promise<string>;
677
607
  setUserId(userId: string): Promise<void>;
678
608
  initialize(): Promise<void>;
@@ -710,14 +640,24 @@ declare class Qdrant implements VectorStore {
710
640
  private dimension;
711
641
  private _initPromise?;
712
642
  constructor(config: QdrantConfig);
643
+ /**
644
+ * Build a single field condition from a key-value filter pair.
645
+ * Supports enhanced filter syntax with comparison operators.
646
+ */
647
+ private buildFieldCondition;
648
+ /**
649
+ * Create a Filter object from the provided filters.
650
+ * Supports logical operators (AND, OR, NOT) and comparison operators.
651
+ */
713
652
  private createFilter;
714
653
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
715
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
654
+ keywordSearch(): Promise<null>;
655
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
716
656
  get(vectorId: string): Promise<VectorStoreResult | null>;
717
657
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
718
658
  delete(vectorId: string): Promise<void>;
719
659
  deleteCol(): Promise<void>;
720
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
660
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
721
661
  private generateUUID;
722
662
  getUserId(): Promise<string>;
723
663
  setUserId(userId: string): Promise<void>;
@@ -744,12 +684,13 @@ declare class RedisDB implements VectorStore {
744
684
  initialize(): Promise<void>;
745
685
  private _doInitialize;
746
686
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
747
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
687
+ keywordSearch(): Promise<null>;
688
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
748
689
  get(vectorId: string): Promise<VectorStoreResult | null>;
749
690
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
750
691
  delete(vectorId: string): Promise<void>;
751
692
  deleteCol(): Promise<void>;
752
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
693
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
753
694
  close(): Promise<void>;
754
695
  getUserId(): Promise<string>;
755
696
  setUserId(userId: string): Promise<void>;
@@ -772,12 +713,13 @@ declare class SupabaseDB implements VectorStore {
772
713
  initialize(): Promise<void>;
773
714
  private _doInitialize;
774
715
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
775
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
716
+ keywordSearch(): Promise<null>;
717
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
776
718
  get(vectorId: string): Promise<VectorStoreResult | null>;
777
719
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
778
720
  delete(vectorId: string): Promise<void>;
779
721
  deleteCol(): Promise<void>;
780
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
722
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
781
723
  getUserId(): Promise<string>;
782
724
  setUserId(userId: string): Promise<void>;
783
725
  }
@@ -791,11 +733,12 @@ declare class LangchainVectorStore implements VectorStore {
791
733
  private storeUserId;
792
734
  constructor(config: LangchainStoreConfig);
793
735
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
794
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
736
+ keywordSearch(): Promise<null>;
737
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
795
738
  get(vectorId: string): Promise<VectorStoreResult | null>;
796
739
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
797
740
  delete(vectorId: string): Promise<void>;
798
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
741
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
799
742
  deleteCol(): Promise<void>;
800
743
  getUserId(): Promise<string>;
801
744
  setUserId(userId: string): Promise<void>;
@@ -815,12 +758,13 @@ declare class VectorizeDB implements VectorStore {
815
758
  private _initPromise?;
816
759
  constructor(config: VectorizeConfig);
817
760
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
818
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
761
+ keywordSearch(): Promise<null>;
762
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
819
763
  get(vectorId: string): Promise<VectorStoreResult | null>;
820
764
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
821
765
  delete(vectorId: string): Promise<void>;
822
766
  deleteCol(): Promise<void>;
823
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
767
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
824
768
  private generateUUID;
825
769
  getUserId(): Promise<string>;
826
770
  setUserId(userId: string): Promise<void>;
@@ -916,10 +860,14 @@ declare class AzureAISearch implements VectorStore {
916
860
  * Handles cases where payload might have extra text
917
861
  */
918
862
  private extractJson;
863
+ /**
864
+ * Keyword search using Azure AI Search native full-text (BM25) capabilities
865
+ */
866
+ keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
919
867
  /**
920
868
  * Search for similar vectors
921
869
  */
922
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
870
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
923
871
  /**
924
872
  * Delete a vector by ID
925
873
  */
@@ -947,7 +895,7 @@ declare class AzureAISearch implements VectorStore {
947
895
  /**
948
896
  * List all vectors in the index
949
897
  */
950
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
898
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
951
899
  /**
952
900
  * Generate a random user ID
953
901
  */
@@ -991,13 +939,14 @@ declare class PGVector implements VectorStore {
991
939
  private createDatabase;
992
940
  private createCol;
993
941
  insert(vectors: number[][], ids: string[], payloads: Record<string, any>[]): Promise<void>;
994
- search(query: number[], limit?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
942
+ keywordSearch(query: string, topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[] | null>;
943
+ search(query: number[], topK?: number, filters?: SearchFilters): Promise<VectorStoreResult[]>;
995
944
  get(vectorId: string): Promise<VectorStoreResult | null>;
996
945
  update(vectorId: string, vector: number[], payload: Record<string, any>): Promise<void>;
997
946
  delete(vectorId: string): Promise<void>;
998
947
  deleteCol(): Promise<void>;
999
948
  private listCols;
1000
- list(filters?: SearchFilters, limit?: number): Promise<[VectorStoreResult[], number]>;
949
+ list(filters?: SearchFilters, topK?: number): Promise<[VectorStoreResult[], number]>;
1001
950
  close(): Promise<void>;
1002
951
  getUserId(): Promise<string>;
1003
952
  setUserId(userId: string): Promise<void>;
@@ -1008,6 +957,26 @@ interface HistoryManager {
1008
957
  getHistory(memoryId: string): Promise<any[]>;
1009
958
  reset(): Promise<void>;
1010
959
  close(): void;
960
+ saveMessages?(messages: Array<{
961
+ role: string;
962
+ content: string;
963
+ name?: string;
964
+ }>, sessionScope: string): Promise<void>;
965
+ getLastMessages?(sessionScope: string, limit?: number): Promise<Array<{
966
+ role: string;
967
+ content: string;
968
+ name?: string;
969
+ createdAt: string;
970
+ }>>;
971
+ batchAddHistory?(records: Array<{
972
+ memoryId: string;
973
+ previousValue: string | null;
974
+ newValue: string | null;
975
+ action: string;
976
+ createdAt?: string;
977
+ updatedAt?: string;
978
+ isDeleted?: number;
979
+ }>): Promise<void>;
1011
980
  }
1012
981
 
1013
982
  declare class EmbedderFactory {
@@ -1023,4 +992,4 @@ declare class HistoryManagerFactory {
1023
992
  static create(provider: string, config: HistoryStoreConfig): HistoryManager;
1024
993
  }
1025
994
 
1026
- export { type AddMemoryOptions, AnthropicLLM, AzureAISearch, AzureOpenAIEmbedder, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, type GraphStoreConfig, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, type LLM, type LLMConfig, LLMFactory, type LLMResponse, LMStudioEmbedder, LMStudioLLM, LangchainEmbedder, LangchainLLM, LangchainVectorStore, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, MistralLLM, type MultiModalMessages, type Neo4jConfig, OllamaEmbedder, OllamaLLM, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, PGVector, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, SupabaseDB, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult, VectorizeDB };
995
+ export { type AddMemoryOptions, AnthropicLLM, AzureAISearch, AzureOpenAIEmbedder, type DeleteAllMemoryOptions, type Embedder, EmbedderFactory, type EmbeddingConfig, type Entity, type GetAllMemoryOptions, GoogleEmbedder, GoogleLLM, GroqLLM, HistoryManagerFactory, type HistoryStoreConfig, type LLM, type LLMConfig, LLMFactory, type LLMResponse, LMStudioEmbedder, LMStudioLLM, LangchainEmbedder, LangchainLLM, LangchainVectorStore, Memory, type MemoryConfig, MemoryConfigSchema, type MemoryItem, MemoryVectorStore, type Message, MistralLLM, type MultiModalMessages, OllamaEmbedder, OllamaLLM, OpenAIEmbedder, OpenAILLM, OpenAIStructuredLLM, PGVector, Qdrant, RedisDB, type SearchFilters, type SearchMemoryOptions, type SearchResult, SupabaseDB, type VectorStore, type VectorStoreConfig, VectorStoreFactory, type VectorStoreResult, VectorizeDB };