@mastra/server 0.10.7-alpha.1 → 0.10.7-alpha.3

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 +162 -22
  2. package/dist/_tsup-dts-rollup.d.ts +162 -22
  3. package/dist/{chunk-WE32JG64.cjs → chunk-4DTDPTQC.cjs} +7 -7
  4. package/dist/{chunk-NGURCFEJ.cjs → chunk-CPPYMJX5.cjs} +5 -5
  5. package/dist/{chunk-FYCCJXBC.cjs → chunk-GKM45O24.cjs} +13 -9
  6. package/dist/{chunk-ASKESBJW.cjs → chunk-MN6F4D5A.cjs} +35 -35
  7. package/dist/{chunk-CLYX4KLH.js → chunk-N2YBMSO2.js} +1 -1
  8. package/dist/{chunk-TGJMNUYJ.js → chunk-OSZM4EAY.js} +35 -35
  9. package/dist/{chunk-GPRXMWEQ.js → chunk-PMUATKV2.js} +9 -5
  10. package/dist/{chunk-6TJSHFCJ.cjs → chunk-RQ2Z56EC.cjs} +50 -20
  11. package/dist/{chunk-JKTNRUKY.js → chunk-SOBBILUG.js} +13 -49
  12. package/dist/{chunk-FRXZL32L.cjs → chunk-TO5U6HW3.cjs} +25 -61
  13. package/dist/{chunk-2HXKRRNS.js → chunk-XR7VJOOP.js} +1 -1
  14. package/dist/{chunk-I7KJZNX5.js → chunk-XUIJ7WRT.js} +50 -20
  15. package/dist/server/handlers/agents.cjs +7 -7
  16. package/dist/server/handlers/agents.js +1 -1
  17. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  18. package/dist/server/handlers/legacyWorkflows.js +1 -1
  19. package/dist/server/handlers/memory.cjs +9 -9
  20. package/dist/server/handlers/memory.js +1 -1
  21. package/dist/server/handlers/tools.cjs +5 -5
  22. package/dist/server/handlers/tools.js +1 -1
  23. package/dist/server/handlers/vNextNetwork.cjs +175 -0
  24. package/dist/server/handlers/vNextNetwork.d.cts +5 -0
  25. package/dist/server/handlers/vNextNetwork.d.ts +5 -0
  26. package/dist/server/handlers/vNextNetwork.js +169 -0
  27. package/dist/server/handlers/workflows.cjs +13 -13
  28. package/dist/server/handlers/workflows.js +1 -1
  29. package/dist/server/handlers.cjs +10 -10
  30. package/dist/server/handlers.js +5 -5
  31. package/package.json +5 -5
@@ -5,6 +5,7 @@ import type { Artifact } from '@mastra/core/a2a';
5
5
  import type { BaseLogMessage } from '@mastra/core/logger';
6
6
  import { CoreMessage } from 'ai';
7
7
  import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
8
+ import { DefaultEngineType } from '@mastra/core/workflows';
8
9
  import { EvalRow } from '@mastra/core/storage';
9
10
  import { GenerateObjectResult } from 'ai';
10
11
  import { GenerateTextResult } from 'ai';
@@ -22,12 +23,14 @@ import { MastraMessageV1 } from '@mastra/core/memory';
22
23
  import type { Message } from '@mastra/core/a2a';
23
24
  import type { QueryResult } from '@mastra/core/vector';
24
25
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
26
+ import { ReadableStream as ReadableStream_3 } from 'stream/web';
25
27
  import { RuntimeContext } from '@mastra/core/runtime-context';
26
28
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
27
29
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
28
30
  import { Step } from '@mastra/core/workflows';
29
31
  import { StepExecutionContext } from '@mastra/core/workflows/legacy';
30
32
  import { StepGraph } from '@mastra/core/workflows/legacy';
33
+ import { StepResult } from '@mastra/core/workflows';
31
34
  import { StorageThreadType } from '@mastra/core/memory';
