/**
 * AgentLifecycleManager - Owns the idle → parked → revived lifecycle of
 * adopted subagents.
 *
 * The task executor hands a finished agent over via {@link AgentLifecycleManager.adopt};
 * from then on the manager arms a TTL timer whenever the agent goes `idle`,
 * parks it on expiry (disposes the live session, keeps the AgentRef +
 * sessionFile), and revives it on demand through
 * {@link AgentLifecycleManager.ensureLive}. Only this manager flips
 * `parked` ↔ `idle`.
 */
import type { AgentSession } from "../session/agent-session.js";
import { type AgentRef, AgentRegistry } from "./agent-registry.js";
export type AgentReviver = () => Promise<AgentSession>;
/**
 * Builds a reviver for a `parked` ref restored from disk (Agent Hub scan,
 * collab mirror, resumed process) that carries a sessionFile but no in-memory
 * adoption. Returns undefined when the ref cannot be faithfully rebuilt (no
 * persisted session contract, or its workspace is gone). Injected from the
 * top-level session so this manager stays free of sdk/SessionManager imports.
 */
export type PersistedSubagentReviverFactory = (ref: AgentRef) => Promise<AgentReviver | undefined>;
export interface AdoptOptions {
    /** TTL before an idle agent is parked. <= 0 disables parking. */
    idleTtlMs: number;
    /** Recreates a live AgentSession from the ref's sessionFile. Absent => not resumable after park (e.g. isolated runs). */
    revive?: AgentReviver;
}
export declare class AgentLifecycleManager {
    #private;
    static global(): AgentLifecycleManager;
    /** Reset the global manager. Test-only. */
    static resetGlobalForTests(): void;
    constructor(registry?: AgentRegistry);
    /**
     * Install the factory used to cold-revive `parked` refs restored from disk
     * (Agent Hub scan, collab mirror, resumed process) — they carry a sessionFile
     * but no adoption. Set by the top-level session, which owns the ambient deps
     * (auth, models, MCP, artifacts) the factory needs at revive time.
     */
    setPersistedSubagentReviverFactory(factory: PersistedSubagentReviverFactory, idleTtlMs: number): void;
    /**
     * Take ownership of a finished subagent. Caller has already set registry
     * status to "idle". Arms the TTL timer (idleTtlMs <= 0 adopts without one).
     */
    adopt(id: string, opts: AdoptOptions): void;
    /** True if the id is adopted (parked or live). */
    has(id: string): boolean;
    /** True while {@link park} is disposing this agent's session (lets dispose hooks distinguish park from teardown). */
    isParking(id: string): boolean;
    /**
     * Dispose the live session, detach it from the registry, and mark the
     * agent `parked`. No-op unless the id is adopted and live.
     */
    park(id: string): Promise<void>;
    /**
     * Return the live session, reviving from the sessionFile if parked.
     * Throws a plain Error if the id is unknown or parked without a reviver.
     * Concurrent calls share one in-flight revive.
     */
    ensureLive(id: string): Promise<AgentSession>;
    /** Hard removal: dispose if live, unregister from registry, drop timers. */
    release(id: string): Promise<void>;
    /** Teardown everything (process exit / main session dispose). */
    dispose(): Promise<void>;
}
