@mastra/mysql 0.6.0 → 0.7.0-alpha.0
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 +45 -0
- package/dist/index.cjs +75 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -28
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @mastra/mysql
|
|
2
2
|
|
|
3
|
+
## 0.7.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added experiment provenance and grouping support to the LibSQL, MongoDB, MySQL, PostgreSQL, and Spanner storage adapters. These fields remain available for later grouping and filtering. ([#20645](https://github.com/mastra-ai/mastra/pull/20645))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { PostgresStore } from '@mastra/pg';
|
|
11
|
+
|
|
12
|
+
const storage = new PostgresStore({
|
|
13
|
+
id: 'postgres-storage',
|
|
14
|
+
connectionString: process.env.DATABASE_URL!,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
await dataset.startExperiment({
|
|
18
|
+
task,
|
|
19
|
+
scorers,
|
|
20
|
+
provenance: { source: 'github', sourceVersion: 'abc123' },
|
|
21
|
+
grouping: { experimentSetId: 'benchmark-1', variantId: 'candidate', trialIndex: 0 },
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Memory list reads now surface database errors instead of silently returning empty results. ([#17910](https://github.com/mastra-ai/mastra/pull/17910))
|
|
26
|
+
|
|
27
|
+
Previously, the paginated memory reads (`listThreads`, `listMessages`, `listMessagesByResourceId`, and `listMessagesById`) caught backend failures, logged them, and returned an empty payload like `{ threads: [], total: 0, hasMore: false }`. A transient outage (locked table, dropped connection) was therefore indistinguishable from a genuinely empty result, so an agent reading conversation history during a brief failure would treat it as "no history" and could overwrite real state. These methods now re-throw the failure as a `MastraError`. Validation (USER) errors and genuinely empty results are unchanged.
|
|
28
|
+
|
|
29
|
+
**Behavior change**
|
|
30
|
+
|
|
31
|
+
Callers that previously received an empty result on a backend failure will now receive a thrown `MastraError`. If you call these read methods directly (rather than through an agent, which already surfaces errors), wrap them so a transient outage doesn't crash the caller:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
try {
|
|
35
|
+
const { threads } = await storage.listThreads({ resourceId });
|
|
36
|
+
// ...use threads
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// a real backend failure. Decide whether to retry, surface, or degrade.
|
|
39
|
+
// An empty thread list no longer hides here; it only means "no threads".
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [[`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`578bf2e`](https://github.com/mastra-ai/mastra/commit/578bf2e6a88e9d5b8bf502204e15a95dfbb679ae), [`06b2d87`](https://github.com/mastra-ai/mastra/commit/06b2d87e63bcdd0ed59215c6789692b9b12de376), [`ac01d63`](https://github.com/mastra-ai/mastra/commit/ac01d6355974aec73fdb8781449ed12bac582094), [`a810a05`](https://github.com/mastra-ai/mastra/commit/a810a058f62ad407cfc1701e0be36ae91145d7cf), [`f8da216`](https://github.com/mastra-ai/mastra/commit/f8da21633e7eb0e31c9ce0fc30567870d19416d3), [`6104347`](https://github.com/mastra-ai/mastra/commit/61043473ba6bfd0a25156824e853e13165562e6c), [`45bfb88`](https://github.com/mastra-ai/mastra/commit/45bfb88fd52f1dd3be20e2a38905777c96499c90), [`e3b9307`](https://github.com/mastra-ai/mastra/commit/e3b9307098daefbfae2a52ae2ef51bc9fc701190), [`d6834c5`](https://github.com/mastra-ai/mastra/commit/d6834c5a7866b16734d23900163c2414ed70d791), [`c52d346`](https://github.com/mastra-ai/mastra/commit/c52d3462ec831a5d95926ecd3d3373f5928ad2e5), [`0023e79`](https://github.com/mastra-ai/mastra/commit/0023e7919431078280abd11c89d1edeae35fcc69), [`c2ad51e`](https://github.com/mastra-ai/mastra/commit/c2ad51e2467f901eecba8c9f4a45e22a50bd7c18), [`3dc97ea`](https://github.com/mastra-ai/mastra/commit/3dc97ea415fad353b48a13095fad1835933cc12a), [`3d01cd3`](https://github.com/mastra-ai/mastra/commit/3d01cd387321b6f9c5cac31d487c84bf51b19c78), [`7bf3086`](https://github.com/mastra-ai/mastra/commit/7bf308663f0115ca74ad20554ade740f06640859), [`a8dd139`](https://github.com/mastra-ai/mastra/commit/a8dd1391a9fe9a6632c25809ef236980afa9a020), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`2093fbd`](https://github.com/mastra-ai/mastra/commit/2093fbd53bb744bae19ec89f6d73db9a66fbe8a7), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`7b4393d`](https://github.com/mastra-ai/mastra/commit/7b4393d557411fdcf07b0e30e5acaf7cc85154ae)]:
|
|
46
|
+
- @mastra/core@1.58.0-alpha.1
|
|
47
|
+
|
|
3
48
|
## 0.6.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -2838,15 +2838,28 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
2838
2838
|
* Returns default index definitions for the experiments domain tables.
|
|
2839
2839
|
*/
|
|
2840
2840
|
static getDefaultIndexDefs(_prefix = "") {
|
|
2841
|
-
return [
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2841
|
+
return [
|
|
2842
|
+
{
|
|
2843
|
+
name: "idx_experiments_grouping",
|
|
2844
|
+
table: _mastra_core_storage.TABLE_EXPERIMENTS,
|
|
2845
|
+
columns: [
|
|
2846
|
+
"experimentSetId",
|
|
2847
|
+
"comparisonId",
|
|
2848
|
+
"variantId",
|
|
2849
|
+
"trialIndex"
|
|
2850
|
+
]
|
|
2851
|
+
},
|
|
2852
|
+
{
|
|
2853
|
+
name: "idx_experiments_org_project",
|
|
2854
|
+
table: _mastra_core_storage.TABLE_EXPERIMENTS,
|
|
2855
|
+
columns: ["organizationId", "projectId"]
|
|
2856
|
+
},
|
|
2857
|
+
{
|
|
2858
|
+
name: "idx_experiment_results_org_project",
|
|
2859
|
+
table: _mastra_core_storage.TABLE_EXPERIMENT_RESULTS,
|
|
2860
|
+
columns: ["organizationId", "projectId"]
|
|
2861
|
+
}
|
|
2862
|
+
];
|
|
2850
2863
|
}
|
|
2851
2864
|
/**
|
|
2852
2865
|
* Exports DDL statements for all managed tables.
|
|
@@ -2902,7 +2915,13 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
2902
2915
|
ifNotExists: [
|
|
2903
2916
|
"agentVersion",
|
|
2904
2917
|
"organizationId",
|
|
2905
|
-
"projectId"
|
|
2918
|
+
"projectId",
|
|
2919
|
+
"provenance",
|
|
2920
|
+
"runnerAttestation",
|
|
2921
|
+
"experimentSetId",
|
|
2922
|
+
"comparisonId",
|
|
2923
|
+
"variantId",
|
|
2924
|
+
"trialIndex"
|
|
2906
2925
|
]
|
|
2907
2926
|
});
|
|
2908
2927
|
await this.operations.alterTable({
|
|
@@ -2934,6 +2953,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
2934
2953
|
name: row.name ?? void 0,
|
|
2935
2954
|
description: row.description ?? void 0,
|
|
2936
2955
|
metadata: parseJSON$2(row.metadata),
|
|
2956
|
+
provenance: parseJSON$2(row.provenance) ?? null,
|
|
2957
|
+
runnerAttestation: parseJSON$2(row.runnerAttestation) ?? null,
|
|
2958
|
+
experimentSetId: row.experimentSetId ?? null,
|
|
2959
|
+
comparisonId: row.comparisonId ?? null,
|
|
2960
|
+
variantId: row.variantId ?? null,
|
|
2961
|
+
trialIndex: row.trialIndex ?? null,
|
|
2937
2962
|
status: row.status,
|
|
2938
2963
|
totalItems: row.totalItems,
|
|
2939
2964
|
succeededCount: row.succeededCount,
|
|
@@ -2985,6 +3010,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
2985
3010
|
name: input.name ?? null,
|
|
2986
3011
|
description: input.description ?? null,
|
|
2987
3012
|
metadata: input.metadata ? JSON.stringify(input.metadata) : null,
|
|
3013
|
+
provenance: input.provenance ? JSON.stringify(input.provenance) : null,
|
|
3014
|
+
runnerAttestation: input.runnerAttestation ? JSON.stringify(input.runnerAttestation) : null,
|
|
3015
|
+
experimentSetId: input.experimentSetId ?? null,
|
|
3016
|
+
comparisonId: input.comparisonId ?? null,
|
|
3017
|
+
variantId: input.variantId ?? null,
|
|
3018
|
+
trialIndex: input.trialIndex ?? null,
|
|
2988
3019
|
status: "pending",
|
|
2989
3020
|
totalItems: input.totalItems,
|
|
2990
3021
|
succeededCount: 0,
|
|
@@ -3008,6 +3039,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3008
3039
|
name: input.name,
|
|
3009
3040
|
description: input.description,
|
|
3010
3041
|
metadata: input.metadata,
|
|
3042
|
+
provenance: input.provenance ?? null,
|
|
3043
|
+
runnerAttestation: input.runnerAttestation ?? null,
|
|
3044
|
+
experimentSetId: input.experimentSetId ?? null,
|
|
3045
|
+
comparisonId: input.comparisonId ?? null,
|
|
3046
|
+
variantId: input.variantId ?? null,
|
|
3047
|
+
trialIndex: input.trialIndex ?? null,
|
|
3011
3048
|
status: "pending",
|
|
3012
3049
|
totalItems: input.totalItems,
|
|
3013
3050
|
succeededCount: 0,
|
|
@@ -3104,6 +3141,22 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3104
3141
|
conditions.push(`${quoteIdentifier("status", "column name")} = ?`);
|
|
3105
3142
|
params.push(args.status);
|
|
3106
3143
|
}
|
|
3144
|
+
if (args.experimentSetId !== void 0) {
|
|
3145
|
+
conditions.push(`${quoteIdentifier("experimentSetId", "column name")} = ?`);
|
|
3146
|
+
params.push(args.experimentSetId);
|
|
3147
|
+
}
|
|
3148
|
+
if (args.comparisonId !== void 0) {
|
|
3149
|
+
conditions.push(`${quoteIdentifier("comparisonId", "column name")} = ?`);
|
|
3150
|
+
params.push(args.comparisonId);
|
|
3151
|
+
}
|
|
3152
|
+
if (args.variantId !== void 0) {
|
|
3153
|
+
conditions.push(`${quoteIdentifier("variantId", "column name")} = ?`);
|
|
3154
|
+
params.push(args.variantId);
|
|
3155
|
+
}
|
|
3156
|
+
if (args.trialIndex !== void 0) {
|
|
3157
|
+
conditions.push(`${quoteIdentifier("trialIndex", "column name")} = ?`);
|
|
3158
|
+
params.push(args.trialIndex);
|
|
3159
|
+
}
|
|
3107
3160
|
if (args.filters) {
|
|
3108
3161
|
const { organizationId, projectId } = args.filters;
|
|
3109
3162
|
if (organizationId !== void 0) {
|
|
@@ -5066,12 +5119,16 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
5066
5119
|
hasMore: perPageInput === false ? false : offset + perPageNormalized < total
|
|
5067
5120
|
};
|
|
5068
5121
|
} catch (error) {
|
|
5069
|
-
|
|
5070
|
-
|
|
5122
|
+
if (error instanceof _mastra_core_error.MastraError && error.category === _mastra_core_error.ErrorCategory.USER) throw error;
|
|
5123
|
+
const mastraError = new _mastra_core_error.MastraError({
|
|
5124
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MYSQL", "LIST_THREADS", "FAILED"),
|
|
5071
5125
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
5072
5126
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
5073
5127
|
details: { filter: JSON.stringify(filter ?? {}) }
|
|
5074
5128
|
}, error);
|
|
5129
|
+
this.logger?.error?.(mastraError.toString());
|
|
5130
|
+
this.logger?.trackException?.(mastraError);
|
|
5131
|
+
throw mastraError;
|
|
5075
5132
|
}
|
|
5076
5133
|
}
|
|
5077
5134
|
async getThreadsByResourceId(args) {
|
|
@@ -5597,8 +5654,9 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
5597
5654
|
hasMore: metadataFilter || !include?.length || mainThreadMessageCount < total ? baseHasMore : false
|
|
5598
5655
|
};
|
|
5599
5656
|
} catch (error) {
|
|
5657
|
+
if (error instanceof _mastra_core_error.MastraError && error.category === _mastra_core_error.ErrorCategory.USER) throw error;
|
|
5600
5658
|
const mastraError = new _mastra_core_error.MastraError({
|
|
5601
|
-
id: "
|
|
5659
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MYSQL", "LIST_MESSAGES", "FAILED"),
|
|
5602
5660
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
5603
5661
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
5604
5662
|
details: {
|
|
@@ -5609,13 +5667,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
5609
5667
|
}, error);
|
|
5610
5668
|
this.logger?.error?.(mastraError.toString());
|
|
5611
5669
|
this.logger?.trackException?.(mastraError);
|
|
5612
|
-
|
|
5613
|
-
messages: [],
|
|
5614
|
-
total: 0,
|
|
5615
|
-
page,
|
|
5616
|
-
perPage,
|
|
5617
|
-
hasMore: false
|
|
5618
|
-
};
|
|
5670
|
+
throw mastraError;
|
|
5619
5671
|
}
|
|
5620
5672
|
}
|
|
5621
5673
|
async listMessagesByResourceId(args) {
|
|
@@ -5707,21 +5759,16 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
5707
5759
|
hasMore
|
|
5708
5760
|
};
|
|
5709
5761
|
} catch (error) {
|
|
5762
|
+
if (error instanceof _mastra_core_error.MastraError && error.category === _mastra_core_error.ErrorCategory.USER) throw error;
|
|
5710
5763
|
const mastraError = new _mastra_core_error.MastraError({
|
|
5711
|
-
id: (0, _mastra_core_storage.createStorageErrorId)("MYSQL", "
|
|
5764
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MYSQL", "LIST_MESSAGES_BY_RESOURCE_ID", "FAILED"),
|
|
5712
5765
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
5713
5766
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
5714
5767
|
details: { resourceId }
|
|
5715
5768
|
}, error);
|
|
5716
5769
|
this.logger?.error?.(mastraError.toString());
|
|
5717
5770
|
this.logger?.trackException?.(mastraError);
|
|
5718
|
-
|
|
5719
|
-
messages: [],
|
|
5720
|
-
total: 0,
|
|
5721
|
-
page,
|
|
5722
|
-
perPage: perPageForResponse,
|
|
5723
|
-
hasMore: false
|
|
5724
|
-
};
|
|
5771
|
+
throw mastraError;
|
|
5725
5772
|
}
|
|
5726
5773
|
}
|
|
5727
5774
|
async getResourceById({ resourceId }) {
|