@mastra/core 0.1.27-alpha.31 → 0.1.27-alpha.33

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.
@@ -15,7 +15,6 @@ var openai = require('@ai-sdk/openai');
15
15
  var xai = require('@ai-sdk/xai');
16
16
  var ai = require('ai');
17
17
  var anthropicVertexAi = require('anthropic-vertex-ai');
18
- var voyageAiProvider = require('voyage-ai-provider');
19
18
  var redis = require('@upstash/redis');
20
19
  var fs = require('fs');
21
20
  var path = require('path');
@@ -29,6 +28,7 @@ var semanticConventions = require('@opentelemetry/semantic-conventions');
29
28
  var radash = require('radash');
30
29
  var sift = require('sift');
31
30
  var xstate = require('xstate');
31
+ var voyageAiProvider = require('voyage-ai-provider');
32
32
 
33
33
  function _arrayLikeToArray(r, a) {
34
34
  (null == a || a > r.length) && (a = r.length);
@@ -1293,129 +1293,16 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1293
1293
  }
1294
1294
  return modelDef;
1295
1295
  };
1296
- _proto.createEmbedding = /*#__PURE__*/function () {
1297
- var _createEmbedding = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
1298
- var model, value, maxRetries, embeddingModel, openai$1, cohere$1, amazon, google$1, mistral$1, voyage;
1299
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1300
- while (1) switch (_context.prev = _context.next) {
1301
- case 0:
1302
- model = _ref4.model, value = _ref4.value, maxRetries = _ref4.maxRetries;
1303
- if (!(model.provider === 'OPEN_AI')) {
1304
- _context.next = 6;
1305
- break;
1306
- }
1307
- openai$1 = openai.createOpenAI({
1308
- apiKey: process.env.OPENAI_API_KEY
1309
- });
1310
- embeddingModel = openai$1.embedding(model.name);
1311
- _context.next = 32;
1312
- break;
1313
- case 6:
1314
- if (!(model.provider === 'COHERE')) {
1315
- _context.next = 11;
1316
- break;
1317
- }
1318
- cohere$1 = cohere.createCohere({
1319
- apiKey: process.env.COHERE_API_KEY
1320
- });
1321
- embeddingModel = cohere$1.embedding(model.name);
1322
- _context.next = 32;
1323
- break;
1324
- case 11:
1325
- if (!(model.provider === 'AMAZON')) {
1326
- _context.next = 16;
1327
- break;
1328
- }
1329
- amazon = amazonBedrock.createAmazonBedrock({
1330
- region: process.env.AWS_REGION || '',
1331
- accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
1332
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
1333
- sessionToken: process.env.AWS_SESSION_TOKEN || ''
1334
- });
1335
- embeddingModel = amazon.embedding(model.name);
1336
- _context.next = 32;
1337
- break;
1338
- case 16:
1339
- if (!(model.provider === 'GOOGLE')) {
1340
- _context.next = 21;
1341
- break;
1342
- }
1343
- google$1 = google.createGoogleGenerativeAI({
1344
- baseURL: 'https://generativelanguage.googleapis.com/v1beta',
1345
- apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY || ''
1346
- });
1347
- embeddingModel = google$1.textEmbeddingModel(model.name);
1348
- _context.next = 32;
1349
- break;
1350
- case 21:
1351
- if (!(model.provider === 'MISTRAL')) {
1352
- _context.next = 26;
1353
- break;
1354
- }
1355
- mistral$1 = mistral.createMistral({
1356
- baseURL: 'https://api.mistral.ai/v1',
1357
- apiKey: process.env.MISTRAL_API_KEY || ''
1358
- });
1359
- embeddingModel = mistral$1.textEmbeddingModel(model.name);
1360
- _context.next = 32;
1361
- break;
1362
- case 26:
1363
- if (!(model.provider === 'VOYAGE')) {
1364
- _context.next = 31;
1365
- break;
1366
- }
1367
- voyage = voyageAiProvider.createVoyage({
1368
- baseURL: 'https://api.voyageai.com/v1',
1369
- apiKey: process.env.VOYAGE_API_KEY || ''
1370
- });
1371
- embeddingModel = voyage.textEmbeddingModel(model.name);
1372
- _context.next = 32;
1373
- break;
1374
- case 31:
1375
- throw new Error("Invalid embedding model");
1376
- case 32:
1377
- if (!(value instanceof Array)) {
1378
- _context.next = 36;
1379
- break;
1380
- }
1381
- _context.next = 35;
1382
- return ai.embedMany({
1383
- model: embeddingModel,
1384
- values: value,
1385
- maxRetries: maxRetries
1386
- });
1387
- case 35:
1388
- return _context.abrupt("return", _context.sent);
1389
- case 36:
1390
- _context.next = 38;
1391
- return ai.embed({
1392
- model: embeddingModel,
1393
- value: value,
1394
- maxRetries: maxRetries
1395
- });
1396
- case 38:
1397
- return _context.abrupt("return", _context.sent);
1398
- case 39:
1399
- case "end":
1400
- return _context.stop();
1401
- }
1402
- }, _callee);
1403
- }));
1404
- function createEmbedding(_x) {
1405
- return _createEmbedding.apply(this, arguments);
1406
- }
1407
- return createEmbedding;
1408
- }();
1409
1296
  _proto.getParams = /*#__PURE__*/function () {
1410
- var _getParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
1297
+ var _getParams = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
1411
1298
  var tools, resultTool, model, toolsConverted, answerTool, modelDef;
1412
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1413
- while (1) switch (_context2.prev = _context2.next) {
1299
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1300
+ while (1) switch (_context.prev = _context.next) {
1414
1301
  case 0:
1415
- tools = _ref5.tools, resultTool = _ref5.resultTool, model = _ref5.model;
1416
- toolsConverted = Object.entries(tools).reduce(function (memo, _ref6) {
1417
- var key = _ref6[0],
1418
- val = _ref6[1];
1302
+ tools = _ref4.tools, resultTool = _ref4.resultTool, model = _ref4.model;
1303
+ toolsConverted = Object.entries(tools).reduce(function (memo, _ref5) {
1304
+ var key = _ref5[0],
1305
+ val = _ref5[1];
1419
1306
  memo[key] = ai.tool(val);
1420
1307
  return memo;
1421
1308
  }, {});
@@ -1426,29 +1313,29 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1426
1313
  };
1427
1314
  }
1428
1315
  if (!('type' in model)) {
1429
- _context2.next = 8;
1316
+ _context.next = 8;
1430
1317
  break;
1431
1318
  }
1432
1319
  modelDef = this.createModelDef({
1433
1320
  model: model
1434
1321
  });
1435
- _context2.next = 15;
1322
+ _context.next = 15;
1436
1323
  break;
1437
1324
  case 8:
1438
1325
  if (!(model.model instanceof Function)) {
1439
- _context2.next = 14;
1326
+ _context.next = 14;
1440
1327
  break;
1441
1328
  }
1442
- _context2.next = 11;
1329
+ _context.next = 11;
1443
1330
  return model.model();
1444
1331
  case 11:
1445
- modelDef = _context2.sent;
1446
- _context2.next = 15;
1332
+ modelDef = _context.sent;
1333
+ _context.next = 15;
1447
1334
  break;
1448
1335
  case 14:
1449
1336
  modelDef = model.model;
1450
1337
  case 15:
1451
- return _context2.abrupt("return", {
1338
+ return _context.abrupt("return", {
1452
1339
  toolsConverted: toolsConverted,
1453
1340
  modelDef: modelDef,
1454
1341
  answerTool: answerTool,
@@ -1456,11 +1343,11 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1456
1343
  });
1457
1344
  case 16:
1458
1345
  case "end":
1459
- return _context2.stop();
1346
+ return _context.stop();
1460
1347
  }
1461
- }, _callee2, this);
1348
+ }, _callee, this);
1462
1349
  }));
