import { ReadableStream } from 'node:stream/web';
import type { MastraPrimitives } from '../action/index.js';
import { Agent } from '../agent/index.js';
import type { AgentExecutionOptions, AgentStreamOptions } from '../agent/index.js';
import { MastraBase } from '../base.js';
import { RequestContext } from '../di/index.js';
import type { MastraScorers } from '../evals/index.js';
import type { PubSub } from '../events/pubsub.js';
import type { IMastraLogger } from '../logger/index.js';
import type { Mastra } from '../mastra/index.js';
import type { ObservabilityContext, TracingOptions, TracingPolicy } from '../observability/index.js';
import type { Processor } from '../processors/index.js';
import { ProcessorStepOutputSchema, ProcessorStepInputSchema } from '../processors/step-schema.js';
import type { InferPublicSchema, InferStandardSchemaOutput, PublicSchema, StandardSchemaWithJSON } from '../schema/index.js';
import type { StorageListWorkflowRunsInput } from '../storage/index.js';
import { WorkflowRunOutput } from '../stream/RunOutput.js';
import { Tool } from '../tools/index.js';
import type { ToolExecutionContext } from '../tools/index.js';
import type { DynamicArgument } from '../types/index.js';
import { PUBSUB_SYMBOL } from './constants.js';
import type { ExecutionEngine, ExecutionGraph } from './execution-engine.js';
import type { ConditionFunction, ExecuteFunction, InnerOutput, LoopConditionFunction, Step, SuspendOptions } from './step.js';
import type { DefaultEngineType, DynamicMapping, ExtractSchemaFromStep, ExtractSchemaType, PathsToStringProps, SerializedStepFlowEntry, StepFlowEntry, StepResult, StepsRecord, StepWithComponent, StreamEvent, SubsetOf, TimeTravelContext, WorkflowConfig, WorkflowEngineType, WorkflowOptions, WorkflowResult, WorkflowType, WorkflowRunStatus, WorkflowState, WorkflowStateField, WorkflowStreamEvent, StepParams, OutputWriter, StepMetadata, WorkflowRunStartOptions } from './types.js';
export type AgentStepOptions<TOUTPUT> = Omit<AgentExecutionOptions<TOUTPUT> & AgentStreamOptions, 'format' | 'tracingContext' | 'requestContext' | 'abortSignal' | 'context' | 'onStepFinish' | 'output' | 'experimental_output' | 'resourceId' | 'threadId' | 'scorers'>;
export declare function mapVariable<TStep extends Step<string, any, any, any, any, any>>({ step, path, }: {
    step: TStep;
    path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '.';
}): {
    step: TStep;
    path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '.';
};
export declare function mapVariable<TWorkflow extends AnyWorkflow>({ initData: TWorkflow, path, }: {
    initData: TWorkflow;
    path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TWorkflow, 'inputSchema'>>> | '.';
}): {
    initData: TWorkflow;
    path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TWorkflow, 'inputSchema'>>> | '.';
};
/**
 * Creates a step from explicit params (IMPORTANT: FIRST overload for best error messages when using .then in workflows)
 * @param params Configuration parameters for the step
 * @param params.id Unique identifier for the step
 * @param params.description Optional description of what the step does
 * @param params.inputSchema Zod schema defining the input structure
 * @param params.outputSchema Zod schema defining the output structure
 * @param params.execute Function that performs the step's operations
 * @returns A Step object that can be added to the workflow
 */
