@mastra/server 0.0.0-ai-v5-20250718021026 → 0.0.0-ai-v5-20250729181825

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 (31) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +172 -19
  2. package/dist/_tsup-dts-rollup.d.ts +172 -19
  3. package/dist/chunk-424T5F2J.cjs +157 -0
  4. package/dist/{chunk-3TMDONWY.cjs → chunk-6KP2OBYA.cjs} +30 -0
  5. package/dist/chunk-6T5JUKOQ.js +149 -0
  6. package/dist/{chunk-34GEZJPU.cjs → chunk-AJRURO6F.cjs} +31 -1
  7. package/dist/{chunk-OKL5JVWU.js → chunk-EZXKTV2W.js} +31 -2
  8. package/dist/{chunk-VDTQM2M5.cjs → chunk-FC5QBMOM.cjs} +259 -4
  9. package/dist/{chunk-N6KVUULV.js → chunk-MKHRYD4K.js} +256 -5
  10. package/dist/{chunk-ORHUZSM2.js → chunk-T7HAZC2E.js} +30 -1
  11. package/dist/server/handlers/agents.cjs +11 -7
  12. package/dist/server/handlers/agents.d.cts +1 -0
  13. package/dist/server/handlers/agents.d.ts +1 -0
  14. package/dist/server/handlers/agents.js +1 -1
  15. package/dist/server/handlers/memory.cjs +27 -11
  16. package/dist/server/handlers/memory.d.cts +4 -0
  17. package/dist/server/handlers/memory.d.ts +4 -0
  18. package/dist/server/handlers/memory.js +1 -1
  19. package/dist/server/handlers/scores.cjs +30 -0
  20. package/dist/server/handlers/scores.d.cts +6 -0
  21. package/dist/server/handlers/scores.d.ts +6 -0
  22. package/dist/server/handlers/scores.js +1 -0
  23. package/dist/server/handlers/workflows.cjs +19 -15
  24. package/dist/server/handlers/workflows.d.cts +1 -0
  25. package/dist/server/handlers/workflows.d.ts +1 -0
  26. package/dist/server/handlers/workflows.js +1 -1
  27. package/dist/server/handlers.cjs +14 -9
  28. package/dist/server/handlers.d.cts +3 -2
  29. package/dist/server/handlers.d.ts +3 -2
  30. package/dist/server/handlers.js +4 -3
  31. package/package.json +5 -4
@@ -2,12 +2,12 @@ import type { Agent } from '@mastra/core/agent';
2
2
  import type { AgentCard } from '@mastra/core/a2a';
3
3
  import type { AgentNetwork } from '@mastra/core/network';
4
4
  import type { Artifact } from '@mastra/core/a2a';
5
- import type { BaseLogMessage } from '@mastra/core/logger';
5
+ import { BaseLogMessage } from '@mastra/core/logger';
6
6
  import type { CoreMessage } from '@mastra/core/llm';
7
7
  import { DefaultEngineType } from '@mastra/core';
8
8
  import { EvalRow } from '@mastra/core';
9
- import { GenerateObjectResult } from 'ai';
10
- import { GenerateTextResult } from 'ai';
9
+ import type { GenerateReturn } from '@mastra/core/llm';
10
+ import { GenerateTextResult } from '@mastra/core';
11
11
  import type { IMastraLogger } from '@mastra/core/logger';
12
12
  import type { JSONRPCError } from '@mastra/core/a2a';
13
13
  import { JSONRPCResponse } from '@mastra/core/a2a';
@@ -20,18 +20,26 @@ import type { Mastra } from '@mastra/core/mastra';
20
20
  import type { MastraError } from '@mastra/core/error';
21
21
  import type { MastraMemory } from '@mastra/core/memory';
22
22
  import { MastraMessageV1 } from '@mastra/core';
23
+ import { MastraMessageV2 } from '@mastra/core';
24
+ import type { MastraScorerEntry } from '@mastra/core/scores';
25
+ import { MastraWorkflowStream } from '@mastra/core';
26
+ import { MemoryConfig } from '@mastra/core';
23
27
  import type { Message } from '@mastra/core/a2a';
24
28
  import { ModelMessage } from 'ai';
