mem0ai 1.0.21 → 1.0.24

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/README.md CHANGED
@@ -24,23 +24,19 @@ For **ESM** usage:
24
24
  import MemoryClient from 'mem0ai';
25
25
 
26
26
  const apiKey = 'your-api-key-here';
27
- const client = new MemoryClient(apiKey);
27
+
28
+ const client = new MemoryClient({
29
+ apiKey: apiKey,
30
+ organizationId: 'your-organization-id-here', // Optional
31
+ projectId: 'your-project-id-here' // Optional
32
+ });
33
+
28
34
  ```
29
35
 
30
- For **CommonJS** usage:
31
- ```javascript
32
- const MemoryClient = require('../dist/index.js').default;
36
+ **Note**: If you are passing `organizationId`, you must also pass `projectId`. Either pass both `organizationId` and `projectId` or none.
33
37
 
34
- const apiKey = 'your-api-key-here';
35
- const client = new MemoryClient(apiKey);
36
- ```
37
38
  Alternatively, you can set the `MEM0_API_KEY` environment variable and instantiate the client without passing the API key:
38
39
 
39
- ```javascript
40
- import MemoryClient from 'mem0ai';
41
-
42
- const client = new MemoryClient(process.env.MEM0_API_KEY);
43
- ```
44
40
 
45
41
  ## 4. Memory Operations
46
42
 
package/dist/index.d.mts CHANGED
@@ -6,6 +6,8 @@ interface MemoryOptions {
6
6
  filters?: Record<string, any>;
7
7
  org_name?: string | null;
8
8
  project_name?: string | null;
9
+ org_id?: string | number | null;
10
+ project_id?: string | number | null;
9
11
  }
10
12
  declare enum API_VERSION {
11
13
  V1 = "v1",
@@ -71,16 +73,26 @@ interface AllUsers {
71
73
  previous: any;
72
74
  }
73
75
 
76
+ interface ClientOptions {
77
+ apiKey: string;
78
+ host?: string;
79
+ organizationName?: string;
80
+ projectName?: string;
81
+ organizationId?: string;
82
+ projectId?: string;
83
+ }
74
84
  declare class MemoryClient {
75
85
  apiKey: string;
76
86
  host: string;
77
87
  organizationName: string | null;
78
88
  projectName: string | null;
89
+ organizationId: string | number | null;
90
+ projectId: string | number | null;
79
91
  headers: Record<string, string>;
80
92
  client: any;
81
93
  telemetryId: string;
82
94
  _validateApiKey(): any;
83
- constructor(apiKey: string, host?: string, organizationName?: null, projectName?: null);
95
+ constructor(options: ClientOptions);
84
96
  wrapMethod(methodName: any, method: any): (...args: any) => Promise<any>;
85
97
  _fetchWithErrorHandling(url: string, options: any): Promise<any>;
86
98
  _preparePayload(messages: string | Array<{
@@ -113,4 +125,4 @@ declare class MemoryClient {
113
125
  }>;
114
126
  }
115
127
 
116
- export { API_VERSION, type AllUsers, type Memory, type MemoryData, type MemoryHistory, type MemoryOptions, type Messages, type SearchOptions, type User, MemoryClient as default };
128
+ export { API_VERSION, type AllUsers, type Memory, MemoryClient, type MemoryData, type MemoryHistory, type MemoryOptions, type Messages, type SearchOptions, type User, MemoryClient as default };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ interface MemoryOptions {
6
6
  filters?: Record<string, any>;
7
7
  org_name?: string | null;
8
8
  project_name?: string | null;
9
+ org_id?: string | number | null;
10
+ project_id?: string | number | null;
9
11
  }
10
12
  declare enum API_VERSION {
11
13
  V1 = "v1",
@@ -71,16 +73,26 @@ interface AllUsers {
71
73
  previous: any;
72
74
  }
73
75
 
76
+ interface ClientOptions {
77
+ apiKey: string;
78
+ host?: string;
79
+ organizationName?: string;
80
+ projectName?: string;
81
+ organizationId?: string;
82
+ projectId?: string;
83
+ }
74
84
  declare class MemoryClient {
75
85
  apiKey: string;
76
86
  host: string;
77
87
  organizationName: string | null;
78
88
  projectName: string | null;
89
+ organizationId: string | number | null;
90
+ projectId: string | number | null;
79
91
  headers: Record<string, string>;
80
92
  client: any;
81
93
  telemetryId: string;
82
94
  _validateApiKey(): any;
83
- constructor(apiKey: string, host?: string, organizationName?: null, projectName?: null);
95
+ constructor(options: ClientOptions);
84
96
  wrapMethod(methodName: any, method: any): (...args: any) => Promise<any>;
85
97
  _fetchWithErrorHandling(url: string, options: any): Promise<any>;
86
98
  _preparePayload(messages: string | Array<{
@@ -113,4 +125,5 @@ declare class MemoryClient {
113
125
  }>;
114
126
  }
115
127
 
116
- export { API_VERSION, type AllUsers, type Memory, type MemoryData, type MemoryHistory, type MemoryOptions, type Messages, type SearchOptions, type User, MemoryClient as default };
128
+ export { API_VERSION, type AllUsers, type Memory, MemoryClient, type MemoryData, type MemoryHistory, type MemoryOptions, type Messages, type SearchOptions, type User, MemoryClient as default };
129
+ export = MemoryClient
package/dist/index.js CHANGED
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  API_VERSION: () => API_VERSION,
34
- default: () => mem0_default
34
+ MemoryClient: () => MemoryClient,
35
+ default: () => src_default
35
36
  });
36
37
  module.exports = __toCommonJS(src_exports);
37
38
 
@@ -110,11 +111,13 @@ var MemoryClient = class {
110
111
  throw new Error("Mem0 API key cannot be empty");
111
112
  }
112
113
  }
113
- constructor(apiKey, host = "https://api.mem0.ai", organizationName = null, projectName = null) {
114
- this.apiKey = apiKey;
115
- this.host = host;
116
- this.organizationName = organizationName;
117
- this.projectName = projectName;
114
+ constructor(options) {
115
+ this.apiKey = options.apiKey;
116
+ this.host = options.host || "https://api.mem0.ai";
117
+ this.organizationName = options.organizationName || null;
118
+ this.projectName = options.projectName || null;
119
+ this.organizationId = options.organizationId || null;
120
+ this.projectId = options.projectId || null;
118
121
  this.headers = {
119
122
  "Authorization": `Token ${this.apiKey}`,
120
123
  "Content-Type": "application/json"
@@ -170,6 +173,12 @@ var MemoryClient = class {
170
173
  options.org_name = this.organizationName;
171
174
  options.project_name = this.projectName;
172
175
  }
176
+ if (this.organizationId != null && this.projectId != null) {
177
+ options.org_id = this.organizationId;
178
+ options.project_id = this.projectId;
179
+ if (options.org_name) delete options.org_name;
180
+ if (options.project_name) delete options.project_name;
181
+ }
173
182
  const payload = this._preparePayload(messages, options);
174
183
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {
175
184
  method: "POST",
@@ -189,6 +198,12 @@ var MemoryClient = class {
189
198
  otherOptions.org_name = this.organizationName;
190
199
  otherOptions.project_name = this.projectName;
191
200
  }
201
+ if (this.organizationId != null && this.projectId != null) {
202
+ otherOptions.org_id = this.organizationId;
203
+ otherOptions.project_id = this.projectId;
204
+ if (otherOptions.org_name) delete otherOptions.org_name;
205
+ if (otherOptions.project_name) delete otherOptions.project_name;
206
+ }
192
207
  if (api_version === "v2") {
193
208
  return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {
194
209
  method: "POST",
@@ -209,6 +224,12 @@ var MemoryClient = class {
209
224
  payload.org_name = this.organizationName;
210
225
  payload.project_name = this.projectName;
211
226
  }
227
+ if (this.organizationId != null && this.projectId != null) {
228
+ payload.org_id = this.organizationId;
229
+ payload.project_id = this.projectId;
230
+ if (payload.org_name) delete payload.org_name;
231
+ if (payload.project_name) delete payload.project_name;
232
+ }
212
233
  const endpoint = api_version === "v2" ? "/v2/memories/search/" : "/v1/memories/search/";
213
234
  const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {
214
235
  method: "POST",
@@ -228,6 +249,12 @@ var MemoryClient = class {
228
249
  options.org_name = this.organizationName;
229
250
  options.project_name = this.projectName;
230
251
  }
252
+ if (this.organizationId != null && this.projectId != null) {
253
+ options.org_id = this.organizationId;
254
+ options.project_id = this.projectId;
255
+ if (options.org_name) delete options.org_name;
256
+ if (options.project_name) delete options.project_name;
257
+ }
231
258
  const params = new URLSearchParams(this._prepareParams(options));
232
259
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {
233
260
  method: "DELETE",
@@ -247,6 +274,12 @@ var MemoryClient = class {
247
274
  options.org_name = this.organizationName;
248
275
  options.project_name = this.projectName;
249
276
  }
277
+ if (this.organizationId != null && this.projectId != null) {
278
+ options.org_id = this.organizationId;
279
+ options.project_id = this.projectId;
280
+ if (options.org_name) delete options.org_name;
281
+ if (options.project_name) delete options.project_name;
282
+ }
250
283
  const params = new URLSearchParams(options);
251
284
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {
252
285
  headers: this.headers
@@ -263,17 +296,22 @@ var MemoryClient = class {
263
296
  async deleteUsers() {
264
297
  const entities = await this.users();
265
298
  for (const entity of entities.results) {
266
- let params = {};
299
+ let options = {};
267
300
  if (this.organizationName != null && this.projectName != null) {
268
- params.org_name = this.organizationName;
269
- params.project_name = this.projectName;
301
+ options.org_name = this.organizationName;
302
+ options.project_name = this.projectName;
270
303
  }
271
- await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params });
304
+ if (this.organizationId != null && this.projectId != null) {
305
+ options.org_id = this.organizationId;
306
+ options.project_id = this.projectId;
307
+ if (options.org_name) delete options.org_name;
308
+ if (options.project_name) delete options.project_name;
309
+ }
310
+ await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params: options });
272
311
  }
273
312
  return { message: "All users, agents, and sessions deleted." };
274
313
  }
275
314
  };
276
- var mem0_default = MemoryClient;
277
315
 
278
316
  // src/mem0.types.ts
279
317
  var API_VERSION = /* @__PURE__ */ ((API_VERSION2) => {
@@ -281,8 +319,18 @@ var API_VERSION = /* @__PURE__ */ ((API_VERSION2) => {
281
319
  API_VERSION2["V2"] = "v2";
282
320
  return API_VERSION2;
283
321
  })(API_VERSION || {});
322
+
323
+ // src/index.ts
324
+ var src_default = MemoryClient;
284
325
  // Annotate the CommonJS export names for ESM import in node:
285
326
  0 && (module.exports = {
286
- API_VERSION
327
+ API_VERSION,
328
+ MemoryClient
287
329
  });
288
- //# sourceMappingURL=index.js.map
330
+ //# sourceMappingURL=index.js.map
331
+ // fix-cjs-exports
332
+ if (module.exports.default) {
333
+ Object.assign(module.exports.default, module.exports);
334
+ module.exports = module.exports.default;
335
+ delete module.exports.default;
336
+ }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/mem0.ts","../src/telemetry.ts","../src/mem0.types.ts"],"sourcesContent":["export {default} from './mem0';\nexport * from './mem0.types';","import axios from 'axios';\nimport { AllUsers, Memory, MemoryHistory, MemoryOptions, SearchOptions } from './mem0.types';\nimport { captureClientEvent } from './telemetry';\nimport crypto from 'crypto';\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'APIError';\n }\n}\n\ninterface ClientOptions {\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n}\n\nclass MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error('Mem0 API key is required');\n }\n if (typeof this.apiKey !== 'string') {\n throw new Error('Mem0 API key must be a string');\n }\n if (this.apiKey.trim() === '') {\n throw new Error('Mem0 API key cannot be empty');\n }\n }\n constructor(apiKey: string, host = 'https://api.mem0.ai', organizationName = null, projectName = null) {\n this.apiKey = apiKey;\n this.host = host;\n this.organizationName = organizationName;\n this.projectName = projectName;\n\n this.headers = {\n 'Authorization': `Token ${this.apiKey}`,\n 'Content-Type': 'application/json'\n };\n\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n\n this.telemetryId = crypto.createHash('md5').update(this.apiKey).digest('hex');\n\n captureClientEvent('init', this);\n\n this.add = this.wrapMethod('add', this.add);\n this.get = this.wrapMethod('get', this.get);\n this.getAll = this.wrapMethod('get_all', this.getAll);\n this.search = this.wrapMethod('search', this.search);\n this.delete = this.wrapMethod('delete', this.delete);\n this.deleteAll = this.wrapMethod('delete_all', this.deleteAll);\n this.history = this.wrapMethod('history', this.history);\n this.users = this.wrapMethod('users', this.users);\n this.deleteUser = this.wrapMethod('delete_user', this.deleteUser);\n this.deleteUsers = this.wrapMethod('delete_users', this.deleteUsers);\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n}\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions): object {\n const payload: any = {};\n if (typeof messages === 'string') {\n payload.messages = [{ role: 'user', content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));\n }\n\n async add(messages: string | Array<{ role: string; content: string }>, options:MemoryOptions = {}): Promise<Array<Memory>> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async get(memoryId: string):Promise<Memory> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n headers: this.headers\n });\n }\n\n getAll(options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n if(this.organizationName != null && this.projectName != null){\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n }\n\n if (api_version === 'v2') {\n return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(otherOptions)\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n headers: this.headers\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if(this.organizationName != null && this.projectName != null){\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n }\n const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';\n const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/history/`, {\n headers: this.headers\n });\n return response;\n }\n\n async users(): Promise<AllUsers>{\n const options: { org_name?: string | null; project_name?: string | null } = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {\n headers: this.headers\n });\n return response;\n }\n\n async deleteUser(entityId: string, entity: { type: string } = { type: 'user' }): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n const entities = await this.users();\n \n for (const entity of entities.results) {\n let params: { org_name?: string | null; project_name?: string | null } = {};\n if (this.organizationName != null && this.projectName != null){\n params.org_name = this.organizationName;\n params.project_name = this.projectName;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n}\n\nexport default MemoryClient;","// @ts-nocheck\nimport { PostHog } from \"posthog-node\";\nimport os from \"os\";\nimport path from \"path\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\n\nclass AnonymousTelemetry {\n constructor(projectApiKey, host) {\n this.client = new PostHog(projectApiKey, { host, flushAt: 1 });\n }\n async captureEvent(distinctId, eventName, properties = {}) {\n const eventProperties = {\n client_source: \"nodejs\",\n client_version: getVersion(),\n node_version: process.version,\n os: process.platform,\n os_version: os.release(),\n os_arch: os.arch(),\n ...properties,\n };\n try {\n this.client.capture({\n distinctId: distinctId,\n event: eventName,\n properties: eventProperties,\n });\n } catch (error) {\n console.error(\"Error capturing event:\", error);\n }\n }\n async shutdown() {\n return this.client.shutdown();\n }\n}\nfunction getVersion() {\n return version;\n}\nconst telemetry = new AnonymousTelemetry(\n \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\",\n \"https://us.i.posthog.com\"\n);\nasync function captureClientEvent(eventName, instance, additionalData = {}) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData\n );\n}\nexport { telemetry, captureClientEvent };","export interface MemoryOptions {\n user_id?: string;\n agent_id?: string;\n app_id?: string;\n metadata?: Record<string, any>;\n filters?: Record<string, any>;\n org_name?: string | null;\n project_name?: string | null;\n}\n\nexport enum API_VERSION {\n V1 = \"v1\",\n V2 = \"v2\",\n}\n\nexport interface Messages {\n role: string;\n content: string;\n}\n\nexport interface MemoryHistory {\n id: string;\n memory_id: string;\n input: Array<Messages>;\n old_memory: string | null;\n new_memory: string | null;\n user_id: string;\n categories: Array<string>;\n event: Event | string;\n created_at: Date;\n updated_at: Date;\n}\n\nexport interface SearchOptions extends MemoryOptions {\n api_version?: API_VERSION | string;\n limit?: number;\n}\n\nenum Event {\n ADD = \"ADD\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n NOOP = \"NOOP\",\n}\n\nexport interface MemoryData {\n memory: string;\n}\n\nexport interface Memory {\n id: string;\n messages?: Array<Messages>;\n event?: Event | string;\n data?: MemoryData | null;\n memory?: string;\n user_id?: string;\n hash?: string;\n categories?: Array<string>;\n created_at?: Date;\n updated_at?: Date;\n memory_type?: string;\n score?: number;\n metadata?: any | null;\n}\n\nexport interface User {\n id: string;\n name: string;\n created_at: Date;\n updated_at: Date;\n total_memories: number;\n owner: string;\n type: string;\n}\n\nexport interface AllUsers {\n count: number;\n results: Array<User>;\n next: any;\n previous: any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;;;ACClB,0BAAwB;AACxB,gBAAe;AAGf,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AAEtD,IAAM,qBAAN,MAAyB;AAAA,EACvB,YAAY,eAAe,MAAM;AAC/B,SAAK,SAAS,IAAI,4BAAQ,eAAe,EAAE,MAAM,SAAS,EAAE,CAAC;AAAA,EAC/D;AAAA,EACA,MAAM,aAAa,YAAY,WAAW,aAAa,CAAC,GAAG;AACzD,UAAM,kBAAkB;AAAA,MACtB,eAAe;AAAA,MACf,gBAAgB,WAAW;AAAA,MAC3B,cAAc,QAAQ;AAAA,MACtB,IAAI,QAAQ;AAAA,MACZ,YAAY,UAAAA,QAAG,QAAQ;AAAA,MACvB,SAAS,UAAAA,QAAG,KAAK;AAAA,MACjB,GAAG;AAAA,IACL;AACA,QAAI;AACF,WAAK,OAAO,QAAQ;AAAA,QAClB;AAAA,QACA,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,0BAA0B,KAAK;AAAA,IAC/C;AAAA,EACF;AAAA,EACA,MAAM,WAAW;AACf,WAAO,KAAK,OAAO,SAAS;AAAA,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EAEA,MAAM,QAA0B;AAC9B,UAAM,UAAsE,CAAC;AAC7E,QAAG,KAAK,oBAAoB,QAAQ,KAAK,eAAe,MAAK;AAC3D,cAAQ,WAAW,KAAK;AACxB,cAAQ,eAAe,KAAK;AAAA,IAC9B;AAEA,UAAM,SAAS,IAAI,gBAAgB,OAAO;AAC1C,UAAM,WAAW,MAAM,KAAK,wBAAwB,GAAG,KAAK,IAAI,iBAAiB,MAAM,IAAI;AAAA,MACvF,SAAS,KAAK;AAAA,IAClB,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,UAAkB,SAA2B,EAAE,MAAM,OAAO,GAAiC;AAC5G,UAAM,WAAW,MAAM,KAAK,wBAAwB,GAAG,KAAK,IAAI,gBAAgB,OAAO,IAAI,IAAI,QAAQ,KAAK;AAAA,MACxG,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAClB,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAA4C;AAChD,UAAM,WAAW,MAAM,KAAK,MAAM;AAElC,eAAW,UAAU,SAAS,SAAS;AACnC,UAAI,SAAqE,CAAC;AAC1E,UAAI,KAAK,oBAAoB,QAAQ,KAAK,eAAe,MAAK;AAC5D,eAAO,WAAW,KAAK;AACvB,eAAO,eAAe,KAAK;AAAA,MAC7B;AACA,YAAM,KAAK,OAAO,OAAO,gBAAgB,OAAO,IAAI,IAAI,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;AAAA,IACpF;AACA,WAAO,EAAE,SAAS,2CAA2C;AAAA,EAC/D;AAEF;AAEA,IAAO,eAAQ;;;AE/NR,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,QAAK;AAFK,SAAAA;AAAA,GAAA;","names":["os","axios","crypto","API_VERSION"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/mem0.ts","../src/telemetry.ts","../src/mem0.types.ts"],"sourcesContent":["import {MemoryClient} from \"./mem0\";\n\nexport { MemoryClient } from './mem0';\nexport * from './mem0.types';\nexport default MemoryClient;","import axios from 'axios';\nimport { AllUsers, Memory, MemoryHistory, MemoryOptions, SearchOptions } from './mem0.types';\nimport { captureClientEvent } from './telemetry';\nimport crypto from 'crypto';\nimport util from \"util\";\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'APIError';\n }\n}\n\ninterface ClientOptions{\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n organizationId?: string;\n projectId?: string;\n}\n\nexport default class MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n organizationId: string | number | null;\n projectId: string | number | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error('Mem0 API key is required');\n }\n if (typeof this.apiKey !== 'string') {\n throw new Error('Mem0 API key must be a string');\n }\n if (this.apiKey.trim() === '') {\n throw new Error('Mem0 API key cannot be empty');\n }\n }\n constructor(options: ClientOptions) {\n this.apiKey = options.apiKey;\n this.host = options.host || \"https://api.mem0.ai\";\n this.organizationName = options.organizationName || null;\n this.projectName = options.projectName || null;\n this.organizationId = options.organizationId || null;\n this.projectId = options.projectId || null;\n\n this.headers = {\n 'Authorization': `Token ${this.apiKey}`,\n 'Content-Type': 'application/json'\n };\n\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n\n this.telemetryId = crypto.createHash('md5').update(this.apiKey).digest('hex');\n\n captureClientEvent('init', this);\n\n this.add = this.wrapMethod('add', this.add);\n this.get = this.wrapMethod('get', this.get);\n this.getAll = this.wrapMethod('get_all', this.getAll);\n this.search = this.wrapMethod('search', this.search);\n this.delete = this.wrapMethod('delete', this.delete);\n this.deleteAll = this.wrapMethod('delete_all', this.deleteAll);\n this.history = this.wrapMethod('history', this.history);\n this.users = this.wrapMethod('users', this.users);\n this.deleteUser = this.wrapMethod('delete_user', this.deleteUser);\n this.deleteUsers = this.wrapMethod('delete_users', this.deleteUsers);\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n}\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions): object {\n const payload: any = {};\n if (typeof messages === 'string') {\n payload.messages = [{ role: 'user', content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));\n }\n\n async add(messages: string | Array<{ role: string; content: string }>, options:MemoryOptions = {}): Promise<Array<Memory>> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async get(memoryId: string):Promise<Memory> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n headers: this.headers\n });\n }\n\n getAll(options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n if(this.organizationName != null && this.projectName != null){\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n otherOptions.org_id = this.organizationId;\n otherOptions.project_id = this.projectId;\n\n if (otherOptions.org_name) delete otherOptions.org_name;\n if(otherOptions.project_name) delete otherOptions.project_name;\n }\n\n if (api_version === 'v2') {\n return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(otherOptions)\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n headers: this.headers\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if(this.organizationName != null && this.projectName != null){\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n payload.org_id = this.organizationId;\n payload.project_id = this.projectId;\n\n if (payload.org_name) delete payload.org_name;\n if(payload.project_name) delete payload.project_name;\n }\n const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';\n const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/history/`, {\n headers: this.headers\n });\n return response;\n }\n\n async users(): Promise<AllUsers>{\n const options: MemoryOptions = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {\n headers: this.headers\n });\n return response;\n }\n\n async deleteUser(entityId: string, entity: { type: string } = { type: 'user' }): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n const entities = await this.users();\n \n for (const entity of entities.results) {\n let options: MemoryOptions = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n \n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n \n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params: options });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n}\n\nexport {MemoryClient};","// @ts-nocheck\nimport { PostHog } from \"posthog-node\";\nimport os from \"os\";\nimport path from \"path\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\n\nclass AnonymousTelemetry {\n constructor(projectApiKey, host) {\n this.client = new PostHog(projectApiKey, { host, flushAt: 1 });\n }\n async captureEvent(distinctId, eventName, properties = {}) {\n const eventProperties = {\n client_source: \"nodejs\",\n client_version: getVersion(),\n node_version: process.version,\n os: process.platform,\n os_version: os.release(),\n os_arch: os.arch(),\n ...properties,\n };\n try {\n this.client.capture({\n distinctId: distinctId,\n event: eventName,\n properties: eventProperties,\n });\n } catch (error) {\n console.error(\"Error capturing event:\", error);\n }\n }\n async shutdown() {\n return this.client.shutdown();\n }\n}\nfunction getVersion() {\n return version;\n}\nconst telemetry = new AnonymousTelemetry(\n \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\",\n \"https://us.i.posthog.com\"\n);\nasync function captureClientEvent(eventName, instance, additionalData = {}) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData\n );\n}\nexport { telemetry, captureClientEvent };","export interface MemoryOptions {\n user_id?: string;\n agent_id?: string;\n app_id?: string;\n metadata?: Record<string, any>;\n filters?: Record<string, any>;\n org_name?: string | null; // Deprecated\n project_name?: string | null; // Deprecated\n org_id?: string | number | null;\n project_id?: string | number | null;\n}\n\nexport enum API_VERSION {\n V1 = \"v1\",\n V2 = \"v2\",\n}\n\nexport interface Messages {\n role: string;\n content: string;\n}\n\nexport interface MemoryHistory {\n id: string;\n memory_id: string;\n input: Array<Messages>;\n old_memory: string | null;\n new_memory: string | null;\n user_id: string;\n categories: Array<string>;\n event: Event | string;\n created_at: Date;\n updated_at: Date;\n}\n\nexport interface SearchOptions extends MemoryOptions {\n api_version?: API_VERSION | string;\n limit?: number;\n}\n\nenum Event {\n ADD = \"ADD\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n NOOP = \"NOOP\",\n}\n\nexport interface MemoryData {\n memory: string;\n}\n\nexport interface Memory {\n id: string;\n messages?: Array<Messages>;\n event?: Event | string;\n data?: MemoryData | null;\n memory?: string;\n user_id?: string;\n hash?: string;\n categories?: Array<string>;\n created_at?: Date;\n updated_at?: Date;\n memory_type?: string;\n score?: number;\n metadata?: any | null;\n}\n\nexport interface User {\n id: string;\n name: string;\n created_at: Date;\n updated_at: Date;\n total_memories: number;\n owner: string;\n type: string;\n}\n\nexport interface AllUsers {\n count: number;\n results: Array<User>;\n next: any;\n previous: any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;;;ACClB,0BAAwB;AACxB,gBAAe;AAGf,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AAEtD,IAAM,qBAAN,MAAyB;AAAA,EACvB,YAAY,eAAe,MAAM;AAC/B,SAAK,SAAS,IAAI,4BAAQ,eAAe,EAAE,MAAM,SAAS,EAAE,CAAC;AAAA,EAC/D;AAAA,EACA,MAAM,aAAa,YAAY,WAAW,aAAa,CAAC,GAAG;AACzD,UAAM,kBAAkB;AAAA,MACtB,eAAe;AAAA,MACf,gBAAgB,WAAW;AAAA,MAC3B,cAAc,QAAQ;AAAA,MACtB,IAAI,QAAQ;AAAA,MACZ,YAAY,UAAAA,QAAG,QAAQ;AAAA,MACvB,SAAS,UAAAA,QAAG,KAAK;AAAA,MACjB,GAAG;AAAA,IACL;AACA,QAAI;AACF,WAAK,OAAO,QAAQ;AAAA,QAClB;AAAA,QACA,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH,SAAS,OAAO;AACd,cAAQ,MAAM,0BAA0B,KAAK;AAAA,IAC/C;AAAA,EACF;AAAA,EACA,MAAM,WAAW;AACf,WAAO,KAAK,OAAO,SAAS;AAAA,EAC9B;AACF;AACA,SAAS,aAAa;AACpB,SA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W,MAAM,KAAK,wBAAwB,GAAG,KAAK,IAAI,iBAAiB,MAAM,IAAI;AAAA,MACvF,SAAS,KAAK;AAAA,IAClB,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,UAAkB,SAA2B,EAAE,MAAM,OAAO,GAAiC;AAC5G,UAAM,WAAW,MAAM,KAAK,wBAAwB,GAAG,KAAK,IAAI,gBAAgB,OAAO,IAAI,IAAI,QAAQ,KAAK;AAAA,MACxG,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAClB,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAA4C;AAChD,UAAM,WAAW,MAAM,KAAK,MAAM;AAElC,eAAW,UAAU,SAAS,SAAS;AACnC,UAAI,UAAyB,CAAC;AAC9B,UAAG,KAAK,oBAAoB,QAAQ,KAAK,eAAe,MAAK;AAC3D,gBAAQ,WAAW,KAAK;AACxB,gBAAQ,eAAe,KAAK;AAAA,MAE9B;AAEA,UAAG,KAAK,kBAAkB,QAAQ,KAAK,aAAa,MAAK;AACvD,gBAAQ,SAAS,KAAK;AACtB,gBAAQ,aAAa,KAAK;AAE1B,YAAI,QAAQ,SAAU,QAAO,QAAQ;AACrC,YAAG,QAAQ,aAAc,QAAO,QAAQ;AAAA,MAC1C;AACA,YAAM,KAAK,OAAO,OAAO,gBAAgB,OAAO,IAAI,IAAI,OAAO,EAAE,KAAK,EAAE,QAAQ,QAAQ,CAAC;AAAA,IAC7F;AACA,WAAO,EAAE,SAAS,2CAA2C;AAAA,EAC/D;AAEF;;;AEzRO,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,QAAK;AAFK,SAAAA;AAAA,GAAA;;;AHRZ,IAAO,cAAQ;","names":["os","axios","crypto","API_VERSION"]}
package/dist/index.mjs CHANGED
@@ -73,11 +73,13 @@ var MemoryClient = class {
73
73
  throw new Error("Mem0 API key cannot be empty");
74
74
  }
75
75
  }
