/** * Task Distributor - Distributes and balances tasks across agents * * The Task Distributor handles: * - Task decomposition into subtasks * - Load balancing across available agents * - Priority-based task queuing * - Task affinity and skill matching */ import type { Agent } from "../agent.js"; import type { TaskAnalysis, DistributableTask, DistributionResult, AgentCapability, TaskDistributorConfig } from "../../types/index.js"; /** * Task Distributor - Manages task distribution across agents */ export declare class TaskDistributor { private agents; private capabilities; private taskQueue; private activeResults; private config; private emitter; private isProcessing; constructor(config: TaskDistributorConfig); /** * Register an agent with capabilities */ registerAgent(agent: Agent, capability?: Partial): void; /** * Unregister an agent */ unregisterAgent(agentId: string): void; /** * Update agent capability */ updateCapability(agentId: string, update: Partial): void; /** * Submit a task for distribution */ submitTask(task: DistributableTask): Promise; /** * Submit multiple tasks */ submitTasks(tasks: DistributableTask[]): Promise; /** * Decompose a complex task into subtasks */ decomposeTask(task: DistributableTask, analysis: TaskAnalysis): Promise; /** * Process the task queue */ private processQueue; /** * Select an agent based on strategy */ private selectAgent; /** * Select agent by skill match */ private selectBySkill; /** * Select agent by load */ private selectByLoad; /** * Select agent by priority matching */ private selectByPriority; /** * Select agent by affinity */ private selectByAffinity; /** * Execute a task on an agent */ private executeTask; /** * Broadcast a task to all agents */ broadcastTask(task: DistributableTask): Promise>; /** * Get task result */ getTaskResult(taskId: string): DistributionResult | undefined; /** * Get queue status */ getQueueStatus(): { pending: number; active: number; completed: number; failed: number; }; /** * Clear completed/failed tasks */ clearCompleted(): void; /** * Fail all queued tasks (used on deadlock detection) */ private failAllQueuedTasks; /** * Helper delay function */ private delay; /** * Subscribe to distributor events */ on(event: string, handler: (...args: unknown[]) => void): void; /** * Unsubscribe from distributor events */ off(event: string, handler: (...args: unknown[]) => void): void; }