@soulcraft/brainy 3.20.2 → 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.
Files changed (89) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/bin/brainy-interactive.js +2 -2
  3. package/dist/brainy.d.ts +1 -1
  4. package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
  5. package/dist/mcp/brainyMCPService.d.ts +1 -1
  6. package/dist/neural/embeddedPatterns.d.ts +1 -1
  7. package/dist/neural/embeddedPatterns.js +1 -1
  8. package/dist/shared/default-augmentations.d.ts +1 -1
  9. package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
  10. package/package.json +1 -1
  11. package/dist/augmentationFactory.d.ts +0 -86
  12. package/dist/augmentationFactory.js +0 -342
  13. package/dist/augmentationRegistry.d.ts +0 -38
  14. package/dist/augmentationRegistry.js +0 -54
  15. package/dist/augmentationRegistryLoader.d.ts +0 -146
  16. package/dist/augmentationRegistryLoader.js +0 -213
  17. package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
  18. package/dist/augmentations/KnowledgeAugmentation.js +0 -251
  19. package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
  20. package/dist/augmentations/intelligentVerbScoring.js +0 -377
  21. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
  22. package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
  23. package/dist/augmentations/marketplace/cli.d.ts +0 -47
  24. package/dist/augmentations/marketplace/cli.js +0 -265
  25. package/dist/augmentations/memoryAugmentations.d.ts +0 -72
  26. package/dist/augmentations/memoryAugmentations.js +0 -280
  27. package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
  28. package/dist/augmentations/serverSearchAugmentations.js +0 -586
  29. package/dist/brainy-unified.d.ts +0 -106
  30. package/dist/brainy-unified.js +0 -327
  31. package/dist/brainyData.d.ts +0 -1832
  32. package/dist/brainyData.js +0 -6443
  33. package/dist/brainyDataV3.d.ts +0 -186
  34. package/dist/brainyDataV3.js +0 -337
  35. package/dist/config/distributedPresets-new.d.ts +0 -118
  36. package/dist/config/distributedPresets-new.js +0 -318
  37. package/dist/config/modelPrecisionManager.d.ts +0 -42
  38. package/dist/config/modelPrecisionManager.js +0 -98
  39. package/dist/connectors/interfaces/IConnector.d.ts +0 -143
  40. package/dist/connectors/interfaces/IConnector.js +0 -8
  41. package/dist/demo.d.ts +0 -106
  42. package/dist/demo.js +0 -201
  43. package/dist/embeddings/SingletonModelManager.d.ts +0 -95
  44. package/dist/embeddings/SingletonModelManager.js +0 -220
  45. package/dist/embeddings/lightweight-embedder.d.ts +0 -22
  46. package/dist/embeddings/lightweight-embedder.js +0 -128
  47. package/dist/embeddings/model-manager.d.ts +0 -39
  48. package/dist/embeddings/model-manager.js +0 -245
  49. package/dist/embeddings/universal-memory-manager.d.ts +0 -38
  50. package/dist/embeddings/universal-memory-manager.js +0 -166
  51. package/dist/embeddings/worker-embedding.d.ts +0 -7
  52. package/dist/embeddings/worker-embedding.js +0 -73
  53. package/dist/embeddings/worker-manager.d.ts +0 -28
  54. package/dist/embeddings/worker-manager.js +0 -162
  55. package/dist/examples/basicUsage.d.ts +0 -4
  56. package/dist/examples/basicUsage.js +0 -121
  57. package/dist/indices/fieldIndex.d.ts +0 -76
  58. package/dist/indices/fieldIndex.js +0 -357
  59. package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
  60. package/dist/mcp/brainyMCPBroadcast.js +0 -303
  61. package/dist/mcp/brainyMCPClient.d.ts +0 -92
  62. package/dist/mcp/brainyMCPClient.js +0 -258
  63. package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
  64. package/dist/scripts/precomputePatternEmbeddings.js +0 -100
  65. package/dist/utils/cacheAutoConfig.d.ts +0 -63
  66. package/dist/utils/cacheAutoConfig.js +0 -261
  67. package/dist/utils/hybridModelManager.d.ts +0 -64
  68. package/dist/utils/hybridModelManager.js +0 -95
  69. package/dist/utils/statistics.d.ts +0 -28
  70. package/dist/utils/statistics.js +0 -25
  71. package/dist/vfs/ConceptSystem.d.ts +0 -203
  72. package/dist/vfs/ConceptSystem.js +0 -545
  73. package/dist/vfs/EntityManager.d.ts +0 -75
  74. package/dist/vfs/EntityManager.js +0 -216
  75. package/dist/vfs/EventRecorder.d.ts +0 -84
  76. package/dist/vfs/EventRecorder.js +0 -269
  77. package/dist/vfs/GitBridge.d.ts +0 -167
  78. package/dist/vfs/GitBridge.js +0 -537
  79. package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
  80. package/dist/vfs/KnowledgeAugmentation.js +0 -146
  81. package/dist/vfs/KnowledgeLayer.d.ts +0 -35
  82. package/dist/vfs/KnowledgeLayer.js +0 -443
  83. package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
  84. package/dist/vfs/PersistentEntitySystem.js +0 -503
  85. package/dist/vfs/SemanticVersioning.d.ts +0 -105
  86. package/dist/vfs/SemanticVersioning.js +0 -309
  87. package/dist/vfs/VFSHealthCheck.d.ts +0 -78
  88. package/dist/vfs/VFSHealthCheck.js +0 -299
  89. /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
