@mastra/server 0.0.0-inject-middleware-20250528222017 → 0.0.0-interpolate-reporter-url-20250910180021
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 +3569 -0
- package/LICENSE.md +11 -42
- package/dist/{chunk-5SN4U5AC.cjs → chunk-3THIIWWW.cjs} +113 -137
- package/dist/chunk-3THIIWWW.cjs.map +1 -0
- package/dist/{chunk-H5PTF3Y4.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-P6SCPDYW.js → chunk-5QUKZCEF.js} +112 -136
- 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-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
- 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-HFWCEP5S.js → chunk-A75S4TDD.js} +36 -11
- 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-YWLUOY3D.cjs → chunk-HVBBFCDH.cjs} +1110 -793
- 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-VPNDC2DI.cjs → chunk-IY34NOLA.cjs} +16 -14
- 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-YIOVBYZH.cjs → chunk-KNGXRN26.cjs} +48 -45
- package/dist/chunk-KNGXRN26.cjs.map +1 -0
- package/dist/{chunk-OR3CIE2H.js → chunk-KV6VHX4V.js} +29 -7
- 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-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/{chunk-LIVAK2DM.js → chunk-N7F33WAD.js} +1083 -794
- 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-MHKNLNAN.cjs → chunk-PWTXZZTR.cjs} +33 -10
- 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-TJKLBTFB.js → chunk-SYRRSBGL.js} +51 -27
- package/dist/chunk-SYRRSBGL.js.map +1 -0
- package/dist/{chunk-BNEY4P4P.cjs → chunk-T3TIA3O6.cjs} +20 -18
- package/dist/chunk-T3TIA3O6.cjs.map +1 -0
- package/dist/{chunk-W7VCKPAD.js → chunk-TTHEEIZ3.js} +19 -16
- 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-C7564HUT.js → chunk-U46VIX2V.js} +6 -4
- package/dist/chunk-U46VIX2V.js.map +1 -0
- package/dist/{chunk-55DOQLP6.js → chunk-WHN4VX55.js} +5 -3
- 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 +13 -11
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +68 -6
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -1
- 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 +13 -11
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -1
- 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 +30 -12
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +73 -11
- 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 +49 -32
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +15 -11
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +16 -11
- 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 -21
- package/dist/_tsup-dts-rollup.d.cts +0 -830
- package/dist/_tsup-dts-rollup.d.ts +0 -830
- package/dist/chunk-57CJTIPW.cjs +0 -18
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-A3KDUGS7.cjs +0 -239
- package/dist/chunk-DJJIUEL2.js +0 -211
- package/dist/chunk-DQLE3DVM.js +0 -49
- package/dist/chunk-J3PKLB3A.js +0 -231
- package/dist/chunk-KUNQFY2W.js +0 -365
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-MLKGABMK.js +0 -7
- package/dist/chunk-MMO2HDM6.cjs +0 -378
- package/dist/chunk-NEOOQUKW.cjs +0 -54
- package/dist/chunk-Y7UWRW5X.cjs +0 -221
- package/dist/chunk-YBVOQN4M.cjs +0 -94
- package/dist/chunk-ZE5AAC4I.cjs +0 -138
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
- 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/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -3
- package/dist/server/handlers/workflows.d.cts +0 -11
- package/dist/server/handlers.d.cts +0 -11
package/dist/chunk-J3PKLB3A.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-LIVAK2DM.js';
|
|
2
|
-
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
3
|
-
import { handleError } from './chunk-M5ABIP7D.js';
|
|
4
|
-
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
5
|
-
import { __export } from './chunk-MLKGABMK.js';
|
|
6
|
-
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/agents.ts
|
|
9
|
-
var agents_exports = {};
|
|
10
|
-
__export(agents_exports, {
|
|
11
|
-
generateHandler: () => generateHandler,
|
|
12
|
-
getAgentByIdHandler: () => getAgentByIdHandler,
|
|
13
|
-
getAgentsHandler: () => getAgentsHandler,
|
|
14
|
-
getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
|
|
15
|
-
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
16
|
-
streamGenerateHandler: () => streamGenerateHandler
|
|
17
|
-
});
|
|
18
|
-
async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
19
|
-
try {
|
|
20
|
-
const agents = mastra.getAgents();
|
|
21
|
-
const serializedAgentsMap = await Promise.all(
|
|
22
|
-
Object.entries(agents).map(async ([id, agent]) => {
|
|
23
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
24
|
-
const tools = await agent.getTools({ runtimeContext });
|
|
25
|
-
const llm = await agent.getLLM({ runtimeContext });
|
|
26
|
-
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
27
|
-
const _tool = tool;
|
|
28
|
-
acc[key] = {
|
|
29
|
-
..._tool,
|
|
30
|
-
inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
|
|
31
|
-
outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
|
|
32
|
-
};
|
|
33
|
-
return acc;
|
|
34
|
-
}, {});
|
|
35
|
-
let serializedAgentWorkflows = {};
|
|
36
|
-
if ("getWorkflows" in agent) {
|
|
37
|
-
const logger = mastra.getLogger();
|
|
38
|
-
try {
|
|
39
|
-
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
40
|
-
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
41
|
-
return {
|
|
42
|
-
...acc,
|
|
43
|
-
[key]: {
|
|
44
|
-
name: workflow.name
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}, {});
|
|
48
|
-
} catch (error) {
|
|
49
|
-
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
id,
|
|
54
|
-
name: agent.name,
|
|
55
|
-
instructions,
|
|
56
|
-
tools: serializedAgentTools,
|
|
57
|
-
workflows: serializedAgentWorkflows,
|
|
58
|
-
provider: llm?.getProvider(),
|
|
59
|
-
modelId: llm?.getModelId(),
|
|
60
|
-
defaultGenerateOptions: agent.getDefaultGenerateOptions(),
|
|
61
|
-
defaultStreamOptions: agent.getDefaultStreamOptions()
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
|
|
66
|
-
acc[id] = rest;
|
|
67
|
-
return acc;
|
|
68
|
-
}, {});
|
|
69
|
-
return serializedAgents;
|
|
70
|
-
} catch (error) {
|
|
71
|
-
return handleError(error, "Error getting agents");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function getAgentByIdHandler({
|
|
75
|
-
mastra,
|
|
76
|
-
runtimeContext,
|
|
77
|
-
agentId
|
|
78
|
-
}) {
|
|
79
|
-
try {
|
|
80
|
-
const agent = mastra.getAgent(agentId);
|
|
81
|
-
if (!agent) {
|
|
82
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
83
|
-
}
|
|
84
|
-
const tools = await agent.getTools({ runtimeContext });
|
|
85
|
-
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
86
|
-
const _tool = tool;
|
|
87
|
-
acc[key] = {
|
|
88
|
-
..._tool,
|
|
89
|
-
inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
|
|
90
|
-
outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
|
|
91
|
-
};
|
|
92
|
-
return acc;
|
|
93
|
-
}, {});
|
|
94
|
-
let serializedAgentWorkflows = {};
|
|
95
|
-
if ("getWorkflows" in agent) {
|
|
96
|
-
const logger = mastra.getLogger();
|
|
97
|
-
try {
|
|
98
|
-
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
99
|
-
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
100
|
-
return {
|
|
101
|
-
...acc,
|
|
102
|
-
[key]: {
|
|
103
|
-
name: workflow.name
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}, {});
|
|
107
|
-
} catch (error) {
|
|
108
|
-
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
112
|
-
const llm = await agent.getLLM({ runtimeContext });
|
|
113
|
-
return {
|
|
114
|
-
name: agent.name,
|
|
115
|
-
instructions,
|
|
116
|
-
tools: serializedAgentTools,
|
|
117
|
-
workflows: serializedAgentWorkflows,
|
|
118
|
-
provider: llm?.getProvider(),
|
|
119
|
-
modelId: llm?.getModelId(),
|
|
120
|
-
defaultGenerateOptions: agent.getDefaultGenerateOptions(),
|
|
121
|
-
defaultStreamOptions: agent.getDefaultStreamOptions()
|
|
122
|
-
};
|
|
123
|
-
} catch (error) {
|
|
124
|
-
return handleError(error, "Error getting agent");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function getEvalsByAgentIdHandler({
|
|
128
|
-
mastra,
|
|
129
|
-
runtimeContext,
|
|
130
|
-
agentId
|
|
131
|
-
}) {
|
|
132
|
-
try {
|
|
133
|
-
const agent = mastra.getAgent(agentId);
|
|
134
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
135
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
136
|
-
return {
|
|
137
|
-
id: agentId,
|
|
138
|
-
name: agent.name,
|
|
139
|
-
instructions,
|
|
140
|
-
evals
|
|
141
|
-
};
|
|
142
|
-
} catch (error) {
|
|
143
|
-
return handleError(error, "Error getting test evals");
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async function getLiveEvalsByAgentIdHandler({
|
|
147
|
-
mastra,
|
|
148
|
-
runtimeContext,
|
|
149
|
-
agentId
|
|
150
|
-
}) {
|
|
151
|
-
try {
|
|
152
|
-
const agent = mastra.getAgent(agentId);
|
|
153
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
154
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
155
|
-
return {
|
|
156
|
-
id: agentId,
|
|
157
|
-
name: agent.name,
|
|
158
|
-
instructions,
|
|
159
|
-
evals
|
|
160
|
-
};
|
|
161
|
-
} catch (error) {
|
|
162
|
-
return handleError(error, "Error getting live evals");
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function generateHandler({
|
|
166
|
-
mastra,
|
|
167
|
-
runtimeContext,
|
|
168
|
-
agentId,
|
|
169
|
-
body
|
|
170
|
-
}) {
|
|
171
|
-
try {
|
|
172
|
-
const agent = mastra.getAgent(agentId);
|
|
173
|
-
if (!agent) {
|
|
174
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
175
|
-
}
|
|
176
|
-
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
177
|
-
const finalResourceId = resourceId ?? resourceid;
|
|
178
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
179
|
-
...Array.from(runtimeContext.entries()),
|
|
180
|
-
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
181
|
-
]);
|
|
182
|
-
validateBody({ messages });
|
|
183
|
-
const result = await agent.generate(messages, {
|
|
184
|
-
...rest,
|
|
185
|
-
// @ts-expect-error TODO fix types
|
|
186
|
-
resourceId: finalResourceId,
|
|
187
|
-
runtimeContext: finalRuntimeContext
|
|
188
|
-
});
|
|
189
|
-
return result;
|
|
190
|
-
} catch (error) {
|
|
191
|
-
return handleError(error, "Error generating from agent");
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async function streamGenerateHandler({
|
|
195
|
-
mastra,
|
|
196
|
-
runtimeContext,
|
|
197
|
-
agentId,
|
|
198
|
-
body
|
|
199
|
-
}) {
|
|
200
|
-
try {
|
|
201
|
-
const agent = mastra.getAgent(agentId);
|
|
202
|
-
if (!agent) {
|
|
203
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
204
|
-
}
|
|
205
|
-
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
206
|
-
const finalResourceId = resourceId ?? resourceid;
|
|
207
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
208
|
-
...Array.from(runtimeContext.entries()),
|
|
209
|
-
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
210
|
-
]);
|
|
211
|
-
validateBody({ messages });
|
|
212
|
-
const streamResult = await agent.stream(messages, {
|
|
213
|
-
...rest,
|
|
214
|
-
// @ts-expect-error TODO fix types
|
|
215
|
-
resourceId: finalResourceId,
|
|
216
|
-
runtimeContext: finalRuntimeContext
|
|
217
|
-
});
|
|
218
|
-
const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
219
|
-
sendUsage: true,
|
|
220
|
-
sendReasoning: true,
|
|
221
|
-
getErrorMessage: (error) => {
|
|
222
|
-
return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
return streamResponse;
|
|
226
|
-
} catch (error) {
|
|
227
|
-
throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler };
|
package/dist/chunk-KUNQFY2W.js
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-LIVAK2DM.js';
|
|
2
|
-
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
|
-
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
-
import { __export } from './chunk-MLKGABMK.js';
|
|
5
|
-
import { ReadableStream } from 'node:stream/web';
|
|
6
|
-
import { RuntimeContext } from '@mastra/core/di';
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/workflows.ts
|
|
9
|
-
var workflows_exports = {};
|
|
10
|
-
__export(workflows_exports, {
|
|
11
|
-
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
12
|
-
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
13
|
-
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
14
|
-
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
15
|
-
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
16
|
-
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
17
|
-
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
18
|
-
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
19
|
-
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
20
|
-
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
21
|
-
watchWorkflowHandler: () => watchWorkflowHandler
|
|
22
|
-
});
|
|
23
|
-
async function getWorkflowsHandler({ mastra }) {
|
|
24
|
-
try {
|
|
25
|
-
const workflows = mastra.getWorkflows({ serialized: false });
|
|
26
|
-
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
27
|
-
acc[key] = {
|
|
28
|
-
name: workflow.name,
|
|
29
|
-
description: workflow.description,
|
|
30
|
-
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
31
|
-
acc2[key2] = {
|
|
32
|
-
id: step.id,
|
|
33
|
-
description: step.description,
|
|
34
|
-
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
35
|
-
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
36
|
-
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
|
|
37
|
-
suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
|
|
38
|
-
};
|
|
39
|
-
return acc2;
|
|
40
|
-
}, {}),
|
|
41
|
-
stepGraph: workflow.serializedStepGraph,
|
|
42
|
-
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
43
|
-
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
44
|
-
};
|
|
45
|
-
return acc;
|
|
46
|
-
}, {});
|
|
47
|
-
return _workflows;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
53
|
-
try {
|
|
54
|
-
if (!workflowId) {
|
|
55
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
56
|
-
}
|
|
57
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
58
|
-
if (!workflow) {
|
|
59
|
-
throw new HTTPException(404, { message: "Workflow not found" });
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
63
|
-
acc[key] = {
|
|
64
|
-
id: step.id,
|
|
65
|
-
description: step.description,
|
|
66
|
-
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
67
|
-
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
68
|
-
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
|
|
69
|
-
suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
|
|
70
|
-
};
|
|
71
|
-
return acc;
|
|
72
|
-
}, {}),
|
|
73
|
-
name: workflow.name,
|
|
74
|
-
description: workflow.description,
|
|
75
|
-
stepGraph: workflow.serializedStepGraph,
|
|
76
|
-
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
77
|
-
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
78
|
-
};
|
|
79
|
-
} catch (error) {
|
|
80
|
-
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function getWorkflowRunByIdHandler({
|
|
84
|
-
mastra,
|
|
85
|
-
workflowId,
|
|
86
|
-
runId
|
|
87
|
-
}) {
|
|
88
|
-
try {
|
|
89
|
-
if (!workflowId) {
|
|
90
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
91
|
-
}
|
|
92
|
-
if (!runId) {
|
|
93
|
-
throw new HTTPException(400, { message: "Run ID is required" });
|
|
94
|
-
}
|
|
95
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
96
|
-
if (!workflow) {
|
|
97
|
-
throw new HTTPException(404, { message: "Workflow not found" });
|
|
98
|
-
}
|
|
99
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
100
|
-
if (!run) {
|
|
101
|
-
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
102
|
-
}
|
|
103
|
-
return run;
|
|
104
|
-
} catch (error) {
|
|
105
|
-
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async function createWorkflowRunHandler({
|
|
109
|
-
mastra,
|
|
110
|
-
workflowId,
|
|
111
|
-
runId: prevRunId
|
|
112
|
-
}) {
|
|
113
|
-
try {
|
|
114
|
-
if (!workflowId) {
|
|
115
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
116
|
-
}
|
|
117
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
118
|
-
if (!workflow) {
|
|
119
|
-
throw new HTTPException(404, { message: "Workflow not found" });
|
|
120
|
-
}
|
|
121
|
-
const run = workflow.createRun({ runId: prevRunId });
|
|
122
|
-
return { runId: run.runId };
|
|
123
|
-
} catch (error) {
|
|
124
|
-
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function startAsyncWorkflowHandler({
|
|
128
|
-
mastra,
|
|
129
|
-
runtimeContext,
|
|
130
|
-
workflowId,
|
|
131
|
-
runId,
|
|
132
|
-
inputData,
|
|
133
|
-
runtimeContextFromRequest
|
|
134
|
-
}) {
|
|
135
|
-
try {
|
|
136
|
-
if (!workflowId) {
|
|
137
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
138
|
-
}
|
|
139
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
140
|
-
if (!workflow) {
|
|
141
|
-
throw new HTTPException(404, { message: "Workflow not found" });
|
|
142
|
-
}
|
|
143
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
144
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
145
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
146
|
-
]);
|
|
147
|
-
const _run = workflow.createRun({ runId });
|
|
148
|
-
const result = await _run.start({
|
|
149
|
-
inputData,
|
|
150
|
-
runtimeContext: finalRuntimeContext
|
|
151
|
-
});
|
|
152
|
-
return result;
|
|
153
|
-
} catch (error) {
|
|
154
|
-
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async function startWorkflowRunHandler({
|
|
158
|
-
mastra,
|
|
159
|
-
runtimeContext,
|
|
160
|
-
workflowId,
|
|
161
|
-
runId,
|
|
162
|
-
inputData,
|
|
163
|
-
runtimeContextFromRequest
|
|
164
|
-
}) {
|
|
165
|
-
try {
|
|
166
|
-
if (!workflowId) {
|
|
167
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
168
|
-
}
|
|
169
|
-
if (!runId) {
|
|
170
|
-
throw new HTTPException(400, { message: "runId required to start run" });
|
|
171
|
-
}
|
|
172
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
173
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
174
|
-
if (!run) {
|
|
175
|
-
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
176
|
-
}
|
|
177
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
178
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
179
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
180
|
-
]);
|
|
181
|
-
const _run = workflow.createRun({ runId });
|
|
182
|
-
void _run.start({
|
|
183
|
-
inputData,
|
|
184
|
-
runtimeContext: finalRuntimeContext
|
|
185
|
-
});
|
|
186
|
-
return { message: "Workflow run started" };
|
|
187
|
-
} catch (e) {
|
|
188
|
-
return handleError(e, "Error starting workflow run");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
async function watchWorkflowHandler({
|
|
192
|
-
mastra,
|
|
193
|
-
workflowId,
|
|
194
|
-
runId
|
|
195
|
-
}) {
|
|
196
|
-
try {
|
|
197
|
-
if (!workflowId) {
|
|
198
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
199
|
-
}
|
|
200
|
-
if (!runId) {
|
|
201
|
-
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
202
|
-
}
|
|
203
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
204
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
205
|
-
if (!run) {
|
|
206
|
-
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
207
|
-
}
|
|
208
|
-
const _run = workflow.createRun({ runId });
|
|
209
|
-
let unwatch;
|
|
210
|
-
let asyncRef = null;
|
|
211
|
-
const stream = new ReadableStream({
|
|
212
|
-
start(controller) {
|
|
213
|
-
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
214
|
-
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
215
|
-
if (asyncRef) {
|
|
216
|
-
clearImmediate(asyncRef);
|
|
217
|
-
asyncRef = null;
|
|
218
|
-
}
|
|
219
|
-
asyncRef = setImmediate(async () => {
|
|
220
|
-
const runDone = payload.workflowState.status !== "running";
|
|
221
|
-
if (runDone) {
|
|
222
|
-
controller.close();
|
|
223
|
-
unwatch?.();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
cancel() {
|
|
229
|
-
unwatch?.();
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return stream;
|
|
233
|
-
} catch (error) {
|
|
234
|
-
return handleError(error, "Error watching workflow");
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
function streamWorkflowHandler({
|
|
238
|
-
mastra,
|
|
239
|
-
runtimeContext,
|
|
240
|
-
workflowId,
|
|
241
|
-
runId,
|
|
242
|
-
inputData,
|
|
243
|
-
runtimeContextFromRequest
|
|
244
|
-
}) {
|
|
245
|
-
try {
|
|
246
|
-
if (!workflowId) {
|
|
247
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
248
|
-
}
|
|
249
|
-
if (!runId) {
|
|
250
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
251
|
-
}
|
|
252
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
253
|
-
if (!workflow) {
|
|
254
|
-
throw new HTTPException(404, { message: "Workflow not found" });
|
|
255
|
-
}
|
|
256
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
257
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
258
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
259
|
-
]);
|
|
260
|
-
const run = workflow.createRun({ runId });
|
|
261
|
-
const result = run.stream({
|
|
262
|
-
inputData,
|
|
263
|
-
runtimeContext: finalRuntimeContext
|
|
264
|
-
});
|
|
265
|
-
return result;
|
|
266
|
-
} catch (error) {
|
|
267
|
-
return handleError(error, "Error executing workflow");
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
async function resumeAsyncWorkflowHandler({
|
|
271
|
-
mastra,
|
|
272
|
-
workflowId,
|
|
273
|
-
runId,
|
|
274
|
-
body,
|
|
275
|
-
runtimeContext,
|
|
276
|
-
runtimeContextFromRequest
|
|
277
|
-
}) {
|
|
278
|
-
try {
|
|
279
|
-
if (!workflowId) {
|
|
280
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
281
|
-
}
|
|
282
|
-
if (!runId) {
|
|
283
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
284
|
-
}
|
|
285
|
-
if (!body.step) {
|
|
286
|
-
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
287
|
-
}
|
|
288
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
289
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
290
|
-
if (!run) {
|
|
291
|
-
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
292
|
-
}
|
|
293
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
294
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
295
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
296
|
-
]);
|
|
297
|
-
const _run = workflow.createRun({ runId });
|
|
298
|
-
const result = await _run.resume({
|
|
299
|
-
step: body.step,
|
|
300
|
-
resumeData: body.resumeData,
|
|
301
|
-
runtimeContext: finalRuntimeContext
|
|
302
|
-
});
|
|
303
|
-
return result;
|
|
304
|
-
} catch (error) {
|
|
305
|
-
return handleError(error, "Error resuming workflow step");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
async function resumeWorkflowHandler({
|
|
309
|
-
mastra,
|
|
310
|
-
workflowId,
|
|
311
|
-
runId,
|
|
312
|
-
body,
|
|
313
|
-
runtimeContext
|
|
314
|
-
}) {
|
|
315
|
-
try {
|
|
316
|
-
if (!workflowId) {
|
|
317
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
318
|
-
}
|
|
319
|
-
if (!runId) {
|
|
320
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
321
|
-
}
|
|
322
|
-
if (!body.step) {
|
|
323
|
-
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
324
|
-
}
|
|
325
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
326
|
-
const run = await workflow.getWorkflowRunById(runId);
|
|
327
|
-
if (!run) {
|
|
328
|
-
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
329
|
-
}
|
|
330
|
-
const _run = workflow.createRun({ runId });
|
|
331
|
-
void _run.resume({
|
|
332
|
-
step: body.step,
|
|
333
|
-
resumeData: body.resumeData,
|
|
334
|
-
runtimeContext
|
|
335
|
-
});
|
|
336
|
-
return { message: "Workflow run resumed" };
|
|
337
|
-
} catch (error) {
|
|
338
|
-
return handleError(error, "Error resuming workflow");
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
async function getWorkflowRunsHandler({
|
|
342
|
-
mastra,
|
|
343
|
-
workflowId,
|
|
344
|
-
fromDate,
|
|
345
|
-
toDate,
|
|
346
|
-
limit,
|
|
347
|
-
offset,
|
|
348
|
-
resourceId
|
|
349
|
-
}) {
|
|
350
|
-
try {
|
|
351
|
-
if (!workflowId) {
|
|
352
|
-
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
353
|
-
}
|
|
354
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
355
|
-
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
356
|
-
runs: [],
|
|
357
|
-
total: 0
|
|
358
|
-
};
|
|
359
|
-
return workflowRuns;
|
|
360
|
-
} catch (error) {
|
|
361
|
-
return handleError(error, "Error getting workflow runs");
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
package/dist/chunk-M5ABIP7D.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
2
|
-
|
|
3
|
-
// src/server/handlers/error.ts
|
|
4
|
-
function handleError(error, defaultMessage) {
|
|
5
|
-
const apiError = error;
|
|
6
|
-
throw new HTTPException(apiError.status || 500, {
|
|
7
|
-
message: apiError.message || defaultMessage
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { handleError };
|