1463
- function getParams(_x2) {
1350
+ function getParams(_x) {
1464
1351
  return _getParams.apply(this, arguments);
1465
1352
  }
1466
1353
  return getParams;
@@ -1504,9 +1391,9 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1504
1391
  };
1505
1392
  _proto.createOutputSchema = function createOutputSchema(output) {
1506
1393
  var _this2 = this;
1507
- var schema = Object.entries(output).reduce(function (memo, _ref7) {
1508
- var k = _ref7[0],
1509
- v = _ref7[1];
1394
+ var schema = Object.entries(output).reduce(function (memo, _ref6) {
1395
+ var k = _ref6[0],
1396
+ v = _ref6[1];
1510
1397
  if (_this2.isBaseOutputType(v.type)) {
1511
1398
  memo[k] = _this2.baseOutputTypeSchema(v.type);
1512
1399
  }
@@ -1531,12 +1418,12 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1531
1418
  return zod.z.object(schema);
1532
1419
  };
1533
1420
  _proto.generate = /*#__PURE__*/function () {
1534
- var _generate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(messages, _temp) {
1535
- var _ref8, schema, stream, _ref8$maxSteps, maxSteps, onFinish, onStepFinish, enabledTools, convertedTools, runId, msgs;
1536
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1537
- while (1) switch (_context3.prev = _context3.next) {
1421
+ var _generate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(messages, _temp) {
1422
+ var _ref7, schema, stream, _ref7$maxSteps, maxSteps, onFinish, onStepFinish, enabledTools, convertedTools, runId, msgs;
1423
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1424
+ while (1) switch (_context2.prev = _context2.next) {
1538
1425
  case 0:
1539
- _ref8 = _temp === void 0 ? {} : _temp, schema = _ref8.schema, stream = _ref8.stream, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, onFinish = _ref8.onFinish, onStepFinish = _ref8.onStepFinish, enabledTools = _ref8.enabledTools, convertedTools = _ref8.convertedTools, runId = _ref8.runId;
1426
+ _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, enabledTools = _ref7.enabledTools, convertedTools = _ref7.convertedTools, runId = _ref7.runId;
1540
1427
  if (Array.isArray(messages)) {
1541
1428
  msgs = messages == null ? void 0 : messages.map(function (m) {
1542
1429
  if (typeof m === 'string') {
@@ -1554,10 +1441,10 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1554
1441
  }];
1555
1442
  }
1556
1443
  if (!(stream && schema)) {
1557
- _context3.next = 6;
1444
+ _context2.next = 6;
1558
1445
  break;
1559
1446
  }
1560
- _context3.next = 5;
1447
+ _context2.next = 5;
1561
1448
  return this.__streamObject({
1562
1449
  messages: msgs,
1563
1450
  structuredOutput: schema,
@@ -1569,13 +1456,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1569
1456
  runId: runId
1570
1457
  });
1571
1458
  case 5:
1572
- return _context3.abrupt("return", _context3.sent);
1459
+ return _context2.abrupt("return", _context2.sent);
1573
1460
  case 6:
1574
1461
  if (!stream) {
1575
- _context3.next = 10;
1462
+ _context2.next = 10;
1576
1463
  break;
1577
1464
  }
1578
- _context3.next = 9;
1465
+ _context2.next = 9;
1579
1466
  return this.__stream({
1580
1467
  messages: msgs,
1581
1468
  onStepFinish: onStepFinish,
@@ -1586,13 +1473,13 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1586
1473
  runId: runId
1587
1474
  });
1588
1475
  case 9:
1589
- return _context3.abrupt("return", _context3.sent);
1476
+ return _context2.abrupt("return", _context2.sent);
1590
1477
  case 10:
1591
1478
  if (!schema) {
1592
- _context3.next = 14;
1479
+ _context2.next = 14;
1593
1480
  break;
1594
1481
  }
1595
- _context3.next = 13;
1482
+ _context2.next = 13;
1596
1483
  return this.__textObject({
1597
1484
  messages: msgs,
1598
1485
  structuredOutput: schema,
@@ -1603,9 +1490,9 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1603
1490
  runId: runId
1604
1491
  });
1605
1492
  case 13:
1606
- return _context3.abrupt("return", _context3.sent);
1493
+ return _context2.abrupt("return", _context2.sent);
1607
1494
  case 14:
1608
- _context3.next = 16;
1495
+ _context2.next = 16;
1609
1496
  return this.__text({
1610
1497
  messages: msgs,
1611
1498
  onStepFinish: onStepFinish,
@@ -1615,26 +1502,26 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1615
1502
  runId: runId
1616
1503
  });
1617
1504
  case 16:
1618
- return _context3.abrupt("return", _context3.sent);
1505
+ return _context2.abrupt("return", _context2.sent);
1619
1506
  case 17:
1620
1507
  case "end":
1621
- return _context3.stop();
1508
+ return _context2.stop();
1622
1509
  }
1623
- }, _callee3, this);
1510
+ }, _callee2, this);
1624
1511
  }));
1625
- function generate(_x3, _x4) {
1512
+ function generate(_x2, _x3) {
1626
1513
  return _generate.apply(this, arguments);
1627
1514
  }
1628
1515
  return generate;
1629
1516
  }();
1630
1517
  _proto.__text = /*#__PURE__*/function () {
1631
- var _text = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref9) {
1518
+ var _text = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref8) {
1632
1519
  var _this3 = this;
1633
- var messages, _onStepFinish, _ref9$maxSteps, maxSteps, enabledTools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1634
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1635
- while (1) switch (_context5.prev = _context5.next) {
1520
+ var messages, _onStepFinish, _ref8$maxSteps, maxSteps, enabledTools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1521
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1522
+ while (1) switch (_context4.prev = _context4.next) {
1636
1523
  case 0:
1637
- messages = _ref9.messages, _onStepFinish = _ref9.onStepFinish, _ref9$maxSteps = _ref9.maxSteps, maxSteps = _ref9$maxSteps === void 0 ? 5 : _ref9$maxSteps, enabledTools = _ref9.enabledTools, runId = _ref9.runId, convertedTools = _ref9.convertedTools;
1524
+ messages = _ref8.messages, _onStepFinish = _ref8.onStepFinish, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, enabledTools = _ref8.enabledTools, runId = _ref8.runId, convertedTools = _ref8.convertedTools;
1638
1525
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1639
1526
  _classPrivateFieldLooseBase(this, _log$2)[_log$2](LogLevel.DEBUG, "Generating text with " + messages.length + " messages", runId);
1640
1527
  if ('name' in model) {
@@ -1649,71 +1536,71 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1649
1536
  } else {
1650
1537
  modelToPass = model;
1651
1538
  }
1652
- _context5.next = 6;
1539
+ _context4.next = 6;
1653
1540
  return this.getParams({
1654
1541
  tools: convertedTools || this.convertTools(enabledTools || {}),
1655
1542
  model: modelToPass
1656
1543
  });
1657
1544
  case 6:
1658
- params = _context5.sent;
1545
+ params = _context4.sent;
1659
1546
  argsForExecute = {
1660
1547
  model: params.modelDef,
1661
1548
  tools: _extends({}, params.toolsConverted, params.answerTool),
1662
1549
  toolChoice: params.toolChoice,
1663
1550
  maxSteps: maxSteps,
1664
1551
  onStepFinish: function () {
1665
- var _onStepFinish2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(props) {
1552
+ var _onStepFinish2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(props) {
1666
1553
  var _props$response, _props$response2;
1667
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1668
- while (1) switch (_context4.prev = _context4.next) {
1554
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1555
+ while (1) switch (_context3.prev = _context3.next) {
1669
1556
  case 0:
1670
1557
  _onStepFinish == null || _onStepFinish(JSON.stringify(props, null, 2));
1671
1558
  if (!(props != null && (_props$response = props.response) != null && (_props$response = _props$response.headers) != null && _props$response['x-ratelimit-remaining-tokens'] && parseInt(props == null || (_props$response2 = props.response) == null || (_props$response2 = _props$response2.headers) == null ? void 0 : _props$response2['x-ratelimit-remaining-tokens'], 10) < 2000)) {
1672
- _context4.next = 5;
1559
+ _context3.next = 5;
1673
1560
  break;
1674
1561
  }
1675
1562
  _classPrivateFieldLooseBase(_this3, _logger$2)[_logger$2].warn('Rate limit approaching, waiting 10 seconds');
1676
- _context4.next = 5;
1563
+ _context3.next = 5;
1677
1564
  return delay(10 * 1000);
1678
1565
  case 5:
1679
1566
  case "end":
1680
- return _context4.stop();
1567
+ return _context3.stop();
1681
1568
  }
1682
- }, _callee4);
1569
+ }, _callee3);
1683
1570
  }));
1684
- function onStepFinish(_x6) {
1571
+ function onStepFinish(_x5) {
1685
1572
  return _onStepFinish2.apply(this, arguments);
1686
1573
  }
1687
1574
  return onStepFinish;
1688
1575
  }()
1689
1576
  };
1690
- _context5.next = 10;
1577
+ _context4.next = 10;
1691
1578
  return ai.generateText(_extends({
1692
1579
  messages: messages
1693
1580
  }, argsForExecute, {
1694
1581
  experimental_telemetry: this.experimental_telemetry
1695
1582
  }));
1696
1583
  case 10:
1697
- return _context5.abrupt("return", _context5.sent);
1584
+ return _context4.abrupt("return", _context4.sent);
1698
1585
  case 11:
1699
1586
  case "end":
1700
- return _context5.stop();
1587
+ return _context4.stop();
1701
1588
  }
1702
- }, _callee5, this);
1589
+ }, _callee4, this);
1703
1590
  }));
