@mastra/core 0.1.27-alpha.60 → 0.1.27-alpha.62

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.
@@ -3324,7 +3324,18 @@ var Integration = /*#__PURE__*/function () {
3324
3324
  }
3325
3325
  this.workflows[name] = fn;
3326
3326
  };
3327
- _proto.getWorkflows = function getWorkflows() {
3327
+ _proto.getWorkflows = function getWorkflows(_ref) {
3328
+ var serialized = _ref.serialized;
3329
+ if (serialized) {
3330
+ return Object.entries(this.workflows).reduce(function (acc, _ref2) {
3331
+ var _extends2;
3332
+ var k = _ref2[0],
3333
+ v = _ref2[1];
3334
+ return _extends({}, acc, (_extends2 = {}, _extends2[k] = {
3335
+ name: v.name
3336
+ }, _extends2));
3337
+ }, {});
3338
+ }
3328
3339
  return this.workflows;
3329
3340
  }
3330
3341
  /**
@@ -3337,11 +3348,11 @@ var Integration = /*#__PURE__*/function () {
3337
3348
  this.syncFunctions.set(fn.id, fn);
3338
3349
  };
3339
3350
  _proto.getSyncs = function getSyncs() {
3340
- return Array.from(this.syncFunctions.entries()).reduce(function (acc, _ref) {
3341
- var _extends2;
3342
- var k = _ref[0],
3343
- v = _ref[1];
3344
- return _extends({}, acc, (_extends2 = {}, _extends2[k] = v, _extends2));
3351
+ return Array.from(this.syncFunctions.entries()).reduce(function (acc, _ref3) {
3352
+ var _extends3;
3353
+ var k = _ref3[0],
3354
+ v = _ref3[1];
3355
+ return _extends({}, acc, (_extends3 = {}, _extends3[k] = v, _extends3));
3345
3356
  }, {});
3346
3357
  }
3347
3358
  /**
@@ -4203,19 +4214,39 @@ exports.Mastra = /*#__PURE__*/function () {
4203
4214
  _proto.getVectors = function getVectors() {
4204
4215
  return this.vectors;
4205
4216
  };
4206
- _proto.getWorkflow = function getWorkflow(id) {
4217
+ _proto.getWorkflow = function getWorkflow(id, _temp) {
4207
4218
  var _this$workflows;
4219
+ var _ref4 = _temp === void 0 ? {} : _temp,
4220
+ serialized = _ref4.serialized;
4208
4221
  var workflow = (_this$workflows = this.workflows) == null ? void 0 : _this$workflows[id];
4209
4222
  if (!workflow) {
4210
4223
  throw new Error("Workflow with ID " + String(id) + " not found");
4211
4224
  }
4225
+ if (serialized) {
4226
+ return {
4227
+ name: workflow.name
4228
+ };
4229
+ }
4212
4230
  return workflow;
4213
4231
  };
4214
- _proto.getWorkflows = function getWorkflows() {
4232
+ _proto.getWorkflows = function getWorkflows(props) {
4233
+ if (props === void 0) {
4234
+ props = {};
4235
+ }
4236
+ if (props.serialized) {
4237
+ return Object.entries(this.workflows).reduce(function (acc, _ref5) {
4238
+ var _extends2;
4239
+ var k = _ref5[0],
4240
+ v = _ref5[1];
4241
+ return _extends({}, acc, (_extends2 = {}, _extends2[k] = {
4242
+ name: v.name
4243
+ }, _extends2));
4244
+ }, {});
4245
+ }
4215
4246
  return this.workflows;
4216
4247
  };
4217
- _proto.setLogger = function setLogger(_ref4) {
4218
- var logger = _ref4.logger;
4248
+ _proto.setLogger = function setLogger(_ref6) {
4249
+ var logger = _ref6.logger;
4219
4250
  this.logger = logger;
4220
4251
  };
4221
4252
  _proto.getLogger = function getLogger() {
@@ -5848,7 +5879,7 @@ function _persistWorkflowSnapshot3() {
5848
5879
  _context15.next = 4;
5849
5880
  break;
5850
5881
  }
5851
- this.log(LogLevel.ERROR, 'Snapshot cannot be persisted. Mastra engine is not initialized', {
5882
+ this.log(LogLevel.DEBUG, 'Snapshot cannot be persisted. Mastra engine is not initialized', {
5852
5883
  runId: _classPrivateFieldLooseBase(this, _runId)[_runId]
5853
5884
  });
5854
5885
  return _context15.abrupt("return");
@@ -6676,6 +6707,224 @@ exports.MastraTTS = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/InstrumentClass(
6676
6707
  excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log']
6677
6708
  }), /*#__PURE__*/tslib.__metadata("design:paramtypes", [Object])], exports.MastraTTS);
6678
6709
 
6710
+ var PromptTemplate = /*#__PURE__*/function () {
6711
+ function PromptTemplate(intent, config) {
6712
+ this.intent = void 0;
6713
+ this.config = void 0;
6714
+ this.components = [];
6715
+ this.intent = intent;
6716
+ this.config = config != null ? config : {};
6717
+ }
6718
+ var _proto = PromptTemplate.prototype;
6719
+ _proto.text = function text(_text) {
6720
+ this.components.push({
6721
+ text: _text
6722
+ });
6723
+ return this;
6724
+ };
6725
+ _proto.constraints = function constraints(_constraints) {
6726
+ this.components.push({
6727
+ constraints: _constraints
6728
+ });
6729
+ return this;
6730
+ };
6731
+ _proto.examples = function examples(_examples) {
6732
+ this.components.push({
6733
+ examples: _examples
6734
+ });
6735
+ return this;
6736
+ };
6737
+ _proto.thinking = function thinking(config) {
6738
+ this.components.push({
6739
+ thinking: config
6740
+ });
6741
+ return this;
6742
+ };
6743
+ _proto.emphasis = function emphasis(_emphasis) {
6744
+ this.components.push({
6745
+ emphasis: _emphasis
6746
+ });
6747
+ return this;
6748
+ };
6749
+ _proto.context = function context(_context) {
6750
+ this.components.push({
6751
+ context: _context
6752
+ });
6753
+ return this;
6754
+ };
6755
+ _proto.buildPromptComponent = function buildPromptComponent(config) {
6756
+ var _config$constraints, _config$examples;
6757
+ var component = [];
6758
+ /*
6759
+ * Add constraints if specified
6760
+ */
6761
+ if ((_config$constraints = config.constraints) != null && _config$constraints.length) {
6762
+ component.push('CONSTRAINTS:');
6763
+ config.constraints.forEach(function (constraint) {
6764
+ component.push("- " + constraint);
6765
+ });
6766
+ }
6767
+ if (config.emphasis) {
6768
+ if (config.emphasis.type === 'IMPORTANT !!!') {
6769
+ component.push('[IMPORTANT !!!] \n');
6770
+ } else if (config.emphasis.type === 'CALLOUT') {
6771
+ component.push('[CALLOUT] \n');
6772
+ } else if (config.emphasis.type === 'CUSTOM') {
6773
+ component.push("[" + config.emphasis.text + "] \n");
6774
+ }
6775
+ }
6776
+ /*
6777
+ * Add context if specified
6778
+ */
6779
+ if (config.context) {
6780
+ component.push("[CONTEXT] \n" + config.context + " \n");
6781
+ }
6782
+ /*
6783
+ * Add examples if specified
6784
+ */
6785
+ if ((_config$examples = config.examples) != null && _config$examples.length) {
6786
+ component.push('\nEXAMPLES:');
6787
+ config.examples.forEach(function (example) {
6788
+ component.push("Input: " + example.input);
6789
+ component.push("Output: " + example.output);
6790
+ });
6791
+ }
6792
+ /*
6793
+ * Add input if specified
6794
+ */
6795
+ if (config.text) {
6796
+ component.push(config.text + " \n");
6797
+ }
6798
+ /*
6799
+ * Add thinking steps if auto-thinking is enabled
6800
+ */
6801
+ if (config.thinking) {
6802
+ var _config$thinking$step, _config$thinking$veri;
6803
+ /*
6804
+ * Add chain of thought if enabled
6805
+ */
6806
+ if (config.thinking.autoChainOfThought) {
6807
+ component.push("Let's solve this step by step \n");
6808
+ }
6809
+ /*
6810
+ * Add steps if specified
6811
+ */
6812
+ if ((_config$thinking$step = config.thinking.steps) != null && _config$thinking$step.length) {
6813
+ config.thinking.steps.forEach(function (step, index) {
6814
+ component.push(index + 1 + ". " + step);
6815
+ });
6816
+ }
6817
+ /*
6818
+ * Add tree of thought if enabled
6819
+ */
6820
+ if (config.thinking.autoTreeOfThought) {
6821
+ component.push("\nLet's explore multiple ways of solving this problem and go through each approach step by step");
6822
+ } else if (config.thinking.branches) {
6823
+ /*
6824
+ * Else add explicit three of thought branches
6825
+ */
6826
+ Object.entries(config.thinking.branches).forEach(function (_ref) {
6827
+ var branch = _ref[0],
6828
+ thoughts = _ref[1];
6829
+ component.push("\n" + branch + " Approach:");
6830
+ thoughts.forEach(function (thought, index) {
6831
+ component.push(" " + (index + 1) + ". " + thought);
6832
+ });
6833
+ });
6834
+ }
6835
+ /*
6836
+ * Add self-ask if enabled
6837
+ */
6838
+ if (config.thinking.autoSelfAsk) {
6839
+ component.push("\nLet's break this down by asking ourselves questions \n");
6840
+ }
6841
+ /*
6842
+ * Add verification if enabled
6843
+ */
6844
+ if (config.thinking.autoVerification) {
6845
+ component.push("\nLet's verify our solution \n");
6846
+ }
6847
+ /*
6848
+ * Add verification steps if specified
6849
+ */
6850
+ if ((_config$thinking$veri = config.thinking.verificationSteps) != null && _config$thinking$veri.length) {
6851
+ component.push("\nLet's verify our solution");
6852
+ config.thinking.verificationSteps.forEach(function (step, index) {
6853
+ component.push(index + 1 + ". " + step);
6854
+ });
6855
+ }
6856
+ }
6857
+ return component;
6858
+ };
6859
+ _proto.toString = function toString(variables) {
6860
+ var _this = this,
6861
+ _Object$entries;
6862
+ var _this$layout = this.layout,
6863
+ intro = _this$layout.intro,
6864
+ outro = _this$layout.outro;
6865
+ var components = this.components.flatMap(function (component) {
6866
+ return _this.buildPromptComponent(component);
6867
+ });
6868
+ var prompt = [intro.join('\n'), components.join('\n'), outro.join('\n')].filter(Boolean).join('\n\n');
6869
+ var hydratedPrompt = prompt;
6870
+ (_Object$entries = Object.entries(variables != null ? variables : {})) == null || _Object$entries.forEach(function (_ref2) {
6871
+ var k = _ref2[0],
6872
+ v = _ref2[1];
6873
+ hydratedPrompt = hydratedPrompt.replace("{{" + k + "}}", "" + v);
6874
+ });
6875
+ return hydratedPrompt;
6876
+ };
6877
+ _proto.toMessage = function toMessage(variables) {
6878
+ return {
6879
+ role: this.config.as || 'system',
6880
+ content: this.toString(variables)
6881
+ };
6882
+ };
6883
+ return _createClass(PromptTemplate, [{
6884
+ key: "layout",
6885
+ get: function get() {
6886
+ var intro = [];
6887
+ var outro = [];
6888
+ /*
6889
+ * Intro
6890
+ */
6891
+ /*
6892
+ * Add persona if specified
6893
+ */
6894
+ if (this.config.persona) {
6895
+ intro.push("As a " + this.config.persona.toUpperCase() + ":");
6896
+ }
6897
+ /*
6898
+ * Add style and tone if specified
6899
+ */
6900
+ if (this.config.style || this.config.tone) {
6901
+ var styleStr = [this.config.style, this.config.tone].filter(Boolean).join(', ');
6902
+ intro.push("Write in a " + styleStr + " manner: \n");
6903
+ }
6904
+ /*
6905
+ * Add perspective if specified
6906
+ */
6907
+ if (this.config.perspective) {
6908
+ intro.push("From the perspective of " + this.config.perspective + ": \n");
6909
+ }
6910
+ intro.push(this.intent + " \n");
6911
+ /*
6912
+ * Outro
6913
+ */
6914
+ if (this.config.outputFormat) {
6915
+ outro.push("Please output your response in the following format: " + this.config.outputFormat + " \n");
6916
+ }
6917
+ return {
6918
+ intro: intro,
6919
+ outro: outro
6920
+ };
6921
+ }
6922
+ }]);
6923
+ }();
6924
+ function createPrompt(intent, config) {
6925
+ return new PromptTemplate(intent, config);
6926
+ }
6927
+
6679
6928
  exports.BaseLogger = BaseLogger;
6680
6929
  exports.CohereRelevanceScorer = CohereRelevanceScorer;
6681
6930
  exports.ConsoleLogger = ConsoleLogger;
@@ -6690,6 +6939,7 @@ exports.MastraVector = MastraVector;
6690
6939
  exports.MockMastraEngine = MockMastraEngine;
6691
6940
  exports.MultiLogger = MultiLogger;
6692
6941
  exports.OpenAPIToolset = OpenAPIToolset;
6942
+ exports.PromptTemplate = PromptTemplate;
6693
6943
  exports.RegisteredLogger = RegisteredLogger;
6694
6944
  exports.Step = Step;
6695
6945
  exports.Sync = Sync;
@@ -6699,6 +6949,7 @@ exports.UpstashRedisLogger = UpstashRedisLogger;
6699
6949
  exports.Workflow = Workflow;
6700
6950
  exports.combineLoggers = combineLoggers;
6701
6951
  exports.createLogger = createLogger;
6952
+ exports.createPrompt = createPrompt;
6702
6953
  exports.createSimilarityPrompt = createSimilarityPrompt;
6703
6954
  exports.createStep = createStep;
6704
6955
  exports.createSync = createSync;