import WebSocket from 'ws'; import { EventEmitter } from 'events'; /** * Type 3 Gateway WebSocket Client * Connects seller's infrastructure to marketplace * * Key Features: * - Persistent WebSocket connection to marketplace * - Automatic reconnection with exponential backoff * - Heartbeat monitoring * - Request/response routing to provider APIs * - Version management with auto-upgrade */ export declare class Type3GatewayClient extends EventEmitter { ws: WebSocket | null; private gatewayId; private apiKey; private marketplaceUrl; private marketplaceApiUrl; private reconnectAttempts; private maxReconnectAttempts; private authFailed; private heartbeatInterval; private requestHandlers; private currentVersion; private nodeId; private providerApiKeys; private metrics; constructor(config: { gatewayId: string; apiKey: string; marketplaceUrl?: string; providerKeys: { [provider: string]: string; }; }); /** * Connect to marketplace WebSocket */ connect(): Promise; /** * Send gateway identification after connection */ private sendIdentification; /** * Handle incoming WebSocket messages */ private handleMessage; /** * Handle inference request from marketplace */ private handleInferenceRequest; /** * Forward request to provider API */ private forwardToProvider; /** * Get provider-specific headers */ private getProviderHeaders; /** * Report error to marketplace API */ private reportErrorToMarketplace; /** * Handle heartbeat from marketplace */ private handleHeartbeat; /** * Handle version update notification */ private handleVersionUpdate; /** * Handle configuration update */ private handleConfigurationUpdate; /** * Handle error messages */ private handleError; /** * Handle authentication failure - exit without retry */ private handleAuthFailed; /** * Start heartbeat monitoring */ private startHeartbeat; /** * Stop heartbeat monitoring */ private stopHeartbeat; /** * Handle disconnection and attempt reconnection */ private handleDisconnection; /** * Send message to marketplace */ private sendMessage; /** * Map error codes to standard codes */ private mapErrorCode; /** * Store learned rate limits */ private storeRateLimits; /** * Get CPU usage (simplified) */ private getCpuUsage; /** * Disconnect from marketplace */ disconnect(): void; } /** * Usage Example: * * const gateway = new Type3GatewayClient({ * gatewayId: 'gw_abc123', * apiKey: 'sk-marketplace-key', * providerKeys: { * 'openai': 'sk-openai-key', * 'anthropic': 'sk-anthropic-key' * } * }); * * gateway.on('error', (err) => console.error('Gateway error:', err)); * gateway.on('version_available', (ver) => console.log('Update available:', ver)); * gateway.on('upgrade_required', (info) => performUpgrade(info)); * * await gateway.connect(); */ //# sourceMappingURL=websocket-handler.d.ts.map