32
35
  import { StreamEvent } from '@mastra/core/workflows';
33
36
  import { Task } from '@mastra/core/a2a';
@@ -45,7 +48,14 @@ import type { Workflow } from '@mastra/core/workflows';
45
48
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
46
49
  import { WorkflowResult } from '@mastra/core/workflows';
47
50
  import type { WorkflowRuns } from '@mastra/core/storage';
51
+ import { ZodBoolean } from 'zod';
52
+ import { ZodEnum } from 'zod';
53
+ import { ZodNumber } from 'zod';
54
+ import { ZodObject } from 'zod';
55
+ import { ZodOptional } from 'zod';
56
+ import { ZodString } from 'zod';
48
57
  import { ZodType } from 'zod';
58
+ import { ZodTypeAny } from 'zod';
49
59
  import { ZodTypeDef } from 'zod';
50
60
 
51
61
  export declare namespace a2a {
@@ -112,7 +122,7 @@ export declare function createTaskContext({ task, userMessage, history, activeCa
112
122
  activeCancellations: Set<string>;
113
123
  }): TaskContext;
114
124
 
115
- export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
125
+ export declare function createThreadHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
116
126
  body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
117
127
  resourceId?: string;
118
128
  };
@@ -128,7 +138,7 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
128
138
  success: boolean;
129
139
  }>;
130
140
 
131
- export declare function deleteThreadHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
141
+ export declare function deleteThreadHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<{
132
142
  result: string;
133
143
  }>;
134
144
 
@@ -153,13 +163,14 @@ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mas
153
163
  runtimeContext: RuntimeContext_2;
154
164
  }) => Promise<any>;
155
165
 
156
- export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
166
+ export declare function generateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
157
167
  runtimeContext: RuntimeContext;
158
168
  agentId: string;
159
169
  body: GetBody<'generate'> & {
160
170
  resourceid?: string;
161
171
  runtimeContext?: Record<string, unknown>;
162
172
  };
173
+ abortSignal?: AbortSignal;
163
174
  }): Promise<GenerateTextResult<any, unknown>>;
164
175
 
165
176
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
@@ -179,6 +190,20 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
179
190
  };
180
191
  }): Promise<NodeJS.ReadableStream>;
181
192
 
193
+ export declare function generateVNextNetworkHandler({ mastra, runtimeContext, networkId, body, }: NetworkContext_2 & {
194
+ runtimeContext: RuntimeContext;
195
+ body: {
196
+ message: string;
197
+ threadId?: string;
198
+ resourceId?: string;
199
+ };
200
+ }): Promise<{
201
+ task: string;
202
+ result: string;
203
+ resourceId: string;
204
+ resourceType: "none" | "tool" | "workflow" | "agent";
205
+ }>;
206
+
182
207
  export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
183
208
  isPlayground?: boolean;
184
209
  runtimeContext: RuntimeContext;
@@ -217,7 +242,17 @@ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, r
217
242
 
218
243
  export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
219
244
  runtimeContext: RuntimeContext;
220
- }): Promise<any>;
245
+ }): Promise<Record<string, Omit<{
246
+ id: string;
247
+ name: any;
248
+ instructions: string;
249
+ tools: any;
250
+ workflows: {};
251
+ provider: string;
252
+ modelId: string;
253
+ defaultGenerateOptions: any;
254
+ defaultStreamOptions: any;
255
+ }, "id">>>;
221
256
 
222
257
  declare type GetBody<T extends keyof Agent & {
223
258
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -294,11 +329,11 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
294
329
  transports: string[];
295
330
  }>;
296
331
 
297
- export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryContext, 'mastra' | 'agentId'>): Promise<{
332
+ export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
298
333
  result: boolean;
299
334
  }>;
300
335
 
301
- export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
336
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
302
337
  limit?: number;
