import type { DevToolsSys } from "@builder.io/dev-tools/core";
import { EventEmitter } from "events";
import type { FusionConfig } from "$/ai-utils";
export declare enum InitState {
    IDLE = "IDLE",
    CHECKING_DIRECTORIES = "CHECKING_DIRECTORIES",
    CONFIGURING_GIT_REPO = "CONFIGURING_GIT_REPO",
    CONFIGURING_GIT_USER = "CONFIGURING_GIT_USER",
    INSTALLING_DEPENDENCIES = "INSTALLING_DEPENDENCIES",
    STASHING_CHANGES = "STASHING_CHANGES",
    COMPLETED = "COMPLETED",
    FAILED = "FAILED",
    CANCELLED = "CANCELLED"
}
export interface InitConfig {
    fusionConfig: FusionConfig;
    retryDelayMs?: number;
    maxRetryDelayMs?: number;
    sys: DevToolsSys;
    debug?: boolean;
    runSetupCommand: boolean;
}
export declare enum InitErrorType {
    FATAL = "fatal",
    SOFT_ERROR = "soft-error",
    HARD_ERROR = "hard-error"
}
export interface InitError {
    userMessage: string;
    contextForLLMs?: string;
    type: InitErrorType;
}
export interface InitExecutionResult {
    success: boolean;
    errors: InitError[];
}
export interface InitStatus {
    state: InitState;
    progress: number;
    message: string;
    error?: string;
    metadata?: Record<string, any>;
}
export interface OperationLogEntry {
    id: string;
    operation: string;
    state: InitState;
    startTime: number;
    endTime?: number;
    duration?: number;
    status: "started" | "completed" | "failed" | "aborted";
    error?: string;
    metadata?: Record<string, any>;
}
export interface InitStateMachineEvents {
    status: (status: InitStatus) => void;
    operation: (entry: OperationLogEntry) => void;
    error: (error: string, state: InitState) => void;
    complete: (success: boolean, finalState: InitState) => void;
    abort: (state: InitState) => void;
}
export interface TypedEventEmitter {
    on<K extends keyof InitStateMachineEvents>(event: K, listener: InitStateMachineEvents[K]): this;
    off<K extends keyof InitStateMachineEvents>(event: K, listener: InitStateMachineEvents[K]): this;
    emit<K extends keyof InitStateMachineEvents>(event: K, ...args: Parameters<InitStateMachineEvents[K]>): boolean;
}
export declare class InitStateMachine extends EventEmitter implements TypedEventEmitter {
    private currentState;
    private config;
    private retryCount;
    private metadata;
    private abortController;
    private activeChildProcesses;
    private readonly baseRetryDelay;
    private readonly maxRetryDelay;
    private readonly execAsync;
    private operationLog;
    private operationCounter;
    private readonly repositories;
    private allInitErrors;
    constructor(config: InitConfig);
    private updateStatus;
    private sanitizeError;
    private delay;
    private calculateRetryDelay;
    private executeWithRetry;
    private getProgress;
    private checkAborted;
    private checkDirectories;
    private isGitConfigured;
    private getGitRemoteUrl;
    private sanitizeGitRemoteUrl;
    private cloneRepository;
    private configureGitRepos;
    private configureGitUser;
    private installDependencies;
    private stashChanges;
    execute(signal?: AbortSignal): Promise<InitExecutionResult>;
    getCurrentState(): InitState;
    getMetadata(): Record<string, any>;
    getOperationLog(): OperationLogEntry[];
    cleanup(): Promise<void>;
    private startOperation;
    private completeOperation;
    private failOperation;
    private abortOperation;
    private getPerformanceStats;
}
