@mastra/server 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-tool-call-parts-20250630193309

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 (41) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +252 -35
  2. package/dist/_tsup-dts-rollup.d.ts +252 -35
  3. package/dist/{chunk-J3PKLB3A.js → chunk-2BCWG3EZ.js} +52 -13
  4. package/dist/{chunk-KUNQFY2W.js → chunk-72LOJGUV.js} +106 -50
  5. package/dist/{chunk-W7VCKPAD.js → chunk-E2LP4J6K.js} +2 -2
  6. package/dist/{chunk-A3KDUGS7.cjs → chunk-EP3XVEVC.cjs} +56 -17
  7. package/dist/{chunk-TJKLBTFB.js → chunk-EWLR2PNT.js} +7 -17
  8. package/dist/{chunk-NEOOQUKW.cjs → chunk-IMBY5XUG.cjs} +36 -4
  9. package/dist/{chunk-MMO2HDM6.cjs → chunk-L3VURYKY.cjs} +117 -60
  10. package/dist/{chunk-YWLUOY3D.cjs → chunk-LI436ITD.cjs} +107 -69
  11. package/dist/{chunk-LIVAK2DM.js → chunk-MEGCYGBU.js} +108 -70
  12. package/dist/{chunk-YIOVBYZH.cjs → chunk-NGHSYB5B.cjs} +7 -7
  13. package/dist/{chunk-DQLE3DVM.js → chunk-QLG2PFHE.js} +36 -4
  14. package/dist/{chunk-CP55EVBK.js → chunk-R5VGYBV6.js} +12 -8
  15. package/dist/{chunk-Y7UWRW5X.cjs → chunk-RQ2Z56EC.cjs} +51 -21
  16. package/dist/{chunk-CMMOIUFC.cjs → chunk-WJY57THV.cjs} +12 -8
  17. package/dist/{chunk-DJJIUEL2.js → chunk-XUIJ7WRT.js} +51 -21
  18. package/dist/{chunk-ZE5AAC4I.cjs → chunk-Z3PTO2AK.cjs} +11 -21
  19. package/dist/server/handlers/agents.cjs +7 -7
  20. package/dist/server/handlers/agents.js +1 -1
  21. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  22. package/dist/server/handlers/legacyWorkflows.js +1 -1
  23. package/dist/server/handlers/logs.cjs +4 -4
  24. package/dist/server/handlers/logs.js +1 -1
  25. package/dist/server/handlers/memory.cjs +9 -9
  26. package/dist/server/handlers/memory.js +1 -1
  27. package/dist/server/handlers/tools.cjs +5 -5
  28. package/dist/server/handlers/tools.js +1 -1
  29. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  30. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  31. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  32. package/dist/server/handlers/vNextNetwork.js +211 -0
  33. package/dist/server/handlers/voice.cjs +5 -5
  34. package/dist/server/handlers/voice.js +1 -1
  35. package/dist/server/handlers/workflows.cjs +16 -12
  36. package/dist/server/handlers/workflows.d.cts +1 -0
  37. package/dist/server/handlers/workflows.d.ts +1 -0
  38. package/dist/server/handlers/workflows.js +1 -1
  39. package/dist/server/handlers.cjs +14 -14
  40. package/dist/server/handlers.js +7 -7
  41. package/package.json +12 -13
@@ -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';
@@ -15,19 +16,23 @@ import { LegacyStep } from '@mastra/core/workflows/legacy';
15
16
  import type { LegacyWorkflow } from '@mastra/core/workflows/legacy';
16
17
  import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
17
18
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
19
+ import type { LogLevel } from '@mastra/core/logger';
18
20
  import type { Mastra } from '@mastra/core/mastra';
19
21
  import type { MastraMemory } from '@mastra/core/memory';
20
22
  import { MastraMessageV1 } from '@mastra/core/memory';
21
23
  import type { Message } from '@mastra/core/a2a';
22
24
  import type { QueryResult } from '@mastra/core/vector';
