/**
 * SandboxManager — Registry mapping projectId → ProjectSandbox.
 *
 * Coordinates lifecycle of per-project sandbox containers. Each project
 * with `sandbox: "docker"` gets exactly one long-lived container managed
 * by a ProjectSandbox instance.
 */
import { ProjectSandbox } from "./project-sandbox.js";
import type { ProjectSandboxOptions, ContainerState } from "./project-sandbox.js";
export interface SandboxManagerStats {
    projects: number;
    containers: ContainerState[];
}
/**
 * Resolves the per-project sandbox configuration for `ensureForProject`. Returns:
 * - a fully-resolved `ProjectSandboxOptions` → proceed with init,
 * - `null` → sandbox is not applicable for this project (disabled, not a git repo, etc.);
 *   `ensureForProject` returns without throwing in that case.
 *
 * Implementations are expected to encapsulate all cross-cutting plumbing (reading
 * project config, image build/version check, mounts/credentials parsing,
 * sandbox network creation, GitHub-token resolution) — keeping SandboxManager
 * itself decoupled from ProjectRegistry, ProjectContextManager, SessionManager, etc.
 */
export type SandboxBootstrap = (projectId: string) => Promise<ProjectSandboxOptions | null>;
export interface SandboxManagerOptions {
    /**
     * Called by `ensureForProject(projectId)` the first time a project's sandbox
     * is requested. The wiring for host-side state (registry, config store,
     * image build, network, credentials) lives in the caller — SandboxManager
     * just coordinates lifecycle.
     */
    bootstrap?: SandboxBootstrap;
}
export declare class SandboxManager {
    private sandboxes;
    private _recoveryListeners;
    private _healthUnsubscribes;
    /**
     * Dedupes concurrent calls to `ensureForProject(projectId)`: while one init
     * is in-flight, later callers await the same Promise. On failure the entry
     * is cleared so the next caller can retry; on success it is left populated
     * so later calls resolve immediately (idempotent).
     */
    private _ensureInFlight;
    private _bootstrap;
    constructor(opts?: SandboxManagerOptions);
    /** Set or replace the bootstrap function post-construction. */
    setBootstrap(bootstrap: SandboxBootstrap | null): void;
    /** Subscribe to container recovery events across all projects. Returns unsubscribe function. */
    onContainerRecovered(listener: (projectId: string, containerId: string) => void): () => void;
    /**
     * Idempotent lazy per-project init. Safe to call concurrently — in-flight
     * inits are deduped via a Promise map (see §3.3 of the design). On success,
     * later calls short-circuit immediately. On failure the in-flight entry is
     * cleared so the next call can retry, and the error propagates to the caller
     * that triggered the failed init (callers for other projects are unaffected).
     *
     * If the bootstrap returns `null` (sandbox disabled / not a git repo) the
     * call resolves without registering anything; subsequent calls will retry
     * the bootstrap in case config has changed.
     */
    ensureForProject(projectId: string): Promise<void>;
    /**
     * Initialize sandbox for a project. Creates the ProjectSandbox and calls init().
     * If a sandbox already exists for this project, reconnects to it.
     */
    initForProject(projectId: string, opts: ProjectSandboxOptions): Promise<void>;
    /** Get the sandbox for a project. Returns undefined if not initialized. */
    get(projectId: string): ProjectSandbox | undefined;
    /** Check if a project has a sandbox registered (regardless of state). */
    has(projectId: string): boolean;
    /** Get stats for all sandboxes. */
    getStats(): SandboxManagerStats;
    /** Shutdown all sandboxes gracefully (stop containers, preserve volumes). */
    shutdownAll(): Promise<void>;
    /** Destroy sandbox for a project (remove container AND volume). */
    destroy(projectId: string): Promise<void>;
    /** Destroy all sandboxes. */
    destroyAll(): Promise<void>;
    /** Number of tracked sandboxes. */
    get size(): number;
}
//# sourceMappingURL=sandbox-manager.d.ts.map