@soulcraft/brainy 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -0
- package/LICENSE +2 -2
- package/README.md +201 -596
- 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 +1336 -855
- 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 +43 -128
- 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,17 +1,12 @@
|
|
|
1
|
-
/** Common types for the augmentation system */
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Brainy 2.0 Augmentation Types
|
|
3
|
+
*
|
|
4
|
+
* This file contains only the minimal types needed for augmentations.
|
|
5
|
+
* The main augmentation interfaces are now in augmentations/brainyAugmentation.ts
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* WebSocket connection type for conduit augmentations
|
|
4
9
|
*/
|
|
5
|
-
export declare enum AugmentationType {
|
|
6
|
-
SENSE = "sense",
|
|
7
|
-
CONDUIT = "conduit",
|
|
8
|
-
COGNITION = "cognition",
|
|
9
|
-
MEMORY = "memory",
|
|
10
|
-
PERCEPTION = "perception",
|
|
11
|
-
DIALOG = "dialog",
|
|
12
|
-
ACTIVATION = "activation",
|
|
13
|
-
WEBSOCKET = "webSocket"
|
|
14
|
-
}
|
|
15
10
|
export type WebSocketConnection = {
|
|
16
11
|
connectionId: string;
|
|
17
12
|
url: string;
|
|
@@ -23,348 +18,54 @@ export type WebSocketConnection = {
|
|
|
23
18
|
}) => void;
|
|
24
19
|
_messageHandlerWrapper?: (data: unknown) => void;
|
|
25
20
|
};
|
|
26
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Generic augmentation response type
|
|
23
|
+
*/
|
|
27
24
|
export type AugmentationResponse<T> = {
|
|
28
25
|
success: boolean;
|
|
29
26
|
data: T;
|
|
30
27
|
error?: string;
|
|
31
28
|
};
|
|
32
29
|
/**
|
|
33
|
-
*
|
|
34
|
-
* All augmentations must implement these core properties.
|
|
30
|
+
* Data callback type for subscriptions
|
|
35
31
|
*/
|
|
36
|
-
export
|
|
37
|
-
/** A unique identifier for the augmentation (e.g., "my-reasoner-v1") */
|
|
38
|
-
readonly name: string;
|
|
39
|
-
/** A human-readable description of the augmentation's purpose */
|
|
40
|
-
readonly description: string;
|
|
41
|
-
/** Whether this augmentation is enabled */
|
|
42
|
-
enabled: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Initializes the augmentation. This method is called when Brainy starts up.
|
|
45
|
-
* @returns A Promise that resolves when initialization is complete
|
|
46
|
-
*/
|
|
47
|
-
initialize(): Promise<void>;
|
|
48
|
-
shutDown(): Promise<void>;
|
|
49
|
-
getStatus(): Promise<'active' | 'inactive' | 'error'>;
|
|
50
|
-
[key: string]: any;
|
|
51
|
-
}
|
|
32
|
+
export type DataCallback<T> = (data: T) => void;
|
|
52
33
|
/**
|
|
53
|
-
*
|
|
54
|
-
* Augmentations that implement this interface can communicate via WebSockets.
|
|
34
|
+
* Import types for re-export (avoiding circular dependencies)
|
|
55
35
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
* Registers a callback for incoming WebSocket messages.
|
|
72
|
-
* @param connectionId The identifier of the established connection
|
|
73
|
-
* @param callback The function to call when a message is received
|
|
74
|
-
*/
|
|
75
|
-
onWebSocketMessage(connectionId: string, callback: DataCallback<unknown>): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Removes a callback for incoming WebSocket messages.
|
|
78
|
-
* @param connectionId The identifier of the established connection
|
|
79
|
-
* @param callback The function to remove from the callbacks
|
|
80
|
-
*/
|
|
81
|
-
offWebSocketMessage(connectionId: string, callback: DataCallback<unknown>): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* Closes an established WebSocket connection.
|
|
84
|
-
* @param connectionId The identifier of the established connection
|
|
85
|
-
* @param code Optional close code
|
|
86
|
-
* @param reason Optional close reason
|
|
87
|
-
*/
|
|
88
|
-
closeWebSocket(connectionId: string, code?: number, reason?: string): Promise<void>;
|
|
36
|
+
import type { BrainyAugmentation as BA, BaseAugmentation as BaseA, AugmentationContext as AC } from '../augmentations/brainyAugmentation.js';
|
|
37
|
+
export type BrainyAugmentation = BA;
|
|
38
|
+
export type BaseAugmentation = BaseA;
|
|
39
|
+
export type AugmentationContext = AC;
|
|
40
|
+
export type IAugmentation = BrainyAugmentation;
|
|
41
|
+
export declare enum AugmentationType {
|
|
42
|
+
SENSE = "sense",
|
|
43
|
+
CONDUIT = "conduit",
|
|
44
|
+
COGNITION = "cognition",
|
|
45
|
+
MEMORY = "memory",
|
|
46
|
+
PERCEPTION = "perception",
|
|
47
|
+
DIALOG = "dialog",
|
|
48
|
+
ACTIVATION = "activation",
|
|
49
|
+
WEBSOCKET = "webSocket",
|
|
50
|
+
SYNAPSE = "synapse"
|
|
89
51
|
}
|
|
90
52
|
export declare namespace BrainyAugmentations {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* @param dataType The type of raw data (e.g., 'text', 'image', 'audio')
|
|
100
|
-
* @param options Optional processing options (e.g., confidence thresholds, filters)
|
|
101
|
-
*/
|
|
102
|
-
processRawData(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
|
|
103
|
-
nouns: string[];
|
|
104
|
-
verbs: string[];
|
|
105
|
-
confidence?: number;
|
|
106
|
-
insights?: Array<{
|
|
107
|
-
type: string;
|
|
108
|
-
description: string;
|
|
109
|
-
confidence: number;
|
|
110
|
-
}>;
|
|
111
|
-
metadata?: Record<string, unknown>;
|
|
112
|
-
}>>;
|
|
113
|
-
/**
|
|
114
|
-
* Registers a listener for real-time data feeds.
|
|
115
|
-
* @param feedUrl The URL or identifier of the real-time feed
|
|
116
|
-
* @param callback A function to call with processed data
|
|
117
|
-
*/
|
|
118
|
-
listenToFeed(feedUrl: string, callback: DataCallback<{
|
|
119
|
-
nouns: string[];
|
|
120
|
-
verbs: string[];
|
|
121
|
-
confidence?: number;
|
|
122
|
-
}>): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Analyzes data structure without processing (preview mode).
|
|
125
|
-
* @param rawData The raw data to analyze
|
|
126
|
-
* @param dataType The type of raw data
|
|
127
|
-
* @param options Optional analysis options
|
|
128
|
-
*/
|
|
129
|
-
analyzeStructure?(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
|
|
130
|
-
entityTypes: Array<{
|
|
131
|
-
type: string;
|
|
132
|
-
count: number;
|
|
133
|
-
confidence: number;
|
|
134
|
-
}>;
|
|
135
|
-
relationshipTypes: Array<{
|
|
136
|
-
type: string;
|
|
137
|
-
count: number;
|
|
138
|
-
confidence: number;
|
|
139
|
-
}>;
|
|
140
|
-
dataQuality: {
|
|
141
|
-
completeness: number;
|
|
142
|
-
consistency: number;
|
|
143
|
-
accuracy: number;
|
|
144
|
-
};
|
|
145
|
-
recommendations: string[];
|
|
146
|
-
}>>;
|
|
147
|
-
/**
|
|
148
|
-
* Validates data compatibility with current knowledge base.
|
|
149
|
-
* @param rawData The raw data to validate
|
|
150
|
-
* @param dataType The type of raw data
|
|
151
|
-
*/
|
|
152
|
-
validateCompatibility?(rawData: Buffer | string, dataType: string): Promise<AugmentationResponse<{
|
|
153
|
-
compatible: boolean;
|
|
154
|
-
issues: Array<{
|
|
155
|
-
type: string;
|
|
156
|
-
description: string;
|
|
157
|
-
severity: 'low' | 'medium' | 'high';
|
|
158
|
-
}>;
|
|
159
|
-
suggestions: string[];
|
|
160
|
-
}>>;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Interface for Conduits augmentations.
|
|
164
|
-
* These augmentations establish and manage high-bandwidth, dedicated channels for structured, programmatic two-way data exchange.
|
|
165
|
-
*/
|
|
166
|
-
interface IConduitAugmentation extends IAugmentation {
|
|
167
|
-
/**
|
|
168
|
-
* Establishes a connection for programmatic data exchange.
|
|
169
|
-
* @param targetSystemId The identifier of the external system to connect to
|
|
170
|
-
* @param config Configuration details for the connection (e.g., API keys, endpoints)
|
|
171
|
-
*/
|
|
172
|
-
establishConnection(targetSystemId: string, config: Record<string, unknown>): Promise<AugmentationResponse<WebSocketConnection>>;
|
|
173
|
-
/**
|
|
174
|
-
* Reads structured data directly from Brainy's knowledge graph.
|
|
175
|
-
* @param query A structured query (e.g., graph query language, object path)
|
|
176
|
-
* @param options Optional query options (e.g., depth, filters)
|
|
177
|
-
*/
|
|
178
|
-
readData(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
179
|
-
/**
|
|
180
|
-
* Writes or updates structured data directly into Brainy's knowledge graph.
|
|
181
|
-
* @param data The structured data to write/update
|
|
182
|
-
* @param options Optional write options (e.g., merge, overwrite)
|
|
183
|
-
*/
|
|
184
|
-
writeData(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
185
|
-
/**
|
|
186
|
-
* Monitors a specific data stream or event within Brainy for external systems.
|
|
187
|
-
* @param streamId The identifier of the data stream or event
|
|
188
|
-
* @param callback A function to call when new data/events occur
|
|
189
|
-
*/
|
|
190
|
-
monitorStream(streamId: string, callback: DataCallback<unknown>): Promise<void>;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Interface for Cognitions augmentations.
|
|
194
|
-
* These augmentations enable advanced reasoning, inference, and logical operations.
|
|
195
|
-
*/
|
|
196
|
-
interface ICognitionAugmentation extends IAugmentation {
|
|
197
|
-
/**
|
|
198
|
-
* Performs a reasoning operation based on current knowledge.
|
|
199
|
-
* @param query The specific reasoning task or question
|
|
200
|
-
* @param context Optional additional context for the reasoning
|
|
201
|
-
*/
|
|
202
|
-
reason(query: string, context?: Record<string, unknown>): AugmentationResponse<{
|
|
203
|
-
inference: string;
|
|
204
|
-
confidence: number;
|
|
205
|
-
}>;
|
|
206
|
-
/**
|
|
207
|
-
* Infers relationships or new facts from existing data.
|
|
208
|
-
* @param dataSubset A subset of data to infer from
|
|
209
|
-
*/
|
|
210
|
-
infer(dataSubset: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
|
|
211
|
-
/**
|
|
212
|
-
* Executes a logical operation or rule set.
|
|
213
|
-
* @param ruleId The identifier of the rule or logic to apply
|
|
214
|
-
* @param input Data to apply the logic to
|
|
215
|
-
*/
|
|
216
|
-
executeLogic(ruleId: string, input: Record<string, unknown>): AugmentationResponse<boolean>;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Interface for Memory augmentations.
|
|
220
|
-
* These augmentations provide storage capabilities for data in different formats (e.g., fileSystem, in-memory).
|
|
221
|
-
*/
|
|
222
|
-
interface IMemoryAugmentation extends IAugmentation {
|
|
223
|
-
/**
|
|
224
|
-
* Stores data in the memory system.
|
|
225
|
-
* @param key The unique identifier for the data
|
|
226
|
-
* @param data The data to store
|
|
227
|
-
* @param options Optional storage options (e.g., expiration, format)
|
|
228
|
-
*/
|
|
229
|
-
storeData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
230
|
-
/**
|
|
231
|
-
* Retrieves data from the memory system.
|
|
232
|
-
* @param key The unique identifier for the data
|
|
233
|
-
* @param options Optional retrieval options (e.g., format, version)
|
|
234
|
-
*/
|
|
235
|
-
retrieveData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
236
|
-
/**
|
|
237
|
-
* Updates existing data in the memory system.
|
|
238
|
-
* @param key The unique identifier for the data
|
|
239
|
-
* @param data The updated data
|
|
240
|
-
* @param options Optional update options (e.g., merge, overwrite)
|
|
241
|
-
*/
|
|
242
|
-
updateData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
243
|
-
/**
|
|
244
|
-
* Deletes data from the memory system.
|
|
245
|
-
* @param key The unique identifier for the data
|
|
246
|
-
* @param options Optional deletion options
|
|
247
|
-
*/
|
|
248
|
-
deleteData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
249
|
-
/**
|
|
250
|
-
* Lists available data keys in the memory system.
|
|
251
|
-
* @param pattern Optional pattern to filter keys (e.g., prefix, regex)
|
|
252
|
-
* @param options Optional listing options (e.g., limit, offset)
|
|
253
|
-
*/
|
|
254
|
-
listDataKeys(pattern?: string, options?: Record<string, unknown>): Promise<AugmentationResponse<string[]>>;
|
|
255
|
-
/**
|
|
256
|
-
* Searches for data in the memory system using vector similarity.
|
|
257
|
-
* @param query The query vector or data to search for
|
|
258
|
-
* @param k Number of results to return
|
|
259
|
-
* @param options Optional search options
|
|
260
|
-
*/
|
|
261
|
-
search(query: unknown, k?: number, options?: Record<string, unknown>): Promise<AugmentationResponse<Array<{
|
|
262
|
-
id: string;
|
|
263
|
-
score: number;
|
|
264
|
-
data: unknown;
|
|
265
|
-
}>>>;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Interface for Perceptions augmentations.
|
|
269
|
-
* These augmentations interpret, contextualize, and visualize identified nouns and verbs.
|
|
270
|
-
*/
|
|
271
|
-
interface IPerceptionAugmentation extends IAugmentation {
|
|
272
|
-
/**
|
|
273
|
-
* Interprets and contextualizes processed nouns and verbs.
|
|
274
|
-
* @param nouns The list of identified nouns
|
|
275
|
-
* @param verbs The list of identified verbs
|
|
276
|
-
* @param context Optional additional context for interpretation
|
|
277
|
-
*/
|
|
278
|
-
interpret(nouns: string[], verbs: string[], context?: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
|
|
279
|
-
/**
|
|
280
|
-
* Organizes and filters information.
|
|
281
|
-
* @param data The data to organize (e.g., interpreted perceptions)
|
|
282
|
-
* @param criteria Optional criteria for filtering/prioritization
|
|
283
|
-
*/
|
|
284
|
-
organize(data: Record<string, unknown>, criteria?: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
|
|
285
|
-
/**
|
|
286
|
-
* Generates a visualization based on the provided data.
|
|
287
|
-
* @param data The data to visualize (e.g., interpreted patterns)
|
|
288
|
-
* @param visualizationType The desired type of visualization (e.g., 'graph', 'chart')
|
|
289
|
-
*/
|
|
290
|
-
generateVisualization(data: Record<string, unknown>, visualizationType: string): AugmentationResponse<string | Buffer | Record<string, unknown>>;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Interface for Dialogs augmentations.
|
|
294
|
-
* These augmentations facilitate natural language understanding and generation for conversational interaction.
|
|
295
|
-
*/
|
|
296
|
-
interface IDialogAugmentation extends IAugmentation {
|
|
297
|
-
/**
|
|
298
|
-
* Processes a user's natural language input (query).
|
|
299
|
-
* @param naturalLanguageQuery The raw text query from the user
|
|
300
|
-
* @param sessionId An optional session ID for conversational context
|
|
301
|
-
*/
|
|
302
|
-
processUserInput(naturalLanguageQuery: string, sessionId?: string): AugmentationResponse<{
|
|
303
|
-
intent: string;
|
|
304
|
-
nouns: string[];
|
|
305
|
-
verbs: string[];
|
|
306
|
-
context: Record<string, unknown>;
|
|
307
|
-
}>;
|
|
308
|
-
/**
|
|
309
|
-
* Generates a natural language response based on Brainy's knowledge and interpreted input.
|
|
310
|
-
* @param interpretedInput The output from `processUserInput` or similar
|
|
311
|
-
* @param knowledgeContext Relevant knowledge retrieved from Brainy
|
|
312
|
-
* @param sessionId An optional session ID for conversational context
|
|
313
|
-
*/
|
|
314
|
-
generateResponse(interpretedInput: Record<string, unknown>, knowledgeContext: Record<string, unknown>, sessionId?: string): AugmentationResponse<string>;
|
|
315
|
-
/**
|
|
316
|
-
* Manages and updates conversational context.
|
|
317
|
-
* @param sessionId The session ID
|
|
318
|
-
* @param contextUpdate The data to update the context with
|
|
319
|
-
*/
|
|
320
|
-
manageContext(sessionId: string, contextUpdate: Record<string, unknown>): Promise<void>;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Interface for Activations augmentations.
|
|
324
|
-
* These augmentations dictate how Brainy initiates actions, responses, or data manipulations.
|
|
325
|
-
*/
|
|
326
|
-
interface IActivationAugmentation extends IAugmentation {
|
|
327
|
-
/**
|
|
328
|
-
* Triggers an action based on a processed command or internal state.
|
|
329
|
-
* @param actionName The name of the action to trigger
|
|
330
|
-
* @param parameters Optional parameters for the action
|
|
331
|
-
*/
|
|
332
|
-
triggerAction(actionName: string, parameters?: Record<string, unknown>): AugmentationResponse<unknown>;
|
|
333
|
-
/**
|
|
334
|
-
* Generates an expressive output or response from Brainy.
|
|
335
|
-
* @param knowledgeId The identifier of the knowledge to express
|
|
336
|
-
* @param format The desired output format (e.g., 'text', 'json')
|
|
337
|
-
*/
|
|
338
|
-
generateOutput(knowledgeId: string, format: string): AugmentationResponse<string | Record<string, unknown>>;
|
|
339
|
-
/**
|
|
340
|
-
* Interacts with an external system or API.
|
|
341
|
-
* @param systemId The identifier of the external system
|
|
342
|
-
* @param payload The data to send to the external system
|
|
343
|
-
*/
|
|
344
|
-
interactExternal(systemId: string, payload: Record<string, unknown>): AugmentationResponse<unknown>;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
/** Direct exports of augmentation interfaces for easier imports */
|
|
348
|
-
export interface ISenseAugmentation extends BrainyAugmentations.ISenseAugmentation {
|
|
349
|
-
}
|
|
350
|
-
export interface IConduitAugmentation extends BrainyAugmentations.IConduitAugmentation {
|
|
351
|
-
}
|
|
352
|
-
export interface ICognitionAugmentation extends BrainyAugmentations.ICognitionAugmentation {
|
|
353
|
-
}
|
|
354
|
-
export interface IMemoryAugmentation extends BrainyAugmentations.IMemoryAugmentation {
|
|
355
|
-
}
|
|
356
|
-
export interface IPerceptionAugmentation extends BrainyAugmentations.IPerceptionAugmentation {
|
|
357
|
-
}
|
|
358
|
-
export interface IDialogAugmentation extends BrainyAugmentations.IDialogAugmentation {
|
|
53
|
+
type ISenseAugmentation = BrainyAugmentation;
|
|
54
|
+
type IConduitAugmentation = BrainyAugmentation;
|
|
55
|
+
type ICognitionAugmentation = BrainyAugmentation;
|
|
56
|
+
type IMemoryAugmentation = BrainyAugmentation;
|
|
57
|
+
type IPerceptionAugmentation = BrainyAugmentation;
|
|
58
|
+
type IDialogAugmentation = BrainyAugmentation;
|
|
59
|
+
type IActivationAugmentation = BrainyAugmentation;
|
|
60
|
+
type ISynapseAugmentation = BrainyAugmentation;
|
|
359
61
|
}
|
|
360
|
-
export
|
|
62
|
+
export type ISenseAugmentation = BrainyAugmentation;
|
|
63
|
+
export type IConduitAugmentation = BrainyAugmentation;
|
|
64
|
+
export type ICognitionAugmentation = BrainyAugmentation;
|
|
65
|
+
export type IMemoryAugmentation = BrainyAugmentation;
|
|
66
|
+
export type IPerceptionAugmentation = BrainyAugmentation;
|
|
67
|
+
export type IDialogAugmentation = BrainyAugmentation;
|
|
68
|
+
export type IActivationAugmentation = BrainyAugmentation;
|
|
69
|
+
export type ISynapseAugmentation = BrainyAugmentation;
|
|
70
|
+
export interface IWebSocketSupport {
|
|
361
71
|
}
|
|
362
|
-
/** WebSocket-enabled augmentation interfaces */
|
|
363
|
-
export type IWebSocketSenseAugmentation = BrainyAugmentations.ISenseAugmentation & IWebSocketSupport;
|
|
364
|
-
export type IWebSocketConduitAugmentation = BrainyAugmentations.IConduitAugmentation & IWebSocketSupport;
|
|
365
|
-
export type IWebSocketCognitionAugmentation = BrainyAugmentations.ICognitionAugmentation & IWebSocketSupport;
|
|
366
|
-
export type IWebSocketMemoryAugmentation = BrainyAugmentations.IMemoryAugmentation & IWebSocketSupport;
|
|
367
|
-
export type IWebSocketPerceptionAugmentation = BrainyAugmentations.IPerceptionAugmentation & IWebSocketSupport;
|
|
368
|
-
export type IWebSocketDialogAugmentation = BrainyAugmentations.IDialogAugmentation & IWebSocketSupport;
|
|
369
|
-
export type IWebSocketActivationAugmentation = BrainyAugmentations.IActivationAugmentation & IWebSocketSupport;
|
|
370
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
/** Common types for the augmentation system */
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Brainy 2.0 Augmentation Types
|
|
3
|
+
*
|
|
4
|
+
* This file contains only the minimal types needed for augmentations.
|
|
5
|
+
* The main augmentation interfaces are now in augmentations/brainyAugmentation.ts
|
|
4
6
|
*/
|
|
5
7
|
export var AugmentationType;
|
|
6
8
|
(function (AugmentationType) {
|
|
@@ -12,5 +14,6 @@ export var AugmentationType;
|
|
|
12
14
|
AugmentationType["DIALOG"] = "dialog";
|
|
13
15
|
AugmentationType["ACTIVATION"] = "activation";
|
|
14
16
|
AugmentationType["WEBSOCKET"] = "webSocket";
|
|
17
|
+
AugmentationType["SYNAPSE"] = "synapse";
|
|
15
18
|
})(AugmentationType || (AugmentationType = {}));
|
|
16
19
|
//# sourceMappingURL=augmentations.js.map
|
|
@@ -14,14 +14,18 @@ export interface BrainyDataInterface<T = unknown> {
|
|
|
14
14
|
* Get a noun by ID
|
|
15
15
|
* @param id The ID of the noun to get
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
getNoun(id: string): Promise<unknown>;
|
|
18
18
|
/**
|
|
19
|
-
* Add a vector
|
|
20
|
-
* @param
|
|
21
|
-
* @param metadata Optional metadata to associate with the
|
|
22
|
-
* @
|
|
19
|
+
* Add a noun (entity with vector and metadata) to the database
|
|
20
|
+
* @param data Text string or vector representation (will auto-embed strings)
|
|
21
|
+
* @param metadata Optional metadata to associate with the noun
|
|
22
|
+
* @param options Optional configuration including custom ID
|
|
23
|
+
* @returns The ID of the added noun
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
addNoun(data: string | Vector, metadata?: T, options?: {
|
|
26
|
+
id?: string;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}): Promise<string>;
|
|
25
29
|
/**
|
|
26
30
|
* Search for text in the database
|
|
27
31
|
* @param text The text to search for
|
|
@@ -30,14 +34,14 @@ export interface BrainyDataInterface<T = unknown> {
|
|
|
30
34
|
*/
|
|
31
35
|
searchText(text: string, limit?: number): Promise<unknown[]>;
|
|
32
36
|
/**
|
|
33
|
-
* Create a relationship between two entities
|
|
37
|
+
* Create a relationship (verb) between two entities
|
|
34
38
|
* @param sourceId The ID of the source entity
|
|
35
39
|
* @param targetId The ID of the target entity
|
|
36
|
-
* @param
|
|
40
|
+
* @param verbType The type of relationship
|
|
37
41
|
* @param metadata Optional metadata about the relationship
|
|
38
|
-
* @returns The ID of the created
|
|
42
|
+
* @returns The ID of the created verb
|
|
39
43
|
*/
|
|
40
|
-
|
|
44
|
+
addVerb(sourceId: string, targetId: string, verbType: string, metadata?: unknown): Promise<string>;
|
|
41
45
|
/**
|
|
42
46
|
* Find entities similar to a given entity ID
|
|
43
47
|
* @param id ID of the entity to find similar entities for
|
|
@@ -47,4 +51,10 @@ export interface BrainyDataInterface<T = unknown> {
|
|
|
47
51
|
findSimilar(id: string, options?: {
|
|
48
52
|
limit?: number;
|
|
49
53
|
}): Promise<unknown[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Generate embedding vector from text
|
|
56
|
+
* @param text The text to embed
|
|
57
|
+
* @returns Vector representation of the text
|
|
58
|
+
*/
|
|
59
|
+
embed(text: string): Promise<Vector>;
|
|
50
60
|
}
|
|
@@ -307,6 +307,42 @@ export interface Measurement extends GraphNoun {
|
|
|
307
307
|
export interface Content extends GraphNoun {
|
|
308
308
|
noun: typeof NounType.Content;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Represents a scientific hypothesis or theory in the graph
|
|
312
|
+
*/
|
|
313
|
+
export interface Hypothesis extends GraphNoun {
|
|
314
|
+
noun: typeof NounType.Hypothesis;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Represents an experiment, study, or research trial in the graph
|
|
318
|
+
*/
|
|
319
|
+
export interface Experiment extends GraphNoun {
|
|
320
|
+
noun: typeof NounType.Experiment;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Represents a legal contract or agreement in the graph
|
|
324
|
+
*/
|
|
325
|
+
export interface Contract extends GraphNoun {
|
|
326
|
+
noun: typeof NounType.Contract;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Represents a regulation, law, or compliance requirement in the graph
|
|
330
|
+
*/
|
|
331
|
+
export interface Regulation extends GraphNoun {
|
|
332
|
+
noun: typeof NounType.Regulation;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Represents an interface, API, or protocol specification in the graph
|
|
336
|
+
*/
|
|
337
|
+
export interface Interface extends GraphNoun {
|
|
338
|
+
noun: typeof NounType.Interface;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Represents a computational or infrastructure resource in the graph
|
|
342
|
+
*/
|
|
343
|
+
export interface Resource extends GraphNoun {
|
|
344
|
+
noun: typeof NounType.Resource;
|
|
345
|
+
}
|
|
310
346
|
/**
|
|
311
347
|
* Defines valid noun types for graph entities
|
|
312
348
|
* Used for categorizing different types of nodes
|
|
@@ -337,6 +373,12 @@ export declare const NounType: {
|
|
|
337
373
|
readonly Language: "language";
|
|
338
374
|
readonly Currency: "currency";
|
|
339
375
|
readonly Measurement: "measurement";
|
|
376
|
+
readonly Hypothesis: "hypothesis";
|
|
377
|
+
readonly Experiment: "experiment";
|
|
378
|
+
readonly Contract: "contract";
|
|
379
|
+
readonly Regulation: "regulation";
|
|
380
|
+
readonly Interface: "interface";
|
|
381
|
+
readonly Resource: "resource";
|
|
340
382
|
};
|
|
341
383
|
export type NounType = (typeof NounType)[keyof typeof NounType];
|
|
342
384
|
/**
|
|
@@ -380,6 +422,10 @@ export declare const VerbType: {
|
|
|
380
422
|
readonly Uses: "uses";
|
|
381
423
|
readonly Implements: "implements";
|
|
382
424
|
readonly Extends: "extends";
|
|
425
|
+
readonly Inherits: "inherits";
|
|
426
|
+
readonly Conflicts: "conflicts";
|
|
427
|
+
readonly Synchronizes: "synchronizes";
|
|
428
|
+
readonly Competes: "competes";
|
|
383
429
|
};
|
|
384
430
|
export type VerbType = (typeof VerbType)[keyof typeof VerbType];
|
|
385
431
|
export {};
|
package/dist/types/graphTypes.js
CHANGED
|
@@ -194,7 +194,16 @@ export const NounType = {
|
|
|
194
194
|
Topic: 'topic', // Subjects or themes
|
|
195
195
|
Language: 'language', // Languages or linguistic entities
|
|
196
196
|
Currency: 'currency', // Currencies and monetary units
|
|
197
|
-
Measurement: 'measurement' // Measurements, metrics, or quantities
|
|
197
|
+
Measurement: 'measurement', // Measurements, metrics, or quantities
|
|
198
|
+
// Scientific/Research Types (100% Coverage)
|
|
199
|
+
Hypothesis: 'hypothesis', // Scientific theories, research hypotheses, propositions
|
|
200
|
+
Experiment: 'experiment', // Controlled studies, trials, tests, research methodologies
|
|
201
|
+
// Legal/Regulatory Types (100% Coverage)
|
|
202
|
+
Contract: 'contract', // Legal agreements, terms, policies, binding documents
|
|
203
|
+
Regulation: 'regulation', // Laws, rules, compliance requirements, standards
|
|
204
|
+
// Technical Infrastructure Types (100% Coverage)
|
|
205
|
+
Interface: 'interface', // APIs, protocols, contracts, specifications, endpoints
|
|
206
|
+
Resource: 'resource' // Compute resources, bandwidth, storage, infrastructure assets
|
|
198
207
|
};
|
|
199
208
|
/**
|
|
200
209
|
* Defines valid verb types for relationships
|
|
@@ -242,6 +251,11 @@ export const VerbType = {
|
|
|
242
251
|
Evaluates: 'evaluates', // Evaluation or assessment relationship
|
|
243
252
|
Uses: 'uses', // Utilization relationship (new)
|
|
244
253
|
Implements: 'implements', // Implementation relationship
|
|
245
|
-
Extends: 'extends' // Extension relationship (
|
|
254
|
+
Extends: 'extends', // Extension relationship (enhancement, building upon)
|
|
255
|
+
// Enhanced Relationships (100% Coverage)
|
|
256
|
+
Inherits: 'inherits', // True inheritance relationship (class inheritance, legacy)
|
|
257
|
+
Conflicts: 'conflicts', // Contradictions, incompatibilities, opposing forces
|
|
258
|
+
Synchronizes: 'synchronizes', // Coordination, timing, synchronized operations
|
|
259
|
+
Competes: 'competes' // Competition, rivalry, competing relationships
|
|
246
260
|
};
|
|
247
261
|
//# sourceMappingURL=graphTypes.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded Registry with LRU eviction
|
|
3
|
+
* Prevents unbounded memory growth in production
|
|
4
|
+
*/
|
|
5
|
+
export declare class BoundedRegistry<T> {
|
|
6
|
+
private items;
|
|
7
|
+
private readonly maxSize;
|
|
8
|
+
constructor(maxSize?: number);
|
|
9
|
+
/**
|
|
10
|
+
* Add item to registry, evicting oldest if at capacity
|
|
11
|
+
*/
|
|
12
|
+
add(item: T): void;
|
|
13
|
+
/**
|
|
14
|
+
* Check if item exists
|
|
15
|
+
*/
|
|
16
|
+
has(item: T): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Get all items
|
|
19
|
+
*/
|
|
20
|
+
getAll(): T[];
|
|
21
|
+
/**
|
|
22
|
+
* Get size
|
|
23
|
+
*/
|
|
24
|
+
get size(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Clear all items
|
|
27
|
+
*/
|
|
28
|
+
clear(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded Registry with LRU eviction
|
|
3
|
+
* Prevents unbounded memory growth in production
|
|
4
|
+
*/
|
|
5
|
+
export class BoundedRegistry {
|
|
6
|
+
constructor(maxSize = 10000) {
|
|
7
|
+
this.items = new Map(); // item -> last accessed timestamp
|
|
8
|
+
this.maxSize = maxSize;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Add item to registry, evicting oldest if at capacity
|
|
12
|
+
*/
|
|
13
|
+
add(item) {
|
|
14
|
+
// Update timestamp if already exists
|
|
15
|
+
if (this.items.has(item)) {
|
|
16
|
+
this.items.delete(item); // Remove to re-add at end
|
|
17
|
+
this.items.set(item, Date.now());
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Evict oldest if at capacity
|
|
21
|
+
if (this.items.size >= this.maxSize) {
|
|
22
|
+
const oldest = this.items.entries().next().value;
|
|
23
|
+
if (oldest) {
|
|
24
|
+
this.items.delete(oldest[0]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
this.items.set(item, Date.now());
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if item exists
|
|
31
|
+
*/
|
|
32
|
+
has(item) {
|
|
33
|
+
return this.items.has(item);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get all items
|
|
37
|
+
*/
|
|
38
|
+
getAll() {
|
|
39
|
+
return Array.from(this.items.keys());
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get size
|
|
43
|
+
*/
|
|
44
|
+
get size() {
|
|
45
|
+
return this.items.size;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear all items
|
|
49
|
+
*/
|
|
50
|
+
clear() {
|
|
51
|
+
this.items.clear();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=BoundedRegistry.js.map
|