1704
- function __text(_x5) {
1591
+ function __text(_x4) {
1705
1592
  return _text.apply(this, arguments);
1706
1593
  }
1707
1594
  return __text;
1708
1595
  }();
1709
1596
  _proto.__textObject = /*#__PURE__*/function () {
1710
- var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref10) {
1597
+ var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref9) {
1711
1598
  var _this4 = this;
1712
- var messages, _onStepFinish3, _ref10$maxSteps, maxSteps, enabledTools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1713
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1714
- while (1) switch (_context7.prev = _context7.next) {
1599
+ var messages, _onStepFinish3, _ref9$maxSteps, maxSteps, enabledTools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1600
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1601
+ while (1) switch (_context6.prev = _context6.next) {
1715
1602
  case 0:
1716
- messages = _ref10.messages, _onStepFinish3 = _ref10.onStepFinish, _ref10$maxSteps = _ref10.maxSteps, maxSteps = _ref10$maxSteps === void 0 ? 5 : _ref10$maxSteps, enabledTools = _ref10.enabledTools, convertedTools = _ref10.convertedTools, structuredOutput = _ref10.structuredOutput, runId = _ref10.runId;
1603
+ messages = _ref9.messages, _onStepFinish3 = _ref9.onStepFinish, _ref9$maxSteps = _ref9.maxSteps, maxSteps = _ref9$maxSteps === void 0 ? 5 : _ref9$maxSteps, enabledTools = _ref9.enabledTools, convertedTools = _ref9.convertedTools, structuredOutput = _ref9.structuredOutput, runId = _ref9.runId;
1717
1604
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1718
1605
  _classPrivateFieldLooseBase(this, _log$2)[_log$2](LogLevel.DEBUG, "Generating text with " + messages.length + " messages", runId);
1719
1606
  if ('name' in model) {
@@ -1728,39 +1615,39 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1728
1615
  } else {
1729
1616
  modelToPass = model;
1730
1617
  }
1731
- _context7.next = 6;
1618
+ _context6.next = 6;
1732
1619
  return this.getParams({
1733
1620
  tools: convertedTools || this.convertTools(enabledTools || {}),
1734
1621
  model: modelToPass
1735
1622
  });
1736
1623
  case 6:
1737
- params = _context7.sent;
1624
+ params = _context6.sent;
1738
1625
  argsForExecute = {
1739
1626
  model: params.modelDef,
1740
1627
  tools: _extends({}, params.toolsConverted, params.answerTool),
1741
1628
  toolChoice: params.toolChoice,
1742
1629
  maxSteps: maxSteps,
1743
1630
  onStepFinish: function () {
1744
- var _onStepFinish4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(props) {
1631
+ var _onStepFinish4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(props) {
1745
1632
  var _props$response3, _props$response4;
1746
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1747
- while (1) switch (_context6.prev = _context6.next) {
1633
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1634
+ while (1) switch (_context5.prev = _context5.next) {
1748
1635
  case 0:
1749
1636
  _onStepFinish3 == null || _onStepFinish3(JSON.stringify(props, null, 2));
1750
1637
  if (!(props != null && (_props$response3 = props.response) != null && (_props$response3 = _props$response3.headers) != null && _props$response3['x-ratelimit-remaining-tokens'] && parseInt(props == null || (_props$response4 = props.response) == null || (_props$response4 = _props$response4.headers) == null ? void 0 : _props$response4['x-ratelimit-remaining-tokens'], 10) < 2000)) {
1751
- _context6.next = 5;
1638
+ _context5.next = 5;
1752
1639
  break;
1753
1640
  }
1754
1641
  _classPrivateFieldLooseBase(_this4, _logger$2)[_logger$2].warn('Rate limit approaching, waiting 10 seconds', runId);
1755
- _context6.next = 5;
1642
+ _context5.next = 5;
1756
1643
  return delay(10 * 1000);
1757
1644
  case 5:
1758
1645
  case "end":
1759
- return _context6.stop();
1646
+ return _context5.stop();
1760
1647
  }
1761
- }, _callee6);
1648
+ }, _callee5);
1762
1649
  }));
1763
- function onStepFinish(_x8) {
1650
+ function onStepFinish(_x7) {
1764
1651
  return _onStepFinish4.apply(this, arguments);
1765
1652
  }
1766
1653
  return onStepFinish;
@@ -1776,7 +1663,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1776
1663
  } else {
1777
1664
  schema = this.createOutputSchema(structuredOutput);
1778
1665
  }
1779
- _context7.next = 12;
1666
+ _context6.next = 12;
1780
1667
  return ai.generateObject(_extends({
1781
1668
  messages: messages
1782
1669
  }, argsForExecute, {
@@ -1785,26 +1672,26 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1785
1672
  experimental_telemetry: this.experimental_telemetry
1786
1673
  }));
1787
1674
  case 12:
1788
- return _context7.abrupt("return", _context7.sent);
1675
+ return _context6.abrupt("return", _context6.sent);
1789
1676
  case 13:
1790
1677
  case "end":
1791
- return _context7.stop();
1678
+ return _context6.stop();
1792
1679
  }
