@mastra/dynamodb 0.0.0-scorers-api-v2-20250801171841 → 0.0.0-scorers-logs-20251208093427

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +1605 -0
  2. package/README.md +0 -4
  3. package/dist/entities/index.d.ts +20 -1
  4. package/dist/entities/index.d.ts.map +1 -1
  5. package/dist/entities/score.d.ts +20 -1
  6. package/dist/entities/score.d.ts.map +1 -1
  7. package/dist/index.cjs +474 -728
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +475 -729
  11. package/dist/index.js.map +1 -1
  12. package/dist/storage/domains/memory/index.d.ts +15 -31
  13. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -1
  15. package/dist/storage/domains/score/index.d.ts +22 -5
  16. package/dist/storage/domains/score/index.d.ts.map +1 -1
  17. package/dist/storage/domains/workflows/index.d.ts +23 -11
  18. package/dist/storage/domains/workflows/index.d.ts.map +1 -1
  19. package/dist/storage/index.d.ts +73 -69
  20. package/dist/storage/index.d.ts.map +1 -1
  21. package/package.json +29 -16
  22. package/dist/storage/domains/legacy-evals/index.d.ts +0 -19
  23. package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
  24. package/dist/storage/domains/traces/index.d.ts +0 -28
  25. package/dist/storage/domains/traces/index.d.ts.map +0 -1
  26. package/src/entities/eval.ts +0 -102
  27. package/src/entities/index.ts +0 -27
  28. package/src/entities/message.ts +0 -143
  29. package/src/entities/resource.ts +0 -57
  30. package/src/entities/score.ts +0 -317
  31. package/src/entities/thread.ts +0 -66
  32. package/src/entities/trace.ts +0 -129
  33. package/src/entities/utils.ts +0 -51
  34. package/src/entities/workflow-snapshot.ts +0 -56
  35. package/src/index.ts +0 -1
  36. package/src/storage/docker-compose.yml +0 -16
  37. package/src/storage/domains/legacy-evals/index.ts +0 -243
  38. package/src/storage/domains/memory/index.ts +0 -894
  39. package/src/storage/domains/operations/index.ts +0 -433
  40. package/src/storage/domains/score/index.ts +0 -288
  41. package/src/storage/domains/traces/index.ts +0 -286
  42. package/src/storage/domains/workflows/index.ts +0 -297
  43. package/src/storage/index.test.ts +0 -1420
  44. package/src/storage/index.ts +0 -483
