@cmdoss/memwal-sdk 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +547 -547
- package/BENCHMARKS.md +238 -238
- package/README.md +181 -181
- package/dist/ai-sdk/tools.d.ts +2 -2
- package/dist/ai-sdk/tools.js +2 -2
- package/dist/client/PersonalDataWallet.d.ts.map +1 -1
- package/dist/client/SimplePDWClient.d.ts +1 -1
- package/dist/client/SimplePDWClient.d.ts.map +1 -1
- package/dist/client/SimplePDWClient.js +16 -7
- package/dist/client/SimplePDWClient.js.map +1 -1
- package/dist/client/namespaces/EmbeddingsNamespace.d.ts +1 -1
- package/dist/client/namespaces/EmbeddingsNamespace.js +1 -1
- package/dist/client/namespaces/MemoryNamespace.d.ts +27 -0
- package/dist/client/namespaces/MemoryNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/MemoryNamespace.js +104 -0
- package/dist/client/namespaces/MemoryNamespace.js.map +1 -1
- package/dist/client/namespaces/consolidated/AINamespace.d.ts +2 -2
- package/dist/client/namespaces/consolidated/AINamespace.js +2 -2
- package/dist/client/namespaces/consolidated/BlockchainNamespace.d.ts.map +1 -1
- package/dist/client/namespaces/consolidated/BlockchainNamespace.js +22 -2
- package/dist/client/namespaces/consolidated/BlockchainNamespace.js.map +1 -1
- package/dist/graph/GraphService.js +1 -1
- package/dist/graph/GraphService.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/retrieval/MemoryRetrievalService.d.ts +31 -0
- package/dist/retrieval/MemoryRetrievalService.d.ts.map +1 -1
- package/dist/retrieval/MemoryRetrievalService.js +44 -4
- package/dist/retrieval/MemoryRetrievalService.js.map +1 -1
- package/dist/services/EmbeddingService.d.ts +28 -1
- package/dist/services/EmbeddingService.d.ts.map +1 -1
- package/dist/services/EmbeddingService.js +54 -0
- package/dist/services/EmbeddingService.js.map +1 -1
- package/dist/services/IndexManager.d.ts +5 -1
- package/dist/services/IndexManager.d.ts.map +1 -1
- package/dist/services/IndexManager.js +17 -40
- package/dist/services/IndexManager.js.map +1 -1
- package/dist/services/QueryService.js +1 -1
- package/dist/services/QueryService.js.map +1 -1
- package/dist/services/StorageService.d.ts +10 -0
- package/dist/services/StorageService.d.ts.map +1 -1
- package/dist/services/StorageService.js +13 -0
- package/dist/services/StorageService.js.map +1 -1
- package/dist/services/storage/QuiltBatchManager.d.ts +101 -1
- package/dist/services/storage/QuiltBatchManager.d.ts.map +1 -1
- package/dist/services/storage/QuiltBatchManager.js +410 -20
- package/dist/services/storage/QuiltBatchManager.js.map +1 -1
- package/dist/services/storage/index.d.ts +1 -1
- package/dist/services/storage/index.d.ts.map +1 -1
- package/dist/services/storage/index.js.map +1 -1
- package/dist/utils/LRUCache.d.ts +106 -0
- package/dist/utils/LRUCache.d.ts.map +1 -0
- package/dist/utils/LRUCache.js +281 -0
- package/dist/utils/LRUCache.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/memoryIndexOnChain.d.ts +212 -0
- package/dist/utils/memoryIndexOnChain.d.ts.map +1 -0
- package/dist/utils/memoryIndexOnChain.js +312 -0
- package/dist/utils/memoryIndexOnChain.js.map +1 -0
- package/dist/utils/rebuildIndexNode.d.ts +29 -0
- package/dist/utils/rebuildIndexNode.d.ts.map +1 -1
- package/dist/utils/rebuildIndexNode.js +366 -98
- package/dist/utils/rebuildIndexNode.js.map +1 -1
- package/dist/vector/HnswWasmService.d.ts +20 -5
- package/dist/vector/HnswWasmService.d.ts.map +1 -1
- package/dist/vector/HnswWasmService.js +73 -40
- package/dist/vector/HnswWasmService.js.map +1 -1
- package/dist/vector/IHnswService.d.ts +10 -1
- package/dist/vector/IHnswService.d.ts.map +1 -1
- package/dist/vector/IHnswService.js.map +1 -1
- package/dist/vector/NodeHnswService.d.ts +16 -0
- package/dist/vector/NodeHnswService.d.ts.map +1 -1
- package/dist/vector/NodeHnswService.js +84 -5
- package/dist/vector/NodeHnswService.js.map +1 -1
- package/dist/vector/createHnswService.d.ts +1 -1
- package/dist/vector/createHnswService.js +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +1 -1
- package/package.json +157 -157
- package/src/access/index.ts +8 -8
- package/src/aggregation/index.ts +8 -8
- package/src/ai-sdk/tools.ts +2 -2
- package/src/client/SimplePDWClient.ts +23 -8
- package/src/client/namespaces/EmbeddingsNamespace.ts +1 -1
- package/src/client/namespaces/MemoryNamespace.ts +137 -0
- package/src/client/namespaces/consolidated/AINamespace.ts +2 -2
- package/src/client/namespaces/consolidated/BlockchainNamespace.ts +20 -2
- package/src/client/signers/DappKitSigner.ts +207 -207
- package/src/core/types/index.ts +1 -1
- package/src/generated/pdw/deps/sui/object.ts +12 -12
- package/src/generated/pdw/deps/sui/vec_map.ts +32 -32
- package/src/generated/pdw/memory.ts +1087 -1087
- package/src/generated/pdw/wallet.ts +123 -123
- package/src/generated/utils/index.ts +159 -159
- package/src/graph/GraphService.ts +1 -1
- package/src/index.ts +25 -1
- package/src/permissions/index.ts +9 -9
- package/src/retrieval/MemoryRetrievalService.ts +78 -4
- package/src/services/EmbeddingService.ts +66 -1
- package/src/services/IndexManager.ts +18 -45
- package/src/services/QueryService.ts +1 -1
- package/src/services/StorageService.ts +15 -0
- package/src/services/storage/QuiltBatchManager.ts +492 -22
- package/src/services/storage/index.ts +6 -1
- package/src/utils/LRUCache.ts +378 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/memoryIndexOnChain.ts +507 -0
- package/src/utils/rebuildIndexNode.ts +453 -106
- package/src/vector/HnswWasmService.ts +95 -43
- package/src/vector/IHnswService.ts +10 -1
- package/src/vector/NodeHnswService.ts +103 -5
- package/src/vector/createHnswService.ts +1 -1
- package/src/vector/index.ts +1 -1
- package/src/wallet/index.ts +17 -17
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
/**************************************************************
|
|
2
|
-
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
-
**************************************************************/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated This module is DEPRECATED - use pdw::capability instead
|
|
8
|
-
*
|
|
9
|
-
* MIGRATION NOTICE: ================= This module used dynamic fields for context
|
|
10
|
-
* management. The new pdw::capability module uses standalone MemoryCap objects.
|
|
11
|
-
*
|
|
12
|
-
* Benefits of new architecture:
|
|
13
|
-
*
|
|
14
|
-
* - No MainWallet object management needed
|
|
15
|
-
* - Standard Sui object ownership
|
|
16
|
-
* - SEAL-compliant PrivateData pattern
|
|
17
|
-
* - Simpler cross-dApp data sharing
|
|
18
|
-
*
|
|
19
|
-
* See CAPABILITY-ARCHITECTURE-SUMMARY.md for details.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Use pdw::capability::MemoryCap instead
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
25
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
26
|
-
import { type Transaction } from '@mysten/sui/transactions';
|
|
27
|
-
import * as object from './deps/sui/object.js';
|
|
28
|
-
const $moduleName = '@local-pkg/pdw::wallet';
|
|
29
|
-
export const UserProfile = new MoveStruct({ name: `${$moduleName}::UserProfile`, fields: {
|
|
30
|
-
id: object.UID,
|
|
31
|
-
owner: bcs.Address,
|
|
32
|
-
created_at: bcs.u64()
|
|
33
|
-
} });
|
|
34
|
-
export const UserProfileCreated = new MoveStruct({ name: `${$moduleName}::UserProfileCreated`, fields: {
|
|
35
|
-
profile_id: bcs.Address,
|
|
36
|
-
owner: bcs.Address,
|
|
37
|
-
created_at: bcs.u64()
|
|
38
|
-
} });
|
|
39
|
-
export interface CreateUserProfileOptions {
|
|
40
|
-
package?: string;
|
|
41
|
-
arguments?: [
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated Use pdw::capability::create_memory_cap instead Create a simple user
|
|
46
|
-
* profile (for backward compatibility)
|
|
47
|
-
*/
|
|
48
|
-
export function createUserProfile(options: CreateUserProfileOptions = {}) {
|
|
49
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
50
|
-
return (tx: Transaction) => tx.moveCall({
|
|
51
|
-
package: packageAddress,
|
|
52
|
-
module: 'wallet',
|
|
53
|
-
function: 'create_user_profile',
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export interface GetOwnerArguments {
|
|
57
|
-
profile: RawTransactionArgument<string>;
|
|
58
|
-
}
|
|
59
|
-
export interface GetOwnerOptions {
|
|
60
|
-
package?: string;
|
|
61
|
-
arguments: GetOwnerArguments | [
|
|
62
|
-
profile: RawTransactionArgument<string>
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
/** Get profile owner */
|
|
66
|
-
export function getOwner(options: GetOwnerOptions) {
|
|
67
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
68
|
-
const argumentsTypes = [
|
|
69
|
-
`${packageAddress}::wallet::UserProfile`
|
|
70
|
-
] satisfies string[];
|
|
71
|
-
const parameterNames = ["profile"];
|
|
72
|
-
return (tx: Transaction) => tx.moveCall({
|
|
73
|
-
package: packageAddress,
|
|
74
|
-
module: 'wallet',
|
|
75
|
-
function: 'get_owner',
|
|
76
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
export interface GetProfileIdArguments {
|
|
80
|
-
profile: RawTransactionArgument<string>;
|
|
81
|
-
}
|
|
82
|
-
export interface GetProfileIdOptions {
|
|
83
|
-
package?: string;
|
|
84
|
-
arguments: GetProfileIdArguments | [
|
|
85
|
-
profile: RawTransactionArgument<string>
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
/** Get profile ID */
|
|
89
|
-
export function getProfileId(options: GetProfileIdOptions) {
|
|
90
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
91
|
-
const argumentsTypes = [
|
|
92
|
-
`${packageAddress}::wallet::UserProfile`
|
|
93
|
-
] satisfies string[];
|
|
94
|
-
const parameterNames = ["profile"];
|
|
95
|
-
return (tx: Transaction) => tx.moveCall({
|
|
96
|
-
package: packageAddress,
|
|
97
|
-
module: 'wallet',
|
|
98
|
-
function: 'get_profile_id',
|
|
99
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
export interface DeleteProfileArguments {
|
|
103
|
-
profile: RawTransactionArgument<string>;
|
|
104
|
-
}
|
|
105
|
-
export interface DeleteProfileOptions {
|
|
106
|
-
package?: string;
|
|
107
|
-
arguments: DeleteProfileArguments | [
|
|
108
|
-
profile: RawTransactionArgument<string>
|
|
109
|
-
];
|
|
110
|
-
}
|
|
111
|
-
/** Delete user profile */
|
|
112
|
-
export function deleteProfile(options: DeleteProfileOptions) {
|
|
113
|
-
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
114
|
-
const argumentsTypes = [
|
|
115
|
-
`${packageAddress}::wallet::UserProfile`
|
|
116
|
-
] satisfies string[];
|
|
117
|
-
const parameterNames = ["profile"];
|
|
118
|
-
return (tx: Transaction) => tx.moveCall({
|
|
119
|
-
package: packageAddress,
|
|
120
|
-
module: 'wallet',
|
|
121
|
-
function: 'delete_profile',
|
|
122
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
123
|
-
});
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated This module is DEPRECATED - use pdw::capability instead
|
|
8
|
+
*
|
|
9
|
+
* MIGRATION NOTICE: ================= This module used dynamic fields for context
|
|
10
|
+
* management. The new pdw::capability module uses standalone MemoryCap objects.
|
|
11
|
+
*
|
|
12
|
+
* Benefits of new architecture:
|
|
13
|
+
*
|
|
14
|
+
* - No MainWallet object management needed
|
|
15
|
+
* - Standard Sui object ownership
|
|
16
|
+
* - SEAL-compliant PrivateData pattern
|
|
17
|
+
* - Simpler cross-dApp data sharing
|
|
18
|
+
*
|
|
19
|
+
* See CAPABILITY-ARCHITECTURE-SUMMARY.md for details.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use pdw::capability::MemoryCap instead
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
25
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
26
|
+
import { type Transaction } from '@mysten/sui/transactions';
|
|
27
|
+
import * as object from './deps/sui/object.js';
|
|
28
|
+
const $moduleName = '@local-pkg/pdw::wallet';
|
|
29
|
+
export const UserProfile = new MoveStruct({ name: `${$moduleName}::UserProfile`, fields: {
|
|
30
|
+
id: object.UID,
|
|
31
|
+
owner: bcs.Address,
|
|
32
|
+
created_at: bcs.u64()
|
|
33
|
+
} });
|
|
34
|
+
export const UserProfileCreated = new MoveStruct({ name: `${$moduleName}::UserProfileCreated`, fields: {
|
|
35
|
+
profile_id: bcs.Address,
|
|
36
|
+
owner: bcs.Address,
|
|
37
|
+
created_at: bcs.u64()
|
|
38
|
+
} });
|
|
39
|
+
export interface CreateUserProfileOptions {
|
|
40
|
+
package?: string;
|
|
41
|
+
arguments?: [
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use pdw::capability::create_memory_cap instead Create a simple user
|
|
46
|
+
* profile (for backward compatibility)
|
|
47
|
+
*/
|
|
48
|
+
export function createUserProfile(options: CreateUserProfileOptions = {}) {
|
|
49
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
50
|
+
return (tx: Transaction) => tx.moveCall({
|
|
51
|
+
package: packageAddress,
|
|
52
|
+
module: 'wallet',
|
|
53
|
+
function: 'create_user_profile',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export interface GetOwnerArguments {
|
|
57
|
+
profile: RawTransactionArgument<string>;
|
|
58
|
+
}
|
|
59
|
+
export interface GetOwnerOptions {
|
|
60
|
+
package?: string;
|
|
61
|
+
arguments: GetOwnerArguments | [
|
|
62
|
+
profile: RawTransactionArgument<string>
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/** Get profile owner */
|
|
66
|
+
export function getOwner(options: GetOwnerOptions) {
|
|
67
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
68
|
+
const argumentsTypes = [
|
|
69
|
+
`${packageAddress}::wallet::UserProfile`
|
|
70
|
+
] satisfies string[];
|
|
71
|
+
const parameterNames = ["profile"];
|
|
72
|
+
return (tx: Transaction) => tx.moveCall({
|
|
73
|
+
package: packageAddress,
|
|
74
|
+
module: 'wallet',
|
|
75
|
+
function: 'get_owner',
|
|
76
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export interface GetProfileIdArguments {
|
|
80
|
+
profile: RawTransactionArgument<string>;
|
|
81
|
+
}
|
|
82
|
+
export interface GetProfileIdOptions {
|
|
83
|
+
package?: string;
|
|
84
|
+
arguments: GetProfileIdArguments | [
|
|
85
|
+
profile: RawTransactionArgument<string>
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
/** Get profile ID */
|
|
89
|
+
export function getProfileId(options: GetProfileIdOptions) {
|
|
90
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
91
|
+
const argumentsTypes = [
|
|
92
|
+
`${packageAddress}::wallet::UserProfile`
|
|
93
|
+
] satisfies string[];
|
|
94
|
+
const parameterNames = ["profile"];
|
|
95
|
+
return (tx: Transaction) => tx.moveCall({
|
|
96
|
+
package: packageAddress,
|
|
97
|
+
module: 'wallet',
|
|
98
|
+
function: 'get_profile_id',
|
|
99
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export interface DeleteProfileArguments {
|
|
103
|
+
profile: RawTransactionArgument<string>;
|
|
104
|
+
}
|
|
105
|
+
export interface DeleteProfileOptions {
|
|
106
|
+
package?: string;
|
|
107
|
+
arguments: DeleteProfileArguments | [
|
|
108
|
+
profile: RawTransactionArgument<string>
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
/** Delete user profile */
|
|
112
|
+
export function deleteProfile(options: DeleteProfileOptions) {
|
|
113
|
+
const packageAddress = options.package ?? '@local-pkg/pdw';
|
|
114
|
+
const argumentsTypes = [
|
|
115
|
+
`${packageAddress}::wallet::UserProfile`
|
|
116
|
+
] satisfies string[];
|
|
117
|
+
const parameterNames = ["profile"];
|
|
118
|
+
return (tx: Transaction) => tx.moveCall({
|
|
119
|
+
package: packageAddress,
|
|
120
|
+
module: 'wallet',
|
|
121
|
+
function: 'delete_profile',
|
|
122
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
123
|
+
});
|
|
124
124
|
}
|
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
import { bcs, BcsType, TypeTag, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
3
|
-
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
4
|
-
import { TransactionArgument, isArgument } from '@mysten/sui/transactions';
|
|
5
|
-
|
|
6
|
-
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');
|
|
7
|
-
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
|
|
8
|
-
const SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');
|
|
9
|
-
|
|
10
|
-
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
11
|
-
|
|
12
|
-
export function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {
|
|
13
|
-
const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
14
|
-
|
|
15
|
-
if ('u8' in parsedTag) {
|
|
16
|
-
return bcs.U8;
|
|
17
|
-
} else if ('u16' in parsedTag) {
|
|
18
|
-
return bcs.U16;
|
|
19
|
-
} else if ('u32' in parsedTag) {
|
|
20
|
-
return bcs.U32;
|
|
21
|
-
} else if ('u64' in parsedTag) {
|
|
22
|
-
return bcs.U64;
|
|
23
|
-
} else if ('u128' in parsedTag) {
|
|
24
|
-
return bcs.U128;
|
|
25
|
-
} else if ('u256' in parsedTag) {
|
|
26
|
-
return bcs.U256;
|
|
27
|
-
} else if ('address' in parsedTag) {
|
|
28
|
-
return bcs.Address;
|
|
29
|
-
} else if ('bool' in parsedTag) {
|
|
30
|
-
return bcs.Bool;
|
|
31
|
-
} else if ('vector' in parsedTag) {
|
|
32
|
-
const type = getPureBcsSchema(parsedTag.vector);
|
|
33
|
-
return type ? bcs.vector(type) : null;
|
|
34
|
-
} else if ('struct' in parsedTag) {
|
|
35
|
-
const structTag = parsedTag.struct;
|
|
36
|
-
const pkg = normalizeSuiAddress(parsedTag.struct.address);
|
|
37
|
-
|
|
38
|
-
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
39
|
-
if (
|
|
40
|
-
(structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
41
|
-
structTag.name === 'String'
|
|
42
|
-
) {
|
|
43
|
-
return bcs.String;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
47
|
-
const type = getPureBcsSchema(structTag.typeParams[0]!);
|
|
48
|
-
return type ? bcs.option(type) : null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {
|
|
53
|
-
return bcs.Address;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]) {
|
|
61
|
-
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
62
|
-
if (parameterNames && argLen !== parameterNames.length) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const normalizedArgs: TransactionArgument[] = [];
|
|
69
|
-
|
|
70
|
-
let index = 0;
|
|
71
|
-
for (const [i, argType] of argTypes.entries()) {
|
|
72
|
-
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
73
|
-
normalizedArgs.push((tx) => tx.object.denyList());
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
78
|
-
normalizedArgs.push((tx) => tx.object.random());
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
83
|
-
normalizedArgs.push((tx) => tx.object.clock());
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
88
|
-
normalizedArgs.push((tx) => tx.object.system());
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let arg
|
|
93
|
-
if (Array.isArray(args)) {
|
|
94
|
-
if (index >= args.length) {
|
|
95
|
-
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
96
|
-
}
|
|
97
|
-
arg = args[index];
|
|
98
|
-
} else {
|
|
99
|
-
if (!parameterNames) {
|
|
100
|
-
throw new Error(`Expected arguments to be passed as an array`);
|
|
101
|
-
}
|
|
102
|
-
const name = parameterNames[index];
|
|
103
|
-
arg = args[name as keyof typeof args];
|
|
104
|
-
|
|
105
|
-
if (arg === undefined) {
|
|
106
|
-
throw new Error(`Parameter ${name} is required`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
index += 1;
|
|
111
|
-
|
|
112
|
-
if (typeof arg === 'function' || isArgument(arg)) {
|
|
113
|
-
normalizedArgs.push(arg as TransactionArgument);
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const type = argTypes[i]!;
|
|
118
|
-
const bcsType = getPureBcsSchema(type);
|
|
119
|
-
|
|
120
|
-
if (bcsType) {
|
|
121
|
-
const bytes = bcsType.serialize(arg as never);
|
|
122
|
-
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
123
|
-
continue;
|
|
124
|
-
} else if (typeof arg === 'string') {
|
|
125
|
-
normalizedArgs.push((tx) => tx.object(arg));
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return normalizedArgs;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export class MoveStruct<
|
|
136
|
-
T extends Record<string, BcsType<any>>,
|
|
137
|
-
const Name extends string = string,
|
|
138
|
-
> extends BcsStruct<T, Name> {}
|
|
139
|
-
|
|
140
|
-
export class MoveEnum<
|
|
141
|
-
T extends Record<string, BcsType<any> | null>,
|
|
142
|
-
const Name extends string,
|
|
143
|
-
> extends BcsEnum<T, Name> {}
|
|
144
|
-
|
|
145
|
-
export class MoveTuple<
|
|
146
|
-
T extends readonly BcsType<any>[],
|
|
147
|
-
const Name extends string,
|
|
148
|
-
> extends BcsTuple<T, Name> {}
|
|
149
|
-
|
|
150
|
-
function stringify(val: unknown) {
|
|
151
|
-
if (typeof val === 'object') {
|
|
152
|
-
return JSON.stringify(val, (val: unknown) => val);
|
|
153
|
-
}
|
|
154
|
-
if (typeof val === 'bigint') {
|
|
155
|
-
return val.toString();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return val;
|
|
159
|
-
}
|
|
1
|
+
|
|
2
|
+
import { bcs, BcsType, TypeTag, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';
|
|
3
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
4
|
+
import { TransactionArgument, isArgument } from '@mysten/sui/transactions';
|
|
5
|
+
|
|
6
|
+
const MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');
|
|
7
|
+
const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');
|
|
8
|
+
const SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');
|
|
9
|
+
|
|
10
|
+
export type RawTransactionArgument<T> = T | TransactionArgument;
|
|
11
|
+
|
|
12
|
+
export function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {
|
|
13
|
+
const parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
|
|
14
|
+
|
|
15
|
+
if ('u8' in parsedTag) {
|
|
16
|
+
return bcs.U8;
|
|
17
|
+
} else if ('u16' in parsedTag) {
|
|
18
|
+
return bcs.U16;
|
|
19
|
+
} else if ('u32' in parsedTag) {
|
|
20
|
+
return bcs.U32;
|
|
21
|
+
} else if ('u64' in parsedTag) {
|
|
22
|
+
return bcs.U64;
|
|
23
|
+
} else if ('u128' in parsedTag) {
|
|
24
|
+
return bcs.U128;
|
|
25
|
+
} else if ('u256' in parsedTag) {
|
|
26
|
+
return bcs.U256;
|
|
27
|
+
} else if ('address' in parsedTag) {
|
|
28
|
+
return bcs.Address;
|
|
29
|
+
} else if ('bool' in parsedTag) {
|
|
30
|
+
return bcs.Bool;
|
|
31
|
+
} else if ('vector' in parsedTag) {
|
|
32
|
+
const type = getPureBcsSchema(parsedTag.vector);
|
|
33
|
+
return type ? bcs.vector(type) : null;
|
|
34
|
+
} else if ('struct' in parsedTag) {
|
|
35
|
+
const structTag = parsedTag.struct;
|
|
36
|
+
const pkg = normalizeSuiAddress(parsedTag.struct.address);
|
|
37
|
+
|
|
38
|
+
if (pkg === MOVE_STDLIB_ADDRESS) {
|
|
39
|
+
if (
|
|
40
|
+
(structTag.module === 'ascii' || structTag.module === 'string') &&
|
|
41
|
+
structTag.name === 'String'
|
|
42
|
+
) {
|
|
43
|
+
return bcs.String;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (structTag.module === 'option' && structTag.name === 'Option') {
|
|
47
|
+
const type = getPureBcsSchema(structTag.typeParams[0]!);
|
|
48
|
+
return type ? bcs.option(type) : null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {
|
|
53
|
+
return bcs.Address;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function normalizeMoveArguments(args: unknown[] | object, argTypes: string[], parameterNames?: string[]) {
|
|
61
|
+
const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
|
|
62
|
+
if (parameterNames && argLen !== parameterNames.length) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const normalizedArgs: TransactionArgument[] = [];
|
|
69
|
+
|
|
70
|
+
let index = 0;
|
|
71
|
+
for (const [i, argType] of argTypes.entries()) {
|
|
72
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {
|
|
73
|
+
normalizedArgs.push((tx) => tx.object.denyList());
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {
|
|
78
|
+
normalizedArgs.push((tx) => tx.object.random());
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {
|
|
83
|
+
normalizedArgs.push((tx) => tx.object.clock());
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (argType === `${SUI_SYSTEM_ADDRESS}::sui_system::SuiSystemState`) {
|
|
88
|
+
normalizedArgs.push((tx) => tx.object.system());
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let arg
|
|
93
|
+
if (Array.isArray(args)) {
|
|
94
|
+
if (index >= args.length) {
|
|
95
|
+
throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
|
|
96
|
+
}
|
|
97
|
+
arg = args[index];
|
|
98
|
+
} else {
|
|
99
|
+
if (!parameterNames) {
|
|
100
|
+
throw new Error(`Expected arguments to be passed as an array`);
|
|
101
|
+
}
|
|
102
|
+
const name = parameterNames[index];
|
|
103
|
+
arg = args[name as keyof typeof args];
|
|
104
|
+
|
|
105
|
+
if (arg === undefined) {
|
|
106
|
+
throw new Error(`Parameter ${name} is required`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
index += 1;
|
|
111
|
+
|
|
112
|
+
if (typeof arg === 'function' || isArgument(arg)) {
|
|
113
|
+
normalizedArgs.push(arg as TransactionArgument);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const type = argTypes[i]!;
|
|
118
|
+
const bcsType = getPureBcsSchema(type);
|
|
119
|
+
|
|
120
|
+
if (bcsType) {
|
|
121
|
+
const bytes = bcsType.serialize(arg as never);
|
|
122
|
+
normalizedArgs.push((tx) => tx.pure(bytes));
|
|
123
|
+
continue;
|
|
124
|
+
} else if (typeof arg === 'string') {
|
|
125
|
+
normalizedArgs.push((tx) => tx.object(arg));
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return normalizedArgs;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export class MoveStruct<
|
|
136
|
+
T extends Record<string, BcsType<any>>,
|
|
137
|
+
const Name extends string = string,
|
|
138
|
+
> extends BcsStruct<T, Name> {}
|
|
139
|
+
|
|
140
|
+
export class MoveEnum<
|
|
141
|
+
T extends Record<string, BcsType<any> | null>,
|
|
142
|
+
const Name extends string,
|
|
143
|
+
> extends BcsEnum<T, Name> {}
|
|
144
|
+
|
|
145
|
+
export class MoveTuple<
|
|
146
|
+
T extends readonly BcsType<any>[],
|
|
147
|
+
const Name extends string,
|
|
148
|
+
> extends BcsTuple<T, Name> {}
|
|
149
|
+
|
|
150
|
+
function stringify(val: unknown) {
|
|
151
|
+
if (typeof val === 'object') {
|
|
152
|
+
return JSON.stringify(val, (val: unknown) => val);
|
|
153
|
+
}
|
|
154
|
+
if (typeof val === 'bigint') {
|
|
155
|
+
return val.toString();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return val;
|
|
159
|
+
}
|
|
@@ -102,7 +102,7 @@ export class GraphService {
|
|
|
102
102
|
maxHops: config.maxHops || 3,
|
|
103
103
|
enableEmbeddings: config.enableEmbeddings !== false,
|
|
104
104
|
deduplicationThreshold: config.deduplicationThreshold || 0.85,
|
|
105
|
-
geminiApiKey: config.geminiApiKey || process.env.GOOGLE_AI_API_KEY || process.env.GEMINI_API_KEY || '',
|
|
105
|
+
geminiApiKey: config.geminiApiKey || process.env.OPENROUTER_API_KEY || process.env.GOOGLE_AI_API_KEY || process.env.GEMINI_API_KEY || '',
|
|
106
106
|
geminiConfig: config.geminiConfig || {},
|
|
107
107
|
useMockAI: config.useMockAI || false
|
|
108
108
|
};
|
package/src/index.ts
CHANGED
|
@@ -33,7 +33,12 @@ import type { PipelineConfig, PipelineManagerConfig } from './pipeline';
|
|
|
33
33
|
// ==================== SERVICES ====================
|
|
34
34
|
// Business logic services
|
|
35
35
|
export { StorageService } from './services/StorageService';
|
|
36
|
-
export {
|
|
36
|
+
export {
|
|
37
|
+
EmbeddingService,
|
|
38
|
+
getSharedEmbeddingService,
|
|
39
|
+
clearSharedEmbeddingServices,
|
|
40
|
+
getSharedEmbeddingStats,
|
|
41
|
+
} from './services/EmbeddingService';
|
|
37
42
|
export { GeminiAIService } from './services/GeminiAIService';
|
|
38
43
|
export { QueryService } from './services/QueryService';
|
|
39
44
|
export { ClassifierService } from './services/ClassifierService';
|
|
@@ -454,6 +459,25 @@ export type { RebuildIndexOptions, RebuildIndexResult } from './utils/rebuildInd
|
|
|
454
459
|
export { rebuildIndexNode, hasExistingIndexNode, clearIndexNode } from './utils/rebuildIndexNode';
|
|
455
460
|
export type { RebuildIndexNodeOptions, RebuildIndexNodeResult } from './utils/rebuildIndexNode';
|
|
456
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
|
+
|
|
457
481
|
// ==================== AI SDK INTEGRATION ====================
|
|
458
482
|
// AI SDK tools and vector store for Vercel AI SDK integration
|
|
459
483
|
export { pdwTools } from './ai-sdk/tools';
|
package/src/permissions/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permissions Module
|
|
3
|
-
*
|
|
4
|
-
* Consent persistence and repository implementations.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export type { ConsentRepository } from './ConsentRepository';
|
|
8
|
-
export { FileSystemConsentRepository } from './ConsentRepository';
|
|
9
|
-
export { InMemoryConsentRepository } from './ConsentRepository';
|
|
1
|
+
/**
|
|
2
|
+
* Permissions Module
|
|
3
|
+
*
|
|
4
|
+
* Consent persistence and repository implementations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type { ConsentRepository } from './ConsentRepository';
|
|
8
|
+
export { FileSystemConsentRepository } from './ConsentRepository';
|
|
9
|
+
export { InMemoryConsentRepository } from './ConsentRepository';
|