/** * Gateway/Bot Module for PraisonAI TypeScript SDK * * Python parity with praisonaiagents gateway/bot types * * Provides: * - Bot protocols and interfaces * - Gateway protocols and interfaces * - Message types */ /** * Bot configuration. * Python parity: praisonaiagents/bots */ export interface BotConfig { name: string; token?: string; prefix?: string; channels?: string[]; allowedUsers?: string[]; metadata?: Record; } /** * Bot user. * Python parity: praisonaiagents/bots */ export interface BotUser { id: string; name: string; displayName?: string; isBot?: boolean; metadata?: Record; } /** * Bot channel. * Python parity: praisonaiagents/bots */ export interface BotChannel { id: string; name: string; type: 'text' | 'voice' | 'dm' | 'group'; metadata?: Record; } /** * Bot message. * Python parity: praisonaiagents/bots */ export interface BotMessage { id: string; content: string; author: BotUser; channel: BotChannel; timestamp: Date; attachments?: Array<{ url: string; type: string; name?: string; }>; metadata?: Record; } /** * Bot protocol interface. * Python parity: praisonaiagents/bots */ export interface BotProtocol { name: string; config: BotConfig; connect(): Promise; disconnect(): Promise; sendMessage(channel: string, content: string): Promise; onMessage(handler: (message: BotMessage) => void | Promise): void; getUser(userId: string): Promise; getChannel(channelId: string): Promise; } /** * Gateway configuration. * Python parity: praisonaiagents/gateway */ export interface GatewayConfig { url: string; apiKey?: string; timeout?: number; retryAttempts?: number; retryDelay?: number; metadata?: Record; } /** * Gateway event. * Python parity: praisonaiagents/gateway */ export interface GatewayEvent { type: string; data: any; timestamp: Date; source?: string; metadata?: Record; } /** * Gateway message. * Python parity: praisonaiagents/gateway */ export interface GatewayMessage { id: string; type: 'request' | 'response' | 'event' | 'error'; payload: any; timestamp: Date; correlationId?: string; metadata?: Record; } /** * Gateway protocol interface. * Python parity: praisonaiagents/gateway */ export interface GatewayProtocol { config: GatewayConfig; connect(): Promise; disconnect(): Promise; isConnected(): boolean; send(message: GatewayMessage): Promise; receive(): Promise; onEvent(handler: (event: GatewayEvent) => void | Promise): void; onError(handler: (error: Error) => void): void; } /** * Gateway client protocol. * Python parity: praisonaiagents/gateway */ export interface GatewayClientProtocol extends GatewayProtocol { request(payload: any, timeout?: number): Promise; subscribe(eventType: string, handler: (event: GatewayEvent) => void): () => void; } /** * Gateway session protocol. * Python parity: praisonaiagents/gateway */ export interface GatewaySessionProtocol { sessionId: string; userId?: string; startTime: Date; metadata?: Record; isActive(): boolean; extend(duration: number): void; terminate(): void; } /** * Provider status. * Python parity: praisonaiagents/gateway */ export interface ProviderStatus { name: string; status: 'online' | 'offline' | 'degraded' | 'unknown'; latency?: number; lastCheck: Date; errorCount?: number; metadata?: Record; } /** * Failover configuration. * Python parity: praisonaiagents/gateway */ export interface FailoverConfig { providers: string[]; strategy: 'round-robin' | 'priority' | 'random' | 'least-latency'; maxRetries?: number; retryDelay?: number; healthCheckInterval?: number; } /** * Failover manager. * Python parity: praisonaiagents/gateway */ export declare class FailoverManager { private config; private providerStatuses; private currentIndex; constructor(config: FailoverConfig); /** * Get the next provider based on strategy. */ getNextProvider(): string | null; /** * Update provider status. */ updateStatus(provider: string, status: Partial): void; /** * Mark provider as failed. */ markFailed(provider: string): void; /** * Mark provider as healthy. */ markHealthy(provider: string, latency?: number): void; /** * Get all provider statuses. */ getStatuses(): ProviderStatus[]; } /** * Auth profile. * Python parity: praisonaiagents/auth */ export interface AuthProfile { userId: string; username?: string; email?: string; roles?: string[]; permissions?: string[]; token?: string; expiresAt?: Date; metadata?: Record; } /** * Resource limits. * Python parity: praisonaiagents/limits */ export interface ResourceLimits { maxTokens?: number; maxRequests?: number; maxConcurrent?: number; rateLimitPerMinute?: number; rateLimitPerHour?: number; maxMemoryMB?: number; maxExecutionTimeMs?: number; } /** * Sandbox status. * Python parity: praisonaiagents/sandbox */ export declare enum SandboxStatus { IDLE = "idle", RUNNING = "running", COMPLETED = "completed", FAILED = "failed", TIMEOUT = "timeout" } /** * Sandbox result. * Python parity: praisonaiagents/sandbox */ export interface SandboxResult { status: SandboxStatus; output?: string; error?: string; exitCode?: number; duration?: number; metadata?: Record; } /** * Sandbox protocol. * Python parity: praisonaiagents/sandbox */ export interface SandboxProtocol { execute(code: string, language?: string): Promise; executeFile(filePath: string): Promise; terminate(): Promise; getStatus(): SandboxStatus; } /** * Autonomy level. * Python parity: praisonaiagents/autonomy */ export declare enum AutonomyLevel { NONE = "none", SUGGEST = "suggest", AUTO_APPROVE = "auto_approve", FULL_AUTO = "full_auto" } /** * Reflection output. * Python parity: praisonaiagents/reflection */ export interface ReflectionOutput { originalOutput: string; reflectedOutput: string; iterations: number; improvements: string[]; score?: number; metadata?: Record; } /** * RAG retrieval policy. * Python parity: praisonaiagents/rag */ export declare enum RagRetrievalPolicy { SIMILARITY = "similarity", MMR = "mmr", HYBRID = "hybrid", RERANK = "rerank" } /** * Auto RAG configuration. * Python parity: praisonaiagents/knowledge */ export interface AutoRagConfig { sources: string[]; chunkSize?: number; chunkOverlap?: number; topK?: number; rerank?: boolean; retrievalPolicy?: RagRetrievalPolicy; }