@mastra/mssql 0.0.0-message-file-url-handling-fix-20250904234524 → 0.0.0-model-router-unknown-provider-20251017212006
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 +142 -3
- package/dist/index.cjs +85 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +85 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +8 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +2 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +11 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { MastraStorage, LegacyEvalsStorage, StoreOperations, TABLE_WORKFLOW_SNAP
|
|
|
3
3
|
import sql2 from 'mssql';
|
|
4
4
|
import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
|
|
5
5
|
import { MessageList } from '@mastra/core/agent';
|
|
6
|
+
import { saveScorePayloadSchema } from '@mastra/core/scores';
|
|
6
7
|
|
|
7
8
|
// src/storage/index.ts
|
|
8
9
|
function getSchemaName(schema) {
|
|
@@ -1473,6 +1474,19 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
1473
1474
|
}
|
|
1474
1475
|
}
|
|
1475
1476
|
async saveScore(score) {
|
|
1477
|
+
let validatedScore;
|
|
1478
|
+
try {
|
|
1479
|
+
validatedScore = saveScorePayloadSchema.parse(score);
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
throw new MastraError(
|
|
1482
|
+
{
|
|
1483
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_SCORE_VALIDATION_FAILED",
|
|
1484
|
+
domain: ErrorDomain.STORAGE,
|
|
1485
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1486
|
+
},
|
|
1487
|
+
error
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1476
1490
|
try {
|
|
1477
1491
|
const scoreId = crypto.randomUUID();
|
|
1478
1492
|
const {
|
|
@@ -1486,7 +1500,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
1486
1500
|
runtimeContext,
|
|
1487
1501
|
entity,
|
|
1488
1502
|
...rest
|
|
1489
|
-
} =
|
|
1503
|
+
} = validatedScore;
|
|
1490
1504
|
await this.operations.insert({
|
|
1491
1505
|
tableName: TABLE_SCORERS,
|
|
1492
1506
|
record: {
|
|
@@ -1671,6 +1685,60 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
1671
1685
|
);
|
|
1672
1686
|
}
|
|
1673
1687
|
}
|
|
1688
|
+
async getScoresBySpan({
|
|
1689
|
+
traceId,
|
|
1690
|
+
spanId,
|
|
1691
|
+
pagination
|
|
1692
|
+
}) {
|
|
1693
|
+
try {
|
|
1694
|
+
const request = this.pool.request();
|
|
1695
|
+
request.input("p1", traceId);
|
|
1696
|
+
request.input("p2", spanId);
|
|
1697
|
+
const totalResult = await request.query(
|
|
1698
|
+
`SELECT COUNT(*) as count FROM ${getTableName({ indexName: TABLE_SCORERS, schemaName: getSchemaName(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2`
|
|
1699
|
+
);
|
|
1700
|
+
const total = totalResult.recordset[0]?.count || 0;
|
|
1701
|
+
if (total === 0) {
|
|
1702
|
+
return {
|
|
1703
|
+
pagination: {
|
|
1704
|
+
total: 0,
|
|
1705
|
+
page: pagination.page,
|
|
1706
|
+
perPage: pagination.perPage,
|
|
1707
|
+
hasMore: false
|
|
1708
|
+
},
|
|
1709
|
+
scores: []
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
const limit = pagination.perPage + 1;
|
|
1713
|
+
const dataRequest = this.pool.request();
|
|
1714
|
+
dataRequest.input("p1", traceId);
|
|
1715
|
+
dataRequest.input("p2", spanId);
|
|
1716
|
+
dataRequest.input("p3", limit);
|
|
1717
|
+
dataRequest.input("p4", pagination.page * pagination.perPage);
|
|
1718
|
+
const result = await dataRequest.query(
|
|
1719
|
+
`SELECT * FROM ${getTableName({ indexName: TABLE_SCORERS, schemaName: getSchemaName(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2 ORDER BY [createdAt] DESC OFFSET @p4 ROWS FETCH NEXT @p3 ROWS ONLY`
|
|
1720
|
+
);
|
|
1721
|
+
return {
|
|
1722
|
+
pagination: {
|
|
1723
|
+
total: Number(total),
|
|
1724
|
+
page: pagination.page,
|
|
1725
|
+
perPage: pagination.perPage,
|
|
1726
|
+
hasMore: result.recordset.length > pagination.perPage
|
|
1727
|
+
},
|
|
1728
|
+
scores: result.recordset.slice(0, pagination.perPage).map((row) => transformScoreRow(row))
|
|
1729
|
+
};
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
throw new MastraError(
|
|
1732
|
+
{
|
|
1733
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_SPAN_FAILED",
|
|
1734
|
+
domain: ErrorDomain.STORAGE,
|
|
1735
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1736
|
+
details: { traceId, spanId }
|
|
1737
|
+
},
|
|
1738
|
+
error
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1674
1742
|
};
|
|
1675
1743
|
var TracesMSSQL = class extends TracesStorage {
|
|
1676
1744
|
pool;
|
|
@@ -1890,6 +1958,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
1890
1958
|
async persistWorkflowSnapshot({
|
|
1891
1959
|
workflowName,
|
|
1892
1960
|
runId,
|
|
1961
|
+
resourceId,
|
|
1893
1962
|
snapshot
|
|
1894
1963
|
}) {
|
|
1895
1964
|
const table = getTableName({ indexName: TABLE_WORKFLOW_SNAPSHOT, schemaName: getSchemaName(this.schema) });
|
|
@@ -1898,6 +1967,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
1898
1967
|
const request = this.pool.request();
|
|
1899
1968
|
request.input("workflow_name", workflowName);
|
|
1900
1969
|
request.input("run_id", runId);
|
|
1970
|
+
request.input("resourceId", resourceId);
|
|
1901
1971
|
request.input("snapshot", JSON.stringify(snapshot));
|
|
1902
1972
|
request.input("createdAt", sql2.DateTime2, new Date(now));
|
|
1903
1973
|
request.input("updatedAt", sql2.DateTime2, new Date(now));
|
|
@@ -1905,10 +1975,11 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
1905
1975
|
USING (SELECT @workflow_name AS workflow_name, @run_id AS run_id) AS src
|
|
1906
1976
|
ON target.workflow_name = src.workflow_name AND target.run_id = src.run_id
|
|
1907
1977
|
WHEN MATCHED THEN UPDATE SET
|
|
1978
|
+
resourceId = @resourceId,
|
|
1908
1979
|
snapshot = @snapshot,
|
|
1909
1980
|
[updatedAt] = @updatedAt
|
|
1910
|
-
WHEN NOT MATCHED THEN INSERT (workflow_name, run_id, snapshot, [createdAt], [updatedAt])
|
|
1911
|
-
VALUES (@workflow_name, @run_id, @snapshot, @createdAt, @updatedAt);`;
|
|
1981
|
+
WHEN NOT MATCHED THEN INSERT (workflow_name, run_id, resourceId, snapshot, [createdAt], [updatedAt])
|
|
1982
|
+
VALUES (@workflow_name, @run_id, @resourceId, @snapshot, @createdAt, @updatedAt);`;
|
|
1912
1983
|
await request.query(mergeSql);
|
|
1913
1984
|
} catch (error) {
|
|
1914
1985
|
throw new MastraError(
|
|
@@ -2157,7 +2228,8 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
2157
2228
|
resourceWorkingMemory: true,
|
|
2158
2229
|
hasColumn: true,
|
|
2159
2230
|
createTable: true,
|
|
2160
|
-
deleteMessages: true
|
|
2231
|
+
deleteMessages: true,
|
|
2232
|
+
getScoresBySpan: true
|
|
2161
2233
|
};
|
|
2162
2234
|
}
|
|
2163
2235
|
/** @deprecated use getEvals instead */
|
|
@@ -2293,9 +2365,10 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
2293
2365
|
async persistWorkflowSnapshot({
|
|
2294
2366
|
workflowName,
|
|
2295
2367
|
runId,
|
|
2368
|
+
resourceId,
|
|
2296
2369
|
snapshot
|
|
2297
2370
|
}) {
|
|
2298
|
-
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
2371
|
+
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
|
|
2299
2372
|
}
|
|
2300
2373
|
async loadWorkflowSnapshot({
|
|
2301
2374
|
workflowName,
|
|
@@ -2354,6 +2427,13 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
2354
2427
|
pagination: _pagination
|
|
2355
2428
|
});
|
|
2356
2429
|
}
|
|
2430
|
+
async getScoresBySpan({
|
|
2431
|
+
traceId,
|
|
2432
|
+
spanId,
|
|
2433
|
+
pagination: _pagination
|
|
2434
|
+
}) {
|
|
2435
|
+
return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination: _pagination });
|
|
2436
|
+
}
|
|
2357
2437
|
};
|
|
2358
2438
|
|
|
2359
2439
|
export { MSSQLStore };
|