/**
 * Preflight phase
 * ---------------
 *
 * The "before we touch anything heavy" phase. Runs in the parent process
 * only (the forked child re-enters deploy with `AGENTUITY_DEPLOYMENT`
 * already set, skipping this phase entirely).
 *
 * Responsibilities:
 *   1. Validate the deployment config in agentuity.json:
 *        - resource limits (`validateResources`)
 *        - apt dependencies (`validateAptDependencies`)
 *      Any failure is fatal: we deliberately surface it before creating a
 *      cloud deployment so we don't leave half-finished records lying
 *      around server-side.
 *   2. Create the deployment record on the server. The returned
 *      `Deployment` carries the deploy id, the public key for client-side
 *      encryption, and the stream URL the child process will tail logs
 *      from.
 *
 * Forking the child process is intentionally NOT in this phase. That
 * concern belongs in `deploy-fork.ts` which knows how to spawn, wire
 * stdio, capture diagnostics, and report cancellation. Preflight just
 * produces the inputs the fork module needs.
 */
import type { Logger } from '@agentuity/core';
import { type Deployment } from '@agentuity/server';
import type { APIClient } from '../../../api.ts';
import type { Config, Project } from '../../../types.ts';
type DeploymentConfigShape = NonNullable<Project['deployment']>;
export interface PreflightParams {
    /** Resolved project (output of the Register phase). */
    project: Project;
    /** API client for deployment creation. */
    apiClient: APIClient;
    /** CLI config for region resolution / overrides used by apt validation. */
    config: Config | null | undefined;
    /** Logger to thread through. */
    logger: Logger;
    /**
     * Whether the caller wants JSON output. Apt validation failures format
     * differently in JSON mode (so callers can render `errors[]` themselves
     * before we exit). When set, we throw `PreflightAptValidationError`
     * carrying the structured payload instead of fatal-rendering.
     */
    json: boolean;
}
export interface PreflightResult {
    /** Newly-created deployment record. */
    deployment: Deployment;
    /** The exact deployment config we sent to the server (echoed for callers). */
    deploymentConfig: DeploymentConfigShape;
}
/**
 * Thrown when apt validation fails AND the caller asked for JSON output.
 * The `payload` field is the structured error envelope the deploy command
 * returns from its handler; callers should serialize and exit.
 */
export declare class PreflightAptValidationError extends Error {
    readonly payload: {
        success: false;
        deploymentId: '';
        projectId: string;
        errors: Array<{
            type: 'invalid-apt-dependency';
            package: string;
            error: string;
            searchUrl: string;
            availableVersions?: string[];
        }>;
    };
    constructor(payload: PreflightAptValidationError['payload']);
}
/**
 * Run the preflight phase in the parent process. Fatals on validation
 * failure (or throws `PreflightAptValidationError` when `json: true`).
 * On success, returns the new `Deployment` and the config that produced it.
 */
export declare function runPreflight(params: PreflightParams): Promise<PreflightResult>;
export {};
//# sourceMappingURL=preflight.d.ts.map