@lanonasis/mem-intel-sdk 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.
Files changed (66) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +490 -0
  4. package/dist/core/client.d.ts +43 -0
  5. package/dist/core/client.d.ts.map +1 -0
  6. package/dist/core/errors.d.ts +24 -0
  7. package/dist/core/errors.d.ts.map +1 -0
  8. package/dist/core/index.cjs +310 -0
  9. package/dist/core/index.cjs.map +1 -0
  10. package/dist/core/index.d.ts +7 -0
  11. package/dist/core/index.d.ts.map +1 -0
  12. package/dist/core/index.js +300 -0
  13. package/dist/core/index.js.map +1 -0
  14. package/dist/core/types.d.ts +171 -0
  15. package/dist/core/types.d.ts.map +1 -0
  16. package/dist/index-sdk.d.ts +8 -0
  17. package/dist/index-sdk.d.ts.map +1 -0
  18. package/dist/index.cjs +310 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.js +300 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/node/client.d.ts +22 -0
  23. package/dist/node/client.d.ts.map +1 -0
  24. package/dist/node/index.cjs +331 -0
  25. package/dist/node/index.cjs.map +1 -0
  26. package/dist/node/index.d.ts +7 -0
  27. package/dist/node/index.d.ts.map +1 -0
  28. package/dist/node/index.js +321 -0
  29. package/dist/node/index.js.map +1 -0
  30. package/dist/react/context/MemoryIntelligenceProvider.d.ts +18 -0
  31. package/dist/react/context/MemoryIntelligenceProvider.d.ts.map +1 -0
  32. package/dist/react/hooks/useMemoryIntelligence.d.ts +115 -0
  33. package/dist/react/hooks/useMemoryIntelligence.d.ts.map +1 -0
  34. package/dist/react/index.cjs +399 -0
  35. package/dist/react/index.cjs.map +1 -0
  36. package/dist/react/index.d.ts +8 -0
  37. package/dist/react/index.d.ts.map +1 -0
  38. package/dist/react/index.js +377 -0
  39. package/dist/react/index.js.map +1 -0
  40. package/dist/server/index.cjs +802 -0
  41. package/dist/server/index.cjs.map +1 -0
  42. package/dist/server/index.d.ts +7 -0
  43. package/dist/server/index.d.ts.map +1 -0
  44. package/dist/server/index.js +792 -0
  45. package/dist/server/index.js.map +1 -0
  46. package/dist/server/mcp-server.d.ts +7 -0
  47. package/dist/server/mcp-server.d.ts.map +1 -0
  48. package/dist/utils/embeddings.d.ts +13 -0
  49. package/dist/utils/embeddings.d.ts.map +1 -0
  50. package/dist/utils/formatting.d.ts +13 -0
  51. package/dist/utils/formatting.d.ts.map +1 -0
  52. package/dist/utils/http-client.d.ts +31 -0
  53. package/dist/utils/http-client.d.ts.map +1 -0
  54. package/dist/utils/index.d.ts +9 -0
  55. package/dist/utils/index.d.ts.map +1 -0
  56. package/dist/utils/similarity.d.ts +8 -0
  57. package/dist/utils/similarity.d.ts.map +1 -0
  58. package/dist/vue/composables/useMemoryIntelligence.d.ts +24 -0
  59. package/dist/vue/composables/useMemoryIntelligence.d.ts.map +1 -0
  60. package/dist/vue/index.cjs +132 -0
  61. package/dist/vue/index.cjs.map +1 -0
  62. package/dist/vue/index.d.ts +7 -0
  63. package/dist/vue/index.d.ts.map +1 -0
  64. package/dist/vue/index.js +115 -0
  65. package/dist/vue/index.js.map +1 -0
  66. package/package.json +144 -0
