@mastra/server 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 0.0.0-http-transporter-20250702160118

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 (65) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +77 -3
  2. package/dist/_tsup-dts-rollup.d.ts +77 -3
  3. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  4. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  5. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  6. package/dist/{chunk-N2YBMSO2.js → chunk-5PQQ42EZ.js} +8 -8
  7. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  8. package/dist/{chunk-TO5U6HW3.cjs → chunk-B2PAS2IB.cjs} +147 -68
  9. package/dist/{chunk-PMUATKV2.js → chunk-BK4XT6EG.js} +5 -5
  10. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  11. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  12. package/dist/{chunk-RQ2Z56EC.cjs → chunk-DN7K6FJK.cjs} +34 -34
  13. package/dist/{chunk-CPPYMJX5.cjs → chunk-FRVBFMO2.cjs} +20 -20
  14. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  15. package/dist/{chunk-SOBBILUG.js → chunk-H7DMHBKY.js} +89 -12
  16. package/dist/{chunk-4DTDPTQC.cjs → chunk-JMLYCXMK.cjs} +43 -43
  17. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  18. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  19. package/dist/chunk-LF7P5PLR.js +14 -0
  20. package/dist/{chunk-MN6F4D5A.cjs → chunk-LI436ITD.cjs} +107 -69
  21. package/dist/{chunk-XR7VJOOP.js → chunk-LRCAAFUA.js} +4 -4
  22. package/dist/{chunk-GKM45O24.cjs → chunk-LZ3VJXSO.cjs} +19 -19
  23. package/dist/{chunk-OSZM4EAY.js → chunk-MEGCYGBU.js} +108 -70
  24. package/dist/{chunk-XUIJ7WRT.js → chunk-MKLYEKEF.js} +3 -3
  25. package/dist/chunk-PZQDCRPV.cjs +16 -0
  26. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  27. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  28. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  29. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  30. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  31. package/dist/server/handlers/agents.cjs +7 -7
  32. package/dist/server/handlers/agents.js +1 -1
  33. package/dist/server/handlers/error.cjs +2 -2
  34. package/dist/server/handlers/error.js +1 -1
  35. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  36. package/dist/server/handlers/legacyWorkflows.js +1 -1
  37. package/dist/server/handlers/logs.cjs +4 -4
  38. package/dist/server/handlers/logs.js +1 -1
  39. package/dist/server/handlers/memory.cjs +9 -9
  40. package/dist/server/handlers/memory.js +1 -1
  41. package/dist/server/handlers/network.cjs +5 -5
  42. package/dist/server/handlers/network.js +1 -1
  43. package/dist/server/handlers/telemetry.cjs +3 -3
  44. package/dist/server/handlers/telemetry.js +1 -1
  45. package/dist/server/handlers/tools.cjs +5 -5
  46. package/dist/server/handlers/tools.js +1 -1
  47. package/dist/server/handlers/utils.cjs +2 -2
  48. package/dist/server/handlers/utils.js +1 -1
  49. package/dist/server/handlers/vNextNetwork.cjs +63 -20
  50. package/dist/server/handlers/vNextNetwork.d.cts +1 -0
  51. package/dist/server/handlers/vNextNetwork.d.ts +1 -0
  52. package/dist/server/handlers/vNextNetwork.js +47 -5
  53. package/dist/server/handlers/vector.cjs +7 -7
  54. package/dist/server/handlers/vector.js +1 -1
  55. package/dist/server/handlers/voice.cjs +5 -5
  56. package/dist/server/handlers/voice.js +1 -1
  57. package/dist/server/handlers/workflows.cjs +21 -13
  58. package/dist/server/handlers/workflows.d.cts +2 -0
  59. package/dist/server/handlers/workflows.d.ts +2 -0
  60. package/dist/server/handlers/workflows.js +1 -1
  61. package/dist/server/handlers.cjs +20 -20
  62. package/dist/server/handlers.js +10 -10
  63. package/package.json +5 -5
  64. package/dist/chunk-64U3UDTH.cjs +0 -13
  65. package/dist/chunk-M5ABIP7D.js +0 -11
