/**
 * SandboxPool — Pre-warmed Docker containers with dedicated git clones.
 *
 * Each pool slot is a (container, clone) pair:
 *   - The clone is a local git clone checked out on the default branch
 *   - The container has that clone bind-mounted as /workspace
 *
 * On claim, the caller can request a branch checkout (for goals/members).
 * On release, the slot is destroyed (container killed, clone deleted).
 *
 * Design: slots are cheap to create (~3-5s — git clone --local + docker create).
 * The worktree setup command is skipped for pool slots because the container
 * entrypoint handles cross-platform dependency installation via its own cache.
 * This keeps the pool simple: no readoption, no idle culling, no health checks
 * trying to keep long-lived containers alive. Fresh containers on every cycle
 * eliminates the entire class of "dead container handed out" race conditions.
 */
export interface SandboxPoolOptions {
    poolSize: number;
    maxIdleSeconds: number;
    image: string;
    projectDir: string;
    repoPath: string;
    healthCheckIntervalMs: number;
    sandboxMounts?: string[];
    sandboxCredentials?: Record<string, string>;
    sandboxNetwork?: string;
    worktreeSetupCommand?: string;
}
export interface ClaimResult {
    containerId: string;
    worktreePath: string;
}
export interface ClaimOptions {
    /** Create a new branch with this name */
    branch?: string;
    /** Base ref to branch from (default: HEAD on default branch) */
    from?: string;
    /** Host path to the shared bare repo for team collaboration */
    teamRepoPath?: string;
}
/**
 * Configure a 'team' git remote and post-commit hook in a clone directory.
 * The remote URL uses the container-internal /team-repos/ path so it resolves
 * correctly inside Docker via bind-mount.
 */
export declare function setupTeamRemote(worktreePath: string, teamRepoPath: string): void;
export declare class SandboxPool {
    readonly options: SandboxPoolOptions;
    private slots;
    private _shutdownRequested;
    private _replenishing;
    readonly label: string;
    private _poolDir;
    private _defaultBranch;
    constructor(options: SandboxPoolOptions);
    /** Host path to the pool directory (used to resolve team repo paths on restore). */
    get poolDir(): string;
    /** Initialize the pool: detect branch, ensure dirs, kill old containers.
     *  Call warmup() separately to pre-warm spare containers in the background. */
    init(): Promise<void>;
    /** Pre-warm spare containers and clean up stale directories.
     *  Safe to call fire-and-forget — errors are caught and logged. */
    warmup(): Promise<void>;
    /**
     * Claim an idle slot. Optionally check out a branch.
     * If no idle slots are available, creates one on-demand.
     * Validates the container is alive before handing it out.
     */
    claim(sessionId: string, opts?: ClaimOptions): Promise<ClaimResult | null>;
    /** Release a session from its slot. Destroys the slot when all sessions are done. */
    release(sessionId: string, containerId: string): Promise<void>;
    /** Get pool statistics. */
    getStats(): {
        enabled: boolean;
        total: number;
        idle: number;
        claimed: number;
        warming: number;
    };
    /** Graceful shutdown: drain sessions, stop containers, clean up directories. */
    shutdown(): Promise<void>;
    /** No-op — kept for API compatibility. Simplified pool has no timers. */
    dispose(): void;
    /** Create a new pool slot: clone repo + create container. Returns the slot, or undefined on failure. */
    private _createSlot;
    /** Build docker run args for a pool container. */
    private _buildDockerArgs;
    /**
     * Create a shared bare git repo for a sandboxed team.
     * Idempotent — returns existing path if already created.
     */
    createTeamRepo(goalId: string, sourceRepo: string, branch: string): Promise<string>;
    /**
     * Destroy the shared bare repo for a team. Retries on Windows lock failures.
     */
    destroyTeamRepo(goalId: string): Promise<void>;
    /** Checkout a branch in a slot's clone. */
    private _checkoutBranch;
    /** Quick liveness probe — returns true if the container is running. */
    private _isContainerAlive;
    /** Destroy a slot entirely (kill container, remove clone directory). */
    private _destroySlot;
    /** Remove a pool slot's cloned repo from disk. Retries on Windows lock failures. */
    private _removeCloneDir;
    /** Kill all containers from previous gateway runs. No readoption — start fresh. */
    private _killAllPreviousContainers;
    /** Remove stale clone directories that have no matching container (async, non-blocking). */
    private _cleanupStaleCloneDirs;
    /** Fill pool back to target size. */
    private _replenish;
    private _countByState;
    private _statsString;
}
//# sourceMappingURL=sandbox-pool.d.ts.map