@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
package/CHANGELOG.md CHANGED
@@ -12,6 +12,15 @@ All notable changes to this project will be documented in this file. See [standa
12
12
  - Adds mutex-based concurrency control for mkdir operations
13
13
  - Adds explicit compression tracking for file reads
14
14
 
15
+ ### BREAKING CHANGES (Deprecated API Removal)
16
+
17
+ * **removed BrainyData**: The deprecated `BrainyData` class has been completely removed
18
+ - `BrainyData` was never part of the official Brainy 3.0 API
19
+ - All users should migrate to the `Brainy` class
20
+ - Migration is simple: Replace `new BrainyData()` with `new Brainy()` and add `await brain.init()`
21
+ - See `.strategy/NEURAL_API_RESPONSE.md` for complete migration guide
22
+ - Renamed `brainyDataInterface.ts` to `brainyInterface.ts` for clarity
23
+
15
24
  ### [3.19.1](https://github.com/soulcraftlabs/brainy/compare/v3.19.0...v3.19.1) (2025-09-29)
16
25
 
17
26
  ## [3.19.0](https://github.com/soulcraftlabs/brainy/compare/v3.18.0...v3.19.0) (2025-09-29)
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { program } from 'commander'
10
- import { BrainyData } from '../dist/brainyData.js'
10
+ import { Brainy } from '../dist/index.js'
11
11
  import chalk from 'chalk'
12
12
  import inquirer from 'inquirer'
13
13
  import ora from 'ora'
@@ -61,7 +61,7 @@ async function getBrainy() {
61
61
  if (!brainyInstance) {
62
62
  const spinner = ora('Initializing Brainy...').start()
63
63
  try {
64
- brainyInstance = new BrainyData()
64
+ brainyInstance = new Brainy()
65
65
  await brainyInstance.init()
66
66
  spinner.succeed('Brainy initialized')
67
67
  } catch (error) {
package/dist/brainy.d.ts CHANGED
@@ -12,7 +12,7 @@ import { TripleIntelligenceSystem } from './triple/TripleIntelligenceSystem.js';
12
12
  import { VirtualFileSystem } from './vfs/VirtualFileSystem.js';
13
13
  import { Entity, Relation, Result, AddParams, UpdateParams, RelateParams, FindParams, SimilarParams, GetRelationsParams, AddManyParams, DeleteManyParams, RelateManyParams, BatchResult, BrainyConfig } from './types/brainy.types.js';
14
14
  import { NounType } from './types/graphTypes.js';
15
- import { BrainyInterface } from './types/brainyDataInterface.js';
15
+ import { BrainyInterface } from './types/brainyInterface.js';
16
16
  /**
17
17
  * The main Brainy class - Clean, Beautiful, Powerful
18
18
  * REAL IMPLEMENTATION - No stubs, no mocks
@@ -5,7 +5,7 @@
5
5
  * It wraps a Brainy instance and exposes methods for getting vectors, searching similar items,
6
6
  * and getting relationships.
7
7
  */
8
- import { BrainyInterface } from '../types/brainyDataInterface.js';
8
+ import { BrainyInterface } from '../types/brainyInterface.js';
9
9
  import { MCPResponse, MCPDataAccessRequest } from '../types/mcpTypes.js';
10
10
  export declare class BrainyMCPAdapter {
11
11
  private brainyData;
@@ -6,7 +6,7 @@
6
6
  * MCPAugmentationToolset classes and provides WebSocket and REST server implementations
7
7
  * for external model access.
8
8
  */
9
- import { BrainyInterface } from '../types/brainyDataInterface.js';
9
+ import { BrainyInterface } from '../types/brainyInterface.js';
10
10
  import { MCPRequest, MCPResponse, MCPServiceOptions } from '../types/mcpTypes.js';
11
11
  export declare class BrainyMCPService {
12
12
  private dataAdapter;
@@ -2,7 +2,7 @@
2
2
  * 🧠 BRAINY EMBEDDED PATTERNS
3
3
  *
4
4
  * AUTO-GENERATED - DO NOT EDIT
5
- * Generated: 2025-09-29T17:05:30.153Z
5
+ * Generated: 2025-09-30T23:01:33.167Z
6
6
  * Patterns: 220
7
7
  * Coverage: 94-98% of all queries
8
8
  *
@@ -2,7 +2,7 @@
2
2
  * 🧠 BRAINY EMBEDDED PATTERNS
3
3
  *
4
4
  * AUTO-GENERATED - DO NOT EDIT
5
- * Generated: 2025-09-29T17:05:30.153Z
5
+ * Generated: 2025-09-30T23:01:33.167Z
6
6
  * Patterns: 220
7
7
  * Coverage: 94-98% of all queries
8
8
  *
@@ -4,7 +4,7 @@
4
4
  * 🧠⚛️ Pre-installed augmentations that come with every Brainy installation
5
5
  * These are the core "sensory organs" of the atomic age brain-in-jar system
6
6
  */
7
- import { BrainyInterface } from '../types/brainyDataInterface.js';
7
+ import { BrainyInterface } from '../types/brainyInterface.js';
8
8
  /**
9
9
  * Default augmentations that ship with Brainy
10
10
  * These are automatically registered on startup
@@ -7,4 +7,4 @@
7
7
  * NO DEPRECATED METHODS - Only clean, modern API patterns.
8
8
  */
9
9
  export {};
10
- //# sourceMappingURL=brainyDataInterface.js.map
10
+ //# sourceMappingURL=brainyInterface.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.20.2",
3
+ "version": "3.20.3",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,86 +0,0 @@
1
- /**
2
- * Augmentation Factory
3
- *
4
- * This module provides a simplified factory for creating augmentations with minimal boilerplate.
5
- * It reduces the complexity of creating and using augmentations by providing a fluent API
6
- * and handling common patterns automatically.
7
- */
8
- import { IAugmentation, AugmentationResponse, ISenseAugmentation, IConduitAugmentation, IMemoryAugmentation, IWebSocketSupport, WebSocketConnection } from './types/augmentations.js';
9
- /**
10
- * Options for creating an augmentation
11
- */
12
- export interface AugmentationOptions {
13
- name: string;
14
- description?: string;
15
- enabled?: boolean;
16
- autoRegister?: boolean;
17
- autoInitialize?: boolean;
18
- }
19
- /**
20
- * Factory for creating sense augmentations
21
- */
22
- export declare function createSenseAugmentation(options: AugmentationOptions & {
23
- processRawData?: (rawData: Buffer | string, dataType: string) => Promise<AugmentationResponse<{
24
- nouns: string[];
25
- verbs: string[];
26
- }>> | AugmentationResponse<{
27
- nouns: string[];
28
- verbs: string[];
29
- }>;
30
- listenToFeed?: (feedUrl: string, callback: (data: {
31
- nouns: string[];
32
- verbs: string[];
33
- }) => void) => Promise<void>;
34
- }): ISenseAugmentation;
35
- /**
36
- * Factory for creating conduit augmentations
37
- */
38
- export declare function createConduitAugmentation(options: AugmentationOptions & {
39
- establishConnection?: (targetSystemId: string, config: Record<string, unknown>) => Promise<AugmentationResponse<WebSocketConnection>> | AugmentationResponse<WebSocketConnection>;
40
- readData?: (query: Record<string, unknown>, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
41
- writeData?: (data: Record<string, unknown>, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
42
- monitorStream?: (streamId: string, callback: (data: unknown) => void) => Promise<void>;
43
- }): IConduitAugmentation;
44
- /**
45
- * Factory for creating memory augmentations
46
- */
47
- export declare function createMemoryAugmentation(options: AugmentationOptions & {
48
- storeData?: (key: string, data: unknown, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
49
- retrieveData?: (key: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
50
- updateData?: (key: string, data: unknown, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
51
- deleteData?: (key: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
52
- listDataKeys?: (pattern?: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<string[]>> | AugmentationResponse<string[]>;
53
- search?: (query: unknown, k?: number, options?: Record<string, unknown>) => Promise<AugmentationResponse<Array<{
54
- id: string;
55
- score: number;
56
- data: unknown;
57
- }>>> | AugmentationResponse<Array<{
58
- id: string;
59
- score: number;
60
- data: unknown;
61
- }>>;
62
- }): IMemoryAugmentation;
63
- /**
64
- * Factory for creating WebSocket-enabled augmentations
65
- * This can be combined with other augmentation factories to create WebSocket-enabled versions
66
- */
67
- export declare function addWebSocketSupport<T extends IAugmentation>(augmentation: T, options: {
68
- connectWebSocket?: (url: string, protocols?: string | string[]) => Promise<WebSocketConnection>;
69
- sendWebSocketMessage?: (connectionId: string, data: unknown) => Promise<void>;
70
- onWebSocketMessage?: (connectionId: string, callback: (data: unknown) => void) => Promise<void>;
71
- offWebSocketMessage?: (connectionId: string, callback: (data: unknown) => void) => Promise<void>;
72
- closeWebSocket?: (connectionId: string, code?: number, reason?: string) => Promise<void>;
73
- }): T & IWebSocketSupport;
74
- /**
75
- * Simplified function to execute an augmentation method with automatic error handling
76
- * This provides a more concise way to execute augmentation methods compared to the full pipeline
77
- */
78
- export declare function executeAugmentation<T, R>(augmentation: IAugmentation, method: string, ...args: any[]): Promise<AugmentationResponse<R>>;
79
- /**
80
- * Dynamically load augmentations from a module at runtime
81
- * This allows for lazy-loading augmentations when needed instead of at build time
82
- */
83
- export declare function loadAugmentationModule(modulePromise: Promise<any>, options?: {
84
- autoRegister?: boolean;
85
- autoInitialize?: boolean;
86
- }): Promise<IAugmentation[]>;
@@ -1,342 +0,0 @@
1
- /**
2
- * Augmentation Factory
3
- *
4
- * This module provides a simplified factory for creating augmentations with minimal boilerplate.
5
- * It reduces the complexity of creating and using augmentations by providing a fluent API
6
- * and handling common patterns automatically.
7
- */
8
- import { registerAugmentation } from './augmentationRegistry.js';
9
- /**
10
- * Base class for all augmentations created with the factory
11
- * Handles common functionality like initialization, shutdown, and status
12
- */
13
- class BaseAugmentation {
14
- constructor(options) {
15
- this.enabled = true;
16
- this.isInitialized = false;
17
- this.name = options.name;
18
- this.description = options.description || `${options.name} augmentation`;
19
- this.enabled = options.enabled !== false;
20
- }
21
- async initialize() {
22
- if (this.isInitialized)
23
- return;
24
- this.isInitialized = true;
25
- }
26
- async shutDown() {
27
- this.isInitialized = false;
28
- }
29
- async getStatus() {
30
- return this.isInitialized ? 'active' : 'inactive';
31
- }
32
- async ensureInitialized() {
33
- if (!this.isInitialized) {
34
- await this.initialize();
35
- }
36
- }
37
- }
38
- /**
39
- * Factory for creating sense augmentations
40
- */
41
- export function createSenseAugmentation(options) {
42
- const augmentation = new BaseAugmentation(options);
43
- // Implement the sense augmentation methods
44
- augmentation.processRawData = async (rawData, dataType) => {
45
- await augmentation.ensureInitialized();
46
- if (options.processRawData) {
47
- const result = options.processRawData(rawData, dataType);
48
- return result instanceof Promise ? await result : result;
49
- }
50
- return {
51
- success: false,
52
- data: { nouns: [], verbs: [] },
53
- error: 'processRawData not implemented'
54
- };
55
- };
56
- augmentation.listenToFeed = async (feedUrl, callback) => {
57
- await augmentation.ensureInitialized();
58
- if (options.listenToFeed) {
59
- return options.listenToFeed(feedUrl, callback);
60
- }
61
- throw new Error('listenToFeed not implemented');
62
- };
63
- // Auto-register if requested
64
- if (options.autoRegister) {
65
- registerAugmentation(augmentation);
66
- // Auto-initialize if requested
67
- if (options.autoInitialize) {
68
- augmentation.initialize().catch((error) => {
69
- console.error(`Failed to initialize augmentation ${augmentation.name}:`, error);
70
- });
71
- }
72
- }
73
- return augmentation;
74
- }
75
- /**
76
- * Factory for creating conduit augmentations
77
- */
78
- export function createConduitAugmentation(options) {
79
- const augmentation = new BaseAugmentation(options);
80
- // Implement the conduit augmentation methods
81
- augmentation.establishConnection = async (targetSystemId, config) => {
82
- await augmentation.ensureInitialized();
83
- if (options.establishConnection) {
84
- const result = options.establishConnection(targetSystemId, config);
85
- return result instanceof Promise ? await result : result;
86
- }
87
- return {
88
- success: false,
89
- data: null,
90
- error: 'establishConnection not implemented'
91
- };
92
- };
93
- augmentation.readData = async (query, opts) => {
94
- await augmentation.ensureInitialized();
95
- if (options.readData) {
96
- const result = options.readData(query, opts);
97
- return result instanceof Promise ? await result : result;
98
- }
99
- return {
100
- success: false,
101
- data: null,
102
- error: 'readData not implemented'
103
- };
104
- };
105
- augmentation.writeData = async (data, opts) => {
106
- await augmentation.ensureInitialized();
107
- if (options.writeData) {
108
- const result = options.writeData(data, opts);
109
- return result instanceof Promise ? await result : result;
110
- }
111
- return {
112
- success: false,
113
- data: null,
114
- error: 'writeData not implemented'
115
- };
116
- };
117
- augmentation.monitorStream = async (streamId, callback) => {
118
- await augmentation.ensureInitialized();
119
- if (options.monitorStream) {
120
- return options.monitorStream(streamId, callback);
121
- }
122
- throw new Error('monitorStream not implemented');
123
- };
124
- // Auto-register if requested
125
- if (options.autoRegister) {
126
- registerAugmentation(augmentation);
127
- // Auto-initialize if requested
128
- if (options.autoInitialize) {
129
- augmentation.initialize().catch((error) => {
130
- console.error(`Failed to initialize augmentation ${augmentation.name}:`, error);
131
- });
132
- }
133
- }
134
- return augmentation;
135
- }
136
- /**
137
- * Factory for creating memory augmentations
138
- */
139
- export function createMemoryAugmentation(options) {
140
- const augmentation = new BaseAugmentation(options);
141
- // Implement the memory augmentation methods
142
- augmentation.storeData = async (key, data, opts) => {
143
- await augmentation.ensureInitialized();
144
- if (options.storeData) {
145
- const result = options.storeData(key, data, opts);
146
- return result instanceof Promise ? await result : result;
147
- }
148
- return {
149
- success: false,
150
- data: false,
151
- error: 'storeData not implemented'
152
- };
153
- };
154
- augmentation.retrieveData = async (key, opts) => {
155
- await augmentation.ensureInitialized();
156
- if (options.retrieveData) {
157
- const result = options.retrieveData(key, opts);
158
- return result instanceof Promise ? await result : result;
159
- }
160
- return {
161
- success: false,
162
- data: null,
163
- error: 'retrieveData not implemented'
164
- };
165
- };
166
- augmentation.updateData = async (key, data, opts) => {
167
- await augmentation.ensureInitialized();
168
- if (options.updateData) {
169
- const result = options.updateData(key, data, opts);
170
- return result instanceof Promise ? await result : result;
171
- }
172
- return {
173
- success: false,
174
- data: false,
175
- error: 'updateData not implemented'
176
- };
177
- };
178
- augmentation.deleteData = async (key, opts) => {
179
- await augmentation.ensureInitialized();
180
- if (options.deleteData) {
181
- const result = options.deleteData(key, opts);
182
- return result instanceof Promise ? await result : result;
183
- }
184
- return {
185
- success: false,
186
- data: false,
187
- error: 'deleteData not implemented'
188
- };
189
- };
190
- augmentation.listDataKeys = async (pattern, opts) => {
191
- await augmentation.ensureInitialized();
192
- if (options.listDataKeys) {
193
- const result = options.listDataKeys(pattern, opts);
194
- return result instanceof Promise ? await result : result;
195
- }
196
- return {
197
- success: false,
198
- data: [],
199
- error: 'listDataKeys not implemented'
200
- };
201
- };
202
- augmentation.search = async (query, k, opts) => {
203
- await augmentation.ensureInitialized();
204
- if (options.search) {
205
- const result = options.search(query, k, opts);
206
- return result instanceof Promise ? await result : result;
207
- }
208
- return {
209
- success: false,
210
- data: [],
211
- error: 'search not implemented'
212
- };
213
- };
214
- // Auto-register if requested
215
- if (options.autoRegister) {
216
- registerAugmentation(augmentation);
217
- // Auto-initialize if requested
218
- if (options.autoInitialize) {
219
- augmentation.initialize().catch((error) => {
220
- console.error(`Failed to initialize augmentation ${augmentation.name}:`, error);
221
- });
222
- }
223
- }
224
- return augmentation;
225
- }
226
- /**
227
- * Factory for creating WebSocket-enabled augmentations
228
- * This can be combined with other augmentation factories to create WebSocket-enabled versions
229
- */
230
- export function addWebSocketSupport(augmentation, options) {
231
- const wsAugmentation = augmentation;
232
- // Add WebSocket methods
233
- wsAugmentation.connectWebSocket = async (url, protocols) => {
234
- await augmentation.ensureInitialized?.();
235
- if (options.connectWebSocket) {
236
- return options.connectWebSocket(url, protocols);
237
- }
238
- throw new Error('connectWebSocket not implemented');
239
- };
240
- wsAugmentation.sendWebSocketMessage = async (connectionId, data) => {
241
- await augmentation.ensureInitialized?.();
242
- if (options.sendWebSocketMessage) {
243
- return options.sendWebSocketMessage(connectionId, data);
244
- }
245
- throw new Error('sendWebSocketMessage not implemented');
246
- };
247
- wsAugmentation.onWebSocketMessage = async (connectionId, callback) => {
248
- await augmentation.ensureInitialized?.();
249
- if (options.onWebSocketMessage) {
250
- return options.onWebSocketMessage(connectionId, callback);
251
- }
252
- throw new Error('onWebSocketMessage not implemented');
253
- };
254
- wsAugmentation.offWebSocketMessage = async (connectionId, callback) => {
255
- await augmentation.ensureInitialized?.();
256
- if (options.offWebSocketMessage) {
257
- return options.offWebSocketMessage(connectionId, callback);
258
- }
259
- throw new Error('offWebSocketMessage not implemented');
260
- };
261
- wsAugmentation.closeWebSocket = async (connectionId, code, reason) => {
262
- await augmentation.ensureInitialized?.();
263
- if (options.closeWebSocket) {
264
- return options.closeWebSocket(connectionId, code, reason);
265
- }
266
- throw new Error('closeWebSocket not implemented');
267
- };
268
- return wsAugmentation;
269
- }
270
- /**
271
- * Simplified function to execute an augmentation method with automatic error handling
272
- * This provides a more concise way to execute augmentation methods compared to the full pipeline
273
- */
274
- export async function executeAugmentation(augmentation, method, ...args) {
275
- try {
276
- if (!augmentation.enabled) {
277
- return {
278
- success: false,
279
- data: null,
280
- error: `Augmentation ${augmentation.name} is disabled`
281
- };
282
- }
283
- if (typeof augmentation[method] !== 'function') {
284
- return {
285
- success: false,
286
- data: null,
287
- error: `Method ${method} not found on augmentation ${augmentation.name}`
288
- };
289
- }
290
- const result = await augmentation[method](...args);
291
- return result;
292
- }
293
- catch (error) {
294
- console.error(`Error executing ${method} on ${augmentation.name}:`, error);
295
- return {
296
- success: false,
297
- data: null,
298
- error: error instanceof Error ? error.message : String(error)
299
- };
300
- }
301
- }
302
- /**
303
- * Dynamically load augmentations from a module at runtime
304
- * This allows for lazy-loading augmentations when needed instead of at build time
305
- */
306
- export async function loadAugmentationModule(modulePromise, options = {}) {
307
- try {
308
- const module = await modulePromise;
309
- const augmentations = [];
310
- // Extract augmentations from the module
311
- for (const key in module) {
312
- const exported = module[key];
313
- // Skip non-objects and null
314
- if (!exported || typeof exported !== 'object') {
315
- continue;
316
- }
317
- // Check if it's an augmentation
318
- if (typeof exported.name === 'string' &&
319
- typeof exported.initialize === 'function' &&
320
- typeof exported.shutDown === 'function' &&
321
- typeof exported.getStatus === 'function') {
322
- augmentations.push(exported);
323
- // Auto-register if requested
324
- if (options.autoRegister) {
325
- registerAugmentation(exported);
326
- // Auto-initialize if requested
327
- if (options.autoInitialize) {
328
- exported.initialize().catch((error) => {
329
- console.error(`Failed to initialize augmentation ${exported.name}:`, error);
330
- });
331
- }
332
- }
333
- }
334
- }
335
- return augmentations;
336
- }
337
- catch (error) {
338
- console.error('Error loading augmentation module:', error);
339
- return [];
340
- }
341
- }
342
- //# sourceMappingURL=augmentationFactory.js.map
@@ -1,38 +0,0 @@
1
- /**
2
- * Augmentation Registry (Compatibility Layer)
3
- *
4
- * @deprecated This module provides backward compatibility for old augmentation
5
- * loading code. All new code should use the AugmentationRegistry class directly
6
- * on Brainy instances.
7
- */
8
- import { BrainyAugmentation } from './types/augmentations.js';
9
- /**
10
- * Registry of all available augmentations (for compatibility)
11
- * @deprecated Use brain.augmentations instead
12
- */
13
- export declare const availableAugmentations: any[];
14
- /**
15
- * Compatibility wrapper for registerAugmentation
16
- * @deprecated Use brain.augmentations.register instead
17
- */
18
- export declare function registerAugmentation<T extends BrainyAugmentation>(augmentation: T): T;
19
- /**
20
- * Sets the default pipeline instance (compatibility)
21
- * @deprecated Use brain.augmentations instead
22
- */
23
- export declare function setDefaultPipeline(pipeline: any): void;
24
- /**
25
- * Initializes the augmentation pipeline (compatibility)
26
- * @deprecated Use brain.augmentations instead
27
- */
28
- export declare function initializeAugmentationPipeline(pipelineInstance?: any): any;
29
- /**
30
- * Enables or disables an augmentation by name (compatibility)
31
- * @deprecated Use brain.augmentations instead
32
- */
33
- export declare function setAugmentationEnabled(name: string, enabled: boolean): boolean;
34
- /**
35
- * Gets all augmentations of a specific type (compatibility)
36
- * @deprecated Use brain.augmentations instead
37
- */
38
- export declare function getAugmentationsByType(type: any): any[];
@@ -1,54 +0,0 @@
1
- /**
2
- * Augmentation Registry (Compatibility Layer)
3
- *
4
- * @deprecated This module provides backward compatibility for old augmentation
5
- * loading code. All new code should use the AugmentationRegistry class directly
6
- * on Brainy instances.
7
- */
8
- /**
9
- * Registry of all available augmentations (for compatibility)
10
- * @deprecated Use brain.augmentations instead
11
- */
12
- export const availableAugmentations = [];
13
- /**
14
- * Compatibility wrapper for registerAugmentation
15
- * @deprecated Use brain.augmentations.register instead
16
- */
17
- export function registerAugmentation(augmentation) {
18
- console.warn('registerAugmentation is deprecated. Use brain.augmentations.register instead.');
19
- // For compatibility, just add to the list (but it won't actually do anything)
20
- availableAugmentations.push(augmentation);
21
- return augmentation;
22
- }
23
- /**
24
- * Sets the default pipeline instance (compatibility)
25
- * @deprecated Use brain.augmentations instead
26
- */
27
- export function setDefaultPipeline(pipeline) {
28
- console.warn('setDefaultPipeline is deprecated. Use brain.augmentations instead.');
29
- }
30
- /**
31
- * Initializes the augmentation pipeline (compatibility)
32
- * @deprecated Use brain.augmentations instead
33
- */
34
- export function initializeAugmentationPipeline(pipelineInstance) {
35
- console.warn('initializeAugmentationPipeline is deprecated. Use brain.augmentations instead.');
36
- return pipelineInstance || {};
37
- }
38
- /**
39
- * Enables or disables an augmentation by name (compatibility)
40
- * @deprecated Use brain.augmentations instead
41
- */
42
- export function setAugmentationEnabled(name, enabled) {
43
- console.warn('setAugmentationEnabled is deprecated. Use brain.augmentations instead.');
44
- return false;
45
- }
46
- /**
47
- * Gets all augmentations of a specific type (compatibility)
48
- * @deprecated Use brain.augmentations instead
49
- */
50
- export function getAugmentationsByType(type) {
51
- console.warn('getAugmentationsByType is deprecated. Use brain.augmentations instead.');
52
- return [];
53
- }
54
- //# sourceMappingURL=augmentationRegistry.js.map