@mastra/core 0.8.0-alpha.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.d.cts +1 -1
  3. package/dist/agent/index.d.ts +1 -1
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-BkKZJMd4.d.ts → base-C7f5RDDD.d.ts} +5 -5
  6. package/dist/{base-2iKEEo-U.d.cts → base-nVWefprR.d.cts} +5 -5
  7. package/dist/{chunk-KHMCAV4W.js → chunk-A74FQNCI.js} +1 -1
  8. package/dist/{chunk-LK5H7SEM.cjs → chunk-ENOIN7PM.cjs} +84 -29
  9. package/dist/{chunk-S3VEAYDK.cjs → chunk-FUQKE5AK.cjs} +2 -2
  10. package/dist/{chunk-TFDALD5V.js → chunk-SGR6AJWC.js} +84 -30
  11. package/dist/eval/index.d.cts +1 -1
  12. package/dist/eval/index.d.ts +1 -1
  13. package/dist/index.cjs +31 -27
  14. package/dist/index.d.cts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +3 -3
  17. package/dist/integration/index.d.cts +1 -1
  18. package/dist/integration/index.d.ts +1 -1
  19. package/dist/llm/index.d.cts +1 -1
  20. package/dist/llm/index.d.ts +1 -1
  21. package/dist/mastra/index.d.cts +1 -1
  22. package/dist/mastra/index.d.ts +1 -1
  23. package/dist/memory/index.d.cts +1 -1
  24. package/dist/memory/index.d.ts +1 -1
  25. package/dist/network/index.cjs +2 -2
  26. package/dist/network/index.d.cts +1 -1
  27. package/dist/network/index.d.ts +1 -1
  28. package/dist/network/index.js +1 -1
  29. package/dist/relevance/index.cjs +4 -4
  30. package/dist/relevance/index.d.cts +1 -1
  31. package/dist/relevance/index.d.ts +1 -1
  32. package/dist/relevance/index.js +1 -1
  33. package/dist/server/index.d.cts +1 -1
  34. package/dist/server/index.d.ts +1 -1
  35. package/dist/storage/index.d.cts +1 -1
  36. package/dist/storage/index.d.ts +1 -1
  37. package/dist/storage/libsql/index.d.cts +1 -1
  38. package/dist/storage/libsql/index.d.ts +1 -1
  39. package/dist/telemetry/index.d.cts +1 -1
  40. package/dist/telemetry/index.d.ts +1 -1
  41. package/dist/tools/index.d.cts +1 -1
  42. package/dist/tools/index.d.ts +1 -1
  43. package/dist/utils.d.cts +1 -1
  44. package/dist/utils.d.ts +1 -1
  45. package/dist/voice/index.d.cts +2 -2
  46. package/dist/voice/index.d.ts +2 -2
  47. package/dist/workflows/index.cjs +26 -22
  48. package/dist/workflows/index.d.cts +4 -3
  49. package/dist/workflows/index.d.ts +4 -3
  50. package/dist/workflows/index.js +1 -1
  51. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkLK5H7SEM_cjs = require('../chunk-LK5H7SEM.cjs');
3
+ var chunkENOIN7PM_cjs = require('../chunk-ENOIN7PM.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Agent", {
8
8
  enumerable: true,
9
- get: function () { return chunkLK5H7SEM_cjs.Agent; }
9
+ get: function () { return chunkENOIN7PM_cjs.Agent; }
10
10
  });
@@ -1,7 +1,7 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-2iKEEo-U.cjs';
4
+ export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-nVWefprR.cjs';
5
5
  import '../base-BihKcqDY.cjs';
6
6
  import '../types-BtMyV38I.cjs';
7
7
  import 'sift';
@@ -1,7 +1,7 @@
1
1
  export { Message as AiMessageType } from 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-BkKZJMd4.js';
4
+ export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-C7f5RDDD.js';
5
5
  import '../base-DT2poiVK.js';
6
6
  import '../types-BtMyV38I.js';
7
7
  import 'sift';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-TFDALD5V.js';
1
+ export { Agent } from '../chunk-SGR6AJWC.js';
@@ -560,7 +560,7 @@ declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema |
560
560
  }
561
561
  declare function createStep<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>>(opts: StepAction<TId, TSchemaIn, TSchemaOut, TContext>): Step<TId, TSchemaIn, TSchemaOut, TContext>;
562
562
 
563
- declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
563
+ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
564
564
  #private;
565
565
  logger: Logger;
566
566
  name: string;
