@mastra/mssql 0.0.0-fix-message-list-merge-20250718043058 → 0.0.0-fix-tool-call-history-20250731222019

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.
@@ -4,6 +4,7 @@ export type MastraMessageV2WithTypedContent = Omit<MastraMessageV2, 'content'> &
4
4
  import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
5
5
  import type { MetricResult } from '@mastra/core/eval';
6
6
  import type { MastraMessageV1, StorageThreadType } from '@mastra/core/memory';
7
+ import type { ScoreRowData } from '@mastra/core/scores';
7
8
  import {
8
9
  MastraStorage,
9
10
  TABLE_MESSAGES,
@@ -23,6 +24,7 @@ import type {
23
24
  WorkflowRun,
24
25
  WorkflowRuns,
25
26
  PaginationArgs,
27
+ StoragePagination,
26
28
  } from '@mastra/core/storage';
27
29
  import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
28
30
  import type { WorkflowRunState } from '@mastra/core/workflows';
@@ -129,10 +131,16 @@ export class MSSQLStore extends MastraStorage {
129
131
  public get supports(): {
130
132
  selectByIncludeResourceScope: boolean;
131
133
  resourceWorkingMemory: boolean;
134
+ hasColumn: boolean;
135
+ createTable: boolean;
136
+ deleteMessages: boolean;
132
137
  } {
133
138
  return {
134
139
  selectByIncludeResourceScope: true,
135
140
  resourceWorkingMemory: true,
141
+ hasColumn: true,
142
+ createTable: true,
143
+ deleteMessages: false,
136
144
  };
137
145
  }
138
146
 
@@ -2041,4 +2049,88 @@ export class MSSQLStore extends MastraStorage {
2041
2049
  throw mastraError;
2042
2050
  }
2043
2051
  }
2052
+
2053
+ async getScoreById({ id }: { id: string }): Promise<ScoreRowData | null> {
2054
+ throw new MastraError({
2055
+ id: 'STORAGE_MONGODB_STORE_GET_SCORE_BY_ID_FAILED',
2056
+ domain: ErrorDomain.STORAGE,
2057
+ category: ErrorCategory.THIRD_PARTY,
2058
+ details: { id },
2059
+ text: 'getScoreById is not implemented yet in MongoDBStore',
2060
+ });
2061
+ }
2062
+
2063
+ async saveScore(_score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{ score: ScoreRowData }> {
2064
+ throw new MastraError({
2065
+ id: 'STORAGE_MONGODB_STORE_SAVE_SCORE_FAILED',
2066
+ domain: ErrorDomain.STORAGE,
2067
+ category: ErrorCategory.THIRD_PARTY,
2068
+ details: {},
2069
+ text: 'saveScore is not implemented yet in MongoDBStore',
2070
+ });
2071
+ }
2072
+
2073
+ async getScoresByScorerId({
2074
+ scorerId,
2075
+ pagination: _pagination,
2076
+ entityId,
2077
+ entityType,
2078
+ }: {
2079
+ scorerId: string;
2080
+ pagination: StoragePagination;
2081
+ entityId?: string;
2082
+ entityType?: string;
2083
+ }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
2084
+ throw new MastraError({
2085
+ id: 'STORAGE_MONGODB_STORE_GET_SCORES_BY_SCORER_ID_FAILED',
2086
+ domain: ErrorDomain.STORAGE,
2087
+ category: ErrorCategory.THIRD_PARTY,
2088
+ details: { scorerId, entityId: entityId || '', entityType: entityType || '' },
2089
+ text: 'getScoresByScorerId is not implemented yet in MongoDBStore',
2090
+ });
2091
+ }
2092
+
2093
+ async getScoresByRunId({
2094
+ runId,
2095
+ pagination: _pagination,
2096
+ }: {
2097
+ runId: string;
2098
+ pagination: StoragePagination;
2099
+ }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
2100
+ throw new MastraError({
2101
+ id: 'STORAGE_MONGODB_STORE_GET_SCORES_BY_RUN_ID_FAILED',
2102
+ domain: ErrorDomain.STORAGE,
2103
+ category: ErrorCategory.THIRD_PARTY,
2104
+ details: { runId },
2105
+ text: 'getScoresByRunId is not implemented yet in MongoDBStore',
2106
+ });
2107
+ }
2108
+
2109
+ async getScoresByEntityId({
2110
+ entityId,
2111
+ entityType,
2112
+ pagination: _pagination,
2113
+ }: {
2114
+ pagination: StoragePagination;
2115
+ entityId: string;
2116
+ entityType: string;
2117
+ }): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
2118
+ throw new MastraError({
2119
+ id: 'STORAGE_MONGODB_STORE_GET_SCORES_BY_ENTITY_ID_FAILED',
2120
+ domain: ErrorDomain.STORAGE,
2121
+ category: ErrorCategory.THIRD_PARTY,
2122
+ details: { entityId, entityType },
2123
+ text: 'getScoresByEntityId is not implemented yet in MongoDBStore',
2124
+ });
2125
+ }
2126
+
2127
+ async dropTable({ tableName }: { tableName: TABLE_NAMES }): Promise<void> {
2128
+ throw new MastraError({
2129
+ id: 'STORAGE_MONGODB_STORE_DROP_TABLE_FAILED',
2130
+ domain: ErrorDomain.STORAGE,
2131
+ category: ErrorCategory.THIRD_PARTY,
2132
+ details: { tableName },
2133
+ text: 'dropTable is not implemented yet in MongoDBStore',
2134
+ });
2135
+ }
2044
2136
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { spawn } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { defineConfig } from 'tsup';
4
+
5
+ const exec = promisify(spawn);
6
+
7
+ export default defineConfig({
8
+ entry: ['src/index.ts'],
9
+ format: ['esm', 'cjs'],
10
+ clean: true,
11
+ dts: false,
12
+ splitting: true,
13
+ treeshake: {
14
+ preset: 'smallest',
15
+ },
16
+ sourcemap: true,
17
+ onSuccess: async () => {
18
+ await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
19
+ stdio: 'inherit',
20
+ });
21
+ },
22
+ });
@@ -1,213 +0,0 @@
1
- import type { EvalRow } from '@mastra/core/storage';
2
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
- import type { MastraMessageV1 } from '@mastra/core/memory';
4
- import type { MastraMessageV2 } from '@mastra/core/agent';
5
- import { MastraStorage } from '@mastra/core/storage';
6
- import type { PaginationArgs } from '@mastra/core/storage';
7
- import type { PaginationInfo } from '@mastra/core/storage';
8
- import sql from 'mssql';
9
- import type { StorageColumn } from '@mastra/core/storage';
10
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
11
- import type { StorageResourceType } from '@mastra/core/storage';
12
- import type { StorageThreadType } from '@mastra/core/memory';
13
- import type { TABLE_NAMES } from '@mastra/core/storage';
14
- import type { WorkflowRun } from '@mastra/core/storage';
15
- import type { WorkflowRuns } from '@mastra/core/storage';
16
- import type { WorkflowRunState } from '@mastra/core/workflows';
17
-
18
- declare type MastraMessageV2WithTypedContent = Omit<MastraMessageV2, 'content'> & {
19
- content: MastraMessageContentV2;
20
- };
21
- export { MastraMessageV2WithTypedContent }
22
- export { MastraMessageV2WithTypedContent as MastraMessageV2WithTypedContent_alias_1 }
23
-
24
- declare type MSSQLConfig = MSSQLConfigType;
25
- export { MSSQLConfig }
26
- export { MSSQLConfig as MSSQLConfig_alias_1 }
27
-
28
- declare type MSSQLConfigType = {
29
- schemaName?: string;
30
- } & ({
31
- server: string;
32
- port: number;
33
- database: string;
34
- user: string;
35
- password: string;
36
- options?: sql.IOptions;
37
- } | {
38
- connectionString: string;
39
- });
40
- export { MSSQLConfigType }
41
- export { MSSQLConfigType as MSSQLConfigType_alias_1 }
42
-
43
- declare class MSSQLStore extends MastraStorage {
44
- pool: sql.ConnectionPool;
45
- private schema?;
46
- private setupSchemaPromise;
47
- private schemaSetupComplete;
48
- private isConnected;
49
- constructor(config: MSSQLConfigType);
50
- init(): Promise<void>;
51
- private _performInitializationAndStore;
52
- get supports(): {
53
- selectByIncludeResourceScope: boolean;
54
- resourceWorkingMemory: boolean;
55
- };
56
- private getTableName;
57
- private getSchemaName;
58
- private transformEvalRow;
59
- /** @deprecated use getEvals instead */
60
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
61
- batchInsert({ tableName, records }: {
62
- tableName: TABLE_NAMES;
63
- records: Record<string, any>[];
64
- }): Promise<void>;
65
- /** @deprecated use getTracesPaginated instead*/
66
- getTraces(args: {
67
- name?: string;
68
- scope?: string;
69
- attributes?: Record<string, string>;
70
- filters?: Record<string, any>;
71
- page: number;
72
- perPage?: number;
73
- fromDate?: Date;
74
- toDate?: Date;
75
- }): Promise<any[]>;
76
- getTracesPaginated(args: {
77
- name?: string;
78
- scope?: string;
79
- attributes?: Record<string, string>;
80
- filters?: Record<string, any>;
81
- } & PaginationArgs): Promise<PaginationInfo & {
82
- traces: any[];
83
- }>;
84
- private setupSchema;
85
- protected getSqlType(type: StorageColumn['type'], isPrimaryKey?: boolean): string;
86
- createTable({ tableName, schema, }: {
87
- tableName: TABLE_NAMES;
88
- schema: Record<string, StorageColumn>;
89
- }): Promise<void>;
90
- protected getDefaultValue(type: StorageColumn['type']): string;
91
- alterTable({ tableName, schema, ifNotExists, }: {
92
- tableName: TABLE_NAMES;
93
- schema: Record<string, StorageColumn>;
94
- ifNotExists: string[];
95
- }): Promise<void>;
96
- clearTable({ tableName }: {
97
- tableName: TABLE_NAMES;
98
- }): Promise<void>;
99
- insert({ tableName, record }: {
100
- tableName: TABLE_NAMES;
101
- record: Record<string, any>;
102
- }): Promise<void>;
103
- load<R>({ tableName, keys }: {
104
- tableName: TABLE_NAMES;
105
- keys: Record<string, string>;
106
- }): Promise<R | null>;
107
- getThreadById({ threadId }: {
108
- threadId: string;
109
- }): Promise<StorageThreadType | null>;
110
- getThreadsByResourceIdPaginated(args: {
111
- resourceId: string;
112
- } & PaginationArgs): Promise<PaginationInfo & {
113
- threads: StorageThreadType[];
114
- }>;
115
- saveThread({ thread }: {
116
- thread: StorageThreadType;
117
- }): Promise<StorageThreadType>;
118
- /**
119
- * @deprecated use getThreadsByResourceIdPaginated instead
120
- */
121
- getThreadsByResourceId(args: {
122
- resourceId: string;
123
- }): Promise<StorageThreadType[]>;
124
- /**
125
- * Updates a thread's title and metadata, merging with existing metadata. Returns the updated thread.
126
- */
127
- updateThread({ id, title, metadata, }: {
128
- id: string;
129
- title: string;
130
- metadata: Record<string, unknown>;
131
- }): Promise<StorageThreadType>;
132
- deleteThread({ threadId }: {
133
- threadId: string;
134
- }): Promise<void>;
135
- private _getIncludedMessages;
136
- /**
137
- * @deprecated use getMessagesPaginated instead
138
- */
139
- getMessages(args: StorageGetMessagesArg & {
140
- format?: 'v1';
141
- }): Promise<MastraMessageV1[]>;
142
- getMessages(args: StorageGetMessagesArg & {
143
- format: 'v2';
144
- }): Promise<MastraMessageV2[]>;
145
- getMessagesPaginated(args: StorageGetMessagesArg & {
146
- format?: 'v1' | 'v2';
147
- }): Promise<PaginationInfo & {
148
- messages: MastraMessageV1[] | MastraMessageV2[];
149
- }>;
150
- private _parseAndFormatMessages;
151
- saveMessages(args: {
152
- messages: MastraMessageV1[];
153
- format?: undefined | 'v1';
154
- }): Promise<MastraMessageV1[]>;
155
- saveMessages(args: {
156
- messages: MastraMessageV2[];
157
- format: 'v2';
158
- }): Promise<MastraMessageV2[]>;
159
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
160
- workflowName: string;
161
- runId: string;
162
- snapshot: WorkflowRunState;
163
- }): Promise<void>;
164
- loadWorkflowSnapshot({ workflowName, runId, }: {
165
- workflowName: string;
166
- runId: string;
167
- }): Promise<WorkflowRunState | null>;
168
- private hasColumn;
169
- private parseWorkflowRun;
170
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
171
- workflowName?: string;
172
- fromDate?: Date;
173
- toDate?: Date;
174
- limit?: number;
175
- offset?: number;
176
- resourceId?: string;
177
- }): Promise<WorkflowRuns>;
178
- getWorkflowRunById({ runId, workflowName, }: {
179
- runId: string;
180
- workflowName?: string;
181
- }): Promise<WorkflowRun | null>;
182
- updateMessages({ messages, }: {
183
- messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
184
- id: string;
185
- content?: {
186
- metadata?: MastraMessageContentV2['metadata'];
187
- content?: MastraMessageContentV2['content'];
188
- };
189
- })[];
190
- }): Promise<MastraMessageV2[]>;
191
- close(): Promise<void>;
192
- getEvals(options?: {
193
- agentName?: string;
194
- type?: 'test' | 'live';
195
- } & PaginationArgs): Promise<PaginationInfo & {
196
- evals: EvalRow[];
197
- }>;
198
- saveResource({ resource }: {
199
- resource: StorageResourceType;
200
- }): Promise<StorageResourceType>;
201
- updateResource({ resourceId, workingMemory, metadata, }: {
202
- resourceId: string;
203
- workingMemory?: string;
204
- metadata?: Record<string, unknown>;
205
- }): Promise<StorageResourceType>;
206
- getResourceById({ resourceId }: {
207
- resourceId: string;
208
- }): Promise<StorageResourceType | null>;
209
- }
210
- export { MSSQLStore }
211
- export { MSSQLStore as MSSQLStore_alias_1 }
212
-
213
- export { }
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export { MastraMessageV2WithTypedContent } from './_tsup-dts-rollup.cjs';
2
- export { MSSQLConfigType } from './_tsup-dts-rollup.cjs';
3
- export { MSSQLConfig } from './_tsup-dts-rollup.cjs';
4
- export { MSSQLStore } from './_tsup-dts-rollup.cjs';