@mastra/mssql 1.12.0 → 1.12.1-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.
- package/dist/_types/@internal_core@0.1.4/dist/memory/index.d.ts +25 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +7 -7
- package/dist/index.cjs +31 -3
- package/dist/index.js +31 -3
- package/package.json +7 -6
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/storage/db/index.d.ts.map +0 -1
- package/dist/storage/db/run-fencing.d.ts.map +0 -1
- package/dist/storage/db/utils.d.ts.map +0 -1
- package/dist/storage/domains/agents/index.d.ts.map +0 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +0 -1
- package/dist/storage/domains/memory/index.d.ts.map +0 -1
- package/dist/storage/domains/memory/observational-memory.d.ts.map +0 -1
- package/dist/storage/domains/observability/index.d.ts.map +0 -1
- package/dist/storage/domains/scores/index.d.ts.map +0 -1
- package/dist/storage/domains/utils.d.ts.map +0 -1
- package/dist/storage/domains/workflow-definitions/index.d.ts.map +0 -1
- package/dist/storage/domains/workflows/index.d.ts.map +0 -1
- 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
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.12.
|
|
2
|
+
"version": "1.12.1-alpha.1",
|
|
3
3
|
"package": "@mastra/mssql",
|
|
4
4
|
"exports": {
|
|
5
5
|
"AgentsMSSQL": {
|
|
@@ -15,32 +15,32 @@
|
|
|
15
15
|
"MSSQLStore": {
|
|
16
16
|
"types": "dist/storage/index.d.ts",
|
|
17
17
|
"implementation": "dist/index.js",
|
|
18
|
-
"line":
|
|
18
|
+
"line": 6178
|
|
19
19
|
},
|
|
20
20
|
"MemoryMSSQL": {
|
|
21
21
|
"types": "dist/storage/domains/memory/index.d.ts",
|
|
22
22
|
"implementation": "dist/index.js",
|
|
23
|
-
"line":
|
|
23
|
+
"line": 3028
|
|
24
24
|
},
|
|
25
25
|
"ObservabilityMSSQL": {
|
|
26
26
|
"types": "dist/storage/domains/observability/index.d.ts",
|
|
27
27
|
"implementation": "dist/index.js",
|
|
28
|
-
"line":
|
|
28
|
+
"line": 4264
|
|
29
29
|
},
|
|
30
30
|
"ScoresMSSQL": {
|
|
31
31
|
"types": "dist/storage/domains/scores/index.d.ts",
|
|
32
32
|
"implementation": "dist/index.js",
|
|
33
|
-
"line":
|
|
33
|
+
"line": 4932
|
|
34
34
|
},
|
|
35
35
|
"WorkflowDefinitionsMSSQL": {
|
|
36
36
|
"types": "dist/storage/domains/workflow-definitions/index.d.ts",
|
|
37
37
|
"implementation": "dist/index.js",
|
|
38
|
-
"line":
|
|
38
|
+
"line": 5361
|
|
39
39
|
},
|
|
40
40
|
"WorkflowsMSSQL": {
|
|
41
41
|
"types": "dist/storage/domains/workflows/index.d.ts",
|
|
42
42
|
"implementation": "dist/index.js",
|
|
43
|
-
"line":
|
|
43
|
+
"line": 5557
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"modules": {}
|
package/dist/index.cjs
CHANGED
|
@@ -2257,6 +2257,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
2257
2257
|
const snapshot = snapshotObservations ?? "";
|
|
2258
2258
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
2259
2259
|
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Whether the stored buffered reflection and reflected line count are still the ones in
|
|
2262
|
+
* `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
|
|
2263
|
+
*
|
|
2264
|
+
* Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
|
|
2265
|
+
* count) after the caller's read. The activated text alone cannot tell the two apart: an
|
|
2266
|
+
* extension that repeats the unreflected tail and moves the cut past it produces the same text.
|
|
2267
|
+
* A snapshot without a buffered reflection (callers that never read one) is not checked.
|
|
2268
|
+
*/
|
|
2269
|
+
function isBufferedReflectionUnchangedSince(stored, snapshot) {
|
|
2270
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
|
|
2271
|
+
if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
|
|
2272
|
+
if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
|
|
2273
|
+
return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* The generation a buffered-reflection swap just created, marked with
|
|
2277
|
+
* `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
|
|
2278
|
+
* `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
|
|
2279
|
+
* reflection was not checked, so its successor is returned unmarked. Always returns a new object,
|
|
2280
|
+
* so a store's own record is never handed out or mutated.
|
|
2281
|
+
*/
|
|
2282
|
+
function withBufferedReflectionVerified(successor, snapshot) {
|
|
2283
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
|
|
2284
|
+
return {
|
|
2285
|
+
...successor,
|
|
2286
|
+
bufferedReflectionVerified: true
|
|
2287
|
+
};
|
|
2288
|
+
}
|
|
2260
2289
|
// src/storage/db/run-fencing.ts
|
|
2261
2290
|
/**
|
|
2262
2291
|
* Epoch milliseconds on the database clock. SQL Server evaluates
|
|
@@ -2770,11 +2799,12 @@ var MssqlObservationalMemory = class {
|
|
|
2770
2799
|
details: { id: currentRecord.id }
|
|
2771
2800
|
});
|
|
2772
2801
|
if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return stored;
|
|
2802
|
+
if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return stored;
|
|
2773
2803
|
const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
|
|
2774
2804
|
const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
2775
2805
|
const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
|
|
2776
2806
|
const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
|
|
2777
|
-
return this.#rollOver(transaction, stored.id, newObservations, tokenCount, input.newRecordId, true);
|
|
2807
|
+
return withBufferedReflectionVerified(await this.#rollOver(transaction, stored.id, newObservations, tokenCount, input.newRecordId, true), currentRecord);
|
|
2778
2808
|
}, "swapBufferedReflectionToActive");
|
|
2779
2809
|
} catch (error) {
|
|
2780
2810
|
rethrowOrWrap(error, "SWAP_BUFFERED_REFLECTION_TO_ACTIVE", { id: currentRecord.id });
|
|
@@ -6272,5 +6302,3 @@ exports.ObservabilityMSSQL = ObservabilityMSSQL;
|
|
|
6272
6302
|
exports.ScoresMSSQL = ScoresMSSQL;
|
|
6273
6303
|
exports.WorkflowDefinitionsMSSQL = WorkflowDefinitionsMSSQL;
|
|
6274
6304
|
exports.WorkflowsMSSQL = WorkflowsMSSQL;
|
|
6275
|
-
|
|
6276
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -2234,6 +2234,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
2234
2234
|
const snapshot = snapshotObservations ?? "";
|
|
2235
2235
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
2236
2236
|
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Whether the stored buffered reflection and reflected line count are still the ones in
|
|
2239
|
+
* `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
|
|
2240
|
+
*
|
|
2241
|
+
* Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
|
|
2242
|
+
* count) after the caller's read. The activated text alone cannot tell the two apart: an
|
|
2243
|
+
* extension that repeats the unreflected tail and moves the cut past it produces the same text.
|
|
2244
|
+
* A snapshot without a buffered reflection (callers that never read one) is not checked.
|
|
2245
|
+
*/
|
|
2246
|
+
function isBufferedReflectionUnchangedSince(stored, snapshot) {
|
|
2247
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
|
|
2248
|
+
if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
|
|
2249
|
+
if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
|
|
2250
|
+
return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* The generation a buffered-reflection swap just created, marked with
|
|
2254
|
+
* `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
|
|
2255
|
+
* `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
|
|
2256
|
+
* reflection was not checked, so its successor is returned unmarked. Always returns a new object,
|
|
2257
|
+
* so a store's own record is never handed out or mutated.
|
|
2258
|
+
*/
|
|
2259
|
+
function withBufferedReflectionVerified(successor, snapshot) {
|
|
2260
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
|
|
2261
|
+
return {
|
|
2262
|
+
...successor,
|
|
2263
|
+
bufferedReflectionVerified: true
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2237
2266
|
// src/storage/db/run-fencing.ts
|
|
2238
2267
|
/**
|
|
2239
2268
|
* Epoch milliseconds on the database clock. SQL Server evaluates
|
|
@@ -2747,11 +2776,12 @@ var MssqlObservationalMemory = class {
|
|
|
2747
2776
|
details: { id: currentRecord.id }
|
|
2748
2777
|
});
|
|
2749
2778
|
if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return stored;
|
|
2779
|
+
if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return stored;
|
|
2750
2780
|
const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
|
|
2751
2781
|
const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
2752
2782
|
const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
|
|
2753
2783
|
const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
|
|
2754
|
-
return this.#rollOver(transaction, stored.id, newObservations, tokenCount, input.newRecordId, true);
|
|
2784
|
+
return withBufferedReflectionVerified(await this.#rollOver(transaction, stored.id, newObservations, tokenCount, input.newRecordId, true), currentRecord);
|
|
2755
2785
|
}, "swapBufferedReflectionToActive");
|
|
2756
2786
|
} catch (error) {
|
|
2757
2787
|
rethrowOrWrap(error, "SWAP_BUFFERED_REFLECTION_TO_ACTIVE", { id: currentRecord.id });
|
|
@@ -6242,5 +6272,3 @@ var MSSQLStore = class extends MastraCompositeStore {
|
|
|
6242
6272
|
}
|
|
6243
6273
|
};
|
|
6244
6274
|
export { AgentsMSSQL, BackgroundTasksMSSQL, MSSQLStore, MemoryMSSQL, ObservabilityMSSQL, ScoresMSSQL, WorkflowDefinitionsMSSQL, WorkflowsMSSQL };
|
|
6245
|
-
|
|
6246
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mssql",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.1-alpha.1",
|
|
4
4
|
"description": "MSSQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"mssql": "^12.7.
|
|
23
|
+
"mssql": "^12.7.14"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/mssql": "^9.1.11",
|
|
@@ -31,17 +31,18 @@
|
|
|
31
31
|
"tsx": "^4.23.15",
|
|
32
32
|
"typescript": "^7.0.2",
|
|
33
33
|
"vitest": "5.1.0",
|
|
34
|
+
"@internal/types-builder": "0.0.126",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.147",
|
|
34
36
|
"@internal/core": "0.1.4",
|
|
35
37
|
"@internal/lint": "0.0.151",
|
|
36
|
-
"@
|
|
37
|
-
"@internal/types-builder": "0.0.126",
|
|
38
|
-
"@mastra/core": "1.85.0"
|
|
38
|
+
"@mastra/core": "1.86.0-alpha.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mastra/core": ">=1.76.0-0 <2.0.0-0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
|
-
"dist"
|
|
44
|
+
"dist",
|
|
45
|
+
"!dist/**/*.d.*ts.map"
|
|
45
46
|
],
|
|
46
47
|
"homepage": "https://mastra.ai",
|
|
47
48
|
"repository": {
|