@mastra/mssql 0.0.0-mssql-store-20250804200341 → 0.0.0-netlify-no-bundle-20251127120354
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 +938 -3
- package/README.md +324 -37
- package/dist/index.cjs +1741 -688
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1743 -690
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +16 -37
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +44 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +67 -4
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +15 -6
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts +19 -0
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +25 -11
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +91 -73
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +31 -12
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -20
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -37
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
- package/docker-compose.yaml +0 -14
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -2
- package/src/storage/domains/legacy-evals/index.ts +0 -175
- package/src/storage/domains/memory/index.ts +0 -1024
- package/src/storage/domains/operations/index.ts +0 -401
- package/src/storage/domains/scores/index.ts +0 -289
- package/src/storage/domains/traces/index.ts +0 -212
- package/src/storage/domains/utils.ts +0 -12
- package/src/storage/domains/workflows/index.ts +0 -259
- package/src/storage/index.test.ts +0 -2228
- package/src/storage/index.ts +0 -448
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -22
- package/vitest.config.ts +0 -12
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { MastraMessageContentV2,
|
|
2
|
-
|
|
1
|
+
import type { MastraMessageContentV2, MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
3
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
4
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
+
export type MastraDBMessageWithTypedContent = Omit<MastraDBMessage, 'content'> & {
|
|
3
6
|
content: MastraMessageContentV2;
|
|
4
7
|
};
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
8
|
-
import type { EvalRow, PaginationInfo, StorageColumn, StorageGetMessagesArg, StorageResourceType, TABLE_NAMES, WorkflowRun, WorkflowRuns, PaginationArgs, StoragePagination, ThreadSortOptions, StorageDomains, StorageGetTracesArg, StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
9
|
-
import type { Trace } from '@mastra/core/telemetry';
|
|
10
|
-
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
8
|
+
import type { PaginationInfo, StorageColumn, StorageResourceType, TABLE_NAMES, WorkflowRun, WorkflowRuns, StoragePagination, StorageDomains, SpanRecord, TraceRecord, TracesPaginatedArg, UpdateSpanRecord, CreateIndexOptions, IndexInfo, StorageIndexStats, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
9
|
+
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
11
10
|
import sql from 'mssql';
|
|
12
11
|
export type MSSQLConfigType = {
|
|
12
|
+
id: string;
|
|
13
13
|
schemaName?: string;
|
|
14
14
|
} & ({
|
|
15
15
|
server: string;
|
|
@@ -36,25 +36,10 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
36
36
|
hasColumn: boolean;
|
|
37
37
|
createTable: boolean;
|
|
38
38
|
deleteMessages: boolean;
|
|
39
|
+
listScoresBySpan: boolean;
|
|
40
|
+
observabilityInstance: boolean;
|
|
41
|
+
indexManagement: boolean;
|
|
39
42
|
};
|
|
40
|
-
/** @deprecated use getEvals instead */
|
|
41
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
42
|
-
getEvals(options?: {
|
|
43
|
-
agentName?: string;
|
|
44
|
-
type?: 'test' | 'live';
|
|
45
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
46
|
-
evals: EvalRow[];
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated use getTracesPaginated instead
|
|
50
|
-
*/
|
|
51
|
-
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
52
|
-
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
53
|
-
traces: Trace[];
|
|
54
|
-
}>;
|
|
55
|
-
batchTraceInsert({ records }: {
|
|
56
|
-
records: Record<string, any>[];
|
|
57
|
-
}): Promise<void>;
|
|
58
43
|
createTable({ tableName, schema, }: {
|
|
59
44
|
tableName: TABLE_NAMES;
|
|
60
45
|
schema: Record<string, StorageColumn>;
|
|
@@ -88,19 +73,6 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
88
73
|
getThreadById({ threadId }: {
|
|
89
74
|
threadId: string;
|
|
90
75
|
}): Promise<StorageThreadType | null>;
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
93
|
-
*/
|
|
94
|
-
getThreadsByResourceId(args: {
|
|
95
|
-
resourceId: string;
|
|
96
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
97
|
-
getThreadsByResourceIdPaginated(args: {
|
|
98
|
-
resourceId: string;
|
|
99
|
-
page: number;
|
|
100
|
-
perPage: number;
|
|
101
|
-
} & ThreadSortOptions): Promise<PaginationInfo & {
|
|
102
|
-
threads: StorageThreadType[];
|
|
103
|
-
}>;
|
|
104
76
|
saveThread({ thread }: {
|
|
105
77
|
thread: StorageThreadType;
|
|
106
78
|
}): Promise<StorageThreadType>;
|
|
@@ -112,37 +84,25 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
112
84
|
deleteThread({ threadId }: {
|
|
113
85
|
threadId: string;
|
|
114
86
|
}): Promise<void>;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
format?: 'v1';
|
|
120
|
-
}): Promise<MastraMessageV1[]>;
|
|
121
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
122
|
-
format: 'v2';
|
|
123
|
-
}): Promise<MastraMessageV2[]>;
|
|
124
|
-
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
125
|
-
format?: 'v1' | 'v2';
|
|
126
|
-
}): Promise<PaginationInfo & {
|
|
127
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
87
|
+
listMessagesById({ messageIds }: {
|
|
88
|
+
messageIds: string[];
|
|
89
|
+
}): Promise<{
|
|
90
|
+
messages: MastraDBMessage[];
|
|
128
91
|
}>;
|
|
129
92
|
saveMessages(args: {
|
|
130
|
-
messages:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
messages: MastraMessageV2[];
|
|
135
|
-
format: 'v2';
|
|
136
|
-
}): Promise<MastraMessageV2[]>;
|
|
93
|
+
messages: MastraDBMessage[];
|
|
94
|
+
}): Promise<{
|
|
95
|
+
messages: MastraDBMessage[];
|
|
96
|
+
}>;
|
|
137
97
|
updateMessages({ messages, }: {
|
|
138
|
-
messages: (Partial<Omit<
|
|
98
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
139
99
|
id: string;
|
|
140
100
|
content?: {
|
|
141
101
|
metadata?: MastraMessageContentV2['metadata'];
|
|
142
102
|
content?: MastraMessageContentV2['content'];
|
|
143
103
|
};
|
|
144
104
|
})[];
|
|
145
|
-
}): Promise<
|
|
105
|
+
}): Promise<MastraDBMessage[]>;
|
|
146
106
|
deleteMessages(messageIds: string[]): Promise<void>;
|
|
147
107
|
getResourceById({ resourceId }: {
|
|
148
108
|
resourceId: string;
|
|
@@ -158,37 +118,87 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
158
118
|
/**
|
|
159
119
|
* Workflows
|
|
160
120
|
*/
|
|
161
|
-
|
|
121
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
122
|
+
workflowName: string;
|
|
123
|
+
runId: string;
|
|
124
|
+
stepId: string;
|
|
125
|
+
result: StepResult<any, any, any, any>;
|
|
126
|
+
requestContext: Record<string, any>;
|
|
127
|
+
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
128
|
+
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
162
129
|
workflowName: string;
|
|
163
130
|
runId: string;
|
|
131
|
+
opts: {
|
|
132
|
+
status: string;
|
|
133
|
+
result?: StepResult<any, any, any, any>;
|
|
134
|
+
error?: string;
|
|
135
|
+
suspendedPaths?: Record<string, number[]>;
|
|
136
|
+
waitingPaths?: Record<string, number[]>;
|
|
137
|
+
};
|
|
138
|
+
}): Promise<WorkflowRunState | undefined>;
|
|
139
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
140
|
+
workflowName: string;
|
|
141
|
+
runId: string;
|
|
142
|
+
resourceId?: string;
|
|
164
143
|
snapshot: WorkflowRunState;
|
|
165
144
|
}): Promise<void>;
|
|
166
145
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
167
146
|
workflowName: string;
|
|
168
147
|
runId: string;
|
|
169
148
|
}): Promise<WorkflowRunState | null>;
|
|
170
|
-
|
|
171
|
-
workflowName?: string;
|
|
172
|
-
fromDate?: Date;
|
|
173
|
-
toDate?: Date;
|
|
174
|
-
limit?: number;
|
|
175
|
-
offset?: number;
|
|
176
|
-
resourceId?: string;
|
|
177
|
-
}): Promise<WorkflowRuns>;
|
|
149
|
+
listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
178
150
|
getWorkflowRunById({ runId, workflowName, }: {
|
|
179
151
|
runId: string;
|
|
180
152
|
workflowName?: string;
|
|
181
153
|
}): Promise<WorkflowRun | null>;
|
|
182
154
|
close(): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Index Management
|
|
157
|
+
*/
|
|
158
|
+
createIndex(options: CreateIndexOptions): Promise<void>;
|
|
159
|
+
listIndexes(tableName?: string): Promise<IndexInfo[]>;
|
|
160
|
+
describeIndex(indexName: string): Promise<StorageIndexStats>;
|
|
161
|
+
dropIndex(indexName: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Tracing / Observability
|
|
164
|
+
*/
|
|
165
|
+
private getObservabilityStore;
|
|
166
|
+
createSpan(span: SpanRecord): Promise<void>;
|
|
167
|
+
updateSpan({ spanId, traceId, updates, }: {
|
|
168
|
+
spanId: string;
|
|
169
|
+
traceId: string;
|
|
170
|
+
updates: Partial<UpdateSpanRecord>;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
getTrace(traceId: string): Promise<TraceRecord | null>;
|
|
173
|
+
getTracesPaginated(args: TracesPaginatedArg): Promise<{
|
|
174
|
+
pagination: PaginationInfo;
|
|
175
|
+
spans: SpanRecord[];
|
|
176
|
+
}>;
|
|
177
|
+
batchCreateSpans(args: {
|
|
178
|
+
records: SpanRecord[];
|
|
179
|
+
}): Promise<void>;
|
|
180
|
+
batchUpdateSpans(args: {
|
|
181
|
+
records: {
|
|
182
|
+
traceId: string;
|
|
183
|
+
spanId: string;
|
|
184
|
+
updates: Partial<UpdateSpanRecord>;
|
|
185
|
+
}[];
|
|
186
|
+
}): Promise<void>;
|
|
187
|
+
batchDeleteTraces(args: {
|
|
188
|
+
traceIds: string[];
|
|
189
|
+
}): Promise<void>;
|
|
183
190
|
/**
|
|
184
191
|
* Scorers
|
|
185
192
|
*/
|
|
186
193
|
getScoreById({ id: _id }: {
|
|
187
194
|
id: string;
|
|
188
195
|
}): Promise<ScoreRowData | null>;
|
|
189
|
-
|
|
196
|
+
listScoresByScorerId({ scorerId: _scorerId, pagination: _pagination, entityId: _entityId, entityType: _entityType, source: _source, }: {
|
|
190
197
|
scorerId: string;
|
|
191
198
|
pagination: StoragePagination;
|
|
199
|
+
entityId?: string;
|
|
200
|
+
entityType?: string;
|
|
201
|
+
source?: ScoringSource;
|
|
192
202
|
}): Promise<{
|
|
193
203
|
pagination: PaginationInfo;
|
|
194
204
|
scores: ScoreRowData[];
|
|
@@ -196,14 +206,14 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
196
206
|
saveScore(_score: ScoreRowData): Promise<{
|
|
197
207
|
score: ScoreRowData;
|
|
198
208
|
}>;
|
|
199
|
-
|
|
209
|
+
listScoresByRunId({ runId: _runId, pagination: _pagination, }: {
|
|
200
210
|
runId: string;
|
|
201
211
|
pagination: StoragePagination;
|
|
202
212
|
}): Promise<{
|
|
203
213
|
pagination: PaginationInfo;
|
|
204
214
|
scores: ScoreRowData[];
|
|
205
215
|
}>;
|
|
206
|
-
|
|
216
|
+
listScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
|
|
207
217
|
pagination: StoragePagination;
|
|
208
218
|
entityId: string;
|
|
209
219
|
entityType: string;
|
|
@@ -211,5 +221,13 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
211
221
|
pagination: PaginationInfo;
|
|
212
222
|
scores: ScoreRowData[];
|
|
213
223
|
}>;
|
|
224
|
+
listScoresBySpan({ traceId, spanId, pagination: _pagination, }: {
|
|
225
|
+
traceId: string;
|
|
226
|
+
spanId: string;
|
|
227
|
+
pagination: StoragePagination;
|
|
228
|
+
}): Promise<{
|
|
229
|
+
pagination: PaginationInfo;
|
|
230
|
+
scores: ScoreRowData[];
|
|
231
|
+
}>;
|
|
214
232
|
}
|
|
215
233
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElF,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,sBAAsB,CAAA;CAAE,CAAC;AACrH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,GAAG,MAAM,OAAO,CAAC;AAOxB,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,CACA;IACE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,E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EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,oBAAoB,CAAC,EACzB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,WAAW,EACvB,UAAU,EAAE,WAAW,GACxB,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAQ7D,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,EAAE,WAAW,GACxB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CAGpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mssql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-netlify-no-bundle-20251127120354",
|
|
4
4
|
"description": "MSSQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,30 +12,49 @@
|
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./dist/index.d.
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"mssql": "^
|
|
23
|
+
"mssql": "^11.0.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.8",
|
|
27
|
-
"@types/mssql": "^9.1.
|
|
28
|
-
"@types/node": "
|
|
29
|
-
"
|
|
27
|
+
"@types/mssql": "^9.1.8",
|
|
28
|
+
"@types/node": "22.13.17",
|
|
29
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
30
|
+
"@vitest/ui": "4.0.12",
|
|
31
|
+
"eslint": "^9.37.0",
|
|
30
32
|
"tsup": "^8.5.0",
|
|
31
33
|
"typescript": "^5.8.3",
|
|
32
|
-
"vitest": "
|
|
33
|
-
"@internal/lint": "0.0.0-
|
|
34
|
-
"@
|
|
35
|
-
"@internal/
|
|
34
|
+
"vitest": "4.0.12",
|
|
35
|
+
"@internal/lint": "0.0.0-netlify-no-bundle-20251127120354",
|
|
36
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
37
|
+
"@internal/types-builder": "0.0.0-netlify-no-bundle-20251127120354",
|
|
38
|
+
"@mastra/core": "0.0.0-netlify-no-bundle-20251127120354"
|
|
36
39
|
},
|
|
37
40
|
"peerDependencies": {
|
|
38
|
-
"@mastra/core": "0.0.0-
|
|
41
|
+
"@mastra/core": "0.0.0-netlify-no-bundle-20251127120354"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"CHANGELOG.md"
|
|
46
|
+
],
|
|
47
|
+
"homepage": "https://mastra.ai",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
51
|
+
"directory": "stores/mssql"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=22.13.0"
|
|
39
58
|
},
|
|
40
59
|
"scripts": {
|
|
41
60
|
"build": "tsup --silent --config tsup.config.ts",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { PaginationArgs, PaginationInfo, EvalRow } from '@mastra/core/storage';
|
|
3
|
-
import sql from 'mssql';
|
|
4
|
-
export declare class LegacyEvalsMSSQL extends LegacyEvalsStorage {
|
|
5
|
-
private pool;
|
|
6
|
-
private schema;
|
|
7
|
-
constructor({ pool, schema }: {
|
|
8
|
-
pool: sql.ConnectionPool;
|
|
9
|
-
schema: string;
|
|
10
|
-
});
|
|
11
|
-
/** @deprecated use getEvals instead */
|
|
12
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
13
|
-
getEvals(options?: {
|
|
14
|
-
agentName?: string;
|
|
15
|
-
type?: 'test' | 'live';
|
|
16
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
17
|
-
evals: EvalRow[];
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/legacy-evals/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAe,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,GAAG,MAAM,OAAO,CAAC;AA8BxB,qBAAa,gBAAiB,SAAQ,kBAAkB;IACtD,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,MAAM,CAAS;gBACX,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAAE,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAM1E,uCAAuC;IACjC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA0BlF,QAAQ,CACZ,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,GAAG,cAAmB,GACtB,OAAO,CAAC,cAAc,GAAG;QAAE,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;CAmGlD"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { PaginationInfo, PaginationArgs } from '@mastra/core/storage';
|
|
2
|
-
import { TracesStorage } from '@mastra/core/storage';
|
|
3
|
-
import sql from 'mssql';
|
|
4
|
-
import type { StoreOperationsMSSQL } from '../operations';
|
|
5
|
-
export declare class TracesMSSQL extends TracesStorage {
|
|
6
|
-
pool: sql.ConnectionPool;
|
|
7
|
-
private operations;
|
|
8
|
-
private schema?;
|
|
9
|
-
constructor({ pool, operations, schema, }: {
|
|
10
|
-
pool: sql.ConnectionPool;
|
|
11
|
-
operations: StoreOperationsMSSQL;
|
|
12
|
-
schema?: string;
|
|
13
|
-
});
|
|
14
|
-
/** @deprecated use getTracesPaginated instead*/
|
|
15
|
-
getTraces(args: {
|
|
16
|
-
name?: string;
|
|
17
|
-
scope?: string;
|
|
18
|
-
attributes?: Record<string, string>;
|
|
19
|
-
filters?: Record<string, any>;
|
|
20
|
-
page: number;
|
|
21
|
-
perPage?: number;
|
|
22
|
-
fromDate?: Date;
|
|
23
|
-
toDate?: Date;
|
|
24
|
-
}): Promise<any[]>;
|
|
25
|
-
getTracesPaginated(args: {
|
|
26
|
-
name?: string;
|
|
27
|
-
scope?: string;
|
|
28
|
-
attributes?: Record<string, string>;
|
|
29
|
-
filters?: Record<string, any>;
|
|
30
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
31
|
-
traces: any[];
|
|
32
|
-
}>;
|
|
33
|
-
batchTraceInsert({ records }: {
|
|
34
|
-
records: Record<string, any>[];
|
|
35
|
-
}): Promise<void>;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/traces/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAgB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,qBAAa,WAAY,SAAQ,aAAa;IACrC,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,EACV,IAAI,EACJ,UAAU,EACV,MAAM,GACP,EAAE;QACD,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC;QACzB,UAAU,EAAE,oBAAoB,CAAC;QACjC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAOD,gDAAgD;IACnC,SAAS,CAAC,IAAI,EAAE;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;KACf,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAWL,kBAAkB,CAC7B,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,GAAG,cAAc,GACjB,OAAO,CACR,cAAc,GAAG;QACf,MAAM,EAAE,GAAG,EAAE,CAAC;KACf,CACF;IAgJK,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvF"}
|
package/docker-compose.yaml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
mssql:
|
|
3
|
-
image: mcr.microsoft.com/mssql/server:2025-latest
|
|
4
|
-
environment:
|
|
5
|
-
- ACCEPT_EULA=Y
|
|
6
|
-
- SA_PASSWORD=Your_password123
|
|
7
|
-
ports:
|
|
8
|
-
- '1433:1433'
|
|
9
|
-
healthcheck:
|
|
10
|
-
test: ['CMD-SHELL', 'echo > /dev/tcp/localhost/1433']
|
|
11
|
-
interval: 10s
|
|
12
|
-
timeout: 5s
|
|
13
|
-
retries: 10
|
|
14
|
-
start_period: 20s
|
package/eslint.config.js
DELETED
package/src/index.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
2
|
-
import type { MetricResult } from '@mastra/core/eval';
|
|
3
|
-
import { LegacyEvalsStorage, TABLE_EVALS } from '@mastra/core/storage';
|
|
4
|
-
import type { PaginationArgs, PaginationInfo, EvalRow } from '@mastra/core/storage';
|
|
5
|
-
import sql from 'mssql';
|
|
6
|
-
import { getSchemaName, getTableName } from '../utils';
|
|
7
|
-
|
|
8
|
-
function transformEvalRow(row: Record<string, any>): EvalRow {
|
|
9
|
-
let testInfoValue = null,
|
|
10
|
-
resultValue = null;
|
|
11
|
-
if (row.test_info) {
|
|
12
|
-
try {
|
|
13
|
-
testInfoValue = typeof row.test_info === 'string' ? JSON.parse(row.test_info) : row.test_info;
|
|
14
|
-
} catch {}
|
|
15
|
-
}
|
|
16
|
-
if (row.test_info) {
|
|
17
|
-
try {
|
|
18
|
-
resultValue = typeof row.result === 'string' ? JSON.parse(row.result) : row.result;
|
|
19
|
-
} catch {}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
agentName: row.agent_name as string,
|
|
23
|
-
input: row.input as string,
|
|
24
|
-
output: row.output as string,
|
|
25
|
-
result: resultValue as MetricResult,
|
|
26
|
-
metricName: row.metric_name as string,
|
|
27
|
-
instructions: row.instructions as string,
|
|
28
|
-
testInfo: testInfoValue,
|
|
29
|
-
globalRunId: row.global_run_id as string,
|
|
30
|
-
runId: row.run_id as string,
|
|
31
|
-
createdAt: row.created_at as string,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class LegacyEvalsMSSQL extends LegacyEvalsStorage {
|
|
36
|
-
private pool: sql.ConnectionPool;
|
|
37
|
-
private schema: string;
|
|
38
|
-
constructor({ pool, schema }: { pool: sql.ConnectionPool; schema: string }) {
|
|
39
|
-
super();
|
|
40
|
-
this.pool = pool;
|
|
41
|
-
this.schema = schema;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** @deprecated use getEvals instead */
|
|
45
|
-
async getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]> {
|
|
46
|
-
try {
|
|
47
|
-
let query = `SELECT * FROM ${getTableName({ indexName: TABLE_EVALS, schemaName: getSchemaName(this.schema) })} WHERE agent_name = @p1`;
|
|
48
|
-
if (type === 'test') {
|
|
49
|
-
query += " AND test_info IS NOT NULL AND JSON_VALUE(test_info, '$.testPath') IS NOT NULL";
|
|
50
|
-
} else if (type === 'live') {
|
|
51
|
-
query += " AND (test_info IS NULL OR JSON_VALUE(test_info, '$.testPath') IS NULL)";
|
|
52
|
-
}
|
|
53
|
-
query += ' ORDER BY created_at DESC';
|
|
54
|
-
|
|
55
|
-
const request = this.pool.request();
|
|
56
|
-
request.input('p1', agentName);
|
|
57
|
-
const result = await request.query(query);
|
|
58
|
-
const rows = result.recordset;
|
|
59
|
-
return typeof transformEvalRow === 'function'
|
|
60
|
-
? (rows?.map((row: any) => transformEvalRow(row)) ?? [])
|
|
61
|
-
: (rows ?? []);
|
|
62
|
-
} catch (error: any) {
|
|
63
|
-
if (error && error.number === 208 && error.message && error.message.includes('Invalid object name')) {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
console.error('Failed to get evals for the specified agent: ' + error?.message);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async getEvals(
|
|
72
|
-
options: {
|
|
73
|
-
agentName?: string;
|
|
74
|
-
type?: 'test' | 'live';
|
|
75
|
-
} & PaginationArgs = {},
|
|
76
|
-
): Promise<PaginationInfo & { evals: EvalRow[] }> {
|
|
77
|
-
const { agentName, type, page = 0, perPage = 100, dateRange } = options;
|
|
78
|
-
const fromDate = dateRange?.start;
|
|
79
|
-
const toDate = dateRange?.end;
|
|
80
|
-
|
|
81
|
-
const where: string[] = [];
|
|
82
|
-
const params: Record<string, any> = {};
|
|
83
|
-
|
|
84
|
-
if (agentName) {
|
|
85
|
-
where.push('agent_name = @agentName');
|
|
86
|
-
params['agentName'] = agentName;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (type === 'test') {
|
|
90
|
-
where.push("test_info IS NOT NULL AND JSON_VALUE(test_info, '$.testPath') IS NOT NULL");
|
|
91
|
-
} else if (type === 'live') {
|
|
92
|
-
where.push("(test_info IS NULL OR JSON_VALUE(test_info, '$.testPath') IS NULL)");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (fromDate instanceof Date && !isNaN(fromDate.getTime())) {
|
|
96
|
-
where.push(`[created_at] >= @fromDate`);
|
|
97
|
-
params[`fromDate`] = fromDate.toISOString();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (toDate instanceof Date && !isNaN(toDate.getTime())) {
|
|
101
|
-
where.push(`[created_at] <= @toDate`);
|
|
102
|
-
params[`toDate`] = toDate.toISOString();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const whereClause = where.length > 0 ? `WHERE ${where.join(' AND ')}` : '';
|
|
106
|
-
const tableName = getTableName({ indexName: TABLE_EVALS, schemaName: getSchemaName(this.schema) });
|
|
107
|
-
const offset = page * perPage;
|
|
108
|
-
|
|
109
|
-
const countQuery = `SELECT COUNT(*) as total FROM ${tableName} ${whereClause}`;
|
|
110
|
-
const dataQuery = `SELECT * FROM ${tableName} ${whereClause} ORDER BY seq_id DESC OFFSET @offset ROWS FETCH NEXT @perPage ROWS ONLY`;
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const countReq = this.pool.request();
|
|
114
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
115
|
-
if (value instanceof Date) {
|
|
116
|
-
countReq.input(key, sql.DateTime, value);
|
|
117
|
-
} else {
|
|
118
|
-
countReq.input(key, value);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
const countResult = await countReq.query(countQuery);
|
|
122
|
-
const total = countResult.recordset[0]?.total || 0;
|
|
123
|
-
|
|
124
|
-
if (total === 0) {
|
|
125
|
-
return {
|
|
126
|
-
evals: [],
|
|
127
|
-
total: 0,
|
|
128
|
-
page,
|
|
129
|
-
perPage,
|
|
130
|
-
hasMore: false,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const req = this.pool.request();
|
|
135
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
136
|
-
if (value instanceof Date) {
|
|
137
|
-
req.input(key, sql.DateTime, value);
|
|
138
|
-
} else {
|
|
139
|
-
req.input(key, value);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
req.input('offset', offset);
|
|
143
|
-
req.input('perPage', perPage);
|
|
144
|
-
|
|
145
|
-
const result = await req.query(dataQuery);
|
|
146
|
-
const rows = result.recordset;
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
evals: rows?.map(row => transformEvalRow(row)) ?? [],
|
|
150
|
-
total,
|
|
151
|
-
page,
|
|
152
|
-
perPage,
|
|
153
|
-
hasMore: offset + (rows?.length ?? 0) < total,
|
|
154
|
-
};
|
|
155
|
-
} catch (error) {
|
|
156
|
-
const mastraError = new MastraError(
|
|
157
|
-
{
|
|
158
|
-
id: 'MASTRA_STORAGE_MSSQL_STORE_GET_EVALS_FAILED',
|
|
159
|
-
domain: ErrorDomain.STORAGE,
|
|
160
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
161
|
-
details: {
|
|
162
|
-
agentName: agentName || 'all',
|
|
163
|
-
type: type || 'all',
|
|
164
|
-
page,
|
|
165
|
-
perPage,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
error,
|
|
169
|
-
);
|
|
170
|
-
this.logger?.error?.(mastraError.toString());
|
|
171
|
-
this.logger?.trackException(mastraError);
|
|
172
|
-
throw mastraError;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|