@mastra/mongodb 0.12.0 → 0.12.1-alpha.0
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +27 -0
- package/LICENSE.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +376 -54
- package/dist/_tsup-dts-rollup.d.ts +376 -54
- package/dist/index.cjs +1420 -424
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1414 -418
- package/docker-compose.yaml +1 -1
- package/package.json +6 -6
- package/src/storage/ConnectorHandler.ts +7 -0
- package/src/storage/MongoDBConnector.ts +93 -0
- package/src/storage/connectors/MongoDBConnector.ts +93 -0
- package/src/storage/connectors/base.ts +7 -0
- package/src/storage/domains/legacy-evals/index.ts +193 -0
- package/src/storage/domains/memory/index.ts +741 -0
- package/src/storage/domains/operations/index.ts +152 -0
- package/src/storage/domains/scores/index.ts +379 -0
- package/src/storage/domains/traces/index.ts +142 -0
- package/src/storage/domains/utils.ts +43 -0
- package/src/storage/domains/workflows/index.ts +196 -0
- package/src/storage/index.test.ts +24 -1226
- package/src/storage/index.ts +218 -776
- package/src/storage/types.ts +14 -0
- package/src/vector/index.test.ts +16 -1
- package/src/vector/index.ts +34 -11
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/mongodb@0.12.
|
|
2
|
+
> @mastra/mongodb@0.12.1-alpha.0 build /home/runner/work/mastra/mastra/stores/mongodb
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 11268ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/mongodb/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 12969ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m73.11 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1963ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m74.40 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1963ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 0.12.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 728b203: feat(mongodb): implement ConnectorHandler interface and MongoDBConnector
|
|
8
|
+
- 7ba91fa: Throw mastra errors methods not implemented yet
|
|
9
|
+
- 65ab763: Pre-filter on properties when running `MongoDBVector` queries
|
|
10
|
+
- Updated dependencies [f248d53]
|
|
11
|
+
- Updated dependencies [2affc57]
|
|
12
|
+
- Updated dependencies [66e13e3]
|
|
13
|
+
- Updated dependencies [edd9482]
|
|
14
|
+
- Updated dependencies [18344d7]
|
|
15
|
+
- Updated dependencies [9d372c2]
|
|
16
|
+
- Updated dependencies [40c2525]
|
|
17
|
+
- Updated dependencies [e473f27]
|
|
18
|
+
- Updated dependencies [032cb66]
|
|
19
|
+
- Updated dependencies [703ac71]
|
|
20
|
+
- Updated dependencies [a723d69]
|
|
21
|
+
- Updated dependencies [5889a31]
|
|
22
|
+
- Updated dependencies [65e3395]
|
|
23
|
+
- Updated dependencies [4933192]
|
|
24
|
+
- Updated dependencies [d1c77a4]
|
|
25
|
+
- Updated dependencies [bea9dd1]
|
|
26
|
+
- Updated dependencies [dcd4802]
|
|
27
|
+
- Updated dependencies [7ba91fa]
|
|
28
|
+
- @mastra/core@0.11.0-alpha.2
|
|
29
|
+
|
|
3
30
|
## 0.12.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -1,35 +1,166 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
2
|
import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
|
|
3
|
+
import { Collection } from 'mongodb';
|
|
3
4
|
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
4
5
|
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
5
6
|
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
6
7
|
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
8
|
+
import { Document } from 'mongodb';
|
|
7
9
|
import type { EvalRow } from '@mastra/core/storage';
|
|
10
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
8
11
|
import type { IndexStats } from '@mastra/core/vector';
|
|
12
|
+
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
9
13
|
import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
|
|
10
14
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
11
15
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
12
16
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
13
17
|
import { MastraStorage } from '@mastra/core/storage';
|
|
14
18
|
import { MastraVector } from '@mastra/core/vector';
|
|
19
|
+
import { MemoryStorage } from '@mastra/core/storage';
|
|
20
|
+
import { MongoClient } from 'mongodb';
|
|
15
21
|
import type { MongoClientOptions } from 'mongodb';
|
|
16
22
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
17
23
|
import type { OperatorValueMap } from '@mastra/core/vector/filter';
|
|
24
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
18
25
|
import type { PaginationInfo } from '@mastra/core/storage';
|
|
19
26
|
import type { QueryResult } from '@mastra/core/vector';
|
|
20
27
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
28
|
+
import type { ScoreRowData } from '@mastra/core/scores';
|
|
29
|
+
import { ScoresStorage } from '@mastra/core/storage';
|
|
21
30
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
31
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
22
32
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
23
33
|
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
34
|
+
import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
35
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
36
|
+
import type { StorageResourceType } from '@mastra/core/storage';
|
|
24
37
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
38
|
+
import { StoreOperations } from '@mastra/core/storage';
|
|
25
39
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
26
40
|
import type { Trace } from '@mastra/core/telemetry';
|
|
41
|
+
import { TracesStorage } from '@mastra/core/storage';
|
|
27
42
|
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
28
43
|
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
29
44
|
import type { VectorFieldValue } from '@mastra/core/vector/filter';
|
|
30
45
|
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
31
46
|
import type { WorkflowRun } from '@mastra/core/storage';
|
|
47
|
+
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
32
48
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
49
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
50
|
+
|
|
51
|
+
export declare interface ConnectorHandler {
|
|
52
|
+
getCollection(collectionName: string): Promise<Collection>;
|
|
53
|
+
close(): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export declare interface ConnectorHandler_alias_1 {
|
|
57
|
+
getCollection(collectionName: string): Promise<Collection>;
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare function createExecuteOperationWithRetry({ logger, maxRetries, initialBackoffMs, }: {
|
|
62
|
+
logger: IMastraLogger;
|
|
63
|
+
maxRetries?: number;
|
|
64
|
+
initialBackoffMs?: number;
|
|
65
|
+
}): <T>(operationFn: () => Promise<T>, operationDescription: string) => Promise<T>;
|
|
66
|
+
|
|
67
|
+
export declare type DatabaseConfig = {
|
|
68
|
+
url: string;
|
|
69
|
+
dbName: string;
|
|
70
|
+
options?: MongoClientOptions;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export declare function formatDateForMongoDB(date: Date | string): Date;
|
|
74
|
+
|
|
75
|
+
export declare class LegacyEvalsMongoDB extends LegacyEvalsStorage {
|
|
76
|
+
private operations;
|
|
77
|
+
constructor({ operations }: {
|
|
78
|
+
operations: StoreOperationsMongoDB;
|
|
79
|
+
});
|
|
80
|
+
/** @deprecated use getEvals instead */
|
|
81
|
+
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
82
|
+
getEvals(options?: {
|
|
83
|
+
agentName?: string;
|
|
84
|
+
type?: 'test' | 'live';
|
|
85
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
86
|
+
evals: EvalRow[];
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare class MemoryStorageMongoDB extends MemoryStorage {
|
|
91
|
+
private operations;
|
|
92
|
+
constructor({ operations }: {
|
|
93
|
+
operations: StoreOperationsMongoDB;
|
|
94
|
+
});
|
|
95
|
+
private parseRow;
|
|
96
|
+
private _getIncludedMessages;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated use getMessagesPaginated instead for paginated results.
|
|
99
|
+
*/
|
|
100
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
101
|
+
format?: 'v1';
|
|
102
|
+
}): Promise<MastraMessageV1[]>;
|
|
103
|
+
getMessages(args: StorageGetMessagesArg & {
|
|
104
|
+
format: 'v2';
|
|
105
|
+
}): Promise<MastraMessageV2[]>;
|
|
106
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
107
|
+
format?: 'v1' | 'v2';
|
|
108
|
+
}): Promise<PaginationInfo & {
|
|
109
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
110
|
+
}>;
|
|
111
|
+
saveMessages(args: {
|
|
112
|
+
messages: MastraMessageV1[];
|
|
113
|
+
format?: undefined | 'v1';
|
|
114
|
+
}): Promise<MastraMessageV1[]>;
|
|
115
|
+
saveMessages(args: {
|
|
116
|
+
messages: MastraMessageV2[];
|
|
117
|
+
format: 'v2';
|
|
118
|
+
}): Promise<MastraMessageV2[]>;
|
|
119
|
+
updateMessages({ messages, }: {
|
|
120
|
+
messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
121
|
+
id: string;
|
|
122
|
+
content?: {
|
|
123
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
124
|
+
content?: MastraMessageContentV2['content'];
|
|
125
|
+
};
|
|
126
|
+
})[];
|
|
127
|
+
}): Promise<MastraMessageV2[]>;
|
|
128
|
+
getResourceById({ resourceId }: {
|
|
129
|
+
resourceId: string;
|
|
130
|
+
}): Promise<StorageResourceType | null>;
|
|
131
|
+
saveResource({ resource }: {
|
|
132
|
+
resource: StorageResourceType;
|
|
133
|
+
}): Promise<StorageResourceType>;
|
|
134
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
135
|
+
resourceId: string;
|
|
136
|
+
workingMemory?: string;
|
|
137
|
+
metadata?: Record<string, unknown>;
|
|
138
|
+
}): Promise<StorageResourceType>;
|
|
139
|
+
getThreadById({ threadId }: {
|
|
140
|
+
threadId: string;
|
|
141
|
+
}): Promise<StorageThreadType | null>;
|
|
142
|
+
getThreadsByResourceId({ resourceId }: {
|
|
143
|
+
resourceId: string;
|
|
144
|
+
}): Promise<StorageThreadType[]>;
|
|
145
|
+
getThreadsByResourceIdPaginated(args: {
|
|
146
|
+
resourceId: string;
|
|
147
|
+
page: number;
|
|
148
|
+
perPage: number;
|
|
149
|
+
}): Promise<PaginationInfo & {
|
|
150
|
+
threads: StorageThreadType[];
|
|
151
|
+
}>;
|
|
152
|
+
saveThread({ thread }: {
|
|
153
|
+
thread: StorageThreadType;
|
|
154
|
+
}): Promise<StorageThreadType>;
|
|
155
|
+
updateThread({ id, title, metadata, }: {
|
|
156
|
+
id: string;
|
|
157
|
+
title: string;
|
|
158
|
+
metadata: Record<string, unknown>;
|
|
159
|
+
}): Promise<StorageThreadType>;
|
|
160
|
+
deleteThread({ threadId }: {
|
|
161
|
+
threadId: string;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
}
|
|
33
164
|
|
|
34
165
|
/**
|
|
35
166
|
* Vector store specific prompt that details supported operators and examples.
|
|
@@ -41,13 +172,49 @@ export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
|
41
172
|
|
|
42
173
|
declare type MongoDBBlacklisted = BlacklistedRootOperators | '$size';
|
|
43
174
|
|
|
44
|
-
declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
175
|
+
export declare type MongoDBConfig = DatabaseConfig | {
|
|
176
|
+
connectorHandler: ConnectorHandler_alias_1;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export declare class MongoDBConnector {
|
|
180
|
+
#private;
|
|
181
|
+
constructor(options: MongoDBConnectorOptions);
|
|
182
|
+
static fromDatabaseConfig(config: DatabaseConfig): MongoDBConnector;
|
|
183
|
+
static fromConnectionHandler(handler: ConnectorHandler): MongoDBConnector;
|
|
184
|
+
private getConnection;
|
|
185
|
+
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
186
|
+
close(): Promise<void>;
|
|
48
187
|
}
|
|
49
|
-
|
|
50
|
-
export
|
|
188
|
+
|
|
189
|
+
export declare class MongoDBConnector_alias_1 {
|
|
190
|
+
#private;
|
|
191
|
+
constructor(options: MongoDBConnectorOptions_2);
|
|
192
|
+
static fromDatabaseConfig(config: DatabaseConfig): MongoDBConnector_alias_1;
|
|
193
|
+
static fromConnectionHandler(handler: ConnectorHandler_alias_1): MongoDBConnector_alias_1;
|
|
194
|
+
private getConnection;
|
|
195
|
+
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
196
|
+
close(): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare type MongoDBConnectorOptions = {
|
|
200
|
+
client: MongoClient;
|
|
201
|
+
dbName: string;
|
|
202
|
+
handler: undefined;
|
|
203
|
+
} | {
|
|
204
|
+
client: undefined;
|
|
205
|
+
dbName: undefined;
|
|
206
|
+
handler: ConnectorHandler;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
declare type MongoDBConnectorOptions_2 = {
|
|
210
|
+
client: MongoClient;
|
|
211
|
+
dbName: string;
|
|
212
|
+
handler: undefined;
|
|
213
|
+
} | {
|
|
214
|
+
client: undefined;
|
|
215
|
+
dbName: undefined;
|
|
216
|
+
handler: ConnectorHandler_alias_1;
|
|
217
|
+
};
|
|
51
218
|
|
|
52
219
|
/**
|
|
53
220
|
* Translator for MongoDB filter queries.
|
|
@@ -70,6 +237,10 @@ declare interface MongoDBIndexReadyParams {
|
|
|
70
237
|
export { MongoDBIndexReadyParams }
|
|
71
238
|
export { MongoDBIndexReadyParams as MongoDBIndexReadyParams_alias_1 }
|
|
72
239
|
|
|
240
|
+
export declare interface MongoDBOperationsConfig {
|
|
241
|
+
connector: ConnectorHandler_alias_1;
|
|
242
|
+
}
|
|
243
|
+
|
|
73
244
|
declare type MongoDBOperatorValueMap = Omit<OperatorValueMap, '$options'> & {
|
|
74
245
|
$size: number;
|
|
75
246
|
};
|
|
@@ -80,21 +251,26 @@ declare interface MongoDBQueryVectorParams extends QueryVectorParams<MongoDBVect
|
|
|
80
251
|
|
|
81
252
|
declare class MongoDBStore extends MastraStorage {
|
|
82
253
|
#private;
|
|
254
|
+
stores: StorageDomains;
|
|
255
|
+
get supports(): {
|
|
256
|
+
selectByIncludeResourceScope: boolean;
|
|
257
|
+
resourceWorkingMemory: boolean;
|
|
258
|
+
hasColumn: boolean;
|
|
259
|
+
createTable: boolean;
|
|
260
|
+
};
|
|
83
261
|
constructor(config: MongoDBConfig);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* No-op: This backend is schemaless and does not require schema changes.
|
|
89
|
-
* @param tableName Name of the table
|
|
90
|
-
* @param schema Schema of the table
|
|
91
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
92
|
-
*/
|
|
262
|
+
createTable({ tableName, schema, }: {
|
|
263
|
+
tableName: TABLE_NAMES;
|
|
264
|
+
schema: Record<string, StorageColumn>;
|
|
265
|
+
}): Promise<void>;
|
|
93
266
|
alterTable(_args: {
|
|
94
267
|
tableName: TABLE_NAMES;
|
|
95
268
|
schema: Record<string, StorageColumn>;
|
|
96
269
|
ifNotExists: string[];
|
|
97
270
|
}): Promise<void>;
|
|
271
|
+
dropTable({ tableName }: {
|
|
272
|
+
tableName: TABLE_NAMES;
|
|
273
|
+
}): Promise<void>;
|
|
98
274
|
clearTable({ tableName }: {
|
|
99
275
|
tableName: TABLE_NAMES;
|
|
100
276
|
}): Promise<void>;
|
|
@@ -141,29 +317,42 @@ declare class MongoDBStore extends MastraStorage {
|
|
|
141
317
|
messages: MastraMessageV2[];
|
|
142
318
|
format: 'v2';
|
|
143
319
|
}): Promise<MastraMessageV2[]>;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
scope?: string;
|
|
320
|
+
getThreadsByResourceIdPaginated(_args: {
|
|
321
|
+
resourceId: string;
|
|
147
322
|
page: number;
|
|
148
323
|
perPage: number;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
324
|
+
}): Promise<PaginationInfo & {
|
|
325
|
+
threads: StorageThreadType[];
|
|
326
|
+
}>;
|
|
327
|
+
getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
328
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
329
|
+
}>;
|
|
330
|
+
updateMessages(_args: {
|
|
331
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
332
|
+
id: string;
|
|
333
|
+
content?: {
|
|
334
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
335
|
+
content?: MastraMessageContentV2['content'];
|
|
336
|
+
};
|
|
337
|
+
}[];
|
|
338
|
+
}): Promise<MastraMessageV2[]>;
|
|
339
|
+
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
340
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
341
|
+
traces: Trace[];
|
|
342
|
+
}>;
|
|
343
|
+
getWorkflowRuns(args?: {
|
|
153
344
|
workflowName?: string;
|
|
154
345
|
fromDate?: Date;
|
|
155
346
|
toDate?: Date;
|
|
156
347
|
limit?: number;
|
|
157
348
|
offset?: number;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}>;
|
|
166
|
-
total: number;
|
|
349
|
+
resourceId?: string;
|
|
350
|
+
}): Promise<WorkflowRuns>;
|
|
351
|
+
getEvals(options?: {
|
|
352
|
+
agentName?: string;
|
|
353
|
+
type?: 'test' | 'live';
|
|
354
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
355
|
+
evals: EvalRow[];
|
|
167
356
|
}>;
|
|
168
357
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
169
358
|
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
@@ -179,32 +368,54 @@ declare class MongoDBStore extends MastraStorage {
|
|
|
179
368
|
runId: string;
|
|
180
369
|
workflowName?: string;
|
|
181
370
|
}): Promise<WorkflowRun | null>;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
371
|
+
close(): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* SCORERS
|
|
374
|
+
*/
|
|
375
|
+
getScoreById({ id }: {
|
|
376
|
+
id: string;
|
|
377
|
+
}): Promise<ScoreRowData | null>;
|
|
378
|
+
saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
379
|
+
score: ScoreRowData;
|
|
187
380
|
}>;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
381
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
382
|
+
runId: string;
|
|
383
|
+
pagination: StoragePagination;
|
|
384
|
+
}): Promise<{
|
|
385
|
+
pagination: PaginationInfo;
|
|
386
|
+
scores: ScoreRowData[];
|
|
194
387
|
}>;
|
|
195
|
-
|
|
196
|
-
|
|
388
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
389
|
+
pagination: StoragePagination;
|
|
390
|
+
entityId: string;
|
|
391
|
+
entityType: string;
|
|
392
|
+
}): Promise<{
|
|
393
|
+
pagination: PaginationInfo;
|
|
394
|
+
scores: ScoreRowData[];
|
|
197
395
|
}>;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
396
|
+
getScoresByScorerId({ scorerId, pagination, entityId, entityType, }: {
|
|
397
|
+
scorerId: string;
|
|
398
|
+
pagination: StoragePagination;
|
|
399
|
+
entityId?: string;
|
|
400
|
+
entityType?: string;
|
|
401
|
+
}): Promise<{
|
|
402
|
+
pagination: PaginationInfo;
|
|
403
|
+
scores: ScoreRowData[];
|
|
404
|
+
}>;
|
|
405
|
+
/**
|
|
406
|
+
* RESOURCES
|
|
407
|
+
*/
|
|
408
|
+
getResourceById({ resourceId }: {
|
|
409
|
+
resourceId: string;
|
|
410
|
+
}): Promise<StorageResourceType | null>;
|
|
411
|
+
saveResource({ resource }: {
|
|
412
|
+
resource: StorageResourceType;
|
|
413
|
+
}): Promise<StorageResourceType>;
|
|
414
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
415
|
+
resourceId: string;
|
|
416
|
+
workingMemory?: string;
|
|
417
|
+
metadata?: Record<string, unknown>;
|
|
418
|
+
}): Promise<StorageResourceType>;
|
|
208
419
|
}
|
|
209
420
|
export { MongoDBStore }
|
|
210
421
|
export { MongoDBStore as MongoDBStore_alias_1 }
|
|
@@ -281,4 +492,115 @@ export { MongoDBVector as MongoDBVector_alias_1 }
|
|
|
281
492
|
|
|
282
493
|
export declare type MongoDBVectorFilter = VectorFilter<keyof MongoDBOperatorValueMap, MongoDBOperatorValueMap, LogicalOperatorValueMap, MongoDBBlacklisted, VectorFieldValue | RegExp>;
|
|
283
494
|
|
|
495
|
+
export declare class ScoresStorageMongoDB extends ScoresStorage {
|
|
496
|
+
private operations;
|
|
497
|
+
constructor({ operations }: {
|
|
498
|
+
operations: StoreOperationsMongoDB;
|
|
499
|
+
});
|
|
500
|
+
getScoreById({ id }: {
|
|
501
|
+
id: string;
|
|
502
|
+
}): Promise<ScoreRowData | null>;
|
|
503
|
+
saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
504
|
+
score: ScoreRowData;
|
|
505
|
+
}>;
|
|
506
|
+
getScoresByScorerId({ scorerId, pagination, entityId, entityType, }: {
|
|
507
|
+
scorerId: string;
|
|
508
|
+
pagination: StoragePagination;
|
|
509
|
+
entityId?: string;
|
|
510
|
+
entityType?: string;
|
|
511
|
+
}): Promise<{
|
|
512
|
+
pagination: PaginationInfo;
|
|
513
|
+
scores: ScoreRowData[];
|
|
514
|
+
}>;
|
|
515
|
+
getScoresByRunId({ runId, pagination, }: {
|
|
516
|
+
runId: string;
|
|
517
|
+
pagination: StoragePagination;
|
|
518
|
+
}): Promise<{
|
|
519
|
+
pagination: PaginationInfo;
|
|
520
|
+
scores: ScoreRowData[];
|
|
521
|
+
}>;
|
|
522
|
+
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
523
|
+
pagination: StoragePagination;
|
|
524
|
+
entityId: string;
|
|
525
|
+
entityType: string;
|
|
526
|
+
}): Promise<{
|
|
527
|
+
pagination: PaginationInfo;
|
|
528
|
+
scores: ScoreRowData[];
|
|
529
|
+
}>;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export declare class StoreOperationsMongoDB extends StoreOperations {
|
|
533
|
+
#private;
|
|
534
|
+
constructor(config: MongoDBOperationsConfig);
|
|
535
|
+
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
536
|
+
hasColumn(_table: string, _column: string): Promise<boolean>;
|
|
537
|
+
createTable(): Promise<void>;
|
|
538
|
+
alterTable(_args: {
|
|
539
|
+
tableName: TABLE_NAMES;
|
|
540
|
+
schema: Record<string, StorageColumn>;
|
|
541
|
+
ifNotExists: string[];
|
|
542
|
+
}): Promise<void>;
|
|
543
|
+
clearTable({ tableName }: {
|
|
544
|
+
tableName: TABLE_NAMES;
|
|
545
|
+
}): Promise<void>;
|
|
546
|
+
dropTable({ tableName }: {
|
|
547
|
+
tableName: TABLE_NAMES;
|
|
548
|
+
}): Promise<void>;
|
|
549
|
+
insert({ tableName, record }: {
|
|
550
|
+
tableName: TABLE_NAMES;
|
|
551
|
+
record: Record<string, any>;
|
|
552
|
+
}): Promise<void>;
|
|
553
|
+
batchInsert({ tableName, records }: {
|
|
554
|
+
tableName: TABLE_NAMES;
|
|
555
|
+
records: Record<string, any>[];
|
|
556
|
+
}): Promise<void>;
|
|
557
|
+
load<R>({ tableName, keys }: {
|
|
558
|
+
tableName: TABLE_NAMES;
|
|
559
|
+
keys: Record<string, string>;
|
|
560
|
+
}): Promise<R | null>;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export declare class TracesStorageMongoDB extends TracesStorage {
|
|
564
|
+
private operations;
|
|
565
|
+
constructor({ operations }: {
|
|
566
|
+
operations: StoreOperationsMongoDB;
|
|
567
|
+
});
|
|
568
|
+
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
569
|
+
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
570
|
+
traces: Trace[];
|
|
571
|
+
}>;
|
|
572
|
+
batchTraceInsert({ records }: {
|
|
573
|
+
records: Record<string, any>[];
|
|
574
|
+
}): Promise<void>;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export declare class WorkflowsStorageMongoDB extends WorkflowsStorage {
|
|
578
|
+
private operations;
|
|
579
|
+
constructor({ operations }: {
|
|
580
|
+
operations: StoreOperationsMongoDB;
|
|
581
|
+
});
|
|
582
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
583
|
+
workflowName: string;
|
|
584
|
+
runId: string;
|
|
585
|
+
snapshot: WorkflowRunState;
|
|
586
|
+
}): Promise<void>;
|
|
587
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
588
|
+
workflowName: string;
|
|
589
|
+
runId: string;
|
|
590
|
+
}): Promise<WorkflowRunState | null>;
|
|
591
|
+
getWorkflowRuns(args?: {
|
|
592
|
+
workflowName?: string;
|
|
593
|
+
fromDate?: Date;
|
|
594
|
+
toDate?: Date;
|
|
595
|
+
limit?: number;
|
|
596
|
+
offset?: number;
|
|
597
|
+
resourceId?: string;
|
|
598
|
+
}): Promise<WorkflowRuns>;
|
|
599
|
+
getWorkflowRunById(args: {
|
|
600
|
+
runId: string;
|
|
601
|
+
workflowName?: string;
|
|
602
|
+
}): Promise<WorkflowRun | null>;
|
|
603
|
+
private parseWorkflowRun;
|
|
604
|
+
}
|
|
605
|
+
|
|
284
606
|
export { }
|