@lanonasis/memory-client 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +578 -51
- package/dist/core/index.js +700 -120
- package/dist/core/index.js.map +1 -1
- package/dist/core/tsconfig.tsbuildinfo +1 -0
- package/dist/index.cjs +1918 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +635 -51
- package/dist/index.esm.js +1383 -123
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1359 -121
- package/dist/index.js.map +1 -1
- package/dist/node/index.d.ts +31 -3
- package/dist/node/index.js +65 -28
- package/dist/node/index.js.map +1 -1
- package/dist/node/tsconfig.tsbuildinfo +1 -0
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/tsconfig.tsbuildinfo +1 -0
- package/dist/react/index.d.ts +33 -11
- package/dist/react/index.js +9 -24
- package/dist/react/index.js.map +1 -1
- package/dist/react/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vue/index.d.ts +127 -22
- package/dist/vue/index.js +9 -24
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/tsconfig.tsbuildinfo +1 -0
- package/package.json +13 -10
package/dist/core/index.d.ts
CHANGED
|
@@ -142,6 +142,414 @@ type CreateMemoryRequest = z.infer<typeof createMemorySchema>;
|
|
|
142
142
|
type UpdateMemoryRequest = z.infer<typeof updateMemorySchema>;
|
|
143
143
|
type SearchMemoryRequest = z.infer<typeof searchMemorySchema>;
|
|
144
144
|
type CreateTopicRequest = z.infer<typeof createTopicSchema>;
|
|
145
|
+
/**
|
|
146
|
+
* Chunking strategies for content preprocessing
|
|
147
|
+
*/
|
|
148
|
+
declare const CHUNKING_STRATEGIES: readonly ["semantic", "fixed-size", "paragraph", "sentence", "code-block"];
|
|
149
|
+
type ChunkingStrategy = typeof CHUNKING_STRATEGIES[number];
|
|
150
|
+
/**
|
|
151
|
+
* Content types detected or specified
|
|
152
|
+
*/
|
|
153
|
+
declare const CONTENT_TYPES: readonly ["text", "code", "markdown", "json", "yaml"];
|
|
154
|
+
type ContentType = typeof CONTENT_TYPES[number];
|
|
155
|
+
/**
|
|
156
|
+
* A chunk of content from a memory entry
|
|
157
|
+
*/
|
|
158
|
+
interface ContentChunk {
|
|
159
|
+
index: number;
|
|
160
|
+
content: string;
|
|
161
|
+
startChar: number;
|
|
162
|
+
endChar: number;
|
|
163
|
+
tokens: number;
|
|
164
|
+
metadata?: {
|
|
165
|
+
type: 'paragraph' | 'sentence' | 'code' | 'section';
|
|
166
|
+
isComplete: boolean;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Extracted intelligence from memory content
|
|
171
|
+
*/
|
|
172
|
+
interface MemoryIntelligence {
|
|
173
|
+
entities: string[];
|
|
174
|
+
keywords: string[];
|
|
175
|
+
language: string;
|
|
176
|
+
topics?: string[];
|
|
177
|
+
sentiment?: 'positive' | 'neutral' | 'negative';
|
|
178
|
+
complexity?: 'low' | 'medium' | 'high';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Extended metadata with intelligence features
|
|
182
|
+
*/
|
|
183
|
+
interface IntelligentMetadata extends Record<string, unknown> {
|
|
184
|
+
chunks?: ContentChunk[];
|
|
185
|
+
total_chunks?: number;
|
|
186
|
+
chunking_strategy?: ChunkingStrategy;
|
|
187
|
+
last_rechunked_at?: string;
|
|
188
|
+
intelligence?: MemoryIntelligence;
|
|
189
|
+
content_type?: ContentType;
|
|
190
|
+
language?: string;
|
|
191
|
+
tokens?: number;
|
|
192
|
+
source?: string;
|
|
193
|
+
priority?: 'high' | 'medium' | 'low';
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Preprocessing options for memory creation/update
|
|
197
|
+
*/
|
|
198
|
+
interface PreprocessingOptions {
|
|
199
|
+
chunking?: {
|
|
200
|
+
strategy?: ChunkingStrategy;
|
|
201
|
+
maxChunkSize?: number;
|
|
202
|
+
overlap?: number;
|
|
203
|
+
};
|
|
204
|
+
cleanContent?: boolean;
|
|
205
|
+
extractMetadata?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Extended create memory request with preprocessing
|
|
209
|
+
*/
|
|
210
|
+
interface CreateMemoryWithPreprocessingRequest extends CreateMemoryRequest {
|
|
211
|
+
preprocessing?: PreprocessingOptions;
|
|
212
|
+
metadata?: IntelligentMetadata;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Extended update memory request with re-chunking
|
|
216
|
+
*/
|
|
217
|
+
interface UpdateMemoryWithPreprocessingRequest extends UpdateMemoryRequest {
|
|
218
|
+
rechunk?: boolean;
|
|
219
|
+
regenerate_embedding?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Search modes for memory queries
|
|
223
|
+
*/
|
|
224
|
+
declare const SEARCH_MODES: readonly ["vector", "text", "hybrid"];
|
|
225
|
+
type SearchMode = typeof SEARCH_MODES[number];
|
|
226
|
+
/**
|
|
227
|
+
* A matching chunk from search results
|
|
228
|
+
*/
|
|
229
|
+
interface MatchingChunk {
|
|
230
|
+
index: number;
|
|
231
|
+
content: string;
|
|
232
|
+
similarity: number;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Enhanced search filters
|
|
236
|
+
*/
|
|
237
|
+
interface SearchFilters {
|
|
238
|
+
tags?: string[];
|
|
239
|
+
project_id?: string;
|
|
240
|
+
topic_id?: string;
|
|
241
|
+
date_range?: {
|
|
242
|
+
from?: string;
|
|
243
|
+
to?: string;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Enhanced search request with hybrid mode
|
|
248
|
+
*/
|
|
249
|
+
interface EnhancedSearchRequest {
|
|
250
|
+
query: string;
|
|
251
|
+
type?: MemoryType;
|
|
252
|
+
threshold?: number;
|
|
253
|
+
limit?: number;
|
|
254
|
+
search_mode?: SearchMode;
|
|
255
|
+
filters?: SearchFilters;
|
|
256
|
+
include_chunks?: boolean;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Enhanced search result with chunk matching
|
|
260
|
+
*/
|
|
261
|
+
interface EnhancedMemorySearchResult extends MemorySearchResult {
|
|
262
|
+
text_rank?: number;
|
|
263
|
+
combined_score?: number;
|
|
264
|
+
matching_chunks?: MatchingChunk[];
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Enhanced search response
|
|
268
|
+
*/
|
|
269
|
+
interface EnhancedSearchResponse {
|
|
270
|
+
results: EnhancedMemorySearchResult[];
|
|
271
|
+
total: number;
|
|
272
|
+
query: string;
|
|
273
|
+
search_mode: SearchMode;
|
|
274
|
+
threshold: number;
|
|
275
|
+
execution_time_ms: number;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Search analytics data point
|
|
279
|
+
*/
|
|
280
|
+
interface SearchAnalyticsDataPoint {
|
|
281
|
+
date: string;
|
|
282
|
+
searches: number;
|
|
283
|
+
avg_results: number;
|
|
284
|
+
avg_time_ms: number;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Popular query entry
|
|
288
|
+
*/
|
|
289
|
+
interface PopularQuery {
|
|
290
|
+
query: string;
|
|
291
|
+
count: number;
|
|
292
|
+
avg_results: number;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Search analytics response
|
|
296
|
+
*/
|
|
297
|
+
interface SearchAnalytics {
|
|
298
|
+
total_searches: number;
|
|
299
|
+
avg_results_count: number;
|
|
300
|
+
avg_execution_time_ms: number;
|
|
301
|
+
search_types: {
|
|
302
|
+
vector: number;
|
|
303
|
+
text: number;
|
|
304
|
+
hybrid: number;
|
|
305
|
+
};
|
|
306
|
+
by_date: SearchAnalyticsDataPoint[];
|
|
307
|
+
popular_queries: PopularQuery[];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Most accessed memory entry
|
|
311
|
+
*/
|
|
312
|
+
interface MostAccessedMemory {
|
|
313
|
+
memory_id: string;
|
|
314
|
+
title: string;
|
|
315
|
+
access_count: number;
|
|
316
|
+
last_accessed: string;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Hourly access data
|
|
320
|
+
*/
|
|
321
|
+
interface HourlyAccess {
|
|
322
|
+
hour: number;
|
|
323
|
+
count: number;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Access patterns response
|
|
327
|
+
*/
|
|
328
|
+
interface AccessPatterns {
|
|
329
|
+
total_accesses: number;
|
|
330
|
+
by_type: {
|
|
331
|
+
read: number;
|
|
332
|
+
update: number;
|
|
333
|
+
delete: number;
|
|
334
|
+
};
|
|
335
|
+
by_method: {
|
|
336
|
+
api: number;
|
|
337
|
+
search: number;
|
|
338
|
+
direct: number;
|
|
339
|
+
};
|
|
340
|
+
most_accessed: MostAccessedMemory[];
|
|
341
|
+
access_by_hour: HourlyAccess[];
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Project memory count
|
|
345
|
+
*/
|
|
346
|
+
interface ProjectMemoryCount {
|
|
347
|
+
project_id: string;
|
|
348
|
+
project_name: string;
|
|
349
|
+
count: number;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Tag count entry
|
|
353
|
+
*/
|
|
354
|
+
interface TagCount {
|
|
355
|
+
tag: string;
|
|
356
|
+
count: number;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Extended memory statistics
|
|
360
|
+
*/
|
|
361
|
+
interface ExtendedMemoryStats {
|
|
362
|
+
total_memories: number;
|
|
363
|
+
by_type: Record<MemoryType, number>;
|
|
364
|
+
by_project: ProjectMemoryCount[];
|
|
365
|
+
storage: {
|
|
366
|
+
total_size_mb: number;
|
|
367
|
+
avg_memory_size_kb: number;
|
|
368
|
+
total_chunks: number;
|
|
369
|
+
};
|
|
370
|
+
activity: {
|
|
371
|
+
created_today: number;
|
|
372
|
+
updated_today: number;
|
|
373
|
+
searched_today: number;
|
|
374
|
+
};
|
|
375
|
+
top_tags: TagCount[];
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Analytics date range filter
|
|
379
|
+
*/
|
|
380
|
+
interface AnalyticsDateRange {
|
|
381
|
+
from?: string;
|
|
382
|
+
to?: string;
|
|
383
|
+
group_by?: 'day' | 'week' | 'month';
|
|
384
|
+
}
|
|
385
|
+
declare const preprocessingOptionsSchema: z.ZodOptional<z.ZodObject<{
|
|
386
|
+
chunking: z.ZodOptional<z.ZodObject<{
|
|
387
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
388
|
+
semantic: "semantic";
|
|
389
|
+
"fixed-size": "fixed-size";
|
|
390
|
+
paragraph: "paragraph";
|
|
391
|
+
sentence: "sentence";
|
|
392
|
+
"code-block": "code-block";
|
|
393
|
+
}>>;
|
|
394
|
+
maxChunkSize: z.ZodOptional<z.ZodNumber>;
|
|
395
|
+
overlap: z.ZodOptional<z.ZodNumber>;
|
|
396
|
+
}, z.core.$strip>>;
|
|
397
|
+
cleanContent: z.ZodOptional<z.ZodBoolean>;
|
|
398
|
+
extractMetadata: z.ZodOptional<z.ZodBoolean>;
|
|
399
|
+
}, z.core.$strip>>;
|
|
400
|
+
declare const enhancedSearchSchema: z.ZodObject<{
|
|
401
|
+
query: z.ZodString;
|
|
402
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
403
|
+
context: "context";
|
|
404
|
+
project: "project";
|
|
405
|
+
knowledge: "knowledge";
|
|
406
|
+
reference: "reference";
|
|
407
|
+
personal: "personal";
|
|
408
|
+
workflow: "workflow";
|
|
409
|
+
}>>;
|
|
410
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
411
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
412
|
+
search_mode: z.ZodDefault<z.ZodEnum<{
|
|
413
|
+
text: "text";
|
|
414
|
+
vector: "vector";
|
|
415
|
+
hybrid: "hybrid";
|
|
416
|
+
}>>;
|
|
417
|
+
filters: z.ZodOptional<z.ZodObject<{
|
|
418
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
419
|
+
project_id: z.ZodOptional<z.ZodString>;
|
|
420
|
+
topic_id: z.ZodOptional<z.ZodString>;
|
|
421
|
+
date_range: z.ZodOptional<z.ZodObject<{
|
|
422
|
+
from: z.ZodOptional<z.ZodString>;
|
|
423
|
+
to: z.ZodOptional<z.ZodString>;
|
|
424
|
+
}, z.core.$strip>>;
|
|
425
|
+
}, z.core.$strip>>;
|
|
426
|
+
include_chunks: z.ZodDefault<z.ZodBoolean>;
|
|
427
|
+
}, z.core.$strip>;
|
|
428
|
+
declare const analyticsDateRangeSchema: z.ZodObject<{
|
|
429
|
+
from: z.ZodOptional<z.ZodString>;
|
|
430
|
+
to: z.ZodOptional<z.ZodString>;
|
|
431
|
+
group_by: z.ZodDefault<z.ZodEnum<{
|
|
432
|
+
day: "day";
|
|
433
|
+
week: "week";
|
|
434
|
+
month: "month";
|
|
435
|
+
}>>;
|
|
436
|
+
}, z.core.$strip>;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Error handling for Memory Client
|
|
440
|
+
* Browser-safe, no Node.js dependencies
|
|
441
|
+
*/
|
|
442
|
+
/**
|
|
443
|
+
* Standardized error codes for programmatic error handling
|
|
444
|
+
*/
|
|
445
|
+
declare const ERROR_CODES: readonly ["API_ERROR", "AUTH_ERROR", "VALIDATION_ERROR", "TIMEOUT_ERROR", "RATE_LIMIT_ERROR", "NOT_FOUND", "NETWORK_ERROR", "FORBIDDEN", "CONFLICT", "SERVER_ERROR"];
|
|
446
|
+
type ErrorCode = typeof ERROR_CODES[number];
|
|
447
|
+
/**
|
|
448
|
+
* Structured API error response - replaces plain string errors
|
|
449
|
+
* Enables programmatic error handling with typed codes
|
|
450
|
+
*/
|
|
451
|
+
interface ApiErrorResponse {
|
|
452
|
+
/** Machine-readable error code for programmatic handling */
|
|
453
|
+
code: ErrorCode;
|
|
454
|
+
/** Human-readable error message */
|
|
455
|
+
message: string;
|
|
456
|
+
/** HTTP status code if from API response */
|
|
457
|
+
statusCode?: number;
|
|
458
|
+
/** Additional error details (validation errors, etc.) */
|
|
459
|
+
details?: unknown;
|
|
460
|
+
/** Request ID for debugging/support */
|
|
461
|
+
requestId?: string;
|
|
462
|
+
/** Timestamp when error occurred */
|
|
463
|
+
timestamp?: string;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Type guard to check if an object is an ApiErrorResponse
|
|
467
|
+
*/
|
|
468
|
+
declare function isApiErrorResponse(value: unknown): value is ApiErrorResponse;
|
|
469
|
+
/**
|
|
470
|
+
* Base error class for Memory Client errors
|
|
471
|
+
*/
|
|
472
|
+
declare class MemoryClientError extends Error {
|
|
473
|
+
code: ErrorCode;
|
|
474
|
+
statusCode?: number | undefined;
|
|
475
|
+
details?: unknown | undefined;
|
|
476
|
+
constructor(message: string, code?: ErrorCode, statusCode?: number | undefined, details?: unknown | undefined);
|
|
477
|
+
/**
|
|
478
|
+
* Convert to ApiErrorResponse for consistent API responses
|
|
479
|
+
*/
|
|
480
|
+
toResponse(): ApiErrorResponse;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Network/API error
|
|
484
|
+
*/
|
|
485
|
+
declare class ApiError extends MemoryClientError {
|
|
486
|
+
constructor(message: string, statusCode?: number, details?: unknown);
|
|
487
|
+
/**
|
|
488
|
+
* Create from an HTTP response
|
|
489
|
+
*/
|
|
490
|
+
static fromResponse(status: number, statusText: string, body?: unknown): ApiError;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Authentication error
|
|
494
|
+
*/
|
|
495
|
+
declare class AuthenticationError extends MemoryClientError {
|
|
496
|
+
constructor(message?: string);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Validation error with field-level details
|
|
500
|
+
*/
|
|
501
|
+
declare class ValidationError extends MemoryClientError {
|
|
502
|
+
readonly validationErrors: Array<{
|
|
503
|
+
field: string;
|
|
504
|
+
message: string;
|
|
505
|
+
}>;
|
|
506
|
+
constructor(message: string, details?: unknown);
|
|
507
|
+
/**
|
|
508
|
+
* Create from Zod error
|
|
509
|
+
*/
|
|
510
|
+
static fromZodError(error: {
|
|
511
|
+
issues: Array<{
|
|
512
|
+
path: (string | number)[];
|
|
513
|
+
message: string;
|
|
514
|
+
}>;
|
|
515
|
+
}): ValidationError;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Timeout error
|
|
519
|
+
*/
|
|
520
|
+
declare class TimeoutError extends MemoryClientError {
|
|
521
|
+
constructor(message?: string);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Rate limit error with retry-after info
|
|
525
|
+
*/
|
|
526
|
+
declare class RateLimitError extends MemoryClientError {
|
|
527
|
+
readonly retryAfter?: number;
|
|
528
|
+
constructor(message?: string, retryAfter?: number);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Not found error
|
|
532
|
+
*/
|
|
533
|
+
declare class NotFoundError extends MemoryClientError {
|
|
534
|
+
readonly resource: string;
|
|
535
|
+
constructor(resource: string);
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Network error (no response received)
|
|
539
|
+
*/
|
|
540
|
+
declare class NetworkError extends MemoryClientError {
|
|
541
|
+
constructor(message?: string);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Server error (5xx responses)
|
|
545
|
+
*/
|
|
546
|
+
declare class ServerError extends MemoryClientError {
|
|
547
|
+
constructor(message: string, statusCode?: number);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Create appropriate error class from status code
|
|
551
|
+
*/
|
|
552
|
+
declare function createErrorFromStatus(status: number, message: string, details?: unknown): MemoryClientError;
|
|
145
553
|
|
|
146
554
|
/**
|
|
147
555
|
* Core Memory Client - Pure Browser-Safe Implementation
|
|
@@ -182,29 +590,41 @@ interface CoreMemoryClientConfig {
|
|
|
182
590
|
ttl?: number;
|
|
183
591
|
};
|
|
184
592
|
/** Called when an error occurs */
|
|
185
|
-
onError?: (error:
|
|
593
|
+
onError?: (error: ApiErrorResponse) => void;
|
|
186
594
|
/** Called before each request */
|
|
187
595
|
onRequest?: (endpoint: string) => void;
|
|
188
596
|
/** Called after each response */
|
|
189
597
|
onResponse?: (endpoint: string, duration: number) => void;
|
|
190
598
|
}
|
|
191
599
|
/**
|
|
192
|
-
* Standard API response wrapper
|
|
600
|
+
* Standard API response wrapper with typed errors
|
|
601
|
+
* Replaces string errors with structured ApiErrorResponse
|
|
193
602
|
*/
|
|
194
603
|
interface ApiResponse<T> {
|
|
195
604
|
data?: T;
|
|
196
|
-
error
|
|
605
|
+
/** Structured error response for programmatic handling */
|
|
606
|
+
error?: ApiErrorResponse;
|
|
607
|
+
/** Optional success message */
|
|
197
608
|
message?: string;
|
|
609
|
+
/** Request metadata */
|
|
610
|
+
meta?: {
|
|
611
|
+
requestId?: string;
|
|
612
|
+
duration?: number;
|
|
613
|
+
retries?: number;
|
|
614
|
+
};
|
|
198
615
|
}
|
|
199
616
|
/**
|
|
200
|
-
*
|
|
617
|
+
* Helper to check if response has error
|
|
201
618
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
619
|
+
declare function hasError<T>(response: ApiResponse<T>): response is ApiResponse<T> & {
|
|
620
|
+
error: ApiErrorResponse;
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* Helper to check if response has data
|
|
624
|
+
*/
|
|
625
|
+
declare function hasData<T>(response: ApiResponse<T>): response is ApiResponse<T> & {
|
|
626
|
+
data: T;
|
|
627
|
+
};
|
|
208
628
|
/**
|
|
209
629
|
* Paginated response for list operations
|
|
210
630
|
*/
|
|
@@ -233,9 +653,13 @@ declare class CoreMemoryClient {
|
|
|
233
653
|
*/
|
|
234
654
|
private enrichWithOrgContext;
|
|
235
655
|
/**
|
|
236
|
-
* Make an HTTP request to the API
|
|
656
|
+
* Make an HTTP request to the API with retry support
|
|
237
657
|
*/
|
|
238
658
|
private request;
|
|
659
|
+
/**
|
|
660
|
+
* Validate input using Zod schema and return validation error if invalid
|
|
661
|
+
*/
|
|
662
|
+
private validateInput;
|
|
239
663
|
/**
|
|
240
664
|
* Test the API connection and authentication
|
|
241
665
|
*/
|
|
@@ -244,7 +668,7 @@ declare class CoreMemoryClient {
|
|
|
244
668
|
timestamp: string;
|
|
245
669
|
}>>;
|
|
246
670
|
/**
|
|
247
|
-
* Create a new memory
|
|
671
|
+
* Create a new memory with validation
|
|
248
672
|
*/
|
|
249
673
|
createMemory(memory: CreateMemoryRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
250
674
|
/**
|
|
@@ -252,7 +676,7 @@ declare class CoreMemoryClient {
|
|
|
252
676
|
*/
|
|
253
677
|
getMemory(id: string): Promise<ApiResponse<MemoryEntry>>;
|
|
254
678
|
/**
|
|
255
|
-
* Update an existing memory
|
|
679
|
+
* Update an existing memory with validation
|
|
256
680
|
*/
|
|
257
681
|
updateMemory(id: string, updates: UpdateMemoryRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
258
682
|
/**
|
|
@@ -274,7 +698,7 @@ declare class CoreMemoryClient {
|
|
|
274
698
|
order?: 'asc' | 'desc';
|
|
275
699
|
}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>>;
|
|
276
700
|
/**
|
|
277
|
-
* Search memories using semantic search
|
|
701
|
+
* Search memories using semantic search with validation
|
|
278
702
|
*/
|
|
279
703
|
searchMemories(request: SearchMemoryRequest): Promise<ApiResponse<{
|
|
280
704
|
results: MemorySearchResult[];
|
|
@@ -289,7 +713,7 @@ declare class CoreMemoryClient {
|
|
|
289
713
|
failed_ids: string[];
|
|
290
714
|
}>>;
|
|
291
715
|
/**
|
|
292
|
-
* Create a new topic
|
|
716
|
+
* Create a new topic with validation
|
|
293
717
|
*/
|
|
294
718
|
createTopic(topic: CreateTopicRequest): Promise<ApiResponse<MemoryTopic>>;
|
|
295
719
|
/**
|
|
@@ -312,6 +736,122 @@ declare class CoreMemoryClient {
|
|
|
312
736
|
* Get user memory statistics
|
|
313
737
|
*/
|
|
314
738
|
getMemoryStats(): Promise<ApiResponse<UserMemoryStats>>;
|
|
739
|
+
/**
|
|
740
|
+
* Create a memory with preprocessing options (chunking, intelligence extraction)
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* ```typescript
|
|
744
|
+
* const result = await client.createMemoryWithPreprocessing({
|
|
745
|
+
* title: 'Auth System Docs',
|
|
746
|
+
* content: 'Long content...',
|
|
747
|
+
* memory_type: 'knowledge',
|
|
748
|
+
* preprocessing: {
|
|
749
|
+
* chunking: { strategy: 'semantic', maxChunkSize: 1000 },
|
|
750
|
+
* extractMetadata: true
|
|
751
|
+
* }
|
|
752
|
+
* });
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
createMemoryWithPreprocessing(memory: CreateMemoryWithPreprocessingRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
756
|
+
/**
|
|
757
|
+
* Update a memory with re-chunking and embedding regeneration
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const result = await client.updateMemoryWithPreprocessing('mem_123', {
|
|
762
|
+
* content: 'Updated content...',
|
|
763
|
+
* rechunk: true,
|
|
764
|
+
* regenerate_embedding: true
|
|
765
|
+
* });
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
updateMemoryWithPreprocessing(id: string, updates: UpdateMemoryWithPreprocessingRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
769
|
+
/**
|
|
770
|
+
* Enhanced semantic search with hybrid mode (vector + text)
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```typescript
|
|
774
|
+
* const result = await client.enhancedSearch({
|
|
775
|
+
* query: 'authentication flow',
|
|
776
|
+
* search_mode: 'hybrid',
|
|
777
|
+
* filters: { tags: ['auth'], project_id: 'proj_123' },
|
|
778
|
+
* include_chunks: true
|
|
779
|
+
* });
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
enhancedSearch(request: EnhancedSearchRequest): Promise<ApiResponse<EnhancedSearchResponse>>;
|
|
783
|
+
/**
|
|
784
|
+
* Get search analytics data
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* const analytics = await client.getSearchAnalytics({
|
|
789
|
+
* from: '2025-01-01',
|
|
790
|
+
* to: '2025-12-31',
|
|
791
|
+
* group_by: 'day'
|
|
792
|
+
* });
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
getSearchAnalytics(options?: AnalyticsDateRange): Promise<ApiResponse<SearchAnalytics>>;
|
|
796
|
+
/**
|
|
797
|
+
* Get memory access patterns
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* ```typescript
|
|
801
|
+
* const patterns = await client.getAccessPatterns({
|
|
802
|
+
* from: '2025-01-01',
|
|
803
|
+
* to: '2025-12-31'
|
|
804
|
+
* });
|
|
805
|
+
* console.log(patterns.data?.most_accessed);
|
|
806
|
+
* ```
|
|
807
|
+
*/
|
|
808
|
+
getAccessPatterns(options?: AnalyticsDateRange): Promise<ApiResponse<AccessPatterns>>;
|
|
809
|
+
/**
|
|
810
|
+
* Get extended memory statistics with storage and activity metrics
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const stats = await client.getExtendedStats();
|
|
815
|
+
* console.log(`Total chunks: ${stats.data?.storage.total_chunks}`);
|
|
816
|
+
* console.log(`Created today: ${stats.data?.activity.created_today}`);
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
getExtendedStats(): Promise<ApiResponse<ExtendedMemoryStats>>;
|
|
820
|
+
/**
|
|
821
|
+
* Get topic with its memories
|
|
822
|
+
*
|
|
823
|
+
* @example
|
|
824
|
+
* ```typescript
|
|
825
|
+
* const topic = await client.getTopicWithMemories('topic_123');
|
|
826
|
+
* console.log(topic.data?.memories);
|
|
827
|
+
* ```
|
|
828
|
+
*/
|
|
829
|
+
getTopicWithMemories(topicId: string, options?: {
|
|
830
|
+
limit?: number;
|
|
831
|
+
offset?: number;
|
|
832
|
+
}): Promise<ApiResponse<{
|
|
833
|
+
topic: MemoryTopic;
|
|
834
|
+
memories: MemoryEntry[];
|
|
835
|
+
total_memories: number;
|
|
836
|
+
subtopics: Array<{
|
|
837
|
+
id: string;
|
|
838
|
+
name: string;
|
|
839
|
+
memory_count: number;
|
|
840
|
+
}>;
|
|
841
|
+
}>>;
|
|
842
|
+
/**
|
|
843
|
+
* Get topics in hierarchical structure
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```typescript
|
|
847
|
+
* const topics = await client.getTopicsHierarchy();
|
|
848
|
+
* // Returns nested topic tree with children
|
|
849
|
+
* ```
|
|
850
|
+
*/
|
|
851
|
+
getTopicsHierarchy(): Promise<ApiResponse<Array<MemoryTopic & {
|
|
852
|
+
children: MemoryTopic[];
|
|
853
|
+
memory_count: number;
|
|
854
|
+
}>>>;
|
|
315
855
|
/**
|
|
316
856
|
* Update authentication token
|
|
317
857
|
*/
|
|
@@ -339,54 +879,41 @@ declare class CoreMemoryClient {
|
|
|
339
879
|
declare function createMemoryClient(config: CoreMemoryClientConfig): CoreMemoryClient;
|
|
340
880
|
|
|
341
881
|
/**
|
|
342
|
-
*
|
|
882
|
+
* Core Utilities for Memory Client
|
|
343
883
|
* Browser-safe, no Node.js dependencies
|
|
344
884
|
*/
|
|
885
|
+
|
|
345
886
|
/**
|
|
346
|
-
*
|
|
347
|
-
*/
|
|
348
|
-
declare class MemoryClientError extends Error {
|
|
349
|
-
code?: string | undefined;
|
|
350
|
-
statusCode?: number | undefined;
|
|
351
|
-
details?: unknown | undefined;
|
|
352
|
-
constructor(message: string, code?: string | undefined, statusCode?: number | undefined, details?: unknown | undefined);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Network/API error
|
|
887
|
+
* Safe JSON parse result - discriminated union for type-safe error handling
|
|
356
888
|
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
889
|
+
type SafeJsonResult<T> = {
|
|
890
|
+
success: true;
|
|
891
|
+
data: T;
|
|
892
|
+
} | {
|
|
893
|
+
success: false;
|
|
894
|
+
error: string;
|
|
895
|
+
};
|
|
360
896
|
/**
|
|
361
|
-
*
|
|
897
|
+
* Safely parse JSON with detailed error reporting
|
|
898
|
+
* Prevents scattered try/catch blocks throughout the codebase
|
|
362
899
|
*/
|
|
363
|
-
declare
|
|
364
|
-
constructor(message?: string);
|
|
365
|
-
}
|
|
900
|
+
declare function safeJsonParse<T = unknown>(input: string): SafeJsonResult<T>;
|
|
366
901
|
/**
|
|
367
|
-
*
|
|
902
|
+
* HTTP status code to error code mapping
|
|
368
903
|
*/
|
|
369
|
-
declare
|
|
370
|
-
constructor(message: string, details?: unknown);
|
|
371
|
-
}
|
|
904
|
+
declare function httpStatusToErrorCode(status: number): ErrorCode;
|
|
372
905
|
/**
|
|
373
|
-
*
|
|
906
|
+
* Create a standardized error response from various error sources
|
|
374
907
|
*/
|
|
375
|
-
declare
|
|
376
|
-
constructor(message?: string);
|
|
377
|
-
}
|
|
908
|
+
declare function createErrorResponse(message: string, code?: ErrorCode, statusCode?: number, details?: unknown): ApiErrorResponse;
|
|
378
909
|
/**
|
|
379
|
-
*
|
|
910
|
+
* Calculate retry delay with exponential backoff and jitter
|
|
380
911
|
*/
|
|
381
|
-
declare
|
|
382
|
-
constructor(message?: string);
|
|
383
|
-
}
|
|
912
|
+
declare function calculateRetryDelay(attempt: number, baseDelay?: number, backoff?: 'linear' | 'exponential', maxDelay?: number): number;
|
|
384
913
|
/**
|
|
385
|
-
*
|
|
914
|
+
* Check if an error is retryable based on status code
|
|
386
915
|
*/
|
|
387
|
-
declare
|
|
388
|
-
constructor(resource: string);
|
|
389
|
-
}
|
|
916
|
+
declare function isRetryableError(statusCode?: number): boolean;
|
|
390
917
|
|
|
391
918
|
/**
|
|
392
919
|
* @lanonasis/memory-client/core
|
|
@@ -417,5 +944,5 @@ declare const defaultConfigs: {
|
|
|
417
944
|
};
|
|
418
945
|
};
|
|
419
946
|
|
|
420
|
-
export { ApiError
|
|
421
|
-
export type {
|
|
947
|
+
export { ApiError, AuthenticationError, CHUNKING_STRATEGIES, CLIENT_NAME, CONTENT_TYPES, CoreMemoryClient, ERROR_CODES, MEMORY_STATUSES, MEMORY_TYPES, MemoryClientError, NetworkError, NotFoundError, RateLimitError, SEARCH_MODES, ServerError, TimeoutError, VERSION, ValidationError, analyticsDateRangeSchema, calculateRetryDelay, createErrorFromStatus, createErrorResponse, createMemoryClient, createMemorySchema, createTopicSchema, defaultConfigs, enhancedSearchSchema, hasData, hasError, httpStatusToErrorCode, isApiErrorResponse, isBrowser, isNode, isRetryableError, preprocessingOptionsSchema, safeJsonParse, searchMemorySchema, updateMemorySchema };
|
|
948
|
+
export type { AccessPatterns, AnalyticsDateRange, ApiErrorResponse, ApiResponse, ChunkingStrategy, ContentChunk, ContentType, CoreMemoryClientConfig, CreateMemoryRequest, CreateMemoryWithPreprocessingRequest, CreateTopicRequest, EnhancedMemorySearchResult, EnhancedSearchRequest, EnhancedSearchResponse, ErrorCode, ExtendedMemoryStats, HourlyAccess, IntelligentMetadata, MatchingChunk, MemoryEntry, MemoryIntelligence, MemorySearchResult, MemoryStatus, MemoryTopic, MemoryType, MostAccessedMemory, PaginatedResponse, PopularQuery, PreprocessingOptions, ProjectMemoryCount, SafeJsonResult, SearchAnalytics, SearchAnalyticsDataPoint, SearchFilters, SearchMemoryRequest, SearchMode, TagCount, UpdateMemoryRequest, UpdateMemoryWithPreprocessingRequest, UserMemoryStats };
|