1793
- }, _callee7, this);
1680
+ }, _callee6, this);
1794
1681
  }));
1795
- function __textObject(_x7) {
1682
+ function __textObject(_x6) {
1796
1683
  return _textObject.apply(this, arguments);
1797
1684
  }
1798
1685
  return __textObject;
1799
1686
  }();
1800
1687
  _proto.__stream = /*#__PURE__*/function () {
1801
- var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref11) {
1688
+ var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref10) {
1802
1689
  var _this5 = this;
1803
- var messages, _onStepFinish5, _onFinish, _ref11$maxSteps, maxSteps, enabledTools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1804
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1805
- while (1) switch (_context10.prev = _context10.next) {
1690
+ var messages, _onStepFinish5, _onFinish, _ref10$maxSteps, maxSteps, enabledTools, runId, convertedTools, model, modelToPass, params, argsForExecute;
1691
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1692
+ while (1) switch (_context9.prev = _context9.next) {
1806
1693
  case 0:
1807
- messages = _ref11.messages, _onStepFinish5 = _ref11.onStepFinish, _onFinish = _ref11.onFinish, _ref11$maxSteps = _ref11.maxSteps, maxSteps = _ref11$maxSteps === void 0 ? 5 : _ref11$maxSteps, enabledTools = _ref11.enabledTools, runId = _ref11.runId, convertedTools = _ref11.convertedTools;
1694
+ messages = _ref10.messages, _onStepFinish5 = _ref10.onStepFinish, _onFinish = _ref10.onFinish, _ref10$maxSteps = _ref10.maxSteps, maxSteps = _ref10$maxSteps === void 0 ? 5 : _ref10$maxSteps, enabledTools = _ref10.enabledTools, runId = _ref10.runId, convertedTools = _ref10.convertedTools;
1808
1695
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1809
1696
  _classPrivateFieldLooseBase(this, _log$2)[_log$2](LogLevel.DEBUG, "Streaming text with " + messages.length + " messages", runId);
1810
1697
  if ('name' in model) {
@@ -1819,88 +1706,88 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1819
1706
  } else {
1820
1707
  modelToPass = model;
1821
1708
  }
1822
- _context10.next = 6;
1709
+ _context9.next = 6;
1823
1710
  return this.getParams({
1824
1711
  tools: convertedTools || this.convertTools(enabledTools),
1825
1712
  model: modelToPass
1826
1713
  });
1827
1714
  case 6:
1828
- params = _context10.sent;
1715
+ params = _context9.sent;
1829
1716
  argsForExecute = {
1830
1717
  model: params.modelDef,
1831
1718
  tools: _extends({}, params.toolsConverted, params.answerTool),
1832
1719
  toolChoice: params.toolChoice,
1833
1720
  maxSteps: maxSteps,
1834
1721
  onStepFinish: function () {
1835
- var _onStepFinish6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(props) {
1722
+ var _onStepFinish6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(props) {
1836
1723
  var _props$response5, _props$response6;
1837
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1838
- while (1) switch (_context8.prev = _context8.next) {
1724
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1725
+ while (1) switch (_context7.prev = _context7.next) {
1839
1726
  case 0:
1840
1727
  _onStepFinish5 == null || _onStepFinish5(JSON.stringify(props, null, 2));
1841
1728
  if (!(props != null && (_props$response5 = props.response) != null && (_props$response5 = _props$response5.headers) != null && _props$response5['x-ratelimit-remaining-tokens'] && parseInt(props == null || (_props$response6 = props.response) == null || (_props$response6 = _props$response6.headers) == null ? void 0 : _props$response6['x-ratelimit-remaining-tokens'], 10) < 2000)) {
1842
- _context8.next = 5;
1729
+ _context7.next = 5;
1843
1730
  break;
1844
1731
  }
1845
1732
  _classPrivateFieldLooseBase(_this5, _logger$2)[_logger$2].warn('Rate limit approaching, waiting 10 seconds', runId);
1846
- _context8.next = 5;
1733
+ _context7.next = 5;
1847
1734
  return delay(10 * 1000);
1848
1735
  case 5:
1849
1736
  case "end":
1850
- return _context8.stop();
1737
+ return _context7.stop();
1851
1738
  }
1852
- }, _callee8);
1739
+ }, _callee7);
1853
1740
  }));
1854
- function onStepFinish(_x10) {
1741
+ function onStepFinish(_x9) {
1855
1742
  return _onStepFinish6.apply(this, arguments);
1856
1743
  }
1857
1744
  return onStepFinish;
1858
1745
  }(),
1859
1746
  onFinish: function () {
1860
- var _onFinish2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(props) {
1861
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1862
- while (1) switch (_context9.prev = _context9.next) {
1747
+ var _onFinish2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(props) {
1748
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1749
+ while (1) switch (_context8.prev = _context8.next) {
1863
1750
  case 0:
1864
1751
  _onFinish == null || _onFinish(JSON.stringify(props, null, 2));
1865
1752
  case 1:
1866
1753
  case "end":
1867
- return _context9.stop();
1754
+ return _context8.stop();
1868
1755
  }
1869
- }, _callee9);
1756
+ }, _callee8);
1870
1757
  }));