@@ -1,102 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const evalEntity = new Entity({
5
- model: {
6
- entity: 'eval',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- input: {
17
- type: 'string',
18
- required: true,
19
- },
20
- output: {
21
- type: 'string',
22
- required: true,
23
- },
24
- result: {
25
- type: 'string', // JSON stringified
26
- required: true,
27
- // Stringify object on set
28
- set: (value?: any) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get
35
- get: (value?: string) => {
36
- if (value) {
37
- return JSON.parse(value);
38
- }
39
- return value;
40
- },
41
- },
42
- agent_name: {
43
- type: 'string',
44
- required: true,
45
- },
46
- metric_name: {
47
- type: 'string',
48
- required: true,
49
- },
50
- instructions: {
51
- type: 'string',
52
- required: true,
53
- },
54
- test_info: {
55
- type: 'string', // JSON stringified
56
- required: false,
57
- // Stringify object on set
58
- set: (value?: any) => {
59
- if (value && typeof value !== 'string') {
60
- return JSON.stringify(value);
61
- }
62
- return value;
63
- },
64
- // Parse JSON string to object on get
65
- get: (value?: string) => {
66
- return value;
67
- },
68
- },
69
- global_run_id: {
70
- type: 'string',
71
- required: true,
72
- },
73
- run_id: {
74
- type: 'string',
75
- required: true,
76
- },
77
- created_at: {
78
- type: 'string',
79
- required: true,
80
- // Initialize with current timestamp if not provided
81
- default: () => new Date().toISOString(),
82
- // Convert Date to ISO string on set
83
- set: (value?: Date | string) => {
84
- if (value instanceof Date) {
85
- return value.toISOString();
86
- }
87
- return value || new Date().toISOString();
88
- },
89
- },
90
- },
91
- indexes: {
92
- primary: {
93
- pk: { field: 'pk', composite: ['entity', 'run_id'] },
94
- sk: { field: 'sk', composite: [] },
95
- },
96
- byAgent: {
97
- index: 'gsi1',
98
- pk: { field: 'gsi1pk', composite: ['entity', 'agent_name'] },
99
- sk: { field: 'gsi1sk', composite: ['created_at'] },
100
- },
101
- },
102
- });
@@ -1,27 +0,0 @@
1
- import type { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
2
- import { Service } from 'electrodb';
3
- import { evalEntity } from './eval';
4
- import { messageEntity } from './message';
5
- import { resourceEntity } from './resource';
6
- import { scoreEntity } from './score';
7
- import { threadEntity } from './thread';
8
- import { traceEntity } from './trace';
9
- import { workflowSnapshotEntity } from './workflow-snapshot';
10
-
11
- export function getElectroDbService(client: DynamoDBDocumentClient, tableName: string) {
12
- return new Service(
13
- {
14
- thread: threadEntity,
15
- message: messageEntity,
16
- eval: evalEntity,
17
- trace: traceEntity,
18
- workflow_snapshot: workflowSnapshotEntity,
19
- resource: resourceEntity,
20
- score: scoreEntity,
21
- },
22
- {
23
- client,
24
- table: tableName,
25
- },
26
- );
27
- }
@@ -1,143 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const messageEntity = new Entity({
5
- model: {
6
- entity: 'message',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- threadId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- content: {
25
- type: 'string',
26
- required: true,
27
- // Stringify content object on set if it's not already a string
28
- set: (value?: string | void) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get ONLY if it looks like JSON
35
- get: (value?: string) => {
36
- if (value && typeof value === 'string') {
37
- try {
38
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
39
- if (value.startsWith('{') || value.startsWith('[')) {
40
- return JSON.parse(value);
41
- }
42
- } catch {
43
- // Ignore parse error, return original string
44
- return value;
45
- }
46
- }
47
- return value;
48
- },
49
- },
50
- role: {
51
- type: 'string',
52
- required: true,
53
- },
54
- type: {
55
- type: 'string',
56
- default: 'text',
57
- },
58
- resourceId: {
59
- type: 'string',
60
- required: false,
61
- },
62
- toolCallIds: {
63
- type: 'string',
64
- required: false,
65
- set: (value?: string[] | string) => {
66
- if (Array.isArray(value)) {
67
- return JSON.stringify(value);
68
- }
69
- return value;
70
- },
71
- // Parse JSON string to array on get
72
- get: (value?: string) => {
73
- if (value && typeof value === 'string') {
74
- try {
75
- return JSON.parse(value);
76
- } catch {
77
- // Return raw value on error, consistent with 'content' field
78
- return value;
79
- }
80
- }
81
- // If value was not a string, or if it was an empty string, return it as is.
82
- return value;
83
- },
84
- },
85
- toolCallArgs: {
86
- type: 'string',
87
- required: false,
88
- set: (value?: Record<string, unknown>[] | string) => {
89
- if (value && typeof value !== 'string') {
90
- return JSON.stringify(value);
91
- }
92
- return value;
93
- },
94
- // Parse JSON string to object on get
95
- get: (value?: string) => {
96
- if (value && typeof value === 'string') {
97
- try {
98
- return JSON.parse(value);
99
- } catch {
100
- // Return raw value on error, consistent with 'content' field
101
- return value;
102
- }
103
- }
104
- // If value was not a string, or if it was an empty string, return it as is.
105
- return value;
106
- },
107
- },
108
- toolNames: {
109
- type: 'string',
110
- required: false,
111
- set: (value?: string[] | string) => {
112
- if (Array.isArray(value)) {
113
- return JSON.stringify(value);
114
- }
115
- return value;
116
- },
117
- // Parse JSON string to array on get
118
- get: (value?: string) => {
119
- if (value && typeof value === 'string') {
120
- try {
121
- return JSON.parse(value);
122
- } catch {
123
- // Return raw value on error, consistent with 'content' field
124
- return value;
125
- }
126
- }
127
- // If value was not a string, or if it was an empty string, return it as is.
128
- return value;
129
- },
130
- },
131
- },
132
- indexes: {
133
- primary: {
134
- pk: { field: 'pk', composite: ['entity', 'id'] },
135
- sk: { field: 'sk', composite: ['entity'] },
136
- },
137
- byThread: {
138
- index: 'gsi1',
139
- pk: { field: 'gsi1pk', composite: ['entity', 'threadId'] },
140
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
141
- },
142
- },
143
- });
@@ -1,57 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const resourceEntity = new Entity({
5
- model: {
6
- entity: 'resource',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- workingMemory: {
21
- type: 'string',
22
- required: false,
23
- },
24
- metadata: {
25
- type: 'string',
26
- required: false,
27
- // Stringify content object on set if it's not already a string
28
- set: (value?: string | void) => {
29
- if (value && typeof value !== 'string') {
30
- return JSON.stringify(value);
31
- }
32
- return value;
33
- },
34
- // Parse JSON string to object on get ONLY if it looks like JSON
35
- get: (value?: string) => {
36
- if (value && typeof value === 'string') {
37
- try {
38
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
39
- if (value.startsWith('{') || value.startsWith('[')) {
40
- return JSON.parse(value);
41
- }
42
- } catch {
43
- // Ignore parse error, return original string
44
- return value;
45
- }
46
- }
47
- return value;
48
- },
49
- },
50
- },
51
- indexes: {
52
- primary: {
53
- pk: { field: 'pk', composite: ['entity', 'id'] },
54
- sk: { field: 'sk', composite: ['entity'] },
55
- },
56
- },
57
- });
@@ -1,317 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const scoreEntity = new Entity({
5
- model: {
6
- entity: 'score',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- scorerId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- traceId: {
25
- type: 'string',
26
- required: false,
27
- },
28
- runId: {
29
- type: 'string',
30
- required: true,
31
- },
32
- scorer: {
33
- type: 'string',
34
- required: true,
35
- set: (value?: Record<string, unknown> | string) => {
36
- if (value && typeof value !== 'string') {
37
- return JSON.stringify(value);
38
- }
39
- return value;
40
- },
41
- get: (value?: string) => {
42
- if (value && typeof value === 'string') {
43
- try {
44
- if (value.startsWith('{') || value.startsWith('[')) {
45
- return JSON.parse(value);
46
- }
47
- } catch {
48
- return value;
49
- }
50
- }
51
- return value;
52
- },
53
- },
54
- extractStepResult: {
55
- type: 'string',
56
- required: false,
57
- set: (value?: Record<string, unknown> | string) => {
58
- if (value && typeof value !== 'string') {
59
- return JSON.stringify(value);
60
- }
61
- return value;
62
- },
63
- get: (value?: string) => {
64
- if (value && typeof value === 'string') {
65
- try {
66
- if (value.startsWith('{') || value.startsWith('[')) {
67
- return JSON.parse(value);
68
- }
69
- } catch {
70
- return value;
71
- }
72
- }
73
- return value;
74
- },
75
- },
76
- preprocessStepResult: {
77
- type: 'string',
78
- required: false,
79
- set: (value?: Record<string, unknown> | string) => {
80
- if (value && typeof value !== 'string') {
81
- return JSON.stringify(value);
82
- }
83
- return value;
84
- },
85
- get: (value?: string) => {
86
- if (value && typeof value === 'string') {
87
- try {
88
- if (value.startsWith('{') || value.startsWith('[')) {
89
- return JSON.parse(value);
90
- }
91
- } catch {
92
- return value;
93
- }
94
- }
95
- return value;
96
- },
97
- },
98
- analyzeStepResult: {
99
- type: 'string',
100
- required: false,
101
- set: (value?: Record<string, unknown> | string) => {
102
- if (value && typeof value !== 'string') {
103
- return JSON.stringify(value);
104
- }
105
- return value;
106
- },
107
- get: (value?: string) => {
108
- if (value && typeof value === 'string') {
109
- try {
110
- if (value.startsWith('{') || value.startsWith('[')) {
111
- return JSON.parse(value);
112
- }
113
- } catch {
114
- return value;
115
- }
116
- }
117
- return value;
118
- },
119
- },
120
- score: {
121
- type: 'number',
122
- required: true,
123
- },
124
- reason: {
125
- type: 'string',
126
- required: false,
127
- },
128
- extractPrompt: {
129
- type: 'string',
130
- required: false,
131
- },
132
- analyzePrompt: {
133
- type: 'string',
134
- required: false,
135
- },
136
-
137
- // Deprecated in favor of generateReasonPrompt
138
- reasonPrompt: {
139
- type: 'string',
140
- required: false,
141
- },
142
- generateScorePrompt: {
143
- type: 'string',
144
- required: false,
145
- },
146
- generateReasonPrompt: {
147
- type: 'string',
148
- required: false,
149
- },
150
- input: {
151
- type: 'string',
152
- required: true,
153
- set: (value?: Record<string, unknown> | string) => {
154
- if (value && typeof value !== 'string') {
155
- return JSON.stringify(value);
156
- }
157
- return value;
158
- },
159
- get: (value?: string) => {
160
- if (value && typeof value === 'string') {
161
- try {
162
- if (value.startsWith('{') || value.startsWith('[')) {
163
- return JSON.parse(value);
164
- }
165
- } catch {
166
- return value;
167
- }
168
- }
169
- return value;
170
- },
171
- },
172
- output: {
173
- type: 'string',
174
- required: true,
175
- set: (value?: Record<string, unknown> | string) => {
176
- if (value && typeof value !== 'string') {
177
- return JSON.stringify(value);
178
- }
179
- return value;
180
- },
181
- get: (value?: string) => {
182
- if (value && typeof value === 'string') {
183
- try {
184
- if (value.startsWith('{') || value.startsWith('[')) {
185
- return JSON.parse(value);
186
- }
187
- } catch {
188
- return value;
189
- }
190
- }
191
- return value;
192
- },
193
- },
194
- additionalContext: {
195
- type: 'string',
196
- required: false,
197
- set: (value?: Record<string, unknown> | string) => {
198
- if (value && typeof value !== 'string') {
199
- return JSON.stringify(value);
200
- }
201
- return value;
202
- },
203
- get: (value?: string) => {
204
- if (value && typeof value === 'string') {
205
- try {
206
- if (value.startsWith('{') || value.startsWith('[')) {
207
- return JSON.parse(value);
208
- }
209
- } catch {
210
- return value;
211
- }
212
- }
213
- return value;
214
- },
215
- },
216
- runtimeContext: {
217
- type: 'string',
218
- required: false,
219
- set: (value?: Record<string, unknown> | string) => {
220
- if (value && typeof value !== 'string') {
221
- return JSON.stringify(value);
222
- }
223
- return value;
224
- },
225
- get: (value?: string) => {
226
- if (value && typeof value === 'string') {
227
- try {
228
- if (value.startsWith('{') || value.startsWith('[')) {
229
- return JSON.parse(value);
230
- }
231
- } catch {
232
- return value;
233
- }
234
- }
235
- return value;
236
- },
237
- },
238
- entityType: {
239
- type: 'string',
240
- required: false,
241
- },
242
- entityData: {
243
- type: 'string',
244
- required: false,
245
- set: (value?: Record<string, unknown> | string) => {
246
- if (value && typeof value !== 'string') {
247
- return JSON.stringify(value);
248
- }
249
- return value;
250
- },
251
- get: (value?: string) => {
252
- if (value && typeof value === 'string') {
253
- try {
254
- if (value.startsWith('{') || value.startsWith('[')) {
255
- return JSON.parse(value);
256
- }
257
- } catch {
258
- return value;
259
- }
260
- }
261
- return value;
262
- },
263
- },
264
- entityId: {
265
- type: 'string',
266
- required: false,
267
- },
268
- source: {
269
- type: 'string',
270
- required: true,
271
- },
272
- resourceId: {
273
- type: 'string',
274
- required: false,
275
- },
276
- threadId: {
277
- type: 'string',
278
- required: false,
279
- },
280
- },
281
- indexes: {
282
- primary: {
283
- pk: { field: 'pk', composite: ['entity', 'id'] },
284
- sk: { field: 'sk', composite: ['entity'] },
285
- },
286
- byScorer: {
287
- index: 'gsi1',
288
- pk: { field: 'gsi1pk', composite: ['entity', 'scorerId'] },
289
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
290
- },
291
- byRun: {
292
- index: 'gsi2',
293
- pk: { field: 'gsi2pk', composite: ['entity', 'runId'] },
294
- sk: { field: 'gsi2sk', composite: ['createdAt'] },
295
- },
296
- byTrace: {
297
- index: 'gsi3',
298
- pk: { field: 'gsi3pk', composite: ['entity', 'traceId'] },
299
- sk: { field: 'gsi3sk', composite: ['createdAt'] },
300
- },
301
- byEntityData: {
302
- index: 'gsi4',
303
- pk: { field: 'gsi4pk', composite: ['entity', 'entityId'] },
304
- sk: { field: 'gsi4sk', composite: ['createdAt'] },
305
- },
306
- byResource: {
307
- index: 'gsi5',
308
- pk: { field: 'gsi5pk', composite: ['entity', 'resourceId'] },
309
- sk: { field: 'gsi5sk', composite: ['createdAt'] },
310
- },
311
- byThread: {
312
- index: 'gsi6',
313
- pk: { field: 'gsi6pk', composite: ['entity', 'threadId'] },
314
- sk: { field: 'gsi6sk', composite: ['createdAt'] },
315
- },
316
- },
317
- });
@@ -1,66 +0,0 @@
1
- import { Entity } from 'electrodb';
2
- import { baseAttributes } from './utils';
3
-
4
- export const threadEntity = new Entity({
5
- model: {
6
- entity: 'thread',
7
- version: '1',
8
- service: 'mastra',
9
- },
10
- attributes: {
11
- entity: {
12
- type: 'string',
13
- required: true,
14
- },
15
- ...baseAttributes,
16
- id: {
17
- type: 'string',
18
- required: true,
19
- },
20
- resourceId: {
21
- type: 'string',
22
- required: true,
23
- },
24
- title: {
25
- type: 'string',
26
- required: true,
27
- },
28
- metadata: {
29
- type: 'string',
30
- required: false,
31
- // Stringify metadata object on set if it's not already a string
32
- set: (value?: Record<string, unknown> | string) => {
33
- if (value && typeof value !== 'string') {
34
- return JSON.stringify(value);
35
- }
36
- return value;
37
- },
38
- // Parse JSON string to object on get
39
- get: (value?: string) => {
40
- if (value && typeof value === 'string') {
41
- try {
42
- // Attempt to parse only if it might be JSON (e.g., starts with { or [)
43
- if (value.startsWith('{') || value.startsWith('[')) {
44
- return JSON.parse(value);
45
- }
46
- } catch {
47
- // Ignore parse error, return original string
48
- return value;
49
- }
50
- }
51
- return value;
52
- },
53
- },
54
- },
55
- indexes: {
56
- primary: {
57
- pk: { field: 'pk', composite: ['entity', 'id'] },
58
- sk: { field: 'sk', composite: ['id'] },
59
- },
60
- byResource: {
61
- index: 'gsi1',
62
- pk: { field: 'gsi1pk', composite: ['entity', 'resourceId'] },
63
- sk: { field: 'gsi1sk', composite: ['createdAt'] },
64
- },
65
- },
66
- });