@@ -1,357 +0,0 @@
1
- /**
2
- * Field Index for efficient field-based queries
3
- * Provides O(log n) lookups for field values and range queries
4
- */
5
- export class FieldIndex {
6
- constructor() {
7
- // Inverted index: field -> value -> noun IDs
8
- this.indices = new Map();
9
- // Sorted arrays for range queries: field -> sorted [value, ids] pairs
10
- this.sortedIndices = new Map();
11
- // Track which fields are indexed
12
- this.indexedFields = new Set();
13
- }
14
- /**
15
- * Add a document to the field index
16
- */
17
- add(id, metadata) {
18
- if (!metadata)
19
- return;
20
- for (const [field, value] of Object.entries(metadata)) {
21
- // Skip null/undefined values
22
- if (value === null || value === undefined)
23
- continue;
24
- // Get or create field index
25
- if (!this.indices.has(field)) {
26
- this.indices.set(field, new Map());
27
- this.sortedIndices.set(field, []);
28
- this.indexedFields.add(field);
29
- }
30
- const fieldIndex = this.indices.get(field);
31
- // Get or create value set
32
- if (!fieldIndex.has(value)) {
33
- fieldIndex.set(value, new Set());
34
- }
35
- // Add ID to value set
36
- fieldIndex.get(value).add(id);
37
- // Mark sorted index as dirty (needs rebuild)
38
- this.markSortedIndexDirty(field);
39
- }
40
- }
41
- /**
42
- * Remove a document from the field index
43
- */
44
- remove(id, metadata) {
45
- if (!metadata)
46
- return;
47
- for (const [field, value] of Object.entries(metadata)) {
48
- if (value === null || value === undefined)
49
- continue;
50
- const fieldIndex = this.indices.get(field);
51
- if (!fieldIndex)
52
- continue;
53
- const valueSet = fieldIndex.get(value);
54
- if (!valueSet)
55
- continue;
56
- valueSet.delete(id);
57
- // Clean up empty sets
58
- if (valueSet.size === 0) {
59
- fieldIndex.delete(value);
60
- this.markSortedIndexDirty(field);
61
- }
62
- // Clean up empty field indices
63
- if (fieldIndex.size === 0) {
64
- this.indices.delete(field);
65
- this.sortedIndices.delete(field);
66
- this.indexedFields.delete(field);
67
- }
68
- }
69
- }
70
- /**
71
- * Query for exact field value match
72
- * O(1) hash lookup
73
- */
74
- queryExact(field, value) {
75
- const fieldIndex = this.indices.get(field);
76
- if (!fieldIndex)
77
- return [];
78
- const ids = fieldIndex.get(value);
79
- return ids ? Array.from(ids) : [];
80
- }
81
- /**
82
- * Query for multiple values (IN operator)
83
- * O(k) where k is number of values
84
- */
85
- queryIn(field, values) {
86
- const fieldIndex = this.indices.get(field);
87
- if (!fieldIndex)
88
- return [];
89
- const resultSet = new Set();
90
- for (const value of values) {
91
- const ids = fieldIndex.get(value);
92
- if (ids) {
93
- for (const id of ids) {
94
- resultSet.add(id);
95
- }
96
- }
97
- }
98
- return Array.from(resultSet);
99
- }
100
- /**
101
- * Query for range of values
102
- * O(log n + m) where m is number of results
103
- */
104
- queryRange(options) {
105
- const { field, min, max, includeMin = true, includeMax = true } = options;
106
- // Ensure sorted index is up to date
107
- this.ensureSortedIndex(field);
108
- const sortedIndex = this.sortedIndices.get(field);
109
- if (!sortedIndex || sortedIndex.length === 0)
110
- return [];
111
- const resultSet = new Set();
112
- // Binary search for start position
113
- let start = 0;
114
- let end = sortedIndex.length - 1;
115
- if (min !== undefined) {
116
- start = this.binarySearch(sortedIndex, min, includeMin);
117
- }
118
- if (max !== undefined) {
119
- end = this.binarySearchEnd(sortedIndex, max, includeMax);
120
- }
121
- // Collect all IDs in range
122
- for (let i = start; i <= end && i < sortedIndex.length; i++) {
123
- const [value, ids] = sortedIndex[i];
124
- // Check if value is in range
125
- if (min !== undefined) {
126
- const minCheck = includeMin ? value >= min : value > min;
127
- if (!minCheck)
128
- continue;
129
- }
130
- if (max !== undefined) {
131
- const maxCheck = includeMax ? value <= max : value < max;
132
- if (!maxCheck)
133
- break;
134
- }
135
- for (const id of ids) {
136
- resultSet.add(id);
137
- }
138
- }
139
- return Array.from(resultSet);
140
- }
141
- /**
142
- * Query with complex where clause
143
- */
144
- query(where) {
145
- const resultSets = [];
146
- for (const [field, condition] of Object.entries(where)) {
147
- let fieldResults = [];
148
- if (typeof condition === 'object' && condition !== null) {
149
- // Handle operators
150
- if (condition.equals !== undefined) {
151
- fieldResults = this.queryExact(field, condition.equals);
152
- }
153
- else if (condition.in !== undefined && Array.isArray(condition.in)) {
154
- fieldResults = this.queryIn(field, condition.in);
155
- }
156
- else if (condition.greaterThan !== undefined || condition.lessThan !== undefined) {
157
- fieldResults = this.queryRange({
158
- field,
159
- min: condition.greaterThan,
160
- max: condition.lessThan,
161
- includeMin: false,
162
- includeMax: false
163
- });
164
- }
165
- else if (condition.greaterEqual !== undefined || condition.lessEqual !== undefined) {
166
- fieldResults = this.queryRange({
167
- field,
168
- min: condition.greaterEqual,
169
- max: condition.lessEqual,
170
- includeMin: true,
171
- includeMax: true
172
- });
173
- }
174
- else if (condition.between !== undefined && Array.isArray(condition.between)) {
175
- fieldResults = this.queryRange({
176
- field,
177
- min: condition.between[0],
178
- max: condition.between[1],
179
- includeMin: true,
180
- includeMax: true
181
- });
182
- }
183
- else if (condition.exists !== undefined) {
184
- // Return all IDs that have this field
185
- if (condition.exists) {
186
- const fieldIndex = this.indices.get(field);
187
- if (fieldIndex) {
188
- const allIds = new Set();
189
- for (const ids of fieldIndex.values()) {
190
- for (const id of ids) {
191
- allIds.add(id);
192
- }
193
- }
194
- fieldResults = Array.from(allIds);
195
- }
196
- }
197
- }
198
- }
199
- else {
200
- // Direct value match
201
- fieldResults = this.queryExact(field, condition);
202
- }
203
- if (fieldResults.length > 0) {
204
- resultSets.push(new Set(fieldResults));
205
- }
206
- else {
207
- // If any field has no matches, intersection will be empty
208
- return [];
209
- }
210
- }
211
- // Intersect all result sets (AND operation)
212
- if (resultSets.length === 0)
213
- return [];
214
- if (resultSets.length === 1)
215
- return Array.from(resultSets[0]);
216
- let intersection = resultSets[0];
217
- for (let i = 1; i < resultSets.length; i++) {
218
- const nextSet = resultSets[i];
219
- const newIntersection = new Set();
220
- // Use smaller set for iteration (optimization)
221
- const [smaller, larger] = intersection.size <= nextSet.size
222
- ? [intersection, nextSet]
223
- : [nextSet, intersection];
224
- for (const id of smaller) {
225
- if (larger.has(id)) {
226
- newIntersection.add(id);
227
- }
228
- }
229
- intersection = newIntersection;
230
- // Early exit if intersection is empty
231
- if (intersection.size === 0)
232
- return [];
233
- }
234
- return Array.from(intersection);
235
- }
236
- /**
237
- * Mark sorted index as needing rebuild
238
- */
239
- markSortedIndexDirty(field) {
240
- // For now, we'll rebuild on demand
241
- // Could optimize with a dirty flag if needed
242
- }
243
- /**
244
- * Ensure sorted index is up to date for a field
245
- */
246
- ensureSortedIndex(field) {
247
- const fieldIndex = this.indices.get(field);
248
- if (!fieldIndex)
249
- return;
250
- // Rebuild sorted index from hash index
251
- const sorted = [];
252
- for (const [value, ids] of fieldIndex.entries()) {
253
- sorted.push([value, ids]);
254
- }
255
- // Sort by value (handles numbers, strings, dates)
256
- sorted.sort((a, b) => {
257
- const aVal = a[0];
258
- const bVal = b[0];
259
- if (aVal < bVal)
260
- return -1;
261
- if (aVal > bVal)
262
- return 1;
263
- return 0;
264
- });
265
- this.sortedIndices.set(field, sorted);
266
- }
267
- /**
268
- * Binary search for start position (inclusive)
269
- */
270
- binarySearch(sorted, target, inclusive) {
271
- let left = 0;
272
- let right = sorted.length - 1;
273
- let result = sorted.length;
274
- while (left <= right) {
275
- const mid = Math.floor((left + right) / 2);
276
- const midVal = sorted[mid][0];
277
- if (inclusive ? midVal >= target : midVal > target) {
278
- result = mid;
279
- right = mid - 1;
280
- }
281
- else {
282
- left = mid + 1;
283
- }
284
- }
285
- return result;
286
- }
287
- /**
288
- * Binary search for end position (inclusive)
289
- */
290
- binarySearchEnd(sorted, target, inclusive) {
291
- let left = 0;
292
- let right = sorted.length - 1;
293
- let result = -1;
294
- while (left <= right) {
295
- const mid = Math.floor((left + right) / 2);
296
- const midVal = sorted[mid][0];
297
- if (inclusive ? midVal <= target : midVal < target) {
298
- result = mid;
299
- left = mid + 1;
300
- }
301
- else {
302
- right = mid - 1;
303
- }
304
- }
305
- return result;
306
- }
307
- /**
308
- * Debug method to inspect index contents
309
- */
310
- debugIndex(field) {
311
- if (field) {
312
- const fieldIndex = this.indices.get(field);
313
- if (!fieldIndex)
314
- return { error: 'Field not found', field };
315
- const values = [];
316
- for (const [value, ids] of fieldIndex.entries()) {
317
- values.push({ value, type: typeof value, ids: Array.from(ids) });
318
- }
319
- return { field, values };
320
- }
321
- const allFields = {};
322
- for (const [field, fieldIndex] of this.indices.entries()) {
323
- allFields[field] = [];
324
- for (const [value, ids] of fieldIndex.entries()) {
325
- allFields[field].push({ value, type: typeof value, ids: Array.from(ids) });
326
- }
327
- }
328
- return allFields;
329
- }
330
- /**
331
- * Get statistics about the index
332
- */
333
- getStats() {
334
- let totalValues = 0;
335
- let totalMappings = 0;
336
- for (const fieldIndex of this.indices.values()) {
337
- totalValues += fieldIndex.size;
338
- for (const ids of fieldIndex.values()) {
339
- totalMappings += ids.size;
340
- }
341
- }
342
- return {
343
- indexedFields: this.indexedFields.size,
344
- totalValues,
345
- totalMappings
346
- };
347
- }
348
- /**
349
- * Clear all indices
350
- */
351
- clear() {
352
- this.indices.clear();
353
- this.sortedIndices.clear();
354
- this.indexedFields.clear();
355
- }
356
- }
357
- //# sourceMappingURL=fieldIndex.js.map
@@ -1,82 +0,0 @@
1
- /**
2
- * BrainyMCPBroadcast
3
- *
4
- * Enhanced MCP service with real-time WebSocket broadcasting capabilities
5
- * for multi-agent coordination (Jarvis ↔ Picasso communication)
6
- *
7
- * Features:
8
- * - WebSocket server for real-time push notifications
9
- * - Subscription management for multiple Claude instances
10
- * - Message broadcasting to all connected agents
11
- * - Works both locally and with cloud deployment
12
- */
13
- import { BrainyMCPService } from './brainyMCPService.js';
14
- import { BrainyInterface } from '../types/brainyDataInterface.js';
15
- import { MCPServiceOptions } from '../types/mcpTypes.js';
16
- interface BroadcastMessage {
17
- id: string;
18
- from: string;
19
- to?: string | string[];
20
- type: 'message' | 'notification' | 'sync' | 'heartbeat' | 'identify';
21
- event?: string;
22
- data: any;
23
- timestamp: number;
24
- }
25
- export declare class BrainyMCPBroadcast extends BrainyMCPService {
26
- private wsServer?;
27
- private httpServer?;
28
- private agents;
29
- private messageHistory;
30
- private maxHistorySize;
31
- constructor(brainyData: BrainyInterface, options?: MCPServiceOptions & {
32
- broadcastPort?: number;
33
- cloudUrl?: string;
34
- });
35
- /**
36
- * Start the WebSocket broadcast server
37
- * @param port Port to listen on (default: 8765)
38
- * @param isCloud Whether this is a cloud deployment
39
- */
40
- startBroadcastServer(port?: number, isCloud?: boolean): Promise<void>;
41
- /**
42
- * Handle new WebSocket connection
43
- */
44
- private handleNewConnection;
45
- /**
46
- * Handle message from an agent
47
- */
48
- private handleAgentMessage;
49
- /**
50
- * Broadcast message to all connected agents
51
- */
52
- broadcast(message: BroadcastMessage, excludeId?: string): void;
53
- /**
54
- * Send message to specific agent
55
- */
56
- private sendToAgent;
57
- /**
58
- * Remove agent from connected list
59
- */
60
- private removeAgent;
61
- /**
62
- * Add message to history
63
- */
64
- private addToHistory;
65
- /**
66
- * Stop the broadcast server
67
- */
68
- stopBroadcastServer(): Promise<void>;
69
- /**
70
- * Get connected agents
71
- */
72
- getConnectedAgents(): Array<{
73
- id: string;
74
- name: string;
75
- role: string;
76
- }>;
77
- /**
78
- * Get message history
79
- */
80
- getMessageHistory(): BroadcastMessage[];
81
- }
82
- export default BrainyMCPBroadcast;