import type { DevToolsSys } from "@builder.io/dev-tools/core";
import { type FusionConfig, type WorkspaceFolder, type InitState, type InitStateStep, type InitStatusLog, type GitDiagnostics } from "$/ai-utils";
type ValidatedWorkspaceFolder = WorkspaceFolder & Required<Pick<WorkspaceFolder, "name" | "path">>;
type WorkspaceFolderWithRepoInfo = ValidatedWorkspaceFolder & Required<Pick<WorkspaceFolder, "repoName" | "repoUrl">>;
import type { Credentials } from "../credentials";
import { type GitBackupDownloadResult } from "../backup";
export interface InitConfig {
    fusionConfig: FusionConfig;
    credentials: Credentials;
    sys: DevToolsSys;
    debug?: boolean;
    sentryTags?: Record<string, string>;
}
export interface InitStatus {
    message: string;
    error?: string;
}
export declare class InitStateMachine {
    #private;
    logIdCounter: number;
    initStatusLogs: InitStatusLog[];
    sys: DevToolsSys;
    config: InitConfig;
    /**
     * @deprecated use addInitLog instead. Do not use this directly.
     */
    debug: boolean;
    initState: InitState;
    constructor(config: InitConfig);
    checkout(branchName: string, ref: string, repoPath: string): Promise<boolean>;
    execAsync(exec: string, args: string[], cwd?: string, retry?: number): Promise<string>;
    git(args: string[], cwd: string, retry?: number, timeout?: number, skipLogging?: boolean): Promise<string>;
    performBackup({ sys, credentials, fusionConfig, volumePath, repositories, isConnectedToProvider, forcedFullBackup, }: {
        sys: DevToolsSys;
        credentials: Credentials;
        fusionConfig: FusionConfig;
        volumePath: string;
        repositories: ValidatedWorkspaceFolder[];
        isConnectedToProvider: boolean;
        forcedFullBackup: boolean;
    }): Promise<void>;
    performRegularBackup(args: Omit<Parameters<typeof this.performBackup>[0], "isConnectedToProvider" | "forcedFullBackup">): Promise<void>;
    performOfflineBackup(args: Omit<Parameters<typeof this.performBackup>[0], "isConnectedToProvider" | "forcedFullBackup">): Promise<void>;
    performForcedFullBackup(args: Omit<Parameters<typeof this.performBackup>[0], "isConnectedToProvider" | "forcedFullBackup">): Promise<void>;
    init(): Promise<boolean>;
    addInitLog(type: "status" | "log" | "error" | "complete", message: string, options?: {
        step?: InitStateStep;
        error?: string;
        success?: boolean;
        gitDiagnostics?: GitDiagnostics;
    }): void;
    clearInitLogs(): void;
    hasFilesButNoGit(repoPath: string): Promise<boolean>;
    step1CheckDirectories(volumePath: string, repositories: ValidatedWorkspaceFolder[]): Promise<void>;
    step2ConfigureGitRepositories(volumePath: string, repositories: ValidatedWorkspaceFolder[]): Promise<void>;
    step3ConfigureGitUser(volumePath: string, repositories: ValidatedWorkspaceFolder[]): Promise<void>;
    step4CollectRepoInfo(config: InitConfig, volumePath: string, repositories: ValidatedWorkspaceFolder[]): Promise<void>;
    private isGitConfigured;
    private getGitRemoteUrl;
    /**
     * Check if the repository URL is from a standard git hosting provider
     */
    private isStandardGitHost;
    /**
     * Check if the repository host is reachable via network
     * Performs DNS resolution and TCP connection check
     */
    private checkHostConnectivity;
    private checkConnectivityDirect;
    private checkConnectivityViaProxy;
    /**
     * Ensures the parent directory of the given path exists.
     * Handles nested repo.path like "subdir/myproject".
     */
    private ensureParentDirExists;
    private cleanupLockFiles;
    validateGitRepo(repoPath: string): Promise<void>;
    /**
     * Check whether the backup's commit is already reachable from a local branch,
     * indicating the backup was already applied (e.g. after a container restart).
     */
    private isBackupAlreadyApplied;
    /**
     * If a backup is available, perform a backup recovery (and throw if it fails and cannot be recovered from).
     * If no backup is available, do nothing.
     */
    private restoreFromPartialBackup;
    private initializeGitRepo;
    private fetchGitConfigsOnce;
    private applyGitConfig;
    runInitializationCommand({ repo, tempCloningDir, repoPath, initCommand, }: {
        repo: ValidatedWorkspaceFolder;
        tempCloningDir: string;
        repoPath: string;
        initCommand: string;
    }): Promise<{
        outcome: boolean;
        error?: Error;
    }>;
    cloneRepository({ repo, repoPath, backupResult, }: {
        repo: WorkspaceFolderWithRepoInfo;
        repoPath: string;
        backupResult: GitBackupDownloadResult | undefined;
    }): Promise<boolean>;
    markGitSafe(repoPath: string): Promise<string>;
}
export {};
