@mastra/mssql 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vnext-20251104230439
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 +399 -3
- package/README.md +315 -36
- package/dist/index.cjs +1687 -710
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1689 -712
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +18 -41
- 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 +13 -4
- 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 +9 -13
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +76 -79
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +23 -10
- 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 -1084
- package/src/storage/domains/operations/index.ts +0 -401
- package/src/storage/domains/scores/index.ts +0 -316
- 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 -296
- package/src/storage/index.test.ts +0 -2228
- package/src/storage/index.ts +0 -494
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.ts +0 -12
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
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 { ScoreRowData } from '@mastra/core/scores';
|
|
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';
|
|
8
|
+
import type { PaginationInfo, StorageColumn, StorageGetMessagesArg, StorageResourceType, TABLE_NAMES, WorkflowRun, WorkflowRuns, StoragePagination, StorageDomains, AISpanRecord, AITraceRecord, AITracesPaginatedArg, UpdateAISpanRecord, CreateIndexOptions, IndexInfo, StorageIndexStats, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
10
9
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
11
10
|
import sql from 'mssql';
|
|
12
11
|
export type MSSQLConfigType = {
|
|
@@ -36,25 +35,10 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
36
35
|
hasColumn: boolean;
|
|
37
36
|
createTable: boolean;
|
|
38
37
|
deleteMessages: boolean;
|
|
38
|
+
listScoresBySpan: boolean;
|
|
39
|
+
aiTracing: boolean;
|
|
40
|
+
indexManagement: boolean;
|
|
39
41
|
};
|
|
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
42
|
createTable({ tableName, schema, }: {
|
|
59
43
|
tableName: TABLE_NAMES;
|
|
60
44
|
schema: Record<string, StorageColumn>;
|
|
@@ -88,19 +72,6 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
88
72
|
getThreadById({ threadId }: {
|
|
89
73
|
threadId: string;
|
|
90
74
|
}): 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
75
|
saveThread({ thread }: {
|
|
105
76
|
thread: StorageThreadType;
|
|
106
77
|
}): Promise<StorageThreadType>;
|
|
@@ -113,44 +84,30 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
113
84
|
threadId: string;
|
|
114
85
|
}): Promise<void>;
|
|
115
86
|
/**
|
|
116
|
-
* @deprecated use
|
|
87
|
+
* @deprecated use listMessages instead
|
|
117
88
|
*/
|
|
118
|
-
getMessages(args: StorageGetMessagesArg
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
format: 'v2';
|
|
123
|
-
}): Promise<MastraMessageV2[]>;
|
|
124
|
-
getMessagesById({ messageIds, format }: {
|
|
125
|
-
messageIds: string[];
|
|
126
|
-
format: 'v1';
|
|
127
|
-
}): Promise<MastraMessageV1[]>;
|
|
128
|
-
getMessagesById({ messageIds, format }: {
|
|
89
|
+
getMessages(args: StorageGetMessagesArg): Promise<{
|
|
90
|
+
messages: MastraDBMessage[];
|
|
91
|
+
}>;
|
|
92
|
+
listMessagesById({ messageIds }: {
|
|
129
93
|
messageIds: string[];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
133
|
-
format?: 'v1' | 'v2';
|
|
134
|
-
}): Promise<PaginationInfo & {
|
|
135
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
94
|
+
}): Promise<{
|
|
95
|
+
messages: MastraDBMessage[];
|
|
136
96
|
}>;
|
|
137
97
|
saveMessages(args: {
|
|
138
|
-
messages:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
messages: MastraMessageV2[];
|
|
143
|
-
format: 'v2';
|
|
144
|
-
}): Promise<MastraMessageV2[]>;
|
|
98
|
+
messages: MastraDBMessage[];
|
|
99
|
+
}): Promise<{
|
|
100
|
+
messages: MastraDBMessage[];
|
|
101
|
+
}>;
|
|
145
102
|
updateMessages({ messages, }: {
|
|
146
|
-
messages: (Partial<Omit<
|
|
103
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
147
104
|
id: string;
|
|
148
105
|
content?: {
|
|
149
106
|
metadata?: MastraMessageContentV2['metadata'];
|
|
150
107
|
content?: MastraMessageContentV2['content'];
|
|
151
108
|
};
|
|
152
109
|
})[];
|
|
153
|
-
}): Promise<
|
|
110
|
+
}): Promise<MastraDBMessage[]>;
|
|
154
111
|
deleteMessages(messageIds: string[]): Promise<void>;
|
|
155
112
|
getResourceById({ resourceId }: {
|
|
156
113
|
resourceId: string;
|
|
@@ -166,12 +123,12 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
166
123
|
/**
|
|
167
124
|
* Workflows
|
|
168
125
|
*/
|
|
169
|
-
updateWorkflowResults({ workflowName, runId, stepId, result,
|
|
126
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
170
127
|
workflowName: string;
|
|
171
128
|
runId: string;
|
|
172
129
|
stepId: string;
|
|
173
130
|
result: StepResult<any, any, any, any>;
|
|
174
|
-
|
|
131
|
+
requestContext: Record<string, any>;
|
|
175
132
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
176
133
|
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
177
134
|
workflowName: string;
|
|
@@ -184,37 +141,69 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
184
141
|
waitingPaths?: Record<string, number[]>;
|
|
185
142
|
};
|
|
186
143
|
}): Promise<WorkflowRunState | undefined>;
|
|
187
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
144
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
188
145
|
workflowName: string;
|
|
189
146
|
runId: string;
|
|
147
|
+
resourceId?: string;
|
|
190
148
|
snapshot: WorkflowRunState;
|
|
191
149
|
}): Promise<void>;
|
|
192
150
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
193
151
|
workflowName: string;
|
|
194
152
|
runId: string;
|
|
195
153
|
}): Promise<WorkflowRunState | null>;
|
|
196
|
-
|
|
197
|
-
workflowName?: string;
|
|
198
|
-
fromDate?: Date;
|
|
199
|
-
toDate?: Date;
|
|
200
|
-
limit?: number;
|
|
201
|
-
offset?: number;
|
|
202
|
-
resourceId?: string;
|
|
203
|
-
}): Promise<WorkflowRuns>;
|
|
154
|
+
listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
204
155
|
getWorkflowRunById({ runId, workflowName, }: {
|
|
205
156
|
runId: string;
|
|
206
157
|
workflowName?: string;
|
|
207
158
|
}): Promise<WorkflowRun | null>;
|
|
208
159
|
close(): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Index Management
|
|
162
|
+
*/
|
|
163
|
+
createIndex(options: CreateIndexOptions): Promise<void>;
|
|
164
|
+
listIndexes(tableName?: string): Promise<IndexInfo[]>;
|
|
165
|
+
describeIndex(indexName: string): Promise<StorageIndexStats>;
|
|
166
|
+
dropIndex(indexName: string): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* AI Tracing / Observability
|
|
169
|
+
*/
|
|
170
|
+
private getObservabilityStore;
|
|
171
|
+
createAISpan(span: AISpanRecord): Promise<void>;
|
|
172
|
+
updateAISpan({ spanId, traceId, updates, }: {
|
|
173
|
+
spanId: string;
|
|
174
|
+
traceId: string;
|
|
175
|
+
updates: Partial<UpdateAISpanRecord>;
|
|
176
|
+
}): Promise<void>;
|
|
177
|
+
getAITrace(traceId: string): Promise<AITraceRecord | null>;
|
|
178
|
+
getAITracesPaginated(args: AITracesPaginatedArg): Promise<{
|
|
179
|
+
pagination: PaginationInfo;
|
|
180
|
+
spans: AISpanRecord[];
|
|
181
|
+
}>;
|
|
182
|
+
batchCreateAISpans(args: {
|
|
183
|
+
records: AISpanRecord[];
|
|
184
|
+
}): Promise<void>;
|
|
185
|
+
batchUpdateAISpans(args: {
|
|
186
|
+
records: {
|
|
187
|
+
traceId: string;
|
|
188
|
+
spanId: string;
|
|
189
|
+
updates: Partial<UpdateAISpanRecord>;
|
|
190
|
+
}[];
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
batchDeleteAITraces(args: {
|
|
193
|
+
traceIds: string[];
|
|
194
|
+
}): Promise<void>;
|
|
209
195
|
/**
|
|
210
196
|
* Scorers
|
|
211
197
|
*/
|
|
212
198
|
getScoreById({ id: _id }: {
|
|
213
199
|
id: string;
|
|
214
200
|
}): Promise<ScoreRowData | null>;
|
|
215
|
-
|
|
201
|
+
listScoresByScorerId({ scorerId: _scorerId, pagination: _pagination, entityId: _entityId, entityType: _entityType, source: _source, }: {
|
|
216
202
|
scorerId: string;
|
|
217
203
|
pagination: StoragePagination;
|
|
204
|
+
entityId?: string;
|
|
205
|
+
entityType?: string;
|
|
206
|
+
source?: ScoringSource;
|
|
218
207
|
}): Promise<{
|
|
219
208
|
pagination: PaginationInfo;
|
|
220
209
|
scores: ScoreRowData[];
|
|
@@ -222,14 +211,14 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
222
211
|
saveScore(_score: ScoreRowData): Promise<{
|
|
223
212
|
score: ScoreRowData;
|
|
224
213
|
}>;
|
|
225
|
-
|
|
214
|
+
listScoresByRunId({ runId: _runId, pagination: _pagination, }: {
|
|
226
215
|
runId: string;
|
|
227
216
|
pagination: StoragePagination;
|
|
228
217
|
}): Promise<{
|
|
229
218
|
pagination: PaginationInfo;
|
|
230
219
|
scores: ScoreRowData[];
|
|
231
220
|
}>;
|
|
232
|
-
|
|
221
|
+
listScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
|
|
233
222
|
pagination: StoragePagination;
|
|
234
223
|
entityId: string;
|
|
235
224
|
entityType: string;
|
|
@@ -237,5 +226,13 @@ export declare class MSSQLStore extends MastraStorage {
|
|
|
237
226
|
pagination: PaginationInfo;
|
|
238
227
|
scores: ScoreRowData[];
|
|
239
228
|
}>;
|
|
229
|
+
listScoresBySpan({ traceId, spanId, pagination: _pagination, }: {
|
|
230
|
+
traceId: string;
|
|
231
|
+
spanId: string;
|
|
232
|
+
pagination: StoragePagination;
|
|
233
|
+
}): Promise<{
|
|
234
|
+
pagination: PaginationInfo;
|
|
235
|
+
scores: ScoreRowData[];
|
|
236
|
+
}>;
|
|
240
237
|
}
|
|
241
238
|
//# 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,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,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,MA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
|
|
3
|
+
"version": "0.0.0-vnext-20251104230439",
|
|
4
4
|
"description": "MSSQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,25 +18,38 @@
|
|
|
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.
|
|
27
|
+
"@types/mssql": "^9.1.8",
|
|
28
28
|
"@types/node": "^20.19.0",
|
|
29
|
-
"eslint": "^9.
|
|
29
|
+
"eslint": "^9.37.0",
|
|
30
30
|
"tsup": "^8.5.0",
|
|
31
31
|
"typescript": "^5.8.3",
|
|
32
32
|
"vitest": "^3.2.4",
|
|
33
|
-
"@internal/lint": "0.0.0-
|
|
34
|
-
"@internal/storage-test-utils": "0.0.
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
33
|
+
"@internal/lint": "0.0.0-vnext-20251104230439",
|
|
34
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
35
|
+
"@internal/types-builder": "0.0.0-vnext-20251104230439",
|
|
36
|
+
"@mastra/core": "0.0.0-vnext-20251104230439"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@mastra/core": "0.0.0-
|
|
39
|
+
"@mastra/core": "0.0.0-vnext-20251104230439"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"CHANGELOG.md"
|
|
44
|
+
],
|
|
45
|
+
"homepage": "https://mastra.ai",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
49
|
+
"directory": "stores/mssql"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
40
53
|
},
|
|
41
54
|
"scripts": {
|
|
42
55
|
"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/index.js';
|
|
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
|
-
}
|