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

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 (69) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +265 -22
  3. package/dist/_tsup-dts-rollup.d.ts +265 -22
  4. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  5. package/dist/{chunk-5BKZNI2F.cjs → chunk-34GEZJPU.cjs} +29 -23
  6. package/dist/{chunk-TGJMNUYJ.js → chunk-36BLNJHS.js} +108 -70
  7. package/dist/{chunk-XUTX4CAB.cjs → chunk-3TMDONWY.cjs} +154 -75
  8. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  9. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  10. package/dist/{chunk-P54JFWUD.js → chunk-BYCOGHDE.js} +3 -3
  11. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  12. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  13. package/dist/{chunk-I3FR2N5I.cjs → chunk-HAGPF7OS.cjs} +12 -12
  14. package/dist/{chunk-ASKESBJW.cjs → chunk-HISYIDYH.cjs} +107 -69
  15. package/dist/{chunk-NGURCFEJ.cjs → chunk-HRSAZUIK.cjs} +20 -20
  16. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  17. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  18. package/dist/chunk-LF7P5PLR.js +14 -0
  19. package/dist/{chunk-BSUAZLUK.js → chunk-N6KVUULV.js} +110 -25
  20. package/dist/{chunk-2XXCPCYB.js → chunk-OKL5JVWU.js} +15 -9
  21. package/dist/{chunk-3CSC35VL.js → chunk-ORHUZSM2.js} +96 -19
  22. package/dist/chunk-PZQDCRPV.cjs +16 -0
  23. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  24. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  25. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  26. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  27. package/dist/{chunk-WE32JG64.cjs → chunk-UCV4247U.cjs} +43 -43
  28. package/dist/chunk-VDTQM2M5.cjs +321 -0
  29. package/dist/{chunk-2HXKRRNS.js → chunk-WBRFIHSF.js} +4 -4
  30. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  31. package/dist/{chunk-CLYX4KLH.js → chunk-ZYAFP2AV.js} +8 -8
  32. package/dist/server/handlers/agents.cjs +7 -7
  33. package/dist/server/handlers/agents.js +1 -1
  34. package/dist/server/handlers/error.cjs +2 -2
  35. package/dist/server/handlers/error.js +1 -1
  36. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  37. package/dist/server/handlers/legacyWorkflows.js +1 -1
  38. package/dist/server/handlers/logs.cjs +4 -4
  39. package/dist/server/handlers/logs.js +1 -1
  40. package/dist/server/handlers/memory.cjs +17 -9
  41. package/dist/server/handlers/memory.d.cts +2 -0
  42. package/dist/server/handlers/memory.d.ts +2 -0
  43. package/dist/server/handlers/memory.js +1 -1
  44. package/dist/server/handlers/network.cjs +5 -5
  45. package/dist/server/handlers/network.js +1 -1
  46. package/dist/server/handlers/telemetry.cjs +3 -3
  47. package/dist/server/handlers/telemetry.js +1 -1
  48. package/dist/server/handlers/tools.cjs +5 -5
  49. package/dist/server/handlers/tools.js +1 -1
  50. package/dist/server/handlers/utils.cjs +2 -2
  51. package/dist/server/handlers/utils.js +1 -1
  52. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  53. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  54. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  55. package/dist/server/handlers/vNextNetwork.js +211 -0
  56. package/dist/server/handlers/vector.cjs +7 -7
  57. package/dist/server/handlers/vector.js +1 -1
  58. package/dist/server/handlers/voice.cjs +5 -5
  59. package/dist/server/handlers/voice.js +1 -1
  60. package/dist/server/handlers/workflows.cjs +21 -13
  61. package/dist/server/handlers/workflows.d.cts +2 -0
  62. package/dist/server/handlers/workflows.d.ts +2 -0
  63. package/dist/server/handlers/workflows.js +1 -1
  64. package/dist/server/handlers.cjs +20 -20
  65. package/dist/server/handlers.js +10 -10
  66. package/package.json +9 -9
  67. package/dist/chunk-64U3UDTH.cjs +0 -13
  68. package/dist/chunk-M5ABIP7D.js +0 -11
  69. package/dist/chunk-PADRC33G.cjs +0 -234