1871
- function onFinish(_x11) {
1758
+ function onFinish(_x10) {
1872
1759
  return _onFinish2.apply(this, arguments);
1873
1760
  }
1874
1761
  return onFinish;
1875
1762
  }()
1876
1763
  };
1877
- _context10.next = 10;
1764
+ _context9.next = 10;
1878
1765
  return ai.streamText(_extends({
1879
1766
  messages: messages
1880
1767
  }, argsForExecute, {
1881
1768
  experimental_telemetry: this.experimental_telemetry
1882
1769
  }));
1883
1770
  case 10:
1884
- return _context10.abrupt("return", _context10.sent);
1771
+ return _context9.abrupt("return", _context9.sent);
1885
1772
  case 11:
1886
1773
  case "end":
1887
- return _context10.stop();
1774
+ return _context9.stop();
1888
1775
  }
1889
- }, _callee10, this);
1776
+ }, _callee9, this);
1890
1777
  }));
1891
- function __stream(_x9) {
1778
+ function __stream(_x8) {
1892
1779
  return _stream.apply(this, arguments);
1893
1780
  }
1894
1781
  return __stream;
1895
1782
  }();
1896
1783
  _proto.__streamObject = /*#__PURE__*/function () {
1897
- var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref12) {
1784
+ var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref11) {
1898
1785
  var _this6 = this;
1899
- var messages, _onStepFinish7, _onFinish3, _ref12$maxSteps, maxSteps, enabledTools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1900
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1901
- while (1) switch (_context13.prev = _context13.next) {
1786
+ var messages, _onStepFinish7, _onFinish3, _ref11$maxSteps, maxSteps, enabledTools, convertedTools, structuredOutput, runId, model, modelToPass, params, argsForExecute, schema, output;
1787
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1788
+ while (1) switch (_context12.prev = _context12.next) {
1902
1789
  case 0:
1903
- messages = _ref12.messages, _onStepFinish7 = _ref12.onStepFinish, _onFinish3 = _ref12.onFinish, _ref12$maxSteps = _ref12.maxSteps, maxSteps = _ref12$maxSteps === void 0 ? 5 : _ref12$maxSteps, enabledTools = _ref12.enabledTools, convertedTools = _ref12.convertedTools, structuredOutput = _ref12.structuredOutput, runId = _ref12.runId;
1790
+ messages = _ref11.messages, _onStepFinish7 = _ref11.onStepFinish, _onFinish3 = _ref11.onFinish, _ref11$maxSteps = _ref11.maxSteps, maxSteps = _ref11$maxSteps === void 0 ? 5 : _ref11$maxSteps, enabledTools = _ref11.enabledTools, convertedTools = _ref11.convertedTools, structuredOutput = _ref11.structuredOutput, runId = _ref11.runId;
1904
1791
  model = _classPrivateFieldLooseBase(this, _model)[_model];
1905
1792
  _classPrivateFieldLooseBase(this, _log$2)[_log$2](LogLevel.DEBUG, "Streaming text with " + messages.length + " messages", runId);
1906
1793
  if ('name' in model) {
@@ -1915,56 +1802,56 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1915
1802
  } else {
1916
1803
  modelToPass = model;
1917
1804
  }
1918
- _context13.next = 6;
1805
+ _context12.next = 6;
1919
1806
  return this.getParams({
1920
1807
  tools: convertedTools || this.convertTools(enabledTools),
1921
1808
  model: modelToPass
1922
1809
  });
1923
1810
  case 6:
1924
- params = _context13.sent;
1811
+ params = _context12.sent;
1925
1812
  argsForExecute = {
1926
1813
  model: params.modelDef,
1927
1814
  tools: _extends({}, params.toolsConverted, params.answerTool),
1928
1815
  toolChoice: params.toolChoice,
1929
1816
  maxSteps: maxSteps,
1930
1817
  onStepFinish: function () {
1931
- var _onStepFinish8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(props) {
1818
+ var _onStepFinish8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(props) {
1932
1819
  var _props$response7, _props$response8;
1933
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1934
- while (1) switch (_context11.prev = _context11.next) {
1820
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1821
+ while (1) switch (_context10.prev = _context10.next) {
1935
1822
  case 0:
1936
1823
  _onStepFinish7 == null || _onStepFinish7(JSON.stringify(props, null, 2));
1937
1824
  if (!(props != null && (_props$response7 = props.response) != null && (_props$response7 = _props$response7.headers) != null && _props$response7['x-ratelimit-remaining-tokens'] && parseInt(props == null || (_props$response8 = props.response) == null || (_props$response8 = _props$response8.headers) == null ? void 0 : _props$response8['x-ratelimit-remaining-tokens'], 10) < 2000)) {
1938
- _context11.next = 5;
1825
+ _context10.next = 5;
1939
1826
  break;
1940
1827
  }
1941
1828
  _classPrivateFieldLooseBase(_this6, _logger$2)[_logger$2].warn('Rate limit approaching, waiting 10 seconds', runId);
1942
- _context11.next = 5;
1829
+ _context10.next = 5;
1943
1830
  return delay(10 * 1000);
1944
1831
  case 5:
1945
1832
  case "end":
1946
- return _context11.stop();
1833
+ return _context10.stop();
1947
1834
  }
1948
- }, _callee11);
1835
+ }, _callee10);
1949
1836
  }));
1950
- function onStepFinish(_x13) {
1837
+ function onStepFinish(_x12) {
1951
1838
  return _onStepFinish8.apply(this, arguments);
1952
1839
  }
1953
1840
  return onStepFinish;
1954
1841
  }(),
1955
1842
  onFinish: function () {
1956
- var _onFinish4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(props) {
1957
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1958
- while (1) switch (_context12.prev = _context12.next) {
1843
+ var _onFinish4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(props) {
1844
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1845
+ while (1) switch (_context11.prev = _context11.next) {
1959
1846
  case 0:
1960
1847
  _onFinish3 == null || _onFinish3(JSON.stringify(props, null, 2));
1961
1848
  case 1:
1962
1849
  case "end":
1963
- return _context12.stop();
1850
+ return _context11.stop();
1964
1851
  }
1965
- }, _callee12);
1852
+ }, _callee11);
1966
1853
  }));