export declare function createStep<TStepId extends string, TStateSchema extends PublicSchema | undefined, TInputSchema extends PublicSchema, TOutputSchema extends PublicSchema, TResumeSchema extends PublicSchema | undefined = undefined, TSuspendSchema extends PublicSchema | undefined = undefined, TRequestContextSchema extends PublicSchema | undefined = undefined>(params: StepParams<TStepId, TStateSchema, TInputSchema, TOutputSchema, TResumeSchema, TSuspendSchema, TRequestContextSchema>): Step<TStepId, TStateSchema extends PublicSchema ? InferPublicSchema<TStateSchema> : unknown, InferPublicSchema<TInputSchema>, InferPublicSchema<TOutputSchema>, TResumeSchema extends PublicSchema ? InferPublicSchema<TResumeSchema> : unknown, TSuspendSchema extends PublicSchema ? InferPublicSchema<TSuspendSchema> : unknown, DefaultEngineType, TRequestContextSchema extends PublicSchema ? InferPublicSchema<TRequestContextSchema> : unknown>;
/**
 * Creates a step from an agent (defaults to { text: string } output)
 */
export declare function createStep<TStepId extends string>(agent: Agent<TStepId, any>, agentOptions?: Omit<AgentStepOptions<{
    text: string;
}>, 'structuredOutput'> & {
    structuredOutput?: never;
    retries?: number;
    scorers?: DynamicArgument<MastraScorers>;
}): Step<TStepId, unknown, {
    prompt: string;
}, {
    text: string;
}, unknown, unknown, DefaultEngineType>;
/**
 * Creates a step from an agent with structured output
 */
export declare function createStep<TStepId extends string, TStepOutput>(agent: Agent<TStepId, any>, agentOptions: Omit<AgentStepOptions<TStepOutput>, 'structuredOutput'> & {
    structuredOutput: {
        schema: StandardSchemaWithJSON<TStepOutput>;
    };
    retries?: number;
    scorers?: DynamicArgument<MastraScorers>;
    metadata?: StepMetadata;
}): Step<TStepId, unknown, {
    prompt: string;
}, TStepOutput, unknown, unknown, DefaultEngineType>;
/**
 * Creates a step from a tool
 */
export declare function createStep<TSchemaIn, TSchemaOut, TSuspend, TResume, TContext extends ToolExecutionContext<TSuspend, TResume, any>, TId extends string, TRequestContext extends Record<string, any> | unknown = unknown>(tool: Tool<TSchemaIn, TSchemaOut, TSuspend, TResume, TContext, TId, TRequestContext>, toolOptions?: {
    retries?: number;
    scorers?: DynamicArgument<MastraScorers>;
    metadata?: StepMetadata;
}): Step<TId, unknown, TSchemaIn, TSchemaOut, TSuspend, TResume, DefaultEngineType, TRequestContext>;
/**
 * Creates a step from a Processor - wraps a Processor as a workflow step
 * Note: We require at least one processor method to distinguish from StepParams
 */
export declare function createStep<TProcessorId extends string>(processor: (Processor<TProcessorId> & {
    processInput: Function;
}) | (Processor<TProcessorId> & {
    processInputStream: Function;
}) | (Processor<TProcessorId> & {
    processInputStep: Function;
}) | (Processor<TProcessorId> & {
    processOutputStream: Function;
}) | (Processor<TProcessorId> & {
    processOutputResult: Function;
}) | (Processor<TProcessorId> & {
    processOutputStep: Function;
})): Step<`processor:${TProcessorId}`, unknown, InferPublicSchema<typeof ProcessorStepInputSchema>, InferPublicSchema<typeof ProcessorStepOutputSchema>, unknown, unknown, DefaultEngineType>;
/**
 * IMPORTANT: Fallback overload - provides better error messages when StepParams doesn't match
 * This should be LAST and will show clearer errors about what's wrong
 * This is a copy of first one, KEEP THIS IN SYNC!
 */