@@ -4,7 +4,8 @@ import type { AgentNetwork } from '@mastra/core/network';
4
4
  import type { Artifact } from '@mastra/core/a2a';
5
5
  import type { BaseLogMessage } from '@mastra/core/logger';
6
6
  import type { CoreMessage } from '@mastra/core/llm';
7
- import { EvalRow } from '@mastra/core/storage';
7
+ import { DefaultEngineType } from '@mastra/core';
8
+ import { EvalRow } from '@mastra/core';
8
9
  import { GenerateObjectResult } from 'ai';
9
10
  import { GenerateTextResult } from 'ai';
10
11
  import type { IMastraLogger } from '@mastra/core/logger';
@@ -16,20 +17,23 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
16
17
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
17
18
  import type { LogLevel } from '@mastra/core/logger';
18
19
  import type { Mastra } from '@mastra/core/mastra';
20
+ import type { MastraError } from '@mastra/core/error';
19
21
  import type { MastraMemory } from '@mastra/core/memory';
20
- import { MastraMessageV1 } from '@mastra/core/memory';
22
+ import { MastraMessageV1 } from '@mastra/core';
21
23
  import type { Message } from '@mastra/core/a2a';
22
24
  import { ModelMessage } from 'ai';
23
25
  import type { QueryResult } from '@mastra/core/vector';
24
26
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
27
+ import { ReadableStream as ReadableStream_3 } from 'stream/web';
25
28
  import { RuntimeContext } from '@mastra/core/runtime-context';
26
29
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
27
30
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
28
- import { Step } from '@mastra/core/workflows';
31
+ import { Step } from '@mastra/core';
29
32
  import { StepExecutionContext } from '@mastra/core/workflows/legacy';
30
33
  import { StepGraph } from '@mastra/core/workflows/legacy';
31
- import { StorageThreadType } from '@mastra/core/memory';
32
- import { StreamEvent } from '@mastra/core/workflows';
34
+ import { StepResult } from '@mastra/core';
35
+ import { StorageThreadType } from '@mastra/core';
36
+ import { StreamEvent } from '@mastra/core';
33
37
  import { Task } from '@mastra/core/a2a';
34
38
  import { TaskAndHistory } from '@mastra/core/a2a';
35
39
  import type { TaskContext } from '@mastra/core/a2a';
@@ -42,9 +46,17 @@ import type { VercelTool } from '@mastra/core/tools';
42
46
  import type { WatchEvent } from '@mastra/core/workflows';
43
47
  import type { Workflow } from '@mastra/core/workflows';
44
48
  import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
45
- import { WorkflowResult } from '@mastra/core/workflows';
49
+ import { WorkflowResult } from '@mastra/core';
46
50
  import type { WorkflowRuns } from '@mastra/core/storage';
51
+ import { WorkingMemoryTemplate } from '@mastra/core';
52
+ import { ZodBoolean } from 'zod';
53
+ import { ZodEnum } from 'zod';
54
+ import { ZodNumber } from 'zod';
55
+ import { ZodObject } from 'zod';
56
+ import { ZodOptional } from 'zod';
57
+ import { ZodString } from 'zod';
47
58
  import { ZodType } from 'zod';
59
+ import { ZodTypeAny } from 'zod';
48
60
  import { ZodTypeDef } from 'zod';
49
61
 
50
62
  export declare namespace a2a {
@@ -69,13 +81,17 @@ export declare namespace agents {
69
81
  }
70
82
  }
71
83
 
72
- export declare interface ApiError extends Error {
84
+ export declare interface ApiError extends MastraError {
73
85
  message: string;
74
86
  status?: number;
75
87
  }
76
88
 
77
89
  export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
78
90
 
91
+ export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
92
+ message: string;
93
+ }>;
94
+
79
95
  declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
80
96
 
81
97
  export declare interface Context {
@@ -111,7 +127,7 @@ export declare function createTaskContext({ task, userMessage, history, activeCa
111
127
  activeCancellations: Set<string>;
112
128
  }): TaskContext;
113
129
 
114
- export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
130
+ export declare function createThreadHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
115
131
  body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
116
132
  resourceId?: string;
117
133
  };
