import type { AgentInfo } from "./types.js"; export type GhostReaperSignal = "SIGTERM" | "SIGKILL"; export interface ProcessSnapshot { pid: number; command: string; startedAt?: string | null; } export interface GhostReaperDeps { inspectProcess?: (pid: number) => ProcessSnapshot | null; signalProcess?: (pid: number, signal: GhostReaperSignal) => void; setTimeout?: (callback: () => void, delayMs: number) => unknown; clearTimeout?: (handle: unknown) => void; now?: () => number; brokerAgentId?: () => string | null; getAgentById?: (agentId: string) => AgentInfo | null; } export interface BrokerGhostReaperOptions { killAfterMs?: number; } export type GhostReapDecision = { eligible: true; agentId: string; pid: number; command: string; } | { eligible: false; agentId: string; pid?: number; reason: string; }; export interface GhostReapAttempt { agentId: string; pid?: number; action: "sigterm" | "sigkill" | "skipped" | "pending" | "failed"; reason?: string; } export interface GhostReapResult { attempts: GhostReapAttempt[]; signaledAgentIds: string[]; skippedAgentIds: string[]; } export declare function isBrokerManagedAgent(agent: Pick): boolean; export declare function inspectProcess(pid: number): ProcessSnapshot | null; export declare function decideGhostReapEligibility(agent: AgentInfo, snapshot: ProcessSnapshot | null, brokerAgentId?: string | null, now?: number): GhostReapDecision; export interface BrokerGhostReaper { reapGhosts: (agents: AgentInfo[]) => GhostReapResult; dispose: () => void; } export declare function createBrokerGhostReaper(deps?: GhostReaperDeps, options?: BrokerGhostReaperOptions): BrokerGhostReaper;