UNPKG

odin-protocol-core

Version:

The world's first standardized AI-to-AI communication infrastructure for JavaScript/TypeScript - 100% functional with 57K+ msgs/sec throughput

87 lines (86 loc) 2.51 kB
/** * ODIN Protocol Core Implementation * The main class for AI-to-AI communication infrastructure */ import { EventEmitter } from 'events'; import { OdinConfig, OdinConnectionStatus, OdinPerformanceMetrics } from '../types/OdinTypes'; import { OdinMessageHeader, OdinMessagePayload, OdinMessageOptions, OdinMessageResponse } from '../types/MessageTypes'; export declare class OdinProtocol extends EventEmitter { private config; private connectionStatus; private isInitialized; private messageQueue; private performanceMetrics; private startTime; emit: (event: string | symbol, ...args: any[]) => boolean; on: (event: string | symbol, listener: (...args: any[]) => void) => this; off: (event: string | symbol, listener: (...args: any[]) => void) => this; constructor(config: OdinConfig); /** * Initialize the ODIN Protocol connection */ initialize(): Promise<void>; /** * Send a message through the ODIN Protocol */ sendMessage(destination: string, content: any, options?: OdinMessageOptions): Promise<OdinMessageResponse>; /** * Register a message handler for incoming messages */ onMessage(messageType: string, handler: (header: OdinMessageHeader, payload: OdinMessagePayload) => Promise<any>): void; /** * Get current connection status */ getConnectionStatus(): OdinConnectionStatus; /** * Get performance metrics */ getPerformanceMetrics(): OdinPerformanceMetrics; /** * Disconnect from the ODIN network */ disconnect(): Promise<void>; /** * Validate the configuration */ private validateConfig; /** * Establish network connections */ private establishConnections; /** * Start heartbeat monitoring */ private heartbeatInterval; private startHeartbeat; /** * Stop heartbeat monitoring */ private stopHeartbeat; /** * Initialize performance monitoring */ private initializePerformanceMonitoring; /** * Calculate current throughput */ private messageCount; private lastThroughputCheck; private calculateThroughput; /** * Process message delivery */ private processMessage; /** * Update performance metrics */ private updatePerformanceMetrics; /** * Generate unique message ID */ private generateMessageId; /** * Close all connections */ private closeConnections; }