23
25
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
26
+ import { ReadableStream as ReadableStream_3 } from 'stream/web';
24
27
  import { RuntimeContext } from '@mastra/core/runtime-context';
25
- import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
28
+ import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
26
29
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
27
30
  import { Step } from '@mastra/core/workflows';
28
31
  import { StepExecutionContext } from '@mastra/core/workflows/legacy';
29
32
  import { StepGraph } from '@mastra/core/workflows/legacy';
33
+ import { StepResult } from '@mastra/core/workflows';
30
34
  import { StorageThreadType } from '@mastra/core/memory';
35
+ import { StreamEvent } from '@mastra/core/workflows';
31
36
  import { Task } from '@mastra/core/a2a';
32
37
  import { TaskAndHistory } from '@mastra/core/a2a';
33
38
  import type { TaskContext } from '@mastra/core/a2a';
@@ -38,12 +43,19 @@ import type { TaskStatus } from '@mastra/core/a2a';
38
43
  import type { ToolAction } from '@mastra/core/tools';
39
44
  import { UIMessage } from 'ai';
40
45
  import type { VercelTool } from '@mastra/core/tools';
41
- import { WatchEvent } from '@mastra/core/workflows';
46
+ import type { WatchEvent } from '@mastra/core/workflows';
42
47
  import type { Workflow } from '@mastra/core/workflows';
43
48
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
44
49
  import { WorkflowResult } from '@mastra/core/workflows';
45
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';
46
57
  import { ZodType } from 'zod';
58
+ import { ZodTypeAny } from 'zod';
47
59
  import { ZodTypeDef } from 'zod';
48
60
 
49
61
  export declare namespace a2a {
@@ -110,7 +122,7 @@ export declare function createTaskContext({ task, userMessage, history, activeCa
110
122
  activeCancellations: Set<string>;
111
123
  }): TaskContext;
112
124
 
113
- 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'> & {
114
126
  body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
115
127
  resourceId?: string;
116
128
  };
@@ -126,7 +138,7 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
126
138
  success: boolean;
127
139
  }>;
128
140
 
129
- 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<{
130
142
  result: string;
131
143
  }>;
132
144
 
@@ -140,27 +152,26 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
140
152
  metric: string | undefined;
141
153
  }>;
142
154
 
143
- export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
155
+ export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
144
156
  agentId?: string;
145
157
  data: any;
146
158
  runtimeContext: RuntimeContext_2;
147
- runtimeContextFromRequest: Record<string, unknown>;
148
159
  }): Promise<any>;
149
160
 
150
- export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, runtimeContextFromRequest, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
161
+ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
151
162
  data?: unknown;
152
163
  runtimeContext: RuntimeContext_2;
153
- runtimeContextFromRequest: Record<string, unknown>;
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
  };
163
- }): Promise<GenerateTextResult<any, any>>;
173
+ abortSignal?: AbortSignal;
174
+ }): Promise<GenerateTextResult<any, unknown>>;
164
175
 
165
176
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
166
177
  runtimeContext: RuntimeContext;
@@ -179,7 +190,22 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
179
190
  };
180
191
  }): Promise<NodeJS.ReadableStream>;
181
192
 
182
- export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
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
+
207
+ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
208
+ isPlayground?: boolean;
183
209
  runtimeContext: RuntimeContext;
184
210
  agentId: string;
185
211
  }): Promise<{
@@ -216,7 +242,17 @@ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, r
216
242
 
217
243
  export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
218
244
  runtimeContext: RuntimeContext;
219
- }): 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">>>;
220
256
 
221
257
  declare type GetBody<T extends keyof Agent & {
222
258
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -273,19 +309,31 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, a
273
309
  evals: EvalRow[];
274
310
  }>;
275
311
 
