@mastra/pg 1.0.0-beta.6 → 1.0.0-beta.8

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 CHANGED
@@ -1,5 +1,77 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.0.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Preserve error details when thrown from workflow steps ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
8
+
9
+ Workflow errors now retain custom properties like `statusCode`, `responseHeaders`, and `cause` chains. This enables error-specific recovery logic in your applications.
10
+
11
+ **Before:**
12
+
13
+ ```typescript
14
+ const result = await workflow.execute({ input });
15
+ if (result.status === 'failed') {
16
+ // Custom error properties were lost
17
+ console.log(result.error); // "Step execution failed" (just a string)
18
+ }
19
+ ```
20
+
21
+ **After:**
22
+
23
+ ```typescript
24
+ const result = await workflow.execute({ input });
25
+ if (result.status === 'failed') {
26
+ // Custom properties are preserved
27
+ console.log(result.error.message); // "Step execution failed"
28
+ console.log(result.error.statusCode); // 429
29
+ console.log(result.error.cause?.name); // "RateLimitError"
30
+ }
31
+ ```
32
+
33
+ **Type change:** `WorkflowState.error` and `WorkflowRunState.error` types changed from `string | Error` to `SerializedError`.
34
+
35
+ Other changes:
36
+ - Added `UpdateWorkflowStateOptions` type for workflow state updates
37
+
38
+ - fix: make getSqlType consistent across storage adapters ([#11112](https://github.com/mastra-ai/mastra/pull/11112))
39
+ - PostgreSQL: use `getSqlType()` in `createTable` instead of `toUpperCase()`
40
+ - LibSQL: use `getSqlType()` in `createTable`, return `JSONB` for jsonb type (matches SQLite 3.45+ support)
41
+ - ClickHouse: use `getSqlType()` in `createTable` instead of `COLUMN_TYPES` constant, add missing types (uuid, float, boolean)
42
+ - Remove unused `getSqlType()` and `getDefaultValue()` from `MastraStorage` base class (all stores use `StoreOperations` versions)
43
+
44
+ - Updated dependencies [[`d5ed981`](https://github.com/mastra-ai/mastra/commit/d5ed981c8701c1b8a27a5f35a9a2f7d9244e695f), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd), [`b760b73`](https://github.com/mastra-ai/mastra/commit/b760b731aca7c8a3f041f61d57a7f125ae9cb215), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`2b459f4`](https://github.com/mastra-ai/mastra/commit/2b459f466fd91688eeb2a44801dc23f7f8a887ab), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`24b76d8`](https://github.com/mastra-ai/mastra/commit/24b76d8e17656269c8ed09a0c038adb9cc2ae95a), [`243a823`](https://github.com/mastra-ai/mastra/commit/243a8239c5906f5c94e4f78b54676793f7510ae3), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`c61fac3`](https://github.com/mastra-ai/mastra/commit/c61fac3add96f0dcce0208c07415279e2537eb62), [`6f14f70`](https://github.com/mastra-ai/mastra/commit/6f14f706ccaaf81b69544b6c1b75ab66a41e5317), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f), [`2a53598`](https://github.com/mastra-ai/mastra/commit/2a53598c6d8cfeb904a7fc74e57e526d751c8fa6), [`c7cd3c7`](https://github.com/mastra-ai/mastra/commit/c7cd3c7a187d7aaf79e2ca139de328bf609a14b4), [`847c212`](https://github.com/mastra-ai/mastra/commit/847c212caba7df0d6f2fc756b494ac3c75c3720d), [`6f941c4`](https://github.com/mastra-ai/mastra/commit/6f941c438ca5f578619788acc7608fc2e23bd176)]:
45
+ - @mastra/core@1.0.0-beta.12
46
+
47
+ ## 1.0.0-beta.7
48
+
49
+ ### Patch Changes
50
+
51
+ - Add delete workflow run API ([#10991](https://github.com/mastra-ai/mastra/pull/10991))
52
+
53
+ ```typescript
54
+ await workflow.deleteWorkflowRunById(runId);
55
+ ```
56
+
57
+ - Add halfvec type support for large dimension embeddings ([#11002](https://github.com/mastra-ai/mastra/pull/11002))
58
+
59
+ Adds `vectorType` option to `createIndex()` for choosing between full precision (`vector`) and half precision (`halfvec`) storage. halfvec uses 2 bytes per dimension instead of 4, enabling indexes on embeddings up to 4000 dimensions.
60
+
61
+ ```typescript
62
+ await pgVector.createIndex({
63
+ indexName: 'large-embeddings',
64
+ dimension: 3072, // text-embedding-3-large
65
+ metric: 'cosine',
66
+ vectorType: 'halfvec',
67
+ });
68
+ ```
69
+
70
+ Requires pgvector >= 0.7.0 for halfvec support. Docker compose files updated to use pgvector 0.8.0.
71
+
72
+ - Updated dependencies [[`edb07e4`](https://github.com/mastra-ai/mastra/commit/edb07e49283e0c28bd094a60e03439bf6ecf0221), [`b7e17d3`](https://github.com/mastra-ai/mastra/commit/b7e17d3f5390bb5a71efc112204413656fcdc18d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`5d7000f`](https://github.com/mastra-ai/mastra/commit/5d7000f757cd65ea9dc5b05e662fd83dfd44e932), [`4f0331a`](https://github.com/mastra-ai/mastra/commit/4f0331a79bf6eb5ee598a5086e55de4b5a0ada03), [`8a000da`](https://github.com/mastra-ai/mastra/commit/8a000da0c09c679a2312f6b3aa05b2ca78ca7393)]:
73
+ - @mastra/core@1.0.0-beta.10
74
+
3
75
  ## 1.0.0-beta.6
4
76
 
5
77
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -506,12 +506,14 @@ var PgVector = class extends vector.MastraVector {
506
506
  pool;
507
507
  describeIndexCache = /* @__PURE__ */ new Map();
508
508
  createdIndexes = /* @__PURE__ */ new Map();
509
+ indexVectorTypes = /* @__PURE__ */ new Map();
509
510
  mutexesByName = /* @__PURE__ */ new Map();
510
511
  schema;
511
512
  setupSchemaPromise = null;
512
513
  installVectorExtensionPromise = null;
513
514
  vectorExtensionInstalled = void 0;
514
515
  vectorExtensionSchema = null;
516
+ vectorExtensionVersion = null;
515
517
  schemaSetupComplete = void 0;
516
518
  cacheWarmupPromise = null;
517
519
  constructor(config) {
@@ -564,9 +566,11 @@ var PgVector = class extends vector.MastraVector {
564
566
  indexName,
565
567
  metric: info.metric,
566
568
  dimension: info.dimension,
567
- type: info.type
569
+ type: info.type,
570
+ vectorType: info.vectorType
568
571
  });
569
572
  this.createdIndexes.set(indexName, key);
573
+ this.indexVectorTypes.set(indexName, info.vectorType);
570
574
  })
571
575
  );
572
576
  } catch (error) {
@@ -592,12 +596,12 @@ var PgVector = class extends vector.MastraVector {
592
596
  return this.mutexesByName.get(indexName);
593
597
  }
594
598
  /**
595
- * Detects which schema contains the vector extension
599
+ * Detects which schema contains the vector extension and its version
596
600
  */
597
601
  async detectVectorExtensionSchema(client) {
598
602
  try {
599
603
  const result = await client.query(`
600
- SELECT n.nspname as schema_name
604
+ SELECT n.nspname as schema_name, e.extversion as version
601
605
  FROM pg_extension e
602
606
  JOIN pg_namespace n ON e.extnamespace = n.oid
603
607
  WHERE e.extname = 'vector'
@@ -605,7 +609,11 @@ var PgVector = class extends vector.MastraVector {
605
609
  `);
606
610
  if (result.rows.length > 0) {
607
611
  this.vectorExtensionSchema = result.rows[0].schema_name;
608
- this.logger.debug("Vector extension found in schema", { schema: this.vectorExtensionSchema });
612
+ this.vectorExtensionVersion = result.rows[0].version;
613
+ this.logger.debug("Vector extension found", {
614
+ schema: this.vectorExtensionSchema,
615
+ version: this.vectorExtensionVersion
616
+ });
609
617
  return this.vectorExtensionSchema;
610
618
  }
611
619
  return null;
@@ -614,18 +622,52 @@ var PgVector = class extends vector.MastraVector {
614
622
  return null;
615
623
  }
616
624
  }
625
+ /**
626
+ * Checks if the installed pgvector version supports halfvec type.
627
+ * halfvec was introduced in pgvector 0.7.0.
628
+ */
629
+ supportsHalfvec() {
630
+ if (!this.vectorExtensionVersion) {
631
+ return false;
632
+ }
633
+ const parts = this.vectorExtensionVersion.split(".");
634
+ const major = parseInt(parts[0] ?? "", 10);
635
+ const minor = parseInt(parts[1] ?? "", 10);
636
+ if (isNaN(major) || isNaN(minor)) {
637
+ return false;
638
+ }
639
+ return major > 0 || major === 0 && minor >= 7;
640
+ }
617
641
  /**
618
642
  * Gets the properly qualified vector type name
643
+ * @param vectorType - The type of vector storage ('vector' or 'halfvec')
619
644
  */
620
- getVectorTypeName() {
645
+ getVectorTypeName(vectorType = "vector") {
621
646
  if (this.vectorExtensionSchema) {
622
647
  if (this.vectorExtensionSchema === "pg_catalog") {
623
- return "vector";
648
+ return vectorType;
624
649
  }
625
650
  const validatedSchema = utils.parseSqlIdentifier(this.vectorExtensionSchema, "vector extension schema");
626
- return `${validatedSchema}.vector`;
651
+ return `${validatedSchema}.${vectorType}`;
652
+ }
653
+ return vectorType;
654
+ }
655
+ /**
656
+ * Gets the operator class for index creation based on metric and vector type.
657
+ * pgvector uses different operator classes for vector vs halfvec types.
658
+ */
659
+ getMetricOperatorClass(metric, vectorType) {
660
+ const prefix = vectorType === "halfvec" ? "halfvec" : "vector";
661
+ switch (metric) {
662
+ case "cosine":
663
+ return `${prefix}_cosine_ops`;
664
+ case "euclidean":
665
+ return `${prefix}_l2_ops`;
666
+ case "dotproduct":
667
+ return `${prefix}_ip_ops`;
668
+ default:
669
+ return `${prefix}_cosine_ops`;
627
670
  }
628
- return "vector";
629
671
  }
630
672
  getTableName(indexName) {
631
673
  const parsedIndexName = utils.parseSqlIdentifier(indexName, "index name");
@@ -698,12 +740,12 @@ var PgVector = class extends vector.MastraVector {
698
740
  await client.query(`SET LOCAL ivfflat.probes = ${probes}`);
699
741
  }
700
742
  const { tableName } = this.getTableName(indexName);
701
- const vectorType = this.getVectorTypeName();
743
+ const qualifiedVectorType = this.getVectorTypeName(indexInfo.vectorType);
702
744
  const query = `
703
745
  WITH vector_scores AS (
704
746
  SELECT
705
747
  vector_id as id,
706
- 1 - (embedding <=> '${vectorStr}'::${vectorType}) as score,
748
+ 1 - (embedding <=> '${vectorStr}'::${qualifiedVectorType}) as score,
707
749
  metadata
708
750
  ${includeVector ? ", embedding" : ""}
709
751
  FROM ${tableName}
@@ -767,14 +809,15 @@ var PgVector = class extends vector.MastraVector {
767
809
  }
768
810
  }
769
811
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
770
- const vectorType = this.getVectorTypeName();
812
+ const indexInfo = await this.getIndexInfo({ indexName });
813
+ const qualifiedVectorType = this.getVectorTypeName(indexInfo.vectorType);
771
814
  for (let i = 0; i < vectors.length; i++) {
772
815
  const query = `
773
816
  INSERT INTO ${tableName} (vector_id, embedding, metadata)
774
- VALUES ($1, $2::${vectorType}, $3::jsonb)
817
+ VALUES ($1, $2::${qualifiedVectorType}, $3::jsonb)
775
818
  ON CONFLICT (vector_id)
776
819
  DO UPDATE SET
777
- embedding = $2::${vectorType},
820
+ embedding = $2::${qualifiedVectorType},
778
821
  metadata = $3::jsonb
779
822
  RETURNING embedding::text
780
823
  `;
@@ -833,9 +876,10 @@ var PgVector = class extends vector.MastraVector {
833
876
  indexName,
834
877
  dimension,
835
878
  metric,
836
- type
879
+ type,
880
+ vectorType = "vector"
837
881
  }) {
838
- const input = indexName + dimension + metric + (type || "ivfflat");
882
+ const input = indexName + dimension + metric + (type || "ivfflat") + vectorType;
839
883
  return (await this.hasher).h32(input);
840
884
  }
841
885
  cachedIndexExists(indexName, newKey) {
@@ -888,7 +932,8 @@ var PgVector = class extends vector.MastraVector {
888
932
  dimension,
889
933
  metric = "cosine",
890
934
  indexConfig = {},
891
- buildIndex = true
935
+ buildIndex = true,
936
+ vectorType = "vector"
892
937
  }) {
893
938
  const { tableName } = this.getTableName(indexName);
894
939
  try {
@@ -898,6 +943,9 @@ var PgVector = class extends vector.MastraVector {
898
943
  if (!Number.isInteger(dimension) || dimension <= 0) {
899
944
  throw new Error("Dimension must be a positive integer");
900
945
  }
946
+ if (vectorType !== "vector" && vectorType !== "halfvec") {
947
+ throw new Error('vectorType must be "vector" or "halfvec"');
948
+ }
901
949
  } catch (error$1) {
902
950
  const mastraError = new error.MastraError(
903
951
  {
@@ -913,7 +961,13 @@ var PgVector = class extends vector.MastraVector {
913
961
  this.logger?.trackException(mastraError);
914
962
  throw mastraError;
915
963
  }
916
- const indexCacheKey = await this.getIndexCacheKey({ indexName, dimension, type: indexConfig.type, metric });
964
+ const indexCacheKey = await this.getIndexCacheKey({
965
+ indexName,
966
+ dimension,
967
+ type: indexConfig.type,
968
+ metric,
969
+ vectorType
970
+ });
917
971
  if (this.cachedIndexExists(indexName, indexCacheKey)) {
918
972
  return;
919
973
  }
@@ -926,24 +980,40 @@ var PgVector = class extends vector.MastraVector {
926
980
  try {
927
981
  await this.setupSchema(client);
928
982
  await this.installVectorExtension(client);
983
+ if (vectorType === "halfvec" && !this.supportsHalfvec()) {
984
+ throw new error.MastraError({
985
+ id: storage.createVectorErrorId("PG", "CREATE_INDEX", "HALFVEC_NOT_SUPPORTED"),
986
+ text: `halfvec type requires pgvector >= 0.7.0, but version ${this.vectorExtensionVersion || "unknown"} is installed. Either upgrade pgvector or use vectorType: 'vector' (which supports up to 2000 dimensions for indexes).`,
987
+ domain: error.ErrorDomain.MASTRA_VECTOR,
988
+ category: error.ErrorCategory.USER,
989
+ details: {
990
+ indexName,
991
+ requestedVectorType: vectorType,
992
+ pgvectorVersion: this.vectorExtensionVersion || "unknown",
993
+ requiredVersion: "0.7.0"
994
+ }
995
+ });
996
+ }
929
997
  if (this.schema && this.vectorExtensionSchema && this.schema !== this.vectorExtensionSchema && this.vectorExtensionSchema !== "pg_catalog") {
930
998
  await client.query(`SET search_path TO ${this.getSchemaName()}, "${this.vectorExtensionSchema}"`);
931
999
  }
932
- const vectorType = this.getVectorTypeName();
1000
+ const qualifiedVectorType = this.getVectorTypeName(vectorType);
933
1001
  await client.query(`
934
1002
  CREATE TABLE IF NOT EXISTS ${tableName} (
935
1003
  id SERIAL PRIMARY KEY,
936
1004
  vector_id TEXT UNIQUE NOT NULL,
937
- embedding ${vectorType}(${dimension}),
1005
+ embedding ${qualifiedVectorType}(${dimension}),
938
1006
  metadata JSONB DEFAULT '{}'::jsonb
939
1007
  );
940
1008
  `);
941
1009
  this.createdIndexes.set(indexName, indexCacheKey);
1010
+ this.indexVectorTypes.set(indexName, vectorType);
942
1011
  if (buildIndex) {
943
- await this.setupIndex({ indexName, metric, indexConfig }, client);
1012
+ await this.setupIndex({ indexName, metric, indexConfig, vectorType }, client);
944
1013
  }
945
1014
  } catch (error) {
946
1015
  this.createdIndexes.delete(indexName);
1016
+ this.indexVectorTypes.delete(indexName);
947
1017
  throw error;
948
1018
  } finally {
949
1019
  client.release();
@@ -986,7 +1056,7 @@ var PgVector = class extends vector.MastraVector {
986
1056
  client.release();
987
1057
  }
988
1058
  }
989
- async setupIndex({ indexName, metric, indexConfig }, client) {
1059
+ async setupIndex({ indexName, metric, indexConfig, vectorType = "vector" }, client) {
990
1060
  const mutex = this.getMutexByName(`build-${indexName}`);
991
1061
  await mutex.runExclusive(async () => {
992
1062
  const isConfigEmpty = !indexConfig || Object.keys(indexConfig).length === 0 || !indexConfig.type && !indexConfig.ivf && !indexConfig.hnsw;
@@ -1008,9 +1078,11 @@ var PgVector = class extends vector.MastraVector {
1008
1078
  indexName,
1009
1079
  dimension,
1010
1080
  type: existingIndexInfo.type,
1011
- metric: existingIndexInfo.metric
1081
+ metric: existingIndexInfo.metric,
1082
+ vectorType: existingIndexInfo.vectorType
1012
1083
  });
1013
1084
  this.createdIndexes.set(indexName, cacheKey);
1085
+ this.indexVectorTypes.set(indexName, existingIndexInfo.vectorType);
1014
1086
  return;
1015
1087
  }
1016
1088
  }
@@ -1028,9 +1100,11 @@ var PgVector = class extends vector.MastraVector {
1028
1100
  indexName,
1029
1101
  dimension,
1030
1102
  type: existingIndexInfo.type,
1031
- metric: existingIndexInfo.metric
1103
+ metric: existingIndexInfo.metric,
1104
+ vectorType: existingIndexInfo.vectorType
1032
1105
  });
1033
1106
  this.createdIndexes.set(indexName, cacheKey);
1107
+ this.indexVectorTypes.set(indexName, existingIndexInfo.vectorType);
1034
1108
  return;
1035
1109
  }
1036
1110
  this.logger?.info(`Index ${vectorIndexName} configuration changed, rebuilding index`);
@@ -1043,7 +1117,8 @@ var PgVector = class extends vector.MastraVector {
1043
1117
  this.describeIndexCache.delete(indexName);
1044
1118
  return;
1045
1119
  }
1046
- const metricOp = metric === "cosine" ? "vector_cosine_ops" : metric === "euclidean" ? "vector_l2_ops" : "vector_ip_ops";
1120
+ const effectiveVectorType = existingIndexInfo?.vectorType ?? vectorType;
1121
+ const metricOp = this.getMetricOperatorClass(metric, effectiveVectorType);
1047
1122
  let indexSQL;
1048
1123
  if (indexType === "hnsw") {
1049
1124
  const m = indexConfig.hnsw?.m ?? 8;
@@ -1093,6 +1168,12 @@ var PgVector = class extends vector.MastraVector {
1093
1168
  if (this.schema && this.schema !== "public") {
1094
1169
  try {
1095
1170
  await client.query(`CREATE EXTENSION IF NOT EXISTS vector SCHEMA ${this.getSchemaName()}`);
1171
+ const installedSchema2 = await this.detectVectorExtensionSchema(client);
1172
+ if (installedSchema2) {
1173
+ this.vectorExtensionInstalled = true;
1174
+ this.logger.info(`Vector extension installed in schema: ${installedSchema2}`);
1175
+ return;
1176
+ }
1096
1177
  this.vectorExtensionInstalled = true;
1097
1178
  this.vectorExtensionSchema = this.schema;
1098
1179
  this.logger.info(`Vector extension installed in schema: ${this.schema}`);
@@ -1155,7 +1236,7 @@ var PgVector = class extends vector.MastraVector {
1155
1236
  WHERE c.table_schema = t.table_schema
1156
1237
  AND c.table_name = t.table_name
1157
1238
  AND c.column_name = 'embedding'
1158
- AND c.udt_name = 'vector'
1239
+ AND c.udt_name IN ('vector', 'halfvec')
1159
1240
  )
1160
1241
  AND EXISTS (
1161
1242
  SELECT 1
@@ -1194,17 +1275,18 @@ var PgVector = class extends vector.MastraVector {
1194
1275
  try {
1195
1276
  const { tableName } = this.getTableName(indexName);
1196
1277
  const tableExistsQuery = `
1197
- SELECT 1
1278
+ SELECT udt_name
1198
1279
  FROM information_schema.columns
1199
1280
  WHERE table_schema = $1
1200
1281
  AND table_name = $2
1201
- AND udt_name = 'vector'
1282
+ AND udt_name IN ('vector', 'halfvec')
1202
1283
  LIMIT 1;
1203
1284
  `;
1204
1285
  const tableExists = await client.query(tableExistsQuery, [this.schema || "public", indexName]);
1205
1286
  if (tableExists.rows.length === 0) {
1206
1287
  throw new Error(`Vector table ${tableName} does not exist`);
1207
1288
  }
1289
+ const vectorType = tableExists.rows[0].udt_name === "halfvec" ? "halfvec" : "vector";
1208
1290
  const dimensionQuery = `
1209
1291
  SELECT atttypmod as dimension
1210
1292
  FROM pg_attribute
@@ -1254,6 +1336,7 @@ var PgVector = class extends vector.MastraVector {
1254
1336
  count: parseInt(countResult.rows[0].count),
1255
1337
  metric,
1256
1338
  type: index_method,
1339
+ vectorType,
1257
1340
  config
1258
1341
  };
1259
1342
  } catch (e) {
@@ -1281,6 +1364,8 @@ var PgVector = class extends vector.MastraVector {
1281
1364
  const { tableName } = this.getTableName(indexName);
1282
1365
  await client.query(`DROP TABLE IF EXISTS ${tableName} CASCADE`);
1283
1366
  this.createdIndexes.delete(indexName);
1367
+ this.indexVectorTypes.delete(indexName);
1368
+ this.describeIndexCache.delete(indexName);
1284
1369
  } catch (error$1) {
1285
1370
  await client.query("ROLLBACK");
1286
1371
  const mastraError = new error.MastraError(
@@ -1369,12 +1454,13 @@ var PgVector = class extends vector.MastraVector {
1369
1454
  }
1370
1455
  client = await this.pool.connect();
1371
1456
  const { tableName } = this.getTableName(indexName);
1372
- const vectorType = this.getVectorTypeName();
1457
+ const indexInfo = await this.getIndexInfo({ indexName });
1458
+ const qualifiedVectorType = this.getVectorTypeName(indexInfo.vectorType);
1373
1459
  let updateParts = [];
1374
1460
  let values = [];
1375
1461
  let valueIndex = 1;
1376
1462
  if (update.vector) {
1377
- updateParts.push(`embedding = $${valueIndex}::${vectorType}`);
1463
+ updateParts.push(`embedding = $${valueIndex}::${qualifiedVectorType}`);
1378
1464
  values.push(`[${update.vector.join(",")}]`);
1379
1465
  valueIndex++;
1380
1466
  }
@@ -3265,7 +3351,7 @@ var StoreOperationsPG = class extends storage.StoreOperations {
3265
3351
  const constraints = [];
3266
3352
  if (def.primaryKey) constraints.push("PRIMARY KEY");
3267
3353
  if (!def.nullable) constraints.push("NOT NULL");
3268
- return `"${parsedName}" ${def.type.toUpperCase()} ${constraints.join(" ")}`;
3354
+ return `"${parsedName}" ${this.getSqlType(def.type)} ${constraints.join(" ")}`;
3269
3355
  });
3270
3356
  if (this.schemaName) {
3271
3357
  await this.setupSchema();
@@ -4374,6 +4460,27 @@ var WorkflowsPG = class extends storage.WorkflowsStorage {
4374
4460
  );
4375
4461
  }
4376
4462
  }
4463
+ async deleteWorkflowRunById({ runId, workflowName }) {
4464
+ try {
4465
+ await this.client.none(
4466
+ `DELETE FROM ${getTableName({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: this.schema })} WHERE run_id = $1 AND workflow_name = $2`,
4467
+ [runId, workflowName]
4468
+ );
4469
+ } catch (error$1) {
4470
+ throw new error.MastraError(
4471
+ {
4472
+ id: storage.createStorageErrorId("PG", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
4473
+ domain: error.ErrorDomain.STORAGE,
4474
+ category: error.ErrorCategory.THIRD_PARTY,
4475
+ details: {
4476
+ runId,
4477
+ workflowName
4478
+ }
4479
+ },
4480
+ error$1
4481
+ );
4482
+ }
4483
+ }
4377
4484
  async listWorkflowRuns({
4378
4485
  workflowName,
4379
4486
  fromDate,
@@ -4688,6 +4795,9 @@ var PostgresStore = class extends storage.MastraStorage {
4688
4795
  }) {
4689
4796
  return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
4690
4797
  }
4798
+ async deleteWorkflowRunById({ runId, workflowName }) {
4799
+ return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
4800
+ }
4691
4801
  async close() {
4692
4802
  this.pgp.end();
4693
4803
  }