76
- constructor(apiKey, host = "https://api.mem0.ai", organizationName = null, projectName = null) {
77
- this.apiKey = apiKey;
78
- this.host = host;
79
- this.organizationName = organizationName;
80
- this.projectName = projectName;
76
+ constructor(options) {
77
+ this.apiKey = options.apiKey;
78
+ this.host = options.host || "https://api.mem0.ai";
79
+ this.organizationName = options.organizationName || null;
80
+ this.projectName = options.projectName || null;
81
+ this.organizationId = options.organizationId || null;
82
+ this.projectId = options.projectId || null;
81
83
  this.headers = {
82
84
  "Authorization": `Token ${this.apiKey}`,
83
85
  "Content-Type": "application/json"
@@ -133,6 +135,12 @@ var MemoryClient = class {
133
135
  options.org_name = this.organizationName;
134
136
  options.project_name = this.projectName;
135
137
  }
138
+ if (this.organizationId != null && this.projectId != null) {
139
+ options.org_id = this.organizationId;
140
+ options.project_id = this.projectId;
141
+ if (options.org_name) delete options.org_name;
142
+ if (options.project_name) delete options.project_name;
143
+ }
136
144
  const payload = this._preparePayload(messages, options);
137
145
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {
138
146
  method: "POST",
@@ -152,6 +160,12 @@ var MemoryClient = class {
152
160
  otherOptions.org_name = this.organizationName;
153
161
  otherOptions.project_name = this.projectName;
154
162
  }
163
+ if (this.organizationId != null && this.projectId != null) {
164
+ otherOptions.org_id = this.organizationId;
165
+ otherOptions.project_id = this.projectId;
166
+ if (otherOptions.org_name) delete otherOptions.org_name;
167
+ if (otherOptions.project_name) delete otherOptions.project_name;
168
+ }
155
169
  if (api_version === "v2") {
156
170
  return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {
157
171
  method: "POST",
@@ -172,6 +186,12 @@ var MemoryClient = class {
172
186
  payload.org_name = this.organizationName;
173
187
  payload.project_name = this.projectName;
174
188
  }
189
+ if (this.organizationId != null && this.projectId != null) {
190
+ payload.org_id = this.organizationId;
191
+ payload.project_id = this.projectId;
192
+ if (payload.org_name) delete payload.org_name;
193
+ if (payload.project_name) delete payload.project_name;
194
+ }
175
195
  const endpoint = api_version === "v2" ? "/v2/memories/search/" : "/v1/memories/search/";
176
196
  const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {
177
197
  method: "POST",
@@ -191,6 +211,12 @@ var MemoryClient = class {
191
211
  options.org_name = this.organizationName;
192
212
  options.project_name = this.projectName;
193
213
  }
214
+ if (this.organizationId != null && this.projectId != null) {
215
+ options.org_id = this.organizationId;
216
+ options.project_id = this.projectId;
217
+ if (options.org_name) delete options.org_name;
218
+ if (options.project_name) delete options.project_name;
219
+ }
194
220
  const params = new URLSearchParams(this._prepareParams(options));
195
221
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {
196
222
  method: "DELETE",
@@ -210,6 +236,12 @@ var MemoryClient = class {
210
236
  options.org_name = this.organizationName;
211
237
  options.project_name = this.projectName;
212
238
  }
239
+ if (this.organizationId != null && this.projectId != null) {
240
+ options.org_id = this.organizationId;
241
+ options.project_id = this.projectId;
242
+ if (options.org_name) delete options.org_name;
243
+ if (options.project_name) delete options.project_name;
244
+ }
213
245
  const params = new URLSearchParams(options);
214
246
  const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {
215
247
  headers: this.headers
@@ -226,17 +258,22 @@ var MemoryClient = class {
226
258
  async deleteUsers() {
227
259
  const entities = await this.users();
228
260
  for (const entity of entities.results) {
229
- let params = {};
261
+ let options = {};
230
262
  if (this.organizationName != null && this.projectName != null) {
231
- params.org_name = this.organizationName;
232
- params.project_name = this.projectName;
263
+ options.org_name = this.organizationName;
264
+ options.project_name = this.projectName;
265
+ }
266
+ if (this.organizationId != null && this.projectId != null) {
267
+ options.org_id = this.organizationId;
268
+ options.project_id = this.projectId;
269
+ if (options.org_name) delete options.org_name;
270
+ if (options.project_name) delete options.project_name;
233
271
  }
234
- await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params });
272
+ await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params: options });
235
273
  }
236
274
  return { message: "All users, agents, and sessions deleted." };
237
275
  }
238
276
  };
239
- var mem0_default = MemoryClient;
240
277
 
241
278
  // src/mem0.types.ts
242
279
  var API_VERSION = /* @__PURE__ */ ((API_VERSION2) => {
@@ -244,8 +281,12 @@ var API_VERSION = /* @__PURE__ */ ((API_VERSION2) => {
244
281
  API_VERSION2["V2"] = "v2";
245
282
  return API_VERSION2;
246
283
  })(API_VERSION || {});
284
+
285
+ // src/index.ts
286
+ var src_default = MemoryClient;
247
287
  export {
248
288
  API_VERSION,
249
- mem0_default as default
289
+ MemoryClient,
290
+ src_default as default
250
291
  };
251
292
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mem0.ts","../src/telemetry.ts","../src/mem0.types.ts"],"sourcesContent":["import axios from 'axios';\nimport { AllUsers, Memory, MemoryHistory, MemoryOptions, SearchOptions } from './mem0.types';\nimport { captureClientEvent } from './telemetry';\nimport crypto from 'crypto';\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'APIError';\n }\n}\n\ninterface ClientOptions {\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n}\n\nclass MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error('Mem0 API key is required');\n }\n if (typeof this.apiKey !== 'string') {\n throw new Error('Mem0 API key must be a string');\n }\n if (this.apiKey.trim() === '') {\n throw new Error('Mem0 API key cannot be empty');\n }\n }\n constructor(apiKey: string, host = 'https://api.mem0.ai', organizationName = null, projectName = null) {\n this.apiKey = apiKey;\n this.host = host;\n this.organizationName = organizationName;\n this.projectName = projectName;\n\n this.headers = {\n 'Authorization': `Token ${this.apiKey}`,\n 'Content-Type': 'application/json'\n };\n\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n\n this.telemetryId = crypto.createHash('md5').update(this.apiKey).digest('hex');\n\n captureClientEvent('init', this);\n\n this.add = this.wrapMethod('add', this.add);\n this.get = this.wrapMethod('get', this.get);\n this.getAll = this.wrapMethod('get_all', this.getAll);\n this.search = this.wrapMethod('search', this.search);\n this.delete = this.wrapMethod('delete', this.delete);\n this.deleteAll = this.wrapMethod('delete_all', this.deleteAll);\n this.history = this.wrapMethod('history', this.history);\n this.users = this.wrapMethod('users', this.users);\n this.deleteUser = this.wrapMethod('delete_user', this.deleteUser);\n this.deleteUsers = this.wrapMethod('delete_users', this.deleteUsers);\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n}\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions): object {\n const payload: any = {};\n if (typeof messages === 'string') {\n payload.messages = [{ role: 'user', content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));\n }\n\n async add(messages: string | Array<{ role: string; content: string }>, options:MemoryOptions = {}): Promise<Array<Memory>> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async get(memoryId: string):Promise<Memory> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n headers: this.headers\n });\n }\n\n getAll(options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n if(this.organizationName != null && this.projectName != null){\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n }\n\n if (api_version === 'v2') {\n return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(otherOptions)\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n headers: this.headers\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if(this.organizationName != null && this.projectName != null){\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n }\n const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';\n const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/history/`, {\n headers: this.headers\n });\n return response;\n }\n\n async users(): Promise<AllUsers>{\n const options: { org_name?: string | null; project_name?: string | null } = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {\n headers: this.headers\n });\n return response;\n }\n\n async deleteUser(entityId: string, entity: { type: string } = { type: 'user' }): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n const entities = await this.users();\n \n for (const entity of entities.results) {\n let params: { org_name?: string | null; project_name?: string | null } = {};\n if (this.organizationName != null && this.projectName != null){\n params.org_name = this.organizationName;\n params.project_name = this.projectName;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n}\n\nexport default MemoryClient;","// @ts-nocheck\nimport { PostHog } from \"posthog-node\";\nimport os from \"os\";\nimport path from \"path\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\n\nclass AnonymousTelemetry {\n constructor(projectApiKey, host) {\n this.client = new PostHog(projectApiKey, { host, flushAt: 1 });\n }\n async captureEvent(distinctId, eventName, properties = {}) {\n const eventProperties = {\n client_source: \"nodejs\",\n client_version: getVersion(),\n node_version: process.version,\n os: process.platform,\n os_version: os.release(),\n os_arch: os.arch(),\n ...properties,\n };\n try {\n this.client.capture({\n distinctId: distinctId,\n event: eventName,\n properties: eventProperties,\n });\n } catch (error) {\n console.error(\"Error capturing event:\", error);\n }\n }\n async shutdown() {\n return this.client.shutdown();\n }\n}\nfunction getVersion() {\n return version;\n}\nconst telemetry = new AnonymousTelemetry(\n \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\",\n \"https://us.i.posthog.com\"\n);\nasync function captureClientEvent(eventName, instance, additionalData = {}) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData\n );\n}\nexport { telemetry, captureClientEvent };","export interface MemoryOptions {\n user_id?: string;\n agent_id?: string;\n app_id?: string;\n metadata?: Record<string, any>;\n filters?: Record<string, any>;\n org_name?: string | null;\n project_name?: string | null;\n}\n\nexport enum API_VERSION {\n V1 = \"v1\",\n V2 = \"v2\",\n}\n\nexport interface Messages {\n role: string;\n content: string;\n}\n\nexport interface MemoryHistory {\n id: string;\n memory_id: string;\n input: Array<Messages>;\n old_memory: string | null;\n new_memory: string | null;\n user_id: string;\n categories: Array<string>;\n event: Event | string;\n created_at: Date;\n updated_at: Date;\n}\n\nexport interface SearchOptions extends MemoryOptions {\n api_version?: API_VERSION | string;\n limit?: number;\n}\n\nenum Event {\n ADD = \"ADD\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n NOOP = \"NOOP\",\n}\n\nexport interface MemoryData {\n memory: string;\n}\n\nexport interface Memory {\n id: string;\n messages?: Array<Messages>;\n event?: Event | string;\n data?: MemoryData | null;\n memory?: string;\n user_id?: string;\n hash?: string;\n categories?: Array<string>;\n created_at?: Date;\n updated_at?: Date;\n memory_type?: string;\n score?: number;\n metadata?: any | null;\n}\n\nexport interface User {\n id: string;\n name: string;\n created_at: Date;\n updated_at: Date;\n total_memories: number;\n owner: string;\n type: string;\n}\n\nexport interface AllUsers {\n count: number;\n results: Array<User>;\n next: any;\n previous: any;\n}\n"],"mappings":";AAAA,OAAO,WAAW;;;ACClB,SAAS,eAAe;AACxB,OAAO,QAAQ;AAGf,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AAEtD,IAAM,qBAAN,MAAyB;AAAA,EACvB,YAAY,eAAe,MAAM;AAC/B,SAAK,SAAS,IAAI,QAAQ,eAAe,EAAE,MAAM,SAAS,EAAE,CAAC;AAAA,EAC/D;AAAA,EACA,MAAM,aAAa,YAAY,WAAW,aAAa,CAAC,GAAG;AACzD,UAAM,kBAAkB;AAAA,MACtB,eAAe;AAAA,MACf,gBAAgB,WAAW;A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,IAAI,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC;AAAA,IACpF;AACA,WAAO,EAAE,SAAS,2CAA2C;AAAA,EAC/D;AAEF;AAEA,IAAO,eAAQ;;;AE/NR,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,QAAK;AAFK,SAAAA;AAAA,GAAA;","names":["API_VERSION"]}
1
+ {"version":3,"sources":["../src/mem0.ts","../src/telemetry.ts","../src/mem0.types.ts","../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { AllUsers, Memory, MemoryHistory, MemoryOptions, SearchOptions } from './mem0.types';\nimport { captureClientEvent } from './telemetry';\nimport crypto from 'crypto';\nimport util from \"util\";\n\nclass APIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'APIError';\n }\n}\n\ninterface ClientOptions{\n apiKey: string;\n host?: string;\n organizationName?: string;\n projectName?: string;\n organizationId?: string;\n projectId?: string;\n}\n\nexport default class MemoryClient {\n apiKey: string;\n host: string;\n organizationName: string | null;\n projectName: string | null;\n organizationId: string | number | null;\n projectId: string | number | null;\n headers: Record<string, string>;\n client: any;\n telemetryId: string;\n\n _validateApiKey(): any {\n if (!this.apiKey) {\n throw new Error('Mem0 API key is required');\n }\n if (typeof this.apiKey !== 'string') {\n throw new Error('Mem0 API key must be a string');\n }\n if (this.apiKey.trim() === '') {\n throw new Error('Mem0 API key cannot be empty');\n }\n }\n constructor(options: ClientOptions) {\n this.apiKey = options.apiKey;\n this.host = options.host || \"https://api.mem0.ai\";\n this.organizationName = options.organizationName || null;\n this.projectName = options.projectName || null;\n this.organizationId = options.organizationId || null;\n this.projectId = options.projectId || null;\n\n this.headers = {\n 'Authorization': `Token ${this.apiKey}`,\n 'Content-Type': 'application/json'\n };\n\n\n this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n\n this.telemetryId = crypto.createHash('md5').update(this.apiKey).digest('hex');\n\n captureClientEvent('init', this);\n\n this.add = this.wrapMethod('add', this.add);\n this.get = this.wrapMethod('get', this.get);\n this.getAll = this.wrapMethod('get_all', this.getAll);\n this.search = this.wrapMethod('search', this.search);\n this.delete = this.wrapMethod('delete', this.delete);\n this.deleteAll = this.wrapMethod('delete_all', this.deleteAll);\n this.history = this.wrapMethod('history', this.history);\n this.users = this.wrapMethod('users', this.users);\n this.deleteUser = this.wrapMethod('delete_user', this.deleteUser);\n this.deleteUsers = this.wrapMethod('delete_users', this.deleteUsers);\n }\n\n wrapMethod(methodName: any, method: any) {\n return async function (...args: any) {\n // @ts-ignore\n await captureClientEvent(methodName, this);\n // @ts-ignore\n return method.apply(this, args);\n }.bind(this);\n}\n\n async _fetchWithErrorHandling(url: string, options: any): Promise<any> {\n const response = await fetch(url, options);\n if (!response.ok) {\n const errorData = await response.text();\n throw new APIError(`API request failed: ${errorData}`);\n }\n const jsonResponse = await response.json();\n return jsonResponse;\n }\n\n _preparePayload(messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions): object {\n const payload: any = {};\n if (typeof messages === 'string') {\n payload.messages = [{ role: 'user', content: messages }];\n } else if (Array.isArray(messages)) {\n payload.messages = messages;\n }\n return { ...payload, ...options };\n }\n\n _prepareParams(options: MemoryOptions): object {\n return Object.fromEntries(Object.entries(options).filter(([_, v]) => v != null));\n }\n\n async add(messages: string | Array<{ role: string; content: string }>, options:MemoryOptions = {}): Promise<Array<Memory>> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n\n const payload = this._preparePayload(messages, options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async get(memoryId: string):Promise<Memory> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n headers: this.headers\n });\n }\n\n getAll(options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n if(this.organizationName != null && this.projectName != null){\n otherOptions.org_name = this.organizationName;\n otherOptions.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n otherOptions.org_id = this.organizationId;\n otherOptions.project_id = this.projectId;\n\n if (otherOptions.org_name) delete otherOptions.org_name;\n if(otherOptions.project_name) delete otherOptions.project_name;\n }\n\n if (api_version === 'v2') {\n return this._fetchWithErrorHandling(`${this.host}/v2/memories/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(otherOptions)\n });\n } else {\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(otherOptions));\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n headers: this.headers\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n const { api_version, ...otherOptions } = options!;\n const payload = { query, ...otherOptions };\n if(this.organizationName != null && this.projectName != null){\n payload.org_name = this.organizationName;\n payload.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n payload.org_id = this.organizationId;\n payload.project_id = this.projectId;\n\n if (payload.org_name) delete payload.org_name;\n if(payload.project_name) delete payload.project_name;\n }\n const endpoint = api_version === 'v2' ? '/v2/memories/search/' : '/v1/memories/search/';\n const response = await this._fetchWithErrorHandling(`${this.host}${endpoint}`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(payload)\n });\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(this._prepareParams(options));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/?${params}`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/history/`, {\n headers: this.headers\n });\n return response;\n }\n\n async users(): Promise<AllUsers>{\n const options: MemoryOptions = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n\n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n\n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n // @ts-ignore\n const params = new URLSearchParams(options);\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/?${params}`, {\n headers: this.headers\n });\n return response;\n }\n\n async deleteUser(entityId: string, entity: { type: string } = { type: 'user' }): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/entities/${entity.type}/${entityId}/`, {\n method: 'DELETE',\n headers: this.headers\n });\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n const entities = await this.users();\n \n for (const entity of entities.results) {\n let options: MemoryOptions = {};\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\n // console.warn(\"organizationName and projectName is deprecated. Please use organizationId and projectId instead.\")\n }\n \n if(this.organizationId != null && this.projectId != null){\n options.org_id = this.organizationId;\n options.project_id = this.projectId;\n \n if (options.org_name) delete options.org_name;\n if(options.project_name) delete options.project_name;\n }\n await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, { params: options });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n}\n\nexport {MemoryClient};","// @ts-nocheck\nimport { PostHog } from \"posthog-node\";\nimport os from \"os\";\nimport path from \"path\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\n\nclass AnonymousTelemetry {\n constructor(projectApiKey, host) {\n this.client = new PostHog(projectApiKey, { host, flushAt: 1 });\n }\n async captureEvent(distinctId, eventName, properties = {}) {\n const eventProperties = {\n client_source: \"nodejs\",\n client_version: getVersion(),\n node_version: process.version,\n os: process.platform,\n os_version: os.release(),\n os_arch: os.arch(),\n ...properties,\n };\n try {\n this.client.capture({\n distinctId: distinctId,\n event: eventName,\n properties: eventProperties,\n });\n } catch (error) {\n console.error(\"Error capturing event:\", error);\n }\n }\n async shutdown() {\n return this.client.shutdown();\n }\n}\nfunction getVersion() {\n return version;\n}\nconst telemetry = new AnonymousTelemetry(\n \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\",\n \"https://us.i.posthog.com\"\n);\nasync function captureClientEvent(eventName, instance, additionalData = {}) {\n const eventData = {\n function: `${instance.constructor.name}`,\n ...additionalData,\n };\n await telemetry.captureEvent(\n instance.telemetryId,\n `client.${eventName}`,\n eventData\n );\n}\nexport { telemetry, captureClientEvent };","export interface MemoryOptions {\n user_id?: string;\n agent_id?: string;\n app_id?: string;\n metadata?: Record<string, any>;\n filters?: Record<string, any>;\n org_name?: string | null; // Deprecated\n project_name?: string | null; // Deprecated\n org_id?: string | number | null;\n project_id?: string | number | null;\n}\n\nexport enum API_VERSION {\n V1 = \"v1\",\n V2 = \"v2\",\n}\n\nexport interface Messages {\n role: string;\n content: string;\n}\n\nexport interface MemoryHistory {\n id: string;\n memory_id: string;\n input: Array<Messages>;\n old_memory: string | null;\n new_memory: string | null;\n user_id: string;\n categories: Array<string>;\n event: Event | string;\n created_at: Date;\n updated_at: Date;\n}\n\nexport interface SearchOptions extends MemoryOptions {\n api_version?: API_VERSION | string;\n limit?: number;\n}\n\nenum Event {\n ADD = \"ADD\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n NOOP = \"NOOP\",\n}\n\nexport interface MemoryData {\n memory: string;\n}\n\nexport interface Memory {\n id: string;\n messages?: Array<Messages>;\n event?: Event | string;\n data?: MemoryData | null;\n memory?: string;\n user_id?: string;\n hash?: string;\n categories?: Array<string>;\n created_at?: Date;\n updated_at?: Date;\n memory_type?: string;\n score?: number;\n metadata?: any | null;\n}\n\nexport interface User {\n id: string;\n name: string;\n created_at: Date;\n updated_at: Date;\n total_memories: number;\n owner: string;\n type: string;\n}\n\nexport interface AllUsers {\n count: number;\n results: Array<User>;\n next: any;\n previous: any;\n}\n","import {MemoryClient} from \"./mem0\";\n\nexport { MemoryClient } from './mem0';\nexport * from './mem0.types';\nexport default MemoryClient;"],"mappings":";AAAA,OAAO,WAAW;;;ACClB,SAAS,eAAe;AACxB,OAAO,QAAQ;AAGf,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AAEtD,IAAM,qBAAN,MAAyB;AAAA,EACvB,YAAY,eAAe,MAAM;AAC/B,SAAK,SAAS,IAAI,QAAQ,eAAe,EAAE,MAAM,SAAS,EAAE,CAAC;AAAA,EAC/D;AAAA,EACA,MAAM,aAAa,YAAY,WAAW,aAAa,CAAC,GAAG;AACzD,UAAM,kBAAkB;AAAA,MACtB,eAAe;AAAA,MACf,gBAAgB,WAAW;AAAA,MAC3B,cAAc,QAAQ;AAAA,MACtB,IAAI,QAAQ;AAAA,MACZ,YAAY,GAAG,QAAQ;AAAA,MACvB,SAAS,GAAG,KAAK;AAAA,MACjB,GAAG;AAAA,IACL;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RO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,QAAK;AACL,EAAAA,aAAA,QAAK;AAFK,SAAAA;AAAA,GAAA;;;ACRZ,IAAO,cAAQ;","names":["API_VERSION"]}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "mem0ai",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "The Memory Layer For Your AI Apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "files": [
9
- "dist/**/*"
9
+ "dist/**/*"
10
10
  ],
11
11
  "scripts": {
12
12
  "test": "jest",
13
- "build": "tsup",
13
+ "build": "tsup && npx fix-tsup-cjs",
14
14
  "dev": "nodemon"
15
15
  },
16
16
  "keywords": [
@@ -35,6 +35,7 @@
35
35
  "dependencies": {
36
36
  "axios": "^1.7.7",
37
37
  "crypto": "^1.0.1",
38
+ "fix-tsup-cjs": "^1.2.0",
38
39
  "posthog-node": "^4.2.1",
39
40
  "ts-node": "^10.9.2"
40
41
  },
@@ -44,4 +45,4 @@
44
45
  "publishConfig": {
45
46
  "access": "public"
46
47
  }
47
- }
48
+ }