import { Socket } from 'socket.io-client'; /** * Bot information for authentication */ interface BotInfo { chatBot: string; taskBotId: string; } /** * Socket connection configuration */ interface SocketConnectionConfig { conversationId: string; botId: string; domainURL: string; token: string; interactiveLanguage: string; customData: string; channel: string; sessionId: string; /** JWT assertion token for authentication */ assertion: string; /** Bot information */ botInfo: BotInfo; /** Headless mode */ headLess: boolean; userName?: string; userId?: string; autoBotId?: string; } /** * Configuration options for the AgentAI SDK client */ interface AgentAIConfig { /** Socket connection configuration */ connection: SocketConnectionConfig; } /** * Message payload for sending messages */ interface MessagePayload { message: string; metadata?: { author: string; }; } /** * Event types emitted by the SDK */ type SDKEventType = 'connect' | 'disconnect' | 'connect_error' | 'reconnect' | 'reconnect_attempt' | 'agent_message_ack' | 'user_message_ack' | 'internal_transfer_response' | 'interm_summary_response' | 'interm_summary_event_ack' | 'agentai_ready' | 'error'; /** * Connection state */ type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting'; /** * Event payload structure */ interface SDKEvent { type: SDKEventType; payload?: MessagePayload | Record; timestamp: string; } /** * AgentAI SDK Client * * Establishes socket connection on instantiation and provides methods * for sending agent/user messages. * * @example * ```typescript * import { AgentAI } from '@koreai/agentai-node-sdk'; * * const client = new AgentAI({ * connection: { * domainURL: 'https://your-server.com', * botId: 'your-bot-id', * conversationId: 'conversation-id', * token: 'your-access-token', * interactiveLanguage: 'en', * customData: '{}', * channel: 'web', * sessionId: 'session-id', * } * }); * * // Listen for connection events * client.on('connect', () => { * console.log('Connected to AgentAI'); * }); * * client.on('disconnect', (event) => { * console.log('Disconnected:', event); * }); * * // Listen for message acknowledgments * client.on('agent_message_ack', (event) => { * console.log('Agent message acknowledged:', event.payload); * }); * * // Send messages * client.sendAgentMessage({ content: 'Hello from agent' }); * ``` */ declare class AgentAI { private rootService; constructor(config: AgentAIConfig); on(event: string, fn: (...args: any[]) => void): this; off(event: string, fn: (...args: any[]) => void): this; once(event: string, fn: (...args: any[]) => void): this; /** * Disconnect from socket */ disconnect(): void; /** * Get current connection state */ getConnectionState(): ConnectionState; /** * Check if connected */ isConnected(): boolean; /** * Check if the client was initialized with valid configuration */ isValid(): boolean; /** * Get current reconnection attempt count */ getReconnectAttempts(): number; /** * Get the raw socket instance (for advanced usage) */ getSocket(): Socket | null; /** * Send a message as an agent * Emits 'agent_message_ack' event as acknowledgment * * @param payload - Message payload containing message and optional metadata * @returns true if message was sent, false if there was an error */ sendAgentMessage(payload: MessagePayload): boolean; /** * Send a message as a user * Emits 'user_message_ack' event as acknowledgment * * @param payload - Message payload containing message and optional metadata * @returns true if message was sent, false if there was an error */ sendUserMessage(payload: MessagePayload): boolean; /** * Internal transfer */ internalTransfer(payload: any, isAnonymous?: boolean): boolean; /** * Generate intermittent summary */ generateIntermSummary(): boolean; /** * End of conversation */ endOfConversation(): boolean; } /** * Error payload structure for error events */ interface ErrorPayload extends Record { /** Human-readable error message */ message: string; /** Optional additional details about the error */ details?: unknown; } export { AgentAI, type AgentAIConfig, type ConnectionState, type ErrorPayload, type MessagePayload, type SDKEvent, type SDKEventType, type SocketConnectionConfig, AgentAI as default };