@mastra/server 0.0.0-feat-tool-input-validation-20250731232758 → 0.0.0-feat-support-ai-sdk-5-again-20250813225910

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 (204) hide show
  1. package/dist/{chunk-GHC4YV6R.js → chunk-25LDKW7R.js} +109 -136
  2. package/dist/chunk-25LDKW7R.js.map +1 -0
  3. package/dist/{chunk-4D66QEKC.js → chunk-4MQU6AJN.js} +5 -3
  4. package/dist/chunk-4MQU6AJN.js.map +1 -0
  5. package/dist/{chunk-CCGRCYWJ.cjs → chunk-4QSNRCOT.cjs} +4 -2
  6. package/dist/chunk-4QSNRCOT.cjs.map +1 -0
  7. package/dist/{chunk-RHSWAXKB.cjs → chunk-4US5W7PH.cjs} +26 -24
  8. package/dist/chunk-4US5W7PH.cjs.map +1 -0
  9. package/dist/{chunk-36BLNJHS.js → chunk-7FHF55WA.js} +2 -0
  10. package/dist/chunk-7FHF55WA.js.map +1 -0
  11. package/dist/{chunk-2KZFMI6P.cjs → chunk-7NADHFD2.cjs} +2 -0
  12. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  13. package/dist/{chunk-QGX47B5D.cjs → chunk-BED2O446.cjs} +11 -9
  14. package/dist/chunk-BED2O446.cjs.map +1 -0
  15. package/dist/{chunk-T7HAZC2E.js → chunk-BUOJL3MN.js} +6 -4
  16. package/dist/chunk-BUOJL3MN.js.map +1 -0
  17. package/dist/{chunk-2SLFAFTR.cjs → chunk-CERIVHRO.cjs} +26 -21
  18. package/dist/chunk-CERIVHRO.cjs.map +1 -0
  19. package/dist/{chunk-LF7P5PLR.js → chunk-CY4TP3FK.js} +3 -1
  20. package/dist/chunk-CY4TP3FK.js.map +1 -0
  21. package/dist/{chunk-WNVFNNWN.js → chunk-G7NVCO5M.js} +5 -3
  22. package/dist/chunk-G7NVCO5M.js.map +1 -0
  23. package/dist/{chunk-KHZKYUNR.js → chunk-HWHKM67I.js} +6 -4
  24. package/dist/chunk-HWHKM67I.js.map +1 -0
  25. package/dist/{chunk-CRCR3ZUK.js → chunk-HXZTRBY4.js} +16 -11
  26. package/dist/chunk-HXZTRBY4.js.map +1 -0
  27. package/dist/{chunk-G7KH752Y.cjs → chunk-ILCWPBYQ.cjs} +9 -7
  28. package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
  29. package/dist/{chunk-UCV4247U.cjs → chunk-JGVY3KWV.cjs} +47 -45
  30. package/dist/chunk-JGVY3KWV.cjs.map +1 -0
  31. package/dist/{chunk-PIAJQ75M.js → chunk-KXXJ7Y4H.js} +64 -11
  32. package/dist/chunk-KXXJ7Y4H.js.map +1 -0
  33. package/dist/{chunk-6T5JUKOQ.js → chunk-L7YG7WQH.js} +5 -3
  34. package/dist/chunk-L7YG7WQH.js.map +1 -0
  35. package/dist/{chunk-HISYIDYH.cjs → chunk-LRUH33B4.cjs} +2 -0
  36. package/dist/chunk-LRUH33B4.cjs.map +1 -0
  37. package/dist/{chunk-UEVYOKAH.cjs → chunk-LZASFI6W.cjs} +118 -64
  38. package/dist/chunk-LZASFI6W.cjs.map +1 -0
  39. package/dist/{chunk-LCM566I4.js → chunk-MMROOK5J.js} +2 -0
  40. package/dist/chunk-MMROOK5J.js.map +1 -0
  41. package/dist/{chunk-7TP2LX5L.cjs → chunk-NCS2OXX6.cjs} +20 -18
  42. package/dist/chunk-NCS2OXX6.cjs.map +1 -0
  43. package/dist/{chunk-HRSAZUIK.cjs → chunk-O4I563YW.cjs} +24 -22
  44. package/dist/chunk-O4I563YW.cjs.map +1 -0
  45. package/dist/{chunk-RSEO4XPX.js → chunk-OW4FX5TS.js} +3 -1
  46. package/dist/chunk-OW4FX5TS.js.map +1 -0
  47. package/dist/{chunk-MLKGABMK.js → chunk-PZ5AY32C.js} +2 -0
  48. package/dist/chunk-PZ5AY32C.js.map +1 -0
  49. package/dist/{chunk-I5JKUCGE.cjs → chunk-Q4OQ4DOR.cjs} +67 -41
  50. package/dist/chunk-Q4OQ4DOR.cjs.map +1 -0
  51. package/dist/{chunk-75ZPJI57.cjs → chunk-Q7SFCCGT.cjs} +2 -0
  52. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  53. package/dist/{chunk-PZQDCRPV.cjs → chunk-RE4RPXT2.cjs} +4 -2
  54. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  55. package/dist/{chunk-424T5F2J.cjs → chunk-RQQNZZAI.cjs} +10 -8
  56. package/dist/chunk-RQQNZZAI.cjs.map +1 -0
  57. package/dist/{chunk-6KP2OBYA.cjs → chunk-S37KCGOR.cjs} +88 -86
  58. package/dist/chunk-S37KCGOR.cjs.map +1 -0
  59. package/dist/{chunk-RG473F6Y.js → chunk-SQ7KKIH3.js} +5 -3
  60. package/dist/chunk-SQ7KKIH3.js.map +1 -0
  61. package/dist/{chunk-VTTN2FW3.js → chunk-SXXGIMWO.js} +45 -20
  62. package/dist/chunk-SXXGIMWO.js.map +1 -0
  63. package/dist/{chunk-ZYAFP2AV.js → chunk-UVOSITKU.js} +6 -4
  64. package/dist/chunk-UVOSITKU.js.map +1 -0
  65. package/dist/{chunk-SDPGVWQJ.cjs → chunk-WNK42E5I.cjs} +110 -137
  66. package/dist/chunk-WNK42E5I.cjs.map +1 -0
  67. package/dist/{chunk-WBRFIHSF.js → chunk-YS66MFDY.js} +7 -5
  68. package/dist/chunk-YS66MFDY.js.map +1 -0
  69. package/dist/index.cjs +2 -0
  70. package/dist/index.cjs.map +1 -0
  71. package/dist/index.d.ts +1 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +2 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/server/a2a/protocol.d.ts +8 -0
  76. package/dist/server/a2a/protocol.d.ts.map +1 -0
  77. package/dist/server/a2a/store.cjs +25 -0
  78. package/dist/server/a2a/store.cjs.map +1 -0
  79. package/dist/server/a2a/store.d.ts +14 -0
  80. package/dist/server/a2a/store.d.ts.map +1 -0
  81. package/dist/server/a2a/store.js +23 -0
  82. package/dist/server/a2a/store.js.map +1 -0
  83. package/dist/server/a2a/tasks.d.ts +20 -0
  84. package/dist/server/a2a/tasks.d.ts.map +1 -0
  85. package/dist/server/handlers/a2a.cjs +13 -11
  86. package/dist/server/handlers/a2a.cjs.map +1 -0
  87. package/dist/server/handlers/a2a.d.ts +68 -6
  88. package/dist/server/handlers/a2a.d.ts.map +1 -0
  89. package/dist/server/handlers/a2a.js +3 -1
  90. package/dist/server/handlers/a2a.js.map +1 -0
  91. package/dist/server/handlers/agents.cjs +14 -8
  92. package/dist/server/handlers/agents.cjs.map +1 -0
  93. package/dist/server/handlers/agents.d.ts +89 -7
  94. package/dist/server/handlers/agents.d.ts.map +1 -0
  95. package/dist/server/handlers/agents.js +3 -1
  96. package/dist/server/handlers/agents.js.map +1 -0
  97. package/dist/server/handlers/error.cjs +4 -2
  98. package/dist/server/handlers/error.cjs.map +1 -0
  99. package/dist/server/handlers/error.d.ts +2 -1
  100. package/dist/server/handlers/error.d.ts.map +1 -0
  101. package/dist/server/handlers/error.js +3 -1
  102. package/dist/server/handlers/error.js.map +1 -0
  103. package/dist/server/handlers/legacyWorkflows.cjs +13 -11
  104. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  105. package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
  106. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  107. package/dist/server/handlers/legacyWorkflows.js +3 -1
  108. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  109. package/dist/server/handlers/logs.cjs +6 -4
  110. package/dist/server/handlers/logs.cjs.map +1 -0
  111. package/dist/server/handlers/logs.d.ts +34 -3
  112. package/dist/server/handlers/logs.d.ts.map +1 -0
  113. package/dist/server/handlers/logs.js +3 -1
  114. package/dist/server/handlers/logs.js.map +1 -0
  115. package/dist/server/handlers/memory.cjs +21 -15
  116. package/dist/server/handlers/memory.cjs.map +1 -0
  117. package/dist/server/handlers/memory.d.ts +121 -14
  118. package/dist/server/handlers/memory.d.ts.map +1 -0
  119. package/dist/server/handlers/memory.js +3 -1
  120. package/dist/server/handlers/memory.js.map +1 -0
  121. package/dist/server/handlers/network.cjs +7 -5
  122. package/dist/server/handlers/network.cjs.map +1 -0
  123. package/dist/server/handlers/network.d.ts +51 -4
  124. package/dist/server/handlers/network.d.ts.map +1 -0
  125. package/dist/server/handlers/network.js +3 -1
  126. package/dist/server/handlers/network.js.map +1 -0
  127. package/dist/server/handlers/scores.cjs +9 -7
  128. package/dist/server/handlers/scores.cjs.map +1 -0
  129. package/dist/server/handlers/scores.d.ts +49 -6
  130. package/dist/server/handlers/scores.d.ts.map +1 -0
  131. package/dist/server/handlers/scores.js +3 -1
  132. package/dist/server/handlers/scores.js.map +1 -0
  133. package/dist/server/handlers/telemetry.cjs +5 -3
  134. package/dist/server/handlers/telemetry.cjs.map +1 -0
  135. package/dist/server/handlers/telemetry.d.ts +32 -2
  136. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  137. package/dist/server/handlers/telemetry.js +3 -1
  138. package/dist/server/handlers/telemetry.js.map +1 -0
  139. package/dist/server/handlers/tools.cjs +7 -5
  140. package/dist/server/handlers/tools.cjs.map +1 -0
  141. package/dist/server/handlers/tools.d.ts +21 -4
  142. package/dist/server/handlers/tools.d.ts.map +1 -0
  143. package/dist/server/handlers/tools.js +3 -1
  144. package/dist/server/handlers/tools.js.map +1 -0
  145. package/dist/server/handlers/utils.cjs +4 -2
  146. package/dist/server/handlers/utils.cjs.map +1 -0
  147. package/dist/server/handlers/utils.d.ts +2 -1
  148. package/dist/server/handlers/utils.d.ts.map +1 -0
  149. package/dist/server/handlers/utils.js +3 -1
  150. package/dist/server/handlers/utils.js.map +1 -0
  151. package/dist/server/handlers/vNextNetwork.cjs +25 -23
  152. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  153. package/dist/server/handlers/vNextNetwork.d.ts +179 -6
  154. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  155. package/dist/server/handlers/vNextNetwork.js +6 -4
  156. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  157. package/dist/server/handlers/vector.cjs +9 -7
  158. package/dist/server/handlers/vector.cjs.map +1 -0
  159. package/dist/server/handlers/vector.d.ts +51 -6
  160. package/dist/server/handlers/vector.d.ts.map +1 -0
  161. package/dist/server/handlers/vector.js +3 -1
  162. package/dist/server/handlers/vector.js.map +1 -0
  163. package/dist/server/handlers/voice.cjs +7 -5
  164. package/dist/server/handlers/voice.cjs.map +1 -0
  165. package/dist/server/handlers/voice.d.ts +39 -4
  166. package/dist/server/handlers/voice.d.ts.map +1 -0
  167. package/dist/server/handlers/voice.js +3 -1
  168. package/dist/server/handlers/voice.js.map +1 -0
  169. package/dist/server/handlers/workflows.cjs +18 -16
  170. package/dist/server/handlers/workflows.cjs.map +1 -0
  171. package/dist/server/handlers/workflows.d.ts +88 -15
  172. package/dist/server/handlers/workflows.d.ts.map +1 -0
  173. package/dist/server/handlers/workflows.js +3 -1
  174. package/dist/server/handlers/workflows.js.map +1 -0
  175. package/dist/server/handlers.cjs +32 -30
  176. package/dist/server/handlers.cjs.map +1 -0
  177. package/dist/server/handlers.d.ts +13 -12
  178. package/dist/server/handlers.d.ts.map +1 -0
  179. package/dist/server/handlers.js +14 -12
  180. package/dist/server/handlers.js.map +1 -0
  181. package/dist/server/http-exception.d.ts +87 -0
  182. package/dist/server/http-exception.d.ts.map +1 -0
  183. package/dist/server/types.d.ts +10 -0
  184. package/dist/server/types.d.ts.map +1 -0
  185. package/package.json +21 -10
  186. package/dist/_tsup-dts-rollup.d.cts +0 -1260
  187. package/dist/_tsup-dts-rollup.d.ts +0 -1260
  188. package/dist/index.d.cts +0 -1
  189. package/dist/server/handlers/a2a.d.cts +0 -6
  190. package/dist/server/handlers/agents.d.cts +0 -7
  191. package/dist/server/handlers/error.d.cts +0 -1
  192. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  193. package/dist/server/handlers/logs.d.cts +0 -3
  194. package/dist/server/handlers/memory.d.cts +0 -14
  195. package/dist/server/handlers/network.d.cts +0 -4
  196. package/dist/server/handlers/scores.d.cts +0 -6
  197. package/dist/server/handlers/telemetry.d.cts +0 -2
  198. package/dist/server/handlers/tools.d.cts +0 -4
  199. package/dist/server/handlers/utils.d.cts +0 -1
  200. package/dist/server/handlers/vNextNetwork.d.cts +0 -6
  201. package/dist/server/handlers/vector.d.cts +0 -6
  202. package/dist/server/handlers/voice.d.cts +0 -4
  203. package/dist/server/handlers/workflows.d.cts +0 -15
  204. package/dist/server/handlers.d.cts +0 -12
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkHISYIDYH_cjs = require('./chunk-HISYIDYH.cjs');
4
- var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
- var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
3
+ var chunkLRUH33B4_cjs = require('./chunk-LRUH33B4.cjs');
4
+ var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
5
+ var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
6
+ var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
7
7
  var web = require('stream/web');
