@soulcraft/brainy 3.20.1 → 3.20.3
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/CHANGELOG.md +19 -0
- package/bin/brainy-interactive.js +2 -2
- package/dist/brainy.d.ts +1 -1
- package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
- package/dist/mcp/brainyMCPService.d.ts +1 -1
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +1 -1
- package/dist/shared/default-augmentations.d.ts +1 -1
- package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
- package/dist/vfs/VirtualFileSystem.d.ts +1 -0
- package/dist/vfs/VirtualFileSystem.js +108 -69
- package/package.json +1 -1
- package/dist/augmentationFactory.d.ts +0 -86
- package/dist/augmentationFactory.js +0 -342
- package/dist/augmentationRegistry.d.ts +0 -38
- package/dist/augmentationRegistry.js +0 -54
- package/dist/augmentationRegistryLoader.d.ts +0 -146
- package/dist/augmentationRegistryLoader.js +0 -213
- package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
- package/dist/augmentations/KnowledgeAugmentation.js +0 -251
- package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
- package/dist/augmentations/intelligentVerbScoring.js +0 -377
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
- package/dist/augmentations/marketplace/cli.d.ts +0 -47
- package/dist/augmentations/marketplace/cli.js +0 -265
- package/dist/augmentations/memoryAugmentations.d.ts +0 -72
- package/dist/augmentations/memoryAugmentations.js +0 -280
- package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
- package/dist/augmentations/serverSearchAugmentations.js +0 -586
- package/dist/brainy-unified.d.ts +0 -106
- package/dist/brainy-unified.js +0 -327
- package/dist/brainyData.d.ts +0 -1832
- package/dist/brainyData.js +0 -6443
- package/dist/brainyDataV3.d.ts +0 -186
- package/dist/brainyDataV3.js +0 -337
- package/dist/config/distributedPresets-new.d.ts +0 -118
- package/dist/config/distributedPresets-new.js +0 -318
- package/dist/config/modelPrecisionManager.d.ts +0 -42
- package/dist/config/modelPrecisionManager.js +0 -98
- package/dist/connectors/interfaces/IConnector.d.ts +0 -143
- package/dist/connectors/interfaces/IConnector.js +0 -8
- package/dist/demo.d.ts +0 -106
- package/dist/demo.js +0 -201
- package/dist/embeddings/SingletonModelManager.d.ts +0 -95
- package/dist/embeddings/SingletonModelManager.js +0 -220
- package/dist/embeddings/lightweight-embedder.d.ts +0 -22
- package/dist/embeddings/lightweight-embedder.js +0 -128
- package/dist/embeddings/model-manager.d.ts +0 -39
- package/dist/embeddings/model-manager.js +0 -245
- package/dist/embeddings/universal-memory-manager.d.ts +0 -38
- package/dist/embeddings/universal-memory-manager.js +0 -166
- package/dist/embeddings/worker-embedding.d.ts +0 -7
- package/dist/embeddings/worker-embedding.js +0 -73
- package/dist/embeddings/worker-manager.d.ts +0 -28
- package/dist/embeddings/worker-manager.js +0 -162
- package/dist/examples/basicUsage.d.ts +0 -4
- package/dist/examples/basicUsage.js +0 -121
- package/dist/indices/fieldIndex.d.ts +0 -76
- package/dist/indices/fieldIndex.js +0 -357
- package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
- package/dist/mcp/brainyMCPBroadcast.js +0 -303
- package/dist/mcp/brainyMCPClient.d.ts +0 -92
- package/dist/mcp/brainyMCPClient.js +0 -258
- package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
- package/dist/scripts/precomputePatternEmbeddings.js +0 -100
- package/dist/utils/cacheAutoConfig.d.ts +0 -63
- package/dist/utils/cacheAutoConfig.js +0 -261
- package/dist/utils/hybridModelManager.d.ts +0 -64
- package/dist/utils/hybridModelManager.js +0 -95
- package/dist/utils/statistics.d.ts +0 -28
- package/dist/utils/statistics.js +0 -25
- package/dist/vfs/ConceptSystem.d.ts +0 -203
- package/dist/vfs/ConceptSystem.js +0 -545
- package/dist/vfs/EntityManager.d.ts +0 -75
- package/dist/vfs/EntityManager.js +0 -216
- package/dist/vfs/EventRecorder.d.ts +0 -84
- package/dist/vfs/EventRecorder.js +0 -269
- package/dist/vfs/GitBridge.d.ts +0 -167
- package/dist/vfs/GitBridge.js +0 -537
- package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
- package/dist/vfs/KnowledgeAugmentation.js +0 -146
- package/dist/vfs/KnowledgeLayer.d.ts +0 -35
- package/dist/vfs/KnowledgeLayer.js +0 -443
- package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
- package/dist/vfs/PersistentEntitySystem.js +0 -503
- package/dist/vfs/SemanticVersioning.d.ts +0 -105
- package/dist/vfs/SemanticVersioning.js +0 -309
- package/dist/vfs/VFSHealthCheck.d.ts +0 -78
- package/dist/vfs/VFSHealthCheck.js +0 -299
- /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
package/dist/brainyData.d.ts
DELETED
|
@@ -1,1832 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BrainyData
|
|
3
|
-
* Main class that provides the vector database functionality
|
|
4
|
-
*/
|
|
5
|
-
import { HNSWIndex } from './hnsw/hnswIndex.js';
|
|
6
|
-
import { HNSWIndexOptimized, HNSWOptimizedConfig } from './hnsw/hnswIndexOptimized.js';
|
|
7
|
-
import { DistanceFunction, GraphVerb, EmbeddingFunction, HNSWConfig, SearchResult, SearchCursor, PaginatedSearchResult, StorageAdapter, Vector, VectorDocument } from './coreTypes.js';
|
|
8
|
-
import { MetadataIndexConfig } from './utils/metadataIndex.js';
|
|
9
|
-
import { CleanupConfig } from './utils/periodicCleanup.js';
|
|
10
|
-
import { NounType, VerbType } from './types/graphTypes.js';
|
|
11
|
-
import { BrainyDataInterface } from './types/brainyDataInterface.js';
|
|
12
|
-
import { DistributedConfig } from './types/distributedTypes.js';
|
|
13
|
-
import { SearchCacheConfig } from './utils/searchCache.js';
|
|
14
|
-
import { ImprovedNeuralAPI } from './neural/improvedNeuralAPI.js';
|
|
15
|
-
import { TripleQuery, TripleResult } from './triple/TripleIntelligence.js';
|
|
16
|
-
export interface BrainyDataConfig {
|
|
17
|
-
/**
|
|
18
|
-
* HNSW index configuration
|
|
19
|
-
* Uses the optimized HNSW implementation which supports large datasets
|
|
20
|
-
* through product quantization and disk-based storage
|
|
21
|
-
*/
|
|
22
|
-
hnsw?: Partial<HNSWOptimizedConfig>;
|
|
23
|
-
/**
|
|
24
|
-
* Default service name to use for all operations
|
|
25
|
-
* When specified, this service name will be used for all operations
|
|
26
|
-
* that don't explicitly provide a service name
|
|
27
|
-
*/
|
|
28
|
-
defaultService?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Distance function to use for similarity calculations
|
|
31
|
-
*/
|
|
32
|
-
distanceFunction?: DistanceFunction;
|
|
33
|
-
/**
|
|
34
|
-
* Custom storage adapter (if not provided, will use OPFS or memory storage)
|
|
35
|
-
*/
|
|
36
|
-
storageAdapter?: StorageAdapter;
|
|
37
|
-
/**
|
|
38
|
-
* Storage configuration options
|
|
39
|
-
* These will be passed to createStorage if storageAdapter is not provided
|
|
40
|
-
*/
|
|
41
|
-
storage?: {
|
|
42
|
-
requestPersistentStorage?: boolean;
|
|
43
|
-
r2Storage?: {
|
|
44
|
-
bucketName?: string;
|
|
45
|
-
accountId?: string;
|
|
46
|
-
accessKeyId?: string;
|
|
47
|
-
secretAccessKey?: string;
|
|
48
|
-
};
|
|
49
|
-
s3Storage?: {
|
|
50
|
-
bucketName?: string;
|
|
51
|
-
accessKeyId?: string;
|
|
52
|
-
secretAccessKey?: string;
|
|
53
|
-
region?: string;
|
|
54
|
-
};
|
|
55
|
-
gcsStorage?: {
|
|
56
|
-
bucketName?: string;
|
|
57
|
-
accessKeyId?: string;
|
|
58
|
-
secretAccessKey?: string;
|
|
59
|
-
endpoint?: string;
|
|
60
|
-
};
|
|
61
|
-
customS3Storage?: {
|
|
62
|
-
bucketName?: string;
|
|
63
|
-
accessKeyId?: string;
|
|
64
|
-
secretAccessKey?: string;
|
|
65
|
-
endpoint?: string;
|
|
66
|
-
region?: string;
|
|
67
|
-
};
|
|
68
|
-
forceFileSystemStorage?: boolean;
|
|
69
|
-
forceMemoryStorage?: boolean;
|
|
70
|
-
cacheConfig?: {
|
|
71
|
-
hotCacheMaxSize?: number;
|
|
72
|
-
hotCacheEvictionThreshold?: number;
|
|
73
|
-
warmCacheTTL?: number;
|
|
74
|
-
batchSize?: number;
|
|
75
|
-
autoTune?: boolean;
|
|
76
|
-
autoTuneInterval?: number;
|
|
77
|
-
readOnly?: boolean;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Embedding function to convert data to vectors
|
|
82
|
-
*/
|
|
83
|
-
embeddingFunction?: EmbeddingFunction;
|
|
84
|
-
/**
|
|
85
|
-
* Set the database to read-only mode
|
|
86
|
-
* When true, all write operations will throw an error
|
|
87
|
-
* Note: Statistics and index optimizations are still allowed unless frozen is also true
|
|
88
|
-
*/
|
|
89
|
-
readOnly?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Completely freeze the database, preventing all changes including statistics and index optimizations
|
|
92
|
-
* When true, the database is completely immutable (no data changes, no index rebalancing, no statistics updates)
|
|
93
|
-
* This is useful for forensic analysis, testing with deterministic state, or compliance scenarios
|
|
94
|
-
* Default: false (allows optimizations even in readOnly mode)
|
|
95
|
-
*/
|
|
96
|
-
frozen?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Enable lazy loading in read-only mode
|
|
99
|
-
* When true and in read-only mode, the index is not fully loaded during initialization
|
|
100
|
-
* Nodes are loaded on-demand during search operations
|
|
101
|
-
* This improves startup performance for large datasets
|
|
102
|
-
*/
|
|
103
|
-
lazyLoadInReadOnlyMode?: boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Set the database to write-only mode
|
|
106
|
-
* When true, the index is not loaded into memory and search operations will throw an error
|
|
107
|
-
* This is useful for data ingestion scenarios where only write operations are needed
|
|
108
|
-
*/
|
|
109
|
-
writeOnly?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Allow direct storage reads in write-only mode
|
|
112
|
-
* When true and writeOnly is also true, enables direct ID-based lookups (get, has, exists, getMetadata, getBatch, getVerb)
|
|
113
|
-
* that don't require search indexes. Search operations (search, similar, query, findRelated) remain disabled.
|
|
114
|
-
* This is useful for writer services that need deduplication without loading expensive search indexes.
|
|
115
|
-
*/
|
|
116
|
-
allowDirectReads?: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Remote server configuration for search operations
|
|
119
|
-
*/
|
|
120
|
-
remoteServer?: {
|
|
121
|
-
/**
|
|
122
|
-
* WebSocket URL of the remote Brainy server
|
|
123
|
-
*/
|
|
124
|
-
url: string;
|
|
125
|
-
/**
|
|
126
|
-
* WebSocket protocols to use for the connection
|
|
127
|
-
*/
|
|
128
|
-
protocols?: string | string[];
|
|
129
|
-
/**
|
|
130
|
-
* Whether to automatically connect to the remote server on initialization
|
|
131
|
-
*/
|
|
132
|
-
autoConnect?: boolean;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Logging configuration
|
|
136
|
-
*/
|
|
137
|
-
logging?: {
|
|
138
|
-
/**
|
|
139
|
-
* Whether to enable verbose logging
|
|
140
|
-
* When false, suppresses non-essential log messages like model loading progress
|
|
141
|
-
* Default: true
|
|
142
|
-
*/
|
|
143
|
-
verbose?: boolean;
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Metadata indexing configuration
|
|
147
|
-
*/
|
|
148
|
-
metadataIndex?: MetadataIndexConfig;
|
|
149
|
-
/**
|
|
150
|
-
* Search result caching configuration
|
|
151
|
-
* Improves performance for repeated queries
|
|
152
|
-
*/
|
|
153
|
-
searchCache?: SearchCacheConfig;
|
|
154
|
-
/**
|
|
155
|
-
* Timeout configuration for async operations
|
|
156
|
-
* Controls how long operations wait before timing out
|
|
157
|
-
*/
|
|
158
|
-
timeouts?: {
|
|
159
|
-
/**
|
|
160
|
-
* Timeout for get operations in milliseconds
|
|
161
|
-
* Default: 30000 (30 seconds)
|
|
162
|
-
*/
|
|
163
|
-
get?: number;
|
|
164
|
-
/**
|
|
165
|
-
* Timeout for add operations in milliseconds
|
|
166
|
-
* Default: 60000 (60 seconds)
|
|
167
|
-
*/
|
|
168
|
-
add?: number;
|
|
169
|
-
/**
|
|
170
|
-
* Timeout for delete operations in milliseconds
|
|
171
|
-
* Default: 30000 (30 seconds)
|
|
172
|
-
*/
|
|
173
|
-
delete?: number;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Retry policy configuration for failed operations
|
|
177
|
-
* Controls how operations are retried on failure
|
|
178
|
-
*/
|
|
179
|
-
retryPolicy?: {
|
|
180
|
-
/**
|
|
181
|
-
* Maximum number of retry attempts
|
|
182
|
-
* Default: 3
|
|
183
|
-
*/
|
|
184
|
-
maxRetries?: number;
|
|
185
|
-
/**
|
|
186
|
-
* Initial delay between retries in milliseconds
|
|
187
|
-
* Default: 1000 (1 second)
|
|
188
|
-
*/
|
|
189
|
-
initialDelay?: number;
|
|
190
|
-
/**
|
|
191
|
-
* Maximum delay between retries in milliseconds
|
|
192
|
-
* Default: 10000 (10 seconds)
|
|
193
|
-
*/
|
|
194
|
-
maxDelay?: number;
|
|
195
|
-
/**
|
|
196
|
-
* Multiplier for exponential backoff
|
|
197
|
-
* Default: 2
|
|
198
|
-
*/
|
|
199
|
-
backoffMultiplier?: number;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Real-time update configuration
|
|
203
|
-
* Controls how the database handles updates when data is added by external processes
|
|
204
|
-
*/
|
|
205
|
-
realtimeUpdates?: {
|
|
206
|
-
/**
|
|
207
|
-
* Whether to enable automatic updates of the index and statistics
|
|
208
|
-
* When true, the database will periodically check for new data in storage
|
|
209
|
-
* Default: false
|
|
210
|
-
*/
|
|
211
|
-
enabled?: boolean;
|
|
212
|
-
/**
|
|
213
|
-
* The interval (in milliseconds) at which to check for updates
|
|
214
|
-
* Default: 30000 (30 seconds)
|
|
215
|
-
*/
|
|
216
|
-
interval?: number;
|
|
217
|
-
/**
|
|
218
|
-
* Whether to update statistics when checking for updates
|
|
219
|
-
* Default: true
|
|
220
|
-
*/
|
|
221
|
-
updateStatistics?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Whether to update the index when checking for updates
|
|
224
|
-
* Default: true
|
|
225
|
-
*/
|
|
226
|
-
updateIndex?: boolean;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* Distributed mode configuration
|
|
230
|
-
* Enables coordination across multiple Brainy instances
|
|
231
|
-
*/
|
|
232
|
-
distributed?: DistributedConfig | boolean;
|
|
233
|
-
/**
|
|
234
|
-
* Cache configuration for optimizing search performance
|
|
235
|
-
* Controls how the system caches data for faster access
|
|
236
|
-
* Particularly important for large datasets in S3 or other remote storage
|
|
237
|
-
*/
|
|
238
|
-
cache?: {
|
|
239
|
-
/**
|
|
240
|
-
* Whether to enable auto-tuning of cache parameters
|
|
241
|
-
* When true, the system will automatically adjust cache sizes based on usage patterns
|
|
242
|
-
* Default: true
|
|
243
|
-
*/
|
|
244
|
-
autoTune?: boolean;
|
|
245
|
-
/**
|
|
246
|
-
* The interval (in milliseconds) at which to auto-tune cache parameters
|
|
247
|
-
* Only applies when autoTune is true
|
|
248
|
-
* Default: 60000 (60 seconds)
|
|
249
|
-
*/
|
|
250
|
-
autoTuneInterval?: number;
|
|
251
|
-
/**
|
|
252
|
-
* Maximum size of the hot cache (most frequently accessed items)
|
|
253
|
-
* If provided, overrides the automatically detected optimal size
|
|
254
|
-
* For large datasets, consider values between 5000-50000 depending on available memory
|
|
255
|
-
*/
|
|
256
|
-
hotCacheMaxSize?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Threshold at which to start evicting items from the hot cache
|
|
259
|
-
* Expressed as a fraction of hotCacheMaxSize (0.0 to 1.0)
|
|
260
|
-
* Default: 0.8 (start evicting when cache is 80% full)
|
|
261
|
-
*/
|
|
262
|
-
hotCacheEvictionThreshold?: number;
|
|
263
|
-
/**
|
|
264
|
-
* Time-to-live for items in the warm cache in milliseconds
|
|
265
|
-
* Default: 3600000 (1 hour)
|
|
266
|
-
*/
|
|
267
|
-
warmCacheTTL?: number;
|
|
268
|
-
/**
|
|
269
|
-
* Batch size for operations like prefetching
|
|
270
|
-
* Larger values improve throughput but use more memory
|
|
271
|
-
* For S3 or remote storage with large datasets, consider values between 50-200
|
|
272
|
-
*/
|
|
273
|
-
batchSize?: number;
|
|
274
|
-
/**
|
|
275
|
-
* Read-only mode specific optimizations
|
|
276
|
-
* These settings are only applied when readOnly is true
|
|
277
|
-
*/
|
|
278
|
-
readOnlyMode?: {
|
|
279
|
-
/**
|
|
280
|
-
* Maximum size of the hot cache in read-only mode
|
|
281
|
-
* In read-only mode, larger cache sizes can be used since there are no write operations
|
|
282
|
-
* For large datasets, consider values between 10000-100000 depending on available memory
|
|
283
|
-
*/
|
|
284
|
-
hotCacheMaxSize?: number;
|
|
285
|
-
/**
|
|
286
|
-
* Batch size for operations in read-only mode
|
|
287
|
-
* Larger values improve throughput in read-only mode
|
|
288
|
-
* For S3 or remote storage with large datasets, consider values between 100-300
|
|
289
|
-
*/
|
|
290
|
-
batchSize?: number;
|
|
291
|
-
/**
|
|
292
|
-
* Prefetch strategy for read-only mode
|
|
293
|
-
* Controls how aggressively the system prefetches data
|
|
294
|
-
* Options: 'conservative', 'moderate', 'aggressive'
|
|
295
|
-
* Default: 'moderate'
|
|
296
|
-
*/
|
|
297
|
-
prefetchStrategy?: 'conservative' | 'moderate' | 'aggressive';
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* Batch processing configuration for enterprise-scale throughput
|
|
302
|
-
* Automatically batches operations for 10-50x performance improvement
|
|
303
|
-
* Critical for processing millions of operations efficiently
|
|
304
|
-
*/
|
|
305
|
-
batchSize?: number;
|
|
306
|
-
batchWaitTime?: number;
|
|
307
|
-
/**
|
|
308
|
-
* Real-time streaming configuration for WebSocket/WebRTC
|
|
309
|
-
* Enables live data broadcasting to thousands of connected clients
|
|
310
|
-
* Essential for real-time applications like Bluesky firehose
|
|
311
|
-
*/
|
|
312
|
-
realtime?: {
|
|
313
|
-
websocket?: {
|
|
314
|
-
enabled?: boolean;
|
|
315
|
-
port?: number;
|
|
316
|
-
maxConnections?: number;
|
|
317
|
-
};
|
|
318
|
-
webrtc?: {
|
|
319
|
-
enabled?: boolean;
|
|
320
|
-
maxPeers?: number;
|
|
321
|
-
};
|
|
322
|
-
broadcasting?: {
|
|
323
|
-
operations?: string[];
|
|
324
|
-
includeData?: boolean;
|
|
325
|
-
};
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Intelligent verb scoring configuration
|
|
329
|
-
* Automatically generates weight and confidence scores for verb relationships
|
|
330
|
-
* Enabled by default for better relationship quality
|
|
331
|
-
*/
|
|
332
|
-
intelligentVerbScoring?: {
|
|
333
|
-
/**
|
|
334
|
-
* Whether to enable intelligent verb scoring
|
|
335
|
-
* Default: true (enabled by default for better relationship quality)
|
|
336
|
-
*/
|
|
337
|
-
enabled?: boolean;
|
|
338
|
-
/**
|
|
339
|
-
* Enable semantic proximity scoring based on entity embeddings
|
|
340
|
-
* Default: true
|
|
341
|
-
*/
|
|
342
|
-
enableSemanticScoring?: boolean;
|
|
343
|
-
/**
|
|
344
|
-
* Enable frequency-based weight amplification
|
|
345
|
-
* Default: true
|
|
346
|
-
*/
|
|
347
|
-
enableFrequencyAmplification?: boolean;
|
|
348
|
-
/**
|
|
349
|
-
* Enable temporal decay for weights
|
|
350
|
-
* Default: true
|
|
351
|
-
*/
|
|
352
|
-
enableTemporalDecay?: boolean;
|
|
353
|
-
/**
|
|
354
|
-
* Decay rate per day for temporal scoring (0-1)
|
|
355
|
-
* Default: 0.01 (1% decay per day)
|
|
356
|
-
*/
|
|
357
|
-
temporalDecayRate?: number;
|
|
358
|
-
/**
|
|
359
|
-
* Minimum weight threshold
|
|
360
|
-
* Default: 0.1
|
|
361
|
-
*/
|
|
362
|
-
minWeight?: number;
|
|
363
|
-
/**
|
|
364
|
-
* Maximum weight threshold
|
|
365
|
-
* Default: 1.0
|
|
366
|
-
*/
|
|
367
|
-
maxWeight?: number;
|
|
368
|
-
/**
|
|
369
|
-
* Base confidence score for new relationships
|
|
370
|
-
* Default: 0.5
|
|
371
|
-
*/
|
|
372
|
-
baseConfidence?: number;
|
|
373
|
-
/**
|
|
374
|
-
* Learning rate for adaptive scoring (0-1)
|
|
375
|
-
* Default: 0.1
|
|
376
|
-
*/
|
|
377
|
-
learningRate?: number;
|
|
378
|
-
};
|
|
379
|
-
/**
|
|
380
|
-
* Entity registry configuration for fast external-ID to UUID mapping
|
|
381
|
-
* Provides lightning-fast lookups for streaming data processing
|
|
382
|
-
*/
|
|
383
|
-
entityCacheSize?: number;
|
|
384
|
-
entityCacheTTL?: number;
|
|
385
|
-
/**
|
|
386
|
-
* Statistics collection configuration
|
|
387
|
-
* When false, disables metrics collection. When true or config object, enables with options.
|
|
388
|
-
* Default: true
|
|
389
|
-
*/
|
|
390
|
-
statistics?: boolean;
|
|
391
|
-
/**
|
|
392
|
-
* Health monitoring configuration
|
|
393
|
-
* When false, disables health monitoring. When true or config object, enables with options.
|
|
394
|
-
* Default: false (enabled automatically for distributed setups)
|
|
395
|
-
*/
|
|
396
|
-
health?: boolean;
|
|
397
|
-
/**
|
|
398
|
-
* Periodic cleanup configuration for old soft-deleted items
|
|
399
|
-
* Automatically removes soft-deleted items after a specified age to prevent memory buildup
|
|
400
|
-
* Default: enabled with 1 hour max age and 15 minute cleanup interval
|
|
401
|
-
*/
|
|
402
|
-
cleanup?: Partial<CleanupConfig>;
|
|
403
|
-
}
|
|
404
|
-
export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
405
|
-
hnswIndex: HNSWIndex | HNSWIndexOptimized;
|
|
406
|
-
private storage;
|
|
407
|
-
private isInitialized;
|
|
408
|
-
private isInitializing;
|
|
409
|
-
private embeddingFunction;
|
|
410
|
-
private distanceFunction;
|
|
411
|
-
private requestPersistentStorage;
|
|
412
|
-
private readOnly;
|
|
413
|
-
private frozen;
|
|
414
|
-
private lazyLoadInReadOnlyMode;
|
|
415
|
-
private writeOnly;
|
|
416
|
-
private allowDirectReads;
|
|
417
|
-
private storageConfig;
|
|
418
|
-
private config;
|
|
419
|
-
private rawConfig;
|
|
420
|
-
private useOptimizedIndex;
|
|
421
|
-
private _dimensions;
|
|
422
|
-
private loggingConfig;
|
|
423
|
-
private defaultService;
|
|
424
|
-
/**
|
|
425
|
-
* Enterprise augmentation system
|
|
426
|
-
* Handles WAL, connection pooling, batching, streaming, and intelligent scoring
|
|
427
|
-
*/
|
|
428
|
-
private augmentations;
|
|
429
|
-
/**
|
|
430
|
-
* Neural similarity API for semantic operations
|
|
431
|
-
*/
|
|
432
|
-
private _neural?;
|
|
433
|
-
private _tripleEngine?;
|
|
434
|
-
private _nlpProcessor?;
|
|
435
|
-
private _importManager?;
|
|
436
|
-
private cacheAutoConfigurator;
|
|
437
|
-
private periodicCleanup;
|
|
438
|
-
private timeoutConfig;
|
|
439
|
-
private retryConfig;
|
|
440
|
-
private cacheConfig;
|
|
441
|
-
private realtimeUpdateConfig;
|
|
442
|
-
private updateTimerId;
|
|
443
|
-
private maintenanceIntervals;
|
|
444
|
-
private lastUpdateTime;
|
|
445
|
-
private lastKnownNounCount;
|
|
446
|
-
private remoteServerConfig;
|
|
447
|
-
private intelligentVerbScoring;
|
|
448
|
-
private distributedConfig;
|
|
449
|
-
private configManager;
|
|
450
|
-
private partitioner;
|
|
451
|
-
private operationalMode;
|
|
452
|
-
private domainDetector;
|
|
453
|
-
private networkTransport;
|
|
454
|
-
private coordinator;
|
|
455
|
-
private shardManager;
|
|
456
|
-
private cacheSync;
|
|
457
|
-
private readWriteSeparation;
|
|
458
|
-
private httpTransport;
|
|
459
|
-
private storageDiscovery;
|
|
460
|
-
private queryPlanner;
|
|
461
|
-
private shardMigrationManager;
|
|
462
|
-
private get cache();
|
|
463
|
-
private get index();
|
|
464
|
-
private get metadataIndex();
|
|
465
|
-
private get metrics();
|
|
466
|
-
private get monitoring();
|
|
467
|
-
/**
|
|
468
|
-
* Get the vector dimensions
|
|
469
|
-
*/
|
|
470
|
-
get dimensions(): number;
|
|
471
|
-
/**
|
|
472
|
-
* Get the maximum connections parameter from HNSW configuration
|
|
473
|
-
*/
|
|
474
|
-
get maxConnections(): number;
|
|
475
|
-
/**
|
|
476
|
-
* Get the efConstruction parameter from HNSW configuration
|
|
477
|
-
*/
|
|
478
|
-
get efConstruction(): number;
|
|
479
|
-
/**
|
|
480
|
-
* Check if BrainyData has been initialized
|
|
481
|
-
*/
|
|
482
|
-
get initialized(): boolean;
|
|
483
|
-
/**
|
|
484
|
-
* Create a new vector database
|
|
485
|
-
* @param config - Zero-config string ('production', 'development', 'minimal'),
|
|
486
|
-
* simplified config object, or legacy full config
|
|
487
|
-
*/
|
|
488
|
-
constructor(config?: BrainyDataConfig | string | any);
|
|
489
|
-
/**
|
|
490
|
-
* Check if the database is in read-only mode and throw an error if it is
|
|
491
|
-
* @throws Error if the database is in read-only mode
|
|
492
|
-
*/
|
|
493
|
-
/**
|
|
494
|
-
* Register default augmentations without initializing them
|
|
495
|
-
* Phase 1 of two-phase initialization
|
|
496
|
-
*/
|
|
497
|
-
private registerDefaultAugmentations;
|
|
498
|
-
/**
|
|
499
|
-
* Resolve storage from augmentation or config
|
|
500
|
-
* Phase 2 of two-phase initialization
|
|
501
|
-
*/
|
|
502
|
-
private resolveStorage;
|
|
503
|
-
/**
|
|
504
|
-
* Initialize the augmentation system with full context
|
|
505
|
-
* Phase 3 of two-phase initialization
|
|
506
|
-
*/
|
|
507
|
-
private initializeAugmentations;
|
|
508
|
-
/**
|
|
509
|
-
* Initialize periodic cleanup system for old soft-deleted items
|
|
510
|
-
* SAFETY-CRITICAL: Coordinates with both HNSW and metadata indexes
|
|
511
|
-
*/
|
|
512
|
-
private initializePeriodicCleanup;
|
|
513
|
-
private checkReadOnly;
|
|
514
|
-
/**
|
|
515
|
-
* Check if the database is frozen and throw an error if it is
|
|
516
|
-
* @throws Error if the database is frozen
|
|
517
|
-
*/
|
|
518
|
-
private checkFrozen;
|
|
519
|
-
/**
|
|
520
|
-
* Check if the database is in write-only mode and throw an error if it is
|
|
521
|
-
* @param allowExistenceChecks If true, allows existence checks (get operations) in write-only mode
|
|
522
|
-
* @param isDirectStorageOperation If true, allows the operation when allowDirectReads is enabled
|
|
523
|
-
* @throws Error if the database is in write-only mode and operation is not allowed
|
|
524
|
-
*/
|
|
525
|
-
private checkWriteOnly;
|
|
526
|
-
/**
|
|
527
|
-
* Start real-time updates if enabled in the configuration
|
|
528
|
-
* This will periodically check for new data in storage and update the in-memory index and statistics
|
|
529
|
-
*/
|
|
530
|
-
private startRealtimeUpdates;
|
|
531
|
-
/**
|
|
532
|
-
* Stop real-time updates
|
|
533
|
-
*/
|
|
534
|
-
private stopRealtimeUpdates;
|
|
535
|
-
/**
|
|
536
|
-
* Manually check for updates in storage and update the in-memory index and statistics
|
|
537
|
-
* This can be called by the user to force an update check even if automatic updates are not enabled
|
|
538
|
-
*/
|
|
539
|
-
checkForUpdatesNow(): Promise<void>;
|
|
540
|
-
/**
|
|
541
|
-
* Enable real-time updates with the specified configuration
|
|
542
|
-
* @param config Configuration for real-time updates
|
|
543
|
-
*/
|
|
544
|
-
enableRealtimeUpdates(config?: Partial<BrainyDataConfig['realtimeUpdates']>): void;
|
|
545
|
-
/**
|
|
546
|
-
* Start metadata index maintenance
|
|
547
|
-
*/
|
|
548
|
-
private startMetadataIndexMaintenance;
|
|
549
|
-
/**
|
|
550
|
-
* Disable real-time updates
|
|
551
|
-
*/
|
|
552
|
-
disableRealtimeUpdates(): void;
|
|
553
|
-
/**
|
|
554
|
-
* Get the current real-time update configuration
|
|
555
|
-
* @returns The current real-time update configuration
|
|
556
|
-
*/
|
|
557
|
-
getRealtimeUpdateConfig(): Required<NonNullable<BrainyDataConfig['realtimeUpdates']>>;
|
|
558
|
-
/**
|
|
559
|
-
* Check for updates in storage and update the in-memory index and statistics if needed
|
|
560
|
-
* This is called periodically by the update timer when real-time updates are enabled
|
|
561
|
-
* Uses change log mechanism for efficient updates instead of full scans
|
|
562
|
-
*/
|
|
563
|
-
private checkForUpdates;
|
|
564
|
-
/**
|
|
565
|
-
* Apply changes using the change log mechanism (efficient for distributed storage)
|
|
566
|
-
*/
|
|
567
|
-
private applyChangesFromLog;
|
|
568
|
-
/**
|
|
569
|
-
* Apply changes using full scan method (fallback for storage adapters without change log support)
|
|
570
|
-
*/
|
|
571
|
-
private applyChangesFromFullScan;
|
|
572
|
-
/**
|
|
573
|
-
* Provide feedback to the intelligent verb scoring system for learning
|
|
574
|
-
* This allows the system to learn from user corrections or validation
|
|
575
|
-
*
|
|
576
|
-
* @param sourceId - Source entity ID
|
|
577
|
-
* @param targetId - Target entity ID
|
|
578
|
-
* @param verbType - Relationship type
|
|
579
|
-
* @param feedbackWeight - The corrected/validated weight (0-1)
|
|
580
|
-
* @param feedbackConfidence - The corrected/validated confidence (0-1)
|
|
581
|
-
* @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
|
|
582
|
-
*/
|
|
583
|
-
provideFeedbackForVerbScoring(sourceId: string, targetId: string, verbType: string, feedbackWeight: number, feedbackConfidence?: number, feedbackType?: 'correction' | 'validation' | 'enhancement'): Promise<void>;
|
|
584
|
-
/**
|
|
585
|
-
* Get learning statistics from the intelligent verb scoring system
|
|
586
|
-
*/
|
|
587
|
-
getVerbScoringStats(): any;
|
|
588
|
-
/**
|
|
589
|
-
* Export learning data from the intelligent verb scoring system
|
|
590
|
-
*/
|
|
591
|
-
exportVerbScoringLearningData(): string | null;
|
|
592
|
-
/**
|
|
593
|
-
* Import learning data into the intelligent verb scoring system
|
|
594
|
-
*/
|
|
595
|
-
importVerbScoringLearningData(jsonData: string): void;
|
|
596
|
-
/**
|
|
597
|
-
* Get the current augmentation name if available
|
|
598
|
-
* This is used to auto-detect the service performing data operations
|
|
599
|
-
* @returns The name of the current augmentation or 'default' if none is detected
|
|
600
|
-
*/
|
|
601
|
-
private getCurrentAugmentation;
|
|
602
|
-
/**
|
|
603
|
-
* Get the service name from options or fallback to default service
|
|
604
|
-
* This provides a consistent way to handle service names across all methods
|
|
605
|
-
* @param options Options object that may contain a service property
|
|
606
|
-
* @returns The service name to use for operations
|
|
607
|
-
*/
|
|
608
|
-
private getServiceName;
|
|
609
|
-
/**
|
|
610
|
-
* Initialize the database
|
|
611
|
-
* Loads existing data from storage if available
|
|
612
|
-
*/
|
|
613
|
-
init(): Promise<void>;
|
|
614
|
-
/**
|
|
615
|
-
* Initialize distributed mode
|
|
616
|
-
* Sets up configuration management, partitioning, and operational modes
|
|
617
|
-
*/
|
|
618
|
-
private initializeDistributedMode;
|
|
619
|
-
/**
|
|
620
|
-
* Handle distributed configuration updates
|
|
621
|
-
*/
|
|
622
|
-
private handleDistributedConfigUpdate;
|
|
623
|
-
/**
|
|
624
|
-
* Initialize NEW distributed components for Brainy 3.0
|
|
625
|
-
* This enables true multi-node operation with consensus and sharding
|
|
626
|
-
*/
|
|
627
|
-
private initializeDistributedComponents;
|
|
628
|
-
/**
|
|
629
|
-
* Execute a query on local shards
|
|
630
|
-
*/
|
|
631
|
-
private executeLocalQuery;
|
|
632
|
-
/**
|
|
633
|
-
* Set up distributed operation handlers
|
|
634
|
-
*/
|
|
635
|
-
private setupDistributedOperations;
|
|
636
|
-
/**
|
|
637
|
-
* Local add operation (without distribution)
|
|
638
|
-
*/
|
|
639
|
-
private localAdd;
|
|
640
|
-
/**
|
|
641
|
-
* Local find operation (potentially for a specific shard)
|
|
642
|
-
*/
|
|
643
|
-
private localFind;
|
|
644
|
-
/**
|
|
645
|
-
* Get distributed health status
|
|
646
|
-
* @returns Health status if distributed mode is enabled
|
|
647
|
-
*/
|
|
648
|
-
getHealthStatus(): any;
|
|
649
|
-
/**
|
|
650
|
-
* Add multiple vectors or data items to the database
|
|
651
|
-
* @param items Array of items to add
|
|
652
|
-
* @param options Additional options
|
|
653
|
-
* @returns Array of IDs for the added items
|
|
654
|
-
*/
|
|
655
|
-
/**
|
|
656
|
-
* Add multiple nouns in batch with required types
|
|
657
|
-
* @param items Array of nouns to add (all must have types)
|
|
658
|
-
* @param options Batch processing options
|
|
659
|
-
* @returns Array of generated IDs
|
|
660
|
-
*/
|
|
661
|
-
addNouns(items: Array<{
|
|
662
|
-
vectorOrData: Vector | any;
|
|
663
|
-
nounType: NounType | string;
|
|
664
|
-
metadata?: T;
|
|
665
|
-
}>, options?: {
|
|
666
|
-
forceEmbed?: boolean;
|
|
667
|
-
addToRemote?: boolean;
|
|
668
|
-
concurrency?: number;
|
|
669
|
-
batchSize?: number;
|
|
670
|
-
}): Promise<string[]>;
|
|
671
|
-
/**
|
|
672
|
-
* Filter search results by service
|
|
673
|
-
* @param results Search results to filter
|
|
674
|
-
* @param service Service to filter by
|
|
675
|
-
* @returns Filtered search results
|
|
676
|
-
* @private
|
|
677
|
-
*/
|
|
678
|
-
private filterResultsByService;
|
|
679
|
-
/**
|
|
680
|
-
* Search for similar vectors within specific noun types
|
|
681
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
682
|
-
* @param k Number of results to return
|
|
683
|
-
* @param nounTypes Array of noun types to search within, or null to search all
|
|
684
|
-
* @param options Additional options
|
|
685
|
-
* @returns Array of search results
|
|
686
|
-
*/
|
|
687
|
-
/**
|
|
688
|
-
* @deprecated Use search() with nounTypes option instead
|
|
689
|
-
* @example
|
|
690
|
-
* // Old way (deprecated)
|
|
691
|
-
* await brain.searchByNounTypes(query, 10, ['type1', 'type2'])
|
|
692
|
-
* // New way
|
|
693
|
-
* await brain.search(query, { limit: 10, nounTypes: ['type1', 'type2'] })
|
|
694
|
-
*/
|
|
695
|
-
searchByNounTypes(queryVectorOrData: Vector | any, k?: number, nounTypes?: string[] | null, options?: {
|
|
696
|
-
forceEmbed?: boolean;
|
|
697
|
-
service?: string;
|
|
698
|
-
metadata?: any;
|
|
699
|
-
offset?: number;
|
|
700
|
-
}): Promise<SearchResult<T>[]>;
|
|
701
|
-
/**
|
|
702
|
-
* Search for similar vectors
|
|
703
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
704
|
-
* @param k Number of results to return
|
|
705
|
-
* @param options Additional options
|
|
706
|
-
* @returns Array of search results
|
|
707
|
-
*/
|
|
708
|
-
/**
|
|
709
|
-
* 🔍 SIMPLE VECTOR SEARCH - Clean wrapper around find() for pure vector search
|
|
710
|
-
*
|
|
711
|
-
* @param queryVectorOrData Vector or text to search for
|
|
712
|
-
* @param k Number of results to return
|
|
713
|
-
* @param options Simple search options (metadata filters only)
|
|
714
|
-
* @returns Vector search results
|
|
715
|
-
*/
|
|
716
|
-
/**
|
|
717
|
-
* 🔍 Simple Vector Similarity Search - Clean wrapper around find()
|
|
718
|
-
*
|
|
719
|
-
* search(query) = find({like: query}) - Pure vector similarity search
|
|
720
|
-
*
|
|
721
|
-
* @param queryVectorOrData - Query string, vector, or object to search with
|
|
722
|
-
* @param options - Search options for filtering and pagination
|
|
723
|
-
* @returns Array of search results with scores and metadata
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* // Simple vector search
|
|
727
|
-
* await brain.search('machine learning')
|
|
728
|
-
*
|
|
729
|
-
* // With filters and pagination
|
|
730
|
-
* await brain.search('AI', {
|
|
731
|
-
* limit: 20,
|
|
732
|
-
* metadata: { type: 'article' },
|
|
733
|
-
* nounTypes: ['document']
|
|
734
|
-
* })
|
|
735
|
-
*/
|
|
736
|
-
search(queryVectorOrData: Vector | any, options?: {
|
|
737
|
-
limit?: number;
|
|
738
|
-
offset?: number;
|
|
739
|
-
cursor?: string;
|
|
740
|
-
metadata?: any;
|
|
741
|
-
nounTypes?: string[];
|
|
742
|
-
itemIds?: string[];
|
|
743
|
-
excludeDeleted?: boolean;
|
|
744
|
-
threshold?: number;
|
|
745
|
-
timeout?: number;
|
|
746
|
-
}): Promise<SearchResult<T>[]>;
|
|
747
|
-
/**
|
|
748
|
-
* Helper method to encode cursor for pagination
|
|
749
|
-
* @internal
|
|
750
|
-
*/
|
|
751
|
-
private encodeCursor;
|
|
752
|
-
/**
|
|
753
|
-
* Helper method to decode cursor for pagination
|
|
754
|
-
* @internal
|
|
755
|
-
*/
|
|
756
|
-
private decodeCursor;
|
|
757
|
-
/**
|
|
758
|
-
* Internal method for direct HNSW vector search
|
|
759
|
-
* Used by TripleIntelligence to avoid circular dependencies
|
|
760
|
-
* Note: For pure metadata filtering, use metadataIndex.getIdsForFilter() directly - it's O(log n)!
|
|
761
|
-
* This method is for vector similarity search with optional metadata filtering during search
|
|
762
|
-
* @internal
|
|
763
|
-
*/
|
|
764
|
-
_internalVectorSearch(queryVectorOrData: Vector | any, k?: number, options?: {
|
|
765
|
-
metadata?: any;
|
|
766
|
-
}): Promise<SearchResult<T>[]>;
|
|
767
|
-
/**
|
|
768
|
-
* 🎯 LEGACY: Original search implementation (kept for complex cases)
|
|
769
|
-
* This is the original search method, now used as fallback for edge cases
|
|
770
|
-
*/
|
|
771
|
-
private _legacySearch;
|
|
772
|
-
/**
|
|
773
|
-
* Search with cursor-based pagination for better performance on large datasets
|
|
774
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
775
|
-
* @param k Number of results to return
|
|
776
|
-
* @param options Additional options including cursor for pagination
|
|
777
|
-
* @returns Paginated search results with cursor for next page
|
|
778
|
-
*/
|
|
779
|
-
/**
|
|
780
|
-
* @deprecated Use search() with cursor option instead
|
|
781
|
-
* @example
|
|
782
|
-
* // Old way (deprecated)
|
|
783
|
-
* await brain.searchWithCursor(query, 10, { cursor: 'abc123' })
|
|
784
|
-
* // New way
|
|
785
|
-
* await brain.search(query, { limit: 10, cursor: 'abc123' })
|
|
786
|
-
*/
|
|
787
|
-
searchWithCursor(queryVectorOrData: Vector | any, k?: number, options?: {
|
|
788
|
-
forceEmbed?: boolean;
|
|
789
|
-
nounTypes?: string[];
|
|
790
|
-
includeVerbs?: boolean;
|
|
791
|
-
service?: string;
|
|
792
|
-
searchField?: string;
|
|
793
|
-
filter?: {
|
|
794
|
-
domain?: string;
|
|
795
|
-
};
|
|
796
|
-
cursor?: SearchCursor;
|
|
797
|
-
skipCache?: boolean;
|
|
798
|
-
}): Promise<PaginatedSearchResult<T>>;
|
|
799
|
-
/**
|
|
800
|
-
* Search the local database for similar vectors
|
|
801
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
802
|
-
* @param k Number of results to return
|
|
803
|
-
* @param options Additional options
|
|
804
|
-
* @returns Array of search results
|
|
805
|
-
*/
|
|
806
|
-
searchLocal(queryVectorOrData: Vector | any, k?: number, options?: {
|
|
807
|
-
forceEmbed?: boolean;
|
|
808
|
-
nounTypes?: string[];
|
|
809
|
-
includeVerbs?: boolean;
|
|
810
|
-
service?: string;
|
|
811
|
-
searchField?: string;
|
|
812
|
-
priorityFields?: string[];
|
|
813
|
-
filter?: {
|
|
814
|
-
domain?: string;
|
|
815
|
-
};
|
|
816
|
-
metadata?: any;
|
|
817
|
-
offset?: number;
|
|
818
|
-
skipCache?: boolean;
|
|
819
|
-
}): Promise<SearchResult<T>[]>;
|
|
820
|
-
/**
|
|
821
|
-
* Find entities similar to a given entity ID
|
|
822
|
-
* @param id ID of the entity to find similar entities for
|
|
823
|
-
* @param options Additional options
|
|
824
|
-
* @returns Array of search results with similarity scores
|
|
825
|
-
*/
|
|
826
|
-
findSimilar(id: string, options?: {
|
|
827
|
-
limit?: number;
|
|
828
|
-
nounTypes?: string[];
|
|
829
|
-
includeVerbs?: boolean;
|
|
830
|
-
searchMode?: 'local' | 'remote' | 'combined';
|
|
831
|
-
relationType?: string;
|
|
832
|
-
}): Promise<SearchResult<T>[]>;
|
|
833
|
-
/**
|
|
834
|
-
* Get a vector by ID
|
|
835
|
-
*/
|
|
836
|
-
/**
|
|
837
|
-
* Check if a document with the given ID exists
|
|
838
|
-
* This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
|
|
839
|
-
* @param id The ID to check for existence
|
|
840
|
-
* @returns Promise<boolean> True if the document exists, false otherwise
|
|
841
|
-
*/
|
|
842
|
-
private has;
|
|
843
|
-
/**
|
|
844
|
-
* Check if a document with the given ID exists (alias for has)
|
|
845
|
-
* This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
|
|
846
|
-
* @param id The ID to check for existence
|
|
847
|
-
* @returns Promise<boolean> True if the document exists, false otherwise
|
|
848
|
-
*/
|
|
849
|
-
/**
|
|
850
|
-
* Check if a noun exists
|
|
851
|
-
* @param id The noun ID
|
|
852
|
-
* @returns True if exists
|
|
853
|
-
*/
|
|
854
|
-
hasNoun(id: string): Promise<boolean>;
|
|
855
|
-
/**
|
|
856
|
-
* Get metadata for a document by ID
|
|
857
|
-
* This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
|
|
858
|
-
* @param id The ID of the document
|
|
859
|
-
* @returns Promise<T | null> The metadata object or null if not found
|
|
860
|
-
*/
|
|
861
|
-
/**
|
|
862
|
-
* Get multiple documents by their IDs
|
|
863
|
-
* This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
|
|
864
|
-
* @param ids Array of IDs to retrieve
|
|
865
|
-
* @returns Promise<Array<VectorDocument<T> | null>> Array of documents (null for missing IDs)
|
|
866
|
-
*/
|
|
867
|
-
/**
|
|
868
|
-
* Get multiple nouns - by IDs, filters, or pagination
|
|
869
|
-
* @param idsOrOptions Array of IDs or query options
|
|
870
|
-
* @returns Array of noun documents
|
|
871
|
-
*
|
|
872
|
-
* @example
|
|
873
|
-
* // Get by IDs
|
|
874
|
-
* await brain.getNouns(['id1', 'id2'])
|
|
875
|
-
*
|
|
876
|
-
* // Get with filters
|
|
877
|
-
* await brain.getNouns({
|
|
878
|
-
* filter: { type: 'article' },
|
|
879
|
-
* limit: 10
|
|
880
|
-
* })
|
|
881
|
-
*
|
|
882
|
-
* // Get with pagination
|
|
883
|
-
* await brain.getNouns({
|
|
884
|
-
* offset: 20,
|
|
885
|
-
* limit: 10
|
|
886
|
-
* })
|
|
887
|
-
*/
|
|
888
|
-
getNouns(idsOrOptions?: string[] | {
|
|
889
|
-
ids?: string[];
|
|
890
|
-
filter?: {
|
|
891
|
-
nounType?: string | string[];
|
|
892
|
-
metadata?: Record<string, any>;
|
|
893
|
-
};
|
|
894
|
-
pagination?: {
|
|
895
|
-
offset?: number;
|
|
896
|
-
limit?: number;
|
|
897
|
-
cursor?: string;
|
|
898
|
-
};
|
|
899
|
-
offset?: number;
|
|
900
|
-
limit?: number;
|
|
901
|
-
}): Promise<Array<VectorDocument<T> | null>>;
|
|
902
|
-
/**
|
|
903
|
-
* Internal: Get nouns by IDs
|
|
904
|
-
*/
|
|
905
|
-
private getNounsByIds;
|
|
906
|
-
/**
|
|
907
|
-
* Get nouns with pagination and filtering
|
|
908
|
-
* @param options Pagination and filtering options
|
|
909
|
-
* @returns Paginated result of vector documents
|
|
910
|
-
*/
|
|
911
|
-
/**
|
|
912
|
-
* Internal: Query nouns with filtering and pagination
|
|
913
|
-
*/
|
|
914
|
-
private queryNounsByFilter;
|
|
915
|
-
/**
|
|
916
|
-
* Add a verb between two nouns
|
|
917
|
-
* If metadata is provided and vector is not, the metadata will be vectorized using the embedding function
|
|
918
|
-
*
|
|
919
|
-
* @param sourceId ID of the source noun
|
|
920
|
-
* @param targetId ID of the target noun
|
|
921
|
-
* @param vector Optional vector for the verb
|
|
922
|
-
* @param options Additional options:
|
|
923
|
-
* - type: Type of the verb
|
|
924
|
-
* - weight: Weight of the verb
|
|
925
|
-
* - metadata: Metadata for the verb
|
|
926
|
-
* - forceEmbed: Force using the embedding function for metadata even if vector is provided
|
|
927
|
-
* - id: Optional ID to use instead of generating a new one
|
|
928
|
-
* - autoCreateMissingNouns: Automatically create missing nouns if they don't exist
|
|
929
|
-
* - missingNounMetadata: Metadata to use when auto-creating missing nouns
|
|
930
|
-
* - writeOnlyMode: Skip noun existence checks for high-speed streaming (creates placeholder nouns)
|
|
931
|
-
*
|
|
932
|
-
* @returns The ID of the added verb
|
|
933
|
-
*
|
|
934
|
-
* @throws Error if source or target nouns don't exist and autoCreateMissingNouns is false or auto-creation fails
|
|
935
|
-
*/
|
|
936
|
-
private _addVerbInternal;
|
|
937
|
-
/**
|
|
938
|
-
* Get a verb by ID
|
|
939
|
-
* This is a direct storage operation that works in write-only mode when allowDirectReads is enabled
|
|
940
|
-
*/
|
|
941
|
-
getVerb(id: string): Promise<GraphVerb | null>;
|
|
942
|
-
/**
|
|
943
|
-
* Internal performance optimization: intelligently load verbs when beneficial
|
|
944
|
-
* @internal - Used by search, indexing, and caching optimizations
|
|
945
|
-
*/
|
|
946
|
-
private _optimizedLoadAllVerbs;
|
|
947
|
-
/**
|
|
948
|
-
* Internal performance optimization: intelligently load nouns when beneficial
|
|
949
|
-
* @internal - Used by search, indexing, and caching optimizations
|
|
950
|
-
*/
|
|
951
|
-
private _optimizedLoadAllNouns;
|
|
952
|
-
/**
|
|
953
|
-
* Intelligent decision making for when to preload all data
|
|
954
|
-
* @internal
|
|
955
|
-
*/
|
|
956
|
-
private _shouldPreloadAllData;
|
|
957
|
-
/**
|
|
958
|
-
* Estimate if dataset size is reasonable for in-memory loading
|
|
959
|
-
* @internal
|
|
960
|
-
*/
|
|
961
|
-
private _isDatasetSizeReasonable;
|
|
962
|
-
/**
|
|
963
|
-
* Get verbs with pagination and filtering
|
|
964
|
-
* @param options Pagination and filtering options
|
|
965
|
-
* @returns Paginated result of verbs
|
|
966
|
-
*/
|
|
967
|
-
getVerbs(options?: {
|
|
968
|
-
pagination?: {
|
|
969
|
-
offset?: number;
|
|
970
|
-
limit?: number;
|
|
971
|
-
cursor?: string;
|
|
972
|
-
};
|
|
973
|
-
filter?: {
|
|
974
|
-
verbType?: string | string[];
|
|
975
|
-
sourceId?: string | string[];
|
|
976
|
-
targetId?: string | string[];
|
|
977
|
-
service?: string | string[];
|
|
978
|
-
metadata?: Record<string, any>;
|
|
979
|
-
};
|
|
980
|
-
}): Promise<{
|
|
981
|
-
items: GraphVerb[];
|
|
982
|
-
totalCount?: number;
|
|
983
|
-
hasMore: boolean;
|
|
984
|
-
nextCursor?: string;
|
|
985
|
-
}>;
|
|
986
|
-
/**
|
|
987
|
-
* Get verbs by source noun ID
|
|
988
|
-
* @param sourceId The ID of the source noun
|
|
989
|
-
* @returns Array of verbs originating from the specified source
|
|
990
|
-
*/
|
|
991
|
-
getVerbsBySource(sourceId: string): Promise<GraphVerb[]>;
|
|
992
|
-
/**
|
|
993
|
-
* Get verbs by target noun ID
|
|
994
|
-
* @param targetId The ID of the target noun
|
|
995
|
-
* @returns Array of verbs targeting the specified noun
|
|
996
|
-
*/
|
|
997
|
-
getVerbsByTarget(targetId: string): Promise<GraphVerb[]>;
|
|
998
|
-
/**
|
|
999
|
-
* Get verbs by type
|
|
1000
|
-
* @param type The type of verb to retrieve
|
|
1001
|
-
* @returns Array of verbs of the specified type
|
|
1002
|
-
*/
|
|
1003
|
-
getVerbsByType(type: string): Promise<GraphVerb[]>;
|
|
1004
|
-
/**
|
|
1005
|
-
* Get all verbs associated with a specific noun (both as source and target)
|
|
1006
|
-
* @param nounId The ID of the noun
|
|
1007
|
-
* @returns Array of verbs where the noun is either source or target
|
|
1008
|
-
*/
|
|
1009
|
-
getVerbsForNoun(nounId: string): Promise<GraphVerb[]>;
|
|
1010
|
-
/**
|
|
1011
|
-
* Delete a verb
|
|
1012
|
-
* @param id The ID of the verb to delete
|
|
1013
|
-
* @param options Additional options
|
|
1014
|
-
* @returns Promise that resolves to true if the verb was deleted, false otherwise
|
|
1015
|
-
*/
|
|
1016
|
-
/**
|
|
1017
|
-
* Add multiple verbs (relationships) in batch
|
|
1018
|
-
* @param verbs Array of verbs to add
|
|
1019
|
-
* @returns Array of generated verb IDs
|
|
1020
|
-
*/
|
|
1021
|
-
addVerbs(verbs: Array<{
|
|
1022
|
-
source: string;
|
|
1023
|
-
target: string;
|
|
1024
|
-
type: string;
|
|
1025
|
-
metadata?: any;
|
|
1026
|
-
}>): Promise<string[]>;
|
|
1027
|
-
/**
|
|
1028
|
-
* Delete multiple verbs by IDs
|
|
1029
|
-
* @param ids Array of verb IDs
|
|
1030
|
-
* @returns Array of success booleans
|
|
1031
|
-
*/
|
|
1032
|
-
deleteVerbs(ids: string[]): Promise<boolean[]>;
|
|
1033
|
-
deleteVerb(id: string, options?: {
|
|
1034
|
-
service?: string;
|
|
1035
|
-
}): Promise<boolean>;
|
|
1036
|
-
/**
|
|
1037
|
-
* Restore a soft-deleted verb (complement to consistent soft delete)
|
|
1038
|
-
* @param id The verb ID to restore
|
|
1039
|
-
* @param options Options for the restore operation
|
|
1040
|
-
* @returns Promise<boolean> True if restored, false if not found or not deleted
|
|
1041
|
-
*/
|
|
1042
|
-
restoreVerb(id: string, options?: {
|
|
1043
|
-
service?: string;
|
|
1044
|
-
}): Promise<boolean>;
|
|
1045
|
-
/**
|
|
1046
|
-
* Get the number of vectors in the database
|
|
1047
|
-
*/
|
|
1048
|
-
size(): number;
|
|
1049
|
-
/**
|
|
1050
|
-
* Get search cache statistics for performance monitoring
|
|
1051
|
-
* @returns Cache statistics including hit rate and memory usage
|
|
1052
|
-
*/
|
|
1053
|
-
getCacheStats(): {
|
|
1054
|
-
search: any;
|
|
1055
|
-
searchMemoryUsage: any;
|
|
1056
|
-
};
|
|
1057
|
-
/**
|
|
1058
|
-
* Clear search cache manually (useful for testing or memory management)
|
|
1059
|
-
*/
|
|
1060
|
-
clearCache(): void;
|
|
1061
|
-
/**
|
|
1062
|
-
* Adapt cache configuration based on current performance metrics
|
|
1063
|
-
* This method analyzes usage patterns and automatically optimizes cache settings
|
|
1064
|
-
* @private
|
|
1065
|
-
*/
|
|
1066
|
-
private adaptCacheConfiguration;
|
|
1067
|
-
/**
|
|
1068
|
-
* @deprecated Use add() instead - it's smart by default now
|
|
1069
|
-
* @hidden
|
|
1070
|
-
*/
|
|
1071
|
-
/**
|
|
1072
|
-
* Get the number of nouns in the database (excluding verbs)
|
|
1073
|
-
* This is used for statistics reporting to match the expected behavior in tests
|
|
1074
|
-
* @private
|
|
1075
|
-
*/
|
|
1076
|
-
private getNounCount;
|
|
1077
|
-
/**
|
|
1078
|
-
* Force an immediate flush of statistics to storage
|
|
1079
|
-
* This ensures that any pending statistics updates are written to persistent storage
|
|
1080
|
-
* @returns Promise that resolves when the statistics have been flushed
|
|
1081
|
-
*/
|
|
1082
|
-
flushStatistics(): Promise<void>;
|
|
1083
|
-
/**
|
|
1084
|
-
* Update storage sizes if needed (called periodically for performance)
|
|
1085
|
-
*/
|
|
1086
|
-
private updateStorageSizesIfNeeded;
|
|
1087
|
-
/**
|
|
1088
|
-
* Get statistics about the current state of the database
|
|
1089
|
-
* @param options Additional options for retrieving statistics
|
|
1090
|
-
* @returns Object containing counts of nouns, verbs, metadata entries, and HNSW index size
|
|
1091
|
-
*/
|
|
1092
|
-
getStatistics(options?: {
|
|
1093
|
-
service?: string | string[];
|
|
1094
|
-
forceRefresh?: boolean;
|
|
1095
|
-
}): Promise<{
|
|
1096
|
-
nounCount: number;
|
|
1097
|
-
verbCount: number;
|
|
1098
|
-
metadataCount: number;
|
|
1099
|
-
hnswIndexSize: number;
|
|
1100
|
-
nouns?: {
|
|
1101
|
-
count: number;
|
|
1102
|
-
};
|
|
1103
|
-
verbs?: {
|
|
1104
|
-
count: number;
|
|
1105
|
-
};
|
|
1106
|
-
metadata?: {
|
|
1107
|
-
count: number;
|
|
1108
|
-
};
|
|
1109
|
-
operations?: {
|
|
1110
|
-
add: number;
|
|
1111
|
-
search: number;
|
|
1112
|
-
delete: number;
|
|
1113
|
-
update: number;
|
|
1114
|
-
relate: number;
|
|
1115
|
-
total: number;
|
|
1116
|
-
};
|
|
1117
|
-
serviceBreakdown?: {
|
|
1118
|
-
[service: string]: {
|
|
1119
|
-
nounCount: number;
|
|
1120
|
-
verbCount: number;
|
|
1121
|
-
metadataCount: number;
|
|
1122
|
-
};
|
|
1123
|
-
};
|
|
1124
|
-
}>;
|
|
1125
|
-
/**
|
|
1126
|
-
* List all services that have written data to the database
|
|
1127
|
-
* @returns Array of service statistics
|
|
1128
|
-
*/
|
|
1129
|
-
listServices(): Promise<import('./coreTypes.js').ServiceStatistics[]>;
|
|
1130
|
-
/**
|
|
1131
|
-
* Get statistics for a specific service
|
|
1132
|
-
* @param service The service name to get statistics for
|
|
1133
|
-
* @returns Service statistics or null if service not found
|
|
1134
|
-
*/
|
|
1135
|
-
getServiceStatistics(service: string): Promise<import('./coreTypes.js').ServiceStatistics | null>;
|
|
1136
|
-
/**
|
|
1137
|
-
* Check if the database is in read-only mode
|
|
1138
|
-
* @returns True if the database is in read-only mode, false otherwise
|
|
1139
|
-
*/
|
|
1140
|
-
isReadOnly(): boolean;
|
|
1141
|
-
/**
|
|
1142
|
-
* Set the database to read-only mode
|
|
1143
|
-
* @param readOnly True to set the database to read-only mode, false to allow writes
|
|
1144
|
-
*/
|
|
1145
|
-
setReadOnly(readOnly: boolean): void;
|
|
1146
|
-
/**
|
|
1147
|
-
* Check if the database is frozen (completely immutable)
|
|
1148
|
-
* @returns True if the database is frozen, false otherwise
|
|
1149
|
-
*/
|
|
1150
|
-
isFrozen(): boolean;
|
|
1151
|
-
/**
|
|
1152
|
-
* Set the database to frozen mode (completely immutable)
|
|
1153
|
-
* When frozen, no changes are allowed including statistics updates and index optimizations
|
|
1154
|
-
* @param frozen True to freeze the database, false to allow optimizations
|
|
1155
|
-
*/
|
|
1156
|
-
setFrozen(frozen: boolean): void;
|
|
1157
|
-
/**
|
|
1158
|
-
* Check if the database is in write-only mode
|
|
1159
|
-
* @returns True if the database is in write-only mode, false otherwise
|
|
1160
|
-
*/
|
|
1161
|
-
isWriteOnly(): boolean;
|
|
1162
|
-
/**
|
|
1163
|
-
* Set the database to write-only mode
|
|
1164
|
-
* @param writeOnly True to set the database to write-only mode, false to allow searches
|
|
1165
|
-
*/
|
|
1166
|
-
setWriteOnly(writeOnly: boolean): void;
|
|
1167
|
-
/**
|
|
1168
|
-
* Embed text or data into a vector using the same embedding function used by this instance
|
|
1169
|
-
* This allows clients to use the same TensorFlow Universal Sentence Encoder throughout their application
|
|
1170
|
-
*
|
|
1171
|
-
* @param data Text or data to embed
|
|
1172
|
-
* @returns A promise that resolves to the embedded vector
|
|
1173
|
-
*/
|
|
1174
|
-
embed(data: string | string[]): Promise<Vector>;
|
|
1175
|
-
/**
|
|
1176
|
-
* Calculate similarity between two vectors or between two pieces of text/data
|
|
1177
|
-
* This method allows clients to directly calculate similarity scores between items
|
|
1178
|
-
* without needing to add them to the database
|
|
1179
|
-
*
|
|
1180
|
-
* @param a First vector or text/data to compare
|
|
1181
|
-
* @param b Second vector or text/data to compare
|
|
1182
|
-
* @param options Additional options
|
|
1183
|
-
* @returns A promise that resolves to the similarity score (higher means more similar)
|
|
1184
|
-
*/
|
|
1185
|
-
calculateSimilarity(a: Vector | string | string[], b: Vector | string | string[], options?: {
|
|
1186
|
-
forceEmbed?: boolean;
|
|
1187
|
-
distanceFunction?: DistanceFunction;
|
|
1188
|
-
}): Promise<number>;
|
|
1189
|
-
/**
|
|
1190
|
-
* Search for verbs by type and/or vector similarity
|
|
1191
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
1192
|
-
* @param k Number of results to return
|
|
1193
|
-
* @param options Additional options
|
|
1194
|
-
* @returns Array of verbs with similarity scores
|
|
1195
|
-
*/
|
|
1196
|
-
searchVerbs(queryVectorOrData: Vector | any, k?: number, options?: {
|
|
1197
|
-
forceEmbed?: boolean;
|
|
1198
|
-
verbTypes?: string[];
|
|
1199
|
-
service?: string;
|
|
1200
|
-
}): Promise<Array<GraphVerb & {
|
|
1201
|
-
similarity: number;
|
|
1202
|
-
}>>;
|
|
1203
|
-
/**
|
|
1204
|
-
* Search for nouns connected by specific verb types
|
|
1205
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
1206
|
-
* @param k Number of results to return
|
|
1207
|
-
* @param options Additional options
|
|
1208
|
-
* @returns Array of search results
|
|
1209
|
-
*/
|
|
1210
|
-
searchNounsByVerbs(queryVectorOrData: Vector | any, k?: number, options?: {
|
|
1211
|
-
forceEmbed?: boolean;
|
|
1212
|
-
verbTypes?: string[];
|
|
1213
|
-
direction?: 'outgoing' | 'incoming' | 'both';
|
|
1214
|
-
}): Promise<SearchResult<T>[]>;
|
|
1215
|
-
/**
|
|
1216
|
-
* Get available filter values for a field
|
|
1217
|
-
* Useful for building dynamic filter UIs
|
|
1218
|
-
*
|
|
1219
|
-
* @param field The field name to get values for
|
|
1220
|
-
* @returns Array of available values for that field
|
|
1221
|
-
*/
|
|
1222
|
-
getFilterValues(field: string): Promise<string[]>;
|
|
1223
|
-
/**
|
|
1224
|
-
* Get all available filter fields
|
|
1225
|
-
* Useful for discovering what metadata fields are indexed
|
|
1226
|
-
*
|
|
1227
|
-
* @returns Array of indexed field names
|
|
1228
|
-
*/
|
|
1229
|
-
getFilterFields(): Promise<string[]>;
|
|
1230
|
-
/**
|
|
1231
|
-
* Search within a specific set of items
|
|
1232
|
-
* This is useful when you've pre-filtered items and want to search only within them
|
|
1233
|
-
*
|
|
1234
|
-
* @param queryVectorOrData Query vector or data to search for
|
|
1235
|
-
* @param itemIds Array of item IDs to search within
|
|
1236
|
-
* @param k Number of results to return
|
|
1237
|
-
* @param options Additional options
|
|
1238
|
-
* @returns Array of search results
|
|
1239
|
-
*/
|
|
1240
|
-
/**
|
|
1241
|
-
* @deprecated Use search() with itemIds option instead
|
|
1242
|
-
* @example
|
|
1243
|
-
* // Old way (deprecated)
|
|
1244
|
-
* await brain.searchWithinItems(query, itemIds, 10)
|
|
1245
|
-
* // New way
|
|
1246
|
-
* await brain.search(query, { limit: 10, itemIds })
|
|
1247
|
-
*/
|
|
1248
|
-
searchWithinItems(queryVectorOrData: Vector | any, itemIds: string[], k?: number, options?: {
|
|
1249
|
-
forceEmbed?: boolean;
|
|
1250
|
-
}): Promise<SearchResult<T>[]>;
|
|
1251
|
-
/**
|
|
1252
|
-
* Search for similar documents using a text query
|
|
1253
|
-
* This is a convenience method that embeds the query text and performs a search
|
|
1254
|
-
*
|
|
1255
|
-
* @param query Text query to search for
|
|
1256
|
-
* @param k Number of results to return
|
|
1257
|
-
* @param options Additional options
|
|
1258
|
-
* @returns Array of search results
|
|
1259
|
-
*/
|
|
1260
|
-
/**
|
|
1261
|
-
* @deprecated Use search() directly with text - it auto-detects strings
|
|
1262
|
-
* @example
|
|
1263
|
-
* // Old way (deprecated)
|
|
1264
|
-
* await brain.searchText('query text', 10)
|
|
1265
|
-
* // New way
|
|
1266
|
-
* await brain.search('query text', { limit: 10 })
|
|
1267
|
-
*/
|
|
1268
|
-
searchText(query: string, k?: number, options?: {
|
|
1269
|
-
nounTypes?: string[];
|
|
1270
|
-
includeVerbs?: boolean;
|
|
1271
|
-
searchMode?: 'local' | 'remote' | 'combined';
|
|
1272
|
-
metadata?: any;
|
|
1273
|
-
}): Promise<SearchResult<T>[]>;
|
|
1274
|
-
/**
|
|
1275
|
-
* Ensure the database is initialized
|
|
1276
|
-
*/
|
|
1277
|
-
private ensureInitialized;
|
|
1278
|
-
/**
|
|
1279
|
-
* Get information about the current storage usage and capacity
|
|
1280
|
-
* @returns Object containing the storage type, used space, quota, and additional details
|
|
1281
|
-
*/
|
|
1282
|
-
status(): Promise<{
|
|
1283
|
-
type: string;
|
|
1284
|
-
used: number;
|
|
1285
|
-
quota: number | null;
|
|
1286
|
-
details?: Record<string, any>;
|
|
1287
|
-
}>;
|
|
1288
|
-
/**
|
|
1289
|
-
* Shut down the database and clean up resources
|
|
1290
|
-
* This should be called when the database is no longer needed
|
|
1291
|
-
*/
|
|
1292
|
-
shutDown(): Promise<void>;
|
|
1293
|
-
/**
|
|
1294
|
-
* Backup all data from the database to a JSON-serializable format
|
|
1295
|
-
* @returns Object containing all nouns, verbs, noun types, verb types, HNSW index, and other related data
|
|
1296
|
-
*
|
|
1297
|
-
* The HNSW index data includes:
|
|
1298
|
-
* - entryPointId: The ID of the entry point for the graph
|
|
1299
|
-
* - maxLevel: The maximum level in the hierarchical structure
|
|
1300
|
-
* - dimension: The dimension of the vectors
|
|
1301
|
-
* - config: Configuration parameters for the HNSW algorithm
|
|
1302
|
-
* - connections: A serialized representation of the connections between nouns
|
|
1303
|
-
*/
|
|
1304
|
-
backup(): Promise<{
|
|
1305
|
-
nouns: VectorDocument<T>[];
|
|
1306
|
-
verbs: GraphVerb[];
|
|
1307
|
-
nounTypes: string[];
|
|
1308
|
-
verbTypes: string[];
|
|
1309
|
-
version: string;
|
|
1310
|
-
hnswIndex?: {
|
|
1311
|
-
entryPointId: string | null;
|
|
1312
|
-
maxLevel: number;
|
|
1313
|
-
dimension: number | null;
|
|
1314
|
-
config: HNSWConfig;
|
|
1315
|
-
connections: Record<string, Record<string, string[]>>;
|
|
1316
|
-
};
|
|
1317
|
-
}>;
|
|
1318
|
-
/**
|
|
1319
|
-
* Import sparse data into the database
|
|
1320
|
-
* @param data The sparse data to import
|
|
1321
|
-
* If vectors are not present for nouns, they will be created using the embedding function
|
|
1322
|
-
* @param options Import options
|
|
1323
|
-
* @returns Object containing counts of imported items
|
|
1324
|
-
*/
|
|
1325
|
-
importSparseData(data: {
|
|
1326
|
-
nouns: VectorDocument<T>[];
|
|
1327
|
-
verbs: GraphVerb[];
|
|
1328
|
-
nounTypes?: string[];
|
|
1329
|
-
verbTypes?: string[];
|
|
1330
|
-
hnswIndex?: {
|
|
1331
|
-
entryPointId: string | null;
|
|
1332
|
-
maxLevel: number;
|
|
1333
|
-
dimension: number | null;
|
|
1334
|
-
config: HNSWConfig;
|
|
1335
|
-
connections: Record<string, Record<string, string[]>>;
|
|
1336
|
-
};
|
|
1337
|
-
version: string;
|
|
1338
|
-
}, options?: {
|
|
1339
|
-
clearExisting?: boolean;
|
|
1340
|
-
}): Promise<{
|
|
1341
|
-
nounsRestored: number;
|
|
1342
|
-
verbsRestored: number;
|
|
1343
|
-
}>;
|
|
1344
|
-
/**
|
|
1345
|
-
* Restore data into the database from a previously backed up format
|
|
1346
|
-
* @param data The data to restore, in the format returned by backup()
|
|
1347
|
-
* This can include HNSW index data if it was included in the backup
|
|
1348
|
-
* If vectors are not present for nouns, they will be created using the embedding function
|
|
1349
|
-
* @param options Restore options
|
|
1350
|
-
* @returns Object containing counts of restored items
|
|
1351
|
-
*/
|
|
1352
|
-
restore(data: {
|
|
1353
|
-
nouns: VectorDocument<T>[];
|
|
1354
|
-
verbs: GraphVerb[];
|
|
1355
|
-
nounTypes?: string[];
|
|
1356
|
-
verbTypes?: string[];
|
|
1357
|
-
hnswIndex?: {
|
|
1358
|
-
entryPointId: string | null;
|
|
1359
|
-
maxLevel: number;
|
|
1360
|
-
dimension: number | null;
|
|
1361
|
-
config: HNSWConfig;
|
|
1362
|
-
connections: Record<string, Record<string, string[]>>;
|
|
1363
|
-
};
|
|
1364
|
-
version: string;
|
|
1365
|
-
}, options?: {
|
|
1366
|
-
clearExisting?: boolean;
|
|
1367
|
-
}): Promise<{
|
|
1368
|
-
nounsRestored: number;
|
|
1369
|
-
verbsRestored: number;
|
|
1370
|
-
}>;
|
|
1371
|
-
/**
|
|
1372
|
-
* Generate a random graph of data with typed nouns and verbs for testing and experimentation
|
|
1373
|
-
* @param options Configuration options for the random graph
|
|
1374
|
-
* @returns Object containing the IDs of the generated nouns and verbs
|
|
1375
|
-
*/
|
|
1376
|
-
generateRandomGraph(options?: {
|
|
1377
|
-
nounCount?: number;
|
|
1378
|
-
verbCount?: number;
|
|
1379
|
-
nounTypes?: NounType[];
|
|
1380
|
-
verbTypes?: VerbType[];
|
|
1381
|
-
clearExisting?: boolean;
|
|
1382
|
-
seed?: string;
|
|
1383
|
-
}): Promise<{
|
|
1384
|
-
nounIds: string[];
|
|
1385
|
-
verbIds: string[];
|
|
1386
|
-
}>;
|
|
1387
|
-
/**
|
|
1388
|
-
* Get available field names by service
|
|
1389
|
-
* This helps users understand what fields are available for searching from different data sources
|
|
1390
|
-
* @returns Record of field names by service
|
|
1391
|
-
*/
|
|
1392
|
-
getAvailableFieldNames(): Promise<Record<string, string[]>>;
|
|
1393
|
-
/**
|
|
1394
|
-
* Get standard field mappings
|
|
1395
|
-
* This helps users understand how fields from different services map to standard field names
|
|
1396
|
-
* @returns Record of standard field mappings
|
|
1397
|
-
*/
|
|
1398
|
-
getStandardFieldMappings(): Promise<Record<string, Record<string, string[]>>>;
|
|
1399
|
-
/**
|
|
1400
|
-
* Search using a standard field name
|
|
1401
|
-
* This allows searching across multiple services using a standardized field name
|
|
1402
|
-
* @param standardField The standard field name to search in
|
|
1403
|
-
* @param searchTerm The term to search for
|
|
1404
|
-
* @param k Number of results to return
|
|
1405
|
-
* @param options Additional search options
|
|
1406
|
-
* @returns Array of search results
|
|
1407
|
-
*/
|
|
1408
|
-
searchByStandardField(standardField: string, searchTerm: string, k?: number, options?: {
|
|
1409
|
-
services?: string[];
|
|
1410
|
-
includeVerbs?: boolean;
|
|
1411
|
-
searchMode?: 'local' | 'remote' | 'combined';
|
|
1412
|
-
}): Promise<SearchResult<T>[]>;
|
|
1413
|
-
/**
|
|
1414
|
-
* Cleanup distributed resources
|
|
1415
|
-
* Should be called when shutting down the instance
|
|
1416
|
-
*/
|
|
1417
|
-
cleanup(): Promise<void>;
|
|
1418
|
-
/**
|
|
1419
|
-
* Load environment variables from Cortex configuration
|
|
1420
|
-
* This enables services to automatically load all their configs from Brainy
|
|
1421
|
-
* @returns Promise that resolves when environment is loaded
|
|
1422
|
-
*/
|
|
1423
|
-
loadEnvironment(): Promise<void>;
|
|
1424
|
-
/**
|
|
1425
|
-
* Set a configuration value with optional encryption
|
|
1426
|
-
* @param key Configuration key
|
|
1427
|
-
* @param value Configuration value
|
|
1428
|
-
* @param options Options including encryption
|
|
1429
|
-
*/
|
|
1430
|
-
setConfig(key: string, value: any, options?: {
|
|
1431
|
-
encrypt?: boolean;
|
|
1432
|
-
}): Promise<void>;
|
|
1433
|
-
/**
|
|
1434
|
-
* Get a configuration value with automatic decryption
|
|
1435
|
-
* @param key Configuration key
|
|
1436
|
-
* @param options Options including decryption (auto-detected by default)
|
|
1437
|
-
* @returns Configuration value or undefined
|
|
1438
|
-
*/
|
|
1439
|
-
getConfig(key: string, options?: {
|
|
1440
|
-
decrypt?: boolean;
|
|
1441
|
-
}): Promise<any>;
|
|
1442
|
-
/**
|
|
1443
|
-
* Encrypt data using universal crypto utilities
|
|
1444
|
-
*/
|
|
1445
|
-
encryptData(data: string): Promise<string>;
|
|
1446
|
-
/**
|
|
1447
|
-
* Decrypt data using universal crypto utilities
|
|
1448
|
-
*/
|
|
1449
|
-
decryptData(encryptedData: string): Promise<string>;
|
|
1450
|
-
/**
|
|
1451
|
-
* Neural Import - Smart bulk data import with semantic type detection
|
|
1452
|
-
* Uses transformer embeddings to automatically detect and classify data types
|
|
1453
|
-
* @param data Array of data items or single item to import
|
|
1454
|
-
* @param options Import options including type hints and processing mode
|
|
1455
|
-
* @returns Array of created IDs
|
|
1456
|
-
*/
|
|
1457
|
-
import(source: any[] | any | string | Buffer, options?: {
|
|
1458
|
-
format?: 'auto' | 'json' | 'csv' | 'yaml' | 'text';
|
|
1459
|
-
batchSize?: number;
|
|
1460
|
-
relationships?: boolean;
|
|
1461
|
-
}): Promise<string[]>;
|
|
1462
|
-
/**
|
|
1463
|
-
* Add Noun - Explicit noun creation with strongly-typed NounType
|
|
1464
|
-
* For when you know exactly what type of noun you're creating
|
|
1465
|
-
* @param data The noun data
|
|
1466
|
-
* @param nounType The explicit noun type from NounType enum
|
|
1467
|
-
* @param metadata Additional metadata
|
|
1468
|
-
* @returns Created noun ID
|
|
1469
|
-
*/
|
|
1470
|
-
/**
|
|
1471
|
-
* @deprecated Use add() instead - it's smart by default now
|
|
1472
|
-
* Add a noun to the database with required type
|
|
1473
|
-
* Clean 2.0 API - primary method for adding data
|
|
1474
|
-
*
|
|
1475
|
-
* @param vectorOrData Vector array or data to embed
|
|
1476
|
-
* @param nounType Required noun type (one of 31 types)
|
|
1477
|
-
* @param metadata Optional metadata object
|
|
1478
|
-
* @returns The generated ID
|
|
1479
|
-
*/
|
|
1480
|
-
addNoun(vectorOrData: Vector | any, nounType: NounType | string, metadata?: T, options?: {
|
|
1481
|
-
forceEmbed?: boolean;
|
|
1482
|
-
addToRemote?: boolean;
|
|
1483
|
-
id?: string;
|
|
1484
|
-
service?: string;
|
|
1485
|
-
process?: 'auto' | 'literal' | 'neural';
|
|
1486
|
-
}): Promise<string>;
|
|
1487
|
-
/**
|
|
1488
|
-
* @deprecated Use relate() instead
|
|
1489
|
-
* Add Verb - Unified relationship creation between nouns
|
|
1490
|
-
* Creates typed relationships with proper vector embeddings from metadata
|
|
1491
|
-
* @param sourceId Source noun ID
|
|
1492
|
-
* @param targetId Target noun ID
|
|
1493
|
-
* @param verbType Relationship type from VerbType enum
|
|
1494
|
-
* @param metadata Additional metadata for the relationship (will be embedded for searchability)
|
|
1495
|
-
* @param weight Relationship weight/strength (0-1, default: 0.5)
|
|
1496
|
-
* @returns Created verb ID
|
|
1497
|
-
*/
|
|
1498
|
-
addVerb(sourceId: string, targetId: string, verbType: VerbType, metadata?: any, weight?: number): Promise<string>;
|
|
1499
|
-
/**
|
|
1500
|
-
* Auto-detect whether to use neural processing for data
|
|
1501
|
-
* @private
|
|
1502
|
-
*/
|
|
1503
|
-
private shouldAutoProcessNeurally;
|
|
1504
|
-
/**
|
|
1505
|
-
* Detect noun type using semantic analysis
|
|
1506
|
-
* @private
|
|
1507
|
-
*/
|
|
1508
|
-
private detectNounType;
|
|
1509
|
-
/**
|
|
1510
|
-
* Get Noun with Connected Verbs - Retrieve noun and all its relationships
|
|
1511
|
-
* Provides complete traversal view of a noun and its connections using existing searchVerbs
|
|
1512
|
-
* @param nounId The noun ID to retrieve
|
|
1513
|
-
* @param options Traversal options
|
|
1514
|
-
* @returns Noun data with connected verbs and related nouns
|
|
1515
|
-
*/
|
|
1516
|
-
getNounWithVerbs(nounId: string, options?: {
|
|
1517
|
-
includeIncoming?: boolean;
|
|
1518
|
-
includeOutgoing?: boolean;
|
|
1519
|
-
verbLimit?: number;
|
|
1520
|
-
verbTypes?: string[];
|
|
1521
|
-
}): Promise<{
|
|
1522
|
-
noun: {
|
|
1523
|
-
id: string;
|
|
1524
|
-
data: any;
|
|
1525
|
-
metadata: any;
|
|
1526
|
-
nounType?: NounType;
|
|
1527
|
-
};
|
|
1528
|
-
incomingVerbs: any[];
|
|
1529
|
-
outgoingVerbs: any[];
|
|
1530
|
-
totalConnections: number;
|
|
1531
|
-
} | null>;
|
|
1532
|
-
/**
|
|
1533
|
-
* Update - Smart noun update with automatic index synchronization
|
|
1534
|
-
* Updates both data and metadata while maintaining search index integrity
|
|
1535
|
-
* @param id The noun ID to update
|
|
1536
|
-
* @param data New data (optional - if not provided, only metadata is updated)
|
|
1537
|
-
* @param metadata New metadata (merged with existing)
|
|
1538
|
-
* @param options Update options
|
|
1539
|
-
* @returns Success boolean
|
|
1540
|
-
*/
|
|
1541
|
-
/**
|
|
1542
|
-
* Preload Transformer Model - Essential for container deployments
|
|
1543
|
-
* Downloads and caches models during initialization to avoid runtime delays
|
|
1544
|
-
* @param options Preload options
|
|
1545
|
-
* @returns Success boolean and model info
|
|
1546
|
-
*/
|
|
1547
|
-
static preloadModel(options?: {
|
|
1548
|
-
model?: string;
|
|
1549
|
-
cacheDir?: string;
|
|
1550
|
-
device?: string;
|
|
1551
|
-
force?: boolean;
|
|
1552
|
-
}): Promise<{
|
|
1553
|
-
success: boolean;
|
|
1554
|
-
modelPath: string;
|
|
1555
|
-
modelSize: number;
|
|
1556
|
-
device: string;
|
|
1557
|
-
}>;
|
|
1558
|
-
/**
|
|
1559
|
-
* Warmup - Initialize BrainyData with preloaded models (container-optimized)
|
|
1560
|
-
* For production deployments where models should be ready immediately
|
|
1561
|
-
* @param config BrainyData configuration
|
|
1562
|
-
* @param options Warmup options
|
|
1563
|
-
*/
|
|
1564
|
-
static warmup(config?: BrainyDataConfig, options?: {
|
|
1565
|
-
preloadModel?: boolean;
|
|
1566
|
-
modelOptions?: Parameters<typeof BrainyData.preloadModel>[0];
|
|
1567
|
-
testEmbedding?: boolean;
|
|
1568
|
-
}): Promise<BrainyData>;
|
|
1569
|
-
/**
|
|
1570
|
-
* Get model size for deployment info
|
|
1571
|
-
* @private
|
|
1572
|
-
*/
|
|
1573
|
-
private static getModelSize;
|
|
1574
|
-
/**
|
|
1575
|
-
* Coordinate storage migration across distributed services
|
|
1576
|
-
* @param options Migration options
|
|
1577
|
-
*/
|
|
1578
|
-
coordinateStorageMigration(options: {
|
|
1579
|
-
newStorage: any;
|
|
1580
|
-
strategy?: 'immediate' | 'gradual' | 'test';
|
|
1581
|
-
message?: string;
|
|
1582
|
-
}): Promise<void>;
|
|
1583
|
-
/**
|
|
1584
|
-
* Check for coordination updates
|
|
1585
|
-
* Services should call this periodically or on startup
|
|
1586
|
-
*/
|
|
1587
|
-
checkCoordination(): Promise<any>;
|
|
1588
|
-
/**
|
|
1589
|
-
* Rebuild metadata index
|
|
1590
|
-
* Exposed for Cortex reindex command
|
|
1591
|
-
*/
|
|
1592
|
-
rebuildMetadataIndex(): Promise<void>;
|
|
1593
|
-
/**
|
|
1594
|
-
* Get a noun by ID
|
|
1595
|
-
* @param id The noun ID
|
|
1596
|
-
* @returns The noun document or null
|
|
1597
|
-
*/
|
|
1598
|
-
getNoun(id: string): Promise<VectorDocument<T> | null>;
|
|
1599
|
-
/**
|
|
1600
|
-
* Delete a noun by ID
|
|
1601
|
-
* @param id The noun ID
|
|
1602
|
-
* @returns Success boolean
|
|
1603
|
-
*/
|
|
1604
|
-
deleteNoun(id: string): Promise<boolean>;
|
|
1605
|
-
/**
|
|
1606
|
-
* Restore a soft-deleted noun (complement to consistent soft delete)
|
|
1607
|
-
* @param id The noun ID to restore
|
|
1608
|
-
* @returns Promise<boolean> True if restored, false if not found or not deleted
|
|
1609
|
-
*/
|
|
1610
|
-
restoreNoun(id: string): Promise<boolean>;
|
|
1611
|
-
/**
|
|
1612
|
-
* Delete multiple nouns by IDs
|
|
1613
|
-
* @param ids Array of noun IDs
|
|
1614
|
-
* @returns Array of success booleans
|
|
1615
|
-
*/
|
|
1616
|
-
deleteNouns(ids: string[]): Promise<boolean[]>;
|
|
1617
|
-
/**
|
|
1618
|
-
* Update a noun
|
|
1619
|
-
* @param id The noun ID
|
|
1620
|
-
* @param data Optional new vector/data
|
|
1621
|
-
* @param metadata Optional new metadata
|
|
1622
|
-
* @returns The updated noun
|
|
1623
|
-
*/
|
|
1624
|
-
updateNoun(id: string, data?: any, metadata?: T): Promise<VectorDocument<T>>;
|
|
1625
|
-
/**
|
|
1626
|
-
* Update only the metadata of a noun
|
|
1627
|
-
* @param id The noun ID
|
|
1628
|
-
* @param metadata New metadata
|
|
1629
|
-
*/
|
|
1630
|
-
updateNounMetadata(id: string, metadata: T): Promise<void>;
|
|
1631
|
-
/**
|
|
1632
|
-
* Get metadata for a noun
|
|
1633
|
-
* @param id The noun ID
|
|
1634
|
-
* @returns Metadata or null
|
|
1635
|
-
*/
|
|
1636
|
-
getNounMetadata(id: string): Promise<T | null>;
|
|
1637
|
-
/**
|
|
1638
|
-
* Neural API - Unified Semantic Intelligence
|
|
1639
|
-
* Best-of-both: Complete functionality + Enterprise performance
|
|
1640
|
-
*
|
|
1641
|
-
* User-friendly methods:
|
|
1642
|
-
* - brain.neural.similar() - Smart similarity detection
|
|
1643
|
-
* - brain.neural.hierarchy() - Semantic hierarchy building
|
|
1644
|
-
* - brain.neural.neighbors() - Neighbor graph generation
|
|
1645
|
-
* - brain.neural.clusters() - Auto-detects best clustering algorithm
|
|
1646
|
-
* - brain.neural.visualize() - Rich visualization data
|
|
1647
|
-
* - brain.neural.outliers() - Outlier detection
|
|
1648
|
-
* - brain.neural.semanticPath() - Path finding
|
|
1649
|
-
*
|
|
1650
|
-
* Enterprise performance methods:
|
|
1651
|
-
* - brain.neural.clusterFast() - O(n) HNSW-based clustering
|
|
1652
|
-
* - brain.neural.clusterLarge() - Million-item clustering
|
|
1653
|
-
* - brain.neural.clusterStream() - Progressive streaming
|
|
1654
|
-
* - brain.neural.getLOD() - Level-of-detail for scale
|
|
1655
|
-
*/
|
|
1656
|
-
get neural(): ImprovedNeuralAPI;
|
|
1657
|
-
/**
|
|
1658
|
-
* Simple similarity check (shorthand for neural.similar)
|
|
1659
|
-
*/
|
|
1660
|
-
similar(a: any, b: any, options?: any): Promise<number>;
|
|
1661
|
-
/**
|
|
1662
|
-
* Get semantic clusters (shorthand for neural.clusters)
|
|
1663
|
-
*/
|
|
1664
|
-
clusters(items?: any, options?: any): Promise<any[]>;
|
|
1665
|
-
/**
|
|
1666
|
-
* Get related items (shorthand for neural.neighbors)
|
|
1667
|
-
*/
|
|
1668
|
-
related(id: string, options?: any): Promise<any[]>;
|
|
1669
|
-
/**
|
|
1670
|
-
* 🚀 TRIPLE INTELLIGENCE SEARCH - Natural Language & Complex Queries
|
|
1671
|
-
* The revolutionary search that combines vector, graph, and metadata intelligence!
|
|
1672
|
-
*
|
|
1673
|
-
* @param query - Natural language string or structured TripleQuery
|
|
1674
|
-
* @param options - Pagination and performance options
|
|
1675
|
-
* @returns Unified search results with fusion scoring
|
|
1676
|
-
*
|
|
1677
|
-
* @example
|
|
1678
|
-
* // Natural language query
|
|
1679
|
-
* await brain.find('frameworks from recent years with high popularity')
|
|
1680
|
-
*
|
|
1681
|
-
* // Structured query with pagination
|
|
1682
|
-
* await brain.find({
|
|
1683
|
-
* like: 'machine learning',
|
|
1684
|
-
* where: { year: { greaterThan: 2020 } },
|
|
1685
|
-
* connected: { from: 'authorId123' }
|
|
1686
|
-
* }, {
|
|
1687
|
-
* limit: 50,
|
|
1688
|
-
* cursor: lastCursor
|
|
1689
|
-
* })
|
|
1690
|
-
*/
|
|
1691
|
-
find(query: TripleQuery | string, options?: {
|
|
1692
|
-
limit?: number;
|
|
1693
|
-
offset?: number;
|
|
1694
|
-
cursor?: string;
|
|
1695
|
-
mode?: 'auto' | 'vector' | 'graph' | 'metadata' | 'fusion';
|
|
1696
|
-
maxDepth?: number;
|
|
1697
|
-
parallel?: boolean;
|
|
1698
|
-
timeout?: number;
|
|
1699
|
-
excludeDeleted?: boolean;
|
|
1700
|
-
}): Promise<TripleResult[]>;
|
|
1701
|
-
/**
|
|
1702
|
-
* 🧠 NATURAL LANGUAGE PROCESSING - Auto-breakdown using all Brainy features
|
|
1703
|
-
* Uses embedding model, neural tools, entity registry, and taxonomy matching
|
|
1704
|
-
*/
|
|
1705
|
-
private processNaturalLanguage;
|
|
1706
|
-
/**
|
|
1707
|
-
* LEGACY: Augment method temporarily disabled during new augmentation system implementation
|
|
1708
|
-
*/
|
|
1709
|
-
/**
|
|
1710
|
-
* UNIFIED API METHOD #9: Export - Extract your data in various formats
|
|
1711
|
-
* Export your brain's knowledge for backup, migration, or integration
|
|
1712
|
-
*
|
|
1713
|
-
* @param options Export configuration
|
|
1714
|
-
* @returns The exported data in the specified format
|
|
1715
|
-
*/
|
|
1716
|
-
export(options?: {
|
|
1717
|
-
format?: 'json' | 'csv' | 'graph' | 'embeddings';
|
|
1718
|
-
includeVectors?: boolean;
|
|
1719
|
-
includeMetadata?: boolean;
|
|
1720
|
-
includeRelationships?: boolean;
|
|
1721
|
-
filter?: any;
|
|
1722
|
-
limit?: number;
|
|
1723
|
-
}): Promise<any>;
|
|
1724
|
-
/**
|
|
1725
|
-
* Helper: Convert data to CSV format
|
|
1726
|
-
* @private
|
|
1727
|
-
*/
|
|
1728
|
-
private convertToCSV;
|
|
1729
|
-
/**
|
|
1730
|
-
* Helper: Convert data to graph format
|
|
1731
|
-
* @private
|
|
1732
|
-
*/
|
|
1733
|
-
private convertToGraphFormat;
|
|
1734
|
-
/**
|
|
1735
|
-
* Unregister an augmentation by name
|
|
1736
|
-
* Remove augmentations from the pipeline
|
|
1737
|
-
*
|
|
1738
|
-
* @param name The name of the augmentation to unregister
|
|
1739
|
-
* @returns The BrainyData instance for chaining
|
|
1740
|
-
*/
|
|
1741
|
-
unregister(name: string): this;
|
|
1742
|
-
/**
|
|
1743
|
-
* Enable an augmentation by name
|
|
1744
|
-
* Universal control for built-in, community, and premium augmentations
|
|
1745
|
-
*
|
|
1746
|
-
* @param name The name of the augmentation to enable
|
|
1747
|
-
* @returns True if augmentation was found and enabled
|
|
1748
|
-
*/
|
|
1749
|
-
enableAugmentation(name: string): boolean;
|
|
1750
|
-
/**
|
|
1751
|
-
* Disable an augmentation by name
|
|
1752
|
-
* Universal control for built-in, community, and premium augmentations
|
|
1753
|
-
*
|
|
1754
|
-
* @param name The name of the augmentation to disable
|
|
1755
|
-
* @returns True if augmentation was found and disabled
|
|
1756
|
-
*/
|
|
1757
|
-
disableAugmentation(name: string): boolean;
|
|
1758
|
-
/**
|
|
1759
|
-
* Check if an augmentation is enabled
|
|
1760
|
-
*
|
|
1761
|
-
* @param name The name of the augmentation to check
|
|
1762
|
-
* @returns True if augmentation is found and enabled, false otherwise
|
|
1763
|
-
*/
|
|
1764
|
-
isAugmentationEnabled(name: string): boolean;
|
|
1765
|
-
/**
|
|
1766
|
-
* Get all augmentations with their enabled status
|
|
1767
|
-
* Shows built-in, community, and premium augmentations
|
|
1768
|
-
*
|
|
1769
|
-
* @returns Array of augmentations with name, type, and enabled status
|
|
1770
|
-
*/
|
|
1771
|
-
listAugmentations(): Array<{
|
|
1772
|
-
name: string;
|
|
1773
|
-
type: string;
|
|
1774
|
-
enabled: boolean;
|
|
1775
|
-
description: string;
|
|
1776
|
-
}>;
|
|
1777
|
-
/**
|
|
1778
|
-
* Enable all augmentations of a specific type
|
|
1779
|
-
*
|
|
1780
|
-
* @param type The type of augmentations to enable (sense, conduit, cognition, etc.)
|
|
1781
|
-
* @returns Number of augmentations enabled
|
|
1782
|
-
*/
|
|
1783
|
-
enableAugmentationType(type: 'sense' | 'conduit' | 'cognition' | 'memory' | 'perception' | 'dialog' | 'activation' | 'webSocket'): number;
|
|
1784
|
-
/**
|
|
1785
|
-
* Disable all augmentations of a specific type
|
|
1786
|
-
*
|
|
1787
|
-
* @param type The type of augmentations to disable (sense, conduit, cognition, etc.)
|
|
1788
|
-
* @returns Number of augmentations disabled
|
|
1789
|
-
*/
|
|
1790
|
-
disableAugmentationType(type: 'sense' | 'conduit' | 'cognition' | 'memory' | 'perception' | 'dialog' | 'activation' | 'webSocket'): number;
|
|
1791
|
-
/**
|
|
1792
|
-
* Clear only nouns from the database
|
|
1793
|
-
* @param options Clear options requiring force confirmation
|
|
1794
|
-
*/
|
|
1795
|
-
/**
|
|
1796
|
-
* Clear all nouns from the database
|
|
1797
|
-
* @param options Options including force flag to skip confirmation
|
|
1798
|
-
*/
|
|
1799
|
-
clearNouns(options?: {
|
|
1800
|
-
force?: boolean;
|
|
1801
|
-
}): Promise<void>;
|
|
1802
|
-
/**
|
|
1803
|
-
* Clear only verbs from the database
|
|
1804
|
-
* @param options Clear options requiring force confirmation
|
|
1805
|
-
*/
|
|
1806
|
-
/**
|
|
1807
|
-
* Clear all verbs from the database
|
|
1808
|
-
* @param options Options including force flag to skip confirmation
|
|
1809
|
-
*/
|
|
1810
|
-
clearVerbs(options?: {
|
|
1811
|
-
force?: boolean;
|
|
1812
|
-
}): Promise<void>;
|
|
1813
|
-
/**
|
|
1814
|
-
* Clear all data from the database (nouns and verbs)
|
|
1815
|
-
* @param options Clear options requiring force confirmation
|
|
1816
|
-
*/
|
|
1817
|
-
/**
|
|
1818
|
-
* Clear all data from the database
|
|
1819
|
-
* @param options Options including force flag to skip confirmation
|
|
1820
|
-
*/
|
|
1821
|
-
clear(options?: {
|
|
1822
|
-
force?: boolean;
|
|
1823
|
-
}): Promise<void>;
|
|
1824
|
-
/**
|
|
1825
|
-
* Clear all data from the database (alias for clear)
|
|
1826
|
-
* @param options Options including force flag to skip confirmation
|
|
1827
|
-
*/
|
|
1828
|
-
clearAll(options?: {
|
|
1829
|
-
force?: boolean;
|
|
1830
|
-
}): Promise<void>;
|
|
1831
|
-
}
|
|
1832
|
-
export { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistance } from './utils/index.js';
|