@mastra/core 0.1.7 → 0.1.9
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/agents/index.d.ts.map +1 -1
- package/dist/agents/vector-sync.d.ts +6 -0
- package/dist/agents/vector-sync.d.ts.map +1 -1
- package/dist/core.cjs.development.js +1004 -454
- 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 +1004 -454
- package/dist/core.esm.js.map +1 -1
- package/dist/data-access/index.d.ts +37 -37
- package/dist/data-access/index.d.ts.map +1 -1
- package/dist/framework.d.ts +11 -0
- package/dist/framework.d.ts.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-access/index.d.ts +12 -1
- package/dist/vector-access/index.d.ts.map +1 -1
- package/dist/vector-access/types.d.ts +7 -0
- package/dist/vector-access/types.d.ts.map +1 -0
- package/package.json +5 -4
|
@@ -1666,47 +1666,53 @@ var DataLayer = /*#__PURE__*/function () {
|
|
|
1666
1666
|
});
|
|
1667
1667
|
case 3:
|
|
1668
1668
|
dataInt = _context24.sent;
|
|
1669
|
-
|
|
1669
|
+
if (dataInt) {
|
|
1670
|
+
_context24.next = 6;
|
|
1671
|
+
break;
|
|
1672
|
+
}
|
|
1673
|
+
throw new Error("No connection found for " + name);
|
|
1674
|
+
case 6:
|
|
1675
|
+
_context24.next = 8;
|
|
1670
1676
|
return this.getEntityByConnectionAndType({
|
|
1671
1677
|
k_id: dataInt == null ? void 0 : dataInt.id,
|
|
1672
1678
|
type: type
|
|
1673
1679
|
});
|
|
1674
|
-
case
|
|
1680
|
+
case 8:
|
|
1675
1681
|
existingEntity = _context24.sent;
|
|
1676
1682
|
if (existingEntity) {
|
|
1677
|
-
_context24.next =
|
|
1683
|
+
_context24.next = 15;
|
|
1678
1684
|
break;
|
|
1679
1685
|
}
|
|
1680
|
-
_context24.next =
|
|
1686
|
+
_context24.next = 12;
|
|
1681
1687
|
return this.createEntity({
|
|
1682
1688
|
k_id: dataInt == null ? void 0 : dataInt.id,
|
|
1683
1689
|
type: type,
|
|
1684
1690
|
connectionId: connectionId
|
|
1685
1691
|
});
|
|
1686
|
-
case
|
|
1692
|
+
case 12:
|
|
1687
1693
|
existingEntity = _context24.sent;
|
|
1688
|
-
_context24.next =
|
|
1694
|
+
_context24.next = 15;
|
|
1689
1695
|
return this.addPropertiesToEntity({
|
|
1690
1696
|
entityId: (_existingEntity = existingEntity) == null ? void 0 : _existingEntity.id,
|
|
1691
1697
|
properties: properties
|
|
1692
1698
|
});
|
|
1693
|
-
case
|
|
1694
|
-
_context24.next =
|
|
1699
|
+
case 15:
|
|
1700
|
+
_context24.next = 17;
|
|
1695
1701
|
return this.mergeExternalRecordsForEntity({
|
|
1696
1702
|
entityId: (_existingEntity2 = existingEntity) == null ? void 0 : _existingEntity2.id,
|
|
1697
1703
|
records: data
|
|
1698
1704
|
});
|
|
1699
|
-
case
|
|
1705
|
+
case 17:
|
|
1700
1706
|
if (!lastSyncId) {
|
|
1701
|
-
_context24.next =
|
|
1707
|
+
_context24.next = 20;
|
|
1702
1708
|
break;
|
|
1703
1709
|
}
|
|
1704
|
-
_context24.next =
|
|
1710
|
+
_context24.next = 20;
|
|
1705
1711
|
return this.updateEntityLastSyncId({
|
|
1706
1712
|
entityId: (_existingEntity3 = existingEntity) == null ? void 0 : _existingEntity3.id,
|
|
1707
1713
|
syncId: lastSyncId
|
|
1708
1714
|
});
|
|
1709
|
-
case
|
|
1715
|
+
case 20:
|
|
1710
1716
|
case "end":
|
|
1711
1717
|
return _context24.stop();
|
|
1712
1718
|
}
|
|
@@ -2188,6 +2194,7 @@ exports.IntegrationCredentialType = void 0;
|
|
|
2188
2194
|
(function (IntegrationCredentialType) {
|
|
2189
2195
|
IntegrationCredentialType["OAUTH"] = "OAUTH";
|
|
2190
2196
|
IntegrationCredentialType["API_KEY"] = "API_KEY";
|
|
2197
|
+
IntegrationCredentialType["SYSTEM"] = "SYSTEM";
|
|
2191
2198
|
})(exports.IntegrationCredentialType || (exports.IntegrationCredentialType = {}));
|
|
2192
2199
|
var IntegrationFieldTypeEnum = {
|
|
2193
2200
|
SINGLE_LINE_TEXT: 'SINGLE_LINE_TEXT',
|
|
@@ -4288,21 +4295,182 @@ var VectorLayer = /*#__PURE__*/function () {
|
|
|
4288
4295
|
var _proto = VectorLayer.prototype;
|
|
4289
4296
|
_proto.getPineconeIndexes = /*#__PURE__*/function () {
|
|
4290
4297
|
var _getPineconeIndexes = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4298
|
+
var inn;
|
|
4291
4299
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4292
4300
|
while (1) switch (_context.prev = _context.next) {
|
|
4293
4301
|
case 0:
|
|
4294
|
-
|
|
4295
|
-
|
|
4302
|
+
_context.prev = 0;
|
|
4303
|
+
_context.next = 3;
|
|
4304
|
+
return this.Pinecone.listIndexes();
|
|
4305
|
+
case 3:
|
|
4306
|
+
inn = _context.sent;
|
|
4307
|
+
console.log('inn====', {
|
|
4308
|
+
inn: inn
|
|
4309
|
+
});
|
|
4310
|
+
return _context.abrupt("return", inn);
|
|
4311
|
+
case 8:
|
|
4312
|
+
_context.prev = 8;
|
|
4313
|
+
_context.t0 = _context["catch"](0);
|
|
4314
|
+
console.log('error getting indexesss====', _context.t0);
|
|
4315
|
+
case 11:
|
|
4296
4316
|
case "end":
|
|
4297
4317
|
return _context.stop();
|
|
4298
4318
|
}
|
|
4299
|
-
}, _callee, this);
|
|
4319
|
+
}, _callee, this, [[0, 8]]);
|
|
4300
4320
|
}));
|
|
4301
4321
|
function getPineconeIndexes() {
|
|
4302
4322
|
return _getPineconeIndexes.apply(this, arguments);
|
|
4303
4323
|
}
|
|
4304
4324
|
return getPineconeIndexes;
|
|
4305
4325
|
}();
|
|
4326
|
+
_proto.createPineconeIndex = /*#__PURE__*/function () {
|
|
4327
|
+
var _createPineconeIndex = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
4328
|
+
var name;
|
|
4329
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4330
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4331
|
+
case 0:
|
|
4332
|
+
name = _ref.name;
|
|
4333
|
+
return _context2.abrupt("return", this.Pinecone.createIndex({
|
|
4334
|
+
suppressConflicts: true,
|
|
4335
|
+
name: name,
|
|
4336
|
+
dimension: 1536,
|
|
4337
|
+
metric: 'cosine',
|
|
4338
|
+
spec: {
|
|
4339
|
+
serverless: {
|
|
4340
|
+
cloud: 'aws',
|
|
4341
|
+
region: 'us-east-1'
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
}));
|
|
4345
|
+
case 2:
|
|
4346
|
+
case "end":
|
|
4347
|
+
return _context2.stop();
|
|
4348
|
+
}
|
|
4349
|
+
}, _callee2, this);
|
|
4350
|
+
}));
|
|
4351
|
+
function createPineconeIndex(_x) {
|
|
4352
|
+
return _createPineconeIndex.apply(this, arguments);
|
|
4353
|
+
}
|
|
4354
|
+
return createPineconeIndex;
|
|
4355
|
+
}();
|
|
4356
|
+
_proto.getPineconeIndex = /*#__PURE__*/function () {
|
|
4357
|
+
var _getPineconeIndex = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
4358
|
+
var name;
|
|
4359
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4360
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4361
|
+
case 0:
|
|
4362
|
+
name = _ref2.name;
|
|
4363
|
+
return _context3.abrupt("return", this.Pinecone.index(name));
|
|
4364
|
+
case 2:
|
|
4365
|
+
case "end":
|
|
4366
|
+
return _context3.stop();
|
|
4367
|
+
}
|
|
4368
|
+
}, _callee3, this);
|
|
4369
|
+
}));
|
|
4370
|
+
function getPineconeIndex(_x2) {
|
|
4371
|
+
return _getPineconeIndex.apply(this, arguments);
|
|
4372
|
+
}
|
|
4373
|
+
return getPineconeIndex;
|
|
4374
|
+
}();
|
|
4375
|
+
_proto.generateVectorEmbedding = /*#__PURE__*/function () {
|
|
4376
|
+
var _generateVectorEmbedding = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
|
|
4377
|
+
var _yield$embed, embedding;
|
|
4378
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4379
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4380
|
+
case 0:
|
|
4381
|
+
_context4.next = 2;
|
|
4382
|
+
return ai.embed({
|
|
4383
|
+
model: openai.openai.embedding('text-embedding-3-small'),
|
|
4384
|
+
value: JSON.stringify(data)
|
|
4385
|
+
});
|
|
4386
|
+
case 2:
|
|
4387
|
+
_yield$embed = _context4.sent;
|
|
4388
|
+
embedding = _yield$embed.embedding;
|
|
4389
|
+
return _context4.abrupt("return", embedding);
|
|
4390
|
+
case 5:
|
|
4391
|
+
case "end":
|
|
4392
|
+
return _context4.stop();
|
|
4393
|
+
}
|
|
4394
|
+
}, _callee4);
|
|
4395
|
+
}));
|
|
4396
|
+
function generateVectorEmbedding(_x3) {
|
|
4397
|
+
return _generateVectorEmbedding.apply(this, arguments);
|
|
4398
|
+
}
|
|
4399
|
+
return generateVectorEmbedding;
|
|
4400
|
+
}();
|
|
4401
|
+
_proto.getPineconeIndexWithMetadata = /*#__PURE__*/function () {
|
|
4402
|
+
var _getPineconeIndexWithMetadata = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
4403
|
+
var name, newIndex, indexQuery, namespaces, data, _iterator, _step, _namespaceData$record, namespace, namespaceData, metadata;
|
|
4404
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4405
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
4406
|
+
case 0:
|
|
4407
|
+
name = _ref3.name;
|
|
4408
|
+
_context5.prev = 1;
|
|
4409
|
+
if (name) {
|
|
4410
|
+
_context5.next = 5;
|
|
4411
|
+
break;
|
|
4412
|
+
}
|
|
4413
|
+
console.log('Index name not passed');
|
|
4414
|
+
return _context5.abrupt("return", []);
|
|
4415
|
+
case 5:
|
|
4416
|
+
_context5.next = 7;
|
|
4417
|
+
return this.getPineconeIndex({
|
|
4418
|
+
name: name
|
|
4419
|
+
});
|
|
4420
|
+
case 7:
|
|
4421
|
+
newIndex = _context5.sent;
|
|
4422
|
+
_context5.next = 10;
|
|
4423
|
+
return newIndex == null ? void 0 : newIndex.describeIndexStats();
|
|
4424
|
+
case 10:
|
|
4425
|
+
indexQuery = _context5.sent;
|
|
4426
|
+
if (!indexQuery) {
|
|
4427
|
+
_context5.next = 27;
|
|
4428
|
+
break;
|
|
4429
|
+
}
|
|
4430
|
+
namespaces = Object.keys((indexQuery == null ? void 0 : indexQuery.namespaces) || {});
|
|
4431
|
+
data = [];
|
|
4432
|
+
if (!namespaces.length) {
|
|
4433
|
+
_context5.next = 26;
|
|
4434
|
+
break;
|
|
4435
|
+
}
|
|
4436
|
+
_iterator = _createForOfIteratorHelperLoose(namespaces);
|
|
4437
|
+
case 16:
|
|
4438
|
+
if ((_step = _iterator()).done) {
|
|
4439
|
+
_context5.next = 26;
|
|
4440
|
+
break;
|
|
4441
|
+
}
|
|
4442
|
+
namespace = _step.value;
|
|
4443
|
+
_context5.next = 20;
|
|
4444
|
+
return newIndex == null ? void 0 : newIndex.namespace(namespace).fetch([name]);
|
|
4445
|
+
case 20:
|
|
4446
|
+
namespaceData = _context5.sent;
|
|
4447
|
+
metadata = namespaceData == null || (_namespaceData$record = namespaceData.records) == null || (_namespaceData$record = _namespaceData$record[name]) == null ? void 0 : _namespaceData$record.metadata;
|
|
4448
|
+
console.log("metadata for " + namespace + "===", JSON.stringify(metadata, null, 2));
|
|
4449
|
+
if (metadata) {
|
|
4450
|
+
data.push(metadata);
|
|
4451
|
+
}
|
|
4452
|
+
case 24:
|
|
4453
|
+
_context5.next = 16;
|
|
4454
|
+
break;
|
|
4455
|
+
case 26:
|
|
4456
|
+
return _context5.abrupt("return", data);
|
|
4457
|
+
case 27:
|
|
4458
|
+
return _context5.abrupt("return", []);
|
|
4459
|
+
case 30:
|
|
4460
|
+
_context5.prev = 30;
|
|
4461
|
+
_context5.t0 = _context5["catch"](1);
|
|
4462
|
+
console.log("Error getting " + name + " index", _context5.t0);
|
|
4463
|
+
case 33:
|
|
4464
|
+
case "end":
|
|
4465
|
+
return _context5.stop();
|
|
4466
|
+
}
|
|
4467
|
+
}, _callee5, this, [[1, 30]]);
|
|
4468
|
+
}));
|
|
4469
|
+
function getPineconeIndexWithMetadata(_x4) {
|
|
4470
|
+
return _getPineconeIndexWithMetadata.apply(this, arguments);
|
|
4471
|
+
}
|
|
4472
|
+
return getPineconeIndexWithMetadata;
|
|
4473
|
+
}();
|
|
4306
4474
|
return _createClass(VectorLayer, [{
|
|
4307
4475
|
key: "Pinecone",
|
|
4308
4476
|
get: function get() {
|
|
@@ -4328,189 +4496,186 @@ var delay$1 = function delay(ms) {
|
|
|
4328
4496
|
return setTimeout(resolve, ms);
|
|
4329
4497
|
});
|
|
4330
4498
|
};
|
|
4331
|
-
function
|
|
4332
|
-
return
|
|
4499
|
+
function executeIndexSync(_x) {
|
|
4500
|
+
return _executeIndexSync.apply(this, arguments);
|
|
4333
4501
|
}
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
var
|
|
4502
|
+
//Generic vector sync from event data
|
|
4503
|
+
function _executeIndexSync() {
|
|
4504
|
+
_executeIndexSync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
4505
|
+
var _event$user, _event$data;
|
|
4506
|
+
var event, mastra, connectionId, providedIndexes, systemName, _iterator, _step, _step$value, provider, indexes, vp, _iterator2, _step2, index, indexMetadata, _loop, _ret, _iterator3, _step3;
|
|
4338
4507
|
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
4339
4508
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4340
4509
|
case 0:
|
|
4341
4510
|
event = _ref.event, mastra = _ref.mastra;
|
|
4342
4511
|
connectionId = event == null || (_event$user = event.user) == null ? void 0 : _event$user.connectionId;
|
|
4343
|
-
|
|
4344
|
-
entities = event == null || (_event$data2 = event.data) == null ? void 0 : _event$data2.entities;
|
|
4512
|
+
providedIndexes = event == null || (_event$data = event.data) == null ? void 0 : _event$data.data;
|
|
4345
4513
|
systemName = mastra.config.name;
|
|
4346
|
-
|
|
4347
|
-
|
|
4514
|
+
_iterator = _createForOfIteratorHelperLoose(providedIndexes);
|
|
4515
|
+
case 5:
|
|
4516
|
+
if ((_step = _iterator()).done) {
|
|
4517
|
+
_context4.next = 36;
|
|
4348
4518
|
break;
|
|
4349
4519
|
}
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
case 8:
|
|
4353
|
-
vp = getVectorProvider(vector_provider);
|
|
4520
|
+
_step$value = _step.value, provider = _step$value.provider, indexes = _step$value.indexes;
|
|
4521
|
+
vp = getVectorProvider(provider);
|
|
4354
4522
|
if (vp) {
|
|
4355
|
-
_context4.next =
|
|
4523
|
+
_context4.next = 11;
|
|
4356
4524
|
break;
|
|
4357
4525
|
}
|
|
4358
|
-
console.error('UNSUPPORTED VECTOR PROVIDER',
|
|
4526
|
+
console.error('UNSUPPORTED VECTOR PROVIDER', provider);
|
|
4359
4527
|
return _context4.abrupt("return");
|
|
4360
|
-
case
|
|
4528
|
+
case 11:
|
|
4361
4529
|
if (process.env.OPENAI_API_KEY) {
|
|
4362
|
-
_context4.next =
|
|
4530
|
+
_context4.next = 14;
|
|
4363
4531
|
break;
|
|
4364
4532
|
}
|
|
4365
4533
|
console.error('NO OPENAI_API_KEY');
|
|
4366
4534
|
return _context4.abrupt("return");
|
|
4535
|
+
case 14:
|
|
4536
|
+
_iterator2 = _createForOfIteratorHelperLoose(indexes);
|
|
4367
4537
|
case 15:
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
if ((_step = _iterator()).done) {
|
|
4371
|
-
_context4.next = 50;
|
|
4372
|
-
break;
|
|
4373
|
-
}
|
|
4374
|
-
vectorE = _step.value;
|
|
4375
|
-
integrationName = vectorE.integration;
|
|
4376
|
-
_context4.next = 21;
|
|
4377
|
-
return (_mastra$dataLayer = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer.getConnection({
|
|
4378
|
-
connectionId: connectionId,
|
|
4379
|
-
name: integrationName
|
|
4380
|
-
});
|
|
4381
|
-
case 21:
|
|
4382
|
-
_context4.t1 = _yield$mastra$dataLay = _context4.sent;
|
|
4383
|
-
if (!(_context4.t1 == null)) {
|
|
4384
|
-
_context4.next = 26;
|
|
4385
|
-
break;
|
|
4386
|
-
}
|
|
4387
|
-
_context4.t2 = void 0;
|
|
4388
|
-
_context4.next = 27;
|
|
4389
|
-
break;
|
|
4390
|
-
case 26:
|
|
4391
|
-
_context4.t2 = _yield$mastra$dataLay.id;
|
|
4392
|
-
case 27:
|
|
4393
|
-
_context4.t0 = _context4.t2;
|
|
4394
|
-
if (_context4.t0) {
|
|
4395
|
-
_context4.next = 30;
|
|
4396
|
-
break;
|
|
4397
|
-
}
|
|
4398
|
-
_context4.t0 = '';
|
|
4399
|
-
case 30:
|
|
4400
|
-
k_id = _context4.t0;
|
|
4401
|
-
if (!(!k_id && integrationName === systemName)) {
|
|
4402
|
-
_context4.next = 36;
|
|
4538
|
+
if ((_step2 = _iterator2()).done) {
|
|
4539
|
+
_context4.next = 34;
|
|
4403
4540
|
break;
|
|
4404
4541
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
name: integrationName
|
|
4410
|
-
},
|
|
4411
|
-
credential: {
|
|
4412
|
-
type: 'API_KEY',
|
|
4413
|
-
value: connectionId,
|
|
4414
|
-
scope: []
|
|
4415
|
-
}
|
|
4542
|
+
index = _step2.value;
|
|
4543
|
+
_context4.next = 19;
|
|
4544
|
+
return mastra.vectorLayer.getPineconeIndexWithMetadata({
|
|
4545
|
+
name: index
|
|
4416
4546
|
});
|
|
4417
|
-
case
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
if (k_id) {
|
|
4422
|
-
_context4.next = 39;
|
|
4547
|
+
case 19:
|
|
4548
|
+
indexMetadata = _context4.sent;
|
|
4549
|
+
if (indexMetadata != null && indexMetadata.length) {
|
|
4550
|
+
_context4.next = 23;
|
|
4423
4551
|
break;
|
|
4424
4552
|
}
|
|
4425
|
-
console.error('
|
|
4553
|
+
console.error('No index metadata found for', index);
|
|
4426
4554
|
return _context4.abrupt("return");
|
|
4427
|
-
case
|
|
4555
|
+
case 23:
|
|
4428
4556
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
4429
|
-
var _mastra$dataLayer3, _entityRecords, _records;
|
|
4430
|
-
var entity, entityRecords, records, _mastra$dataLayer4, _entityRecords2, _records2, _yield$mastra$trigger, _event, res, recordsMapped, entityTypeIndex, _recordsMapped$map, vectors;
|
|
4557
|
+
var _yield$mastra$dataLay, _mastra$dataLayer, _mastra$dataLayer3, _entityRecords, _records;
|
|
4558
|
+
var entity, fields, integration, name, syncEvent, k_id, _mastra$dataLayer2, connection, entityRecords, records, _mastra$dataLayer4, _entityRecords2, _records2, _yield$mastra$trigger, _event, res, recordsMapped, entityTypeIndex, _recordsMapped$map, vectors;
|
|
4431
4559
|
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
|
4432
4560
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4433
4561
|
case 0:
|
|
4434
|
-
entity =
|
|
4435
|
-
|
|
4562
|
+
entity = _step3.value;
|
|
4563
|
+
fields = entity.fields, integration = entity.integration, name = entity.name, syncEvent = entity.syncEvent;
|
|
4564
|
+
_context3.next = 4;
|
|
4565
|
+
return (_mastra$dataLayer = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer.getConnection({
|
|
4566
|
+
connectionId: connectionId,
|
|
4567
|
+
name: integration
|
|
4568
|
+
});
|
|
4569
|
+
case 4:
|
|
4570
|
+
_context3.t1 = _yield$mastra$dataLay = _context3.sent;
|
|
4571
|
+
if (!(_context3.t1 == null)) {
|
|
4572
|
+
_context3.next = 9;
|
|
4573
|
+
break;
|
|
4574
|
+
}
|
|
4575
|
+
_context3.t2 = void 0;
|
|
4576
|
+
_context3.next = 10;
|
|
4577
|
+
break;
|
|
4578
|
+
case 9:
|
|
4579
|
+
_context3.t2 = _yield$mastra$dataLay.id;
|
|
4580
|
+
case 10:
|
|
4581
|
+
_context3.t0 = _context3.t2;
|
|
4582
|
+
if (_context3.t0) {
|
|
4583
|
+
_context3.next = 13;
|
|
4584
|
+
break;
|
|
4585
|
+
}
|
|
4586
|
+
_context3.t0 = '';
|
|
4587
|
+
case 13:
|
|
4588
|
+
k_id = _context3.t0;
|
|
4589
|
+
if (!(!k_id && integration === systemName)) {
|
|
4590
|
+
_context3.next = 19;
|
|
4591
|
+
break;
|
|
4592
|
+
}
|
|
4593
|
+
_context3.next = 17;
|
|
4594
|
+
return (_mastra$dataLayer2 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer2.createConnection({
|
|
4595
|
+
connection: {
|
|
4596
|
+
connectionId: connectionId,
|
|
4597
|
+
name: integration
|
|
4598
|
+
},
|
|
4599
|
+
credential: {
|
|
4600
|
+
type: 'API_KEY',
|
|
4601
|
+
value: connectionId,
|
|
4602
|
+
scope: []
|
|
4603
|
+
}
|
|
4604
|
+
});
|
|
4605
|
+
case 17:
|
|
4606
|
+
connection = _context3.sent;
|
|
4607
|
+
k_id = connection.id;
|
|
4608
|
+
case 19:
|
|
4609
|
+
if (k_id) {
|
|
4610
|
+
_context3.next = 22;
|
|
4611
|
+
break;
|
|
4612
|
+
}
|
|
4613
|
+
console.error('Error bootstrapping shit');
|
|
4614
|
+
return _context3.abrupt("return", {
|
|
4615
|
+
v: void 0
|
|
4616
|
+
});
|
|
4617
|
+
case 22:
|
|
4618
|
+
_context3.next = 24;
|
|
4436
4619
|
return (_mastra$dataLayer3 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer3.getEntityRecordsByConnectionAndType({
|
|
4437
4620
|
k_id: k_id,
|
|
4438
|
-
type:
|
|
4621
|
+
type: name
|
|
4439
4622
|
});
|
|
4440
|
-
case
|
|
4623
|
+
case 24:
|
|
4441
4624
|
entityRecords = _context3.sent;
|
|
4442
4625
|
records = (_entityRecords = entityRecords) == null ? void 0 : _entityRecords.records;
|
|
4443
4626
|
if (!(!records || ((_records = records) == null ? void 0 : _records.length) === 0)) {
|
|
4444
|
-
_context3.next =
|
|
4627
|
+
_context3.next = 44;
|
|
4445
4628
|
break;
|
|
4446
4629
|
}
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
_context3.next = 9;
|
|
4630
|
+
console.error('NO RECORDS ATTEMPTING SYNC');
|
|
4631
|
+
_context3.next = 30;
|
|
4450
4632
|
return mastra.triggerEvent({
|
|
4451
|
-
key:
|
|
4633
|
+
key: syncEvent,
|
|
4452
4634
|
data: {},
|
|
4453
4635
|
user: {
|
|
4454
4636
|
connectionId: connectionId
|
|
4455
4637
|
}
|
|
4456
4638
|
});
|
|
4457
|
-
case
|
|
4639
|
+
case 30:
|
|
4458
4640
|
_yield$mastra$trigger = _context3.sent;
|
|
4459
4641
|
_event = _yield$mastra$trigger.event;
|
|
4460
4642
|
console.log(_event, '####');
|
|
4461
|
-
_context3.next =
|
|
4643
|
+
_context3.next = 35;
|
|
4462
4644
|
return _event.subscribe();
|
|
4463
|
-
case
|
|
4645
|
+
case 35:
|
|
4464
4646
|
res = _context3.sent;
|
|
4465
4647
|
console.log('Subscribe result', res);
|
|
4466
|
-
_context3.next =
|
|
4648
|
+
_context3.next = 39;
|
|
4467
4649
|
return (_mastra$dataLayer4 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer4.getEntityRecordsByConnectionAndType({
|
|
4468
4650
|
k_id: k_id,
|
|
4469
4651
|
type: entity.name
|
|
4470
4652
|
});
|
|
4471
|
-
case
|
|
4653
|
+
case 39:
|
|
4472
4654
|
entityRecords = _context3.sent;
|
|
4473
4655
|
records = (_entityRecords2 = entityRecords) == null ? void 0 : _entityRecords2.records;
|
|
4474
4656
|
if (!(!records || ((_records2 = records) == null ? void 0 : _records2.length) === 0)) {
|
|
4475
|
-
_context3.next =
|
|
4657
|
+
_context3.next = 44;
|
|
4476
4658
|
break;
|
|
4477
4659
|
}
|
|
4478
4660
|
console.error('NO RECORDS AFTER SYNC');
|
|
4479
4661
|
return _context3.abrupt("return", {
|
|
4480
4662
|
v: void 0
|
|
4481
4663
|
});
|
|
4482
|
-
case
|
|
4483
|
-
recordsMapped = records.map(function (
|
|
4484
|
-
var data =
|
|
4485
|
-
externalId =
|
|
4664
|
+
case 44:
|
|
4665
|
+
recordsMapped = records.map(function (_ref8) {
|
|
4666
|
+
var data = _ref8.data,
|
|
4667
|
+
externalId = _ref8.externalId;
|
|
4486
4668
|
return _extends({
|
|
4487
4669
|
id: externalId
|
|
4488
|
-
}, _.pick(data,
|
|
4670
|
+
}, _.pick(data, fields));
|
|
4489
4671
|
});
|
|
4490
4672
|
console.log(recordsMapped, 'RECORDS');
|
|
4491
|
-
|
|
4492
|
-
return vp.createIndex({
|
|
4493
|
-
suppressConflicts: true,
|
|
4494
|
-
name: entity.name,
|
|
4495
|
-
dimension: 1536,
|
|
4496
|
-
metric: 'cosine',
|
|
4497
|
-
spec: {
|
|
4498
|
-
serverless: {
|
|
4499
|
-
cloud: 'aws',
|
|
4500
|
-
region: 'us-east-1'
|
|
4501
|
-
}
|
|
4502
|
-
}
|
|
4503
|
-
});
|
|
4504
|
-
case 27:
|
|
4505
|
-
_context3.next = 29;
|
|
4506
|
-
return delay$1(5000);
|
|
4507
|
-
case 29:
|
|
4508
|
-
entityTypeIndex = vp.index(entity.name);
|
|
4673
|
+
entityTypeIndex = vp.index(index);
|
|
4509
4674
|
console.log(entityTypeIndex, 'INDEX');
|
|
4510
|
-
_context3.prev =
|
|
4511
|
-
_context3.next =
|
|
4675
|
+
_context3.prev = 48;
|
|
4676
|
+
_context3.next = 51;
|
|
4512
4677
|
return Promise.all((_recordsMapped$map = recordsMapped.map(/*#__PURE__*/function () {
|
|
4513
|
-
var
|
|
4678
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(record) {
|
|
4514
4679
|
var _yield$embed, embedding;
|
|
4515
4680
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4516
4681
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -4534,95 +4699,96 @@ function _executeGenericVectorSync() {
|
|
|
4534
4699
|
}
|
|
4535
4700
|
}, _callee2);
|
|
4536
4701
|
}));
|
|
4537
|
-
return function (
|
|
4538
|
-
return
|
|
4702
|
+
return function (_x6) {
|
|
4703
|
+
return _ref9.apply(this, arguments);
|
|
4539
4704
|
};
|
|
4540
4705
|
}())) != null ? _recordsMapped$map : []);
|
|
4541
|
-
case
|
|
4706
|
+
case 51:
|
|
4542
4707
|
vectors = _context3.sent;
|
|
4543
4708
|
console.log('UPSERTING', vectors);
|
|
4544
4709
|
if (!(vectors.length > 0)) {
|
|
4545
|
-
_context3.next =
|
|
4710
|
+
_context3.next = 56;
|
|
4546
4711
|
break;
|
|
4547
4712
|
}
|
|
4548
|
-
_context3.next =
|
|
4549
|
-
return entityTypeIndex.namespace(
|
|
4550
|
-
case
|
|
4551
|
-
_context3.next =
|
|
4713
|
+
_context3.next = 56;
|
|
4714
|
+
return entityTypeIndex.namespace(name).upsert(vectors);
|
|
4715
|
+
case 56:
|
|
4716
|
+
_context3.next = 61;
|
|
4552
4717
|
break;
|
|
4553
|
-
case
|
|
4554
|
-
_context3.prev =
|
|
4555
|
-
_context3.
|
|
4556
|
-
console.error(_context3.
|
|
4557
|
-
case
|
|
4718
|
+
case 58:
|
|
4719
|
+
_context3.prev = 58;
|
|
4720
|
+
_context3.t3 = _context3["catch"](48);
|
|
4721
|
+
console.error(_context3.t3);
|
|
4722
|
+
case 61:
|
|
4558
4723
|
return _context3.abrupt("return", {
|
|
4559
4724
|
v: void 0
|
|
4560
4725
|
});
|
|
4561
|
-
case
|
|
4726
|
+
case 62:
|
|
4562
4727
|
case "end":
|
|
4563
4728
|
return _context3.stop();
|
|
4564
4729
|
}
|
|
4565
|
-
}, _loop, null, [[
|
|
4730
|
+
}, _loop, null, [[48, 58]]);
|
|
4566
4731
|
});
|
|
4567
|
-
|
|
4568
|
-
case
|
|
4569
|
-
if ((
|
|
4570
|
-
_context4.next =
|
|
4732
|
+
_iterator3 = _createForOfIteratorHelperLoose(indexMetadata);
|
|
4733
|
+
case 25:
|
|
4734
|
+
if ((_step3 = _iterator3()).done) {
|
|
4735
|
+
_context4.next = 32;
|
|
4571
4736
|
break;
|
|
4572
4737
|
}
|
|
4573
|
-
return _context4.delegateYield(_loop(), "
|
|
4574
|
-
case
|
|
4575
|
-
_ret = _context4.
|
|
4738
|
+
return _context4.delegateYield(_loop(), "t0", 27);
|
|
4739
|
+
case 27:
|
|
4740
|
+
_ret = _context4.t0;
|
|
4576
4741
|
if (!_ret) {
|
|
4577
|
-
_context4.next =
|
|
4742
|
+
_context4.next = 30;
|
|
4578
4743
|
break;
|
|
4579
4744
|
}
|
|
4580
4745
|
return _context4.abrupt("return", _ret.v);
|
|
4581
|
-
case
|
|
4582
|
-
_context4.next =
|
|
4746
|
+
case 30:
|
|
4747
|
+
_context4.next = 25;
|
|
4583
4748
|
break;
|
|
4584
|
-
case
|
|
4585
|
-
_context4.next =
|
|
4749
|
+
case 32:
|
|
4750
|
+
_context4.next = 15;
|
|
4586
4751
|
break;
|
|
4587
|
-
case
|
|
4752
|
+
case 34:
|
|
4753
|
+
_context4.next = 5;
|
|
4754
|
+
break;
|
|
4755
|
+
case 36:
|
|
4588
4756
|
case "end":
|
|
4589
4757
|
return _context4.stop();
|
|
4590
4758
|
}
|
|
4591
4759
|
}, _callee3);
|
|
4592
4760
|
}));
|
|
4593
|
-
return
|
|
4761
|
+
return _executeIndexSync.apply(this, arguments);
|
|
4594
4762
|
}
|
|
4595
|
-
function
|
|
4596
|
-
return
|
|
4763
|
+
function executeGenericVectorSync(_x2) {
|
|
4764
|
+
return _executeGenericVectorSync.apply(this, arguments);
|
|
4597
4765
|
}
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
var
|
|
4766
|
+
// Vector Sync from agents Dir
|
|
4767
|
+
function _executeGenericVectorSync() {
|
|
4768
|
+
_executeGenericVectorSync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
|
|
4769
|
+
var _event$user2, _event$data2, _event$data3;
|
|
4770
|
+
var event, mastra, connectionId, vector_provider, entities, systemName, vp, _iterator4, _step4, _yield$mastra$dataLay2, _mastra$dataLayer5, vectorE, integrationName, k_id, _mastra$dataLayer6, connection, _loop2, _ret2, _iterator5, _step5;
|
|
4602
4771
|
return _regeneratorRuntime().wrap(function _callee5$(_context7) {
|
|
4603
4772
|
while (1) switch (_context7.prev = _context7.next) {
|
|
4604
4773
|
case 0:
|
|
4605
4774
|
event = _ref2.event, mastra = _ref2.mastra;
|
|
4606
|
-
agentDir = mastra.config.agents.agentDirPath;
|
|
4607
|
-
agent = getAgentBlueprint({
|
|
4608
|
-
agentDir: agentDir,
|
|
4609
|
-
agentId: event.data.agentId
|
|
4610
|
-
});
|
|
4611
4775
|
connectionId = event == null || (_event$user2 = event.user) == null ? void 0 : _event$user2.connectionId;
|
|
4776
|
+
vector_provider = event == null || (_event$data2 = event.data) == null ? void 0 : _event$data2.vector_provider;
|
|
4777
|
+
entities = event == null || (_event$data3 = event.data) == null ? void 0 : _event$data3.entities;
|
|
4612
4778
|
systemName = mastra.config.name;
|
|
4613
|
-
if (
|
|
4779
|
+
if (vector_provider) {
|
|
4614
4780
|
_context7.next = 8;
|
|
4615
4781
|
break;
|
|
4616
4782
|
}
|
|
4617
4783
|
console.error("No vector_provider defined for agent");
|
|
4618
4784
|
return _context7.abrupt("return");
|
|
4619
4785
|
case 8:
|
|
4620
|
-
vp = getVectorProvider(
|
|
4786
|
+
vp = getVectorProvider(vector_provider);
|
|
4621
4787
|
if (vp) {
|
|
4622
4788
|
_context7.next = 12;
|
|
4623
4789
|
break;
|
|
4624
4790
|
}
|
|
4625
|
-
console.error('UNSUPPORTED VECTOR PROVIDER',
|
|
4791
|
+
console.error('UNSUPPORTED VECTOR PROVIDER', vector_provider);
|
|
4626
4792
|
return _context7.abrupt("return");
|
|
4627
4793
|
case 12:
|
|
4628
4794
|
if (process.env.OPENAI_API_KEY) {
|
|
@@ -4632,51 +4798,44 @@ function _executeVectorSync() {
|
|
|
4632
4798
|
console.error('NO OPENAI_API_KEY');
|
|
4633
4799
|
return _context7.abrupt("return");
|
|
4634
4800
|
case 15:
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
console.error('NO AGENT OR KNOWLEDGE SOURCES');
|
|
4640
|
-
return _context7.abrupt("return");
|
|
4641
|
-
case 18:
|
|
4642
|
-
_iterator3 = _createForOfIteratorHelperLoose(agent.knowledge_sources.entities);
|
|
4643
|
-
case 19:
|
|
4644
|
-
if ((_step3 = _iterator3()).done) {
|
|
4645
|
-
_context7.next = 53;
|
|
4801
|
+
_iterator4 = _createForOfIteratorHelperLoose(entities);
|
|
4802
|
+
case 16:
|
|
4803
|
+
if ((_step4 = _iterator4()).done) {
|
|
4804
|
+
_context7.next = 50;
|
|
4646
4805
|
break;
|
|
4647
4806
|
}
|
|
4648
|
-
vectorE =
|
|
4807
|
+
vectorE = _step4.value;
|
|
4649
4808
|
integrationName = vectorE.integration;
|
|
4650
|
-
_context7.next =
|
|
4809
|
+
_context7.next = 21;
|
|
4651
4810
|
return (_mastra$dataLayer5 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer5.getConnection({
|
|
4652
4811
|
connectionId: connectionId,
|
|
4653
4812
|
name: integrationName
|
|
4654
4813
|
});
|
|
4655
|
-
case
|
|
4814
|
+
case 21:
|
|
4656
4815
|
_context7.t1 = _yield$mastra$dataLay2 = _context7.sent;
|
|
4657
4816
|
if (!(_context7.t1 == null)) {
|
|
4658
|
-
_context7.next =
|
|
4817
|
+
_context7.next = 26;
|
|
4659
4818
|
break;
|
|
4660
4819
|
}
|
|
4661
4820
|
_context7.t2 = void 0;
|
|
4662
|
-
_context7.next =
|
|
4821
|
+
_context7.next = 27;
|
|
4663
4822
|
break;
|
|
4664
|
-
case
|
|
4823
|
+
case 26:
|
|
4665
4824
|
_context7.t2 = _yield$mastra$dataLay2.id;
|
|
4666
|
-
case
|
|
4825
|
+
case 27:
|
|
4667
4826
|
_context7.t0 = _context7.t2;
|
|
4668
4827
|
if (_context7.t0) {
|
|
4669
|
-
_context7.next =
|
|
4828
|
+
_context7.next = 30;
|
|
4670
4829
|
break;
|
|
4671
4830
|
}
|
|
4672
4831
|
_context7.t0 = '';
|
|
4673
|
-
case
|
|
4832
|
+
case 30:
|
|
4674
4833
|
k_id = _context7.t0;
|
|
4675
4834
|
if (!(!k_id && integrationName === systemName)) {
|
|
4676
|
-
_context7.next =
|
|
4835
|
+
_context7.next = 36;
|
|
4677
4836
|
break;
|
|
4678
4837
|
}
|
|
4679
|
-
_context7.next =
|
|
4838
|
+
_context7.next = 34;
|
|
4680
4839
|
return (_mastra$dataLayer6 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer6.createConnection({
|
|
4681
4840
|
connection: {
|
|
4682
4841
|
connectionId: connectionId,
|
|
@@ -4688,24 +4847,24 @@ function _executeVectorSync() {
|
|
|
4688
4847
|
scope: []
|
|
4689
4848
|
}
|
|
4690
4849
|
});
|
|
4691
|
-
case
|
|
4850
|
+
case 34:
|
|
4692
4851
|
connection = _context7.sent;
|
|
4693
4852
|
k_id = connection.id;
|
|
4694
|
-
case
|
|
4853
|
+
case 36:
|
|
4695
4854
|
if (k_id) {
|
|
4696
|
-
_context7.next =
|
|
4855
|
+
_context7.next = 39;
|
|
4697
4856
|
break;
|
|
4698
4857
|
}
|
|
4699
4858
|
console.error('Error bootstrapping shit');
|
|
4700
4859
|
return _context7.abrupt("return");
|
|
4701
|
-
case
|
|
4860
|
+
case 39:
|
|
4702
4861
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
4703
4862
|
var _mastra$dataLayer7, _entityRecords3, _records3;
|
|
4704
4863
|
var entity, entityRecords, records, _mastra$dataLayer8, _entityRecords4, _records4, _yield$mastra$trigger2, _event2, res, recordsMapped, entityTypeIndex, _recordsMapped$map2, vectors;
|
|
4705
4864
|
return _regeneratorRuntime().wrap(function _loop2$(_context6) {
|
|
4706
4865
|
while (1) switch (_context6.prev = _context6.next) {
|
|
4707
4866
|
case 0:
|
|
4708
|
-
entity =
|
|
4867
|
+
entity = _step5.value;
|
|
4709
4868
|
_context6.next = 3;
|
|
4710
4869
|
return (_mastra$dataLayer7 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer7.getEntityRecordsByConnectionAndType({
|
|
4711
4870
|
k_id: k_id,
|
|
@@ -4754,9 +4913,9 @@ function _executeVectorSync() {
|
|
|
4754
4913
|
v: void 0
|
|
4755
4914
|
});
|
|
4756
4915
|
case 23:
|
|
4757
|
-
recordsMapped = records.map(function (
|
|
4758
|
-
var data =
|
|
4759
|
-
externalId =
|
|
4916
|
+
recordsMapped = records.map(function (_ref10) {
|
|
4917
|
+
var data = _ref10.data,
|
|
4918
|
+
externalId = _ref10.externalId;
|
|
4760
4919
|
return _extends({
|
|
4761
4920
|
id: externalId
|
|
4762
4921
|
}, _.pick(data, entity.fields));
|
|
@@ -4776,12 +4935,15 @@ function _executeVectorSync() {
|
|
|
4776
4935
|
}
|
|
4777
4936
|
});
|
|
4778
4937
|
case 27:
|
|
4938
|
+
_context6.next = 29;
|
|
4939
|
+
return delay$1(5000);
|
|
4940
|
+
case 29:
|
|
4779
4941
|
entityTypeIndex = vp.index(entity.name);
|
|
4780
4942
|
console.log(entityTypeIndex, 'INDEX');
|
|
4781
|
-
_context6.prev =
|
|
4782
|
-
_context6.next =
|
|
4943
|
+
_context6.prev = 31;
|
|
4944
|
+
_context6.next = 34;
|
|
4783
4945
|
return Promise.all((_recordsMapped$map2 = recordsMapped.map(/*#__PURE__*/function () {
|
|
4784
|
-
var
|
|
4946
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(record) {
|
|
4785
4947
|
var _yield$embed2, embedding;
|
|
4786
4948
|
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
4787
4949
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -4805,111 +4967,382 @@ function _executeVectorSync() {
|
|
|
4805
4967
|
}
|
|
4806
4968
|
}, _callee4);
|
|
4807
4969
|
}));
|
|
4808
|
-
return function (
|
|
4809
|
-
return
|
|
4970
|
+
return function (_x7) {
|
|
4971
|
+
return _ref11.apply(this, arguments);
|
|
4810
4972
|
};
|
|
4811
4973
|
}())) != null ? _recordsMapped$map2 : []);
|
|
4812
|
-
case
|
|
4974
|
+
case 34:
|
|
4813
4975
|
vectors = _context6.sent;
|
|
4814
4976
|
console.log('UPSERTING', vectors);
|
|
4815
4977
|
if (!(vectors.length > 0)) {
|
|
4816
|
-
_context6.next =
|
|
4978
|
+
_context6.next = 39;
|
|
4817
4979
|
break;
|
|
4818
4980
|
}
|
|
4819
|
-
_context6.next =
|
|
4981
|
+
_context6.next = 39;
|
|
4820
4982
|
return entityTypeIndex.namespace(entity.name).upsert(vectors);
|
|
4821
|
-
case 37:
|
|
4822
|
-
_context6.next = 42;
|
|
4823
|
-
break;
|
|
4824
4983
|
case 39:
|
|
4825
|
-
_context6.
|
|
4826
|
-
|
|
4984
|
+
_context6.next = 44;
|
|
4985
|
+
break;
|
|
4986
|
+
case 41:
|
|
4987
|
+
_context6.prev = 41;
|
|
4988
|
+
_context6.t0 = _context6["catch"](31);
|
|
4827
4989
|
console.error(_context6.t0);
|
|
4828
|
-
case
|
|
4990
|
+
case 44:
|
|
4829
4991
|
return _context6.abrupt("return", {
|
|
4830
4992
|
v: void 0
|
|
4831
4993
|
});
|
|
4832
|
-
case
|
|
4994
|
+
case 45:
|
|
4833
4995
|
case "end":
|
|
4834
4996
|
return _context6.stop();
|
|
4835
4997
|
}
|
|
4836
|
-
}, _loop2, null, [[
|
|
4998
|
+
}, _loop2, null, [[31, 41]]);
|
|
4837
4999
|
});
|
|
4838
|
-
|
|
4839
|
-
case
|
|
4840
|
-
if ((
|
|
4841
|
-
_context7.next =
|
|
5000
|
+
_iterator5 = _createForOfIteratorHelperLoose(vectorE.data);
|
|
5001
|
+
case 41:
|
|
5002
|
+
if ((_step5 = _iterator5()).done) {
|
|
5003
|
+
_context7.next = 48;
|
|
4842
5004
|
break;
|
|
4843
5005
|
}
|
|
4844
|
-
return _context7.delegateYield(_loop2(), "t3",
|
|
4845
|
-
case
|
|
5006
|
+
return _context7.delegateYield(_loop2(), "t3", 43);
|
|
5007
|
+
case 43:
|
|
4846
5008
|
_ret2 = _context7.t3;
|
|
4847
5009
|
if (!_ret2) {
|
|
4848
|
-
_context7.next =
|
|
5010
|
+
_context7.next = 46;
|
|
4849
5011
|
break;
|
|
4850
5012
|
}
|
|
4851
5013
|
return _context7.abrupt("return", _ret2.v);
|
|
5014
|
+
case 46:
|
|
5015
|
+
_context7.next = 41;
|
|
5016
|
+
break;
|
|
5017
|
+
case 48:
|
|
5018
|
+
_context7.next = 16;
|
|
5019
|
+
break;
|
|
5020
|
+
case 50:
|
|
5021
|
+
case "end":
|
|
5022
|
+
return _context7.stop();
|
|
5023
|
+
}
|
|
5024
|
+
}, _callee5);
|
|
5025
|
+
}));
|
|
5026
|
+
return _executeGenericVectorSync.apply(this, arguments);
|
|
5027
|
+
}
|
|
5028
|
+
function executeVectorSync(_x3) {
|
|
5029
|
+
return _executeVectorSync.apply(this, arguments);
|
|
5030
|
+
}
|
|
5031
|
+
function _executeVectorSync() {
|
|
5032
|
+
_executeVectorSync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref3) {
|
|
5033
|
+
var _event$user3, _agent$knowledge_sour3;
|
|
5034
|
+
var event, mastra, agentDir, agent, connectionId, systemName, vp, _agent$knowledge_sour4, _iterator6, _step6, _yield$mastra$dataLay3, _mastra$dataLayer9, vectorE, integrationName, k_id, _mastra$dataLayer10, connection, _loop3, _ret3, _iterator7, _step7;
|
|
5035
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context10) {
|
|
5036
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
5037
|
+
case 0:
|
|
5038
|
+
event = _ref3.event, mastra = _ref3.mastra;
|
|
5039
|
+
agentDir = mastra.config.agents.agentDirPath;
|
|
5040
|
+
agent = getAgentBlueprint({
|
|
5041
|
+
agentDir: agentDir,
|
|
5042
|
+
agentId: event.data.agentId
|
|
5043
|
+
});
|
|
5044
|
+
connectionId = event == null || (_event$user3 = event.user) == null ? void 0 : _event$user3.connectionId;
|
|
5045
|
+
systemName = mastra.config.name;
|
|
5046
|
+
if (agent.knowledge_sources.vector_provider) {
|
|
5047
|
+
_context10.next = 8;
|
|
5048
|
+
break;
|
|
5049
|
+
}
|
|
5050
|
+
console.error("No vector_provider defined for agent");
|
|
5051
|
+
return _context10.abrupt("return");
|
|
5052
|
+
case 8:
|
|
5053
|
+
vp = getVectorProvider(agent == null || (_agent$knowledge_sour3 = agent.knowledge_sources) == null ? void 0 : _agent$knowledge_sour3.vector_provider);
|
|
5054
|
+
if (vp) {
|
|
5055
|
+
_context10.next = 12;
|
|
5056
|
+
break;
|
|
5057
|
+
}
|
|
5058
|
+
console.error('UNSUPPORTED VECTOR PROVIDER', agent == null || (_agent$knowledge_sour4 = agent.knowledge_sources) == null ? void 0 : _agent$knowledge_sour4.vector_provider);
|
|
5059
|
+
return _context10.abrupt("return");
|
|
5060
|
+
case 12:
|
|
5061
|
+
if (process.env.OPENAI_API_KEY) {
|
|
5062
|
+
_context10.next = 15;
|
|
5063
|
+
break;
|
|
5064
|
+
}
|
|
5065
|
+
console.error('NO OPENAI_API_KEY');
|
|
5066
|
+
return _context10.abrupt("return");
|
|
5067
|
+
case 15:
|
|
5068
|
+
if (!(!agent || !(agent != null && agent.knowledge_sources))) {
|
|
5069
|
+
_context10.next = 18;
|
|
5070
|
+
break;
|
|
5071
|
+
}
|
|
5072
|
+
console.error('NO AGENT OR KNOWLEDGE SOURCES');
|
|
5073
|
+
return _context10.abrupt("return");
|
|
5074
|
+
case 18:
|
|
5075
|
+
_iterator6 = _createForOfIteratorHelperLoose(agent.knowledge_sources.entities);
|
|
5076
|
+
case 19:
|
|
5077
|
+
if ((_step6 = _iterator6()).done) {
|
|
5078
|
+
_context10.next = 53;
|
|
5079
|
+
break;
|
|
5080
|
+
}
|
|
5081
|
+
vectorE = _step6.value;
|
|
5082
|
+
integrationName = vectorE.integration;
|
|
5083
|
+
_context10.next = 24;
|
|
5084
|
+
return (_mastra$dataLayer9 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer9.getConnection({
|
|
5085
|
+
connectionId: connectionId,
|
|
5086
|
+
name: integrationName
|
|
5087
|
+
});
|
|
5088
|
+
case 24:
|
|
5089
|
+
_context10.t1 = _yield$mastra$dataLay3 = _context10.sent;
|
|
5090
|
+
if (!(_context10.t1 == null)) {
|
|
5091
|
+
_context10.next = 29;
|
|
5092
|
+
break;
|
|
5093
|
+
}
|
|
5094
|
+
_context10.t2 = void 0;
|
|
5095
|
+
_context10.next = 30;
|
|
5096
|
+
break;
|
|
5097
|
+
case 29:
|
|
5098
|
+
_context10.t2 = _yield$mastra$dataLay3.id;
|
|
5099
|
+
case 30:
|
|
5100
|
+
_context10.t0 = _context10.t2;
|
|
5101
|
+
if (_context10.t0) {
|
|
5102
|
+
_context10.next = 33;
|
|
5103
|
+
break;
|
|
5104
|
+
}
|
|
5105
|
+
_context10.t0 = '';
|
|
5106
|
+
case 33:
|
|
5107
|
+
k_id = _context10.t0;
|
|
5108
|
+
if (!(!k_id && integrationName === systemName)) {
|
|
5109
|
+
_context10.next = 39;
|
|
5110
|
+
break;
|
|
5111
|
+
}
|
|
5112
|
+
_context10.next = 37;
|
|
5113
|
+
return (_mastra$dataLayer10 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer10.createConnection({
|
|
5114
|
+
connection: {
|
|
5115
|
+
connectionId: connectionId,
|
|
5116
|
+
name: integrationName
|
|
5117
|
+
},
|
|
5118
|
+
credential: {
|
|
5119
|
+
type: 'API_KEY',
|
|
5120
|
+
value: connectionId,
|
|
5121
|
+
scope: []
|
|
5122
|
+
}
|
|
5123
|
+
});
|
|
5124
|
+
case 37:
|
|
5125
|
+
connection = _context10.sent;
|
|
5126
|
+
k_id = connection.id;
|
|
5127
|
+
case 39:
|
|
5128
|
+
if (k_id) {
|
|
5129
|
+
_context10.next = 42;
|
|
5130
|
+
break;
|
|
5131
|
+
}
|
|
5132
|
+
console.error('Error bootstrapping shit');
|
|
5133
|
+
return _context10.abrupt("return");
|
|
5134
|
+
case 42:
|
|
5135
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
5136
|
+
var _mastra$dataLayer11, _entityRecords5, _records5;
|
|
5137
|
+
var entity, entityRecords, records, _mastra$dataLayer12, _entityRecords6, _records6, _yield$mastra$trigger3, _event3, res, recordsMapped, entityTypeIndex, _recordsMapped$map3, vectors;
|
|
5138
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context9) {
|
|
5139
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
5140
|
+
case 0:
|
|
5141
|
+
entity = _step7.value;
|
|
5142
|
+
_context9.next = 3;
|
|
5143
|
+
return (_mastra$dataLayer11 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer11.getEntityRecordsByConnectionAndType({
|
|
5144
|
+
k_id: k_id,
|
|
5145
|
+
type: entity.name
|
|
5146
|
+
});
|
|
5147
|
+
case 3:
|
|
5148
|
+
entityRecords = _context9.sent;
|
|
5149
|
+
records = (_entityRecords5 = entityRecords) == null ? void 0 : _entityRecords5.records;
|
|
5150
|
+
if (!(!records || ((_records5 = records) == null ? void 0 : _records5.length) === 0)) {
|
|
5151
|
+
_context9.next = 23;
|
|
5152
|
+
break;
|
|
5153
|
+
}
|
|
5154
|
+
// @TODO: SYNC THEM
|
|
5155
|
+
console.error('NO RECORDS');
|
|
5156
|
+
_context9.next = 9;
|
|
5157
|
+
return mastra.triggerEvent({
|
|
5158
|
+
key: entity.syncEvent,
|
|
5159
|
+
data: {},
|
|
5160
|
+
user: {
|
|
5161
|
+
connectionId: connectionId
|
|
5162
|
+
}
|
|
5163
|
+
});
|
|
5164
|
+
case 9:
|
|
5165
|
+
_yield$mastra$trigger3 = _context9.sent;
|
|
5166
|
+
_event3 = _yield$mastra$trigger3.event;
|
|
5167
|
+
console.log(_event3, '####');
|
|
5168
|
+
_context9.next = 14;
|
|
5169
|
+
return _event3.subscribe();
|
|
5170
|
+
case 14:
|
|
5171
|
+
res = _context9.sent;
|
|
5172
|
+
console.log('Subscribe result', res);
|
|
5173
|
+
_context9.next = 18;
|
|
5174
|
+
return (_mastra$dataLayer12 = mastra.dataLayer) == null ? void 0 : _mastra$dataLayer12.getEntityRecordsByConnectionAndType({
|
|
5175
|
+
k_id: k_id,
|
|
5176
|
+
type: entity.name
|
|
5177
|
+
});
|
|
5178
|
+
case 18:
|
|
5179
|
+
entityRecords = _context9.sent;
|
|
5180
|
+
records = (_entityRecords6 = entityRecords) == null ? void 0 : _entityRecords6.records;
|
|
5181
|
+
if (!(!records || ((_records6 = records) == null ? void 0 : _records6.length) === 0)) {
|
|
5182
|
+
_context9.next = 23;
|
|
5183
|
+
break;
|
|
5184
|
+
}
|
|
5185
|
+
console.error('NO RECORDS AFTER SYNC');
|
|
5186
|
+
return _context9.abrupt("return", {
|
|
5187
|
+
v: void 0
|
|
5188
|
+
});
|
|
5189
|
+
case 23:
|
|
5190
|
+
recordsMapped = records.map(function (_ref12) {
|
|
5191
|
+
var data = _ref12.data,
|
|
5192
|
+
externalId = _ref12.externalId;
|
|
5193
|
+
return _extends({
|
|
5194
|
+
id: externalId
|
|
5195
|
+
}, _.pick(data, entity.fields));
|
|
5196
|
+
});
|
|
5197
|
+
console.log(recordsMapped, 'RECORDS');
|
|
5198
|
+
_context9.next = 27;
|
|
5199
|
+
return vp.createIndex({
|
|
5200
|
+
suppressConflicts: true,
|
|
5201
|
+
name: entity.name,
|
|
5202
|
+
dimension: 1536,
|
|
5203
|
+
metric: 'cosine',
|
|
5204
|
+
spec: {
|
|
5205
|
+
serverless: {
|
|
5206
|
+
cloud: 'aws',
|
|
5207
|
+
region: 'us-east-1'
|
|
5208
|
+
}
|
|
5209
|
+
}
|
|
5210
|
+
});
|
|
5211
|
+
case 27:
|
|
5212
|
+
entityTypeIndex = vp.index(entity.name);
|
|
5213
|
+
console.log(entityTypeIndex, 'INDEX');
|
|
5214
|
+
_context9.prev = 29;
|
|
5215
|
+
_context9.next = 32;
|
|
5216
|
+
return Promise.all((_recordsMapped$map3 = recordsMapped.map(/*#__PURE__*/function () {
|
|
5217
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(record) {
|
|
5218
|
+
var _yield$embed3, embedding;
|
|
5219
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
|
5220
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
5221
|
+
case 0:
|
|
5222
|
+
_context8.next = 2;
|
|
5223
|
+
return ai.embed({
|
|
5224
|
+
model: openai.openai.embedding('text-embedding-3-small'),
|
|
5225
|
+
value: JSON.stringify(record)
|
|
5226
|
+
});
|
|
5227
|
+
case 2:
|
|
5228
|
+
_yield$embed3 = _context8.sent;
|
|
5229
|
+
embedding = _yield$embed3.embedding;
|
|
5230
|
+
return _context8.abrupt("return", {
|
|
5231
|
+
id: record.id,
|
|
5232
|
+
values: embedding,
|
|
5233
|
+
metadata: record
|
|
5234
|
+
});
|
|
5235
|
+
case 5:
|
|
5236
|
+
case "end":
|
|
5237
|
+
return _context8.stop();
|
|
5238
|
+
}
|
|
5239
|
+
}, _callee6);
|
|
5240
|
+
}));
|
|
5241
|
+
return function (_x8) {
|
|
5242
|
+
return _ref13.apply(this, arguments);
|
|
5243
|
+
};
|
|
5244
|
+
}())) != null ? _recordsMapped$map3 : []);
|
|
5245
|
+
case 32:
|
|
5246
|
+
vectors = _context9.sent;
|
|
5247
|
+
console.log('UPSERTING', vectors);
|
|
5248
|
+
if (!(vectors.length > 0)) {
|
|
5249
|
+
_context9.next = 37;
|
|
5250
|
+
break;
|
|
5251
|
+
}
|
|
5252
|
+
_context9.next = 37;
|
|
5253
|
+
return entityTypeIndex.namespace(entity.name).upsert(vectors);
|
|
5254
|
+
case 37:
|
|
5255
|
+
_context9.next = 42;
|
|
5256
|
+
break;
|
|
5257
|
+
case 39:
|
|
5258
|
+
_context9.prev = 39;
|
|
5259
|
+
_context9.t0 = _context9["catch"](29);
|
|
5260
|
+
console.error(_context9.t0);
|
|
5261
|
+
case 42:
|
|
5262
|
+
return _context9.abrupt("return", {
|
|
5263
|
+
v: void 0
|
|
5264
|
+
});
|
|
5265
|
+
case 43:
|
|
5266
|
+
case "end":
|
|
5267
|
+
return _context9.stop();
|
|
5268
|
+
}
|
|
5269
|
+
}, _loop3, null, [[29, 39]]);
|
|
5270
|
+
});
|
|
5271
|
+
_iterator7 = _createForOfIteratorHelperLoose(vectorE.data);
|
|
5272
|
+
case 44:
|
|
5273
|
+
if ((_step7 = _iterator7()).done) {
|
|
5274
|
+
_context10.next = 51;
|
|
5275
|
+
break;
|
|
5276
|
+
}
|
|
5277
|
+
return _context10.delegateYield(_loop3(), "t3", 46);
|
|
5278
|
+
case 46:
|
|
5279
|
+
_ret3 = _context10.t3;
|
|
5280
|
+
if (!_ret3) {
|
|
5281
|
+
_context10.next = 49;
|
|
5282
|
+
break;
|
|
5283
|
+
}
|
|
5284
|
+
return _context10.abrupt("return", _ret3.v);
|
|
4852
5285
|
case 49:
|
|
4853
|
-
|
|
5286
|
+
_context10.next = 44;
|
|
4854
5287
|
break;
|
|
4855
5288
|
case 51:
|
|
4856
|
-
|
|
5289
|
+
_context10.next = 19;
|
|
4857
5290
|
break;
|
|
4858
5291
|
case 53:
|
|
4859
5292
|
case "end":
|
|
4860
|
-
return
|
|
5293
|
+
return _context10.stop();
|
|
4861
5294
|
}
|
|
4862
|
-
},
|
|
5295
|
+
}, _callee7);
|
|
4863
5296
|
}));
|
|
4864
5297
|
return _executeVectorSync.apply(this, arguments);
|
|
4865
5298
|
}
|
|
4866
|
-
function vectorQueryEngine(
|
|
5299
|
+
function vectorQueryEngine(_x4) {
|
|
4867
5300
|
return _vectorQueryEngine.apply(this, arguments);
|
|
4868
5301
|
}
|
|
4869
5302
|
function _vectorQueryEngine() {
|
|
4870
|
-
_vectorQueryEngine = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4871
|
-
var vector_provider,
|
|
4872
|
-
return _regeneratorRuntime().wrap(function
|
|
4873
|
-
while (1) switch (
|
|
5303
|
+
_vectorQueryEngine = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref4) {
|
|
5304
|
+
var vector_provider, _ref4$topK, topK, indexName, content, entityType, vp, index, _yield$embed4, embedding, queryResponse;
|
|
5305
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context11) {
|
|
5306
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
4874
5307
|
case 0:
|
|
4875
|
-
vector_provider =
|
|
5308
|
+
vector_provider = _ref4.vector_provider, _ref4$topK = _ref4.topK, topK = _ref4$topK === void 0 ? 1 : _ref4$topK, indexName = _ref4.indexName, content = _ref4.content, entityType = _ref4.entityType;
|
|
4876
5309
|
vp = getVectorProvider(vector_provider);
|
|
4877
5310
|
if (vp) {
|
|
4878
|
-
|
|
5311
|
+
_context11.next = 5;
|
|
4879
5312
|
break;
|
|
4880
5313
|
}
|
|
4881
5314
|
console.error('UNSUPPORTED VECTOR PROVIDER', vector_provider);
|
|
4882
|
-
return
|
|
5315
|
+
return _context11.abrupt("return");
|
|
4883
5316
|
case 5:
|
|
4884
5317
|
index = vp.index(indexName);
|
|
4885
|
-
|
|
5318
|
+
_context11.next = 8;
|
|
4886
5319
|
return ai.embed({
|
|
4887
5320
|
model: openai.openai.embedding('text-embedding-3-small'),
|
|
4888
5321
|
value: content
|
|
4889
5322
|
});
|
|
4890
5323
|
case 8:
|
|
4891
|
-
_yield$
|
|
4892
|
-
embedding = _yield$
|
|
5324
|
+
_yield$embed4 = _context11.sent;
|
|
5325
|
+
embedding = _yield$embed4.embedding;
|
|
4893
5326
|
console.log(embedding, 'EMBEDDING');
|
|
4894
|
-
|
|
5327
|
+
_context11.next = 13;
|
|
4895
5328
|
return index.namespace(entityType).query({
|
|
4896
5329
|
vector: embedding,
|
|
4897
5330
|
topK: topK,
|
|
4898
5331
|
includeMetadata: true
|
|
4899
5332
|
});
|
|
4900
5333
|
case 13:
|
|
4901
|
-
queryResponse =
|
|
4902
|
-
return
|
|
5334
|
+
queryResponse = _context11.sent;
|
|
5335
|
+
return _context11.abrupt("return", queryResponse);
|
|
4903
5336
|
case 15:
|
|
4904
5337
|
case "end":
|
|
4905
|
-
return
|
|
5338
|
+
return _context11.stop();
|
|
4906
5339
|
}
|
|
4907
|
-
},
|
|
5340
|
+
}, _callee8);
|
|
4908
5341
|
}));
|
|
4909
5342
|
return _vectorQueryEngine.apply(this, arguments);
|
|
4910
5343
|
}
|
|
4911
|
-
function getVectorQueryApis(
|
|
4912
|
-
var mastra =
|
|
5344
|
+
function getVectorQueryApis(_ref5) {
|
|
5345
|
+
var mastra = _ref5.mastra;
|
|
4913
5346
|
var agentDir = mastra.config.agents.agentDirPath;
|
|
4914
5347
|
var agents = listAgentsJson({
|
|
4915
5348
|
agentDir: agentDir
|
|
@@ -4928,9 +5361,9 @@ function getVectorQueryApis(_ref4) {
|
|
|
4928
5361
|
}).filter(Boolean);
|
|
4929
5362
|
return agentData.flatMap(function (agent) {
|
|
4930
5363
|
var entities = agent == null ? void 0 : agent.knowledge_sources.entities;
|
|
4931
|
-
return entities.flatMap(function (
|
|
4932
|
-
var data =
|
|
4933
|
-
integration =
|
|
5364
|
+
return entities.flatMap(function (_ref6) {
|
|
5365
|
+
var data = _ref6.data,
|
|
5366
|
+
integration = _ref6.integration;
|
|
4934
5367
|
return data.map(function (entity) {
|
|
4935
5368
|
return {
|
|
4936
5369
|
integrationName: integration,
|
|
@@ -4942,13 +5375,13 @@ function getVectorQueryApis(_ref4) {
|
|
|
4942
5375
|
topResult: zod.z.number()
|
|
4943
5376
|
}),
|
|
4944
5377
|
executor: function () {
|
|
4945
|
-
var _executor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
|
5378
|
+
var _executor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref7) {
|
|
4946
5379
|
var _agent$knowledge_sour2;
|
|
4947
5380
|
var data, res;
|
|
4948
5381
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4949
5382
|
while (1) switch (_context.prev = _context.next) {
|
|
4950
5383
|
case 0:
|
|
4951
|
-
data =
|
|
5384
|
+
data = _ref7.data;
|
|
4952
5385
|
_context.next = 3;
|
|
4953
5386
|
return vectorQueryEngine({
|
|
4954
5387
|
vector_provider: agent == null || (_agent$knowledge_sour2 = agent.knowledge_sources) == null ? void 0 : _agent$knowledge_sour2.vector_provider,
|
|
@@ -4970,7 +5403,7 @@ function getVectorQueryApis(_ref4) {
|
|
|
4970
5403
|
}
|
|
4971
5404
|
}, _callee);
|
|
4972
5405
|
}));
|
|
4973
|
-
function executor(
|
|
5406
|
+
function executor(_x5) {
|
|
4974
5407
|
return _executor.apply(this, arguments);
|
|
4975
5408
|
}
|
|
4976
5409
|
return executor;
|
|
@@ -4996,6 +5429,13 @@ function genericVectorySyncEvent() {
|
|
|
4996
5429
|
executor: executeGenericVectorSync
|
|
4997
5430
|
};
|
|
4998
5431
|
}
|
|
5432
|
+
function vectorIndexSync() {
|
|
5433
|
+
return {
|
|
5434
|
+
id: 'vector-index-sync',
|
|
5435
|
+
event: 'VECTOR_INDEX_SYNC',
|
|
5436
|
+
executor: executeIndexSync
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
4999
5439
|
|
|
5000
5440
|
function getAgentSystemApis(_ref) {
|
|
5001
5441
|
var mastra = _ref.mastra;
|
|
@@ -5973,7 +6413,59 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
5973
6413
|
});
|
|
5974
6414
|
}), getVectorQueryApis({
|
|
5975
6415
|
mastra: framework
|
|
5976
|
-
})
|
|
6416
|
+
}), [{
|
|
6417
|
+
integrationName: config.name,
|
|
6418
|
+
type: 'trigger_event',
|
|
6419
|
+
label: 'Trigger event',
|
|
6420
|
+
// getSchemaOptions({ ctx }) {
|
|
6421
|
+
// const options = Promise.resolve({
|
|
6422
|
+
// event: {
|
|
6423
|
+
// options: Array.from(framework.globalEvents.values()).flatMap(
|
|
6424
|
+
// (eventRecord) =>
|
|
6425
|
+
// Object.values(eventRecord).map((event) => ({
|
|
6426
|
+
// value: event.key || event.label || '',
|
|
6427
|
+
// label: event.key || event.label || '',
|
|
6428
|
+
// })).filter((event) => event.value !== '')
|
|
6429
|
+
// ),
|
|
6430
|
+
// },
|
|
6431
|
+
// });
|
|
6432
|
+
// return options;
|
|
6433
|
+
// },
|
|
6434
|
+
description: 'Trigger event',
|
|
6435
|
+
schema: zod.z.object({
|
|
6436
|
+
event: zod.z.string(),
|
|
6437
|
+
data: zod.z.record(zod.z.any())
|
|
6438
|
+
}),
|
|
6439
|
+
executor: function () {
|
|
6440
|
+
var _executor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref7) {
|
|
6441
|
+
var data, ctx, event;
|
|
6442
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
6443
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
6444
|
+
case 0:
|
|
6445
|
+
data = _ref7.data, ctx = _ref7.ctx;
|
|
6446
|
+
event = data.event;
|
|
6447
|
+
_context2.next = 4;
|
|
6448
|
+
return framework.triggerEvent({
|
|
6449
|
+
key: event,
|
|
6450
|
+
data: data.data,
|
|
6451
|
+
user: {
|
|
6452
|
+
connectionId: ctx.connectionId
|
|
6453
|
+
}
|
|
6454
|
+
});
|
|
6455
|
+
case 4:
|
|
6456
|
+
return _context2.abrupt("return", _context2.sent);
|
|
6457
|
+
case 5:
|
|
6458
|
+
case "end":
|
|
6459
|
+
return _context2.stop();
|
|
6460
|
+
}
|
|
6461
|
+
}, _callee2);
|
|
6462
|
+
}));
|
|
6463
|
+
function executor(_x2) {
|
|
6464
|
+
return _executor.apply(this, arguments);
|
|
6465
|
+
}
|
|
6466
|
+
return executor;
|
|
6467
|
+
}()
|
|
6468
|
+
}])
|
|
5977
6469
|
});
|
|
5978
6470
|
// Register System events
|
|
5979
6471
|
framework.__registerEvents({
|
|
@@ -6006,6 +6498,17 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6006
6498
|
}))
|
|
6007
6499
|
}),
|
|
6008
6500
|
handler: genericVectorySyncEvent
|
|
6501
|
+
},
|
|
6502
|
+
VECTOR_INDEX_SYNC: {
|
|
6503
|
+
label: 'Sync vector index',
|
|
6504
|
+
description: 'Sync vector index',
|
|
6505
|
+
schema: zod.z.object({
|
|
6506
|
+
data: zod.z.array(zod.z.object({
|
|
6507
|
+
provider: zod.z.string(),
|
|
6508
|
+
indexes: zod.z.array(zod.z.string())
|
|
6509
|
+
}))
|
|
6510
|
+
}),
|
|
6511
|
+
handler: vectorIndexSync
|
|
6009
6512
|
}
|
|
6010
6513
|
},
|
|
6011
6514
|
integrationName: config.name
|
|
@@ -6016,59 +6519,59 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6016
6519
|
};
|
|
6017
6520
|
var _proto = Mastra.prototype;
|
|
6018
6521
|
_proto.connectedIntegrations = /*#__PURE__*/function () {
|
|
6019
|
-
var _connectedIntegrations = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6522
|
+
var _connectedIntegrations = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref8) {
|
|
6020
6523
|
var _this2 = this;
|
|
6021
6524
|
var context, ints, connectionChecks;
|
|
6022
|
-
return _regeneratorRuntime().wrap(function
|
|
6023
|
-
while (1) switch (
|
|
6525
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
6526
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
6024
6527
|
case 0:
|
|
6025
|
-
context =
|
|
6528
|
+
context = _ref8.context;
|
|
6026
6529
|
ints = this.availableIntegrations();
|
|
6027
|
-
|
|
6530
|
+
_context4.next = 4;
|
|
6028
6531
|
return Promise.all(ints.map(/*#__PURE__*/function () {
|
|
6029
|
-
var
|
|
6532
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref9) {
|
|
6030
6533
|
var integration, connection;
|
|
6031
|
-
return _regeneratorRuntime().wrap(function
|
|
6032
|
-
while (1) switch (
|
|
6534
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
6535
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
6033
6536
|
case 0:
|
|
6034
|
-
integration =
|
|
6035
|
-
|
|
6537
|
+
integration = _ref9.integration;
|
|
6538
|
+
_context3.next = 3;
|
|
6036
6539
|
return _this2.dataLayer.getConnection({
|
|
6037
6540
|
connectionId: context.connectionId,
|
|
6038
6541
|
name: integration.name
|
|
6039
6542
|
});
|
|
6040
6543
|
case 3:
|
|
6041
|
-
connection =
|
|
6042
|
-
return
|
|
6544
|
+
connection = _context3.sent;
|
|
6545
|
+
return _context3.abrupt("return", {
|
|
6043
6546
|
integration: integration,
|
|
6044
6547
|
connected: !!connection
|
|
6045
6548
|
});
|
|
6046
6549
|
case 5:
|
|
6047
6550
|
case "end":
|
|
6048
|
-
return
|
|
6551
|
+
return _context3.stop();
|
|
6049
6552
|
}
|
|
6050
|
-
},
|
|
6553
|
+
}, _callee3);
|
|
6051
6554
|
}));
|
|
6052
|
-
return function (
|
|
6053
|
-
return
|
|
6555
|
+
return function (_x4) {
|
|
6556
|
+
return _ref10.apply(this, arguments);
|
|
6054
6557
|
};
|
|
6055
6558
|
}()));
|
|
6056
6559
|
case 4:
|
|
6057
|
-
connectionChecks =
|
|
6058
|
-
return
|
|
6059
|
-
var connected =
|
|
6560
|
+
connectionChecks = _context4.sent;
|
|
6561
|
+
return _context4.abrupt("return", connectionChecks.filter(function (_ref11) {
|
|
6562
|
+
var connected = _ref11.connected;
|
|
6060
6563
|
return connected;
|
|
6061
|
-
}).map(function (
|
|
6062
|
-
var integration =
|
|
6564
|
+
}).map(function (_ref12) {
|
|
6565
|
+
var integration = _ref12.integration;
|
|
6063
6566
|
return integration;
|
|
6064
6567
|
}));
|
|
6065
6568
|
case 6:
|
|
6066
6569
|
case "end":
|
|
6067
|
-
return
|
|
6570
|
+
return _context4.stop();
|
|
6068
6571
|
}
|
|
6069
|
-
},
|
|
6572
|
+
}, _callee4, this);
|
|
6070
6573
|
}));
|
|
6071
|
-
function connectedIntegrations(
|
|
6574
|
+
function connectedIntegrations(_x3) {
|
|
6072
6575
|
return _connectedIntegrations.apply(this, arguments);
|
|
6073
6576
|
}
|
|
6074
6577
|
return connectedIntegrations;
|
|
@@ -6107,17 +6610,17 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6107
6610
|
var integrationEvents = this.globalEvents.get('SYSTEM') || {};
|
|
6108
6611
|
this.globalEvents.set('SYSTEM', _extends({}, integrationEvents, (_extends3 = {}, _extends3[name] = event, _extends3)));
|
|
6109
6612
|
};
|
|
6110
|
-
_proto.__registerEvents = function __registerEvents(
|
|
6111
|
-
var events =
|
|
6112
|
-
|
|
6113
|
-
integrationName =
|
|
6613
|
+
_proto.__registerEvents = function __registerEvents(_ref13) {
|
|
6614
|
+
var events = _ref13.events,
|
|
6615
|
+
_ref13$integrationNam = _ref13.integrationName,
|
|
6616
|
+
integrationName = _ref13$integrationNam === void 0 ? this.config.name : _ref13$integrationNam;
|
|
6114
6617
|
var integrationEvents = this.globalEvents.get(integrationName) || {};
|
|
6115
6618
|
this.globalEvents.set(integrationName, _extends({}, integrationEvents, events));
|
|
6116
6619
|
};
|
|
6117
|
-
_proto.__registerApis = function __registerApis(
|
|
6118
|
-
var apis =
|
|
6119
|
-
|
|
6120
|
-
integrationName =
|
|
6620
|
+
_proto.__registerApis = function __registerApis(_ref14) {
|
|
6621
|
+
var apis = _ref14.apis,
|
|
6622
|
+
_ref14$integrationNam = _ref14.integrationName,
|
|
6623
|
+
integrationName = _ref14$integrationNam === void 0 ? this.config.name : _ref14$integrationNam;
|
|
6121
6624
|
var integrationApis = this.globalApis.get(integrationName) || {};
|
|
6122
6625
|
this.globalApis.set(integrationName, _extends({}, integrationApis, apis.reduce(function (acc, api) {
|
|
6123
6626
|
var _extends4;
|
|
@@ -6125,9 +6628,9 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6125
6628
|
}, {})));
|
|
6126
6629
|
};
|
|
6127
6630
|
_proto.availableIntegrations = function availableIntegrations() {
|
|
6128
|
-
return Array.from(this.integrations.entries()).map(function (
|
|
6129
|
-
var name =
|
|
6130
|
-
integration =
|
|
6631
|
+
return Array.from(this.integrations.entries()).map(function (_ref15) {
|
|
6632
|
+
var name = _ref15[0],
|
|
6633
|
+
integration = _ref15[1];
|
|
6131
6634
|
return {
|
|
6132
6635
|
name: name,
|
|
6133
6636
|
integration: integration
|
|
@@ -6149,9 +6652,9 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6149
6652
|
};
|
|
6150
6653
|
_proto.getGlobalEventHandlers = function getGlobalEventHandlers() {
|
|
6151
6654
|
var _this3 = this;
|
|
6152
|
-
return Array.from(this.globalEvents.entries()).flatMap(function (
|
|
6153
|
-
var integrationName =
|
|
6154
|
-
events =
|
|
6655
|
+
return Array.from(this.globalEvents.entries()).flatMap(function (_ref16) {
|
|
6656
|
+
var integrationName = _ref16[0],
|
|
6657
|
+
events = _ref16[1];
|
|
6155
6658
|
var groupedHandlers = Object.keys(events).map(function (eventKey) {
|
|
6156
6659
|
var _events$eventKey;
|
|
6157
6660
|
var eventHandler = (_events$eventKey = events[eventKey]) == null ? void 0 : _events$eventKey.handler;
|
|
@@ -6200,8 +6703,8 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6200
6703
|
});
|
|
6201
6704
|
};
|
|
6202
6705
|
_proto.authenticatableIntegrations = function authenticatableIntegrations() {
|
|
6203
|
-
return this.availableIntegrations().filter(function (
|
|
6204
|
-
var integration =
|
|
6706
|
+
return this.availableIntegrations().filter(function (_ref17) {
|
|
6707
|
+
var integration = _ref17.integration;
|
|
6205
6708
|
try {
|
|
6206
6709
|
integration.getAuthenticator();
|
|
6207
6710
|
return true;
|
|
@@ -6218,20 +6721,20 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6218
6721
|
return _int.getAuthenticator();
|
|
6219
6722
|
};
|
|
6220
6723
|
_proto.connectIntegrationByCredential = /*#__PURE__*/function () {
|
|
6221
|
-
var _connectIntegrationByCredential = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6724
|
+
var _connectIntegrationByCredential = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref18) {
|
|
6222
6725
|
var name, connectionId, credential, authenticator, integration;
|
|
6223
|
-
return _regeneratorRuntime().wrap(function
|
|
6224
|
-
while (1) switch (
|
|
6726
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
6727
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
6225
6728
|
case 0:
|
|
6226
|
-
name =
|
|
6729
|
+
name = _ref18.name, connectionId = _ref18.connectionId, credential = _ref18.credential;
|
|
6227
6730
|
authenticator = this.authenticator(name);
|
|
6228
6731
|
if (authenticator) {
|
|
6229
|
-
|
|
6732
|
+
_context5.next = 4;
|
|
6230
6733
|
break;
|
|
6231
6734
|
}
|
|
6232
6735
|
throw new Error("Authenticator for " + name + " not found");
|
|
6233
6736
|
case 4:
|
|
6234
|
-
|
|
6737
|
+
_context5.next = 6;
|
|
6235
6738
|
return authenticator.dataAccess.createConnection({
|
|
6236
6739
|
connection: {
|
|
6237
6740
|
name: name,
|
|
@@ -6240,157 +6743,198 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6240
6743
|
credential: credential
|
|
6241
6744
|
});
|
|
6242
6745
|
case 6:
|
|
6243
|
-
integration =
|
|
6746
|
+
integration = _context5.sent;
|
|
6244
6747
|
if (!authenticator.onConnectionCreated) {
|
|
6245
|
-
|
|
6748
|
+
_context5.next = 10;
|
|
6246
6749
|
break;
|
|
6247
6750
|
}
|
|
6248
|
-
|
|
6751
|
+
_context5.next = 10;
|
|
6249
6752
|
return authenticator.onConnectionCreated(integration, credential);
|
|
6250
6753
|
case 10:
|
|
6251
6754
|
case "end":
|
|
6252
|
-
return
|
|
6755
|
+
return _context5.stop();
|
|
6253
6756
|
}
|
|
6254
|
-
},
|
|
6757
|
+
}, _callee5, this);
|
|
6255
6758
|
}));
|
|
6256
|
-
function connectIntegrationByCredential(
|
|
6759
|
+
function connectIntegrationByCredential(_x5) {
|
|
6257
6760
|
return _connectIntegrationByCredential.apply(this, arguments);
|
|
6258
6761
|
}
|
|
6259
6762
|
return connectIntegrationByCredential;
|
|
6260
6763
|
}();
|
|
6261
6764
|
_proto.disconnectIntegration = /*#__PURE__*/function () {
|
|
6262
|
-
var _disconnectIntegration = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6765
|
+
var _disconnectIntegration = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref19) {
|
|
6263
6766
|
var _yield$this$dataLayer;
|
|
6264
6767
|
var name, connectionId, integration, k_id, authenticator;
|
|
6265
|
-
return _regeneratorRuntime().wrap(function
|
|
6266
|
-
while (1) switch (
|
|
6768
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
6769
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
6267
6770
|
case 0:
|
|
6268
|
-
name =
|
|
6771
|
+
name = _ref19.name, connectionId = _ref19.connectionId;
|
|
6269
6772
|
integration = this.getIntegration(name);
|
|
6270
|
-
|
|
6773
|
+
_context6.next = 4;
|
|
6271
6774
|
return this.dataLayer.getConnection({
|
|
6272
6775
|
name: name,
|
|
6273
6776
|
connectionId: connectionId
|
|
6274
6777
|
});
|
|
6275
6778
|
case 4:
|
|
6276
|
-
|
|
6277
|
-
if (!(
|
|
6278
|
-
|
|
6779
|
+
_context6.t0 = _yield$this$dataLayer = _context6.sent;
|
|
6780
|
+
if (!(_context6.t0 == null)) {
|
|
6781
|
+
_context6.next = 9;
|
|
6279
6782
|
break;
|
|
6280
6783
|
}
|
|
6281
|
-
|
|
6282
|
-
|
|
6784
|
+
_context6.t1 = void 0;
|
|
6785
|
+
_context6.next = 10;
|
|
6283
6786
|
break;
|
|
6284
6787
|
case 9:
|
|
6285
|
-
|
|
6788
|
+
_context6.t1 = _yield$this$dataLayer.id;
|
|
6286
6789
|
case 10:
|
|
6287
|
-
k_id =
|
|
6790
|
+
k_id = _context6.t1;
|
|
6288
6791
|
if (k_id) {
|
|
6289
|
-
|
|
6792
|
+
_context6.next = 13;
|
|
6290
6793
|
break;
|
|
6291
6794
|
}
|
|
6292
6795
|
throw new Error("No connection found for " + name);
|
|
6293
6796
|
case 13:
|
|
6294
6797
|
if (!(integration != null && integration.dataLayer)) {
|
|
6295
|
-
|
|
6798
|
+
_context6.next = 16;
|
|
6296
6799
|
break;
|
|
6297
6800
|
}
|
|
6298
|
-
|
|
6801
|
+
_context6.next = 16;
|
|
6299
6802
|
return integration.onDisconnect({
|
|
6300
6803
|
connectionId: connectionId
|
|
6301
6804
|
});
|
|
6302
6805
|
case 16:
|
|
6303
6806
|
if (!((integration == null ? void 0 : integration.config.authType) === exports.IntegrationCredentialType.OAUTH)) {
|
|
6304
|
-
|
|
6807
|
+
_context6.next = 20;
|
|
6305
6808
|
break;
|
|
6306
6809
|
}
|
|
6307
6810
|
authenticator = this.authenticator(name);
|
|
6308
|
-
|
|
6811
|
+
_context6.next = 20;
|
|
6309
6812
|
return authenticator.revokeAuth({
|
|
6310
6813
|
k_id: k_id
|
|
6311
6814
|
});
|
|
6312
6815
|
case 20:
|
|
6313
|
-
|
|
6816
|
+
_context6.next = 22;
|
|
6314
6817
|
return this.dataLayer.deleteConnection({
|
|
6315
6818
|
connectionId: connectionId
|
|
6316
6819
|
});
|
|
6317
6820
|
case 22:
|
|
6318
6821
|
case "end":
|
|
6319
|
-
return
|
|
6822
|
+
return _context6.stop();
|
|
6320
6823
|
}
|
|
6321
|
-
},
|
|
6824
|
+
}, _callee6, this);
|
|
6322
6825
|
}));
|
|
6323
|
-
function disconnectIntegration(
|
|
6826
|
+
function disconnectIntegration(_x6) {
|
|
6324
6827
|
return _disconnectIntegration.apply(this, arguments);
|
|
6325
6828
|
}
|
|
6326
6829
|
return disconnectIntegration;
|
|
6327
6830
|
}();
|
|
6831
|
+
_proto.createSystemConnection = /*#__PURE__*/function () {
|
|
6832
|
+
var _createSystemConnection = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
6833
|
+
var systemConnectionId, existingSystemConnection;
|
|
6834
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
6835
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
6836
|
+
case 0:
|
|
6837
|
+
systemConnectionId = 'SYSTEM';
|
|
6838
|
+
_context7.next = 3;
|
|
6839
|
+
return this.dataLayer.getConnection({
|
|
6840
|
+
connectionId: systemConnectionId,
|
|
6841
|
+
name: this.config.name
|
|
6842
|
+
});
|
|
6843
|
+
case 3:
|
|
6844
|
+
existingSystemConnection = _context7.sent;
|
|
6845
|
+
if (!existingSystemConnection) {
|
|
6846
|
+
_context7.next = 6;
|
|
6847
|
+
break;
|
|
6848
|
+
}
|
|
6849
|
+
return _context7.abrupt("return", existingSystemConnection);
|
|
6850
|
+
case 6:
|
|
6851
|
+
return _context7.abrupt("return", this.dataLayer.createConnection({
|
|
6852
|
+
connection: {
|
|
6853
|
+
connectionId: systemConnectionId,
|
|
6854
|
+
name: this.config.name
|
|
6855
|
+
},
|
|
6856
|
+
credential: {
|
|
6857
|
+
type: 'SYSTEM',
|
|
6858
|
+
value: systemConnectionId
|
|
6859
|
+
}
|
|
6860
|
+
}));
|
|
6861
|
+
case 7:
|
|
6862
|
+
case "end":
|
|
6863
|
+
return _context7.stop();
|
|
6864
|
+
}
|
|
6865
|
+
}, _callee7, this);
|
|
6866
|
+
}));
|
|
6867
|
+
function createSystemConnection() {
|
|
6868
|
+
return _createSystemConnection.apply(this, arguments);
|
|
6869
|
+
}
|
|
6870
|
+
return createSystemConnection;
|
|
6871
|
+
}();
|
|
6328
6872
|
_proto.callApi = /*#__PURE__*/function () {
|
|
6329
|
-
var _callApi = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6873
|
+
var _callApi = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref20) {
|
|
6330
6874
|
var _int2$getApis;
|
|
6331
|
-
var
|
|
6332
|
-
return _regeneratorRuntime().wrap(function
|
|
6333
|
-
while (1) switch (
|
|
6875
|
+
var _ref20$integrationNam, integrationName, api, payload, _this$globalApis$get, _apiExecutor, _int2, apiExecutor;
|
|
6876
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
6877
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
6334
6878
|
case 0:
|
|
6335
|
-
|
|
6879
|
+
_ref20$integrationNam = _ref20.integrationName, integrationName = _ref20$integrationNam === void 0 ? this.config.name : _ref20$integrationNam, api = _ref20.api, payload = _ref20.payload;
|
|
6336
6880
|
if (!(integrationName === this.config.name || integrationName === 'SYSTEM')) {
|
|
6337
|
-
|
|
6881
|
+
_context8.next = 6;
|
|
6338
6882
|
break;
|
|
6339
6883
|
}
|
|
6340
6884
|
_apiExecutor = (_this$globalApis$get = this.globalApis.get(this.config.name)) == null ? void 0 : _this$globalApis$get[api];
|
|
6341
6885
|
if (_apiExecutor) {
|
|
6342
|
-
|
|
6886
|
+
_context8.next = 5;
|
|
6343
6887
|
break;
|
|
6344
6888
|
}
|
|
6345
6889
|
throw new Error("No global api exists for " + api);
|
|
6346
6890
|
case 5:
|
|
6347
|
-
return
|
|
6891
|
+
return _context8.abrupt("return", _apiExecutor.executor(payload));
|
|
6348
6892
|
case 6:
|
|
6349
6893
|
_int2 = this.getIntegration(integrationName);
|
|
6350
6894
|
if (_int2) {
|
|
6351
|
-
|
|
6895
|
+
_context8.next = 9;
|
|
6352
6896
|
break;
|
|
6353
6897
|
}
|
|
6354
6898
|
throw new Error("No Integration exists for " + integrationName);
|
|
6355
6899
|
case 9:
|
|
6356
6900
|
apiExecutor = (_int2$getApis = _int2.getApis()) == null ? void 0 : _int2$getApis[api];
|
|
6357
6901
|
if (apiExecutor) {
|
|
6358
|
-
|
|
6902
|
+
_context8.next = 12;
|
|
6359
6903
|
break;
|
|
6360
6904
|
}
|
|
6361
6905
|
throw new Error("No api exists for " + api + " in " + integrationName);
|
|
6362
6906
|
case 12:
|
|
6363
|
-
return
|
|
6907
|
+
return _context8.abrupt("return", apiExecutor.executor(payload));
|
|
6364
6908
|
case 13:
|
|
6365
6909
|
case "end":
|
|
6366
|
-
return
|
|
6910
|
+
return _context8.stop();
|
|
6367
6911
|
}
|
|
6368
|
-
},
|
|
6912
|
+
}, _callee8, this);
|
|
6369
6913
|
}));
|
|
6370
|
-
function callApi(
|
|
6914
|
+
function callApi(_x7) {
|
|
6371
6915
|
return _callApi.apply(this, arguments);
|
|
6372
6916
|
}
|
|
6373
6917
|
return callApi;
|
|
6374
6918
|
}();
|
|
6375
6919
|
_proto.subscribeEvent = /*#__PURE__*/function () {
|
|
6376
|
-
var _subscribeEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6377
|
-
var _this$config$runner$u, _this$config$runner,
|
|
6378
|
-
var id,
|
|
6379
|
-
return _regeneratorRuntime().wrap(function
|
|
6380
|
-
while (1) switch (
|
|
6920
|
+
var _subscribeEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref21) {
|
|
6921
|
+
var _this$config$runner$u, _this$config$runner, _ref22, _this$config$runner$s, _this$config$runner2;
|
|
6922
|
+
var id, _ref21$interval, interval, _ref21$timeout, timeout, inngestApiUrl, inngestApiToken, startTime, _poll;
|
|
6923
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
6924
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
6381
6925
|
case 0:
|
|
6382
|
-
id =
|
|
6926
|
+
id = _ref21.id, _ref21$interval = _ref21.interval, interval = _ref21$interval === void 0 ? 5000 : _ref21$interval, _ref21$timeout = _ref21.timeout, timeout = _ref21$timeout === void 0 ? 60000 : _ref21$timeout;
|
|
6383
6927
|
inngestApiUrl = (_this$config$runner$u = (_this$config$runner = this.config.runner) == null ? void 0 : _this$config$runner.uri) != null ? _this$config$runner$u : process.env.INNGEST_URL;
|
|
6384
|
-
inngestApiToken = (
|
|
6928
|
+
inngestApiToken = (_ref22 = (_this$config$runner$s = (_this$config$runner2 = this.config.runner) == null ? void 0 : _this$config$runner2.signingKey) != null ? _this$config$runner$s : process.env.INNGEST_SIGNING_KEY) != null ? _ref22 : '123';
|
|
6385
6929
|
startTime = Date.now();
|
|
6386
6930
|
_poll = /*#__PURE__*/function () {
|
|
6387
|
-
var
|
|
6931
|
+
var _ref23 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
6388
6932
|
var response, obj, data, error, lastRun, elapsedTime;
|
|
6389
|
-
return _regeneratorRuntime().wrap(function
|
|
6390
|
-
while (1) switch (
|
|
6933
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
6934
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
6391
6935
|
case 0:
|
|
6392
|
-
|
|
6393
|
-
|
|
6936
|
+
_context9.prev = 0;
|
|
6937
|
+
_context9.next = 3;
|
|
6394
6938
|
return fetch(inngestApiUrl + "/v1/events/" + id + "/runs", {
|
|
6395
6939
|
method: 'GET',
|
|
6396
6940
|
headers: {
|
|
@@ -6399,169 +6943,175 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6399
6943
|
}
|
|
6400
6944
|
});
|
|
6401
6945
|
case 3:
|
|
6402
|
-
response =
|
|
6946
|
+
response = _context9.sent;
|
|
6403
6947
|
console.log("Polling for event " + id + "...", response.ok);
|
|
6404
6948
|
if (!response.ok) {
|
|
6405
|
-
|
|
6949
|
+
_context9.next = 28;
|
|
6406
6950
|
break;
|
|
6407
6951
|
}
|
|
6408
|
-
|
|
6952
|
+
_context9.next = 8;
|
|
6409
6953
|
return response.json();
|
|
6410
6954
|
case 8:
|
|
6411
|
-
obj =
|
|
6955
|
+
obj = _context9.sent;
|
|
6412
6956
|
console.log({
|
|
6413
6957
|
obj: obj
|
|
6414
6958
|
});
|
|
6415
6959
|
data = obj.data, error = obj.error;
|
|
6416
6960
|
console.log("Got data for event " + id + "...", data, error);
|
|
6417
6961
|
if (!error) {
|
|
6418
|
-
|
|
6962
|
+
_context9.next = 15;
|
|
6419
6963
|
break;
|
|
6420
6964
|
}
|
|
6421
6965
|
console.error(error);
|
|
6422
|
-
return
|
|
6966
|
+
return _context9.abrupt("return", null);
|
|
6423
6967
|
case 15:
|
|
6424
6968
|
if (!((data == null ? void 0 : data.length) === 0)) {
|
|
6425
|
-
|
|
6969
|
+
_context9.next = 19;
|
|
6426
6970
|
break;
|
|
6427
6971
|
}
|
|
6428
|
-
|
|
6972
|
+
_context9.next = 18;
|
|
6429
6973
|
return new Promise(function (resolve) {
|
|
6430
6974
|
return setTimeout(resolve, interval);
|
|
6431
6975
|
});
|
|
6432
6976
|
case 18:
|
|
6433
|
-
return
|
|
6977
|
+
return _context9.abrupt("return", _poll());
|
|
6434
6978
|
case 19:
|
|
6435
6979
|
lastRun = data == null ? void 0 : data[0];
|
|
6436
6980
|
console.log(lastRun);
|
|
6437
6981
|
if (lastRun) {
|
|
6438
|
-
|
|
6982
|
+
_context9.next = 23;
|
|
6439
6983
|
break;
|
|
6440
6984
|
}
|
|
6441
|
-
return
|
|
6985
|
+
return _context9.abrupt("return", null);
|
|
6442
6986
|
case 23:
|
|
6443
6987
|
if (!(lastRun.status === 'Running')) {
|
|
6444
|
-
|
|
6988
|
+
_context9.next = 27;
|
|
6445
6989
|
break;
|
|
6446
6990
|
}
|
|
6447
|
-
|
|
6991
|
+
_context9.next = 26;
|
|
6448
6992
|
return new Promise(function (resolve) {
|
|
6449
6993
|
return setTimeout(resolve, interval);
|
|
6450
6994
|
});
|
|
6451
6995
|
case 26:
|
|
6452
|
-
return
|
|
6996
|
+
return _context9.abrupt("return", _poll());
|
|
6453
6997
|
case 27:
|
|
6454
|
-
return
|
|
6998
|
+
return _context9.abrupt("return", {
|
|
6455
6999
|
status: lastRun.status,
|
|
6456
7000
|
startedAt: lastRun.run_started_at,
|
|
6457
7001
|
endedAt: lastRun.ended_at
|
|
6458
7002
|
});
|
|
6459
7003
|
case 28:
|
|
6460
|
-
|
|
7004
|
+
_context9.next = 33;
|
|
6461
7005
|
break;
|
|
6462
7006
|
case 30:
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
console.error("Request failed: " +
|
|
7007
|
+
_context9.prev = 30;
|
|
7008
|
+
_context9.t0 = _context9["catch"](0);
|
|
7009
|
+
console.error("Request failed: " + _context9.t0);
|
|
6466
7010
|
case 33:
|
|
6467
7011
|
// Check if timeout has been reached
|
|
6468
7012
|
elapsedTime = Date.now() - startTime;
|
|
6469
7013
|
if (!(elapsedTime >= timeout)) {
|
|
6470
|
-
|
|
7014
|
+
_context9.next = 37;
|
|
6471
7015
|
break;
|
|
6472
7016
|
}
|
|
6473
7017
|
console.log('Polling timeout reached.');
|
|
6474
|
-
return
|
|
7018
|
+
return _context9.abrupt("return", null);
|
|
6475
7019
|
case 37:
|
|
6476
|
-
|
|
7020
|
+
_context9.next = 39;
|
|
6477
7021
|
return new Promise(function (resolve) {
|
|
6478
7022
|
return setTimeout(resolve, interval);
|
|
6479
7023
|
});
|
|
6480
7024
|
case 39:
|
|
6481
|
-
return
|
|
7025
|
+
return _context9.abrupt("return", _poll());
|
|
6482
7026
|
case 40:
|
|
6483
7027
|
case "end":
|
|
6484
|
-
return
|
|
7028
|
+
return _context9.stop();
|
|
6485
7029
|
}
|
|
6486
|
-
},
|
|
7030
|
+
}, _callee9, null, [[0, 30]]);
|
|
6487
7031
|
}));
|
|
6488
7032
|
return function poll() {
|
|
6489
|
-
return
|
|
7033
|
+
return _ref23.apply(this, arguments);
|
|
6490
7034
|
};
|
|
6491
7035
|
}();
|
|
6492
|
-
return
|
|
7036
|
+
return _context10.abrupt("return", _poll());
|
|
6493
7037
|
case 6:
|
|
6494
7038
|
case "end":
|
|
6495
|
-
return
|
|
7039
|
+
return _context10.stop();
|
|
6496
7040
|
}
|
|
6497
|
-
},
|
|
7041
|
+
}, _callee10, this);
|
|
6498
7042
|
}));
|
|
6499
|
-
function subscribeEvent(
|
|
7043
|
+
function subscribeEvent(_x8) {
|
|
6500
7044
|
return _subscribeEvent.apply(this, arguments);
|
|
6501
7045
|
}
|
|
6502
7046
|
return subscribeEvent;
|
|
6503
7047
|
}();
|
|
6504
7048
|
_proto.triggerEvent = /*#__PURE__*/function () {
|
|
6505
|
-
var _triggerEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7049
|
+
var _triggerEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref24) {
|
|
6506
7050
|
var _this4 = this;
|
|
6507
|
-
var key, data, user,
|
|
6508
|
-
return _regeneratorRuntime().wrap(function
|
|
6509
|
-
while (1) switch (
|
|
7051
|
+
var key, data, user, integrationName, returnObj, integrationEvents, integrationEvent, event, workflowEvent;
|
|
7052
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
7053
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
6510
7054
|
case 0:
|
|
6511
|
-
key =
|
|
6512
|
-
|
|
7055
|
+
key = _ref24.key, data = _ref24.data, user = _ref24.user, integrationName = _ref24.integrationName;
|
|
7056
|
+
_context13.prev = 1;
|
|
6513
7057
|
returnObj = {
|
|
6514
7058
|
event: {}
|
|
6515
7059
|
};
|
|
6516
|
-
|
|
7060
|
+
if (integrationName) {
|
|
7061
|
+
integrationEvents = this.getEventsByIntegration(integrationName);
|
|
7062
|
+
} else {
|
|
7063
|
+
integrationEvents = Array.from(this.globalEvents.values()).reduce(function (acc, curr) {
|
|
7064
|
+
return _extends({}, acc, curr);
|
|
7065
|
+
}, {});
|
|
7066
|
+
}
|
|
6517
7067
|
if (integrationEvents) {
|
|
6518
|
-
|
|
7068
|
+
_context13.next = 6;
|
|
6519
7069
|
break;
|
|
6520
7070
|
}
|
|
6521
|
-
throw new Error("No events
|
|
7071
|
+
throw new Error("No integration events found");
|
|
6522
7072
|
case 6:
|
|
6523
7073
|
integrationEvent = integrationEvents[key];
|
|
6524
7074
|
if (integrationEvent) {
|
|
6525
|
-
|
|
7075
|
+
_context13.next = 9;
|
|
6526
7076
|
break;
|
|
6527
7077
|
}
|
|
6528
|
-
throw new Error("No event exists for " + key + " in " + integrationName);
|
|
7078
|
+
throw new Error("No event exists for " + key + " in " + (integrationName || 'system'));
|
|
6529
7079
|
case 9:
|
|
6530
|
-
|
|
7080
|
+
_context13.next = 11;
|
|
6531
7081
|
return client$1.send({
|
|
6532
7082
|
name: key,
|
|
6533
7083
|
data: data,
|
|
6534
7084
|
user: user
|
|
6535
7085
|
});
|
|
6536
7086
|
case 11:
|
|
6537
|
-
event =
|
|
7087
|
+
event = _context13.sent;
|
|
6538
7088
|
returnObj['event'] = _extends({}, event, {
|
|
6539
7089
|
subscribe: function () {
|
|
6540
|
-
var _subscribe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7090
|
+
var _subscribe = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_temp) {
|
|
6541
7091
|
var _event$ids;
|
|
6542
|
-
var
|
|
6543
|
-
return _regeneratorRuntime().wrap(function
|
|
6544
|
-
while (1) switch (
|
|
7092
|
+
var _ref25, interval, timeout;
|
|
7093
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
7094
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
6545
7095
|
case 0:
|
|
6546
|
-
|
|
6547
|
-
return
|
|
7096
|
+
_ref25 = _temp === void 0 ? {} : _temp, interval = _ref25.interval, timeout = _ref25.timeout;
|
|
7097
|
+
return _context11.abrupt("return", _this4.subscribeEvent({
|
|
6548
7098
|
id: (_event$ids = event.ids) == null ? void 0 : _event$ids[0],
|
|
6549
7099
|
interval: interval,
|
|
6550
7100
|
timeout: timeout
|
|
6551
7101
|
}));
|
|
6552
7102
|
case 2:
|
|
6553
7103
|
case "end":
|
|
6554
|
-
return
|
|
7104
|
+
return _context11.stop();
|
|
6555
7105
|
}
|
|
6556
|
-
},
|
|
7106
|
+
}, _callee11);
|
|
6557
7107
|
}));
|
|
6558
|
-
function subscribe(
|
|
7108
|
+
function subscribe(_x10) {
|
|
6559
7109
|
return _subscribe.apply(this, arguments);
|
|
6560
7110
|
}
|
|
6561
7111
|
return subscribe;
|
|
6562
7112
|
}()
|
|
6563
7113
|
});
|
|
6564
|
-
|
|
7114
|
+
_context13.next = 15;
|
|
6565
7115
|
return client$1.send({
|
|
6566
7116
|
name: 'workflow/run-automations',
|
|
6567
7117
|
data: {
|
|
@@ -6571,45 +7121,45 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6571
7121
|
user: user
|
|
6572
7122
|
});
|
|
6573
7123
|
case 15:
|
|
6574
|
-
workflowEvent =
|
|
7124
|
+
workflowEvent = _context13.sent;
|
|
6575
7125
|
returnObj['workflowEvent'] = _extends({}, workflowEvent, {
|
|
6576
7126
|
subscribe: function () {
|
|
6577
|
-
var _subscribe2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7127
|
+
var _subscribe2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_temp2) {
|
|
6578
7128
|
var _workflowEvent$ids;
|
|
6579
|
-
var
|
|
6580
|
-
return _regeneratorRuntime().wrap(function
|
|
6581
|
-
while (1) switch (
|
|
7129
|
+
var _ref26, interval, timeout;
|
|
7130
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
7131
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
6582
7132
|
case 0:
|
|
6583
|
-
|
|
6584
|
-
return
|
|
7133
|
+
_ref26 = _temp2 === void 0 ? {} : _temp2, interval = _ref26.interval, timeout = _ref26.timeout;
|
|
7134
|
+
return _context12.abrupt("return", _this4.subscribeEvent({
|
|
6585
7135
|
id: (_workflowEvent$ids = workflowEvent.ids) == null ? void 0 : _workflowEvent$ids[0],
|
|
6586
7136
|
interval: interval,
|
|
6587
7137
|
timeout: timeout
|
|
6588
7138
|
}));
|
|
6589
7139
|
case 2:
|
|
6590
7140
|
case "end":
|
|
6591
|
-
return
|
|
7141
|
+
return _context12.stop();
|
|
6592
7142
|
}
|
|
6593
|
-
},
|
|
7143
|
+
}, _callee12);
|
|
6594
7144
|
}));
|
|
6595
|
-
function subscribe(
|
|
7145
|
+
function subscribe(_x11) {
|
|
6596
7146
|
return _subscribe2.apply(this, arguments);
|
|
6597
7147
|
}
|
|
6598
7148
|
return subscribe;
|
|
6599
7149
|
}()
|
|
6600
7150
|
});
|
|
6601
|
-
return
|
|
7151
|
+
return _context13.abrupt("return", returnObj);
|
|
6602
7152
|
case 20:
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
throw new Error("Error triggering event: " +
|
|
7153
|
+
_context13.prev = 20;
|
|
7154
|
+
_context13.t0 = _context13["catch"](1);
|
|
7155
|
+
throw new Error("Error triggering event: " + _context13.t0);
|
|
6606
7156
|
case 23:
|
|
6607
7157
|
case "end":
|
|
6608
|
-
return
|
|
7158
|
+
return _context13.stop();
|
|
6609
7159
|
}
|
|
6610
|
-
},
|
|
7160
|
+
}, _callee13, this, [[1, 20]]);
|
|
6611
7161
|
}));
|
|
6612
|
-
function triggerEvent(
|
|
7162
|
+
function triggerEvent(_x9) {
|
|
6613
7163
|
return _triggerEvent.apply(this, arguments);
|
|
6614
7164
|
}
|
|
6615
7165
|
return triggerEvent;
|
|
@@ -6618,26 +7168,26 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6618
7168
|
_proto.triggerSystemEvent =
|
|
6619
7169
|
/*#__PURE__*/
|
|
6620
7170
|
function () {
|
|
6621
|
-
var _triggerSystemEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7171
|
+
var _triggerSystemEvent = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(_ref27) {
|
|
6622
7172
|
var key, data, user, event, systemEvent;
|
|
6623
|
-
return _regeneratorRuntime().wrap(function
|
|
6624
|
-
while (1) switch (
|
|
7173
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
7174
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
6625
7175
|
case 0:
|
|
6626
|
-
key =
|
|
6627
|
-
|
|
7176
|
+
key = _ref27.key, data = _ref27.data, user = _ref27.user;
|
|
7177
|
+
_context14.next = 3;
|
|
6628
7178
|
return client$1.send({
|
|
6629
7179
|
name: key,
|
|
6630
7180
|
data: data,
|
|
6631
7181
|
user: user
|
|
6632
7182
|
});
|
|
6633
7183
|
case 3:
|
|
6634
|
-
event =
|
|
7184
|
+
event = _context14.sent;
|
|
6635
7185
|
systemEvent = this.getSystemEvents()[key];
|
|
6636
7186
|
if (!systemEvent) {
|
|
6637
|
-
|
|
7187
|
+
_context14.next = 8;
|
|
6638
7188
|
break;
|
|
6639
7189
|
}
|
|
6640
|
-
|
|
7190
|
+
_context14.next = 8;
|
|
6641
7191
|
return client$1.send({
|
|
6642
7192
|
name: 'workflow/run-automations',
|
|
6643
7193
|
data: {
|
|
@@ -6647,24 +7197,24 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6647
7197
|
user: user
|
|
6648
7198
|
});
|
|
6649
7199
|
case 8:
|
|
6650
|
-
return
|
|
7200
|
+
return _context14.abrupt("return", event);
|
|
6651
7201
|
case 9:
|
|
6652
7202
|
case "end":
|
|
6653
|
-
return
|
|
7203
|
+
return _context14.stop();
|
|
6654
7204
|
}
|
|
6655
|
-
},
|
|
7205
|
+
}, _callee14, this);
|
|
6656
7206
|
}));
|
|
6657
|
-
function triggerSystemEvent(
|
|
7207
|
+
function triggerSystemEvent(_x12) {
|
|
6658
7208
|
return _triggerSystemEvent.apply(this, arguments);
|
|
6659
7209
|
}
|
|
6660
7210
|
return triggerSystemEvent;
|
|
6661
7211
|
}();
|
|
6662
7212
|
_proto.createRouter = function createRouter() {
|
|
6663
7213
|
var self = this;
|
|
6664
|
-
var makeWebhookUrl = function makeWebhookUrl(
|
|
7214
|
+
var makeWebhookUrl = function makeWebhookUrl(_ref28) {
|
|
6665
7215
|
var _self$config;
|
|
6666
|
-
var event =
|
|
6667
|
-
name =
|
|
7216
|
+
var event = _ref28.event,
|
|
7217
|
+
name = _ref28.name;
|
|
6668
7218
|
return encodeURI("" + (self == null || (_self$config = self.config) == null ? void 0 : _self$config.systemHostURL) + self.routes.webhook + "?name=" + name + "&event=" + event);
|
|
6669
7219
|
};
|
|
6670
7220
|
var makeRedirectURI = function makeRedirectURI() {
|
|
@@ -6695,36 +7245,36 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6695
7245
|
};
|
|
6696
7246
|
};
|
|
6697
7247
|
_proto.getAgent = /*#__PURE__*/function () {
|
|
6698
|
-
var _getAgent2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7248
|
+
var _getAgent2 = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref29) {
|
|
6699
7249
|
var connectionId, agentId, agentBlueprint, arrMap, finalApis;
|
|
6700
|
-
return _regeneratorRuntime().wrap(function
|
|
6701
|
-
while (1) switch (
|
|
7250
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
7251
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
6702
7252
|
case 0:
|
|
6703
|
-
connectionId =
|
|
6704
|
-
|
|
7253
|
+
connectionId = _ref29.connectionId, agentId = _ref29.agentId;
|
|
7254
|
+
_context15.next = 3;
|
|
6705
7255
|
return getAgentBlueprint({
|
|
6706
7256
|
agentDir: this.config.agents.agentDirPath,
|
|
6707
7257
|
agentId: agentId
|
|
6708
7258
|
});
|
|
6709
7259
|
case 3:
|
|
6710
|
-
agentBlueprint =
|
|
7260
|
+
agentBlueprint = _context15.sent;
|
|
6711
7261
|
arrMap = Array.from(this.getApis());
|
|
6712
|
-
finalApis = arrMap.reduce(function (acc,
|
|
6713
|
-
var v =
|
|
7262
|
+
finalApis = arrMap.reduce(function (acc, _ref30) {
|
|
7263
|
+
var v = _ref30[1];
|
|
6714
7264
|
return _extends({}, acc, v);
|
|
6715
7265
|
}, {});
|
|
6716
|
-
return
|
|
7266
|
+
return _context15.abrupt("return", getAgent({
|
|
6717
7267
|
connectionId: connectionId,
|
|
6718
7268
|
agent: agentBlueprint,
|
|
6719
7269
|
apis: finalApis
|
|
6720
7270
|
}));
|
|
6721
7271
|
case 7:
|
|
6722
7272
|
case "end":
|
|
6723
|
-
return
|
|
7273
|
+
return _context15.stop();
|
|
6724
7274
|
}
|
|
6725
|
-
},
|
|
7275
|
+
}, _callee15, this);
|
|
6726
7276
|
}));
|
|
6727
|
-
function getAgent$1(
|
|
7277
|
+
function getAgent$1(_x13) {
|
|
6728
7278
|
return _getAgent2.apply(this, arguments);
|
|
6729
7279
|
}
|
|
6730
7280
|
return getAgent$1;
|
|
@@ -6739,10 +7289,10 @@ var Mastra = /*#__PURE__*/function () {
|
|
|
6739
7289
|
inngest: '/inngest',
|
|
6740
7290
|
webhook: '/webhook'
|
|
6741
7291
|
};
|
|
6742
|
-
return Object.entries(registry).reduce(function (acc,
|
|
7292
|
+
return Object.entries(registry).reduce(function (acc, _ref31) {
|
|
6743
7293
|
var _extends5;
|
|
6744
|
-
var key =
|
|
6745
|
-
value =
|
|
7294
|
+
var key = _ref31[0],
|
|
7295
|
+
value = _ref31[1];
|
|
6746
7296
|
return _extends({}, acc, (_extends5 = {}, _extends5[key] = "" + _this5.config.routeRegistrationPath + value, _extends5));
|
|
6747
7297
|
}, {});
|
|
6748
7298
|
}
|