@mastra/longmemeval 1.0.0-beta.24 → 1.0.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/package.json +4 -4
- package/src/storage/benchmark-store.ts +41 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @mastra/longmemeval
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
8
|
+
|
|
9
|
+
**New Features**
|
|
10
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
11
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
12
|
+
- Full pagination and sorting support
|
|
13
|
+
|
|
14
|
+
**Example Usage**
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// List all threads
|
|
18
|
+
const allThreads = await memory.listThreads({});
|
|
19
|
+
|
|
20
|
+
// Filter by resourceId only
|
|
21
|
+
const userThreads = await memory.listThreads({
|
|
22
|
+
filter: { resourceId: 'user-123' },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Filter by metadata only
|
|
26
|
+
const supportThreads = await memory.listThreads({
|
|
27
|
+
filter: { metadata: { category: 'support' } },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Filter by both with pagination
|
|
31
|
+
const filteredThreads = await memory.listThreads({
|
|
32
|
+
filter: {
|
|
33
|
+
resourceId: 'user-123',
|
|
34
|
+
metadata: { priority: 'high', status: 'open' },
|
|
35
|
+
},
|
|
36
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
37
|
+
page: 0,
|
|
38
|
+
perPage: 20,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Security Improvements**
|
|
43
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
44
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`6833c69`](https://github.com/mastra-ai/mastra/commit/6833c69607418d257750bbcdd84638993d343539), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`3a76a80`](https://github.com/mastra-ai/mastra/commit/3a76a80284cb71a0faa975abb3d4b2a9631e60cd), [`8538a0d`](https://github.com/mastra-ai/mastra/commit/8538a0d232619bf55dad7ddc2a8b0ca77c679a87), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5)]:
|
|
47
|
+
- @mastra/core@1.0.0-beta.25
|
|
48
|
+
- @mastra/memory@1.0.0-beta.15
|
|
49
|
+
- @mastra/libsql@1.0.0-beta.13
|
|
50
|
+
|
|
3
51
|
## 1.0.0-beta.24
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/longmemeval",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.25",
|
|
4
4
|
"description": "LongMemEval benchmark implementation for Mastra Memory",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@ai-sdk/openai": "^1.3.23",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"openai": "^4.73.1",
|
|
17
17
|
"ora": "^8.1.1",
|
|
18
18
|
"zod": "^3.23.8",
|
|
19
|
-
"@mastra/core": "1.0.0-beta.
|
|
20
|
-
"@mastra/libsql": "1.0.0-beta.12",
|
|
19
|
+
"@mastra/core": "1.0.0-beta.25",
|
|
21
20
|
"@mastra/fastembed": "1.0.0-beta.3",
|
|
22
|
-
"@mastra/
|
|
21
|
+
"@mastra/libsql": "1.0.0-beta.13",
|
|
22
|
+
"@mastra/memory": "1.0.0-beta.15",
|
|
23
23
|
"@mastra/rag": "2.0.0-beta.7"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -8,8 +8,8 @@ import type {
|
|
|
8
8
|
WorkflowRun,
|
|
9
9
|
WorkflowRuns,
|
|
10
10
|
StorageListWorkflowRunsInput,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
StorageListThreadsInput,
|
|
12
|
+
StorageListThreadsOutput,
|
|
13
13
|
StorageListMessagesInput,
|
|
14
14
|
StorageListMessagesOutput,
|
|
15
15
|
} from '@mastra/core/storage';
|
|
@@ -320,24 +320,50 @@ export class BenchmarkStore extends MastraStorage {
|
|
|
320
320
|
return parsedRun as WorkflowRun;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
async
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
async listThreads(args: StorageListThreadsInput): Promise<StorageListThreadsOutput> {
|
|
324
|
+
const { page = 0, perPage: perPageInput, filter, orderBy } = args;
|
|
325
|
+
let allThreads: StorageThreadType[] = Array.from(this.data.mastra_threads.values());
|
|
326
|
+
|
|
327
|
+
// Apply resourceId filter if provided
|
|
328
|
+
if (filter?.resourceId) {
|
|
329
|
+
allThreads = allThreads.filter(thread => thread.resourceId === filter.resourceId);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Apply metadata filter if provided (AND logic)
|
|
333
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
334
|
+
allThreads = allThreads.filter(thread => {
|
|
335
|
+
if (!thread.metadata) return false;
|
|
336
|
+
return Object.entries(filter.metadata!).every(([key, value]) => thread.metadata![key] === value);
|
|
337
|
+
});
|
|
331
338
|
}
|
|
332
|
-
|
|
333
|
-
|
|
339
|
+
|
|
340
|
+
// Apply ordering - default to DESC by createdAt
|
|
341
|
+
const sortField = orderBy?.field || 'createdAt';
|
|
342
|
+
const sortDirection = orderBy?.direction || 'DESC';
|
|
343
|
+
const direction = sortDirection === 'ASC' ? 1 : -1;
|
|
344
|
+
|
|
345
|
+
allThreads.sort((a: any, b: any) => {
|
|
346
|
+
const aVal = a[sortField];
|
|
347
|
+
const bVal = b[sortField];
|
|
348
|
+
if (aVal instanceof Date && bVal instanceof Date) {
|
|
349
|
+
return direction * (aVal.getTime() - bVal.getTime());
|
|
350
|
+
}
|
|
351
|
+
return direction * (aVal < bVal ? -1 : aVal > bVal ? 1 : 0);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// Handle perPage: false (fetch all results)
|
|
355
|
+
const fetchAll = perPageInput === false;
|
|
356
|
+
const normalizedPerPage = fetchAll ? allThreads.length : typeof perPageInput === 'number' ? perPageInput : 100;
|
|
357
|
+
const normalizedPage = fetchAll ? 0 : Math.max(0, page);
|
|
358
|
+
const offset = normalizedPage * normalizedPerPage;
|
|
359
|
+
const threads = allThreads.slice(offset, fetchAll ? undefined : offset + normalizedPerPage);
|
|
334
360
|
|
|
335
361
|
return {
|
|
336
362
|
threads,
|
|
337
363
|
total: allThreads.length,
|
|
338
|
-
page:
|
|
339
|
-
perPage:
|
|
340
|
-
hasMore:
|
|
364
|
+
page: normalizedPage,
|
|
365
|
+
perPage: fetchAll ? false : normalizedPerPage,
|
|
366
|
+
hasMore: fetchAll ? false : offset + normalizedPerPage < allThreads.length,
|
|
341
367
|
};
|
|
342
368
|
}
|
|
343
369
|
|