import { AgentGraphConfigType, AgentMessageType, GraphResultType, RunOptionsType, ThreadStateType } from '../../Types/AgentGraph/AgentGraphTypes'; /** * AgentGraphService - Main orchestrator for multi-agent systems * Manages agent execution flow, memory, and message passing */ export default class AgentGraphService { private agents; private startAgent; private memory; private maxIterations; private readonly BOX; private readonly STATUS_ICONS; private readonly COLORS; private readonly TYPE_COLORS; /** * Format date for logging in YYYY-MM-DD HH:mm:ss format * @param date - Date to format * @returns Formatted date string */ private formatDate; /** * Create a new AgentGraphService instance * @param config - Graph configuration with agents and start agent */ constructor(config: AgentGraphConfigType); /** * Run the agent graph with the given input * @param input - Initial user input/task * @param options - Run options including threadId * @returns Promise resolving to the graph result */ run(input: string, options: RunOptionsType): Promise; /** * Get the current state of a thread * @param threadId - Thread identifier * @returns Promise resolving to thread state or null */ getState(threadId: string): Promise; /** * Get the message history for a thread * @param threadId - Thread identifier * @returns Promise resolving to array of messages */ getHistory(threadId: string): Promise; /** * Initialize a new thread * @param threadId - Thread identifier */ private initializeThread; /** * Update thread state * @param threadId - Thread identifier * @param currentAgent - Current agent ID * @param status - New status */ private updateThreadState; /** * Prepare context for an agent * @param threadId - Thread identifier * @param agent - Agent to prepare context for * @param initialMessage - Initial user message for this thread * @param currentAgentIterations - Current agent's iteration count * @param totalIterations - Total iterations across all agents * @returns Promise resolving to agent context */ private prepareContext; /** * Format content with tree symbol prefix, handling multiline content * @param content - Content to format (string or object) * @param firstLinePrefix - Prefix for first line (e.g., '├─ IN: ') * @param continuationPrefix - Prefix for continuation lines * @returns Formatted string with all lines */ private formatContentWithTreeSymbol; /** * Format thread start block with modern visual style and colors * @param threadId - Thread identifier * @param startAgent - Starting agent ID * @param input - Initial user input * @returns Object with separators and content for separate logging */ private formatThreadStart; /** * Format agent execution block with modern visual style and colors * @param params - Agent block parameters * @returns Object with separators and content for separate logging */ private formatAgentBlock; /** * Format thread completion or error block with modern visual style and colors * @param threadId - Thread identifier * @param iterations - Total number of iterations * @param totalTime - Total execution time in ms * @param status - Thread status (completed or error) * @param error - Error message (if status is error) * @returns Object with separators and content for separate logging */ private formatThreadEnd; /** * Log thread start - visual output to console, brief info to file logger * @param threadId - Thread identifier * @param startAgent - Starting agent ID * @param input - Initial user input */ private logThreadStart; /** * Log agent block - visual output to console, brief info to file logger * @param params - Agent block parameters */ private logAgentBlock; /** * Log thread end - visual output to console * @param threadId - Thread identifier * @param iterations - Total number of iterations * @param totalTime - Total execution time in ms * @param status - Thread status (completed or error) * @param error - Error message (if status is error) */ private logThreadEnd; }