import { ReadableStream } from 'node:stream/web';
import { z } from 'zod/v4';
import type { MastraPrimitives } from '../action/index.js';
import type { Agent } from '../agent/agent.js';
import type { SubAgent } from '../agent/subagent.js';
import type { ActorSignal } from '../auth/ee/index.js';
import { MastraBase } from '../base.js';
import type { ClassifierQuestions } from '../classifier/index.js';
import { Classifier } from '../classifier/index.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, Span, TracingOptions, TracingPolicy } from '../observability/index.js';
import { SpanType } from '../observability/index.js';
import type { Processor, ProcessorStepExecutor } from '../processors/index.js';
import { ProcessorStepOutputSchema, ProcessorStepInputSchema } from '../processors/step-schema.js';
import type { ProcessorStepInput, ProcessorStepOutput } from '../processors/step-schema.js';
import type { InferPublicSchema, InferStandardSchemaOutput, PublicSchema, StandardSchemaWithJSON } from '../schema/index.js';
import type { StorageListWorkflowRunsInput } from '../storage/index.js';
import type { WorkflowRunHeader } from '../storage/domains/workflows/journal.js';
import { WorkflowRunOutput } from '../stream/RunOutput.js';
import type { Tool } from '../tools/tool.js';
import type { ToolExecutionContext } from '../tools/types.js';
import type { DynamicArgument } from '../types/index.js';
import { HAND_BACK_STATE_SYMBOL, PARENT_STATE_SYMBOL, PUBSUB_SYMBOL } from './constants.js';
import type { ClassifierStepOutput } from './entry-executors/index.js';
import type { ExecutionEngine, ExecutionGraph } from './execution-engine.js';
import type { Predicate } from './predicate/index.js';
import type { ParentStateLink, StateBase } from './run-journal.js';
import type { WorkflowRunOwnership } from './run-ownership.js';
import type { RunStorage } from './run-storage.js';
import type { WorkflowScheduleConfig } from './scheduler/types.js';
import type { ConditionFunction, ExecuteFunction, InnerOutput, LoopConditionFunction, Step, SuspendOptions } from './step.js';
import type { AgentStepOptions, ClassifierStepOptions } from './step-factories.js';
import type { DefaultEngineType, DynamicMapping, ExtractSchemaFromStep, ExtractSchemaType, PathsToStringProps, SerializedStepFlowEntry, StepFlowEntry, StepResult, StepsRecord, StepWithComponent, StreamEvent, SubsetOf, TimeTravelContext, WorkflowConfig, WorkflowEngineType, WorkflowOptions, WorkflowStateTracingContext, WorkflowResult, WorkflowType, WorkflowRunState, NestedWorkflowParent, WorkflowRunStatus, WorkflowState, WorkflowStateField, WorkflowStreamEvent, StepParams, OutputWriter, StepMetadata, WorkflowRunStartOptions, ForeachOptions, StepFlowEntryOptions, InferWorkflowRequestContext } from './types.js';
export { createMappingStep, createStepFromAgent, createStepFromClassifier, createStepFromTool } from './step-factories.js';
export type { AgentStepOptions, ClassifierStepOptions } from './step-factories.js';
export type { ClassifierStepOutput } from './entry-executors/index.js';
/**
 * Wrap a declarative `Predicate` as a runtime condition callback so the
 * existing execution engine (which only knows how to call `condition(params)`)
 * can execute stored / declarative predicates unchanged.
 *
 * Exported for the rehydration path (workflows/dynamic), which rebuilds
 * conditional/loop entries from stored predicates.
 */
