import { exec } from "child_process";
import type { DevToolsSys } from "@builder.io/dev-tools/core";
import { type FusionConfig, type WorkspaceFolder, type InitState, type InitStateStep, type InitStatusLog } from "$/ai-utils";
import type { Credentials } from "../credentials";
import { type GitBackupDownloadResult } from "../backup";
export interface InitConfig {
    fusionConfig: FusionConfig;
    credentials: Credentials;
    sys: DevToolsSys;
    debug?: boolean;
}
export interface InitStatus {
    message: string;
    error?: string;
}
declare const _execAsync: typeof exec.__promisify__;
export declare class InitStateMachine {
    logIdCounter: number;
    initStatusLogs: InitStatusLog[];
    initState: InitState;
    debug: boolean;
    execAsync(...args: Parameters<typeof _execAsync>): Promise<{
        stdout: string | Buffer;
        stderr: string | Buffer;
    }>;
    init(config: InitConfig, signal?: AbortSignal): Promise<boolean>;
    addInitLog(type: "status" | "log" | "error" | "complete", message: string, options?: {
        step?: InitStateStep;
        error?: string;
        success?: boolean;
    }): void;
    clearInitLogs(): void;
    step1CheckDirectories(config: InitConfig, repositories: Required<WorkspaceFolder>[], signal?: AbortSignal): Promise<void>;
    step2ConfigureGitRepositories(config: InitConfig, repositories: Required<WorkspaceFolder>[], signal?: AbortSignal): Promise<void>;
    step3ConfigureGitUser(config: InitConfig, repositories: Required<WorkspaceFolder>[], signal?: AbortSignal): Promise<void>;
    step4StashChanges(config: InitConfig, repositories: Required<WorkspaceFolder>[], signal?: AbortSignal): Promise<void>;
    private isGitConfigured;
    private getGitRemoteUrl;
    private sanitizeGitRemoteUrl;
    validateGitRepo(repoPath: string): Promise<void>;
    /**
     * 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;
    cloneRepository({ repo, repoPath, signal, backupResult, }: {
        repo: Required<WorkspaceFolder>;
        repoPath: string;
        signal?: AbortSignal;
        backupResult: GitBackupDownloadResult | undefined;
    }): Promise<boolean>;
}
export {};