@@ -571,7 +571,7 @@ declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema
571
571
  executionSpan?: Span;
572
572
  name: string;
573
573
  runId: string;
574
- steps: Record<string, TSteps[0]>;
574
+ steps: Record<string, StepNode>;
575
575
  stepGraph: StepGraph;
576
576
  retryConfig?: RetryConfig;
577
577
  startStepId: string;
@@ -946,7 +946,7 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
946
946
  }) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
947
947
  resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
948
948
  }
949
- declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
949
+ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
950
950
  #private;
951
951
  name: string;
952
952
  logger: Logger;
@@ -956,7 +956,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
956
956
  constructor({ name, logger, steps, runId, retryConfig, mastra, stepGraph, stepSubscriberGraph, onFinish, onStepTransition, resultMapping, events, }: {
957
957
  name: string;
958
958
  logger: Logger;
959
- steps: Record<string, StepAction<any, any, any, any>>;
959
+ steps: Record<string, StepNode>;
960
960
  mastra?: Mastra;
961
961
  retryConfig?: RetryConfig;
962
962
  runId?: string;
@@ -998,7 +998,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
998
998
  resumeData?: any;
999
999
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
1000
1000
  hasSubscribers(stepId: string): boolean;
1001
- runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<any, any, any>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1001
+ runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1002
1002
  suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
1003
1003
  /**
1004
1004
  * Persists the workflow state to the database
@@ -560,7 +560,7 @@ declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema |
560
560
  }
561
561
  declare function createStep<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>>(opts: StepAction<TId, TSchemaIn, TSchemaOut, TContext>): Step<TId, TSchemaIn, TSchemaOut, TContext>;
562
562
 
563
- declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
563
+ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
564
564
  #private;
565
565
  logger: Logger;
566
566
  name: string;
@@ -571,7 +571,7 @@ declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema
571
571
  executionSpan?: Span;
572
572
  name: string;
573
573
  runId: string;
574
- steps: Record<string, TSteps[0]>;
574
+ steps: Record<string, StepNode>;
575
575
  stepGraph: StepGraph;
576
576
  retryConfig?: RetryConfig;
577
577
  startStepId: string;
@@ -946,7 +946,7 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
946
946
  }) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
947
947
  resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
948
948
  }
949
- declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
949
+ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
950
950
  #private;
951
951
  name: string;
952
952
  logger: Logger;
@@ -956,7 +956,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
956
956
  constructor({ name, logger, steps, runId, retryConfig, mastra, stepGraph, stepSubscriberGraph, onFinish, onStepTransition, resultMapping, events, }: {
957
957
  name: string;
958
958
  logger: Logger;
959
- steps: Record<string, StepAction<any, any, any, any>>;
959
+ steps: Record<string, StepNode>;
960
960
  mastra?: Mastra;
961
961
  retryConfig?: RetryConfig;
962
962
  runId?: string;
@@ -998,7 +998,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
998
998
  resumeData?: any;
999
999
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
1000
1000
  hasSubscribers(stepId: string): boolean;
1001
- runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<any, any, any>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1001
+ runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
1002
1002
  suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
1003
1003
  /**
1004
1004
  * Persists the workflow state to the database
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-TFDALD5V.js';
1
+ import { Agent } from './chunk-SGR6AJWC.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -2052,6 +2052,9 @@ function generateRandomLetters(length) {
2052
2052
  }
2053
2053
  return result;
2054
2054
  }
2055
+ function isConditionalKey(key) {
2056
+ return key.startsWith("__") && (key.includes("_if") || key.includes("_else"));
2057
+ }
2055
2058
  var Machine = class extends EventEmitter__default.default {
2056
2059
  logger;
2057
2060
  #mastra;
@@ -2247,7 +2250,7 @@ var Machine = class extends EventEmitter__default.default {
2247
2250
  #makeDelayMap() {
2248
2251
  const delayMap = {};
2249
2252
  Object.keys(this.#steps).forEach(stepId => {
2250
- delayMap[stepId] = this.#steps[stepId]?.retryConfig?.delay || this.#retryConfig?.delay || 1e3;
2253
+ delayMap[stepId] = this.#steps[stepId]?.step?.retryConfig?.delay || this.#retryConfig?.delay || 1e3;
2251
2254
  });
2252
2255
  return delayMap;
2253
2256
  }
@@ -2500,6 +2503,11 @@ var Machine = class extends EventEmitter__default.default {
2500
2503
  type: "CONDITIONS_MET"
2501
2504
  };
2502
2505
  }
2506
+ if (isConditionalKey(stepNode.id)) {
2507
+ return {
2508
+ type: "CONDITIONS_LIMBO"
2509
+ };
2510
+ }
2503
2511
  return this.#workflowInstance.hasSubscribers(stepNode.id) ? {
2504
2512
  type: "CONDITIONS_SKIPPED"
2505
2513
  } : {
@@ -3247,7 +3255,7 @@ var WorkflowInstance = class {
3247
3255
  steps: {},
3248
3256
  triggerData: triggerData || {},
3249
3257
  attempts: Object.keys(this.#steps).reduce((acc, stepKey) => {
3250
- acc[stepKey] = this.#steps[stepKey]?.retryConfig?.attempts || this.#retryConfig?.attempts || 0;
3258
+ acc[stepKey] = this.#steps[stepKey]?.step?.retryConfig?.attempts || this.#retryConfig?.attempts || 0;
3251
3259
  return acc;
3252
3260
  }, {})
3253
3261
  };
@@ -3616,7 +3624,7 @@ var WorkflowInstance = class {
3616
3624
  }
3617
3625
  parsedSnapshot.value = updateStepInHierarchy(parsedSnapshot.value, stepId);
3618
3626
  if (parsedSnapshot.context?.attempts) {
3619
- parsedSnapshot.context.attempts[stepId] = this.#steps[stepId]?.retryConfig?.attempts || this.#retryConfig?.attempts || 0;
3627
+ parsedSnapshot.context.attempts[stepId] = this.#steps[stepId]?.step?.retryConfig?.attempts || this.#retryConfig?.attempts || 0;
3620
3628
  }
3621
3629
  this.logger.debug("Resuming workflow with updated snapshot", {
3622
3630
  updatedSnapshot: parsedSnapshot,
@@ -3673,7 +3681,7 @@ var WorkflowInstance = class {
3673
3681
  const {
3674
3682
  payload = {},
3675
3683
  execute = async () => {}
3676
- } = targetStep;
3684
+ } = targetStep.step;
3677
3685
  const mergedData = {
3678
3686
  ...payload,
3679
3687
  ...context
@@ -3741,6 +3749,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
3741
3749
  #stepSubscriberGraph = {};
3742
3750
  #serializedStepSubscriberGraph = {};
3743
3751
  #steps = {};
3752
+ #ifCount = 0;
3744
3753
  /**
3745
3754
  * Creates a new Workflow instance
3746
3755
  * @param name - Identifier for the workflow (not necessarily unique)
@@ -3831,7 +3840,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
3831
3840
  return that.#makeStepKey(this.step, this.config);
3832
3841
  }
3833
3842
  };
3834
- this.#steps[stepKey] = step;
3843
+ this.#steps[stepKey] = graphEntry;
3835
3844
  const parentStepKey = this.#getParentStepKey({
3836
3845
  loop_check: true
3837
3846
  });
@@ -3906,7 +3915,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
3906
3915
  return that.#makeStepKey(this.step, this.config);
3907
3916
  }
3908
3917
  };
3909
- this.#steps[stepKey] = step;
3918
+ this.#steps[stepKey] = graphEntry;
3910
3919
  const parentStepKey = this.#getParentStepKey();
3911
3920
  const stepGraph = this.#stepSubscriberGraph[parentStepKey || ""];
3912
3921
  const serializedStepGraph = this.#serializedStepSubscriberGraph[parentStepKey || ""];
@@ -3937,7 +3946,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
3937
3946
  if (!lastStep) {
3938
3947
  throw new Error("Condition requires a step to be executed after");
3939
3948
  }
3940
- this.after(lastStep);
3949
+ this.after(lastStep.step);
3941
3950
  const nextSteps = next.map(step2 => {
3942
3951
  if (isWorkflow(step2)) {
3943
3952
  return workflowToStep(step2, {
@@ -3990,9 +3999,9 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
3990
3999
  return that.#makeStepKey(this.step, this.config);
3991
4000
  }
3992
4001
  };
3993
- this.#steps[stepKey] = step;
4002
+ this.#steps[stepKey] = graphEntry;
3994
4003
  if (!lastStepKey) return this;
3995
- const parentStepKey = this.#afterStepStack[this.#afterStepStack.length - 1];
4004
+ const parentStepKey = this.#getParentStepKey();
3996
4005
  const stepGraph = this.#stepSubscriberGraph[parentStepKey || ""];
3997
4006
  const serializedStepGraph = this.#serializedStepSubscriberGraph[parentStepKey || ""];
3998
4007
  if (parentStepKey && this.#lastBuilderType === "after") {
@@ -4014,7 +4023,16 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4014
4023
  const lastStepKey = this.#lastStepStack[this.#lastStepStack.length - 1];
4015
4024
  if (!lastStepKey) return this;
4016
4025
  const fallbackStepKey = this.#makeStepKey(fallbackStep);
4017
- this.#steps[fallbackStepKey] = fallbackStep;
4026
+ const fallbackStepNode = {
4027
+ step: fallbackStep,
4028
+ config: {
4029
+ ...this.#makeStepDef(fallbackStepKey)
4030
+ },
4031
+ get id() {
4032
+ return fallbackStepKey;
4033
+ }
4034
+ };
4035
+ this.#steps[fallbackStepKey] = fallbackStepNode;
4018
4036
  const checkStepKey = `__${fallbackStepKey}_${loopType}_loop_check`;
4019
4037
  const checkStep = {
4020
4038
  id: checkStepKey,
@@ -4068,7 +4086,16 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4068
4086
  status: zod.z.enum(["continue", "complete"])
4069
4087
  })
4070
4088
  };
4071
- this.#steps[checkStepKey] = checkStep;
4089
+ const checkStepNode = {
4090
+ step: checkStep,
4091
+ config: {
4092
+ ...this.#makeStepDef(checkStepKey)
4093
+ },
4094
+ get id() {
4095
+ return checkStepKey;
4096
+ }
4097
+ };
4098
+ this.#steps[checkStepKey] = checkStepNode;
4072
4099
  const loopFinishedStepKey = `__${fallbackStepKey}_${loopType}_loop_finished`;
4073
4100
  const loopFinishedStep = {
4074
4101
  id: loopFinishedStepKey,
@@ -4078,7 +4105,16 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4078
4105
  };
4079
4106
  }
4080
4107
  };
4081
- this.#steps[loopFinishedStepKey] = loopFinishedStep;
4108
+ const loopFinishedStepNode = {
4109
+ step: loopFinishedStep,
4110
+ config: {
4111
+ ...this.#makeStepDef(loopFinishedStepKey)
4112
+ },
4113
+ get id() {
4114
+ return loopFinishedStepKey;
4115
+ }
4116
+ };
4117
+ this.#steps[loopFinishedStepKey] = loopFinishedStepNode;
4082
4118
  this.then(checkStep, {
4083
4119
  id: checkStepKey,
4084
4120
  "#internal": {
@@ -4204,11 +4240,14 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4204
4240
  return res;
4205
4241
  }
4206
4242
  if(condition, ifStep, elseStep) {
4207
- const lastStep = this.#steps[this.#lastStepStack[this.#lastStepStack.length - 1] ?? ""];
4243
+ this.#ifCount++;
4244
+ const lastStep = this.#getLastStep({
4245
+ if_else_check: this.#lastBuilderType !== "else"
4246
+ });
4208
4247
  if (!lastStep) {
4209
4248
  throw new Error("Condition requires a step to be executed after");
4210
4249
  }
4211
- this.after(lastStep);
4250
+ this.after(lastStep.step);
4212
4251
  if (ifStep) {
4213
4252
  const _ifStep = isWorkflow(ifStep) ? workflowToStep(ifStep, {
4214
4253
  mastra: this.#mastra
@@ -4244,7 +4283,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4244
4283
  }));
4245
4284
  return this;
4246
4285
  }
4247
- const ifStepKey = `__${lastStep.id}_if`;
4286
+ const ifStepKey = `__${lastStep.id}_if_${this.#ifCount}`;
4248
4287
  this.step({
4249
4288
  id: ifStepKey,
4250
4289
  execute: async () => {
@@ -4256,11 +4295,11 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4256
4295
  id: ifStepKey,
4257
4296
  when: condition
4258
4297
  });
4259
- const elseStepKey = `__${lastStep.id}_else`;
4298
+ const elseStepKey = `__${lastStep.id}_else_${this.#ifCount}`;
4260
4299
  this.#ifStack.push({
4261
4300
  condition,
4262
4301
  elseStepKey,
4263
- condStep: lastStep
4302
+ condStep: lastStep.step
4264
4303
  });
4265
4304
  this.#lastBuilderType = "if";
4266
4305
  return this;
@@ -4333,7 +4372,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4333
4372
  };
4334
4373
  }
4335
4374
  });
4336
- this.after(lastStep).step(eventStep).after(eventStep);
4375
+ this.after(lastStep.step).step(eventStep).after(eventStep);
4337
4376
  this.#lastBuilderType = "afterEvent";
4338
4377
  return this;
4339
4378
  }
@@ -4425,19 +4464,31 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4425
4464
  return this.#runs.get(runId)?.executionSpan;
4426
4465
  }
4427
4466
  #getParentStepKey({
4428
- loop_check
4429
- } = {
4430
- loop_check: false
4431
- }) {
4432
- let parentStepKey = void 0;
4467
+ loop_check = false,
4468
+ if_else_check = false
4469
+ } = {}) {
4433
4470
  for (let i = this.#afterStepStack.length - 1; i >= 0; i--) {
4434
4471
  const stepKey = this.#afterStepStack[i];
4435
- if (stepKey && this.#stepSubscriberGraph[stepKey] && (loop_check ? !stepKey.includes("loop_check") : true)) {
4436
- parentStepKey = stepKey;
4437
- break;
4472
+ if (!stepKey) continue;
4473
+ const isValidStep = this.#stepSubscriberGraph[stepKey] && (!loop_check || !stepKey.includes("loop_check")) && (!if_else_check || !isConditionalKey(stepKey));
4474
+ if (isValidStep) {
4475
+ return stepKey;
4438
4476
  }
4439
4477
  }
4440
- return parentStepKey;
4478
+ return void 0;
4479
+ }
4480
+ #getLastStep({
4481
+ if_else_check
4482
+ }) {
4483
+ for (let i = this.#lastStepStack.length - 1; i >= 0; i--) {
4484
+ const stepKey = this.#lastStepStack[i];
4485
+ if (!stepKey) continue;
4486
+ const step = this.#steps[stepKey];
4487
+ const isInvalidStep = !step || if_else_check && isConditionalKey(stepKey);
4488
+ if (isInvalidStep) continue;
4489
+ return step;
4490
+ }
4491
+ return void 0;
4441
4492
  }
4442
4493
  #makeStepDef(stepId) {
4443
4494
  const executeStep = (handler2, spanName, attributes) => {
@@ -4463,7 +4514,7 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4463
4514
  const {
4464
4515
  payload = {},
4465
4516
  execute = async () => {}
4466
- } = targetStep;
4517
+ } = targetStep.step;
4467
4518
  const finalAction = this.telemetry ? executeStep(execute, `workflow.${this.name}.action.${stepId}`, {
4468
4519
  componentName: this.name,
4469
4520
  runId: rest.runId
@@ -4611,7 +4662,10 @@ var Workflow = class extends chunkD63P5O4Q_cjs.MastraBase {
4611
4662
  return this.#serializedStepSubscriberGraph;
4612
4663
  }
4613
4664
  get steps() {
4614
- return this.#steps;
4665
+ return Object.entries(this.#steps).reduce((acc, [key, step]) => {
4666
+ acc[key] = step.step;
4667
+ return acc;
4668
+ }, {});
4615
4669
  }
4616
4670
  setNested(isNested) {
4617
4671
  this.isNested = isNested;
@@ -4634,6 +4688,7 @@ exports.getResultActivePaths = getResultActivePaths;
4634
4688
  exports.getStepResult = getStepResult;
4635
4689
  exports.getSuspendedPaths = getSuspendedPaths;
4636
4690
  exports.isAgent = isAgent;
4691
+ exports.isConditionalKey = isConditionalKey;
4637
4692
  exports.isErrorEvent = isErrorEvent;
4638
4693
  exports.isFinalState = isFinalState;
4639
4694
  exports.isLimboState = isLimboState;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkLK5H7SEM_cjs = require('./chunk-LK5H7SEM.cjs');
3
+ var chunkENOIN7PM_cjs = require('./chunk-ENOIN7PM.cjs');
4
4
  var cohereAi = require('cohere-ai');
5
5
 
6
6
  var CohereRelevanceScorer = class {
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
38
38
  var MastraAgentRelevanceScorer = class {
39
39
  agent;
40
40
  constructor(name, model) {
41
- this.agent = new chunkLK5H7SEM_cjs.Agent({
41
+ this.agent = new chunkENOIN7PM_cjs.Agent({
42
42
  name: `Relevance Scorer ${name}`,
43
43
  instructions: `You are a specialized agent for evaluating the relevance of text to queries.
44
44
  Your task is to rate how well a text passage answers a given query.