@mastra/upstash 0.0.0-vnextWorkflows-20250422142014 → 0.0.0-workflow-deno-20250616115451

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/PAGINATION.md ADDED
@@ -0,0 +1,397 @@
1
+ # Upstash Store Pagination Features
2
+
3
+ This document describes the pagination capabilities added to the UpstashStore class for efficient data retrieval from Upstash Redis.
4
+
5
+ ## Overview
6
+
7
+ The UpstashStore now supports comprehensive pagination across all major data retrieval methods. Pagination helps manage large datasets by:
8
+
9
+ - Reducing memory usage by loading data in chunks
10
+ - Improving response times for large collections
11
+ - Supporting both cursor-based and offset-based pagination patterns
12
+ - Providing total count information for UI pagination controls
13
+
14
+ ## Pagination Patterns
15
+
16
+ The implementation supports two pagination patterns to match different use cases:
17
+
18
+ ### 1. Page-based Pagination (page/perPage)
19
+
20
+ ```typescript
21
+ const result = await store.getEvals({
22
+ agentName: 'my-agent',
23
+ page: 0, // First page (0-based)
24
+ perPage: 20, // 20 items per page
25
+ });
26
+ ```
27
+
28
+ ### 2. Offset-based Pagination (limit/offset)
29
+
30
+ ```typescript
31
+ const result = await store.getEvals({
32
+ agentName: 'my-agent',
33
+ limit: 20, // Maximum items to return
34
+ offset: 40, // Skip first 40 items
35
+ });
36
+ ```
37
+
38
+ ## Enhanced Methods
39
+
40
+ ### 1. getEvals() - New Comprehensive Evaluation Retrieval
41
+
42
+ ```typescript
43
+ const result = await store.getEvals({
44
+ agentName?: string; // Filter by agent name
45
+ type?: 'test' | 'live'; // Filter by evaluation type
46
+ page?: number; // Page number (0-based)
47
+ perPage?: number; // Items per page
48
+ limit?: number; // Alternative: max items
49
+ offset?: number; // Alternative: items to skip
50
+ fromDate?: Date; // Filter by date range
51
+ toDate?: Date;
52
+ });
53
+
54
+ // Returns:
55
+ {
56
+ evals: EvalRow[]; // Evaluation results
57
+ total: number; // Total count (before pagination)
58
+ page?: number; // Current page (page-based)
59
+ perPage?: number; // Items per page (page-based)
60
+ hasMore: boolean; // Whether more data exists
61
+ }
62
+ ```
63
+
64
+ ### 2. getMessages() - Enhanced with Pagination Support
65
+
66
+ The existing `getMessages` function now supports pagination while maintaining full backward compatibility:
67
+
68
+ ```typescript
69
+ // Original usage (backward compatible) - returns message array
70
+ const messages = await store.getMessages({
71
+ threadId: 'thread-id',
72
+ format: 'v2'
73
+ });
74
+
75
+ // New paginated usage - returns pagination object
76
+ const result = await store.getMessages({
77
+ threadId: 'thread-id',
78
+ page: 0, // Page number (0-based)
79
+ perPage: 20, // Items per page (default: 40)
80
+ format: 'v2', // Message format
81
+ fromDate?: Date, // Filter by creation date
82
+ toDate?: Date, // Filter by creation date
83
+ });
84
+
85
+ // Paginated result format:
86
+ {
87
+ messages: MastraMessageV1[] | MastraMessageV2[];
88
+ total: number; // Total count
89
+ page: number; // Current page
90
+ perPage: number; // Items per page
91
+ hasMore: boolean; // Whether more data exists
92
+ }
93
+ ```
94
+
95
+ **Key Features:**
96
+
97
+ - **Backward Compatible**: Existing code continues to work unchanged
98
+ - **Conditional Return Type**: Returns array when no pagination params, object when paginated
99
+ - **Date Filtering**: Combine pagination with date range filtering
100
+ - **Maintains Message Order**: Preserves chronological order from Redis sorted sets
101
+ - **Efficient Pipelines**: Uses Redis pipelines for batch operations
102
+
103
+ ### 3. getThreads() - New Comprehensive Thread Retrieval
104
+
105
+ ```typescript
106
+ const result = await store.getThreads({
107
+ resourceId?: string; // Filter by resource ID
108
+ page?: number; // Page number (0-based)
109
+ perPage?: number; // Items per page
110
+ limit?: number; // Alternative: max items
111
+ offset?: number; // Alternative: items to skip
112
+ fromDate?: Date; // Filter by creation date
113
+ toDate?: Date;
114
+ });
115
+
116
+ // Returns:
117
+ {
118
+ threads: StorageThreadType[]; // Thread results
119
+ total: number; // Total count
120
+ page?: number;
121
+ perPage?: number;
122
+ hasMore: boolean;
123
+ }
124
+ ```
125
+
126
+ ### 4. getTracesWithCount() - Enhanced Trace Retrieval
127
+
128
+ ```typescript
129
+ const result = await store.getTracesWithCount({
130
+ name?: string; // Filter by trace name
131
+ scope?: string; // Filter by scope
132
+ page?: number; // Page number (0-based)
133
+ perPage?: number; // Items per page (default: 100)
134
+ attributes?: Record<string, string>; // Filter by attributes
135
+ filters?: Record<string, any>; // Custom filters
136
+ fromDate?: Date; // Date range filtering
137
+ toDate?: Date;
138
+ });
139
+
140
+ // Returns:
141
+ {
142
+ traces: any[]; // Trace results
143
+ total: number; // Total count
144
+ page: number;
145
+ perPage: number;
146
+ hasMore: boolean;
147
+ }
148
+ ```
149
+
150
+ ## Enhanced Existing Methods
151
+
152
+ ### 1. getEvalsByAgentName() - Now with Pagination
153
+
154
+ ```typescript
155
+ const evals = await store.getEvalsByAgentName(
156
+ 'agent-name',
157
+ 'test' | 'live',
158
+ {
159
+ page?: number;
160
+ perPage?: number;
161
+ limit?: number;
162
+ offset?: number;
163
+ }
164
+ );
165
+ ```
166
+
167
+ ### 2. getThreadsByResourceId() - Now with Pagination
168
+
169
+ ```typescript
170
+ const threads = await store.getThreadsByResourceId({
171
+ resourceId: 'resource-id',
172
+ page?: number;
173
+ perPage?: number;
174
+ limit?: number;
175
+ offset?: number;
176
+ });
177
+ ```
178
+
179
+ ### 3. getWorkflowRuns() - Improved Performance
180
+
181
+ The existing method now uses Redis pipelines for better performance:
182
+
183
+ ```typescript
184
+ const result = await store.getWorkflowRuns({
185
+ namespace?: string; // Default: 'workflows'
186
+ workflowName?: string;
187
+ fromDate?: Date;
188
+ toDate?: Date;
189
+ limit?: number;
190
+ offset?: number;
191
+ resourceId?: string;
192
+ });
193
+ ```
194
+
195
+ ## Utility Methods
196
+
197
+ ### 1. scanWithCursor() - Cursor-based Key Scanning
198
+
199
+ ```typescript
200
+ const result = await store.scanWithCursor(
201
+ 'pattern:*', // Redis key pattern
202
+ '0', // Cursor (use '0' for first scan)
203
+ 1000 // Count hint
204
+ );
205
+
206
+ // Returns:
207
+ {
208
+ keys: string[]; // Found keys
209
+ nextCursor: string; // Cursor for next iteration
210
+ hasMore: boolean; // Whether more keys exist
211
+ }
212
+ ```
213
+
214
+ ### 2. getPaginatedResults() - Generic Pagination Utility
215
+
216
+ ```typescript
217
+ const result = await store.getPaginatedResults<TransformedType>(
218
+ 'pattern:*', // Redis key pattern
219
+ 0, // Page number
220
+ 20, // Items per page
221
+ (record) => ({ // Optional transformer function
222
+ // Transform raw record to desired format
223
+ id: record.id,
224
+ name: record.name
225
+ })
226
+ );
227
+
228
+ // Returns:
229
+ {
230
+ data: TransformedType[];
231
+ total: number;
232
+ page: number;
233
+ perPage: number;
234
+ hasMore: boolean;
235
+ }
236
+ ```
237
+
238
+ ## Performance Optimizations
239
+
240
+ ### Redis Pipeline Usage
241
+
242
+ All pagination methods use Redis pipelines to batch multiple GET operations, significantly improving performance when retrieving multiple records.
243
+
244
+ ```typescript
245
+ // Instead of multiple individual calls:
246
+ // const result1 = await redis.get(key1);
247
+ // const result2 = await redis.get(key2);
248
+
249
+ // We use pipelines:
250
+ const pipeline = redis.pipeline();
251
+ keys.forEach(key => pipeline.get(key));
252
+ const results = await pipeline.exec();
253
+ ```
254
+
255
+ ### Efficient Scanning
256
+
257
+ The implementation uses Redis SCAN operations with cursor-based iteration to efficiently handle large key spaces without blocking the Redis server.
258
+
259
+ ### Memory Management
260
+
261
+ - Results are filtered and transformed only after pagination is applied
262
+ - Large datasets are processed in chunks to prevent memory issues
263
+ - Unnecessary data transformations are avoided for better performance
264
+
265
+ ## Example Usage
266
+
267
+ ### Basic Message Pagination
268
+
269
+ ```typescript
270
+ // Get first page of messages with pagination metadata
271
+ const page1 = await store.getMessages({
272
+ threadId: 'thread-123',
273
+ page: 0,
274
+ perPage: 20,
275
+ format: 'v2',
276
+ });
277
+
278
+ console.log(`Showing ${page1.messages.length} of ${page1.total} messages`);
279
+ console.log(`Has more: ${page1.hasMore}`);
280
+
281
+ // Backward compatible usage (no pagination metadata)
282
+ const allMessages = await store.getMessages({
283
+ threadId: 'thread-123',
284
+ format: 'v2',
285
+ });
286
+ console.log(`Retrieved ${allMessages.length} messages`);
287
+ ```
288
+
289
+ ### Basic Evaluation Pagination
290
+
291
+ ```typescript
292
+ // Get first page of evaluations for an agent
293
+ const page1 = await store.getEvals({
294
+ agentName: 'my-agent',
295
+ page: 0,
296
+ perPage: 20,
297
+ });
298
+
299
+ console.log(`Showing ${page1.evals.length} of ${page1.total} evaluations`);
300
+ console.log(`Has more: ${page1.hasMore}`);
301
+ ```
302
+
303
+ ### Date Range with Pagination
304
+
305
+ ```typescript
306
+ // Get recent threads with pagination
307
+ const recentThreads = await store.getThreads({
308
+ fromDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), // Last 7 days
309
+ page: 0,
310
+ perPage: 10,
311
+ });
312
+ ```
313
+
314
+ ### Filtered Traces with Pagination
315
+
316
+ ```typescript
317
+ // Get production traces with specific attributes
318
+ const prodTraces = await store.getTracesWithCount({
319
+ scope: 'production',
320
+ attributes: { environment: 'prod', service: 'api' },
321
+ page: 1,
322
+ perPage: 50,
323
+ });
324
+ ```
325
+
326
+ ### Message Date Filtering
327
+
328
+ ```typescript
329
+ // Get recent messages from a thread
330
+ const recentMessages = await store.getMessages({
331
+ threadId: 'thread-123',
332
+ page: 0,
333
+ perPage: 10,
334
+ fromDate: new Date(Date.now() - 24 * 60 * 60 * 1000), // Last 24 hours
335
+ format: 'v2',
336
+ });
337
+ ```
338
+
339
+ ## Best Practices
340
+
341
+ 1. **Use appropriate page sizes**: Start with 20-100 items per page depending on data size
342
+ 2. **Implement client-side caching**: Cache paginated results to reduce server load
343
+ 3. **Handle empty results**: Always check if the returned array is empty
344
+ 4. **Use date filters**: Combine pagination with date filters for better performance
345
+ 5. **Monitor total counts**: Use the `total` field to implement proper pagination UI
346
+ 6. **Choose the right pattern**: Use page/perPage for UI pagination, limit/offset for data processing
347
+ 7. **Leverage backward compatibility**: Existing `getMessages` calls work unchanged
348
+ 8. **Check return types**: Use TypeScript overloads to get proper type inference
349
+
350
+ ## Migration Guide
351
+
352
+ The enhanced `getMessages` function is fully backward compatible. No changes are required for existing code, but you can opt into pagination features:
353
+
354
+ ### For Messages
355
+
356
+ ```typescript
357
+ // Existing code (continues to work unchanged)
358
+ const messages = await store.getMessages({
359
+ threadId: 'thread-123',
360
+ format: 'v2',
361
+ });
362
+
363
+ // Enhanced with pagination (new functionality)
364
+ const result = await store.getMessages({
365
+ threadId: 'thread-123',
366
+ page: 0,
367
+ perPage: 20,
368
+ format: 'v2',
369
+ });
370
+ const messages = result.messages;
371
+ const total = result.total;
372
+ ```
373
+
374
+ ### For Other Methods
375
+
376
+ If you're using existing methods, they remain backward compatible. To take advantage of new pagination features:
377
+
378
+ 1. **Replace** `getEvalsByAgentName()` calls with `getEvals()` for better filtering and pagination
379
+ 2. **Replace** `getThreadsByResourceId()` calls with `getThreads()` for date filtering and total counts
380
+ 3. **Use** `getMessages()` with pagination parameters instead of complex `selectBy` logic when appropriate
381
+ 4. **Use** `getTracesWithCount()` instead of `getTraces()` when you need total counts
382
+
383
+ Example migration:
384
+
385
+ ```typescript
386
+ // Before:
387
+ const evals = await store.getEvalsByAgentName('agent-name');
388
+
389
+ // After:
390
+ const result = await store.getEvals({
391
+ agentName: 'agent-name',
392
+ page: 0,
393
+ perPage: 20,
394
+ });
395
+ const evals = result.evals;
396
+ const total = result.total;
397
+ ```
@@ -1,21 +1,39 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { EvalRow } from '@mastra/core/storage';
7
+ import type { IndexStats } from '@mastra/core/vector';
8
+ import type { MastraMessageV1 } from '@mastra/core/memory';
9
+ import type { MastraMessageV2 } from '@mastra/core/memory';
4
10
  import { MastraStorage } from '@mastra/core/storage';
