@zibby/mem0ai 2.4.7

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.
@@ -0,0 +1,364 @@
1
+ interface Common {
2
+ project_id?: string | null;
3
+ org_id?: string | null;
4
+ }
5
+ interface MemoryOptions {
6
+ api_version?: API_VERSION | string;
7
+ version?: API_VERSION | string;
8
+ user_id?: string;
9
+ agent_id?: string;
10
+ app_id?: string;
11
+ run_id?: string;
12
+ metadata?: Record<string, any>;
13
+ filters?: Record<string, any>;
14
+ org_name?: string | null;
15
+ project_name?: string | null;
16
+ org_id?: string | number | null;
17
+ project_id?: string | number | null;
18
+ infer?: boolean;
19
+ page?: number;
20
+ page_size?: number;
21
+ includes?: string;
22
+ excludes?: string;
23
+ enable_graph?: boolean;
24
+ start_date?: string;
25
+ end_date?: string;
26
+ custom_categories?: custom_categories[];
27
+ custom_instructions?: string;
28
+ timestamp?: number;
29
+ output_format?: string | OutputFormat;
30
+ async_mode?: boolean;
31
+ filter_memories?: boolean;
32
+ immutable?: boolean;
33
+ structured_data_schema?: Record<string, any>;
34
+ }
35
+ interface ProjectOptions {
36
+ fields?: string[];
37
+ }
38
+ declare enum OutputFormat {
39
+ V1 = "v1.0",
40
+ V1_1 = "v1.1"
41
+ }
42
+ declare enum API_VERSION {
43
+ V1 = "v1",
44
+ V2 = "v2"
45
+ }
46
+ declare enum Feedback {
47
+ POSITIVE = "POSITIVE",
48
+ NEGATIVE = "NEGATIVE",
49
+ VERY_NEGATIVE = "VERY_NEGATIVE"
50
+ }
51
+ interface MultiModalMessages {
52
+ type: "image_url";
53
+ image_url: {
54
+ url: string;
55
+ };
56
+ }
57
+ interface Messages {
58
+ role: "user" | "assistant";
59
+ content: string | MultiModalMessages;
60
+ }
61
+ interface Message extends Messages {
62
+ }
63
+ interface MemoryHistory {
64
+ id: string;
65
+ memory_id: string;
66
+ input: Array<Messages>;
67
+ old_memory: string | null;
68
+ new_memory: string | null;
69
+ user_id: string;
70
+ categories: Array<string>;
71
+ event: Event | string;
72
+ created_at: Date;
73
+ updated_at: Date;
74
+ }
75
+ interface SearchOptions extends MemoryOptions {
76
+ api_version?: API_VERSION | string;
77
+ limit?: number;
78
+ enable_graph?: boolean;
79
+ threshold?: number;
80
+ top_k?: number;
81
+ only_metadata_based_search?: boolean;
82
+ keyword_search?: boolean;
83
+ fields?: string[];
84
+ categories?: string[];
85
+ rerank?: boolean;
86
+ }
87
+ declare enum Event {
88
+ ADD = "ADD",
89
+ UPDATE = "UPDATE",
90
+ DELETE = "DELETE",
91
+ NOOP = "NOOP"
92
+ }
93
+ interface MemoryData {
94
+ memory: string;
95
+ }
96
+ interface Memory {
97
+ id: string;
98
+ messages?: Array<Messages>;
99
+ event?: Event | string;
100
+ data?: MemoryData | null;
101
+ memory?: string;
102
+ user_id?: string;
103
+ hash?: string;
104
+ categories?: Array<string>;
105
+ created_at?: Date;
106
+ updated_at?: Date;
107
+ memory_type?: string;
108
+ score?: number;
109
+ metadata?: any | null;
110
+ owner?: string | null;
111
+ agent_id?: string | null;
112
+ app_id?: string | null;
113
+ run_id?: string | null;
114
+ }
115
+ interface MemoryUpdateBody {
116
+ memoryId: string;
117
+ text: string;
118
+ }
119
+ interface User {
120
+ id: string;
121
+ name: string;
122
+ created_at: Date;
123
+ updated_at: Date;
124
+ total_memories: number;
125
+ owner: string;
126
+ type: string;
127
+ }
128
+ interface AllUsers {
129
+ count: number;
130
+ results: Array<User>;
131
+ next: any;
132
+ previous: any;
133
+ }
134
+ interface ProjectResponse {
135
+ custom_instructions?: string;
136
+ custom_categories?: string[];
137
+ [key: string]: any;
138
+ }
139
+ interface custom_categories {
140
+ [key: string]: any;
141
+ }
142
+ interface PromptUpdatePayload {
143
+ custom_instructions?: string;
144
+ custom_categories?: custom_categories[];
145
+ retrieval_criteria?: any[];
146
+ enable_graph?: boolean;
147
+ version?: string;
148
+ inclusion_prompt?: string;
149
+ exclusion_prompt?: string;
150
+ memory_depth?: string | null;
151
+ usecase_setting?: string | number;
152
+ multilingual?: boolean;
153
+ [key: string]: any;
154
+ }
155
+ declare enum WebhookEvent {
156
+ MEMORY_ADDED = "memory_add",
157
+ MEMORY_UPDATED = "memory_update",
158
+ MEMORY_DELETED = "memory_delete",
159
+ MEMORY_CATEGORIZED = "memory_categorize"
160
+ }
161
+ interface Webhook {
162
+ webhook_id?: string;
163
+ name: string;
164
+ url: string;
165
+ project?: string;
166
+ created_at?: Date;
167
+ updated_at?: Date;
168
+ is_active?: boolean;
169
+ event_types?: WebhookEvent[];
170
+ }
171
+ interface WebhookCreatePayload {
172
+ name: string;
173
+ url: string;
174
+ eventTypes: WebhookEvent[];
175
+ }
176
+ interface WebhookUpdatePayload {
177
+ webhookId: string;
178
+ name?: string;
179
+ url?: string;
180
+ eventTypes?: WebhookEvent[];
181
+ }
182
+ interface FeedbackPayload {
183
+ memory_id: string;
184
+ feedback?: Feedback | null;
185
+ feedback_reason?: string | null;
186
+ }
187
+ interface CreateMemoryExportPayload extends Common {
188
+ schema: Record<string, any>;
189
+ filters: Record<string, any>;
190
+ export_instructions?: string;
191
+ }
192
+ interface GetMemoryExportPayload extends Common {
193
+ filters?: Record<string, any>;
194
+ memory_export_id?: string;
195
+ }
196
+
197
+ interface ClientOptions {
198
+ apiKey: string;
199
+ host?: string;
200
+ organizationName?: string;
201
+ projectName?: string;
202
+ organizationId?: string;
203
+ projectId?: string;
204
+ }
205
+ declare class MemoryClient {
206
+ apiKey: string;
207
+ host: string;
208
+ organizationName: string | null;
209
+ projectName: string | null;
210
+ organizationId: string | number | null;
211
+ projectId: string | number | null;
212
+ headers: Record<string, string>;
213
+ client: any;
214
+ telemetryId: string;
215
+ _validateApiKey(): any;
216
+ _validateOrgProject(): void;
217
+ constructor(options: ClientOptions);
218
+ private _initializeClient;
219
+ private _captureEvent;
220
+ _fetchWithErrorHandling(url: string, options: any): Promise<any>;
221
+ _preparePayload(messages: Array<Message>, options: MemoryOptions): object;
222
+ _prepareParams(options: MemoryOptions): object;
223
+ ping(): Promise<void>;
224
+ add(messages: Array<Message>, options?: MemoryOptions & Record<string, any>): Promise<Array<Memory>>;
225
+ update(memoryId: string, { text, metadata, timestamp, }: {
226
+ text?: string;
227
+ metadata?: Record<string, any>;
228
+ timestamp?: number | string;
229
+ }): Promise<Array<Memory>>;
230
+ get(memoryId: string): Promise<Memory>;
231
+ getAll(options?: SearchOptions): Promise<Array<Memory>>;
232
+ search(query: string, options?: SearchOptions & Record<string, any>): Promise<Array<Memory>>;
233
+ delete(memoryId: string): Promise<{
234
+ message: string;
235
+ }>;
236
+ deleteAll(options?: MemoryOptions): Promise<{
237
+ message: string;
238
+ }>;
239
+ history(memoryId: string): Promise<Array<MemoryHistory>>;
240
+ users(): Promise<AllUsers>;
241
+ /**
242
+ * @deprecated The method should not be used, use `deleteUsers` instead. This will be removed in version 2.2.0.
243
+ */
244
+ deleteUser(data: {
245
+ entity_id: number;
246
+ entity_type: string;
247
+ }): Promise<{
248
+ message: string;
249
+ }>;
250
+ deleteUsers(params?: {
251
+ user_id?: string;
252
+ agent_id?: string;
253
+ app_id?: string;
254
+ run_id?: string;
255
+ }): Promise<{
256
+ message: string;
257
+ }>;
258
+ batchUpdate(memories: Array<MemoryUpdateBody>): Promise<string>;
259
+ batchDelete(memories: Array<string>): Promise<string>;
260
+ getProject(options: ProjectOptions): Promise<ProjectResponse>;
261
+ updateProject(prompts: PromptUpdatePayload): Promise<Record<string, any>>;
262
+ getWebhooks(data?: {
263
+ projectId?: string;
264
+ }): Promise<Array<Webhook>>;
265
+ createWebhook(webhook: WebhookCreatePayload): Promise<Webhook>;
266
+ updateWebhook(webhook: WebhookUpdatePayload): Promise<{
267
+ message: string;
268
+ }>;
269
+ deleteWebhook(data: {
270
+ webhookId: string;
271
+ }): Promise<{
272
+ message: string;
273
+ }>;
274
+ feedback(data: FeedbackPayload): Promise<{
275
+ message: string;
276
+ }>;
277
+ createMemoryExport(data: CreateMemoryExportPayload): Promise<{
278
+ message: string;
279
+ id: string;
280
+ }>;
281
+ getMemoryExport(data: GetMemoryExportPayload): Promise<{
282
+ message: string;
283
+ id: string;
284
+ }>;
285
+ }
286
+
287
+ /**
288
+ * Structured exception classes for mem0 TypeScript SDK.
289
+ *
290
+ * Provides specific, actionable exceptions with error codes, suggestions,
291
+ * and debug information. Maps HTTP status codes to appropriate exception types.
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * import { RateLimitError, MemoryNotFoundError } from 'mem0ai'
296
+ *
297
+ * try {
298
+ * await client.get(memoryId)
299
+ * } catch (e) {
300
+ * if (e instanceof MemoryNotFoundError) {
301
+ * console.log(e.suggestion) // "The requested resource was not found"
302
+ * } else if (e instanceof RateLimitError) {
303
+ * await sleep(e.debugInfo.retryAfter ?? 60)
304
+ * }
305
+ * }
306
+ * ```
307
+ */
308
+ interface MemoryErrorOptions {
309
+ details?: Record<string, unknown>;
310
+ suggestion?: string;
311
+ debugInfo?: Record<string, unknown>;
312
+ }
313
+ /**
314
+ * Base exception for all memory-related errors.
315
+ *
316
+ * Every mem0 exception includes an error code for programmatic handling,
317
+ * optional details, a user-friendly suggestion, and debug information.
318
+ */
319
+ declare class MemoryError extends Error {
320
+ readonly errorCode: string;
321
+ readonly details: Record<string, unknown>;
322
+ readonly suggestion?: string;
323
+ readonly debugInfo: Record<string, unknown>;
324
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
325
+ }
326
+ /** Raised when authentication fails (401, 403). */
327
+ declare class AuthenticationError extends MemoryError {
328
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
329
+ }
330
+ /** Raised when rate limits are exceeded (429). */
331
+ declare class RateLimitError extends MemoryError {
332
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
333
+ }
334
+ /** Raised when input validation fails (400, 409, 422). */
335
+ declare class ValidationError extends MemoryError {
336
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
337
+ }
338
+ /** Raised when a memory is not found (404). */
339
+ declare class MemoryNotFoundError extends MemoryError {
340
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
341
+ }
342
+ /** Raised when network connectivity issues occur (408, 502, 503, 504). */
343
+ declare class NetworkError extends MemoryError {
344
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
345
+ }
346
+ /** Raised when client configuration is invalid. */
347
+ declare class ConfigurationError extends MemoryError {
348
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
349
+ }
350
+ /** Raised when memory quota is exceeded (413). */
351
+ declare class MemoryQuotaExceededError extends MemoryError {
352
+ constructor(message: string, errorCode: string, options?: MemoryErrorOptions);
353
+ }
354
+ /**
355
+ * Create an appropriate exception based on HTTP response status code.
356
+ *
357
+ * @param statusCode - HTTP status code from the response
358
+ * @param responseText - Response body text
359
+ * @param options - Additional error context (details, debugInfo)
360
+ * @returns An instance of the appropriate MemoryError subclass
361
+ */
362
+ declare function createExceptionFromResponse(statusCode: number, responseText: string, options?: Omit<MemoryErrorOptions, "suggestion">): MemoryError;
363
+
364
+ export { type AllUsers, AuthenticationError, ConfigurationError, Feedback, type FeedbackPayload, type Memory, MemoryClient, MemoryError, type MemoryErrorOptions, type MemoryHistory, MemoryNotFoundError, type MemoryOptions, MemoryQuotaExceededError, type MemoryUpdateBody, type Message, type Messages, NetworkError, type ProjectOptions, type ProjectResponse, type PromptUpdatePayload, RateLimitError, type SearchOptions, type User, ValidationError, type Webhook, type WebhookCreatePayload, WebhookEvent, type WebhookUpdatePayload, createExceptionFromResponse, MemoryClient as default };