/**
 * Shared build pipeline.
 *
 * Both `agentuity build` (the standalone command) and the deploy
 * command's "Build, Verify and Package" step go through this single
 * function. Each caller wraps the result with its own surface
 * (TUI progress, Step state machine, deploy-metadata emission), but
 * the core ordering — detect, typecheck, build, package — lives here
 * so the two paths can't drift apart again.
 *
 * Why ordering matters:
 *   1. Detect framework and detect monorepo *first*, because
 *      `monorepo` determines where staging output goes
 *      (`<monorepoRoot>/.agentuity`, not `<projectDir>/.agentuity`).
 *   2. Typecheck *before* the build, so a broken project fails fast
 *      without spending minutes compiling. The deploy flow has done
 *      this for a while; the standalone command used to typecheck
 *      after the build, which wasted CI time and hid type errors
 *      behind framework build noise.
 *   3. Adapter build receives the monorepo context (so it runs
 *      install at the workspace root, builds the subpackage in
 *      place, and copies the whole tree into the staging dir).
 *   4. Packaging writes launch metadata with `workingDirectory` set
 *      when monorepo is non-null, so pilot starts the process in
 *      the right subdirectory.
 */
import type { Logger, DeployOptions } from '../../types.ts';
import type { BuildReportCollector } from '../../build-report.ts';
import type { BuildResult } from './adapters/types.ts';
import { type MonorepoContext } from './detect/monorepo.ts';
import type { DetectedFramework, PackageJsonData } from './detect/types.ts';
import { type PackageResult } from './package/index.ts';
/**
 * Inputs the shared pipeline needs. The caller is responsible for
 * passing in a `logger` and `collector`; everything else is optional.
 *
 * `prediscovered` lets the deploy phase reuse the result of the
 * Discover step instead of re-running detection.
 */
export interface BuildPipelineInput {
    /** Absolute path to the user's project root (the subpackage in monorepo mode). */
    projectDir: string;
    logger: Logger;
    collector: BuildReportCollector;
    /** Optional pre-detected framework + package.json from a prior step. */
    prediscovered?: {
        framework: DetectedFramework;
        packageJson: PackageJsonData | null;
    } | null;
    /**
     * Override the staging output dir. Defaults to
     * `<monorepoRoot ?? projectDir>/.agentuity`.
     */
    outputDir?: string;
    /** Skip the type-check phase (used by `--dev` and CI-only builds). */
    skipTypeCheck?: boolean;
    /** Development-mode build (looser, sourcemaps, etc.). */
    dev?: boolean;
    projectId?: string;
    orgId?: string;
    region?: string;
    deploymentId?: string;
    deploymentOptions?: DeployOptions;
    deploymentConfig?: Record<string, unknown>;
}
export interface BuildPipelineOutput {
    framework: DetectedFramework;
    packageJson: PackageJsonData | null;
    monorepo: MonorepoContext | null;
    buildResult: BuildResult;
    packageResult: PackageResult;
    /** Absolute path to the staging output dir. */
    outputDir: string;
    /** Time spent in typecheck (ms). 0 if skipped. */
    typecheckMs: number;
    /** Time spent in the adapter build (ms). */
    buildMs: number;
    /** Human-readable log lines for the caller to render. */
    logs: string[];
}
/**
 * Error subclasses used to carry phase-specific context back to the
 * caller. Both callers map these onto their own surfaces: `agentuity
 * build` calls `tui.fatal`, the deploy step returns `stepError`.
 */
export declare class FrameworkDetectionError extends Error {
    readonly code = "NO_DEPLOYABLE_PROJECT";
    constructor();
}
export declare class TypecheckError extends Error {
    readonly code = "TYPECHECK_FAILED";
    /** Raw tsc output for the caller to render. */
    readonly output: string;
    constructor(output: string);
}
/**
 * Run the shared build pipeline. Throws `FrameworkDetectionError` or
 * `TypecheckError` on the structured failure cases; any other error
 * propagates as-is so the caller can decide how to surface it.
 */
export declare function runBuildPipeline(input: BuildPipelineInput): Promise<BuildPipelineOutput>;
//# sourceMappingURL=run.d.ts.map