@mastra/mysql 0.17.1 → 0.17.2-alpha.1

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.
Files changed (36) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/memory/index.d.ts +25 -0
  2. package/dist/docs/SKILL.md +1 -1
  3. package/dist/docs/assets/SOURCE_MAP.json +10 -10
  4. package/dist/index.cjs +31 -3
  5. package/dist/index.js +31 -3
  6. package/package.json +8 -7
  7. package/dist/index.cjs.map +0 -1
  8. package/dist/index.d.ts.map +0 -1
  9. package/dist/index.js.map +0 -1
  10. package/dist/storage/db/run-fencing.d.ts.map +0 -1
  11. package/dist/storage/db/schema-snapshot.d.ts.map +0 -1
  12. package/dist/storage/domains/agents/index.d.ts.map +0 -1
  13. package/dist/storage/domains/background-tasks/index.d.ts.map +0 -1
  14. package/dist/storage/domains/blobs/index.d.ts.map +0 -1
  15. package/dist/storage/domains/channels/index.d.ts.map +0 -1
  16. package/dist/storage/domains/datasets/index.d.ts.map +0 -1
  17. package/dist/storage/domains/experiments/index.d.ts.map +0 -1
  18. package/dist/storage/domains/favorites/index.d.ts.map +0 -1
  19. package/dist/storage/domains/knowledge/index.d.ts.map +0 -1
  20. package/dist/storage/domains/knowledge/pages.d.ts.map +0 -1
  21. package/dist/storage/domains/mcp-clients/index.d.ts.map +0 -1
  22. package/dist/storage/domains/mcp-servers/index.d.ts.map +0 -1
  23. package/dist/storage/domains/memory/index.d.ts.map +0 -1
  24. package/dist/storage/domains/observability/index.d.ts.map +0 -1
  25. package/dist/storage/domains/operations/index.d.ts.map +0 -1
  26. package/dist/storage/domains/prompt-blocks/index.d.ts.map +0 -1
  27. package/dist/storage/domains/schedules/index.d.ts.map +0 -1
  28. package/dist/storage/domains/scorer-definitions/index.d.ts.map +0 -1
  29. package/dist/storage/domains/scores/index.d.ts.map +0 -1
  30. package/dist/storage/domains/skills/index.d.ts.map +0 -1
  31. package/dist/storage/domains/tool-provider-connections/index.d.ts.map +0 -1
  32. package/dist/storage/domains/utils.d.ts.map +0 -1
  33. package/dist/storage/domains/workflow-definitions/index.d.ts.map +0 -1
  34. package/dist/storage/domains/workflows/index.d.ts.map +0 -1
  35. package/dist/storage/domains/workspaces/index.d.ts.map +0 -1
  36. package/dist/storage/index.d.ts.map +0 -1