export declare function createStep<TStepId extends string, TStateSchema extends PublicSchema | undefined, TInputSchema extends PublicSchema, TOutputSchema extends PublicSchema, TResumeSchema extends PublicSchema | undefined = undefined, TSuspendSchema extends PublicSchema | undefined = undefined, TRequestContextSchema extends PublicSchema | undefined = undefined>(params: StepParams<TStepId, TStateSchema, TInputSchema, TOutputSchema, TResumeSchema, TSuspendSchema, TRequestContextSchema>): Step<TStepId, TStateSchema extends PublicSchema ? InferPublicSchema<TStateSchema> : unknown, InferPublicSchema<TInputSchema>, InferPublicSchema<TOutputSchema>, TResumeSchema extends PublicSchema ? InferPublicSchema<TResumeSchema> : unknown, TSuspendSchema extends PublicSchema ? InferPublicSchema<TSuspendSchema> : unknown, DefaultEngineType, TRequestContextSchema extends PublicSchema ? InferPublicSchema<TRequestContextSchema> : unknown>;
export declare function cloneStep<TStepId extends string>(step: Step<string, any, any, any, any, any, DefaultEngineType>, opts: {
    id: TStepId;
}): Step<TStepId, any, any, any, any, any, DefaultEngineType>;
/**
 * Type guard to check if an object is a Processor.
 * A Processor must have an 'id' property and at least one processor method.
 */
export declare function isProcessor(obj: unknown): obj is Processor;
/**
 * A Workflow with all type parameters erased.
 * Use this instead of manually specifying `Workflow<any, any, ...>` so that
 * adding or removing type parameters only requires updating one place.
 */