@@ -127,7 +143,7 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
127
143
  success: boolean;
128
144
  }>;
129
145
 
130
- export declare function deleteThreadHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
146
+ export declare function deleteThreadHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<{
131
147
  result: string;
132
148
  }>;
133
149
 
@@ -152,13 +168,14 @@ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mas
152
168
  runtimeContext: RuntimeContext_2;
153
169
  }) => Promise<any>;
154
170
 
155
- export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
171
+ export declare function generateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
156
172
  runtimeContext: RuntimeContext;
157
173
  agentId: string;
158
174
  body: GetBody<'generate'> & {
159
175
  resourceid?: string;
160
176
  runtimeContext?: Record<string, unknown>;
161
177
  };
178
+ abortSignal?: AbortSignal;
162
179
  }): Promise<GenerateTextResult<any, unknown>>;
163
180
 
164
181
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
@@ -178,6 +195,20 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
178
195
  };
179
196
  }): Promise<NodeJS.ReadableStream>;
180
197
 
198
+ export declare function generateVNextNetworkHandler({ mastra, runtimeContext, networkId, body, }: NetworkContext_2 & {
199
+ runtimeContext: RuntimeContext;
200
+ body: {
201
+ message: string;
202
+ threadId?: string;
203
+ resourceId?: string;
204
+ };
205
+ }): Promise<{
206
+ task: string;
207
+ result: string;
208
+ resourceId: string;
209
+ resourceType: "tool" | "none" | "workflow" | "agent";
210
+ }>;
211
+
181
212
  export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
182
213
  isPlayground?: boolean;
183
214
  runtimeContext: RuntimeContext;
@@ -216,7 +247,17 @@ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, r
216
247
 
217
248
  export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
218
249
  runtimeContext: RuntimeContext;
219
- }): Promise<any>;
250
+ }): Promise<Record<string, Omit<{
251
+ id: string;
252
+ name: any;
253
+ instructions: string;
254
+ tools: any;
255
+ workflows: {};
256
+ provider: string;
257
+ modelId: string;
258
+ defaultGenerateOptions: any;
259
+ defaultStreamOptions: any;
260
+ }, "id">>>;
220
261
 
221
262
  declare type GetBody<T extends keyof Agent & {
222
263
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -293,11 +334,11 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
293
334
  transports: string[];
294
335
  }>;
295
336
 
296
- export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryContext, 'mastra' | 'agentId'>): Promise<{
337
+ export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
297
338
  result: boolean;
298
339
  }>;
299
340
 
