@cmdoss/memwal-sdk 0.7.0 → 0.8.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 (192) hide show
  1. package/README.md +129 -0
  2. package/dist/client/ClientMemoryManager.js +2 -2
  3. package/dist/client/ClientMemoryManager.js.map +1 -1
  4. package/dist/client/PersonalDataWallet.d.ts.map +1 -1
  5. package/dist/client/SimplePDWClient.d.ts +28 -0
  6. package/dist/client/SimplePDWClient.d.ts.map +1 -1
  7. package/dist/client/SimplePDWClient.js +29 -6
  8. package/dist/client/SimplePDWClient.js.map +1 -1
  9. package/dist/client/namespaces/MemoryNamespace.d.ts +4 -0
  10. package/dist/client/namespaces/MemoryNamespace.d.ts.map +1 -1
  11. package/dist/client/namespaces/MemoryNamespace.js +168 -39
  12. package/dist/client/namespaces/MemoryNamespace.js.map +1 -1
  13. package/dist/client/namespaces/consolidated/BlockchainNamespace.d.ts +12 -2
  14. package/dist/client/namespaces/consolidated/BlockchainNamespace.d.ts.map +1 -1
  15. package/dist/client/namespaces/consolidated/BlockchainNamespace.js +40 -2
  16. package/dist/client/namespaces/consolidated/BlockchainNamespace.js.map +1 -1
  17. package/dist/client/namespaces/consolidated/StorageNamespace.d.ts +67 -2
  18. package/dist/client/namespaces/consolidated/StorageNamespace.d.ts.map +1 -1
  19. package/dist/client/namespaces/consolidated/StorageNamespace.js +549 -16
  20. package/dist/client/namespaces/consolidated/StorageNamespace.js.map +1 -1
  21. package/dist/config/ConfigurationHelper.js +61 -61
  22. package/dist/config/defaults.js +2 -2
  23. package/dist/config/defaults.js.map +1 -1
  24. package/dist/graph/GraphService.js +20 -20
  25. package/dist/infrastructure/seal/EncryptionService.d.ts +9 -5
  26. package/dist/infrastructure/seal/EncryptionService.d.ts.map +1 -1
  27. package/dist/infrastructure/seal/EncryptionService.js +37 -15
  28. package/dist/infrastructure/seal/EncryptionService.js.map +1 -1
  29. package/dist/infrastructure/seal/SealService.d.ts +13 -5
  30. package/dist/infrastructure/seal/SealService.d.ts.map +1 -1
  31. package/dist/infrastructure/seal/SealService.js +36 -34
  32. package/dist/infrastructure/seal/SealService.js.map +1 -1
  33. package/dist/langchain/createPDWRAG.js +30 -30
  34. package/dist/retrieval/MemoryDecryptionPipeline.d.ts.map +1 -1
  35. package/dist/retrieval/MemoryDecryptionPipeline.js +2 -1
  36. package/dist/retrieval/MemoryDecryptionPipeline.js.map +1 -1
  37. package/dist/services/CapabilityService.d.ts.map +1 -1
  38. package/dist/services/CapabilityService.js +30 -14
  39. package/dist/services/CapabilityService.js.map +1 -1
  40. package/dist/services/CrossContextPermissionService.d.ts.map +1 -1
  41. package/dist/services/CrossContextPermissionService.js +9 -7
  42. package/dist/services/CrossContextPermissionService.js.map +1 -1
  43. package/dist/services/EncryptionService.d.ts.map +1 -1
  44. package/dist/services/EncryptionService.js +6 -5
  45. package/dist/services/EncryptionService.js.map +1 -1
  46. package/dist/services/GeminiAIService.js +309 -309
  47. package/dist/services/StorageService.d.ts +1 -0
  48. package/dist/services/StorageService.d.ts.map +1 -1
  49. package/dist/services/StorageService.js +60 -10
  50. package/dist/services/StorageService.js.map +1 -1
  51. package/dist/services/TransactionService.d.ts +20 -0
  52. package/dist/services/TransactionService.d.ts.map +1 -1
  53. package/dist/services/TransactionService.js +43 -0
  54. package/dist/services/TransactionService.js.map +1 -1
  55. package/dist/services/ViewService.js +2 -2
  56. package/dist/services/ViewService.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/access/PermissionService.ts +635 -635
  59. package/src/access/index.ts +8 -8
  60. package/src/aggregation/AggregationService.ts +389 -389
  61. package/src/aggregation/index.ts +8 -8
  62. package/src/ai-sdk/PDWVectorStore.ts +715 -715
  63. package/src/ai-sdk/index.ts +65 -65
  64. package/src/ai-sdk/tools.ts +460 -460
  65. package/src/ai-sdk/types.ts +404 -404
  66. package/src/batch/BatchManager.ts +597 -597
  67. package/src/batch/BatchingService.ts +429 -429
  68. package/src/batch/MemoryProcessingCache.ts +492 -492
  69. package/src/batch/index.ts +30 -30
  70. package/src/browser.ts +200 -200
  71. package/src/client/ClientMemoryManager.ts +987 -987
  72. package/src/client/PersonalDataWallet.ts +345 -345
  73. package/src/client/SimplePDWClient.ts +1289 -1237
  74. package/src/client/factory.ts +154 -154
  75. package/src/client/namespaces/AnalyticsNamespace.ts +377 -377
  76. package/src/client/namespaces/BatchNamespace.ts +356 -356
  77. package/src/client/namespaces/CacheNamespace.ts +123 -123
  78. package/src/client/namespaces/CapabilityNamespace.ts +217 -217
  79. package/src/client/namespaces/ClassifyNamespace.ts +169 -169
  80. package/src/client/namespaces/ContextNamespace.ts +297 -297
  81. package/src/client/namespaces/EmbeddingsNamespace.ts +99 -99
  82. package/src/client/namespaces/EncryptionNamespace.ts +221 -221
  83. package/src/client/namespaces/GraphNamespace.ts +468 -468
  84. package/src/client/namespaces/IndexNamespace.ts +361 -361
  85. package/src/client/namespaces/MemoryNamespace.ts +1422 -1272
  86. package/src/client/namespaces/PermissionsNamespace.ts +254 -254
  87. package/src/client/namespaces/PipelineNamespace.ts +220 -220
  88. package/src/client/namespaces/SearchNamespace.ts +1049 -1049
  89. package/src/client/namespaces/StorageNamespace.ts +458 -458
  90. package/src/client/namespaces/TxNamespace.ts +260 -260
  91. package/src/client/namespaces/WalletNamespace.ts +243 -243
  92. package/src/client/namespaces/consolidated/AINamespace.ts +449 -449
  93. package/src/client/namespaces/consolidated/BlockchainNamespace.ts +607 -564
  94. package/src/client/namespaces/consolidated/SecurityNamespace.ts +648 -648
  95. package/src/client/namespaces/consolidated/StorageNamespace.ts +1141 -497
  96. package/src/client/namespaces/consolidated/index.ts +39 -39
  97. package/src/client/signers/DappKitSigner.ts +207 -207
  98. package/src/client/signers/KeypairSigner.ts +108 -108
  99. package/src/client/signers/UnifiedSigner.ts +110 -110
  100. package/src/client/signers/WalletAdapterSigner.ts +159 -159
  101. package/src/client/signers/index.ts +26 -26
  102. package/src/config/ConfigurationHelper.ts +412 -412
  103. package/src/config/defaults.ts +51 -51
  104. package/src/config/index.ts +8 -8
  105. package/src/config/validation.ts +70 -70
  106. package/src/core/index.ts +14 -14
  107. package/src/core/interfaces/IService.ts +307 -307
  108. package/src/core/interfaces/index.ts +8 -8
  109. package/src/core/types/capability.ts +297 -297
  110. package/src/core/types/index.ts +870 -870
  111. package/src/core/types/wallet.ts +270 -270
  112. package/src/core/types.ts +9 -9
  113. package/src/core/wallet.ts +222 -222
  114. package/src/embedding/index.ts +19 -19
  115. package/src/embedding/types.ts +357 -357
  116. package/src/errors/index.ts +602 -602
  117. package/src/errors/recovery.ts +461 -461
  118. package/src/errors/validation.ts +567 -567
  119. package/src/generated/pdw/capability.ts +319 -319
  120. package/src/generated/pdw/deps/sui/object.ts +12 -12
  121. package/src/generated/pdw/deps/sui/vec_map.ts +32 -32
  122. package/src/generated/pdw/memory.ts +1087 -1087
  123. package/src/generated/pdw/wallet.ts +123 -123
  124. package/src/generated/utils/index.ts +159 -159
  125. package/src/graph/GraphService.ts +887 -887
  126. package/src/graph/KnowledgeGraphManager.ts +728 -728
  127. package/src/graph/index.ts +25 -25
  128. package/src/index.ts +498 -498
  129. package/src/infrastructure/index.ts +22 -22
  130. package/src/infrastructure/seal/EncryptionService.ts +628 -603
  131. package/src/infrastructure/seal/SealService.ts +613 -615
  132. package/src/infrastructure/seal/index.ts +9 -9
  133. package/src/infrastructure/sui/BlockchainManager.ts +627 -627
  134. package/src/infrastructure/sui/SuiService.ts +888 -888
  135. package/src/infrastructure/sui/index.ts +9 -9
  136. package/src/infrastructure/walrus/StorageManager.ts +604 -604
  137. package/src/infrastructure/walrus/WalrusStorageService.ts +612 -612
  138. package/src/infrastructure/walrus/index.ts +9 -9
  139. package/src/langchain/PDWEmbeddings.ts +145 -145
  140. package/src/langchain/PDWVectorStore.ts +456 -456
  141. package/src/langchain/createPDWRAG.ts +303 -303
  142. package/src/langchain/index.ts +47 -47
  143. package/src/permissions/ConsentRepository.browser.ts +249 -249
  144. package/src/permissions/ConsentRepository.ts +364 -364
  145. package/src/permissions/index.ts +9 -9
  146. package/src/pipeline/MemoryPipeline.ts +862 -862
  147. package/src/pipeline/PipelineManager.ts +683 -683
  148. package/src/pipeline/index.ts +26 -26
  149. package/src/retrieval/AdvancedSearchService.ts +629 -629
  150. package/src/retrieval/MemoryAnalyticsService.ts +711 -711
  151. package/src/retrieval/MemoryDecryptionPipeline.ts +825 -824
  152. package/src/retrieval/MemoryRetrievalService.ts +904 -904
  153. package/src/retrieval/index.ts +42 -42
  154. package/src/services/BatchService.ts +352 -352
  155. package/src/services/CapabilityService.ts +464 -448
  156. package/src/services/ClassifierService.ts +465 -465
  157. package/src/services/CrossContextPermissionService.ts +486 -484
  158. package/src/services/EmbeddingService.ts +771 -771
  159. package/src/services/EncryptionService.ts +712 -711
  160. package/src/services/GeminiAIService.ts +753 -753
  161. package/src/services/IndexManager.ts +977 -977
  162. package/src/services/MemoryIndexService.ts +1003 -1003
  163. package/src/services/MemoryService.ts +369 -369
  164. package/src/services/QueryService.ts +890 -890
  165. package/src/services/StorageService.ts +1182 -1126
  166. package/src/services/TransactionService.ts +838 -790
  167. package/src/services/VectorService.ts +462 -462
  168. package/src/services/ViewService.ts +484 -484
  169. package/src/services/index.ts +25 -25
  170. package/src/services/storage/BlobAttributesManager.ts +333 -333
  171. package/src/services/storage/KnowledgeGraphManager.ts +425 -425
  172. package/src/services/storage/MemorySearchManager.ts +387 -387
  173. package/src/services/storage/QuiltBatchManager.ts +1130 -1130
  174. package/src/services/storage/WalrusMetadataManager.ts +268 -268
  175. package/src/services/storage/WalrusStorageManager.ts +287 -287
  176. package/src/services/storage/index.ts +57 -57
  177. package/src/types/index.ts +13 -13
  178. package/src/utils/LRUCache.ts +378 -378
  179. package/src/utils/index.ts +76 -76
  180. package/src/utils/memoryIndexOnChain.ts +507 -507
  181. package/src/utils/rebuildIndex.ts +290 -290
  182. package/src/utils/rebuildIndexNode.ts +771 -771
  183. package/src/vector/BrowserHnswIndexService.ts +758 -758
  184. package/src/vector/HnswWasmService.ts +731 -731
  185. package/src/vector/IHnswService.ts +233 -233
  186. package/src/vector/NodeHnswService.ts +833 -833
  187. package/src/vector/VectorManager.ts +478 -478
  188. package/src/vector/createHnswService.ts +135 -135
  189. package/src/vector/index.ts +56 -56
  190. package/src/wallet/ContextWalletService.ts +656 -656
  191. package/src/wallet/MainWalletService.ts +317 -317
  192. package/src/wallet/index.ts +17 -17