@@ -0,0 +1,399 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var reactQuery = require('@tanstack/react-query');
5
+ var zod = require('zod');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefault(React);
10
+
11
+ // src/react/context/MemoryIntelligenceProvider.tsx
12
+
13
+ // src/core/errors.ts
14
+ var MemoryIntelligenceError = class extends Error {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = "MemoryIntelligenceError";
18
+ }
19
+ };
20
+ var ConfigurationError = class extends MemoryIntelligenceError {
21
+ constructor(message) {
22
+ super(message);
23
+ this.name = "ConfigurationError";
24
+ }
25
+ };
26
+ var MemoryNotFoundError = class extends MemoryIntelligenceError {
27
+ constructor(memoryId) {
28
+ super(`Memory not found: ${memoryId}`);
29
+ this.name = "MemoryNotFoundError";
30
+ }
31
+ };
32
+ var DatabaseError = class extends MemoryIntelligenceError {
33
+ constructor(message, originalError) {
34
+ super(message);
35
+ this.originalError = originalError;
36
+ this.name = "DatabaseError";
37
+ }
38
+ };
39
+ var EmbeddingError = class extends MemoryIntelligenceError {
40
+ constructor(message, originalError) {
41
+ super(message);
42
+ this.originalError = originalError;
43
+ this.name = "EmbeddingError";
44
+ }
45
+ };
46
+ var ValidationError = class extends MemoryIntelligenceError {
47
+ constructor(message) {
48
+ super(message);
49
+ this.name = "ValidationError";
50
+ }
51
+ };
52
+
53
+ // src/utils/http-client.ts
54
+ var HttpClient = class {
55
+ apiUrl;
56
+ apiKey;
57
+ timeout;
58
+ headers;
59
+ constructor(config) {
60
+ if (!config.apiKey) {
61
+ throw new ConfigurationError("API key is required");
62
+ }
63
+ if (!config.apiKey.startsWith("lano_")) {
64
+ throw new ConfigurationError(
65
+ "Invalid API key format. API key should start with 'lano_'"
66
+ );
67
+ }
68
+ this.apiUrl = config.apiUrl.replace(/\/$/, "");
69
+ this.apiKey = config.apiKey;
70
+ this.timeout = config.timeout || 3e4;
71
+ this.headers = {
72
+ "Content-Type": "application/json",
73
+ "X-API-Key": this.apiKey,
74
+ ...config.headers
75
+ };
76
+ }
77
+ async request(method, endpoint, data) {
78
+ const url = `${this.apiUrl}${endpoint}`;
79
+ const controller = new AbortController();
80
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
81
+ try {
82
+ const options = {
83
+ method,
84
+ headers: this.headers,
85
+ signal: controller.signal
86
+ };
87
+ if (data && (method === "POST" || method === "PUT" || method === "PATCH")) {
88
+ options.body = JSON.stringify(data);
89
+ }
90
+ const response = await fetch(url, options);
91
+ clearTimeout(timeoutId);
92
+ const responseData = await response.json();
93
+ if (!response.ok) {
94
+ return {
95
+ status: response.status,
96
+ error: {
97
+ message: responseData?.message || responseData?.error || "Request failed",
98
+ code: responseData?.code
99
+ }
100
+ };
101
+ }
102
+ return {
103
+ status: response.status,
104
+ data: responseData
105
+ };
106
+ } catch (error) {
107
+ clearTimeout(timeoutId);
108
+ if (error instanceof Error) {
109
+ if (error.name === "AbortError") {
110
+ return {
111
+ status: 408,
112
+ error: {
113
+ message: `Request timeout after ${this.timeout}ms`,
114
+ code: "TIMEOUT"
115
+ }
116
+ };
117
+ }
118
+ return {
119
+ status: 0,
120
+ error: {
121
+ message: error.message,
122
+ code: "NETWORK_ERROR"
123
+ }
124
+ };
125
+ }
126
+ return {
127
+ status: 0,
128
+ error: {
129
+ message: "Unknown error occurred",
130
+ code: "UNKNOWN_ERROR"
131
+ }
132
+ };
133
+ }
134
+ }
135
+ async get(endpoint) {
136
+ return this.request("GET", endpoint);
137
+ }
138
+ async post(endpoint, data) {
139
+ return this.request("POST", endpoint, data);
140
+ }
141
+ async put(endpoint, data) {
142
+ return this.request("PUT", endpoint, data);
143
+ }
144
+ async patch(endpoint, data) {
145
+ return this.request("PATCH", endpoint, data);
146
+ }
147
+ async delete(endpoint) {
148
+ return this.request("DELETE", endpoint);
149
+ }
150
+ };
151
+
152
+ // src/core/client.ts
153
+ var DEFAULT_API_URL = "https://api.lanonasis.com/api/v1";
154
+ var MemoryIntelligenceClient = class {
155
+ httpClient;
156
+ defaultResponseFormat;
157
+ constructor(config) {
158
+ if (!config.apiKey) {
159
+ throw new ConfigurationError(
160
+ "Missing required configuration: apiKey is required (format: lano_xxxxxxxxxx)"
161
+ );
162
+ }
163
+ this.httpClient = new HttpClient({
164
+ apiUrl: config.apiUrl || DEFAULT_API_URL,
165
+ apiKey: config.apiKey,
166
+ timeout: config.timeout,
167
+ headers: config.headers
168
+ });
169
+ this.defaultResponseFormat = config.responseFormat || "markdown";
170
+ }
171
+ /**
172
+ * Get HTTP client for direct API access
173
+ */
174
+ getHttpClient() {
175
+ return this.httpClient;
176
+ }
177
+ /**
178
+ * Query memories from the API
179
+ */
180
+ async queryMemories(userId, options = {}) {
181
+ const { type, limit = 100, offset = 0 } = options;
182
+ const params = new URLSearchParams({
183
+ user_id: userId,
184
+ limit: limit.toString(),
185
+ offset: offset.toString()
186
+ });
187
+ if (type) {
188
+ params.append("type", type);
189
+ }
190
+ const response = await this.httpClient.get(
191
+ `/intelligence/memories?${params.toString()}`
192
+ );
193
+ if (response.error) {
194
+ throw new DatabaseError(`Failed to query memories: ${response.error.message}`);
195
+ }
196
+ return response.data?.memories || [];
197
+ }
198
+ /**
199
+ * Analyze usage patterns and trends in memory collection
200
+ */
201
+ async analyzePatterns(params) {
202
+ const response = await this.httpClient.post(
203
+ "/intelligence/analyze-patterns",
204
+ {
205
+ ...params,
206
+ responseFormat: params.responseFormat || this.defaultResponseFormat
207
+ }
208
+ );
209
+ if (response.error) {
210
+ throw new DatabaseError(`Failed to analyze patterns: ${response.error.message}`);
211
+ }
212
+ return response.data;
213
+ }
214
+ /**
215
+ * Get AI-powered tag suggestions for a memory
216
+ */
217
+ async suggestTags(params) {
218
+ const response = await this.httpClient.post(
219
+ "/intelligence/suggest-tags",
220
+ {
221
+ ...params,
222
+ responseFormat: params.responseFormat || this.defaultResponseFormat
223
+ }
224
+ );
225
+ if (response.error) {
226
+ throw new DatabaseError(`Failed to suggest tags: ${response.error.message}`);
227
+ }
228
+ return response.data;
229
+ }
230
+ /**
231
+ * Find semantically related memories using vector similarity
232
+ */
233
+ async findRelated(params) {
234
+ const response = await this.httpClient.post(
235
+ "/intelligence/find-related",
236
+ {
237
+ ...params,
238
+ responseFormat: params.responseFormat || this.defaultResponseFormat
239
+ }
240
+ );
241
+ if (response.error) {
242
+ throw new DatabaseError(`Failed to find related memories: ${response.error.message}`);
243
+ }
244
+ return response.data;
245
+ }
246
+ /**
247
+ * Detect potential duplicate memories
248
+ */
249
+ async detectDuplicates(params) {
250
+ const response = await this.httpClient.post(
251
+ "/intelligence/detect-duplicates",
252
+ {
253
+ ...params,
254
+ responseFormat: params.responseFormat || this.defaultResponseFormat
255
+ }
256
+ );
257
+ if (response.error) {
258
+ throw new DatabaseError(`Failed to detect duplicates: ${response.error.message}`);
259
+ }
260
+ return response.data;
261
+ }
262
+ /**
263
+ * Extract insights and patterns from memories
264
+ */
265
+ async extractInsights(params) {
266
+ const response = await this.httpClient.post(
267
+ "/intelligence/extract-insights",
268
+ {
269
+ ...params,
270
+ responseFormat: params.responseFormat || this.defaultResponseFormat
271
+ }
272
+ );
273
+ if (response.error) {
274
+ throw new DatabaseError(`Failed to extract insights: ${response.error.message}`);
275
+ }
276
+ return response.data;
277
+ }
278
+ /**
279
+ * Check the health and organization quality of memories
280
+ */
281
+ async healthCheck(params) {
282
+ const response = await this.httpClient.post(
283
+ "/intelligence/health-check",
284
+ {
285
+ ...params,
286
+ responseFormat: params.responseFormat || this.defaultResponseFormat
287
+ }
288
+ );
289
+ if (response.error) {
290
+ throw new DatabaseError(`Failed to check health: ${response.error.message}`);
291
+ }
292
+ return response.data;
293
+ }
294
+ };
295
+
296
+ // src/react/context/MemoryIntelligenceProvider.tsx
297
+ var MemoryIntelligenceContext = React.createContext(
298
+ null
299
+ );
300
+ function MemoryIntelligenceProvider({
301
+ config,
302
+ children
303
+ }) {
304
+ const [client] = React__default.default.useState(() => new MemoryIntelligenceClient(config));
305
+ return /* @__PURE__ */ React__default.default.createElement(MemoryIntelligenceContext.Provider, { value: { client } }, children);
306
+ }
307
+ function useMemoryIntelligenceContext() {
308
+ const context = React.useContext(MemoryIntelligenceContext);
309
+ if (!context) {
310
+ throw new Error(
311
+ "useMemoryIntelligenceContext must be used within MemoryIntelligenceProvider"
312
+ );
313
+ }
314
+ return context;
315
+ }
316
+ function useMemoryIntelligence() {
317
+ const { client } = useMemoryIntelligenceContext();
318
+ return client;
319
+ }
320
+ function usePatternAnalysis(params, options) {
321
+ const client = useMemoryIntelligence();
322
+ return reactQuery.useQuery({
323
+ queryKey: ["memory-intelligence", "analyze-patterns", params],
324
+ queryFn: () => client.analyzePatterns(params),
325
+ ...options
326
+ });
327
+ }
328
+ function useTagSuggestions(params, options) {
329
+ const client = useMemoryIntelligence();
330
+ return reactQuery.useQuery({
331
+ queryKey: ["memory-intelligence", "suggest-tags", params],
332
+ queryFn: () => client.suggestTags(params),
333
+ ...options
334
+ });
335
+ }
336
+ function useRelatedMemories(params, options) {
337
+ const client = useMemoryIntelligence();
338
+ return reactQuery.useQuery({
339
+ queryKey: ["memory-intelligence", "find-related", params],
340
+ queryFn: () => client.findRelated(params),
341
+ ...options
342
+ });
343
+ }
344
+ function useDuplicateDetection(params, options) {
345
+ const client = useMemoryIntelligence();
346
+ return reactQuery.useQuery({
347
+ queryKey: ["memory-intelligence", "detect-duplicates", params],
348
+ queryFn: () => client.detectDuplicates(params),
349
+ ...options
350
+ });
351
+ }
352
+ function useInsightExtraction(params, options) {
353
+ const client = useMemoryIntelligence();
354
+ return reactQuery.useQuery({
355
+ queryKey: ["memory-intelligence", "extract-insights", params],
356
+ queryFn: () => client.extractInsights(params),
357
+ ...options
358
+ });
359
+ }
360
+ function useHealthCheck(params, options) {
361
+ const client = useMemoryIntelligence();
362
+ return reactQuery.useQuery({
363
+ queryKey: ["memory-intelligence", "health-check", params],
364
+ queryFn: () => client.healthCheck(params),
365
+ ...options
366
+ });
367
+ }
368
+ var ResponseFormat = {
369
+ JSON: "json",
370
+ MARKDOWN: "markdown"
371
+ };
372
+ var MemoryType = zod.z.enum([
373
+ "context",
374
+ "project",
375
+ "knowledge",
376
+ "reference",
377
+ "personal",
378
+ "workflow"
379
+ ]);
380
+
381
+ exports.ConfigurationError = ConfigurationError;
382
+ exports.DatabaseError = DatabaseError;
383
+ exports.EmbeddingError = EmbeddingError;
384
+ exports.MemoryIntelligenceError = MemoryIntelligenceError;
385
+ exports.MemoryIntelligenceProvider = MemoryIntelligenceProvider;
386
+ exports.MemoryNotFoundError = MemoryNotFoundError;
387
+ exports.MemoryType = MemoryType;
388
+ exports.ResponseFormat = ResponseFormat;
389
+ exports.ValidationError = ValidationError;
390
+ exports.useDuplicateDetection = useDuplicateDetection;
391
+ exports.useHealthCheck = useHealthCheck;
392
+ exports.useInsightExtraction = useInsightExtraction;
393
+ exports.useMemoryIntelligence = useMemoryIntelligence;
394
+ exports.useMemoryIntelligenceContext = useMemoryIntelligenceContext;
395
+ exports.usePatternAnalysis = usePatternAnalysis;
396
+ exports.useRelatedMemories = useRelatedMemories;
397
+ exports.useTagSuggestions = useTagSuggestions;
398
+ //# sourceMappingURL=index.cjs.map
399
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/errors.ts","../../src/utils/http-client.ts","../../src/core/client.ts","../../src/react/context/MemoryIntelligenceProvider.tsx","../../src/react/hooks/useMemoryIntelligence.ts","../../src/core/types.ts"],"names":["createContext","React","useContext","useQuery","z"],"mappings":";;;;;;;;;;;;;AAIO,IAAM,uBAAA,GAAN,cAAsC,KAAA,CAAM;AAAA,EACjD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,yBAAA;AAAA,EACd;AACF;AAEO,IAAM,kBAAA,GAAN,cAAiC,uBAAA,CAAwB;AAAA,EAC9D,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAEO,IAAM,mBAAA,GAAN,cAAkC,uBAAA,CAAwB;AAAA,EAC/D,YAAY,QAAA,EAAkB;AAC5B,IAAA,KAAA,CAAM,CAAA,kBAAA,EAAqB,QAAQ,CAAA,CAAE,CAAA;AACrC,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AAAA,EACd;AACF;AAEO,IAAM,aAAA,GAAN,cAA4B,uBAAA,CAAwB;AAAA,EACzD,WAAA,CAAY,SAAwB,aAAA,EAAuB;AACzD,IAAA,KAAA,CAAM,OAAO,CAAA;AADqB,IAAA,IAAA,CAAA,aAAA,GAAA,aAA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BAAA,EAAuB,kBAAA,EAAoB,MAAM,CAAA;AAAA,IAC5D,OAAA,EAAS,MAAM,MAAA,CAAO,eAAA,CAAgB,MAAM,CAAA;AAAA,IAC5C,GAAG;AAAA,GACJ,CAAA;AACH;AA2BO,SAAS,cAAA,CACd,QACA,OAAA,EACA;AACA,EAAA,MAAM,SAAS,qBAAA,EAAsB;AAErC,EAAA,OAAOA,mBAAA,CAAuB;AAAA,IAC5B,QAAA,EAAU,CAAC,qBAAA,EAAuB,cAAA,EAAgB,MAAM,CAAA;AAAA,IACxD,OAAA,EAAS,MAAM,MAAA,CAAO,WAAA,CAAY,MAAM,CAAA;AAAA,IACxC,GAAG;AAAA,GACJ,CAAA;AACH;AC/NO,IAAM,cAAA,GAAiB;AAAA,EAC5B,IAAA,EAAM,MAAA;AAAA,EACN,QAAA,EAAU;AACZ;AAKO,IAAM,UAAA,GAAaC,MAAE,IAAA,CAAK;AAAA,EAC/B,SAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAC","file":"index.cjs","sourcesContent":["/**\n * SDK-specific error classes\n */\n\nexport class MemoryIntelligenceError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"MemoryIntelligenceError\";\n }\n}\n\nexport class ConfigurationError extends MemoryIntelligenceError {\n constructor(message: string) {\n super(message);\n this.name = \"ConfigurationError\";\n }\n}\n\nexport class MemoryNotFoundError extends MemoryIntelligenceError {\n constructor(memoryId: string) {\n super(`Memory not found: ${memoryId}`);\n this.name = \"MemoryNotFoundError\";\n }\n}\n\nexport class DatabaseError extends MemoryIntelligenceError {\n constructor(message: string, public originalError?: Error) {\n super(message);\n this.name = \"DatabaseError\";\n }\n}\n\nexport class EmbeddingError extends MemoryIntelligenceError {\n constructor(message: string, public originalError?: Error) {\n super(message);\n this.name = \"EmbeddingError\";\n }\n}\n\nexport class ValidationError extends MemoryIntelligenceError {\n constructor(message: string) {\n super(message);\n this.name = \"ValidationError\";\n }\n}\n","/**\n * HTTP client for Lanonasis API\n */\n\nimport { ConfigurationError } from \"../core/errors\";\n\nexport interface HttpClientConfig {\n apiUrl: string;\n apiKey: string;\n timeout?: number;\n headers?: Record<string, string>;\n}\n\nexport interface ApiResponse<T = any> {\n data?: T;\n error?: {\n message: string;\n code?: string;\n };\n status: number;\n}\n\nexport class HttpClient {\n private apiUrl: string;\n private apiKey: string;\n private timeout: number;\n private headers: Record<string, string>;\n\n constructor(config: HttpClientConfig) {\n if (!config.apiKey) {\n throw new ConfigurationError(\"API key is required\");\n }\n\n if (!config.apiKey.startsWith(\"lano_\")) {\n throw new ConfigurationError(\n \"Invalid API key format. API key should start with 'lano_'\"\n );\n }\n\n this.apiUrl = config.apiUrl.replace(/\\/$/, \"\"); // Remove trailing slash\n this.apiKey = config.apiKey;\n this.timeout = config.timeout || 30000;\n this.headers = {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": this.apiKey,\n ...config.headers,\n };\n }\n\n private async request<T>(\n method: string,\n endpoint: string,\n data?: any\n ): Promise<ApiResponse<T>> {\n const url = `${this.apiUrl}${endpoint}`;\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const options: RequestInit = {\n method,\n headers: this.headers,\n signal: controller.signal,\n };\n\n if (data && (method === \"POST\" || method === \"PUT\" || method === \"PATCH\")) {\n options.body = JSON.stringify(data);\n }\n\n const response = await fetch(url, options);\n clearTimeout(timeoutId);\n\n const responseData = await response.json() as any;\n\n if (!response.ok) {\n return {\n status: response.status,\n error: {\n message: responseData?.message || responseData?.error || \"Request failed\",\n code: responseData?.code,\n },\n };\n }\n\n return {\n status: response.status,\n data: responseData as T,\n };\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error) {\n if (error.name === \"AbortError\") {\n return {\n status: 408,\n error: {\n message: `Request timeout after ${this.timeout}ms`,\n code: \"TIMEOUT\",\n },\n };\n }\n\n return {\n status: 0,\n error: {\n message: error.message,\n code: \"NETWORK_ERROR\",\n },\n };\n }\n\n return {\n status: 0,\n error: {\n message: \"Unknown error occurred\",\n code: \"UNKNOWN_ERROR\",\n },\n };\n }\n }\n\n async get<T>(endpoint: string): Promise<ApiResponse<T>> {\n return this.request<T>(\"GET\", endpoint);\n }\n\n async post<T>(endpoint: string, data?: any): Promise<ApiResponse<T>> {\n return this.request<T>(\"POST\", endpoint, data);\n }\n\n async put<T>(endpoint: string, data?: any): Promise<ApiResponse<T>> {\n return this.request<T>(\"PUT\", endpoint, data);\n }\n\n async patch<T>(endpoint: string, data?: any): Promise<ApiResponse<T>> {\n return this.request<T>(\"PATCH\", endpoint, data);\n }\n\n async delete<T>(endpoint: string): Promise<ApiResponse<T>> {\n return this.request<T>(\"DELETE\", endpoint);\n }\n}\n","/**\n * Core Memory Intelligence Client\n */\n\nimport {\n MemoryIntelligenceConfig,\n AnalyzePatternsParams,\n PatternAnalysis,\n SuggestTagsParams,\n TagSuggestionsResult,\n FindRelatedParams,\n RelatedMemoriesResult,\n DetectDuplicatesParams,\n DuplicatesResult,\n ExtractInsightsParams,\n InsightsResult,\n HealthCheckParams,\n MemoryHealth,\n QueryMemoriesOptions,\n MemoryEntry,\n} from \"./types\";\nimport { ConfigurationError, DatabaseError } from \"./errors\";\nimport { HttpClient } from \"../utils/http-client\";\n\nconst DEFAULT_API_URL = \"https://api.lanonasis.com/api/v1\";\n\nexport class MemoryIntelligenceClient {\n private httpClient: HttpClient;\n private defaultResponseFormat: \"json\" | \"markdown\";\n\n constructor(config: MemoryIntelligenceConfig) {\n // Validate configuration\n if (!config.apiKey) {\n throw new ConfigurationError(\n \"Missing required configuration: apiKey is required (format: lano_xxxxxxxxxx)\"\n );\n }\n\n this.httpClient = new HttpClient({\n apiUrl: config.apiUrl || DEFAULT_API_URL,\n apiKey: config.apiKey,\n timeout: config.timeout,\n headers: config.headers,\n });\n\n this.defaultResponseFormat = config.responseFormat || \"markdown\";\n }\n\n /**\n * Get HTTP client for direct API access\n */\n public getHttpClient(): HttpClient {\n return this.httpClient;\n }\n\n /**\n * Query memories from the API\n */\n public async queryMemories(\n userId: string,\n options: QueryMemoriesOptions = {}\n ): Promise<MemoryEntry[]> {\n const { type, limit = 100, offset = 0 } = options;\n\n const params = new URLSearchParams({\n user_id: userId,\n limit: limit.toString(),\n offset: offset.toString(),\n });\n\n if (type) {\n params.append(\"type\", type);\n }\n\n const response = await this.httpClient.get<{ memories: MemoryEntry[] }>(\n `/intelligence/memories?${params.toString()}`\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to query memories: ${response.error.message}`);\n }\n\n return response.data?.memories || [];\n }\n\n /**\n * Analyze usage patterns and trends in memory collection\n */\n async analyzePatterns(params: AnalyzePatternsParams): Promise<PatternAnalysis> {\n const response = await this.httpClient.post<PatternAnalysis>(\n \"/intelligence/analyze-patterns\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to analyze patterns: ${response.error.message}`);\n }\n\n return response.data!;\n }\n\n /**\n * Get AI-powered tag suggestions for a memory\n */\n async suggestTags(params: SuggestTagsParams): Promise<TagSuggestionsResult> {\n const response = await this.httpClient.post<TagSuggestionsResult>(\n \"/intelligence/suggest-tags\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to suggest tags: ${response.error.message}`);\n }\n\n return response.data!;\n }\n\n /**\n * Find semantically related memories using vector similarity\n */\n async findRelated(params: FindRelatedParams): Promise<RelatedMemoriesResult> {\n const response = await this.httpClient.post<RelatedMemoriesResult>(\n \"/intelligence/find-related\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to find related memories: ${response.error.message}`);\n }\n\n return response.data!;\n }\n\n /**\n * Detect potential duplicate memories\n */\n async detectDuplicates(params: DetectDuplicatesParams): Promise<DuplicatesResult> {\n const response = await this.httpClient.post<DuplicatesResult>(\n \"/intelligence/detect-duplicates\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to detect duplicates: ${response.error.message}`);\n }\n\n return response.data!;\n }\n\n /**\n * Extract insights and patterns from memories\n */\n async extractInsights(params: ExtractInsightsParams): Promise<InsightsResult> {\n const response = await this.httpClient.post<InsightsResult>(\n \"/intelligence/extract-insights\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to extract insights: ${response.error.message}`);\n }\n\n return response.data!;\n }\n\n /**\n * Check the health and organization quality of memories\n */\n async healthCheck(params: HealthCheckParams): Promise<MemoryHealth> {\n const response = await this.httpClient.post<MemoryHealth>(\n \"/intelligence/health-check\",\n {\n ...params,\n responseFormat: params.responseFormat || this.defaultResponseFormat,\n }\n );\n\n if (response.error) {\n throw new DatabaseError(`Failed to check health: ${response.error.message}`);\n }\n\n return response.data!;\n }\n}\n","/**\n * React Context Provider for Memory Intelligence\n */\n\nimport React, { createContext, useContext, ReactNode } from \"react\";\nimport { MemoryIntelligenceClient } from \"../../core/client\";\nimport { MemoryIntelligenceConfig } from \"../../core/types\";\n\ninterface MemoryIntelligenceContextValue {\n client: MemoryIntelligenceClient;\n}\n\nconst MemoryIntelligenceContext = createContext<MemoryIntelligenceContextValue | null>(\n null\n);\n\ninterface MemoryIntelligenceProviderProps {\n config: MemoryIntelligenceConfig;\n children: ReactNode;\n}\n\nexport function MemoryIntelligenceProvider({\n config,\n children,\n}: MemoryIntelligenceProviderProps) {\n const [client] = React.useState(() => new MemoryIntelligenceClient(config));\n\n return (\n <MemoryIntelligenceContext.Provider value={{ client }}>\n {children}\n </MemoryIntelligenceContext.Provider>\n );\n}\n\nexport function useMemoryIntelligenceContext() {\n const context = useContext(MemoryIntelligenceContext);\n if (!context) {\n throw new Error(\n \"useMemoryIntelligenceContext must be used within MemoryIntelligenceProvider\"\n );\n }\n return context;\n}\n\nexport { MemoryIntelligenceContext };\n","/**\n * React hooks for Memory Intelligence using React Query\n */\n\nimport { useQuery, useMutation, UseQueryOptions, UseMutationOptions } from \"@tanstack/react-query\";\nimport { useMemoryIntelligenceContext } from \"../context/MemoryIntelligenceProvider\";\nimport {\n PatternAnalysis,\n TagSuggestionsResult,\n RelatedMemoriesResult,\n DuplicatesResult,\n InsightsResult,\n MemoryHealth,\n AnalyzePatternsParams,\n SuggestTagsParams,\n FindRelatedParams,\n DetectDuplicatesParams,\n ExtractInsightsParams,\n HealthCheckParams,\n} from \"../../core/types\";\n\n/**\n * Get the Memory Intelligence client from context\n */\nexport function useMemoryIntelligence() {\n const { client } = useMemoryIntelligenceContext();\n return client;\n}\n\n/**\n * Hook for analyzing memory patterns\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = usePatternAnalysis({\n * userId: \"user-123\",\n * timeRangeDays: 30,\n * responseFormat: \"json\"\n * });\n * ```\n */\nexport function usePatternAnalysis(\n params: AnalyzePatternsParams,\n options?: Omit<UseQueryOptions<PatternAnalysis>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<PatternAnalysis>({\n queryKey: [\"memory-intelligence\", \"analyze-patterns\", params],\n queryFn: () => client.analyzePatterns(params),\n ...options,\n });\n}\n\n/**\n * Hook for getting tag suggestions\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTagSuggestions({\n * memoryId: \"mem-123\",\n * userId: \"user-123\",\n * maxSuggestions: 5\n * });\n * ```\n */\nexport function useTagSuggestions(\n params: SuggestTagsParams,\n options?: Omit<UseQueryOptions<TagSuggestionsResult>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<TagSuggestionsResult>({\n queryKey: [\"memory-intelligence\", \"suggest-tags\", params],\n queryFn: () => client.suggestTags(params),\n ...options,\n });\n}\n\n/**\n * Mutation hook for getting tag suggestions (if you need manual trigger)\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useTagSuggestionsMutation();\n *\n * // Later...\n * mutate({\n * memoryId: \"mem-123\",\n * userId: \"user-123\"\n * });\n * ```\n */\nexport function useTagSuggestionsMutation(\n options?: UseMutationOptions<TagSuggestionsResult, Error, SuggestTagsParams>\n) {\n const client = useMemoryIntelligence();\n\n return useMutation<TagSuggestionsResult, Error, SuggestTagsParams>({\n mutationFn: (params) => client.suggestTags(params),\n ...options,\n });\n}\n\n/**\n * Hook for finding related memories\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useRelatedMemories({\n * memoryId: \"mem-123\",\n * userId: \"user-123\",\n * limit: 10,\n * similarityThreshold: 0.7\n * });\n * ```\n */\nexport function useRelatedMemories(\n params: FindRelatedParams,\n options?: Omit<UseQueryOptions<RelatedMemoriesResult>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<RelatedMemoriesResult>({\n queryKey: [\"memory-intelligence\", \"find-related\", params],\n queryFn: () => client.findRelated(params),\n ...options,\n });\n}\n\n/**\n * Hook for detecting duplicate memories\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useDuplicateDetection({\n * userId: \"user-123\",\n * similarityThreshold: 0.9,\n * maxPairs: 20\n * });\n * ```\n */\nexport function useDuplicateDetection(\n params: DetectDuplicatesParams,\n options?: Omit<UseQueryOptions<DuplicatesResult>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<DuplicatesResult>({\n queryKey: [\"memory-intelligence\", \"detect-duplicates\", params],\n queryFn: () => client.detectDuplicates(params),\n ...options,\n });\n}\n\n/**\n * Mutation hook for duplicate detection (if you need manual trigger)\n */\nexport function useDuplicateDetectionMutation(\n options?: UseMutationOptions<DuplicatesResult, Error, DetectDuplicatesParams>\n) {\n const client = useMemoryIntelligence();\n\n return useMutation<DuplicatesResult, Error, DetectDuplicatesParams>({\n mutationFn: (params) => client.detectDuplicates(params),\n ...options,\n });\n}\n\n/**\n * Hook for extracting insights\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useInsightExtraction({\n * userId: \"user-123\",\n * topic: \"machine learning\",\n * maxMemories: 20\n * });\n * ```\n */\nexport function useInsightExtraction(\n params: ExtractInsightsParams,\n options?: Omit<UseQueryOptions<InsightsResult>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<InsightsResult>({\n queryKey: [\"memory-intelligence\", \"extract-insights\", params],\n queryFn: () => client.extractInsights(params),\n ...options,\n });\n}\n\n/**\n * Mutation hook for insight extraction (if you need manual trigger)\n */\nexport function useInsightExtractionMutation(\n options?: UseMutationOptions<InsightsResult, Error, ExtractInsightsParams>\n) {\n const client = useMemoryIntelligence();\n\n return useMutation<InsightsResult, Error, ExtractInsightsParams>({\n mutationFn: (params) => client.extractInsights(params),\n ...options,\n });\n}\n\n/**\n * Hook for checking memory health\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useHealthCheck({\n * userId: \"user-123\",\n * responseFormat: \"json\"\n * });\n * ```\n */\nexport function useHealthCheck(\n params: HealthCheckParams,\n options?: Omit<UseQueryOptions<MemoryHealth>, \"queryKey\" | \"queryFn\">\n) {\n const client = useMemoryIntelligence();\n\n return useQuery<MemoryHealth>({\n queryKey: [\"memory-intelligence\", \"health-check\", params],\n queryFn: () => client.healthCheck(params),\n ...options,\n });\n}\n\n/**\n * Mutation hook for health check (if you need manual trigger)\n */\nexport function useHealthCheckMutation(\n options?: UseMutationOptions<MemoryHealth, Error, HealthCheckParams>\n) {\n const client = useMemoryIntelligence();\n\n return useMutation<MemoryHealth, Error, HealthCheckParams>({\n mutationFn: (params) => client.healthCheck(params),\n ...options,\n });\n}\n","/**\n * Type definitions for Memory Intelligence SDK\n */\n\nimport { z } from \"zod\";\n\n// Response format enum\nexport const ResponseFormat = {\n JSON: \"json\",\n MARKDOWN: \"markdown\",\n} as const;\n\nexport type ResponseFormatType = (typeof ResponseFormat)[keyof typeof ResponseFormat];\n\n// Memory type enum\nexport const MemoryType = z.enum([\n \"context\",\n \"project\",\n \"knowledge\",\n \"reference\",\n \"personal\",\n \"workflow\",\n]);\n\nexport type MemoryTypeValue = z.infer<typeof MemoryType>;\n\n// Configuration interface\nexport interface MemoryIntelligenceConfig {\n apiUrl?: string; // Lanonasis API URL (default: https://api.lanonasis.com/api/v1)\n apiKey: string; // Lanonasis API key (format: lano_xxxxxxxxxx)\n timeout?: number; // Request timeout in milliseconds (default: 30000)\n responseFormat?: ResponseFormatType;\n headers?: Record<string, string>; // Custom headers\n}\n\n// Tool parameter interfaces\nexport interface AnalyzePatternsParams {\n userId: string;\n timeRangeDays?: number;\n responseFormat?: ResponseFormatType;\n}\n\nexport interface SuggestTagsParams {\n memoryId: string;\n userId: string;\n maxSuggestions?: number;\n includeExistingTags?: boolean;\n responseFormat?: ResponseFormatType;\n}\n\nexport interface FindRelatedParams {\n memoryId: string;\n userId: string;\n limit?: number;\n similarityThreshold?: number;\n responseFormat?: ResponseFormatType;\n}\n\nexport interface DetectDuplicatesParams {\n userId: string;\n similarityThreshold?: number;\n maxPairs?: number;\n responseFormat?: ResponseFormatType;\n}\n\nexport interface ExtractInsightsParams {\n userId: string;\n topic?: string;\n memoryType?: MemoryTypeValue;\n maxMemories?: number;\n responseFormat?: ResponseFormatType;\n}\n\nexport interface HealthCheckParams {\n userId: string;\n responseFormat?: ResponseFormatType;\n}\n\n// Tool result interfaces\nexport interface PatternAnalysis {\n total_memories: number;\n memories_by_type: Record<string, number>;\n memories_by_day_of_week: Record<string, number>;\n peak_creation_hours: number[];\n average_content_length: number;\n most_common_tags: Array<{ tag: string; count: number }>;\n creation_velocity: {\n daily_average: number;\n trend: \"increasing\" | \"stable\" | \"decreasing\";\n };\n insights: string[];\n}\n\nexport interface TagSuggestion {\n tag: string;\n confidence: number;\n reasoning: string;\n}\n\nexport interface TagSuggestionsResult {\n memory_id: string;\n existing_tags: string[];\n suggestions: TagSuggestion[];\n context: {\n memory_type: string;\n related_memories_analyzed: number;\n };\n}\n\nexport interface RelatedMemory {\n id: string;\n title: string;\n type: string;\n similarity_score: number;\n shared_tags: string[];\n content_preview: string;\n}\n\nexport interface RelatedMemoriesResult {\n source_memory: {\n id: string;\n title: string;\n type: string;\n };\n related_memories: RelatedMemory[];\n total_found: number;\n}\n\nexport interface DuplicatePair {\n memory_1: {\n id: string;\n title: string;\n created_at: string;\n };\n memory_2: {\n id: string;\n title: string;\n created_at: string;\n };\n similarity_score: number;\n recommendation: \"keep_newer\" | \"keep_older\" | \"merge\" | \"review_manually\";\n reasoning: string;\n}\n\nexport interface DuplicatesResult {\n total_memories_analyzed: number;\n duplicate_pairs_found: number;\n duplicate_pairs: DuplicatePair[];\n estimated_storage_savings: string;\n}\n\nexport interface Insight {\n category: \"pattern\" | \"learning\" | \"opportunity\" | \"risk\" | \"action_item\";\n title: string;\n description: string;\n confidence: number;\n supporting_memories: string[];\n}\n\nexport interface InsightsResult {\n total_memories_analyzed: number;\n insights: Insight[];\n summary: string;\n topic_filter?: string;\n type_filter?: string;\n}\n\nexport interface MemoryHealth {\n user_id: string;\n health_score: number;\n metrics: {\n total_memories: number;\n memories_with_embeddings: number;\n embedding_coverage_percentage: number;\n memories_with_tags: number;\n tagging_percentage: number;\n average_tags_per_memory: number;\n memories_by_type: Record<string, number>;\n };\n issues: string[];\n recommendations: string[];\n analysis_date: string;\n}\n\n// Memory entry interface (from database)\nexport interface MemoryEntry {\n id: string;\n user_id: string;\n title: string;\n content: string;\n type: MemoryTypeValue;\n tags?: string[];\n metadata?: Record<string, any>;\n embedding?: number[];\n created_at: string;\n updated_at: string;\n}\n\n// Query options for internal use\nexport interface QueryMemoriesOptions {\n type?: string;\n limit?: number;\n offset?: number;\n includeEmbeddings?: boolean;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * React entry point
3
+ */
4
+ export { MemoryIntelligenceProvider, useMemoryIntelligenceContext } from "./context/MemoryIntelligenceProvider";
5
+ export { useMemoryIntelligence, usePatternAnalysis, useTagSuggestions, useRelatedMemories, useDuplicateDetection, useInsightExtraction, useHealthCheck, } from "./hooks/useMemoryIntelligence";
6
+ export * from "../core/types";
7
+ export * from "../core/errors";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAChH,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}