8
8
 
9
9
  // src/server/handlers/legacyWorkflows.ts
10
10
  var legacyWorkflows_exports = {};
11
- chunk75ZPJI57_cjs.__export(legacyWorkflows_exports, {
11
+ chunkQ7SFCCGT_cjs.__export(legacyWorkflows_exports, {
12
12
  createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
13
13
  getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
14
14
  getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
@@ -31,15 +31,15 @@ async function getLegacyWorkflowsHandler({ mastra }) {
31
31
  serializedStepGraph: workflow.serializedStepGraph,
32
32
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
33
33
  name: workflow.name,
34
- triggerSchema: workflow.triggerSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
+ triggerSchema: workflow.triggerSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.triggerSchema)) : void 0,
35
35
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
36
36
  const _step = step;
37
37
  acc2[key2] = {
38
38
  id: _step.id,
39
39
  description: _step.description,
40
40
  workflowId: _step.workflowId,
41
- inputSchema: _step.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_step.inputSchema)) : void 0,
42
- outputSchema: _step.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_step.outputSchema)) : void 0
41
+ inputSchema: _step.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(_step.inputSchema)) : void 0,
42
+ outputSchema: _step.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(_step.outputSchema)) : void 0
43
43
  };
44
44
  return acc2;
45
45
  }, {})
