@mastra/mongodb 0.12.3 → 0.12.4
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 +2 -21
- package/CHANGELOG.md +23 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/MongoDBConnector.d.ts +23 -0
- package/dist/storage/MongoDBConnector.d.ts.map +1 -0
- package/dist/storage/connectors/MongoDBConnector.d.ts +23 -0
- package/dist/storage/connectors/MongoDBConnector.d.ts.map +1 -0
- package/dist/storage/connectors/base.d.ts +6 -0
- package/dist/storage/connectors/base.d.ts.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +18 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +80 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +38 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +41 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +18 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +8 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +33 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +178 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/types.d.ts +11 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/vector/filter.d.ts +21 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/index.d.ts +78 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/prompt.d.ts +6 -0
- package/dist/vector/prompt.d.ts.map +1 -0
- package/package.json +6 -6
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +22 -0
- package/dist/_tsup-dts-rollup.d.cts +0 -605
- package/dist/_tsup-dts-rollup.d.ts +0 -605
- package/dist/index.d.cts +0 -6
|
@@ -1,605 +0,0 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
|
|
3
|
-
import { Collection } from 'mongodb';
|
|
4
|
-
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
5
|
-
import type { DeleteIndexParams } from '@mastra/core/vector';
|
|
6
|
-
import type { DeleteVectorParams } from '@mastra/core/vector';
|
|
7
|
-
import type { DescribeIndexParams } from '@mastra/core/vector';
|
|
8
|
-
import { Document } from 'mongodb';
|
|
9
|
-
import type { EvalRow } from '@mastra/core/storage';
|
|
10
|
-
import type { IMastraLogger } from '@mastra/core/logger';
|
|
11
|
-
import type { IndexStats } from '@mastra/core/vector';
|
|
12
|
-
import { LegacyEvalsStorage } from '@mastra/core/storage';
|
|
13
|
-
import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
|
|
14
|
-
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
15
|
-
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
16
|
-
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
17
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
18
|
-
import { MastraVector } from '@mastra/core/vector';
|
|
19
|
-
import { MemoryStorage } from '@mastra/core/storage';
|
|
20
|
-
import { MongoClient } from 'mongodb';
|
|
21
|
-
import type { MongoClientOptions } from 'mongodb';
|
|
22
|
-
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
23
|
-
import type { OperatorValueMap } from '@mastra/core/vector/filter';
|
|
24
|
-
import type { PaginationArgs } from '@mastra/core/storage';
|
|
25
|
-
import type { PaginationInfo } from '@mastra/core/storage';
|
|
26
|
-
import type { QueryResult } from '@mastra/core/vector';
|
|
27
|
-
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
28
|
-
import type { ScoreRowData } from '@mastra/core/scores';
|
|
29
|
-
import { ScoresStorage } from '@mastra/core/storage';
|
|
30
|
-
import type { StorageColumn } from '@mastra/core/storage';
|
|
31
|
-
import type { StorageDomains } from '@mastra/core/storage';
|
|
32
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
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';
|
|
37
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
38
|
-
import { StoreOperations } from '@mastra/core/storage';
|
|
39
|
-
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
40
|
-
import type { Trace } from '@mastra/core/telemetry';
|
|
41
|
-
import { TracesStorage } from '@mastra/core/storage';
|
|
42
|
-
import type { UpdateVectorParams } from '@mastra/core/vector';
|
|
43
|
-
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
44
|
-
import type { VectorFieldValue } from '@mastra/core/vector/filter';
|
|
45
|
-
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
46
|
-
import type { WorkflowRun } from '@mastra/core/storage';
|
|
47
|
-
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
48
|
-
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
49
|
-
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
50
|
-
|
|
51
|
-
declare interface ConnectorHandler {
|
|
52
|
-
getCollection(collectionName: string): Promise<Collection>;
|
|
53
|
-
close(): Promise<void>;
|
|
54
|
-
}
|
|
55
|
-
export { ConnectorHandler }
|
|
56
|
-
export { ConnectorHandler as ConnectorHandler_alias_1 }
|
|
57
|
-
|
|
58
|
-
export declare function createExecuteOperationWithRetry({ logger, maxRetries, initialBackoffMs, }: {
|
|
59
|
-
logger: IMastraLogger;
|
|
60
|
-
maxRetries?: number;
|
|
61
|
-
initialBackoffMs?: number;
|
|
62
|
-
}): <T>(operationFn: () => Promise<T>, operationDescription: string) => Promise<T>;
|
|
63
|
-
|
|
64
|
-
export declare type DatabaseConfig = {
|
|
65
|
-
url: string;
|
|
66
|
-
dbName: string;
|
|
67
|
-
options?: MongoClientOptions;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export declare function formatDateForMongoDB(date: Date | string): Date;
|
|
71
|
-
|
|
72
|
-
export declare class LegacyEvalsMongoDB extends LegacyEvalsStorage {
|
|
73
|
-
private operations;
|
|
74
|
-
constructor({ operations }: {
|
|
75
|
-
operations: StoreOperationsMongoDB;
|
|
76
|
-
});
|
|
77
|
-
/** @deprecated use getEvals instead */
|
|
78
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
79
|
-
getEvals(options?: {
|
|
80
|
-
agentName?: string;
|
|
81
|
-
type?: 'test' | 'live';
|
|
82
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
83
|
-
evals: EvalRow[];
|
|
84
|
-
}>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export declare class MemoryStorageMongoDB extends MemoryStorage {
|
|
88
|
-
private operations;
|
|
89
|
-
constructor({ operations }: {
|
|
90
|
-
operations: StoreOperationsMongoDB;
|
|
91
|
-
});
|
|
92
|
-
private parseRow;
|
|
93
|
-
private _getIncludedMessages;
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated use getMessagesPaginated instead for paginated results.
|
|
96
|
-
*/
|
|
97
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
98
|
-
format?: 'v1';
|
|
99
|
-
}): Promise<MastraMessageV1[]>;
|
|
100
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
101
|
-
format: 'v2';
|
|
102
|
-
}): Promise<MastraMessageV2[]>;
|
|
103
|
-
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
104
|
-
format?: 'v1' | 'v2';
|
|
105
|
-
}): Promise<PaginationInfo & {
|
|
106
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
107
|
-
}>;
|
|
108
|
-
saveMessages(args: {
|
|
109
|
-
messages: MastraMessageV1[];
|
|
110
|
-
format?: undefined | 'v1';
|
|
111
|
-
}): Promise<MastraMessageV1[]>;
|
|
112
|
-
saveMessages(args: {
|
|
113
|
-
messages: MastraMessageV2[];
|
|
114
|
-
format: 'v2';
|
|
115
|
-
}): Promise<MastraMessageV2[]>;
|
|
116
|
-
updateMessages({ messages, }: {
|
|
117
|
-
messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
118
|
-
id: string;
|
|
119
|
-
content?: {
|
|
120
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
121
|
-
content?: MastraMessageContentV2['content'];
|
|
122
|
-
};
|
|
123
|
-
})[];
|
|
124
|
-
}): Promise<MastraMessageV2[]>;
|
|
125
|
-
getResourceById({ resourceId }: {
|
|
126
|
-
resourceId: string;
|
|
127
|
-
}): Promise<StorageResourceType | null>;
|
|
128
|
-
saveResource({ resource }: {
|
|
129
|
-
resource: StorageResourceType;
|
|
130
|
-
}): Promise<StorageResourceType>;
|
|
131
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
132
|
-
resourceId: string;
|
|
133
|
-
workingMemory?: string;
|
|
134
|
-
metadata?: Record<string, unknown>;
|
|
135
|
-
}): Promise<StorageResourceType>;
|
|
136
|
-
getThreadById({ threadId }: {
|
|
137
|
-
threadId: string;
|
|
138
|
-
}): Promise<StorageThreadType | null>;
|
|
139
|
-
getThreadsByResourceId({ resourceId }: {
|
|
140
|
-
resourceId: string;
|
|
141
|
-
}): Promise<StorageThreadType[]>;
|
|
142
|
-
getThreadsByResourceIdPaginated(args: {
|
|
143
|
-
resourceId: string;
|
|
144
|
-
page: number;
|
|
145
|
-
perPage: number;
|
|
146
|
-
}): Promise<PaginationInfo & {
|
|
147
|
-
threads: StorageThreadType[];
|
|
148
|
-
}>;
|
|
149
|
-
saveThread({ thread }: {
|
|
150
|
-
thread: StorageThreadType;
|
|
151
|
-
}): Promise<StorageThreadType>;
|
|
152
|
-
updateThread({ id, title, metadata, }: {
|
|
153
|
-
id: string;
|
|
154
|
-
title: string;
|
|
155
|
-
metadata: Record<string, unknown>;
|
|
156
|
-
}): Promise<StorageThreadType>;
|
|
157
|
-
deleteThread({ threadId }: {
|
|
158
|
-
threadId: string;
|
|
159
|
-
}): Promise<void>;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Vector store specific prompt that details supported operators and examples.
|
|
164
|
-
* This prompt helps users construct valid filters for MongoDB Vector.
|
|
165
|
-
*/
|
|
166
|
-
declare const MONGODB_PROMPT = "When querying MongoDB Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $size: Match arrays with specific length\n Example: { \"tags\": { \"$size\": 3 } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $type: Check field type\n Example: { \"price\": { \"$type\": \"number\" } }\n\nText Search Operators:\n- $text: Full text search\n Example: { \"$text\": { \"$search\": \"gaming laptop\" } }\n- $regex: Regular expression match\n Example: { \"name\": { \"$regex\": \"^Gaming\" } }\n\nRestrictions:\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- Empty arrays in array operators will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$text\": { \"$search\": \"gaming laptop\" } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
|
|
167
|
-
export { MONGODB_PROMPT }
|
|
168
|
-
export { MONGODB_PROMPT as MONGODB_PROMPT_alias_1 }
|
|
169
|
-
|
|
170
|
-
declare type MongoDBBlacklisted = BlacklistedRootOperators | '$size';
|
|
171
|
-
|
|
172
|
-
export declare type MongoDBConfig = DatabaseConfig | {
|
|
173
|
-
connectorHandler: ConnectorHandler;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export declare class MongoDBConnector {
|
|
177
|
-
#private;
|
|
178
|
-
constructor(options: MongoDBConnectorOptions);
|
|
179
|
-
static fromDatabaseConfig(config: DatabaseConfig): MongoDBConnector;
|
|
180
|
-
static fromConnectionHandler(handler: ConnectorHandler): MongoDBConnector;
|
|
181
|
-
private getConnection;
|
|
182
|
-
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
183
|
-
close(): Promise<void>;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export declare class MongoDBConnector_alias_1 {
|
|
187
|
-
#private;
|
|
188
|
-
constructor(options: MongoDBConnectorOptions_2);
|
|
189
|
-
static fromDatabaseConfig(config: DatabaseConfig): MongoDBConnector_alias_1;
|
|
190
|
-
static fromConnectionHandler(handler: ConnectorHandler): MongoDBConnector_alias_1;
|
|
191
|
-
private getConnection;
|
|
192
|
-
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
193
|
-
close(): Promise<void>;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
declare type MongoDBConnectorOptions = {
|
|
197
|
-
client: MongoClient;
|
|
198
|
-
dbName: string;
|
|
199
|
-
handler: undefined;
|
|
200
|
-
} | {
|
|
201
|
-
client: undefined;
|
|
202
|
-
dbName: undefined;
|
|
203
|
-
handler: ConnectorHandler;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
declare type MongoDBConnectorOptions_2 = {
|
|
207
|
-
client: MongoClient;
|
|
208
|
-
dbName: string;
|
|
209
|
-
handler: undefined;
|
|
210
|
-
} | {
|
|
211
|
-
client: undefined;
|
|
212
|
-
dbName: undefined;
|
|
213
|
-
handler: ConnectorHandler;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Translator for MongoDB filter queries.
|
|
218
|
-
* Maintains MongoDB-compatible syntax while ensuring proper validation
|
|
219
|
-
* and normalization of values.
|
|
220
|
-
*/
|
|
221
|
-
export declare class MongoDBFilterTranslator extends BaseFilterTranslator<MongoDBVectorFilter> {
|
|
222
|
-
protected getSupportedOperators(): OperatorSupport;
|
|
223
|
-
translate(filter?: MongoDBVectorFilter): any;
|
|
224
|
-
private translateNode;
|
|
225
|
-
private translateOperatorValue;
|
|
226
|
-
isEmpty(filter: any): boolean;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
declare interface MongoDBIndexReadyParams {
|
|
230
|
-
indexName: string;
|
|
231
|
-
timeoutMs?: number;
|
|
232
|
-
checkIntervalMs?: number;
|
|
233
|
-
}
|
|
234
|
-
export { MongoDBIndexReadyParams }
|
|
235
|
-
export { MongoDBIndexReadyParams as MongoDBIndexReadyParams_alias_1 }
|
|
236
|
-
|
|
237
|
-
export declare interface MongoDBOperationsConfig {
|
|
238
|
-
connector: ConnectorHandler;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
declare type MongoDBOperatorValueMap = Omit<OperatorValueMap, '$options'> & {
|
|
242
|
-
$size: number;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
declare interface MongoDBQueryVectorParams extends QueryVectorParams<MongoDBVectorFilter> {
|
|
246
|
-
documentFilter?: MongoDBVectorFilter;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
declare class MongoDBStore extends MastraStorage {
|
|
250
|
-
#private;
|
|
251
|
-
stores: StorageDomains;
|
|
252
|
-
get supports(): {
|
|
253
|
-
selectByIncludeResourceScope: boolean;
|
|
254
|
-
resourceWorkingMemory: boolean;
|
|
255
|
-
hasColumn: boolean;
|
|
256
|
-
createTable: boolean;
|
|
257
|
-
deleteMessages: boolean;
|
|
258
|
-
};
|
|
259
|
-
constructor(config: MongoDBConfig);
|
|
260
|
-
createTable({ tableName, schema, }: {
|
|
261
|
-
tableName: TABLE_NAMES;
|
|
262
|
-
schema: Record<string, StorageColumn>;
|
|
263
|
-
}): Promise<void>;
|
|
264
|
-
alterTable(_args: {
|
|
265
|
-
tableName: TABLE_NAMES;
|
|
266
|
-
schema: Record<string, StorageColumn>;
|
|
267
|
-
ifNotExists: string[];
|
|
268
|
-
}): Promise<void>;
|
|
269
|
-
dropTable({ tableName }: {
|
|
270
|
-
tableName: TABLE_NAMES;
|
|
271
|
-
}): Promise<void>;
|
|
272
|
-
clearTable({ tableName }: {
|
|
273
|
-
tableName: TABLE_NAMES;
|
|
274
|
-
}): Promise<void>;
|
|
275
|
-
insert({ tableName, record }: {
|
|
276
|
-
tableName: TABLE_NAMES;
|
|
277
|
-
record: Record<string, any>;
|
|
278
|
-
}): Promise<void>;
|
|
279
|
-
batchInsert({ tableName, records }: {
|
|
280
|
-
tableName: TABLE_NAMES;
|
|
281
|
-
records: Record<string, any>[];
|
|
282
|
-
}): Promise<void>;
|
|
283
|
-
load<R>({ tableName, keys }: {
|
|
284
|
-
tableName: TABLE_NAMES;
|
|
285
|
-
keys: Record<string, string>;
|
|
286
|
-
}): Promise<R | null>;
|
|
287
|
-
getThreadById({ threadId }: {
|
|
288
|
-
threadId: string;
|
|
289
|
-
}): Promise<StorageThreadType | null>;
|
|
290
|
-
getThreadsByResourceId({ resourceId }: {
|
|
291
|
-
resourceId: string;
|
|
292
|
-
}): Promise<StorageThreadType[]>;
|
|
293
|
-
saveThread({ thread }: {
|
|
294
|
-
thread: StorageThreadType;
|
|
295
|
-
}): Promise<StorageThreadType>;
|
|
296
|
-
updateThread({ id, title, metadata, }: {
|
|
297
|
-
id: string;
|
|
298
|
-
title: string;
|
|
299
|
-
metadata: Record<string, unknown>;
|
|
300
|
-
}): Promise<StorageThreadType>;
|
|
301
|
-
deleteThread({ threadId }: {
|
|
302
|
-
threadId: string;
|
|
303
|
-
}): Promise<void>;
|
|
304
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
305
|
-
format?: 'v1';
|
|
306
|
-
}): Promise<MastraMessageV1[]>;
|
|
307
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
308
|
-
format: 'v2';
|
|
309
|
-
}): Promise<MastraMessageV2[]>;
|
|
310
|
-
saveMessages(args: {
|
|
311
|
-
messages: MastraMessageV1[];
|
|
312
|
-
format?: undefined | 'v1';
|
|
313
|
-
}): Promise<MastraMessageV1[]>;
|
|
314
|
-
saveMessages(args: {
|
|
315
|
-
messages: MastraMessageV2[];
|
|
316
|
-
format: 'v2';
|
|
317
|
-
}): Promise<MastraMessageV2[]>;
|
|
318
|
-
getThreadsByResourceIdPaginated(_args: {
|
|
319
|
-
resourceId: string;
|
|
320
|
-
page: number;
|
|
321
|
-
perPage: number;
|
|
322
|
-
}): Promise<PaginationInfo & {
|
|
323
|
-
threads: StorageThreadType[];
|
|
324
|
-
}>;
|
|
325
|
-
getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
326
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
327
|
-
}>;
|
|
328
|
-
updateMessages(_args: {
|
|
329
|
-
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
330
|
-
id: string;
|
|
331
|
-
content?: {
|
|
332
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
333
|
-
content?: MastraMessageContentV2['content'];
|
|
334
|
-
};
|
|
335
|
-
}[];
|
|
336
|
-
}): Promise<MastraMessageV2[]>;
|
|
337
|
-
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
338
|
-
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
339
|
-
traces: Trace[];
|
|
340
|
-
}>;
|
|
341
|
-
getWorkflowRuns(args?: {
|
|
342
|
-
workflowName?: string;
|
|
343
|
-
fromDate?: Date;
|
|
344
|
-
toDate?: Date;
|
|
345
|
-
limit?: number;
|
|
346
|
-
offset?: number;
|
|
347
|
-
resourceId?: string;
|
|
348
|
-
}): Promise<WorkflowRuns>;
|
|
349
|
-
getEvals(options?: {
|
|
350
|
-
agentName?: string;
|
|
351
|
-
type?: 'test' | 'live';
|
|
352
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
353
|
-
evals: EvalRow[];
|
|
354
|
-
}>;
|
|
355
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
356
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
357
|
-
workflowName: string;
|
|
358
|
-
runId: string;
|
|
359
|
-
snapshot: WorkflowRunState;
|
|
360
|
-
}): Promise<void>;
|
|
361
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
362
|
-
workflowName: string;
|
|
363
|
-
runId: string;
|
|
364
|
-
}): Promise<WorkflowRunState | null>;
|
|
365
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
366
|
-
runId: string;
|
|
367
|
-
workflowName?: string;
|
|
368
|
-
}): Promise<WorkflowRun | null>;
|
|
369
|
-
close(): Promise<void>;
|
|
370
|
-
/**
|
|
371
|
-
* SCORERS
|
|
372
|
-
*/
|
|
373
|
-
getScoreById({ id }: {
|
|
374
|
-
id: string;
|
|
375
|
-
}): Promise<ScoreRowData | null>;
|
|
376
|
-
saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
377
|
-
score: ScoreRowData;
|
|
378
|
-
}>;
|
|
379
|
-
getScoresByRunId({ runId, pagination, }: {
|
|
380
|
-
runId: string;
|
|
381
|
-
pagination: StoragePagination;
|
|
382
|
-
}): Promise<{
|
|
383
|
-
pagination: PaginationInfo;
|
|
384
|
-
scores: ScoreRowData[];
|
|
385
|
-
}>;
|
|
386
|
-
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
387
|
-
pagination: StoragePagination;
|
|
388
|
-
entityId: string;
|
|
389
|
-
entityType: string;
|
|
390
|
-
}): Promise<{
|
|
391
|
-
pagination: PaginationInfo;
|
|
392
|
-
scores: ScoreRowData[];
|
|
393
|
-
}>;
|
|
394
|
-
getScoresByScorerId({ scorerId, pagination, entityId, entityType, }: {
|
|
395
|
-
scorerId: string;
|
|
396
|
-
pagination: StoragePagination;
|
|
397
|
-
entityId?: string;
|
|
398
|
-
entityType?: string;
|
|
399
|
-
}): Promise<{
|
|
400
|
-
pagination: PaginationInfo;
|
|
401
|
-
scores: ScoreRowData[];
|
|
402
|
-
}>;
|
|
403
|
-
/**
|
|
404
|
-
* RESOURCES
|
|
405
|
-
*/
|
|
406
|
-
getResourceById({ resourceId }: {
|
|
407
|
-
resourceId: string;
|
|
408
|
-
}): Promise<StorageResourceType | null>;
|
|
409
|
-
saveResource({ resource }: {
|
|
410
|
-
resource: StorageResourceType;
|
|
411
|
-
}): Promise<StorageResourceType>;
|
|
412
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
413
|
-
resourceId: string;
|
|
414
|
-
workingMemory?: string;
|
|
415
|
-
metadata?: Record<string, unknown>;
|
|
416
|
-
}): Promise<StorageResourceType>;
|
|
417
|
-
}
|
|
418
|
-
export { MongoDBStore }
|
|
419
|
-
export { MongoDBStore as MongoDBStore_alias_1 }
|
|
420
|
-
|
|
421
|
-
declare interface MongoDBUpsertVectorParams extends UpsertVectorParams {
|
|
422
|
-
documents?: string[];
|
|
423
|
-
}
|
|
424
|
-
export { MongoDBUpsertVectorParams }
|
|
425
|
-
export { MongoDBUpsertVectorParams as MongoDBUpsertVectorParams_alias_1 }
|
|
426
|
-
|
|
427
|
-
declare class MongoDBVector extends MastraVector<MongoDBVectorFilter> {
|
|
428
|
-
private client;
|
|
429
|
-
private db;
|
|
430
|
-
private collections;
|
|
431
|
-
private readonly embeddingFieldName;
|
|
432
|
-
private readonly metadataFieldName;
|
|
433
|
-
private readonly documentFieldName;
|
|
434
|
-
private collectionForValidation;
|
|
435
|
-
private mongoMetricMap;
|
|
436
|
-
constructor({ uri, dbName, options }: {
|
|
437
|
-
uri: string;
|
|
438
|
-
dbName: string;
|
|
439
|
-
options?: MongoClientOptions;
|
|
440
|
-
});
|
|
441
|
-
connect(): Promise<void>;
|
|
442
|
-
disconnect(): Promise<void>;
|
|
443
|
-
createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
|
|
444
|
-
/**
|
|
445
|
-
* Waits for the index to be ready.
|
|
446
|
-
*
|
|
447
|
-
* @param {string} indexName - The name of the index to wait for
|
|
448
|
-
* @param {number} timeoutMs - The maximum time in milliseconds to wait for the index to be ready (default: 60000)
|
|
449
|
-
* @param {number} checkIntervalMs - The interval in milliseconds at which to check if the index is ready (default: 2000)
|
|
450
|
-
* @returns A promise that resolves when the index is ready
|
|
451
|
-
*/
|
|
452
|
-
waitForIndexReady({ indexName, timeoutMs, checkIntervalMs, }: MongoDBIndexReadyParams): Promise<void>;
|
|
453
|
-
upsert({ indexName, vectors, metadata, ids, documents }: MongoDBUpsertVectorParams): Promise<string[]>;
|
|
454
|
-
query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: MongoDBQueryVectorParams): Promise<QueryResult[]>;
|
|
455
|
-
listIndexes(): Promise<string[]>;
|
|
456
|
-
/**
|
|
457
|
-
* Retrieves statistics about a vector index.
|
|
458
|
-
*
|
|
459
|
-
* @param {string} indexName - The name of the index to describe
|
|
460
|
-
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
461
|
-
*/
|
|
462
|
-
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
463
|
-
deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
|
|
464
|
-
/**
|
|
465
|
-
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
466
|
-
* @param indexName - The name of the index containing the vector.
|
|
467
|
-
* @param id - The ID of the vector to update.
|
|
468
|
-
* @param update - An object containing the vector and/or metadata to update.
|
|
469
|
-
* @param update.vector - An optional array of numbers representing the new vector.
|
|
470
|
-
* @param update.metadata - An optional record containing the new metadata.
|
|
471
|
-
* @returns A promise that resolves when the update is complete.
|
|
472
|
-
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
473
|
-
*/
|
|
474
|
-
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
475
|
-
/**
|
|
476
|
-
* Deletes a vector by its ID.
|
|
477
|
-
* @param indexName - The name of the index containing the vector.
|
|
478
|
-
* @param id - The ID of the vector to delete.
|
|
479
|
-
* @returns A promise that resolves when the deletion is complete.
|
|
480
|
-
* @throws Will throw an error if the deletion operation fails.
|
|
481
|
-
*/
|
|
482
|
-
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
483
|
-
private getCollection;
|
|
484
|
-
private validateVectorDimensions;
|
|
485
|
-
private setIndexDimension;
|
|
486
|
-
private transformFilter;
|
|
487
|
-
}
|
|
488
|
-
export { MongoDBVector }
|
|
489
|
-
export { MongoDBVector as MongoDBVector_alias_1 }
|
|
490
|
-
|
|
491
|
-
export declare type MongoDBVectorFilter = VectorFilter<keyof MongoDBOperatorValueMap, MongoDBOperatorValueMap, LogicalOperatorValueMap, MongoDBBlacklisted, VectorFieldValue | RegExp>;
|
|
492
|
-
|
|
493
|
-
export declare class ScoresStorageMongoDB extends ScoresStorage {
|
|
494
|
-
private operations;
|
|
495
|
-
constructor({ operations }: {
|
|
496
|
-
operations: StoreOperationsMongoDB;
|
|
497
|
-
});
|
|
498
|
-
getScoreById({ id }: {
|
|
499
|
-
id: string;
|
|
500
|
-
}): Promise<ScoreRowData | null>;
|
|
501
|
-
saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
|
|
502
|
-
score: ScoreRowData;
|
|
503
|
-
}>;
|
|
504
|
-
getScoresByScorerId({ scorerId, pagination, entityId, entityType, }: {
|
|
505
|
-
scorerId: string;
|
|
506
|
-
pagination: StoragePagination;
|
|
507
|
-
entityId?: string;
|
|
508
|
-
entityType?: string;
|
|
509
|
-
}): Promise<{
|
|
510
|
-
pagination: PaginationInfo;
|
|
511
|
-
scores: ScoreRowData[];
|
|
512
|
-
}>;
|
|
513
|
-
getScoresByRunId({ runId, pagination, }: {
|
|
514
|
-
runId: string;
|
|
515
|
-
pagination: StoragePagination;
|
|
516
|
-
}): Promise<{
|
|
517
|
-
pagination: PaginationInfo;
|
|
518
|
-
scores: ScoreRowData[];
|
|
519
|
-
}>;
|
|
520
|
-
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
521
|
-
pagination: StoragePagination;
|
|
522
|
-
entityId: string;
|
|
523
|
-
entityType: string;
|
|
524
|
-
}): Promise<{
|
|
525
|
-
pagination: PaginationInfo;
|
|
526
|
-
scores: ScoreRowData[];
|
|
527
|
-
}>;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
export declare class StoreOperationsMongoDB extends StoreOperations {
|
|
531
|
-
#private;
|
|
532
|
-
constructor(config: MongoDBOperationsConfig);
|
|
533
|
-
getCollection(collectionName: string): Promise<Collection<Document>>;
|
|
534
|
-
hasColumn(_table: string, _column: string): Promise<boolean>;
|
|
535
|
-
createTable(): Promise<void>;
|
|
536
|
-
alterTable(_args: {
|
|
537
|
-
tableName: TABLE_NAMES;
|
|
538
|
-
schema: Record<string, StorageColumn>;
|
|
539
|
-
ifNotExists: string[];
|
|
540
|
-
}): Promise<void>;
|
|
541
|
-
clearTable({ tableName }: {
|
|
542
|
-
tableName: TABLE_NAMES;
|
|
543
|
-
}): Promise<void>;
|
|
544
|
-
dropTable({ tableName }: {
|
|
545
|
-
tableName: TABLE_NAMES;
|
|
546
|
-
}): Promise<void>;
|
|
547
|
-
private processJsonbFields;
|
|
548
|
-
insert({ tableName, record }: {
|
|
549
|
-
tableName: TABLE_NAMES;
|
|
550
|
-
record: Record<string, any>;
|
|
551
|
-
}): Promise<void>;
|
|
552
|
-
batchInsert({ tableName, records }: {
|
|
553
|
-
tableName: TABLE_NAMES;
|
|
554
|
-
records: Record<string, any>[];
|
|
555
|
-
}): Promise<void>;
|
|
556
|
-
load<R>({ tableName, keys }: {
|
|
557
|
-
tableName: TABLE_NAMES;
|
|
558
|
-
keys: Record<string, string>;
|
|
559
|
-
}): Promise<R | null>;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
export declare class TracesStorageMongoDB extends TracesStorage {
|
|
563
|
-
private operations;
|
|
564
|
-
constructor({ operations }: {
|
|
565
|
-
operations: StoreOperationsMongoDB;
|
|
566
|
-
});
|
|
567
|
-
getTraces(args: StorageGetTracesArg): Promise<Trace[]>;
|
|
568
|
-
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
569
|
-
traces: Trace[];
|
|
570
|
-
}>;
|
|
571
|
-
batchTraceInsert({ records }: {
|
|
572
|
-
records: Record<string, any>[];
|
|
573
|
-
}): Promise<void>;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
export declare class WorkflowsStorageMongoDB extends WorkflowsStorage {
|
|
577
|
-
private operations;
|
|
578
|
-
constructor({ operations }: {
|
|
579
|
-
operations: StoreOperationsMongoDB;
|
|
580
|
-
});
|
|
581
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
582
|
-
workflowName: string;
|
|
583
|
-
runId: string;
|
|
584
|
-
snapshot: WorkflowRunState;
|
|
585
|
-
}): Promise<void>;
|
|
586
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
587
|
-
workflowName: string;
|
|
588
|
-
runId: string;
|
|
589
|
-
}): Promise<WorkflowRunState | null>;
|
|
590
|
-
getWorkflowRuns(args?: {
|
|
591
|
-
workflowName?: string;
|
|
592
|
-
fromDate?: Date;
|
|
593
|
-
toDate?: Date;
|
|
594
|
-
limit?: number;
|
|
595
|
-
offset?: number;
|
|
596
|
-
resourceId?: string;
|
|
597
|
-
}): Promise<WorkflowRuns>;
|
|
598
|
-
getWorkflowRunById(args: {
|
|
599
|
-
runId: string;
|
|
600
|
-
workflowName?: string;
|
|
601
|
-
}): Promise<WorkflowRun | null>;
|
|
602
|
-
private parseWorkflowRun;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
export { }
|
package/dist/index.d.cts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { MONGODB_PROMPT } from './_tsup-dts-rollup.cjs';
|
|
2
|
-
export { MongoDBUpsertVectorParams } from './_tsup-dts-rollup.cjs';
|
|
3
|
-
export { MongoDBIndexReadyParams } from './_tsup-dts-rollup.cjs';
|
|
4
|
-
export { MongoDBVector } from './_tsup-dts-rollup.cjs';
|
|
5
|
-
export { MongoDBStore } from './_tsup-dts-rollup.cjs';
|
|
6
|
-
export { ConnectorHandler } from './_tsup-dts-rollup.cjs';
|