1967
- function onFinish(_x14) {
1854
+ function onFinish(_x13) {
1968
1855
  return _onFinish4.apply(this, arguments);
1969
1856
  }
1970
1857
  return onFinish;
@@ -1980,7 +1867,7 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1980
1867
  } else {
1981
1868
  schema = this.createOutputSchema(structuredOutput);
1982
1869
  }
1983
- _context13.next = 12;
1870
+ _context12.next = 12;
1984
1871
  return ai.streamObject(_extends({
1985
1872
  messages: messages
1986
1873
  }, argsForExecute, {
@@ -1989,14 +1876,14 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
1989
1876
  experimental_telemetry: this.experimental_telemetry
1990
1877
  }));
1991
1878
  case 12:
1992
- return _context13.abrupt("return", _context13.sent);
1879
+ return _context12.abrupt("return", _context12.sent);
1993
1880
  case 13:
1994
1881
  case "end":
1995
- return _context13.stop();
1882
+ return _context12.stop();
1996
1883
  }
1997
- }, _callee13, this);
1884
+ }, _callee12, this);
1998
1885
  }));
1999
- function __streamObject(_x12) {
1886
+ function __streamObject(_x11) {
2000
1887
  return _streamObject.apply(this, arguments);
2001
1888
  }
2002
1889
  return __streamObject;
@@ -3957,6 +3844,18 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
3957
3844
  }
