/**
 * Workflow Loader — multi-stage pipeline for resolving and loading workflows.
 *
 * Pipeline: Discover → Resolve → Validate → Load
 *
 * Each stage returns a typed discriminated result so callers get structured
 * error information without try/catch guesswork.
 *
 * Discovery (finding workflow files on disk) remains in `discovery.ts`.
 * This module handles everything after a workflow is discovered.
 */
import type { WorkflowDefinition } from "../types.ts";
import type { DiscoveredWorkflow } from "./discovery.ts";
export declare namespace WorkflowLoader {
    /** Successful pipeline result. */
    type Ok<T> = {
        ok: true;
        value: T;
    };
    /** Failed pipeline result with stage and error context. */
    type StageError<S extends string> = {
        ok: false;
        stage: S;
        error: unknown;
        message: string;
    };
    type StageResult<T, S extends string> = Ok<T> | StageError<S>;
    /** Input to the pipeline — a discovered workflow from disk. */
    type Plan = DiscoveredWorkflow;
    /** Output of the resolve stage. */
    type Resolved = Plan;
    /** Source validation warning — alias of the canonical type from types.ts. */
    type ValidationWarning = import("../types.ts").ValidationWarning;
    /** Output of the validate stage. */
    type Validated = Resolved & {
        warnings: ValidationWarning[];
    };
    /** Output of the load stage — the final result. */
    type Loaded = Validated & {
        definition: WorkflowDefinition;
    };
    interface Report {
        /** Called when a stage begins. */
        start?: (stage: "resolve" | "validate" | "load") => void;
        /** Called when source validation produces warnings. */
        warn?: (warnings: ValidationWarning[]) => void;
        /** Called when a stage fails. */
        error?: (stage: "resolve" | "validate" | "load", error: unknown, message: string) => void;
    }
    /** Verify the workflow file exists. */
    function resolve(plan: Plan): Promise<StageResult<Resolved, "resolve">>;
    /**
     * Read the workflow source and run agent-specific validation checks.
     * Validation warnings are non-fatal — the pipeline continues.
     */
    function validate(resolved: Resolved): Promise<StageResult<Validated, "validate">>;
    /**
     * Import the workflow module and extract the WorkflowDefinition.
     * Checks for common authoring mistakes (missing `.compile()`, wrong export).
     */
    function load(validated: Validated): Promise<StageResult<Loaded, "load">>;
    /**
     * Run the full pipeline: resolve → validate → load.
     *
     * Returns a structured result with the loaded WorkflowDefinition on success,
     * or a stage-specific error on failure.
     */
    function loadWorkflow(plan: Plan, report?: Report): Promise<StageResult<Loaded, "resolve" | "validate" | "load">>;
}
//# sourceMappingURL=loader.d.ts.map