@mastra/server 0.0.0-break-rename-vnext-legacy-20250926163953 → 0.0.0-break-rename-vnext-legacy-20251002212351
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 +66 -3
- package/dist/{chunk-CML3EOO5.cjs → chunk-4HS3I2TI.cjs} +118 -25
- package/dist/chunk-4HS3I2TI.cjs.map +1 -0
- package/dist/{chunk-5N724Q2T.cjs → chunk-52UP7DFT.cjs} +23 -2
- package/dist/chunk-52UP7DFT.cjs.map +1 -0
- package/dist/{chunk-NH7XUTIO.js → chunk-AX5SCBJL.js} +118 -26
- package/dist/chunk-AX5SCBJL.js.map +1 -0
- package/dist/{chunk-2GDLSAVJ.cjs → chunk-BKCWZLEL.cjs} +2 -2
- package/dist/{chunk-2GDLSAVJ.cjs.map → chunk-BKCWZLEL.cjs.map} +1 -1
- package/dist/{chunk-N5G6GCIU.cjs → chunk-FYZHFAFB.cjs} +92 -41
- package/dist/chunk-FYZHFAFB.cjs.map +1 -0
- package/dist/{chunk-LVQ53LE4.js → chunk-HRG5HN4U.js} +90 -42
- package/dist/chunk-HRG5HN4U.js.map +1 -0
- package/dist/{chunk-MKETEHXX.cjs → chunk-JOXMWFM6.cjs} +2494 -219
- package/dist/chunk-JOXMWFM6.cjs.map +1 -0
- package/dist/{chunk-OZLRIVC4.cjs → chunk-LHGBI76Y.cjs} +19 -39
- package/dist/chunk-LHGBI76Y.cjs.map +1 -0
- package/dist/{chunk-HAXRTSG2.js → chunk-QDPOVUS4.js} +2480 -205
- package/dist/chunk-QDPOVUS4.js.map +1 -0
- package/dist/{chunk-SQY4T6EJ.js → chunk-SZUAJANR.js} +19 -39
- package/dist/chunk-SZUAJANR.js.map +1 -0
- package/dist/{chunk-5KRXONRF.js → chunk-WUJLVNLU.js} +23 -3
- package/dist/chunk-WUJLVNLU.js.map +1 -0
- package/dist/{chunk-IYJW2OVQ.js → chunk-XJOYGRTN.js} +2 -2
- package/dist/{chunk-IYJW2OVQ.js.map → chunk-XJOYGRTN.js.map} +1 -1
- package/dist/{chunk-HZJRQ5L3.cjs → dist-3DRD6USP.cjs} +2 -2
- package/dist/dist-3DRD6USP.cjs.map +1 -0
- package/dist/{chunk-EMNGA4R4.js → dist-7GVM5ZCS.js} +2 -2
- package/dist/dist-7GVM5ZCS.js.map +1 -0
- package/dist/{chunk-OGW6HHVI.js → dist-CCDXEZDR.js} +2 -2
- package/dist/dist-CCDXEZDR.js.map +1 -0
- package/dist/{chunk-66YYHFGF.js → dist-COC6WFAX.js} +2 -2
- package/dist/dist-COC6WFAX.js.map +1 -0
- package/dist/{chunk-RCHEPTZZ.js → dist-H7RR3EXL.js} +2 -2
- package/dist/dist-H7RR3EXL.js.map +1 -0
- package/dist/{chunk-LYPU75T6.js → dist-JNIWWFE5.js} +2 -2
- package/dist/dist-JNIWWFE5.js.map +1 -0
- package/dist/{chunk-P7RBMCBE.cjs → dist-L76NFIWM.cjs} +2 -2
- package/dist/dist-L76NFIWM.cjs.map +1 -0
- package/dist/{chunk-FQNT7PI4.js → dist-LKU3RRT2.js} +2 -2
- package/dist/dist-LKU3RRT2.js.map +1 -0
- package/dist/{chunk-IOQGI4ML.js → dist-MQUZENT7.js} +2 -2
- package/dist/dist-MQUZENT7.js.map +1 -0
- package/dist/{chunk-5DP5XZH6.cjs → dist-N6P7NYGX.cjs} +2 -2
- package/dist/dist-N6P7NYGX.cjs.map +1 -0
- package/dist/{chunk-TVSIG4JE.cjs → dist-OC4J73ML.cjs} +2 -2
- package/dist/dist-OC4J73ML.cjs.map +1 -0
- package/dist/{chunk-HJQKWRKQ.cjs → dist-QI7RYOYQ.cjs} +2 -2
- package/dist/dist-QI7RYOYQ.cjs.map +1 -0
- package/dist/{chunk-IGFMAZZ5.cjs → dist-R3L5J3LL.cjs} +2 -2
- package/dist/dist-R3L5J3LL.cjs.map +1 -0
- package/dist/{chunk-743UIDHI.cjs → dist-S3ILRJUH.cjs} +2 -2
- package/dist/dist-S3ILRJUH.cjs.map +1 -0
- package/dist/{chunk-AK2FXLLB.cjs → dist-WY4WSW7C.cjs} +2 -2
- package/dist/dist-WY4WSW7C.cjs.map +1 -0
- package/dist/{chunk-P7CIEIJ3.js → dist-ZHCN47XA.js} +2 -2
- package/dist/dist-ZHCN47XA.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts +6 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +27 -15
- package/dist/server/handlers/agents.d.ts +33 -2
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/memory.cjs +16 -16
- package/dist/server/handlers/memory.d.ts +14 -15
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +8 -4
- package/dist/server/handlers/observability.d.ts +9 -1
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.d.ts +15 -15
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/workflows.cjs +22 -18
- package/dist/server/handlers/workflows.d.ts +17 -8
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +17 -17
- package/dist/server/handlers.js +7 -7
- package/package.json +8 -16
- package/dist/chunk-5DP5XZH6.cjs.map +0 -1
- package/dist/chunk-5KRXONRF.js.map +0 -1
- package/dist/chunk-5N724Q2T.cjs.map +0 -1
- package/dist/chunk-66YYHFGF.js.map +0 -1
- package/dist/chunk-743UIDHI.cjs.map +0 -1
- package/dist/chunk-AK2FXLLB.cjs.map +0 -1
- package/dist/chunk-CML3EOO5.cjs.map +0 -1
- package/dist/chunk-EMNGA4R4.js.map +0 -1
- package/dist/chunk-FQNT7PI4.js.map +0 -1
- package/dist/chunk-HAXRTSG2.js.map +0 -1
- package/dist/chunk-HJQKWRKQ.cjs.map +0 -1
- package/dist/chunk-HZJRQ5L3.cjs.map +0 -1
- package/dist/chunk-IGFMAZZ5.cjs.map +0 -1
- package/dist/chunk-IOQGI4ML.js.map +0 -1
- package/dist/chunk-LVQ53LE4.js.map +0 -1
- package/dist/chunk-LYPU75T6.js.map +0 -1
- package/dist/chunk-MKETEHXX.cjs.map +0 -1
- package/dist/chunk-N5G6GCIU.cjs.map +0 -1
- package/dist/chunk-NH7XUTIO.js.map +0 -1
- package/dist/chunk-OGW6HHVI.js.map +0 -1
- package/dist/chunk-OZLRIVC4.cjs.map +0 -1
- package/dist/chunk-P7CIEIJ3.js.map +0 -1
- package/dist/chunk-P7RBMCBE.cjs.map +0 -1
- package/dist/chunk-RCHEPTZZ.js.map +0 -1
- package/dist/chunk-SQY4T6EJ.js.map +0 -1
- package/dist/chunk-TVSIG4JE.cjs.map +0 -1
- package/dist/dist-3A5DXB37.cjs +0 -20
- package/dist/dist-3A5DXB37.cjs.map +0 -1
- package/dist/dist-3SJKQJGY.cjs +0 -16
- package/dist/dist-3SJKQJGY.cjs.map +0 -1
- package/dist/dist-4ZQSPE5K.js +0 -3
- package/dist/dist-4ZQSPE5K.js.map +0 -1
- package/dist/dist-5W5QNRTD.js +0 -3
- package/dist/dist-5W5QNRTD.js.map +0 -1
- package/dist/dist-653SRMPL.js +0 -3
- package/dist/dist-653SRMPL.js.map +0 -1
- package/dist/dist-6U6EFC5C.cjs +0 -16
- package/dist/dist-6U6EFC5C.cjs.map +0 -1
- package/dist/dist-7IHNNYMF.cjs +0 -16
- package/dist/dist-7IHNNYMF.cjs.map +0 -1
- package/dist/dist-B5IPRF6W.js +0 -3
- package/dist/dist-B5IPRF6W.js.map +0 -1
- package/dist/dist-EOMYFT4Y.cjs +0 -16
- package/dist/dist-EOMYFT4Y.cjs.map +0 -1
- package/dist/dist-F2ET4MNO.cjs +0 -16
- package/dist/dist-F2ET4MNO.cjs.map +0 -1
- package/dist/dist-HY7RMLJQ.cjs +0 -16
- package/dist/dist-HY7RMLJQ.cjs.map +0 -1
- package/dist/dist-M6S4P3FJ.js +0 -3
- package/dist/dist-M6S4P3FJ.js.map +0 -1
- package/dist/dist-NR7QSCQT.js +0 -3
- package/dist/dist-NR7QSCQT.js.map +0 -1
- package/dist/dist-QLFMCMCX.js +0 -3
- package/dist/dist-QLFMCMCX.js.map +0 -1
- package/dist/dist-UY46BFRP.js +0 -3
- package/dist/dist-UY46BFRP.js.map +0 -1
- package/dist/dist-WCQDRTIV.cjs +0 -16
- package/dist/dist-WCQDRTIV.cjs.map +0 -1
- package/dist/server/handlers/vNextNetwork.cjs +0 -220
- package/dist/server/handlers/vNextNetwork.cjs.map +0 -1
- package/dist/server/handlers/vNextNetwork.d.ts +0 -246
- package/dist/server/handlers/vNextNetwork.d.ts.map +0 -1
- package/dist/server/handlers/vNextNetwork.js +0 -213
- package/dist/server/handlers/vNextNetwork.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
-
## 0.0.0-break-rename-vnext-legacy-
|
|
3
|
+
## 0.0.0-break-rename-vnext-legacy-20251002212351
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -8,14 +8,77 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
+
- Add approve and decline tool calls to mastra server pkg ([#8360](https://github.com/mastra-ai/mastra/pull/8360))
|
|
12
|
+
|
|
13
|
+
- Fix/8219 preserve resourceid on resume ([#8359](https://github.com/mastra-ai/mastra/pull/8359))
|
|
14
|
+
|
|
15
|
+
- Add observe strean to get streans after workflow has been interrupted ([#8318](https://github.com/mastra-ai/mastra/pull/8318))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`aef427d`](https://github.com/mastra-ai/mastra/commit/aef427d7e7a414afcf3c561b94289b580f117219), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
|
|
18
|
+
- @mastra/core@0.0.0-break-rename-vnext-legacy-20251002212351
|
|
19
|
+
|
|
20
|
+
## 0.19.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Added Mastra model router to Playground UI ([#8332](https://github.com/mastra-ai/mastra/pull/8332))
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`4a70ccc`](https://github.com/mastra-ai/mastra/commit/4a70ccc5cfa12ae9c2b36545a5814cd98e5a0ead), [`0992b8b`](https://github.com/mastra-ai/mastra/commit/0992b8bf0f4f1ba7ad9940883ec4bb8d867d3105), [`283bea0`](https://github.com/mastra-ai/mastra/commit/283bea07adbaf04a27fa3ad2df611095e0825195)]:
|
|
27
|
+
- @mastra/core@0.19.1
|
|
28
|
+
|
|
29
|
+
## 0.19.1-alpha.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`4a70ccc`](https://github.com/mastra-ai/mastra/commit/4a70ccc5cfa12ae9c2b36545a5814cd98e5a0ead)]:
|
|
34
|
+
- @mastra/core@0.19.1-alpha.1
|
|
35
|
+
|
|
36
|
+
## 0.19.1-alpha.0
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Added Mastra model router to Playground UI ([#8332](https://github.com/mastra-ai/mastra/pull/8332))
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`0992b8b`](https://github.com/mastra-ai/mastra/commit/0992b8bf0f4f1ba7ad9940883ec4bb8d867d3105), [`283bea0`](https://github.com/mastra-ai/mastra/commit/283bea07adbaf04a27fa3ad2df611095e0825195)]:
|
|
43
|
+
- @mastra/core@0.19.1-alpha.0
|
|
44
|
+
|
|
45
|
+
## 0.19.0
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Support passing tracing options for start/resume workflows for server APIs and client sdk ([#8277](https://github.com/mastra-ai/mastra/pull/8277))
|
|
50
|
+
|
|
11
51
|
- add a way to hide the deploy mastra cloud button ([#8137](https://github.com/mastra-ai/mastra/pull/8137))
|
|
12
52
|
|
|
53
|
+
- Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
54
|
+
|
|
13
55
|
- Add types in the streamVNext codepath, fixes for various issues across multiple packages surfaced from type issues, align return types. ([#8010](https://github.com/mastra-ai/mastra/pull/8010))
|
|
14
56
|
|
|
57
|
+
- Support tracing options for workflow streaming endpoints ([#8278](https://github.com/mastra-ai/mastra/pull/8278))
|
|
58
|
+
|
|
59
|
+
- Adjust deprecation warnings ([#8326](https://github.com/mastra-ai/mastra/pull/8326))
|
|
60
|
+
|
|
15
61
|
- When step is created from agent or tool, add the description and component key to show that ([#8151](https://github.com/mastra-ai/mastra/pull/8151))
|
|
16
62
|
|
|
17
|
-
-
|
|
18
|
-
|
|
63
|
+
- Add server apis to get scores by span ([#8237](https://github.com/mastra-ai/mastra/pull/8237))
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`67b0f00`](https://github.com/mastra-ai/mastra/commit/67b0f005b520335c71fb85cbaa25df4ce8484a81), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
|
|
66
|
+
- @mastra/core@0.19.0
|
|
67
|
+
|
|
68
|
+
## 0.19.0-alpha.1
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Support passing tracing options for start/resume workflows for server APIs and client sdk ([#8277](https://github.com/mastra-ai/mastra/pull/8277))
|
|
73
|
+
|
|
74
|
+
- Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
75
|
+
|
|
76
|
+
- Support tracing options for workflow streaming endpoints ([#8278](https://github.com/mastra-ai/mastra/pull/8278))
|
|
77
|
+
|
|
78
|
+
- Add server apis to get scores by span ([#8237](https://github.com/mastra-ai/mastra/pull/8237))
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [[`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
|
|
81
|
+
- @mastra/core@0.19.0-alpha.1
|
|
19
82
|
|
|
20
83
|
## 0.18.1-alpha.0
|
|
21
84
|
|
|
@@ -16,6 +16,7 @@ chunkEMMSS5I5_cjs.__export(workflows_exports, {
|
|
|
16
16
|
getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
|
|
17
17
|
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
18
18
|
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
19
|
+
observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
|
|
19
20
|
observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
|
|
20
21
|
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
21
22
|
resumeStreamWorkflowHandler: () => resumeStreamWorkflowHandler,
|
|
@@ -164,7 +165,8 @@ async function startAsyncWorkflowHandler({
|
|
|
164
165
|
runtimeContext,
|
|
165
166
|
workflowId,
|
|
166
167
|
runId,
|
|
167
|
-
inputData
|
|
168
|
+
inputData,
|
|
169
|
+
tracingOptions
|
|
168
170
|
}) {
|
|
169
171
|
try {
|
|
170
172
|
if (!workflowId) {
|
|
@@ -177,7 +179,8 @@ async function startAsyncWorkflowHandler({
|
|
|
177
179
|
const _run = await workflow.createRunAsync({ runId });
|
|
178
180
|
const result = await _run.start({
|
|
179
181
|
inputData,
|
|
180
|
-
runtimeContext
|
|
182
|
+
runtimeContext,
|
|
183
|
+
tracingOptions
|
|
181
184
|
});
|
|
182
185
|
return result;
|
|
183
186
|
} catch (error) {
|
|
@@ -189,7 +192,8 @@ async function startWorkflowRunHandler({
|
|
|
189
192
|
runtimeContext,
|
|
190
193
|
workflowId,
|
|
191
194
|
runId,
|
|
192
|
-
inputData
|
|
195
|
+
inputData,
|
|
196
|
+
tracingOptions
|
|
193
197
|
}) {
|
|
194
198
|
try {
|
|
195
199
|
if (!workflowId) {
|
|
@@ -206,10 +210,11 @@ async function startWorkflowRunHandler({
|
|
|
206
210
|
if (!run) {
|
|
207
211
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
208
212
|
}
|
|
209
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
213
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
210
214
|
void _run.start({
|
|
211
215
|
inputData,
|
|
212
|
-
runtimeContext
|
|
216
|
+
runtimeContext,
|
|
217
|
+
tracingOptions
|
|
213
218
|
});
|
|
214
219
|
return { message: "Workflow run started" };
|
|
215
220
|
} catch (e) {
|
|
@@ -237,7 +242,7 @@ async function watchWorkflowHandler({
|
|
|
237
242
|
if (!run) {
|
|
238
243
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
239
244
|
}
|
|
240
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
245
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
241
246
|
let unwatch;
|
|
242
247
|
let asyncRef = null;
|
|
243
248
|
const stream = new web.ReadableStream({
|
|
@@ -276,7 +281,8 @@ async function streamWorkflowHandler({
|
|
|
276
281
|
runtimeContext,
|
|
277
282
|
workflowId,
|
|
278
283
|
runId,
|
|
279
|
-
inputData
|
|
284
|
+
inputData,
|
|
285
|
+
tracingOptions
|
|
280
286
|
}) {
|
|
281
287
|
try {
|
|
282
288
|
if (!workflowId) {
|
|
@@ -299,7 +305,8 @@ async function streamWorkflowHandler({
|
|
|
299
305
|
const cacheKey = runId;
|
|
300
306
|
await serverCache.listPush(cacheKey, chunk);
|
|
301
307
|
}
|
|
302
|
-
}
|
|
308
|
+
},
|
|
309
|
+
tracingOptions
|
|
303
310
|
});
|
|
304
311
|
return result;
|
|
305
312
|
} catch (error) {
|
|
@@ -326,7 +333,7 @@ async function observeStreamWorkflowHandler({
|
|
|
326
333
|
if (!run) {
|
|
327
334
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
328
335
|
}
|
|
329
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
336
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
330
337
|
const serverCache = mastra.getServerCache();
|
|
331
338
|
if (!serverCache) {
|
|
332
339
|
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
@@ -350,7 +357,8 @@ async function streamVNextWorkflowHandler({
|
|
|
350
357
|
workflowId,
|
|
351
358
|
runId,
|
|
352
359
|
inputData,
|
|
353
|
-
closeOnSuspend
|
|
360
|
+
closeOnSuspend,
|
|
361
|
+
tracingOptions
|
|
354
362
|
}) {
|
|
355
363
|
try {
|
|
356
364
|
if (!workflowId) {
|
|
@@ -363,23 +371,95 @@ async function streamVNextWorkflowHandler({
|
|
|
363
371
|
if (!workflow) {
|
|
364
372
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
365
373
|
}
|
|
374
|
+
const serverCache = mastra.getServerCache();
|
|
366
375
|
const run = await workflow.createRunAsync({ runId });
|
|
367
376
|
const result = run.streamVNext({
|
|
368
377
|
inputData,
|
|
369
378
|
runtimeContext,
|
|
370
|
-
closeOnSuspend
|
|
379
|
+
closeOnSuspend,
|
|
380
|
+
onChunk: async (chunk) => {
|
|
381
|
+
if (serverCache) {
|
|
382
|
+
const cacheKey = runId;
|
|
383
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
tracingOptions
|
|
371
387
|
});
|
|
372
388
|
return result;
|
|
373
389
|
} catch (error) {
|
|
374
390
|
return chunkRE4RPXT2_cjs.handleError(error, "Error streaming workflow");
|
|
375
391
|
}
|
|
376
392
|
}
|
|
393
|
+
async function observeStreamVNextWorkflowHandler({
|
|
394
|
+
mastra,
|
|
395
|
+
workflowId,
|
|
396
|
+
runId
|
|
397
|
+
}) {
|
|
398
|
+
try {
|
|
399
|
+
if (!workflowId) {
|
|
400
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
401
|
+
}
|
|
402
|
+
if (!runId) {
|
|
403
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
|
|
404
|
+
}
|
|
405
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
406
|
+
if (!workflow) {
|
|
407
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
408
|
+
}
|
|
409
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
410
|
+
if (!run) {
|
|
411
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
412
|
+
}
|
|
413
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
414
|
+
const serverCache = mastra.getServerCache();
|
|
415
|
+
if (!serverCache) {
|
|
416
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
417
|
+
}
|
|
418
|
+
const cachedRunChunks = await serverCache.listFromTo(runId, 0);
|
|
419
|
+
const combinedStream = new web.ReadableStream({
|
|
420
|
+
start(controller) {
|
|
421
|
+
const emitCachedChunks = async () => {
|
|
422
|
+
for (const chunk of cachedRunChunks) {
|
|
423
|
+
controller.enqueue(chunk);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const liveStream = _run.observeStreamVNext();
|
|
427
|
+
const reader = liveStream.getReader();
|
|
428
|
+
const pump = async () => {
|
|
429
|
+
try {
|
|
430
|
+
while (true) {
|
|
431
|
+
const { done, value } = await reader.read();
|
|
432
|
+
if (done) {
|
|
433
|
+
controller.close();
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
controller.enqueue(value);
|
|
437
|
+
}
|
|
438
|
+
} catch (error) {
|
|
439
|
+
controller.error(error);
|
|
440
|
+
} finally {
|
|
441
|
+
reader.releaseLock();
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
void emitCachedChunks().then(() => {
|
|
445
|
+
void pump();
|
|
446
|
+
}).catch((error) => {
|
|
447
|
+
controller.error(error);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
return combinedStream;
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error observing workflow stream");
|
|
454
|
+
}
|
|
455
|
+
}
|
|
377
456
|
async function resumeAsyncWorkflowHandler({
|
|
378
457
|
mastra,
|
|
379
458
|
workflowId,
|
|
380
459
|
runId,
|
|
381
460
|
body,
|
|
382
|
-
runtimeContext
|
|
461
|
+
runtimeContext,
|
|
462
|
+
tracingOptions
|
|
383
463
|
}) {
|
|
384
464
|
try {
|
|
385
465
|
if (!workflowId) {
|
|
@@ -399,11 +479,12 @@ async function resumeAsyncWorkflowHandler({
|
|
|
399
479
|
if (!run) {
|
|
400
480
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
401
481
|
}
|
|
402
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
482
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
403
483
|
const result = await _run.resume({
|
|
404
484
|
step: body.step,
|
|
405
485
|
resumeData: body.resumeData,
|
|
406
|
-
runtimeContext
|
|
486
|
+
runtimeContext,
|
|
487
|
+
tracingOptions
|
|
407
488
|
});
|
|
408
489
|
return result;
|
|
409
490
|
} catch (error) {
|
|
@@ -415,7 +496,8 @@ async function resumeWorkflowHandler({
|
|
|
415
496
|
workflowId,
|
|
416
497
|
runId,
|
|
417
498
|
body,
|
|
418
|
-
runtimeContext
|
|
499
|
+
runtimeContext,
|
|
500
|
+
tracingOptions
|
|
419
501
|
}) {
|
|
420
502
|
try {
|
|
421
503
|
if (!workflowId) {
|
|
@@ -435,11 +517,12 @@ async function resumeWorkflowHandler({
|
|
|
435
517
|
if (!run) {
|
|
436
518
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
437
519
|
}
|
|
438
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
520
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
439
521
|
void _run.resume({
|
|
440
522
|
step: body.step,
|
|
441
523
|
resumeData: body.resumeData,
|
|
442
|
-
runtimeContext
|
|
524
|
+
runtimeContext,
|
|
525
|
+
tracingOptions
|
|
443
526
|
});
|
|
444
527
|
return { message: "Workflow run resumed" };
|
|
445
528
|
} catch (error) {
|
|
@@ -451,7 +534,8 @@ async function resumeStreamWorkflowHandler({
|
|
|
451
534
|
workflowId,
|
|
452
535
|
runId,
|
|
453
536
|
body,
|
|
454
|
-
runtimeContext
|
|
537
|
+
runtimeContext,
|
|
538
|
+
tracingOptions
|
|
455
539
|
}) {
|
|
456
540
|
try {
|
|
457
541
|
if (!workflowId) {
|
|
@@ -471,11 +555,19 @@ async function resumeStreamWorkflowHandler({
|
|
|
471
555
|
if (!run) {
|
|
472
556
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
473
557
|
}
|
|
474
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
475
|
-
const
|
|
558
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
559
|
+
const serverCache = mastra.getServerCache();
|
|
560
|
+
const stream = _run.resumeStreamVNext({
|
|
476
561
|
step: body.step,
|
|
477
562
|
resumeData: body.resumeData,
|
|
478
|
-
runtimeContext
|
|
563
|
+
runtimeContext,
|
|
564
|
+
tracingOptions,
|
|
565
|
+
onChunk: async (chunk) => {
|
|
566
|
+
if (serverCache) {
|
|
567
|
+
const cacheKey = runId;
|
|
568
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
479
571
|
});
|
|
480
572
|
return stream;
|
|
481
573
|
} catch (error) {
|
|
@@ -528,7 +620,7 @@ async function cancelWorkflowRunHandler({
|
|
|
528
620
|
if (!run) {
|
|
529
621
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
530
622
|
}
|
|
531
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
623
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
532
624
|
await _run.cancel();
|
|
533
625
|
return { message: "Workflow run cancelled" };
|
|
534
626
|
} catch (error) {
|
|
@@ -557,7 +649,7 @@ async function sendWorkflowRunEventHandler({
|
|
|
557
649
|
if (!run) {
|
|
558
650
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
559
651
|
}
|
|
560
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
652
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
561
653
|
await _run.sendEvent(event, data);
|
|
562
654
|
return { message: "Workflow run event sent" };
|
|
563
655
|
} catch (error) {
|
|
@@ -572,6 +664,7 @@ exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
|
572
664
|
exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
|
|
573
665
|
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
574
666
|
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
667
|
+
exports.observeStreamVNextWorkflowHandler = observeStreamVNextWorkflowHandler;
|
|
575
668
|
exports.observeStreamWorkflowHandler = observeStreamWorkflowHandler;
|
|
576
669
|
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
577
670
|
exports.resumeStreamWorkflowHandler = resumeStreamWorkflowHandler;
|
|
@@ -583,5 +676,5 @@ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
|
|
|
583
676
|
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
584
677
|
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
585
678
|
exports.workflows_exports = workflows_exports;
|
|
586
|
-
//# sourceMappingURL=chunk-
|
|
587
|
-
//# sourceMappingURL=chunk-
|
|
679
|
+
//# sourceMappingURL=chunk-4HS3I2TI.cjs.map
|
|
680
|
+
//# sourceMappingURL=chunk-4HS3I2TI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","getWorkflowInfo","handleError","HTTPException","WorkflowRegistry","ReadableStream","TransformStream"],"mappings":";;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BA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AA,EAAY,GAAA,CAAI,UAAA,EAAY,CAAA;AAEhF,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,IAAI,CAAA;AAEhC,IAAA,OAAO,EAAE,SAAS,yBAAA,EAA0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-4HS3I2TI.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { TracingOptions } from '@mastra/core/ai-tracing';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type { Workflow, WatchEvent, WorkflowInfo, StreamEvent, ChunkType } from '@mastra/core/workflows';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n}\n\nasync function getWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.getAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.getWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowInfo> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\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 } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(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 getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\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.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\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 } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n runtimeContext,\n tracingOptions,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n void _run.start({\n inputData,\n runtimeContext,\n tracingOptions,\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 watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n eventType = 'watch',\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n eventType?: 'watch' | 'watch-v2';\n}): 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 } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch((event: any) => {\n const { type, payload, eventTimestamp } = event;\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = eventType === 'watch' ? payload.workflowState.status !== 'running' : type === 'finish';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n }, eventType);\n },\n cancel() {\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n tracingOptions,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function observeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\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 observe workflow stream' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n const transformStream = new TransformStream<StreamEvent, StreamEvent>();\n\n const writer = transformStream.writable.getWriter();\n\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n for (const chunk of cachedRunChunks) {\n await writer.write(chunk as any);\n }\n\n writer.releaseLock();\n\n const result = _run.observeStream();\n return result.stream?.pipeThrough(transformStream);\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n closeOnSuspend,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n closeOnSuspend?: boolean;\n tracingOptions?: TracingOptions;\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 stream workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n closeOnSuspend,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n tracingOptions,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function observeStreamVNextWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\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 observe workflow stream' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks first\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n // Create a readable stream that first emits cached chunks, then the live stream\n const combinedStream = new ReadableStream<ChunkType>({\n start(controller) {\n // First, emit all cached chunks\n const emitCachedChunks = async () => {\n for (const chunk of cachedRunChunks) {\n controller.enqueue(chunk as ChunkType);\n }\n };\n\n // Then, pipe the live stream\n const liveStream = _run.observeStreamVNext();\n const reader = liveStream.getReader();\n\n const pump = async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n break;\n }\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n } finally {\n reader.releaseLock();\n }\n };\n\n // Start with cached chunks, then live stream\n void emitCachedChunks()\n .then(() => {\n void pump();\n })\n .catch(error => {\n controller.error(error);\n });\n },\n });\n\n return combinedStream;\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function resumeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const stream = _run.resumeStreamVNext({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getWorkflowRunsHandler({\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<WorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\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\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\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 cancel workflow run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n}\n\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\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 send workflow run event' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n"]}
|
|
@@ -10,6 +10,7 @@ var observability_exports = {};
|
|
|
10
10
|
chunkEMMSS5I5_cjs.__export(observability_exports, {
|
|
11
11
|
getAITraceHandler: () => getAITraceHandler,
|
|
12
12
|
getAITracesPaginatedHandler: () => getAITracesPaginatedHandler,
|
|
13
|
+
getScoresBySpan: () => getScoresBySpan,
|
|
13
14
|
scoreTracesHandler: () => scoreTracesHandler
|
|
14
15
|
});
|
|
15
16
|
async function getAITraceHandler({ mastra, traceId }) {
|
|
@@ -100,10 +101,30 @@ async function scoreTracesHandler({ mastra, body }) {
|
|
|
100
101
|
chunkRE4RPXT2_cjs.handleError(error, "Error processing trace scoring");
|
|
101
102
|
}
|
|
102
103
|
}
|
|
104
|
+
async function getScoresBySpan({
|
|
105
|
+
mastra,
|
|
106
|
+
traceId,
|
|
107
|
+
spanId,
|
|
108
|
+
pagination
|
|
109
|
+
}) {
|
|
110
|
+
try {
|
|
111
|
+
const storage = mastra.getStorage();
|
|
112
|
+
if (!storage) {
|
|
113
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
|
|
114
|
+
}
|
|
115
|
+
if (!traceId || !spanId) {
|
|
116
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Trace ID and span ID are required" });
|
|
117
|
+
}
|
|
118
|
+
return await storage.getScoresBySpan({ traceId, spanId, pagination });
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting scores by span");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
103
123
|
|
|
104
124
|
exports.getAITraceHandler = getAITraceHandler;
|
|
105
125
|
exports.getAITracesPaginatedHandler = getAITracesPaginatedHandler;
|
|
126
|
+
exports.getScoresBySpan = getScoresBySpan;
|
|
106
127
|
exports.observability_exports = observability_exports;
|
|
107
128
|
exports.scoreTracesHandler = scoreTracesHandler;
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-52UP7DFT.cjs.map
|
|
130
|
+
//# sourceMappingURL=chunk-52UP7DFT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/observability.ts"],"names":["__export","HTTPException","handleError","scoreTraces"],"mappings":";;;;;;;;AAAA,IAAA,qBAAA,GAAA;AAAAA,0BAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,eAAA,EAAA,MAAA,eAAA;AAAA,EAAA,kBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAyBA,eAAsB,iBAAA,CAAkB,EAAE,MAAA,EAAQ,OAAA,EAAQ,EAA+C;AACvG,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIC,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,IAAA,IAAI,CAAC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AA,EAAS,4BAA4B,CAAA;AAAA,IACtE;AAEA,IAAA,IAAI,CAAC,OAAA,IAAW,CAAC,MAAA,EAAQ;AACvB,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,qCAAqC,CAAA;AAAA,IAC/E;AAEA,IAAA,OAAO,MAAM,OAAA,CAAQ,eAAA,CAAgB,EAAE,OAAA,EAAS,MAAA,EAAQ,YAAY,CAAA;AAAA,EACtE,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,6BAAA,CAAY,OAAO,8BAA8B,CAAA;AAAA,EAC1D;AACF","file":"chunk-52UP7DFT.cjs","sourcesContent":["import type { AITracesPaginatedArg, StoragePagination } from '@mastra/core';\nimport { scoreTraces } from '@mastra/core/scores/scoreTraces';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface ObservabilityContext extends Context {\n traceId?: string;\n body?: AITracesPaginatedArg;\n}\n\ninterface ScoreTracesContext extends Context {\n body?: {\n scorerName: string;\n targets: Array<{\n traceId: string;\n spanId?: string;\n }>;\n };\n}\n\n/**\n * Get a complete AI trace by trace ID\n * Returns all spans in the trace with their parent-child relationships\n */\nexport async function getAITraceHandler({ mastra, traceId }: ObservabilityContext & { traceId: string }) {\n try {\n if (!traceId) {\n throw new HTTPException(400, { message: 'Trace ID is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const trace = await storage.getAITrace(traceId);\n\n if (!trace) {\n throw new HTTPException(404, { message: `Trace with ID '${traceId}' not found` });\n }\n\n return trace;\n } catch (error) {\n handleError(error, 'Error getting AI trace');\n }\n}\n\n/**\n * Get paginated AI traces with filtering and pagination\n * Returns only root spans (parent spans) for pagination, not child spans\n */\nexport async function getAITracesPaginatedHandler({ mastra, body }: ObservabilityContext) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { filters, pagination } = body;\n\n if (pagination?.page && pagination.page < 0) {\n throw new HTTPException(400, { message: 'Page must be a non-negative integer' });\n }\n\n if (pagination?.perPage && pagination.perPage < 0) {\n throw new HTTPException(400, { message: 'Per page must be a non-negative integer' });\n }\n\n if (pagination?.dateRange) {\n const { start, end } = pagination.dateRange;\n\n if (start && !(start instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n\n if (end && !(end instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n }\n\n return storage.getAITracesPaginated({\n pagination,\n filters,\n });\n } catch (error) {\n handleError(error, 'Error getting AI traces paginated');\n }\n}\n\n/**\n * Score traces using a specified scorer\n * Fire-and-forget approach - returns immediately while scoring runs in background\n */\nexport async function scoreTracesHandler({ mastra, body }: ScoreTracesContext) {\n try {\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { scorerName, targets } = body;\n\n if (!scorerName) {\n throw new HTTPException(400, { message: 'Scorer Name is required' });\n }\n\n if (!targets || targets.length === 0) {\n throw new HTTPException(400, { message: 'At least one target is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const scorer = mastra.getScorerByName(scorerName);\n if (!scorer) {\n throw new HTTPException(404, { message: `Scorer '${scorerName}' not found` });\n }\n\n const logger = mastra.getLogger();\n scoreTraces({\n scorerName,\n targets,\n mastra,\n }).catch(error => {\n logger?.error(`Background trace scoring failed: ${error.message}`, error);\n });\n\n // Return immediate response\n return {\n status: 'success',\n message: `Scoring started for ${targets.length} ${targets.length === 1 ? 'trace' : 'traces'}`,\n traceCount: targets.length,\n };\n } catch (error) {\n handleError(error, 'Error processing trace scoring');\n }\n}\n\nexport async function getScoresBySpan({\n mastra,\n traceId,\n spanId,\n pagination,\n}: Context & { traceId: string; spanId: string; pagination: StoragePagination }) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!traceId || !spanId) {\n throw new HTTPException(400, { message: 'Trace ID and span ID are required' });\n }\n\n return await storage.getScoresBySpan({ traceId, spanId, pagination });\n } catch (error) {\n return handleError(error, 'Error getting scores by span');\n }\n}\n"]}
|