From a22fd7de775a487854aa899a96acb450cb2cfc37 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Tue, 27 May 2025 13:13:04 -0700 Subject: [PATCH] feat: add memory and WebSocket augmentation examples with configuration files --- .idea/brainy.iml | 11 + .idea/jsLibraryMappings.xml | 7 + .idea/material_theme_project_new.xml | 17 + .idea/misc.xml | 9 + .idea/modules.xml | 8 + .idea/typescript-compiler.xml | 8 + .idea/vcs.xml | 6 + src/examples/memoryAugmentation.ts | 755 ++++++++++++++++++++++++++ src/examples/webSocketAugmentation.ts | 210 +++++++ 9 files changed, 1031 insertions(+) create mode 100644 .idea/brainy.iml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/material_theme_project_new.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/typescript-compiler.xml create mode 100644 .idea/vcs.xml create mode 100644 src/examples/memoryAugmentation.ts create mode 100644 src/examples/webSocketAugmentation.ts diff --git a/.idea/brainy.iml b/.idea/brainy.iml new file mode 100644 index 00000000..53815b20 --- /dev/null +++ b/.idea/brainy.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 00000000..bc5a8d4f --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 00000000..4bc91b71 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..3add60e4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..0b9a2e1f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/typescript-compiler.xml b/.idea/typescript-compiler.xml new file mode 100644 index 00000000..4f42f93b --- /dev/null +++ b/.idea/typescript-compiler.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/examples/memoryAugmentation.ts b/src/examples/memoryAugmentation.ts new file mode 100644 index 00000000..250b0d38 --- /dev/null +++ b/src/examples/memoryAugmentation.ts @@ -0,0 +1,755 @@ +/** + * Memory Augmentation Example + * + * This example demonstrates how to create and register memory augmentations + * for storing data in different formats (e.g., fileSystem, in memory, or firestore). + */ + +import { + augmentationPipeline, + IAugmentation, + IWebSocketSupport, + IWebSocketMemoryAugmentation, + AugmentationResponse, + BrainyAugmentations, + ExecutionMode +} from '../index.js' + +/** + * Example In-Memory Augmentation + * + * This augmentation stores data in memory using a JavaScript Map. + */ +class InMemoryAugmentation implements BrainyAugmentations.IMemoryAugmentation { + readonly name = 'in-memory-storage' + readonly description = 'A simple in-memory storage augmentation' + + private storage: Map = new Map() + + async initialize(): Promise { + console.log('Initializing InMemoryAugmentation') + } + + async shutDown(): Promise { + console.log('Shutting down InMemoryAugmentation') + this.storage.clear() + } + + async getStatus(): Promise<'active' | 'inactive' | 'error'> { + return 'active' + } + + async storeData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`Storing data with key: ${key}`) + try { + this.storage.set(key, data) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async retrieveData( + key: string, + options?: Record + ): Promise> { + console.log(`Retrieving data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: null, + error: `Key not found: ${key}` + } + } + + return { + success: true, + data: this.storage.get(key) + } + } catch (error) { + return { + success: false, + data: null, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async updateData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`Updating data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `Key not found: ${key}` + } + } + + this.storage.set(key, data) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async deleteData( + key: string, + options?: Record + ): Promise> { + console.log(`Deleting data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `Key not found: ${key}` + } + } + + this.storage.delete(key) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async listDataKeys( + pattern?: string, + options?: Record + ): Promise> { + console.log(`Listing data keys with pattern: ${pattern || 'all'}`) + try { + const keys = Array.from(this.storage.keys()) + + // Filter keys by pattern if provided + const filteredKeys = pattern + ? keys.filter(key => key.includes(pattern)) + : keys + + return { + success: true, + data: filteredKeys + } + } catch (error) { + return { + success: false, + data: [], + error: error instanceof Error ? error.message : String(error) + } + } + } +} + +/** + * Example File System Memory Augmentation + * + * This augmentation simulates storing data in the file system. + */ +class FileSystemMemoryAugmentation implements BrainyAugmentations.IMemoryAugmentation { + readonly name = 'file-system-storage' + readonly description = 'A file system storage augmentation' + + private storage: Map = new Map() + + async initialize(): Promise { + console.log('Initializing FileSystemMemoryAugmentation') + console.log('Simulating file system initialization...') + } + + async shutDown(): Promise { + console.log('Shutting down FileSystemMemoryAugmentation') + console.log('Simulating file system cleanup...') + this.storage.clear() + } + + async getStatus(): Promise<'active' | 'inactive' | 'error'> { + return 'active' + } + + async storeData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`Storing data in file system with key: ${key}`) + try { + // Simulate file system operations + console.log(`Writing to file: ${key}.json`) + this.storage.set(key, data) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async retrieveData( + key: string, + options?: Record + ): Promise> { + console.log(`Retrieving data from file system with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: null, + error: `File not found: ${key}.json` + } + } + + // Simulate file system operations + console.log(`Reading from file: ${key}.json`) + return { + success: true, + data: this.storage.get(key) + } + } catch (error) { + return { + success: false, + data: null, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async updateData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`Updating data in file system with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `File not found: ${key}.json` + } + } + + // Simulate file system operations + console.log(`Updating file: ${key}.json`) + this.storage.set(key, data) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async deleteData( + key: string, + options?: Record + ): Promise> { + console.log(`Deleting data from file system with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `File not found: ${key}.json` + } + } + + // Simulate file system operations + console.log(`Deleting file: ${key}.json`) + this.storage.delete(key) + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async listDataKeys( + pattern?: string, + options?: Record + ): Promise> { + console.log(`Listing data keys from file system with pattern: ${pattern || 'all'}`) + try { + // Simulate file system operations + console.log('Reading directory contents...') + const keys = Array.from(this.storage.keys()) + + // Filter keys by pattern if provided + const filteredKeys = pattern + ? keys.filter(key => key.includes(pattern)) + : keys + + return { + success: true, + data: filteredKeys + } + } catch (error) { + return { + success: false, + data: [], + error: error instanceof Error ? error.message : String(error) + } + } + } +} + +/** + * Example Combined WebSocket and Memory Augmentation + * + * This augmentation implements both WebSocket and Memory interfaces. + */ +class WebSocketMemoryAugmentation implements IWebSocketMemoryAugmentation { + readonly name = 'websocket-memory-storage' + readonly description = 'A combined WebSocket and Memory storage augmentation' + + private storage: Map = new Map() + private connections: Map = new Map() + + async initialize(): Promise { + console.log('Initializing WebSocketMemoryAugmentation') + } + + async shutDown(): Promise { + console.log('Shutting down WebSocketMemoryAugmentation') + this.storage.clear() + this.connections.clear() + } + + async getStatus(): Promise<'active' | 'inactive' | 'error'> { + return 'active' + } + + // WebSocket methods + async connectWebSocket(url: string, protocols?: string | string[]): Promise<{ + connectionId: string; + url: string; + status: 'connected' | 'disconnected' | 'error' + }> { + console.log(`WebSocketMemory connecting to WebSocket at ${url}`) + const connectionId = `ws-memory-${Date.now()}` + this.connections.set(connectionId, { url, status: 'connected' }) + return { + connectionId, + url, + status: 'connected' + } + } + + async sendWebSocketMessage(connectionId: string, data: unknown): Promise { + console.log(`WebSocketMemory sending message to WebSocket ${connectionId}:`, data) + if (!this.connections.has(connectionId)) { + throw new Error(`Connection not found: ${connectionId}`) + } + } + + async onWebSocketMessage(connectionId: string, callback: (data: unknown) => void): Promise { + console.log(`WebSocketMemory registering callback for WebSocket ${connectionId}`) + if (!this.connections.has(connectionId)) { + throw new Error(`Connection not found: ${connectionId}`) + } + } + + async closeWebSocket(connectionId: string, code?: number, reason?: string): Promise { + console.log(`WebSocketMemory closing WebSocket ${connectionId}`) + if (!this.connections.has(connectionId)) { + throw new Error(`Connection not found: ${connectionId}`) + } + this.connections.delete(connectionId) + } + + // Memory methods + async storeData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`WebSocketMemory storing data with key: ${key}`) + try { + this.storage.set(key, data) + + // If a WebSocket connection is specified in options, send the data through it + const connectionId = options?.connectionId as string + if (connectionId && this.connections.has(connectionId)) { + await this.sendWebSocketMessage(connectionId, { + action: 'store', + key, + data + }) + } + + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async retrieveData( + key: string, + options?: Record + ): Promise> { + console.log(`WebSocketMemory retrieving data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: null, + error: `Key not found: ${key}` + } + } + + const data = this.storage.get(key) + + // If a WebSocket connection is specified in options, send the request through it + const connectionId = options?.connectionId as string + if (connectionId && this.connections.has(connectionId)) { + await this.sendWebSocketMessage(connectionId, { + action: 'retrieve', + key + }) + } + + return { + success: true, + data + } + } catch (error) { + return { + success: false, + data: null, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async updateData( + key: string, + data: unknown, + options?: Record + ): Promise> { + console.log(`WebSocketMemory updating data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `Key not found: ${key}` + } + } + + this.storage.set(key, data) + + // If a WebSocket connection is specified in options, send the update through it + const connectionId = options?.connectionId as string + if (connectionId && this.connections.has(connectionId)) { + await this.sendWebSocketMessage(connectionId, { + action: 'update', + key, + data + }) + } + + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async deleteData( + key: string, + options?: Record + ): Promise> { + console.log(`WebSocketMemory deleting data with key: ${key}`) + try { + if (!this.storage.has(key)) { + return { + success: false, + data: false, + error: `Key not found: ${key}` + } + } + + this.storage.delete(key) + + // If a WebSocket connection is specified in options, send the delete request through it + const connectionId = options?.connectionId as string + if (connectionId && this.connections.has(connectionId)) { + await this.sendWebSocketMessage(connectionId, { + action: 'delete', + key + }) + } + + return { + success: true, + data: true + } + } catch (error) { + return { + success: false, + data: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + async listDataKeys( + pattern?: string, + options?: Record + ): Promise> { + console.log(`WebSocketMemory listing data keys with pattern: ${pattern || 'all'}`) + try { + const keys = Array.from(this.storage.keys()) + + // Filter keys by pattern if provided + const filteredKeys = pattern + ? keys.filter(key => key.includes(pattern)) + : keys + + // If a WebSocket connection is specified in options, send the list request through it + const connectionId = options?.connectionId as string + if (connectionId && this.connections.has(connectionId)) { + await this.sendWebSocketMessage(connectionId, { + action: 'list', + pattern + }) + } + + return { + success: true, + data: filteredKeys + } + } catch (error) { + return { + success: false, + data: [], + error: error instanceof Error ? error.message : String(error) + } + } + } +} + +/** + * Main function to demonstrate the memory augmentation + */ +async function main() { + try { + console.log('=== Memory Augmentation Example ===') + + // Create augmentation instances + const inMemoryStorage = new InMemoryAugmentation() + const fileSystemStorage = new FileSystemMemoryAugmentation() + const webSocketMemory = new WebSocketMemoryAugmentation() + + // Register augmentations with the pipeline + augmentationPipeline + .register(inMemoryStorage) + .register(fileSystemStorage) + .register(webSocketMemory) + + // Initialize all registered augmentations + console.log('\n=== Initializing Augmentations ===') + await augmentationPipeline.initialize() + + // Store data in all memory augmentations + console.log('\n=== Storing Data ===') + const storeResults = await augmentationPipeline.executeMemoryPipeline( + 'storeData', + ['user123', { name: 'John Doe', email: 'john@example.com' }] + ) + + console.log('\nStore Results:') + storeResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (!result.success) { + console.log(` Error: ${result.error}`) + } + }) + + // Retrieve data from all memory augmentations + console.log('\n=== Retrieving Data ===') + const retrieveResults = await augmentationPipeline.executeMemoryPipeline( + 'retrieveData', + ['user123'] + ) + + console.log('\nRetrieve Results:') + retrieveResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (result.success) { + console.log(` Data: ${JSON.stringify(result.data)}`) + } else { + console.log(` Error: ${result.error}`) + } + }) + + // Update data in all memory augmentations + console.log('\n=== Updating Data ===') + const updateResults = await augmentationPipeline.executeMemoryPipeline( + 'updateData', + ['user123', { name: 'John Doe', email: 'john.updated@example.com' }] + ) + + console.log('\nUpdate Results:') + updateResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (!result.success) { + console.log(` Error: ${result.error}`) + } + }) + + // Retrieve updated data from all memory augmentations + console.log('\n=== Retrieving Updated Data ===') + const retrieveUpdatedResults = await augmentationPipeline.executeMemoryPipeline( + 'retrieveData', + ['user123'] + ) + + console.log('\nRetrieve Updated Results:') + retrieveUpdatedResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (result.success) { + console.log(` Data: ${JSON.stringify(result.data)}`) + } else { + console.log(` Error: ${result.error}`) + } + }) + + // Store additional data + console.log('\n=== Storing Additional Data ===') + await augmentationPipeline.executeMemoryPipeline( + 'storeData', + ['user456', { name: 'Jane Smith', email: 'jane@example.com' }] + ) + + // List all keys + console.log('\n=== Listing All Keys ===') + const listResults = await augmentationPipeline.executeMemoryPipeline( + 'listDataKeys', + [] + ) + + console.log('\nList Results:') + listResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (result.success) { + console.log(` Keys: ${result.data.join(', ')}`) + } else { + console.log(` Error: ${result.error}`) + } + }) + + // Use the WebSocket-Memory augmentation directly + console.log('\n=== Using WebSocket-Memory Augmentation ===') + const connection = await webSocketMemory.connectWebSocket('wss://example.com/storage') + console.log('Connection established:', connection) + + // Store data through WebSocket + console.log('\n=== Storing Data Through WebSocket ===') + const wsStoreResult = await webSocketMemory.storeData( + 'wsUser123', + { name: 'WebSocket User', email: 'ws@example.com' }, + { connectionId: connection.connectionId } + ) + console.log('WebSocket Store Result:', wsStoreResult) + + // Retrieve data through WebSocket + console.log('\n=== Retrieving Data Through WebSocket ===') + const wsRetrieveResult = await webSocketMemory.retrieveData( + 'wsUser123', + { connectionId: connection.connectionId } + ) + console.log('WebSocket Retrieve Result:', wsRetrieveResult) + + // Delete data from all memory augmentations + console.log('\n=== Deleting Data ===') + const deleteResults = await augmentationPipeline.executeMemoryPipeline( + 'deleteData', + ['user123'] + ) + + console.log('\nDelete Results:') + deleteResults.forEach((result, index) => { + console.log(`Result ${index + 1}:`) + console.log(` Success: ${result.success}`) + if (!result.success) { + console.log(` Error: ${result.error}`) + } + }) + + // Shut down all registered augmentations + console.log('\n=== Shutting Down Augmentations ===') + await augmentationPipeline.shutDown() + + console.log('\n=== Example Complete ===') + } catch (error) { + console.error('Error in memory augmentation example:', error) + } +} + +// Run the example +main() diff --git a/src/examples/webSocketAugmentation.ts b/src/examples/webSocketAugmentation.ts new file mode 100644 index 00000000..2a8f5f5f --- /dev/null +++ b/src/examples/webSocketAugmentation.ts @@ -0,0 +1,210 @@ +/** + * WebSocket Augmentation Example + * + * This example demonstrates how to create and register a WebSocket-supporting augmentation. + */ + +import { + augmentationPipeline, + IAugmentation, + IWebSocketSupport, + IWebSocketCognitionAugmentation, + AugmentationResponse, + BrainyAugmentations +} from '../index.js' + +/** + * Example WebSocket Augmentation + */ +class SimpleWebSocketAugmentation implements IWebSocketSupport { + readonly name = 'simple-websocket' + readonly description = 'A simple WebSocket augmentation for demonstration' + + async initialize(): Promise { + console.log('Initializing SimpleWebSocketAugmentation') + } + + async shutDown(): Promise { + console.log('Shutting down SimpleWebSocketAugmentation') + } + + async getStatus(): Promise<'active' | 'inactive' | 'error'> { + return 'active' + } + + async connectWebSocket(url: string, protocols?: string | string[]): Promise<{ + connectionId: string; + url: string; + status: 'connected' | 'disconnected' | 'error' + }> { + console.log(`Connecting to WebSocket at ${url}`) + return { + connectionId: 'ws-1', + url, + status: 'connected' + } + } + + async sendWebSocketMessage(connectionId: string, data: unknown): Promise { + console.log(`Sending message to WebSocket ${connectionId}:`, data) + } + + async onWebSocketMessage(connectionId: string, callback: (data: unknown) => void): Promise { + console.log(`Registering callback for WebSocket ${connectionId}`) + // In a real implementation, this would set up a listener + } + + async closeWebSocket(connectionId: string, code?: number, reason?: string): Promise { + console.log(`Closing WebSocket ${connectionId}`) + } +} + +/** + * Example Combined WebSocket and Cognition Augmentation + */ +class WebSocketCognitionAugmentation implements IWebSocketCognitionAugmentation { + readonly name = 'websocket-cognition' + readonly description = 'A combined WebSocket and Cognition augmentation for demonstration' + + async initialize(): Promise { + console.log('Initializing WebSocketCognitionAugmentation') + } + + async shutDown(): Promise { + console.log('Shutting down WebSocketCognitionAugmentation') + } + + async getStatus(): Promise<'active' | 'inactive' | 'error'> { + return 'active' + } + + // WebSocket methods + async connectWebSocket(url: string, protocols?: string | string[]): Promise<{ + connectionId: string; + url: string; + status: 'connected' | 'disconnected' | 'error' + }> { + console.log(`WebSocketCognition connecting to WebSocket at ${url}`) + return { + connectionId: 'ws-cognition-1', + url, + status: 'connected' + } + } + + async sendWebSocketMessage(connectionId: string, data: unknown): Promise { + console.log(`WebSocketCognition sending message to WebSocket ${connectionId}:`, data) + } + + async onWebSocketMessage(connectionId: string, callback: (data: unknown) => void): Promise { + console.log(`WebSocketCognition registering callback for WebSocket ${connectionId}`) + } + + async closeWebSocket(connectionId: string, code?: number, reason?: string): Promise { + console.log(`WebSocketCognition closing WebSocket ${connectionId}`) + } + + // Cognition methods + async reason( + query: string, + context?: Record + ): Promise> { + console.log(`WebSocketCognition reasoning about: ${query}`) + console.log('Context:', context) + + return { + success: true, + data: { + inference: `WebSocket-enabled inference about: ${query}`, + confidence: 0.85 + } + } + } + + async infer( + dataSubset: Record + ): Promise>> { + return { + success: true, + data: { + result: `WebSocket-enabled inference from data: ${JSON.stringify(dataSubset)}` + } + } + } + + async executeLogic( + ruleId: string, + input: Record + ): Promise> { + return { + success: true, + data: true + } + } +} + +/** + * Main function to demonstrate the WebSocket augmentation + */ +async function main() { + try { + console.log('=== WebSocket Augmentation Example ===') + + // Create augmentation instances + const simpleWebSocket = new SimpleWebSocketAugmentation() + const webSocketCognition = new WebSocketCognitionAugmentation() + + // Register augmentations with the pipeline + augmentationPipeline + .register(simpleWebSocket) + .register(webSocketCognition) + + // Initialize all registered augmentations + console.log('\n=== Initializing Augmentations ===') + await augmentationPipeline.initialize() + + // Get all WebSocket-supporting augmentations + console.log('\n=== WebSocket Augmentations ===') + const webSocketAugmentations = augmentationPipeline.getWebSocketAugmentations() + console.log(`Found ${webSocketAugmentations.length} WebSocket augmentations:`) + webSocketAugmentations.forEach(aug => { + console.log(`- ${aug.name}: ${aug.description}`) + }) + + // Use the simple WebSocket augmentation + console.log('\n=== Using Simple WebSocket Augmentation ===') + const connection = await simpleWebSocket.connectWebSocket('wss://example.com') + console.log('Connection established:', connection) + await simpleWebSocket.sendWebSocketMessage(connection.connectionId, { message: 'Hello, WebSocket!' }) + + // Use the combined WebSocket and Cognition augmentation + console.log('\n=== Using Combined WebSocket-Cognition Augmentation ===') + const wsConnection = await webSocketCognition.connectWebSocket('wss://example.com/cognition') + console.log('Connection established:', wsConnection) + await webSocketCognition.sendWebSocketMessage(wsConnection.connectionId, { message: 'Hello from cognition!' }) + + // Execute a cognition method on the combined augmentation + console.log('\n=== Executing Cognition Method on Combined Augmentation ===') + const reasoningResult = await webSocketCognition.reason('What is the meaning of life?', { context: 'philosophical' }) + console.log('Reasoning result:', reasoningResult) + + // Use the cognition pipeline with the combined augmentation + console.log('\n=== Executing Cognition Pipeline ===') + const pipelineResults = await augmentationPipeline.executeCognitionPipeline( + 'reason', + ['What is the capital of France?', { additionalContext: 'geography' }] + ) + console.log('Pipeline results:', pipelineResults) + + // Shut down all registered augmentations + console.log('\n=== Shutting Down Augmentations ===') + await augmentationPipeline.shutDown() + + console.log('\n=== Example Complete ===') + } catch (error) { + console.error('Error in WebSocket augmentation example:', error) + } +} + +// Run the example +main()