@mastra/dynamodb 0.0.0-workflow-deno-20250616132510 → 0.0.0-working-memory-per-user-20250620163010
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/dist/_tsup-dts-rollup.d.cts +10 -0
- package/dist/_tsup-dts-rollup.d.ts +10 -0
- package/dist/index.cjs +9 -3
- package/dist/index.js +10 -4
- package/package.json +10 -10
- package/src/storage/index.ts +17 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
2
|
import { Entity } from 'electrodb';
|
|
3
3
|
import type { EvalRow } from '@mastra/core/storage';
|
|
4
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
5
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
6
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
6
7
|
import { MastraStorage } from '@mastra/core/storage';
|
|
@@ -196,6 +197,15 @@ declare class DynamoDBStore extends MastraStorage {
|
|
|
196
197
|
* Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.
|
|
197
198
|
*/
|
|
198
199
|
close(): Promise<void>;
|
|
200
|
+
updateMessages(_args: {
|
|
201
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
202
|
+
id: string;
|
|
203
|
+
content?: {
|
|
204
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
205
|
+
content?: MastraMessageContentV2['content'];
|
|
206
|
+
};
|
|
207
|
+
}[];
|
|
208
|
+
}): Promise<MastraMessageV2[]>;
|
|
199
209
|
}
|
|
200
210
|
export { DynamoDBStore }
|
|
201
211
|
export { DynamoDBStore as DynamoDBStore_alias_1 }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
2
|
import { Entity } from 'electrodb';
|
|
3
3
|
import type { EvalRow } from '@mastra/core/storage';
|
|
4
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
5
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
6
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
6
7
|
import { MastraStorage } from '@mastra/core/storage';
|
|
@@ -196,6 +197,15 @@ declare class DynamoDBStore extends MastraStorage {
|
|
|
196
197
|
* Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.
|
|
197
198
|
*/
|
|
198
199
|
close(): Promise<void>;
|
|
200
|
+
updateMessages(_args: {
|
|
201
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
202
|
+
id: string;
|
|
203
|
+
content?: {
|
|
204
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
205
|
+
content?: MastraMessageContentV2['content'];
|
|
206
|
+
};
|
|
207
|
+
}[];
|
|
208
|
+
}): Promise<MastraMessageV2[]>;
|
|
199
209
|
}
|
|
200
210
|
export { DynamoDBStore }
|
|
201
211
|
export { DynamoDBStore as DynamoDBStore_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -928,8 +928,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
928
928
|
this.logger.debug("Getting messages", { threadId, selectBy });
|
|
929
929
|
try {
|
|
930
930
|
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
931
|
-
|
|
932
|
-
|
|
931
|
+
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
932
|
+
if (limit !== Number.MAX_SAFE_INTEGER) {
|
|
933
|
+
const results2 = await query.go({ limit, order: "desc" });
|
|
933
934
|
const list2 = new agent.MessageList({ threadId, resourceId }).add(
|
|
934
935
|
results2.data.map((data) => this.parseMessageData(data)),
|
|
935
936
|
"memory"
|
|
@@ -1249,7 +1250,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1249
1250
|
[storage.TABLE_MESSAGES]: "message",
|
|
1250
1251
|
[storage.TABLE_WORKFLOW_SNAPSHOT]: "workflowSnapshot",
|
|
1251
1252
|
[storage.TABLE_EVALS]: "eval",
|
|
1252
|
-
[storage.TABLE_TRACES]: "trace"
|
|
1253
|
+
[storage.TABLE_TRACES]: "trace",
|
|
1254
|
+
[storage.TABLE_RESOURCES]: "resource"
|
|
1253
1255
|
};
|
|
1254
1256
|
return mapping[tableName] || null;
|
|
1255
1257
|
}
|
|
@@ -1333,6 +1335,10 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1333
1335
|
throw error;
|
|
1334
1336
|
}
|
|
1335
1337
|
}
|
|
1338
|
+
async updateMessages(_args) {
|
|
1339
|
+
this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
|
|
1340
|
+
throw new Error("Method not implemented");
|
|
1341
|
+
}
|
|
1336
1342
|
};
|
|
1337
1343
|
|
|
1338
1344
|
exports.DynamoDBStore = DynamoDBStore;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamoDBClient, DescribeTableCommand } from '@aws-sdk/client-dynamodb';
|
|
2
2
|
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
3
3
|
import { MessageList } from '@mastra/core/agent';
|
|
4
|
-
import { MastraStorage, TABLE_TRACES, TABLE_EVALS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
|
|
4
|
+
import { MastraStorage, TABLE_TRACES, TABLE_RESOURCES, TABLE_EVALS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
|
|
5
5
|
import { Entity, Service } from 'electrodb';
|
|
6
6
|
|
|
7
7
|
// src/storage/index.ts
|
|
@@ -926,8 +926,9 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
926
926
|
this.logger.debug("Getting messages", { threadId, selectBy });
|
|
927
927
|
try {
|
|
928
928
|
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
929
|
-
|
|
930
|
-
|
|
929
|
+
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
930
|
+
if (limit !== Number.MAX_SAFE_INTEGER) {
|
|
931
|
+
const results2 = await query.go({ limit, order: "desc" });
|
|
931
932
|
const list2 = new MessageList({ threadId, resourceId }).add(
|
|
932
933
|
results2.data.map((data) => this.parseMessageData(data)),
|
|
933
934
|
"memory"
|
|
@@ -1247,7 +1248,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1247
1248
|
[TABLE_MESSAGES]: "message",
|
|
1248
1249
|
[TABLE_WORKFLOW_SNAPSHOT]: "workflowSnapshot",
|
|
1249
1250
|
[TABLE_EVALS]: "eval",
|
|
1250
|
-
[TABLE_TRACES]: "trace"
|
|
1251
|
+
[TABLE_TRACES]: "trace",
|
|
1252
|
+
[TABLE_RESOURCES]: "resource"
|
|
1251
1253
|
};
|
|
1252
1254
|
return mapping[tableName] || null;
|
|
1253
1255
|
}
|
|
@@ -1331,6 +1333,10 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1331
1333
|
throw error;
|
|
1332
1334
|
}
|
|
1333
1335
|
}
|
|
1336
|
+
async updateMessages(_args) {
|
|
1337
|
+
this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
|
|
1338
|
+
throw new Error("Method not implemented");
|
|
1339
|
+
}
|
|
1334
1340
|
};
|
|
1335
1341
|
|
|
1336
1342
|
export { DynamoDBStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dynamodb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-working-memory-per-user-20250620163010",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,26 +23,26 @@
|
|
|
23
23
|
"src"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
27
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
26
|
+
"@aws-sdk/client-dynamodb": "^3.828.0",
|
|
27
|
+
"@aws-sdk/lib-dynamodb": "^3.828.0",
|
|
28
28
|
"electrodb": "^3.4.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@mastra/core": "0.0.0-
|
|
31
|
+
"@mastra/core": "0.0.0-working-memory-per-user-20250620163010"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "^7.52.8",
|
|
35
35
|
"@types/node": "^20.19.0",
|
|
36
|
-
"@vitest/coverage-v8": "3.2.
|
|
37
|
-
"@vitest/ui": "3.2.
|
|
38
|
-
"axios": "^1.
|
|
36
|
+
"@vitest/coverage-v8": "3.2.3",
|
|
37
|
+
"@vitest/ui": "3.2.3",
|
|
38
|
+
"axios": "^1.10.0",
|
|
39
39
|
"eslint": "^9.28.0",
|
|
40
40
|
"tsup": "^8.5.0",
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
42
|
"vitest": "^3.2.3",
|
|
43
|
-
"@internal/
|
|
44
|
-
"@internal/
|
|
45
|
-
"@mastra/core": "0.0.0-
|
|
43
|
+
"@internal/lint": "0.0.0-working-memory-per-user-20250620163010",
|
|
44
|
+
"@internal/storage-test-utils": "0.0.9",
|
|
45
|
+
"@mastra/core": "0.0.0-working-memory-per-user-20250620163010"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
package/src/storage/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DynamoDBClient, DescribeTableCommand } from '@aws-sdk/client-dynamodb';
|
|
2
2
|
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
3
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
4
|
import { MessageList } from '@mastra/core/agent';
|
|
4
5
|
import type { StorageThreadType, MastraMessageV2, MastraMessageV1 } from '@mastra/core/memory';
|
|
5
6
|
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
TABLE_WORKFLOW_SNAPSHOT,
|
|
11
12
|
TABLE_EVALS,
|
|
12
13
|
TABLE_TRACES,
|
|
14
|
+
TABLE_RESOURCES,
|
|
13
15
|
} from '@mastra/core/storage';
|
|
14
16
|
import type {
|
|
15
17
|
EvalRow,
|
|
@@ -579,12 +581,13 @@ export class DynamoDBStore extends MastraStorage {
|
|
|
579
581
|
// Provide *all* composite key components for the 'byThread' index ('entity', 'threadId')
|
|
580
582
|
const query = this.service.entities.message.query.byThread({ entity: 'message', threadId });
|
|
581
583
|
|
|
584
|
+
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
582
585
|
// Apply the 'last' limit if provided
|
|
583
|
-
if (
|
|
586
|
+
if (limit !== Number.MAX_SAFE_INTEGER) {
|
|
584
587
|
// Use ElectroDB's limit parameter
|
|
585
588
|
// DDB GSIs are sorted in ascending order
|
|
586
589
|
// Use ElectroDB's order parameter to sort in descending order to retrieve 'latest' messages
|
|
587
|
-
const results = await query.go({ limit
|
|
590
|
+
const results = await query.go({ limit, order: 'desc' });
|
|
588
591
|
// Use arrow function in map to preserve 'this' context for parseMessageData
|
|
589
592
|
const list = new MessageList({ threadId, resourceId }).add(
|
|
590
593
|
results.data.map((data: any) => this.parseMessageData(data)),
|
|
@@ -1019,6 +1022,7 @@ export class DynamoDBStore extends MastraStorage {
|
|
|
1019
1022
|
[TABLE_WORKFLOW_SNAPSHOT]: 'workflowSnapshot',
|
|
1020
1023
|
[TABLE_EVALS]: 'eval',
|
|
1021
1024
|
[TABLE_TRACES]: 'trace',
|
|
1025
|
+
[TABLE_RESOURCES]: 'resource',
|
|
1022
1026
|
};
|
|
1023
1027
|
return mapping[tableName] || null;
|
|
1024
1028
|
}
|
|
@@ -1135,4 +1139,15 @@ export class DynamoDBStore extends MastraStorage {
|
|
|
1135
1139
|
throw error;
|
|
1136
1140
|
}
|
|
1137
1141
|
}
|
|
1142
|
+
|
|
1143
|
+
async updateMessages(_args: {
|
|
1144
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> &
|
|
1145
|
+
{
|
|
1146
|
+
id: string;
|
|
1147
|
+
content?: { metadata?: MastraMessageContentV2['metadata']; content?: MastraMessageContentV2['content'] };
|
|
1148
|
+
}[];
|
|
1149
|
+
}): Promise<MastraMessageV2[]> {
|
|
1150
|
+
this.logger.error('updateMessages is not yet implemented in DynamoDBStore');
|
|
1151
|
+
throw new Error('Method not implemented');
|
|
1152
|
+
}
|
|
1138
1153
|
}
|