@cmdoss/memwal-sdk 0.6.1 → 0.6.2

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 (82) hide show
  1. package/ARCHITECTURE.md +547 -547
  2. package/BENCHMARKS.md +238 -238
  3. package/README.md +181 -181
  4. package/dist/ai-sdk/PDWVectorStore.d.ts.map +1 -1
  5. package/dist/ai-sdk/PDWVectorStore.js +4 -1
  6. package/dist/ai-sdk/PDWVectorStore.js.map +1 -1
  7. package/dist/browser.d.ts +5 -6
  8. package/dist/browser.d.ts.map +1 -1
  9. package/dist/browser.js +7 -6
  10. package/dist/browser.js.map +1 -1
  11. package/dist/client/ClientMemoryManager.d.ts +1 -0
  12. package/dist/client/ClientMemoryManager.d.ts.map +1 -1
  13. package/dist/client/ClientMemoryManager.js +5 -1
  14. package/dist/client/ClientMemoryManager.js.map +1 -1
  15. package/dist/client/PersonalDataWallet.d.ts.map +1 -1
  16. package/dist/client/SimplePDWClient.d.ts +23 -0
  17. package/dist/client/SimplePDWClient.d.ts.map +1 -1
  18. package/dist/client/SimplePDWClient.js +15 -2
  19. package/dist/client/SimplePDWClient.js.map +1 -1
  20. package/dist/client/namespaces/IndexNamespace.d.ts +38 -9
  21. package/dist/client/namespaces/IndexNamespace.d.ts.map +1 -1
  22. package/dist/client/namespaces/IndexNamespace.js +77 -10
  23. package/dist/client/namespaces/IndexNamespace.js.map +1 -1
  24. package/dist/client/namespaces/SearchNamespace.d.ts.map +1 -1
  25. package/dist/client/namespaces/SearchNamespace.js +25 -14
  26. package/dist/client/namespaces/SearchNamespace.js.map +1 -1
  27. package/dist/client/namespaces/consolidated/BlockchainNamespace.d.ts.map +1 -1
  28. package/dist/client/namespaces/consolidated/BlockchainNamespace.js +49 -1
  29. package/dist/client/namespaces/consolidated/BlockchainNamespace.js.map +1 -1
  30. package/dist/client/namespaces/consolidated/StorageNamespace.d.ts +46 -0
  31. package/dist/client/namespaces/consolidated/StorageNamespace.d.ts.map +1 -1
  32. package/dist/client/namespaces/consolidated/StorageNamespace.js +34 -0
  33. package/dist/client/namespaces/consolidated/StorageNamespace.js.map +1 -1
  34. package/dist/graph/GraphService.js +1 -1
  35. package/dist/permissions/ConsentRepository.browser.d.ts +56 -0
  36. package/dist/permissions/ConsentRepository.browser.d.ts.map +1 -0
  37. package/dist/permissions/ConsentRepository.browser.js +198 -0
  38. package/dist/permissions/ConsentRepository.browser.js.map +1 -0
  39. package/dist/services/GeminiAIService.d.ts.map +1 -1
  40. package/dist/services/GeminiAIService.js +283 -27
  41. package/dist/services/GeminiAIService.js.map +1 -1
  42. package/dist/services/MemoryIndexService.d.ts +31 -2
  43. package/dist/services/MemoryIndexService.d.ts.map +1 -1
  44. package/dist/services/MemoryIndexService.js +75 -3
  45. package/dist/services/MemoryIndexService.js.map +1 -1
  46. package/dist/services/storage/QuiltBatchManager.d.ts +10 -3
  47. package/dist/services/storage/QuiltBatchManager.d.ts.map +1 -1
  48. package/dist/services/storage/QuiltBatchManager.js +49 -27
  49. package/dist/services/storage/QuiltBatchManager.js.map +1 -1
  50. package/dist/utils/rebuildIndexNode.d.ts.map +1 -1
  51. package/dist/utils/rebuildIndexNode.js +109 -35
  52. package/dist/utils/rebuildIndexNode.js.map +1 -1
  53. package/dist/vector/NodeHnswService.d.ts.map +1 -1
  54. package/dist/vector/NodeHnswService.js +26 -7
  55. package/dist/vector/NodeHnswService.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/access/index.ts +8 -8
  58. package/src/aggregation/index.ts +8 -8
  59. package/src/ai-sdk/PDWVectorStore.ts +4 -1
  60. package/src/browser.ts +15 -10
  61. package/src/client/ClientMemoryManager.ts +6 -1
  62. package/src/client/SimplePDWClient.ts +40 -2
  63. package/src/client/namespaces/IndexNamespace.ts +89 -11
  64. package/src/client/namespaces/SearchNamespace.ts +27 -14
  65. package/src/client/namespaces/consolidated/BlockchainNamespace.ts +55 -1
  66. package/src/client/namespaces/consolidated/StorageNamespace.ts +57 -0
  67. package/src/client/signers/DappKitSigner.ts +207 -207
  68. package/src/generated/pdw/capability.ts +319 -319
  69. package/src/generated/pdw/deps/sui/object.ts +12 -12
  70. package/src/generated/pdw/deps/sui/vec_map.ts +32 -32
  71. package/src/generated/pdw/memory.ts +1087 -1087
  72. package/src/generated/pdw/wallet.ts +123 -123
  73. package/src/generated/utils/index.ts +159 -159
  74. package/src/graph/GraphService.ts +1 -1
  75. package/src/permissions/ConsentRepository.browser.ts +249 -0
  76. package/src/permissions/index.ts +9 -9
  77. package/src/services/GeminiAIService.ts +283 -27
  78. package/src/services/MemoryIndexService.ts +85 -3
  79. package/src/services/storage/QuiltBatchManager.ts +55 -29
  80. package/src/utils/rebuildIndexNode.ts +126 -43
  81. package/src/vector/NodeHnswService.ts +29 -7
  82. package/src/wallet/index.ts +17 -17
