import { type Logger } from '../utility/logging/logger.ts';
interface ApplicationConfig {
    package: string;
    install?: {
        command?: string;
        timeout?: number;
        allowInstallScripts?: boolean;
    };
    [key: string]: unknown;
}
export declare class InvalidPackageIdentifierError extends TypeError {
    constructor(applicationName: string, packageIdentifier: unknown);
}
export declare class InvalidInstallPropertyError extends TypeError {
    constructor(applicationName: string, installProperty: unknown);
}
export declare class InvalidInstallCommandError extends TypeError {
    constructor(applicationName: string, command: unknown);
}
export declare class InvalidInstallTimeoutError extends TypeError {
    constructor(applicationName: string, timeout: unknown);
}
export declare function assertApplicationConfig(applicationName: string, applicationConfig: Record<'package', unknown> & Record<string, unknown>): asserts applicationConfig is ApplicationConfig;
/**
 * Extract an application given payload (content of the application) or package (npm-compatible identifier to the application).
 *
 * Only one of `application.payload` or `application.package` should be specified; otherwise, an error is thrown.
 *
 * Writes the application to the configured components root directory using the `application.name` and overwrites any existing directory.
 *
 * This method should only be called from the main thread
 */
export declare function extractApplication(application: Application): Promise<void>;
/**
 * Install an application to its relative `application.dirPath` using either a
 * configured `application.install` command, a derived package manager from the
 * application's `package.json#devEngines`, or falling back to the default
 * package manager, `npm`.
 *
 * Will return early if `node_modules` already exists within the `application.dirPath`
 *
 * This method should only be called from the main thread
 */
export declare function installApplication(application: Application): Promise<void>;
interface ApplicationOptions {
    name: string;
    payload?: Buffer | string;
    packageIdentifier?: string;
    install?: {
        command?: string;
        timeout?: number;
        allowInstallScripts?: boolean;
    };
}
export declare class Application {
    name: string;
    payload?: Buffer | string;
    packageIdentifier?: string;
    install?: {
        command?: string;
        timeout?: number;
        allowInstallScripts?: boolean;
    };
    dirPath: string;
    logger: Logger;
    packageManagerPrefix: string;
    constructor({ name, payload, packageIdentifier, install }: ApplicationOptions);
}
/**
 * Based on an old implementation for a method called `getPkgPrefix()` that was used
 * during the installation process in order to actually resolve what the user specifies for a
 * component matching some of npm's package resolution rules.
 */
export declare function derivePackageIdentifier(packageIdentifier: string): string;
/**
 * Extract and install the specified application.
 *
 * This method should only be called from the main thread
 *
 * @param application The application to prepare.
 * @returns A promise that resolves when all preparation steps complete.
 */
export declare function prepareApplication(application: Application): Promise<void>;
/**
 * Install all applications specified in the root config.
 *
 * This method should only be called from the main thread otherwise certain
 * operations may conflict with each other (such as writing to the same directory).
 */
export declare function installApplications(): Promise<void>;
/**
 * Execute a command (using `spawn`) with stdin ignored.
 *
 * Stdout is logged chunk-by-chunk. Stderr is buffered and then logged line-by-line.
 *
 * Rejects with an error if the command fails or times out.
 *
 * @param command The command to run.
 * @param args The arguments to pass to the command.
 * @param cwd The working directory for the command.
 * @param timeoutMs The timeout for the command in milliseconds. Defaults to 5 minutes.
 * @returns A promise that resolves when the command completes.
 */
export declare function nonInteractiveSpawn(applicationName: string, command: string, args: string[], cwd: string, timeoutMs?: number): Promise<{
    stdout: string;
    stderr: string;
    code: number;
}>;
export declare function getEnvBuiltInComponents(): {
    name: string;
    packageIdentifier: string;
}[];
export {};
