/**
 * Auto-Assignment Service
 *
 * Automatically assigns tasks to idle agents based on role matching,
 * priority, and dependency rules.
 *
 * @module services/autonomous/auto-assign.service
 */
import { EventEmitter } from 'events';
import { TaskService } from '../project/task.service.js';
import { TaskTrackingService } from '../project/task-tracking.service.js';
import { AssignmentStrategy, AssignmentEvent, TaskAssignmentResult, TaskQueue, FindNextTaskParams, FindNextTaskResult } from '../../types/auto-assign.types.js';
/**
 * Agent workload information
 */
export interface AgentWorkload {
    /** Session name of the agent */
    sessionName: string;
    /** Agent ID */
    agentId: string;
    /** Agent's role */
    role: string;
    /** Currently assigned task IDs */
    currentTasks: string[];
    /** Tasks completed today */
    completedToday: number;
    /** Average iterations per task */
    averageIterations: number;
}
/**
 * Interface for the Auto-Assignment Service
 */
export interface IAutoAssignService {
    /**
     * Initialize the service for a project
     *
     * @param projectPath - Path to the project
     */
    initialize(projectPath: string): Promise<void>;
    /**
     * Get the assignment strategy configuration for a project
     *
     * @param projectPath - Path to the project
     * @returns Assignment strategy configuration
     */
    getConfig(projectPath: string): Promise<AssignmentStrategy>;
    /**
     * Update the assignment strategy configuration
     *
     * @param projectPath - Path to the project
     * @param config - Partial configuration to merge
     */
    setConfig(projectPath: string, config: Partial<AssignmentStrategy>): Promise<void>;
    /**
     * Assign the next available task to an agent
     *
     * @param sessionName - Agent session name
     * @returns Assignment result or null if no task available
     */
    assignNextTask(sessionName: string): Promise<TaskAssignmentResult | null>;
    /**
     * Find the next task suitable for a role
     *
     * @param params - Search parameters
     * @returns Search result with task or reason for no match
     */
    findNextTask(params: FindNextTaskParams): Promise<FindNextTaskResult>;
    /**
     * Assign a specific task to an agent
     *
     * @param taskPath - Path to the task file
     * @param sessionName - Agent session name
     * @returns Assignment result
     */
    assignTask(taskPath: string, sessionName: string): Promise<TaskAssignmentResult>;
    /**
     * Get the task queue for a project
     *
     * @param projectPath - Path to the project
     * @returns Task queue
     */
    getTaskQueue(projectPath: string): Promise<TaskQueue>;
    /**
     * Refresh the task queue from the filesystem
     *
     * @param projectPath - Path to the project
     */
    refreshQueue(projectPath: string): Promise<void>;
    /**
     * Get an agent's current workload
     *
     * @param sessionName - Agent session name
     * @returns Agent workload information
     */
    getAgentWorkload(sessionName: string): Promise<AgentWorkload>;
    /**
     * Register a handler for task assignment events
     *
     * @param handler - Event handler function
     */
    onTaskAssigned(handler: (event: AssignmentEvent) => void): void;
    /**
     * Register a handler for agent idle events
     *
     * @param handler - Event handler function
     */
    onAgentIdle(handler: (event: AssignmentEvent) => void): void;
    /**
     * Pause auto-assignment for a project
     *
     * @param projectPath - Path to the project
     */
    pauseAutoAssign(projectPath: string): Promise<void>;
    /**
     * Resume auto-assignment for a project
     *
     * @param projectPath - Path to the project
     */
    resumeAutoAssign(projectPath: string): Promise<void>;
    /**
     * Check if auto-assignment is enabled for a project
     *
     * @param projectPath - Path to the project
     * @returns True if enabled and not paused
     */
    isAutoAssignEnabled(projectPath: string): Promise<boolean>;
}
/**
 * Service for automatic task assignment to agents
 *
 * @example
 * ```typescript
 * const service = AutoAssignService.getInstance();
 * await service.initialize('/path/to/project');
 *
 * // Assign next task to an idle agent
 * const result = await service.assignNextTask('agent-session');
 * if (result) {
 *   console.log(`Assigned task ${result.taskId} to agent`);
 * }
 * ```
 */