276
- export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<any[]>;
312
+ export declare function getLogsByRunIdHandler({ mastra, runId, transportId, params, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId' | 'params'>): Promise<{
313
+ logs: BaseLogMessage[];
314
+ total: number;
315
+ page: number;
316
+ perPage: number;
317
+ hasMore: boolean;
318
+ }>;
277
319
 
278
- export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
320
+ export declare function getLogsHandler({ mastra, transportId, params, }: Pick<LogsContext, 'mastra' | 'transportId' | 'params'>): Promise<{
321
+ logs: BaseLogMessage[];
322
+ total: number;
323
+ page: number;
324
+ perPage: number;
325
+ hasMore: boolean;
326
+ }>;
279
327
 
280
328
  export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
281
329
  transports: string[];
282
330
  }>;
283
331
 
284
- 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<{
285
333
  result: boolean;
286
334
  }>;
287
335
 
288
- 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'> & {
289
337
  limit?: number;
290
338
  }): Promise<{
291
339
  messages: CoreMessage[];
@@ -331,14 +379,64 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
331
379
 
332
380
  export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
333
381
 
334
- 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>;
335
383
 
336
- 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[]>;
337
385
 
338
386
  export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
339
387
 
340
388
  export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
341
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
+ tools: {
406
+ id: string;
407
+ description: string;
408
+ }[];
409
+ routingModel: {
410
+ provider: string;
411
+ modelId: string;
412
+ };
413
+ }>;
414
+
415
+ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'runtimeContext'>): Promise<{
416
+ id: string;
417
+ name: string;
418
+ instructions: string;
419
+ tools: {
420
+ id: string;
421
+ description: string;
422
+ }[];
423
+ agents: {
424
+ name: string;
425
+ provider: string;
426
+ modelId: string;
427
+ }[];
428
+ workflows: {
429
+ name: string | undefined;
430
+ description: string | undefined;
431
+ inputSchema: string | undefined;
432
+ outputSchema: string | undefined;
433
+ }[];
434
+ routingModel: {
435
+ provider: string;
436
+ modelId: string;
437
+ };
438
+ }[]>;
439
+
342
440
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
343
441
  steps: SerializedStep[];
344
442
  name: string | undefined;
@@ -350,6 +448,8 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
350
448
 
351
449
  export declare function getWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>>;
352
450
 
451
+ export declare function getWorkflowRunExecutionResultHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']>;
452
+
353
453
  export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext_3 & {
354
454
  fromDate?: Date;
355
455
  toDate?: Date;
@@ -519,8 +619,72 @@ declare type LogsContext = {
519
619
  mastra: Mastra;
520
620
  transportId?: string;
521
621
  runId?: string;
622
+ params?: {
623
+ fromDate?: Date;
624
+ toDate?: Date;
625
+ logLevel?: LogLevel;
626
+ filters?: string | string[];
627
+ page?: number;
628
+ perPage?: number;
629
+ };
522
630
  };
523
631
 
632
+ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
633
+ runtimeContext: RuntimeContext;
634
+ body: {
635
+ message: string;
636
+ threadId?: string;
637
+ resourceId?: string;
638
+ maxIterations?: number;
639
+ };
640
+ }): Promise<{
641
+ stream: ReadableStream_3<StreamEvent>;
642
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
643
+ task: ZodString;
644
+ resourceId: ZodString;
645
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
646
+ prompt: ZodString;
647
+ result: ZodString;
648
+ isComplete: ZodOptional<ZodBoolean>;
649
+ completionReason: ZodOptional<ZodString>;
650
+ iteration: ZodNumber;
651
+ }, "strip", ZodTypeAny, {
652
+ prompt: string;
653
+ resourceId: string;
654
+ result: string;
655
+ task: string;
656
+ resourceType: "none" | "tool" | "workflow" | "agent";
657
+ iteration: number;
658
+ isComplete?: boolean | undefined;
659
+ completionReason?: string | undefined;
660
+ }, {
661
+ prompt: string;
662
+ resourceId: string;
663
+ result: string;
664
+ task: string;
665
+ resourceType: "none" | "tool" | "workflow" | "agent";
666
+ iteration: number;
667
+ isComplete?: boolean | undefined;
668
+ completionReason?: string | undefined;
669
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
670
+ }>;
671
+
672
+ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
673
+ runtimeContext: RuntimeContext;
674
+ body: {
675
+ message: string;
676
+ };
677
+ }): Promise<{
678
+ status: "success";
679
+ result: {
680
+ text: string;
681
+ iteration: number;
682
+ };
683
+ steps: {
684
+ [x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
685
+ };
686
+ }>;
687
+
524
688
  export declare namespace memory {
525
689
  export {
526
690
  getMemoryStatusHandler,
@@ -538,6 +702,8 @@ declare interface MemoryContext extends Context {
538
702
  agentId?: string;
539
703
  resourceId?: string;
540
704
  threadId?: string;
705
+ networkId?: string;
706
+ runtimeContext?: RuntimeContext_2;
541
707
  }
542
708
 
543
709
  export declare namespace network {
@@ -554,6 +720,11 @@ declare interface NetworkContext extends Context {
554
720
  runtimeContext: RuntimeContext;
555
721
  }
556
722
 
723
+ declare interface NetworkContext_2 extends Context {
724
+ networkId?: string;
725
+ runtimeContext: RuntimeContext;
726
+ }
727
+
557
728
  export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: IMastraLogger): JSONRPCResponse<null, unknown>;
558
729
 
559
730
  declare interface QueryRequest {
@@ -578,14 +749,13 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
578
749
  runtimeContext: RuntimeContext;
579
750
  }): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
580
751
 
581
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, runtimeContextFromRequest, }: WorkflowContext_3 & {
752
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
582
753
  body: {
583
754
  step: string | string[];
584
755
  resumeData?: unknown;
585
756
  };
586
757
  runtimeContext?: RuntimeContext_2;
587
- runtimeContextFromRequest?: Record<string, unknown>;
588
- }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
758
+ }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
589
759
 
