tlnt
Version:
TLNT - HMS-Powered Multi-Agent Platform with Government Agency Analysis, Deep Research, and Enterprise-Ready Deployment. Self-optimizing multi-domain AI agent with continuous learning and enterprise-grade performance monitoring.
117 lines • 3.37 kB
TypeScript
import { EventEmitter } from 'events';
export interface Message {
id: string;
type: string;
source: string;
target?: string;
data: Record<string, unknown>;
timestamp: number;
priority: MessagePriority;
}
export interface ControlCommand {
command: 'PAUSE' | 'RESUME' | 'MUTE' | 'UNMUTE' | 'KILL' | 'ESCALATE';
agentId: string;
operatorId: string;
reason?: string;
metadata?: Record<string, unknown>;
}
export declare enum MessagePriority {
LOW = 0,
NORMAL = 1,
HIGH = 2,
URGENT = 3
}
export type MessageHandler = (message: Message) => Promise<void> | void;
export interface MessageBusConfig {
redisUrl?: string;
redisOptions?: any;
messageRetention?: number;
maxRetries?: number;
retryDelay?: number;
}
/**
* Redis-backed message bus for agent communication
* Supports pub/sub patterns, control channels, and message persistence
*/
export declare class MessageBus extends EventEmitter {
private redis;
private subscriber;
private channels;
private config;
private connected;
private retryCount;
constructor(config?: MessageBusConfig);
private setupEventHandlers;
private attemptReconnect;
connect(): Promise<void>;
disconnect(): Promise<void>;
isConnected(): boolean;
/**
* Publish a message to a specific channel
*/
publish(channel: string, message: Omit<Message, 'id' | 'timestamp'>): Promise<string>;
/**
* Subscribe to messages on a specific channel
*/
subscribe(channel: string, handler: MessageHandler): Promise<void>;
/**
* Subscribe to messages matching a pattern
*/
subscribePattern(pattern: string, handler: MessageHandler): Promise<void>;
/**
* Unsubscribe from a channel
*/
unsubscribe(channel: string, handler?: MessageHandler): Promise<void>;
/**
* Send a control command to an agent
*/
sendControl(agentId: string, command: ControlCommand): Promise<string>;
/**
* Send a delegation message
*/
sendDelegation(fromAgent: string, toAgent: string, task: Record<string, unknown>): Promise<string>;
/**
* Broadcast a message to all agents
*/
broadcast(message: Omit<Message, 'id' | 'timestamp' | 'target'>): Promise<string>;
/**
* Get message history for a channel
*/
getMessageHistory(channel: string, limit?: number): Promise<Message[]>;
/**
* Get agent status
*/
getAgentStatus(agentId: string): Promise<Record<string, unknown> | null>;
/**
* Update agent status
*/
updateAgentStatus(agentId: string, status: Record<string, unknown>): Promise<void>;
/**
* Check if agent is alive based on heartbeat
*/
isAgentAlive(agentId: string, maxAge?: number): Promise<boolean>;
/**
* Get all active agents
*/
getActiveAgents(): Promise<string[]>;
private handleIncomingMessage;
private storeMessage;
private generateMessageId;
/**
* Get connection statistics
*/
getStats(): {
connected: boolean;
channelCount: number;
retryCount: number;
uptime: number;
};
/**
* Health check
*/
healthCheck(): Promise<{
status: 'healthy' | 'unhealthy';
details: Record<string, unknown>;
}>;
}
//# sourceMappingURL=messageBus.d.ts.map