import { EventEmitter } from 'events'; import { Agent } from './agent'; import { RunOptions, RunResult } from './types'; /** * Configuration for creating an agent swarm */ export interface AgentSwarmConfig { agents: Agent[]; coordinator?: Agent; planningStrategy?: 'sequential' | 'parallel' | 'hierarchical'; maxConcurrentAgents?: number; enableFeedback?: boolean; } /** * AgentSwarm manages a group of agents that work together to accomplish tasks */ export declare class AgentSwarm extends EventEmitter { id: string; private agents; private coordinator; private planningStrategy; private maxConcurrentAgents; private logger; private feedbackSystem?; /** * Creates a new agent swarm * * @param config - Configuration for the swarm */ constructor(config: AgentSwarmConfig); /** * Adds an agent to the swarm * * @param agent - The agent to add * @returns The swarm instance (for chaining) */ addAgent(agent: Agent): AgentSwarm; /** * Removes an agent from the swarm * * @param agentId - The ID of the agent to remove * @returns Boolean indicating if an agent was removed */ removeAgent(agentId: string): boolean; /** * Gets an agent by ID * * @param agentId - The ID of the agent to get * @returns The agent, or undefined if not found */ getAgent(agentId: string): Agent | undefined; /** * Gets all agents in the swarm * * @returns Array of all agents */ getAllAgents(): Agent[]; /** * Sets the coordinator agent * * @param agent - The agent to use as coordinator * @returns The swarm instance (for chaining) */ setCoordinator(agent: Agent): AgentSwarm; /** * Runs the swarm with a specific task * * @param options - Execution options including the task to perform * @returns Promise resolving to the execution result */ run(options: RunOptions): Promise; /** * Creates a coordination plan for the swarm * * @param task - The task to create a plan for * @returns Promise resolving to the created plan */ private createCoordinationPlan; /** * Executes a plan sequentially * * @param plan - The plan to execute * @param options - The original run options * @returns Promise resolving to the execution result */ private executeSequential; /** * Executes a plan with parallel execution where possible * * @param plan - The plan to execute * @param options - The original run options * @returns Promise resolving to the execution result */ private executeParallel; /** * Executes a plan with hierarchical execution (coordinator delegates to teams) * * @param plan - The plan to execute * @param options - The original run options * @returns Promise resolving to the execution result */ private executeHierarchical; /** * Updates a task's status and result * * @param plan - The plan containing the task * @param taskId - ID of the task to update * @param status - New status * @param result - Optional result from the task * @param error - Optional error message * @returns The updated plan */ private updateTaskStatus; /** * Simple parser to extract agent tasks from the coordinator's response * * @param response - The coordinator's response * @returns Array of agent tasks */ private parseTasksFromResponse; }