export type AnyWorkflow = Workflow<any, any, any, any, any, any, any, any>;
export declare function createWorkflow<TWorkflowId extends string = string, TState = unknown, TInput = unknown, TOutput = unknown, TSteps extends Step<string, any, any, any, any, any, DefaultEngineType>[] = Step[], TRequestContext extends Record<string, any> | unknown = unknown>(params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>): Workflow<DefaultEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>;
export declare function cloneWorkflow<TWorkflowId extends string = string, TState = unknown, TInput = unknown, TOutput = unknown, TSteps extends Step<string, any, any, any, any, any, DefaultEngineType>[] = Step<string, any, any, any, any, any, DefaultEngineType>[], TPrevSchema = TInput>(workflow: Workflow<DefaultEngineType, TSteps, string, TState, TInput, TOutput, TPrevSchema>, opts: {
    id: TWorkflowId;
}): Workflow<DefaultEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema>;
export declare class Workflow<TEngineType = DefaultEngineType, TSteps extends Step<string, any, any, any, any, any, TEngineType, any>[] = Step<string, unknown, unknown, unknown, unknown, unknown, TEngineType>[], TWorkflowId extends string = string, TState = unknown, TInput = unknown, TOutput = unknown, TPrevSchema = TInput, TRequestContext extends Record<string, any> | unknown = unknown> extends MastraBase implements Step<TWorkflowId, TState, TInput, TOutput | undefined, any, any, DefaultEngineType, TRequestContext> {
    #private;
    id: TWorkflowId;
    description?: string | undefined;
    inputSchema: StandardSchemaWithJSON<TInput>;
    outputSchema: StandardSchemaWithJSON<TOutput>;
    stateSchema?: StandardSchemaWithJSON<TState>;
    requestContextSchema?: StandardSchemaWithJSON<TRequestContext>;
    steps: Record<string, StepWithComponent>;
    stepDefs?: TSteps;
    engineType: WorkflowEngineType;
    /** Type of workflow - 'processor' for processor workflows, 'default' otherwise */
    type: WorkflowType;
    committed: boolean;
    protected stepFlow: StepFlowEntry<TEngineType>[];
    protected serializedStepFlow: SerializedStepFlowEntry[];
    protected executionEngine: ExecutionEngine;
    protected executionGraph: ExecutionGraph;
    retryConfig: {
        attempts?: number;
        delay?: number;
    };
    constructor({ mastra, id, inputSchema, outputSchema, stateSchema, requestContextSchema, description, executionEngine, retryConfig, steps, options, type, }: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>);
    get runs(): Map<string, Run<TEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>;
    get mastra(): Mastra<Record<string, Agent<any, import("../agent").ToolsInput, undefined, unknown>>, Record<string, AnyWorkflow>, Record<string, import("../vector").MastraVector<any>>, Record<string, import("../tts").MastraTTS>, IMastraLogger, Record<string, import("../mcp").MCPServerBase<any>>, Record<string, import("../evals").MastraScorer<any, any, any, any>>, Record<string, import("../tools").ToolAction<any, any, any, any, any, any, unknown>>, Record<string, Processor<any, unknown>>, Record<string, import("../memory").MastraMemory>, Record<string, import("../channels").ChannelProvider>> | undefined;
    get options(): Omit<WorkflowOptions, "validateInputs" | "shouldPersistSnapshot"> & Required<Pick<WorkflowOptions, "validateInputs" | "shouldPersistSnapshot">>;
    __registerMastra(mastra: Mastra): void;
    __registerPrimitives(p: MastraPrimitives): void;
    __setLogger(logger: IMastraLogger): void;
    setStepFlow(stepFlow: StepFlowEntry<TEngineType>[]): void;
    /**
     * Adds a step to the workflow
     * @param step The step to add to the workflow
     * @returns The workflow instance for chaining
     *
     * The step's inputSchema must be satisfied by the previous step's output (or workflow input for first step).
     * This means: TPrevSchema must be assignable to TStepInput
     */
    then<TStepId extends string, TStepState, TStepInput, TSchemaOut>(step: Step<TStepId, unknown extends TStepState ? TStepState : SubsetOf<TStepState, TState>, TPrevSchema extends TStepInput ? TStepInput : TPrevSchema, TSchemaOut, any, any, TEngineType, any>): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext>;
    /**
     * Adds a sleep step to the workflow
     * @param duration The duration to sleep for
     * @returns The workflow instance for chaining
     */
    sleep(duration: number | ExecuteFunction<TState, TPrevSchema, number, any, any, TEngineType>): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext>;
    /**
     * Adds a sleep until step to the workflow
     * @param date The date to sleep until
     * @returns The workflow instance for chaining
     */
    sleepUntil(date: Date | ExecuteFunction<TState, TPrevSchema, Date, any, any, TEngineType>): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext>;
    /**
     * @deprecated waitForEvent has been removed. Please use suspend/resume instead.
     */
    waitForEvent<TStepState, TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut>(_event: string, _step: Step<TStepId, SubsetOf<TStepState, TState>, TStepInputSchema, TSchemaOut, any, any, TEngineType>, _opts?: {
        timeout?: number;
    }): void;
    map(mappingConfig: {
        [k: string]: {
            step: Step<string, any, any, any, any, any, TEngineType, any> | Step<string, any, any, any, any, any, TEngineType, any>[];
            path: string;
        } | {
            value: any;
            schema: PublicSchema<any>;
        } | {
            initData: Workflow<TEngineType, any, any, any, any, any, any>;
            path: string;
        } | {
            requestContextPath: string;
            schema: PublicSchema<any>;
        } | DynamicMapping<TPrevSchema, any>;
    } | ExecuteFunction<TState, TPrevSchema, any, any, any, TEngineType>, stepOptions?: {
        id?: string | null;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, any, TRequestContext>;
    parallel<TParallelSteps extends readonly Step<string, any, TPrevSchema, any, any, any, TEngineType, any>[]>(steps: TParallelSteps & {
        [K in keyof TParallelSteps]: TParallelSteps[K] extends Step<string, infer S, TPrevSchema, infer O, any, // Don't infer TResume - causes issues with heterogeneous tuples
        any, // Don't infer TSuspend - causes issues with heterogeneous tuples
        TEngineType> ? Step<string, SubsetOf<S, TState>, TPrevSchema, O, any, any, TEngineType> : `Error: Expected Step with state schema that is a subset of workflow state`;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, { [K in keyof StepsRecord<TParallelSteps>]: InferStandardSchemaOutput<StepsRecord<TParallelSteps>[K]["outputSchema"]>; }, TRequestContext>;
    branch<TBranchSteps extends Array<[
        ConditionFunction<TState, TPrevSchema, any, any, any, TEngineType>,
        Step<string, any, TPrevSchema, any, any, any, TEngineType, any>
    ]>>(steps: TBranchSteps): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, { [K in keyof StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>]?: InferStandardSchemaOutput<StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>[K]["outputSchema"]>; }, TRequestContext>;
    dowhile<TStepState, TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut, TStepRC>(step: Step<TStepId, SubsetOf<TStepState, TState>, TStepInputSchema, TSchemaOut, any, any, TEngineType, unknown extends TStepRC ? unknown : TRequestContext>, condition: LoopConditionFunction<TState, TSchemaOut, any, any, any, TEngineType>): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext>;
    dountil<TStepState, TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut, TStepRC>(step: Step<TStepId, SubsetOf<TStepState, TState>, TStepInputSchema, TSchemaOut, any, any, TEngineType, unknown extends TStepRC ? unknown : TRequestContext>, condition: LoopConditionFunction<TState, TSchemaOut, any, any, any, TEngineType>): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext>;
    foreach<TPrevIsArray extends TPrevSchema extends any[] ? true : false, TStepState, TStepInputSchema extends TPrevSchema extends (infer TElement)[] ? TElement : never, TStepId extends string, TSchemaOut, TStepRC>(step: TPrevIsArray extends true ? Step<TStepId, SubsetOf<TStepState, TState>, TStepInputSchema, TSchemaOut, any, any, TEngineType, unknown extends TStepRC ? unknown : TRequestContext> : 'Previous step must return an array type', opts?: {
        concurrency: number;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut[], TRequestContext>;
    /**
     * Builds the execution graph for this workflow
     * @returns The execution graph that can be used to execute the workflow
     */
    buildExecutionGraph(): ExecutionGraph;
    /**
     * Finalizes the workflow definition and prepares it for execution
     * This method should be called after all steps have been added to the workflow
     * @returns A built workflow instance ready for execution
     */
    commit(): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TOutput, TRequestContext>;
    get stepGraph(): StepFlowEntry<TEngineType>[];
    get serializedStepGraph(): SerializedStepFlowEntry[];
    /**
     * Creates a new workflow run instance and stores a snapshot of the workflow in the storage
     * @param options Optional configuration for the run
     * @param options.runId Optional custom run ID, defaults to a random UUID
     * @param options.resourceId Optional resource ID to associate with this run
     * @param options.disableScorers Optional flag to disable scorers for this run
     * @returns A Run instance that can be used to execute the workflow
     */
    createRun(options?: {
        runId?: string;
        resourceId?: string;
        disableScorers?: boolean;
        /** Optional pubsub instance for streaming events. If not provided, a new EventEmitterPubSub is created. */
        pubsub?: PubSub;
    }): Promise<Run<TEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>;
    listScorers({ requestContext, }?: {
        requestContext?: RequestContext;
    }): Promise<MastraScorers>;
    execute({ runId, resourceId, inputData, resumeData, state, setState, suspend, restart, resume, timeTravel, [PUBSUB_SYMBOL]: pubsub, mastra, requestContext, abort, abortSignal, retryCount, outputWriter, validateInputs, perStep, engine: _engine, bail: _bail, ...rest }: {
        runId?: string;
        resourceId?: string;
        inputData: TInput;
        resumeData?: unknown;
        state: TState;
        setState: (state: TState) => Promise<void>;
        suspend: (suspendPayload: any, suspendOptions?: SuspendOptions) => InnerOutput | Promise<InnerOutput>;
        restart?: boolean;
        timeTravel?: {
            inputData?: TInput;
            steps: string[];
            nestedStepResults?: Record<string, Record<string, StepResult<any, any, any, any>>>;
            resumeData?: any;
        };
        resume?: {
            steps: string[];
            resumePayload: any;
            runId?: string;
            label?: string;
            forEachIndex?: number;
        };
        [PUBSUB_SYMBOL]: PubSub;
        mastra: Mastra;
        requestContext?: RequestContext<TRequestContext>;
        engine: DefaultEngineType;
        abortSignal: AbortSignal;
        bail: (result: any) => any;
        abort: () => any;
        retryCount?: number;
        outputWriter?: OutputWriter;
        validateInputs?: boolean;
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<TOutput | undefined>;
    listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<import("../storage").WorkflowRuns>;
    listActiveWorkflowRuns(): Promise<{
        runs: import("../storage").WorkflowRun[];
        total: number;
    }>;
    restartAllActiveWorkflowRuns(): Promise<void>;
    deleteWorkflowRunById(runId: string): Promise<void>;
    protected getWorkflowRunSteps({ runId, workflowId }: {
        runId: string;
        workflowId: string;
    }): Promise<Record<string, StepResult<any, any, any, any>>>;
    /**
     * Get a workflow run by ID with processed execution state and metadata.
     *
     * @param runId - The unique identifier of the workflow run
     * @param options - Configuration options for the result
     * @param options.withNestedWorkflows - Whether to include nested workflow steps (default: true)
     * @param options.fields - Specific fields to return (for performance optimization)
     * @returns The workflow run result with metadata and processed execution state, or null if not found
     */
    getWorkflowRunById(runId: string, options?: {
        withNestedWorkflows?: boolean;
        fields?: WorkflowStateField[];
    }): Promise<WorkflowState | null>;
}
/**
 * Represents a workflow run that can be executed
 */
export declare class Run<TEngineType = DefaultEngineType, TSteps extends Step<string, any, any, any, any, any, TEngineType, any>[] = Step<string, unknown, unknown, unknown, unknown, unknown, TEngineType>[], TState = unknown, TInput = unknown, TOutput = unknown, TRequestContext extends Record<string, any> | unknown = unknown> {
    #private;
    protected pubsub: PubSub;
    /**
     * Unique identifier for this workflow
     */
    readonly workflowId: string;
    /**
     * Unique identifier for this run
     */
    readonly runId: string;
    /**
     * Unique identifier for the resource this run is associated with
     */
    readonly resourceId?: string;
    /**
     * Whether to disable scorers for this run
     */
    readonly disableScorers?: boolean;
    /**
     * Options around how to trace this run
     */
    readonly tracingPolicy?: TracingPolicy;
    /**
     * Options around how to trace this run
     */
    readonly validateInputs?: boolean;
    /**
     * Internal state of the workflow run
     */
    protected state: Record<string, any>;
    /**
     * The execution engine for this run
     */
    executionEngine: ExecutionEngine;
    /**
     * The execution graph for this run
     */
    executionGraph: ExecutionGraph;
    /**
     * The serialized step graph for this run
     */
    serializedStepGraph: SerializedStepFlowEntry[];
    /**
     * The steps for this workflow
     */
    readonly workflowSteps: Record<string, StepWithComponent>;
    workflowRunStatus: WorkflowRunStatus;
    readonly workflowEngineType: WorkflowEngineType;
    get mastra(): Mastra<Record<string, Agent<any, import("../agent").ToolsInput, undefined, unknown>>, Record<string, AnyWorkflow>, Record<string, import("../vector").MastraVector<any>>, Record<string, import("../tts").MastraTTS>, IMastraLogger, Record<string, import("../mcp").MCPServerBase<any>>, Record<string, import("../evals").MastraScorer<any, any, any, any>>, Record<string, import("../tools").ToolAction<any, any, any, any, any, any, unknown>>, Record<string, Processor<any, unknown>>, Record<string, import("../memory").MastraMemory>, Record<string, import("../channels").ChannelProvider>> | undefined;
    streamOutput?: WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    protected closeStreamAction?: () => Promise<void>;
    protected executionResults?: Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    protected stateSchema?: StandardSchemaWithJSON<TState>;
    protected inputSchema?: StandardSchemaWithJSON<TInput>;
    protected requestContextSchema?: StandardSchemaWithJSON<any>;
    protected cleanup?: () => void;
    protected retryConfig?: {
        attempts?: number;
        delay?: number;
    };
    constructor(params: {
        workflowId: string;
        runId: string;
        resourceId?: string;
        stateSchema?: StandardSchemaWithJSON<TState>;
        inputSchema?: StandardSchemaWithJSON<TInput>;
        requestContextSchema?: StandardSchemaWithJSON<any>;
        executionEngine: ExecutionEngine;
        executionGraph: ExecutionGraph;
        mastra?: Mastra;
        retryConfig?: {
            attempts?: number;
            delay?: number;
        };
        cleanup?: () => void;
        serializedStepGraph: SerializedStepFlowEntry[];
        disableScorers?: boolean;
        tracingPolicy?: TracingPolicy;
        workflowSteps: Record<string, StepWithComponent>;
        validateInputs?: boolean;
        workflowEngineType: WorkflowEngineType;
        /** Optional pubsub instance. If not provided, a new EventEmitterPubSub is created. */
        pubsub?: PubSub;
    });
    get abortController(): AbortController;
    /**
     * Cancels the workflow execution.
     * This aborts any running execution and updates the workflow status to 'canceled' in storage.
     */
    cancel(): Promise<void>;
    protected _validateInput(inputData?: TInput): Promise<TInput | undefined>;
    protected _validateInitialState(initialState?: TState): Promise<TState | undefined>;
    protected _validateRequestContext(requestContext?: RequestContext): Promise<void>;
    protected _validateResumeData<TResume>(resumeData: TResume, suspendedStep?: StepWithComponent): Promise<any>;
    protected _validateTimetravelInputData<TInput>(inputData: TInput, step: Step<string, any, TInput, any, any, any, TEngineType, any>): Promise<TInput>;
    protected _start({ inputData, initialState, requestContext, outputWriter, tracingOptions, format, outputOptions, perStep, ...rest }: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & (TState extends unknown ? {
        initialState?: TState;
    } : {
        initialState: TState;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
        format?: 'legacy' | 'vnext' | undefined;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * Starts the workflow execution with the provided input
     * @param input The input data for the workflow
     * @returns A promise that resolves to the workflow output
     */
    start(args: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & (TState extends unknown ? {
        initialState?: TState;
    } : {
        initialState: TState;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
    } & WorkflowRunStartOptions): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * Starts the workflow execution without waiting for completion (fire-and-forget).
     * Returns immediately with the runId. The workflow executes in the background.
     * Use this when you don't need to wait for the result or want to avoid polling failures.
     * @param args The input data and configuration for the workflow
     * @returns A promise that resolves immediately with the runId
     */
    startAsync(args: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & (TState extends unknown ? {
        initialState?: TState;
    } : {
        initialState: TState;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
    } & WorkflowRunStartOptions): Promise<{
        runId: string;
    }>;
    /**
     * Starts the workflow execution with the provided input as a stream
     * @param input The input data for the workflow
     * @returns A promise that resolves to the workflow output
     */
    streamLegacy({ inputData, requestContext, onChunk, tracingOptions, ...rest }?: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
        onChunk?: (chunk: StreamEvent) => Promise<unknown>;
        tracingOptions?: TracingOptions;
    } & Partial<ObservabilityContext>): {
        stream: ReadableStream<StreamEvent>;
        getWorkflowState: () => Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    };
    /**
     * Observe the workflow stream
     * @returns A readable stream of the workflow events
     */
    observeStreamLegacy(): {
        stream: ReadableStream<StreamEvent>;
    };
    /**
     * Observe the workflow stream
     * @returns A readable stream of the workflow events
     */
    observeStream(): ReadableStream<WorkflowStreamEvent>;
    /**
     * Starts the workflow execution with the provided input as a stream
     * @param input The input data for the workflow
     * @returns A promise that resolves to the workflow output
     */
    stream({ inputData, requestContext, tracingOptions, closeOnSuspend, initialState, outputOptions, perStep, ...rest }: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & (TState extends unknown ? {
        initialState?: TState;
    } : {
        initialState: TState;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
        tracingOptions?: TracingOptions;
        closeOnSuspend?: boolean;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * Resumes the workflow execution with the provided input as a stream
     * @param input The input data for the workflow
     * @returns A promise that resolves to the workflow output
     */
    resumeStream<TResume>({ step, resumeData, requestContext, tracingOptions, forEachIndex, outputOptions, perStep, ...rest }?: {
        resumeData?: TResume;
        step?: Step<string, any, any, any, TResume, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, any, any, TResume, any, TEngineType, any>
        ] | string | string[];
        requestContext?: RequestContext<TRequestContext>;
        tracingOptions?: TracingOptions;
        forEachIndex?: number;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * @internal
     */
    watch(cb: (event: WorkflowStreamEvent) => void): () => void;
    /**
     * @internal
     */
    watchAsync(cb: (event: WorkflowStreamEvent) => void): Promise<() => void>;
    resume<TResume>(params: {
        resumeData?: TResume;
        step?: Step<string, any, any, any, TResume, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, any, any, TResume, any, TEngineType, any>
        ] | string | string[];
        label?: string;
        requestContext?: RequestContext<TRequestContext>;
        retryCount?: number;
        tracingOptions?: TracingOptions;
        outputWriter?: OutputWriter;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        forEachIndex?: number;
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * Restarts the workflow execution that was previously active
     * @returns A promise that resolves to the workflow output
     */
    restart(args?: {
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    protected _resume<TResume>(params: {
        resumeData?: TResume;
        step?: Step<string, any, any, TResume, any, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, any, TResume, any, any, TEngineType, any>
        ] | string | string[];
        label?: string;
        requestContext?: RequestContext<TRequestContext>;
        retryCount?: number;
        tracingOptions?: TracingOptions;
        outputWriter?: OutputWriter;
        format?: 'legacy' | 'vnext' | undefined;
        isVNext?: boolean;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        forEachIndex?: number;
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    protected _restart({ requestContext, outputWriter, tracingOptions, ...rest }: {
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    protected _timeTravel<TInput>({ inputData, resumeData, initialState, step: stepParam, context, nestedStepsContext, requestContext, outputWriter, tracingOptions, outputOptions, perStep, ...rest }: {
        inputData?: TInput;
        resumeData?: any;
        initialState?: TState;
        step: Step<string, any, TInput, any, any, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, TInput, any, any, any, TEngineType, any>
        ] | string | string[];
        context?: TimeTravelContext<any, any, any, any>;
        nestedStepsContext?: Record<string, TimeTravelContext<any, any, any, any>>;
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    timeTravel<TInput>(args: {
        inputData?: TInput;
        resumeData?: any;
        initialState?: TState;
        step: Step<string, any, TInput, any, any, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, TInput, any, any, any, TEngineType, any>
        ] | string | string[];
        context?: TimeTravelContext<any, any, any, any>;
        nestedStepsContext?: Record<string, TimeTravelContext<any, any, any, any>>;
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    timeTravelStream<TTravelInput>({ inputData, resumeData, initialState, step, context, nestedStepsContext, requestContext, tracingOptions, outputOptions, perStep, ...rest }: {
        inputData?: TTravelInput;
        initialState?: TState;
        resumeData?: any;
        step: Step<string, any, any, any, any, any, TEngineType, any> | [
            ...Step<string, any, any, any, any, any, TEngineType, any>[],
            Step<string, any, any, any, any, any, TEngineType, any>
        ] | string | string[];
        context?: TimeTravelContext<any, any, any, any>;
        nestedStepsContext?: Record<string, TimeTravelContext<any, any, any, any>>;
        requestContext?: RequestContext<TRequestContext>;
        tracingOptions?: TracingOptions;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        perStep?: boolean;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>;
    /**
     * @access private
     * @returns The execution results of the workflow run
     */
    _getExecutionResults(): Promise<WorkflowResult<TState, TInput, TOutput, TSteps>> | undefined;
}
//# sourceMappingURL=workflow.d.ts.map