@mastra/core 0.1.27-alpha.14 → 0.1.27-alpha.16
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.
- package/dist/core.cjs.development.js +24 -30
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +22 -28
- package/dist/core.esm.js.map +1 -1
- package/dist/engine/engine.mock.d.ts +140 -0
- package/dist/workflows/step.d.ts +4 -4
- package/dist/workflows/types.d.ts +40 -27
- package/dist/workflows/workflow.d.ts +1 -1
- package/package.json +2 -2
|
@@ -18,7 +18,7 @@ var ai = require('ai');
|
|
|
18
18
|
var zod = require('zod');
|
|
19
19
|
var sift = require('sift');
|
|
20
20
|
var xstate = require('xstate');
|
|
21
|
-
var
|
|
21
|
+
var radash = require('radash');
|
|
22
22
|
|
|
23
23
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
24
24
|
try {
|
|
@@ -2022,7 +2022,8 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
2022
2022
|
},
|
|
2023
2023
|
agents: _this.agents,
|
|
2024
2024
|
llm: _this.llm,
|
|
2025
|
-
engine: _this.engine
|
|
2025
|
+
engine: _this.engine,
|
|
2026
|
+
vectors: _this.vectors
|
|
2026
2027
|
}));
|
|
2027
2028
|
}
|
|
2028
2029
|
});
|
|
@@ -2232,8 +2233,8 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
2232
2233
|
*/
|
|
2233
2234
|
function Workflow(_ref) {
|
|
2234
2235
|
var name = _ref.name,
|
|
2235
|
-
logger = _ref.logger,
|
|
2236
2236
|
steps = _ref.steps,
|
|
2237
|
+
logger = _ref.logger,
|
|
2237
2238
|
triggerSchema = _ref.triggerSchema;
|
|
2238
2239
|
/**
|
|
2239
2240
|
* Detects unreachable steps in the workflow
|
|
@@ -2494,11 +2495,8 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
2494
2495
|
*/
|
|
2495
2496
|
_proto.step = function step(id, config) {
|
|
2496
2497
|
var _this2 = this;
|
|
2497
|
-
var
|
|
2498
|
-
|
|
2499
|
-
variables = _ref9$variables === void 0 ? {} : _ref9$variables,
|
|
2500
|
-
_ref9$transitions = _ref9.transitions,
|
|
2501
|
-
transitions = _ref9$transitions === void 0 ? undefined : _ref9$transitions;
|
|
2498
|
+
var variables = (config == null ? void 0 : config.variables) || {};
|
|
2499
|
+
var transitions = (config == null ? void 0 : config.transitions) || undefined;
|
|
2502
2500
|
var requiredData = {};
|
|
2503
2501
|
// Add valid variables to requiredData
|
|
2504
2502
|
for (var _i = 0, _Object$entries = Object.entries(variables); _i < _Object$entries.length; _i++) {
|
|
@@ -2639,7 +2637,7 @@ function _log2(_x4, _x5, _x6, _x7) {
|
|
|
2639
2637
|
}
|
|
2640
2638
|
function _log3() {
|
|
2641
2639
|
_log3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(level, message, data, stepId) {
|
|
2642
|
-
var
|
|
2640
|
+
var _classPrivateFieldLoo5, _classPrivateFieldLoo6;
|
|
2643
2641
|
var logMessage, logMethod;
|
|
2644
2642
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2645
2643
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -2660,7 +2658,7 @@ function _log3() {
|
|
|
2660
2658
|
};
|
|
2661
2659
|
logMethod = level.toLowerCase();
|
|
2662
2660
|
_context4.next = 6;
|
|
2663
|
-
return (
|
|
2661
|
+
return (_classPrivateFieldLoo5 = (_classPrivateFieldLoo6 = _classPrivateFieldLooseBase(this, _logger)[_logger])[logMethod]) == null ? void 0 : _classPrivateFieldLoo5.call(_classPrivateFieldLoo6, logMessage);
|
|
2664
2662
|
case 6:
|
|
2665
2663
|
case "end":
|
|
2666
2664
|
return _context4.stop();
|
|
@@ -2692,8 +2690,8 @@ function _buildStateHierarchy2() {
|
|
|
2692
2690
|
var state = {
|
|
2693
2691
|
invoke: {
|
|
2694
2692
|
src: 'resolverFunction',
|
|
2695
|
-
input: function input(
|
|
2696
|
-
var context =
|
|
2693
|
+
input: function input(_ref9) {
|
|
2694
|
+
var context = _ref9.context;
|
|
2697
2695
|
return {
|
|
2698
2696
|
context: context,
|
|
2699
2697
|
stepId: currentStepId,
|
|
@@ -2703,7 +2701,7 @@ function _buildStateHierarchy2() {
|
|
|
2703
2701
|
onDone: {
|
|
2704
2702
|
actions: ['updateStepResult'],
|
|
2705
2703
|
// If no transitions, go to success state
|
|
2706
|
-
target: (_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(_this4, _transitions)[_transitions][currentStepId]) != null && _classPrivateFieldLoo2.transitions ?
|
|
2704
|
+
target: !((_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(_this4, _transitions)[_transitions][currentStepId]) != null && _classPrivateFieldLoo2.transitions) ? 'success' : undefined
|
|
2707
2705
|
},
|
|
2708
2706
|
onError: {
|
|
2709
2707
|
target: 'failure',
|
|
@@ -2716,7 +2714,6 @@ function _buildStateHierarchy2() {
|
|
|
2716
2714
|
target: 'failure',
|
|
2717
2715
|
actions: xstate.assign({
|
|
2718
2716
|
error: function error() {
|
|
2719
|
-
console.log('No matching transition conditions');
|
|
2720
2717
|
return new Error('No matching transition conditions');
|
|
2721
2718
|
}
|
|
2722
2719
|
})
|
|
@@ -2726,14 +2723,14 @@ function _buildStateHierarchy2() {
|
|
|
2726
2723
|
// Handle transitions
|
|
2727
2724
|
if ((_classPrivateFieldLoo3 = _classPrivateFieldLooseBase(_this4, _transitions)[_transitions][currentStepId]) != null && _classPrivateFieldLoo3.transitions) {
|
|
2728
2725
|
var _classPrivateFieldLoo4;
|
|
2729
|
-
Object.entries((_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(_this4, _transitions)[_transitions][currentStepId]) == null ? void 0 : _classPrivateFieldLoo4.transitions).forEach(function (
|
|
2730
|
-
var targetId =
|
|
2731
|
-
config =
|
|
2726
|
+
Object.entries((_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(_this4, _transitions)[_transitions][currentStepId]) == null ? void 0 : _classPrivateFieldLoo4.transitions).forEach(function (_ref10) {
|
|
2727
|
+
var targetId = _ref10[0],
|
|
2728
|
+
config = _ref10[1];
|
|
2732
2729
|
// Create flat state structure with transitions
|
|
2733
2730
|
state.on["TRANSITION_" + targetId] = {
|
|
2734
2731
|
target: targetId,
|
|
2735
|
-
guard: function guard(
|
|
2736
|
-
var context =
|
|
2732
|
+
guard: function guard(_ref11) {
|
|
2733
|
+
var context = _ref11.context;
|
|
2737
2734
|
return !(config != null && config.condition) || _classPrivateFieldLooseBase(_this4, _evaluateCondition)[_evaluateCondition](config == null ? void 0 : config.condition, context);
|
|
2738
2735
|
}
|
|
2739
2736
|
};
|
|
@@ -2766,7 +2763,7 @@ function _resolveVariables2(stepConfig, context) {
|
|
|
2766
2763
|
throw new Error("Cannot resolve variable: Step " + variable.stepId + " has not been executed yet");
|
|
2767
2764
|
}
|
|
2768
2765
|
// If path is empty or '.', return the entire source data
|
|
2769
|
-
var value = variable.path === '' || variable.path === '.' ? sourceData[key] : get(sourceData, variable.path);
|
|
2766
|
+
var value = variable.path === '' || variable.path === '.' ? sourceData[key] : radash.get(sourceData, variable.path);
|
|
2770
2767
|
if (value === undefined) {
|
|
2771
2768
|
throw new Error("Cannot resolve path \"" + variable.path + "\" from " + variable.stepId);
|
|
2772
2769
|
}
|
|
@@ -2793,7 +2790,7 @@ function _evaluateCondition2(condition, context) {
|
|
|
2793
2790
|
if (!sourceData) {
|
|
2794
2791
|
throw new Error("Cannot evaluate condition: Step " + ref.stepId + " has not been executed yet");
|
|
2795
2792
|
}
|
|
2796
|
-
var value = get(sourceData, ref.path);
|
|
2793
|
+
var value = radash.get(sourceData, ref.path);
|
|
2797
2794
|
baseResult = sift(query)(value);
|
|
2798
2795
|
}
|
|
2799
2796
|
// AND condition
|
|
@@ -2849,8 +2846,7 @@ function _detectCircularDependencies2() {
|
|
|
2849
2846
|
};
|
|
2850
2847
|
// Start DFS from first step
|
|
2851
2848
|
if (_classPrivateFieldLooseBase(this, _steps)[_steps].length > 0) {
|
|
2852
|
-
|
|
2853
|
-
_dfs((_classPrivateFieldLoo5 = _classPrivateFieldLooseBase(this, _steps)[_steps][0]) == null ? void 0 : _classPrivateFieldLoo5.id);
|
|
2849
|
+
_dfs(_classPrivateFieldLooseBase(this, _steps)[_steps][0].id);
|
|
2854
2850
|
}
|
|
2855
2851
|
return errors;
|
|
2856
2852
|
}
|
|
@@ -2898,8 +2894,7 @@ function _validateTerminalPaths2() {
|
|
|
2898
2894
|
};
|
|
2899
2895
|
// Start from first step
|
|
2900
2896
|
if (_classPrivateFieldLooseBase(this, _steps)[_steps].length > 0) {
|
|
2901
|
-
|
|
2902
|
-
_dfs2((_classPrivateFieldLoo6 = _classPrivateFieldLooseBase(this, _steps)[_steps][0]) == null ? void 0 : _classPrivateFieldLoo6.id);
|
|
2897
|
+
_dfs2(_classPrivateFieldLooseBase(this, _steps)[_steps][0].id);
|
|
2903
2898
|
}
|
|
2904
2899
|
return errors;
|
|
2905
2900
|
}
|
|
@@ -2919,8 +2914,7 @@ function _detectUnreachableSteps2() {
|
|
|
2919
2914
|
};
|
|
2920
2915
|
// Start from first step
|
|
2921
2916
|
if (_classPrivateFieldLooseBase(this, _steps)[_steps].length > 0) {
|
|
2922
|
-
|
|
2923
|
-
_dfs3((_classPrivateFieldLoo7 = _classPrivateFieldLooseBase(this, _steps)[_steps][0]) == null ? void 0 : _classPrivateFieldLoo7.id);
|
|
2917
|
+
_dfs3(_classPrivateFieldLooseBase(this, _steps)[_steps][0].id);
|
|
2924
2918
|
}
|
|
2925
2919
|
// Find unreachable steps
|
|
2926
2920
|
_classPrivateFieldLooseBase(this, _steps)[_steps].forEach(function (step) {
|
|
@@ -2939,10 +2933,10 @@ function _detectUnreachableSteps2() {
|
|
|
2939
2933
|
|
|
2940
2934
|
var Step = function Step(_ref) {
|
|
2941
2935
|
var id = _ref.id,
|
|
2942
|
-
|
|
2943
|
-
outputSchema = _ref.outputSchema,
|
|
2936
|
+
action = _ref.action,
|
|
2944
2937
|
payload = _ref.payload,
|
|
2945
|
-
|
|
2938
|
+
outputSchema = _ref.outputSchema,
|
|
2939
|
+
inputSchema = _ref.inputSchema;
|
|
2946
2940
|
this.id = void 0;
|
|
2947
2941
|
this.inputSchema = void 0;
|
|
2948
2942
|
this.outputSchema = void 0;
|