import { MastraBase } from '../base.js'; import type { RequestContext } from '../di/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 { Span, SpanType, TracingPolicy } from '../observability/index.js'; import type { OutputWriter, SerializedStepFlowEntry, StepResult, WorkflowRunStatus, WorkflowFinishCallbackResult, WorkflowErrorCallbackInfo } from './types.js'; import type { RestartExecutionParams, StepFlowEntry, TimeTravelExecutionParams } from '.'; /** * Represents an execution graph for a workflow */ export interface ExecutionGraph { id: string; steps: StepFlowEntry[]; } export interface ExecutionEngineOptions { tracingPolicy?: TracingPolicy; validateInputs: boolean; shouldPersistSnapshot: (params: { stepResults: Record>; workflowStatus: WorkflowRunStatus; }) => boolean; /** * Called when workflow execution completes (success, failed, suspended, or tripwire). * Errors thrown in this callback are caught and logged, not propagated. */ onFinish?: (result: WorkflowFinishCallbackResult) => Promise | void; /** * Called only when workflow execution fails (failed or tripwire status). * Errors thrown in this callback are caught and logged, not propagated. */ onError?: (errorInfo: WorkflowErrorCallbackInfo) => Promise | void; } /** * Execution engine abstract class for building and executing workflow graphs * Providers will implement this class to provide their own execution logic */ export declare abstract class ExecutionEngine extends MastraBase { mastra?: Mastra; options: ExecutionEngineOptions; constructor({ mastra, options }: { mastra?: Mastra; options: ExecutionEngineOptions; }); __registerMastra(mastra: Mastra): void; getLogger(): IMastraLogger; /** * Invokes the onFinish and onError lifecycle callbacks if they are defined. * Errors in callbacks are caught and logged, not propagated. * @param result The workflow result containing status, result, error, steps, tripwire info, and context */ invokeLifecycleCallbacks(result: { status: WorkflowRunStatus; result?: any; error?: any; steps: Record>; tripwire?: any; runId: string; workflowId: string; resourceId?: string; input?: any; requestContext: RequestContext; state: Record; stepExecutionPath?: string[]; }): Promise; /** * Executes a workflow run with the provided execution graph and input * @param graph The execution graph to execute * @param input The input data for the workflow * @returns A promise that resolves to the workflow output */ abstract execute(params: { workflowId: string; runId: string; resourceId?: string; disableScorers?: boolean; graph: ExecutionGraph; serializedStepGraph: SerializedStepFlowEntry[]; input?: TInput; initialState?: TState; timeTravel?: TimeTravelExecutionParams; restart?: RestartExecutionParams; resume?: { steps: string[]; stepResults: Record>; resumePayload: any; resumePath: number[]; stepExecutionPath?: string[]; forEachIndex?: number; label?: string; }; pubsub: PubSub; requestContext: RequestContext; workflowSpan?: Span; retryConfig?: { attempts?: number; delay?: number; }; abortController: AbortController; outputWriter?: OutputWriter; format?: 'legacy' | 'vnext' | undefined; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; perStep?: boolean; }): Promise; } //# sourceMappingURL=execution-engine.d.ts.map