3958
3845
  return agent;
3959
3846
  };
3847
+ _proto.getAgents = function getAgents() {
3848
+ return Array.from(this.agents.entries()).map(function (_ref3) {
3849
+ var name = _ref3[0],
3850
+ agent = _ref3[1];
3851
+ return {
3852
+ name: name,
3853
+ instructions: agent.instructions,
3854
+ modelProvider: agent.model.provider,
3855
+ modelName: agent.model.name
3856
+ };
3857
+ });
3858
+ };
3960
3859
  _proto.getWorkflow = function getWorkflow(name) {
3961
3860
  var workflow = _classPrivateFieldLooseBase(this, _workflows)[_workflows].get(name);
3962
3861
  if (!workflow) {
@@ -3980,7 +3879,7 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
3980
3879
  throw new Error("Tool with name " + String(name) + " not found");
3981
3880
  }
3982
3881
  var hydratedExecutor = /*#__PURE__*/function () {
3983
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, runId) {
3882
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, runId) {
3984
3883
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3985
3884
  while (1) switch (_context2.prev = _context2.next) {
3986
3885
  case 0:
@@ -4006,7 +3905,7 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
4006
3905
  }, _callee2);
4007
3906
  }));
4008
3907
  return function hydratedExecutor(_x4, _x5) {
4009
- return _ref3.apply(this, arguments);
3908
+ return _ref4.apply(this, arguments);
4010
3909
  };
4011
3910
  }();
4012
3911
  return _extends({}, tool, {
@@ -4019,9 +3918,9 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
4019
3918
  });
4020
3919
  };