590
760
  export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
591
761
  body: {
@@ -607,7 +777,7 @@ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body,
607
777
  message: string;
608
778
  }>;
609
779
 
610
- export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
780
+ export declare function saveMessagesHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
611
781
  body: {
612
782
  messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];
613
783
  };
@@ -629,11 +799,10 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
629
799
  runtimeContext: RuntimeContext;
630
800
  }): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
631
801
 
632
- export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
802
+ export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
633
803
  inputData?: unknown;
634
804
  runtimeContext?: RuntimeContext_2;
635
- runtimeContextFromRequest?: Record<string, unknown>;
636
- }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
805
+ }): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
637
806
 
638
807
  export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
639
808
  triggerData?: unknown;
@@ -642,10 +811,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
642
811
  message: string;
643
812
  }>;
644
813
 
645
- export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
814
+ export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
646
815
  inputData?: unknown;
647
816
  runtimeContext?: RuntimeContext_2;
648
- runtimeContextFromRequest?: Record<string, unknown>;
649
817
  }): Promise<{
650
818
  message: string;
651
819
  }>;
@@ -673,13 +841,14 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
673
841
  traceCount: number;
674
842
  }>;
675
843
 
676
- export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
844
+ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
677
845
  runtimeContext: RuntimeContext;
678
846
  agentId: string;
679
847
  body: GetBody<'stream'> & {
680
848
  resourceid?: string;
681
849
  runtimeContext?: string;
682
850
  };
851
+ abortSignal?: AbortSignal;
683
852
  }): Promise<Response | undefined>;
684
853
 
685
854
  export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, runtimeContext, }: NetworkContext & {
@@ -689,14 +858,61 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
689
858
  } & Parameters<AgentNetwork['stream']>[1];
690
859
  }): Promise<Response>;
691
860
 
