@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,19 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Augmentation Pipeline (Compatibility Layer)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* @deprecated This file provides backward compatibility for code that imports
|
|
5
|
+
* from augmentationPipeline. All new code should use AugmentationRegistry directly.
|
|
5
6
|
*
|
|
6
|
-
* This
|
|
7
|
-
* augmentations across all categories. Like the brain's cortex, it orchestrates
|
|
8
|
-
* different capabilities (augmentations) in sequence or parallel.
|
|
9
|
-
*
|
|
10
|
-
* @deprecated AugmentationPipeline - Use Cortex instead
|
|
7
|
+
* This minimal implementation redirects to the new AugmentationRegistry system.
|
|
11
8
|
*/
|
|
12
|
-
import { AugmentationType } from './types/augmentations.js';
|
|
13
|
-
import { isThreadingAvailable } from './utils/environment.js';
|
|
14
|
-
import { executeInThread } from './utils/workerUtils.js';
|
|
15
9
|
/**
|
|
16
|
-
* Execution mode for
|
|
10
|
+
* Execution mode for pipeline operations
|
|
17
11
|
*/
|
|
18
12
|
export var ExecutionMode;
|
|
19
13
|
(function (ExecutionMode) {
|
|
@@ -21,549 +15,105 @@ export var ExecutionMode;
|
|
|
21
15
|
ExecutionMode["PARALLEL"] = "parallel";
|
|
22
16
|
ExecutionMode["FIRST_SUCCESS"] = "firstSuccess";
|
|
23
17
|
ExecutionMode["FIRST_RESULT"] = "firstResult";
|
|
24
|
-
ExecutionMode["THREADED"] = "threaded";
|
|
18
|
+
ExecutionMode["THREADED"] = "threaded";
|
|
25
19
|
})(ExecutionMode || (ExecutionMode = {}));
|
|
26
20
|
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
const DEFAULT_PIPELINE_OPTIONS = {
|
|
30
|
-
mode: ExecutionMode.SEQUENTIAL,
|
|
31
|
-
timeout: 30000,
|
|
32
|
-
stopOnError: false,
|
|
33
|
-
forceThreading: false,
|
|
34
|
-
disableThreading: false
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Cortex class - The Brain's Orchestration Center
|
|
38
|
-
*
|
|
39
|
-
* Manages all augmentations like the cerebral cortex coordinates different brain regions.
|
|
40
|
-
* This is the central pipeline that orchestrates all augmentation execution.
|
|
21
|
+
* Minimal Cortex class for backward compatibility
|
|
22
|
+
* Redirects all operations to the new AugmentationRegistry system
|
|
41
23
|
*/
|
|
42
24
|
export class Cortex {
|
|
43
25
|
constructor() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
conduit: [],
|
|
47
|
-
cognition: [],
|
|
48
|
-
memory: [],
|
|
49
|
-
perception: [],
|
|
50
|
-
dialog: [],
|
|
51
|
-
activation: [],
|
|
52
|
-
webSocket: []
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Register an augmentation with the cortex
|
|
57
|
-
*
|
|
58
|
-
* @param augmentation The augmentation to register
|
|
59
|
-
* @returns The cortex instance for chaining
|
|
60
|
-
*/
|
|
61
|
-
register(augmentation) {
|
|
62
|
-
let registered = false;
|
|
63
|
-
// Check for specific augmentation types
|
|
64
|
-
if (this.isAugmentationType(augmentation, 'processRawData', 'listenToFeed')) {
|
|
65
|
-
this.registry.sense.push(augmentation);
|
|
66
|
-
registered = true;
|
|
67
|
-
}
|
|
68
|
-
else if (this.isAugmentationType(augmentation, 'establishConnection', 'readData', 'writeData', 'monitorStream')) {
|
|
69
|
-
this.registry.conduit.push(augmentation);
|
|
70
|
-
registered = true;
|
|
71
|
-
}
|
|
72
|
-
else if (this.isAugmentationType(augmentation, 'reason', 'infer', 'executeLogic')) {
|
|
73
|
-
this.registry.cognition.push(augmentation);
|
|
74
|
-
registered = true;
|
|
75
|
-
}
|
|
76
|
-
else if (this.isAugmentationType(augmentation, 'storeData', 'retrieveData', 'updateData', 'deleteData', 'listDataKeys')) {
|
|
77
|
-
this.registry.memory.push(augmentation);
|
|
78
|
-
registered = true;
|
|
79
|
-
}
|
|
80
|
-
else if (this.isAugmentationType(augmentation, 'interpret', 'organize', 'generateVisualization')) {
|
|
81
|
-
this.registry.perception.push(augmentation);
|
|
82
|
-
registered = true;
|
|
83
|
-
}
|
|
84
|
-
else if (this.isAugmentationType(augmentation, 'processUserInput', 'generateResponse', 'manageContext')) {
|
|
85
|
-
this.registry.dialog.push(augmentation);
|
|
86
|
-
registered = true;
|
|
87
|
-
}
|
|
88
|
-
else if (this.isAugmentationType(augmentation, 'triggerAction', 'generateOutput', 'interactExternal')) {
|
|
89
|
-
this.registry.activation.push(augmentation);
|
|
90
|
-
registered = true;
|
|
91
|
-
}
|
|
92
|
-
// Check if the augmentation supports WebSocket
|
|
93
|
-
if (this.isAugmentationType(augmentation, 'connectWebSocket', 'sendWebSocketMessage', 'onWebSocketMessage', 'closeWebSocket')) {
|
|
94
|
-
this.registry.webSocket.push(augmentation);
|
|
95
|
-
registered = true;
|
|
96
|
-
}
|
|
97
|
-
// If the augmentation wasn't registered as any known type, throw an error
|
|
98
|
-
if (!registered) {
|
|
99
|
-
throw new Error(`Unknown augmentation type: ${augmentation.name}`);
|
|
100
|
-
}
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Unregister an augmentation from the pipeline
|
|
105
|
-
*
|
|
106
|
-
* @param augmentationName The name of the augmentation to unregister
|
|
107
|
-
* @returns The pipeline instance for chaining
|
|
108
|
-
*/
|
|
109
|
-
unregister(augmentationName) {
|
|
110
|
-
let found = false;
|
|
111
|
-
// Remove from all registries
|
|
112
|
-
for (const type in this.registry) {
|
|
113
|
-
const typedRegistry = this.registry[type];
|
|
114
|
-
const index = typedRegistry.findIndex((aug) => aug.name === augmentationName);
|
|
115
|
-
if (index !== -1) {
|
|
116
|
-
typedRegistry.splice(index, 1);
|
|
117
|
-
found = true;
|
|
118
|
-
}
|
|
26
|
+
if (Cortex.instance) {
|
|
27
|
+
return Cortex.instance;
|
|
119
28
|
}
|
|
120
|
-
|
|
29
|
+
Cortex.instance = this;
|
|
121
30
|
}
|
|
122
31
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @returns A promise that resolves when all augmentations are initialized
|
|
126
|
-
*/
|
|
127
|
-
async initialize() {
|
|
128
|
-
const allAugmentations = this.getAllAugmentations();
|
|
129
|
-
await Promise.all(allAugmentations.map((augmentation) => augmentation.initialize().catch((error) => {
|
|
130
|
-
console.error(`Failed to initialize augmentation ${augmentation.name}:`, error);
|
|
131
|
-
})));
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Shut down all registered augmentations
|
|
135
|
-
*
|
|
136
|
-
* @returns A promise that resolves when all augmentations are shut down
|
|
137
|
-
*/
|
|
138
|
-
async shutDown() {
|
|
139
|
-
const allAugmentations = this.getAllAugmentations();
|
|
140
|
-
await Promise.all(allAugmentations.map((augmentation) => augmentation.shutDown().catch((error) => {
|
|
141
|
-
console.error(`Failed to shut down augmentation ${augmentation.name}:`, error);
|
|
142
|
-
})));
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Execute a sense pipeline
|
|
146
|
-
*
|
|
147
|
-
* @param method The method to execute on each sense augmentation
|
|
148
|
-
* @param args The arguments to pass to the method
|
|
149
|
-
* @param options The pipeline execution options
|
|
150
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
151
|
-
*/
|
|
152
|
-
async executeSensePipeline(method, args, options = {}) {
|
|
153
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
154
|
-
return this.executeTypedPipeline(this.registry.sense, method, args, opts);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Execute a conduit pipeline
|
|
158
|
-
*
|
|
159
|
-
* @param method The method to execute on each conduit augmentation
|
|
160
|
-
* @param args The arguments to pass to the method
|
|
161
|
-
* @param options The pipeline execution options
|
|
162
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
163
|
-
*/
|
|
164
|
-
async executeConduitPipeline(method, args, options = {}) {
|
|
165
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
166
|
-
return this.executeTypedPipeline(this.registry.conduit, method, args, opts);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Execute a cognition pipeline
|
|
170
|
-
*
|
|
171
|
-
* @param method The method to execute on each cognition augmentation
|
|
172
|
-
* @param args The arguments to pass to the method
|
|
173
|
-
* @param options The pipeline execution options
|
|
174
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
175
|
-
*/
|
|
176
|
-
async executeCognitionPipeline(method, args, options = {}) {
|
|
177
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
178
|
-
return this.executeTypedPipeline(this.registry.cognition, method, args, opts);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Execute a memory pipeline
|
|
182
|
-
*
|
|
183
|
-
* @param method The method to execute on each memory augmentation
|
|
184
|
-
* @param args The arguments to pass to the method
|
|
185
|
-
* @param options The pipeline execution options
|
|
186
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
187
|
-
*/
|
|
188
|
-
async executeMemoryPipeline(method, args, options = {}) {
|
|
189
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
190
|
-
return this.executeTypedPipeline(this.registry.memory, method, args, opts);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Execute a perception pipeline
|
|
194
|
-
*
|
|
195
|
-
* @param method The method to execute on each perception augmentation
|
|
196
|
-
* @param args The arguments to pass to the method
|
|
197
|
-
* @param options The pipeline execution options
|
|
198
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
199
|
-
*/
|
|
200
|
-
async executePerceptionPipeline(method, args, options = {}) {
|
|
201
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
202
|
-
return this.executeTypedPipeline(this.registry.perception, method, args, opts);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Execute a dialog pipeline
|
|
206
|
-
*
|
|
207
|
-
* @param method The method to execute on each dialog augmentation
|
|
208
|
-
* @param args The arguments to pass to the method
|
|
209
|
-
* @param options The pipeline execution options
|
|
210
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
211
|
-
*/
|
|
212
|
-
async executeDialogPipeline(method, args, options = {}) {
|
|
213
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
214
|
-
return this.executeTypedPipeline(this.registry.dialog, method, args, opts);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Execute an activation pipeline
|
|
218
|
-
*
|
|
219
|
-
* @param method The method to execute on each activation augmentation
|
|
220
|
-
* @param args The arguments to pass to the method
|
|
221
|
-
* @param options The pipeline execution options
|
|
222
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
223
|
-
*/
|
|
224
|
-
async executeActivationPipeline(method, args, options = {}) {
|
|
225
|
-
const opts = { ...DEFAULT_PIPELINE_OPTIONS, ...options };
|
|
226
|
-
return this.executeTypedPipeline(this.registry.activation, method, args, opts);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Get all registered augmentations
|
|
230
|
-
*
|
|
231
|
-
* @returns An array of all registered augmentations
|
|
232
|
-
*/
|
|
233
|
-
getAllAugmentations() {
|
|
234
|
-
// Create a Set to avoid duplicates (an augmentation might be in multiple registries)
|
|
235
|
-
const allAugmentations = new Set([
|
|
236
|
-
...this.registry.sense,
|
|
237
|
-
...this.registry.conduit,
|
|
238
|
-
...this.registry.cognition,
|
|
239
|
-
...this.registry.memory,
|
|
240
|
-
...this.registry.perception,
|
|
241
|
-
...this.registry.dialog,
|
|
242
|
-
...this.registry.activation,
|
|
243
|
-
...this.registry.webSocket
|
|
244
|
-
]);
|
|
245
|
-
// Convert back to array
|
|
246
|
-
return Array.from(allAugmentations);
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Get all augmentations of a specific type
|
|
250
|
-
*
|
|
251
|
-
* @param type The type of augmentation to get
|
|
252
|
-
* @returns An array of all augmentations of the specified type
|
|
253
|
-
*/
|
|
254
|
-
getAugmentationsByType(type) {
|
|
255
|
-
switch (type) {
|
|
256
|
-
case AugmentationType.SENSE:
|
|
257
|
-
return [...this.registry.sense];
|
|
258
|
-
case AugmentationType.CONDUIT:
|
|
259
|
-
return [...this.registry.conduit];
|
|
260
|
-
case AugmentationType.COGNITION:
|
|
261
|
-
return [...this.registry.cognition];
|
|
262
|
-
case AugmentationType.MEMORY:
|
|
263
|
-
return [...this.registry.memory];
|
|
264
|
-
case AugmentationType.PERCEPTION:
|
|
265
|
-
return [...this.registry.perception];
|
|
266
|
-
case AugmentationType.DIALOG:
|
|
267
|
-
return [...this.registry.dialog];
|
|
268
|
-
case AugmentationType.ACTIVATION:
|
|
269
|
-
return [...this.registry.activation];
|
|
270
|
-
case AugmentationType.WEBSOCKET:
|
|
271
|
-
return [...this.registry.webSocket];
|
|
272
|
-
default:
|
|
273
|
-
return [];
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Get all available augmentation types
|
|
278
|
-
*
|
|
279
|
-
* @returns An array of all augmentation types that have at least one registered augmentation
|
|
32
|
+
* Get all available augmentation types (returns empty for compatibility)
|
|
33
|
+
* @deprecated Use brain.augmentations instead
|
|
280
34
|
*/
|
|
281
35
|
getAvailableAugmentationTypes() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
availableTypes.push(AugmentationType.SENSE);
|
|
285
|
-
if (this.registry.conduit.length > 0)
|
|
286
|
-
availableTypes.push(AugmentationType.CONDUIT);
|
|
287
|
-
if (this.registry.cognition.length > 0)
|
|
288
|
-
availableTypes.push(AugmentationType.COGNITION);
|
|
289
|
-
if (this.registry.memory.length > 0)
|
|
290
|
-
availableTypes.push(AugmentationType.MEMORY);
|
|
291
|
-
if (this.registry.perception.length > 0)
|
|
292
|
-
availableTypes.push(AugmentationType.PERCEPTION);
|
|
293
|
-
if (this.registry.dialog.length > 0)
|
|
294
|
-
availableTypes.push(AugmentationType.DIALOG);
|
|
295
|
-
if (this.registry.activation.length > 0)
|
|
296
|
-
availableTypes.push(AugmentationType.ACTIVATION);
|
|
297
|
-
if (this.registry.webSocket.length > 0)
|
|
298
|
-
availableTypes.push(AugmentationType.WEBSOCKET);
|
|
299
|
-
return availableTypes;
|
|
36
|
+
console.warn('getAvailableAugmentationTypes is deprecated. Use brain.augmentations instead.');
|
|
37
|
+
return [];
|
|
300
38
|
}
|
|
301
39
|
/**
|
|
302
|
-
* Get
|
|
303
|
-
*
|
|
304
|
-
* @returns An array of all augmentations that support WebSocket connections
|
|
40
|
+
* Get augmentations by type (returns empty for compatibility)
|
|
41
|
+
* @deprecated Use brain.augmentations instead
|
|
305
42
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
43
|
+
getAugmentationsByType(type) {
|
|
44
|
+
console.warn('getAugmentationsByType is deprecated. Use brain.augmentations instead.');
|
|
45
|
+
return [];
|
|
308
46
|
}
|
|
309
47
|
/**
|
|
310
|
-
* Check if
|
|
311
|
-
*
|
|
312
|
-
* @param augmentation The augmentation to check
|
|
313
|
-
* @param methods The methods that should be present on the augmentation
|
|
314
|
-
* @returns True if the augmentation is of the specified type
|
|
48
|
+
* Check if augmentation is enabled (returns false for compatibility)
|
|
49
|
+
* @deprecated Use brain.augmentations instead
|
|
315
50
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (!baseMethodsExist) {
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
// Then check that it has all the specific methods for this type
|
|
323
|
-
return methods.every((method) => typeof augmentation[method] === 'function');
|
|
51
|
+
isAugmentationEnabled(name) {
|
|
52
|
+
console.warn('isAugmentationEnabled is deprecated. Use brain.augmentations instead.');
|
|
53
|
+
return false;
|
|
324
54
|
}
|
|
325
55
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param options The pipeline options
|
|
329
|
-
* @returns True if threading should be used, false otherwise
|
|
56
|
+
* List augmentations with status (returns empty for compatibility)
|
|
57
|
+
* @deprecated Use brain.augmentations instead
|
|
330
58
|
*/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
// If threading is explicitly forced, use it if available
|
|
337
|
-
if (options.forceThreading) {
|
|
338
|
-
return isThreadingAvailable();
|
|
339
|
-
}
|
|
340
|
-
// If in THREADED mode, use threading if available
|
|
341
|
-
if (options.mode === ExecutionMode.THREADED) {
|
|
342
|
-
return isThreadingAvailable();
|
|
343
|
-
}
|
|
344
|
-
// Otherwise, don't use threading
|
|
345
|
-
return false;
|
|
59
|
+
listAugmentationsWithStatus() {
|
|
60
|
+
console.warn('listAugmentationsWithStatus is deprecated. Use brain.augmentations instead.');
|
|
61
|
+
return [];
|
|
346
62
|
}
|
|
347
63
|
/**
|
|
348
|
-
* Execute
|
|
349
|
-
*
|
|
350
|
-
* @param augmentations The augmentations to execute
|
|
351
|
-
* @param method The method to execute on each augmentation
|
|
352
|
-
* @param args The arguments to pass to the method
|
|
353
|
-
* @param options The pipeline execution options
|
|
354
|
-
* @returns A promise that resolves with the results from all augmentations
|
|
64
|
+
* Execute augmentations (compatibility method)
|
|
65
|
+
* @deprecated Use brain.augmentations.execute instead
|
|
355
66
|
*/
|
|
356
|
-
async
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (enabledAugmentations.length === 0) {
|
|
360
|
-
return [];
|
|
361
|
-
}
|
|
362
|
-
// Create a function to execute the method on an augmentation
|
|
363
|
-
const executeMethod = async (augmentation) => {
|
|
364
|
-
try {
|
|
365
|
-
// Create a timeout promise if a timeout is specified
|
|
366
|
-
const timeoutPromise = options.timeout
|
|
367
|
-
? new Promise((_, reject) => {
|
|
368
|
-
setTimeout(() => {
|
|
369
|
-
reject(new Error(`Timeout executing ${String(method)} on ${augmentation.name}`));
|
|
370
|
-
}, options.timeout);
|
|
371
|
-
})
|
|
372
|
-
: null;
|
|
373
|
-
// Check if threading should be used
|
|
374
|
-
const useThreading = this.shouldUseThreading(options);
|
|
375
|
-
// Execute the method on the augmentation, using threading if appropriate
|
|
376
|
-
let methodPromise;
|
|
377
|
-
if (useThreading) {
|
|
378
|
-
// Execute in a separate thread
|
|
379
|
-
try {
|
|
380
|
-
// Create a function that can be serialized and executed in a worker
|
|
381
|
-
const workerFn = (...workerArgs) => {
|
|
382
|
-
// This function will be stringified and executed in the worker
|
|
383
|
-
// It needs to be self-contained
|
|
384
|
-
const augFn = augmentation[method];
|
|
385
|
-
return augFn.apply(augmentation, workerArgs);
|
|
386
|
-
};
|
|
387
|
-
methodPromise = executeInThread(workerFn.toString(), args);
|
|
388
|
-
}
|
|
389
|
-
catch (threadError) {
|
|
390
|
-
console.warn(`Failed to execute in thread, falling back to main thread: ${threadError}`);
|
|
391
|
-
// Fall back to executing in the main thread
|
|
392
|
-
methodPromise = Promise.resolve(augmentation[method](...args));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
// Execute in the main thread
|
|
397
|
-
methodPromise = Promise.resolve(augmentation[method](...args));
|
|
398
|
-
}
|
|
399
|
-
// Race the method promise against the timeout promise if a timeout is specified
|
|
400
|
-
const result = timeoutPromise
|
|
401
|
-
? await Promise.race([methodPromise, timeoutPromise])
|
|
402
|
-
: await methodPromise;
|
|
403
|
-
return result;
|
|
404
|
-
}
|
|
405
|
-
catch (error) {
|
|
406
|
-
console.error(`Error executing ${String(method)} on ${augmentation.name}:`, error);
|
|
407
|
-
return {
|
|
408
|
-
success: false,
|
|
409
|
-
data: null,
|
|
410
|
-
error: error instanceof Error ? error.message : String(error)
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
// Execute the pipeline based on the specified mode
|
|
415
|
-
switch (options.mode) {
|
|
416
|
-
case ExecutionMode.PARALLEL:
|
|
417
|
-
// Execute all augmentations in parallel
|
|
418
|
-
return enabledAugmentations.map(executeMethod);
|
|
419
|
-
case ExecutionMode.THREADED:
|
|
420
|
-
// Execute all augmentations in parallel with threading enabled
|
|
421
|
-
// Force threading for this mode
|
|
422
|
-
const threadedOptions = { ...options, forceThreading: true };
|
|
423
|
-
// Create a new executeMethod function that uses the threaded options
|
|
424
|
-
const executeMethodThreaded = async (augmentation) => {
|
|
425
|
-
// Save the original options
|
|
426
|
-
const originalOptions = options;
|
|
427
|
-
// Set the options to the threaded options
|
|
428
|
-
options = threadedOptions;
|
|
429
|
-
// Execute the method
|
|
430
|
-
const result = await executeMethod(augmentation);
|
|
431
|
-
// Restore the original options
|
|
432
|
-
options = originalOptions;
|
|
433
|
-
return result;
|
|
434
|
-
};
|
|
435
|
-
return enabledAugmentations.map(executeMethodThreaded);
|
|
436
|
-
case ExecutionMode.FIRST_SUCCESS:
|
|
437
|
-
// Execute augmentations sequentially until one succeeds
|
|
438
|
-
for (const augmentation of enabledAugmentations) {
|
|
439
|
-
const resultPromise = executeMethod(augmentation);
|
|
440
|
-
const result = await resultPromise;
|
|
441
|
-
if (result.success) {
|
|
442
|
-
return [resultPromise];
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return [];
|
|
446
|
-
case ExecutionMode.FIRST_RESULT:
|
|
447
|
-
// Execute augmentations sequentially until one returns a result
|
|
448
|
-
for (const augmentation of enabledAugmentations) {
|
|
449
|
-
const resultPromise = executeMethod(augmentation);
|
|
450
|
-
const result = await resultPromise;
|
|
451
|
-
if (result.success && result.data) {
|
|
452
|
-
return [resultPromise];
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return [];
|
|
456
|
-
case ExecutionMode.SEQUENTIAL:
|
|
457
|
-
default:
|
|
458
|
-
// Execute augmentations sequentially
|
|
459
|
-
const results = [];
|
|
460
|
-
for (const augmentation of enabledAugmentations) {
|
|
461
|
-
const resultPromise = executeMethod(augmentation);
|
|
462
|
-
results.push(resultPromise);
|
|
463
|
-
// Check if we need to stop on error
|
|
464
|
-
if (options.stopOnError) {
|
|
465
|
-
const result = await resultPromise;
|
|
466
|
-
if (!result.success) {
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return results;
|
|
472
|
-
}
|
|
67
|
+
async executeAugmentations(operation, data, options) {
|
|
68
|
+
console.warn('executeAugmentations is deprecated. Use brain.augmentations.execute instead.');
|
|
69
|
+
return data;
|
|
473
70
|
}
|
|
474
71
|
/**
|
|
475
|
-
* Enable
|
|
476
|
-
*
|
|
477
|
-
* @param name The name of the augmentation to enable
|
|
478
|
-
* @returns True if augmentation was found and enabled
|
|
72
|
+
* Enable augmentation (compatibility method)
|
|
73
|
+
* @deprecated Use brain.augmentations instead
|
|
479
74
|
*/
|
|
480
75
|
enableAugmentation(name) {
|
|
481
|
-
|
|
482
|
-
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
483
|
-
if (augmentation) {
|
|
484
|
-
augmentation.enabled = true;
|
|
485
|
-
return true;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
76
|
+
console.warn('enableAugmentation is deprecated. Use brain.augmentations instead.');
|
|
488
77
|
return false;
|
|
489
78
|
}
|
|
490
79
|
/**
|
|
491
|
-
* Disable
|
|
492
|
-
*
|
|
493
|
-
* @param name The name of the augmentation to disable
|
|
494
|
-
* @returns True if augmentation was found and disabled
|
|
80
|
+
* Disable augmentation (compatibility method)
|
|
81
|
+
* @deprecated Use brain.augmentations instead
|
|
495
82
|
*/
|
|
496
83
|
disableAugmentation(name) {
|
|
497
|
-
|
|
498
|
-
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
499
|
-
if (augmentation) {
|
|
500
|
-
augmentation.enabled = false;
|
|
501
|
-
return true;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
84
|
+
console.warn('disableAugmentation is deprecated. Use brain.augmentations instead.');
|
|
504
85
|
return false;
|
|
505
86
|
}
|
|
506
87
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
* @param name The name of the augmentation to check
|
|
510
|
-
* @returns True if augmentation is found and enabled, false otherwise
|
|
88
|
+
* Register augmentation (compatibility method)
|
|
89
|
+
* @deprecated Use brain.augmentations.register instead
|
|
511
90
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
515
|
-
if (augmentation) {
|
|
516
|
-
return augmentation.enabled;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
return false;
|
|
91
|
+
register(augmentation) {
|
|
92
|
+
console.warn('register is deprecated. Use brain.augmentations.register instead.');
|
|
520
93
|
}
|
|
521
94
|
/**
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
* @returns Array of augmentations with name, type, and enabled status
|
|
95
|
+
* Unregister augmentation (compatibility method)
|
|
96
|
+
* @deprecated Use brain.augmentations instead
|
|
525
97
|
*/
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
for (const aug of augmentations) {
|
|
530
|
-
result.push({
|
|
531
|
-
name: aug.name,
|
|
532
|
-
type: type,
|
|
533
|
-
enabled: aug.enabled,
|
|
534
|
-
description: aug.description
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return result;
|
|
98
|
+
unregister(name) {
|
|
99
|
+
console.warn('unregister is deprecated. Use brain.augmentations instead.');
|
|
100
|
+
return false;
|
|
539
101
|
}
|
|
540
102
|
/**
|
|
541
|
-
* Enable
|
|
542
|
-
*
|
|
543
|
-
* @param type The type of augmentations to enable
|
|
544
|
-
* @returns Number of augmentations enabled
|
|
103
|
+
* Enable augmentation type (compatibility method)
|
|
104
|
+
* @deprecated Use brain.augmentations instead
|
|
545
105
|
*/
|
|
546
106
|
enableAugmentationType(type) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
aug.enabled = true;
|
|
550
|
-
count++;
|
|
551
|
-
}
|
|
552
|
-
return count;
|
|
107
|
+
console.warn('enableAugmentationType is deprecated. Use brain.augmentations instead.');
|
|
108
|
+
return 0;
|
|
553
109
|
}
|
|
554
110
|
/**
|
|
555
|
-
* Disable
|
|
556
|
-
*
|
|
557
|
-
* @param type The type of augmentations to disable
|
|
558
|
-
* @returns Number of augmentations disabled
|
|
111
|
+
* Disable augmentation type (compatibility method)
|
|
112
|
+
* @deprecated Use brain.augmentations instead
|
|
559
113
|
*/
|
|
560
114
|
disableAugmentationType(type) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
aug.enabled = false;
|
|
564
|
-
count++;
|
|
565
|
-
}
|
|
566
|
-
return count;
|
|
115
|
+
console.warn('disableAugmentationType is deprecated. Use brain.augmentations instead.');
|
|
116
|
+
return 0;
|
|
567
117
|
}
|
|
568
118
|
}
|
|
569
119
|
// Create and export a default instance of the cortex
|
|
@@ -571,4 +121,6 @@ export const cortex = new Cortex();
|
|
|
571
121
|
// Backward compatibility exports
|
|
572
122
|
export const AugmentationPipeline = Cortex;
|
|
573
123
|
export const augmentationPipeline = cortex;
|
|
124
|
+
// Export types for compatibility (avoid duplicate export)
|
|
125
|
+
// PipelineOptions already exported above
|
|
574
126
|
//# sourceMappingURL=augmentationPipeline.js.map
|