/**
 * Agent Auto-Claim Service
 *
 * Automatically assigns work to idle agents. When an agent finishes a task
 * and goes idle, this service finds the best available WorkItem and claims
 * it for the agent — creating a continuous execution loop.
 *
 * Trigger sources:
 * - EventBus `agent:idle` events (primary, event-driven)
 * - EventBus `task:done` events (claim next for completing agent)
 * - Polling every 60s (backup, catches missed events)
 *
 * Complements Hybrid Wake (no conflict):
 * - Hybrid Wake = "unclaimed tasks find dormant agents" (push)
 * - AutoClaim = "idle agents find unclaimed tasks" (pull)
 *
 * @module services/v3/agent-auto-claim.service
 */
import { type AgentHealth } from '../reconciler/reconcile-rules.js';
export declare class AgentAutoClaimService {
    private static instance;
    private readonly logger;
    private pollingTimer;
    private eventBusService;
    private agentHealthProvider;
    private lastClaimAttempt;
    private constructor();
    static getInstance(): AgentAutoClaimService;
    static resetInstance(): void;
    /**
     * Initialize with EventBus and agent health data source.
     *
     * @param eventBusService - EventBusService for subscribing to agent events
     * @param agentHealthProvider - Function that returns the current agent health map
     */
    initialize(eventBusService: {
        on: (event: string, handler: (...args: unknown[]) => void) => void;
    }, agentHealthProvider?: () => Promise<Map<string, AgentHealth>>): void;
    /**
     * Start listening for events and polling.
     *
     * The polling cadence is read from
     * `settings.general.autonomyTickIntervalMinutes` (default 5 minutes).
     * A value of `0` disables polling entirely — autonomy then runs purely
     * on the `agent:idle` / `task:done` event path. The settings read is
     * non-blocking and failure-soft: any error falls back to the default.
     */
    start(): Promise<void>;
    /**
     * Read `general.autonomyTickIntervalMinutes` from settings, falling back
     * to the default on any failure (file missing, parse error, validation
     * failure). Kept as a separate helper so `start()` stays simple and the
     * settings dependency can be swapped in tests.
     */
    private resolvePollingIntervalMinutes;
    /**
     * Stop polling and clean up.
     */
    stop(): void;
    /**
     * Handle an agent:idle or task:done event.
     * Debounces per agent to avoid rapid re-trigger.
     *
     * @param agentSessionName - The agent that went idle or completed a task
     */
    private onAgentIdleOrTaskDone;
    /**
     * Find the best available WorkItem for a given agent and claim it.
     *
     * Steps:
     * 1. Get available items from TaskPool
     * 2. Get agent health info
     * 3. Score each item for this agent using computeAgentScore()
     * 4. Claim the highest-scoring item above the threshold
     *
     * @param agentSessionName - Agent to find work for
     * @returns The claim result, or null if nothing suitable
     */
    tryAutoClaimForAgent(agentSessionName: string): Promise<{
        workItemId: string;
        score: number;
    } | null>;
    /**
     * Scan all idle agents and try auto-claiming for each.
     * Polling backup for when events are missed.
     */
    private pollIdleAgents;
    /**
     * Build AgentHealth info for a specific agent.
     *
     * @param sessionName - Agent session name
     * @returns AgentHealth or null if agent not found
     */
    private getAgentHealth;
    /**
     * On startup, check for queued tasks whose target agents are offline.
     * For each:
     * - If agent exists in teams.json → attempt to wake via start-agent API
     * - If agent does NOT exist → escalate to Orchestrator for human confirmation
     */
    private recoverPendingTasks;
}
//# sourceMappingURL=agent-auto-claim.service.d.ts.map