@@ -48,17 +48,17 @@ async function getLegacyWorkflowsHandler({ mastra }) {
48
48
  }, {});
49
49
  return _workflows;
50
50
  } catch (error) {
51
- return chunkPZQDCRPV_cjs.handleError(error, "error getting workflows");
51
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflows");
52
52
  }
53
53
  }
54
54
  async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
55
55
  try {
56
56
  if (!workflowId) {
57
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
57
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
58
58
  }
59
59
  const workflow = mastra.legacy_getWorkflow(workflowId);
60
60
  if (!workflow) {
61
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
61
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
62
62
  }
63
63
  return {
64
64
  stepGraph: workflow.stepGraph,
@@ -66,21 +66,21 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
66
66
  serializedStepGraph: workflow.serializedStepGraph,
67
67
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
68
68
  name: workflow.name,
69
- triggerSchema: workflow.triggerSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.triggerSchema)) : void 0,
69
+ triggerSchema: workflow.triggerSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.triggerSchema)) : void 0,
70
70
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
71
71
  const _step = step;
72
72
  acc[key] = {
73
73
  id: _step.id,
74
74
  description: _step.description,
75
75
  workflowId: _step.workflowId,
76
- inputSchema: _step.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_step.inputSchema)) : void 0,
77
- outputSchema: _step.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(_step.outputSchema)) : void 0
76
+ inputSchema: _step.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(_step.inputSchema)) : void 0,
77
+ outputSchema: _step.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(_step.outputSchema)) : void 0
78
78
  };
79
79
  return acc;
80
80
  }, {})
81
81
  };
82
82
  } catch (error) {
83
- return chunkPZQDCRPV_cjs.handleError(error, "error getting workflow by id");
83
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflow by id");
84
84
  }
85
85
  }
