/**
 * SupervisorAgentWorker — long-lived in-process subscriber that forwards
 * supervisor events to the {@link ISupervisorAgent} evaluator.
 *
 * One worker exists per `(scopeType, scopeId?, featureId?)` scope. It mirrors the
 * feature-agent-worker shape:
 *   - owns its own `AgentRun` row (`agentName='supervisor'`),
 *   - heartbeats at the same cadence as the feature agent (30s),
 *   - reaps itself after `idleTtlMs` of inactivity (default 10 minutes).
 *
 * The worker is *not* a forked process; it lives inside whichever Shep
 * process happens to receive the first event for a scope. Cross-process
 * coordination remains the SQLite bus's job — see research decision 12.
 *
 * The `SupervisorAgentWorkerRegistry` lazily starts a worker the first
 * time `submit(event)` is called for a new scope. Subsequent events
 * reuse the warm worker. Idle workers are reaped automatically.
 */
import { type SupervisorPolicy } from '../../../../domain/generated/output.js';
import type { IAgentRunRepository } from '../../../../application/ports/output/agents/agent-run-repository.interface.js';
import type { ISupervisorAgent, SupervisorDecisionResult, SupervisorEvent } from '../../../../application/ports/output/agents/supervisor-agent.interface.js';
/** Heartbeat cadence — matches feature-agent-worker (30s). */
export declare const SUPERVISOR_HEARTBEAT_INTERVAL_MS = 30000;
/** Default idle TTL before a worker reaps itself (10 minutes). */
export declare const SUPERVISOR_IDLE_TTL_MS: number;
/** Reserved AgentRun.agentName for supervisor runs (single source of truth). */
export declare const SUPERVISOR_AGENT_NAME = "supervisor";
export interface SupervisorAgentWorkerScope {
    scopeType: string;
    scopeId?: string;
    featureId?: string;
}
export interface SupervisorAgentWorkerDeps {
    supervisorAgent: ISupervisorAgent;
    runRepository: IAgentRunRepository;
    /** Override for tests — defaults to {@link SUPERVISOR_HEARTBEAT_INTERVAL_MS}. */
    heartbeatIntervalMs?: number;
    /** Override for tests — defaults to {@link SUPERVISOR_IDLE_TTL_MS}. */
    idleTtlMs?: number;
    /**
     * Hook invoked after a decision is produced. The use-case layer wires
     * this to {@link EvaluateSupervisorDecisionUseCase}-style persistence
     * so the worker stays free of repository concerns.
     */
    onDecision?: (scope: SupervisorAgentWorkerScope, runId: string, event: SupervisorEvent, decision: SupervisorDecisionResult) => Promise<void>;
    /** Hook invoked when the worker reaps itself. */
    onReaped?: (scope: SupervisorAgentWorkerScope, runId: string) => Promise<void>;
}
interface PolicyCarrier {
    policy: SupervisorPolicy;
}
/**
 * One worker = one scope. Owns its own AgentRun row, heartbeat timer,
 * and idle-reaper timer. `submit(event)` runs the evaluator and the
 * `onDecision` callback, then resets the idle timer.
 */
export declare class SupervisorAgentWorker {
    readonly scope: SupervisorAgentWorkerScope;
    private readonly deps;
    readonly runId: string;
    private heartbeatTimer?;
    private idleTimer?;
    private started;
    private stopped;
    constructor(scope: SupervisorAgentWorkerScope, deps: SupervisorAgentWorkerDeps);
    /**
     * Persist the AgentRun row, start heartbeat + idle timers. Idempotent.
     */
    start(): Promise<void>;
    /**
     * Evaluate one event and forward the resulting decision to `onDecision`.
     * Resets the idle reaper.
     */
    submit(event: SupervisorEvent, policy: SupervisorPolicy): Promise<SupervisorDecisionResult>;
    /** Stop heartbeat + idle timers and mark the run completed. Idempotent. */
    stop(reason?: 'reaped' | 'shutdown'): Promise<void>;
    isRunning(): boolean;
    /** Reset the idle timer to the configured TTL. */
    private resetIdleTimer;
    /** Single heartbeat tick. Failures are non-fatal. */
    private heartbeat;
}
export type SupervisorAgentWorkerRegistryDeps = SupervisorAgentWorkerDeps;
/**
 * Lazily starts (and reaps) one worker per `(scopeType, scopeId?, featureId?)` scope.
 *
 * Production code submits events via `submitEvent`; the registry starts
 * a worker on first event for a new scope and reuses warm workers for
 * subsequent events. Idle workers reap themselves after `idleTtlMs` and
 * deregister via the registry's `onReaped` hook.
 */
export declare class SupervisorAgentWorkerRegistry {
    private readonly deps;
    private readonly workers;
    constructor(deps: SupervisorAgentWorkerRegistryDeps);
    /**
     * Submit one event for the given policy's scope. Starts a worker
     * lazily on first call and forwards the event to it.
     */
    submitEvent(event: SupervisorEvent, carrier: PolicyCarrier): Promise<SupervisorDecisionResult>;
    /** Stop every active worker. Used on process shutdown. */
    stopAll(reason?: 'reaped' | 'shutdown'): Promise<void>;
    /** True if a warm worker exists for the given scope. */
    hasWorker(scopeType: string, scopeId: string | undefined, featureId: string | undefined): boolean;
    private createAndStartWorker;
}
export {};
//# sourceMappingURL=supervisor-agent-worker.d.ts.map