@mastra/server 0.11.0-alpha.0 → 0.11.0-alpha.2
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 +155 -12
- package/dist/_tsup-dts-rollup.d.ts +155 -12
- package/dist/{chunk-H7DMHBKY.js → chunk-2SPBWAKY.js} +30 -1
- package/dist/chunk-424T5F2J.cjs +157 -0
- package/dist/chunk-6T5JUKOQ.js +149 -0
- package/dist/{chunk-KOHWJYJT.js → chunk-AHXXKSOO.js} +207 -2
- package/dist/{chunk-LZ3VJXSO.cjs → chunk-ENPKI53P.cjs} +31 -1
- package/dist/{chunk-B2PAS2IB.cjs → chunk-G7AFLCTK.cjs} +30 -0
- package/dist/{chunk-LRCAAFUA.js → chunk-RFV6JJFC.js} +1 -1
- package/dist/{chunk-3CNDE7QY.cjs → chunk-SE2BQ536.cjs} +209 -1
- package/dist/{chunk-BK4XT6EG.js → chunk-VRJ2TE5J.js} +31 -2
- package/dist/{chunk-FRVBFMO2.cjs → chunk-WDFLW64N.cjs} +4 -4
- package/dist/server/handlers/agents.cjs +11 -7
- package/dist/server/handlers/agents.d.cts +1 -0
- package/dist/server/handlers/agents.d.ts +1 -0
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/memory.cjs +23 -11
- package/dist/server/handlers/memory.d.cts +3 -0
- package/dist/server/handlers/memory.d.ts +3 -0
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/scores.cjs +30 -0
- package/dist/server/handlers/scores.d.cts +6 -0
- package/dist/server/handlers/scores.d.ts +6 -0
- package/dist/server/handlers/scores.js +1 -0
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/workflows.cjs +19 -15
- package/dist/server/handlers/workflows.d.cts +1 -0
- package/dist/server/handlers/workflows.d.ts +1 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +16 -11
- package/dist/server/handlers.d.cts +3 -2
- package/dist/server/handlers.d.ts +3 -2
- package/dist/server/handlers.js +5 -4
- package/package.json +3 -2
|
@@ -7,8 +7,8 @@ import { CoreMessage } from 'ai';
|
|
|
7
7
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
8
8
|
import { DefaultEngineType } from '@mastra/core';
|
|
9
9
|
import { EvalRow } from '@mastra/core';
|
|
10
|
-
import {
|
|
11
|
-
import { GenerateTextResult } from '
|
|
10
|
+
import type { GenerateReturn } from '@mastra/core/llm';
|
|
11
|
+
import { GenerateTextResult } from '@mastra/core';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
13
13
|
import type { JSONRPCError } from '@mastra/core/a2a';
|
|
14
14
|
import { JSONRPCResponse } from '@mastra/core/a2a';
|
|
@@ -21,17 +21,25 @@ import type { Mastra } from '@mastra/core/mastra';
|
|
|
21
21
|
import type { MastraError } from '@mastra/core/error';
|
|
22
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
23
23
|
import { MastraMessageV1 } from '@mastra/core';
|
|
24
|
+
import { MastraMessageV2 } from '@mastra/core';
|
|
25
|
+
import type { MastraScorerEntry } from '@mastra/core/scores';
|
|
26
|
+
import { MastraWorkflowStream } from '@mastra/core';
|
|
27
|
+
import { MemoryConfig } from '@mastra/core';
|
|
24
28
|
import type { Message } from '@mastra/core/a2a';
|
|
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';
|
|
@@ -42,6 +50,7 @@ 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';
|
|
44
52
|
import type { ToolAction } from '@mastra/core/tools';
|
|
53
|
+
import { Trace } from '@mastra/core';
|
|
45
54
|
import { UIMessage } from 'ai';
|
|
46
55
|
import type { VercelTool } from '@mastra/core/tools';
|
|
47
56
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
@@ -78,7 +87,8 @@ export declare namespace agents {
|
|
|
78
87
|
getEvalsByAgentIdHandler,
|
|
79
88
|
getLiveEvalsByAgentIdHandler,
|
|
80
89
|
generateHandler,
|
|
81
|
-
streamGenerateHandler
|
|
90
|
+
streamGenerateHandler,
|
|
91
|
+
streamVNextGenerateHandler
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
|
|
@@ -177,14 +187,14 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
|
|
|
177
187
|
runtimeContext?: Record<string, unknown>;
|
|
178
188
|
};
|
|
179
189
|
abortSignal?: AbortSignal;
|
|
180
|
-
}): Promise<GenerateTextResult<any,
|
|
190
|
+
}): Promise<GenerateTextResult<any, undefined>>;
|
|
181
191
|
|
|
182
192
|
export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
|
|
183
193
|
runtimeContext: RuntimeContext;
|
|
184
194
|
body: {
|
|
185
195
|
messages?: Parameters<AgentNetwork['generate']>[0];
|
|
186
196
|
} & Parameters<AgentNetwork['generate']>[1];
|
|
187
|
-
}): Promise<
|
|
197
|
+
}): Promise<GenerateReturn<any, any, any>>;
|
|
188
198
|
|
|
189
199
|
/**
|
|
190
200
|
* Generate speech from text
|
|
@@ -335,6 +345,10 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
|
|
|
335
345
|
transports: string[];
|
|
336
346
|
}>;
|
|
337
347
|
|
|
348
|
+
export declare function getMemoryConfigHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
349
|
+
config: MemoryConfig;
|
|
350
|
+
}>;
|
|
351
|
+
|
|
338
352
|
export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
339
353
|
result: boolean;
|
|
340
354
|
}>;
|
|
@@ -346,6 +360,10 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, n
|
|
|
346
360
|
uiMessages: UIMessage[];
|
|
347
361
|
}>;
|
|
348
362
|
|
|
363
|
+
export declare function getMessagesPaginatedHandler({ mastra, threadId, resourceId, selectBy, format, }: StorageGetMessagesArg & Pick<MemoryContext, 'mastra'>): Promise<PaginationInfo & {
|
|
364
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
365
|
+
}>;
|
|
366
|
+
|
|
349
367
|
export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
350
368
|
id: string;
|
|
351
369
|
name: string;
|
|
@@ -376,6 +394,50 @@ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<Net
|
|
|
376
394
|
};
|
|
377
395
|
}[]>;
|
|
378
396
|
|
|
397
|
+
export declare function getScorerHandler({ mastra, scorerId, runtimeContext, }: Context & {
|
|
398
|
+
scorerId: string;
|
|
399
|
+
runtimeContext: RuntimeContext;
|
|
400
|
+
}): Promise<(MastraScorerEntry & {
|
|
401
|
+
agentIds: string[];
|
|
402
|
+
workflowIds: string[];
|
|
403
|
+
}) | null>;
|
|
404
|
+
|
|
405
|
+
export declare function getScorersHandler({ mastra, runtimeContext }: Context & {
|
|
406
|
+
runtimeContext: RuntimeContext;
|
|
407
|
+
}): Promise<{
|
|
408
|
+
[k: string]: MastraScorerEntry & {
|
|
409
|
+
agentIds: string[];
|
|
410
|
+
workflowIds: string[];
|
|
411
|
+
};
|
|
412
|
+
}>;
|
|
413
|
+
|
|
414
|
+
export declare function getScoresByEntityIdHandler({ mastra, entityId, entityType, pagination, }: Context & {
|
|
415
|
+
entityId: string;
|
|
416
|
+
entityType: string;
|
|
417
|
+
pagination: StoragePagination;
|
|
418
|
+
}): Promise<never[] | {
|
|
419
|
+
pagination: PaginationInfo;
|
|
420
|
+
scores: ScoreRowData[];
|
|
421
|
+
}>;
|
|
422
|
+
|
|
423
|
+
export declare function getScoresByRunIdHandler({ mastra, runId, pagination, }: Context & {
|
|
424
|
+
runId: string;
|
|
425
|
+
pagination: StoragePagination;
|
|
426
|
+
}): Promise<never[] | {
|
|
427
|
+
pagination: PaginationInfo;
|
|
428
|
+
scores: ScoreRowData[];
|
|
429
|
+
}>;
|
|
430
|
+
|
|
431
|
+
export declare function getScoresByScorerIdHandler({ mastra, scorerId, pagination, entityId, entityType, }: Context & {
|
|
432
|
+
scorerId: string;
|
|
433
|
+
pagination: StoragePagination;
|
|
434
|
+
entityId?: string;
|
|
435
|
+
entityType?: string;
|
|
436
|
+
}): Promise<never[] | {
|
|
437
|
+
pagination: PaginationInfo;
|
|
438
|
+
scores: ScoreRowData[];
|
|
439
|
+
}>;
|
|
440
|
+
|
|
379
441
|
/**
|
|
380
442
|
* Get available speakers for an agent
|
|
381
443
|
*/
|
|
@@ -383,7 +445,7 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
|
|
|
383
445
|
voiceId: string;
|
|
384
446
|
}[]>;
|
|
385
447
|
|
|
386
|
-
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<
|
|
448
|
+
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<Trace[]>;
|
|
387
449
|
|
|
388
450
|
export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
|
|
389
451
|
|
|
@@ -673,18 +735,18 @@ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body,
|
|
|
673
735
|
completionReason: ZodOptional<ZodString>;
|
|
674
736
|
iteration: ZodNumber;
|
|
675
737
|
}, "strip", ZodTypeAny, {
|
|
738
|
+
result: string;
|
|
676
739
|
prompt: string;
|
|
677
740
|
resourceId: string;
|
|
678
|
-
result: string;
|
|
679
741
|
task: string;
|
|
680
742
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
681
743
|
iteration: number;
|
|
682
744
|
isComplete?: boolean | undefined;
|
|
683
745
|
completionReason?: string | undefined;
|
|
684
746
|
}, {
|
|
747
|
+
result: string;
|
|
685
748
|
prompt: string;
|
|
686
749
|
resourceId: string;
|
|
687
|
-
result: string;
|
|
688
750
|
task: string;
|
|
689
751
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
690
752
|
iteration: number;
|
|
@@ -701,8 +763,17 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
|
|
|
701
763
|
}): Promise<{
|
|
702
764
|
status: "success";
|
|
703
765
|
result: {
|
|
704
|
-
|
|
766
|
+
result: string;
|
|
767
|
+
prompt: string;
|
|
768
|
+
resourceId: string;
|
|
769
|
+
task: string;
|
|
770
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
705
771
|
iteration: number;
|
|
772
|
+
isOneOff: boolean;
|
|
773
|
+
threadId?: string | undefined;
|
|
774
|
+
threadResourceId?: string | undefined;
|
|
775
|
+
isComplete?: boolean | undefined;
|
|
776
|
+
completionReason?: string | undefined;
|
|
706
777
|
};
|
|
707
778
|
steps: {
|
|
708
779
|
[x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
|
|
@@ -712,15 +783,18 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
|
|
|
712
783
|
export declare namespace memory {
|
|
713
784
|
export {
|
|
714
785
|
getMemoryStatusHandler,
|
|
786
|
+
getMemoryConfigHandler,
|
|
715
787
|
getThreadsHandler,
|
|
716
788
|
getThreadByIdHandler,
|
|
717
789
|
saveMessagesHandler,
|
|
718
790
|
createThreadHandler,
|
|
719
791
|
updateThreadHandler,
|
|
720
792
|
deleteThreadHandler,
|
|
793
|
+
getMessagesPaginatedHandler,
|
|
721
794
|
getMessagesHandler,
|
|
722
795
|
getWorkingMemoryHandler,
|
|
723
|
-
updateWorkingMemoryHandler
|
|
796
|
+
updateWorkingMemoryHandler,
|
|
797
|
+
searchMemoryHandler
|
|
724
798
|
}
|
|
725
799
|
}
|
|
726
800
|
|
|
@@ -809,6 +883,60 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
|
|
|
809
883
|
};
|
|
810
884
|
}): Promise<MastraMessageV1[]>;
|
|
811
885
|
|
|
886
|
+
export declare function saveScoreHandler({ mastra, score }: Context & {
|
|
887
|
+
score: ScoreRowData;
|
|
888
|
+
}): Promise<never[] | {
|
|
889
|
+
score: ScoreRowData;
|
|
890
|
+
}>;
|
|
891
|
+
|
|
892
|
+
export declare namespace scores {
|
|
893
|
+
export {
|
|
894
|
+
getScorersHandler,
|
|
895
|
+
getScorerHandler,
|
|
896
|
+
getScoresByRunIdHandler,
|
|
897
|
+
getScoresByScorerIdHandler,
|
|
898
|
+
getScoresByEntityIdHandler,
|
|
899
|
+
saveScoreHandler
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Handler to search messages in a thread.
|
|
905
|
+
* @param searchQuery - the text to search for
|
|
906
|
+
* @param resourceId - the resource id (user/org) to validate thread ownership
|
|
907
|
+
* @param threadId - the thread id to search within
|
|
908
|
+
* @param limit - maximum number of results to return (default: 20)
|
|
909
|
+
*/
|
|
910
|
+
export declare function searchMemoryHandler({ mastra, agentId, searchQuery, resourceId, threadId, limit, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
|
|
911
|
+
searchQuery: string;
|
|
912
|
+
resourceId: string;
|
|
913
|
+
threadId?: string;
|
|
914
|
+
limit?: number;
|
|
915
|
+
memoryConfig?: any;
|
|
916
|
+
}): Promise<SearchResponse | ReturnType<typeof handleError>>;
|
|
917
|
+
|
|
918
|
+
declare interface SearchResponse {
|
|
919
|
+
results: SearchResult[];
|
|
920
|
+
count: number;
|
|
921
|
+
query: string;
|
|
922
|
+
searchScope?: string;
|
|
923
|
+
searchType?: string;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
declare interface SearchResult {
|
|
927
|
+
id: string;
|
|
928
|
+
role: string;
|
|
929
|
+
content: any;
|
|
930
|
+
createdAt: Date;
|
|
931
|
+
threadId?: string;
|
|
932
|
+
threadTitle?: string;
|
|
933
|
+
score?: number;
|
|
934
|
+
context?: {
|
|
935
|
+
before?: SearchResult[];
|
|
936
|
+
after?: SearchResult[];
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
|
|
812
940
|
export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
813
941
|
event: string;
|
|
814
942
|
data: unknown;
|
|
@@ -913,9 +1041,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
913
1041
|
threadResourceId: ZodOptional<ZodString>;
|
|
914
1042
|
isOneOff: ZodBoolean;
|
|
915
1043
|
}, "strip", ZodTypeAny, {
|
|
1044
|
+
result: string;
|
|
916
1045
|
prompt: string;
|
|
917
1046
|
resourceId: string;
|
|
918
|
-
result: string;
|
|
919
1047
|
task: string;
|
|
920
1048
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
921
1049
|
iteration: number;
|
|
@@ -925,9 +1053,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
925
1053
|
isComplete?: boolean | undefined;
|
|
926
1054
|
completionReason?: string | undefined;
|
|
927
1055
|
}, {
|
|
1056
|
+
result: string;
|
|
928
1057
|
prompt: string;
|
|
929
1058
|
resourceId: string;
|
|
930
|
-
result: string;
|
|
931
1059
|
task: string;
|
|
932
1060
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
933
1061
|
iteration: number;
|
|
@@ -939,6 +1067,20 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
939
1067
|
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
940
1068
|
}>;
|
|
941
1069
|
|
|
1070
|
+
export declare function streamVNextGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
|
|
1071
|
+
runtimeContext: RuntimeContext;
|
|
1072
|
+
agentId: string;
|
|
1073
|
+
body: GetBody<'streamVNext'> & {
|
|
1074
|
+
runtimeContext?: string;
|
|
1075
|
+
};
|
|
1076
|
+
abortSignal?: AbortSignal;
|
|
1077
|
+
}): ReturnType<Agent['streamVNext']>;
|
|
1078
|
+
|
|
1079
|
+
export declare function streamVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
1080
|
+
inputData?: unknown;
|
|
1081
|
+
runtimeContext?: RuntimeContext_2;
|
|
1082
|
+
}): Promise<MastraWorkflowStream>;
|
|
1083
|
+
|
|
942
1084
|
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
943
1085
|
inputData?: unknown;
|
|
944
1086
|
runtimeContext?: RuntimeContext_2;
|
|
@@ -1096,6 +1238,7 @@ export declare namespace workflows {
|
|
|
1096
1238
|
startWorkflowRunHandler,
|
|
1097
1239
|
watchWorkflowHandler,
|
|
1098
1240
|
streamWorkflowHandler,
|
|
1241
|
+
streamVNextWorkflowHandler,
|
|
1099
1242
|
resumeAsyncWorkflowHandler,
|
|
1100
1243
|
resumeWorkflowHandler,
|
|
1101
1244
|
getWorkflowRunsHandler,
|
|
@@ -7,8 +7,8 @@ import { CoreMessage } from 'ai';
|
|
|
7
7
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
8
8
|
import { DefaultEngineType } from '@mastra/core';
|
|
9
9
|
import { EvalRow } from '@mastra/core';
|
|
10
|
-
import {
|
|
11
|
-
import { GenerateTextResult } from '
|
|
10
|
+
import type { GenerateReturn } from '@mastra/core/llm';
|
|
11
|
+
import { GenerateTextResult } from '@mastra/core';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
13
13
|
import type { JSONRPCError } from '@mastra/core/a2a';
|
|
14
14
|
import { JSONRPCResponse } from '@mastra/core/a2a';
|
|
@@ -21,17 +21,25 @@ import type { Mastra } from '@mastra/core/mastra';
|
|
|
21
21
|
import type { MastraError } from '@mastra/core/error';
|
|
22
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
23
23
|
import { MastraMessageV1 } from '@mastra/core';
|
|
24
|
+
import { MastraMessageV2 } from '@mastra/core';
|
|
25
|
+
import type { MastraScorerEntry } from '@mastra/core/scores';
|
|
26
|
+
import { MastraWorkflowStream } from '@mastra/core';
|
|
27
|
+
import { MemoryConfig } from '@mastra/core';
|
|
24
28
|
import type { Message } from '@mastra/core/a2a';
|
|
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';
|
|
@@ -42,6 +50,7 @@ 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';
|
|
44
52
|
import type { ToolAction } from '@mastra/core/tools';
|
|
53
|
+
import { Trace } from '@mastra/core';
|
|
45
54
|
import { UIMessage } from 'ai';
|
|
46
55
|
import type { VercelTool } from '@mastra/core/tools';
|
|
47
56
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
@@ -78,7 +87,8 @@ export declare namespace agents {
|
|
|
78
87
|
getEvalsByAgentIdHandler,
|
|
79
88
|
getLiveEvalsByAgentIdHandler,
|
|
80
89
|
generateHandler,
|
|
81
|
-
streamGenerateHandler
|
|
90
|
+
streamGenerateHandler,
|
|
91
|
+
streamVNextGenerateHandler
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
|
|
@@ -177,14 +187,14 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
|
|
|
177
187
|
runtimeContext?: Record<string, unknown>;
|
|
178
188
|
};
|
|
179
189
|
abortSignal?: AbortSignal;
|
|
180
|
-
}): Promise<GenerateTextResult<any,
|
|
190
|
+
}): Promise<GenerateTextResult<any, undefined>>;
|
|
181
191
|
|
|
182
192
|
export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
|
|
183
193
|
runtimeContext: RuntimeContext;
|
|
184
194
|
body: {
|
|
185
195
|
messages?: Parameters<AgentNetwork['generate']>[0];
|
|
186
196
|
} & Parameters<AgentNetwork['generate']>[1];
|
|
187
|
-
}): Promise<
|
|
197
|
+
}): Promise<GenerateReturn<any, any, any>>;
|
|
188
198
|
|
|
189
199
|
/**
|
|
190
200
|
* Generate speech from text
|
|
@@ -335,6 +345,10 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
|
|
|
335
345
|
transports: string[];
|
|
336
346
|
}>;
|
|
337
347
|
|
|
348
|
+
export declare function getMemoryConfigHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
349
|
+
config: MemoryConfig;
|
|
350
|
+
}>;
|
|
351
|
+
|
|
338
352
|
export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
339
353
|
result: boolean;
|
|
340
354
|
}>;
|
|
@@ -346,6 +360,10 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, n
|
|
|
346
360
|
uiMessages: UIMessage[];
|
|
347
361
|
}>;
|
|
348
362
|
|
|
363
|
+
export declare function getMessagesPaginatedHandler({ mastra, threadId, resourceId, selectBy, format, }: StorageGetMessagesArg & Pick<MemoryContext, 'mastra'>): Promise<PaginationInfo & {
|
|
364
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
365
|
+
}>;
|
|
366
|
+
|
|
349
367
|
export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
350
368
|
id: string;
|
|
351
369
|
name: string;
|
|
@@ -376,6 +394,50 @@ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<Net
|
|
|
376
394
|
};
|
|
377
395
|
}[]>;
|
|
378
396
|
|
|
397
|
+
export declare function getScorerHandler({ mastra, scorerId, runtimeContext, }: Context & {
|
|
398
|
+
scorerId: string;
|
|
399
|
+
runtimeContext: RuntimeContext;
|
|
400
|
+
}): Promise<(MastraScorerEntry & {
|
|
401
|
+
agentIds: string[];
|
|
402
|
+
workflowIds: string[];
|
|
403
|
+
}) | null>;
|
|
404
|
+
|
|
405
|
+
export declare function getScorersHandler({ mastra, runtimeContext }: Context & {
|
|
406
|
+
runtimeContext: RuntimeContext;
|
|
407
|
+
}): Promise<{
|
|
408
|
+
[k: string]: MastraScorerEntry & {
|
|
409
|
+
agentIds: string[];
|
|
410
|
+
workflowIds: string[];
|
|
411
|
+
};
|
|
412
|
+
}>;
|
|
413
|
+
|
|
414
|
+
export declare function getScoresByEntityIdHandler({ mastra, entityId, entityType, pagination, }: Context & {
|
|
415
|
+
entityId: string;
|
|
416
|
+
entityType: string;
|
|
417
|
+
pagination: StoragePagination;
|
|
418
|
+
}): Promise<never[] | {
|
|
419
|
+
pagination: PaginationInfo;
|
|
420
|
+
scores: ScoreRowData[];
|
|
421
|
+
}>;
|
|
422
|
+
|
|
423
|
+
export declare function getScoresByRunIdHandler({ mastra, runId, pagination, }: Context & {
|
|
424
|
+
runId: string;
|
|
425
|
+
pagination: StoragePagination;
|
|
426
|
+
}): Promise<never[] | {
|
|
427
|
+
pagination: PaginationInfo;
|
|
428
|
+
scores: ScoreRowData[];
|
|
429
|
+
}>;
|
|
430
|
+
|
|
431
|
+
export declare function getScoresByScorerIdHandler({ mastra, scorerId, pagination, entityId, entityType, }: Context & {
|
|
432
|
+
scorerId: string;
|
|
433
|
+
pagination: StoragePagination;
|
|
434
|
+
entityId?: string;
|
|
435
|
+
entityType?: string;
|
|
436
|
+
}): Promise<never[] | {
|
|
437
|
+
pagination: PaginationInfo;
|
|
438
|
+
scores: ScoreRowData[];
|
|
439
|
+
}>;
|
|
440
|
+
|
|
379
441
|
/**
|
|
380
442
|
* Get available speakers for an agent
|
|
381
443
|
*/
|
|
@@ -383,7 +445,7 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
|
|
|
383
445
|
voiceId: string;
|
|
384
446
|
}[]>;
|
|
385
447
|
|
|
386
|
-
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<
|
|
448
|
+
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<Trace[]>;
|
|
387
449
|
|
|
388
450
|
export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
|
|
389
451
|
|
|
@@ -673,18 +735,18 @@ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body,
|
|
|
673
735
|
completionReason: ZodOptional<ZodString>;
|
|
674
736
|
iteration: ZodNumber;
|
|
675
737
|
}, "strip", ZodTypeAny, {
|
|
738
|
+
result: string;
|
|
676
739
|
prompt: string;
|
|
677
740
|
resourceId: string;
|
|
678
|
-
result: string;
|
|
679
741
|
task: string;
|
|
680
742
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
681
743
|
iteration: number;
|
|
682
744
|
isComplete?: boolean | undefined;
|
|
683
745
|
completionReason?: string | undefined;
|
|
684
746
|
}, {
|
|
747
|
+
result: string;
|
|
685
748
|
prompt: string;
|
|
686
749
|
resourceId: string;
|
|
687
|
-
result: string;
|
|
688
750
|
task: string;
|
|
689
751
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
690
752
|
iteration: number;
|
|
@@ -701,8 +763,17 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
|
|
|
701
763
|
}): Promise<{
|
|
702
764
|
status: "success";
|
|
703
765
|
result: {
|
|
704
|
-
|
|
766
|
+
result: string;
|
|
767
|
+
prompt: string;
|
|
768
|
+
resourceId: string;
|
|
769
|
+
task: string;
|
|
770
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
705
771
|
iteration: number;
|
|
772
|
+
isOneOff: boolean;
|
|
773
|
+
threadId?: string | undefined;
|
|
774
|
+
threadResourceId?: string | undefined;
|
|
775
|
+
isComplete?: boolean | undefined;
|
|
776
|
+
completionReason?: string | undefined;
|
|
706
777
|
};
|
|
707
778
|
steps: {
|
|
708
779
|
[x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
|
|
@@ -712,15 +783,18 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
|
|
|
712
783
|
export declare namespace memory {
|
|
713
784
|
export {
|
|
714
785
|
getMemoryStatusHandler,
|
|
786
|
+
getMemoryConfigHandler,
|
|
715
787
|
getThreadsHandler,
|
|
716
788
|
getThreadByIdHandler,
|
|
717
789
|
saveMessagesHandler,
|
|
718
790
|
createThreadHandler,
|
|
719
791
|
updateThreadHandler,
|
|
720
792
|
deleteThreadHandler,
|
|
793
|
+
getMessagesPaginatedHandler,
|
|
721
794
|
getMessagesHandler,
|
|
722
795
|
getWorkingMemoryHandler,
|
|
723
|
-
updateWorkingMemoryHandler
|
|
796
|
+
updateWorkingMemoryHandler,
|
|
797
|
+
searchMemoryHandler
|
|
724
798
|
}
|
|
725
799
|
}
|
|
726
800
|
|
|
@@ -809,6 +883,60 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
|
|
|
809
883
|
};
|
|
810
884
|
}): Promise<MastraMessageV1[]>;
|
|
811
885
|
|
|
886
|
+
export declare function saveScoreHandler({ mastra, score }: Context & {
|
|
887
|
+
score: ScoreRowData;
|
|
888
|
+
}): Promise<never[] | {
|
|
889
|
+
score: ScoreRowData;
|
|
890
|
+
}>;
|
|
891
|
+
|
|
892
|
+
export declare namespace scores {
|
|
893
|
+
export {
|
|
894
|
+
getScorersHandler,
|
|
895
|
+
getScorerHandler,
|
|
896
|
+
getScoresByRunIdHandler,
|
|
897
|
+
getScoresByScorerIdHandler,
|
|
898
|
+
getScoresByEntityIdHandler,
|
|
899
|
+
saveScoreHandler
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Handler to search messages in a thread.
|
|
905
|
+
* @param searchQuery - the text to search for
|
|
906
|
+
* @param resourceId - the resource id (user/org) to validate thread ownership
|
|
907
|
+
* @param threadId - the thread id to search within
|
|
908
|
+
* @param limit - maximum number of results to return (default: 20)
|
|
909
|
+
*/
|
|
910
|
+
export declare function searchMemoryHandler({ mastra, agentId, searchQuery, resourceId, threadId, limit, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
|
|
911
|
+
searchQuery: string;
|
|
912
|
+
resourceId: string;
|
|
913
|
+
threadId?: string;
|
|
914
|
+
limit?: number;
|
|
915
|
+
memoryConfig?: any;
|
|
916
|
+
}): Promise<SearchResponse | ReturnType<typeof handleError>>;
|
|
917
|
+
|
|
918
|
+
declare interface SearchResponse {
|
|
919
|
+
results: SearchResult[];
|
|
920
|
+
count: number;
|
|
921
|
+
query: string;
|
|
922
|
+
searchScope?: string;
|
|
923
|
+
searchType?: string;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
declare interface SearchResult {
|
|
927
|
+
id: string;
|
|
928
|
+
role: string;
|
|
929
|
+
content: any;
|
|
930
|
+
createdAt: Date;
|
|
931
|
+
threadId?: string;
|
|
932
|
+
threadTitle?: string;
|
|
933
|
+
score?: number;
|
|
934
|
+
context?: {
|
|
935
|
+
before?: SearchResult[];
|
|
936
|
+
after?: SearchResult[];
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
|
|
812
940
|
export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
813
941
|
event: string;
|
|
814
942
|
data: unknown;
|
|
@@ -913,9 +1041,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
913
1041
|
threadResourceId: ZodOptional<ZodString>;
|
|
914
1042
|
isOneOff: ZodBoolean;
|
|
915
1043
|
}, "strip", ZodTypeAny, {
|
|
1044
|
+
result: string;
|
|
916
1045
|
prompt: string;
|
|
917
1046
|
resourceId: string;
|
|
918
|
-
result: string;
|
|
919
1047
|
task: string;
|
|
920
1048
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
921
1049
|
iteration: number;
|
|
@@ -925,9 +1053,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
925
1053
|
isComplete?: boolean | undefined;
|
|
926
1054
|
completionReason?: string | undefined;
|
|
927
1055
|
}, {
|
|
1056
|
+
result: string;
|
|
928
1057
|
prompt: string;
|
|
929
1058
|
resourceId: string;
|
|
930
|
-
result: string;
|
|
931
1059
|
task: string;
|
|
932
1060
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
933
1061
|
iteration: number;
|
|
@@ -939,6 +1067,20 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
939
1067
|
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
940
1068
|
}>;
|
|
941
1069
|
|
|
1070
|
+
export declare function streamVNextGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
|
|
1071
|
+
runtimeContext: RuntimeContext;
|
|
1072
|
+
agentId: string;
|
|
1073
|
+
body: GetBody<'streamVNext'> & {
|
|
1074
|
+
runtimeContext?: string;
|
|
1075
|
+
};
|
|
1076
|
+
abortSignal?: AbortSignal;
|
|
1077
|
+
}): ReturnType<Agent['streamVNext']>;
|
|
1078
|
+
|
|
1079
|
+
export declare function streamVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
1080
|
+
inputData?: unknown;
|
|
1081
|
+
runtimeContext?: RuntimeContext_2;
|
|
1082
|
+
}): Promise<MastraWorkflowStream>;
|
|
1083
|
+
|
|
942
1084
|
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
943
1085
|
inputData?: unknown;
|
|
944
1086
|
runtimeContext?: RuntimeContext_2;
|
|
@@ -1096,6 +1238,7 @@ export declare namespace workflows {
|
|
|
1096
1238
|
startWorkflowRunHandler,
|
|
1097
1239
|
watchWorkflowHandler,
|
|
1098
1240
|
streamWorkflowHandler,
|
|
1241
|
+
streamVNextWorkflowHandler,
|
|
1099
1242
|
resumeAsyncWorkflowHandler,
|
|
1100
1243
|
resumeWorkflowHandler,
|
|
1101
1244
|
getWorkflowRunsHandler,
|
|
@@ -19,6 +19,7 @@ __export(workflows_exports, {
|
|
|
19
19
|
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
20
20
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
21
21
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
22
|
+
streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
|
|
22
23
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
23
24
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
24
25
|
});
|
|
@@ -340,6 +341,34 @@ async function streamWorkflowHandler({
|
|
|
340
341
|
return handleError(error, "Error executing workflow");
|
|
341
342
|
}
|
|
342
343
|
}
|
|
344
|
+
async function streamVNextWorkflowHandler({
|
|
345
|
+
mastra,
|
|
346
|
+
runtimeContext,
|
|
347
|
+
workflowId,
|
|
348
|
+
runId,
|
|
349
|
+
inputData
|
|
350
|
+
}) {
|
|
351
|
+
try {
|
|
352
|
+
if (!workflowId) {
|
|
353
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
354
|
+
}
|
|
355
|
+
if (!runId) {
|
|
356
|
+
throw new HTTPException(400, { message: "runId required to stream workflow" });
|
|
357
|
+
}
|
|
358
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
359
|
+
if (!workflow) {
|
|
360
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
361
|
+
}
|
|
362
|
+
const run = await workflow.createRunAsync({ runId });
|
|
363
|
+
const result = run.streamVNext({
|
|
364
|
+
inputData,
|
|
365
|
+
runtimeContext
|
|
366
|
+
});
|
|
367
|
+
return result;
|
|
368
|
+
} catch (error) {
|
|
369
|
+
return handleError(error, "Error streaming workflow");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
343
372
|
async function resumeAsyncWorkflowHandler({
|
|
344
373
|
mastra,
|
|
345
374
|
workflowId,
|
|
@@ -495,4 +524,4 @@ async function sendWorkflowRunEventHandler({
|
|
|
495
524
|
}
|
|
496
525
|
}
|
|
497
526
|
|
|
498
|
-
export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
|
527
|
+
export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamVNextWorkflowHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|