@mastra/mysql 0.14.0-alpha.1 → 0.14.1-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/dist/_types/@internal_core/dist/memory/index.d.ts +12 -15
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +93 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -106
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/favorites/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/package.json +15 -16
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/memory/index.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Shared rules for observational memory lifecycle writes. Every storage adapter applies
|
|
4
3
|
* these inside its own atomic section (lock, transaction, or conditional update), so the
|
|
@@ -9,18 +8,18 @@
|
|
|
9
8
|
* into the table schema they get from `@mastra/core`, so the columns exist even when the
|
|
10
9
|
* installed core predates them.
|
|
11
10
|
*/
|
|
12
|
-
declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
11
|
+
export declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
13
12
|
readonly supersededBy: {
|
|
14
13
|
readonly type: 'text';
|
|
15
14
|
readonly nullable: true;
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
17
|
/** `schema` plus {@link OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS}; `undefined` when `schema` is. */
|
|
19
|
-
declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
18
|
+
export declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
20
19
|
/**
|
|
21
20
|
* Result of `commitActiveObservations`.
|
|
22
21
|
*/
|
|
23
|
-
interface UpdateActiveObservationsResult {
|
|
22
|
+
export interface UpdateActiveObservationsResult {
|
|
24
23
|
/** Whether the observations were written. */
|
|
25
24
|
applied: boolean;
|
|
26
25
|
/**
|
|
@@ -38,14 +37,14 @@ interface UpdateActiveObservationsResult {
|
|
|
38
37
|
* the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
|
|
39
38
|
* wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
|
|
40
39
|
*/
|
|
41
|
-
interface UpdateBufferedObservationsResult {
|
|
40
|
+
export interface UpdateBufferedObservationsResult {
|
|
42
41
|
/** Whether the chunk was stored. */
|
|
43
42
|
persisted: boolean;
|
|
44
43
|
/** The record the chunk was written to (or would have been written to). */
|
|
45
44
|
recordId: string;
|
|
46
45
|
}
|
|
47
46
|
/** The fields of an observational memory record that decide head order. */
|
|
48
|
-
interface ObservationalMemoryHeadOrderFields {
|
|
47
|
+
export interface ObservationalMemoryHeadOrderFields {
|
|
49
48
|
generationCount: number;
|
|
50
49
|
createdAt: Date | string;
|
|
51
50
|
id: string;
|
|
@@ -54,16 +53,16 @@ interface ObservationalMemoryHeadOrderFields {
|
|
|
54
53
|
* Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
|
|
55
54
|
* Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
|
|
56
55
|
*/
|
|
57
|
-
declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
56
|
+
export declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
58
57
|
/**
|
|
59
58
|
* A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
|
|
60
59
|
* (every message it observed is already at or before the cursor) iff
|
|
61
60
|
* `cursor >= chunk.lastObservedAt - 1ms`.
|
|
62
61
|
*/
|
|
63
|
-
declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
62
|
+
export declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
64
63
|
/** The later of two cursors; `undefined` only when both are absent. */
|
|
65
|
-
declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
66
|
-
interface ReflectionTextPlan {
|
|
64
|
+
export declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
65
|
+
export interface ReflectionTextPlan {
|
|
67
66
|
/** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
|
|
68
67
|
mode: 'equal' | 'append';
|
|
69
68
|
observations: string;
|
|
@@ -78,7 +77,7 @@ interface ReflectionTextPlan {
|
|
|
78
77
|
* after the reflection, and its tokens are added.
|
|
79
78
|
* - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
|
|
80
79
|
*/
|
|
81
|
-
declare function planReflectionGenerationText(input: {
|
|
80
|
+
export declare function planReflectionGenerationText(input: {
|
|
82
81
|
storedObservations: string;
|
|
83
82
|
storedObservationTokenCount: number;
|
|
84
83
|
snapshotObservations: string;
|
|
@@ -91,12 +90,10 @@ declare function planReflectionGenerationText(input: {
|
|
|
91
90
|
* Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
|
|
92
91
|
* write that was not applied throws instead of resolving as if it had committed.
|
|
93
92
|
*/
|
|
94
|
-
declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
93
|
+
export declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
95
94
|
/**
|
|
96
95
|
* Whether the stored text can still accept a reflection built from `snapshot`
|
|
97
96
|
* (equal, or only appended to since).
|
|
98
97
|
*/
|
|
99
|
-
declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
100
|
-
//#endregion
|
|
101
|
-
export { OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS, ObservationalMemoryHeadOrderFields, ReflectionTextPlan, UpdateActiveObservationsResult, UpdateBufferedObservationsResult, assertActiveObservationsApplied, compareObservationalMemoryHeadOrder, isAppendOnlySince, isBufferedChunkCoveredByCursor, maxObservationCursor, planReflectionGenerationText, withObservationalMemoryLifecycleColumns };
|
|
98
|
+
export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
102
99
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -294,7 +294,7 @@ const storage = new MongoDBStore({
|
|
|
294
294
|
|
|
295
295
|
## Reclaiming disk
|
|
296
296
|
|
|
297
|
-
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist
|
|
297
|
+
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist for reuse by future writes. Reusing these pages prevents unbounded file growth for most users.
|
|
298
298
|
|
|
299
299
|
Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically. A manual `VACUUM FULL` is only needed if you must return disk to the OS.
|
|
300
300
|
|
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ let _mastra_core_utils = require("@mastra/core/utils");
|
|
|
6
6
|
let crypto$1 = require("crypto");
|
|
7
7
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
8
8
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
9
|
-
|
|
9
|
+
// src/storage/db/schema-snapshot.ts
|
|
10
10
|
/** Builds the `table.index` presence key the snapshot uses. */
|
|
11
11
|
function indexKey(table, index) {
|
|
12
12
|
return `${table.toLowerCase()}.${index.toLowerCase()}`;
|
|
@@ -45,8 +45,7 @@ async function loadSchemaSnapshot(pool, schemaName) {
|
|
|
45
45
|
indexes
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
//#region src/storage/domains/utils.ts
|
|
48
|
+
// src/storage/domains/utils.ts
|
|
50
49
|
function quoteIdentifier(value, context) {
|
|
51
50
|
return `\`${(0, _mastra_core_utils.parseSqlIdentifier)(value, context)}\``;
|
|
52
51
|
}
|
|
@@ -86,13 +85,14 @@ function prepareWhereClause(filters) {
|
|
|
86
85
|
if (value === true) conditions.push(`${quoteIdentifier(fieldName, "column name")} IS NULL`);
|
|
87
86
|
else if (value === false) conditions.push(`${quoteIdentifier(fieldName, "column name")} IS NOT NULL`);
|
|
88
87
|
} else if (value === null) conditions.push(`${quoteIdentifier(key, "column name")} IS NULL`);
|
|
89
|
-
else if (Array.isArray(value))
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
else if (Array.isArray(value)) {
|
|
89
|
+
if (value.length === 0) conditions.push("FALSE");
|
|
90
|
+
else {
|
|
91
|
+
const placeholders = value.map(() => "?").join(", ");
|
|
92
|
+
conditions.push(`${quoteIdentifier(key, "column name")} IN (${placeholders})`);
|
|
93
|
+
args.push(...value.map(transformToSqlValue));
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
96
|
conditions.push(`${quoteIdentifier(key, "column name")} = ?`);
|
|
97
97
|
args.push(transformToSqlValue(value));
|
|
98
98
|
}
|
|
@@ -157,13 +157,14 @@ function transformFromSqlRow({ tableName, sqlRow }) {
|
|
|
157
157
|
const result = {};
|
|
158
158
|
Object.entries(sqlRow).forEach(([key, value]) => {
|
|
159
159
|
const columnSchema = schema?.[key];
|
|
160
|
-
if (columnSchema?.type === "jsonb")
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
if (columnSchema?.type === "jsonb") {
|
|
161
|
+
if (typeof value === "string") try {
|
|
162
|
+
result[key] = JSON.parse(value);
|
|
163
|
+
} catch {
|
|
164
|
+
result[key] = value;
|
|
165
|
+
}
|
|
166
|
+
else result[key] = value;
|
|
167
|
+
} else if (columnSchema?.type === "timestamp") result[key] = value === null ? null : parseDateTime(value);
|
|
167
168
|
else if (columnSchema?.type === "boolean") result[key] = value === true || value === 1 || value === "1";
|
|
168
169
|
else result[key] = value;
|
|
169
170
|
});
|
|
@@ -179,8 +180,7 @@ function parseDateTime(value) {
|
|
|
179
180
|
const withZone = /[zZ]|[+-]\d\d:?\d\d$/.test(normalized) ? normalized : `${normalized}Z`;
|
|
180
181
|
return new Date(withZone);
|
|
181
182
|
}
|
|
182
|
-
|
|
183
|
-
//#region src/storage/domains/operations/index.ts
|
|
183
|
+
// src/storage/domains/operations/index.ts
|
|
184
184
|
var StoreOperationsMySQL = class extends _mastra_core_storage.StoreOperations {
|
|
185
185
|
pool;
|
|
186
186
|
database;
|
|
@@ -774,8 +774,7 @@ function mapToMySqlType(type, isKey = false) {
|
|
|
774
774
|
default: return "TEXT";
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
|
-
|
|
778
|
-
//#region src/storage/domains/agents/index.ts
|
|
777
|
+
// src/storage/domains/agents/index.ts
|
|
779
778
|
var AgentsMySQL = class AgentsMySQL extends _mastra_core_storage.AgentsStorage {
|
|
780
779
|
pool;
|
|
781
780
|
operations;
|
|
@@ -1372,8 +1371,7 @@ var AgentsMySQL = class AgentsMySQL extends _mastra_core_storage.AgentsStorage {
|
|
|
1372
1371
|
};
|
|
1373
1372
|
}
|
|
1374
1373
|
};
|
|
1375
|
-
|
|
1376
|
-
//#region src/storage/domains/background-tasks/index.ts
|
|
1374
|
+
// src/storage/domains/background-tasks/index.ts
|
|
1377
1375
|
function serializeJson(v) {
|
|
1378
1376
|
if (typeof v === "object" && v != null) return JSON.stringify(v);
|
|
1379
1377
|
return v ?? null;
|
|
@@ -1565,15 +1563,19 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
|
|
|
1565
1563
|
predicates.push(`${quoteIdentifier("status", "column name")} = ?`);
|
|
1566
1564
|
params.push(options.expectedStatus);
|
|
1567
1565
|
}
|
|
1568
|
-
if (options?.expectedOwnerId !== void 0)
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1566
|
+
if (options?.expectedOwnerId !== void 0) {
|
|
1567
|
+
if (options.expectedOwnerId === null) predicates.push(`${quoteIdentifier("ownerId", "column name")} IS NULL`);
|
|
1568
|
+
else {
|
|
1569
|
+
predicates.push(`${quoteIdentifier("ownerId", "column name")} = ?`);
|
|
1570
|
+
params.push(options.expectedOwnerId);
|
|
1571
|
+
}
|
|
1572
1572
|
}
|
|
1573
|
-
if (options?.expectedLeaseExpiresAt !== void 0)
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1573
|
+
if (options?.expectedLeaseExpiresAt !== void 0) {
|
|
1574
|
+
if (options.expectedLeaseExpiresAt === null) predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} IS NULL`);
|
|
1575
|
+
else {
|
|
1576
|
+
predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} = ?`);
|
|
1577
|
+
params.push(transformToSqlValue(options.expectedLeaseExpiresAt));
|
|
1578
|
+
}
|
|
1577
1579
|
}
|
|
1578
1580
|
const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
|
|
1579
1581
|
const [result] = await this.pool.execute(`UPDATE ${formatTableName(_mastra_core_storage.TABLE_BACKGROUND_TASKS)} SET ${setClauses.join(", ")} WHERE ${quoteIdentifier("id", "column name")} = ?${predicateSql}`, params);
|
|
@@ -1687,8 +1689,7 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends _mastra_core_stora
|
|
|
1687
1689
|
return Number(rows[0]?.count ?? 0);
|
|
1688
1690
|
}
|
|
1689
1691
|
};
|
|
1690
|
-
|
|
1691
|
-
//#region src/storage/domains/blobs/index.ts
|
|
1692
|
+
// src/storage/domains/blobs/index.ts
|
|
1692
1693
|
const INSERT_IGNORE_SQL = `INSERT IGNORE INTO ${formatTableName(_mastra_core_storage.TABLE_SKILL_BLOBS)} (${[
|
|
1693
1694
|
"hash",
|
|
1694
1695
|
"content",
|
|
@@ -1769,8 +1770,7 @@ var BlobsMySQL = class extends _mastra_core_storage.BlobStore {
|
|
|
1769
1770
|
};
|
|
1770
1771
|
}
|
|
1771
1772
|
};
|
|
1772
|
-
|
|
1773
|
-
//#region src/storage/domains/channels/index.ts
|
|
1773
|
+
// src/storage/domains/channels/index.ts
|
|
1774
1774
|
var ChannelsMySQL = class ChannelsMySQL extends _mastra_core_storage.ChannelsStorage {
|
|
1775
1775
|
pool;
|
|
1776
1776
|
operations;
|
|
@@ -1904,8 +1904,7 @@ var ChannelsMySQL = class ChannelsMySQL extends _mastra_core_storage.ChannelsSto
|
|
|
1904
1904
|
};
|
|
1905
1905
|
}
|
|
1906
1906
|
};
|
|
1907
|
-
|
|
1908
|
-
//#region src/storage/domains/datasets/index.ts
|
|
1907
|
+
// src/storage/domains/datasets/index.ts
|
|
1909
1908
|
function parseJSON$3(value) {
|
|
1910
1909
|
if (value === null || value === void 0) return void 0;
|
|
1911
1910
|
if (typeof value === "string") try {
|
|
@@ -3056,8 +3055,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
3056
3055
|
}
|
|
3057
3056
|
}
|
|
3058
3057
|
};
|
|
3059
|
-
|
|
3060
|
-
//#region src/storage/domains/experiments/index.ts
|
|
3058
|
+
// src/storage/domains/experiments/index.ts
|
|
3061
3059
|
function parseJSON$2(value) {
|
|
3062
3060
|
if (value === null || value === void 0) return void 0;
|
|
3063
3061
|
if (typeof value === "string") {
|
|
@@ -3929,8 +3927,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3929
3927
|
}
|
|
3930
3928
|
}
|
|
3931
3929
|
};
|
|
3932
|
-
|
|
3933
|
-
//#region src/storage/domains/favorites/index.ts
|
|
3930
|
+
// src/storage/domains/favorites/index.ts
|
|
3934
3931
|
/**
|
|
3935
3932
|
* Maps a favorite entity type to its parent entity table.
|
|
3936
3933
|
*/
|
|
@@ -4166,8 +4163,7 @@ var FavoritesMySQL = class FavoritesMySQL extends _mastra_core_storage.Favorites
|
|
|
4166
4163
|
}
|
|
4167
4164
|
}
|
|
4168
4165
|
};
|
|
4169
|
-
|
|
4170
|
-
//#region src/storage/domains/knowledge/index.ts
|
|
4166
|
+
// src/storage/domains/knowledge/index.ts
|
|
4171
4167
|
let assertDescriptionWithinBound;
|
|
4172
4168
|
async function assertKnowledgeDescriptionWithinBoundCompat(description) {
|
|
4173
4169
|
let assertWithinBound = assertDescriptionWithinBound;
|
|
@@ -5062,8 +5058,7 @@ var KnowledgeMySQL = class extends _mastra_core_storage.KnowledgeStorage {
|
|
|
5062
5058
|
});
|
|
5063
5059
|
}
|
|
5064
5060
|
};
|
|
5065
|
-
|
|
5066
|
-
//#region src/storage/domains/mcp-clients/index.ts
|
|
5061
|
+
// src/storage/domains/mcp-clients/index.ts
|
|
5067
5062
|
var MCPClientsMySQL = class MCPClientsMySQL extends _mastra_core_storage.MCPClientsStorage {
|
|
5068
5063
|
pool;
|
|
5069
5064
|
operations;
|
|
@@ -5536,8 +5531,7 @@ var MCPClientsMySQL = class MCPClientsMySQL extends _mastra_core_storage.MCPClie
|
|
|
5536
5531
|
}
|
|
5537
5532
|
}
|
|
5538
5533
|
};
|
|
5539
|
-
|
|
5540
|
-
//#region src/storage/domains/mcp-servers/index.ts
|
|
5534
|
+
// src/storage/domains/mcp-servers/index.ts
|
|
5541
5535
|
var MCPServersMySQL = class MCPServersMySQL extends _mastra_core_storage.MCPServersStorage {
|
|
5542
5536
|
pool;
|
|
5543
5537
|
operations;
|
|
@@ -6026,8 +6020,7 @@ var MCPServersMySQL = class MCPServersMySQL extends _mastra_core_storage.MCPServ
|
|
|
6026
6020
|
}
|
|
6027
6021
|
}
|
|
6028
6022
|
};
|
|
6029
|
-
|
|
6030
|
-
//#region ../../packages/_internal-core/dist/memory/index.js
|
|
6023
|
+
// ../../packages/_internal-core/dist/memory/index.js
|
|
6031
6024
|
/**
|
|
6032
6025
|
* Shared rules for observational memory lifecycle writes. Every storage adapter applies
|
|
6033
6026
|
* these inside its own atomic section (lock, transaction, or conditional update), so the
|
|
@@ -6112,8 +6105,7 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
6112
6105
|
const snapshot = snapshotObservations ?? "";
|
|
6113
6106
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
6114
6107
|
}
|
|
6115
|
-
|
|
6116
|
-
//#region src/storage/db/run-fencing.ts
|
|
6108
|
+
// src/storage/db/run-fencing.ts
|
|
6117
6109
|
/**
|
|
6118
6110
|
* Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
|
|
6119
6111
|
* statement started and doesn't depend on the session time zone. Every lease
|
|
@@ -6134,10 +6126,11 @@ async function assertRunFence(q, claimsTable, fence, operation) {
|
|
|
6134
6126
|
const [rows] = await q.execute(`SELECT generation, ${quoteIdentifier("ownerId", "column name")} AS ownerId FROM ${claimsTable}
|
|
6135
6127
|
WHERE ${quoteIdentifier("runId", "column name")} = ? LOCK IN SHARE MODE`, [fence.runId]);
|
|
6136
6128
|
const row = rows[0];
|
|
6137
|
-
|
|
6129
|
+
const current = row ? {
|
|
6138
6130
|
generation: Number(row.generation),
|
|
6139
6131
|
ownerId: String(row.ownerId)
|
|
6140
|
-
} : null
|
|
6132
|
+
} : null;
|
|
6133
|
+
if (!(0, _mastra_core_storage.matchesRunFence)(current, fence)) throw new _mastra_core_storage.RunFenceConflictError(fence, operation);
|
|
6141
6134
|
}
|
|
6142
6135
|
/** Runs `fn` in a transaction on its own pooled connection. */
|
|
6143
6136
|
async function inTransaction(pool, fn) {
|
|
@@ -6180,8 +6173,7 @@ async function claimTransaction(pool, fn) {
|
|
|
6180
6173
|
if (attempt >= MAX_CLAIM_ATTEMPTS || errno !== ER_DUP_ENTRY && errno !== ER_LOCK_DEADLOCK) throw error;
|
|
6181
6174
|
}
|
|
6182
6175
|
}
|
|
6183
|
-
|
|
6184
|
-
//#region src/storage/domains/memory/index.ts
|
|
6176
|
+
// src/storage/domains/memory/index.ts
|
|
6185
6177
|
const OM_TABLE = "mastra_observational_memory";
|
|
6186
6178
|
const OM_TABLE_QUOTED = quoteIdentifier(OM_TABLE, "table name");
|
|
6187
6179
|
const RUN_FENCES_TABLE = formatTableName(_mastra_core_storage.TABLE_MEMORY_RUN_FENCES);
|
|
@@ -6471,13 +6463,14 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
6471
6463
|
for (const indexDef of this.#indexes) await this.operations.createIndex(indexDef);
|
|
6472
6464
|
}
|
|
6473
6465
|
async prune(policies, options) {
|
|
6466
|
+
const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
6467
|
+
policies,
|
|
6468
|
+
descriptor: MemoryMySQL.retentionTables,
|
|
6469
|
+
order: ["runFences"]
|
|
6470
|
+
});
|
|
6474
6471
|
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
6475
6472
|
domain: "memory",
|
|
6476
|
-
targets
|
|
6477
|
-
policies,
|
|
6478
|
-
descriptor: MemoryMySQL.retentionTables,
|
|
6479
|
-
order: ["runFences"]
|
|
6480
|
-
}),
|
|
6473
|
+
targets,
|
|
6481
6474
|
options,
|
|
6482
6475
|
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
6483
6476
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -8371,8 +8364,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
8371
8364
|
};
|
|
8372
8365
|
}
|
|
8373
8366
|
};
|
|
8374
|
-
|
|
8375
|
-
//#region src/storage/domains/observability/index.ts
|
|
8367
|
+
// src/storage/domains/observability/index.ts
|
|
8376
8368
|
const JSON_SPAN_FIELDS = [
|
|
8377
8369
|
"input",
|
|
8378
8370
|
"output",
|
|
@@ -8405,13 +8397,14 @@ var ObservabilityMySQL = class ObservabilityMySQL extends _mastra_core_storage.O
|
|
|
8405
8397
|
this.#indexes = indexes?.filter((idx) => ObservabilityMySQL.MANAGED_TABLES.includes(idx.table));
|
|
8406
8398
|
}
|
|
8407
8399
|
async prune(policies, options) {
|
|
8400
|
+
const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
8401
|
+
policies,
|
|
8402
|
+
descriptor: ObservabilityMySQL.retentionTables,
|
|
8403
|
+
order: ["spans"]
|
|
8404
|
+
});
|
|
8408
8405
|
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
8409
8406
|
domain: "observability",
|
|
8410
|
-
targets
|
|
8411
|
-
policies,
|
|
8412
|
-
descriptor: ObservabilityMySQL.retentionTables,
|
|
8413
|
-
order: ["spans"]
|
|
8414
|
-
}),
|
|
8407
|
+
targets,
|
|
8415
8408
|
options,
|
|
8416
8409
|
cutoffFor: (target, now) => new Date((0, _mastra_core_storage.retentionCutoffMs)(target.policy, now)),
|
|
8417
8410
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -8778,22 +8771,22 @@ var ObservabilityMySQL = class ObservabilityMySQL extends _mastra_core_storage.O
|
|
|
8778
8771
|
case _mastra_core_storage.TraceStatus.RUNNING:
|
|
8779
8772
|
conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8780
8773
|
break;
|
|
8781
|
-
case _mastra_core_storage.TraceStatus.SUCCESS:
|
|
8782
|
-
conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NOT NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8783
|
-
break;
|
|
8774
|
+
case _mastra_core_storage.TraceStatus.SUCCESS: conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NOT NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8784
8775
|
}
|
|
8785
|
-
if (filters.hasChildError !== void 0)
|
|
8776
|
+
if (filters.hasChildError !== void 0) {
|
|
8777
|
+
if (filters.hasChildError) conditions.push(`EXISTS (
|
|
8786
8778
|
SELECT 1 FROM ${tbl} c
|
|
8787
8779
|
WHERE c.${quoteIdentifier("traceId", "column name")} = ${tbl}.${quoteIdentifier("traceId", "column name")}
|
|
8788
8780
|
AND c.${quoteIdentifier("parentSpanId", "column name")} IS NOT NULL
|
|
8789
8781
|
AND c.${quoteIdentifier("error", "column name")} IS NOT NULL
|
|
8790
8782
|
)`);
|
|
8791
|
-
|
|
8783
|
+
else conditions.push(`NOT EXISTS (
|
|
8792
8784
|
SELECT 1 FROM ${tbl} c
|
|
8793
8785
|
WHERE c.${quoteIdentifier("traceId", "column name")} = ${tbl}.${quoteIdentifier("traceId", "column name")}
|
|
8794
8786
|
AND c.${quoteIdentifier("parentSpanId", "column name")} IS NOT NULL
|
|
8795
8787
|
AND c.${quoteIdentifier("error", "column name")} IS NOT NULL
|
|
8796
8788
|
)`);
|
|
8789
|
+
}
|
|
8797
8790
|
}
|
|
8798
8791
|
const whereClause = conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : "";
|
|
8799
8792
|
const sortField = quoteIdentifier(orderBy.field, "column name");
|
|
@@ -8905,8 +8898,7 @@ var ObservabilityMySQL = class ObservabilityMySQL extends _mastra_core_storage.O
|
|
|
8905
8898
|
}
|
|
8906
8899
|
}
|
|
8907
8900
|
};
|
|
8908
|
-
|
|
8909
|
-
//#region src/storage/domains/prompt-blocks/index.ts
|
|
8901
|
+
// src/storage/domains/prompt-blocks/index.ts
|
|
8910
8902
|
var PromptBlocksMySQL = class PromptBlocksMySQL extends _mastra_core_storage.PromptBlocksStorage {
|
|
8911
8903
|
pool;
|
|
8912
8904
|
operations;
|
|
@@ -9378,8 +9370,7 @@ var PromptBlocksMySQL = class PromptBlocksMySQL extends _mastra_core_storage.Pro
|
|
|
9378
9370
|
}
|
|
9379
9371
|
}
|
|
9380
9372
|
};
|
|
9381
|
-
|
|
9382
|
-
//#region src/storage/domains/schedules/index.ts
|
|
9373
|
+
// src/storage/domains/schedules/index.ts
|
|
9383
9374
|
function parseJson(val) {
|
|
9384
9375
|
if (val == null) return void 0;
|
|
9385
9376
|
if (typeof val === "string") try {
|
|
@@ -9529,15 +9520,19 @@ var SchedulesMySQL = class SchedulesMySQL extends _mastra_core_storage.Schedules
|
|
|
9529
9520
|
conditions.push(`JSON_EXTRACT(${quoteIdentifier("target", "column name")}, '$.workflowId') = ?`);
|
|
9530
9521
|
params.push(filter.workflowId);
|
|
9531
9522
|
}
|
|
9532
|
-
if (filter?.ownerType !== void 0)
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9523
|
+
if (filter?.ownerType !== void 0) {
|
|
9524
|
+
if (filter.ownerType === null) conditions.push(`${quoteIdentifier("owner_type", "column name")} IS NULL`);
|
|
9525
|
+
else {
|
|
9526
|
+
conditions.push(`${quoteIdentifier("owner_type", "column name")} = ?`);
|
|
9527
|
+
params.push(filter.ownerType);
|
|
9528
|
+
}
|
|
9536
9529
|
}
|
|
9537
|
-
if (filter?.ownerId !== void 0)
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9530
|
+
if (filter?.ownerId !== void 0) {
|
|
9531
|
+
if (filter.ownerId === null) conditions.push(`${quoteIdentifier("owner_id", "column name")} IS NULL`);
|
|
9532
|
+
else {
|
|
9533
|
+
conditions.push(`${quoteIdentifier("owner_id", "column name")} = ?`);
|
|
9534
|
+
params.push(filter.ownerId);
|
|
9535
|
+
}
|
|
9541
9536
|
}
|
|
9542
9537
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
9543
9538
|
const [rows] = await this.pool.execute(`SELECT * FROM ${formatTableName(_mastra_core_storage.TABLE_SCHEDULES)} ${where} ORDER BY ${quoteIdentifier("created_at", "column name")} ASC`, params);
|
|
@@ -9644,8 +9639,7 @@ var SchedulesMySQL = class SchedulesMySQL extends _mastra_core_storage.Schedules
|
|
|
9644
9639
|
return rows.map((r) => rowToTrigger(r));
|
|
9645
9640
|
}
|
|
9646
9641
|
};
|
|
9647
|
-
|
|
9648
|
-
//#region src/storage/domains/scorer-definitions/index.ts
|
|
9642
|
+
// src/storage/domains/scorer-definitions/index.ts
|
|
9649
9643
|
var ScorerDefinitionsMySQL = class ScorerDefinitionsMySQL extends _mastra_core_storage.ScorerDefinitionsStorage {
|
|
9650
9644
|
pool;
|
|
9651
9645
|
operations;
|
|
@@ -10120,8 +10114,7 @@ var ScorerDefinitionsMySQL = class ScorerDefinitionsMySQL extends _mastra_core_s
|
|
|
10120
10114
|
}
|
|
10121
10115
|
}
|
|
10122
10116
|
};
|
|
10123
|
-
|
|
10124
|
-
//#region src/storage/domains/scores/index.ts
|
|
10117
|
+
// src/storage/domains/scores/index.ts
|
|
10125
10118
|
function parseJSON(value) {
|
|
10126
10119
|
if (value === null || value === void 0) return void 0;
|
|
10127
10120
|
if (typeof value === "string") {
|
|
@@ -10416,8 +10409,7 @@ var ScoresMySQL = class ScoresMySQL extends _mastra_core_storage.ScoresStorage {
|
|
|
10416
10409
|
}), pagination);
|
|
10417
10410
|
}
|
|
10418
10411
|
};
|
|
10419
|
-
|
|
10420
|
-
//#region src/storage/domains/skills/index.ts
|
|
10412
|
+
// src/storage/domains/skills/index.ts
|
|
10421
10413
|
const SNAPSHOT_FIELDS$1 = [
|
|
10422
10414
|
"name",
|
|
10423
10415
|
"description",
|
|
@@ -10977,8 +10969,7 @@ var SkillsMySQL = class SkillsMySQL extends _mastra_core_storage.SkillsStorage {
|
|
|
10977
10969
|
}
|
|
10978
10970
|
}
|
|
10979
10971
|
};
|
|
10980
|
-
|
|
10981
|
-
//#region src/storage/domains/tool-provider-connections/index.ts
|
|
10972
|
+
// src/storage/domains/tool-provider-connections/index.ts
|
|
10982
10973
|
function normaliseScope(raw) {
|
|
10983
10974
|
const value = raw == null ? "per-author" : String(raw);
|
|
10984
10975
|
if (value === "shared") return "shared";
|
|
@@ -11203,8 +11194,7 @@ var ToolProviderConnectionsMySQL = class ToolProviderConnectionsMySQL extends _m
|
|
|
11203
11194
|
}
|
|
11204
11195
|
}
|
|
11205
11196
|
};
|
|
11206
|
-
|
|
11207
|
-
//#region src/storage/domains/workflow-definitions/index.ts
|
|
11197
|
+
// src/storage/domains/workflow-definitions/index.ts
|
|
11208
11198
|
function rowToDefinition(row) {
|
|
11209
11199
|
const transformed = transformFromSqlRow({
|
|
11210
11200
|
tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
|
|
@@ -11345,8 +11335,7 @@ var WorkflowDefinitionsMySQL = class extends _mastra_core_storage.WorkflowDefini
|
|
|
11345
11335
|
await this.pool.execute(`DELETE FROM ${formatTableName(_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS, this.database)} WHERE ${quoteIdentifier("id", "column name")} = ?`, [id]);
|
|
11346
11336
|
}
|
|
11347
11337
|
};
|
|
11348
|
-
|
|
11349
|
-
//#region src/storage/domains/workflows/index.ts
|
|
11338
|
+
// src/storage/domains/workflows/index.ts
|
|
11350
11339
|
function parseSnapshot(snapshot) {
|
|
11351
11340
|
if (typeof snapshot === "string") try {
|
|
11352
11341
|
return JSON.parse(snapshot);
|
|
@@ -11472,13 +11461,14 @@ var WorkflowsMySQL = class WorkflowsMySQL extends _mastra_core_storage.Workflows
|
|
|
11472
11461
|
await this.createCustomIndexes();
|
|
11473
11462
|
}
|
|
11474
11463
|
async prune(policies, options) {
|
|
11464
|
+
const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
11465
|
+
policies,
|
|
11466
|
+
descriptor: WorkflowsMySQL.retentionTables,
|
|
11467
|
+
order: ["runOwnership"]
|
|
11468
|
+
});
|
|
11475
11469
|
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
11476
11470
|
domain: "workflows",
|
|
11477
|
-
targets
|
|
11478
|
-
policies,
|
|
11479
|
-
descriptor: WorkflowsMySQL.retentionTables,
|
|
11480
|
-
order: ["runOwnership"]
|
|
11481
|
-
}),
|
|
11471
|
+
targets,
|
|
11482
11472
|
options,
|
|
11483
11473
|
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
11484
11474
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -11864,8 +11854,7 @@ var WorkflowsMySQL = class WorkflowsMySQL extends _mastra_core_storage.Workflows
|
|
|
11864
11854
|
}
|
|
11865
11855
|
}
|
|
11866
11856
|
};
|
|
11867
|
-
|
|
11868
|
-
//#region src/storage/domains/workspaces/index.ts
|
|
11857
|
+
// src/storage/domains/workspaces/index.ts
|
|
11869
11858
|
const SNAPSHOT_FIELDS = [
|
|
11870
11859
|
"name",
|
|
11871
11860
|
"description",
|
|
@@ -12383,8 +12372,7 @@ var WorkspacesMySQL = class WorkspacesMySQL extends _mastra_core_storage.Workspa
|
|
|
12383
12372
|
}
|
|
12384
12373
|
}
|
|
12385
12374
|
};
|
|
12386
|
-
|
|
12387
|
-
//#region src/storage/index.ts
|
|
12375
|
+
// src/storage/index.ts
|
|
12388
12376
|
function validateConfig(config) {
|
|
12389
12377
|
if ("connectionString" in config) {
|
|
12390
12378
|
if (!config.connectionString || typeof config.connectionString !== "string") throw new Error("MySQLStore: connectionString must be a non-empty string.");
|
|
@@ -12657,7 +12645,6 @@ var MySQLStore = class extends _mastra_core_storage.MastraCompositeStore {
|
|
|
12657
12645
|
await this.pool.end();
|
|
12658
12646
|
}
|
|
12659
12647
|
};
|
|
12660
|
-
//#endregion
|
|
12661
12648
|
exports.AgentsMySQL = AgentsMySQL;
|
|
12662
12649
|
exports.BlobsMySQL = BlobsMySQL;
|
|
12663
12650
|
exports.DatasetsMySQL = DatasetsMySQL;
|