692
- export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
861
+ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
862
+ runtimeContext: RuntimeContext;
863
+ body: {
864
+ message: string;
865
+ threadId?: string;
866
+ resourceId?: string;
867
+ };
868
+ }): Promise<{
869
+ stream: ReadableStream_3<StreamEvent>;
870
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
871
+ task: ZodString;
872
+ resourceId: ZodString;
873
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
874
+ prompt: ZodString;
875
+ result: ZodString;
876
+ isComplete: ZodOptional<ZodBoolean>;
877
+ completionReason: ZodOptional<ZodString>;
878
+ iteration: ZodNumber;
879
+ threadId: ZodOptional<ZodString>;
880
+ threadResourceId: ZodOptional<ZodString>;
881
+ isOneOff: ZodBoolean;
882
+ }, "strip", ZodTypeAny, {
883
+ prompt: string;
884
+ resourceId: string;
885
+ result: string;
886
+ task: string;
887
+ resourceType: "none" | "tool" | "workflow" | "agent";
888
+ iteration: number;
889
+ isOneOff: boolean;
890
+ threadId?: string | undefined;
891
+ threadResourceId?: string | undefined;
892
+ isComplete?: boolean | undefined;
893
+ completionReason?: string | undefined;
894
+ }, {
895
+ prompt: string;
896
+ resourceId: string;
897
+ result: string;
898
+ task: string;
899
+ resourceType: "none" | "tool" | "workflow" | "agent";
900
+ iteration: number;
901
+ isOneOff: boolean;
902
+ threadId?: string | undefined;
903
+ threadResourceId?: string | undefined;
904
+ isComplete?: boolean | undefined;
905
+ completionReason?: string | undefined;
906
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
907
+ }>;
908
+
909
+ export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
693
910
  inputData?: unknown;
694
911
  runtimeContext?: RuntimeContext_2;
695
- runtimeContextFromRequest?: Record<string, unknown>;
696
- }): {
697
- stream: globalThis.ReadableStream<WatchEvent>;
698
- getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
699
- };
912
+ }): Promise<{
913
+ stream: ReadableStream_2<StreamEvent>;
914
+ getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
915
+ }>;
700
916
 
701
917
  declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
702
918
 
@@ -764,7 +980,7 @@ export declare type UnOfficalStatusCode = UnofficialStatusCode;
764
980
  */
765
981
  export declare type UnofficialStatusCode = -1;
766
982
 
767
- export declare function updateThreadHandler({ mastra, agentId, threadId, body, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
983
+ export declare function updateThreadHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
768
984
  body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
769
985
  }): Promise<StorageThreadType>;
770
986
 
@@ -830,6 +1046,7 @@ export declare namespace workflows {
830
1046
  getWorkflowsHandler,
831
1047
  getWorkflowByIdHandler,
832
1048
  getWorkflowRunByIdHandler,
1049
+ getWorkflowRunExecutionResultHandler,
833
1050
  createWorkflowRunHandler,
834
1051
  startAsyncWorkflowHandler,
835
1052
  startWorkflowRunHandler,
@@ -1,4 +1,4 @@
1
- import { stringify, esm_default } from './chunk-LIVAK2DM.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
2
  import { validateBody } from './chunk-H5PTF3Y4.js';
3
3
  import { handleError } from './chunk-M5ABIP7D.js';
4
4
  import { HTTPException } from './chunk-NYN7KFXL.js';
@@ -23,6 +23,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
23
23
  const instructions = await agent.getInstructions({ runtimeContext });
24
24
  const tools = await agent.getTools({ runtimeContext });
25
25
  const llm = await agent.getLLM({ runtimeContext });
26
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
27
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
26
28
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
27
29
  const _tool = tool;
28
30
  acc[key] = {
@@ -57,8 +59,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
57
59
  workflows: serializedAgentWorkflows,
58
60
  provider: llm?.getProvider(),
59
61
  modelId: llm?.getModelId(),
60
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
61
- defaultStreamOptions: agent.getDefaultStreamOptions()
62
+ defaultGenerateOptions,
63
+ defaultStreamOptions
62
64
  };
63
65
  })
64
66
  );
