@mastra/server 0.0.0-remove-cloud-span-transform-20250425214156 → 0.0.0-remove-unused-import-20250909212718
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.
- package/CHANGELOG.md +3541 -0
- package/LICENSE.md +11 -42
- package/README.md +48 -135
- package/dist/chunk-3THIIWWW.cjs +484 -0
- package/dist/chunk-3THIIWWW.cjs.map +1 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-4QCXUEAT.js} +11 -2
- package/dist/chunk-4QCXUEAT.js.map +1 -0
- package/dist/chunk-4RRMWXQ2.js +3522 -0
- package/dist/chunk-4RRMWXQ2.js.map +1 -0
- package/dist/chunk-5DP5XZH6.cjs +928 -0
- package/dist/chunk-5DP5XZH6.cjs.map +1 -0
- package/dist/chunk-5QUKZCEF.js +476 -0
- package/dist/chunk-5QUKZCEF.js.map +1 -0
- package/dist/chunk-66YYHFGF.js +761 -0
- package/dist/chunk-66YYHFGF.js.map +1 -0
- package/dist/chunk-6GMFZ5LK.js +2774 -0
- package/dist/chunk-6GMFZ5LK.js.map +1 -0
- package/dist/chunk-6LUKYSWE.cjs +610 -0
- package/dist/chunk-6LUKYSWE.cjs.map +1 -0
- package/dist/chunk-743UIDHI.cjs +2013 -0
- package/dist/chunk-743UIDHI.cjs.map +1 -0
- package/dist/{chunk-FV45V6WC.cjs → chunk-7NADHFD2.cjs} +3 -7
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/chunk-7QEJ5QG5.js +151 -0
- package/dist/chunk-7QEJ5QG5.js.map +1 -0
- package/dist/chunk-A3AL7EWJ.js +83 -0
- package/dist/chunk-A3AL7EWJ.js.map +1 -0
- package/dist/{chunk-Q6SHQECN.js → chunk-A75S4TDD.js} +36 -10
- package/dist/chunk-A75S4TDD.js.map +1 -0
- package/dist/chunk-AK2FXLLB.cjs +849 -0
- package/dist/chunk-AK2FXLLB.cjs.map +1 -0
- package/dist/chunk-B2V3PUB7.js +591 -0
- package/dist/chunk-B2V3PUB7.js.map +1 -0
- package/dist/chunk-CY4TP3FK.js +16 -0
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/chunk-EMMSS5I5.cjs +37 -0
- package/dist/chunk-EMMSS5I5.cjs.map +1 -0
- package/dist/chunk-EMNGA4R4.js +845 -0
- package/dist/chunk-EMNGA4R4.js.map +1 -0
- package/dist/chunk-FALVL2VV.cjs +3525 -0
- package/dist/chunk-FALVL2VV.cjs.map +1 -0
- package/dist/chunk-FQNT7PI4.js +937 -0
- package/dist/chunk-FQNT7PI4.js.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-G4PUALCE.cjs +28 -0
- package/dist/chunk-G4PUALCE.cjs.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-GUI3CROV.cjs +159 -0
- package/dist/chunk-GUI3CROV.cjs.map +1 -0
- package/dist/chunk-HJQKWRKQ.cjs +764 -0
- package/dist/chunk-HJQKWRKQ.cjs.map +1 -0
- package/dist/chunk-HVBBFCDH.cjs +2321 -0
- package/dist/chunk-HVBBFCDH.cjs.map +1 -0
- package/dist/chunk-HZJRQ5L3.cjs +1411 -0
- package/dist/chunk-HZJRQ5L3.cjs.map +1 -0
- package/dist/chunk-IGFMAZZ5.cjs +1150 -0
- package/dist/chunk-IGFMAZZ5.cjs.map +1 -0
- package/dist/chunk-IOQGI4ML.js +931 -0
- package/dist/chunk-IOQGI4ML.js.map +1 -0
- package/dist/chunk-IY34NOLA.cjs +150 -0
- package/dist/chunk-IY34NOLA.cjs.map +1 -0
- package/dist/chunk-J7BPKKOG.cjs +163 -0
- package/dist/chunk-J7BPKKOG.cjs.map +1 -0
- package/dist/chunk-KNGXRN26.cjs +335 -0
- package/dist/chunk-KNGXRN26.cjs.map +1 -0
- package/dist/{chunk-WTHDCRMY.js → chunk-KV6VHX4V.js} +33 -8
- package/dist/chunk-KV6VHX4V.js.map +1 -0
- package/dist/chunk-L265APUD.cjs +69 -0
- package/dist/chunk-L265APUD.cjs.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/chunk-LYPU75T6.js +1147 -0
- package/dist/chunk-LYPU75T6.js.map +1 -0
- package/dist/chunk-M2YFWHSB.js +455 -0
- package/dist/chunk-M2YFWHSB.js.map +1 -0
- package/dist/chunk-MLGHQDZZ.js +15671 -0
- package/dist/chunk-MLGHQDZZ.js.map +1 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-MMROOK5J.js} +4 -7
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/chunk-N7F33WAD.js +2290 -0
- package/dist/chunk-N7F33WAD.js.map +1 -0
- package/dist/chunk-NG5IVLEZ.js +1012 -0
- package/dist/chunk-NG5IVLEZ.js.map +1 -0
- package/dist/chunk-OGW6HHVI.js +1408 -0
- package/dist/chunk-OGW6HHVI.js.map +1 -0
- package/dist/chunk-OZLRIVC4.cjs +588 -0
- package/dist/chunk-OZLRIVC4.cjs.map +1 -0
- package/dist/chunk-P7CIEIJ3.js +925 -0
- package/dist/chunk-P7CIEIJ3.js.map +1 -0
- package/dist/chunk-P7RBMCBE.cjs +934 -0
- package/dist/chunk-P7RBMCBE.cjs.map +1 -0
- package/dist/chunk-PPYGWINI.cjs +2777 -0
- package/dist/chunk-PPYGWINI.cjs.map +1 -0
- package/dist/{chunk-7IWQE76Z.cjs → chunk-PWTXZZTR.cjs} +37 -11
- package/dist/chunk-PWTXZZTR.cjs.map +1 -0
- package/dist/chunk-R7NOGUZG.js +65 -0
- package/dist/chunk-R7NOGUZG.js.map +1 -0
- package/dist/chunk-RCHEPTZZ.js +2006 -0
- package/dist/chunk-RCHEPTZZ.js.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/chunk-RW2D3G4K.cjs +470 -0
- package/dist/chunk-RW2D3G4K.cjs.map +1 -0
- package/dist/chunk-SIGXR3JT.cjs +1043 -0
- package/dist/chunk-SIGXR3JT.cjs.map +1 -0
- package/dist/chunk-SPLSYTYW.cjs +88 -0
- package/dist/chunk-SPLSYTYW.cjs.map +1 -0
- package/dist/chunk-SQY4T6EJ.js +571 -0
- package/dist/chunk-SQY4T6EJ.js.map +1 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-SYRRSBGL.js} +48 -12
- package/dist/chunk-SYRRSBGL.js.map +1 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-T3TIA3O6.cjs} +22 -19
- package/dist/chunk-T3TIA3O6.cjs.map +1 -0
- package/dist/{chunk-LFOBHRFO.js → chunk-TTHEEIZ3.js} +83 -65
- package/dist/chunk-TTHEEIZ3.js.map +1 -0
- package/dist/chunk-TVSIG4JE.cjs +940 -0
- package/dist/chunk-TVSIG4JE.cjs.map +1 -0
- package/dist/{chunk-RE6YL32K.js → chunk-U46VIX2V.js} +54 -30
- package/dist/chunk-U46VIX2V.js.map +1 -0
- package/dist/{chunk-4JINXASC.js → chunk-WHN4VX55.js} +7 -4
- package/dist/chunk-WHN4VX55.js.map +1 -0
- package/dist/chunk-WZC6CIVD.cjs +120 -0
- package/dist/chunk-WZC6CIVD.cjs.map +1 -0
- package/dist/chunk-YITREQVN.cjs +15707 -0
- package/dist/chunk-YITREQVN.cjs.map +1 -0
- package/dist/dist-26HWEQY6.js +3 -0
- package/dist/dist-26HWEQY6.js.map +1 -0
- package/dist/dist-3A5DXB37.cjs +20 -0
- package/dist/dist-3A5DXB37.cjs.map +1 -0
- package/dist/dist-3SJKQJGY.cjs +16 -0
- package/dist/dist-3SJKQJGY.cjs.map +1 -0
- package/dist/dist-4ZQSPE5K.js +3 -0
- package/dist/dist-4ZQSPE5K.js.map +1 -0
- package/dist/dist-5W5QNRTD.js +3 -0
- package/dist/dist-5W5QNRTD.js.map +1 -0
- package/dist/dist-653SRMPL.js +3 -0
- package/dist/dist-653SRMPL.js.map +1 -0
- package/dist/dist-6U6EFC5C.cjs +16 -0
- package/dist/dist-6U6EFC5C.cjs.map +1 -0
- package/dist/dist-7IHNNYMF.cjs +16 -0
- package/dist/dist-7IHNNYMF.cjs.map +1 -0
- package/dist/dist-B5IPRF6W.js +3 -0
- package/dist/dist-B5IPRF6W.js.map +1 -0
- package/dist/dist-EOMYFT4Y.cjs +16 -0
- package/dist/dist-EOMYFT4Y.cjs.map +1 -0
- package/dist/dist-EZZMMMNT.cjs +16 -0
- package/dist/dist-EZZMMMNT.cjs.map +1 -0
- package/dist/dist-F2ET4MNO.cjs +16 -0
- package/dist/dist-F2ET4MNO.cjs.map +1 -0
- package/dist/dist-H64VX6DE.js +3 -0
- package/dist/dist-H64VX6DE.js.map +1 -0
- package/dist/dist-HY7RMLJQ.cjs +16 -0
- package/dist/dist-HY7RMLJQ.cjs.map +1 -0
- package/dist/dist-M6S4P3FJ.js +3 -0
- package/dist/dist-M6S4P3FJ.js.map +1 -0
- package/dist/dist-NR7QSCQT.js +3 -0
- package/dist/dist-NR7QSCQT.js.map +1 -0
- package/dist/dist-QLFMCMCX.js +3 -0
- package/dist/dist-QLFMCMCX.js.map +1 -0
- package/dist/dist-UY46BFRP.js +3 -0
- package/dist/dist-UY46BFRP.js.map +1 -0
- package/dist/dist-WCQDRTIV.cjs +16 -0
- package/dist/dist-WCQDRTIV.cjs.map +1 -0
- package/dist/dist-WKYB3LTJ.cjs +16 -0
- package/dist/dist-WKYB3LTJ.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server/a2a/protocol.d.ts +8 -0
- package/dist/server/a2a/protocol.d.ts.map +1 -0
- package/dist/server/a2a/store.cjs +25 -0
- package/dist/server/a2a/store.cjs.map +1 -0
- package/dist/server/a2a/store.d.ts +14 -0
- package/dist/server/a2a/store.d.ts.map +1 -0
- package/dist/server/a2a/store.js +23 -0
- package/dist/server/a2a/store.js.map +1 -0
- package/dist/server/a2a/tasks.d.ts +20 -0
- package/dist/server/a2a/tasks.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +32 -0
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +68 -0
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -0
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +68 -0
- package/dist/server/handlers/agent-builder.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.d.ts +87 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -0
- package/dist/server/handlers/agent-builder.js +3 -0
- package/dist/server/handlers/agent-builder.js.map +1 -0
- package/dist/server/handlers/agents.cjs +37 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +129 -6
- package/dist/server/handlers/agents.d.ts.map +1 -0
- package/dist/server/handlers/agents.js +3 -1
- package/dist/server/handlers/agents.js.map +1 -0
- package/dist/server/handlers/error.cjs +4 -2
- package/dist/server/handlers/error.cjs.map +1 -0
- package/dist/server/handlers/error.d.ts +2 -1
- package/dist/server/handlers/error.d.ts.map +1 -0
- package/dist/server/handlers/error.js +3 -1
- package/dist/server/handlers/error.js.map +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +48 -0
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -0
- package/dist/server/handlers/legacyWorkflows.js.map +1 -0
- package/dist/server/handlers/logs.cjs +6 -4
- package/dist/server/handlers/logs.cjs.map +1 -0
- package/dist/server/handlers/logs.d.ts +34 -3
- package/dist/server/handlers/logs.d.ts.map +1 -0
- package/dist/server/handlers/logs.js +3 -1
- package/dist/server/handlers/logs.js.map +1 -0
- package/dist/server/handlers/memory.cjs +39 -9
- package/dist/server/handlers/memory.cjs.map +1 -0
- package/dist/server/handlers/memory.d.ts +118 -8
- package/dist/server/handlers/memory.d.ts.map +1 -0
- package/dist/server/handlers/memory.js +3 -1
- package/dist/server/handlers/memory.js.map +1 -0
- package/dist/server/handlers/network.cjs +7 -5
- package/dist/server/handlers/network.cjs.map +1 -0
- package/dist/server/handlers/network.d.ts +50 -4
- package/dist/server/handlers/network.d.ts.map +1 -0
- package/dist/server/handlers/network.js +3 -1
- package/dist/server/handlers/network.js.map +1 -0
- package/dist/server/handlers/observability.cjs +16 -0
- package/dist/server/handlers/observability.cjs.map +1 -0
- package/dist/server/handlers/observability.d.ts +23 -0
- package/dist/server/handlers/observability.d.ts.map +1 -0
- package/dist/server/handlers/observability.js +3 -0
- package/dist/server/handlers/observability.js.map +1 -0
- package/dist/server/handlers/scores.cjs +32 -0
- package/dist/server/handlers/scores.cjs.map +1 -0
- package/dist/server/handlers/scores.d.ts +49 -0
- package/dist/server/handlers/scores.d.ts.map +1 -0
- package/dist/server/handlers/scores.js +3 -0
- package/dist/server/handlers/scores.js.map +1 -0
- package/dist/server/handlers/telemetry.cjs +9 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +33 -2
- package/dist/server/handlers/telemetry.d.ts.map +1 -0
- package/dist/server/handlers/telemetry.js +3 -1
- package/dist/server/handlers/telemetry.js.map +1 -0
- package/dist/server/handlers/tools.cjs +11 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +25 -4
- package/dist/server/handlers/tools.d.ts.map +1 -0
- package/dist/server/handlers/tools.js +3 -1
- package/dist/server/handlers/tools.js.map +1 -0
- package/dist/server/handlers/utils.cjs +8 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +8 -1
- package/dist/server/handlers/utils.d.ts.map +1 -0
- package/dist/server/handlers/utils.js +3 -1
- package/dist/server/handlers/utils.js.map +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +220 -0
- package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +179 -0
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
- package/dist/server/handlers/vNextNetwork.js +213 -0
- package/dist/server/handlers/vNextNetwork.js.map +1 -0
- package/dist/server/handlers/vector.cjs +9 -7
- package/dist/server/handlers/vector.cjs.map +1 -0
- package/dist/server/handlers/vector.d.ts +51 -6
- package/dist/server/handlers/vector.d.ts.map +1 -0
- package/dist/server/handlers/vector.js +3 -1
- package/dist/server/handlers/vector.js.map +1 -0
- package/dist/server/handlers/voice.cjs +10 -4
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +39 -3
- package/dist/server/handlers/voice.d.ts.map +1 -0
- package/dist/server/handlers/voice.js +3 -1
- package/dist/server/handlers/voice.js.map +1 -0
- package/dist/server/handlers/workflows.cjs +35 -13
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +73 -10
- package/dist/server/handlers/workflows.d.ts.map +1 -0
- package/dist/server/handlers/workflows.js +3 -1
- package/dist/server/handlers/workflows.js.map +1 -0
- package/dist/server/handlers.cjs +52 -30
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +15 -10
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +16 -10
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/http-exception.d.ts +87 -0
- package/dist/server/http-exception.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/utils.d.ts +42 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/package.json +51 -19
- package/dist/_tsup-dts-rollup.d.cts +0 -648
- package/dist/_tsup-dts-rollup.d.ts +0 -648
- package/dist/chunk-2FJURXCL.cjs +0 -213
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-55HTWX4C.cjs +0 -93
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-B66WVPGJ.js +0 -297
- package/dist/chunk-D3G23FP3.cjs +0 -126
- package/dist/chunk-FPIWDH5Y.cjs +0 -126
- package/dist/chunk-HCOPJZ4A.cjs +0 -164
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-QN4KF3BH.cjs +0 -18
- package/dist/chunk-R4J7XQYU.js +0 -156
- package/dist/chunk-RBQASTUP.js +0 -203
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-TZK63M5N.cjs +0 -317
- package/dist/chunk-ZHNKYTNS.cjs +0 -309
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -3
- package/dist/server/handlers/workflows.d.cts +0 -10
- package/dist/server/handlers.d.cts +0 -10
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { handleError } from './chunk-
|
|
4
|
-
import {
|
|
1
|
+
import { validateBody } from './chunk-4QCXUEAT.js';
|
|
2
|
+
import { stringify } from './chunk-LF2ZLOFP.js';
|
|
3
|
+
import { handleError } from './chunk-CY4TP3FK.js';
|
|
4
|
+
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
5
|
+
import { __export } from './chunk-G3PMV62Z.js';
|
|
5
6
|
import { isVercelTool } from '@mastra/core/tools';
|
|
7
|
+
import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
|
|
6
8
|
|
|
7
9
|
// src/server/handlers/tools.ts
|
|
8
10
|
var tools_exports = {};
|
|
9
11
|
__export(tools_exports, {
|
|
10
12
|
executeAgentToolHandler: () => executeAgentToolHandler,
|
|
11
13
|
executeToolHandler: () => executeToolHandler,
|
|
14
|
+
getAgentToolHandler: () => getAgentToolHandler,
|
|
12
15
|
getToolByIdHandler: () => getToolByIdHandler,
|
|
13
16
|
getToolsHandler: () => getToolsHandler
|
|
14
17
|
});
|
|
@@ -22,8 +25,8 @@ async function getToolsHandler({ tools }) {
|
|
|
22
25
|
const tool = _tool;
|
|
23
26
|
acc[id] = {
|
|
24
27
|
...tool,
|
|
25
|
-
inputSchema: tool.inputSchema ? stringify(
|
|
26
|
-
outputSchema: tool.outputSchema ? stringify(
|
|
28
|
+
inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
29
|
+
outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
|
|
27
30
|
};
|
|
28
31
|
return acc;
|
|
29
32
|
},
|
|
@@ -42,8 +45,8 @@ async function getToolByIdHandler({ tools, toolId }) {
|
|
|
42
45
|
}
|
|
43
46
|
const serializedTool = {
|
|
44
47
|
...tool,
|
|
45
|
-
inputSchema: tool.inputSchema ? stringify(
|
|
46
|
-
outputSchema: tool.outputSchema ? stringify(
|
|
48
|
+
inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
49
|
+
outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
|
|
47
50
|
};
|
|
48
51
|
return serializedTool;
|
|
49
52
|
} catch (error) {
|
|
@@ -78,7 +81,9 @@ function executeToolHandler(tools) {
|
|
|
78
81
|
context: data,
|
|
79
82
|
mastra,
|
|
80
83
|
runId,
|
|
81
|
-
runtimeContext
|
|
84
|
+
runtimeContext,
|
|
85
|
+
// TODO: Pass proper tracing context when server API supports tracing
|
|
86
|
+
tracingContext: { currentSpan: void 0 }
|
|
82
87
|
});
|
|
83
88
|
return result;
|
|
84
89
|
} catch (error) {
|
|
@@ -86,6 +91,32 @@ function executeToolHandler(tools) {
|
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
93
|
}
|
|
94
|
+
async function getAgentToolHandler({
|
|
95
|
+
mastra,
|
|
96
|
+
agentId,
|
|
97
|
+
toolId,
|
|
98
|
+
runtimeContext
|
|
99
|
+
}) {
|
|
100
|
+
try {
|
|
101
|
+
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
102
|
+
if (!agent) {
|
|
103
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
104
|
+
}
|
|
105
|
+
const agentTools = await agent.getTools({ runtimeContext });
|
|
106
|
+
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
107
|
+
if (!tool) {
|
|
108
|
+
throw new HTTPException(404, { message: "Tool not found" });
|
|
109
|
+
}
|
|
110
|
+
const serializedTool = {
|
|
111
|
+
...tool,
|
|
112
|
+
inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
113
|
+
outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
|
|
114
|
+
};
|
|
115
|
+
return serializedTool;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return handleError(error, "Error getting agent tool");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
89
120
|
async function executeAgentToolHandler({
|
|
90
121
|
mastra,
|
|
91
122
|
agentId,
|
|
@@ -98,7 +129,8 @@ async function executeAgentToolHandler({
|
|
|
98
129
|
if (!agent) {
|
|
99
130
|
throw new HTTPException(404, { message: "Tool not found" });
|
|
100
131
|
}
|
|
101
|
-
const
|
|
132
|
+
const agentTools = await agent.getTools({ runtimeContext });
|
|
133
|
+
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
102
134
|
if (!tool) {
|
|
103
135
|
throw new HTTPException(404, { message: "Tool not found" });
|
|
104
136
|
}
|
|
@@ -109,7 +141,9 @@ async function executeAgentToolHandler({
|
|
|
109
141
|
context: data,
|
|
110
142
|
runtimeContext,
|
|
111
143
|
mastra,
|
|
112
|
-
runId: agentId
|
|
144
|
+
runId: agentId,
|
|
145
|
+
// TODO: Pass proper tracing context when server API supports tracing
|
|
146
|
+
tracingContext: { currentSpan: void 0 }
|
|
113
147
|
});
|
|
114
148
|
return result;
|
|
115
149
|
} catch (error) {
|
|
@@ -117,4 +151,6 @@ async function executeAgentToolHandler({
|
|
|
117
151
|
}
|
|
118
152
|
}
|
|
119
153
|
|
|
120
|
-
export { executeAgentToolHandler, executeToolHandler, getToolByIdHandler, getToolsHandler, tools_exports };
|
|
154
|
+
export { executeAgentToolHandler, executeToolHandler, getAgentToolHandler, getToolByIdHandler, getToolsHandler, tools_exports };
|
|
155
|
+
//# sourceMappingURL=chunk-SYRRSBGL.js.map
|
|
156
|
+
//# sourceMappingURL=chunk-SYRRSBGL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/tools.ts"],"names":["tool","result"],"mappings":";;;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,QAAA,CAAA,aAAA,EAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,eAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA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,cAAA,EAAgB,EAAE,WAAA,EAAa,MAAA;AAAU,KAC1C,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,sBAAsB,CAAA;AAAA,EAClD;AACF","file":"chunk-SYRRSBGL.js","sourcesContent":["import type { RuntimeContext } from '@mastra/core/di';\nimport type { ToolAction, VercelTool } from '@mastra/core/tools';\nimport { isVercelTool } from '@mastra/core/tools';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport { stringify } from 'superjson';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface ToolsContext extends Context {\n tools?: Record<string, ToolAction | VercelTool>;\n toolId?: string;\n runId?: string;\n}\n\n// Tool handlers\nexport async function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>) {\n try {\n if (!tools) {\n return {};\n }\n\n const serializedTools = Object.entries(tools).reduce(\n (acc, [id, _tool]) => {\n const tool = _tool as any;\n acc[id] = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n return serializedTools;\n } catch (error) {\n return handleError(error, 'Error getting tools');\n }\n}\n\nexport async function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>) {\n try {\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting tool');\n }\n}\n\nexport function executeToolHandler(tools: ToolsContext['tools']) {\n return async ({\n mastra,\n runId,\n toolId,\n data,\n runtimeContext,\n }: Pick<ToolsContext, 'mastra' | 'toolId' | 'runId'> & {\n data?: unknown;\n runtimeContext: RuntimeContext;\n }) => {\n try {\n if (!toolId) {\n throw new HTTPException(400, { message: 'Tool ID is required' });\n }\n\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n validateBody({ data });\n\n if (isVercelTool(tool)) {\n const result = await (tool as any).execute(data);\n return result;\n }\n\n const result = await tool.execute({\n context: data!,\n mastra,\n runId,\n runtimeContext,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n };\n}\n\nexport async function getAgentToolHandler({\n mastra,\n agentId,\n toolId,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting agent tool');\n }\n}\n\nexport async function executeAgentToolHandler({\n mastra,\n agentId,\n toolId,\n data,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n data: any;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n // if (isVercelTool(tool)) {\n // const result = await (tool as any).execute(data);\n // return result;\n // }\n\n const result = await tool.execute({\n context: data,\n runtimeContext,\n mastra,\n runId: agentId,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
4
|
+
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
5
|
+
var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
|
|
5
6
|
|
|
6
7
|
// src/server/handlers/vector.ts
|
|
7
8
|
var vector_exports = {};
|
|
8
|
-
|
|
9
|
+
chunkEMMSS5I5_cjs.__export(vector_exports, {
|
|
9
10
|
createIndex: () => createIndex,
|
|
10
11
|
deleteIndex: () => deleteIndex,
|
|
11
12
|
describeIndex: () => describeIndex,
|
|
@@ -15,24 +16,24 @@ chunkFV45V6WC_cjs.__export(vector_exports, {
|
|
|
15
16
|
});
|
|
16
17
|
function getVector(mastra, vectorName) {
|
|
17
18
|
if (!vectorName) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Vector name is required" });
|
|
19
20
|
}
|
|
20
21
|
const vector = mastra.getVector(vectorName);
|
|
21
22
|
if (!vector) {
|
|
22
|
-
throw new
|
|
23
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
|
|
23
24
|
}
|
|
24
25
|
return vector;
|
|
25
26
|
}
|
|
26
27
|
async function upsertVectors({ mastra, vectorName, index }) {
|
|
27
28
|
try {
|
|
28
29
|
if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
|
|
30
31
|
}
|
|
31
32
|
const vector = getVector(mastra, vectorName);
|
|
32
33
|
const result = await vector.upsert(index);
|
|
33
34
|
return { ids: result };
|
|
34
35
|
} catch (error) {
|
|
35
|
-
return
|
|
36
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error upserting vectors");
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
async function createIndex({
|
|
@@ -43,18 +44,18 @@ async function createIndex({
|
|
|
43
44
|
try {
|
|
44
45
|
const { indexName, dimension, metric } = index;
|
|
45
46
|
if (!indexName || typeof dimension !== "number" || dimension <= 0) {
|
|
46
|
-
throw new
|
|
47
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, {
|
|
47
48
|
message: "Invalid request index, indexName and positive dimension number are required."
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
51
|
-
throw new
|
|
52
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
|
|
52
53
|
}
|
|
53
54
|
const vector = getVector(mastra, vectorName);
|
|
54
55
|
await vector.createIndex({ indexName, dimension, metric });
|
|
55
56
|
return { success: true };
|
|
56
57
|
} catch (error) {
|
|
57
|
-
return
|
|
58
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error creating index");
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
async function queryVectors({
|
|
@@ -64,13 +65,13 @@ async function queryVectors({
|
|
|
64
65
|
}) {
|
|
65
66
|
try {
|
|
66
67
|
if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
|
|
67
|
-
throw new
|
|
68
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
|
|
68
69
|
}
|
|
69
70
|
const vector = getVector(mastra, vectorName);
|
|
70
71
|
const results = await vector.query(query);
|
|
71
72
|
return results;
|
|
72
73
|
} catch (error) {
|
|
73
|
-
return
|
|
74
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error querying vectors");
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
async function listIndexes({ mastra, vectorName }) {
|
|
@@ -79,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
|
|
|
79
80
|
const indexes = await vector.listIndexes();
|
|
80
81
|
return indexes.filter(Boolean);
|
|
81
82
|
} catch (error) {
|
|
82
|
-
return
|
|
83
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error listing indexes");
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
async function describeIndex({
|
|
@@ -89,17 +90,17 @@ async function describeIndex({
|
|
|
89
90
|
}) {
|
|
90
91
|
try {
|
|
91
92
|
if (!indexName) {
|
|
92
|
-
throw new
|
|
93
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Index name is required" });
|
|
93
94
|
}
|
|
94
95
|
const vector = getVector(mastra, vectorName);
|
|
95
|
-
const stats = await vector.describeIndex(indexName);
|
|
96
|
+
const stats = await vector.describeIndex({ indexName });
|
|
96
97
|
return {
|
|
97
98
|
dimension: stats.dimension,
|
|
98
99
|
count: stats.count,
|
|
99
100
|
metric: stats.metric?.toLowerCase()
|
|
100
101
|
};
|
|
101
102
|
} catch (error) {
|
|
102
|
-
return
|
|
103
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error describing index");
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
async function deleteIndex({
|
|
@@ -109,13 +110,13 @@ async function deleteIndex({
|
|
|
109
110
|
}) {
|
|
110
111
|
try {
|
|
111
112
|
if (!indexName) {
|
|
112
|
-
throw new
|
|
113
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Index name is required" });
|
|
113
114
|
}
|
|
114
115
|
const vector = getVector(mastra, vectorName);
|
|
115
|
-
await vector.deleteIndex(indexName);
|
|
116
|
+
await vector.deleteIndex({ indexName });
|
|
116
117
|
return { success: true };
|
|
117
118
|
} catch (error) {
|
|
118
|
-
return
|
|
119
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error deleting index");
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -126,3 +127,5 @@ exports.listIndexes = listIndexes;
|
|
|
126
127
|
exports.queryVectors = queryVectors;
|
|
127
128
|
exports.upsertVectors = upsertVectors;
|
|
128
129
|
exports.vector_exports = vector_exports;
|
|
130
|
+
//# sourceMappingURL=chunk-T3TIA3O6.cjs.map
|
|
131
|
+
//# sourceMappingURL=chunk-T3TIA3O6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/vector.ts"],"names":["__export","HTTPException","handleError"],"mappings":";;;;;;;AAAA,IAAA,cAAA,GAAA;AAAAA,0BAAA,CAAA,cAAA,EAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,aAAA,EAAA,MAAA,aAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,aAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AA+BA,SAAS,SAAA,CAAU,QAA2B,UAAA,EAAmC;AAC/E,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAIC,+BAAA,CAAc,GAAA,EAAK,EAAE,OAA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tC,IAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAAA,EACzB,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,6BAAA,CAAY,OAAO,sBAAsB,CAAA;AAAA,EAClD;AACF","file":"chunk-T3TIA3O6.cjs","sourcesContent":["import type { MastraVector, QueryResult, IndexStats } from '@mastra/core/vector';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\n\ninterface VectorContext extends Context {\n vectorName?: string;\n}\n\ninterface UpsertRequest {\n indexName: string;\n vectors: number[][];\n metadata?: Record<string, any>[];\n ids?: string[];\n}\n\ninterface CreateIndexRequest {\n indexName: string;\n dimension: number;\n metric?: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\ninterface QueryRequest {\n indexName: string;\n queryVector: number[];\n topK?: number;\n filter?: Record<string, any>;\n includeVector?: boolean;\n}\n\nfunction getVector(mastra: Context['mastra'], vectorName?: string): MastraVector {\n if (!vectorName) {\n throw new HTTPException(400, { message: 'Vector name is required' });\n }\n\n const vector = mastra.getVector(vectorName);\n if (!vector) {\n throw new HTTPException(404, { message: `Vector store ${vectorName} not found` });\n }\n\n return vector;\n}\n\n// Upsert vectors\nexport async function upsertVectors({ mastra, vectorName, index }: VectorContext & { index: UpsertRequest }) {\n try {\n if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {\n throw new HTTPException(400, { message: 'Invalid request index. indexName and vectors array are required.' });\n }\n\n const vector = getVector(mastra, vectorName);\n const result = await vector.upsert(index);\n return { ids: result };\n } catch (error) {\n return handleError(error, 'Error upserting vectors');\n }\n}\n\n// Create index\nexport async function createIndex({\n mastra,\n vectorName,\n index,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { index: CreateIndexRequest }) {\n try {\n const { indexName, dimension, metric } = index;\n\n if (!indexName || typeof dimension !== 'number' || dimension <= 0) {\n throw new HTTPException(400, {\n message: 'Invalid request index, indexName and positive dimension number are required.',\n });\n }\n\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new HTTPException(400, { message: 'Invalid metric. Must be one of: cosine, euclidean, dotproduct' });\n }\n\n const vector = getVector(mastra, vectorName);\n await vector.createIndex({ indexName, dimension, metric });\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error creating index');\n }\n}\n\n// Query vectors\nexport async function queryVectors({\n mastra,\n vectorName,\n query,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { query: QueryRequest }) {\n try {\n if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {\n throw new HTTPException(400, { message: 'Invalid request query. indexName and queryVector array are required.' });\n }\n\n const vector = getVector(mastra, vectorName);\n const results: QueryResult[] = await vector.query(query);\n return results;\n } catch (error) {\n return handleError(error, 'Error querying vectors');\n }\n}\n\n// List indexes\nexport async function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>) {\n try {\n const vector = getVector(mastra, vectorName);\n\n const indexes = await vector.listIndexes();\n return indexes.filter(Boolean);\n } catch (error) {\n return handleError(error, 'Error listing indexes');\n }\n}\n\n// Describe index\nexport async function describeIndex({\n mastra,\n vectorName,\n indexName,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { indexName?: string }) {\n try {\n if (!indexName) {\n throw new HTTPException(400, { message: 'Index name is required' });\n }\n\n const vector = getVector(mastra, vectorName);\n const stats: IndexStats = await vector.describeIndex({ indexName });\n\n return {\n dimension: stats.dimension,\n count: stats.count,\n metric: stats.metric?.toLowerCase(),\n };\n } catch (error) {\n return handleError(error, 'Error describing index');\n }\n}\n\n// Delete index\nexport async function deleteIndex({\n mastra,\n vectorName,\n indexName,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { indexName?: string }) {\n try {\n if (!indexName) {\n throw new HTTPException(400, { message: 'Index name is required' });\n }\n\n const vector = getVector(mastra, vectorName);\n await vector.deleteIndex({ indexName });\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error deleting index');\n }\n}\n"]}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { stringify
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { stringify } from './chunk-LF2ZLOFP.js';
|
|
2
|
+
import { handleError } from './chunk-CY4TP3FK.js';
|
|
3
|
+
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
4
|
+
import { __export } from './chunk-G3PMV62Z.js';
|
|
5
|
+
import { ReadableStream } from 'stream/web';
|
|
6
|
+
import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
|
|
5
7
|
|
|
6
|
-
// src/server/handlers/
|
|
7
|
-
var
|
|
8
|
-
__export(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
// src/server/handlers/legacyWorkflows.ts
|
|
9
|
+
var legacyWorkflows_exports = {};
|
|
10
|
+
__export(legacyWorkflows_exports, {
|
|
11
|
+
createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
|
|
12
|
+
getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
|
|
13
|
+
getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
|
|
14
|
+
getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
|
|
15
|
+
getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
|
|
16
|
+
resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
|
|
17
|
+
resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
|
|
18
|
+
startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
|
|
19
|
+
startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
|
|
20
|
+
watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
|
|
19
21
|
});
|
|
20
|
-
async function
|
|
22
|
+
async function getLegacyWorkflowsHandler({ mastra }) {
|
|
21
23
|
try {
|
|
22
|
-
const workflows = mastra.
|
|
24
|
+
const workflows = mastra.legacy_getWorkflows({ serialized: false });
|
|
23
25
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
24
26
|
if (workflow.isNested) return acc;
|
|
25
27
|
acc[key] = {
|
|
@@ -28,13 +30,15 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
28
30
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
29
31
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
30
32
|
name: workflow.name,
|
|
31
|
-
triggerSchema: workflow.triggerSchema ? stringify(
|
|
33
|
+
triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : void 0,
|
|
32
34
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
33
35
|
const _step = step;
|
|
34
36
|
acc2[key2] = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
id: _step.id,
|
|
38
|
+
description: _step.description,
|
|
39
|
+
workflowId: _step.workflowId,
|
|
40
|
+
inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : void 0,
|
|
41
|
+
outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : void 0
|
|
38
42
|
};
|
|
39
43
|
return acc2;
|
|
40
44
|
}, {})
|
|
@@ -43,15 +47,15 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
43
47
|
}, {});
|
|
44
48
|
return _workflows;
|
|
45
49
|
} catch (error) {
|
|
46
|
-
|
|
50
|
+
return handleError(error, "error getting workflows");
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
|
-
async function
|
|
53
|
+
async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
|
|
50
54
|
try {
|
|
51
55
|
if (!workflowId) {
|
|
52
56
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
53
57
|
}
|
|
54
|
-
const workflow = mastra.
|
|
58
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
55
59
|
if (!workflow) {
|
|
56
60
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
57
61
|
}
|
|
@@ -61,22 +65,24 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
61
65
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
62
66
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
63
67
|
name: workflow.name,
|
|
64
|
-
triggerSchema: workflow.triggerSchema ? stringify(
|
|
68
|
+
triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : void 0,
|
|
65
69
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
66
70
|
const _step = step;
|
|
67
71
|
acc[key] = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
id: _step.id,
|
|
73
|
+
description: _step.description,
|
|
74
|
+
workflowId: _step.workflowId,
|
|
75
|
+
inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : void 0,
|
|
76
|
+
outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : void 0
|
|
71
77
|
};
|
|
72
78
|
return acc;
|
|
73
79
|
}, {})
|
|
74
80
|
};
|
|
75
81
|
} catch (error) {
|
|
76
|
-
|
|
82
|
+
return handleError(error, "error getting workflow by id");
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
|
-
async function
|
|
85
|
+
async function startAsyncLegacyWorkflowHandler({
|
|
80
86
|
mastra,
|
|
81
87
|
runtimeContext,
|
|
82
88
|
workflowId,
|
|
@@ -87,19 +93,19 @@ async function startAsyncWorkflowHandler({
|
|
|
87
93
|
if (!workflowId) {
|
|
88
94
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
89
95
|
}
|
|
90
|
-
const workflow = mastra.
|
|
96
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
91
97
|
if (!workflow) {
|
|
92
98
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
93
99
|
}
|
|
94
100
|
if (!runId) {
|
|
95
|
-
const
|
|
96
|
-
const result2 = await start({
|
|
101
|
+
const newRun = workflow.createRun();
|
|
102
|
+
const result2 = await newRun.start({
|
|
97
103
|
triggerData,
|
|
98
104
|
runtimeContext
|
|
99
105
|
});
|
|
100
106
|
return result2;
|
|
101
107
|
}
|
|
102
|
-
const run = workflow.
|
|
108
|
+
const run = workflow.getMemoryRun(runId);
|
|
103
109
|
if (!run) {
|
|
104
110
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
105
111
|
}
|
|
@@ -109,10 +115,10 @@ async function startAsyncWorkflowHandler({
|
|
|
109
115
|
});
|
|
110
116
|
return result;
|
|
111
117
|
} catch (error) {
|
|
112
|
-
|
|
118
|
+
return handleError(error, "error starting workflow");
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
|
-
async function
|
|
121
|
+
async function getLegacyWorkflowRunHandler({
|
|
116
122
|
mastra,
|
|
117
123
|
workflowId,
|
|
118
124
|
runId
|
|
@@ -124,20 +130,20 @@ async function getWorkflowRunHandler({
|
|
|
124
130
|
if (!runId) {
|
|
125
131
|
throw new HTTPException(400, { message: "Run ID is required" });
|
|
126
132
|
}
|
|
127
|
-
const workflow = mastra.
|
|
133
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
128
134
|
if (!workflow) {
|
|
129
135
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
130
136
|
}
|
|
131
|
-
const run = workflow.getRun(runId);
|
|
137
|
+
const run = await workflow.getRun(runId);
|
|
132
138
|
if (!run) {
|
|
133
139
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
134
140
|
}
|
|
135
141
|
return run;
|
|
136
142
|
} catch (error) {
|
|
137
|
-
|
|
143
|
+
return handleError(error, "error getting workflow run");
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
|
-
async function
|
|
146
|
+
async function createLegacyWorkflowRunHandler({
|
|
141
147
|
mastra,
|
|
142
148
|
workflowId,
|
|
143
149
|
runId: prevRunId
|
|
@@ -146,17 +152,17 @@ async function createRunHandler({
|
|
|
146
152
|
if (!workflowId) {
|
|
147
153
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
148
154
|
}
|
|
149
|
-
const workflow = mastra.
|
|
155
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
150
156
|
if (!workflow) {
|
|
151
157
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
152
158
|
}
|
|
153
|
-
const
|
|
154
|
-
return { runId };
|
|
159
|
+
const newRun = workflow.createRun({ runId: prevRunId });
|
|
160
|
+
return { runId: newRun.runId };
|
|
155
161
|
} catch (error) {
|
|
156
|
-
|
|
162
|
+
return handleError(error, "error creating workflow run");
|
|
157
163
|
}
|
|
158
164
|
}
|
|
159
|
-
async function
|
|
165
|
+
async function startLegacyWorkflowRunHandler({
|
|
160
166
|
mastra,
|
|
161
167
|
runtimeContext,
|
|
162
168
|
workflowId,
|
|
@@ -170,12 +176,12 @@ async function startWorkflowRunHandler({
|
|
|
170
176
|
if (!runId) {
|
|
171
177
|
throw new HTTPException(400, { message: "runId required to start run" });
|
|
172
178
|
}
|
|
173
|
-
const workflow = mastra.
|
|
174
|
-
const run = workflow.
|
|
179
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
180
|
+
const run = workflow.getMemoryRun(runId);
|
|
175
181
|
if (!run) {
|
|
176
182
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
177
183
|
}
|
|
178
|
-
|
|
184
|
+
void run.start({
|
|
179
185
|
triggerData,
|
|
180
186
|
runtimeContext
|
|
181
187
|
});
|
|
@@ -184,7 +190,7 @@ async function startWorkflowRunHandler({
|
|
|
184
190
|
return handleError(e, "Error starting workflow run");
|
|
185
191
|
}
|
|
186
192
|
}
|
|
187
|
-
async function
|
|
193
|
+
async function watchLegacyWorkflowHandler({
|
|
188
194
|
mastra,
|
|
189
195
|
workflowId,
|
|
190
196
|
runId
|
|
@@ -196,8 +202,8 @@ async function watchWorkflowHandler({
|
|
|
196
202
|
if (!runId) {
|
|
197
203
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
198
204
|
}
|
|
199
|
-
const workflow = mastra.
|
|
200
|
-
const run = workflow.
|
|
205
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
206
|
+
const run = workflow.getMemoryRun(runId);
|
|
201
207
|
if (!run) {
|
|
202
208
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
203
209
|
}
|
|
@@ -213,8 +219,10 @@ async function watchWorkflowHandler({
|
|
|
213
219
|
asyncRef = null;
|
|
214
220
|
}
|
|
215
221
|
asyncRef = setImmediate(() => {
|
|
216
|
-
|
|
222
|
+
const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
|
|
223
|
+
if (runDone) {
|
|
217
224
|
controller.close();
|
|
225
|
+
unwatch?.();
|
|
218
226
|
}
|
|
219
227
|
});
|
|
220
228
|
});
|
|
@@ -228,7 +236,7 @@ async function watchWorkflowHandler({
|
|
|
228
236
|
return handleError(error, "Error watching workflow");
|
|
229
237
|
}
|
|
230
238
|
}
|
|
231
|
-
async function
|
|
239
|
+
async function resumeAsyncLegacyWorkflowHandler({
|
|
232
240
|
mastra,
|
|
233
241
|
workflowId,
|
|
234
242
|
runId,
|
|
@@ -242,8 +250,8 @@ async function resumeAsyncWorkflowHandler({
|
|
|
242
250
|
if (!runId) {
|
|
243
251
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
244
252
|
}
|
|
245
|
-
const workflow = mastra.
|
|
246
|
-
const run = workflow.
|
|
253
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
254
|
+
const run = workflow.getMemoryRun(runId);
|
|
247
255
|
if (!run) {
|
|
248
256
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
249
257
|
}
|
|
@@ -257,7 +265,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
257
265
|
return handleError(error, "Error resuming workflow step");
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
|
-
async function
|
|
268
|
+
async function resumeLegacyWorkflowHandler({
|
|
261
269
|
mastra,
|
|
262
270
|
workflowId,
|
|
263
271
|
runId,
|
|
@@ -271,12 +279,12 @@ async function resumeWorkflowHandler({
|
|
|
271
279
|
if (!runId) {
|
|
272
280
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
273
281
|
}
|
|
274
|
-
const workflow = mastra.
|
|
275
|
-
const run = workflow.
|
|
282
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
283
|
+
const run = workflow.getMemoryRun(runId);
|
|
276
284
|
if (!run) {
|
|
277
285
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
278
286
|
}
|
|
279
|
-
|
|
287
|
+
void run.resume({
|
|
280
288
|
stepId: body.stepId,
|
|
281
289
|
context: body.context,
|
|
282
290
|
runtimeContext
|
|
@@ -286,13 +294,21 @@ async function resumeWorkflowHandler({
|
|
|
286
294
|
return handleError(error, "Error resuming workflow");
|
|
287
295
|
}
|
|
288
296
|
}
|
|
289
|
-
async function
|
|
297
|
+
async function getLegacyWorkflowRunsHandler({
|
|
298
|
+
mastra,
|
|
299
|
+
workflowId,
|
|
300
|
+
fromDate,
|
|
301
|
+
toDate,
|
|
302
|
+
limit,
|
|
303
|
+
offset,
|
|
304
|
+
resourceId
|
|
305
|
+
}) {
|
|
290
306
|
try {
|
|
291
307
|
if (!workflowId) {
|
|
292
308
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
293
309
|
}
|
|
294
|
-
const workflow = mastra.
|
|
295
|
-
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
310
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
311
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
296
312
|
runs: [],
|
|
297
313
|
total: 0
|
|
298
314
|
};
|
|
@@ -302,4 +318,6 @@ async function getWorkflowRunsHandler({ mastra, workflowId }) {
|
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
320
|
|
|
305
|
-
export {
|
|
321
|
+
export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, legacyWorkflows_exports, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler };
|
|
322
|
+
//# sourceMappingURL=chunk-TTHEEIZ3.js.map
|
|
323
|
+
//# sourceMappingURL=chunk-TTHEEIZ3.js.map
|