mem0ai 1.0.39 → 2.0.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.
- package/README.md +24 -333
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4474 -108
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -92
- package/dist/index.mjs.map +1 -1
- package/dist/module-QI3FML2A.mjs +4314 -0
- package/dist/module-QI3FML2A.mjs.map +1 -0
- package/dist/oss/index.d.mts +421 -0
- package/dist/oss/index.d.ts +421 -0
- package/dist/oss/index.js +1726 -0
- package/dist/oss/index.js.map +1 -0
- package/dist/oss/index.mjs +1677 -0
- package/dist/oss/index.mjs.map +1 -0
- package/package.json +109 -77
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// src/mem0.ts
|
|
1
|
+
// src/client/mem0.ts
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
|
|
4
|
-
// src/telemetry.browser.ts
|
|
4
|
+
// src/client/telemetry.browser.ts
|
|
5
5
|
var version = "1.0.20";
|
|
6
6
|
var MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== "false";
|
|
7
7
|
var POSTHOG_API_KEY = "phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX";
|
|
@@ -21,7 +21,7 @@ var BrowserTelemetry = class {
|
|
|
21
21
|
}
|
|
22
22
|
async initializeClient(projectApiKey, host) {
|
|
23
23
|
try {
|
|
24
|
-
const posthog = await import("
|
|
24
|
+
const posthog = await import("./module-QI3FML2A.mjs").catch(() => null);
|
|
25
25
|
if (posthog) {
|
|
26
26
|
posthog.init(projectApiKey, { api_host: host });
|
|
27
27
|
this.client = posthog;
|
|
@@ -39,10 +39,7 @@ var BrowserTelemetry = class {
|
|
|
39
39
|
...properties
|
|
40
40
|
};
|
|
41
41
|
try {
|
|
42
|
-
this.client.capture(
|
|
43
|
-
eventName,
|
|
44
|
-
eventProperties
|
|
45
|
-
);
|
|
42
|
+
this.client.capture(eventName, eventProperties);
|
|
46
43
|
} catch (error) {
|
|
47
44
|
}
|
|
48
45
|
}
|
|
@@ -52,10 +49,7 @@ var BrowserTelemetry = class {
|
|
|
52
49
|
function getVersion() {
|
|
53
50
|
return version;
|
|
54
51
|
}
|
|
55
|
-
var telemetry = new BrowserTelemetry(
|
|
56
|
-
POSTHOG_API_KEY,
|
|
57
|
-
POSTHOG_HOST
|
|
58
|
-
);
|
|
52
|
+
var telemetry = new BrowserTelemetry(POSTHOG_API_KEY, POSTHOG_HOST);
|
|
59
53
|
async function captureClientEvent(eventName, instance, additionalData = {}) {
|
|
60
54
|
const eventData = {
|
|
61
55
|
function: `${instance.constructor.name}`,
|
|
@@ -68,7 +62,7 @@ async function captureClientEvent(eventName, instance, additionalData = {}) {
|
|
|
68
62
|
);
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
// src/mem0.ts
|
|
65
|
+
// src/client/mem0.ts
|
|
72
66
|
var APIError = class extends Error {
|
|
73
67
|
constructor(message) {
|
|
74
68
|
super(message);
|
|
@@ -89,10 +83,14 @@ var MemoryClient = class {
|
|
|
89
83
|
}
|
|
90
84
|
_validateOrgProject() {
|
|
91
85
|
if (this.organizationName === null && this.projectName !== null || this.organizationName !== null && this.projectName === null) {
|
|
92
|
-
console.warn(
|
|
86
|
+
console.warn(
|
|
87
|
+
"Warning: Both organizationName and projectName must be provided together when using either. This will be removedfrom the version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId."
|
|
88
|
+
);
|
|
93
89
|
}
|
|
94
90
|
if (this.organizationId === null && this.projectId !== null || this.organizationId !== null && this.projectId === null) {
|
|
95
|
-
console.warn(
|
|
91
|
+
console.warn(
|
|
92
|
+
"Warning: Both organizationId and projectId must be provided together when using either. This will be removedfrom the version 1.0.40."
|
|
93
|
+
);
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
constructor(options) {
|
|
@@ -103,7 +101,7 @@ var MemoryClient = class {
|
|
|
103
101
|
this.organizationId = options.organizationId || null;
|
|
104
102
|
this.projectId = options.projectId || null;
|
|
105
103
|
this.headers = {
|
|
106
|
-
|
|
104
|
+
Authorization: `Token ${this.apiKey}`,
|
|
107
105
|
"Content-Type": "application/json"
|
|
108
106
|
};
|
|
109
107
|
this.client = axios.create({
|
|
@@ -118,8 +116,10 @@ var MemoryClient = class {
|
|
|
118
116
|
}
|
|
119
117
|
async _initializeClient() {
|
|
120
118
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
if (typeof window !== "undefined") {
|
|
120
|
+
this.telemetryId = await generateHash(this.apiKey);
|
|
121
|
+
await captureClientEvent("init", this);
|
|
122
|
+
}
|
|
123
123
|
this.add = this.wrapMethod("add", this.add);
|
|
124
124
|
this.get = this.wrapMethod("get", this.get);
|
|
125
125
|
this.getAll = this.wrapMethod("get_all", this.getAll);
|
|
@@ -133,11 +133,23 @@ var MemoryClient = class {
|
|
|
133
133
|
this.batchUpdate = this.wrapMethod("batch_update", this.batchUpdate);
|
|
134
134
|
this.batchDelete = this.wrapMethod("batch_delete", this.batchDelete);
|
|
135
135
|
this.getProject = this.wrapMethod("get_project", this.getProject);
|
|
136
|
-
this.updateProject = this.wrapMethod(
|
|
136
|
+
this.updateProject = this.wrapMethod(
|
|
137
|
+
"update_project",
|
|
138
|
+
this.updateProject
|
|
139
|
+
);
|
|
137
140
|
this.getWebhooks = this.wrapMethod("get_webhook", this.getWebhooks);
|
|
138
|
-
this.createWebhook = this.wrapMethod(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
this.createWebhook = this.wrapMethod(
|
|
142
|
+
"create_webhook",
|
|
143
|
+
this.createWebhook
|
|
144
|
+
);
|
|
145
|
+
this.updateWebhook = this.wrapMethod(
|
|
146
|
+
"update_webhook",
|
|
147
|
+
this.updateWebhook
|
|
148
|
+
);
|
|
149
|
+
this.deleteWebhook = this.wrapMethod(
|
|
150
|
+
"delete_webhook",
|
|
151
|
+
this.deleteWebhook
|
|
152
|
+
);
|
|
141
153
|
} catch (error) {
|
|
142
154
|
console.error("Failed to initialize client:", error);
|
|
143
155
|
}
|
|
@@ -167,7 +179,9 @@ var MemoryClient = class {
|
|
|
167
179
|
return { ...payload, ...options };
|
|
168
180
|
}
|
|
169
181
|
_prepareParams(options) {
|
|
170
|
-
return Object.fromEntries(
|
|
182
|
+
return Object.fromEntries(
|
|
183
|
+
Object.entries(options).filter(([_, v]) => v != null)
|
|
184
|
+
);
|
|
171
185
|
}
|
|
172
186
|
async add(messages, options = {}) {
|
|
173
187
|
this._validateOrgProject();
|
|
@@ -182,11 +196,14 @@ var MemoryClient = class {
|
|
|
182
196
|
if (options.project_name) delete options.project_name;
|
|
183
197
|
}
|
|
184
198
|
const payload = this._preparePayload(messages, options);
|
|
185
|
-
const response = await this._fetchWithErrorHandling(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
const response = await this._fetchWithErrorHandling(
|
|
200
|
+
`${this.host}/v1/memories/`,
|
|
201
|
+
{
|
|
202
|
+
method: "POST",
|
|
203
|
+
headers: this.headers,
|
|
204
|
+
body: JSON.stringify(payload)
|
|
205
|
+
}
|
|
206
|
+
);
|
|
190
207
|
return response;
|
|
191
208
|
}
|
|
192
209
|
async update(memoryId, message) {
|
|
@@ -194,17 +211,23 @@ var MemoryClient = class {
|
|
|
194
211
|
const payload = {
|
|
195
212
|
text: message
|
|
196
213
|
};
|
|
197
|
-
const response = await this._fetchWithErrorHandling(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
214
|
+
const response = await this._fetchWithErrorHandling(
|
|
215
|
+
`${this.host}/v1/memories/${memoryId}/`,
|
|
216
|
+
{
|
|
217
|
+
method: "PUT",
|
|
218
|
+
headers: this.headers,
|
|
219
|
+
body: JSON.stringify(payload)
|
|
220
|
+
}
|
|
221
|
+
);
|
|
202
222
|
return response;
|
|
203
223
|
}
|
|
204
224
|
async get(memoryId) {
|
|
205
|
-
return this._fetchWithErrorHandling(
|
|
206
|
-
|
|
207
|
-
|
|
225
|
+
return this._fetchWithErrorHandling(
|
|
226
|
+
`${this.host}/v1/memories/${memoryId}/`,
|
|
227
|
+
{
|
|
228
|
+
headers: this.headers
|
|
229
|
+
}
|
|
230
|
+
);
|
|
208
231
|
}
|
|
209
232
|
async getAll(options) {
|
|
210
233
|
this._validateOrgProject();
|
|
@@ -255,18 +278,24 @@ var MemoryClient = class {
|
|
|
255
278
|
if (payload.project_name) delete payload.project_name;
|
|
256
279
|
}
|
|
257
280
|
const endpoint = api_version === "v2" ? "/v2/memories/search/" : "/v1/memories/search/";
|
|
258
|
-
const response = await this._fetchWithErrorHandling(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
281
|
+
const response = await this._fetchWithErrorHandling(
|
|
282
|
+
`${this.host}${endpoint}`,
|
|
283
|
+
{
|
|
284
|
+
method: "POST",
|
|
285
|
+
headers: this.headers,
|
|
286
|
+
body: JSON.stringify(payload)
|
|
287
|
+
}
|
|
288
|
+
);
|
|
263
289
|
return response;
|
|
264
290
|
}
|
|
265
291
|
async delete(memoryId) {
|
|
266
|
-
return this._fetchWithErrorHandling(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
292
|
+
return this._fetchWithErrorHandling(
|
|
293
|
+
`${this.host}/v1/memories/${memoryId}/`,
|
|
294
|
+
{
|
|
295
|
+
method: "DELETE",
|
|
296
|
+
headers: this.headers
|
|
297
|
+
}
|
|
298
|
+
);
|
|
270
299
|
}
|
|
271
300
|
async deleteAll(options = {}) {
|
|
272
301
|
this._validateOrgProject();
|
|
@@ -281,16 +310,22 @@ var MemoryClient = class {
|
|
|
281
310
|
if (options.project_name) delete options.project_name;
|
|
282
311
|
}
|
|
283
312
|
const params = new URLSearchParams(this._prepareParams(options));
|
|
284
|
-
const response = await this._fetchWithErrorHandling(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
313
|
+
const response = await this._fetchWithErrorHandling(
|
|
314
|
+
`${this.host}/v1/memories/?${params}`,
|
|
315
|
+
{
|
|
316
|
+
method: "DELETE",
|
|
317
|
+
headers: this.headers
|
|
318
|
+
}
|
|
319
|
+
);
|
|
288
320
|
return response;
|
|
289
321
|
}
|
|
290
322
|
async history(memoryId) {
|
|
291
|
-
const response = await this._fetchWithErrorHandling(
|
|
292
|
-
|
|
293
|
-
|
|
323
|
+
const response = await this._fetchWithErrorHandling(
|
|
324
|
+
`${this.host}/v1/memories/${memoryId}/history/`,
|
|
325
|
+
{
|
|
326
|
+
headers: this.headers
|
|
327
|
+
}
|
|
328
|
+
);
|
|
294
329
|
return response;
|
|
295
330
|
}
|
|
296
331
|
async users() {
|
|
@@ -307,16 +342,22 @@ var MemoryClient = class {
|
|
|
307
342
|
if (options.project_name) delete options.project_name;
|
|
308
343
|
}
|
|
309
344
|
const params = new URLSearchParams(options);
|
|
310
|
-
const response = await this._fetchWithErrorHandling(
|
|
311
|
-
|
|
312
|
-
|
|
345
|
+
const response = await this._fetchWithErrorHandling(
|
|
346
|
+
`${this.host}/v1/entities/?${params}`,
|
|
347
|
+
{
|
|
348
|
+
headers: this.headers
|
|
349
|
+
}
|
|
350
|
+
);
|
|
313
351
|
return response;
|
|
314
352
|
}
|
|
315
353
|
async deleteUser(entityId, entity = { type: "user" }) {
|
|
316
|
-
const response = await this._fetchWithErrorHandling(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
354
|
+
const response = await this._fetchWithErrorHandling(
|
|
355
|
+
`${this.host}/v1/entities/${entity.type}/${entityId}/`,
|
|
356
|
+
{
|
|
357
|
+
method: "DELETE",
|
|
358
|
+
headers: this.headers
|
|
359
|
+
}
|
|
360
|
+
);
|
|
320
361
|
return response;
|
|
321
362
|
}
|
|
322
363
|
async deleteUsers() {
|
|
@@ -334,7 +375,9 @@ var MemoryClient = class {
|
|
|
334
375
|
if (options.org_name) delete options.org_name;
|
|
335
376
|
if (options.project_name) delete options.project_name;
|
|
336
377
|
}
|
|
337
|
-
await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, {
|
|
378
|
+
await this.client.delete(`/v1/entities/${entity.type}/${entity.id}/`, {
|
|
379
|
+
params: options
|
|
380
|
+
});
|
|
338
381
|
}
|
|
339
382
|
return { message: "All users, agents, and sessions deleted." };
|
|
340
383
|
}
|
|
@@ -343,29 +386,37 @@ var MemoryClient = class {
|
|
|
343
386
|
memory_id: memory.memoryId,
|
|
344
387
|
text: memory.text
|
|
345
388
|
}));
|
|
346
|
-
const response = await this._fetchWithErrorHandling(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
389
|
+
const response = await this._fetchWithErrorHandling(
|
|
390
|
+
`${this.host}/v1/batch/`,
|
|
391
|
+
{
|
|
392
|
+
method: "PUT",
|
|
393
|
+
headers: this.headers,
|
|
394
|
+
body: JSON.stringify({ memories: memoriesBody })
|
|
395
|
+
}
|
|
396
|
+
);
|
|
351
397
|
return response;
|
|
352
398
|
}
|
|
353
399
|
async batchDelete(memories) {
|
|
354
400
|
const memoriesBody = memories.map((memory) => ({
|
|
355
401
|
memory_id: memory
|
|
356
402
|
}));
|
|
357
|
-
const response = await this._fetchWithErrorHandling(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
403
|
+
const response = await this._fetchWithErrorHandling(
|
|
404
|
+
`${this.host}/v1/batch/`,
|
|
405
|
+
{
|
|
406
|
+
method: "DELETE",
|
|
407
|
+
headers: this.headers,
|
|
408
|
+
body: JSON.stringify({ memories: memoriesBody })
|
|
409
|
+
}
|
|
410
|
+
);
|
|
362
411
|
return response;
|
|
363
412
|
}
|
|
364
413
|
async getProject(options) {
|
|
365
414
|
this._validateOrgProject();
|
|
366
415
|
const { fields } = options;
|
|
367
416
|
if (!(this.organizationId && this.projectId)) {
|
|
368
|
-
throw new Error(
|
|
417
|
+
throw new Error(
|
|
418
|
+
"organizationId and projectId must be set to access instructions or categories"
|
|
419
|
+
);
|
|
369
420
|
}
|
|
370
421
|
const params = new URLSearchParams();
|
|
371
422
|
fields == null ? void 0 : fields.forEach((field) => params.append("fields", field));
|
|
@@ -380,7 +431,9 @@ var MemoryClient = class {
|
|
|
380
431
|
async updateProject(prompts) {
|
|
381
432
|
this._validateOrgProject();
|
|
382
433
|
if (!(this.organizationId && this.projectId)) {
|
|
383
|
-
throw new Error(
|
|
434
|
+
throw new Error(
|
|
435
|
+
"organizationId and projectId must be set to update instructions or categories"
|
|
436
|
+
);
|
|
384
437
|
}
|
|
385
438
|
const response = await this._fetchWithErrorHandling(
|
|
386
439
|
`${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,
|
|
@@ -395,42 +448,54 @@ var MemoryClient = class {
|
|
|
395
448
|
// WebHooks
|
|
396
449
|
async getWebhooks(data) {
|
|
397
450
|
const project_id = (data == null ? void 0 : data.projectId) || this.projectId;
|
|
398
|
-
const response = await this._fetchWithErrorHandling(
|
|
399
|
-
|
|
400
|
-
|
|
451
|
+
const response = await this._fetchWithErrorHandling(
|
|
452
|
+
`${this.host}/api/v1/webhooks/projects/${project_id}/`,
|
|
453
|
+
{
|
|
454
|
+
headers: this.headers
|
|
455
|
+
}
|
|
456
|
+
);
|
|
401
457
|
return response;
|
|
402
458
|
}
|
|
403
459
|
async createWebhook(webhook) {
|
|
404
|
-
const response = await this._fetchWithErrorHandling(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
460
|
+
const response = await this._fetchWithErrorHandling(
|
|
461
|
+
`${this.host}/api/v1/webhooks/projects/${this.projectId}/`,
|
|
462
|
+
{
|
|
463
|
+
method: "POST",
|
|
464
|
+
headers: this.headers,
|
|
465
|
+
body: JSON.stringify(webhook)
|
|
466
|
+
}
|
|
467
|
+
);
|
|
409
468
|
return response;
|
|
410
469
|
}
|
|
411
470
|
async updateWebhook(webhook) {
|
|
412
471
|
const project_id = webhook.projectId || this.projectId;
|
|
413
|
-
const response = await this._fetchWithErrorHandling(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
472
|
+
const response = await this._fetchWithErrorHandling(
|
|
473
|
+
`${this.host}/api/v1/webhooks/${webhook.webhookId}/`,
|
|
474
|
+
{
|
|
475
|
+
method: "PUT",
|
|
476
|
+
headers: this.headers,
|
|
477
|
+
body: JSON.stringify({
|
|
478
|
+
...webhook,
|
|
479
|
+
projectId: project_id
|
|
480
|
+
})
|
|
481
|
+
}
|
|
482
|
+
);
|
|
421
483
|
return response;
|
|
422
484
|
}
|
|
423
485
|
async deleteWebhook(data) {
|
|
424
486
|
const webhook_id = data.webhookId || data;
|
|
425
|
-
const response = await this._fetchWithErrorHandling(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
487
|
+
const response = await this._fetchWithErrorHandling(
|
|
488
|
+
`${this.host}/api/v1/webhooks/${webhook_id}/`,
|
|
489
|
+
{
|
|
490
|
+
method: "DELETE",
|
|
491
|
+
headers: this.headers
|
|
492
|
+
}
|
|
493
|
+
);
|
|
429
494
|
return response;
|
|
430
495
|
}
|
|
431
496
|
};
|
|
432
497
|
|
|
433
|
-
// src/index.ts
|
|
498
|
+
// src/client/index.ts
|
|
434
499
|
var index_default = MemoryClient;
|
|
435
500
|
export {
|
|
436
501
|
MemoryClient,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mem0.ts","../src/telemetry.browser.ts","../src/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { AllUsers, ProjectOptions, Memory, MemoryHistory, MemoryOptions, MemoryUpdateBody, ProjectResponse, PromptUpdatePayload, SearchOptions, Webhook, WebhookPayload } from './mem0.types';\nimport { captureClientEvent, generateHash } from './telemetry';\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\n _validateOrgProject(): void {\n // Check for organizationName/projectName pair\n if ((this.organizationName === null && this.projectName !== null) || \n (this.organizationName !== null && this.projectName === null)) {\n console.warn('Warning: Both organizationName and projectName must be provided together when using either. This will be removedfrom the version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId.');\n }\n\n // Check for organizationId/projectId pair\n if ((this.organizationId === null && this.projectId !== null) || \n (this.organizationId !== null && this.projectId === null)) {\n console.warn('Warning: Both organizationId and projectId must be provided together when using either. This will be removedfrom the version 1.0.40.');\n }\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 this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n this._validateOrgProject();\n\n // Initialize with a temporary ID that will be updated\n this.telemetryId = '';\n \n // Initialize the client\n this._initializeClient();\n }\n\n private async _initializeClient() {\n try {\n this.telemetryId = await generateHash(this.apiKey);\n await captureClientEvent('init', this);\n\n // Wrap methods after initialization\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 this.batchUpdate = this.wrapMethod('batch_update', this.batchUpdate);\n this.batchDelete = this.wrapMethod('batch_delete', this.batchDelete);\n this.getProject = this.wrapMethod('get_project', this.getProject);\n this.updateProject = this.wrapMethod('update_project', this.updateProject);\n this.getWebhooks = this.wrapMethod('get_webhook', this.getWebhooks);\n this.createWebhook = this.wrapMethod('create_webhook', this.createWebhook);\n this.updateWebhook = this.wrapMethod('update_webhook', this.updateWebhook);\n this.deleteWebhook = this.wrapMethod('delete_webhook', this.deleteWebhook);\n } catch (error) {\n console.error('Failed to initialize client:', error);\n }\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 this._validateOrgProject();\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\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 update(memoryId: string, message: string): Promise<Array<Memory>> {\n this._validateOrgProject();\n const payload = {\n text: message\n }\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/memories/${memoryId}/`, {\n method: 'PUT',\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 async getAll(options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, page, page_size, ...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 let appendedParams = \"\";\n let paginated_response = false;\n\n if(page && page_size){\n appendedParams += `page=${page}&page_size=${page_size}`\n paginated_response = true;\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 let url = paginated_response ? `${this.host}/v2/memories/?${appendedParams}` : `${this.host}/v2/memories/`;\n return this._fetchWithErrorHandling(url, {\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 const url = paginated_response ? `${this.host}/v1/memories/?${params}&${appendedParams}` : `${this.host}/v1/memories/?${params}`;\n return this._fetchWithErrorHandling(url, {\n headers: this.headers\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\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\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 this._validateOrgProject();\n if(this.organizationName != null && this.projectName != null){\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\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 this._validateOrgProject();\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 }\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 this._validateOrgProject();\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 }\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 async batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string> {\n const memoriesBody = memories.map(memory => ({\n memory_id: memory.memoryId,\n text: memory.text\n }));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/batch/`, {\n method: 'PUT',\n headers: this.headers,\n body: JSON.stringify({memories: memoriesBody})\n });\n return response;\n }\n\n async batchDelete(memories: Array<string>): Promise<string> {\n const memoriesBody = memories.map(memory => ({\n memory_id: memory\n }));\n const response = await this._fetchWithErrorHandling(`${this.host}/v1/batch/`, {\n method: 'DELETE',\n headers: this.headers,\n body: JSON.stringify({memories: memoriesBody})\n });\n return response;\n }\n\n async getProject(options: ProjectOptions): Promise<ProjectResponse> {\n this._validateOrgProject();\n\n const { fields } = options;\n \n if (!(this.organizationId && this.projectId)) {\n throw new Error(\"organizationId and projectId must be set to access instructions or categories\");\n }\n\n const params = new URLSearchParams();\n fields?.forEach(field => params.append('fields', field));\n \n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/?${params.toString()}`,\n {\n headers: this.headers\n }\n );\n return response;\n }\n\n async updateProject(prompts: PromptUpdatePayload): Promise<Record<string, any>> {\n this._validateOrgProject();\n \n if (!(this.organizationId && this.projectId)) {\n throw new Error(\"organizationId and projectId must be set to update instructions or categories\");\n }\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,\n {\n method: 'PATCH',\n headers: this.headers,\n body: JSON.stringify(prompts)\n }\n );\n return response;\n }\n\n // WebHooks\n async getWebhooks(data?: {projectId?: string}): Promise<Array<Webhook>> {\n const project_id = data?.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(`${this.host}/api/v1/webhooks/projects/${project_id}/`, {\n headers: this.headers\n });\n return response;\n }\n\n async createWebhook(webhook: WebhookPayload): Promise<Webhook> {\n const response = await this._fetchWithErrorHandling(`${this.host}/api/v1/webhooks/projects/${this.projectId}/`, {\n method: 'POST',\n headers: this.headers,\n body: JSON.stringify(webhook)\n });\n return response;\n }\n\n async updateWebhook(webhook: WebhookPayload): Promise<{ message: string }> {\n const project_id = webhook.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(`${this.host}/api/v1/webhooks/${webhook.webhookId}/`, {\n method: 'PUT',\n headers: this.headers,\n body: JSON.stringify({\n ...webhook,\n projectId: project_id\n })\n });\n return response;\n }\n\n async deleteWebhook(data: {webhookId: string}): Promise<{ message: string }> {\n const webhook_id = data.webhookId || data;\n const response = await this._fetchWithErrorHandling(`${this.host}/api/v1/webhooks/${webhook_id}/`, {\n method: 'DELETE', \n headers: this.headers\n });\n return response;\n }\n}\n\nexport {MemoryClient};","// @ts-nocheck\nimport type { PostHog } from \"posthog-js\";\nimport type { TelemetryClient } from \"./telemetry.types\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\nconst POSTHOG_API_KEY = \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\";\nconst POSTHOG_HOST = \"https://us.i.posthog.com\";\n\n// Browser-specific hash function using Web Crypto API\nasync function generateHash(input: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(input);\n const hashBuffer = await window.crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');\n}\n\nclass BrowserTelemetry implements TelemetryClient {\n client: PostHog | null = null;\n\n constructor(projectApiKey: string, host: string) {\n if (MEM0_TELEMETRY) {\n this.initializeClient(projectApiKey, host);\n }\n }\n\n private async initializeClient(projectApiKey: string, host: string) {\n try {\n const posthog = await import('posthog-js').catch(() => null);\n if (posthog) {\n posthog.init(projectApiKey, { api_host: host });\n this.client = posthog;\n }\n } catch (error) {\n // Silently fail if posthog-js is not available\n this.client = null;\n }\n }\n\n async captureEvent(distinctId: string, eventName: string, properties = {}) {\n if (!this.client || !MEM0_TELEMETRY) return;\n\n const eventProperties = {\n client_source: \"browser\",\n client_version: getVersion(),\n browser: window.navigator.userAgent,\n ...properties,\n };\n\n try {\n this.client.capture(\n eventName,\n eventProperties\n );\n } catch (error) {\n // Silently fail if telemetry fails\n }\n }\n\n async shutdown() {\n // No shutdown needed for browser client\n }\n}\n\nfunction getVersion() {\n return version;\n}\n\nconst telemetry = new BrowserTelemetry(\n POSTHOG_API_KEY,\n POSTHOG_HOST\n);\n\nasync function captureClientEvent(eventName: string, instance: any, 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}\n\nexport { telemetry, captureClientEvent, generateHash }; ","import { MemoryClient } from \"./mem0\";\nimport type { TelemetryClient, TelemetryInstance } from './telemetry.types';\nimport { telemetry, captureClientEvent, generateHash } from './telemetry.browser';\nimport type * as MemoryTypes from './mem0.types';\n\n// Re-export all types from mem0.types\nexport type {\n MemoryOptions,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n Messages,\n Message,\n AllUsers,\n User\n} from './mem0.types';\n\n// Export telemetry types\nexport type { TelemetryClient, TelemetryInstance };\n\n// Export telemetry implementation\nexport { telemetry, captureClientEvent, generateHash };\n\n// Export the main client\nexport { MemoryClient };\nexport default MemoryClient;"],"mappings":";AAAA,OAAO,WAAW;;;ACIlB,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AACtD,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAGrB,eAAe,aAAa,OAAgC;AAC1D,QAAM,YAAY,IAAI,YAAY,EAAE,OAAO,KAAK;AAChD,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,OAAO,WAAW,SAAS;AACzE,QAAM,YAAY,MAAM,KAAK,IAAI,WAAW,UAAU,CAAC;AACvD,SAAO,UAAU,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACpE;AAEA,IAAM,mBAAN,MAAkD;AAAA,EAGhD,YAAY,eAAuB,MAAc;AAFjD,kBAAyB;AAGvB,QAAI,gBAAgB;AAClB,WAAK,iBAAiB,eAAe,IAAI;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAc,iBAAiB,eAAuB,MAAc;AAClE,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,YAAY,EAAE,MAAM,MAAM,IAAI;AAC3D,UAAI,SAAS;AACX,gBAAQ,KAAK,eAAe,EAAE,UAAU,KAAK,CAAC;AAC9C,aAAK,SAAS;AAAA,MAChB;AAAA,IACF,SAAS,OAAO;AAEd,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,YAAoB,WAAmB,aAAa,CAAC,GAAG;AACzE,QAAI,CAAC,KAAK,UAAU,CAAC,eAAgB;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,KAAK;AAAA,MACd,MAAM,KAAK,UAAU;AAAA,QACnB,GAAG;AAAA,QACH,WAAW;AAAA,MACb,CAAC;AAAA,IACH,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,cAAc,MAAyD;AAC3E,UAAM,aAAa,KAAK,aAAa;AACrC,UAAM,WAAW,MAAM,KAAK,wBAAwB,GAAG,KAAK,IAAI,oBAAoB,UAAU,KAAK;AAAA,MACjG,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAChB,CAAC;AACD,WAAO;AAAA,EACT;AACF;;;AEraA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/client/mem0.ts","../src/client/telemetry.browser.ts","../src/client/index.ts"],"sourcesContent":["import axios from \"axios\";\nimport {\n AllUsers,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryOptions,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n} from \"./mem0.types\";\nimport { captureClientEvent, generateHash } from \"./telemetry\";\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\n _validateOrgProject(): void {\n // Check for organizationName/projectName pair\n if (\n (this.organizationName === null && this.projectName !== null) ||\n (this.organizationName !== null && this.projectName === null)\n ) {\n console.warn(\n \"Warning: Both organizationName and projectName must be provided together when using either. This will be removedfrom the version 1.0.40. Note that organizationName/projectName are being deprecated in favor of organizationId/projectId.\",\n );\n }\n\n // Check for organizationId/projectId pair\n if (\n (this.organizationId === null && this.projectId !== null) ||\n (this.organizationId !== null && this.projectId === null)\n ) {\n console.warn(\n \"Warning: Both organizationId and projectId must be provided together when using either. This will be removedfrom the version 1.0.40.\",\n );\n }\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 this.client = axios.create({\n baseURL: this.host,\n headers: { Authorization: `Token ${this.apiKey}` },\n timeout: 60000,\n });\n\n this._validateApiKey();\n this._validateOrgProject();\n\n // Initialize with a temporary ID that will be updated\n this.telemetryId = \"\";\n\n // Initialize the client\n this._initializeClient();\n }\n\n private async _initializeClient() {\n try {\n // do this only in browser\n if (typeof window !== \"undefined\") {\n this.telemetryId = await generateHash(this.apiKey);\n await captureClientEvent(\"init\", this);\n }\n\n // Wrap methods after initialization\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 this.batchUpdate = this.wrapMethod(\"batch_update\", this.batchUpdate);\n this.batchDelete = this.wrapMethod(\"batch_delete\", this.batchDelete);\n this.getProject = this.wrapMethod(\"get_project\", this.getProject);\n this.updateProject = this.wrapMethod(\n \"update_project\",\n this.updateProject,\n );\n this.getWebhooks = this.wrapMethod(\"get_webhook\", this.getWebhooks);\n this.createWebhook = this.wrapMethod(\n \"create_webhook\",\n this.createWebhook,\n );\n this.updateWebhook = this.wrapMethod(\n \"update_webhook\",\n this.updateWebhook,\n );\n this.deleteWebhook = this.wrapMethod(\n \"delete_webhook\",\n this.deleteWebhook,\n );\n } catch (error) {\n console.error(\"Failed to initialize client:\", error);\n }\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(\n messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions,\n ): 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(\n Object.entries(options).filter(([_, v]) => v != null),\n );\n }\n\n async add(\n messages: string | Array<{ role: string; content: string }>,\n options: MemoryOptions = {},\n ): Promise<Array<Memory>> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\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(\n `${this.host}/v1/memories/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async update(memoryId: string, message: string): Promise<Array<Memory>> {\n this._validateOrgProject();\n const payload = {\n text: message,\n };\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async get(memoryId: string): Promise<Memory> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n headers: this.headers,\n },\n );\n }\n\n async getAll(options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\n const { api_version, page, page_size, ...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 let appendedParams = \"\";\n let paginated_response = false;\n\n if (page && page_size) {\n appendedParams += `page=${page}&page_size=${page_size}`;\n paginated_response = true;\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 let url = paginated_response\n ? `${this.host}/v2/memories/?${appendedParams}`\n : `${this.host}/v2/memories/`;\n return this._fetchWithErrorHandling(url, {\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 const url = paginated_response\n ? `${this.host}/v1/memories/?${params}&${appendedParams}`\n : `${this.host}/v1/memories/?${params}`;\n return this._fetchWithErrorHandling(url, {\n headers: this.headers,\n });\n }\n }\n\n async search(query: string, options?: SearchOptions): Promise<Array<Memory>> {\n this._validateOrgProject();\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\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 =\n api_version === \"v2\" ? \"/v2/memories/search/\" : \"/v1/memories/search/\";\n const response = await this._fetchWithErrorHandling(\n `${this.host}${endpoint}`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(payload),\n },\n );\n return response;\n }\n\n async delete(memoryId: string): Promise<{ message: string }> {\n return this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n }\n\n async deleteAll(options: MemoryOptions = {}): Promise<{ message: string }> {\n this._validateOrgProject();\n if (this.organizationName != null && this.projectName != null) {\n options.org_name = this.organizationName;\n options.project_name = this.projectName;\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(\n `${this.host}/v1/memories/?${params}`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async history(memoryId: string): Promise<Array<MemoryHistory>> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/memories/${memoryId}/history/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async users(): Promise<AllUsers> {\n this._validateOrgProject();\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 }\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(\n `${this.host}/v1/entities/?${params}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUser(\n entityId: string,\n entity: { type: string } = { type: \"user\" },\n ): Promise<{ message: string }> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/entities/${entity.type}/${entityId}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n\n async deleteUsers(): Promise<{ message: string }> {\n this._validateOrgProject();\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 }\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}/`, {\n params: options,\n });\n }\n return { message: \"All users, agents, and sessions deleted.\" };\n }\n\n async batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory.memoryId,\n text: memory.text,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async batchDelete(memories: Array<string>): Promise<string> {\n const memoriesBody = memories.map((memory) => ({\n memory_id: memory,\n }));\n const response = await this._fetchWithErrorHandling(\n `${this.host}/v1/batch/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n body: JSON.stringify({ memories: memoriesBody }),\n },\n );\n return response;\n }\n\n async getProject(options: ProjectOptions): Promise<ProjectResponse> {\n this._validateOrgProject();\n\n const { fields } = options;\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to access instructions or categories\",\n );\n }\n\n const params = new URLSearchParams();\n fields?.forEach((field) => params.append(\"fields\", field));\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/?${params.toString()}`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async updateProject(\n prompts: PromptUpdatePayload,\n ): Promise<Record<string, any>> {\n this._validateOrgProject();\n\n if (!(this.organizationId && this.projectId)) {\n throw new Error(\n \"organizationId and projectId must be set to update instructions or categories\",\n );\n }\n\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/orgs/organizations/${this.organizationId}/projects/${this.projectId}/`,\n {\n method: \"PATCH\",\n headers: this.headers,\n body: JSON.stringify(prompts),\n },\n );\n return response;\n }\n\n // WebHooks\n async getWebhooks(data?: { projectId?: string }): Promise<Array<Webhook>> {\n const project_id = data?.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${project_id}/`,\n {\n headers: this.headers,\n },\n );\n return response;\n }\n\n async createWebhook(webhook: WebhookPayload): Promise<Webhook> {\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/projects/${this.projectId}/`,\n {\n method: \"POST\",\n headers: this.headers,\n body: JSON.stringify(webhook),\n },\n );\n return response;\n }\n\n async updateWebhook(webhook: WebhookPayload): Promise<{ message: string }> {\n const project_id = webhook.projectId || this.projectId;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook.webhookId}/`,\n {\n method: \"PUT\",\n headers: this.headers,\n body: JSON.stringify({\n ...webhook,\n projectId: project_id,\n }),\n },\n );\n return response;\n }\n\n async deleteWebhook(data: {\n webhookId: string;\n }): Promise<{ message: string }> {\n const webhook_id = data.webhookId || data;\n const response = await this._fetchWithErrorHandling(\n `${this.host}/api/v1/webhooks/${webhook_id}/`,\n {\n method: \"DELETE\",\n headers: this.headers,\n },\n );\n return response;\n }\n}\n\nexport { MemoryClient };\n","// @ts-nocheck\nimport type { PostHog } from \"posthog-js\";\nimport type { TelemetryClient } from \"./telemetry.types\";\n\nlet version = \"1.0.20\";\n\nconst MEM0_TELEMETRY = process.env.MEM0_TELEMETRY !== \"false\";\nconst POSTHOG_API_KEY = \"phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX\";\nconst POSTHOG_HOST = \"https://us.i.posthog.com\";\n\n// Browser-specific hash function using Web Crypto API\nasync function generateHash(input: string): Promise<string> {\n const msgBuffer = new TextEncoder().encode(input);\n const hashBuffer = await window.crypto.subtle.digest(\"SHA-256\", msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nclass BrowserTelemetry implements TelemetryClient {\n client: PostHog | null = null;\n\n constructor(projectApiKey: string, host: string) {\n if (MEM0_TELEMETRY) {\n this.initializeClient(projectApiKey, host);\n }\n }\n\n private async initializeClient(projectApiKey: string, host: string) {\n try {\n const posthog = await import(\"posthog-js\").catch(() => null);\n if (posthog) {\n posthog.init(projectApiKey, { api_host: host });\n this.client = posthog;\n }\n } catch (error) {\n // Silently fail if posthog-js is not available\n this.client = null;\n }\n }\n\n async captureEvent(distinctId: string, eventName: string, properties = {}) {\n if (!this.client || !MEM0_TELEMETRY) return;\n\n const eventProperties = {\n client_source: \"browser\",\n client_version: getVersion(),\n browser: window.navigator.userAgent,\n ...properties,\n };\n\n try {\n this.client.capture(eventName, eventProperties);\n } catch (error) {\n // Silently fail if telemetry fails\n }\n }\n\n async shutdown() {\n // No shutdown needed for browser client\n }\n}\n\nfunction getVersion() {\n return version;\n}\n\nconst telemetry = new BrowserTelemetry(POSTHOG_API_KEY, POSTHOG_HOST);\n\nasync function captureClientEvent(\n eventName: string,\n instance: any,\n additionalData = {},\n) {\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}\n\nexport { telemetry, captureClientEvent, generateHash };\n","import { MemoryClient } from \"./mem0\";\nimport type { TelemetryClient, TelemetryInstance } from \"./telemetry.types\";\nimport {\n telemetry,\n captureClientEvent,\n generateHash,\n} from \"./telemetry.browser\";\nimport type * as MemoryTypes from \"./mem0.types\";\n\n// Re-export all types from mem0.types\nexport type {\n MemoryOptions,\n ProjectOptions,\n Memory,\n MemoryHistory,\n MemoryUpdateBody,\n ProjectResponse,\n PromptUpdatePayload,\n SearchOptions,\n Webhook,\n WebhookPayload,\n Messages,\n Message,\n AllUsers,\n User,\n} from \"./mem0.types\";\n\n// Export telemetry types\nexport type { TelemetryClient, TelemetryInstance };\n\n// Export telemetry implementation\nexport { telemetry, captureClientEvent, generateHash };\n\n// Export the main client\nexport { MemoryClient };\nexport default MemoryClient;\n"],"mappings":";AAAA,OAAO,WAAW;;;ACIlB,IAAI,UAAU;AAEd,IAAM,iBAAiB,QAAQ,IAAI,mBAAmB;AACtD,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAGrB,eAAe,aAAa,OAAgC;AAC1D,QAAM,YAAY,IAAI,YAAY,EAAE,OAAO,KAAK;AAChD,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,OAAO,WAAW,SAAS;AACzE,QAAM,YAAY,MAAM,KAAK,IAAI,WAAW,UAAU,CAAC;AACvD,SAAO,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACtE;AAEA,IAAM,mBAAN,MAAkD;AAAA,EAGhD,YAAY,eAAuB,MAAc;AAFjD,kBAAyB;AAGvB,QAAI,gBAAgB;AAClB,WAAK,iBAAiB,eAAe,IAAI;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAc,iBAAiB,eAAuB,MAAc;AAClE,QAAI;AACF,YAAM,UAAU,MAAM,OAAO,uBAAY,EAAE,MAAM,MAAM,IAAI;AAC3D,UAAI,SAAS;AACX,gBAAQ,KAAK,eAAe,EAAE,UAAU,KAAK,CAAC;AAC9C,aAAK,SAAS;AAAA,MAChB;AAAA,IACF,SAAS,OAAO;AAEd,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,YAAoB,WAAmB,aAAa,CAAC,GAAG;AAC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