/** * V3 Coordinator Interfaces * Domain-Driven Design - Coordination Bounded Context * Aligned with ADR-003 (Single Coordination Engine) */ import type { ITask, ITaskResult } from './task.interface.js'; import type { IAgent, IAgentConfig } from './agent.interface.js'; /** * Swarm topology types */ export type SwarmTopology = 'hierarchical' | 'mesh' | 'ring' | 'star' | 'adaptive' | 'hierarchical-mesh'; /** * Coordination status */ export type CoordinationStatus = 'initializing' | 'ready' | 'coordinating' | 'degraded' | 'error' | 'shutdown'; /** * Swarm configuration */ export interface ISwarmConfig { topology: SwarmTopology; maxAgents: number; autoScale?: { enabled: boolean; minAgents: number; maxAgents: number; scaleUpThreshold: number; scaleDownThreshold: number; }; coordination?: { consensusRequired: boolean; timeoutMs: number; retryPolicy: { maxRetries: number; backoffMs: number; }; }; communication?: { protocol: 'events' | 'messages' | 'shared-memory'; batchSize: number; flushIntervalMs: number; }; metadata?: Record; } /** * Swarm state */ export interface ISwarmState { readonly id: string; readonly topology: SwarmTopology; readonly createdAt: Date; status: CoordinationStatus; agentCount: number; taskCount: number; metrics?: { throughput: number; latencyMs: number; successRate: number; resourceUtilization: number; }; } /** * Coordinator interface - unified coordination engine */ export interface ICoordinator { /** * Initialize the coordinator */ initialize(): Promise; /** * Shutdown the coordinator */ shutdown(): Promise; /** * Initialize a swarm with configuration */ initializeSwarm(config: ISwarmConfig): Promise; /** * Get swarm state */ getSwarmState(): ISwarmState | undefined; /** * Assign a task to an agent */ assignTask(task: ITask, agentId: string): Promise; /** * Get tasks assigned to an agent */ getAgentTasks(agentId: string): Promise; /** * Get task count for an agent */ getAgentTaskCount(agentId: string): Promise; /** * Cancel a task */ cancelTask(taskId: string): Promise; /** * Report task completion */ reportTaskComplete(taskId: string, result: ITaskResult): Promise; /** * Get coordination health status */ getHealthStatus(): Promise<{ healthy: boolean; error?: string; metrics?: Record; }>; /** * Perform maintenance tasks */ performMaintenance(): Promise; } /** * Coordination manager interface - higher-level orchestration */ export interface ICoordinationManager extends ICoordinator { /** * Register an agent with the coordinator */ registerAgent(agent: IAgent): Promise; /** * Unregister an agent */ unregisterAgent(agentId: string): Promise; /** * Get all registered agents */ getRegisteredAgents(): IAgent[]; /** * Request agent consensus on a decision */ requestConsensus(topic: string, options: unknown[], timeout?: number): Promise; /** * Broadcast message to all agents */ broadcast(message: unknown): Promise; /** * Send message to specific agent */ sendToAgent(agentId: string, message: unknown): Promise; /** * Acquire a distributed lock */ acquireLock(resourceId: string, agentId: string, timeout?: number): Promise; /** * Release a distributed lock */ releaseLock(resourceId: string, agentId: string): Promise; /** * Check for deadlocks */ detectDeadlocks(): Promise<{ detected: boolean; agents?: string[]; resources?: string[]; }>; } /** * Health status for components */ export interface IHealthStatus { status: 'healthy' | 'degraded' | 'unhealthy'; components: Record; timestamp: Date; } /** * Component health details */ export interface IComponentHealth { name: string; status: 'healthy' | 'degraded' | 'unhealthy'; lastCheck: Date; error?: string; metrics?: Record; } /** * Health monitor interface */ export interface IHealthMonitor { /** * Start health monitoring */ start(): void; /** * Stop health monitoring */ stop(): void; /** * Get current health status */ getStatus(): Promise; /** * Register a health check */ registerCheck(name: string, check: () => Promise<{ healthy: boolean; error?: string; metrics?: Record; }>): void; /** * Unregister a health check */ unregisterCheck(name: string): void; /** * Get health history */ getHistory(limit?: number): IHealthStatus[]; /** * Subscribe to health changes */ onHealthChange(callback: (status: IHealthStatus) => void): () => void; } /** * Metrics collector interface */ export interface IMetricsCollector { /** * Start metrics collection */ start(): void; /** * Stop metrics collection */ stop(): void; /** * Record a metric value */ record(name: string, value: number, tags?: Record): void; /** * Increment a counter */ increment(name: string, value?: number, tags?: Record): void; /** * Record a timing */ timing(name: string, durationMs: number, tags?: Record): void; /** * Get current metrics */ getMetrics(): Record; /** * Reset all metrics */ reset(): void; } /** * Orchestrator metrics structure */ export interface IOrchestratorMetrics { uptime: number; totalAgents: number; activeAgents: number; totalTasks: number; completedTasks: number; failedTasks: number; queuedTasks: number; avgTaskDuration: number; memoryUsage: NodeJS.MemoryUsage; cpuUsage: NodeJS.CpuUsage; timestamp: Date; } /** * Main orchestrator interface - facade for all orchestration capabilities */ export interface IOrchestrator { /** * Initialize the orchestrator */ initialize(): Promise; /** * Shutdown the orchestrator */ shutdown(): Promise; /** * Get health status */ getHealthStatus(): Promise; /** * Get orchestrator metrics */ getMetrics(): Promise; /** * Spawn a new agent */ spawnAgent(config: IAgentConfig): Promise; /** * Terminate an agent */ terminateAgent(agentId: string, reason?: string): Promise; /** * Submit a task */ submitTask(task: ITask): Promise; /** * Get task by ID */ getTask(taskId: string): Promise; /** * Cancel a task */ cancelTask(taskId: string): Promise; } //# sourceMappingURL=coordinator.interface.d.ts.map