29
+ import { PaginationInfo } from '@mastra/core';
25
30
  import type { QueryResult } from '@mastra/core/vector';
26
31
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
27
32
  import { ReadableStream as ReadableStream_3 } from 'stream/web';
28
33
  import { RuntimeContext } from '@mastra/core/runtime-context';
29
34
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
35
+ import type { ScoreRowData } from '@mastra/core/scores';
30
36
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
31
37
  import { Step } from '@mastra/core';
32
38
  import { StepExecutionContext } from '@mastra/core/workflows/legacy';
33
39
  import { StepGraph } from '@mastra/core/workflows/legacy';
34
40
  import { StepResult } from '@mastra/core';
41
+ import type { StorageGetMessagesArg } from '@mastra/core';
42
+ import type { StoragePagination } from '@mastra/core/storage';
35
43
  import { StorageThreadType } from '@mastra/core';
36
44
  import { StreamEvent } from '@mastra/core';
37
45
  import { Task } from '@mastra/core/a2a';
@@ -41,7 +49,9 @@ import type { TaskIdParams } from '@mastra/core/a2a';
41
49
  import type { TaskQueryParams } from '@mastra/core/a2a';
42
50
  import type { TaskSendParams } from '@mastra/core/a2a';
43
51
  import type { TaskStatus } from '@mastra/core/a2a';
52
+ import type { ThreadSortOptions } from '@mastra/core/storage';
44
53
  import type { ToolAction } from '@mastra/core/tools';
54
+ import { Trace } from '@mastra/core';
45
55
  import type { VercelTool } from '@mastra/core/tools';
46
56
  import type { WatchEvent } from '@mastra/core/workflows';
47
57
  import type { Workflow } from '@mastra/core/workflows';
@@ -77,7 +87,8 @@ export declare namespace agents {
77
87
  getEvalsByAgentIdHandler,
78
88
  getLiveEvalsByAgentIdHandler,
79
89
  generateHandler,
80
- streamGenerateHandler
90
+ streamGenerateHandler,
91
+ streamVNextGenerateHandler
81
92
  }
82
93
  }
83
94
 
@@ -143,6 +154,21 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
143
154
  success: boolean;
144
155
  }>;
145
156
 
157
+ /**
158
+ * Handler to delete one or more messages.
159
+ * @param messageIds - Can be a single ID, array of IDs, or objects with ID property
160
+ */
161
+ export declare function deleteMessagesHandler({ mastra, agentId, messageIds, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
162
+ messageIds: string | string[] | {
163
+ id: string;
164
+ } | {
165
+ id: string;
166
+ }[];
167
+ }): Promise<{
168
+ success: boolean;
169
+ message: string;
170
+ }>;
171
+
146
172
  export declare function deleteThreadHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<{
147
173
  result: string;
148
174
  }>;
@@ -176,14 +202,14 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
176
202
  runtimeContext?: Record<string, unknown>;
177
203
  };
178
204
  abortSignal?: AbortSignal;
179
- }): Promise<GenerateTextResult<any, unknown>>;
205
+ }): Promise<GenerateTextResult<any, undefined>>;
180
206
 
181
207
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
182
208
  runtimeContext: RuntimeContext;
183
209
  body: {
184
210
  messages?: Parameters<AgentNetwork['generate']>[0];
185
211
  } & Parameters<AgentNetwork['generate']>[1];
186
- }): Promise<GenerateObjectResult<any>>;
212
+ }): Promise<GenerateReturn<any>>;
187
213
 