export declare function predicateToCondition(predicate: Predicate): (params: any) => Promise<boolean>;
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
 *
 * @example
 * ```typescript
 * import { createStep } from '@mastra/core/workflows';
 * import { z } from 'zod';
 *
 * const greet = createStep({
 *   id: 'greet',
 *   inputSchema: z.string(),
 *   outputSchema: z.string(),
 *   execute: async ({ inputData }) => `Hello, ${inputData}!`,
 * });
 * ```
 *
 * @see For documentation bundled with your installed package, locate
 * `@mastra/core/package.json` with your project's resolver or package-manager
 * tooling, then read `dist/docs/SKILL.md` from that package root and follow its
 * reference links. Use package-manager tools for virtual or archived packages.
 *
 * @see [Workflow documentation](https://mastra.ai/docs/workflows/overview)
 * if packaged docs are unavailable.
 */
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, InferWorkflowRequestContext<TRequestContextSchema>>;
/**
 * Creates a step from an agent (defaults to { text: string } output)
 */
export declare function createStep<TStepId extends string>(agent: SubAgent<TStepId, any> | 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: SubAgent<TStepId, any> | Agent<TStepId, any>, agentOptions: Omit<AgentStepOptions<TStepOutput>, 'structuredOutput'> & {
    structuredOutput: {
        schema: PublicSchema<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;
    actor?: ActorSignal;
}): Step<TId, unknown, TSchemaIn, TSchemaOut, TSuspend, TResume, DefaultEngineType, TRequestContext>;
/** Creates a workflow step from a configured Classifier. */
export declare function createStep<const QUESTIONS extends ClassifierQuestions, TStepInput = unknown>(classifier: Classifier<QUESTIONS>, options?: ClassifierStepOptions<TStepInput>): Step<string, unknown, TStepInput, ClassifierStepOutput<QUESTIONS>, unknown, unknown, DefaultEngineType>;
/**
 * 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, TInput extends InferPublicSchema<typeof ProcessorStepInputSchema> | InferPublicSchema<typeof ProcessorStepOutputSchema> = InferPublicSchema<typeof ProcessorStepInputSchema>>(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;
}) | (Processor<TProcessorId> & {
    processToolResult: Function;
}) | (Processor<TProcessorId> & {
    computeStateSignal: Function;
})): Step<`processor:${TProcessorId}`, unknown, TInput, 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, InferWorkflowRequestContext<TRequestContextSchema>>;
/** @internal Builds the adapter shared by processor workflows and direct stream execution. */
export declare function createStepFromProcessor<TProcessorId extends string>(processor: Processor<TProcessorId>): Step<`processor:${TProcessorId}`, unknown, z.infer<typeof ProcessorStepInputSchema>, z.infer<typeof ProcessorStepOutputSchema>, unknown, unknown, DefaultEngineType> & {
    execute: ProcessorStepExecutor<ProcessorStepInput | ProcessorStepOutput>;
    providesSkillDiscovery?: Processor['providesSkillDiscovery'];
};
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>;
/**
 * Compile-time guard for the declarative `.agent()` builder. Agent steps require a
 * `{ prompt: string }` input. When the previous step output `TPrev` is assignable to
 * that, this resolves to `unknown` (a no-op intersection); otherwise it resolves to a
 * branded object the passed agent can't satisfy, surfacing a readable error on the
 * argument that names the expected input.
 *
 * `[any] extends [...]` is `true` => `unknown`, so a `.map()` returning `any` stays a
 * deliberate escape hatch. A `unknown`/mismatched prev output errors. The tuple wrap
 * prevents distribution over union prev-output types.
 */
type RequireAgentInput<TPrev> = [TPrev] extends [{
    prompt: string;
}] ? unknown : {
    readonly __chainError: 'Previous step output must be assignable to { prompt: string }';
    readonly expectedInput: {
        prompt: string;
    };
    readonly receivedPrevOutput: TPrev;
};
/**
 * Expected shape of one step passed to `.parallel()`. Distributes over unions so a
 * non-tuple array of different steps is checked step by step. Input follows the
 * `.then()` rule: the previous output only has to satisfy the step's input.
 */
type ParallelStepCheck<TStep, TState, TPrevSchema, TEngineType, TRequestContext> = TStep extends Step<string, infer S, infer TStepInput, infer O, any, // Don't infer TResume - causes issues with heterogeneous tuples
any, // Don't infer TSuspend - causes issues with heterogeneous tuples
TEngineType, infer TStepRC> ? Step<string, SubsetOf<S, TState>, TPrevSchema extends TStepInput ? TStepInput : TPrevSchema, O, any, any, TEngineType, unknown extends TStepRC ? unknown : TRequestContext> : `Error: Expected Step with state schema that is a subset of workflow state`;
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, TStorageVersion extends 1 | 2 = any> extends MastraBase implements Step<TWorkflowId, TState, TInput, TOutput | undefined, any, any, DefaultEngineType, TRequestContext> {
    #private;
    id: TWorkflowId;
    description?: string | undefined;
    metadata?: Record<string, unknown> | 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;
    /** Where this workflow came from: 'code' for statically registered workflows, 'dynamic' for workflows rehydrated from storage. Set by rehydrateWorkflow; defaults to 'code'. */
    origin: 'code' | 'dynamic';
    isInternal: boolean;
    committed: boolean;
    protected stepFlow: StepFlowEntry<TEngineType>[];
    protected serializedStepFlow: SerializedStepFlowEntry[];
    protected executionEngine: ExecutionEngine;
    /**
     * @internal For run-scoped agent loops only. Overrides the parent saved on
     * suspension without changing live tracing. Ordinary workflows derive it
     * from their execution span instead.
     */
    __setResumeTracingContext(context: WorkflowStateTracingContext | undefined): void;
    /**
     * @internal Currently set by normal agent loops. Evented persistence also
     * honors it for engine parity: changing engines must not change the saved parent.
     */
    __getResumeTracingContext(): WorkflowStateTracingContext | undefined;
    protected executionGraph: ExecutionGraph;
    retryConfig: {
        attempts?: number;
        delay?: number;
    };
    constructor({ mastra, id, inputSchema, outputSchema, stateSchema, requestContextSchema, description, metadata, executionEngine, retryConfig, steps, options, type, schedule, }: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext, TStorageVersion>);
    get runs(): Map<string, Run<TEngineType, TSteps, TState, TInput, TOutput, TRequestContext, TStorageVersion>>;
    get mastra(): Mastra<Record<string, Agent<any, import("../agent").ToolsInput, undefined, any, import("../agent").AgentEditorConfig | undefined>>, 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>, Record<string, Classifier<any>>, Record<string, import("../knowledge").Knowledge>> | undefined;
    get options(): Omit<WorkflowOptions<TStorageVersion>, "shouldPersistSnapshot" | "validateInputs"> & Required<Pick<WorkflowOptions<TStorageVersion>, "shouldPersistSnapshot" | "validateInputs">>;
    /**
     * Returns the cron schedule configurations declared on this workflow as a
     * normalized array. Used by the Mastra scheduler to register declarative
     * schedules at boot. Returns an empty array when no schedule is declared.
     */
    getScheduleConfigs(): WorkflowScheduleConfig[];
    __registerMastra(mastra: Mastra): void;
    __markInternal(): void;
    __registerPrimitives(p: MastraPrimitives): void;
    __setLogger(logger: IMastraLogger): void;
    setStepFlow(stepFlow: StepFlowEntry<TEngineType>[]): void;
    /**
     * @internal Rehydration-only (workflows/dynamic). Appends a fully-built
     * graph entry without laundering it through the live-`Step` builder
     * overloads: rehydration already holds the declarative entry it parsed from
     * storage, so wrapping it in a fake `Step` just so the builder can sniff it
     * back into the same entry would lose data (options, ids) and lie to the
     * type system. Mirrors the bookkeeping the public builder methods do:
     * pushes the live + serialized entries and registers inner steps in
     * `this.steps`.
     */
    __pushStepFlowEntry(live: StepFlowEntry<TEngineType>, serialized: SerializedStepFlowEntry): 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, TStorageVersion>;
    /** Adds a configured classifier as a declarative workflow step. */
    classifier<const QUESTIONS extends ClassifierQuestions>(classifier: Classifier<QUESTIONS>, options?: ClassifierStepOptions<TPrevSchema>, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, ClassifierStepOutput<QUESTIONS>, TRequestContext, TStorageVersion>;
    classifier<const QUESTIONS extends ClassifierQuestions = ClassifierQuestions>(classifierId: string, options?: ClassifierStepOptions<TPrevSchema>, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, ClassifierStepOutput<QUESTIONS>, TRequestContext, TStorageVersion>;
    /**
     * Adds an agent as a declarative `{ type: 'agent' }` step to the workflow.
     *
     * The step output is the agent's structured output (when `structuredOutput` is
     * provided) or `{ text: string }` otherwise.
     */
    agent<TStepId extends string>(agent: (SubAgent<TStepId, any> | Agent<TStepId, any>) & RequireAgentInput<TPrevSchema>, options?: Omit<AgentStepOptions<{
        text: string;
    }>, 'structuredOutput'> & {
        structuredOutput?: never;
        retries?: number;
        scorers?: DynamicArgument<MastraScorers>;
        metadata?: StepMetadata;
    }, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, {
        text: string;
    }, TRequestContext, TStorageVersion>;
    agent<TStepId extends string, TStepOutput>(agent: (SubAgent<TStepId, any> | Agent<TStepId, any>) & RequireAgentInput<TPrevSchema>, options: Omit<AgentStepOptions<TStepOutput>, 'structuredOutput'> & {
        structuredOutput: {
            schema: PublicSchema<TStepOutput>;
        };
        retries?: number;
        scorers?: DynamicArgument<MastraScorers>;
        metadata?: StepMetadata;
    }, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TStepOutput, TRequestContext, TStorageVersion>;
    agent(agentId: string, options?: AgentStepOptions<any> & {
        retries?: number;
        scorers?: DynamicArgument<MastraScorers>;
        metadata?: StepMetadata;
    }, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, {
        text: string;
    }, TRequestContext, TStorageVersion>;
    /**
     * Adds a tool as a declarative `{ type: 'tool' }` step to the workflow.
     *
     * The step output type is the tool's `outputSchema` type; the input it accepts
     * is the tool's `inputSchema` type.
     */
    tool<TSchemaIn, TSchemaOut, TSuspend, TResume, TContext extends ToolExecutionContext<TSuspend, TResume, any>, TId extends string, TToolRC extends Record<string, any> | unknown = unknown>(tool: Tool<TPrevSchema extends TSchemaIn ? TSchemaIn : TPrevSchema, TSchemaOut, TSuspend, TResume, TContext, TId, TToolRC>, options?: {
        retries?: number;
        scorers?: DynamicArgument<MastraScorers>;
        metadata?: StepMetadata;
    }, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext, TStorageVersion>;
    tool(toolId: string, options?: {
        retries?: number;
        scorers?: DynamicArgument<MastraScorers>;
        metadata?: StepMetadata;
    }, stepOptions?: {
        id?: string;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, unknown, TRequestContext, TStorageVersion>;
    /**
     * Adds a sleep step to the workflow
     * @param duration The duration to sleep for
     * @param options Optional stable `id`, `description`, and `metadata` for the entry
     * @returns The workflow instance for chaining
     */
    sleep(duration: number | ExecuteFunction<TState, TPrevSchema, number, any, any, TEngineType>, options?: StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext, TStorageVersion>;
    /**
     * Adds a sleep until step to the workflow
     * @param date The date to sleep until
     * @param options Optional stable `id`, `description`, and `metadata` for the entry
     * @returns The workflow instance for chaining
     */
    sleepUntil(date: Date | ExecuteFunction<TState, TPrevSchema, Date, any, any, TEngineType>, options?: StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext, TStorageVersion>;
    /**
     * @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>;
        }
        /**
         * String template with `${<scope>.<path>}` placeholders. Resolved at
         * run time against the step's execution context.
         *
         * Scopes: `inputData`, `initData`, `state`, `requestContext`,
         * `stepResults.<stepId>`. Paths are dotted (`a.b.c`). Whitespace
         * inside placeholders is not allowed (`${ inputData.x }` errors at
         * workflow-definition time). Renders `null`/`undefined` as `''`;
         * throws on objects/arrays.
         */
         | {
            template: string;
        } | DynamicMapping<TPrevSchema, any>;
    } | ExecuteFunction<TState, TPrevSchema, any, any, any, TEngineType>, stepOptions?: {
        id?: string | null;
        description?: string;
        metadata?: StepMetadata;
    }): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, any, TRequestContext, TStorageVersion>;
    parallel<TParallelSteps extends readonly Step<string, any, any, any, any, any, TEngineType, any>[]>(steps: TParallelSteps & {
        [K in keyof TParallelSteps]: ParallelStepCheck<TParallelSteps[K], TState, TPrevSchema, TEngineType, TRequestContext>;
    }, options?: StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, { [K in keyof StepsRecord<TParallelSteps>]: InferStandardSchemaOutput<StepsRecord<TParallelSteps>[K]['outputSchema']>; }, TRequestContext, TStorageVersion>;
    branch<TBranchSteps extends Array<[
        ConditionFunction<TState, TPrevSchema, any, any, any, TEngineType> | {
            predicate: Predicate;
        },
        Step<string, any, TPrevSchema, any, any, any, TEngineType, any>
    ]>>(steps: TBranchSteps, options?: StepFlowEntryOptions): 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, TStorageVersion>;
    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> | {
        predicate: Predicate;
    }, options?: StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext, TStorageVersion>;
    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> | {
        predicate: Predicate;
    }, options?: StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut, TRequestContext, TStorageVersion>;
    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?: Partial<ForeachOptions> & StepFlowEntryOptions): Workflow<TEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TSchemaOut[], TRequestContext, TStorageVersion>;
    /**
     * 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, TStorageVersion>;
    get stepGraph(): StepFlowEntry<TEngineType>[];
    get serializedStepGraph(): SerializedStepFlowEntry[];
    /**
     * Takes the nested-run handoff set by execute() and clears it, so a later top-level createRun()
     * on the same instance cannot inherit it. Concurrent parent runs share the workflow instance, so
     * this must be taken synchronously, before the first await.
     */
    protected takeNestedRun(): {
        /** The parent run's storage version, which a new nested run takes. */
        storageVersion: 1 | 2;
        /** Set when execute() starts the nested run rather than resuming or restarting it. */
        start?: {
            input: TInput;
            state: TState;
            inheritedState?: StateBase;
        };
    } | undefined;
    /**
     * Resolves the storage version a createRun() call uses, and reads the stored run that call
     * reopens. Shared by the default and evented engines so their rules cannot drift.
     *
     * A stored run keeps the version it was created with, whatever the workflow sets now. A new
     * nested run takes its parent run's version, so the version its parent looks it up under is the
     * one it is stored in. A new top-level run takes the workflow's option, or the automatic choice.
     * Only a caller-given top-level id can name a run stored in the other version's table.
     */
    protected resolveRunStorage({ runId, reopen, cachedRun, nestedRun, lookUpStoredRun, }: {
        runId: string;
        /** The caller supplied this id, so it may name a run created earlier. */
        reopen: boolean;
        cachedRun?: {
            storageVersion: 1 | 2;
        };
        nestedRun?: {
            storageVersion: 1 | 2;
        };
        /** The run can be in storage: the snapshot policy persists it, or the caller named it. */
        lookUpStoredRun: boolean;
    }): Promise<{
        storageVersion: 1 | 2;
        existsInStorage: boolean;
        stored?: Pick<WorkflowRunState, 'status' | 'parentWorkflow'>;
    }>;
    /**
     * 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;
        /**
         * Overrides the workflow-wide `shouldPersistSnapshot` option for this run only.
         * Used for transient runs that must never touch storage even when the workflow
         * persists normally (e.g. per-chunk agent output-processor runs, #19605).
         */
        shouldPersistSnapshot?: WorkflowOptions['shouldPersistSnapshot'];
        /** Overrides the workflow-wide tracing policy for this run only. */
        tracingPolicy?: TracingPolicy;
        parentWorkflow?: NestedWorkflowParent;
    }): Promise<Run<TEngineType, TSteps, TState, TInput, TOutput, TRequestContext, TStorageVersion>>;
    listScorers({ requestContext, }?: {
        requestContext?: RequestContext;
    }): Promise<MastraScorers>;
    execute({ runId, resourceId, inputData, resumeData, state, setState, suspend, restart, resume, timeTravel, parentWorkflow, [PUBSUB_SYMBOL]: pubsub, [PARENT_STATE_SYMBOL]: parentState, [HAND_BACK_STATE_SYMBOL]: handBackState, mastra, requestContext, abort, abortSignal, retryCount, outputWriter, validateInputs, perStep, actor, engine: _engine, bail: _bail, tracing, tracingContext, loggerVNext, metrics, }: {
        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;
        };
        parentWorkflow?: NestedWorkflowParent;
        resume?: {
            steps: string[];
            resumePayload: any;
            runId?: string;
            label?: string;
            forEachIndex?: number;
        };
        [PUBSUB_SYMBOL]: PubSub;
        [PARENT_STATE_SYMBOL]?: ParentStateLink;
        [HAND_BACK_STATE_SYMBOL]?: (state: TState, base: Record<string, unknown>) => Promise<void>;
        mastra: Mastra;
        requestContext?: RequestContext<TRequestContext>;
        engine: DefaultEngineType;
        abortSignal: AbortSignal;
        bail: (result: any) => any;
        abort: () => any;
        retryCount?: number;
        outputWriter?: OutputWriter;
        validateInputs?: boolean;
        perStep?: boolean;
        actor?: ActorSignal;
    } & 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, options?: {
        storageVersion: 1 | 2;
    }): 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, TStorageVersion extends 1 | 2 = any> {
    #private;
    protected workflowRunSpan?: Span<SpanType.WORKFLOW_RUN>;
    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;
    readonly isInternalWorkflow: boolean;
    /**
     * 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;
    parentWorkflow?: NestedWorkflowParent;
    readonly workflowEngineType: WorkflowEngineType;
    /**
     * How this run is stored: the version it was stored with, or for a new run the workflow's
     * `storageVersion` option.
     * @experimental
     */
    readonly storageVersion: 1 | 2;
    /**
     * For the next start or time travel of a storage v2 nested run: the stored version of its parent's
     * state it starts from and stores only its changes to. Set by `createRun`, taken by `_start` and
     * `_timeTravel`.
     * @internal
     */
    inheritedState?: StateBase;
    /**
     * For a nested run its parent resumes: the state it resumed from, as JSON. Its parent already
     * holds that state, so it takes only the changes after it. Set by `_resume`, taken by the parent's step.
     * @internal
     */
    resumedFromState?: Record<string, unknown>;
    /**
     * For a nested run its parent starts: the state it started from after its `stateSchema` parsed
     * it, as JSON. Its changes are taken relative to this, so a schema default or transform isn't
     * mistaken for one. Set by `_start`, taken by the parent's step.
     * @internal
     */
    startedFromState?: Record<string, unknown>;
    /**
     * The store calls this run makes, for its `storageVersion`.
     * @internal
     */
    readonly runStorage: RunStorage;
    get mastra(): Mastra<Record<string, Agent<any, import("../agent").ToolsInput, undefined, any, import("../agent").AgentEditorConfig | undefined>>, 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>, Record<string, Classifier<any>>, Record<string, import("../knowledge").Knowledge>> | undefined;
    streamOutput?: WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    protected closeStreamAction?: () => Promise<void>;
    protected executionResults?: Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    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;
        parentWorkflow?: NestedWorkflowParent;
        resourceId?: string;
        isInternalWorkflow?: boolean;
        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;
        /** @experimental Defaults to 1. */
        storageVersion?: 1 | 2;
        /** Whether the boot-time recovery sweep may restart this run, so it must hold an ownership lease while it executes. */
        recoverable?: boolean;
    });
    get abortController(): AbortController;
    /**
     * Whether the run has already finished, according to either its in-memory status or its persisted snapshot.
     * The snapshot covers runs finished by another Run instance; the in-memory status covers runs without storage
     * or whose terminal snapshot was not persisted.
     */
    protected hasReachedTerminalStatus(): Promise<boolean>;
    /**
     * Cancels a canceled run's suspended nested runs. Running nested runs are canceled through the abort signal.
     * `header` is the storage v2 header the cancel just stored, so it isn't read again.
     * @throws When reading this run, or reading or updating a nested run, fails.
     */
    protected cancelSuspendedNestedRuns(header?: WorkflowRunHeader): Promise<void>;
    /**
     * Cancels the workflow execution.
     * This aborts any running execution and updates the workflow status to 'canceled' in storage,
     * along with the status of its suspended nested workflow runs.
     * Runs that already finished (success, failed, canceled, tripwire, bailed) are left unchanged.
     * Canceling an already canceled run cancels any of its nested runs that are still suspended.
     */
    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 _resolveTimetravelInputData(inputData: unknown, steps: string[]): Promise<any>;
    protected _start({ inputData, initialState, requestContext, outputWriter, tracingOptions, format, outputOptions, perStep, actor, ...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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>, onDispatched?: () => void): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * 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, TStorageVersion>>;
    /**
     * Starts the workflow execution without waiting for completion (fire-and-forget).
     * Returns with the runId after startup validation, lifecycle hooks, and durable dispatch complete.
     * The workflow continues executing 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 with the runId after startup validation, lifecycle hooks, and durable dispatch,
     * or rejects if any of those operations fail
     */
    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, actor, ...rest }?: (TInput extends unknown ? {
        inputData?: TInput;
    } : {
        inputData: TInput;
    }) & {
        requestContext?: RequestContext<TRequestContext>;
        onChunk?: (chunk: StreamEvent) => Promise<unknown>;
        tracingOptions?: TracingOptions;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): {
        stream: ReadableStream<StreamEvent>;
        getWorkflowState: () => Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    };
    /**
     * 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, actor, ...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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * 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, actor, ...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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * @internal
     */
    watch(cb: (event: WorkflowStreamEvent) => void | Promise<void>): () => void;
    /**
     * @internal
     */
    watchAsync(cb: (event: WorkflowStreamEvent) => void | Promise<void>): Promise<() => void>;
    /** @internal */
    resumeNestedByParent(params: Parameters<this['resume']>[0]): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * Resumes a run whose suspension the caller already claimed (`suspended -> running`) in storage.
     * Skips the built-in claim and the `suspended` status check, which a claimed run no longer passes.
     * @internal
     */
    resumeClaimed(params: Parameters<this['resume']>[0] & {
        claimedSnapshot: WorkflowRunState;
        onExecutionStarted?: () => void;
    }): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * Resumes a suspended workflow without waiting for completion (fire-and-forget).
     * Returns immediately with the runId after dispatching the resume.
     *
     * The resume executes in the background and the result is never awaited. Engines that
     * poll for results (e.g. Inngest) override this with an implementation that skips polling
     * entirely, which avoids the `getRunOutput()` polling race.
     *
     * NOTE: this is exposed over HTTP / the client SDK as `resume-no-wait` / `resumeNoWait()`,
     * not `resumeAsync`, because the existing `resumeAsync()` client/server surface awaits the
     * full workflow result. TODO(v2): consolidate so `resumeAsync` consistently means
     * fire-and-forget (mirroring `start`/`startAsync` semantics) across core, client SDK and
     * HTTP routes; that consolidation is a breaking change deferred to Mastra v2.
     * @returns A promise that resolves to the runId
     */
    resumeAsync<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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<{
        runId: string;
    }>;
    /**
     * 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;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    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;
        actor?: ActorSignal;
        skipParentWorkflowClaim?: boolean;
        claimedSnapshot?: WorkflowRunState;
        onExecutionStarted?: () => void;
        /** Hands over a run lease the caller already holds, which the execution uses instead of claiming one. */
        takeHeldOwnership?: () => WorkflowRunOwnership | undefined;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    protected _restart({ requestContext, outputWriter, tracingOptions, outputOptions, actor, ...rest }: {
        requestContext?: RequestContext<TRequestContext>;
        outputWriter?: OutputWriter;
        tracingOptions?: TracingOptions;
        outputOptions?: {
            includeState?: boolean;
            includeResumeLabels?: boolean;
        };
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    protected _timeTravel<TInput>({ inputData, resumeData, initialState, step: stepParam, context, nestedStepsContext, requestContext, outputWriter, tracingOptions, outputOptions, perStep, actor, ...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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    timeTravelStream<TTravelInput>({ inputData, resumeData, initialState, step, context, nestedStepsContext, requestContext, tracingOptions, outputOptions, perStep, actor, ...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;
        actor?: ActorSignal;
    } & Partial<ObservabilityContext>): WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>>;
    /**
     * @access private
     * @returns The execution results of the workflow run
     */
    _getExecutionResults(): Promise<WorkflowResult<TState, TInput, TOutput, TSteps, TStorageVersion>> | undefined;
}
//# sourceMappingURL=workflow.d.ts.map