@mastra/core
Version:
The core foundation of the Mastra framework, providing essential components and interfaces for building AI-powered applications.
181 lines (178 loc) • 6.62 kB
TypeScript
import { g as ExecutionEngine, h as ExecutionGraph, i as StepResult, j as StepFlowEntry, N as NewStep, k as ExecuteFunction } from '../../base-BS0LLAna.js';
export { x as ExtractSchemaFromStep, w as ExtractSchemaType, r as NewWorkflow, q as NewWorkflowConfig, P as PathsToStringProps, R as Run, t as StepFailure, s as StepSuccess, u as StepSuspended, v as StepsRecord, V as VariableReference, y as WatchEvent, p as WorkflowResult, Z as ZodPathType, m as cloneStep, o as cloneWorkflow, l as createStep, n as createWorkflow } from '../../base-BS0LLAna.js';
import EventEmitter from 'events';
import { RuntimeContext } from '../../runtime-context/index.js';
import 'ai';
import '../../base-DT2poiVK.js';
import '@opentelemetry/api';
import '../../index-CquI0inB.js';
import 'stream';
import 'pino';
import '@opentelemetry/sdk-trace-base';
import '../../types-BtMyV38I.js';
import 'sift';
import 'zod';
import 'json-schema';
import 'xstate';
import 'node:events';
import '../../vector/index.js';
import '../../vector/filter/index.js';
import '../../tts/index.js';
import '../../deployer/index.js';
import '../../bundler/index.js';
import 'hono';
import 'hono/cors';
import 'hono-openapi';
import 'ai/test';
type ExecutionContext = {
executionPath: number[];
suspendedPaths: Record<string, number[]>;
retryConfig: {
attempts: number;
delay: number;
};
};
/**
* Default implementation of the ExecutionEngine using XState
*/
declare class DefaultExecutionEngine extends ExecutionEngine {
/**
* 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<TInput, TOutput>(params: {
workflowId: string;
runId: string;
graph: ExecutionGraph;
input?: TInput;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
emitter: EventEmitter;
retryConfig?: {
attempts?: number;
delay?: number;
};
runtimeContext: RuntimeContext;
}): Promise<TOutput>;
getStepOutput(stepResults: Record<string, any>, step?: StepFlowEntry): any;
executeStep({ step, stepResults, executionContext, resume, prevOutput, emitter, runtimeContext, }: {
step: NewStep<string, any, any>;
stepResults: Record<string, StepResult<any>>;
executionContext: ExecutionContext;
resume?: {
steps: string[];
resumePayload: any;
};
prevOutput: any;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
executeParallel({ workflowId, runId, entry, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
workflowId: string;
runId: string;
entry: {
type: 'parallel';
steps: StepFlowEntry[];
};
prevStep: StepFlowEntry;
stepResults: Record<string, StepResult<any>>;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
executionContext: ExecutionContext;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
workflowId: string;
runId: string;
entry: {
type: 'conditional';
steps: StepFlowEntry[];
conditions: ExecuteFunction<any, any, any, any>[];
};
prevStep: StepFlowEntry;
prevOutput: any;
stepResults: Record<string, StepResult<any>>;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
executionContext: ExecutionContext;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
executeLoop({ entry, prevOutput, stepResults, resume, executionContext, emitter, runtimeContext, }: {
workflowId: string;
runId: string;
entry: {
type: 'loop';
step: NewStep;
condition: ExecuteFunction<any, any, any, any>;
loopType: 'dowhile' | 'dountil';
};
prevStep: StepFlowEntry;
prevOutput: any;
stepResults: Record<string, StepResult<any>>;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
executionContext: ExecutionContext;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
executeForeach({ entry, prevOutput, stepResults, resume, executionContext, emitter, runtimeContext, }: {
workflowId: string;
runId: string;
entry: {
type: 'foreach';
step: NewStep;
opts: {
concurrency: number;
};
};
prevStep: StepFlowEntry;
prevOutput: any;
stepResults: Record<string, StepResult<any>>;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
executionContext: ExecutionContext;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
executeEntry({ workflowId, runId, entry, prevStep, stepResults, resume, executionContext, emitter, runtimeContext, }: {
workflowId: string;
runId: string;
entry: StepFlowEntry;
prevStep: StepFlowEntry;
stepResults: Record<string, StepResult<any>>;
resume?: {
steps: string[];
stepResults: Record<string, StepResult<any>>;
resumePayload: any;
resumePath: number[];
};
executionContext: ExecutionContext;
emitter: EventEmitter;
runtimeContext: RuntimeContext;
}): Promise<StepResult<any>>;
}
export { DefaultExecutionEngine, ExecuteFunction, ExecutionEngine, ExecutionGraph, NewStep, StepFlowEntry, StepResult };