@lanonasis/memory-client 1.0.1 → 2.1.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 +948 -0
- package/dist/core/index.js +1027 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/tsconfig.tsbuildinfo +1 -0
- package/dist/index.d.ts +703 -352
- package/dist/index.esm.js +1070 -277
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1098 -283
- package/dist/index.js.map +1 -1
- package/dist/node/index.d.ts +329 -0
- package/dist/node/index.js +647 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/tsconfig.tsbuildinfo +1 -0
- package/dist/presets/index.d.ts +146 -0
- package/dist/presets/index.js +234 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/tsconfig.tsbuildinfo +1 -0
- package/dist/react/index.d.ts +235 -0
- package/dist/react/index.js +333 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vue/index.d.ts +316 -0
- package/dist/vue/index.js +341 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/tsconfig.tsbuildinfo +1 -0
- package/package.json +67 -13
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { ApiResponse, PaginatedResponse, CoreMemoryClientConfig } from '../core/client';
|
|
2
|
+
export { ApiResponse, PaginatedResponse } from '../core/client';
|
|
3
|
+
import { MemoryEntry, MemorySearchResult, CreateMemoryRequest, SearchMemoryRequest, UpdateMemoryRequest, CreateTopicRequest, MemoryTopic, UserMemoryStats } from '../core/types';
|
|
4
|
+
export { CreateMemoryRequest, CreateTopicRequest, MemoryEntry, MemorySearchResult, MemoryStatus, MemoryTopic, MemoryType, SearchMemoryRequest, UpdateMemoryRequest, UserMemoryStats } from '../core/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CLI Integration Module for Memory Client SDK
|
|
8
|
+
*
|
|
9
|
+
* Provides intelligent CLI detection and MCP channel utilization
|
|
10
|
+
* when @lanonasis/cli v1.5.2+ is available in the environment
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: This file imports Node.js modules and should only be used in Node.js environments
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface CLIInfo {
|
|
16
|
+
available: boolean;
|
|
17
|
+
version?: string;
|
|
18
|
+
mcpAvailable?: boolean;
|
|
19
|
+
authenticated?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface CLIExecutionOptions {
|
|
22
|
+
timeout?: number;
|
|
23
|
+
verbose?: boolean;
|
|
24
|
+
outputFormat?: 'json' | 'table' | 'yaml';
|
|
25
|
+
}
|
|
26
|
+
interface CLICommand {
|
|
27
|
+
command: string;
|
|
28
|
+
args: string[];
|
|
29
|
+
options?: CLIExecutionOptions;
|
|
30
|
+
}
|
|
31
|
+
interface MCPChannel {
|
|
32
|
+
available: boolean;
|
|
33
|
+
version?: string;
|
|
34
|
+
capabilities?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface CLICapabilities {
|
|
37
|
+
cliAvailable: boolean;
|
|
38
|
+
mcpSupport: boolean;
|
|
39
|
+
authenticated: boolean;
|
|
40
|
+
goldenContract: boolean;
|
|
41
|
+
version?: string;
|
|
42
|
+
}
|
|
43
|
+
type RoutingStrategy = 'cli-first' | 'api-first' | 'cli-only' | 'api-only' | 'auto';
|
|
44
|
+
interface CLIAuthStatus {
|
|
45
|
+
authenticated: boolean;
|
|
46
|
+
user?: {
|
|
47
|
+
id?: string;
|
|
48
|
+
email?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
scopes?: string[];
|
|
53
|
+
expiresAt?: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
interface CLIMCPStatus {
|
|
57
|
+
connected: boolean;
|
|
58
|
+
channel?: string;
|
|
59
|
+
endpoint?: string;
|
|
60
|
+
details?: Record<string, unknown>;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
interface CLIMCPTool {
|
|
64
|
+
name: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* CLI Detection and Integration Service
|
|
71
|
+
*/
|
|
72
|
+
declare class CLIIntegration {
|
|
73
|
+
private cliInfo;
|
|
74
|
+
private detectionPromise;
|
|
75
|
+
/**
|
|
76
|
+
* Detect if CLI is available and get its capabilities
|
|
77
|
+
*/
|
|
78
|
+
detectCLI(): Promise<CLIInfo>;
|
|
79
|
+
private performDetection;
|
|
80
|
+
/**
|
|
81
|
+
* Execute CLI command and return parsed JSON result
|
|
82
|
+
*/
|
|
83
|
+
executeCLICommand<T = unknown>(command: string, options?: CLIExecutionOptions): Promise<ApiResponse<T>>;
|
|
84
|
+
/**
|
|
85
|
+
* Get preferred CLI command (onasis for Golden Contract, fallback to lanonasis)
|
|
86
|
+
*/
|
|
87
|
+
private getPreferredCLICommand;
|
|
88
|
+
/**
|
|
89
|
+
* Memory operations via CLI
|
|
90
|
+
*/
|
|
91
|
+
createMemoryViaCLI(title: string, content: string, options?: {
|
|
92
|
+
memoryType?: string;
|
|
93
|
+
tags?: string[];
|
|
94
|
+
topicId?: string;
|
|
95
|
+
}): Promise<ApiResponse<MemoryEntry>>;
|
|
96
|
+
listMemoriesViaCLI(options?: {
|
|
97
|
+
limit?: number;
|
|
98
|
+
memoryType?: string;
|
|
99
|
+
tags?: string[];
|
|
100
|
+
sortBy?: string;
|
|
101
|
+
}): Promise<ApiResponse<PaginatedResponse<MemoryEntry>>>;
|
|
102
|
+
searchMemoriesViaCLI(query: string, options?: {
|
|
103
|
+
limit?: number;
|
|
104
|
+
memoryTypes?: string[];
|
|
105
|
+
}): Promise<ApiResponse<{
|
|
106
|
+
results: MemorySearchResult[];
|
|
107
|
+
total_results: number;
|
|
108
|
+
search_time_ms: number;
|
|
109
|
+
}>>;
|
|
110
|
+
/**
|
|
111
|
+
* Health check via CLI
|
|
112
|
+
*/
|
|
113
|
+
healthCheckViaCLI(): Promise<ApiResponse<{
|
|
114
|
+
status: string;
|
|
115
|
+
timestamp: string;
|
|
116
|
+
}>>;
|
|
117
|
+
/**
|
|
118
|
+
* MCP-specific operations
|
|
119
|
+
*/
|
|
120
|
+
getMCPStatus(): Promise<ApiResponse<CLIMCPStatus>>;
|
|
121
|
+
listMCPTools(): Promise<ApiResponse<{
|
|
122
|
+
tools: CLIMCPTool[];
|
|
123
|
+
}>>;
|
|
124
|
+
/**
|
|
125
|
+
* Authentication operations
|
|
126
|
+
*/
|
|
127
|
+
getAuthStatus(): Promise<ApiResponse<CLIAuthStatus>>;
|
|
128
|
+
/**
|
|
129
|
+
* Check if specific CLI features are available
|
|
130
|
+
*/
|
|
131
|
+
getCapabilities(): Promise<{
|
|
132
|
+
cliAvailable: boolean;
|
|
133
|
+
version?: string;
|
|
134
|
+
mcpSupport: boolean;
|
|
135
|
+
authenticated: boolean;
|
|
136
|
+
goldenContract: boolean;
|
|
137
|
+
}>;
|
|
138
|
+
private isGoldenContractCompliant;
|
|
139
|
+
/**
|
|
140
|
+
* Force refresh CLI detection
|
|
141
|
+
*/
|
|
142
|
+
refresh(): Promise<CLIInfo>;
|
|
143
|
+
/**
|
|
144
|
+
* Get cached CLI info without re-detection
|
|
145
|
+
*/
|
|
146
|
+
getCachedInfo(): CLIInfo | null;
|
|
147
|
+
}
|
|
148
|
+
declare const cliIntegration: CLIIntegration;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Error handling for Memory Client
|
|
152
|
+
* Browser-safe, no Node.js dependencies
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* Standardized error codes for programmatic error handling
|
|
156
|
+
*/
|
|
157
|
+
declare const ERROR_CODES: readonly ["API_ERROR", "AUTH_ERROR", "VALIDATION_ERROR", "TIMEOUT_ERROR", "RATE_LIMIT_ERROR", "NOT_FOUND", "NETWORK_ERROR", "FORBIDDEN", "CONFLICT", "SERVER_ERROR"];
|
|
158
|
+
type ErrorCode = typeof ERROR_CODES[number];
|
|
159
|
+
/**
|
|
160
|
+
* Structured API error response - replaces plain string errors
|
|
161
|
+
* Enables programmatic error handling with typed codes
|
|
162
|
+
*/
|
|
163
|
+
interface ApiErrorResponse {
|
|
164
|
+
/** Machine-readable error code for programmatic handling */
|
|
165
|
+
code: ErrorCode;
|
|
166
|
+
/** Human-readable error message */
|
|
167
|
+
message: string;
|
|
168
|
+
/** HTTP status code if from API response */
|
|
169
|
+
statusCode?: number;
|
|
170
|
+
/** Additional error details (validation errors, etc.) */
|
|
171
|
+
details?: unknown;
|
|
172
|
+
/** Request ID for debugging/support */
|
|
173
|
+
requestId?: string;
|
|
174
|
+
/** Timestamp when error occurred */
|
|
175
|
+
timestamp?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Enhanced Memory Client with CLI Integration
|
|
180
|
+
*
|
|
181
|
+
* Intelligently routes requests through CLI v1.5.2+ when available,
|
|
182
|
+
* with fallback to direct API for maximum compatibility and performance
|
|
183
|
+
*
|
|
184
|
+
* IMPORTANT: This file uses Node.js-specific features (process.env) and should only be used in Node.js environments
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
interface EnhancedMemoryClientConfig extends CoreMemoryClientConfig {
|
|
188
|
+
/** Prefer CLI when available (default: true) */
|
|
189
|
+
preferCLI?: boolean;
|
|
190
|
+
/** Enable MCP channels when available (default: true) */
|
|
191
|
+
enableMCP?: boolean;
|
|
192
|
+
/** CLI detection timeout in ms (default: 5000) */
|
|
193
|
+
cliDetectionTimeout?: number;
|
|
194
|
+
/** Fallback to direct API on CLI failure (default: true) */
|
|
195
|
+
fallbackToAPI?: boolean;
|
|
196
|
+
/** Minimum CLI version required for Golden Contract compliance (default: 1.5.2) */
|
|
197
|
+
minCLIVersion?: string;
|
|
198
|
+
/** Enable verbose logging for troubleshooting (default: false) */
|
|
199
|
+
verbose?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface OperationResult<T> {
|
|
202
|
+
data?: T;
|
|
203
|
+
error?: ApiErrorResponse;
|
|
204
|
+
source: 'cli' | 'api';
|
|
205
|
+
mcpUsed?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Enhanced Memory Client with intelligent CLI/API routing
|
|
209
|
+
*/
|
|
210
|
+
declare class EnhancedMemoryClient {
|
|
211
|
+
private directClient;
|
|
212
|
+
private cliIntegration;
|
|
213
|
+
private config;
|
|
214
|
+
private capabilities;
|
|
215
|
+
private createDefaultCapabilities;
|
|
216
|
+
constructor(config: EnhancedMemoryClientConfig);
|
|
217
|
+
/**
|
|
218
|
+
* Initialize the client and detect capabilities
|
|
219
|
+
*/
|
|
220
|
+
initialize(): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Get current capabilities
|
|
223
|
+
*/
|
|
224
|
+
getCapabilities(): Promise<Awaited<ReturnType<CLIIntegration['getCapabilities']>>>;
|
|
225
|
+
/**
|
|
226
|
+
* Determine if operation should use CLI
|
|
227
|
+
*/
|
|
228
|
+
private shouldUseCLI;
|
|
229
|
+
/**
|
|
230
|
+
* Execute operation with intelligent routing
|
|
231
|
+
*/
|
|
232
|
+
private executeOperation;
|
|
233
|
+
/**
|
|
234
|
+
* Health check with intelligent routing
|
|
235
|
+
*/
|
|
236
|
+
healthCheck(): Promise<OperationResult<{
|
|
237
|
+
status: string;
|
|
238
|
+
timestamp: string;
|
|
239
|
+
}>>;
|
|
240
|
+
/**
|
|
241
|
+
* Create memory with CLI/API routing
|
|
242
|
+
*/
|
|
243
|
+
createMemory(memory: CreateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
|
|
244
|
+
/**
|
|
245
|
+
* List memories with intelligent routing
|
|
246
|
+
*/
|
|
247
|
+
listMemories(options?: {
|
|
248
|
+
page?: number;
|
|
249
|
+
limit?: number;
|
|
250
|
+
memory_type?: string;
|
|
251
|
+
topic_id?: string;
|
|
252
|
+
project_ref?: string;
|
|
253
|
+
status?: string;
|
|
254
|
+
tags?: string[];
|
|
255
|
+
sort?: string;
|
|
256
|
+
order?: 'asc' | 'desc';
|
|
257
|
+
}): Promise<OperationResult<PaginatedResponse<MemoryEntry>>>;
|
|
258
|
+
/**
|
|
259
|
+
* Search memories with MCP enhancement when available
|
|
260
|
+
*/
|
|
261
|
+
searchMemories(request: SearchMemoryRequest): Promise<OperationResult<{
|
|
262
|
+
results: MemorySearchResult[];
|
|
263
|
+
total_results: number;
|
|
264
|
+
search_time_ms: number;
|
|
265
|
+
}>>;
|
|
266
|
+
/**
|
|
267
|
+
* Get memory by ID (API only for now)
|
|
268
|
+
*/
|
|
269
|
+
getMemory(id: string): Promise<OperationResult<MemoryEntry>>;
|
|
270
|
+
/**
|
|
271
|
+
* Update memory (API only for now)
|
|
272
|
+
*/
|
|
273
|
+
updateMemory(id: string, updates: UpdateMemoryRequest): Promise<OperationResult<MemoryEntry>>;
|
|
274
|
+
/**
|
|
275
|
+
* Delete memory (API only for now)
|
|
276
|
+
*/
|
|
277
|
+
deleteMemory(id: string): Promise<OperationResult<void>>;
|
|
278
|
+
createTopic(topic: CreateTopicRequest): Promise<OperationResult<MemoryTopic>>;
|
|
279
|
+
getTopics(): Promise<OperationResult<MemoryTopic[]>>;
|
|
280
|
+
getTopic(id: string): Promise<OperationResult<MemoryTopic>>;
|
|
281
|
+
updateTopic(id: string, updates: Partial<CreateTopicRequest>): Promise<OperationResult<MemoryTopic>>;
|
|
282
|
+
deleteTopic(id: string): Promise<OperationResult<void>>;
|
|
283
|
+
/**
|
|
284
|
+
* Get memory statistics
|
|
285
|
+
*/
|
|
286
|
+
getMemoryStats(): Promise<OperationResult<UserMemoryStats>>;
|
|
287
|
+
/**
|
|
288
|
+
* Force CLI re-detection
|
|
289
|
+
*/
|
|
290
|
+
refreshCLIDetection(): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Get authentication status from CLI
|
|
293
|
+
*/
|
|
294
|
+
getAuthStatus(): Promise<OperationResult<CLIAuthStatus>>;
|
|
295
|
+
/**
|
|
296
|
+
* Get MCP status when available
|
|
297
|
+
*/
|
|
298
|
+
getMCPStatus(): Promise<OperationResult<CLIMCPStatus>>;
|
|
299
|
+
/**
|
|
300
|
+
* Update authentication for both CLI and API client
|
|
301
|
+
*/
|
|
302
|
+
setAuthToken(token: string): void;
|
|
303
|
+
setApiKey(apiKey: string): void;
|
|
304
|
+
clearAuth(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Update configuration
|
|
307
|
+
*/
|
|
308
|
+
updateConfig(updates: Partial<EnhancedMemoryClientConfig>): void;
|
|
309
|
+
/**
|
|
310
|
+
* Get configuration summary
|
|
311
|
+
*/
|
|
312
|
+
getConfigSummary(): {
|
|
313
|
+
apiUrl: string;
|
|
314
|
+
preferCLI: boolean;
|
|
315
|
+
enableMCP: boolean;
|
|
316
|
+
capabilities?: Awaited<ReturnType<CLIIntegration['getCapabilities']>>;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Factory function to create an enhanced memory client
|
|
321
|
+
*/
|
|
322
|
+
declare function createNodeMemoryClient(config: EnhancedMemoryClientConfig): Promise<EnhancedMemoryClient>;
|
|
323
|
+
/**
|
|
324
|
+
* Synchronous factory function (initialization happens on first API call)
|
|
325
|
+
*/
|
|
326
|
+
declare function createEnhancedMemoryClient(config: EnhancedMemoryClientConfig): EnhancedMemoryClient;
|
|
327
|
+
|
|
328
|
+
export { CLIIntegration, EnhancedMemoryClient, cliIntegration, createEnhancedMemoryClient, createNodeMemoryClient };
|
|
329
|
+
export type { ApiErrorResponse, CLIAuthStatus, CLICapabilities, CLICommand, CLIExecutionOptions, CLIInfo, CLIMCPStatus, CLIMCPTool, EnhancedMemoryClientConfig, ErrorCode, MCPChannel, OperationResult, RoutingStrategy };
|