303
338
  }): Promise<{
304
339
  messages: CoreMessage[];
@@ -344,14 +379,56 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
344
379
 
345
380
  export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
346
381
 
347
- export declare function getThreadByIdHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<StorageThreadType>;
382
+ export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
348
383
 
349
- export declare function getThreadsHandler({ mastra, agentId, resourceId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId'>): Promise<StorageThreadType[]>;
384
+ export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType[]>;
350
385
 
351
386
  export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
352
387
 
353
388
  export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
354
389
 
390
+ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
391
+ id: string;
392
+ name: string;
393
+ instructions: string;
394
+ agents: {
395
+ name: string;
396
+ provider: string;
397
+ modelId: string;
398
+ }[];
399
+ workflows: {
400
+ name: string | undefined;
401
+ description: string | undefined;
402
+ inputSchema: string | undefined;
403
+ outputSchema: string | undefined;
404
+ }[];
405
+ routingModel: {
406
+ provider: string;
407
+ modelId: string;
408
+ };
409
+ }>;
410
+
411
+ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'runtimeContext'>): Promise<{
412
+ id: string;
413
+ name: string;
414
+ instructions: string;
415
+ agents: {
416
+ name: string;
417
+ provider: string;
418
+ modelId: string;
419
+ }[];
420
+ workflows: {
421
+ name: string | undefined;
422
+ description: string | undefined;
423
+ inputSchema: string | undefined;
424
+ outputSchema: string | undefined;
425
+ }[];
426
+ routingModel: {
427
+ provider: string;
428
+ modelId: string;
429
+ };
430
+ }[]>;
431
+
355
432
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
356
433
  steps: SerializedStep[];
357
434
  name: string | undefined;
@@ -544,6 +621,22 @@ declare type LogsContext = {
544
621
  };
545
622
  };
546
623
 
624
+ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
625
+ runtimeContext: RuntimeContext;
626
+ body: {
627
+ message: string;
628
+ };
629
+ }): Promise<{
630
+ status: "success";
631
+ result: {
632
+ text: string;
633
+ iteration: number;
634
+ };
635
+ steps: {
636
+ [x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
637
+ };
638
+ }>;
639
+
547
640
  export declare namespace memory {
548
641
  export {
549
642
  getMemoryStatusHandler,
@@ -561,6 +654,8 @@ declare interface MemoryContext extends Context {
561
654
  agentId?: string;
562
655
  resourceId?: string;
563
656
  threadId?: string;
657
+ networkId?: string;
658
+ runtimeContext?: RuntimeContext_2;
564
659
  }
565
660
 
566
661
  export declare namespace network {
@@ -577,6 +672,11 @@ declare interface NetworkContext extends Context {
577
672
  runtimeContext: RuntimeContext;
578
673
  }
579
674
 
675
+ declare interface NetworkContext_2 extends Context {
676
+ networkId?: string;
677
+ runtimeContext: RuntimeContext;
678
+ }
679
+
580
680
  export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: IMastraLogger): JSONRPCResponse<null, unknown>;
581
681
 
582
682
  declare interface QueryRequest {
@@ -601,12 +701,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
601
701
  runtimeContext: RuntimeContext;
602
702
  }): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
603
703
 
604
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
704
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
605
705
  body: {
606
706
  step: string | string[];
607
707
  resumeData?: unknown;
608
708
  };
609
- runtimeContext?: Record<string, any>;
709
+ runtimeContext?: RuntimeContext_2;
610
710
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
611
711
 
612
712
  export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
@@ -619,17 +719,17 @@ export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId,
619
719
  message: string;
620
720
  }>;
621
721
 
622
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext: payloadRuntimeContext, }: WorkflowContext_3 & {
722
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
623
723
  body: {
624
724
  step: string | string[];
625
725
  resumeData?: unknown;
626
726
  };
627
- runtimeContext?: Record<string, any>;
727
+ runtimeContext?: RuntimeContext_2;
628
728
  }): Promise<{
629
729
  message: string;
630
730
  }>;