5
11
  import { MastraVector } from '@mastra/core/vector';
6
- import type { MessageType } from '@mastra/core/memory';
7
12
  import type { OperatorSupport } from '@mastra/core/vector/filter';
8
- import type { ParamsToArgs } from '@mastra/core/vector';
13
+ import type { PaginationArgs } from '@mastra/core/storage';
14
+ import type { PaginationInfo } from '@mastra/core/storage';
9
15
  import type { QueryResult } from '@mastra/core/vector';
10
16
  import type { QueryVectorParams } from '@mastra/core/vector';
11
17
  import type { StorageColumn } from '@mastra/core/storage';
12
18
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
19
+ import type { StorageGetTracesArg } from '@mastra/core/storage';
13
20
  import type { StorageThreadType } from '@mastra/core/memory';
14
21
  import type { TABLE_NAMES } from '@mastra/core/storage';
22
+ import type { UpdateVectorParams } from '@mastra/core/vector';
15
23
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
24
  import type { VectorFilter } from '@mastra/core/vector/filter';
25
+ import type { WorkflowRun } from '@mastra/core/storage';
26
+ import type { WorkflowRuns } from '@mastra/core/storage';
17
27
  import type { WorkflowRunState } from '@mastra/core/workflows';
18
28
 
29
+ /**
30
+ * Vector store specific prompt that details supported operators and examples.
31
+ * This prompt helps users construct valid filters for Upstash Vector.
32
+ */
33
+ declare const UPSTASH_PROMPT = "When querying Upstash 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\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\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\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):\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 { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
34
+ export { UPSTASH_PROMPT }
35
+ export { UPSTASH_PROMPT as UPSTASH_PROMPT_alias_1 }
36
+
19
37
  declare interface UpstashConfig {
20
38
  url: string;
21
39
  token: string;
@@ -38,30 +56,61 @@ export declare class UpstashFilterTranslator extends BaseFilterTranslator {
38
56
  }
39
57
 
40
58
  declare class UpstashStore extends MastraStorage {
41
- batchInsert(_input: {
42
- tableName: TABLE_NAMES;
43
- records: Record<string, any>[];
44
- }): Promise<void>;
45
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
59
+ private redis;
60
+ constructor(config: UpstashConfig);
61
+ get supports(): {
62
+ selectByIncludeResourceScope: boolean;
63
+ };
46
64
  private transformEvalRecord;
47
- getTraces({ name, scope, page, perPage, attributes, filters, }?: {
65
+ private parseJSON;
66
+ private getKey;
67
+ /**
68
+ * Scans for keys matching the given pattern using SCAN and returns them as an array.
69
+ * @param pattern Redis key pattern, e.g. "table:*"
70
+ * @param batchSize Number of keys to scan per batch (default: 1000)
71
+ */
72
+ private scanKeys;
73
+ /**
74
+ * Deletes all keys matching the given pattern using SCAN and DEL in batches.
75
+ * @param pattern Redis key pattern, e.g. "table:*"
76
+ * @param batchSize Number of keys to delete per batch (default: 1000)
77
+ */
78
+ private scanAndDelete;
79
+ private getMessageKey;
80
+ private getThreadMessagesKey;
81
+ private parseWorkflowRun;
82
+ private processRecord;
83
+ /**
84
+ * @deprecated Use getEvals instead
85
+ */
86
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
87
+ /**
88
+ * @deprecated use getTracesPaginated instead
89
+ */
90
+ getTraces(args: StorageGetTracesArg): Promise<any[]>;
91
+ getTracesPaginated(args: {
48
92
  name?: string;
49
93
  scope?: string;
50
- page: number;
51
- perPage: number;
52
94
  attributes?: Record<string, string>;
53
95
  filters?: Record<string, any>;
54
- }): Promise<any[]>;
55
- private parseJSON;
56
- private redis;
57
- constructor(config: UpstashConfig);
58
- private getKey;
59
- private ensureDate;
60
- private serializeDate;
96
+ } & PaginationArgs): Promise<PaginationInfo & {
97
+ traces: any[];
98
+ }>;
61
99
  createTable({ tableName, schema, }: {
62
100
  tableName: TABLE_NAMES;
63
101
  schema: Record<string, StorageColumn>;
64
102
  }): Promise<void>;
103
+ /**
104
+ * No-op: This backend is schemaless and does not require schema changes.
105
+ * @param tableName Name of the table
106
+ * @param schema Schema of the table
107
+ * @param ifNotExists Array of column names to add if they don't exist
108
+ */
109
+ alterTable(_args: {
110
+ tableName: TABLE_NAMES;
111
+ schema: Record<string, StorageColumn>;
112
+ ifNotExists: string[];
113
+ }): Promise<void>;
65
114
  clearTable({ tableName }: {
66
115
  tableName: TABLE_NAMES;
67
116
  }): Promise<void>;
@@ -69,6 +118,10 @@ declare class UpstashStore extends MastraStorage {
69
118
  tableName: TABLE_NAMES;
70
119
  record: Record<string, any>;
71
120
  }): Promise<void>;
121
+ batchInsert(input: {
122
+ tableName: TABLE_NAMES;
123
+ records: Record<string, any>[];
124
+ }): Promise<void>;
72
125
  load<R>({ tableName, keys }: {
73
126
  tableName: TABLE_NAMES;
74
127
  keys: Record<string, string>;
@@ -76,9 +129,17 @@ declare class UpstashStore extends MastraStorage {
76
129
  getThreadById({ threadId }: {
77
130
  threadId: string;
78
131
  }): Promise<StorageThreadType | null>;
132
+ /**
133
+ * @deprecated use getThreadsByResourceIdPaginated instead
134
+ */
79
135
  getThreadsByResourceId({ resourceId }: {
80
136
  resourceId: string;
81
137
  }): Promise<StorageThreadType[]>;
138
+ getThreadsByResourceIdPaginated(args: {
139
+ resourceId: string;
140
+ } & PaginationArgs): Promise<PaginationInfo & {
141
+ threads: StorageThreadType[];
142
+ }>;
82
143
  saveThread({ thread }: {
83
144
  thread: StorageThreadType;
84
145
  }): Promise<StorageThreadType>;
@@ -90,12 +151,29 @@ declare class UpstashStore extends MastraStorage {
90
151
  deleteThread({ threadId }: {
91
152
  threadId: string;
92
153
  }): Promise<void>;
93
- private getMessageKey;
94
- private getThreadMessagesKey;
95
- saveMessages({ messages }: {
96
- messages: MessageType[];
97
- }): Promise<MessageType[]>;
98
- getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
154
+ saveMessages(args: {
155
+ messages: MastraMessageV1[];
156
+ format?: undefined | 'v1';
157
+ }): Promise<MastraMessageV1[]>;
158
+ saveMessages(args: {
159
+ messages: MastraMessageV2[];
160
+ format: 'v2';
161
+ }): Promise<MastraMessageV2[]>;
162
+ private _getIncludedMessages;
163
+ /**
164
+ * @deprecated use getMessagesPaginated instead
165
+ */
166
+ getMessages(args: StorageGetMessagesArg & {
167
+ format?: 'v1';
168
+ }): Promise<MastraMessageV1[]>;
169
+ getMessages(args: StorageGetMessagesArg & {
170
+ format: 'v2';
171
+ }): Promise<MastraMessageV2[]>;
172
+ getMessagesPaginated(args: StorageGetMessagesArg & {
173
+ format?: 'v1' | 'v2';
174
+ }): Promise<PaginationInfo & {
175
+ messages: MastraMessageV1[] | MastraMessageV2[];
176
+ }>;
99
177
  persistWorkflowSnapshot(params: {
100
178
  namespace: string;
101
179
  workflowName: string;
@@ -107,23 +185,31 @@ declare class UpstashStore extends MastraStorage {
107
185
  workflowName: string;
108
186
  runId: string;
109
187
  }): Promise<WorkflowRunState | null>;
110
- getWorkflowRuns({ namespace, workflowName, fromDate, toDate, limit, offset, }?: {
188
+ /**
189
+ * Get all evaluations with pagination and total count
190
+ * @param options Pagination and filtering options
191
+ * @returns Object with evals array and total count
192
+ */
193
+ getEvals(options?: {
194
+ agentName?: string;
195
+ type?: 'test' | 'live';
196
+ } & PaginationArgs): Promise<PaginationInfo & {
197
+ evals: EvalRow[];
198
+ }>;
199
+ getWorkflowRuns({ namespace, workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
111
200
  namespace: string;
112
201
  workflowName?: string;
113
202
  fromDate?: Date;
114
203
  toDate?: Date;
115
204
  limit?: number;
116
205
  offset?: number;
117
- }): Promise<{
118
- runs: Array<{
119
- workflowName: string;
120
- runId: string;
121
- snapshot: WorkflowRunState | string;
122
- createdAt: Date;
123
- updatedAt: Date;
124
- }>;
125
- total: number;
126
- }>;
206
+ resourceId?: string;
207
+ }): Promise<WorkflowRuns>;
208
+ getWorkflowRunById({ namespace, runId, workflowName, }: {
209
+ namespace: string;
210
+ runId: string;
211
+ workflowName?: string;
212
+ }): Promise<WorkflowRun | null>;
127
213
  close(): Promise<void>;
128
214
  }
129
215
  export { UpstashStore }
@@ -135,22 +221,38 @@ declare class UpstashVector extends MastraVector {
135
221
  url: string;
136
222
  token: string;
137
223
  });
138
- upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
224
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
139
225
  transformFilter(filter?: VectorFilter): string | undefined;
140
- createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
141
- query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
226
+ createIndex(_params: CreateIndexParams): Promise<void>;
227
+ query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
142
228
  listIndexes(): Promise<string[]>;
143
- describeIndex(indexName: string): Promise<{
144
- dimension: number;
145
- count: number;
146
- metric: "cosine" | "euclidean" | "dotproduct";
147
- }>;
148
- deleteIndex(indexName: string): Promise<void>;
149
- updateIndexById(indexName: string, id: string, update: {
150
- vector?: number[];
151
- metadata?: Record<string, any>;
152
- }): Promise<void>;
153
- deleteIndexById(indexName: string, id: string): Promise<void>;
229
+ /**
230
+ * Retrieves statistics about a vector index.
231
+ *
232
+ * @param {string} indexName - The name of the index to describe
233
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
234
+ */
235
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
236
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
237
+ /**
238
+ * Updates a vector by its ID with the provided vector and/or metadata.
239
+ * @param indexName - The name of the index containing the vector.
240
+ * @param id - The ID of the vector to update.
241
+ * @param update - An object containing the vector and/or metadata to update.
242
+ * @param update.vector - An optional array of numbers representing the new vector.
243
+ * @param update.metadata - An optional record containing the new metadata.
244
+ * @returns A promise that resolves when the update is complete.
245
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
246
+ */
247
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
248
+ /**
249
+ * Deletes a vector by its ID.
250
+ * @param indexName - The name of the index containing the vector.
251
+ * @param id - The ID of the vector to delete.
252
+ * @returns A promise that resolves when the deletion is complete.
253
+ * @throws Will throw an error if the deletion operation fails.
254
+ */
255
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
154
256
  }
155
257
  export { UpstashVector }
156
258
  export { UpstashVector as UpstashVector_alias_1 }