@@ -18,6 +18,7 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
18
18
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
19
19
  import type { LogLevel } from '@mastra/core/logger';
20
20
  import type { Mastra } from '@mastra/core/mastra';
21
+ import type { MastraError } from '@mastra/core/error';
21
22
  import type { MastraMemory } from '@mastra/core/memory';
22
23
  import { MastraMessageV1 } from '@mastra/core/memory';
23
24
  import type { Message } from '@mastra/core/a2a';
@@ -80,13 +81,17 @@ export declare namespace agents {
80
81
  }
81
82
  }
82
83
 
83
- export declare interface ApiError extends Error {
84
+ export declare interface ApiError extends MastraError {
84
85
  message: string;
85
86
  status?: number;
86
87
  }
87
88
 
88
89
  export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
89
90
 
91
+ export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
92
+ message: string;
93
+ }>;
94
+
90
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;
91
96
 
92
97
  export declare interface Context {
@@ -402,6 +407,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
402
407
  inputSchema: string | undefined;
403
408
  outputSchema: string | undefined;
404
409
  }[];
410
+ tools: {
411
+ id: string;
412
+ description: string;
413
+ }[];
405
414
  routingModel: {
406
415
  provider: string;
407
416
  modelId: string;
@@ -412,6 +421,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
412
421
  id: string;
413
422
  name: string;
414
423
  instructions: string;
424
+ tools: {
425
+ id: string;
426
+ description: string;
427
+ }[];
415
428
  agents: {
416
429
  name: string;
417
430
  provider: string;
@@ -430,7 +443,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
430
443
  }[]>;
431
444
 
432
445
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
433
- steps: SerializedStep[];
446
+ steps: Record<string, SerializedStep>;
447
+ allSteps: Record<string, SerializedStep>;
434
448
  name: string | undefined;
435
449
  description: string | undefined;
436
450
  stepGraph: SerializedStepFlowEntry[];
@@ -546,11 +560,13 @@ export declare class HTTPException extends Error {
546
560
  * @property res - Optional response object to use.
547
561
  * @property message - Optional custom error message.
548
562
  * @property cause - Optional cause of the error.
563
+ * @property stack - Optional stack trace for the error.
549
564
  */
550
565
  declare type HTTPExceptionOptions = {
551
566
  res?: Response;
552
567
  message?: string;
553
568
  cause?: unknown;
569
+ stack?: string;
554
570
  };
555
571
 
556
572
  /**
@@ -621,6 +637,46 @@ declare type LogsContext = {
621
637
  };
622
638
  };
623
639
 
640
+ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
641
+ runtimeContext: RuntimeContext;
642
+ body: {
643
+ message: string;
644
+ threadId?: string;
645
+ resourceId?: string;
646
+ maxIterations?: number;
647
+ };
648
+ }): Promise<{
649
+ stream: ReadableStream_3<StreamEvent>;
650
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
651
+ task: ZodString;
652
+ resourceId: ZodString;
653
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
654
+ prompt: ZodString;
655
+ result: ZodString;
656
+ isComplete: ZodOptional<ZodBoolean>;
657
+ completionReason: ZodOptional<ZodString>;
658
+ iteration: ZodNumber;
659
+ }, "strip", ZodTypeAny, {
660
+ prompt: string;
661
+ resourceId: string;
662
+ result: string;
663
+ task: string;
664
+ resourceType: "none" | "tool" | "workflow" | "agent";
665
+ iteration: number;
666
+ isComplete?: boolean | undefined;
667
+ completionReason?: string | undefined;
668
+ }, {
669
+ prompt: string;
670
+ resourceId: string;
671
+ result: string;
672
+ task: string;
673
+ resourceType: "none" | "tool" | "workflow" | "agent";
674
+ iteration: number;
675
+ isComplete?: boolean | undefined;
676
+ completionReason?: string | undefined;
677
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
678
+ }>;
679
+
624
680
  export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
625
681
  runtimeContext: RuntimeContext;
626
682
  body: {
@@ -735,6 +791,13 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
735
791
  };
736
792
  }): Promise<MastraMessageV1[]>;
737
793
 
794
+ export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
795
+ event: string;
796
+ data: unknown;
797
+ }): Promise<{
798
+ message: string;
799
+ }>;
800
+
738
801
  declare type SerializedStep = {
739
802
  id: string;
740
803
  description: string;
@@ -828,6 +891,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
828
891
  isComplete: ZodOptional<ZodBoolean>;
829
892
  completionReason: ZodOptional<ZodString>;
830
893
  iteration: ZodNumber;
894
+ threadId: ZodOptional<ZodString>;
895
+ threadResourceId: ZodOptional<ZodString>;
896
+ isOneOff: ZodBoolean;
831
897
  }, "strip", ZodTypeAny, {
832
898
  prompt: string;
833
899
  resourceId: string;
@@ -835,6 +901,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
835
901
  task: string;
836
902
  resourceType: "none" | "tool" | "workflow" | "agent";
837
903
  iteration: number;
904
+ isOneOff: boolean;
905
+ threadId?: string | undefined;
906
+ threadResourceId?: string | undefined;
838
907
  isComplete?: boolean | undefined;
839
908
  completionReason?: string | undefined;
840
909
  }, {
@@ -844,6 +913,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
844
913
  task: string;
845
914
  resourceType: "none" | "tool" | "workflow" | "agent";
846
915
  iteration: number;
916
+ isOneOff: boolean;
917
+ threadId?: string | undefined;
918
+ threadResourceId?: string | undefined;
847
919
  isComplete?: boolean | undefined;
848
920
  completionReason?: string | undefined;
849
921
  }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
@@ -997,7 +1069,9 @@ export declare namespace workflows {
997
1069
  streamWorkflowHandler,
998
1070
  resumeAsyncWorkflowHandler,
999
1071
  resumeWorkflowHandler,
1000
- getWorkflowRunsHandler
1072
+ getWorkflowRunsHandler,
1073
+ cancelWorkflowRunHandler,
1074
+ sendWorkflowRunEventHandler
1001
1075
  }
1002
1076
  }
1003
1077
 
@@ -18,6 +18,7 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
18
18
  import type { LegacyWorkflowRuns } from '@mastra/core/storage';
19
19
  import type { LogLevel } from '@mastra/core/logger';
20
20
  import type { Mastra } from '@mastra/core/mastra';
21
+ import type { MastraError } from '@mastra/core/error';
21
22
  import type { MastraMemory } from '@mastra/core/memory';
22
23
  import { MastraMessageV1 } from '@mastra/core/memory';
23
24
  import type { Message } from '@mastra/core/a2a';
@@ -80,13 +81,17 @@ export declare namespace agents {
80
81
  }
81
82
  }
82
83
 
83
- export declare interface ApiError extends Error {
84
+ export declare interface ApiError extends MastraError {
84
85
  message: string;
85
86
  status?: number;
86
87
  }
87
88
 
88
89
  export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
89
90
 
91
+ export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
92
+ message: string;
93
+ }>;
94
+
90
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;
91
96
 
92
97
  export declare interface Context {
@@ -402,6 +407,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
402
407
  inputSchema: string | undefined;
403
408
  outputSchema: string | undefined;
404
409
  }[];
410
+ tools: {
411
+ id: string;
412
+ description: string;
413
+ }[];
405
414
  routingModel: {
406
415
  provider: string;
407
416
  modelId: string;
@@ -412,6 +421,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
412
421
  id: string;
413
422
  name: string;
414
423
  instructions: string;
424
+ tools: {
425
+ id: string;
426
+ description: string;
427
+ }[];
415
428
  agents: {
416
429
  name: string;
417
430
  provider: string;
@@ -430,7 +443,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
430
443
  }[]>;
431
444
 
432
445
  export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
433
- steps: SerializedStep[];
446
+ steps: Record<string, SerializedStep>;
447
+ allSteps: Record<string, SerializedStep>;
434
448
  name: string | undefined;
435
449
  description: string | undefined;
436
450
  stepGraph: SerializedStepFlowEntry[];
@@ -546,11 +560,13 @@ export declare class HTTPException extends Error {
546
560
  * @property res - Optional response object to use.
547
561
  * @property message - Optional custom error message.
548
562
  * @property cause - Optional cause of the error.
563
+ * @property stack - Optional stack trace for the error.
549
564
  */
550
565
  declare type HTTPExceptionOptions = {
551
566
  res?: Response;
552
567
  message?: string;
553
568
  cause?: unknown;
569
+ stack?: string;
554
570
  };
555
571
 
556
572
  /**
@@ -621,6 +637,46 @@ declare type LogsContext = {
621
637
  };
622
638
  };
623
639
 
640
+ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
641
+ runtimeContext: RuntimeContext;
642
+ body: {
643
+ message: string;
644
+ threadId?: string;
645
+ resourceId?: string;
646
+ maxIterations?: number;
647
+ };
648
+ }): Promise<{
649
+ stream: ReadableStream_3<StreamEvent>;
650
+ getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
651
+ task: ZodString;
652
+ resourceId: ZodString;
653
+ resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
654
+ prompt: ZodString;
655
+ result: ZodString;
656
+ isComplete: ZodOptional<ZodBoolean>;
657
+ completionReason: ZodOptional<ZodString>;
658
+ iteration: ZodNumber;
659
+ }, "strip", ZodTypeAny, {
660
+ prompt: string;
661
+ resourceId: string;
662
+ result: string;
663
+ task: string;
664
+ resourceType: "none" | "tool" | "workflow" | "agent";
665
+ iteration: number;
666
+ isComplete?: boolean | undefined;
667
+ completionReason?: string | undefined;
668
+ }, {
669
+ prompt: string;
670
+ resourceId: string;
671
+ result: string;
672
+ task: string;
673
+ resourceType: "none" | "tool" | "workflow" | "agent";
674
+ iteration: number;
675
+ isComplete?: boolean | undefined;
676
+ completionReason?: string | undefined;
677
+ }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
678
+ }>;
679
+
624
680
  export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
625
681
  runtimeContext: RuntimeContext;
626
682
  body: {
@@ -735,6 +791,13 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
735
791
  };
736
792
  }): Promise<MastraMessageV1[]>;
737
793
 
794
+ export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
795
+ event: string;
796
+ data: unknown;
797
+ }): Promise<{
798
+ message: string;
799
+ }>;
800
+
738
801
  declare type SerializedStep = {
739
802
  id: string;
740
803
  description: string;
@@ -828,6 +891,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
828
891
  isComplete: ZodOptional<ZodBoolean>;
829
892
  completionReason: ZodOptional<ZodString>;
830
893
  iteration: ZodNumber;
894
+ threadId: ZodOptional<ZodString>;
895
+ threadResourceId: ZodOptional<ZodString>;
896
+ isOneOff: ZodBoolean;
831
897
  }, "strip", ZodTypeAny, {
832
898
  prompt: string;
833
899
  resourceId: string;
@@ -835,6 +901,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
835
901
  task: string;
836
902
  resourceType: "none" | "tool" | "workflow" | "agent";
837
903
  iteration: number;
904
+ isOneOff: boolean;
905
+ threadId?: string | undefined;
906
+ threadResourceId?: string | undefined;
838
907
  isComplete?: boolean | undefined;
839
908
  completionReason?: string | undefined;
840
909
  }, {
@@ -844,6 +913,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
844
913
  task: string;
845
914
  resourceType: "none" | "tool" | "workflow" | "agent";
846
915
  iteration: number;
916
+ isOneOff: boolean;
917
+ threadId?: string | undefined;
918
+ threadResourceId?: string | undefined;
847
919
  isComplete?: boolean | undefined;
848
920
  completionReason?: string | undefined;
849
921
  }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
@@ -997,7 +1069,9 @@ export declare namespace workflows {
997
1069
  streamWorkflowHandler,
998
1070
  resumeAsyncWorkflowHandler,
999
1071
  resumeWorkflowHandler,
1000
- getWorkflowRunsHandler
1072
+ getWorkflowRunsHandler,
1073
+ cancelWorkflowRunHandler,
1074
+ sendWorkflowRunEventHandler
1001
1075
  }
1002
1076
  }
1003
1077
 
@@ -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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
 
8
8
  // src/server/handlers/network.ts
@@ -47,7 +47,7 @@ async function getNetworksHandler({
47
47
  );
48
48
  return serializedNetworks;
49
49
  } catch (error) {
50
- return chunk64U3UDTH_cjs.handleError(error, "Error getting networks");
50
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting networks");
51
51
  }
52
52
  }
53
53
  async function getNetworkByIdHandler({
@@ -62,7 +62,7 @@ async function getNetworkByIdHandler({
62
62
  return network2.formatAgentId(routingAgent2.name) === networkId;
63
63
  });
64
64
  if (!network) {
65
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
65
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
66
66
  }
67
67
  const routingAgent = network.getRoutingAgent();
68
68
  const routingLLM = await routingAgent.getLLM({ runtimeContext });
@@ -88,7 +88,7 @@ async function getNetworkByIdHandler({
88
88
  };
89
89
  return serializedNetwork;
90
90
  } catch (error) {
91
- return chunk64U3UDTH_cjs.handleError(error, "Error getting network by ID");
91
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting network by ID");
92
92
  }
93
93
  }
94
94
  async function generateHandler({
@@ -100,14 +100,14 @@ async function generateHandler({
100
100
  try {
101
101
  const network = mastra.getNetwork(networkId);
102
102
  if (!network) {
103
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
103
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
104
104
  }
105
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
105
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
106
106
  const { messages, ...rest } = body;
107
107
  const result = await network.generate(messages, { ...rest, runtimeContext });
108
108
  return result;
109
109
  } catch (error) {
110
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from network");
110
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from network");
111
111
  }
112
112
  }
113
113
  async function streamGenerateHandler({
@@ -119,9 +119,9 @@ async function streamGenerateHandler({
119
119
  try {
120
120
  const network = mastra.getNetwork(networkId);
121
121
  if (!network) {
122
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
122
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
123
123
  }
124
- chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
124
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
125
125
  const { messages, output, ...rest } = body;
126
126
  const streamResult = await network.stream(messages, {
127
127
  output,
@@ -137,7 +137,7 @@ async function streamGenerateHandler({
137
137
  });
138
138
  return streamResponse;
139
139
  } catch (error) {
140
- return chunk64U3UDTH_cjs.handleError(error, "Error streaming from network");
140
+ return chunkPZQDCRPV_cjs.handleError(error, "Error streaming from network");
141
141
  }
142
142
  }
143
143
 
@@ -1,5 +1,5 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/logs.ts
@@ -1,6 +1,6 @@
1
- import { stringify, esm_default } from './chunk-OSZM4EAY.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { ReadableStream } from 'stream/web';
6
6
 
@@ -46,7 +46,7 @@ async function getLegacyWorkflowsHandler({ mastra }) {
46
46
  }, {});
47
47
  return _workflows;
48
48
  } catch (error) {
49
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
+ return handleError(error, "error getting workflows");
50
50
  }
51
51
  }
52
52
  async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
@@ -78,7 +78,7 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
78
78
  }, {})
79
79
  };
80
80
  } catch (error) {
81
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
81
+ return handleError(error, "error getting workflow by id");
82
82
  }
83
83
  }
84
84
  async function startAsyncLegacyWorkflowHandler({
@@ -114,7 +114,7 @@ async function startAsyncLegacyWorkflowHandler({
114
114
  });
115
115
  return result;
116
116
  } catch (error) {
117
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
117
+ return handleError(error, "error starting workflow");
118
118
  }
119
119
  }
120
120
  async function getLegacyWorkflowRunHandler({
@@ -139,7 +139,7 @@ async function getLegacyWorkflowRunHandler({
139
139
  }
140
140
  return run;
141
141
  } catch (error) {
142
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
142
+ return handleError(error, "error getting workflow run");
143
143
  }
144
144
  }
145
145
  async function createLegacyWorkflowRunHandler({
@@ -158,7 +158,7 @@ async function createLegacyWorkflowRunHandler({
158
158
  const newRun = workflow.createRun({ runId: prevRunId });
159
159
  return { runId: newRun.runId };
160
160
  } catch (error) {
161
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
161
+ return handleError(error, "error creating workflow run");
162
162
  }
163
163
  }
164
164
  async function startLegacyWorkflowRunHandler({
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/vector.ts
@@ -16,24 +16,24 @@ chunk75ZPJI57_cjs.__export(vector_exports, {
16
16
  });
17
17
  function getVector(mastra, vectorName) {
18
18
  if (!vectorName) {
19
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Vector name is required" });
19
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Vector name is required" });
20
20
  }
21
21
  const vector = mastra.getVector(vectorName);
22
22
  if (!vector) {
23
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
24
24
  }
25
25
  return vector;
26
26
  }
27
27
  async function upsertVectors({ mastra, vectorName, index }) {
28
28
  try {
29
29
  if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
30
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
31
31
  }
32
32
  const vector = getVector(mastra, vectorName);
33
33
  const result = await vector.upsert(index);
34
34
  return { ids: result };
35
35
  } catch (error) {
36
- return chunk64U3UDTH_cjs.handleError(error, "Error upserting vectors");
36
+ return chunkPZQDCRPV_cjs.handleError(error, "Error upserting vectors");
37
37
  }
38
38
  }
39
39
  async function createIndex({
@@ -44,18 +44,18 @@ async function createIndex({
44
44
  try {
45
45
  const { indexName, dimension, metric } = index;
46
46
  if (!indexName || typeof dimension !== "number" || dimension <= 0) {
47
- throw new chunkOCWPVYNI_cjs.HTTPException(400, {
47
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, {
48
48
  message: "Invalid request index, indexName and positive dimension number are required."
49
49
  });
50
50
  }
51
51
  if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
52
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
53
53
  }
54
54
  const vector = getVector(mastra, vectorName);
55
55
  await vector.createIndex({ indexName, dimension, metric });
56
56
  return { success: true };
57
57
  } catch (error) {
58
- return chunk64U3UDTH_cjs.handleError(error, "Error creating index");
58
+ return chunkPZQDCRPV_cjs.handleError(error, "Error creating index");
59
59
  }
60
60
  }
61
61
  async function queryVectors({
@@ -65,13 +65,13 @@ async function queryVectors({
65
65
  }) {
66
66
  try {
67
67
  if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
69
69
  }
70
70
  const vector = getVector(mastra, vectorName);
71
71
  const results = await vector.query(query);
72
72
  return results;
73
73
  } catch (error) {
74
- return chunk64U3UDTH_cjs.handleError(error, "Error querying vectors");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error querying vectors");
75
75
  }
76
76
  }
77
77
  async function listIndexes({ mastra, vectorName }) {
@@ -80,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
80
80
  const indexes = await vector.listIndexes();
81
81
  return indexes.filter(Boolean);
82
82
  } catch (error) {
83
- return chunk64U3UDTH_cjs.handleError(error, "Error listing indexes");
83
+ return chunkPZQDCRPV_cjs.handleError(error, "Error listing indexes");
84
84
  }
85
85
  }
86
86
  async function describeIndex({
@@ -90,7 +90,7 @@ async function describeIndex({
90
90
  }) {
91
91
  try {
92
92
  if (!indexName) {
93
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
93
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
94
94
  }
95
95
  const vector = getVector(mastra, vectorName);
96
96
  const stats = await vector.describeIndex({ indexName });
@@ -100,7 +100,7 @@ async function describeIndex({
100
100
  metric: stats.metric?.toLowerCase()
101
101
  };
102
102
  } catch (error) {
103
- return chunk64U3UDTH_cjs.handleError(error, "Error describing index");
103
+ return chunkPZQDCRPV_cjs.handleError(error, "Error describing index");
104
104
  }
105
105
  }
106
106
  async function deleteIndex({
@@ -110,13 +110,13 @@ async function deleteIndex({
110
110
  }) {
111
111
  try {
112
112
  if (!indexName) {
113
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
113
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
114
114
  }
115
115
  const vector = getVector(mastra, vectorName);
116
116
  await vector.deleteIndex({ indexName });
117
117
  return { success: true };
118
118
  } catch (error) {
119
- return chunk64U3UDTH_cjs.handleError(error, "Error deleting index");
119
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting index");
120
120
  }
121
121
  }
122
122