@mastra/core 0.1.27-alpha.44 → 0.1.27-alpha.46

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.
@@ -28,7 +28,7 @@ export declare class Agent<TTools extends Record<string, ToolAction<any, any, an
28
28
  __setTools(tools: TTools): void;
29
29
  generateTitleFromUserMessage({ message }: {
30
30
  message: CoreUserMessage;
31
- }): Promise<any>;
31
+ }): Promise<string>;
32
32
  getMostRecentUserMessage(messages: Array<CoreMessage>): CoreUserMessage | undefined;
33
33
  genTitle(userMessage: CoreUserMessage | undefined): Promise<string>;
34
34
  saveMemory({ threadId, resourceid, userMessages, }: {
@@ -1581,58 +1581,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1581
1581
  this.log(LogLevel.DEBUG, "Converted tools for LLM");
1582
1582
  return converted;
1583
1583
  };
1584
- _proto.isBaseOutputType = function isBaseOutputType(outputType) {
1585
- return outputType === 'string' || outputType === 'number' || outputType === 'boolean' || outputType === 'date';
1586
- };
1587
- _proto.baseOutputTypeSchema = function baseOutputTypeSchema(outputType) {
1588
- switch (outputType) {
1589
- case 'string':
1590
- return zod.z.string();
1591
- case 'number':
1592
- return zod.z.number();
1593
- case 'boolean':
1594
- return zod.z["boolean"]();
1595
- case 'date':
1596
- return zod.z.string().describe('ISO 8601 date string');
1597
- default:
1598
- return zod.z.string();
1599
- }
1600
- };
1601
- _proto.createOutputSchema = function createOutputSchema(output) {
1602
- var _this3 = this;
1603
- var schema = Object.entries(output).reduce(function (memo, _ref6) {
1604
- var k = _ref6[0],
1605
- v = _ref6[1];
1606
- if (_this3.isBaseOutputType(v.type)) {
1607
- memo[k] = _this3.baseOutputTypeSchema(v.type);
1608
- }
1609
- if (v.type === 'object') {
1610
- var objectItem = v.items;
1611
- var objectItemSchema = _this3.createOutputSchema(objectItem);
1612
- memo[k] = objectItemSchema;
1613
- }
1614
- if (v.type === 'array') {
1615
- var arrayItem = v.items;
1616
- if (_this3.isBaseOutputType(arrayItem.type)) {
1617
- var itemSchema = _this3.baseOutputTypeSchema(arrayItem.type);
1618
- memo[k] = zod.z.array(itemSchema);
1619
- }
1620
- if (arrayItem.type === 'object') {
1621
- var objectInArrayItemSchema = _this3.createOutputSchema(arrayItem.items);
1622
- memo[k] = zod.z.array(objectInArrayItemSchema);
1623
- }
1624
- }
1625
- return memo;
1626
- }, {});
1627
- return zod.z.object(schema);
1628
- };
1629
1584
  _proto.generate = /*#__PURE__*/function () {
1630
1585
  var _generate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(messages, _temp) {
1631
- var _ref7, schema, stream, _ref7$maxSteps, maxSteps, onFinish, onStepFinish, tools, convertedTools, runId, msgs;
1586
+ var _ref6, schema, stream, _ref6$maxSteps, maxSteps, onFinish, onStepFinish, tools, convertedTools, runId, msgs;
1632
1587
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1633
1588
  while (1) switch (_context3.prev = _context3.next) {
1634
1589
  case 0:
1635
- _ref7 = _temp === void 0 ? {} : _temp, schema = _ref7.schema, stream = _ref7.stream, _ref7$maxSteps = _ref7.maxSteps, maxSteps = _ref7$maxSteps === void 0 ? 5 : _ref7$maxSteps, onFinish = _ref7.onFinish, onStepFinish = _ref7.onStepFinish, tools = _ref7.tools, convertedTools = _ref7.convertedTools, runId = _ref7.runId;
1590
+ _ref6 = _temp === void 0 ? {} : _temp, schema = _ref6.schema, stream = _ref6.stream, _ref6$maxSteps = _ref6.maxSteps, maxSteps = _ref6$maxSteps === void 0 ? 5 : _ref6$maxSteps, onFinish = _ref6.onFinish, onStepFinish = _ref6.onStepFinish, tools = _ref6.tools, convertedTools = _ref6.convertedTools, runId = _ref6.runId;
1636
1591
  if (Array.isArray(messages)) {
1637
1592
  msgs = messages == null ? void 0 : messages.map(function (m) {
1638
1593
  if (typeof m === 'string') {
@@ -1724,13 +1679,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1724
1679
  return generate;
1725
1680
  }();
1726
1681
  _proto.__text = /*#__PURE__*/function () {
1727
- var _text = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref8) {
1728
- var _this4 = this;
1729
- var messages, _onStepFinish, _ref8$maxSteps, maxSteps, tools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1682
+ var _text = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref7) {
1683
+ var _this3 = this;
1684
+ var messages, _onStepFinish, _ref7$maxSteps, maxSteps, tools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1730
1685
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1731
1686
  while (1) switch (_context5.prev = _context5.next) {
1732
1687
  case 0:
1733
- messages = _ref8.messages, _onStepFinish = _ref8.onStepFinish, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, tools = _ref8.tools, runId = _ref8.runId, convertedTools = _ref8.convertedTools;
1688
+ messages = _ref7.messages, _onStepFinish = _ref7.onStepFinish, _ref7$maxSteps = _ref7.maxSteps, maxSteps = _ref7$maxSteps === void 0 ? 5 : _ref7$maxSteps, tools = _ref7.tools, runId = _ref7.runId, convertedTools = _ref7.convertedTools;
1734
1689
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1735
1690
  this.log(LogLevel.DEBUG, "Generating text with " + messages.length + " messages", {
1736
1691
  runId: runId
@@ -1770,7 +1725,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1770
1725
  _context4.next = 5;
1771
1726
  break;
1772
1727
  }
1773
- _this4.logger.warn('Rate limit approaching, waiting 10 seconds');
1728
+ _this3.logger.warn('Rate limit approaching, waiting 10 seconds');
1774
1729
  _context4.next = 5;
1775
1730
  return delay(10 * 1000);
1776
1731
  case 5:
@@ -1805,13 +1760,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1805
1760
  return __text;
1806
1761
  }();
1807
1762
  _proto.__textObject = /*#__PURE__*/function () {
1808
- var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref9) {
1809
- var _this5 = this;
1810
- var messages, _onStepFinish3, _ref9$maxSteps, maxSteps, tools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1763
+ var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref8) {
1764
+ var _this4 = this;
1765
+ var messages, _onStepFinish3, _ref8$maxSteps, maxSteps, tools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1811
1766
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1812
1767
  while (1) switch (_context7.prev = _context7.next) {
1813
1768
  case 0:
1814
- messages = _ref9.messages, _onStepFinish3 = _ref9.onStepFinish, _ref9$maxSteps = _ref9.maxSteps, maxSteps = _ref9$maxSteps === void 0 ? 5 : _ref9$maxSteps, tools = _ref9.tools, convertedTools = _ref9.convertedTools, structuredOutput = _ref9.structuredOutput, runId = _ref9.runId;
1769
+ messages = _ref8.messages, _onStepFinish3 = _ref8.onStepFinish, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, tools = _ref8.tools, convertedTools = _ref8.convertedTools, structuredOutput = _ref8.structuredOutput, runId = _ref8.runId;
1815
1770
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1816
1771
  this.log(LogLevel.DEBUG, "Generating text with " + messages.length + " messages", {
1817
1772
  runId: runId
@@ -1851,7 +1806,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1851
1806
  _context6.next = 5;
1852
1807
  break;
1853
1808
  }
1854
- _this5.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
1809
+ _this4.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
1855
1810
  _context6.next = 5;
1856
1811
  return delay(10 * 1000);
1857
1812
  case 5:
@@ -1874,7 +1829,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1874
1829
  schema = schema._def.type;
1875
1830
  }
1876
1831
  } else {
1877
- schema = this.createOutputSchema(structuredOutput);
1832
+ schema = ai.jsonSchema(structuredOutput);
1878
1833
  }
1879
1834
  _context7.next = 12;
1880
1835
  return ai.generateObject(_extends({
@@ -1898,13 +1853,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1898
1853
  return __textObject;
1899
1854
  }();
1900
1855
  _proto.__stream = /*#__PURE__*/function () {
1901
- var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref10) {
1902
- var _this6 = this;
1903
- var messages, _onStepFinish5, _onFinish, _ref10$maxSteps, maxSteps, tools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1856
+ var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref9) {
1857
+ var _this5 = this;
1858
+ var messages, _onStepFinish5, _onFinish, _ref9$maxSteps, maxSteps, tools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1904
1859
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1905
1860
  while (1) switch (_context10.prev = _context10.next) {
1906
1861
  case 0:
1907
- messages = _ref10.messages, _onStepFinish5 = _ref10.onStepFinish, _onFinish = _ref10.onFinish, _ref10$maxSteps = _ref10.maxSteps, maxSteps = _ref10$maxSteps === void 0 ? 5 : _ref10$maxSteps, tools = _ref10.tools, runId = _ref10.runId, convertedTools = _ref10.convertedTools;
1862
+ messages = _ref9.messages, _onStepFinish5 = _ref9.onStepFinish, _onFinish = _ref9.onFinish, _ref9$maxSteps = _ref9.maxSteps, maxSteps = _ref9$maxSteps === void 0 ? 5 : _ref9$maxSteps, tools = _ref9.tools, runId = _ref9.runId, convertedTools = _ref9.convertedTools;
1908
1863
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1909
1864
  this.log(LogLevel.DEBUG, "Streaming text with " + messages.length + " messages", {
1910
1865
  runId: runId
@@ -1944,7 +1899,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1944
1899
  _context8.next = 5;
1945
1900
  break;
1946
1901
  }
1947
- _this6.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
1902
+ _this5.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
1948
1903
  _context8.next = 5;
1949
1904
  return delay(10 * 1000);
1950
1905
  case 5:
@@ -1996,13 +1951,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
1996
1951
  return __stream;
1997
1952
  }();
1998
1953
  _proto.__streamObject = /*#__PURE__*/function () {
1999
- var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref11) {
2000
- var _this7 = this;
2001
- var messages, _onStepFinish7, _onFinish3, _ref11$maxSteps, maxSteps, tools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1954
+ var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref10) {
1955
+ var _this6 = this;
1956
+ var messages, _onStepFinish7, _onFinish3, _ref10$maxSteps, maxSteps, tools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
2002
1957
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2003
1958
  while (1) switch (_context13.prev = _context13.next) {
2004
1959
  case 0:
2005
- messages = _ref11.messages, _onStepFinish7 = _ref11.onStepFinish, _onFinish3 = _ref11.onFinish, _ref11$maxSteps = _ref11.maxSteps, maxSteps = _ref11$maxSteps === void 0 ? 5 : _ref11$maxSteps, tools = _ref11.tools, convertedTools = _ref11.convertedTools, structuredOutput = _ref11.structuredOutput, runId = _ref11.runId;
1960
+ messages = _ref10.messages, _onStepFinish7 = _ref10.onStepFinish, _onFinish3 = _ref10.onFinish, _ref10$maxSteps = _ref10.maxSteps, maxSteps = _ref10$maxSteps === void 0 ? 5 : _ref10$maxSteps, tools = _ref10.tools, convertedTools = _ref10.convertedTools, structuredOutput = _ref10.structuredOutput, runId = _ref10.runId;
2006
1961
  model = _classPrivateFieldLooseBase(this, _model)[_model];
2007
1962
  this.log(LogLevel.DEBUG, "Streaming text with " + messages.length + " messages", {
2008
1963
  runId: runId
@@ -2042,7 +1997,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
2042
1997
  _context11.next = 5;
2043
1998
  break;
2044
1999
  }
2045
- _this7.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
2000
+ _this6.logger.warn('Rate limit approaching, waiting 10 seconds', runId);
2046
2001
  _context11.next = 5;
2047
2002
  return delay(10 * 1000);
2048
2003
  case 5:
@@ -2082,7 +2037,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), /*#__PURE_
2082
2037
  schema = schema._def.type;
2083
2038
  }
2084
2039
  } else {
2085
- schema = this.createOutputSchema(structuredOutput);
2040
+ schema = ai.jsonSchema(structuredOutput);
2086
2041
  }
2087
2042
  _context13.next = 12;
2088
2043
  return ai.streamObject(_extends({