@@ -96,4 +96,29 @@ export declare function assertActiveObservationsApplied(result: UpdateActiveObse
96
96
  * (equal, or only appended to since).
97
97
  */
98
98
  export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
99
+ /** The buffered-reflection fields a `swapBufferedReflectionToActive` caller read, and the stored ones. */
100
+ export interface BufferedReflectionState {
101
+ bufferedReflection?: string | null;
102
+ reflectedObservationLineCount?: number | null;
103
+ }
104
+ /**
105
+ * Whether the stored buffered reflection and reflected line count are still the ones in
106
+ * `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
107
+ *
108
+ * Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
109
+ * count) after the caller's read. The activated text alone cannot tell the two apart: an
110
+ * extension that repeats the unreflected tail and moves the cut past it produces the same text.
111
+ * A snapshot without a buffered reflection (callers that never read one) is not checked.
112
+ */
113
+ export declare function isBufferedReflectionUnchangedSince(stored: BufferedReflectionState, snapshot: BufferedReflectionState): boolean;
114
+ /**
115
+ * The generation a buffered-reflection swap just created, marked with
116
+ * `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
117
+ * `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
118
+ * reflection was not checked, so its successor is returned unmarked. Always returns a new object,
119
+ * so a store's own record is never handed out or mutated.
120
+ */
121
+ export declare function withBufferedReflectionVerified<T extends object>(successor: T, snapshot: BufferedReflectionState): T & {
122
+ bufferedReflectionVerified?: true;
123
+ };
99
124
  //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@ name: mastra-mysql
3
3
  description: Documentation for @mastra/mysql. Use when working with @mastra/mysql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mysql"
6
- version: "0.17.1"
6
+ version: "0.17.2-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.17.1",
2
+ "version": "0.17.2-alpha.1",
3
3
  "package": "@mastra/mysql",
4
4
  "exports": {
5
5
  "AgentsMySQL": {
@@ -35,37 +35,37 @@
35
35
  "MemoryMySQL": {
36
36
  "types": "dist/storage/domains/memory/index.d.ts",
37
37
  "implementation": "dist/index.js",
38
- "line": 7271
38
+ "line": 7300
39
39
  },
40
40
  "MySQLStore": {
41
41
  "types": "dist/storage/index.d.ts",
42
42
  "implementation": "dist/index.js",
43
- "line": 13573
43
+ "line": 13603
44
44
  },
45
45
  "ObservabilityMySQL": {
46
46
  "types": "dist/storage/domains/observability/index.d.ts",
47
47
  "implementation": "dist/index.js",
48
- "line": 9385
48
+ "line": 9415
49
49
  },
50
50
  "PromptBlocksMySQL": {
51
51
  "types": "dist/storage/domains/prompt-blocks/index.d.ts",
52
52
  "implementation": "dist/index.js",
53
- "line": 9904
53
+ "line": 9934
54
54
  },
55
55
  "ScorerDefinitionsMySQL": {
56
56
  "types": "dist/storage/domains/scorer-definitions/index.d.ts",
57
57
  "implementation": "dist/index.js",
58
- "line": 10662
58
+ "line": 10692
59
59
  },
60
60
  "ScoresMySQL": {
61
61
  "types": "dist/storage/domains/scores/index.d.ts",
62
62
  "implementation": "dist/index.js",
63
- "line": 11149
63
+ "line": 11179
64
64
  },
65
65
  "SkillsMySQL": {
66
66
  "types": "dist/storage/domains/skills/index.d.ts",
67
67
  "implementation": "dist/index.js",
68
- "line": 11446
68
+ "line": 11476
69
69
  },
70
70
  "StoreOperationsMySQL": {
71
71
  "types": "dist/storage/domains/operations/index.d.ts",
@@ -75,12 +75,12 @@
75
75
  "WorkflowsMySQL": {
76
76
  "types": "dist/storage/domains/workflows/index.d.ts",
77
77
  "implementation": "dist/index.js",
78
- "line": 12414
78
+ "line": 12444
79
79
  },
80
80
  "WorkspacesMySQL": {
81
81
  "types": "dist/storage/domains/workspaces/index.d.ts",
82
82
  "implementation": "dist/index.js",
83
- "line": 12977
83
+ "line": 13007
84
84
  }
85
85
  },
86
86
  "modules": {}
package/dist/index.cjs CHANGED
@@ -7108,6 +7108,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
7108
7108
  const snapshot = snapshotObservations ?? "";
7109
7109
  return stored === snapshot || stored.startsWith(snapshot);
7110
7110
  }
7111
+ /**
7112
+ * Whether the stored buffered reflection and reflected line count are still the ones in
7113
+ * `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
7114
+ *
7115
+ * Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
7116
+ * count) after the caller's read. The activated text alone cannot tell the two apart: an
7117
+ * extension that repeats the unreflected tail and moves the cut past it produces the same text.
7118
+ * A snapshot without a buffered reflection (callers that never read one) is not checked.
7119
+ */
7120
+ function isBufferedReflectionUnchangedSince(stored, snapshot) {
7121
+ if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
7122
+ if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
7123
+ if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
7124
+ return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
7125
+ }
7126
+ /**
7127
+ * The generation a buffered-reflection swap just created, marked with
7128
+ * `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
7129
+ * `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
7130
+ * reflection was not checked, so its successor is returned unmarked. Always returns a new object,
7131
+ * so a store's own record is never handed out or mutated.
7132
+ */
7133
+ function withBufferedReflectionVerified(successor, snapshot) {
7134
+ if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
7135
+ return {
7136
+ ...successor,
7137
+ bufferedReflectionVerified: true
7138
+ };
7139
+ }
7111
7140
  // src/storage/db/run-fencing.ts
7112
7141
  /**
7113
7142
  * Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
@@ -9153,11 +9182,12 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
9153
9182
  details: { id: currentRecord.id }
9154
9183
  });
9155
9184
  if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return stored;
9185
+ if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return stored;
9156
9186
  const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
9157
9187
  const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
9158
9188
  const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
9159
9189
  const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
9160
- return this.rollOverOMRow(connection, stored.id, newObservations, tokenCount, input.newRecordId, true);
9190
+ return withBufferedReflectionVerified(await this.rollOverOMRow(connection, stored.id, newObservations, tokenCount, input.newRecordId, true), currentRecord);
9161
9191
  }, "swapBufferedReflectionToActive");
9162
9192
  } catch (error) {
9163
9193
  rethrowOrWrapOM(error, input.currentRecord.id, "SWAP_BUFFERED_REFLECTION_TO_ACTIVE");
@@ -13769,5 +13799,3 @@ exports.SkillsMySQL = SkillsMySQL;
13769
13799
  exports.StoreOperationsMySQL = StoreOperationsMySQL;
13770
13800
  exports.WorkflowsMySQL = WorkflowsMySQL;
13771
13801
  exports.WorkspacesMySQL = WorkspacesMySQL;
13772
-
13773
- //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -7107,6 +7107,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
7107
7107
  const snapshot = snapshotObservations ?? "";
7108
7108
  return stored === snapshot || stored.startsWith(snapshot);
7109
7109
  }
7110
+ /**
7111
+ * Whether the stored buffered reflection and reflected line count are still the ones in
7112
+ * `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
7113
+ *
7114
+ * Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
7115
+ * count) after the caller's read. The activated text alone cannot tell the two apart: an
7116
+ * extension that repeats the unreflected tail and moves the cut past it produces the same text.
7117
+ * A snapshot without a buffered reflection (callers that never read one) is not checked.
7118
+ */
7119
+ function isBufferedReflectionUnchangedSince(stored, snapshot) {
7120
+ if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
7121
+ if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
7122
+ if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
7123
+ return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
7124
+ }
7125
+ /**
7126
+ * The generation a buffered-reflection swap just created, marked with
7127
+ * `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
7128
+ * `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
7129
+ * reflection was not checked, so its successor is returned unmarked. Always returns a new object,
7130
+ * so a store's own record is never handed out or mutated.
7131
+ */
7132
+ function withBufferedReflectionVerified(successor, snapshot) {
7133
+ if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
7134
+ return {
7135
+ ...successor,
7136
+ bufferedReflectionVerified: true
7137
+ };
7138
+ }
7110
7139
  // src/storage/db/run-fencing.ts
7111
7140
  /**
7112
7141
  * Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
@@ -9152,11 +9181,12 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
9152
9181
  details: { id: currentRecord.id }
9153
9182
  });
9154
9183
  if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return stored;
9184
+ if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return stored;
9155
9185
  const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
9156
9186
  const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
9157
9187
  const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
9158
9188
  const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
9159
- return this.rollOverOMRow(connection, stored.id, newObservations, tokenCount, input.newRecordId, true);
9189
+ return withBufferedReflectionVerified(await this.rollOverOMRow(connection, stored.id, newObservations, tokenCount, input.newRecordId, true), currentRecord);
9160
9190
  }, "swapBufferedReflectionToActive");
9161
9191
  } catch (error) {
9162
9192
  rethrowOrWrapOM(error, input.currentRecord.id, "SWAP_BUFFERED_REFLECTION_TO_ACTIVE");
@@ -13753,5 +13783,3 @@ var MySQLStore = class extends MastraCompositeStore {
13753
13783
  }
13754
13784
  };
13755
13785
  export { AgentsMySQL, BlobsMySQL, DatasetsMySQL, ExperimentsMySQL, MCPClientsMySQL, MCPServersMySQL, MemoryMySQL, MySQLStore, ObservabilityMySQL, PromptBlocksMySQL, ScorerDefinitionsMySQL, ScoresMySQL, SkillsMySQL, StoreOperationsMySQL, WorkflowsMySQL, WorkspacesMySQL };
13756
-
13757
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mysql",
3
- "version": "0.17.1",
3
+ "version": "0.17.2-alpha.1",
4
4
  "description": "MySQL provider for Mastra - db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,17 +30,18 @@
30
30
  "tsx": "^4.23.15",
31
31
  "typescript": "^7.0.2",
32
32
  "vitest": "5.1.0",
33
- "@internal/lint": "0.0.150",
34
- "@mastra/core": "1.84.0",
35
- "@internal/types-builder": "0.0.125",
36
- "@internal/storage-test-utils": "0.0.146",
37
- "@internal/core": "0.1.4"
33
+ "@internal/lint": "0.0.151",
34
+ "@internal/core": "0.1.4",
35
+ "@internal/storage-test-utils": "0.0.147",
36
+ "@internal/types-builder": "0.0.126",
37
+ "@mastra/core": "1.86.0-alpha.7"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@mastra/core": ">=1.76.0-0 <2.0.0-0"
41
41
  },
42
42
  "files": [
43
- "dist"
43
+ "dist",
44
+ "!dist/**/*.d.*ts.map"
44
45
  ],
45
46
  "homepage": "https://mastra.ai",
46
47
  "repository": {