@@ -1,207 +1,207 @@
1
- /**
2
- * DappKit Signer Implementation
3
- *
4
- * Adapter for @mysten/dapp-kit hooks to work with SimplePDWClient.
5
- * Bridges dApp-kit's hook-based API with SDK's UnifiedSigner interface.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { DappKitSigner, createSimplePDWClient } from '@cmdoss/memwal-sdk';
10
- * import { useCurrentAccount, useSignAndExecuteTransaction, useSuiClient } from '@mysten/dapp-kit';
11
- *
12
- * function MyComponent() {
13
- * const account = useCurrentAccount();
14
- * const client = useSuiClient();
15
- * const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
16
- *
17
- * const signer = useMemo(() => {
18
- * if (!account) return null;
19
- * return new DappKitSigner({
20
- * address: account.address,
21
- * client,
22
- * signAndExecuteTransaction: signAndExecute,
23
- * });
24
- * }, [account, client, signAndExecute]);
25
- *
26
- * // Now use signer with SDK
27
- * const pdw = await createSimplePDWClient({ signer, network: 'testnet' });
28
- * }
29
- * ```
30
- *
31
- * @module client/signers
32
- */
33
-
34
- import type { Transaction } from '@mysten/sui/transactions';
35
- import type { SuiClient } from '@mysten/sui/client';
36
- import type { Signer } from '@mysten/sui/cryptography';
37
- import type {
38
- UnifiedSigner,
39
- SignAndExecuteResult,
40
- SignPersonalMessageResult
41
- } from './UnifiedSigner';
42
-
43
- /**
44
- * Function signature for dApp-kit's signAndExecuteTransaction
45
- * Compatible with useSignAndExecuteTransaction().mutateAsync
46
- */
47
- export interface DappKitSignAndExecuteFn {
48
- (params: { transaction: Transaction }): Promise<{
49
- digest: string;
50
- effects?: any;
51
- events?: any[];
52
- objectChanges?: any[];
53
- }>;
54
- }
55
-
56
- /**
57
- * Function signature for dApp-kit's signPersonalMessage
58
- * Compatible with useSignPersonalMessage().mutateAsync
59
- */
60
- export interface DappKitSignPersonalMessageFn {
61
- (params: { message: Uint8Array }): Promise<{
62
- signature: string;
63
- bytes?: Uint8Array;
64
- }>;
65
- }
66
-
67
- /**
68
- * Configuration for DappKitSigner
69
- */
70
- export interface DappKitSignerConfig {
71
- /**
72
- * User's Sui address (from useCurrentAccount().address)
73
- */
74
- address: string;
75
-
76
- /**
77
- * SuiClient instance (from useSuiClient())
78
- */
79
- client: SuiClient;
80
-
81
- /**
82
- * signAndExecuteTransaction function (from useSignAndExecuteTransaction().mutateAsync)
83
- */
84
- signAndExecuteTransaction: DappKitSignAndExecuteFn;
85
-
86
- /**
87
- * signPersonalMessage function (from useSignPersonalMessage().mutateAsync)
88
- * Optional - only required for operations that need message signing
89
- */
90
- signPersonalMessage?: DappKitSignPersonalMessageFn;
91
-
92
- /**
93
- * Public key bytes (optional, from useCurrentAccount().publicKey)
94
- */
95
- publicKey?: Uint8Array;
96
- }
97
-
98
- /**
99
- * DappKitSigner - Adapter for @mysten/dapp-kit hooks
100
- *
101
- * Wraps dApp-kit's useSignAndExecuteTransaction and useSignPersonalMessage hooks
102
- * to provide a UnifiedSigner interface compatible with SDK managers.
103
- *
104
- * This adapter does NOT depend on React - it accepts function references
105
- * that can come from dApp-kit hooks or any other source with compatible signatures.
106
- */
107
- export class DappKitSigner implements UnifiedSigner {
108
- private config: DappKitSignerConfig;
109
-
110
- constructor(config: DappKitSignerConfig) {
111
- if (!config.address) {
112
- throw new Error('DappKitSigner requires an address');
113
- }
114
- if (!config.client) {
115
- throw new Error('DappKitSigner requires a SuiClient');
116
- }
117
- if (!config.signAndExecuteTransaction) {
118
- throw new Error('DappKitSigner requires signAndExecuteTransaction function');
119
- }
120
- this.config = config;
121
- }
122
-
123
- /**
124
- * Sign and execute transaction using dApp-kit hook
125
- *
126
- * Wraps the dApp-kit signAndExecuteTransaction function and waits for
127
- * transaction finalization to prevent gas coin version conflicts.
128
- */
129
- async signAndExecuteTransaction(transaction: Transaction): Promise<SignAndExecuteResult> {
130
- const result = await this.config.signAndExecuteTransaction({ transaction });
131
-
132
- // Wait for transaction to be finalized (important for gas coin versioning)
133
- if (result.digest) {
134
- try {
135
- await this.config.client.waitForTransaction({ digest: result.digest });
136
- } catch (waitError) {
137
- console.warn('DappKitSigner: waitForTransaction failed:', waitError);
138
- // Continue anyway - transaction was submitted
139
- }
140
- }
141
-
142
- return {
143
- digest: result.digest,
144
- effects: result.effects,
145
- events: result.events,
146
- objectChanges: result.objectChanges,
147
- };
148
- }
149
-
150
- /**
151
- * Sign personal message using dApp-kit hook
152
- *
153
- * Required for SEAL encryption identity and other message signing operations.
154
- */
155
- async signPersonalMessage(message: Uint8Array): Promise<SignPersonalMessageResult> {
156
- if (!this.config.signPersonalMessage) {
157
- throw new Error(
158
- 'DappKitSigner: signPersonalMessage not configured. ' +
159
- 'Pass signPersonalMessage function from useSignPersonalMessage().mutateAsync'
160
- );
161
- }
162
-
163
- const result = await this.config.signPersonalMessage({ message });
164
-
165
- return {
166
- signature: result.signature,
167
- bytes: result.bytes || message,
168
- };
169
- }
170
-
171
- /**
172
- * Get Sui address
173
- */
174
- getAddress(): string {
175
- return this.config.address;
176
- }
177
-
178
- /**
179
- * Get public key (if available)
180
- */
181
- getPublicKey(): Uint8Array | null {
182
- return this.config.publicKey || null;
183
- }
184
-
185
- /**
186
- * Get underlying Signer
187
- *
188
- * Note: dApp-kit does not expose the underlying Signer for security reasons.
189
- * Use KeypairSigner for backend/Node.js environments that need raw Signer access.
190
- */
191
- getSigner(): Signer {
192
- throw new Error(
193
- 'DappKitSigner does not expose underlying Signer. ' +
194
- 'Browser wallets do not provide raw Signer access for security. ' +
195
- 'Use KeypairSigner for backend/Node.js environments.'
196
- );
197
- }
198
-
199
- /**
200
- * Get SuiClient
201
- *
202
- * Returns the SuiClient instance for managers that need to build transactions.
203
- */
204
- getClient(): SuiClient {
205
- return this.config.client;
206
- }
207
- }
1
+ /**
2
+ * DappKit Signer Implementation
3
+ *
4
+ * Adapter for @mysten/dapp-kit hooks to work with SimplePDWClient.
5
+ * Bridges dApp-kit's hook-based API with SDK's UnifiedSigner interface.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { DappKitSigner, createSimplePDWClient } from '@cmdoss/memwal-sdk';
10
+ * import { useCurrentAccount, useSignAndExecuteTransaction, useSuiClient } from '@mysten/dapp-kit';
11
+ *
12
+ * function MyComponent() {
13
+ * const account = useCurrentAccount();
14
+ * const client = useSuiClient();
15
+ * const { mutateAsync: signAndExecute } = useSignAndExecuteTransaction();
16
+ *
17
+ * const signer = useMemo(() => {
18
+ * if (!account) return null;
19
+ * return new DappKitSigner({
20
+ * address: account.address,
21
+ * client,
22
+ * signAndExecuteTransaction: signAndExecute,
23
+ * });
24
+ * }, [account, client, signAndExecute]);
25
+ *
26
+ * // Now use signer with SDK
27
+ * const pdw = await createSimplePDWClient({ signer, network: 'testnet' });
28
+ * }
29
+ * ```
30
+ *
31
+ * @module client/signers
32
+ */
33
+
34
+ import type { Transaction } from '@mysten/sui/transactions';
35
+ import type { SuiClient } from '@mysten/sui/client';
36
+ import type { Signer } from '@mysten/sui/cryptography';
37
+ import type {
38
+ UnifiedSigner,
39
+ SignAndExecuteResult,
40
+ SignPersonalMessageResult
41
+ } from './UnifiedSigner';
42
+
43
+ /**
44
+ * Function signature for dApp-kit's signAndExecuteTransaction
45
+ * Compatible with useSignAndExecuteTransaction().mutateAsync
46
+ */
47
+ export interface DappKitSignAndExecuteFn {
48
+ (params: { transaction: Transaction }): Promise<{
49
+ digest: string;
50
+ effects?: any;
51
+ events?: any[];
52
+ objectChanges?: any[];
53
+ }>;
54
+ }
55
+
56
+ /**
57
+ * Function signature for dApp-kit's signPersonalMessage
58
+ * Compatible with useSignPersonalMessage().mutateAsync
59
+ */
60
+ export interface DappKitSignPersonalMessageFn {
61
+ (params: { message: Uint8Array }): Promise<{
62
+ signature: string;
63
+ bytes?: Uint8Array;
64
+ }>;
65
+ }
66
+
67
+ /**
68
+ * Configuration for DappKitSigner
69
+ */
70
+ export interface DappKitSignerConfig {
71
+ /**
72
+ * User's Sui address (from useCurrentAccount().address)
73
+ */
74
+ address: string;
75
+
76
+ /**
77
+ * SuiClient instance (from useSuiClient())
78
+ */
79
+ client: SuiClient;
80
+
81
+ /**
82
+ * signAndExecuteTransaction function (from useSignAndExecuteTransaction().mutateAsync)
83
+ */
84
+ signAndExecuteTransaction: DappKitSignAndExecuteFn;
85
+
86
+ /**
87
+ * signPersonalMessage function (from useSignPersonalMessage().mutateAsync)
88
+ * Optional - only required for operations that need message signing
89
+ */
90
+ signPersonalMessage?: DappKitSignPersonalMessageFn;
91
+
92
+ /**
93
+ * Public key bytes (optional, from useCurrentAccount().publicKey)
94
+ */
95
+ publicKey?: Uint8Array;
96
+ }
97
+
98
+ /**
99
+ * DappKitSigner - Adapter for @mysten/dapp-kit hooks
100
+ *
101
+ * Wraps dApp-kit's useSignAndExecuteTransaction and useSignPersonalMessage hooks
102
+ * to provide a UnifiedSigner interface compatible with SDK managers.
103
+ *
104
+ * This adapter does NOT depend on React - it accepts function references
105
+ * that can come from dApp-kit hooks or any other source with compatible signatures.
106
+ */
107
+ export class DappKitSigner implements UnifiedSigner {
108
+ private config: DappKitSignerConfig;
109
+
110
+ constructor(config: DappKitSignerConfig) {
111
+ if (!config.address) {
112
+ throw new Error('DappKitSigner requires an address');
113
+ }
114
+ if (!config.client) {
115
+ throw new Error('DappKitSigner requires a SuiClient');
116
+ }
117
+ if (!config.signAndExecuteTransaction) {
118
+ throw new Error('DappKitSigner requires signAndExecuteTransaction function');
119
+ }
120
+ this.config = config;
121
+ }
122
+
123
+ /**
124
+ * Sign and execute transaction using dApp-kit hook
125
+ *
126
+ * Wraps the dApp-kit signAndExecuteTransaction function and waits for
127
+ * transaction finalization to prevent gas coin version conflicts.
128
+ */
129
+ async signAndExecuteTransaction(transaction: Transaction): Promise<SignAndExecuteResult> {
130
+ const result = await this.config.signAndExecuteTransaction({ transaction });
131
+
132
+ // Wait for transaction to be finalized (important for gas coin versioning)
133
+ if (result.digest) {
134
+ try {
135
+ await this.config.client.waitForTransaction({ digest: result.digest });
136
+ } catch (waitError) {
137
+ console.warn('DappKitSigner: waitForTransaction failed:', waitError);
138
+ // Continue anyway - transaction was submitted
139
+ }
140
+ }
141
+
142
+ return {
143
+ digest: result.digest,
144
+ effects: result.effects,
145
+ events: result.events,
146
+ objectChanges: result.objectChanges,
147
+ };
148
+ }
149
+
150
+ /**
151
+ * Sign personal message using dApp-kit hook
152
+ *
153
+ * Required for SEAL encryption identity and other message signing operations.
154
+ */
155
+ async signPersonalMessage(message: Uint8Array): Promise<SignPersonalMessageResult> {
156
+ if (!this.config.signPersonalMessage) {
157
+ throw new Error(
158
+ 'DappKitSigner: signPersonalMessage not configured. ' +
159
+ 'Pass signPersonalMessage function from useSignPersonalMessage().mutateAsync'
160
+ );
161
+ }
162
+
163
+ const result = await this.config.signPersonalMessage({ message });
164
+
165
+ return {
166
+ signature: result.signature,
167
+ bytes: result.bytes || message,
168
+ };
169
+ }
170
+
171
+ /**
172
+ * Get Sui address
173
+ */
174
+ getAddress(): string {
175
+ return this.config.address;
176
+ }
177
+
178
+ /**
179
+ * Get public key (if available)
180
+ */
181
+ getPublicKey(): Uint8Array | null {
182
+ return this.config.publicKey || null;
183
+ }
184
+
185
+ /**
186
+ * Get underlying Signer
187
+ *
188
+ * Note: dApp-kit does not expose the underlying Signer for security reasons.
189
+ * Use KeypairSigner for backend/Node.js environments that need raw Signer access.
190
+ */
191
+ getSigner(): Signer {
192
+ throw new Error(
193
+ 'DappKitSigner does not expose underlying Signer. ' +
194
+ 'Browser wallets do not provide raw Signer access for security. ' +
195
+ 'Use KeypairSigner for backend/Node.js environments.'
196
+ );
197
+ }
198
+
199
+ /**
200
+ * Get SuiClient
201
+ *
202
+ * Returns the SuiClient instance for managers that need to build transactions.
203
+ */
204
+ getClient(): SuiClient {
205
+ return this.config.client;
206
+ }
207
+ }