@mastra/dynamodb 0.13.0 → 0.13.1

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.
@@ -1,22 +1,33 @@
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 { LegacyEvalsStorage } from '@mastra/core/storage';
4
5
  import type { MastraMessageContentV2 } from '@mastra/core/agent';
5
6
  import type { MastraMessageV1 } from '@mastra/core/memory';
6
7
  import type { MastraMessageV2 } from '@mastra/core/memory';
7
8
  import { MastraStorage } from '@mastra/core/storage';
9
+ import { MemoryStorage } from '@mastra/core/storage';
10
+ import type { PaginationArgs } from '@mastra/core/storage';
8
11
  import type { PaginationInfo } from '@mastra/core/storage';
12
+ import type { ScoreRowData } from '@mastra/core/scores';
13
+ import { ScoresStorage } from '@mastra/core/storage';
9
14
  import { Service } from 'electrodb';
10
15
  import type { StorageColumn } from '@mastra/core/storage';
16
+ import type { StorageDomains } from '@mastra/core/storage';
11
17
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
12
18
  import type { StorageGetTracesArg } from '@mastra/core/storage';
19
+ import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
20
+ import type { StoragePagination } from '@mastra/core/storage';
21
+ import type { StorageResourceType } from '@mastra/core/storage';
13
22
  import type { StorageThreadType } from '@mastra/core/memory';
23
+ import { StoreOperations } from '@mastra/core/storage';
14
24
  import type { TABLE_NAMES } from '@mastra/core/storage';
15
- import type { TABLE_RESOURCES } from '@mastra/core/storage';
16
25
  import type { Trace } from '@mastra/core/telemetry';
26
+ import { TracesStorage } from '@mastra/core/storage';
17
27
  import type { WorkflowRun } from '@mastra/core/storage';
18
28
  import type { WorkflowRuns } from '@mastra/core/storage';
19
29
  import type { WorkflowRunState } from '@mastra/core/workflows';
30
+ import { WorkflowsStorage } from '@mastra/core/storage';
20
31
 
