@lanonasis/memory-client 1.0.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/LICENSE +21 -0
- package/README.md +387 -0
- package/dist/index.d.ts +679 -0
- package/dist/index.esm.js +1031 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1052 -0
- package/dist/index.js.map +1 -0
- package/package.json +96 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Memory types supported by the service
|
|
5
|
+
*/
|
|
6
|
+
declare const MEMORY_TYPES: readonly ["context", "project", "knowledge", "reference", "personal", "workflow"];
|
|
7
|
+
type MemoryType = typeof MEMORY_TYPES[number];
|
|
8
|
+
/**
|
|
9
|
+
* Memory status values
|
|
10
|
+
*/
|
|
11
|
+
declare const MEMORY_STATUSES: readonly ["active", "archived", "draft", "deleted"];
|
|
12
|
+
type MemoryStatus = typeof MEMORY_STATUSES[number];
|
|
13
|
+
/**
|
|
14
|
+
* Core memory entry interface
|
|
15
|
+
*/
|
|
16
|
+
interface MemoryEntry {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
content: string;
|
|
20
|
+
summary?: string;
|
|
21
|
+
memory_type: MemoryType;
|
|
22
|
+
status: MemoryStatus;
|
|
23
|
+
relevance_score?: number;
|
|
24
|
+
access_count: number;
|
|
25
|
+
last_accessed?: string;
|
|
26
|
+
user_id: string;
|
|
27
|
+
topic_id?: string;
|
|
28
|
+
project_ref?: string;
|
|
29
|
+
tags: string[];
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
created_at: string;
|
|
32
|
+
updated_at: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Memory topic for organization
|
|
36
|
+
*/
|
|
37
|
+
interface MemoryTopic {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
color?: string;
|
|
42
|
+
icon?: string;
|
|
43
|
+
user_id: string;
|
|
44
|
+
parent_topic_id?: string;
|
|
45
|
+
is_system: boolean;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
created_at: string;
|
|
48
|
+
updated_at: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Memory search result with similarity score
|
|
52
|
+
*/
|
|
53
|
+
interface MemorySearchResult extends MemoryEntry {
|
|
54
|
+
similarity_score: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* User memory statistics
|
|
58
|
+
*/
|
|
59
|
+
interface UserMemoryStats {
|
|
60
|
+
total_memories: number;
|
|
61
|
+
memories_by_type: Record<MemoryType, number>;
|
|
62
|
+
total_topics: number;
|
|
63
|
+
most_accessed_memory?: string;
|
|
64
|
+
recent_memories: string[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validation schemas using Zod
|
|
68
|
+
*/
|
|
69
|
+
declare const createMemorySchema: z.ZodObject<{
|
|
70
|
+
title: z.ZodString;
|
|
71
|
+
content: z.ZodString;
|
|
72
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
73
|
+
memory_type: z.ZodDefault<z.ZodEnum<["context", "project", "knowledge", "reference", "personal", "workflow"]>>;
|
|
74
|
+
topic_id: z.ZodOptional<z.ZodString>;
|
|
75
|
+
project_ref: z.ZodOptional<z.ZodString>;
|
|
76
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
77
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
title: string;
|
|
80
|
+
content: string;
|
|
81
|
+
memory_type: "context" | "project" | "knowledge" | "reference" | "personal" | "workflow";
|
|
82
|
+
tags: string[];
|
|
83
|
+
summary?: string | undefined;
|
|
84
|
+
topic_id?: string | undefined;
|
|
85
|
+
project_ref?: string | undefined;
|
|
86
|
+
metadata?: Record<string, unknown> | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
title: string;
|
|
89
|
+
content: string;
|
|
90
|
+
summary?: string | undefined;
|
|
91
|
+
memory_type?: "context" | "project" | "knowledge" | "reference" | "personal" | "workflow" | undefined;
|
|
92
|
+
topic_id?: string | undefined;
|
|
93
|
+
project_ref?: string | undefined;
|
|
94
|
+
tags?: string[] | undefined;
|
|
95
|
+
metadata?: Record<string, unknown> | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
declare const updateMemorySchema: z.ZodObject<{
|
|
98
|
+
title: z.ZodOptional<z.ZodString>;
|
|
99
|
+
content: z.ZodOptional<z.ZodString>;
|
|
100
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
101
|
+
memory_type: z.ZodOptional<z.ZodEnum<["context", "project", "knowledge", "reference", "personal", "workflow"]>>;
|
|
102
|
+
status: z.ZodOptional<z.ZodEnum<["active", "archived", "draft", "deleted"]>>;
|
|
103
|
+
topic_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
104
|
+
project_ref: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
106
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
title?: string | undefined;
|
|
109
|
+
content?: string | undefined;
|
|
110
|
+
summary?: string | undefined;
|
|
111
|
+
memory_type?: "context" | "project" | "knowledge" | "reference" | "personal" | "workflow" | undefined;
|
|
112
|
+
topic_id?: string | null | undefined;
|
|
113
|
+
project_ref?: string | null | undefined;
|
|
114
|
+
status?: "active" | "archived" | "draft" | "deleted" | undefined;
|
|
115
|
+
tags?: string[] | undefined;
|
|
116
|
+
metadata?: Record<string, unknown> | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
title?: string | undefined;
|
|
119
|
+
content?: string | undefined;
|
|
120
|
+
summary?: string | undefined;
|
|
121
|
+
memory_type?: "context" | "project" | "knowledge" | "reference" | "personal" | "workflow" | undefined;
|
|
122
|
+
topic_id?: string | null | undefined;
|
|
123
|
+
project_ref?: string | null | undefined;
|
|
124
|
+
status?: "active" | "archived" | "draft" | "deleted" | undefined;
|
|
125
|
+
tags?: string[] | undefined;
|
|
126
|
+
metadata?: Record<string, unknown> | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
declare const searchMemorySchema: z.ZodObject<{
|
|
129
|
+
query: z.ZodString;
|
|
130
|
+
memory_types: z.ZodOptional<z.ZodArray<z.ZodEnum<["context", "project", "knowledge", "reference", "personal", "workflow"]>, "many">>;
|
|
131
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
132
|
+
topic_id: z.ZodOptional<z.ZodString>;
|
|
133
|
+
project_ref: z.ZodOptional<z.ZodString>;
|
|
134
|
+
status: z.ZodDefault<z.ZodEnum<["active", "archived", "draft", "deleted"]>>;
|
|
135
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
136
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
status: "active" | "archived" | "draft" | "deleted";
|
|
139
|
+
query: string;
|
|
140
|
+
limit: number;
|
|
141
|
+
threshold: number;
|
|
142
|
+
topic_id?: string | undefined;
|
|
143
|
+
project_ref?: string | undefined;
|
|
144
|
+
tags?: string[] | undefined;
|
|
145
|
+
memory_types?: ("context" | "project" | "knowledge" | "reference" | "personal" | "workflow")[] | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
query: string;
|
|
148
|
+
topic_id?: string | undefined;
|
|
149
|
+
project_ref?: string | undefined;
|
|
150
|
+
status?: "active" | "archived" | "draft" | "deleted" | undefined;
|
|
151
|
+
tags?: string[] | undefined;
|
|
152
|
+
memory_types?: ("context" | "project" | "knowledge" | "reference" | "personal" | "workflow")[] | undefined;
|
|
153
|
+
limit?: number | undefined;
|
|
154
|
+
threshold?: number | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
declare const createTopicSchema: z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
description: z.ZodOptional<z.ZodString>;
|
|
159
|
+
color: z.ZodOptional<z.ZodString>;
|
|
160
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
161
|
+
parent_topic_id: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
name: string;
|
|
164
|
+
description?: string | undefined;
|
|
165
|
+
color?: string | undefined;
|
|
166
|
+
icon?: string | undefined;
|
|
167
|
+
parent_topic_id?: string | undefined;
|
|
168
|
+
}, {
|
|
169
|
+
name: string;
|
|
170
|
+
description?: string | undefined;
|
|
171
|
+
color?: string | undefined;
|
|
172
|
+
icon?: string | undefined;
|
|
173
|
+
parent_topic_id?: string | undefined;
|
|
174
|
+
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Inferred types from schemas
|
|
177
|
+
*/
|
|
178
|
+
type CreateMemoryRequest = z.infer<typeof createMemorySchema>;
|
|
179
|
+
type UpdateMemoryRequest = z.infer<typeof updateMemorySchema>;
|
|
180
|
+
type SearchMemoryRequest = z.infer<typeof searchMemorySchema>;
|
|
181
|
+
type CreateTopicRequest = z.infer<typeof createTopicSchema>;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Configuration options for the Memory Client
|
|
185
|
+
*/
|
|
186
|
+
interface MemoryClientConfig {
|
|
187
|
+
/** API endpoint URL */
|
|
188
|
+
apiUrl: string;
|
|
189
|
+
/** API key for authentication */
|
|
190
|
+
apiKey?: string;
|
|
191
|
+
/** Bearer token for authentication (alternative to API key) */
|
|
192
|
+
authToken?: string;
|
|
193
|
+
/** Request timeout in milliseconds */
|
|
194
|
+
timeout?: number;
|
|
195
|
+
/** Enable gateway mode for enhanced performance */
|
|
196
|
+
useGateway?: boolean;
|
|
197
|
+
/** Custom headers to include with requests */
|
|
198
|
+
headers?: Record<string, string>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Standard API response wrapper
|
|
202
|
+
*/
|
|
203
|
+
interface ApiResponse<T> {
|
|
204
|
+
data?: T;
|
|
205
|
+
error?: string;
|
|
206
|
+
message?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Paginated response for list operations
|
|
210
|
+
*/
|
|
211
|
+
interface PaginatedResponse<T> {
|
|
212
|
+
data: T[];
|
|
213
|
+
pagination: {
|
|
214
|
+
page: number;
|
|
215
|
+
limit: number;
|
|
216
|
+
total: number;
|
|
217
|
+
pages: number;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Memory Client class for interacting with the Memory as a Service API
|
|
222
|
+
*/
|
|
223
|
+
declare class MemoryClient {
|
|
224
|
+
private config;
|
|
225
|
+
private baseHeaders;
|
|
226
|
+
constructor(config: MemoryClientConfig);
|
|
227
|
+
/**
|
|
228
|
+
* Make an HTTP request to the API
|
|
229
|
+
*/
|
|
230
|
+
private request;
|
|
231
|
+
/**
|
|
232
|
+
* Test the API connection and authentication
|
|
233
|
+
*/
|
|
234
|
+
healthCheck(): Promise<ApiResponse<{
|
|
235
|
+
status: string;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
}>>;
|
|
238
|
+
/**
|
|
239
|
+
* Create a new memory
|
|
240
|
+
*/
|
|
241
|
+
createMemory(memory: CreateMemoryRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
242
|
+
/**
|
|
243
|
+
* Get a memory by ID
|
|
244
|
+
*/
|
|
245
|
+
getMemory(id: string): Promise<ApiResponse<MemoryEntry>>;
|
|
246
|
+
/**
|
|
247
|
+
* Update an existing memory
|
|
248
|
+
*/
|
|
249
|
+
updateMemory(id: string, updates: UpdateMemoryRequest): Promise<ApiResponse<MemoryEntry>>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete a memory
|
|
252
|
+
*/
|
|
253
|
+
deleteMemory(id: string): Promise<ApiResponse<void>>;
|
|
254
|
+
/**
|
|
255
|
+
* List memories with optional filtering and pagination
|
|
256
|
+
*/
|
|
257
|
+
listMemories(options?: {
|
|
258
|
+
page?: number;
|
|
259
|
+
limit?: number;
|
|
260
|
+
memory_type?: string;
|
|
261
|
+
topic_id?: string;
|
|
262
|
+
project_ref?: string;
|
|
263
|
+
status?: string;
|
|
264
|
+
tags?: string[];
|
|
265
|
+
sort?: string;
|
|
266
|
+
order?: 'asc' | 'desc';
|
|
267
|
+
}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>>;
|
|
268
|
+
/**
|
|
269
|
+
* Search memories using semantic search
|
|
270
|
+
*/
|
|
271
|
+
searchMemories(request: SearchMemoryRequest): Promise<ApiResponse<{
|
|
272
|
+
results: MemorySearchResult[];
|
|
273
|
+
total_results: number;
|
|
274
|
+
search_time_ms: number;
|
|
275
|
+
}>>;
|
|
276
|
+
/**
|
|
277
|
+
* Bulk delete multiple memories
|
|
278
|
+
*/
|
|
279
|
+
bulkDeleteMemories(memoryIds: string[]): Promise<ApiResponse<{
|
|
280
|
+
deleted_count: number;
|
|
281
|
+
failed_ids: string[];
|
|
282
|
+
}>>;
|
|
283
|
+
/**
|
|
284
|
+
* Create a new topic
|
|
285
|
+
*/
|
|
286
|
+
createTopic(topic: CreateTopicRequest): Promise<ApiResponse<MemoryTopic>>;
|
|
287
|
+
/**
|
|
288
|
+
* Get all topics
|
|
289
|
+
*/
|
|
290
|
+
getTopics(): Promise<ApiResponse<MemoryTopic[]>>;
|
|
291
|
+
/**
|
|
292
|
+
* Get a topic by ID
|
|
293
|
+
*/
|
|
294
|
+
getTopic(id: string): Promise<ApiResponse<MemoryTopic>>;
|
|
295
|
+
/**
|
|
296
|
+
* Update a topic
|
|
297
|
+
*/
|
|
298
|
+
updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<ApiResponse<MemoryTopic>>;
|
|
299
|
+
/**
|
|
300
|
+
* Delete a topic
|
|
301
|
+
*/
|
|
302
|
+
deleteTopic(id: string): Promise<ApiResponse<void>>;
|
|
303
|
+
/**
|
|
304
|
+
* Get user memory statistics
|
|
305
|
+
*/
|
|
306
|
+
getMemoryStats(): Promise<ApiResponse<UserMemoryStats>>;
|
|
307
|
+
/**
|
|
308
|
+
* Update authentication token
|
|
309
|
+
*/
|
|
310
|
+
setAuthToken(token: string): void;
|
|
311
|
+
/**
|
|
312
|
+
* Update API key
|
|
313
|
+
*/
|
|
314
|
+
setApiKey(apiKey: string): void;
|
|
315
|
+
/**
|
|
316
|
+
* Clear authentication
|
|
317
|
+
*/
|
|
318
|
+
clearAuth(): void;
|
|
319
|
+
/**
|
|
320
|
+
* Update configuration
|
|
321
|
+
*/
|
|
322
|
+
updateConfig(updates: Partial<MemoryClientConfig>): void;
|
|
323
|
+
/**
|
|
324
|
+
* Get current configuration (excluding sensitive data)
|
|
325
|
+
*/
|
|
326
|
+
getConfig(): Omit<MemoryClientConfig, 'apiKey' | 'authToken'>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Factory function to create a new Memory Client instance
|
|
330
|
+
*/
|
|
331
|
+
declare function createMemoryClient(config: MemoryClientConfig): MemoryClient;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* CLI Integration Module for Memory Client SDK
|
|
335
|
+
*
|
|
336
|
+
* Provides intelligent CLI detection and MCP channel utilization
|
|
337
|
+
* when @lanonasis/cli v1.5.2+ is available in the environment
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
interface CLIInfo {
|
|
341
|
+
available: boolean;
|
|
342
|
+
version?: string;
|
|
343
|
+
mcpAvailable?: boolean;
|
|
344
|
+
authenticated?: boolean;
|
|
345
|
+
}
|
|
346
|
+
interface CLIExecutionOptions {
|
|
347
|
+
timeout?: number;
|
|
348
|
+
verbose?: boolean;
|
|
349
|
+
outputFormat?: 'json' | 'table' | 'yaml';
|
|
350
|
+
}
|
|
351
|
+
interface CLICommand {
|
|
352
|
+
command: string;
|
|
353
|
+
args: string[];
|
|
354
|
+
options?: CLIExecutionOptions;
|
|
355
|
+
}
|
|
356
|
+
interface MCPChannel {
|
|
357
|
+
available: boolean;
|
|
358
|
+
version?: string;
|
|
359
|
+
capabilities?: string[];
|
|
360
|
+
}
|
|
361
|
+
interface CLICapabilities {
|
|
362
|
+
cliAvailable: boolean;
|
|
363
|
+
mcpSupport: boolean;
|
|
364
|
+
authenticated: boolean;
|
|
365
|
+
goldenContract: boolean;
|
|
366
|
+
version?: string;
|
|
367
|
+
}
|
|
368
|
+
type RoutingStrategy = 'cli-first' | 'api-first' | 'cli-only' | 'api-only' | 'auto';
|
|
369
|
+
/**
|
|
370
|
+
* CLI Detection and Integration Service
|
|
371
|
+
*/
|
|
372
|
+
declare class CLIIntegration {
|
|
373
|
+
private cliInfo;
|
|
374
|
+
private detectionPromise;
|
|
375
|
+
/**
|
|
376
|
+
* Detect if CLI is available and get its capabilities
|
|
377
|
+
*/
|
|
378
|
+
detectCLI(): Promise<CLIInfo>;
|
|
379
|
+
private performDetection;
|
|
380
|
+
/**
|
|
381
|
+
* Execute CLI command and return parsed JSON result
|
|
382
|
+
*/
|
|
383
|
+
executeCLICommand<T = any>(command: string, options?: CLIExecutionOptions): Promise<ApiResponse<T>>;
|
|
384
|
+
/**
|
|
385
|
+
* Get preferred CLI command (onasis for Golden Contract, fallback to lanonasis)
|
|
386
|
+
*/
|
|
387
|
+
private getPreferredCLICommand;
|
|
388
|
+
/**
|
|
389
|
+
* Memory operations via CLI
|
|
390
|
+
*/
|
|
391
|
+
createMemoryViaCLI(title: string, content: string, options?: {
|
|
392
|
+
memoryType?: string;
|
|
393
|
+
tags?: string[];
|
|
394
|
+
topicId?: string;
|
|
395
|
+
}): Promise<ApiResponse<any>>;
|
|
396
|
+
listMemoriesViaCLI(options?: {
|
|
397
|
+
limit?: number;
|
|
398
|
+
memoryType?: string;
|
|
399
|
+
tags?: string[];
|
|
400
|
+
sortBy?: string;
|
|
401
|
+
}): Promise<ApiResponse<any>>;
|
|
402
|
+
searchMemoriesViaCLI(query: string, options?: {
|
|
403
|
+
limit?: number;
|
|
404
|
+
memoryTypes?: string[];
|
|
405
|
+
}): Promise<ApiResponse<any>>;
|
|
406
|
+
/**
|
|
407
|
+
* Health check via CLI
|
|
408
|
+
*/
|
|
409
|
+
healthCheckViaCLI(): Promise<ApiResponse<any>>;
|
|
410
|
+
/**
|
|
411
|
+
* MCP-specific operations
|
|
412
|
+
*/
|
|
413
|
+
getMCPStatus(): Promise<ApiResponse<any>>;
|
|
414
|
+
listMCPTools(): Promise<ApiResponse<any>>;
|
|
415
|
+
/**
|
|
416
|
+
* Authentication operations
|
|
417
|
+
*/
|
|
418
|
+
getAuthStatus(): Promise<ApiResponse<any>>;
|
|
419
|
+
/**
|
|
420
|
+
* Check if specific CLI features are available
|
|
421
|
+
*/
|
|
422
|
+
getCapabilities(): Promise<{
|
|
423
|
+
cliAvailable: boolean;
|
|
424
|
+
version?: string;
|
|
425
|
+
mcpSupport: boolean;
|
|
426
|
+
authenticated: boolean;
|
|
427
|
+
goldenContract: boolean;
|
|
428
|
+
}>;
|
|
429
|
+
private isGoldenContractCompliant;
|
|
430
|
+
/**
|
|
431
|
+
* Force refresh CLI detection
|
|
432
|
+
*/
|
|
433
|
+
refresh(): Promise<CLIInfo>;
|
|
434
|
+
/**
|
|
435
|
+
* Get cached CLI info without re-detection
|
|
436
|
+
*/
|
|
437
|
+
getCachedInfo(): CLIInfo | null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Enhanced Memory Client with CLI Integration
|
|
442
|
+
*
|
|
443
|
+
* Intelligently routes requests through CLI v1.5.2+ when available,
|
|
444
|
+
* with fallback to direct API for maximum compatibility and performance
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
interface EnhancedMemoryClientConfig extends MemoryClientConfig {
|
|
448
|
+
/** Prefer CLI when available (default: true) */
|
|
449
|
+
preferCLI?: boolean;
|
|
450
|
+
/** Enable MCP channels when available (default: true) */
|
|
451
|
+
enableMCP?: boolean;
|
|
452
|
+
/** CLI detection timeout in ms (default: 5000) */
|
|
453
|
+
cliDetectionTimeout?: number;
|
|
454
|
+
/** Fallback to direct API on CLI failure (default: true) */
|
|
455
|
+
fallbackToAPI?: boolean;
|
|
456
|
+
/** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */
|
|
457
|
+
minCLIVersion?: string;
|
|
458
|
+
/** Enable verbose logging for troubleshooting (default: false) */
|
|
459
|
+
verbose?: boolean;
|
|
460
|
+
}
|
|
461
|
+
interface OperationResult<T> {
|
|
462
|
+
data?: T;
|
|
463
|
+
error?: string;
|
|
464
|
+
source: 'cli' | 'api';
|
|
465
|
+
mcpUsed?: boolean;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Enhanced Memory Client with intelligent CLI/API routing
|
|
469
|
+
*/
|
|
470
|
+
declare class EnhancedMemoryClient {
|
|
471
|
+
private directClient;
|
|
472
|
+
private cliIntegration;
|
|
473
|
+
private config;
|
|
474
|
+
private capabilities;
|
|
475
|
+
private createDefaultCapabilities;
|
|
476
|
+
constructor(config: EnhancedMemoryClientConfig);
|
|
477
|
+
/**
|
|
478
|
+
* Initialize the client and detect capabilities
|
|
479
|
+
*/
|
|
480
|
+
initialize(): Promise<void>;
|
|
481
|
+
/**
|
|
482
|
+
* Get current capabilities
|
|
483
|
+
*/
|
|
484
|
+
getCapabilities(): Promise<Awaited<ReturnType<CLIIntegration['getCapabilities']>>>;
|
|
485
|
+
/**
|
|
486
|
+
* Determine if operation should use CLI
|
|
487
|
+
*/
|
|
488
|
+
private shouldUseCLI;
|
|
489
|
+
/**
|
|
490
|
+
* Execute operation with intelligent routing
|
|
491
|
+
*/
|
|
492
|
+
private executeOperation;
|
|
493
|
+
/**
|
|
494
|
+
* Health check with intelligent routing
|
|
495
|
+
*/
|
|
496
|
+
healthCheck(): Promise<OperationResult<{
|
|
497
|
+
status: string;
|
|
498
|
+
timestamp: string;
|
|
499
|
+
}>>;
|
|
500
|
+
/**
|
|
501
|
+
* Create memory with CLI/API routing
|
|
502
|
+
*/
|
|
503
|
+
createMemory(memory: CreateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
|
|
504
|
+
/**
|
|
505
|
+
* List memories with intelligent routing
|
|
506
|
+
*/
|
|
507
|
+
listMemories(options?: {
|
|
508
|
+
page?: number;
|
|
509
|
+
limit?: number;
|
|
510
|
+
memory_type?: string;
|
|
511
|
+
topic_id?: string;
|
|
512
|
+
project_ref?: string;
|
|
513
|
+
status?: string;
|
|
514
|
+
tags?: string[];
|
|
515
|
+
sort?: string;
|
|
516
|
+
order?: 'asc' | 'desc';
|
|
517
|
+
}): Promise<OperationResult<any>>;
|
|
518
|
+
/**
|
|
519
|
+
* Search memories with MCP enhancement when available
|
|
520
|
+
*/
|
|
521
|
+
searchMemories(request: SearchMemoryRequest): Promise<OperationResult<{
|
|
522
|
+
results: MemorySearchResult[];
|
|
523
|
+
total_results: number;
|
|
524
|
+
search_time_ms: number;
|
|
525
|
+
}>>;
|
|
526
|
+
/**
|
|
527
|
+
* Get memory by ID (API only for now)
|
|
528
|
+
*/
|
|
529
|
+
getMemory(id: string): Promise<OperationResult<MemoryEntry>>;
|
|
530
|
+
/**
|
|
531
|
+
* Update memory (API only for now)
|
|
532
|
+
*/
|
|
533
|
+
updateMemory(id: string, updates: UpdateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
|
|
534
|
+
/**
|
|
535
|
+
* Delete memory (API only for now)
|
|
536
|
+
*/
|
|
537
|
+
deleteMemory(id: string): Promise<OperationResult<void>>;
|
|
538
|
+
createTopic(topic: any): Promise<OperationResult<MemoryTopic>>;
|
|
539
|
+
getTopics(): Promise<OperationResult<MemoryTopic[]>>;
|
|
540
|
+
getTopic(id: string): Promise<OperationResult<MemoryTopic>>;
|
|
541
|
+
updateTopic(id: string, updates: any): Promise<OperationResult<MemoryTopic>>;
|
|
542
|
+
deleteTopic(id: string): Promise<OperationResult<void>>;
|
|
543
|
+
/**
|
|
544
|
+
* Get memory statistics
|
|
545
|
+
*/
|
|
546
|
+
getMemoryStats(): Promise<OperationResult<UserMemoryStats>>;
|
|
547
|
+
/**
|
|
548
|
+
* Force CLI re-detection
|
|
549
|
+
*/
|
|
550
|
+
refreshCLIDetection(): Promise<void>;
|
|
551
|
+
/**
|
|
552
|
+
* Get authentication status from CLI
|
|
553
|
+
*/
|
|
554
|
+
getAuthStatus(): Promise<OperationResult<any>>;
|
|
555
|
+
/**
|
|
556
|
+
* Get MCP status when available
|
|
557
|
+
*/
|
|
558
|
+
getMCPStatus(): Promise<OperationResult<any>>;
|
|
559
|
+
/**
|
|
560
|
+
* Update authentication for both CLI and API client
|
|
561
|
+
*/
|
|
562
|
+
setAuthToken(token: string): void;
|
|
563
|
+
setApiKey(apiKey: string): void;
|
|
564
|
+
clearAuth(): void;
|
|
565
|
+
/**
|
|
566
|
+
* Update configuration
|
|
567
|
+
*/
|
|
568
|
+
updateConfig(updates: Partial<EnhancedMemoryClientConfig>): void;
|
|
569
|
+
/**
|
|
570
|
+
* Get configuration summary
|
|
571
|
+
*/
|
|
572
|
+
getConfigSummary(): {
|
|
573
|
+
apiUrl: string;
|
|
574
|
+
preferCLI: boolean;
|
|
575
|
+
enableMCP: boolean;
|
|
576
|
+
capabilities?: Awaited<ReturnType<CLIIntegration['getCapabilities']>>;
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Factory function to create an enhanced memory client
|
|
581
|
+
*/
|
|
582
|
+
declare function createEnhancedMemoryClient(config: EnhancedMemoryClientConfig): Promise<EnhancedMemoryClient>;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Configuration utilities for Memory Client SDK
|
|
586
|
+
* Provides smart defaults and environment detection for CLI/MCP integration
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
interface SmartConfigOptions {
|
|
590
|
+
/** Prefer CLI integration when available (default: true in Node.js environments) */
|
|
591
|
+
preferCLI?: boolean;
|
|
592
|
+
/** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */
|
|
593
|
+
minCLIVersion?: string;
|
|
594
|
+
/** Enable MCP channel detection (default: true) */
|
|
595
|
+
enableMCP?: boolean;
|
|
596
|
+
/** API fallback configuration */
|
|
597
|
+
apiConfig?: Partial<MemoryClientConfig>;
|
|
598
|
+
/** Timeout for CLI detection in milliseconds (default: 3000) */
|
|
599
|
+
cliDetectionTimeout?: number;
|
|
600
|
+
/** Enable verbose logging for troubleshooting (default: false) */
|
|
601
|
+
verbose?: boolean;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Environment detection utilities
|
|
605
|
+
*/
|
|
606
|
+
declare const Environment: {
|
|
607
|
+
isNode: string | false;
|
|
608
|
+
isBrowser: boolean;
|
|
609
|
+
isVSCode: boolean;
|
|
610
|
+
isCursor: boolean;
|
|
611
|
+
isWindsurf: boolean;
|
|
612
|
+
readonly isIDE: boolean;
|
|
613
|
+
readonly supportsCLI: boolean;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Create smart configuration with environment-aware defaults
|
|
617
|
+
*/
|
|
618
|
+
declare function createSmartConfig(baseConfig: Partial<MemoryClientConfig>, options?: SmartConfigOptions): EnhancedMemoryClientConfig;
|
|
619
|
+
/**
|
|
620
|
+
* Preset configurations for common scenarios
|
|
621
|
+
*/
|
|
622
|
+
declare const ConfigPresets: {
|
|
623
|
+
/**
|
|
624
|
+
* Development configuration with local API and CLI preference
|
|
625
|
+
*/
|
|
626
|
+
development: (apiKey?: string) => EnhancedMemoryClientConfig;
|
|
627
|
+
/**
|
|
628
|
+
* Production configuration optimized for performance
|
|
629
|
+
*/
|
|
630
|
+
production: (apiKey?: string) => EnhancedMemoryClientConfig;
|
|
631
|
+
/**
|
|
632
|
+
* IDE extension configuration with MCP prioritization
|
|
633
|
+
*/
|
|
634
|
+
ideExtension: (apiKey?: string) => EnhancedMemoryClientConfig;
|
|
635
|
+
/**
|
|
636
|
+
* Browser-only configuration (no CLI support)
|
|
637
|
+
*/
|
|
638
|
+
browserOnly: (apiKey?: string) => EnhancedMemoryClientConfig;
|
|
639
|
+
/**
|
|
640
|
+
* CLI-first configuration for server environments
|
|
641
|
+
*/
|
|
642
|
+
serverCLI: (apiKey?: string) => EnhancedMemoryClientConfig;
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* Migration helper for existing MemoryClient users
|
|
646
|
+
*/
|
|
647
|
+
declare function migrateToEnhanced(existingConfig: MemoryClientConfig, enhancementOptions?: SmartConfigOptions): EnhancedMemoryClientConfig;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* @lanonasis/memory-client
|
|
651
|
+
*
|
|
652
|
+
* Memory as a Service (MaaS) Client SDK for Lanonasis
|
|
653
|
+
* Intelligent memory management with semantic search capabilities
|
|
654
|
+
*/
|
|
655
|
+
|
|
656
|
+
declare const VERSION = "1.0.0";
|
|
657
|
+
declare const CLIENT_NAME = "@lanonasis/memory-client";
|
|
658
|
+
declare const isBrowser: boolean;
|
|
659
|
+
declare const isNode: string | false;
|
|
660
|
+
declare const defaultConfigs: {
|
|
661
|
+
readonly development: {
|
|
662
|
+
readonly apiUrl: "http://localhost:3001";
|
|
663
|
+
readonly timeout: 30000;
|
|
664
|
+
readonly useGateway: false;
|
|
665
|
+
};
|
|
666
|
+
readonly production: {
|
|
667
|
+
readonly apiUrl: "https://api.lanonasis.com";
|
|
668
|
+
readonly timeout: 15000;
|
|
669
|
+
readonly useGateway: true;
|
|
670
|
+
};
|
|
671
|
+
readonly gateway: {
|
|
672
|
+
readonly apiUrl: "https://api.lanonasis.com";
|
|
673
|
+
readonly timeout: 10000;
|
|
674
|
+
readonly useGateway: true;
|
|
675
|
+
};
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
export { CLIENT_NAME, CLIIntegration, ConfigPresets, EnhancedMemoryClient, Environment, MEMORY_STATUSES, MEMORY_TYPES, MemoryClient, VERSION, createEnhancedMemoryClient, createMemoryClient, createMemorySchema, createSmartConfig, createTopicSchema, defaultConfigs, isBrowser, isNode, migrateToEnhanced, searchMemorySchema, updateMemorySchema };
|
|
679
|
+
export type { ApiResponse, CLICapabilities, CLICommand, CLIInfo, CreateMemoryRequest, CreateTopicRequest, EnhancedMemoryClientConfig, MCPChannel, MemoryClientConfig, MemoryEntry, MemorySearchResult, MemoryStatus, MemoryTopic, MemoryType, OperationResult, PaginatedResponse, RoutingStrategy, SearchMemoryRequest, SmartConfigOptions, UpdateMemoryRequest, UserMemoryStats };
|