package/src/index.ts CHANGED
@@ -1,498 +1,498 @@
1
- /**
2
- * Personal Data Wallet SDK
3
- *
4
- * Comprehensive SDK for decentralized memory processing with AI-powered insights.
5
- *
6
- * Features:
7
- * - 🧠 Local AI embedding generation (Gemini API)
8
- * - 🔍 HNSW vector indexing with intelligent batching
9
- * - 📊 Knowledge graph extraction and management
10
- * - 🗄️ Walrus decentralized storage with encryption
11
- * - ⛓️ Sui blockchain ownership tracking
12
- * - 🔄 Unified processing pipeline with monitoring
13
- *
14
- * @version 1.0.0
15
- * @author Personal Data Wallet Team
16
- */
17
-
18
- // Core pipeline - the main entry point
19
- export { MemoryPipeline, PipelineManager } from './pipeline';
20
- export type {
21
- PipelineConfig,
22
- PipelineExecution,
23
- PipelineMetrics,
24
- PipelineManagerConfig,
25
- SystemMetrics
26
- } from './pipeline';
27
-
28
- // Import for internal use
29
- import { MemoryPipeline } from './pipeline/MemoryPipeline';
30
- import { PipelineManager } from './pipeline/PipelineManager';
31
- import type { PipelineConfig, PipelineManagerConfig } from './pipeline';
32
-
33
- // ==================== SERVICES ====================
34
- // Business logic services
35
- export { StorageService } from './services/StorageService';
36
- export {
37
- EmbeddingService,
38
- getSharedEmbeddingService,
39
- clearSharedEmbeddingServices,
40
- getSharedEmbeddingStats,
41
- } from './services/EmbeddingService';
42
- export { GeminiAIService } from './services/GeminiAIService';
43
- export { QueryService } from './services/QueryService';
44
- export { ClassifierService } from './services/ClassifierService';
45
- export { MemoryIndexService } from './services/MemoryIndexService';
46
- export { ViewService } from './services/ViewService';
47
- export { TransactionService } from './services/TransactionService';
48
- export { BatchService } from './services/BatchService';
49
- export { CrossContextPermissionService } from './services/CrossContextPermissionService';
50
- export { MemoryService } from './services/MemoryService';
51
- export { VectorService } from './services/VectorService';
52
- export { CapabilityService } from './services/CapabilityService';
53
- export { IndexManager } from './services/IndexManager';
54
- export type {
55
- IndexState,
56
- SerializedIndexPackage,
57
- IndexProgressCallback,
58
- IndexManagerOptions
59
- } from './services/IndexManager';
60
-
61
- // ==================== INFRASTRUCTURE ====================
62
- // External integrations (use these instead of old paths)
63
- export { WalrusStorageService, StorageManager } from './infrastructure/walrus';
64
- export { SuiService, BlockchainManager } from './infrastructure/sui';
65
- export { SealService } from './infrastructure/seal';
66
- export { EncryptionService } from './infrastructure/seal';
67
-
68
- // ==================== CORE ====================
69
- // Core interfaces and base classes
70
- export * from './core/interfaces';
71
-
72
- // ==================== UTILITIES ====================
73
- // Vector indexing and batch processing
74
- export { VectorManager, createHnswService, isBrowser, isNode } from './vector';
75
- export type { IHnswService, IHnswSearchResultItem, IHnswSearchOptions, IHnswBatchStats } from './vector';
76
- export { BrowserHnswIndexService } from './vector/BrowserHnswIndexService';
77
- export { BatchManager, BatchingService, MemoryProcessingCache } from './batch';
78
- export { GraphService, KnowledgeGraphManager } from './graph';
79
-
80
- // Memory retrieval, analytics, and decryption
81
- export { MemoryRetrievalService, MemoryDecryptionPipeline } from './retrieval';
82
- export type {
83
- UnifiedMemoryQuery,
84
- UnifiedMemoryResult,
85
- RetrievalStats,
86
- RetrievalContext,
87
- KeyServerConfig,
88
- DecryptionConfig,
89
- DecryptionRequest,
90
- DecryptionResult,
91
- BatchDecryptionResult
92
- } from './retrieval';
93
-
94
- // Configuration management
95
- import { Config as ConfigClass } from './config';
96
- export { ConfigurationHelper, Config } from './config';
97
- export type { SDKConfig, EnvironmentConfig } from './config';
98
-
99
- // Internal Config reference for use in this file
100
- const Config = ConfigClass;
101
-
102
- // Type exports for all modules
103
- export type {
104
- Memory,
105
- ProcessedMemory,
106
- EmbeddingResult,
107
- EmbeddingConfig
108
- } from './embedding/types';
109
-
110
- export type {
111
- VectorSearchResult,
112
- HNSWIndexConfig
113
- } from './vector';
114
-
115
- export type {
116
- CacheConfig,
117
- CacheMetrics
118
- } from './batch';
119
-
120
- export type {
121
- Entity,
122
- Relationship,
123
- KnowledgeGraph
124
- } from './graph';
125
-
126
- // Infrastructure types - Walrus
127
- export type {
128
- WalrusUploadResult,
129
- WalrusRetrievalResult,
130
- MemoryMetadata
131
- } from './infrastructure/walrus/WalrusStorageService';
132
-
133
- export type {
134
- StorageResult
135
- } from './infrastructure/walrus/StorageManager';
136
-
137
- // Infrastructure types - Sui
138
- export type {
139
- MemoryRecord,
140
- TransactionResult
141
- } from './infrastructure/sui/SuiService';
142
-
143
- export type {
144
- OwnershipVerification,
145
- BlockchainStats
146
- } from './infrastructure/sui/BlockchainManager';
147
-
148
- // Utility exports - using imported classes above
149
-
150
- /**
151
- * SDK Version Information
152
- */
153
- export const SDK_VERSION = '1.0.0';
154
- export const SDK_NAME = 'Personal Data Wallet SDK';
155
-
156
- /**
157
- * Quick start configuration presets
158
- */
159
- export const QuickStartConfigs = {
160
- /**
161
- * Basic configuration for simple memory processing
162
- */
163
- BASIC: {
164
- embedding: {
165
- enableBatching: true,
166
- batchSize: 10
167
- },
168
- storage: {
169
- enableEncryption: false,
170
- enableBatching: false
171
- },
172
- blockchain: {
173
- enableOwnershipTracking: false
174
- }
175
- } as PipelineConfig,
176
-
177
- /**
178
- * Full decentralized configuration with all features
179
- */
180
- DECENTRALIZED: {
181
- embedding: {
182
- enableBatching: true,
183
- batchSize: 20
184
- },
185
- vector: {
186
- enablePersistence: true,
187
- maxElements: 10000
188
- },
189
- graph: {
190
- enableExtraction: true,
191
- confidenceThreshold: 0.7
192
- },
193
- storage: {
194
- enableEncryption: true,
195
- enableBatching: true,
196
- network: 'testnet'
197
- },
198
- blockchain: {
199
- enableOwnershipTracking: true,
200
- enableBatching: true,
201
- network: 'testnet'
202
- },
203
- enableRollback: true,
204
- enableMonitoring: true
205
- } as PipelineConfig,
206
-
207
- /**
208
- * High-performance configuration optimized for throughput
209
- */
210
- HIGH_PERFORMANCE: {
211
- embedding: {
212
- enableBatching: true,
213
- batchSize: 50
214
- },
215
- batch: {
216
- enableBatching: true,
217
- batchSize: 100,
218
- batchDelayMs: 2000
219
- },
220
- vector: {
221
- maxElements: 50000,
222
- enablePersistence: true
223
- },
224
- graph: {
225
- enableExtraction: false // Disable for performance
226
- },
227
- storage: {
228
- enableBatching: true,
229
- enableEncryption: false // Disable for performance
230
- },
231
- blockchain: {
232
- enableBatching: true,
233
- enableOwnershipTracking: true
234
- },
235
- skipFailedSteps: true,
236
- maxRetryAttempts: 1,
237
- enableMonitoring: true
238
- } as PipelineConfig,
239
-
240
- /**
241
- * Development configuration with enhanced debugging
242
- */
243
- DEVELOPMENT: {
244
- embedding: {
245
- enableBatching: false // Process individually for debugging
246
- },
247
- vector: {
248
- maxElements: 1000
249
- },
250
- graph: {
251
- enableExtraction: true,
252
- confidenceThreshold: 0.5 // Lower threshold for testing
253
- },
254
- storage: {
255
- enableEncryption: false,
256
- enableBatching: false
257
- },
258
- blockchain: {
259
- enableOwnershipTracking: false, // Skip for dev
260
- enableBatching: false
261
- },
262
- enableRollback: true,
263
- enableMonitoring: true,
264
- skipFailedSteps: false,
265
- maxRetryAttempts: 0 // Fail fast for debugging
266
- } as PipelineConfig
267
- };
268
-
269
- /**
270
- * Create a pre-configured pipeline with quick start settings
271
- */
272
- export function createQuickStartPipeline(
273
- preset: keyof typeof QuickStartConfigs,
274
- overrides: Partial<PipelineConfig> = {}
275
- ): MemoryPipeline {
276
- const baseConfig = QuickStartConfigs[preset];
277
- const mergedConfig = { ...baseConfig, ...overrides };
278
-
279
- // Auto-configure API key if not provided
280
- if (!mergedConfig.embedding?.apiKey) {
281
- try {
282
- // Config is already imported at top of file
283
- const apiKey = Config.getGeminiKey();
284
- mergedConfig.embedding = {
285
- ...mergedConfig.embedding,
286
- apiKey
287
- };
288
- console.log('✅ Auto-configured Gemini API key from environment');
289
- } catch (error) {
290
- console.warn('⚠️ No Gemini API key found. Please provide one for AI features to work.');
291
- }
292
- }
293
-
294
- return new MemoryPipeline(mergedConfig);
295
- }
296
-
297
- /**
298
- * Create a pipeline manager with recommended settings
299
- */
300
- export function createPipelineManager(
301
- config: Partial<PipelineManagerConfig> = {}
302
- ): PipelineManager {
303
- const defaultConfig: PipelineManagerConfig = {
304
- maxConcurrentPipelines: 5,
305
- enableScheduling: true,
306
- enableHealthChecks: true,
307
- enableMetricsCollection: true,
308
- defaultPipelineConfig: QuickStartConfigs.BASIC
309
- };
310
-
311
- const mergedConfig = { ...defaultConfig, ...config };
312
- return new PipelineManager(mergedConfig);
313
- }
314
-
315
- /**
316
- * SDK Information and utilities
317
- */
318
- export const SDK = {
319
- version: SDK_VERSION,
320
- name: SDK_NAME,
321
-
322
- /**
323
- * Get SDK build information
324
- */
325
- getBuildInfo(): {
326
- version: string;
327
- name: string;
328
- buildDate: string;
329
- features: string[];
330
- } {
331
- return {
332
- version: SDK_VERSION,
333
- name: SDK_NAME,
334
- buildDate: new Date().toISOString(),
335
- features: [
336
- 'AI Embedding Generation',
337
- 'HNSW Vector Indexing',
338
- 'Knowledge Graph Extraction',
339
- 'Walrus Decentralized Storage',
340
- 'Sui Blockchain Integration',
341
- 'Unified Processing Pipeline',
342
- 'Batch Processing & Caching',
343
- 'Comprehensive Monitoring'
344
- ]
345
- };
346
- },
347
-
348
- /**
349
- * Validate configuration
350
- */
351
- validateConfig(config: PipelineConfig): {
352
- isValid: boolean;
353
- errors: string[];
354
- warnings: string[];
355
- } {
356
- const errors: string[] = [];
357
- const warnings: string[] = [];
358
-
359
- // Validate embedding config
360
- if (config.embedding?.batchSize && config.embedding.batchSize > 100) {
361
- warnings.push('Large embedding batch size may cause memory issues');
362
- }
363
-
364
- // Validate vector config
365
- if (config.vector?.maxElements && config.vector.maxElements > 100000) {
366
- warnings.push('Large vector index may impact performance');
367
- }
368
-
369
- // Validate network consistency
370
- if (config.storage?.network !== config.blockchain?.network) {
371
- warnings.push('Storage and blockchain networks should match');
372
- }
373
-
374
- return {
375
- isValid: errors.length === 0,
376
- errors,
377
- warnings
378
- };
379
- }
380
- };
381
-
382
- // Default export for convenience
383
- export default {
384
- MemoryPipeline,
385
- PipelineManager,
386
- createQuickStartPipeline,
387
- createPipelineManager,
388
- QuickStartConfigs,
389
- SDK
390
- };
391
-
392
- // Client-side memory management for React dApps
393
- export { ClientMemoryManager } from './client/ClientMemoryManager';
394
- export { PersonalDataWallet } from './client/PersonalDataWallet';
395
- export { SimplePDWClient } from './client/SimplePDWClient';
396
- export type { SimplePDWConfig, ServiceContainer } from './client/SimplePDWClient';
397
-
398
- // Signer abstractions for different environments
399
- export {
400
- KeypairSigner,
401
- WalletAdapterSigner,
402
- DappKitSigner
403
- } from './client/signers';
404
- export type {
405
- UnifiedSigner,
406
- SignAndExecuteResult,
407
- SignPersonalMessageResult,
408
- WalletAdapter,
409
- DappKitSignerConfig,
410
- DappKitSignAndExecuteFn,
411
- DappKitSignPersonalMessageFn
412
- } from './client/signers';
413
- export type {
414
- ClientMemoryManagerConfig,
415
- CreateMemoryOptions as ClientCreateMemoryOptions,
416
- RetrieveMemoryOptions as ClientRetrieveMemoryOptions,
417
- BatchRetrieveMemoriesOptions as ClientBatchRetrieveMemoriesOptions,
418
- BatchRetrieveResult as ClientBatchRetrieveResult,
419
- ClientMemoryMetadata
420
- } from './client/ClientMemoryManager';
421
-
422
- // Wallet architecture components
423
- /** @deprecated Use CapabilityService instead */
424
- export { MainWalletService } from './wallet/MainWalletService';
425
- /** @deprecated Use ContextNamespace instead */
426
- export { ContextWalletService } from './wallet/ContextWalletService';
427
- export { PermissionService } from './access/PermissionService';
428
- export type { ConsentRepository } from './permissions/ConsentRepository';
429
- export { FileSystemConsentRepository, InMemoryConsentRepository } from './permissions/ConsentRepository';
430
- export { AggregationService } from './aggregation/AggregationService';
431
- export type {
432
- MainWallet,
433
- ContextWallet,
434
- ConsentRequest,
435
- ConsentRequestRecord,
436
- ConsentStatus,
437
- AccessGrant,
438
- CreateMainWalletOptions,
439
- CreateContextWalletOptions,
440
- DeriveContextIdOptions,
441
- RotateKeysOptions,
442
- RotateKeysResult,
443
- PermissionScope,
444
- RequestConsentOptions,
445
- GrantPermissionsOptions,
446
- RevokePermissionsOptions,
447
- AggregatedQueryOptions,
448
- PermissionScopes
449
- } from './core/types/wallet';
450
-
451
- // Legacy version for compatibility
452
- export const VERSION = '1.0.0';
453
-
454
- // Rebuild utility (Browser)
455
- export { rebuildIndex, hasExistingIndex, clearIndex } from './utils/rebuildIndex';
456
- export type { RebuildIndexOptions, RebuildIndexResult } from './utils/rebuildIndex';
457
-
458
- // Rebuild utility (Node.js)
459
- export { rebuildIndexNode, hasExistingIndexNode, clearIndexNode } from './utils/rebuildIndexNode';
460
- export type { RebuildIndexNodeOptions, RebuildIndexNodeResult } from './utils/rebuildIndexNode';
461
-
462
- // MemoryIndex on-chain utilities
463
- export {
464
- getMemoryIndex,
465
- updateMemoryIndexOnChain,
466
- createMemoryIndexOnChain,
467
- syncIndexAndUpdateOnChain,
468
- uploadPlaceholderToWalrus
469
- } from './utils/memoryIndexOnChain';
470
- export type {
471
- OnChainMemoryIndex,
472
- GetMemoryIndexOptions,
473
- UpdateMemoryIndexOnChainOptions,
474
- CreateMemoryIndexOnChainOptions,
475
- UpdateMemoryIndexResult,
476
- CreateMemoryIndexResult,
477
- SyncAndUpdateOptions,
478
- SyncAndUpdateResult
479
- } from './utils/memoryIndexOnChain';
480
-
481
- // ==================== AI SDK INTEGRATION ====================
482
- // AI SDK tools and vector store for Vercel AI SDK integration
483
- export { pdwTools } from './ai-sdk/tools';
484
- export type { PDWToolsConfig, PDWToolResult } from './ai-sdk/tools';
485
- export { PDWVectorStore as AIPDWVectorStore } from './ai-sdk/PDWVectorStore';
486
- export type {
487
- PDWVectorStoreConfig as AIPDWVectorStoreConfig,
488
- AddVectorParams,
489
- SearchParams as AISearchParams,
490
- SearchResult as AISearchResult
491
- } from './ai-sdk/types';
492
-
493
- // ==================== LANGCHAIN INTEGRATION ====================
494
- // LangChain adapters for RAG workflows with decentralized storage
495
- export { PDWEmbeddings } from './langchain/PDWEmbeddings';
496
- export type { PDWEmbeddingsParams } from './langchain/PDWEmbeddings';
497
- export { PDWVectorStore } from './langchain/PDWVectorStore';
498
- export type { PDWVectorStoreConfig, PDWAddDocumentOptions } from './langchain/PDWVectorStore';
1
+ /**
2
+ * Personal Data Wallet SDK
3
+ *
4
+ * Comprehensive SDK for decentralized memory processing with AI-powered insights.
5
+ *
6
+ * Features:
7
+ * - 🧠 Local AI embedding generation (Gemini API)
8
+ * - 🔍 HNSW vector indexing with intelligent batching
9
+ * - 📊 Knowledge graph extraction and management
10
+ * - 🗄️ Walrus decentralized storage with encryption
11
+ * - ⛓️ Sui blockchain ownership tracking
12
+ * - 🔄 Unified processing pipeline with monitoring
13
+ *
14
+ * @version 1.0.0
15
+ * @author Personal Data Wallet Team
16
+ */
17
+
18
+ // Core pipeline - the main entry point
19
+ export { MemoryPipeline, PipelineManager } from './pipeline';
20
+ export type {
21
+ PipelineConfig,
22
+ PipelineExecution,
23
+ PipelineMetrics,
24
+ PipelineManagerConfig,
25
+ SystemMetrics
26
+ } from './pipeline';
27
+
28
+ // Import for internal use
29
+ import { MemoryPipeline } from './pipeline/MemoryPipeline';
30
+ import { PipelineManager } from './pipeline/PipelineManager';
31
+ import type { PipelineConfig, PipelineManagerConfig } from './pipeline';
32
+
33
+ // ==================== SERVICES ====================
34
+ // Business logic services
35
+ export { StorageService } from './services/StorageService';
36
+ export {
37
+ EmbeddingService,
38
+ getSharedEmbeddingService,
39
+ clearSharedEmbeddingServices,
40
+ getSharedEmbeddingStats,
41
+ } from './services/EmbeddingService';
42
+ export { GeminiAIService } from './services/GeminiAIService';
43
+ export { QueryService } from './services/QueryService';
44
+ export { ClassifierService } from './services/ClassifierService';
45
+ export { MemoryIndexService } from './services/MemoryIndexService';
46
+ export { ViewService } from './services/ViewService';
47
+ export { TransactionService } from './services/TransactionService';
48
+ export { BatchService } from './services/BatchService';
49
+ export { CrossContextPermissionService } from './services/CrossContextPermissionService';
50
+ export { MemoryService } from './services/MemoryService';
51
+ export { VectorService } from './services/VectorService';
52
+ export { CapabilityService } from './services/CapabilityService';
53
+ export { IndexManager } from './services/IndexManager';
54
+ export type {
55
+ IndexState,
56
+ SerializedIndexPackage,
57
+ IndexProgressCallback,
58
+ IndexManagerOptions
59
+ } from './services/IndexManager';
60
+
61
+ // ==================== INFRASTRUCTURE ====================
62
+ // External integrations (use these instead of old paths)
63
+ export { WalrusStorageService, StorageManager } from './infrastructure/walrus';
64
+ export { SuiService, BlockchainManager } from './infrastructure/sui';
65
+ export { SealService } from './infrastructure/seal';
66
+ export { EncryptionService } from './infrastructure/seal';
67
+
68
+ // ==================== CORE ====================
69
+ // Core interfaces and base classes
70
+ export * from './core/interfaces';
71
+
72
+ // ==================== UTILITIES ====================
73
+ // Vector indexing and batch processing
74
+ export { VectorManager, createHnswService, isBrowser, isNode } from './vector';
75
+ export type { IHnswService, IHnswSearchResultItem, IHnswSearchOptions, IHnswBatchStats } from './vector';
76
+ export { BrowserHnswIndexService } from './vector/BrowserHnswIndexService';
77
+ export { BatchManager, BatchingService, MemoryProcessingCache } from './batch';
78
+ export { GraphService, KnowledgeGraphManager } from './graph';
79
+
80
+ // Memory retrieval, analytics, and decryption
81
+ export { MemoryRetrievalService, MemoryDecryptionPipeline } from './retrieval';
82
+ export type {
83
+ UnifiedMemoryQuery,
84
+ UnifiedMemoryResult,
85
+ RetrievalStats,
86
+ RetrievalContext,
87
+ KeyServerConfig,
88
+ DecryptionConfig,
89
+ DecryptionRequest,
90
+ DecryptionResult,
91
+ BatchDecryptionResult
92
+ } from './retrieval';
93
+
94
+ // Configuration management
95
+ import { Config as ConfigClass } from './config';
96
+ export { ConfigurationHelper, Config } from './config';
97
+ export type { SDKConfig, EnvironmentConfig } from './config';
98
+
99
+ // Internal Config reference for use in this file
100
+ const Config = ConfigClass;
101
+
102
+ // Type exports for all modules
103
+ export type {
104
+ Memory,
105
+ ProcessedMemory,
106
+ EmbeddingResult,
107
+ EmbeddingConfig
108
+ } from './embedding/types';
109
+
110
+ export type {
111
+ VectorSearchResult,
112
+ HNSWIndexConfig
113
+ } from './vector';
114
+
115
+ export type {
116
+ CacheConfig,
117
+ CacheMetrics
118
+ } from './batch';
119
+
120
+ export type {
121
+ Entity,
122
+ Relationship,
123
+ KnowledgeGraph
124
+ } from './graph';
125
+
126
+ // Infrastructure types - Walrus
127
+ export type {
128
+ WalrusUploadResult,
129
+ WalrusRetrievalResult,
130
+ MemoryMetadata
131
+ } from './infrastructure/walrus/WalrusStorageService';
132
+
133
+ export type {
134
+ StorageResult
135
+ } from './infrastructure/walrus/StorageManager';
136
+
137
+ // Infrastructure types - Sui
138
+ export type {
139
+ MemoryRecord,
140
+ TransactionResult
141
+ } from './infrastructure/sui/SuiService';
142
+
143
+ export type {
144
+ OwnershipVerification,
145
+ BlockchainStats
146
+ } from './infrastructure/sui/BlockchainManager';
147
+
148
+ // Utility exports - using imported classes above
149
+
150
+ /**
151
+ * SDK Version Information
152
+ */
153
+ export const SDK_VERSION = '1.0.0';
154
+ export const SDK_NAME = 'Personal Data Wallet SDK';
155
+
156
+ /**
157
+ * Quick start configuration presets
158
+ */
159
+ export const QuickStartConfigs = {
160
+ /**
161
+ * Basic configuration for simple memory processing
162
+ */
163
+ BASIC: {
164
+ embedding: {
165
+ enableBatching: true,
166
+ batchSize: 10
167
+ },
168
+ storage: {
169
+ enableEncryption: false,
170
+ enableBatching: false
171
+ },
172
+ blockchain: {
173
+ enableOwnershipTracking: false
174
+ }
175
+ } as PipelineConfig,
176
+
177
+ /**
178
+ * Full decentralized configuration with all features
179
+ */
180
+ DECENTRALIZED: {
181
+ embedding: {
182
+ enableBatching: true,
183
+ batchSize: 20
184
+ },
185
+ vector: {
186
+ enablePersistence: true,
187
+ maxElements: 10000
188
+ },
189
+ graph: {
190
+ enableExtraction: true,
191
+ confidenceThreshold: 0.7
192
+ },
193
+ storage: {
194
+ enableEncryption: true,
195
+ enableBatching: true,
196
+ network: 'testnet'
197
+ },
198
+ blockchain: {
199
+ enableOwnershipTracking: true,
200
+ enableBatching: true,
201
+ network: 'testnet'
202
+ },
203
+ enableRollback: true,
204
+ enableMonitoring: true
205
+ } as PipelineConfig,
206
+
207
+ /**
208
+ * High-performance configuration optimized for throughput
209
+ */
210
+ HIGH_PERFORMANCE: {
211
+ embedding: {
212
+ enableBatching: true,
213
+ batchSize: 50
214
+ },
215
+ batch: {
216
+ enableBatching: true,
217
+ batchSize: 100,
218
+ batchDelayMs: 2000
219
+ },
220
+ vector: {
221
+ maxElements: 50000,
222
+ enablePersistence: true
223
+ },
224
+ graph: {
225
+ enableExtraction: false // Disable for performance
226
+ },
227
+ storage: {
228
+ enableBatching: true,
229
+ enableEncryption: false // Disable for performance
230
+ },
231
+ blockchain: {
232
+ enableBatching: true,
233
+ enableOwnershipTracking: true
234
+ },
235
+ skipFailedSteps: true,
236
+ maxRetryAttempts: 1,
237
+ enableMonitoring: true
238
+ } as PipelineConfig,
239
+
240
+ /**
241
+ * Development configuration with enhanced debugging
242
+ */
243
+ DEVELOPMENT: {
244
+ embedding: {
245
+ enableBatching: false // Process individually for debugging
246
+ },
247
+ vector: {
248
+ maxElements: 1000
249
+ },
250
+ graph: {
251
+ enableExtraction: true,
252
+ confidenceThreshold: 0.5 // Lower threshold for testing
253
+ },
254
+ storage: {
255
+ enableEncryption: false,
256
+ enableBatching: false
257
+ },
258
+ blockchain: {
259
+ enableOwnershipTracking: false, // Skip for dev
260
+ enableBatching: false
261
+ },
262
+ enableRollback: true,
263
+ enableMonitoring: true,
264
+ skipFailedSteps: false,
265
+ maxRetryAttempts: 0 // Fail fast for debugging
266
+ } as PipelineConfig
267
+ };
268
+
269
+ /**
270
+ * Create a pre-configured pipeline with quick start settings
271
+ */
272
+ export function createQuickStartPipeline(
273
+ preset: keyof typeof QuickStartConfigs,
274
+ overrides: Partial<PipelineConfig> = {}
275
+ ): MemoryPipeline {
276
+ const baseConfig = QuickStartConfigs[preset];
277
+ const mergedConfig = { ...baseConfig, ...overrides };
278
+
279
+ // Auto-configure API key if not provided
280
+ if (!mergedConfig.embedding?.apiKey) {
281
+ try {
282
+ // Config is already imported at top of file
283
+ const apiKey = Config.getGeminiKey();
284
+ mergedConfig.embedding = {
285
+ ...mergedConfig.embedding,
286
+ apiKey
287
+ };
288
+ console.log('✅ Auto-configured Gemini API key from environment');
289
+ } catch (error) {
290
+ console.warn('⚠️ No Gemini API key found. Please provide one for AI features to work.');
291
+ }
292
+ }
293
+
294
+ return new MemoryPipeline(mergedConfig);
295
+ }
296
+
297
+ /**
298
+ * Create a pipeline manager with recommended settings
299
+ */
300
+ export function createPipelineManager(
301
+ config: Partial<PipelineManagerConfig> = {}
302
+ ): PipelineManager {
303
+ const defaultConfig: PipelineManagerConfig = {
304
+ maxConcurrentPipelines: 5,
305
+ enableScheduling: true,
306
+ enableHealthChecks: true,
307
+ enableMetricsCollection: true,
308
+ defaultPipelineConfig: QuickStartConfigs.BASIC
309
+ };
310
+
311
+ const mergedConfig = { ...defaultConfig, ...config };
312
+ return new PipelineManager(mergedConfig);
313
+ }
314
+
315
+ /**
316
+ * SDK Information and utilities
317
+ */
318
+ export const SDK = {
319
+ version: SDK_VERSION,
320
+ name: SDK_NAME,
321
+
322
+ /**
323
+ * Get SDK build information
324
+ */
325
+ getBuildInfo(): {
326
+ version: string;
327
+ name: string;
328
+ buildDate: string;
329
+ features: string[];
330
+ } {
331
+ return {
332
+ version: SDK_VERSION,
333
+ name: SDK_NAME,
334
+ buildDate: new Date().toISOString(),
335
+ features: [
336
+ 'AI Embedding Generation',
337
+ 'HNSW Vector Indexing',
338
+ 'Knowledge Graph Extraction',
339
+ 'Walrus Decentralized Storage',
340
+ 'Sui Blockchain Integration',
341
+ 'Unified Processing Pipeline',
342
+ 'Batch Processing & Caching',
343
+ 'Comprehensive Monitoring'
344
+ ]
345
+ };
346
+ },
347
+
348
+ /**
349
+ * Validate configuration
350
+ */
351
+ validateConfig(config: PipelineConfig): {
352
+ isValid: boolean;
353
+ errors: string[];
354
+ warnings: string[];
355
+ } {
356
+ const errors: string[] = [];
357
+ const warnings: string[] = [];
358
+
359
+ // Validate embedding config
360
+ if (config.embedding?.batchSize && config.embedding.batchSize > 100) {
361
+ warnings.push('Large embedding batch size may cause memory issues');
362
+ }
363
+
364
+ // Validate vector config
365
+ if (config.vector?.maxElements && config.vector.maxElements > 100000) {
366
+ warnings.push('Large vector index may impact performance');
367
+ }
368
+
369
+ // Validate network consistency
370
+ if (config.storage?.network !== config.blockchain?.network) {
371
+ warnings.push('Storage and blockchain networks should match');
372
+ }
373
+
374
+ return {
375
+ isValid: errors.length === 0,
376
+ errors,
377
+ warnings
378
+ };
379
+ }
380
+ };
381
+
382
+ // Default export for convenience
383
+ export default {
384
+ MemoryPipeline,
385
+ PipelineManager,
386
+ createQuickStartPipeline,
387
+ createPipelineManager,
388
+ QuickStartConfigs,
389
+ SDK
390
+ };
391
+
392
+ // Client-side memory management for React dApps
393
+ export { ClientMemoryManager } from './client/ClientMemoryManager';
394
+ export { PersonalDataWallet } from './client/PersonalDataWallet';
395
+ export { SimplePDWClient } from './client/SimplePDWClient';
396
+ export type { SimplePDWConfig, ServiceContainer } from './client/SimplePDWClient';
397
+
398
+ // Signer abstractions for different environments
399
+ export {
400
+ KeypairSigner,
401
+ WalletAdapterSigner,
402
+ DappKitSigner
403
+ } from './client/signers';
404
+ export type {
405
+ UnifiedSigner,
406
+ SignAndExecuteResult,
407
+ SignPersonalMessageResult,
408
+ WalletAdapter,
409
+ DappKitSignerConfig,
410
+ DappKitSignAndExecuteFn,
411
+ DappKitSignPersonalMessageFn
412
+ } from './client/signers';
413
+ export type {
414
+ ClientMemoryManagerConfig,
415
+ CreateMemoryOptions as ClientCreateMemoryOptions,
416
+ RetrieveMemoryOptions as ClientRetrieveMemoryOptions,
417
+ BatchRetrieveMemoriesOptions as ClientBatchRetrieveMemoriesOptions,
418
+ BatchRetrieveResult as ClientBatchRetrieveResult,
419
+ ClientMemoryMetadata
420
+ } from './client/ClientMemoryManager';
421
+
422
+ // Wallet architecture components
423
+ /** @deprecated Use CapabilityService instead */
424
+ export { MainWalletService } from './wallet/MainWalletService';
425
+ /** @deprecated Use ContextNamespace instead */
426
+ export { ContextWalletService } from './wallet/ContextWalletService';
427
+ export { PermissionService } from './access/PermissionService';
428
+ export type { ConsentRepository } from './permissions/ConsentRepository';
429
+ export { FileSystemConsentRepository, InMemoryConsentRepository } from './permissions/ConsentRepository';
430
+ export { AggregationService } from './aggregation/AggregationService';
431
+ export type {
432
+ MainWallet,
433
+ ContextWallet,
434
+ ConsentRequest,
435
+ ConsentRequestRecord,
436
+ ConsentStatus,
437
+ AccessGrant,
438
+ CreateMainWalletOptions,
439
+ CreateContextWalletOptions,
440
+ DeriveContextIdOptions,
441
+ RotateKeysOptions,
442
+ RotateKeysResult,
443
+ PermissionScope,
444
+ RequestConsentOptions,
445
+ GrantPermissionsOptions,
446
+ RevokePermissionsOptions,
447
+ AggregatedQueryOptions,
448
+ PermissionScopes
449
+ } from './core/types/wallet';
450
+
451
+ // Legacy version for compatibility
452
+ export const VERSION = '1.0.0';
453
+
454
+ // Rebuild utility (Browser)
455
+ export { rebuildIndex, hasExistingIndex, clearIndex } from './utils/rebuildIndex';
456
+ export type { RebuildIndexOptions, RebuildIndexResult } from './utils/rebuildIndex';
457
+
458
+ // Rebuild utility (Node.js)
459
+ export { rebuildIndexNode, hasExistingIndexNode, clearIndexNode } from './utils/rebuildIndexNode';
460
+ export type { RebuildIndexNodeOptions, RebuildIndexNodeResult } from './utils/rebuildIndexNode';
461
+
462
+ // MemoryIndex on-chain utilities
463
+ export {
464
+ getMemoryIndex,
465
+ updateMemoryIndexOnChain,
466
+ createMemoryIndexOnChain,
467
+ syncIndexAndUpdateOnChain,
468
+ uploadPlaceholderToWalrus
469
+ } from './utils/memoryIndexOnChain';
470
+ export type {
471
+ OnChainMemoryIndex,
472
+ GetMemoryIndexOptions,
473
+ UpdateMemoryIndexOnChainOptions,
474
+ CreateMemoryIndexOnChainOptions,
475
+ UpdateMemoryIndexResult,
476
+ CreateMemoryIndexResult,
477
+ SyncAndUpdateOptions,
478
+ SyncAndUpdateResult
479
+ } from './utils/memoryIndexOnChain';
480
+
481
+ // ==================== AI SDK INTEGRATION ====================
482
+ // AI SDK tools and vector store for Vercel AI SDK integration
483
+ export { pdwTools } from './ai-sdk/tools';
484
+ export type { PDWToolsConfig, PDWToolResult } from './ai-sdk/tools';
485
+ export { PDWVectorStore as AIPDWVectorStore } from './ai-sdk/PDWVectorStore';
486
+ export type {
487
+ PDWVectorStoreConfig as AIPDWVectorStoreConfig,
488
+ AddVectorParams,
489
+ SearchParams as AISearchParams,
490
+ SearchResult as AISearchResult
491
+ } from './ai-sdk/types';
492
+
493
+ // ==================== LANGCHAIN INTEGRATION ====================
494
+ // LangChain adapters for RAG workflows with decentralized storage
495
+ export { PDWEmbeddings } from './langchain/PDWEmbeddings';
496
+ export type { PDWEmbeddingsParams } from './langchain/PDWEmbeddings';
497
+ export { PDWVectorStore } from './langchain/PDWVectorStore';
498
+ export type { PDWVectorStoreConfig, PDWAddDocumentOptions } from './langchain/PDWVectorStore';