export declare class AutoAssignService extends EventEmitter implements IAutoAssignService {
    private static instance;
    private readonly logger;
    private taskService;
    private taskTrackingService;
    /** Configuration cache per project */
    private configs;
    /** Task queue cache per project */
    private queues;
    /** Paused projects */
    private paused;
    /** Agent to project mapping */
    private agentProjects;
    /** Assignment history per project */
    private assignmentHistory;
    /** Daily assignment counts per agent */
    private dailyAssignments;
    /** Last assignment time per agent */
    private lastAssignmentTime;
    /**
     * Private constructor for singleton pattern
     */
    private constructor();
    /**
     * Gets the singleton instance
     *
     * @returns The AutoAssignService instance
     */
    static getInstance(): AutoAssignService;
    /**
     * Clears the singleton instance (for testing)
     */
    static clearInstance(): void;
    /**
     * Set the task service (for dependency injection/testing)
     *
     * @param service - Task service instance
     */
    setTaskService(service: TaskService): void;
    /**
     * Set the task tracking service (for dependency injection/testing)
     *
     * @param service - Task tracking service instance
     */
    setTaskTrackingService(service: TaskTrackingService): void;
    /**
     * Get the task service, creating one if needed
     *
     * @param projectPath - Project path
     * @returns Task service
     */
    private getTaskService;
    /**
     * Get the task tracking service, creating one if needed
     *
     * @returns Task tracking service
     */
    private getTaskTrackingService;
    /**
     * Initialize the service for a project
     *
     * @param projectPath - Path to the project
     */
    initialize(projectPath: string): Promise<void>;
    /**
     * Load configuration from file or return defaults
     *
     * @param projectPath - Project path
     * @returns Auto-assign configuration
     */
    private loadConfig;
    /**
     * Get the assignment strategy configuration for a project
     *
     * @param projectPath - Path to the project
     * @returns Assignment strategy configuration
     */
    getConfig(projectPath: string): Promise<AssignmentStrategy>;
    /**
     * Update the assignment strategy configuration
     *
     * @param projectPath - Path to the project
     * @param config - Partial configuration to merge
     */
    setConfig(projectPath: string, config: Partial<AssignmentStrategy>): Promise<void>;
    /**
     * Assign the next available task to an agent
     *
     * @param sessionName - Agent session name
     * @returns Assignment result or null if no task available
     */
    assignNextTask(sessionName: string): Promise<TaskAssignmentResult | null>;
    /**
     * Find the next task suitable for a role
     *
     * @param params - Search parameters
     * @returns Search result with task or reason for no match
     */
    findNextTask(params: FindNextTaskParams): Promise<FindNextTaskResult>;
    /**
     * Sort tasks by priority and preferences
     *
     * @param tasks - Tasks to sort
     * @param config - Assignment strategy
     * @param preferredTypes - Preferred task types
     * @returns Sorted tasks
     */
    private sortTasks;
    /**
     * Check if a role can handle a specific task
     *
     * @param role - Agent role
     * @param task - Task to check
     * @param config - Assignment strategy
     * @returns True if role can handle the task
     */
    private canRoleHandleTask;
    /**
     * Check if a role can handle a task type
     *
     * @param role - Agent role
     * @param taskType - Task type
     * @param config - Assignment strategy
     * @returns True if role can handle the task type
     */
    private canRoleHandleTaskType;
    /**
     * Check if a task type is exclusive to another role
     *
     * @param role - Current role
     * @param taskType - Task type
     * @param config - Assignment strategy
     * @returns True if exclusive to another role
     */
    private isExclusiveForOtherRole;
    /**
     * Assign a specific task to an agent
     *
     * @param taskPath - Path to the task file
     * @param sessionName - Agent session name
     * @returns Assignment result
     */
    assignTask(taskPath: string, sessionName: string): Promise<TaskAssignmentResult>;
    /**
     * Get the task queue for a project
     *
     * @param projectPath - Path to the project
     * @returns Task queue
     */
    getTaskQueue(projectPath: string): Promise<TaskQueue>;
    /**
     * Refresh the task queue from the filesystem
     *
     * @param projectPath - Path to the project
     */
    refreshQueue(projectPath: string): Promise<void>;
    /**
     * Convert priority string to numeric value
     *
     * @param priority - Priority string
     * @returns Numeric priority value
     */
    private getPriorityValue;
    /**
     * Extract task type from task
     *
     * @param task - Task object
     * @returns Task type or undefined
     */
    private extractTaskType;
    /**
     * Extract dependencies from task
     *
     * @param task - Task object
     * @returns Array of dependency task IDs
     */
    private extractDependencies;
    /**
     * Extract estimated hours from task
     *
     * @param task - Task object
     * @returns Estimated hours or undefined
     */
    private extractEstimatedHours;
    /**
     * Extract labels from task
     *
     * @param task - Task object
     * @returns Array of labels
     */
    private extractLabels;
    /**
     * Get an agent's current workload
     *
     * @param sessionName - Agent session name
     * @returns Agent workload information
     */
    getAgentWorkload(sessionName: string): Promise<AgentWorkload>;
    /**
     * Get the role for an agent session
     *
     * @param sessionName - Session name
     * @returns Role string
     */
    private getAgentRole;
    /**
     * Register an agent with a project
     *
     * @param sessionName - Agent session name
     * @param projectPath - Project path
     */
    registerAgent(sessionName: string, projectPath: string): void;
    /**
     * Unregister an agent
     *
     * @param sessionName - Agent session name
     */
    unregisterAgent(sessionName: string): void;
    /**
     * Emit an assignment event
     *
     * @param event - Event to emit
     */
    private emitEvent;
    /**
     * Register a handler for task assignment events
     *
     * @param handler - Event handler function
     */
    onTaskAssigned(handler: (event: AssignmentEvent) => void): void;
    /**
     * Register a handler for agent idle events
     *
     * @param handler - Event handler function
     */
    onAgentIdle(handler: (event: AssignmentEvent) => void): void;
    /**
     * Subscribe to task tracking events for a project
     *
     * @param projectPath - Project path
     */
    private subscribeToEvents;
    /**
     * Pause auto-assignment for a project
     *
     * @param projectPath - Path to the project
     */
    pauseAutoAssign(projectPath: string): Promise<void>;
    /**
     * Resume auto-assignment for a project
     *
     * @param projectPath - Path to the project
     */
    resumeAutoAssign(projectPath: string): Promise<void>;
    /**
     * Check if auto-assignment is enabled for a project
     *
     * @param projectPath - Path to the project
     * @returns True if enabled and not paused
     */
    isAutoAssignEnabled(projectPath: string): Promise<boolean>;
    /**
     * Mark a task as failed
     *
     * @param taskId - Task ID
     * @param sessionName - Agent session name
     * @param reason - Failure reason
     */
    markTaskFailed(taskId: string, sessionName: string, reason?: string): Promise<void>;
    /**
     * Get assignment statistics for a project
     *
     * @param projectPath - Project path
     * @returns Assignment statistics
     */
    getStatistics(projectPath: string): {
        totalAssigned: number;
        completed: number;
        failed: number;
        active: number;
    };
    /**
     * Clear all cached data (for testing)
     */
    clearCache(): void;
}
//# sourceMappingURL=auto-assign.service.d.ts.map