UNPKG

@mastra/core

Version:
80 lines • 3.54 kB
import type { ActorSignal } from '../../auth/ee/index.js'; import type { RequestContext } from '../../di/index.js'; import type { PubSub } from '../../events/pubsub.js'; import type { Mastra } from '../../mastra/index.js'; import type { Span, SpanType } from '../../observability/index.js'; import { ExecutionEngine } from '../../workflows/execution-engine.js'; import type { ExecutionEngineOptions, ExecutionGraph } from '../../workflows/execution-engine.js'; import type { SerializedStepFlowEntry, StepResult, RestartExecutionParams, TimeTravelExecutionParams, NestedWorkflowParent } from '../types.js'; import type { WorkflowEventProcessor } from './workflow-event-processor/index.js'; export declare class EventedExecutionEngine extends ExecutionEngine { protected eventProcessor: WorkflowEventProcessor; constructor({ mastra, eventProcessor, options, }: { mastra?: Mastra; eventProcessor: WorkflowEventProcessor; options: ExecutionEngineOptions; }); __registerMastra(mastra: Mastra): void; /** * Internal workflows (registered via `Mastra.__registerInternalWorkflow`) * are resolvable from the workflow event processor but `Mastra.getWorkflow` * intentionally only sees public ones. The `execute` resume/time-travel * branches need access to the workflow's step graph by id, so prefer the * internal registry when present. */ private resolveWorkflow; /** * `Run.restart()` and `Run.timeTravel()` hand the engine a WORKFLOW_RUN span to own. Evented * steps only find a span registered on Mastra for their run, so hold it there while the run * executes, then end it with the run's result as the default engine does. */ private executeInRunSpan; /** * 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 */ execute<TState, TInput, TOutput>(params: { workflowId: string; runId: string; parentWorkflow?: NestedWorkflowParent; resourceId?: string; graph: ExecutionGraph; serializedStepGraph: SerializedStepFlowEntry[]; input?: TInput; initialState?: TState; restart?: RestartExecutionParams; timeTravel?: TimeTravelExecutionParams; resume?: { steps: string[]; stepResults: Record<string, StepResult<any, any, any, any>>; resumePayload: any; resumePath: number[]; forEachIndex?: number; }; pubsub?: PubSub; requestContext: RequestContext; actor?: ActorSignal; retryConfig?: { attempts?: number; delay?: number; }; abortController: AbortController; format?: 'legacy' | 'vnext' | undefined; outputOptions?: { includeState?: boolean; includeResumeLabels?: boolean; }; perStep?: boolean; storageVersion?: 1 | 2; workflowSpan?: Span<SpanType.WORKFLOW_RUN>; /** * Called once the start/resume event is published. `Run.startAsync()` returns at this point * and leaves the returned promise to settle in the background, so lifecycle callbacks still * run when the worker reports the finish. */ onDispatched?: () => void; }): Promise<TOutput>; } //# sourceMappingURL=execution-engine.d.ts.map