188
214
  /**
189
215
  * Generate speech from text
@@ -206,7 +232,7 @@ export declare function generateVNextNetworkHandler({ mastra, runtimeContext, ne
206
232
  task: string;
207
233
  result: string;
208
234
  resourceId: string;
209
- resourceType: "tool" | "none" | "workflow" | "agent";
235
+ resourceType: "tool" | "none" | "agent" | "workflow";
210
236
  }>;
211
237
 
212
238
  export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
@@ -334,6 +360,10 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
334
360
  transports: string[];
335
361
  }>;
336
362
 
363
+ export declare function getMemoryConfigHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
364
+ config: MemoryConfig;
365
+ }>;
366
+
337
367
  export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
338
368
  result: boolean;
339
369
  }>;
@@ -347,6 +377,10 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, f
347
377
  uiMessages: any[];
348
378
  }>;
349
379
 
380
+ export declare function getMessagesPaginatedHandler({ mastra, threadId, resourceId, selectBy, format, }: StorageGetMessagesArg & Pick<MemoryContext, 'mastra'>): Promise<PaginationInfo & {
381
+ messages: MastraMessageV1[] | MastraMessageV2[];
382
+ }>;
383
+
350
384
  export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
351
385
  id: string;
352
386
  name: string;
@@ -377,6 +411,50 @@ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<Net
377
411
  };
378
412
  }[]>;
379
413
 
414
+ export declare function getScorerHandler({ mastra, scorerId, runtimeContext, }: Context & {
415
+ scorerId: string;
416
+ runtimeContext: RuntimeContext;
417
+ }): Promise<(MastraScorerEntry & {
418
+ agentIds: string[];
419
+ workflowIds: string[];
420
+ }) | null>;
421
+
422
+ export declare function getScorersHandler({ mastra, runtimeContext }: Context & {
423
+ runtimeContext: RuntimeContext;
424
+ }): Promise<{
425
+ [k: string]: MastraScorerEntry & {
426
+ agentIds: string[];
427
+ workflowIds: string[];
428
+ };
429
+ }>;
430
+
431
+ export declare function getScoresByEntityIdHandler({ mastra, entityId, entityType, pagination, }: Context & {
432
+ entityId: string;
433
+ entityType: string;
434
+ pagination: StoragePagination;
435
+ }): Promise<never[] | {
436
+ pagination: PaginationInfo;
437
+ scores: ScoreRowData[];
438
+ }>;
439
+
440
+ export declare function getScoresByRunIdHandler({ mastra, runId, pagination, }: Context & {
441
+ runId: string;
442
+ pagination: StoragePagination;
443
+ }): Promise<never[] | {
444
+ pagination: PaginationInfo;
445
+ scores: ScoreRowData[];
446
+ }>;
447
+
448
+ export declare function getScoresByScorerIdHandler({ mastra, scorerId, pagination, entityId, entityType, }: Context & {
449
+ scorerId: string;
450
+ pagination: StoragePagination;
451
+ entityId?: string;
452
+ entityType?: string;
453
+ }): Promise<never[] | {
454
+ pagination: PaginationInfo;
455
+ scores: ScoreRowData[];
456
+ }>;
457
+
380
458
  /**
381
459
  * Get available speakers for an agent
382
460
  */
@@ -384,11 +462,11 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
384
462
  voiceId: string;
385
463
  }[]>;
386
464
 
387
- export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
465
+ export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<Trace[]>;
388
466
 
389
467
  export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
390
468
 
391
- export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType[]>;
469
+ export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, orderBy, sortDirection, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'> & ThreadSortOptions): Promise<StorageThreadType[]>;
392
470
 
393
471
  export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
394
472
 
@@ -674,20 +752,20 @@ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body,
674
752
  completionReason: ZodOptional<ZodString>;
675
753
  iteration: ZodNumber;
