import { Agent } from '../../agent/index.js'; import { RequestContext } from '../../di/index.js'; import type { MastraScorers } from '../../evals/index.js'; import type { Mastra } from '../../mastra/index.js'; import type { Processor } from '../../processors/index.js'; import { ProcessorStepOutputSchema, ProcessorStepSchema } from '../../processors/index.js'; import type { InferPublicSchema, InferStandardSchemaOutput, PublicSchema, StandardSchemaWithJSON } from '../../schema/index.js'; import { WorkflowRunOutput } from '../../stream/RunOutput.js'; import { Tool } from '../../tools/index.js'; import type { ToolExecutionContext } from '../../tools/types.js'; import type { DynamicArgument } from '../../types/index.js'; import { Workflow, Run } from '../../workflows/index.js'; import type { AgentStepOptions } from '../../workflows/index.js'; import type { ExecutionEngine, ExecutionGraph } from '../../workflows/execution-engine.js'; import type { Step } from '../../workflows/step.js'; import type { SerializedStepFlowEntry, WorkflowConfig, WorkflowResult, StepWithComponent, WorkflowStreamEvent, WorkflowEngineType, StepParams, DefaultEngineType, StepMetadata } from '../../workflows/types.js'; export type EventedEngineType = {}; export declare function cloneWorkflow[] = Step[], TPrevSchema = TInput>(workflow: Workflow, opts: { id: TWorkflowId; }): Workflow; export declare function cloneStep(step: Step, opts: { id: TStepId; }): Step; /** * Creates a step from explicit params (FIRST overload for best error messages) * @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(params: StepParams): Step : unknown, InferPublicSchema, InferPublicSchema, TResumeSchema extends PublicSchema ? InferPublicSchema : unknown, TSuspendSchema extends PublicSchema ? InferPublicSchema : unknown, DefaultEngineType>; /** * Creates a step from an agent with structured output */ export declare function createStep(agent: Agent, agentOptions: AgentStepOptions & { structuredOutput: { schema: TStepOutput; }; retries?: number; scorers?: DynamicArgument; metadata?: StepMetadata; }): Step; /** * Creates a step from an agent (defaults to { text: string } output) */ export declare function createStep(agent: Agent): Step; /** * Creates a step from a tool */ export declare function createStep, TId extends string, TRequestContext extends Record | unknown = unknown>(tool: Tool, toolOptions?: { retries?: number; scorers?: DynamicArgument; metadata?: StepMetadata; }): Step; /** * 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(processor: (Processor & { processInput: Function; }) | (Processor & { processInputStream: Function; }) | (Processor & { processInputStep: Function; }) | (Processor & { processOutputStream: Function; }) | (Processor & { processOutputResult: Function; }) | (Processor & { processOutputStep: Function; })): Step<`processor:${TProcessorId}`, unknown, InferStandardSchemaOutput, InferStandardSchemaOutput, 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 | undefined, TInputSchema extends PublicSchema, TOutputSchema extends PublicSchema, TResumeSchema extends PublicSchema | undefined = undefined, TSuspendSchema extends PublicSchema | undefined = undefined>(params: StepParams): Step ? InferPublicSchema : unknown, InferPublicSchema, InferPublicSchema, TResumeSchema extends PublicSchema ? InferPublicSchema : unknown, TSuspendSchema extends PublicSchema ? InferPublicSchema : unknown, DefaultEngineType>; export declare function createWorkflow[] = Step[]>(params: WorkflowConfig): EventedWorkflow; export declare class EventedWorkflow[] = Step[], TWorkflowId extends string = string, TState = unknown, TInput = unknown, TOutput = unknown, TPrevSchema = TInput> extends Workflow { constructor(params: WorkflowConfig); __registerMastra(mastra: Mastra): void; createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean; }): Promise>; } export declare class EventedRun[] = Step[], TState = unknown, TInput = unknown, TOutput = unknown> extends Run { constructor(params: { workflowId: string; runId: string; resourceId?: string; executionEngine: ExecutionEngine; executionGraph: ExecutionGraph; serializedStepGraph: SerializedStepFlowEntry[]; mastra?: Mastra; retryConfig?: { attempts?: number; delay?: number; }; cleanup?: () => void; workflowSteps: Record; validateInputs?: boolean; inputSchema?: StandardSchemaWithJSON; stateSchema?: StandardSchemaWithJSON; workflowEngineType: WorkflowEngineType; }); /** * Set up abort signal handler to publish workflow.cancel event when abortController.abort() is called. * This ensures consistent cancellation behavior whether abort() is called directly or via cancel(). */ private setupAbortHandler; start({ inputData, initialState, requestContext, perStep, outputOptions, }: { inputData?: TInput; requestContext?: RequestContext; initialState?: TState; perStep?: boolean; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; }): Promise>; /** * Starts the workflow execution without waiting for completion (fire-and-forget). * Returns immediately with the runId. The workflow executes in the background via pubsub. * Use this when you don't need to wait for the result or want to avoid polling failures. */ startAsync({ inputData, initialState, requestContext, perStep, }: { inputData?: TInput; requestContext?: RequestContext; initialState?: TState; perStep?: boolean; }): Promise<{ runId: string; }>; /** * Starts the workflow execution as a stream, returning a WorkflowRunOutput * with .fullStream for iteration and .result for the final result. */ stream({ inputData, requestContext, initialState, closeOnSuspend, perStep, outputOptions, }: (TInput extends unknown ? { inputData?: TInput; } : { inputData: TInput; }) & (TState extends unknown ? { initialState?: TState; } : { initialState: TState; }) & { requestContext?: RequestContext; closeOnSuspend?: boolean; perStep?: boolean; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; }): WorkflowRunOutput>; /** * Resumes a suspended workflow as a stream, returning a WorkflowRunOutput * with .fullStream for iteration and .result for the final result. */ resumeStream({ step, resumeData, requestContext, perStep, outputOptions, }?: { resumeData?: TResume; step?: Step | [ ...Step[], Step ] | string | string[]; requestContext?: RequestContext; perStep?: boolean; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; }): WorkflowRunOutput>; resume(params: { resumeData?: TResumeSchema; step?: Step | [ ...Step[], Step ] | string | string[]; label?: string; forEachIndex?: number; requestContext?: RequestContext; perStep?: boolean; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; }): Promise>; watch(cb: (event: WorkflowStreamEvent) => void): () => void; watchAsync(cb: (event: WorkflowStreamEvent) => void): Promise<() => void>; cancel(): Promise; } //# sourceMappingURL=workflow.d.ts.map