300
- export declare function getMessagesHandler({ mastra, agentId, threadId, limit, format, clientSdkCompat, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
341
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, format, clientSdkCompat, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
301
342
  limit?: number;
302
343
  format?: 'aiv4' | 'aiv5';
303
344
  clientSdkCompat?: string;
@@ -345,16 +386,67 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
345
386
 
346
387
  export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
347
388
 
348
- export declare function getThreadByIdHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<StorageThreadType>;
389
+ export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
349
390
 
350
- export declare function getThreadsHandler({ mastra, agentId, resourceId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId'>): Promise<StorageThreadType[]>;
391
+ export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType[]>;
351
392
 
352
393
  export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
353
394
 
354
395
  export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
355
396
 
397
+ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
398
+ id: string;
399
+ name: string;
400
+ instructions: string;
401
+ agents: {
402
+ name: string;
403
+ provider: string;
404
+ modelId: string;
405
+ }[];
406
+ workflows: {
407
+ name: string | undefined;
408
+ description: string | undefined;
409
+ inputSchema: string | undefined;
410
+ outputSchema: string | undefined;
411
+ }[];
412
+ tools: {
413
+ id: string;
414
+ description: string;
415
+ }[];
416
+ routingModel: {
417
+ provider: string;
418
+ modelId: string;
419
+ };
420
+ }>;
421
+
422
+ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'runtimeContext'>): Promise<{
423
+ id: string;
424
+ name: string;
425
+ instructions: string;
426
+ tools: {
427
+ id: string;
428
+ description: string;
429
+ }[];
430
+ agents: {
431
+ name: string;
432
+ provider: string;
433
+ modelId: string;
434
+ }[];
435
+ workflows: {
436
+ name: string | undefined;
437
+ description: string | undefined;
438
+ inputSchema: string | undefined;
439
+ outputSchema: string | undefined;
440
+ }[];
441
+ routingModel: {
442
+ provider: string;
443
+ modelId: string;
444
+ };
445
+ }[]>;
446
+
356
447
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
357
- steps: SerializedStep[];
448
+ steps: Record<string, SerializedStep>;
449
+ allSteps: Record<string, SerializedStep>;
358
450
  name: string | undefined;
359
451
  description: string | undefined;
360
452
  stepGraph: SerializedStepFlowEntry[];
@@ -376,6 +468,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
376
468
 
377
469
  export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
378
470
 
471
+ /**
472
+ * Handler to get the working memory for a thread (optionally resource-scoped).
473
+ * @returns workingMemory - the working memory for the thread
474
+ * @returns source - thread or resource
475
+ */
476
+ export declare function getWorkingMemoryHandler({ mastra, agentId, threadId, resourceId, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
477
+ resourceId?: Parameters<MastraMemory['getWorkingMemory']>[0]['resourceId'];
478
+ memoryConfig?: Parameters<MastraMemory['getWorkingMemory']>[0]['memoryConfig'];
479
+ }): Promise<{
480
+ workingMemory: string | null;
481
+ source: string;
482
+ workingMemoryTemplate: WorkingMemoryTemplate | null;
483
+ threadExists: boolean;
484
+ }>;
485
+
379
486
  export declare function handleError(error: unknown, defaultMessage: string): never;
380
487
 
381
488
  export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
@@ -470,11 +577,13 @@ export declare class HTTPException extends Error {
470
577
  * @property res - Optional response object to use.
471
578
  * @property message - Optional custom error message.
472
579
  * @property cause - Optional cause of the error.
580
+ * @property stack - Optional stack trace for the error.
473
581
  */
474
582
  declare type HTTPExceptionOptions = {
475
583
  res?: Response;
476
584
  message?: string;
477
585
  cause?: unknown;
586
+ stack?: string;
478
587
  };
479
588
 
480
589
  /**
@@ -545,6 +654,62 @@ declare type LogsContext = {
545
654
  };
546
655
  };
547
656
 
657
+ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
658
+ runtimeContext: RuntimeContext;
659
+ body: {
660
+ message: string;
661
+ threadId?: string;
662
+ resourceId?: string;
663
+ maxIterations?: number;
664
+ };
665
+ }): Promise<{
666
+ stream: ReadableStream_3<StreamEvent>;
667
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
668
+ task: ZodString;
669
+ resourceId: ZodString;
670
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool"]>;
671
+ prompt: ZodString;
672
+ result: ZodString;
673
+ isComplete: ZodOptional<ZodBoolean>;
674
+ completionReason: ZodOptional<ZodString>;
675
+ iteration: ZodNumber;
676
+ }, "strip", ZodTypeAny, {
677
+ result: string;
678
+ prompt: string;
679
+ resourceId: string;
680
+ task: string;
681
+ resourceType: "tool" | "none" | "workflow" | "agent";
682
+ iteration: number;
683
+ isComplete?: boolean | undefined;
684
+ completionReason?: string | undefined;
685
+ }, {
686
+ result: string;
687
+ prompt: string;
688
+ resourceId: string;
689
+ task: string;
690
+ resourceType: "tool" | "none" | "workflow" | "agent";
691
+ iteration: number;
692
+ isComplete?: boolean | undefined;
693
+ completionReason?: string | undefined;
694
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
695
+ }>;
696
+
697
+ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
698
+ runtimeContext: RuntimeContext;
699
+ body: {
700
+ message: string;
701
+ };
702
+ }): Promise<{
703
+ status: "success";
704
+ result: {
705
+ text: string;
706
+ iteration: number;
707
+ };
708
+ steps: {
709
+ [x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
710
+ };
711
+ }>;
712
+
548
713
  export declare namespace memory {
549
714
  export {
550
715
  getMemoryStatusHandler,
@@ -554,7 +719,9 @@ export declare namespace memory {
554
719
  createThreadHandler,
555
720
  updateThreadHandler,
556
721
  deleteThreadHandler,
557
- getMessagesHandler
722
+ getMessagesHandler,
723
+ getWorkingMemoryHandler,
724
+ updateWorkingMemoryHandler
558
725
  }
559
726
  }
560
727
 
@@ -562,6 +729,8 @@ declare interface MemoryContext extends Context {
562
729
  agentId?: string;
563
730
  resourceId?: string;
564
731
  threadId?: string;
732
+ networkId?: string;
733
+ runtimeContext?: RuntimeContext_2;
565
734
  }
566
735
 
567
736
  export declare namespace network {
@@ -578,6 +747,11 @@ declare interface NetworkContext extends Context {
578
747
  runtimeContext: RuntimeContext;
579
748
  }
580
749
 
750
+ declare interface NetworkContext_2 extends Context {
751
+ networkId?: string;
752
+ runtimeContext: RuntimeContext;
753
+ }
754
+
581
755
  export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: IMastraLogger): JSONRPCResponse<null, unknown>;
582
756
 
583
757
  declare interface QueryRequest {
@@ -630,12 +804,19 @@ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body,
630
804
  message: string;
631
805
  }>;
632
806
 
633
- export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
807
+ export declare function saveMessagesHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
634
808
  body: {
635
809
  messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];
636
810
  };
637
811
  }): Promise<MastraMessageV1[]>;
638
812
 
813
+ export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
814
+ event: string;
815
+ data: unknown;
816
+ }): Promise<{
817
+ message: string;
818
+ }>;
819
+
639
820
  declare type SerializedStep = {
640
821
  id: string;
641
822
  description: string;
@@ -694,13 +875,14 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
694
875
  traceCount: number;
695
876
  }>;
696
877
 
697
- export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, clientSdkCompat, }: Context & {
878
+ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, clientSdkCompat, abortSignal, }: Context & {
698
879
  runtimeContext: RuntimeContext;
699
880
  agentId: string;
700
881
  body: GetBody<'stream'> & {
701
882
  runtimeContext?: string;
702
883
  };
703
884
  clientSdkCompat?: string;
885
+ abortSignal?: AbortSignal;
704
886
  }): Promise<Response | undefined>;
705
887
 
706
888
  export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, runtimeContext, clientSdkCompat, }: NetworkContext & {
@@ -711,11 +893,59 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
711
893
  clientSdkCompat?: string;
712
894
  }): Promise<Response>;
713
895
 
896
+ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
897
+ runtimeContext: RuntimeContext;
898
+ body: {
899
+ message: string;
900
+ threadId?: string;
901
+ resourceId?: string;
902
+ };
903
+ }): Promise<{
904
+ stream: ReadableStream_3<StreamEvent>;
905
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
906
+ task: ZodString;
907
+ resourceId: ZodString;
908
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool"]>;
909
+ prompt: ZodString;
910
+ result: ZodString;
911
+ isComplete: ZodOptional<ZodBoolean>;
912
+ completionReason: ZodOptional<ZodString>;
913
+ iteration: ZodNumber;
914
+ threadId: ZodOptional<ZodString>;
915
+ threadResourceId: ZodOptional<ZodString>;
916
+ isOneOff: ZodBoolean;
917
+ }, "strip", ZodTypeAny, {
918
+ result: string;
919
+ prompt: string;
920
+ resourceId: string;
921
+ task: string;
922
+ resourceType: "tool" | "none" | "workflow" | "agent";
923
+ iteration: number;
924
+ isOneOff: boolean;
925
+ threadId?: string | undefined;
926
+ threadResourceId?: string | undefined;
927
+ isComplete?: boolean | undefined;
928
+ completionReason?: string | undefined;
929
+ }, {
930
+ result: string;
931
+ prompt: string;
932
+ resourceId: string;
933
+ task: string;
934
+ resourceType: "tool" | "none" | "workflow" | "agent";
935
+ iteration: number;
936
+ isOneOff: boolean;
937
+ threadId?: string | undefined;
938
+ threadResourceId?: string | undefined;
939
+ isComplete?: boolean | undefined;
940
+ completionReason?: string | undefined;
941
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
942
+ }>;
943
+
714
944
  export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
715
945
  inputData?: unknown;
716
946
  runtimeContext?: RuntimeContext_2;
717
947
  }): Promise<{
718
- stream: globalThis.ReadableStream<StreamEvent>;
948
+ stream: ReadableStream_2<StreamEvent>;
719
949
  getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
720
950
  }>;
721
951
 
@@ -785,10 +1015,21 @@ export declare type UnOfficalStatusCode = UnofficialStatusCode;
785
1015
  */
786
1016
  export declare type UnofficialStatusCode = -1;
787
1017
 
788
- export declare function updateThreadHandler({ mastra, agentId, threadId, body, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
1018
+ export declare function updateThreadHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
789
1019
  body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
790
1020
  }): Promise<StorageThreadType>;
791
1021
 
1022
+ /**
1023
+ * Handler to update the working memory for a thread (optionally resource-scoped).
1024
+ * @param threadId - the thread id
1025
+ * @param body - the body containing the working memory to update and the resource id (optional)
1026
+ */
1027
+ export declare function updateWorkingMemoryHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
1028
+ body: Omit<Parameters<MastraMemory['updateWorkingMemory']>[0], 'threadId'>;
1029
+ }): Promise<{
1030
+ success: boolean;
1031
+ }>;
1032
+
792
1033
  declare interface UpsertRequest {
793
1034
  indexName: string;
794
1035
  vectors: number[][];
@@ -859,7 +1100,9 @@ export declare namespace workflows {
859
1100
  streamWorkflowHandler,
860
1101
  resumeAsyncWorkflowHandler,
861
1102
  resumeWorkflowHandler,
862
- getWorkflowRunsHandler
1103
+ getWorkflowRunsHandler,
1104
+ cancelWorkflowRunHandler,
1105
+ sendWorkflowRunEventHandler
863
1106
  }
864
1107
  }
865
1108
 
@@ -13,6 +13,7 @@ var HTTPException = class extends Error {
13
13
  super(options?.message, { cause: options?.cause });
14
14
  this.res = options?.res;
15
15
  this.status = status;
16
+ this.stack = options?.stack || this.stack;
16
17
  }
17
18
  /**
18
19
  * Returns the response object associated with the exception.
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkASKESBJW_cjs = require('./chunk-ASKESBJW.cjs');
4
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
6
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkHISYIDYH_cjs = require('./chunk-HISYIDYH.cjs');
4
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
5
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
6
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
7
7
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
8
  var agent = require('@mastra/core/agent');
9
9
  var runtimeContext = require('@mastra/core/runtime-context');
@@ -32,8 +32,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
32
32
  const _tool = tool;
33
33
  acc[key] = {
34
34
  ..._tool,
35
- inputSchema: _tool.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(_tool.inputSchema)) : void 0,
36
- outputSchema: _tool.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(_tool.outputSchema)) : void 0
35
+ inputSchema: _tool.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_tool.inputSchema)) : void 0,
36
+ outputSchema: _tool.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_tool.outputSchema)) : void 0
37
37
  };
38
38
  return acc;
39
39
  }, {});
@@ -73,7 +73,7 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
73
73
  }, {});
74
74
  return serializedAgents;
75
75
  } catch (error) {
76
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
76
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agents");
77
77
  }
78
78
  }
79
79
  async function getAgentByIdHandler({
@@ -85,15 +85,15 @@ async function getAgentByIdHandler({
85
85
  try {
86
86
  const agent = mastra.getAgent(agentId);
87
87
  if (!agent) {
88
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
88
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
89
89
  }
90
90
  const tools = await agent.getTools({ runtimeContext });
91
91
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
92
92
  const _tool = tool;
93
93
  acc[key] = {
94
94
  ..._tool,
95
- inputSchema: _tool.inputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(_tool.inputSchema)) : void 0,
96
- outputSchema: _tool.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(_tool.outputSchema)) : void 0
95
+ inputSchema: _tool.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_tool.inputSchema)) : void 0,
96
+ outputSchema: _tool.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_tool.outputSchema)) : void 0
97
97
  };
98
98
  return acc;
99
99
  }, {});
@@ -152,7 +152,7 @@ async function getAgentByIdHandler({
152
152
  defaultStreamOptions
153
153
  };
154
154
  } catch (error) {
155
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
155
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agent");
156
156
  }
157
157
  }
158
158
  async function getEvalsByAgentIdHandler({
@@ -171,7 +171,7 @@ async function getEvalsByAgentIdHandler({
171
171
  evals
172
172
  };
173
173
  } catch (error) {
174
- return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
174
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting test evals");
175
175
  }
176
176
  }
177
177
  async function getLiveEvalsByAgentIdHandler({
@@ -190,19 +190,21 @@ async function getLiveEvalsByAgentIdHandler({
190
190
  evals
191
191
  };
192
192
  } catch (error) {
193
- return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
193
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting live evals");
194
194
  }
195
195
  }
196
196
  async function generateHandler({
197
197
  mastra,
198
198
  runtimeContext: runtimeContext$1,
199
199
  agentId,
200
- body
200
+ body,
201
+ abortSignal
201
202
  }) {
202
203
  try {
203
204
  const agent = mastra.getAgent(agentId);
205
+ console.log("agent", agent);
204
206
  if (!agent) {
205
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
207
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
206
208
  }
207
209
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
208
210
  const finalResourceId = resourceId ?? resourceid;
@@ -210,16 +212,18 @@ async function generateHandler({
210
212
  ...Array.from(runtimeContext$1.entries()),
211
213
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
212
214
  ]);
213
- chunk57CJTIPW_cjs.validateBody({ messages });
215
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
214
216
  const result = await agent.generate(messages, {
215
217
  ...rest,
216
218
  // @ts-expect-error TODO fix types
217
219
  resourceId: finalResourceId,
218
- runtimeContext: finalRuntimeContext
220
+ runtimeContext: finalRuntimeContext,
221
+ signal: abortSignal
219
222
  });
220
223
  return result;
221
224
  } catch (error) {
222
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
225
+ console.log("error", error);
226
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from agent");
223
227
  }
224
228
  }
225
229
  async function streamGenerateHandler({
@@ -227,24 +231,26 @@ async function streamGenerateHandler({
227
231
  runtimeContext: runtimeContext$1,
228
232
  agentId,
229
233
  body,
230
- clientSdkCompat
234
+ clientSdkCompat,
235
+ abortSignal
231
236
  }) {
232
237
  try {
233
238
  const agent$1 = mastra.getAgent(agentId);
234
239
  if (!agent$1) {
235
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
240
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
236
241
  }
237
242
  const { messages, resourceId, runtimeContext: agentRuntimeContext, ...rest } = body;
238
243
  const finalRuntimeContext = new runtimeContext.RuntimeContext([
239
244
  ...Array.from(runtimeContext$1.entries()),
240
245
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
241
246
  ]);
242
- chunk57CJTIPW_cjs.validateBody({ messages });
247
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
243
248
  const streamResult = await agent$1.stream(messages, {
244
249
  ...rest,
245
250
  // @ts-expect-error TODO fix types
246
251
  resourceId,
247
- runtimeContext: finalRuntimeContext
252
+ runtimeContext: finalRuntimeContext,
253
+ signal: abortSignal
248
254
  });
249
255
  const headers = {
250
256
  "Transfer-Encoding": "chunked"
@@ -264,7 +270,7 @@ async function streamGenerateHandler({
264
270
  const streamResponse = useV4Compat ? agent.createV4CompatibleResponse(uiMessageStream.body) : uiMessageStream;
265
271
  return streamResponse;
266
272
  } catch (error) {
267
- throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
273
+ return chunkPZQDCRPV_cjs.handleError(error, "error streaming agent response");
268
274
  }
269
275
  }
270
276