21
32
  export declare const baseAttributes: {
22
33
  readonly createdAt: {
@@ -44,21 +55,17 @@ declare class DynamoDBStore extends MastraStorage {
44
55
  private client;
45
56
  private service;
46
57
  protected hasInitialized: Promise<boolean> | null;
58
+ stores: StorageDomains;
47
59
  constructor({ name, config }: {
48
60
  name: string;
49
61
  config: DynamoDBStoreConfig;
50
62
  });
51
- /**
52
- * This method is modified for DynamoDB with ElectroDB single-table design.
53
- * It assumes the table is created and managed externally via CDK/CloudFormation.
54
- *
55
- * This implementation only validates that the required table exists and is accessible.
56
- * No table creation is attempted - we simply check if we can access the table.
57
- */
58
- createTable({ tableName }: {
59
- tableName: TABLE_NAMES;
60
- schema: Record<string, any>;
61
- }): Promise<void>;
63
+ get supports(): {
64
+ selectByIncludeResourceScope: boolean;
65
+ resourceWorkingMemory: boolean;
66
+ hasColumn: boolean;
67
+ createTable: boolean;
68
+ };
62
69
  /**
63
70
  * Validates that the required DynamoDB table exists and is accessible.
64
71
  * This does not check the table structure - it assumes the table
@@ -76,41 +83,31 @@ declare class DynamoDBStore extends MastraStorage {
76
83
  * Handles resetting the stored promise on failure to allow retries.
77
84
  */
78
85
  private _performInitializationAndStore;
79
- /**
80
- * Pre-processes a record to ensure Date objects are converted to ISO strings
81
- * This is necessary because ElectroDB validation happens before setters are applied
82
- */
83
- private preprocessRecord;
86
+ createTable({ tableName, schema }: {
87
+ tableName: TABLE_NAMES;
88
+ schema: Record<string, any>;
89
+ }): Promise<void>;
84
90
  alterTable(_args: {
85
91
  tableName: TABLE_NAMES;
86
92
  schema: Record<string, StorageColumn>;
87
93
  ifNotExists: string[];
88
94
  }): Promise<void>;
89
- /**
90
- * Clear all items from a logical "table" (entity type)
91
- */
92
95
  clearTable({ tableName }: {
93
- tableName: SUPPORTED_TABLE_NAMES;
96
+ tableName: TABLE_NAMES;
94
97
  }): Promise<void>;
95
- /**
96
- * Insert a record into the specified "table" (entity)
97
- */
98
- insert({ tableName, record, }: {
99
- tableName: SUPPORTED_TABLE_NAMES;
98
+ dropTable({ tableName }: {
99
+ tableName: TABLE_NAMES;
100
+ }): Promise<void>;
101
+ insert({ tableName, record }: {
102
+ tableName: TABLE_NAMES;
100
103
  record: Record<string, any>;
101
104
  }): Promise<void>;
102
- /**
103
- * Insert multiple records as a batch
104
- */
105
- batchInsert({ tableName, records, }: {
106
- tableName: SUPPORTED_TABLE_NAMES;
105
+ batchInsert({ tableName, records }: {
106
+ tableName: TABLE_NAMES;
107
107
  records: Record<string, any>[];
108
108
  }): Promise<void>;
109
- /**
110
- * Load a record by its keys
111
- */
112
- load<R>({ tableName, keys, }: {
113
- tableName: SUPPORTED_TABLE_NAMES;
109
+ load<R>({ tableName, keys }: {
110
+ tableName: TABLE_NAMES;
114
111
  keys: Record<string, string>;
115
112
  }): Promise<R | null>;
116
113
  getThreadById({ threadId }: {
@@ -144,7 +141,27 @@ declare class DynamoDBStore extends MastraStorage {
144
141
  messages: MastraMessageV2[];
145
142
  format: 'v2';
146
143
  }): Promise<MastraMessageV2[]>;
147
- private parseMessageData;
144
+ getThreadsByResourceIdPaginated(args: {
145
+ resourceId: string;
146
+ page: number;
147
+ perPage: number;
148
+ }): Promise<PaginationInfo & {
149
+ threads: StorageThreadType[];
150
+ }>;
151
+ getMessagesPaginated(args: StorageGetMessagesArg & {
152
+ format?: 'v1' | 'v2';
153
+ }): Promise<PaginationInfo & {
154
+ messages: MastraMessageV1[] | MastraMessageV2[];
155
+ }>;
156
+ updateMessages(_args: {
157
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
158
+ id: string;
159
+ content?: {
160
+ metadata?: MastraMessageContentV2['metadata'];
161
+ content?: MastraMessageContentV2['content'];
162
+ };
163
+ }[];
164
+ }): Promise<MastraMessageV2[]>;
148
165
  getTraces(args: {
149
166
  name?: string;
150
167
  scope?: string;
@@ -156,6 +173,9 @@ declare class DynamoDBStore extends MastraStorage {
156
173
  batchTraceInsert({ records }: {
157
174
  records: Record<string, any>[];
158
175
  }): Promise<void>;
176
+ getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
177
+ traces: Trace[];
178
+ }>;
159
179
  persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
160
180
  workflowName: string;
161
181
  runId: string;
@@ -177,36 +197,60 @@ declare class DynamoDBStore extends MastraStorage {
177
197
  runId: string;
178
198
  workflowName?: string;
179
199
  }): Promise<WorkflowRun | null>;
180
- private formatWorkflowRun;
181
- private getEntityNameForTable;
182
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
183
- getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
184
- traces: Trace[];
185
- }>;
186
- getThreadsByResourceIdPaginated(_args: {
200
+ getResourceById({ resourceId }: {
187
201
  resourceId: string;
188
- page?: number;
189
- perPage?: number;
190
- }): Promise<PaginationInfo & {
191
- threads: StorageThreadType[];
192
- }>;
193
- getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
194
- messages: MastraMessageV1[] | MastraMessageV2[];
202
+ }): Promise<StorageResourceType | null>;
203
+ saveResource({ resource }: {
204
+ resource: StorageResourceType;
205
+ }): Promise<StorageResourceType>;
206
+ updateResource({ resourceId, workingMemory, metadata, }: {
207
+ resourceId: string;
208
+ workingMemory?: string;
209
+ metadata?: Record<string, any>;
210
+ }): Promise<StorageResourceType>;
211
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
212
+ getEvals(options: {
213
+ agentName?: string;
214
+ type?: 'test' | 'live';
215
+ } & PaginationArgs): Promise<PaginationInfo & {
216
+ evals: EvalRow[];
195
217
  }>;
196
218
  /**
197
219
  * Closes the DynamoDB client connection and cleans up resources.
198
220
  * Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.
199
221
  */
200
222
  close(): Promise<void>;
201
- updateMessages(_args: {
202
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
203
- id: string;
204
- content?: {
205
- metadata?: MastraMessageContentV2['metadata'];
206
- content?: MastraMessageContentV2['content'];
207
- };
208
- }[];
209
- }): Promise<MastraMessageV2[]>;
223
+ /**
224
+ * SCORERS - Not implemented
225
+ */
226
+ getScoreById({ id: _id }: {
227
+ id: string;
228
+ }): Promise<ScoreRowData | null>;
229
+ saveScore(_score: ScoreRowData): Promise<{
230
+ score: ScoreRowData;
231
+ }>;
232
+ getScoresByRunId({ runId: _runId, pagination: _pagination, }: {
233
+ runId: string;
234
+ pagination: StoragePagination;
235
+ }): Promise<{
236
+ pagination: PaginationInfo;
237
+ scores: ScoreRowData[];
238
+ }>;
239
+ getScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
240
+ pagination: StoragePagination;
241
+ entityId: string;
242
+ entityType: string;
243
+ }): Promise<{
244
+ pagination: PaginationInfo;
245
+ scores: ScoreRowData[];
246
+ }>;
247
+ getScoresByScorerId({ scorerId: _scorerId, pagination: _pagination, }: {
248
+ scorerId: string;
249
+ pagination: StoragePagination;
250
+ }): Promise<{
251
+ pagination: PaginationInfo;
252
+ scores: ScoreRowData[];
253
+ }>;
210
254
  }
211
255
  export { DynamoDBStore }
212
256
  export { DynamoDBStore as DynamoDBStore_alias_1 }
@@ -715,7 +759,7 @@ export declare function getElectroDbService(client: DynamoDBDocumentClient, tabl
715
759
  };
716
760
  };
717
761
  }>;
718
- workflowSnapshot: Entity<string, string, string, {
762
+ workflow_snapshot: Entity<string, string, string, {
719
763
  model: {
720
764
  entity: string;
721
765
  version: string;
@@ -787,136 +831,857 @@ export declare function getElectroDbService(client: DynamoDBDocumentClient, tabl
787
831
  };
788
832
  };
789
833
  }>;
790
- }>;
791
-
792
- export declare const messageEntity: Entity<string, string, string, {
834
+ resource: Entity<string, string, string, {
793
835
  model: {
794
- entity: string;
795
- version: string;
796
- service: string;
836
+ entity: string;
837
+ version: string;
838
+ service: string;
797
839
  };
798
840
  attributes: {
799
- id: {
800
- type: "string";
801
- required: true;
802
- };
803
- threadId: {
804
- type: "string";
805
- required: true;
806
- };
807
- content: {
808
- type: "string";
809
- required: true;
810
- set: (value?: string | void | undefined) => string | void;
811
- get: (value?: string) => any;
812
- };
813
- role: {
814
- type: "string";
815
- required: true;
816
- };
817
- type: {
818
- type: "string";
819
- default: string;
820
- };
821
- resourceId: {
822
- type: "string";
823
- required: false;
824
- };
825
- toolCallIds: {
826
- type: "string";
827
- required: false;
828
- set: (value?: string[] | string) => string | undefined;
829
- get: (value?: string) => any;
830
- };
831
- toolCallArgs: {
832
- type: "string";
833
- required: false;
834
- set: (value?: Record<string, unknown>[] | string) => string | undefined;
835
- get: (value?: string) => any;
836
- };
837
- toolNames: {
838
- type: "string";
839
- required: false;
840
- set: (value?: string[] | string) => string | undefined;
841
- get: (value?: string) => any;
842
- };
843
- createdAt: {
844
- readonly type: "string";
845
- readonly required: true;
846
- readonly readOnly: true;
847
- readonly set: (value?: Date | string) => string;
848
- readonly default: () => string;
849
- };
850
- updatedAt: {
851
- readonly type: "string";
852
- readonly required: true;
853
- readonly set: (value?: Date | string) => string;
854
- readonly default: () => string;
855
- };
856
- metadata: {
857
- readonly type: "string";
858
- readonly set: (value?: Record<string, unknown> | string) => string | undefined;
859
- readonly get: (value?: string) => any;
860
- };
861
- entity: {
862
- type: "string";
863
- required: true;
864
- };
841
+ id: {
842
+ type: "string";
843
+ required: true;
844
+ };
845
+ workingMemory: {
846
+ type: "string";
847
+ required: false;
848
+ };
849
+ metadata: {
850
+ type: "string";
851
+ required: false;
852
+ set: (value?: string | void | undefined) => string | void;
853
+ get: (value?: string) => any;
854
+ };
855
+ createdAt: {
856
+ readonly type: "string";
857
+ readonly required: true;
858
+ readonly readOnly: true;
859
+ readonly set: (value?: Date | string) => string;
860
+ readonly default: () => string;
861
+ };
862
+ updatedAt: {
863
+ readonly type: "string";
864
+ readonly required: true;
865
+ readonly set: (value?: Date | string) => string;
866
+ readonly default: () => string;
867
+ };
868
+ entity: {
869
+ type: "string";
870
+ required: true;
871
+ };
865
872
  };
866
873
  indexes: {
867
- primary: {
868
- pk: {
869
- field: string;
870
- composite: ("entity" | "id")[];
871
- };
872
- sk: {
873
- field: string;
874
- composite: "entity"[];
875
- };
876
- };
877
- byThread: {
878
- index: string;
879
- pk: {
880
- field: string;
881
- composite: ("entity" | "threadId")[];
882
- };
883
- sk: {
884
- field: string;
885
- composite: "createdAt"[];
886
- };
887
- };
874
+ primary: {
875
+ pk: {
876
+ field: string;
877
+ composite: ("entity" | "id")[];
888
878
  };
889
- }>;
890
-
891
- declare type SUPPORTED_TABLE_NAMES = Exclude<TABLE_NAMES, typeof TABLE_RESOURCES>;
892
-
893
- export declare const threadEntity: Entity<string, string, string, {
879
+ sk: {
880
+ field: string;
881
+ composite: "entity"[];
882
+ };
883
+ };
884
+ };
885
+ }>;
886
+ score: Entity<string, string, string, {
894
887
  model: {
895
- entity: string;
896
- version: string;
897
- service: string;
888
+ entity: string;
889
+ version: string;
890
+ service: string;
898
891
  };
899
892
  attributes: {
900
- id: {
901
- type: "string";
902
- required: true;
903
- };
904
- resourceId: {
905
- type: "string";
906
- required: true;
907
- };
908
- title: {
909
- type: "string";
910
- required: true;
911
- };
912
- metadata: {
913
- type: "string";
914
- required: false;
915
- set: (value?: Record<string, unknown> | string) => string | undefined;
916
- get: (value?: string) => any;
917
- };
918
- createdAt: {
919
- readonly type: "string";
893
+ id: {
894
+ type: "string";
895
+ required: true;
896
+ };
897
+ scorerId: {
898
+ type: "string";
899
+ required: true;
900
+ };
901
+ traceId: {
902
+ type: "string";
903
+ required: false;
904
+ };
905
+ runId: {
906
+ type: "string";
907
+ required: true;
908
+ };
909
+ scorer: {
910
+ type: "string";
911
+ required: true;
912
+ set: (value?: Record<string, unknown> | string) => string | undefined;
913
+ get: (value?: string) => any;
914
+ };
915
+ extractStepResult: {
916
+ type: "string";
917
+ required: false;
918
+ set: (value?: Record<string, unknown> | string) => string | undefined;
919
+ get: (value?: string) => any;
920
+ };
921
+ analyzeStepResult: {
922
+ type: "string";
923
+ required: false;
924
+ set: (value?: Record<string, unknown> | string) => string | undefined;
925
+ get: (value?: string) => any;
926
+ };
927
+ score: {
928
+ type: "number";
929
+ required: true;
930
+ };
931
+ reason: {
932
+ type: "string";
933
+ required: false;
934
+ };
935
+ extractPrompt: {
936
+ type: "string";
937
+ required: false;
938
+ };
939
+ analyzePrompt: {
940
+ type: "string";
941
+ required: false;
942
+ };
943
+ reasonPrompt: {
944
+ type: "string";
945
+ required: false;
946
+ };
947
+ input: {
948
+ type: "string";
949
+ required: true;
950
+ set: (value?: Record<string, unknown> | string) => string | undefined;
951
+ get: (value?: string) => any;
952
+ };
953
+ output: {
954
+ type: "string";
955
+ required: true;
956
+ set: (value?: Record<string, unknown> | string) => string | undefined;
957
+ get: (value?: string) => any;
958
+ };
959
+ additionalContext: {
960
+ type: "string";
961
+ required: false;
962
+ set: (value?: Record<string, unknown> | string) => string | undefined;
963
+ get: (value?: string) => any;
964
+ };
965
+ runtimeContext: {
966
+ type: "string";
967
+ required: false;
968
+ set: (value?: Record<string, unknown> | string) => string | undefined;
969
+ get: (value?: string) => any;
970
+ };
971
+ entityType: {
972
+ type: "string";
973
+ required: false;
974
+ };
975
+ entityData: {
976
+ type: "string";
977
+ required: false;
978
+ set: (value?: Record<string, unknown> | string) => string | undefined;
979
+ get: (value?: string) => any;
980
+ };
981
+ entityId: {
982
+ type: "string";
983
+ required: false;
984
+ };
985
+ source: {
986
+ type: "string";
987
+ required: true;
988
+ };
989
+ resourceId: {
990
+ type: "string";
991
+ required: false;
992
+ };
993
+ threadId: {
994
+ type: "string";
995
+ required: false;
996
+ };
997
+ createdAt: {
998
+ readonly type: "string";
999
+ readonly required: true;
1000
+ readonly readOnly: true;
1001
+ readonly set: (value?: Date | string) => string;
1002
+ readonly default: () => string;
1003
+ };
1004
+ updatedAt: {
1005
+ readonly type: "string";
1006
+ readonly required: true;
1007
+ readonly set: (value?: Date | string) => string;
1008
+ readonly default: () => string;
1009
+ };
1010
+ metadata: {
1011
+ readonly type: "string";
1012
+ readonly set: (value?: Record<string, unknown> | string) => string | undefined;
1013
+ readonly get: (value?: string) => any;
1014
+ };
1015
+ entity: {
1016
+ type: "string";
1017
+ required: true;
1018
+ };
1019
+ };
1020
+ indexes: {
1021
+ primary: {
1022
+ pk: {
1023
+ field: string;
1024
+ composite: ("entity" | "id")[];
1025
+ };
1026
+ sk: {
1027
+ field: string;
1028
+ composite: "entity"[];
1029
+ };
1030
+ };
1031
+ byScorer: {
1032
+ index: string;
1033
+ pk: {
1034
+ field: string;
1035
+ composite: ("entity" | "scorerId")[];
1036
+ };
1037
+ sk: {
1038
+ field: string;
1039
+ composite: "createdAt"[];
1040
+ };
1041
+ };
1042
+ byRun: {
1043
+ index: string;
1044
+ pk: {
1045
+ field: string;
1046
+ composite: ("entity" | "runId")[];
1047
+ };
1048
+ sk: {
1049
+ field: string;
1050
+ composite: "createdAt"[];
1051
+ };
1052
+ };
1053
+ byTrace: {
1054
+ index: string;
1055
+ pk: {
1056
+ field: string;
1057
+ composite: ("entity" | "traceId")[];
1058
+ };
1059
+ sk: {
1060
+ field: string;
1061
+ composite: "createdAt"[];
1062
+ };
1063
+ };
1064
+ byEntityData: {
1065
+ index: string;
1066
+ pk: {
1067
+ field: string;
1068
+ composite: ("entity" | "entityId")[];
1069
+ };
1070
+ sk: {
1071
+ field: string;
1072
+ composite: "createdAt"[];
1073
+ };
1074
+ };
1075
+ byResource: {
1076
+ index: string;
1077
+ pk: {
1078
+ field: string;
1079
+ composite: ("entity" | "resourceId")[];
1080
+ };
1081
+ sk: {
1082
+ field: string;
1083
+ composite: "createdAt"[];
1084
+ };
1085
+ };
1086
+ byThread: {
1087
+ index: string;
1088
+ pk: {
1089
+ field: string;
1090
+ composite: ("entity" | "threadId")[];
1091
+ };
1092
+ sk: {
1093
+ field: string;
1094
+ composite: "createdAt"[];
1095
+ };
1096
+ };
1097
+ };
1098
+ }>;
1099
+ }>;
1100
+
1101
+ export declare class LegacyEvalsDynamoDB extends LegacyEvalsStorage {
1102
+ service: Service<Record<string, any>>;
1103
+ tableName: string;
1104
+ constructor({ service, tableName }: {
1105
+ service: Service<Record<string, any>>;
1106
+ tableName: string;
1107
+ });
1108
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
1109
+ getEvals(options?: {
1110
+ agentName?: string;
1111
+ type?: 'test' | 'live';
1112
+ } & PaginationArgs): Promise<PaginationInfo & {
1113
+ evals: EvalRow[];
1114
+ }>;
1115
+ }
1116
+
1117
+ export declare class MemoryStorageDynamoDB extends MemoryStorage {
1118
+ private service;
1119
+ constructor({ service }: {
1120
+ service: Service<Record<string, any>>;
1121
+ });
1122
+ private parseMessageData;
1123
+ getThreadById({ threadId }: {
1124
+ threadId: string;
1125
+ }): Promise<StorageThreadType | null>;
1126
+ getThreadsByResourceId({ resourceId }: {
1127
+ resourceId: string;
1128
+ }): Promise<StorageThreadType[]>;
1129
+ saveThread({ thread }: {
1130
+ thread: StorageThreadType;
1131
+ }): Promise<StorageThreadType>;
1132
+ updateThread({ id, title, metadata, }: {
1133
+ id: string;
1134
+ title: string;
1135
+ metadata: Record<string, unknown>;
1136
+ }): Promise<StorageThreadType>;
1137
+ deleteThread({ threadId }: {
1138
+ threadId: string;
1139
+ }): Promise<void>;
1140
+ getMessages(args: StorageGetMessagesArg & {
1141
+ format?: 'v1';
1142
+ }): Promise<MastraMessageV1[]>;
1143
+ getMessages(args: StorageGetMessagesArg & {
1144
+ format: 'v2';
1145
+ }): Promise<MastraMessageV2[]>;
1146
+ saveMessages(args: {
1147
+ messages: MastraMessageV1[];
1148
+ format?: undefined | 'v1';
1149
+ }): Promise<MastraMessageV1[]>;
1150
+ saveMessages(args: {
1151
+ messages: MastraMessageV2[];
1152
+ format: 'v2';
1153
+ }): Promise<MastraMessageV2[]>;
1154
+ getThreadsByResourceIdPaginated(args: {
1155
+ resourceId: string;
1156
+ page?: number;
1157
+ perPage?: number;
1158
+ }): Promise<PaginationInfo & {
1159
+ threads: StorageThreadType[];
1160
+ }>;
1161
+ getMessagesPaginated(args: StorageGetMessagesArg & {
1162
+ format?: 'v1' | 'v2';
1163
+ }): Promise<PaginationInfo & {
1164
+ messages: MastraMessageV1[] | MastraMessageV2[];
1165
+ }>;
1166
+ private _getIncludedMessages;
1167
+ updateMessages(args: {
1168
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
1169
+ id: string;
1170
+ content?: {
1171
+ metadata?: MastraMessageContentV2['metadata'];
1172
+ content?: MastraMessageContentV2['content'];
1173
+ };
1174
+ }[];
1175
+ }): Promise<MastraMessageV2[]>;
1176
+ getResourceById({ resourceId }: {
1177
+ resourceId: string;
1178
+ }): Promise<StorageResourceType | null>;
1179
+ saveResource({ resource }: {
1180
+ resource: StorageResourceType;
1181
+ }): Promise<StorageResourceType>;
1182
+ updateResource({ resourceId, workingMemory, metadata, }: {
1183
+ resourceId: string;
1184
+ workingMemory?: string;
1185
+ metadata?: Record<string, unknown>;
1186
+ }): Promise<StorageResourceType>;
1187
+ }
1188
+
1189
+ export declare const messageEntity: Entity<string, string, string, {
1190
+ model: {
1191
+ entity: string;
1192
+ version: string;
1193
+ service: string;
1194
+ };
1195
+ attributes: {
1196
+ id: {
1197
+ type: "string";
1198
+ required: true;
1199
+ };
1200
+ threadId: {
1201
+ type: "string";
1202
+ required: true;
1203
+ };
1204
+ content: {
1205
+ type: "string";
1206
+ required: true;
1207
+ set: (value?: string | void | undefined) => string | void;
1208
+ get: (value?: string) => any;
1209
+ };
1210
+ role: {
1211
+ type: "string";
1212
+ required: true;
1213
+ };
1214
+ type: {
1215
+ type: "string";
1216
+ default: string;
1217
+ };
1218
+ resourceId: {
1219
+ type: "string";
1220
+ required: false;
1221
+ };
1222
+ toolCallIds: {
1223
+ type: "string";
1224
+ required: false;
1225
+ set: (value?: string[] | string) => string | undefined;
1226
+ get: (value?: string) => any;
1227
+ };
1228
+ toolCallArgs: {
1229
+ type: "string";
1230
+ required: false;
1231
+ set: (value?: Record<string, unknown>[] | string) => string | undefined;
1232
+ get: (value?: string) => any;
1233
+ };
1234
+ toolNames: {
1235
+ type: "string";
1236
+ required: false;
1237
+ set: (value?: string[] | string) => string | undefined;
1238
+ get: (value?: string) => any;
1239
+ };
1240
+ createdAt: {
1241
+ readonly type: "string";
1242
+ readonly required: true;
1243
+ readonly readOnly: true;
1244
+ readonly set: (value?: Date | string) => string;
1245
+ readonly default: () => string;
1246
+ };
1247
+ updatedAt: {
1248
+ readonly type: "string";
1249
+ readonly required: true;
1250
+ readonly set: (value?: Date | string) => string;
1251
+ readonly default: () => string;
1252
+ };
1253
+ metadata: {
1254
+ readonly type: "string";
1255
+ readonly set: (value?: Record<string, unknown> | string) => string | undefined;
1256
+ readonly get: (value?: string) => any;
1257
+ };
1258
+ entity: {
1259
+ type: "string";
1260
+ required: true;
1261
+ };
1262
+ };
1263
+ indexes: {
1264
+ primary: {
1265
+ pk: {
1266
+ field: string;
1267
+ composite: ("entity" | "id")[];
1268
+ };
1269
+ sk: {
1270
+ field: string;
1271
+ composite: "entity"[];
1272
+ };
1273
+ };
1274
+ byThread: {
1275
+ index: string;
1276
+ pk: {
1277
+ field: string;
1278
+ composite: ("entity" | "threadId")[];
1279
+ };
1280
+ sk: {
1281
+ field: string;
1282
+ composite: "createdAt"[];
1283
+ };
1284
+ };
1285
+ };
1286
+ }>;
1287
+
1288
+ export declare const resourceEntity: Entity<string, string, string, {
1289
+ model: {
1290
+ entity: string;
1291
+ version: string;
1292
+ service: string;
1293
+ };
1294
+ attributes: {
1295
+ id: {
1296
+ type: "string";
1297
+ required: true;
1298
+ };
1299
+ workingMemory: {
1300
+ type: "string";
1301
+ required: false;
1302
+ };
1303
+ metadata: {
1304
+ type: "string";
1305
+ required: false;
1306
+ set: (value?: string | void | undefined) => string | void;
1307
+ get: (value?: string) => any;
1308
+ };
1309
+ createdAt: {
1310
+ readonly type: "string";
1311
+ readonly required: true;
1312
+ readonly readOnly: true;
1313
+ readonly set: (value?: Date | string) => string;
1314
+ readonly default: () => string;
1315
+ };
1316
+ updatedAt: {
1317
+ readonly type: "string";
1318
+ readonly required: true;
1319
+ readonly set: (value?: Date | string) => string;
1320
+ readonly default: () => string;
1321
+ };
1322
+ entity: {
1323
+ type: "string";
1324
+ required: true;
1325
+ };
1326
+ };
1327
+ indexes: {
1328
+ primary: {
1329
+ pk: {
1330
+ field: string;
1331
+ composite: ("entity" | "id")[];
1332
+ };
1333
+ sk: {
1334
+ field: string;
1335
+ composite: "entity"[];
1336
+ };
1337
+ };
1338
+ };
1339
+ }>;
1340
+
1341
+ export declare const scoreEntity: Entity<string, string, string, {
1342
+ model: {
1343
+ entity: string;
1344
+ version: string;
1345
+ service: string;
1346
+ };
1347
+ attributes: {
1348
+ id: {
1349
+ type: "string";
1350
+ required: true;
1351
+ };
1352
+ scorerId: {
1353
+ type: "string";
1354
+ required: true;
1355
+ };
1356
+ traceId: {
1357
+ type: "string";
1358
+ required: false;
1359
+ };
1360
+ runId: {
1361
+ type: "string";
1362
+ required: true;
1363
+ };
1364
+ scorer: {
1365
+ type: "string";
1366
+ required: true;
1367
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1368
+ get: (value?: string) => any;
1369
+ };
1370
+ extractStepResult: {
1371
+ type: "string";
1372
+ required: false;
1373
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1374
+ get: (value?: string) => any;
1375
+ };
1376
+ analyzeStepResult: {
1377
+ type: "string";
1378
+ required: false;
1379
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1380
+ get: (value?: string) => any;
1381
+ };
1382
+ score: {
1383
+ type: "number";
1384
+ required: true;
1385
+ };
1386
+ reason: {
1387
+ type: "string";
1388
+ required: false;
1389
+ };
1390
+ extractPrompt: {
1391
+ type: "string";
1392
+ required: false;
1393
+ };
1394
+ analyzePrompt: {
1395
+ type: "string";
1396
+ required: false;
1397
+ };
1398
+ reasonPrompt: {
1399
+ type: "string";
1400
+ required: false;
1401
+ };
1402
+ input: {
1403
+ type: "string";
1404
+ required: true;
1405
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1406
+ get: (value?: string) => any;
1407
+ };
1408
+ output: {
1409
+ type: "string";
1410
+ required: true;
1411
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1412
+ get: (value?: string) => any;
1413
+ };
1414
+ additionalContext: {
1415
+ type: "string";
1416
+ required: false;
1417
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1418
+ get: (value?: string) => any;
1419
+ };
1420
+ runtimeContext: {
1421
+ type: "string";
1422
+ required: false;
1423
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1424
+ get: (value?: string) => any;
1425
+ };
1426
+ entityType: {
1427
+ type: "string";
1428
+ required: false;
1429
+ };
1430
+ entityData: {
1431
+ type: "string";
1432
+ required: false;
1433
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1434
+ get: (value?: string) => any;
1435
+ };
1436
+ entityId: {
1437
+ type: "string";
1438
+ required: false;
1439
+ };
1440
+ source: {
1441
+ type: "string";
1442
+ required: true;
1443
+ };
1444
+ resourceId: {
1445
+ type: "string";
1446
+ required: false;
1447
+ };
1448
+ threadId: {
1449
+ type: "string";
1450
+ required: false;
1451
+ };
1452
+ createdAt: {
1453
+ readonly type: "string";
1454
+ readonly required: true;
1455
+ readonly readOnly: true;
1456
+ readonly set: (value?: Date | string) => string;
1457
+ readonly default: () => string;
1458
+ };
1459
+ updatedAt: {
1460
+ readonly type: "string";
1461
+ readonly required: true;
1462
+ readonly set: (value?: Date | string) => string;
1463
+ readonly default: () => string;
1464
+ };
1465
+ metadata: {
1466
+ readonly type: "string";
1467
+ readonly set: (value?: Record<string, unknown> | string) => string | undefined;
1468
+ readonly get: (value?: string) => any;
1469
+ };
1470
+ entity: {
1471
+ type: "string";
1472
+ required: true;
1473
+ };
1474
+ };
1475
+ indexes: {
1476
+ primary: {
1477
+ pk: {
1478
+ field: string;
1479
+ composite: ("entity" | "id")[];
1480
+ };
1481
+ sk: {
1482
+ field: string;
1483
+ composite: "entity"[];
1484
+ };
1485
+ };
1486
+ byScorer: {
1487
+ index: string;
1488
+ pk: {
1489
+ field: string;
1490
+ composite: ("entity" | "scorerId")[];
1491
+ };
1492
+ sk: {
1493
+ field: string;
1494
+ composite: "createdAt"[];
1495
+ };
1496
+ };
1497
+ byRun: {
1498
+ index: string;
1499
+ pk: {
1500
+ field: string;
1501
+ composite: ("entity" | "runId")[];
1502
+ };
1503
+ sk: {
1504
+ field: string;
1505
+ composite: "createdAt"[];
1506
+ };
1507
+ };
1508
+ byTrace: {
1509
+ index: string;
1510
+ pk: {
1511
+ field: string;
1512
+ composite: ("entity" | "traceId")[];
1513
+ };
1514
+ sk: {
1515
+ field: string;
1516
+ composite: "createdAt"[];
1517
+ };
1518
+ };
1519
+ byEntityData: {
1520
+ index: string;
1521
+ pk: {
1522
+ field: string;
1523
+ composite: ("entity" | "entityId")[];
1524
+ };
1525
+ sk: {
1526
+ field: string;
1527
+ composite: "createdAt"[];
1528
+ };
1529
+ };
1530
+ byResource: {
1531
+ index: string;
1532
+ pk: {
1533
+ field: string;
1534
+ composite: ("entity" | "resourceId")[];
1535
+ };
1536
+ sk: {
1537
+ field: string;
1538
+ composite: "createdAt"[];
1539
+ };
1540
+ };
1541
+ byThread: {
1542
+ index: string;
1543
+ pk: {
1544
+ field: string;
1545
+ composite: ("entity" | "threadId")[];
1546
+ };
1547
+ sk: {
1548
+ field: string;
1549
+ composite: "createdAt"[];
1550
+ };
1551
+ };
1552
+ };
1553
+ }>;
1554
+
1555
+ export declare class ScoresStorageDynamoDB extends ScoresStorage {
1556
+ private service;
1557
+ constructor({ service }: {
1558
+ service: Service<Record<string, any>>;
1559
+ });
1560
+ private parseScoreData;
1561
+ getScoreById({ id }: {
1562
+ id: string;
1563
+ }): Promise<ScoreRowData | null>;
1564
+ saveScore(score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>): Promise<{
1565
+ score: ScoreRowData;
1566
+ }>;
1567
+ getScoresByScorerId({ scorerId, pagination, entityId, entityType, }: {
1568
+ scorerId: string;
1569
+ pagination: StoragePagination;
1570
+ entityId?: string;
1571
+ entityType?: string;
1572
+ }): Promise<{
1573
+ pagination: PaginationInfo;
1574
+ scores: ScoreRowData[];
1575
+ }>;
1576
+ getScoresByRunId({ runId, pagination, }: {
1577
+ runId: string;
1578
+ pagination: StoragePagination;
1579
+ }): Promise<{
1580
+ pagination: PaginationInfo;
1581
+ scores: ScoreRowData[];
1582
+ }>;
1583
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
1584
+ entityId: string;
1585
+ entityType: string;
1586
+ pagination: StoragePagination;
1587
+ }): Promise<{
1588
+ pagination: PaginationInfo;
1589
+ scores: ScoreRowData[];
1590
+ }>;
1591
+ }
1592
+
1593
+ export declare class StoreOperationsDynamoDB extends StoreOperations {
1594
+ client: DynamoDBDocumentClient;
1595
+ tableName: string;
1596
+ service: Service<Record<string, any>>;
1597
+ constructor({ service, tableName, client, }: {
1598
+ service: Service<Record<string, any>>;
1599
+ tableName: string;
1600
+ client: DynamoDBDocumentClient;
1601
+ });
1602
+ hasColumn(): Promise<boolean>;
1603
+ dropTable(): Promise<void>;
1604
+ private getEntityNameForTable;
1605
+ /**
1606
+ * Pre-processes a record to ensure Date objects are converted to ISO strings
1607
+ * This is necessary because ElectroDB validation happens before setters are applied
1608
+ */
1609
+ private preprocessRecord;
1610
+ /**
1611
+ * Validates that the required DynamoDB table exists and is accessible.
1612
+ * This does not check the table structure - it assumes the table
1613
+ * was created with the correct structure via CDK/CloudFormation.
1614
+ */
1615
+ private validateTableExists;
1616
+ /**
1617
+ * This method is modified for DynamoDB with ElectroDB single-table design.
1618
+ * It assumes the table is created and managed externally via CDK/CloudFormation.
1619
+ *
1620
+ * This implementation only validates that the required table exists and is accessible.
1621
+ * No table creation is attempted - we simply check if we can access the table.
1622
+ */
1623
+ createTable({ tableName }: {
1624
+ tableName: TABLE_NAMES;
1625
+ schema: Record<string, any>;
1626
+ }): Promise<void>;
1627
+ insert({ tableName, record }: {
1628
+ tableName: TABLE_NAMES;
1629
+ record: Record<string, any>;
1630
+ }): Promise<void>;
1631
+ alterTable(_args: {
1632
+ tableName: TABLE_NAMES;
1633
+ schema: Record<string, StorageColumn>;
1634
+ ifNotExists: string[];
1635
+ }): Promise<void>;
1636
+ /**
1637
+ * Clear all items from a logical "table" (entity type)
1638
+ */
1639
+ clearTable({ tableName }: {
1640
+ tableName: TABLE_NAMES;
1641
+ }): Promise<void>;
1642
+ /**
1643
+ * Insert multiple records as a batch
1644
+ */
1645
+ batchInsert({ tableName, records }: {
1646
+ tableName: TABLE_NAMES;
1647
+ records: Record<string, any>[];
1648
+ }): Promise<void>;
1649
+ /**
1650
+ * Load a record by its keys
1651
+ */
1652
+ load<R>({ tableName, keys }: {
1653
+ tableName: TABLE_NAMES;
1654
+ keys: Record<string, string>;
1655
+ }): Promise<R | null>;
1656
+ }
1657
+
1658
+ export declare const threadEntity: Entity<string, string, string, {
1659
+ model: {
1660
+ entity: string;
1661
+ version: string;
1662
+ service: string;
1663
+ };
1664
+ attributes: {
1665
+ id: {
1666
+ type: "string";
1667
+ required: true;
1668
+ };
1669
+ resourceId: {
1670
+ type: "string";
1671
+ required: true;
1672
+ };
1673
+ title: {
1674
+ type: "string";
1675
+ required: true;
1676
+ };
1677
+ metadata: {
1678
+ type: "string";
1679
+ required: false;
1680
+ set: (value?: Record<string, unknown> | string) => string | undefined;
1681
+ get: (value?: string) => any;
1682
+ };
1683
+ createdAt: {
1684
+ readonly type: "string";
920
1685
  readonly required: true;
921
1686
  readonly readOnly: true;
922
1687
  readonly set: (value?: Date | string) => string;
@@ -1084,6 +1849,29 @@ export declare const traceEntity: Entity<string, string, string, {
1084
1849
  };
1085
1850
  }>;
1086
1851
 
1852
+ export declare class TracesStorageDynamoDB extends TracesStorage {
1853
+ private service;
1854
+ private operations;
1855
+ constructor({ service, operations }: {
1856
+ service: Service<Record<string, any>>;
1857
+ operations: StoreOperationsDynamoDB;
1858
+ });
1859
+ getTraces(args: {
1860
+ name?: string;
1861
+ scope?: string;
1862
+ page: number;
1863
+ perPage: number;
1864
+ attributes?: Record<string, string>;
1865
+ filters?: Record<string, any>;
1866
+ }): Promise<any[]>;
1867
+ batchTraceInsert({ records }: {
1868
+ records: Record<string, any>[];
1869
+ }): Promise<void>;
1870
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
1871
+ traces: Trace[];
1872
+ }>;
1873
+ }
1874
+
1087
1875
  export declare const workflowSnapshotEntity: Entity<string, string, string, {
1088
1876
  model: {
1089
1877
  entity: string;
@@ -1157,4 +1945,32 @@ export declare const workflowSnapshotEntity: Entity<string, string, string, {
1157
1945
  };
1158
1946
  }>;
1159
1947
 
1948
+ export declare class WorkflowStorageDynamoDB extends WorkflowsStorage {
1949
+ private service;
1950
+ constructor({ service }: {
1951
+ service: Service<Record<string, any>>;
1952
+ });
1953
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
1954
+ workflowName: string;
1955
+ runId: string;
1956
+ snapshot: WorkflowRunState;
1957
+ }): Promise<void>;
1958
+ loadWorkflowSnapshot({ workflowName, runId, }: {
1959
+ workflowName: string;
1960
+ runId: string;
1961
+ }): Promise<WorkflowRunState | null>;
1962
+ getWorkflowRuns(args?: {
1963
+ workflowName?: string;
1964
+ fromDate?: Date;
1965
+ toDate?: Date;
1966
+ limit?: number;
1967
+ offset?: number;
1968
+ resourceId?: string;
1969
+ }): Promise<WorkflowRuns>;
1970
+ getWorkflowRunById(args: {
1971
+ runId: string;
1972
+ workflowName?: string;
1973
+ }): Promise<WorkflowRun | null>;
1974
+ }
1975
+
1160
1976
  export { }