@@ -74,7 +76,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
74
76
  async function getAgentByIdHandler({
75
77
  mastra,
76
78
  runtimeContext,
77
- agentId
79
+ agentId,
80
+ isPlayground = false
78
81
  }) {
79
82
  try {
80
83
  const agent = mastra.getAgent(agentId);
@@ -100,7 +103,16 @@ async function getAgentByIdHandler({
100
103
  return {
101
104
  ...acc,
102
105
  [key]: {
103
- name: workflow.name
106
+ name: workflow.name,
107
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
108
+ return {
109
+ ...acc2,
110
+ [key2]: {
111
+ id: step.id,
112
+ description: step.description
113
+ }
114
+ };
115
+ }, {})
104
116
  }
105
117
  };
106
118
  }, {});
@@ -108,8 +120,24 @@ async function getAgentByIdHandler({
108
120
  logger.error("Error getting workflows for agent", { agentName: agent.name, error });
109
121
  }
110
122
  }
111
- const instructions = await agent.getInstructions({ runtimeContext });
123
+ let proxyRuntimeContext = runtimeContext;
124
+ if (isPlayground) {
125
+ proxyRuntimeContext = new Proxy(runtimeContext, {
126
+ get(target, prop) {
127
+ if (prop === "get") {
128
+ return function(key) {
129
+ const value = target.get(key);
130
+ return value ?? `<${key}>`;
131
+ };
132
+ }
133
+ return Reflect.get(target, prop);
134
+ }
135
+ });
136
+ }
137
+ const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
112
138
  const llm = await agent.getLLM({ runtimeContext });
139
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
140
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
113
141
  return {
114
142
  name: agent.name,
115
143
  instructions,
@@ -117,8 +145,8 @@ async function getAgentByIdHandler({
117
145
  workflows: serializedAgentWorkflows,
118
146
  provider: llm?.getProvider(),
119
147
  modelId: llm?.getModelId(),
120
- defaultGenerateOptions: agent.getDefaultGenerateOptions(),
121
- defaultStreamOptions: agent.getDefaultStreamOptions()
148
+ defaultGenerateOptions,
149
+ defaultStreamOptions
122
150
  };
123
151
  } catch (error) {
124
152
  return handleError(error, "Error getting agent");
@@ -166,7 +194,8 @@ async function generateHandler({
166
194
  mastra,
167
195
  runtimeContext,
168
196
  agentId,
169
- body
197
+ body,
198
+ abortSignal
170
199
  }) {
171
200
  try {
172
201
  const agent = mastra.getAgent(agentId);
@@ -184,7 +213,8 @@ async function generateHandler({
184
213
  ...rest,
185
214
  // @ts-expect-error TODO fix types
186
215
  resourceId: finalResourceId,
187
- runtimeContext: finalRuntimeContext
216
+ runtimeContext: finalRuntimeContext,
217
+ signal: abortSignal
188
218
  });
189
219
  return result;
190
220
  } catch (error) {
@@ -195,7 +225,8 @@ async function streamGenerateHandler({
195
225
  mastra,
196
226
  runtimeContext,
197
227
  agentId,
198
- body
228
+ body,
229
+ abortSignal
199
230
  }) {
200
231
  try {
201
232
  const agent = mastra.getAgent(agentId);
@@ -213,13 +244,21 @@ async function streamGenerateHandler({
213
244
  ...rest,
214
245
  // @ts-expect-error TODO fix types
215
246
  resourceId: finalResourceId,
216
- runtimeContext: finalRuntimeContext
247
+ runtimeContext: finalRuntimeContext,
248
+ signal: abortSignal
217
249
  });
218
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
250
+ const streamResponse = rest.output ? streamResult.toTextStreamResponse({
251
+ headers: {
252
+ "Transfer-Encoding": "chunked"
253
+ }
254
+ }) : streamResult.toDataStreamResponse({
219
255
  sendUsage: true,
220
256
  sendReasoning: true,
221
257
  getErrorMessage: (error) => {
222
258
  return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
259
+ },
260
+ headers: {
261
+ "Transfer-Encoding": "chunked"
223
262
  }
224
263
  });
225
264
  return streamResponse;