4021
3920
  _proto.availableIntegrations = function availableIntegrations() {
4022
- return Array.from(this.integrations.entries()).map(function (_ref4) {
4023
- var name = _ref4[0],
4024
- integration = _ref4[1];
3921
+ return Array.from(this.integrations.entries()).map(function (_ref5) {
3922
+ var name = _ref5[0],
3923
+ integration = _ref5[1];
4025
3924
  return {
4026
3925
  name: name,
4027
3926
  integration: integration
@@ -4031,8 +3930,8 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
4031
3930
  _proto.getTools = function getTools() {
4032
3931
  return this.tools;
4033
3932
  };
4034
- _proto.setLogger = function setLogger(_ref5) {
4035
- var logger = _ref5.logger;
3933
+ _proto.setLogger = function setLogger(_ref6) {
3934
+ var logger = _ref6.logger;
4036
3935
  this.logger = logger;
4037
3936
  };
4038
3937
  _proto.getLogger = function getLogger() {
@@ -5482,6 +5381,120 @@ var MastraMemory = /*#__PURE__*/function () {
5482
5381
  return MastraMemory;
5483
5382
  }();
5484
5383
 
5384
+ function embed(_x) {
5385
+ return _embed.apply(this, arguments);
5386
+ }
5387
+ function _embed() {
5388
+ _embed = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
5389
+ var model, value, maxRetries, embeddingModel, openai$1, cohere$1, amazon, google$1, mistral$1, voyage;
5390
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5391
+ while (1) switch (_context.prev = _context.next) {
5392
+ case 0:
5393
+ model = _ref.model, value = _ref.value, maxRetries = _ref.maxRetries;
5394
+ if (!(model.provider === 'OPEN_AI')) {
5395
+ _context.next = 6;
5396
+ break;
5397
+ }
5398
+ openai$1 = openai.createOpenAI({
5399
+ apiKey: model.apiKey || process.env.OPENAI_API_KEY
5400
+ });
5401
+ embeddingModel = openai$1.embedding(model.name);
5402
+ _context.next = 32;
5403
+ break;
5404
+ case 6:
5405
+ if (!(model.provider === 'COHERE')) {
5406
+ _context.next = 11;
5407
+ break;
5408
+ }
5409
+ cohere$1 = cohere.createCohere({
5410
+ apiKey: model.apiKey || process.env.COHERE_API_KEY
5411
+ });
5412
+ embeddingModel = cohere$1.embedding(model.name);
5413
+ _context.next = 32;
5414
+ break;
5415
+ case 11:
5416
+ if (!(model.provider === 'AMAZON')) {
5417
+ _context.next = 16;
5418
+ break;
5419
+ }
5420
+ amazon = amazonBedrock.createAmazonBedrock({
5421
+ region: process.env.AWS_REGION || '',
5422
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID || '',
5423
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '',
5424
+ sessionToken: process.env.AWS_SESSION_TOKEN || ''
5425
+ });
5426
+ embeddingModel = amazon.embedding(model.name);
5427
+ _context.next = 32;
5428
+ break;
5429
+ case 16:
5430
+ if (!(model.provider === 'GOOGLE')) {
5431
+ _context.next = 21;
5432
+ break;
5433
+ }
5434
+ google$1 = google.createGoogleGenerativeAI({
5435
+ baseURL: 'https://generativelanguage.googleapis.com/v1beta',
5436
+ apiKey: model.apiKey || process.env.GOOGLE_GENERATIVE_AI_API_KEY || ''
5437
+ });
5438
+ embeddingModel = google$1.textEmbeddingModel(model.name);
5439
+ _context.next = 32;
5440
+ break;
5441
+ case 21:
5442
+ if (!(model.provider === 'MISTRAL')) {
5443
+ _context.next = 26;
5444
+ break;
5445
+ }
5446
+ mistral$1 = mistral.createMistral({
5447
+ baseURL: 'https://api.mistral.ai/v1',
5448
+ apiKey: model.apiKey || process.env.MISTRAL_API_KEY || ''
5449
+ });
5450
+ embeddingModel = mistral$1.textEmbeddingModel(model.name);
5451
+ _context.next = 32;
5452
+ break;
5453
+ case 26:
5454
+ if (!(model.provider === 'VOYAGE')) {
5455
+ _context.next = 31;
5456
+ break;
5457
+ }
5458
+ voyage = voyageAiProvider.createVoyage({
5459
+ baseURL: 'https://api.voyageai.com/v1',
5460
+ apiKey: model.apiKey || process.env.VOYAGE_API_KEY || ''
5461
+ });
5462
+ embeddingModel = voyage.textEmbeddingModel(model.name);
5463
+ _context.next = 32;
5464
+ break;
5465
+ case 31:
5466
+ throw new Error("Invalid embedding model");
5467
+ case 32:
5468
+ if (!(value instanceof Array)) {
5469
+ _context.next = 36;
5470
+ break;
5471
+ }
5472
+ _context.next = 35;
5473
+ return ai.embedMany({
5474
+ model: embeddingModel,
5475
+ values: value,
5476
+ maxRetries: maxRetries
5477
+ });
5478
+ case 35:
5479
+ return _context.abrupt("return", _context.sent);
5480
+ case 36:
5481
+ _context.next = 38;
5482
+ return ai.embed({
5483
+ model: embeddingModel,
5484
+ value: value,
5485
+ maxRetries: maxRetries
5486
+ });
5487
+ case 38:
5488
+ return _context.abrupt("return", _context.sent);
5489
+ case 39:
5490
+ case "end":
5491
+ return _context.stop();
5492
+ }
5493
+ }, _callee);
5494
+ }));
5495
+ return _embed.apply(this, arguments);
5496
+ }
5497
+
5485
5498
  exports.BaseLogger = BaseLogger;
5486
5499
  exports.ConsoleLogger = ConsoleLogger;
5487
5500
  exports.FileLogger = FileLogger;
@@ -5502,6 +5515,7 @@ exports.createLogger = createLogger;
5502
5515
  exports.createMultiLogger = createMultiLogger;
5503
5516
  exports.createSync = createSync;
5504
5517
  exports.createTool = createTool;
5518
+ exports.embed = embed;
5505
5519
  exports.hasActiveTelemetry = hasActiveTelemetry;
5506
5520
  exports.withSpan = withSpan;
5507
5521
  //# sourceMappingURL=core.cjs.development.js.map