vibe-coder-mcp
Version:
Production-ready MCP server with complete agent integration, multi-transport support, and comprehensive development automation tools for AI-assisted workflows.
221 lines • 7.61 kB
TypeScript
import { ParallelBatch } from '../core/dependency-graph.js';
import { TaskScheduler, ScheduledTask } from './task-scheduler.js';
export type ExecutionStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timeout';
export interface Agent {
id: string;
name: string;
status: 'idle' | 'busy' | 'offline' | 'error';
capacity: {
maxMemoryMB: number;
maxCpuWeight: number;
maxConcurrentTasks: number;
};
currentUsage: {
memoryMB: number;
cpuWeight: number;
activeTasks: number;
};
metadata: {
lastHeartbeat: Date;
totalTasksExecuted: number;
averageExecutionTime: number;
successRate: number;
};
}
export interface TaskExecution {
scheduledTask: ScheduledTask;
agent: Agent;
status: ExecutionStatus;
startTime: Date;
endTime?: Date;
actualDuration?: number;
result?: {
success: boolean;
output?: string;
error?: string;
exitCode?: number;
};
resourceUsage: {
peakMemoryMB: number;
averageCpuWeight: number;
networkIO?: number;
diskIO?: number;
};
metadata: {
retryCount: number;
timeoutCount: number;
lastRetryAt?: Date;
executionId: string;
};
}
export interface ExecutionBatch {
parallelBatch: ParallelBatch;
executions: Map<string, TaskExecution>;
status: 'pending' | 'running' | 'completed' | 'failed' | 'partial';
startTime: Date;
endTime?: Date;
resourceAllocation: {
totalMemoryMB: number;
totalCpuWeight: number;
agentCount: number;
};
}
export interface ExecutionConfig {
maxConcurrentBatches: number;
taskTimeoutMinutes: number;
maxRetryAttempts: number;
retryDelaySeconds: number;
agentHeartbeatInterval: number;
resourceMonitoringInterval: number;
enableAutoRecovery: boolean;
loadBalancingStrategy: 'round_robin' | 'least_loaded' | 'resource_aware' | 'priority_based';
enableExecutionStateEvents: boolean;
executionRetentionMinutes: number;
enableExecutionDelays: boolean;
defaultExecutionDelayMs: number;
}
export interface ExecutionStateChangeEvent {
executionId: string;
taskId: string;
agentId: string;
previousStatus: ExecutionStatus;
newStatus: ExecutionStatus;
timestamp: Date;
metadata?: Record<string, unknown>;
}
export type ExecutionStateChangeCallback = (event: ExecutionStateChangeEvent) => void;
export interface ExecutionLifecycleHooks {
onExecutionStart?: (execution: TaskExecution) => Promise<void> | void;
onExecutionProgress?: (execution: TaskExecution, progress: number) => Promise<void> | void;
onExecutionComplete?: (execution: TaskExecution) => Promise<void> | void;
onExecutionFailed?: (execution: TaskExecution, error: Error) => Promise<void> | void;
onExecutionCancelled?: (execution: TaskExecution) => Promise<void> | void;
}
export interface ExecutionMetrics {
totalTasksExecuted: number;
runningTasks: number;
queuedTasks: number;
failedTasks: number;
averageExecutionTime: number;
successRate: number;
resourceUtilization: {
memoryUtilization: number;
cpuUtilization: number;
agentUtilization: number;
};
throughput: {
tasksPerHour: number;
batchesPerHour: number;
parallelismFactor: number;
};
}
export declare const DEFAULT_EXECUTION_CONFIG: ExecutionConfig;
export declare class ExecutionCoordinator {
private static instance;
private config;
private taskScheduler;
private agents;
private activeExecutions;
private completedExecutions;
private executionBatches;
private executionQueue;
private isRunning;
private coordinatorTimer;
private monitoringTimer;
private securityEngine;
private activeLocks;
private performanceMonitor;
private startupOptimizer;
private stateChangeCallbacks;
private executionStateSync;
private lifecycleHooks;
private executionDelays;
private executionPauses;
constructor(taskScheduler: TaskScheduler, config?: Partial<ExecutionConfig>);
static getInstance(): Promise<ExecutionCoordinator>;
static setInstance(instance: ExecutionCoordinator): void;
static resetInstance(): void;
static hasInstance(): boolean;
start(): Promise<void>;
private waitForDependencies;
stop(): Promise<void>;
registerAgent(agent: Agent): void;
unregisterAgent(agentId: string): void;
executeBatch(parallelBatch: ParallelBatch): Promise<ExecutionBatch>;
executeTask(scheduledTask: ScheduledTask): Promise<TaskExecution>;
getExecutionMetrics(): ExecutionMetrics;
getActiveExecutions(): TaskExecution[];
getTaskExecutionStatus(taskId: string): Promise<{
status: ExecutionStatus;
message?: string;
executionId?: string;
} | null>;
getRunningStatus(): boolean;
cancelExecution(executionId: string): Promise<boolean>;
private releaseExecutionLocks;
retryExecution(executionId: string): Promise<TaskExecution | null>;
dispose(): Promise<void>;
isDisposed: boolean;
private coordinationLoop;
private processExecutionQueue;
private checkForReadyBatches;
private monitorRunningExecutions;
private handleTimeoutsAndFailures;
private executeTasksInBatch;
private runTaskExecution;
private executeTaskWithAgent;
private waitForAgentResponse;
private parseAgentResponse;
private selectAgent;
private selectAgentRoundRobin;
private selectAgentLeastLoaded;
private selectAgentResourceAware;
private selectAgentPriorityBased;
private calculateBatchResourceAllocation;
private canExecuteBatch;
private getScheduledTasksForBatch;
private simulateAgentAssignments;
private updateAgentBeforeTaskExecution;
private updateAgentAfterTaskCompletion;
private updateExecutionResourceUsage;
private isExecutionComplete;
private completeExecution;
private signalCancellation;
private cancelAllExecutions;
private cancelTasksOnAgent;
private monitorResources;
private calculateTasksPerHour;
private calculateBatchesPerHour;
private calculateParallelismFactor;
private getExecutionStatusMessage;
optimizeBatchProcessing(): Promise<void>;
private optimizeExecutionQueue;
private optimizeAgentUtilization;
private cleanupCompletedExecutions;
private groupSimilarTasks;
private getPriorityWeight;
onExecutionStateChange(callback: ExecutionStateChangeCallback): void;
removeExecutionStateChangeCallback(callback: ExecutionStateChangeCallback): void;
setLifecycleHooks(hooks: ExecutionLifecycleHooks): void;
clearLifecycleHooks(): void;
private callLifecycleHook;
private notifyExecutionStateChange;
private updateExecutionStatus;
private handleExecutionCompletion;
getExecution(executionId: string): TaskExecution | undefined;
getAllExecutions(): TaskExecution[];
getExecutionSyncStatus(): {
activeCount: number;
completedCount: number;
syncedCount: number;
callbackCount: number;
};
setExecutionDelay(executionId: string, delayMs: number): void;
pauseExecution(executionId: string): void;
resumeExecution(executionId: string): void;
isExecutionPaused(executionId: string): boolean;
clearExecutionControls(): void;
private applyExecutionDelay;
private waitForExecutionUnpause;
}
//# sourceMappingURL=execution-coordinator.d.ts.map