@mastra/pg 1.0.0-beta.3 → 1.0.0-beta.5
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/CHANGELOG.md +51 -0
- package/dist/index.cjs +118 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +118 -123
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts +20 -0
- package/dist/shared/config.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +2 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var error = require('@mastra/core/error');
|
|
4
|
+
var storage = require('@mastra/core/storage');
|
|
4
5
|
var utils = require('@mastra/core/utils');
|
|
5
6
|
var vector = require('@mastra/core/vector');
|
|
6
7
|
var asyncMutex = require('async-mutex');
|
|
7
8
|
var pg = require('pg');
|
|
8
9
|
var xxhash = require('xxhash-wasm');
|
|
9
10
|
var filter = require('@mastra/core/vector/filter');
|
|
10
|
-
var storage = require('@mastra/core/storage');
|
|
11
11
|
var pgPromise = require('pg-promise');
|
|
12
12
|
var agent = require('@mastra/core/agent');
|
|
13
13
|
var evals = require('@mastra/core/evals');
|
|
@@ -576,7 +576,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
576
576
|
} catch (error$1) {
|
|
577
577
|
throw new error.MastraError(
|
|
578
578
|
{
|
|
579
|
-
id: "
|
|
579
|
+
id: storage.createVectorErrorId("PG", "INITIALIZATION", "FAILED"),
|
|
580
580
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
581
581
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
582
582
|
details: {
|
|
@@ -670,7 +670,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
670
670
|
} catch (error$1) {
|
|
671
671
|
const mastraError = new error.MastraError(
|
|
672
672
|
{
|
|
673
|
-
id: "
|
|
673
|
+
id: storage.createVectorErrorId("PG", "QUERY", "INVALID_INPUT"),
|
|
674
674
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
675
675
|
category: error.ErrorCategory.USER,
|
|
676
676
|
details: {
|
|
@@ -726,7 +726,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
726
726
|
await client.query("ROLLBACK");
|
|
727
727
|
const mastraError = new error.MastraError(
|
|
728
728
|
{
|
|
729
|
-
id: "
|
|
729
|
+
id: storage.createVectorErrorId("PG", "QUERY", "FAILED"),
|
|
730
730
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
731
731
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
732
732
|
details: {
|
|
@@ -795,7 +795,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
795
795
|
const [, expected, actual] = match;
|
|
796
796
|
const mastraError2 = new error.MastraError(
|
|
797
797
|
{
|
|
798
|
-
id: "
|
|
798
|
+
id: storage.createVectorErrorId("PG", "UPSERT", "INVALID_INPUT"),
|
|
799
799
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
800
800
|
category: error.ErrorCategory.USER,
|
|
801
801
|
text: `Vector dimension mismatch: Index "${indexName}" expects ${expected} dimensions but got ${actual} dimensions. Either use a matching embedding model or delete and recreate the index with the new dimension.`,
|
|
@@ -813,7 +813,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
813
813
|
}
|
|
814
814
|
const mastraError = new error.MastraError(
|
|
815
815
|
{
|
|
816
|
-
id: "
|
|
816
|
+
id: storage.createVectorErrorId("PG", "UPSERT", "FAILED"),
|
|
817
817
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
818
818
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
819
819
|
details: {
|
|
@@ -901,7 +901,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
901
901
|
} catch (error$1) {
|
|
902
902
|
const mastraError = new error.MastraError(
|
|
903
903
|
{
|
|
904
|
-
id: "
|
|
904
|
+
id: storage.createVectorErrorId("PG", "CREATE_INDEX", "INVALID_INPUT"),
|
|
905
905
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
906
906
|
category: error.ErrorCategory.USER,
|
|
907
907
|
details: {
|
|
@@ -951,7 +951,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
951
951
|
}).catch((error$1) => {
|
|
952
952
|
const mastraError = new error.MastraError(
|
|
953
953
|
{
|
|
954
|
-
id: "
|
|
954
|
+
id: storage.createVectorErrorId("PG", "CREATE_INDEX", "FAILED"),
|
|
955
955
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
956
956
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
957
957
|
details: {
|
|
@@ -971,7 +971,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
971
971
|
} catch (error$1) {
|
|
972
972
|
const mastraError = new error.MastraError(
|
|
973
973
|
{
|
|
974
|
-
id: "
|
|
974
|
+
id: storage.createVectorErrorId("PG", "BUILD_INDEX", "FAILED"),
|
|
975
975
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
976
976
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
977
977
|
details: {
|
|
@@ -1171,7 +1171,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1171
1171
|
} catch (e) {
|
|
1172
1172
|
const mastraError = new error.MastraError(
|
|
1173
1173
|
{
|
|
1174
|
-
id: "
|
|
1174
|
+
id: storage.createVectorErrorId("PG", "LIST_INDEXES", "FAILED"),
|
|
1175
1175
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1176
1176
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1177
1177
|
},
|
|
@@ -1260,7 +1260,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1260
1260
|
await client.query("ROLLBACK");
|
|
1261
1261
|
const mastraError = new error.MastraError(
|
|
1262
1262
|
{
|
|
1263
|
-
id: "
|
|
1263
|
+
id: storage.createVectorErrorId("PG", "DESCRIBE_INDEX", "FAILED"),
|
|
1264
1264
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1265
1265
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1266
1266
|
details: {
|
|
@@ -1285,7 +1285,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1285
1285
|
await client.query("ROLLBACK");
|
|
1286
1286
|
const mastraError = new error.MastraError(
|
|
1287
1287
|
{
|
|
1288
|
-
id: "
|
|
1288
|
+
id: storage.createVectorErrorId("PG", "DELETE_INDEX", "FAILED"),
|
|
1289
1289
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1290
1290
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1291
1291
|
details: {
|
|
@@ -1309,7 +1309,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1309
1309
|
await client.query("ROLLBACK");
|
|
1310
1310
|
const mastraError = new error.MastraError(
|
|
1311
1311
|
{
|
|
1312
|
-
id: "
|
|
1312
|
+
id: storage.createVectorErrorId("PG", "TRUNCATE_INDEX", "FAILED"),
|
|
1313
1313
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1314
1314
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1315
1315
|
details: {
|
|
@@ -1351,7 +1351,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
if (!id && !filter) {
|
|
1353
1353
|
throw new error.MastraError({
|
|
1354
|
-
id: "
|
|
1354
|
+
id: storage.createVectorErrorId("PG", "UPDATE_VECTOR", "NO_TARGET"),
|
|
1355
1355
|
text: "Either id or filter must be provided",
|
|
1356
1356
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1357
1357
|
category: error.ErrorCategory.USER,
|
|
@@ -1360,7 +1360,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
if (id && filter) {
|
|
1362
1362
|
throw new error.MastraError({
|
|
1363
|
-
id: "
|
|
1363
|
+
id: storage.createVectorErrorId("PG", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
1364
1364
|
text: "Cannot provide both id and filter - they are mutually exclusive",
|
|
1365
1365
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1366
1366
|
category: error.ErrorCategory.USER,
|
|
@@ -1394,7 +1394,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1394
1394
|
} else {
|
|
1395
1395
|
if (!filter || Object.keys(filter).length === 0) {
|
|
1396
1396
|
throw new error.MastraError({
|
|
1397
|
-
id: "
|
|
1397
|
+
id: storage.createVectorErrorId("PG", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
1398
1398
|
text: "Cannot update with empty filter",
|
|
1399
1399
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1400
1400
|
category: error.ErrorCategory.USER,
|
|
@@ -1406,7 +1406,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1406
1406
|
whereClause = filterQuery.trim().replace(/^WHERE\s+/i, "");
|
|
1407
1407
|
if (!whereClause) {
|
|
1408
1408
|
throw new error.MastraError({
|
|
1409
|
-
id: "
|
|
1409
|
+
id: storage.createVectorErrorId("PG", "UPDATE_VECTOR", "INVALID_FILTER"),
|
|
1410
1410
|
text: "Filter produced empty WHERE clause",
|
|
1411
1411
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1412
1412
|
category: error.ErrorCategory.USER,
|
|
@@ -1437,7 +1437,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
const mastraError = new error.MastraError(
|
|
1439
1439
|
{
|
|
1440
|
-
id: "
|
|
1440
|
+
id: storage.createVectorErrorId("PG", "UPDATE_VECTOR", "FAILED"),
|
|
1441
1441
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1442
1442
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1443
1443
|
details: {
|
|
@@ -1474,7 +1474,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1474
1474
|
} catch (error$1) {
|
|
1475
1475
|
const mastraError = new error.MastraError(
|
|
1476
1476
|
{
|
|
1477
|
-
id: "
|
|
1477
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTOR", "FAILED"),
|
|
1478
1478
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1479
1479
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1480
1480
|
details: {
|
|
@@ -1504,7 +1504,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1504
1504
|
const { tableName } = this.getTableName(indexName);
|
|
1505
1505
|
if (!filter && !ids) {
|
|
1506
1506
|
throw new error.MastraError({
|
|
1507
|
-
id: "
|
|
1507
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "NO_TARGET"),
|
|
1508
1508
|
text: "Either filter or ids must be provided",
|
|
1509
1509
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1510
1510
|
category: error.ErrorCategory.USER,
|
|
@@ -1513,7 +1513,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1513
1513
|
}
|
|
1514
1514
|
if (filter && ids) {
|
|
1515
1515
|
throw new error.MastraError({
|
|
1516
|
-
id: "
|
|
1516
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
1517
1517
|
text: "Cannot provide both filter and ids - they are mutually exclusive",
|
|
1518
1518
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1519
1519
|
category: error.ErrorCategory.USER,
|
|
@@ -1525,7 +1525,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1525
1525
|
if (ids) {
|
|
1526
1526
|
if (ids.length === 0) {
|
|
1527
1527
|
throw new error.MastraError({
|
|
1528
|
-
id: "
|
|
1528
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
1529
1529
|
text: "Cannot delete with empty ids array",
|
|
1530
1530
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1531
1531
|
category: error.ErrorCategory.USER,
|
|
@@ -1538,7 +1538,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1538
1538
|
} else {
|
|
1539
1539
|
if (!filter || Object.keys(filter).length === 0) {
|
|
1540
1540
|
throw new error.MastraError({
|
|
1541
|
-
id: "
|
|
1541
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
1542
1542
|
text: "Cannot delete with empty filter. Use deleteIndex to delete all vectors.",
|
|
1543
1543
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1544
1544
|
category: error.ErrorCategory.USER,
|
|
@@ -1550,7 +1550,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1550
1550
|
const whereClause = filterQuery.trim().replace(/^WHERE\s+/i, "");
|
|
1551
1551
|
if (!whereClause) {
|
|
1552
1552
|
throw new error.MastraError({
|
|
1553
|
-
id: "
|
|
1553
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "INVALID_FILTER"),
|
|
1554
1554
|
text: "Filter produced empty WHERE clause",
|
|
1555
1555
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1556
1556
|
category: error.ErrorCategory.USER,
|
|
@@ -1573,7 +1573,7 @@ var PgVector = class extends vector.MastraVector {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
const mastraError = new error.MastraError(
|
|
1575
1575
|
{
|
|
1576
|
-
id: "
|
|
1576
|
+
id: storage.createVectorErrorId("PG", "DELETE_VECTORS", "FAILED"),
|
|
1577
1577
|
domain: error.ErrorDomain.MASTRA_VECTOR,
|
|
1578
1578
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1579
1579
|
details: {
|
|
@@ -1713,7 +1713,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1713
1713
|
} catch (error$1) {
|
|
1714
1714
|
throw new error.MastraError(
|
|
1715
1715
|
{
|
|
1716
|
-
id: "
|
|
1716
|
+
id: storage.createStorageErrorId("PG", "GET_THREAD_BY_ID", "FAILED"),
|
|
1717
1717
|
domain: error.ErrorDomain.STORAGE,
|
|
1718
1718
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1719
1719
|
details: {
|
|
@@ -1728,7 +1728,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1728
1728
|
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
1729
1729
|
if (page < 0) {
|
|
1730
1730
|
throw new error.MastraError({
|
|
1731
|
-
id: "
|
|
1731
|
+
id: storage.createStorageErrorId("PG", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
1732
1732
|
domain: error.ErrorDomain.STORAGE,
|
|
1733
1733
|
category: error.ErrorCategory.USER,
|
|
1734
1734
|
text: "Page number must be non-negative",
|
|
@@ -1777,7 +1777,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1777
1777
|
} catch (error$1) {
|
|
1778
1778
|
const mastraError = new error.MastraError(
|
|
1779
1779
|
{
|
|
1780
|
-
id: "
|
|
1780
|
+
id: storage.createStorageErrorId("PG", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
1781
1781
|
domain: error.ErrorDomain.STORAGE,
|
|
1782
1782
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1783
1783
|
details: {
|
|
@@ -1835,7 +1835,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1835
1835
|
} catch (error$1) {
|
|
1836
1836
|
throw new error.MastraError(
|
|
1837
1837
|
{
|
|
1838
|
-
id: "
|
|
1838
|
+
id: storage.createStorageErrorId("PG", "SAVE_THREAD", "FAILED"),
|
|
1839
1839
|
domain: error.ErrorDomain.STORAGE,
|
|
1840
1840
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1841
1841
|
details: {
|
|
@@ -1855,7 +1855,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1855
1855
|
const existingThread = await this.getThreadById({ threadId: id });
|
|
1856
1856
|
if (!existingThread) {
|
|
1857
1857
|
throw new error.MastraError({
|
|
1858
|
-
id: "
|
|
1858
|
+
id: storage.createStorageErrorId("PG", "UPDATE_THREAD", "FAILED"),
|
|
1859
1859
|
domain: error.ErrorDomain.STORAGE,
|
|
1860
1860
|
category: error.ErrorCategory.USER,
|
|
1861
1861
|
text: `Thread ${id} not found`,
|
|
@@ -1893,7 +1893,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1893
1893
|
} catch (error$1) {
|
|
1894
1894
|
throw new error.MastraError(
|
|
1895
1895
|
{
|
|
1896
|
-
id: "
|
|
1896
|
+
id: storage.createStorageErrorId("PG", "UPDATE_THREAD", "FAILED"),
|
|
1897
1897
|
domain: error.ErrorDomain.STORAGE,
|
|
1898
1898
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1899
1899
|
details: {
|
|
@@ -1930,7 +1930,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
1930
1930
|
} catch (error$1) {
|
|
1931
1931
|
throw new error.MastraError(
|
|
1932
1932
|
{
|
|
1933
|
-
id: "
|
|
1933
|
+
id: storage.createStorageErrorId("PG", "DELETE_THREAD", "FAILED"),
|
|
1934
1934
|
domain: error.ErrorDomain.STORAGE,
|
|
1935
1935
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1936
1936
|
details: {
|
|
@@ -2037,7 +2037,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2037
2037
|
} catch (error$1) {
|
|
2038
2038
|
const mastraError = new error.MastraError(
|
|
2039
2039
|
{
|
|
2040
|
-
id: "
|
|
2040
|
+
id: storage.createStorageErrorId("PG", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
2041
2041
|
domain: error.ErrorDomain.STORAGE,
|
|
2042
2042
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2043
2043
|
details: {
|
|
@@ -2059,7 +2059,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2059
2059
|
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
2060
2060
|
throw new error.MastraError(
|
|
2061
2061
|
{
|
|
2062
|
-
id: "
|
|
2062
|
+
id: storage.createStorageErrorId("PG", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
2063
2063
|
domain: error.ErrorDomain.STORAGE,
|
|
2064
2064
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2065
2065
|
details: { threadId: Array.isArray(threadId) ? String(threadId) : String(threadId) }
|
|
@@ -2069,7 +2069,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2069
2069
|
}
|
|
2070
2070
|
if (page < 0) {
|
|
2071
2071
|
throw new error.MastraError({
|
|
2072
|
-
id: "
|
|
2072
|
+
id: storage.createStorageErrorId("PG", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
2073
2073
|
domain: error.ErrorDomain.STORAGE,
|
|
2074
2074
|
category: error.ErrorCategory.USER,
|
|
2075
2075
|
text: "Page number must be non-negative",
|
|
@@ -2164,7 +2164,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2164
2164
|
} catch (error$1) {
|
|
2165
2165
|
const mastraError = new error.MastraError(
|
|
2166
2166
|
{
|
|
2167
|
-
id: "
|
|
2167
|
+
id: storage.createStorageErrorId("PG", "LIST_MESSAGES", "FAILED"),
|
|
2168
2168
|
domain: error.ErrorDomain.STORAGE,
|
|
2169
2169
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2170
2170
|
details: {
|
|
@@ -2190,7 +2190,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2190
2190
|
const threadId = messages[0]?.threadId;
|
|
2191
2191
|
if (!threadId) {
|
|
2192
2192
|
throw new error.MastraError({
|
|
2193
|
-
id: "
|
|
2193
|
+
id: storage.createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
|
|
2194
2194
|
domain: error.ErrorDomain.STORAGE,
|
|
2195
2195
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2196
2196
|
text: `Thread ID is required`
|
|
@@ -2199,7 +2199,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2199
2199
|
const thread = await this.getThreadById({ threadId });
|
|
2200
2200
|
if (!thread) {
|
|
2201
2201
|
throw new error.MastraError({
|
|
2202
|
-
id: "
|
|
2202
|
+
id: storage.createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
|
|
2203
2203
|
domain: error.ErrorDomain.STORAGE,
|
|
2204
2204
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2205
2205
|
text: `Thread ${threadId} not found`,
|
|
@@ -2270,7 +2270,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2270
2270
|
} catch (error$1) {
|
|
2271
2271
|
throw new error.MastraError(
|
|
2272
2272
|
{
|
|
2273
|
-
id: "
|
|
2273
|
+
id: storage.createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
|
|
2274
2274
|
domain: error.ErrorDomain.STORAGE,
|
|
2275
2275
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2276
2276
|
details: {
|
|
@@ -2399,7 +2399,7 @@ var MemoryPG = class extends storage.MemoryStorage {
|
|
|
2399
2399
|
} catch (error$1) {
|
|
2400
2400
|
throw new error.MastraError(
|
|
2401
2401
|
{
|
|
2402
|
-
id: "
|
|
2402
|
+
id: storage.createStorageErrorId("PG", "DELETE_MESSAGES", "FAILED"),
|
|
2403
2403
|
domain: error.ErrorDomain.STORAGE,
|
|
2404
2404
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2405
2405
|
details: { messageIds: messageIds.join(", ") }
|
|
@@ -2520,7 +2520,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2520
2520
|
} catch (error$1) {
|
|
2521
2521
|
throw new error.MastraError(
|
|
2522
2522
|
{
|
|
2523
|
-
id: "
|
|
2523
|
+
id: storage.createStorageErrorId("PG", "CREATE_SPAN", "FAILED"),
|
|
2524
2524
|
domain: error.ErrorDomain.STORAGE,
|
|
2525
2525
|
category: error.ErrorCategory.USER,
|
|
2526
2526
|
details: {
|
|
@@ -2566,7 +2566,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2566
2566
|
} catch (error$1) {
|
|
2567
2567
|
throw new error.MastraError(
|
|
2568
2568
|
{
|
|
2569
|
-
id: "
|
|
2569
|
+
id: storage.createStorageErrorId("PG", "GET_TRACE", "FAILED"),
|
|
2570
2570
|
domain: error.ErrorDomain.STORAGE,
|
|
2571
2571
|
category: error.ErrorCategory.USER,
|
|
2572
2572
|
details: {
|
|
@@ -2598,7 +2598,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2598
2598
|
} catch (error$1) {
|
|
2599
2599
|
throw new error.MastraError(
|
|
2600
2600
|
{
|
|
2601
|
-
id: "
|
|
2601
|
+
id: storage.createStorageErrorId("PG", "UPDATE_SPAN", "FAILED"),
|
|
2602
2602
|
domain: error.ErrorDomain.STORAGE,
|
|
2603
2603
|
category: error.ErrorCategory.USER,
|
|
2604
2604
|
details: {
|
|
@@ -2634,7 +2634,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2634
2634
|
name = `agent run: '${entityId}'`;
|
|
2635
2635
|
} else {
|
|
2636
2636
|
const error$1 = new error.MastraError({
|
|
2637
|
-
id: "
|
|
2637
|
+
id: storage.createStorageErrorId("PG", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
|
|
2638
2638
|
domain: error.ErrorDomain.STORAGE,
|
|
2639
2639
|
category: error.ErrorCategory.USER,
|
|
2640
2640
|
details: {
|
|
@@ -2702,7 +2702,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2702
2702
|
} catch (error$1) {
|
|
2703
2703
|
throw new error.MastraError(
|
|
2704
2704
|
{
|
|
2705
|
-
id: "
|
|
2705
|
+
id: storage.createStorageErrorId("PG", "GET_TRACES_PAGINATED", "FAILED"),
|
|
2706
2706
|
domain: error.ErrorDomain.STORAGE,
|
|
2707
2707
|
category: error.ErrorCategory.USER
|
|
2708
2708
|
},
|
|
@@ -2731,7 +2731,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2731
2731
|
} catch (error$1) {
|
|
2732
2732
|
throw new error.MastraError(
|
|
2733
2733
|
{
|
|
2734
|
-
id: "
|
|
2734
|
+
id: storage.createStorageErrorId("PG", "BATCH_CREATE_SPANS", "FAILED"),
|
|
2735
2735
|
domain: error.ErrorDomain.STORAGE,
|
|
2736
2736
|
category: error.ErrorCategory.USER
|
|
2737
2737
|
},
|
|
@@ -2766,7 +2766,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2766
2766
|
} catch (error$1) {
|
|
2767
2767
|
throw new error.MastraError(
|
|
2768
2768
|
{
|
|
2769
|
-
id: "
|
|
2769
|
+
id: storage.createStorageErrorId("PG", "BATCH_UPDATE_SPANS", "FAILED"),
|
|
2770
2770
|
domain: error.ErrorDomain.STORAGE,
|
|
2771
2771
|
category: error.ErrorCategory.USER
|
|
2772
2772
|
},
|
|
@@ -2785,7 +2785,7 @@ var ObservabilityPG = class extends storage.ObservabilityStorage {
|
|
|
2785
2785
|
} catch (error$1) {
|
|
2786
2786
|
throw new error.MastraError(
|
|
2787
2787
|
{
|
|
2788
|
-
id: "
|
|
2788
|
+
id: storage.createStorageErrorId("PG", "BATCH_DELETE_TRACES", "FAILED"),
|
|
2789
2789
|
domain: error.ErrorDomain.STORAGE,
|
|
2790
2790
|
category: error.ErrorCategory.USER
|
|
2791
2791
|
},
|
|
@@ -2915,7 +2915,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
2915
2915
|
} catch (error$1) {
|
|
2916
2916
|
throw new error.MastraError(
|
|
2917
2917
|
{
|
|
2918
|
-
id: "
|
|
2918
|
+
id: storage.createStorageErrorId("PG", "INSERT", "FAILED"),
|
|
2919
2919
|
domain: error.ErrorDomain.STORAGE,
|
|
2920
2920
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2921
2921
|
details: {
|
|
@@ -2934,7 +2934,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
2934
2934
|
} catch (error$1) {
|
|
2935
2935
|
throw new error.MastraError(
|
|
2936
2936
|
{
|
|
2937
|
-
id: "
|
|
2937
|
+
id: storage.createStorageErrorId("PG", "CLEAR_TABLE", "FAILED"),
|
|
2938
2938
|
domain: error.ErrorDomain.STORAGE,
|
|
2939
2939
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2940
2940
|
details: {
|
|
@@ -3007,7 +3007,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3007
3007
|
} catch (error$1) {
|
|
3008
3008
|
throw new error.MastraError(
|
|
3009
3009
|
{
|
|
3010
|
-
id: "
|
|
3010
|
+
id: storage.createStorageErrorId("PG", "CREATE_TABLE", "FAILED"),
|
|
3011
3011
|
domain: error.ErrorDomain.STORAGE,
|
|
3012
3012
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3013
3013
|
details: {
|
|
@@ -3094,7 +3094,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3094
3094
|
} catch (error$1) {
|
|
3095
3095
|
throw new error.MastraError(
|
|
3096
3096
|
{
|
|
3097
|
-
id: "
|
|
3097
|
+
id: storage.createStorageErrorId("PG", "ALTER_TABLE", "FAILED"),
|
|
3098
3098
|
domain: error.ErrorDomain.STORAGE,
|
|
3099
3099
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3100
3100
|
details: {
|
|
@@ -3128,7 +3128,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3128
3128
|
} catch (error$1) {
|
|
3129
3129
|
throw new error.MastraError(
|
|
3130
3130
|
{
|
|
3131
|
-
id: "
|
|
3131
|
+
id: storage.createStorageErrorId("PG", "LOAD", "FAILED"),
|
|
3132
3132
|
domain: error.ErrorDomain.STORAGE,
|
|
3133
3133
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3134
3134
|
details: {
|
|
@@ -3150,7 +3150,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3150
3150
|
await this.client.query("ROLLBACK");
|
|
3151
3151
|
throw new error.MastraError(
|
|
3152
3152
|
{
|
|
3153
|
-
id: "
|
|
3153
|
+
id: storage.createStorageErrorId("PG", "BATCH_INSERT", "FAILED"),
|
|
3154
3154
|
domain: error.ErrorDomain.STORAGE,
|
|
3155
3155
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3156
3156
|
details: {
|
|
@@ -3170,7 +3170,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3170
3170
|
} catch (error$1) {
|
|
3171
3171
|
throw new error.MastraError(
|
|
3172
3172
|
{
|
|
3173
|
-
id: "
|
|
3173
|
+
id: storage.createStorageErrorId("PG", "DROP_TABLE", "FAILED"),
|
|
3174
3174
|
domain: error.ErrorDomain.STORAGE,
|
|
3175
3175
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3176
3176
|
details: {
|
|
@@ -3243,7 +3243,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3243
3243
|
}
|
|
3244
3244
|
throw new error.MastraError(
|
|
3245
3245
|
{
|
|
3246
|
-
id: "
|
|
3246
|
+
id: storage.createStorageErrorId("PG", "INDEX_CREATE", "FAILED"),
|
|
3247
3247
|
domain: error.ErrorDomain.STORAGE,
|
|
3248
3248
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3249
3249
|
details: {
|
|
@@ -3275,7 +3275,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3275
3275
|
} catch (error$1) {
|
|
3276
3276
|
throw new error.MastraError(
|
|
3277
3277
|
{
|
|
3278
|
-
id: "
|
|
3278
|
+
id: storage.createStorageErrorId("PG", "INDEX_DROP", "FAILED"),
|
|
3279
3279
|
domain: error.ErrorDomain.STORAGE,
|
|
3280
3280
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3281
3281
|
details: {
|
|
@@ -3351,7 +3351,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3351
3351
|
} catch (error$1) {
|
|
3352
3352
|
throw new error.MastraError(
|
|
3353
3353
|
{
|
|
3354
|
-
id: "
|
|
3354
|
+
id: storage.createStorageErrorId("PG", "INDEX_LIST", "FAILED"),
|
|
3355
3355
|
domain: error.ErrorDomain.STORAGE,
|
|
3356
3356
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3357
3357
|
details: tableName ? {
|
|
@@ -3433,7 +3433,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3433
3433
|
} catch (error$1) {
|
|
3434
3434
|
throw new error.MastraError(
|
|
3435
3435
|
{
|
|
3436
|
-
id: "
|
|
3436
|
+
id: storage.createStorageErrorId("PG", "CREATE_AUTOMATIC_INDEXES", "FAILED"),
|
|
3437
3437
|
domain: error.ErrorDomain.STORAGE,
|
|
3438
3438
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3439
3439
|
},
|
|
@@ -3495,7 +3495,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3495
3495
|
} catch (error$1) {
|
|
3496
3496
|
throw new error.MastraError(
|
|
3497
3497
|
{
|
|
3498
|
-
id: "
|
|
3498
|
+
id: storage.createStorageErrorId("PG", "INDEX_DESCRIBE", "FAILED"),
|
|
3499
3499
|
domain: error.ErrorDomain.STORAGE,
|
|
3500
3500
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3501
3501
|
details: {
|
|
@@ -3540,7 +3540,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3540
3540
|
} catch (error$1) {
|
|
3541
3541
|
throw new error.MastraError(
|
|
3542
3542
|
{
|
|
3543
|
-
id: "
|
|
3543
|
+
id: storage.createStorageErrorId("PG", "UPDATE", "FAILED"),
|
|
3544
3544
|
domain: error.ErrorDomain.STORAGE,
|
|
3545
3545
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3546
3546
|
details: {
|
|
@@ -3568,7 +3568,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3568
3568
|
await this.client.query("ROLLBACK");
|
|
3569
3569
|
throw new error.MastraError(
|
|
3570
3570
|
{
|
|
3571
|
-
id: "
|
|
3571
|
+
id: storage.createStorageErrorId("PG", "BATCH_UPDATE", "FAILED"),
|
|
3572
3572
|
domain: error.ErrorDomain.STORAGE,
|
|
3573
3573
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3574
3574
|
details: {
|
|
@@ -3609,7 +3609,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
|
|
|
3609
3609
|
} catch (error$1) {
|
|
3610
3610
|
throw new error.MastraError(
|
|
3611
3611
|
{
|
|
3612
|
-
id: "
|
|
3612
|
+
id: storage.createStorageErrorId("PG", "BATCH_DELETE", "FAILED"),
|
|
3613
3613
|
domain: error.ErrorDomain.STORAGE,
|
|
3614
3614
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3615
3615
|
details: {
|
|
@@ -3654,7 +3654,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3654
3654
|
} catch (error$1) {
|
|
3655
3655
|
throw new error.MastraError(
|
|
3656
3656
|
{
|
|
3657
|
-
id: "
|
|
3657
|
+
id: storage.createStorageErrorId("PG", "GET_SCORE_BY_ID", "FAILED"),
|
|
3658
3658
|
domain: error.ErrorDomain.STORAGE,
|
|
3659
3659
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3660
3660
|
},
|
|
@@ -3722,7 +3722,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3722
3722
|
} catch (error$1) {
|
|
3723
3723
|
throw new error.MastraError(
|
|
3724
3724
|
{
|
|
3725
|
-
id: "
|
|
3725
|
+
id: storage.createStorageErrorId("PG", "GET_SCORES_BY_SCORER_ID", "FAILED"),
|
|
3726
3726
|
domain: error.ErrorDomain.STORAGE,
|
|
3727
3727
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3728
3728
|
},
|
|
@@ -3737,15 +3737,15 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3737
3737
|
} catch (error$1) {
|
|
3738
3738
|
throw new error.MastraError(
|
|
3739
3739
|
{
|
|
3740
|
-
id: "
|
|
3740
|
+
id: storage.createStorageErrorId("PG", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
3741
3741
|
domain: error.ErrorDomain.STORAGE,
|
|
3742
3742
|
category: error.ErrorCategory.USER,
|
|
3743
3743
|
details: {
|
|
3744
|
-
scorer: score.scorer
|
|
3745
|
-
entityId: score.entityId,
|
|
3746
|
-
entityType: score.entityType,
|
|
3747
|
-
traceId: score.traceId
|
|
3748
|
-
spanId: score.spanId
|
|
3744
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
3745
|
+
entityId: score.entityId ?? "unknown",
|
|
3746
|
+
entityType: score.entityType ?? "unknown",
|
|
3747
|
+
traceId: score.traceId ?? "",
|
|
3748
|
+
spanId: score.spanId ?? ""
|
|
3749
3749
|
}
|
|
3750
3750
|
},
|
|
3751
3751
|
error$1
|
|
@@ -3753,6 +3753,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3753
3753
|
}
|
|
3754
3754
|
try {
|
|
3755
3755
|
const id = crypto.randomUUID();
|
|
3756
|
+
const now = /* @__PURE__ */ new Date();
|
|
3756
3757
|
const {
|
|
3757
3758
|
scorer,
|
|
3758
3759
|
preprocessStepResult,
|
|
@@ -3775,18 +3776,19 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3775
3776
|
scorer: scorer ? JSON.stringify(scorer) : null,
|
|
3776
3777
|
preprocessStepResult: preprocessStepResult ? JSON.stringify(preprocessStepResult) : null,
|
|
3777
3778
|
analyzeStepResult: analyzeStepResult ? JSON.stringify(analyzeStepResult) : null,
|
|
3779
|
+
metadata: metadata ? JSON.stringify(metadata) : null,
|
|
3780
|
+
additionalContext: additionalContext ? JSON.stringify(additionalContext) : null,
|
|
3778
3781
|
requestContext: requestContext ? JSON.stringify(requestContext) : null,
|
|
3779
3782
|
entity: entity ? JSON.stringify(entity) : null,
|
|
3780
|
-
createdAt:
|
|
3781
|
-
updatedAt:
|
|
3783
|
+
createdAt: now.toISOString(),
|
|
3784
|
+
updatedAt: now.toISOString()
|
|
3782
3785
|
}
|
|
3783
3786
|
});
|
|
3784
|
-
|
|
3785
|
-
return { score: scoreFromDb };
|
|
3787
|
+
return { score: { ...parsedScore, id, createdAt: now, updatedAt: now } };
|
|
3786
3788
|
} catch (error$1) {
|
|
3787
3789
|
throw new error.MastraError(
|
|
3788
3790
|
{
|
|
3789
|
-
id: "
|
|
3791
|
+
id: storage.createStorageErrorId("PG", "SAVE_SCORE", "FAILED"),
|
|
3790
3792
|
domain: error.ErrorDomain.STORAGE,
|
|
3791
3793
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3792
3794
|
},
|
|
@@ -3835,7 +3837,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3835
3837
|
} catch (error$1) {
|
|
3836
3838
|
throw new error.MastraError(
|
|
3837
3839
|
{
|
|
3838
|
-
id: "
|
|
3840
|
+
id: storage.createStorageErrorId("PG", "GET_SCORES_BY_RUN_ID", "FAILED"),
|
|
3839
3841
|
domain: error.ErrorDomain.STORAGE,
|
|
3840
3842
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3841
3843
|
},
|
|
@@ -3885,7 +3887,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3885
3887
|
} catch (error$1) {
|
|
3886
3888
|
throw new error.MastraError(
|
|
3887
3889
|
{
|
|
3888
|
-
id: "
|
|
3890
|
+
id: storage.createStorageErrorId("PG", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
3889
3891
|
domain: error.ErrorDomain.STORAGE,
|
|
3890
3892
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3891
3893
|
},
|
|
@@ -3928,7 +3930,7 @@ var ScoresPG = class extends storage.ScoresStorage {
|
|
|
3928
3930
|
} catch (error$1) {
|
|
3929
3931
|
throw new error.MastraError(
|
|
3930
3932
|
{
|
|
3931
|
-
id: "
|
|
3933
|
+
id: storage.createStorageErrorId("PG", "GET_SCORES_BY_SPAN", "FAILED"),
|
|
3932
3934
|
domain: error.ErrorDomain.STORAGE,
|
|
3933
3935
|
category: error.ErrorCategory.THIRD_PARTY
|
|
3934
3936
|
},
|
|
@@ -4003,7 +4005,7 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
4003
4005
|
} catch (error$1) {
|
|
4004
4006
|
throw new error.MastraError(
|
|
4005
4007
|
{
|
|
4006
|
-
id: "
|
|
4008
|
+
id: storage.createStorageErrorId("PG", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
4007
4009
|
domain: error.ErrorDomain.STORAGE,
|
|
4008
4010
|
category: error.ErrorCategory.THIRD_PARTY
|
|
4009
4011
|
},
|
|
@@ -4024,7 +4026,7 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
4024
4026
|
} catch (error$1) {
|
|
4025
4027
|
throw new error.MastraError(
|
|
4026
4028
|
{
|
|
4027
|
-
id: "
|
|
4029
|
+
id: storage.createStorageErrorId("PG", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
4028
4030
|
domain: error.ErrorDomain.STORAGE,
|
|
4029
4031
|
category: error.ErrorCategory.THIRD_PARTY
|
|
4030
4032
|
},
|
|
@@ -4065,7 +4067,7 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
4065
4067
|
} catch (error$1) {
|
|
4066
4068
|
throw new error.MastraError(
|
|
4067
4069
|
{
|
|
4068
|
-
id: "
|
|
4070
|
+
id: storage.createStorageErrorId("PG", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
4069
4071
|
domain: error.ErrorDomain.STORAGE,
|
|
4070
4072
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
4071
4073
|
details: {
|
|
@@ -4147,7 +4149,7 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
4147
4149
|
} catch (error$1) {
|
|
4148
4150
|
throw new error.MastraError(
|
|
4149
4151
|
{
|
|
4150
|
-
id: "
|
|
4152
|
+
id: storage.createStorageErrorId("PG", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
4151
4153
|
domain: error.ErrorDomain.STORAGE,
|
|
4152
4154
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
4153
4155
|
details: {
|
|
@@ -4164,17 +4166,17 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
|
|
|
4164
4166
|
var PostgresStore = class extends storage.MastraStorage {
|
|
4165
4167
|
#db;
|
|
4166
4168
|
#pgp;
|
|
4167
|
-
#config;
|
|
4168
4169
|
schema;
|
|
4169
|
-
|
|
4170
|
+
isInitialized = false;
|
|
4170
4171
|
stores;
|
|
4171
4172
|
constructor(config) {
|
|
4172
4173
|
try {
|
|
4173
4174
|
validateConfig("PostgresStore", config);
|
|
4174
|
-
super({ id: config.id, name: "PostgresStore" });
|
|
4175
|
+
super({ id: config.id, name: "PostgresStore", disableInit: config.disableInit });
|
|
4175
4176
|
this.schema = config.schemaName || "public";
|
|
4177
|
+
let pgConfig;
|
|
4176
4178
|
if (isConnectionStringConfig(config)) {
|
|
4177
|
-
|
|
4179
|
+
pgConfig = {
|
|
4178
4180
|
id: config.id,
|
|
4179
4181
|
connectionString: config.connectionString,
|
|
4180
4182
|
max: config.max,
|
|
@@ -4182,14 +4184,14 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4182
4184
|
ssl: config.ssl
|
|
4183
4185
|
};
|
|
4184
4186
|
} else if (isCloudSqlConfig(config)) {
|
|
4185
|
-
|
|
4187
|
+
pgConfig = {
|
|
4186
4188
|
...config,
|
|
4187
4189
|
id: config.id,
|
|
4188
4190
|
max: config.max,
|
|
4189
4191
|
idleTimeoutMillis: config.idleTimeoutMillis
|
|
4190
4192
|
};
|
|
4191
4193
|
} else if (isHostConfig(config)) {
|
|
4192
|
-
|
|
4194
|
+
pgConfig = {
|
|
4193
4195
|
id: config.id,
|
|
4194
4196
|
host: config.host,
|
|
4195
4197
|
port: config.port,
|
|
@@ -4205,11 +4207,24 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4205
4207
|
"PostgresStore: invalid config. Provide either {connectionString}, {host,port,database,user,password}, or a pg ClientConfig (e.g., Cloud SQL connector with `stream`)."
|
|
4206
4208
|
);
|
|
4207
4209
|
}
|
|
4208
|
-
this
|
|
4210
|
+
this.#pgp = pgPromise__default.default();
|
|
4211
|
+
this.#db = this.#pgp(pgConfig);
|
|
4212
|
+
const operations = new StoreOperationsPG({ client: this.#db, schemaName: this.schema });
|
|
4213
|
+
const scores = new ScoresPG({ client: this.#db, operations, schema: this.schema });
|
|
4214
|
+
const workflows = new WorkflowsPG({ client: this.#db, operations, schema: this.schema });
|
|
4215
|
+
const memory = new MemoryPG({ client: this.#db, schema: this.schema, operations });
|
|
4216
|
+
const observability = new ObservabilityPG({ client: this.#db, operations, schema: this.schema });
|
|
4217
|
+
this.stores = {
|
|
4218
|
+
operations,
|
|
4219
|
+
scores,
|
|
4220
|
+
workflows,
|
|
4221
|
+
memory,
|
|
4222
|
+
observability
|
|
4223
|
+
};
|
|
4209
4224
|
} catch (e) {
|
|
4210
4225
|
throw new error.MastraError(
|
|
4211
4226
|
{
|
|
4212
|
-
id: "
|
|
4227
|
+
id: storage.createStorageErrorId("PG", "INITIALIZATION", "FAILED"),
|
|
4213
4228
|
domain: error.ErrorDomain.STORAGE,
|
|
4214
4229
|
category: error.ErrorCategory.USER
|
|
4215
4230
|
},
|
|
@@ -4218,36 +4233,22 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4218
4233
|
}
|
|
4219
4234
|
}
|
|
4220
4235
|
async init() {
|
|
4221
|
-
if (this.
|
|
4236
|
+
if (this.isInitialized) {
|
|
4222
4237
|
return;
|
|
4223
4238
|
}
|
|
4224
4239
|
try {
|
|
4225
|
-
this.
|
|
4226
|
-
this.#pgp = pgPromise__default.default();
|
|
4227
|
-
this.#db = this.#pgp(this.#config);
|
|
4228
|
-
const operations = new StoreOperationsPG({ client: this.#db, schemaName: this.schema });
|
|
4229
|
-
const scores = new ScoresPG({ client: this.#db, operations, schema: this.schema });
|
|
4230
|
-
const workflows = new WorkflowsPG({ client: this.#db, operations, schema: this.schema });
|
|
4231
|
-
const memory = new MemoryPG({ client: this.#db, schema: this.schema, operations });
|
|
4232
|
-
const observability = new ObservabilityPG({ client: this.#db, operations, schema: this.schema });
|
|
4233
|
-
this.stores = {
|
|
4234
|
-
operations,
|
|
4235
|
-
scores,
|
|
4236
|
-
workflows,
|
|
4237
|
-
memory,
|
|
4238
|
-
observability
|
|
4239
|
-
};
|
|
4240
|
+
this.isInitialized = true;
|
|
4240
4241
|
await super.init();
|
|
4241
4242
|
try {
|
|
4242
|
-
await operations.createAutomaticIndexes();
|
|
4243
|
+
await this.stores.operations.createAutomaticIndexes();
|
|
4243
4244
|
} catch (indexError) {
|
|
4244
4245
|
console.warn("Failed to create indexes:", indexError);
|
|
4245
4246
|
}
|
|
4246
4247
|
} catch (error$1) {
|
|
4247
|
-
this.
|
|
4248
|
+
this.isInitialized = false;
|
|
4248
4249
|
throw new error.MastraError(
|
|
4249
4250
|
{
|
|
4250
|
-
id: "
|
|
4251
|
+
id: storage.createStorageErrorId("PG", "INIT", "FAILED"),
|
|
4251
4252
|
domain: error.ErrorDomain.STORAGE,
|
|
4252
4253
|
category: error.ErrorCategory.THIRD_PARTY
|
|
4253
4254
|
},
|
|
@@ -4256,15 +4257,9 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4256
4257
|
}
|
|
4257
4258
|
}
|
|
4258
4259
|
get db() {
|
|
4259
|
-
if (!this.#db) {
|
|
4260
|
-
throw new Error(`PostgresStore: Store is not initialized, please call "init()" first.`);
|
|
4261
|
-
}
|
|
4262
4260
|
return this.#db;
|
|
4263
4261
|
}
|
|
4264
4262
|
get pgp() {
|
|
4265
|
-
if (!this.#pgp) {
|
|
4266
|
-
throw new Error(`PostgresStore: Store is not initialized, please call "init()" first.`);
|
|
4267
|
-
}
|
|
4268
4263
|
return this.#pgp;
|
|
4269
4264
|
}
|
|
4270
4265
|
get supports() {
|
|
@@ -4404,7 +4399,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4404
4399
|
async createSpan(span) {
|
|
4405
4400
|
if (!this.stores.observability) {
|
|
4406
4401
|
throw new error.MastraError({
|
|
4407
|
-
id: "
|
|
4402
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4408
4403
|
domain: error.ErrorDomain.STORAGE,
|
|
4409
4404
|
category: error.ErrorCategory.SYSTEM,
|
|
4410
4405
|
text: "Observability storage is not initialized"
|
|
@@ -4419,7 +4414,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4419
4414
|
}) {
|
|
4420
4415
|
if (!this.stores.observability) {
|
|
4421
4416
|
throw new error.MastraError({
|
|
4422
|
-
id: "
|
|
4417
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4423
4418
|
domain: error.ErrorDomain.STORAGE,
|
|
4424
4419
|
category: error.ErrorCategory.SYSTEM,
|
|
4425
4420
|
text: "Observability storage is not initialized"
|
|
@@ -4430,7 +4425,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4430
4425
|
async getTrace(traceId) {
|
|
4431
4426
|
if (!this.stores.observability) {
|
|
4432
4427
|
throw new error.MastraError({
|
|
4433
|
-
id: "
|
|
4428
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4434
4429
|
domain: error.ErrorDomain.STORAGE,
|
|
4435
4430
|
category: error.ErrorCategory.SYSTEM,
|
|
4436
4431
|
text: "Observability storage is not initialized"
|
|
@@ -4441,7 +4436,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4441
4436
|
async getTracesPaginated(args) {
|
|
4442
4437
|
if (!this.stores.observability) {
|
|
4443
4438
|
throw new error.MastraError({
|
|
4444
|
-
id: "
|
|
4439
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4445
4440
|
domain: error.ErrorDomain.STORAGE,
|
|
4446
4441
|
category: error.ErrorCategory.SYSTEM,
|
|
4447
4442
|
text: "Observability storage is not initialized"
|
|
@@ -4452,7 +4447,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4452
4447
|
async batchCreateSpans(args) {
|
|
4453
4448
|
if (!this.stores.observability) {
|
|
4454
4449
|
throw new error.MastraError({
|
|
4455
|
-
id: "
|
|
4450
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4456
4451
|
domain: error.ErrorDomain.STORAGE,
|
|
4457
4452
|
category: error.ErrorCategory.SYSTEM,
|
|
4458
4453
|
text: "Observability storage is not initialized"
|
|
@@ -4463,7 +4458,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4463
4458
|
async batchUpdateSpans(args) {
|
|
4464
4459
|
if (!this.stores.observability) {
|
|
4465
4460
|
throw new error.MastraError({
|
|
4466
|
-
id: "
|
|
4461
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4467
4462
|
domain: error.ErrorDomain.STORAGE,
|
|
4468
4463
|
category: error.ErrorCategory.SYSTEM,
|
|
4469
4464
|
text: "Observability storage is not initialized"
|
|
@@ -4474,7 +4469,7 @@ var PostgresStore = class extends storage.MastraStorage {
|
|
|
4474
4469
|
async batchDeleteTraces(args) {
|
|
4475
4470
|
if (!this.stores.observability) {
|
|
4476
4471
|
throw new error.MastraError({
|
|
4477
|
-
id: "
|
|
4472
|
+
id: storage.createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
4478
4473
|
domain: error.ErrorDomain.STORAGE,
|
|
4479
4474
|
category: error.ErrorCategory.SYSTEM,
|
|
4480
4475
|
text: "Observability storage is not initialized"
|