86
86
  async function startAsyncLegacyWorkflowHandler({
@@ -92,11 +92,11 @@ async function startAsyncLegacyWorkflowHandler({
92
92
  }) {
93
93
  try {
94
94
  if (!workflowId) {
95
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
95
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
96
96
  }
97
97
  const workflow = mastra.legacy_getWorkflow(workflowId);
98
98
  if (!workflow) {
99
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
99
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
100
100
  }
101
101
  if (!runId) {
102
102
  const newRun = workflow.createRun();
@@ -108,7 +108,7 @@ async function startAsyncLegacyWorkflowHandler({
108
108
  }
109
109
  const run = workflow.getMemoryRun(runId);
110
110
  if (!run) {
111
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
111
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
112
112
  }
113
113
  const result = await run.start({
114
114
  triggerData,
@@ -116,7 +116,7 @@ async function startAsyncLegacyWorkflowHandler({
116
116
  });
117
117
  return result;
118
118
  } catch (error) {
119
- return chunkPZQDCRPV_cjs.handleError(error, "error starting workflow");
119
+ return chunkRE4RPXT2_cjs.handleError(error, "error starting workflow");
120
120
  }
121
121
  }
122
122
  async function getLegacyWorkflowRunHandler({
@@ -126,22 +126,22 @@ async function getLegacyWorkflowRunHandler({
126
126
  }) {
127
127
  try {
128
128
  if (!workflowId) {
129
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
129
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
130
130
  }
131
131
  if (!runId) {
132
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
132
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
133
133
  }
134
134
  const workflow = mastra.legacy_getWorkflow(workflowId);
135
135
  if (!workflow) {
136
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
136
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
137
137
  }
138
138
  const run = await workflow.getRun(runId);
139
139
  if (!run) {
140
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
140
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
141
141
  }
142
142
  return run;
143
143
  } catch (error) {
144
- return chunkPZQDCRPV_cjs.handleError(error, "error getting workflow run");
144
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflow run");
145
145
  }
146
146
  }
147
147
  async function createLegacyWorkflowRunHandler({
@@ -151,16 +151,16 @@ async function createLegacyWorkflowRunHandler({
151
151
  }) {
152
152
  try {
153
153
  if (!workflowId) {
154
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
155
155
  }
156
156
  const workflow = mastra.legacy_getWorkflow(workflowId);
157
157
  if (!workflow) {
158
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
158
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
159
159
  }
160
160
  const newRun = workflow.createRun({ runId: prevRunId });
161
161
  return { runId: newRun.runId };
162
162
  } catch (error) {
163
- return chunkPZQDCRPV_cjs.handleError(error, "error creating workflow run");
163
+ return chunkRE4RPXT2_cjs.handleError(error, "error creating workflow run");
164
164
  }
165
165
  }
166
166
  async function startLegacyWorkflowRunHandler({
@@ -172,15 +172,15 @@ async function startLegacyWorkflowRunHandler({
172
172
  }) {
173
173
  try {
174
174
  if (!workflowId) {
175
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
175
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
176
176
  }
177
177
  if (!runId) {
178
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to start run" });
178
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
179
179
  }
180
180
  const workflow = mastra.legacy_getWorkflow(workflowId);
181
181
  const run = workflow.getMemoryRun(runId);
182
182
  if (!run) {
183
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
183
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
184
184
  }
185
185
  void run.start({
186
186
  triggerData,
@@ -188,7 +188,7 @@ async function startLegacyWorkflowRunHandler({
188
188
  });
189
189
  return { message: "Workflow run started" };
190
190
  } catch (e) {
191
- return chunkPZQDCRPV_cjs.handleError(e, "Error starting workflow run");
191
+ return chunkRE4RPXT2_cjs.handleError(e, "Error starting workflow run");
192
192
  }
193
193
  }
194
194
  async function watchLegacyWorkflowHandler({
@@ -198,15 +198,15 @@ async function watchLegacyWorkflowHandler({
198
198
  }) {
199
199
  try {
200
200
  if (!workflowId) {
201
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
201
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
202
202
  }
203
203
  if (!runId) {
204
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to watch workflow" });
204
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
205
205
  }
206
206
  const workflow = mastra.legacy_getWorkflow(workflowId);
207
207
  const run = workflow.getMemoryRun(runId);
208
208
  if (!run) {
209
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
209
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
210
210
  }
211
211
  let unwatch;
212
212
  let asyncRef = null;
@@ -234,7 +234,7 @@ async function watchLegacyWorkflowHandler({
234
234
  });
235
235
  return stream;
236
236
  } catch (error) {
237
- return chunkPZQDCRPV_cjs.handleError(error, "Error watching workflow");
237
+ return chunkRE4RPXT2_cjs.handleError(error, "Error watching workflow");
238
238
  }
239
239
  }
240
240
  async function resumeAsyncLegacyWorkflowHandler({
@@ -246,15 +246,15 @@ async function resumeAsyncLegacyWorkflowHandler({
246
246
  }) {
247
247
  try {
248
248
  if (!workflowId) {
249
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
249
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
250
250
  }
251
251
  if (!runId) {
252
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
252
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
253
253
  }
254
254
  const workflow = mastra.legacy_getWorkflow(workflowId);
255
255
  const run = workflow.getMemoryRun(runId);
256
256
  if (!run) {
257
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
257
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
258
258
  }
259
259
  const result = await run.resume({
260
260
  stepId: body.stepId,
@@ -263,7 +263,7 @@ async function resumeAsyncLegacyWorkflowHandler({
263
263
  });
264
264
  return result;
265
265
  } catch (error) {
266
- return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow step");
266
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow step");
267
267
  }
268
268
  }
269
269
  async function resumeLegacyWorkflowHandler({
@@ -275,15 +275,15 @@ async function resumeLegacyWorkflowHandler({
275
275
  }) {
276
276
  try {
277
277
  if (!workflowId) {
278
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
278
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
279
279
  }
280
280
  if (!runId) {
281
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
281
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
282
282
  }
283
283
  const workflow = mastra.legacy_getWorkflow(workflowId);
284
284
  const run = workflow.getMemoryRun(runId);
285
285
  if (!run) {
286
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
286
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
287
287
  }
288
288
  void run.resume({
289
289
  stepId: body.stepId,
@@ -292,7 +292,7 @@ async function resumeLegacyWorkflowHandler({
292
292
  });
293
293
  return { message: "Workflow run resumed" };
294
294
  } catch (error) {
295
- return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow");
295
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
296
296
  }
297
297
  }
298
298
  async function getLegacyWorkflowRunsHandler({
@@ -306,7 +306,7 @@ async function getLegacyWorkflowRunsHandler({
306
306
  }) {
307
307
  try {
308
308
  if (!workflowId) {
309
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
309
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
310
310
  }
311
311
  const workflow = mastra.legacy_getWorkflow(workflowId);
312
312
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
@@ -315,7 +315,7 @@ async function getLegacyWorkflowRunsHandler({
315
315
  };
316
316
  return workflowRuns;
317
317
  } catch (error) {
318
- return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow runs");
318
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow runs");
319
319
  }
320
320
  }
321
321
 
@@ -330,3 +330,5 @@ exports.resumeLegacyWorkflowHandler = resumeLegacyWorkflowHandler;
330
330
  exports.startAsyncLegacyWorkflowHandler = startAsyncLegacyWorkflowHandler;
331
331
  exports.startLegacyWorkflowRunHandler = startLegacyWorkflowRunHandler;
332
332
  exports.watchLegacyWorkflowHandler = watchLegacyWorkflowHandler;
333
+ //# sourceMappingURL=chunk-JGVY3KWV.cjs.map
334
+ //# sourceMappingURL=chunk-JGVY3KWV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/legacyWorkflows.ts"],"names":["__export","stringify","esm_default","acc","key","handleError","HTTPException","result","ReadableStream","runId"],"mappings":";;;;;;;;;AAAA,IAAA,uBAAA,GAAA;AAAAA,0BAAA,CAAA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,EAAY,CAAA,IAAM;AAAA,MACxG,MAAM,EAAC;AAAA,MACP,KAAA,EAAO;AAAA,KACT;AACA,IAAA,OAAO,YAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,6BAA6B,CAAA;AAAA,EACzD;AACF","file":"chunk-JGVY3KWV.cjs","sourcesContent":["import { ReadableStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport type { LegacyWorkflowRuns } from '@mastra/core/storage';\nimport type { LegacyWorkflow } from '@mastra/core/workflows/legacy';\nimport { stringify } from 'superjson';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getLegacyWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.legacy_getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<any>((acc, [key, workflow]) => {\n if (workflow.isNested) return acc;\n acc[key] = {\n stepGraph: workflow.stepGraph,\n stepSubscriberGraph: workflow.stepSubscriberGraph,\n serializedStepGraph: workflow.serializedStepGraph,\n serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,\n name: workflow.name,\n triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : undefined,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n const _step = step as any;\n acc[key] = {\n id: _step.id,\n description: _step.description,\n workflowId: _step.workflowId,\n inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : undefined,\n outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : undefined,\n };\n return acc;\n }, {}),\n };\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'error getting workflows');\n }\n}\n\nexport async function getLegacyWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return {\n stepGraph: workflow.stepGraph,\n stepSubscriberGraph: workflow.stepSubscriberGraph,\n serializedStepGraph: workflow.serializedStepGraph,\n serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,\n name: workflow.name,\n triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : undefined,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n const _step = step as any;\n acc[key] = {\n id: _step.id,\n description: _step.description,\n workflowId: _step.workflowId,\n inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : undefined,\n outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : undefined,\n };\n return acc;\n }, {}),\n };\n } catch (error) {\n return handleError(error, 'error getting workflow by id');\n }\n}\n\nexport async function startAsyncLegacyWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n triggerData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n triggerData?: unknown;\n runtimeContext: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (!runId) {\n const newRun = workflow.createRun();\n const result = await newRun.start({\n triggerData,\n runtimeContext,\n });\n return result;\n }\n\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n // const newRun = workflow.createRun({ runId });\n\n const result = await run.start({\n triggerData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'error starting workflow');\n }\n}\n\nexport async function getLegacyWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<LegacyWorkflow['getRun']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'error getting workflow run');\n }\n}\n\nexport async function createLegacyWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const newRun = workflow.createRun({ runId: prevRunId });\n\n return { runId: newRun.runId };\n } catch (error) {\n return handleError(error, 'error creating workflow run');\n }\n}\n\nexport async function startLegacyWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n triggerData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n triggerData?: unknown;\n runtimeContext: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n void run.start({\n triggerData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = run.watch(({ activePaths, runId, timestamp, results }) => {\n const activePathsObj = Object.fromEntries(activePaths);\n controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId, timestamp, results }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if none of the active paths is currently being executed\n asyncRef = setImmediate(() => {\n const runDone = Object.values(activePathsObj).every(value => value.status !== 'executing');\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n });\n },\n cancel() {\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function resumeAsyncLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & { body: { stepId: string; context: any }; runtimeContext: RuntimeContext }) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n // const newRun = workflow.createRun({ runId });\n\n const result = await run.resume({\n stepId: body.stepId,\n context: body.context,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & { body: { stepId: string; context: any }; runtimeContext: RuntimeContext }) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n void run.resume({\n stepId: body.stepId,\n context: body.context,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getLegacyWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<LegacyWorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { validateBody } from './chunk-RSEO4XPX.js';
2
- import { handleError } from './chunk-LF7P5PLR.js';
3
- import { HTTPException } from './chunk-LCM566I4.js';
4
- import { __export } from './chunk-MLKGABMK.js';
1
+ import { validateBody } from './chunk-OW4FX5TS.js';
2
+ import { handleError } from './chunk-CY4TP3FK.js';
3
+ import { HTTPException } from './chunk-MMROOK5J.js';
4
+ import { __export } from './chunk-PZ5AY32C.js';
5
5
  import { generateEmptyFromSchema } from '@mastra/core';
6
6
 
7
7
  // src/server/handlers/memory.ts
@@ -16,6 +16,7 @@ __export(memory_exports, {
16
16
  getMessagesPaginatedHandler: () => getMessagesPaginatedHandler,
17
17
  getThreadByIdHandler: () => getThreadByIdHandler,
18
18
  getThreadsHandler: () => getThreadsHandler,
19
+ getThreadsPaginatedHandler: () => getThreadsPaginatedHandler,
19
20
  getWorkingMemoryHandler: () => getWorkingMemoryHandler,
20
21
  saveMessagesHandler: () => saveMessagesHandler,
21
22
  searchMemoryHandler: () => searchMemoryHandler,
@@ -102,6 +103,35 @@ async function getThreadsHandler({
102
103
  return handleError(error, "Error getting threads");
103
104
  }
104
105
  }
106
+ async function getThreadsPaginatedHandler({
107
+ mastra,
108
+ agentId,
109
+ resourceId,
110
+ networkId,
111
+ runtimeContext,
112
+ page,
113
+ perPage,
114
+ orderBy,
115
+ sortDirection
116
+ }) {
117
+ try {
118
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
119
+ if (!memory) {
120
+ throw new HTTPException(400, { message: "Memory is not initialized" });
121
+ }
122
+ validateBody({ resourceId });
123
+ const result = await memory.getThreadsByResourceIdPaginated({
124
+ resourceId,
125
+ page,
126
+ perPage,
127
+ orderBy,
128
+ sortDirection
129
+ });
130
+ return result;
131
+ } catch (error) {
132
+ return handleError(error, "Error getting paginated threads");
133
+ }
134
+ }
105
135
  async function getThreadByIdHandler({
106
136
  mastra,
107
137
  agentId,
@@ -271,6 +301,8 @@ async function getMessagesHandler({
271
301
  agentId,
272
302
  threadId,
273
303
  limit,
304
+ format,
305
+ clientSdkCompat,
274
306
  networkId,
275
307
  runtimeContext
276
308
  }) {
@@ -291,6 +323,17 @@ async function getMessagesHandler({
291
323
  threadId,
292
324
  ...limit && { selectBy: { last: limit } }
293
325
  });
326
+ let useV4Format = false;
327
+ if (format === "aiv4") {
328
+ useV4Format = true;
329
+ } else if (format === "aiv5") {
330
+ useV4Format = false;
331
+ } else {
332
+ useV4Format = clientSdkCompat === "v4" || mastra.getAiSdkCompatMode() === "v4";
333
+ }
334
+ if (useV4Format) {
335
+ return { messages: result.messages, uiMessages: result.uiMessagesV4 };
336
+ }
294
337
  return { messages: result.messages, uiMessages: result.uiMessages };
295
338
  } catch (error) {
296
339
  return handleError(error, "Error getting messages");
@@ -434,7 +477,7 @@ async function searchMemoryHandler({
434
477
  vectorMessageSearch: searchQuery,
435
478
  config
436
479
  });
437
- const threadMessages = (await memory.query({ threadId: thread.id })).uiMessages;
480
+ const threadMessages = (await memory.query({ threadId: thread.id, format: "v2" })).uiMessages;
438
481
  result.messagesV2.forEach((msg) => {
439
482
  if (messageMap.has(msg.id)) return;
440
483
  messageMap.set(msg.id, true);
@@ -456,13 +499,17 @@ async function searchMemoryHandler({
456
499
  before: threadMessages.slice(Math.max(0, messageIndex - 2), messageIndex).map((m) => ({
457
500
  id: m.id,
458
501
  role: m.role,
459
- content: m.content,
502
+ content: m.parts.map((p) => p.type === `text` ? p.text : null).filter(Boolean).join(`
503
+ `),
504
+ // @ts-ignore
460
505
  createdAt: m.createdAt || /* @__PURE__ */ new Date()
461
506
  })),
462
507
  after: threadMessages.slice(messageIndex + 1, messageIndex + 3).map((m) => ({
463
508
  id: m.id,
464
509
  role: m.role,
465
- content: m.content,
510
+ content: m.parts.map((p) => p.type === `text` ? p.text : null).filter(Boolean).join(`
511
+ `),
512
+ // @ts-ignore
466
513
  createdAt: m.createdAt || /* @__PURE__ */ new Date()
467
514
  }))
468
515
  };
@@ -487,7 +534,7 @@ async function searchMemoryHandler({
487
534
  vectorMessageSearch: searchQuery,
488
535
  config
489
536
  });
490
- const threadMessages = (await memory.query({ threadId })).uiMessages;
537
+ const threadMessages = (await memory.query({ threadId, format: "v2" })).uiMessages;
491
538
  result.messagesV2.forEach((msg) => {
492
539
  if (messageMap.has(msg.id)) return;
493
540
  messageMap.set(msg.id, true);
@@ -509,13 +556,17 @@ async function searchMemoryHandler({
509
556
  before: threadMessages.slice(Math.max(0, messageIndex - 2), messageIndex).map((m) => ({
510
557
  id: m.id,
511
558
  role: m.role,
512
- content: m.content,
559
+ content: m.parts.map((p) => p.type === `text` ? p.text : null).filter(Boolean).join(`
560
+ `),
561
+ // @ts-ignore
513
562
  createdAt: m.createdAt || /* @__PURE__ */ new Date()
514
563
  })),
515
564
  after: threadMessages.slice(messageIndex + 1, messageIndex + 3).map((m) => ({
516
565
  id: m.id,
517
566
  role: m.role,
518
- content: m.content,
567
+ content: m.parts.map((p) => p.type === `text` ? p.text : null).filter(Boolean).join(`
568
+ `),
569
+ // @ts-ignore
519
570
  createdAt: m.createdAt || /* @__PURE__ */ new Date()
520
571
  }))
521
572
  };
@@ -536,4 +587,6 @@ async function searchMemoryHandler({
536
587
  }
537
588
  }
538
589
 
539
- export { createThreadHandler, deleteMessagesHandler, deleteThreadHandler, getMemoryConfigHandler, getMemoryStatusHandler, getMessagesHandler, getMessagesPaginatedHandler, getThreadByIdHandler, getThreadsHandler, getWorkingMemoryHandler, memory_exports, saveMessagesHandler, searchMemoryHandler, updateThreadHandler, updateWorkingMemoryHandler };
590
+ export { createThreadHandler, deleteMessagesHandler, deleteThreadHandler, getMemoryConfigHandler, getMemoryStatusHandler, getMessagesHandler, getMessagesPaginatedHandler, getThreadByIdHandler, getThreadsHandler, getThreadsPaginatedHandler, getWorkingMemoryHandler, memory_exports, saveMessagesHandler, searchMemoryHandler, updateThreadHandler, updateWorkingMemoryHandler };
591
+ //# sourceMappingURL=chunk-KXXJ7Y4H.js.map
592
+ //# sourceMappingURL=chunk-KXXJ7Y4H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/memory.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,cAAA,GAAA;AAAA,QAAA,CAAA,cAAA,EAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,kBAAA,EAAA,M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MACrB,KAAA,EAAO,WAAA;AAAA,MACP,WAAA,EAAa,gBAAgB,UAAA,GAAa,QAAA;AAAA,MAC1C,UAAA,EAAY,oBAAoB,UAAA,GAAa;AAAA,KAC/C;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,wBAAwB,CAAA;AAAA,EACpD;AACF","file":"chunk-KXXJ7Y4H.js","sourcesContent":["import { generateEmptyFromSchema } from '@mastra/core';\nimport type { StorageGetMessagesArg } from '@mastra/core';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { MastraMemory } from '@mastra/core/memory';\nimport type { ThreadSortOptions } from '@mastra/core/storage';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface MemoryContext extends Context {\n agentId?: string;\n resourceId?: string;\n threadId?: string;\n networkId?: string;\n runtimeContext?: RuntimeContext;\n}\n\nasync function getMemoryFromContext({\n mastra,\n agentId,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<\n MastraMemory | null | undefined\n> {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (agentId && !agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const network = networkId ? mastra.vnext_getNetwork(networkId) : null;\n\n if (networkId && !network) {\n throw new HTTPException(404, { message: 'Network not found' });\n }\n\n if (agent) {\n return (await agent?.getMemory()) || mastra.getMemory();\n }\n\n if (network) {\n return (await network?.getMemory({ runtimeContext })) || mastra.getMemory();\n }\n\n return mastra.getMemory();\n}\n\n// Memory handlers\nexport async function getMemoryStatusHandler({\n mastra,\n agentId,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n return { result: false };\n }\n\n return { result: true };\n } catch (error) {\n return handleError(error, 'Error getting memory status');\n }\n}\n\nexport async function getMemoryConfigHandler({\n mastra,\n agentId,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n // Get the merged configuration (defaults + custom)\n const config = memory.getMergedThreadConfig({});\n\n return { config };\n } catch (error) {\n return handleError(error, 'Error getting memory configuration');\n }\n}\n\nexport async function getThreadsHandler({\n mastra,\n agentId,\n resourceId,\n networkId,\n runtimeContext,\n orderBy,\n sortDirection,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'> & ThreadSortOptions) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n validateBody({ resourceId });\n\n const threads = await memory.getThreadsByResourceId({\n resourceId: resourceId!,\n orderBy,\n sortDirection,\n });\n return threads;\n } catch (error) {\n return handleError(error, 'Error getting threads');\n }\n}\n\nexport async function getThreadsPaginatedHandler({\n mastra,\n agentId,\n resourceId,\n networkId,\n runtimeContext,\n page,\n perPage,\n orderBy,\n sortDirection,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'> & {\n page: number;\n perPage: number;\n} & ThreadSortOptions) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n validateBody({ resourceId });\n\n const result = await memory.getThreadsByResourceIdPaginated({\n resourceId: resourceId!,\n page,\n perPage,\n orderBy,\n sortDirection,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error getting paginated threads');\n }\n}\n\nexport async function getThreadByIdHandler({\n mastra,\n agentId,\n threadId,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>) {\n try {\n validateBody({ threadId });\n\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n const thread = await memory.getThreadById({ threadId: threadId! });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n return thread;\n } catch (error) {\n return handleError(error, 'Error getting thread');\n }\n}\n\nexport async function saveMessagesHandler({\n mastra,\n agentId,\n body,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {\n body: {\n messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];\n };\n}) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n if (!body?.messages) {\n throw new HTTPException(400, { message: 'Messages are required' });\n }\n\n if (!Array.isArray(body.messages)) {\n throw new HTTPException(400, { message: 'Messages should be an array' });\n }\n\n // Validate that all messages have threadId and resourceId\n const invalidMessages = body.messages.filter(message => !message.threadId || !message.resourceId);\n if (invalidMessages.length > 0) {\n throw new HTTPException(400, {\n message: `All messages must have threadId and resourceId fields. Found ${invalidMessages.length} invalid message(s).`,\n });\n }\n\n const processedMessages = body.messages.map(message => ({\n ...message,\n id: message.id || memory.generateId(),\n createdAt: message.createdAt ? new Date(message.createdAt) : new Date(),\n }));\n\n const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });\n return result;\n } catch (error) {\n return handleError(error, 'Error saving messages');\n }\n}\n\nexport async function createThreadHandler({\n mastra,\n agentId,\n body,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {\n body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & { resourceId?: string };\n}) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n validateBody({ resourceId: body?.resourceId });\n\n const result = await memory.createThread({\n resourceId: body?.resourceId!,\n title: body?.title,\n metadata: body?.metadata,\n threadId: body?.threadId,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error saving thread to memory');\n }\n}\n\nexport async function updateThreadHandler({\n mastra,\n agentId,\n threadId,\n body,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {\n body?: Parameters<MastraMemory['saveThread']>[0]['thread'];\n}) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!body) {\n throw new HTTPException(400, { message: 'Body is required' });\n }\n\n const { title, metadata, resourceId } = body;\n const updatedAt = new Date();\n\n validateBody({ threadId });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n const thread = await memory.getThreadById({ threadId: threadId! });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n const updatedThread = {\n ...thread,\n title: title || thread.title,\n metadata: metadata || thread.metadata,\n resourceId: resourceId || thread.resourceId,\n createdAt: thread.createdAt,\n updatedAt,\n };\n\n const result = await memory.saveThread({ thread: updatedThread });\n return result;\n } catch (error) {\n return handleError(error, 'Error updating thread');\n }\n}\n\nexport async function deleteThreadHandler({\n mastra,\n agentId,\n threadId,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>) {\n try {\n validateBody({ threadId });\n\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n const thread = await memory.getThreadById({ threadId: threadId! });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n await memory.deleteThread(threadId!);\n return { result: 'Thread deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting thread');\n }\n}\n\nexport async function getMessagesPaginatedHandler({\n mastra,\n threadId,\n resourceId,\n selectBy,\n format,\n}: StorageGetMessagesArg & Pick<MemoryContext, 'mastra'>) {\n try {\n validateBody({ threadId });\n\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(400, { message: 'Storage is not initialized' });\n }\n\n const thread = await storage.getThreadById({ threadId: threadId! });\n\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n const result = await storage.getMessagesPaginated({ threadId: threadId!, resourceId, selectBy, format });\n return result;\n } catch (error) {\n return handleError(error, 'Error getting messages');\n }\n}\n\nexport async function getMessagesHandler({\n mastra,\n agentId,\n threadId,\n limit,\n format,\n clientSdkCompat,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {\n limit?: number;\n format?: 'aiv4' | 'aiv5';\n clientSdkCompat?: string;\n}) {\n if (limit !== undefined && (!Number.isInteger(limit) || limit <= 0)) {\n throw new HTTPException(400, { message: 'Invalid limit: must be a positive integer' });\n }\n try {\n validateBody({ threadId });\n\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n const thread = await memory.getThreadById({ threadId: threadId! });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n const result = await memory.query({\n threadId: threadId!,\n ...(limit && { selectBy: { last: limit } }),\n });\n\n // Determine format: explicit format parameter, auto-detection, or default to v5\n let useV4Format = false;\n if (format === 'aiv4') {\n useV4Format = true;\n } else if (format === 'aiv5') {\n useV4Format = false;\n } else {\n // No explicit format - check for client header override first, then fall back to Mastra config\n useV4Format = clientSdkCompat === 'v4' || mastra.getAiSdkCompatMode() === 'v4';\n }\n\n // Return appropriate format\n if (useV4Format) {\n return { messages: result.messages, uiMessages: result.uiMessagesV4 };\n }\n\n return { messages: result.messages, uiMessages: result.uiMessages };\n } catch (error) {\n return handleError(error, 'Error getting messages');\n }\n}\n\n/**\n * Handler to get the working memory for a thread (optionally resource-scoped).\n * @returns workingMemory - the working memory for the thread\n * @returns source - thread or resource\n */\nexport async function getWorkingMemoryHandler({\n mastra,\n agentId,\n threadId,\n resourceId,\n networkId,\n runtimeContext,\n memoryConfig,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {\n resourceId?: Parameters<MastraMemory['getWorkingMemory']>[0]['resourceId'];\n memoryConfig?: Parameters<MastraMemory['getWorkingMemory']>[0]['memoryConfig'];\n}) {\n try {\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n validateBody({ threadId });\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n const thread = await memory.getThreadById({ threadId: threadId! });\n const threadExists = !!thread;\n const template = await memory.getWorkingMemoryTemplate({ memoryConfig });\n const workingMemoryTemplate =\n template?.format === 'json'\n ? { ...template, content: JSON.stringify(generateEmptyFromSchema(template.content)) }\n : template;\n const workingMemory = await memory.getWorkingMemory({ threadId: threadId!, resourceId, memoryConfig });\n const config = memory.getMergedThreadConfig(memoryConfig || {});\n const source = config.workingMemory?.scope === 'resource' && resourceId ? 'resource' : 'thread';\n return { workingMemory, source, workingMemoryTemplate, threadExists };\n } catch (error) {\n return handleError(error, 'Error getting working memory');\n }\n}\n\n/**\n * Handler to update the working memory for a thread (optionally resource-scoped).\n * @param threadId - the thread id\n * @param body - the body containing the working memory to update and the resource id (optional)\n */\nexport async function updateWorkingMemoryHandler({\n mastra,\n agentId,\n threadId,\n body,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {\n body: Omit<Parameters<MastraMemory['updateWorkingMemory']>[0], 'threadId'>;\n}) {\n try {\n validateBody({ threadId });\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n const { resourceId, memoryConfig, workingMemory } = body;\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n const thread = await memory.getThreadById({ threadId: threadId! });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n\n await memory.updateWorkingMemory({ threadId: threadId!, resourceId, workingMemory, memoryConfig });\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error updating working memory');\n }\n}\n\ninterface SearchResult {\n id: string;\n role: string;\n content: any;\n createdAt: Date;\n threadId?: string;\n threadTitle?: string;\n score?: number;\n context?: {\n before?: SearchResult[];\n after?: SearchResult[];\n };\n}\n\ninterface SearchResponse {\n results: SearchResult[];\n count: number;\n query: string;\n searchScope?: string;\n searchType?: string;\n}\n\n/**\n * Handler to delete one or more messages.\n * @param messageIds - Can be a single ID, array of IDs, or objects with ID property\n */\nexport async function deleteMessagesHandler({\n mastra,\n agentId,\n messageIds,\n networkId,\n runtimeContext,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {\n messageIds: string | string[] | { id: string } | { id: string }[];\n}) {\n try {\n if (messageIds === undefined || messageIds === null) {\n throw new HTTPException(400, { message: 'messageIds is required' });\n }\n\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n // Delete the messages - let the memory method handle validation\n await memory.deleteMessages(messageIds as any);\n\n // Count messages for response\n let count = 1;\n if (Array.isArray(messageIds)) {\n count = messageIds.length;\n }\n\n return { success: true, message: `${count} message${count === 1 ? '' : 's'} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting messages');\n }\n}\n\nexport async function searchMemoryHandler({\n mastra,\n agentId,\n searchQuery,\n resourceId,\n threadId,\n limit = 20,\n networkId,\n runtimeContext,\n memoryConfig,\n}: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {\n searchQuery: string;\n resourceId: string;\n threadId?: string;\n limit?: number;\n memoryConfig?: any;\n}): Promise<SearchResponse | ReturnType<typeof handleError>> {\n try {\n validateBody({ searchQuery, resourceId });\n\n const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });\n if (!memory) {\n throw new HTTPException(400, { message: 'Memory is not initialized' });\n }\n\n // Get memory configuration first to check scope\n const config = memory.getMergedThreadConfig(memoryConfig || {});\n const hasSemanticRecall = !!config?.semanticRecall;\n const resourceScope = typeof config?.semanticRecall === 'object' && config?.semanticRecall?.scope === 'resource';\n\n // Only validate thread ownership if we're in thread scope\n if (threadId && !resourceScope) {\n const thread = await memory.getThreadById({ threadId });\n if (!thread) {\n throw new HTTPException(404, { message: 'Thread not found' });\n }\n if (thread.resourceId !== resourceId) {\n throw new HTTPException(403, { message: 'Thread does not belong to the specified resource' });\n }\n }\n\n const searchResults: SearchResult[] = [];\n const messageMap = new Map<string, boolean>(); // For deduplication\n\n // If threadId is provided and scope is thread-based, check if the thread exists\n if (threadId && !resourceScope) {\n const thread = await memory.getThreadById({ threadId });\n if (!thread) {\n // Thread doesn't exist yet (new unsaved thread) - return empty results\n return {\n results: [],\n count: 0,\n query: searchQuery,\n searchScope: 'thread',\n searchType: hasSemanticRecall ? 'semantic' : 'text',\n };\n }\n }\n\n // If resource scope is enabled or no threadId provided, search across all threads\n if (!threadId || resourceScope) {\n // Search across all threads for this resource\n const threads = await memory.getThreadsByResourceId({ resourceId });\n\n // If no threads exist yet, return empty results\n if (threads.length === 0) {\n return {\n results: [],\n count: 0,\n query: searchQuery,\n searchScope: 'resource',\n searchType: hasSemanticRecall ? 'semantic' : 'text',\n };\n }\n\n for (const thread of threads) {\n // Use rememberMessages for semantic search\n const result = await memory.rememberMessages({\n threadId: thread.id,\n resourceId,\n vectorMessageSearch: searchQuery,\n config,\n });\n\n // Get thread messages for context\n const threadMessages = (await memory.query({ threadId: thread.id, format: 'v2' })).uiMessages;\n\n // Process results\n result.messagesV2.forEach(msg => {\n if (messageMap.has(msg.id)) return;\n messageMap.set(msg.id, true);\n\n const content =\n msg.content.content || msg.content.parts?.map(p => (p.type === 'text' ? p.text : '')).join(' ') || '';\n\n if (!hasSemanticRecall && !content.toLowerCase().includes(searchQuery.toLowerCase())) {\n return;\n }\n\n const messageIndex = threadMessages.findIndex(m => m.id === msg.id);\n\n const searchResult: SearchResult = {\n id: msg.id,\n role: msg.role,\n content,\n createdAt: msg.createdAt,\n threadId: msg.threadId || thread.id,\n threadTitle: thread.title || msg.threadId || thread.id,\n };\n\n if (messageIndex !== -1) {\n searchResult.context = {\n before: threadMessages.slice(Math.max(0, messageIndex - 2), messageIndex).map(m => ({\n id: m.id,\n role: m.role,\n content: m.parts\n .map(p => (p.type === `text` ? p.text : null))\n .filter(Boolean)\n .join(`\\n`),\n // @ts-ignore\n createdAt: m.createdAt || new Date(),\n })),\n after: threadMessages.slice(messageIndex + 1, messageIndex + 3).map(m => ({\n id: m.id,\n role: m.role,\n content: m.parts\n .map(p => (p.type === `text` ? p.text : null))\n .filter(Boolean)\n .join(`\\n`),\n // @ts-ignore\n createdAt: m.createdAt || new Date(),\n })),\n };\n }\n\n searchResults.push(searchResult);\n });\n }\n } else if (threadId) {\n // Search in specific thread only\n const thread = await memory.getThreadById({ threadId });\n if (!thread) {\n // Thread doesn't exist yet - return empty results\n return {\n results: [],\n count: 0,\n query: searchQuery,\n searchScope: 'thread',\n searchType: hasSemanticRecall ? 'semantic' : 'text',\n };\n }\n\n const result = await memory.rememberMessages({\n threadId,\n resourceId,\n vectorMessageSearch: searchQuery,\n config,\n });\n\n const threadMessages = (await memory.query({ threadId, format: 'v2' })).uiMessages;\n\n result.messagesV2.forEach(msg => {\n // Skip duplicates\n if (messageMap.has(msg.id)) return;\n messageMap.set(msg.id, true);\n\n // Extract content\n const content =\n msg.content.content || msg.content.parts?.map(p => (p.type === 'text' ? p.text : '')).join(' ') || '';\n\n // If not using semantic recall, filter by text search\n if (!hasSemanticRecall && !content.toLowerCase().includes(searchQuery.toLowerCase())) {\n return;\n }\n\n // Find message index for context\n const messageIndex = threadMessages.findIndex(m => m.id === msg.id);\n\n const searchResult: SearchResult = {\n id: msg.id,\n role: msg.role,\n content,\n createdAt: msg.createdAt,\n threadId: threadId,\n threadTitle: thread?.title || threadId,\n };\n\n // Add context if found\n if (messageIndex !== -1) {\n searchResult.context = {\n before: threadMessages.slice(Math.max(0, messageIndex - 2), messageIndex).map(m => ({\n id: m.id,\n role: m.role,\n content: m.parts\n .map(p => (p.type === `text` ? p.text : null))\n .filter(Boolean)\n .join(`\\n`),\n // @ts-ignore\n createdAt: m.createdAt || new Date(),\n })),\n after: threadMessages.slice(messageIndex + 1, messageIndex + 3).map(m => ({\n id: m.id,\n role: m.role,\n content: m.parts\n .map(p => (p.type === `text` ? p.text : null))\n .filter(Boolean)\n .join(`\\n`),\n // @ts-ignore\n createdAt: m.createdAt || new Date(),\n })),\n };\n }\n\n searchResults.push(searchResult);\n });\n }\n\n // Sort by date (newest first) and limit\n const sortedResults = searchResults\n .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())\n .slice(0, limit);\n\n return {\n results: sortedResults,\n count: sortedResults.length,\n query: searchQuery,\n searchScope: resourceScope ? 'resource' : 'thread',\n searchType: hasSemanticRecall ? 'semantic' : 'text',\n };\n } catch (error) {\n return handleError(error, 'Error searching memory');\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { handleError } from './chunk-LF7P5PLR.js';
2
- import { __export } from './chunk-MLKGABMK.js';
1
+ import { handleError } from './chunk-CY4TP3FK.js';
2
+ import { __export } from './chunk-PZ5AY32C.js';
3
3
 
4
4
  // src/server/handlers/scores.ts
5
5
  var scores_exports = {};
@@ -30,7 +30,7 @@ async function getScorersFromSystem({
30
30
  scorersMap.set(scorerId, {
31
31
  workflowIds: [],
32
32
  ...scorer,
33
- agentIds: [agent.name]
33
+ agentIds: [agentId]
34
34
  });
35
35
  }
36
36
  }
@@ -147,3 +147,5 @@ async function saveScoreHandler({ mastra, score }) {
147
147
  }
148
148
 
149
149
  export { getScorerHandler, getScorersHandler, getScoresByEntityIdHandler, getScoresByRunIdHandler, getScoresByScorerIdHandler, saveScoreHandler, scores_exports };
150
+ //# sourceMappingURL=chunk-L7YG7WQH.js.map
151
+ //# sourceMappingURL=chunk-L7YG7WQH.js.map