@soulcraft/brainy 1.5.0 → 2.0.1
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 +188 -0
- package/LICENSE +2 -2
- package/README.md +200 -595
- package/bin/brainy-interactive.js +564 -0
- package/bin/brainy-ts.js +18 -0
- package/bin/brainy.js +672 -81
- package/dist/augmentationPipeline.d.ts +48 -220
- package/dist/augmentationPipeline.js +60 -508
- package/dist/augmentationRegistry.d.ts +22 -31
- package/dist/augmentationRegistry.js +28 -79
- package/dist/augmentations/apiServerAugmentation.d.ts +108 -0
- package/dist/augmentations/apiServerAugmentation.js +502 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +95 -0
- package/dist/augmentations/batchProcessingAugmentation.js +567 -0
- package/dist/augmentations/brainyAugmentation.d.ts +153 -0
- package/dist/augmentations/brainyAugmentation.js +145 -0
- package/dist/augmentations/cacheAugmentation.d.ts +105 -0
- package/dist/augmentations/cacheAugmentation.js +238 -0
- package/dist/augmentations/conduitAugmentations.d.ts +54 -156
- package/dist/augmentations/conduitAugmentations.js +156 -1082
- package/dist/augmentations/connectionPoolAugmentation.d.ts +62 -0
- package/dist/augmentations/connectionPoolAugmentation.js +316 -0
- package/dist/augmentations/defaultAugmentations.d.ts +53 -0
- package/dist/augmentations/defaultAugmentations.js +88 -0
- package/dist/augmentations/entityRegistryAugmentation.d.ts +126 -0
- package/dist/augmentations/entityRegistryAugmentation.js +386 -0
- package/dist/augmentations/indexAugmentation.d.ts +117 -0
- package/dist/augmentations/indexAugmentation.js +284 -0
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +152 -0
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +554 -0
- package/dist/augmentations/metricsAugmentation.d.ts +202 -0
- package/dist/augmentations/metricsAugmentation.js +291 -0
- package/dist/augmentations/monitoringAugmentation.d.ts +94 -0
- package/dist/augmentations/monitoringAugmentation.js +227 -0
- package/dist/augmentations/neuralImport.d.ts +50 -117
- package/dist/augmentations/neuralImport.js +255 -629
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +52 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.js +162 -0
- package/dist/augmentations/serverSearchAugmentations.d.ts +43 -22
- package/dist/augmentations/serverSearchAugmentations.js +125 -72
- package/dist/augmentations/storageAugmentation.d.ts +54 -0
- package/dist/augmentations/storageAugmentation.js +93 -0
- package/dist/augmentations/storageAugmentations.d.ts +96 -0
- package/dist/augmentations/storageAugmentations.js +182 -0
- package/dist/augmentations/synapseAugmentation.d.ts +156 -0
- package/dist/augmentations/synapseAugmentation.js +312 -0
- package/dist/augmentations/walAugmentation.d.ts +108 -0
- package/dist/augmentations/walAugmentation.js +515 -0
- package/dist/brainyData.d.ts +404 -130
- package/dist/brainyData.js +1331 -853
- package/dist/chat/BrainyChat.d.ts +16 -8
- package/dist/chat/BrainyChat.js +60 -32
- package/dist/chat/ChatCLI.d.ts +1 -1
- package/dist/chat/ChatCLI.js +6 -6
- package/dist/cli/catalog.d.ts +3 -3
- package/dist/cli/catalog.js +116 -70
- package/dist/cli/commands/core.d.ts +61 -0
- package/dist/cli/commands/core.js +348 -0
- package/dist/cli/commands/neural.d.ts +25 -0
- package/dist/cli/commands/neural.js +508 -0
- package/dist/cli/commands/utility.d.ts +37 -0
- package/dist/cli/commands/utility.js +276 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +167 -0
- package/dist/cli/interactive.d.ts +164 -0
- package/dist/cli/interactive.js +542 -0
- package/dist/cortex/neuralImport.js +5 -5
- package/dist/critical/model-guardian.js +11 -4
- package/dist/embeddings/lightweight-embedder.d.ts +23 -0
- package/dist/embeddings/lightweight-embedder.js +136 -0
- package/dist/embeddings/universal-memory-manager.d.ts +38 -0
- package/dist/embeddings/universal-memory-manager.js +206 -0
- package/dist/embeddings/worker-embedding.d.ts +7 -0
- package/dist/embeddings/worker-embedding.js +77 -0
- package/dist/embeddings/worker-manager.d.ts +28 -0
- package/dist/embeddings/worker-manager.js +162 -0
- package/dist/examples/basicUsage.js +7 -7
- package/dist/graph/pathfinding.d.ts +78 -0
- package/dist/graph/pathfinding.js +393 -0
- package/dist/hnsw/hnswIndex.d.ts +13 -0
- package/dist/hnsw/hnswIndex.js +35 -0
- package/dist/hnsw/hnswIndexOptimized.d.ts +1 -0
- package/dist/hnsw/hnswIndexOptimized.js +3 -0
- package/dist/index.d.ts +9 -11
- package/dist/index.js +21 -11
- package/dist/indices/fieldIndex.d.ts +76 -0
- package/dist/indices/fieldIndex.js +357 -0
- package/dist/mcp/brainyMCPAdapter.js +3 -2
- package/dist/mcp/mcpAugmentationToolset.js +11 -17
- package/dist/neural/embeddedPatterns.d.ts +41 -0
- package/dist/neural/embeddedPatterns.js +4044 -0
- package/dist/neural/naturalLanguageProcessor.d.ts +94 -0
- package/dist/neural/naturalLanguageProcessor.js +317 -0
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +64 -0
- package/dist/neural/naturalLanguageProcessorStatic.js +151 -0
- package/dist/neural/neuralAPI.d.ts +255 -0
- package/dist/neural/neuralAPI.js +612 -0
- package/dist/neural/patternLibrary.d.ts +101 -0
- package/dist/neural/patternLibrary.js +313 -0
- package/dist/neural/patterns.d.ts +27 -0
- package/dist/neural/patterns.js +68 -0
- package/dist/neural/staticPatternMatcher.d.ts +35 -0
- package/dist/neural/staticPatternMatcher.js +153 -0
- package/dist/scripts/precomputePatternEmbeddings.d.ts +19 -0
- package/dist/scripts/precomputePatternEmbeddings.js +100 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +5 -0
- package/dist/storage/adapters/fileSystemStorage.js +20 -0
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +5 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +16 -0
- package/dist/storage/enhancedClearOperations.d.ts +83 -0
- package/dist/storage/enhancedClearOperations.js +345 -0
- package/dist/storage/storageFactory.js +31 -27
- package/dist/triple/TripleIntelligence.d.ts +134 -0
- package/dist/triple/TripleIntelligence.js +548 -0
- package/dist/types/augmentations.d.ts +45 -344
- package/dist/types/augmentations.js +5 -2
- package/dist/types/brainyDataInterface.d.ts +20 -10
- package/dist/types/graphTypes.d.ts +46 -0
- package/dist/types/graphTypes.js +16 -2
- package/dist/utils/BoundedRegistry.d.ts +29 -0
- package/dist/utils/BoundedRegistry.js +54 -0
- package/dist/utils/embedding.js +20 -3
- package/dist/utils/hybridModelManager.js +10 -5
- package/dist/utils/metadataFilter.d.ts +33 -19
- package/dist/utils/metadataFilter.js +58 -23
- package/dist/utils/metadataIndex.d.ts +37 -6
- package/dist/utils/metadataIndex.js +427 -64
- package/dist/utils/requestDeduplicator.d.ts +10 -0
- package/dist/utils/requestDeduplicator.js +24 -0
- package/dist/utils/unifiedCache.d.ts +103 -0
- package/dist/utils/unifiedCache.js +311 -0
- package/package.json +40 -125
- package/scripts/ensure-models.js +108 -0
- package/scripts/prepare-models.js +387 -0
- package/OFFLINE_MODELS.md +0 -56
- package/dist/intelligence/neuralEngine.d.ts +0 -207
- package/dist/intelligence/neuralEngine.js +0 -706
- package/dist/utils/modelLoader.d.ts +0 -32
- package/dist/utils/modelLoader.js +0 -219
- package/dist/utils/modelManager.d.ts +0 -77
- package/dist/utils/modelManager.js +0 -219
|
@@ -1,172 +1,70 @@
|
|
|
1
|
-
import { AugmentationType, IConduitAugmentation, IWebSocketSupport, AugmentationResponse, WebSocketConnection } from '../types/augmentations.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Conduit Augmentations - Data Synchronization Bridges
|
|
3
|
+
*
|
|
4
|
+
* These augmentations connect and synchronize data between multiple Brainy instances.
|
|
5
|
+
* Now using the unified BrainyAugmentation interface.
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(name: string);
|
|
12
|
-
initialize(): Promise<void>;
|
|
13
|
-
shutDown(): Promise<void>;
|
|
14
|
-
getStatus(): Promise<'active' | 'inactive' | 'error'>;
|
|
15
|
-
abstract establishConnection(targetSystemId: string, config: Record<string, unknown>): Promise<AugmentationResponse<WebSocketConnection>>;
|
|
16
|
-
abstract readData(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
17
|
-
abstract writeData(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
18
|
-
abstract monitorStream(streamId: string, callback: (data: unknown) => void): Promise<void>;
|
|
19
|
-
protected ensureInitialized(): Promise<void>;
|
|
7
|
+
import { BaseAugmentation } from './brainyAugmentation.js';
|
|
8
|
+
export interface WebSocketConnection {
|
|
9
|
+
connectionId: string;
|
|
10
|
+
url: string;
|
|
11
|
+
readyState: number;
|
|
12
|
+
socket?: any;
|
|
20
13
|
}
|
|
21
14
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* This conduit is for syncing between browsers and servers, or between servers.
|
|
25
|
-
* WebSockets cannot be used for direct browser-to-browser communication without a server in the middle.
|
|
15
|
+
* Base class for conduit augmentations that sync between Brainy instances
|
|
16
|
+
* Converted to use the unified BrainyAugmentation interface
|
|
26
17
|
*/
|
|
27
|
-
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* Establishes a connection to another Brainy instance
|
|
35
|
-
* @param targetSystemId The URL or identifier of the target system
|
|
36
|
-
* @param config Configuration options for the connection
|
|
37
|
-
*/
|
|
38
|
-
establishConnection(targetSystemId: string, config: Record<string, unknown>): Promise<AugmentationResponse<WebSocketConnection>>;
|
|
39
|
-
/**
|
|
40
|
-
* Reads data from a connected Brainy instance
|
|
41
|
-
* @param query Query parameters for reading data
|
|
42
|
-
* @param options Additional options
|
|
43
|
-
*/
|
|
44
|
-
readData(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
45
|
-
/**
|
|
46
|
-
* Writes data to a connected Brainy instance
|
|
47
|
-
* @param data The data to write
|
|
48
|
-
* @param options Additional options
|
|
49
|
-
*/
|
|
50
|
-
writeData(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
51
|
-
/**
|
|
52
|
-
* Monitors a data stream from a connected Brainy instance
|
|
53
|
-
* @param streamId The ID of the stream to monitor (usually a connection ID)
|
|
54
|
-
* @param callback Function to call when new data is received
|
|
55
|
-
*/
|
|
56
|
-
monitorStream(streamId: string, callback: (data: unknown) => void): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Establishes a WebSocket connection
|
|
59
|
-
* @param url The WebSocket server URL to connect to
|
|
60
|
-
* @param protocols Optional subprotocols
|
|
61
|
-
*/
|
|
62
|
-
connectWebSocket(url: string, protocols?: string | string[]): Promise<WebSocketConnection>;
|
|
63
|
-
/**
|
|
64
|
-
* Sends data through an established WebSocket connection
|
|
65
|
-
* @param connectionId The identifier of the established connection
|
|
66
|
-
* @param data The data to send (will be serialized if not a string)
|
|
67
|
-
*/
|
|
68
|
-
sendWebSocketMessage(connectionId: string, data: unknown): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Registers a callback for incoming WebSocket messages
|
|
71
|
-
* @param connectionId The identifier of the established connection
|
|
72
|
-
* @param callback The function to call when a message is received
|
|
73
|
-
*/
|
|
74
|
-
onWebSocketMessage(connectionId: string, callback: (data: unknown) => void): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Removes a callback for incoming WebSocket messages
|
|
77
|
-
* @param connectionId The identifier of the established connection
|
|
78
|
-
* @param callback The function to remove from the callbacks
|
|
79
|
-
*/
|
|
80
|
-
offWebSocketMessage(connectionId: string, callback: (data: unknown) => void): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Closes an established WebSocket connection
|
|
83
|
-
* @param connectionId The identifier of the established connection
|
|
84
|
-
* @param code Optional close code
|
|
85
|
-
* @param reason Optional close reason
|
|
86
|
-
*/
|
|
87
|
-
closeWebSocket(connectionId: string, code?: number, reason?: string): Promise<void>;
|
|
18
|
+
declare abstract class BaseConduitAugmentation extends BaseAugmentation {
|
|
19
|
+
readonly timing: "after";
|
|
20
|
+
readonly operations: ("addNoun" | "delete" | "addVerb")[];
|
|
21
|
+
readonly priority = 20;
|
|
22
|
+
protected connections: Map<string, any>;
|
|
23
|
+
protected onShutdown(): Promise<void>;
|
|
24
|
+
abstract establishConnection(targetSystemId: string, config?: Record<string, unknown>): Promise<WebSocketConnection | null>;
|
|
88
25
|
}
|
|
89
26
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* This conduit is for direct peer-to-peer syncing between browsers.
|
|
93
|
-
* It is the recommended approach for browser-to-browser communication.
|
|
27
|
+
* WebSocket Conduit Augmentation
|
|
28
|
+
* Syncs data between Brainy instances using WebSockets
|
|
94
29
|
*/
|
|
95
|
-
export declare class
|
|
96
|
-
readonly
|
|
97
|
-
private peerConnections;
|
|
98
|
-
private dataChannels;
|
|
30
|
+
export declare class WebSocketConduitAugmentation extends BaseConduitAugmentation {
|
|
31
|
+
readonly name = "websocket-conduit";
|
|
99
32
|
private webSocketConnections;
|
|
100
33
|
private messageCallbacks;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* @param targetSystemId The peer ID or signal server URL
|
|
108
|
-
* @param config Configuration options for the connection
|
|
109
|
-
*/
|
|
110
|
-
establishConnection(targetSystemId: string, config: Record<string, unknown>): Promise<AugmentationResponse<WebSocketConnection>>;
|
|
111
|
-
/**
|
|
112
|
-
* Handles an incoming WebRTC offer
|
|
113
|
-
* @param peerId The ID of the peer sending the offer
|
|
114
|
-
* @param offer The SDP offer
|
|
115
|
-
* @param config Configuration options
|
|
116
|
-
*/
|
|
117
|
-
private handleOffer;
|
|
118
|
-
/**
|
|
119
|
-
* Reads data from a connected Brainy instance
|
|
120
|
-
* @param query Query parameters for reading data
|
|
121
|
-
* @param options Additional options
|
|
122
|
-
*/
|
|
123
|
-
readData(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
124
|
-
/**
|
|
125
|
-
* Writes data to a connected Brainy instance
|
|
126
|
-
* @param data The data to write
|
|
127
|
-
* @param options Additional options
|
|
128
|
-
*/
|
|
129
|
-
writeData(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
130
|
-
/**
|
|
131
|
-
* Monitors a data stream from a connected Brainy instance
|
|
132
|
-
* @param streamId The ID of the stream to monitor (usually a connection ID)
|
|
133
|
-
* @param callback Function to call when new data is received
|
|
134
|
-
*/
|
|
135
|
-
monitorStream(streamId: string, callback: (data: unknown) => void): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Establishes a WebSocket connection (used for signaling in WebRTC)
|
|
138
|
-
* @param url The WebSocket server URL to connect to
|
|
139
|
-
* @param protocols Optional subprotocols
|
|
140
|
-
*/
|
|
141
|
-
connectWebSocket(url: string, protocols?: string | string[]): Promise<WebSocketConnection>;
|
|
142
|
-
/**
|
|
143
|
-
* Sends data through an established WebSocket or WebRTC connection
|
|
144
|
-
* @param connectionId The identifier of the established connection
|
|
145
|
-
* @param data The data to send (will be serialized if not a string)
|
|
146
|
-
*/
|
|
147
|
-
sendWebSocketMessage(connectionId: string, data: unknown): Promise<void>;
|
|
34
|
+
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
|
|
35
|
+
private shouldSync;
|
|
36
|
+
private syncOperation;
|
|
37
|
+
establishConnection(url: string, config?: Record<string, unknown>): Promise<WebSocketConnection | null>;
|
|
38
|
+
private handleMessage;
|
|
39
|
+
private applySyncOperation;
|
|
148
40
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @param connectionId The identifier of the established connection
|
|
151
|
-
* @param callback The function to call when a message is received
|
|
41
|
+
* Subscribe to messages from a specific connection
|
|
152
42
|
*/
|
|
153
|
-
|
|
43
|
+
onMessage(connectionId: string, callback: (data: any) => void): void;
|
|
154
44
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param connectionId The identifier of the established connection
|
|
157
|
-
* @param callback The function to remove from the callbacks
|
|
45
|
+
* Send a message to a specific connection
|
|
158
46
|
*/
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Closes an established WebSocket or WebRTC connection
|
|
162
|
-
* @param connectionId The identifier of the established connection
|
|
163
|
-
* @param code Optional close code
|
|
164
|
-
* @param reason Optional close reason
|
|
165
|
-
*/
|
|
166
|
-
closeWebSocket(connectionId: string, code?: number, reason?: string): Promise<void>;
|
|
47
|
+
sendMessage(connectionId: string, data: any): boolean;
|
|
167
48
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Factory function to create the appropriate conduit augmentation based on the type
|
|
170
|
-
*/
|
|
171
|
-
export declare function createConduitAugmentation(type: 'websocket' | 'webrtc', name?: string, options?: Record<string, unknown>): Promise<IConduitAugmentation & IWebSocketSupport>;
|
|
172
49
|
export {};
|
|
50
|
+
/**
|
|
51
|
+
* Example usage:
|
|
52
|
+
*
|
|
53
|
+
* // Server instance
|
|
54
|
+
* const serverBrain = new BrainyData()
|
|
55
|
+
* serverBrain.augmentations.register(new APIServerAugmentation())
|
|
56
|
+
* await serverBrain.init()
|
|
57
|
+
*
|
|
58
|
+
* // Client instance
|
|
59
|
+
* const clientBrain = new BrainyData()
|
|
60
|
+
* const conduit = new WebSocketConduitAugmentation()
|
|
61
|
+
* clientBrain.augmentations.register(conduit)
|
|
62
|
+
* await clientBrain.init()
|
|
63
|
+
*
|
|
64
|
+
* // Connect client to server
|
|
65
|
+
* await conduit.establishConnection('ws://localhost:3000/ws')
|
|
66
|
+
*
|
|
67
|
+
* // Now operations sync automatically!
|
|
68
|
+
* await clientBrain.addNoun('synced data', { source: 'client' })
|
|
69
|
+
* // This will automatically sync to the server
|
|
70
|
+
*/
|