676
754
  }, "strip", ZodTypeAny, {
755
+ resourceId: string;
677
756
  result: string;
678
757
  prompt: string;
679
- resourceId: string;
680
758
  task: string;
681
- resourceType: "tool" | "none" | "workflow" | "agent";
759
+ resourceType: "tool" | "none" | "agent" | "workflow";
682
760
  iteration: number;
683
761
  isComplete?: boolean | undefined;
684
762
  completionReason?: string | undefined;
685
763
  }, {
764
+ resourceId: string;
686
765
  result: string;
687
766
  prompt: string;
688
- resourceId: string;
689
767
  task: string;
690
- resourceType: "tool" | "none" | "workflow" | "agent";
768
+ resourceType: "tool" | "none" | "agent" | "workflow";
691
769
  iteration: number;
692
770
  isComplete?: boolean | undefined;
693
771
  completionReason?: string | undefined;
@@ -702,8 +780,17 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
702
780
  }): Promise<{
703
781
  status: "success";
704
782
  result: {
705
- text: string;
783
+ resourceId: string;
784
+ result: string;
785
+ prompt: string;
786
+ task: string;
787
+ resourceType: "tool" | "none" | "agent" | "workflow";
706
788
  iteration: number;
789
+ isOneOff: boolean;
790
+ threadId?: string | undefined;
791
+ threadResourceId?: string | undefined;
792
+ isComplete?: boolean | undefined;
793
+ completionReason?: string | undefined;
707
794
  };
708
795
  steps: {
709
796
  [x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
@@ -713,15 +800,19 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
713
800
  export declare namespace memory {
714
801
  export {
715
802
  getMemoryStatusHandler,
803
+ getMemoryConfigHandler,
716
804
  getThreadsHandler,
717
805
  getThreadByIdHandler,
718
806
  saveMessagesHandler,
719
807
  createThreadHandler,
720
808
  updateThreadHandler,
721
809
  deleteThreadHandler,
810
+ getMessagesPaginatedHandler,
722
811
  getMessagesHandler,
723
812
  getWorkingMemoryHandler,
724
- updateWorkingMemoryHandler
813
+ updateWorkingMemoryHandler,
814
+ deleteMessagesHandler,
815
+ searchMemoryHandler
725
816
  }
726
817
  }
727
818
 
@@ -810,6 +901,53 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
810
901
  };
811
902
  }): Promise<MastraMessageV1[]>;
812
903
 
904
+ export declare function saveScoreHandler({ mastra, score }: Context & {
905
+ score: ScoreRowData;
906
+ }): Promise<never[] | {
907
+ score: ScoreRowData;
908
+ }>;
909
+
910
+ export declare namespace scores {
911
+ export {
912
+ getScorersHandler,
913
+ getScorerHandler,
914
+ getScoresByRunIdHandler,
915
+ getScoresByScorerIdHandler,
916
+ getScoresByEntityIdHandler,
917
+ saveScoreHandler
918
+ }
919
+ }
920
+
921
+ export declare function searchMemoryHandler({ mastra, agentId, searchQuery, resourceId, threadId, limit, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
922
+ searchQuery: string;
923
+ resourceId: string;
924
+ threadId?: string;
925
+ limit?: number;
926
+ memoryConfig?: any;
927
+ }): Promise<SearchResponse | ReturnType<typeof handleError>>;
928
+
929
+ declare interface SearchResponse {
930
+ results: SearchResult[];
931
+ count: number;
932
+ query: string;
933
+ searchScope?: string;
934
+ searchType?: string;
935
+ }
936
+
937
+ declare interface SearchResult {
938
+ id: string;
939
+ role: string;
940
+ content: any;
941
+ createdAt: Date;
942
+ threadId?: string;
943
+ threadTitle?: string;
944
+ score?: number;
945
+ context?: {
946
+ before?: SearchResult[];
947
+ after?: SearchResult[];
948
+ };
949
+ }
950
+
813
951
  export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
814
952
  event: string;
815
953
  data: unknown;
@@ -915,11 +1053,11 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
915
1053
  threadResourceId: ZodOptional<ZodString>;
916
1054
  isOneOff: ZodBoolean;
917
1055
  }, "strip", ZodTypeAny, {
1056
+ resourceId: string;
918
1057
  result: string;
919
1058
  prompt: string;
920
- resourceId: string;
921
1059
  task: string;
922
- resourceType: "tool" | "none" | "workflow" | "agent";
1060
+ resourceType: "tool" | "none" | "agent" | "workflow";
923
1061
  iteration: number;
924
1062
  isOneOff: boolean;
925
1063
  threadId?: string | undefined;
@@ -927,11 +1065,11 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
927
1065
  isComplete?: boolean | undefined;
928
1066
  completionReason?: string | undefined;
929
1067
  }, {
1068
+ resourceId: string;
930
1069
  result: string;
931
1070
  prompt: string;
932
- resourceId: string;
933
1071
  task: string;
934
- resourceType: "tool" | "none" | "workflow" | "agent";
1072
+ resourceType: "tool" | "none" | "agent" | "workflow";
935
1073
  iteration: number;
936
1074
  isOneOff: boolean;
937
1075
  threadId?: string | undefined;
@@ -941,6 +1079,20 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
941
1079
  }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
942
1080
  }>;
