@mastra/mssql 0.0.0-remove-unused-model-providers-api-20251030210744 → 0.0.0-remove-ai-peer-dep-from-evals-20260105220639
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 +1244 -4
- package/README.md +27 -19
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +141 -0
- package/dist/index.cjs +2582 -2281
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2586 -2289
- package/dist/index.js.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +73 -15
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/db/utils.d.ts +21 -0
- package/dist/storage/db/utils.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +36 -47
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +36 -34
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +34 -30
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts +2 -2
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +33 -18
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +115 -229
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +16 -11
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ MSSQLStore supports multiple connection methods:
|
|
|
27
27
|
import { MSSQLStore } from '@mastra/mssql';
|
|
28
28
|
|
|
29
29
|
const store = new MSSQLStore({
|
|
30
|
+
id: 'mssql-storage',
|
|
30
31
|
connectionString:
|
|
31
32
|
'Server=localhost,1433;Database=mastra;User Id=sa;Password=yourPassword;Encrypt=true;TrustServerCertificate=true',
|
|
32
33
|
});
|
|
@@ -36,6 +37,7 @@ const store = new MSSQLStore({
|
|
|
36
37
|
|
|
37
38
|
```typescript
|
|
38
39
|
const store = new MSSQLStore({
|
|
40
|
+
id: 'mssql-storage',
|
|
39
41
|
server: 'localhost',
|
|
40
42
|
port: 1433,
|
|
41
43
|
database: 'mastra',
|
|
@@ -49,6 +51,7 @@ const store = new MSSQLStore({
|
|
|
49
51
|
|
|
50
52
|
```typescript
|
|
51
53
|
const store = new MSSQLStore({
|
|
54
|
+
id: 'mssql-storage',
|
|
52
55
|
connectionString:
|
|
53
56
|
'Server=localhost,1433;Database=mastra;User Id=sa;Password=yourPassword;Encrypt=true;TrustServerCertificate=true',
|
|
54
57
|
schemaName: 'custom_schema', // Use custom schema (default: dbo)
|
|
@@ -98,11 +101,15 @@ await store.saveMessages({
|
|
|
98
101
|
|
|
99
102
|
// Query threads and messages
|
|
100
103
|
const savedThread = await store.getThreadById({ threadId: 'thread-123' });
|
|
101
|
-
const messages = await store.
|
|
104
|
+
const messages = await store.listMessages({ threadId: 'thread-123' });
|
|
102
105
|
```
|
|
103
106
|
|
|
104
107
|
## Configuration
|
|
105
108
|
|
|
109
|
+
### Identifier
|
|
110
|
+
|
|
111
|
+
- `id`: Unique identifier for this store instance (required)
|
|
112
|
+
|
|
106
113
|
### Connection Methods
|
|
107
114
|
|
|
108
115
|
MSSQLStore supports multiple connection methods:
|
|
@@ -111,6 +118,7 @@ MSSQLStore supports multiple connection methods:
|
|
|
111
118
|
|
|
112
119
|
```typescript
|
|
113
120
|
{
|
|
121
|
+
id: 'mssql-storage',
|
|
114
122
|
connectionString: 'Server=localhost,1433;Database=mastra;User Id=sa;Password=yourPassword;Encrypt=true;TrustServerCertificate=true';
|
|
115
123
|
}
|
|
116
124
|
```
|
|
@@ -118,6 +126,7 @@ MSSQLStore supports multiple connection methods:
|
|
|
118
126
|
2. **Server/Port/Database**
|
|
119
127
|
```typescript
|
|
120
128
|
{
|
|
129
|
+
id: 'mssql-storage',
|
|
121
130
|
server: 'localhost',
|
|
122
131
|
port: 1433,
|
|
123
132
|
database: 'mastra',
|
|
@@ -161,7 +170,7 @@ MSSQLStore supports multiple connection methods:
|
|
|
161
170
|
- Rich metadata support
|
|
162
171
|
- Update working memory and metadata independently
|
|
163
172
|
|
|
164
|
-
- **
|
|
173
|
+
- **Tracing & Observability**
|
|
165
174
|
- Trace AI agent execution with spans
|
|
166
175
|
- Query traces with pagination and filtering
|
|
167
176
|
- Batch operations for high-volume tracing
|
|
@@ -209,14 +218,13 @@ MSSQLStore supports multiple connection methods:
|
|
|
209
218
|
- `getThreadById({ threadId })`: Get a thread by ID
|
|
210
219
|
- `updateThread({ id, title, metadata })`: Update thread title and metadata
|
|
211
220
|
- `deleteThread({ threadId })`: Delete a thread and its messages
|
|
212
|
-
- `
|
|
221
|
+
- `listThreadsByResourceId({ resourceId, offset, limit, orderBy? })`: List paginated threads for a resource
|
|
213
222
|
|
|
214
223
|
### Messages
|
|
215
224
|
|
|
216
|
-
- `saveMessages({ messages
|
|
217
|
-
- `
|
|
218
|
-
- `
|
|
219
|
-
- `getMessagesPaginated({ threadId, format?, page?, perPage? })`: Get paginated messages for a thread
|
|
225
|
+
- `saveMessages({ messages })`: Save multiple messages with atomic transaction
|
|
226
|
+
- `listMessagesById({ messageIds })`: Get messages by their IDs
|
|
227
|
+
- `listMessages({ threadId, resourceId?, page?, perPage?, orderBy?, filter? })`: Get paginated messages for a thread with filtering and sorting
|
|
220
228
|
- `updateMessages({ messages })`: Update existing messages with atomic transaction
|
|
221
229
|
- `deleteMessages(messageIds)`: Delete specific messages with atomic transaction
|
|
222
230
|
|
|
@@ -226,15 +234,15 @@ MSSQLStore supports multiple connection methods:
|
|
|
226
234
|
- `getResourceById({ resourceId })`: Get a resource by ID
|
|
227
235
|
- `updateResource({ resourceId, workingMemory?, metadata? })`: Update resource working memory and metadata
|
|
228
236
|
|
|
229
|
-
###
|
|
237
|
+
### Tracing & Observability
|
|
230
238
|
|
|
231
|
-
- `
|
|
232
|
-
- `
|
|
233
|
-
- `
|
|
234
|
-
- `
|
|
235
|
-
- `
|
|
236
|
-
- `
|
|
237
|
-
- `
|
|
239
|
+
- `createSpan(span)`: Create a trace span
|
|
240
|
+
- `updateSpan({ spanId, traceId, updates })`: Update an existing span
|
|
241
|
+
- `getTrace(traceId)`: Get complete trace with all spans
|
|
242
|
+
- `getTracesPaginated({ filters?, pagination? })`: Query traces with pagination and filters
|
|
243
|
+
- `batchCreateSpans({ records })`: Batch create multiple spans
|
|
244
|
+
- `batchUpdateSpans({ records })`: Batch update multiple spans
|
|
245
|
+
- `batchDeleteTraces({ traceIds })`: Batch delete traces
|
|
238
246
|
|
|
239
247
|
### Index Management
|
|
240
248
|
|
|
@@ -256,10 +264,10 @@ MSSQLStore supports multiple connection methods:
|
|
|
256
264
|
|
|
257
265
|
- `saveScore(score)`: Save evaluation score
|
|
258
266
|
- `getScoreById({ id })`: Get score by ID
|
|
259
|
-
- `
|
|
260
|
-
- `
|
|
261
|
-
- `
|
|
262
|
-
- `
|
|
267
|
+
- `listScoresByScorerId({ scorerId, pagination, entityId?, entityType?, source? })`: Get scores by scorer
|
|
268
|
+
- `listScoresByRunId({ runId, pagination })`: Get scores for a run
|
|
269
|
+
- `listScoresByEntityId({ entityId, entityType, pagination })`: Get scores for an entity
|
|
270
|
+
- `listScoresBySpan({ traceId, spanId, pagination })`: Get scores for a trace span
|
|
263
271
|
|
|
264
272
|
### Traces (Legacy)
|
|
265
273
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @mastra/mssql Documentation
|
|
2
|
+
|
|
3
|
+
> Embedded documentation for coding agents
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Read the skill overview
|
|
9
|
+
cat docs/SKILL.md
|
|
10
|
+
|
|
11
|
+
# Get the source map
|
|
12
|
+
cat docs/SOURCE_MAP.json
|
|
13
|
+
|
|
14
|
+
# Read topic documentation
|
|
15
|
+
cat docs/<topic>/01-overview.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
docs/
|
|
22
|
+
├── SKILL.md # Entry point
|
|
23
|
+
├── README.md # This file
|
|
24
|
+
├── SOURCE_MAP.json # Export index
|
|
25
|
+
├── storage/ (1 files)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Version
|
|
29
|
+
|
|
30
|
+
Package: @mastra/mssql
|
|
31
|
+
Version: 1.0.0-beta.9
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-mssql-docs
|
|
3
|
+
description: Documentation for @mastra/mssql. Includes links to type definitions and readable implementation code in dist/.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @mastra/mssql Documentation
|
|
7
|
+
|
|
8
|
+
> **Version**: 1.0.0-beta.9
|
|
9
|
+
> **Package**: @mastra/mssql
|
|
10
|
+
|
|
11
|
+
## Quick Navigation
|
|
12
|
+
|
|
13
|
+
Use SOURCE_MAP.json to find any export:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cat docs/SOURCE_MAP.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each export maps to:
|
|
20
|
+
- **types**: `.d.ts` file with JSDoc and API signatures
|
|
21
|
+
- **implementation**: `.js` chunk file with readable source
|
|
22
|
+
- **docs**: Conceptual documentation in `docs/`
|
|
23
|
+
|
|
24
|
+
## Top Exports
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
See SOURCE_MAP.json for the complete list.
|
|
29
|
+
|
|
30
|
+
## Available Topics
|
|
31
|
+
|
|
32
|
+
- [Storage](storage/) - 1 file(s)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Storage API Reference
|
|
2
|
+
|
|
3
|
+
> API reference for storage - 1 entries
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reference: MSSQL Storage
|
|
9
|
+
|
|
10
|
+
> Documentation for the MSSQL storage implementation in Mastra.
|
|
11
|
+
|
|
12
|
+
The MSSQL storage implementation provides a production-ready storage solution using Microsoft SQL Server databases.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @mastra/mssql@beta
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { MSSQLStore } from "@mastra/mssql";
|
|
24
|
+
|
|
25
|
+
const storage = new MSSQLStore({
|
|
26
|
+
id: 'mssql-storage',
|
|
27
|
+
connectionString: process.env.DATABASE_URL,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Parameters
|
|
32
|
+
|
|
33
|
+
## Constructor Examples
|
|
34
|
+
|
|
35
|
+
You can instantiate `MSSQLStore` in the following ways:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { MSSQLStore } from "@mastra/mssql";
|
|
39
|
+
|
|
40
|
+
// Using a connection string only
|
|
41
|
+
const store1 = new MSSQLStore({
|
|
42
|
+
id: 'mssql-storage-1',
|
|
43
|
+
connectionString: "Server=localhost,1433;Database=mydb;User Id=sa;Password=password;Encrypt=true;TrustServerCertificate=true",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Using a connection string with a custom schema name
|
|
47
|
+
const store2 = new MSSQLStore({
|
|
48
|
+
id: 'mssql-storage-2',
|
|
49
|
+
connectionString: "Server=localhost,1433;Database=mydb;User Id=sa;Password=password;Encrypt=true;TrustServerCertificate=true",
|
|
50
|
+
schemaName: "custom_schema", // optional
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Using individual connection parameters
|
|
54
|
+
const store4 = new MSSQLStore({
|
|
55
|
+
id: 'mssql-storage-3',
|
|
56
|
+
server: "localhost",
|
|
57
|
+
port: 1433,
|
|
58
|
+
database: "mydb",
|
|
59
|
+
user: "user",
|
|
60
|
+
password: "password",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Individual parameters with schemaName
|
|
64
|
+
const store5 = new MSSQLStore({
|
|
65
|
+
id: 'mssql-storage-4',
|
|
66
|
+
server: "localhost",
|
|
67
|
+
port: 1433,
|
|
68
|
+
database: "mydb",
|
|
69
|
+
user: "user",
|
|
70
|
+
password: "password",
|
|
71
|
+
schemaName: "custom_schema", // optional
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Additional Notes
|
|
76
|
+
|
|
77
|
+
### Schema Management
|
|
78
|
+
|
|
79
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
80
|
+
|
|
81
|
+
- `mastra_workflow_snapshot`: Stores workflow state and execution data
|
|
82
|
+
- `mastra_evals`: Stores evaluation results and metadata
|
|
83
|
+
- `mastra_threads`: Stores conversation threads
|
|
84
|
+
- `mastra_messages`: Stores individual messages
|
|
85
|
+
- `mastra_traces`: Stores telemetry and tracing data
|
|
86
|
+
- `mastra_scorers`: Stores scoring and evaluation data
|
|
87
|
+
- `mastra_resources`: Stores resource working memory data
|
|
88
|
+
|
|
89
|
+
### Initialization
|
|
90
|
+
|
|
91
|
+
When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { Mastra } from "@mastra/core";
|
|
95
|
+
import { MSSQLStore } from "@mastra/mssql";
|
|
96
|
+
|
|
97
|
+
const storage = new MSSQLStore({
|
|
98
|
+
connectionString: process.env.DATABASE_URL,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const mastra = new Mastra({
|
|
102
|
+
storage, // init() is called automatically
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If you're using storage directly without Mastra, you must call `init()` explicitly to create the tables:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { MSSQLStore } from "@mastra/mssql";
|
|
110
|
+
|
|
111
|
+
const storage = new MSSQLStore({
|
|
112
|
+
id: 'mssql-storage',
|
|
113
|
+
connectionString: process.env.DATABASE_URL,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Required when using storage directly
|
|
117
|
+
await storage.init();
|
|
118
|
+
|
|
119
|
+
// Access domain-specific stores via getStore()
|
|
120
|
+
const memoryStore = await storage.getStore('memory');
|
|
121
|
+
const thread = await memoryStore?.getThreadById({ threadId: "..." });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> **Note:**
|
|
125
|
+
If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
|
|
126
|
+
|
|
127
|
+
### Direct Database and Pool Access
|
|
128
|
+
|
|
129
|
+
`MSSQLStore` exposes the mssql connection pool as public fields:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
store.pool; // mssql connection pool instance
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This enables direct queries and custom transaction management. When using these fields:
|
|
136
|
+
|
|
137
|
+
- You are responsible for proper connection and transaction handling.
|
|
138
|
+
- Closing the store (`store.close()`) will destroy the associated connection pool.
|
|
139
|
+
- Direct access bypasses any additional logic or validation provided by MSSQLStore methods.
|
|
140
|
+
|
|
141
|
+
This approach is intended for advanced scenarios where low-level access is required.
|