631
731
 
632
- export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
732
+ export declare function saveMessagesHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
633
733
  body: {
634
734
  messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];
635
735
  };
@@ -651,9 +751,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
651
751
  runtimeContext: RuntimeContext;
652
752
  }): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
653
753
 
654
- export declare function startAsyncWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
754
+ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
655
755
  inputData?: unknown;
656
- runtimeContext?: Record<string, any>;
756
+ runtimeContext?: RuntimeContext_2;
657
757
  }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
658
758
 
659
759
  export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
@@ -663,9 +763,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
663
763
  message: string;
664
764
  }>;
665
765
 
666
- export declare function startWorkflowRunHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
766
+ export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
667
767
  inputData?: unknown;
668
- runtimeContext?: Record<string, any>;
768
+ runtimeContext?: RuntimeContext_2;
669
769
  }): Promise<{
670
770
  message: string;
671
771
  }>;
@@ -693,13 +793,14 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
693
793
  traceCount: number;
694
794
  }>;
695
795
 
696
- export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
796
+ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
697
797
  runtimeContext: RuntimeContext;
698
798
  agentId: string;
699
799
  body: GetBody<'stream'> & {
700
800
  resourceid?: string;
701
801
  runtimeContext?: string;
702
802
  };
803
+ abortSignal?: AbortSignal;
703
804
  }): Promise<Response | undefined>;
704
805
 
705
806
  export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, runtimeContext, }: NetworkContext & {
@@ -709,11 +810,50 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
709
810
  } & Parameters<AgentNetwork['stream']>[1];
710
811
  }): Promise<Response>;
711
812
 
712
- export declare function streamWorkflowHandler({ mastra, runtimeContext: payloadRuntimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
813
+ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
814
+ runtimeContext: RuntimeContext;
815
+ body: {
816
+ message: string;
817
+ threadId?: string;
818
+ resourceId?: string;
819
+ };
820
+ }): Promise<{
821
+ stream: ReadableStream_3<StreamEvent>;
822
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
823
+ task: ZodString;
824
+ resourceId: ZodString;
825
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
826
+ prompt: ZodString;
827
+ result: ZodString;
828
+ isComplete: ZodOptional<ZodBoolean>;
829
+ completionReason: ZodOptional<ZodString>;
830
+ iteration: ZodNumber;
831
+ }, "strip", ZodTypeAny, {
832
+ prompt: string;
833
+ resourceId: string;
834
+ result: string;
835
+ task: string;
836
+ resourceType: "none" | "tool" | "workflow" | "agent";
837
+ iteration: number;
838
+ isComplete?: boolean | undefined;
839
+ completionReason?: string | undefined;
840
+ }, {
841
+ prompt: string;
842
+ resourceId: string;
843
+ result: string;
844
+ task: string;
845
+ resourceType: "none" | "tool" | "workflow" | "agent";
846
+ iteration: number;
847
+ isComplete?: boolean | undefined;
848
+ completionReason?: string | undefined;
849
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
850
+ }>;
851
+
852
+ export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
713
853
  inputData?: unknown;
714
- runtimeContext?: Record<string, any>;
854
+ runtimeContext?: RuntimeContext_2;
715
855
  }): Promise<{
716
- stream: globalThis.ReadableStream<StreamEvent>;
856
+ stream: ReadableStream_2<StreamEvent>;
717
857
  getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
718
858
  }>;
719
859
 
@@ -783,7 +923,7 @@ export declare type UnOfficalStatusCode = UnofficialStatusCode;
783
923
  */
784
924
  export declare type UnofficialStatusCode = -1;
785
925
 
786
- export declare function updateThreadHandler({ mastra, agentId, threadId, body, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
926
+ export declare function updateThreadHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
787
927
  body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
788
928
  }): Promise<StorageThreadType>;
789
929