943
1081
 
1082
+ export declare function streamVNextGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
1083
+ runtimeContext: RuntimeContext;
1084
+ agentId: string;
1085
+ body: GetBody<'streamVNext'> & {
1086
+ runtimeContext?: string;
1087
+ };
1088
+ abortSignal?: AbortSignal;
1089
+ }): ReturnType<Agent['streamVNext']>;
1090
+
1091
+ export declare function streamVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
1092
+ inputData?: unknown;
1093
+ runtimeContext?: RuntimeContext_2;
1094
+ }): Promise<MastraWorkflowStream>;
1095
+
944
1096
  export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
945
1097
  inputData?: unknown;
946
1098
  runtimeContext?: RuntimeContext_2;
@@ -1098,6 +1250,7 @@ export declare namespace workflows {
1098
1250
  startWorkflowRunHandler,
1099
1251
  watchWorkflowHandler,
1100
1252
  streamWorkflowHandler,
1253
+ streamVNextWorkflowHandler,
1101
1254
  resumeAsyncWorkflowHandler,
1102
1255
  resumeWorkflowHandler,
1103
1256
  getWorkflowRunsHandler,
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
+
6
+ // src/server/handlers/scores.ts
7
+ var scores_exports = {};
8
+ chunk75ZPJI57_cjs.__export(scores_exports, {
9
+ getScorerHandler: () => getScorerHandler,
10
+ getScorersHandler: () => getScorersHandler,
11
+ getScoresByEntityIdHandler: () => getScoresByEntityIdHandler,
12
+ getScoresByRunIdHandler: () => getScoresByRunIdHandler,
13
+ getScoresByScorerIdHandler: () => getScoresByScorerIdHandler,
14
+ saveScoreHandler: () => saveScoreHandler
15
+ });
16
+ async function getScorersFromSystem({
17
+ mastra,
18
+ runtimeContext
19
+ }) {
20
+ const agents = mastra.getAgents();
21
+ const workflows = mastra.getWorkflows();
22
+ const scorersMap = /* @__PURE__ */ new Map();
23
+ for (const [agentId, agent] of Object.entries(agents)) {
24
+ const scorers = await agent.getScorers({
25
+ runtimeContext
26
+ }) || {};
27
+ if (Object.keys(scorers).length > 0) {
28
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
29
+ if (scorersMap.has(scorerId)) {
30
+ scorersMap.get(scorerId)?.agentIds.push(agentId);
31
+ } else {
32
+ scorersMap.set(scorerId, {
33
+ workflowIds: [],
34
+ ...scorer,
35
+ agentIds: [agent.name]
36
+ });
37
+ }
38
+ }
39
+ }
40
+ }
41
+ for (const [workflowId, workflow] of Object.entries(workflows)) {
42
+ const scorers = await workflow.getScorers({
43
+ runtimeContext
44
+ }) || {};
45
+ if (Object.keys(scorers).length > 0) {
46
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
47
+ if (scorersMap.has(scorerId)) {
48
+ scorersMap.get(scorerId)?.workflowIds.push(workflowId);
49
+ } else {
50
+ scorersMap.set(scorerId, {
51
+ agentIds: [],
52
+ ...scorer,
53
+ workflowIds: [workflowId]
54
+ });
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return Object.fromEntries(scorersMap.entries());
60
+ }
61
+ async function getScorersHandler({ mastra, runtimeContext }) {
62
+ const scorers = await getScorersFromSystem({
63
+ mastra,
64
+ runtimeContext
65
+ });
66
+ return scorers;
67
+ }
68
+ async function getScorerHandler({
69
+ mastra,
70
+ scorerId,
71
+ runtimeContext
72
+ }) {
73
+ const scorers = await getScorersFromSystem({
74
+ mastra,
75
+ runtimeContext
76
+ });
77
+ const scorer = scorers[scorerId];
78
+ if (!scorer) {
79
+ return null;
80
+ }
81
+ return scorer;
82
+ }
83
+ async function getScoresByRunIdHandler({
84
+ mastra,
85
+ runId,
86
+ pagination
87
+ }) {
88
+ try {
89
+ const scores = await mastra.getStorage()?.getScoresByRunId?.({
90
+ runId,
91
+ pagination
92
+ }) || [];
93
+ return scores;
94
+ } catch (error) {
95
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by run id");
96
+ }
97
+ }
98
+ async function getScoresByScorerIdHandler({
99
+ mastra,
100
+ scorerId,
101
+ pagination,
102
+ entityId,
103
+ entityType
104
+ }) {
105
+ try {
106
+ const scores = await mastra.getStorage()?.getScoresByScorerId?.({
107
+ scorerId,
108
+ pagination,
109
+ entityId,
110
+ entityType
111
+ }) || [];
112
+ return scores;
113
+ } catch (error) {
114
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by scorer id");
115
+ }
116
+ }
117
+ async function getScoresByEntityIdHandler({
118
+ mastra,
119
+ entityId,
120
+ entityType,
121
+ pagination
122
+ }) {
123
+ try {
124
+ let entityIdToUse = entityId;
125
+ if (entityType === "AGENT") {
126
+ const agent = mastra.getAgentById(entityId);
127
+ entityIdToUse = agent.id;
128
+ } else if (entityType === "WORKFLOW") {
129
+ const workflow = mastra.getWorkflowById(entityId);
130
+ entityIdToUse = workflow.id;
131
+ }
132
+ const scores = await mastra.getStorage()?.getScoresByEntityId?.({
133
+ entityId: entityIdToUse,
134
+ entityType,
135
+ pagination
136
+ }) || [];
137
+ return scores;
138
+ } catch (error) {
139
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by entity id");
140
+ }
141
+ }
142
+ async function saveScoreHandler({ mastra, score }) {
143
+ try {
144
+ const scores = await mastra.getStorage()?.saveScore?.(score) || [];
145
+ return scores;
146
+ } catch (error) {
147
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving score");
148
+ }
149
+ }
150
+
151
+ exports.getScorerHandler = getScorerHandler;
152
+ exports.getScorersHandler = getScorersHandler;
153
+ exports.getScoresByEntityIdHandler = getScoresByEntityIdHandler;
154
+ exports.getScoresByRunIdHandler = getScoresByRunIdHandler;
155
+ exports.getScoresByScorerIdHandler = getScoresByScorerIdHandler;
156
+ exports.saveScoreHandler = saveScoreHandler;
157
+ exports.scores_exports = scores_exports;
@@ -21,6 +21,7 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
21
21
  sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
22
22
  startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
23
23
  startWorkflowRunHandler: () => startWorkflowRunHandler,
24
+ streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
24
25
  streamWorkflowHandler: () => streamWorkflowHandler,
25
26
  watchWorkflowHandler: () => watchWorkflowHandler
26
27
  });
@@ -342,6 +343,34 @@ async function streamWorkflowHandler({
342
343
  return chunkPZQDCRPV_cjs.handleError(error, "Error executing workflow");
343
344
  }
344
345
  }
346
+ async function streamVNextWorkflowHandler({
347
+ mastra,
348
+ runtimeContext,
349
+ workflowId,
350
+ runId,
351
+ inputData
352
+ }) {
353
+ try {
354
+ if (!workflowId) {
355
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
356
+ }
357
+ if (!runId) {
358
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to stream workflow" });
359
+ }
360
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
361
+ if (!workflow) {
362
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
363
+ }
364
+ const run = await workflow.createRunAsync({ runId });
365
+ const result = run.streamVNext({
366
+ inputData,
367
+ runtimeContext
368
+ });
369
+ return result;
370
+ } catch (error) {
371
+ return chunkPZQDCRPV_cjs.handleError(error, "Error streaming workflow");
372
+ }
373
+ }
345
374
  async function resumeAsyncWorkflowHandler({
346
375
  mastra,
347
376
  workflowId,
@@ -509,6 +538,7 @@ exports.resumeWorkflowHandler = resumeWorkflowHandler;
509
538
  exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
510
539
  exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
511
540
  exports.startWorkflowRunHandler = startWorkflowRunHandler;
541
+ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
512
542
  exports.streamWorkflowHandler = streamWorkflowHandler;
513
543
  exports.watchWorkflowHandler = watchWorkflowHandler;
514
544
  exports.workflows_exports = workflows_exports;