@mastra/server 0.0.0-fix-bundle-cleanup-20250911062914 → 0.0.0-fix-cloud-peer-deps-20250929-20250929175756
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 +241 -4
- package/README.md +0 -5
- package/dist/{chunk-L265APUD.cjs → chunk-52UP7DFT.cjs} +64 -3
- package/dist/chunk-52UP7DFT.cjs.map +1 -0
- package/dist/{chunk-5QUKZCEF.js → chunk-6IJWRJZE.js} +4 -3
- package/dist/chunk-6IJWRJZE.js.map +1 -0
- package/dist/{chunk-GUI3CROV.cjs → chunk-BKCWZLEL.cjs} +60 -22
- package/dist/chunk-BKCWZLEL.cjs.map +1 -0
- package/dist/{chunk-DMSCGAWM.js → chunk-BOVFMBXY.js} +92 -9
- package/dist/chunk-BOVFMBXY.js.map +1 -0
- package/dist/{chunk-6LUKYSWE.cjs → chunk-CML3EOO5.cjs} +96 -119
- package/dist/chunk-CML3EOO5.cjs.map +1 -0
- package/dist/{chunk-A75S4TDD.js → chunk-JRDEOHAJ.js} +19 -11
- package/dist/chunk-JRDEOHAJ.js.map +1 -0
- package/dist/{chunk-SYRRSBGL.js → chunk-KM7EJKXV.js} +8 -4
- package/dist/chunk-KM7EJKXV.js.map +1 -0
- package/dist/{chunk-J7BPKKOG.cjs → chunk-LJFAAEU7.cjs} +8 -4
- package/dist/chunk-LJFAAEU7.cjs.map +1 -0
- package/dist/{chunk-OTU37YZO.js → chunk-N5ID53SA.js} +172 -131
- package/dist/chunk-N5ID53SA.js.map +1 -0
- package/dist/{chunk-B2V3PUB7.js → chunk-NH7XUTIO.js} +93 -116
- package/dist/chunk-NH7XUTIO.js.map +1 -0
- package/dist/{chunk-WZC6CIVD.cjs → chunk-NLWACBE7.cjs} +19 -11
- package/dist/chunk-NLWACBE7.cjs.map +1 -0
- package/dist/{chunk-3THIIWWW.cjs → chunk-OPI3FZYH.cjs} +4 -3
- package/dist/chunk-OPI3FZYH.cjs.map +1 -0
- package/dist/{chunk-2JEDATG5.cjs → chunk-QNWXF57L.cjs} +191 -150
- package/dist/chunk-QNWXF57L.cjs.map +1 -0
- package/dist/{chunk-3TETONBL.cjs → chunk-SXENNNR7.cjs} +93 -8
- package/dist/chunk-SXENNNR7.cjs.map +1 -0
- package/dist/chunk-VY4ENABS.cjs +135 -0
- package/dist/chunk-VY4ENABS.cjs.map +1 -0
- package/dist/{chunk-R7NOGUZG.js → chunk-WUJLVNLU.js} +63 -4
- package/dist/chunk-WUJLVNLU.js.map +1 -0
- package/dist/{chunk-7QEJ5QG5.js → chunk-XJOYGRTN.js} +60 -22
- package/dist/chunk-XJOYGRTN.js.map +1 -0
- package/dist/chunk-YWOK4F5A.js +131 -0
- package/dist/chunk-YWOK4F5A.js.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts +5 -4
- 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 +23 -15
- package/dist/server/handlers/agents.d.ts +51 -5
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/observability.cjs +11 -3
- package/dist/server/handlers/observability.d.ts +27 -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 +208 -6
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vNextNetwork.d.ts +73 -6
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.d.ts +6 -4
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +24 -16
- package/dist/server/handlers/workflows.d.ts +16 -7
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +16 -21
- package/dist/server/handlers.d.ts +0 -1
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +8 -9
- package/dist/server/utils.d.ts +2 -0
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-2JEDATG5.cjs.map +0 -1
- package/dist/chunk-3TETONBL.cjs.map +0 -1
- package/dist/chunk-3THIIWWW.cjs.map +0 -1
- package/dist/chunk-5QUKZCEF.js.map +0 -1
- package/dist/chunk-6LUKYSWE.cjs.map +0 -1
- package/dist/chunk-7QEJ5QG5.js.map +0 -1
- package/dist/chunk-A75S4TDD.js.map +0 -1
- package/dist/chunk-B2V3PUB7.js.map +0 -1
- package/dist/chunk-DMSCGAWM.js.map +0 -1
- package/dist/chunk-GUI3CROV.cjs.map +0 -1
- package/dist/chunk-IY34NOLA.cjs +0 -150
- package/dist/chunk-IY34NOLA.cjs.map +0 -1
- package/dist/chunk-J7BPKKOG.cjs.map +0 -1
- package/dist/chunk-L265APUD.cjs.map +0 -1
- package/dist/chunk-OTU37YZO.js.map +0 -1
- package/dist/chunk-R7NOGUZG.js.map +0 -1
- package/dist/chunk-SYRRSBGL.js.map +0 -1
- package/dist/chunk-U46VIX2V.js +0 -144
- package/dist/chunk-U46VIX2V.js.map +0 -1
- package/dist/chunk-WZC6CIVD.cjs.map +0 -1
- package/dist/server/handlers/network.cjs +0 -24
- package/dist/server/handlers/network.cjs.map +0 -1
- package/dist/server/handlers/network.d.ts +0 -50
- package/dist/server/handlers/network.d.ts.map +0 -1
- package/dist/server/handlers/network.js +0 -3
- package/dist/server/handlers/network.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,252 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-cloud-peer-deps-20250929-20250929175756
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- add a way to hide the deploy mastra cloud button ([#8137](https://github.com/mastra-ai/mastra/pull/8137))
|
|
8
|
+
|
|
9
|
+
- Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
10
|
+
|
|
11
|
+
- 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))
|
|
12
|
+
|
|
13
|
+
- 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))
|
|
14
|
+
|
|
15
|
+
- Add server apis to get scores by span ([#8237](https://github.com/mastra-ai/mastra/pull/8237))
|
|
16
|
+
|
|
17
|
+
- 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), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`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), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5)]:
|
|
18
|
+
- @mastra/core@0.0.0-fix-cloud-peer-deps-20250929-20250929175756
|
|
19
|
+
|
|
20
|
+
## 0.18.1-alpha.0
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- add a way to hide the deploy mastra cloud button ([#8137](https://github.com/mastra-ai/mastra/pull/8137))
|
|
25
|
+
|
|
26
|
+
- 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))
|
|
27
|
+
|
|
28
|
+
- 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))
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`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), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5)]:
|
|
31
|
+
- @mastra/core@0.18.1-alpha.0
|
|
32
|
+
|
|
33
|
+
## 0.18.0
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Allow agent instructions to accept SystemMessage types ([#7987](https://github.com/mastra-ai/mastra/pull/7987))
|
|
38
|
+
|
|
39
|
+
Agents can now use rich instruction formats beyond simple strings:
|
|
40
|
+
- CoreSystemMessage and SystemModelMessage objects with provider-specific options
|
|
41
|
+
- Arrays of strings or system messages
|
|
42
|
+
- Dynamic instructions returning any SystemMessage type
|
|
43
|
+
|
|
44
|
+
- Add model fallback handlers and apis ([#7378](https://github.com/mastra-ai/mastra/pull/7378))
|
|
45
|
+
|
|
46
|
+
- Delayed streamVNext breaking change notice by 1 week ([#8121](https://github.com/mastra-ai/mastra/pull/8121))
|
|
47
|
+
|
|
48
|
+
- Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
|
|
49
|
+
|
|
50
|
+
- Add server api to score traces ([#8064](https://github.com/mastra-ai/mastra/pull/8064))
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`4b339b8`](https://github.com/mastra-ai/mastra/commit/4b339b8141c20d6a6d80583c7e8c5c05d8c19492), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad), [`c591dfc`](https://github.com/mastra-ai/mastra/commit/c591dfc1e600fae1dedffe239357d250e146378f), [`1920c5c`](https://github.com/mastra-ai/mastra/commit/1920c5c6d666f687785c73021196aa551e579e0d), [`b6a3b65`](https://github.com/mastra-ai/mastra/commit/b6a3b65d830fa0ca7754ad6481661d1f2c878f21), [`af3abb6`](https://github.com/mastra-ai/mastra/commit/af3abb6f7c7585d856e22d27f4e7d2ece2186b9a)]:
|
|
53
|
+
- @mastra/core@0.18.0
|
|
54
|
+
|
|
55
|
+
## 0.18.0-alpha.3
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Add model fallback handlers and apis ([#7378](https://github.com/mastra-ai/mastra/pull/7378))
|
|
60
|
+
|
|
61
|
+
- Delayed streamVNext breaking change notice by 1 week ([#8121](https://github.com/mastra-ai/mastra/pull/8121))
|
|
62
|
+
|
|
63
|
+
- Add server api to score traces ([#8064](https://github.com/mastra-ai/mastra/pull/8064))
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [[`4b339b8`](https://github.com/mastra-ai/mastra/commit/4b339b8141c20d6a6d80583c7e8c5c05d8c19492), [`c591dfc`](https://github.com/mastra-ai/mastra/commit/c591dfc1e600fae1dedffe239357d250e146378f), [`1920c5c`](https://github.com/mastra-ai/mastra/commit/1920c5c6d666f687785c73021196aa551e579e0d), [`b6a3b65`](https://github.com/mastra-ai/mastra/commit/b6a3b65d830fa0ca7754ad6481661d1f2c878f21), [`af3abb6`](https://github.com/mastra-ai/mastra/commit/af3abb6f7c7585d856e22d27f4e7d2ece2186b9a)]:
|
|
66
|
+
- @mastra/core@0.18.0-alpha.3
|
|
67
|
+
|
|
68
|
+
## 0.18.0-alpha.2
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Allow agent instructions to accept SystemMessage types ([#7987](https://github.com/mastra-ai/mastra/pull/7987))
|
|
73
|
+
|
|
74
|
+
Agents can now use rich instruction formats beyond simple strings:
|
|
75
|
+
- CoreSystemMessage and SystemModelMessage objects with provider-specific options
|
|
76
|
+
- Arrays of strings or system messages
|
|
77
|
+
- Dynamic instructions returning any SystemMessage type
|
|
78
|
+
|
|
79
|
+
- Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55)]:
|
|
82
|
+
- @mastra/core@0.18.0-alpha.2
|
|
83
|
+
|
|
84
|
+
## 0.17.2-alpha.1
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [[`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb)]:
|
|
89
|
+
- @mastra/core@0.17.2-alpha.1
|
|
90
|
+
|
|
91
|
+
## 0.17.2-alpha.0
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [[`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad)]:
|
|
96
|
+
- @mastra/core@0.17.2-alpha.0
|
|
97
|
+
|
|
98
|
+
## 0.17.1
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- fix workflow resuming issue in the playground ([#7988](https://github.com/mastra-ai/mastra/pull/7988))
|
|
103
|
+
|
|
104
|
+
- Updated dependencies [[`fd00e63`](https://github.com/mastra-ai/mastra/commit/fd00e63759cbcca3473c40cac9843280b0557cff), [`ab610f6`](https://github.com/mastra-ai/mastra/commit/ab610f6f41dbfe6c9502368671485ca7a0aac09b), [`e6bda5f`](https://github.com/mastra-ai/mastra/commit/e6bda5f954ee8493ea18adc1a883f0a5b785ad9b)]:
|
|
105
|
+
- @mastra/core@0.17.1
|
|
106
|
+
|
|
107
|
+
## 0.17.1-alpha.0
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- fix workflow resuming issue in the playground ([#7988](https://github.com/mastra-ai/mastra/pull/7988))
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [[`fd00e63`](https://github.com/mastra-ai/mastra/commit/fd00e63759cbcca3473c40cac9843280b0557cff), [`ab610f6`](https://github.com/mastra-ai/mastra/commit/ab610f6f41dbfe6c9502368671485ca7a0aac09b), [`e6bda5f`](https://github.com/mastra-ai/mastra/commit/e6bda5f954ee8493ea18adc1a883f0a5b785ad9b)]:
|
|
114
|
+
- @mastra/core@0.17.1-alpha.0
|
|
115
|
+
|
|
116
|
+
## 0.17.0
|
|
117
|
+
|
|
118
|
+
### Minor Changes
|
|
119
|
+
|
|
120
|
+
- Remove original AgentNetwork ([#7919](https://github.com/mastra-ai/mastra/pull/7919))
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Add helpful error message when trying to import from top-level import ([#7762](https://github.com/mastra-ai/mastra/pull/7762))
|
|
125
|
+
|
|
126
|
+
- Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
|
|
127
|
+
|
|
128
|
+
- Resumable streams ([#7949](https://github.com/mastra-ai/mastra/pull/7949))
|
|
129
|
+
|
|
130
|
+
- Voice errors that are instance of a MastraError should not throw a 500 ([#7749](https://github.com/mastra-ai/mastra/pull/7749))
|
|
131
|
+
|
|
132
|
+
- Update package.json and README ([#7886](https://github.com/mastra-ai/mastra/pull/7886))
|
|
133
|
+
|
|
134
|
+
- Updated dependencies [[`197cbb2`](https://github.com/mastra-ai/mastra/commit/197cbb248fc8cb4bbf61bf70b770f1388b445df2), [`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`6590763`](https://github.com/mastra-ai/mastra/commit/65907630ef4bf4127067cecd1cb21b56f55d5f1b), [`fb84c21`](https://github.com/mastra-ai/mastra/commit/fb84c21859d09bdc8f158bd5412bdc4b5835a61c), [`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`c2eade3`](https://github.com/mastra-ai/mastra/commit/c2eade3508ef309662f065e5f340d7840295dd53), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`222965a`](https://github.com/mastra-ai/mastra/commit/222965a98ce8197b86673ec594244650b5960257), [`6047778`](https://github.com/mastra-ai/mastra/commit/6047778e501df460648f31decddf8e443f36e373), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`9d4fc09`](https://github.com/mastra-ai/mastra/commit/9d4fc09b2ad55caa7738c7ceb3a905e454f74cdd), [`05c7abf`](https://github.com/mastra-ai/mastra/commit/05c7abfe105a015b7760c9bf33ff4419727502a0), [`0324ceb`](https://github.com/mastra-ai/mastra/commit/0324ceb8af9d16c12a531f90e575f6aab797ac81), [`d75ccf0`](https://github.com/mastra-ai/mastra/commit/d75ccf06dfd2582b916aa12624e3cd61b279edf1), [`0f9d227`](https://github.com/mastra-ai/mastra/commit/0f9d227890a98db33865abbea39daf407cd55ef7), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`de056a0`](https://github.com/mastra-ai/mastra/commit/de056a02cbb43f6aa0380ab2150ea404af9ec0dd), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`60c9cec`](https://github.com/mastra-ai/mastra/commit/60c9cec7048a79a87440f7840c383875bd710d93), [`c93532a`](https://github.com/mastra-ai/mastra/commit/c93532a340b80e4dd946d4c138d9381de5f70399), [`6cb1fcb`](https://github.com/mastra-ai/mastra/commit/6cb1fcbc8d0378ffed0d17784c96e68f30cb0272), [`aee4f00`](https://github.com/mastra-ai/mastra/commit/aee4f00e61e1a42e81a6d74ff149dbe69e32695a), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4), [`897995e`](https://github.com/mastra-ai/mastra/commit/897995e630d572fe2891e7ede817938cabb43251), [`0fed8f2`](https://github.com/mastra-ai/mastra/commit/0fed8f2aa84b167b3415ea6f8f70755775132c8d), [`4f9ea8c`](https://github.com/mastra-ai/mastra/commit/4f9ea8c95ea74ba9abbf3b2ab6106c7d7bc45689), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`87fd07f`](https://github.com/mastra-ai/mastra/commit/87fd07ff35387a38728967163460231b5d33ae3b), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`2685a78`](https://github.com/mastra-ai/mastra/commit/2685a78f224b8b04e20d4fab5ac1adb638190071), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11), [`239b5a4`](https://github.com/mastra-ai/mastra/commit/239b5a497aeae2e8b4d764f46217cfff2284788e), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
|
|
135
|
+
- @mastra/core@0.17.0
|
|
136
|
+
|
|
137
|
+
## 0.17.0-alpha.8
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [[`05c7abf`](https://github.com/mastra-ai/mastra/commit/05c7abfe105a015b7760c9bf33ff4419727502a0), [`aee4f00`](https://github.com/mastra-ai/mastra/commit/aee4f00e61e1a42e81a6d74ff149dbe69e32695a)]:
|
|
142
|
+
- @mastra/core@0.17.0-alpha.8
|
|
143
|
+
|
|
144
|
+
## 0.17.0-alpha.7
|
|
145
|
+
|
|
146
|
+
### Patch Changes
|
|
147
|
+
|
|
148
|
+
- Updated dependencies [[`4f9ea8c`](https://github.com/mastra-ai/mastra/commit/4f9ea8c95ea74ba9abbf3b2ab6106c7d7bc45689)]:
|
|
149
|
+
- @mastra/core@0.17.0-alpha.7
|
|
150
|
+
|
|
151
|
+
## 0.17.0-alpha.6
|
|
152
|
+
|
|
153
|
+
### Minor Changes
|
|
154
|
+
|
|
155
|
+
- Remove original AgentNetwork ([#7919](https://github.com/mastra-ai/mastra/pull/7919))
|
|
156
|
+
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- Resumable streams ([#7949](https://github.com/mastra-ai/mastra/pull/7949))
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [[`197cbb2`](https://github.com/mastra-ai/mastra/commit/197cbb248fc8cb4bbf61bf70b770f1388b445df2), [`6590763`](https://github.com/mastra-ai/mastra/commit/65907630ef4bf4127067cecd1cb21b56f55d5f1b), [`c2eade3`](https://github.com/mastra-ai/mastra/commit/c2eade3508ef309662f065e5f340d7840295dd53), [`222965a`](https://github.com/mastra-ai/mastra/commit/222965a98ce8197b86673ec594244650b5960257), [`0324ceb`](https://github.com/mastra-ai/mastra/commit/0324ceb8af9d16c12a531f90e575f6aab797ac81), [`0f9d227`](https://github.com/mastra-ai/mastra/commit/0f9d227890a98db33865abbea39daf407cd55ef7), [`de056a0`](https://github.com/mastra-ai/mastra/commit/de056a02cbb43f6aa0380ab2150ea404af9ec0dd), [`c93532a`](https://github.com/mastra-ai/mastra/commit/c93532a340b80e4dd946d4c138d9381de5f70399), [`6cb1fcb`](https://github.com/mastra-ai/mastra/commit/6cb1fcbc8d0378ffed0d17784c96e68f30cb0272), [`2685a78`](https://github.com/mastra-ai/mastra/commit/2685a78f224b8b04e20d4fab5ac1adb638190071), [`239b5a4`](https://github.com/mastra-ai/mastra/commit/239b5a497aeae2e8b4d764f46217cfff2284788e)]:
|
|
162
|
+
- @mastra/core@0.17.0-alpha.6
|
|
163
|
+
|
|
164
|
+
## 0.17.0-alpha.5
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [[`6047778`](https://github.com/mastra-ai/mastra/commit/6047778e501df460648f31decddf8e443f36e373)]:
|
|
169
|
+
- @mastra/core@0.17.0-alpha.5
|
|
170
|
+
|
|
171
|
+
## 0.17.0-alpha.4
|
|
172
|
+
|
|
173
|
+
### Patch Changes
|
|
174
|
+
|
|
175
|
+
- Update package.json and README ([#7886](https://github.com/mastra-ai/mastra/pull/7886))
|
|
176
|
+
|
|
177
|
+
- Updated dependencies [[`fb84c21`](https://github.com/mastra-ai/mastra/commit/fb84c21859d09bdc8f158bd5412bdc4b5835a61c), [`9d4fc09`](https://github.com/mastra-ai/mastra/commit/9d4fc09b2ad55caa7738c7ceb3a905e454f74cdd), [`d75ccf0`](https://github.com/mastra-ai/mastra/commit/d75ccf06dfd2582b916aa12624e3cd61b279edf1), [`0fed8f2`](https://github.com/mastra-ai/mastra/commit/0fed8f2aa84b167b3415ea6f8f70755775132c8d), [`87fd07f`](https://github.com/mastra-ai/mastra/commit/87fd07ff35387a38728967163460231b5d33ae3b)]:
|
|
178
|
+
- @mastra/core@0.17.0-alpha.4
|
|
179
|
+
|
|
180
|
+
## 0.17.0-alpha.3
|
|
181
|
+
|
|
182
|
+
### Patch Changes
|
|
183
|
+
|
|
184
|
+
- Add helpful error message when trying to import from top-level import ([#7762](https://github.com/mastra-ai/mastra/pull/7762))
|
|
185
|
+
|
|
186
|
+
- Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
|
|
187
|
+
|
|
188
|
+
- Updated dependencies [[`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
|
|
189
|
+
- @mastra/core@0.17.0-alpha.3
|
|
190
|
+
|
|
191
|
+
## 0.16.4-alpha.2
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- Updated dependencies [[`60c9cec`](https://github.com/mastra-ai/mastra/commit/60c9cec7048a79a87440f7840c383875bd710d93), [`897995e`](https://github.com/mastra-ai/mastra/commit/897995e630d572fe2891e7ede817938cabb43251)]:
|
|
196
|
+
- @mastra/core@0.16.4-alpha.2
|
|
197
|
+
|
|
198
|
+
## 0.16.4-alpha.1
|
|
199
|
+
|
|
200
|
+
### Patch Changes
|
|
201
|
+
|
|
202
|
+
- Updated dependencies [[`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4)]:
|
|
203
|
+
- @mastra/core@0.16.4-alpha.1
|
|
204
|
+
|
|
205
|
+
## 0.16.4-alpha.0
|
|
206
|
+
|
|
207
|
+
### Patch Changes
|
|
208
|
+
|
|
209
|
+
- Voice errors that are instance of a MastraError should not throw a 500 ([#7749](https://github.com/mastra-ai/mastra/pull/7749))
|
|
210
|
+
|
|
211
|
+
- Updated dependencies [[`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11)]:
|
|
212
|
+
- @mastra/core@0.16.4-alpha.0
|
|
213
|
+
|
|
214
|
+
## 0.16.3
|
|
215
|
+
|
|
216
|
+
### Patch Changes
|
|
217
|
+
|
|
218
|
+
- Delayed deprecation notice for streamVNext() replacing stream() until Sept 23rd ([#7739](https://github.com/mastra-ai/mastra/pull/7739))
|
|
219
|
+
|
|
220
|
+
- an part 3 ([#7705](https://github.com/mastra-ai/mastra/pull/7705))
|
|
221
|
+
|
|
222
|
+
- Update peer deps ([#7741](https://github.com/mastra-ai/mastra/pull/7741))
|
|
223
|
+
|
|
224
|
+
- Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
|
|
225
|
+
|
|
226
|
+
- Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`2a6585f`](https://github.com/mastra-ai/mastra/commit/2a6585f7cb71f023f805d521d1c3c95fb9a3aa59), [`3d26e83`](https://github.com/mastra-ai/mastra/commit/3d26e8353a945719028f087cc6ac4b06f0ce27d2), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`56e55d1`](https://github.com/mastra-ai/mastra/commit/56e55d1e9eb63e7d9e41aa46e012aae471256812), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a566c4e`](https://github.com/mastra-ai/mastra/commit/a566c4e92d86c1671707c54359b1d33934f7cc13), [`af333aa`](https://github.com/mastra-ai/mastra/commit/af333aa30fe6d1b127024b03a64736c46eddeca2), [`3863c52`](https://github.com/mastra-ai/mastra/commit/3863c52d44b4e5779968b802d977e87adf939d8e), [`6424c7e`](https://github.com/mastra-ai/mastra/commit/6424c7ec38b6921d66212431db1e0958f441b2a7), [`db94750`](https://github.com/mastra-ai/mastra/commit/db94750a41fd29b43eb1f7ce8e97ba8b9978c91b), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab), [`69fc3cd`](https://github.com/mastra-ai/mastra/commit/69fc3cd0fd814901785bdcf49bf536ab1e7fd975)]:
|
|
227
|
+
- @mastra/core@0.16.3
|
|
228
|
+
|
|
229
|
+
## 0.16.3-alpha.1
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- Delayed deprecation notice for streamVNext() replacing stream() until Sept 23rd ([#7739](https://github.com/mastra-ai/mastra/pull/7739))
|
|
234
|
+
|
|
235
|
+
- Update peer deps ([#7741](https://github.com/mastra-ai/mastra/pull/7741))
|
|
236
|
+
|
|
237
|
+
- Client SDK Agents, Mastra server - support runtimeContext with GET requests ([#7734](https://github.com/mastra-ai/mastra/pull/7734))
|
|
238
|
+
|
|
239
|
+
- Updated dependencies [[`2a6585f`](https://github.com/mastra-ai/mastra/commit/2a6585f7cb71f023f805d521d1c3c95fb9a3aa59), [`3d26e83`](https://github.com/mastra-ai/mastra/commit/3d26e8353a945719028f087cc6ac4b06f0ce27d2), [`56e55d1`](https://github.com/mastra-ai/mastra/commit/56e55d1e9eb63e7d9e41aa46e012aae471256812)]:
|
|
240
|
+
- @mastra/core@0.16.3-alpha.1
|
|
241
|
+
|
|
242
|
+
## 0.16.3-alpha.0
|
|
243
|
+
|
|
244
|
+
### Patch Changes
|
|
8
245
|
|
|
9
246
|
- an part 3 ([#7705](https://github.com/mastra-ai/mastra/pull/7705))
|
|
10
247
|
|
|
11
|
-
- Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`
|
|
12
|
-
- @mastra/core@0.
|
|
248
|
+
- Updated dependencies [[`b4379f7`](https://github.com/mastra-ai/mastra/commit/b4379f703fd74474f253420e8c3a684f2c4b2f8e), [`dd9119b`](https://github.com/mastra-ai/mastra/commit/dd9119b175a8f389082f75c12750e51f96d65dca), [`d34aaa1`](https://github.com/mastra-ai/mastra/commit/d34aaa1da5d3c5f991740f59e2fe6d28d3e2dd91), [`ce1e580`](https://github.com/mastra-ai/mastra/commit/ce1e580f6391e94a0c6816a9c5db0a21566a262f), [`b2babfa`](https://github.com/mastra-ai/mastra/commit/b2babfa9e75b22f2759179e71d8473f6dc5421ed), [`d8c3ba5`](https://github.com/mastra-ai/mastra/commit/d8c3ba516f4173282d293f7e64769cfc8738d360), [`a566c4e`](https://github.com/mastra-ai/mastra/commit/a566c4e92d86c1671707c54359b1d33934f7cc13), [`af333aa`](https://github.com/mastra-ai/mastra/commit/af333aa30fe6d1b127024b03a64736c46eddeca2), [`3863c52`](https://github.com/mastra-ai/mastra/commit/3863c52d44b4e5779968b802d977e87adf939d8e), [`6424c7e`](https://github.com/mastra-ai/mastra/commit/6424c7ec38b6921d66212431db1e0958f441b2a7), [`db94750`](https://github.com/mastra-ai/mastra/commit/db94750a41fd29b43eb1f7ce8e97ba8b9978c91b), [`a66a371`](https://github.com/mastra-ai/mastra/commit/a66a3716b00553d7f01842be9deb34f720b10fab), [`69fc3cd`](https://github.com/mastra-ai/mastra/commit/69fc3cd0fd814901785bdcf49bf536ab1e7fd975)]:
|
|
249
|
+
- @mastra/core@0.16.3-alpha.0
|
|
13
250
|
|
|
14
251
|
## 0.16.2
|
|
15
252
|
|
package/README.md
CHANGED
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
4
4
|
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
5
5
|
var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
|
|
6
|
+
var scoreTraces = require('@mastra/core/scores/scoreTraces');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/observability.ts
|
|
8
9
|
var observability_exports = {};
|
|
9
10
|
chunkEMMSS5I5_cjs.__export(observability_exports, {
|
|
10
11
|
getAITraceHandler: () => getAITraceHandler,
|
|
11
|
-
getAITracesPaginatedHandler: () => getAITracesPaginatedHandler
|
|
12
|
+
getAITracesPaginatedHandler: () => getAITracesPaginatedHandler,
|
|
13
|
+
getScoresBySpan: () => getScoresBySpan,
|
|
14
|
+
scoreTracesHandler: () => scoreTracesHandler
|
|
12
15
|
});
|
|
13
16
|
async function getAITraceHandler({ mastra, traceId }) {
|
|
14
17
|
try {
|
|
@@ -61,9 +64,67 @@ async function getAITracesPaginatedHandler({ mastra, body }) {
|
|
|
61
64
|
chunkRE4RPXT2_cjs.handleError(error, "Error getting AI traces paginated");
|
|
62
65
|
}
|
|
63
66
|
}
|
|
67
|
+
async function scoreTracesHandler({ mastra, body }) {
|
|
68
|
+
try {
|
|
69
|
+
if (!body) {
|
|
70
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Request body is required" });
|
|
71
|
+
}
|
|
72
|
+
const { scorerName, targets } = body;
|
|
73
|
+
if (!scorerName) {
|
|
74
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Scorer Name is required" });
|
|
75
|
+
}
|
|
76
|
+
if (!targets || targets.length === 0) {
|
|
77
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "At least one target is required" });
|
|
78
|
+
}
|
|
79
|
+
const storage = mastra.getStorage();
|
|
80
|
+
if (!storage) {
|
|
81
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
|
|
82
|
+
}
|
|
83
|
+
const scorer = mastra.getScorerByName(scorerName);
|
|
84
|
+
if (!scorer) {
|
|
85
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: `Scorer '${scorerName}' not found` });
|
|
86
|
+
}
|
|
87
|
+
const logger = mastra.getLogger();
|
|
88
|
+
scoreTraces.scoreTraces({
|
|
89
|
+
scorerName,
|
|
90
|
+
targets,
|
|
91
|
+
mastra
|
|
92
|
+
}).catch((error) => {
|
|
93
|
+
logger?.error(`Background trace scoring failed: ${error.message}`, error);
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
status: "success",
|
|
97
|
+
message: `Scoring started for ${targets.length} ${targets.length === 1 ? "trace" : "traces"}`,
|
|
98
|
+
traceCount: targets.length
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
chunkRE4RPXT2_cjs.handleError(error, "Error processing trace scoring");
|
|
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
|
+
}
|
|
64
123
|
|
|
65
124
|
exports.getAITraceHandler = getAITraceHandler;
|
|
66
125
|
exports.getAITracesPaginatedHandler = getAITracesPaginatedHandler;
|
|
126
|
+
exports.getScoresBySpan = getScoresBySpan;
|
|
67
127
|
exports.observability_exports = observability_exports;
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
exports.scoreTracesHandler = scoreTracesHandler;
|
|
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,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,4BAA4B,CAAA;AAAA,IACtE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAE9C,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAIA,gCAAc,GAAA,EAAK,EAAE,SAAS,CAAA,eAAA,EAAkB,OAAO,eAAe,CAAA;AAAA,IAClF;AAEA,IAAA,OAAO,KAAA;AAA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A8B,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"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { convertInstructionsToString } from './chunk-YWOK4F5A.js';
|
|
1
2
|
import { __export } from './chunk-G3PMV62Z.js';
|
|
2
3
|
import { MastraA2AError } from '@mastra/core/a2a';
|
|
3
4
|
import { z } from 'zod';
|
|
@@ -218,7 +219,7 @@ async function getAgentCardByIdHandler({
|
|
|
218
219
|
]);
|
|
219
220
|
const agentCard = {
|
|
220
221
|
name: agent.id || agentId,
|
|
221
|
-
description: instructions,
|
|
222
|
+
description: convertInstructionsToString(instructions),
|
|
222
223
|
url: executionUrl,
|
|
223
224
|
provider,
|
|
224
225
|
version,
|
|
@@ -472,5 +473,5 @@ async function getAgentExecutionHandler({
|
|
|
472
473
|
}
|
|
473
474
|
|
|
474
475
|
export { a2a_exports, getAgentCardByIdHandler, getAgentExecutionHandler, handleMessageSend, handleMessageStream, handleTaskCancel, handleTaskGet };
|
|
475
|
-
//# sourceMappingURL=chunk-
|
|
476
|
-
//# sourceMappingURL=chunk-
|
|
476
|
+
//# sourceMappingURL=chunk-6IJWRJZE.js.map
|
|
477
|
+
//# sourceMappingURL=chunk-6IJWRJZE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/a2a.ts","../src/server/a2a/protocol.ts","../src/server/a2a/tasks.ts"],"names":["MastraA2AError","result"],"mappings":";;;;;;AAAA,IAAA,WAAA,GAAA;AAAA,QAAA,CAAA,WAAA,EAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,aAAA,EAAA,MAAA;AAAA,CAAA,CAAA;ACMO,SAAS,cAAA,CACd,KAAA,EACA,KAAA,EACA,MAAA,EACA,MAAA,EACgC;AAChC,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,iBAAiB,cAAA,EAAgB;AACnC,IAAA,QAAA,GAAW,KAAA;AAAA,EACb,CAAA,MAAA,IAAW,iBAAiB,KAAA,EAAO;AAEjC,I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.js","sourcesContent":["import { MastraA2AError } from '@mastra/core/a2a';\nimport type {\n MessageSendParams,\n TaskQueryParams,\n TaskIdParams,\n AgentCard,\n TaskStatus,\n TaskState,\n} from '@mastra/core/a2a';\nimport type { Agent } from '@mastra/core/agent';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { z } from 'zod';\nimport { convertToCoreMessage, normalizeError, createSuccessResponse, createErrorResponse } from '../a2a/protocol';\nimport type { InMemoryTaskStore } from '../a2a/store';\nimport { applyUpdateToTask, createTaskContext, loadOrCreateTask } from '../a2a/tasks';\nimport type { Context } from '../types';\nimport { convertInstructionsToString } from '../utils';\n\nconst messageSendParamsSchema = z.object({\n message: z.object({\n role: z.enum(['user', 'agent']),\n parts: z.array(\n z.object({\n kind: z.enum(['text']),\n text: z.string(),\n }),\n ),\n kind: z.literal('message'),\n messageId: z.string(),\n contextId: z.string().optional(),\n taskId: z.string().optional(),\n referenceTaskIds: z.array(z.string()).optional(),\n extensions: z.array(z.string()).optional(),\n metadata: z.record(z.any()).optional(),\n }),\n});\n\nexport async function getAgentCardByIdHandler({\n mastra,\n agentId,\n executionUrl = `/a2a/${agentId}`,\n provider = {\n organization: 'Mastra',\n url: 'https://mastra.ai',\n },\n version = '1.0',\n runtimeContext,\n}: Context & {\n runtimeContext: RuntimeContext;\n agentId: keyof ReturnType<typeof mastra.getAgents>;\n executionUrl?: string;\n version?: string;\n provider?: {\n organization: string;\n url: string;\n };\n}): Promise<AgentCard> {\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new Error(`Agent with ID ${agentId} not found`);\n }\n\n const [instructions, tools] = await Promise.all([\n agent.getInstructions({ runtimeContext }),\n agent.getTools({ runtimeContext }),\n ]);\n\n // Extract agent information to create the AgentCard\n const agentCard: AgentCard = {\n name: agent.id || agentId,\n description: convertInstructionsToString(instructions),\n url: executionUrl,\n provider,\n version,\n capabilities: {\n streaming: true, // All agents support streaming\n pushNotifications: false,\n stateTransitionHistory: false,\n },\n defaultInputModes: ['text'],\n defaultOutputModes: ['text'],\n // Convert agent tools to skills format for A2A protocol\n skills: Object.entries(tools).map(([toolId, tool]) => ({\n id: toolId,\n name: toolId,\n description: tool.description || `Tool: ${toolId}`,\n // Optional fields\n tags: ['tool'],\n })),\n };\n\n return agentCard;\n}\n\nfunction validateMessageSendParams(params: MessageSendParams) {\n try {\n messageSendParamsSchema.parse(params);\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw MastraA2AError.invalidParams((error as z.ZodError).errors[0]!.message);\n }\n\n throw error;\n }\n}\n\nexport async function handleMessageSend({\n requestId,\n params,\n taskStore,\n agent,\n agentId,\n logger,\n runtimeContext,\n}: {\n requestId: string;\n params: MessageSendParams;\n taskStore: InMemoryTaskStore;\n agent: Agent;\n agentId: string;\n logger?: IMastraLogger;\n runtimeContext: RuntimeContext;\n}) {\n validateMessageSendParams(params);\n\n const { message, metadata } = params;\n const { contextId } = message;\n const taskId = message.taskId || crypto.randomUUID();\n\n // Load or create task\n let currentData = await loadOrCreateTask({\n taskId,\n taskStore,\n agentId,\n message,\n contextId,\n metadata,\n });\n\n // Use the new TaskContext definition, passing history\n const context = createTaskContext({\n task: currentData,\n userMessage: message,\n history: currentData.history || [],\n activeCancellations: taskStore.activeCancellations,\n });\n\n try {\n const { text } = await agent.generate([convertToCoreMessage(message)], {\n runId: taskId,\n runtimeContext,\n });\n\n currentData = applyUpdateToTask(currentData, {\n state: 'completed',\n message: {\n messageId: crypto.randomUUID(),\n role: 'agent',\n parts: [\n {\n kind: 'text',\n text: text,\n },\n ],\n kind: 'message',\n },\n });\n\n await taskStore.save({ agentId, data: currentData });\n context.task = currentData;\n } catch (handlerError) {\n // If handler throws, apply 'failed' status, save, and rethrow\n const failureStatusUpdate: Omit<TaskStatus, 'timestamp'> = {\n state: 'failed',\n message: {\n messageId: crypto.randomUUID(),\n role: 'agent',\n parts: [\n {\n kind: 'text',\n text: `Handler failed: ${handlerError instanceof Error ? handlerError.message : String(handlerError)}`,\n },\n ],\n kind: 'message',\n },\n };\n currentData = applyUpdateToTask(currentData, failureStatusUpdate);\n\n try {\n await taskStore.save({ agentId, data: currentData });\n } catch (saveError) {\n // @ts-expect-error saveError is an unknown error\n logger?.error(`Failed to save task ${currentData.id} after handler error:`, saveError?.message);\n }\n\n return normalizeError(handlerError, requestId, currentData.id, logger); // Rethrow original error\n }\n\n // The loop finished, send the final task state\n return createSuccessResponse(requestId, currentData);\n}\n\nexport async function handleTaskGet({\n requestId,\n taskStore,\n agentId,\n taskId,\n}: {\n requestId: string;\n taskStore: InMemoryTaskStore;\n agentId: string;\n taskId: string;\n}) {\n const task = await taskStore.load({ agentId, taskId });\n\n if (!task) {\n throw MastraA2AError.taskNotFound(taskId);\n }\n\n return createSuccessResponse(requestId, task);\n}\n\nexport async function* handleMessageStream({\n requestId,\n params,\n taskStore,\n agent,\n agentId,\n logger,\n runtimeContext,\n}: {\n requestId: string;\n params: MessageSendParams;\n taskStore: InMemoryTaskStore;\n agent: Agent;\n agentId: string;\n logger?: IMastraLogger;\n runtimeContext: RuntimeContext;\n}) {\n yield createSuccessResponse(requestId, {\n state: 'working',\n message: {\n messageId: crypto.randomUUID(),\n kind: 'message',\n role: 'agent',\n parts: [{ kind: 'text', text: 'Generating response...' }],\n },\n });\n\n let result;\n try {\n result = await handleMessageSend({\n requestId,\n params,\n taskStore,\n agent,\n agentId,\n runtimeContext,\n logger,\n });\n } catch (err) {\n if (!(err instanceof MastraA2AError)) {\n throw err;\n }\n\n result = createErrorResponse(requestId, err.toJSONRPCError());\n }\n\n yield result;\n}\n\nexport async function handleTaskCancel({\n requestId,\n taskStore,\n agentId,\n taskId,\n logger,\n}: {\n requestId: string;\n taskStore: InMemoryTaskStore;\n agentId: string;\n taskId: string;\n logger?: IMastraLogger;\n}) {\n // Load task and history\n let data = await taskStore.load({\n agentId,\n taskId,\n });\n\n if (!data) {\n throw MastraA2AError.taskNotFound(taskId);\n }\n\n // Check if cancelable (not already in a final state)\n const finalStates: TaskState[] = ['completed', 'failed', 'canceled'];\n\n if (finalStates.includes(data.status.state)) {\n logger?.info(`Task ${taskId} already in final state ${data.status.state}, cannot cancel.`);\n return createSuccessResponse(requestId, data);\n }\n\n // Signal cancellation\n taskStore.activeCancellations.add(taskId);\n\n // Apply 'canceled' state update\n const cancelUpdate: Omit<TaskStatus, 'timestamp'> = {\n state: 'canceled',\n message: {\n role: 'agent',\n parts: [{ kind: 'text', text: 'Task cancelled by request.' }],\n kind: 'message',\n messageId: crypto.randomUUID(),\n },\n };\n\n data = applyUpdateToTask(data, cancelUpdate);\n\n // Save the updated state\n await taskStore.save({ agentId, data });\n\n // Remove from active cancellations *after* saving\n taskStore.activeCancellations.delete(taskId);\n\n // Return the updated task object\n return createSuccessResponse(requestId, data);\n}\n\nexport async function getAgentExecutionHandler({\n requestId,\n mastra,\n agentId,\n runtimeContext,\n method,\n params,\n taskStore,\n logger,\n}: Context & {\n requestId: string;\n runtimeContext: RuntimeContext;\n agentId: string;\n method: 'message/send' | 'message/stream' | 'tasks/get' | 'tasks/cancel';\n params: MessageSendParams | TaskQueryParams | TaskIdParams;\n taskStore: InMemoryTaskStore;\n logger?: IMastraLogger;\n}): Promise<any> {\n const agent = mastra.getAgent(agentId);\n\n let taskId: string | undefined; // For error context\n\n try {\n // Attempt to get task ID early for error context. Cast params to any to access id.\n // Proper validation happens within specific handlers.\n taskId = 'id' in params ? params.id : params.message?.taskId || 'No task ID provided';\n\n // 2. Route based on method\n switch (method) {\n case 'message/send': {\n const result = await handleMessageSend({\n requestId,\n params: params as MessageSendParams,\n taskStore,\n agent,\n agentId,\n runtimeContext,\n });\n return result;\n }\n case 'message/stream':\n const result = await handleMessageStream({\n requestId,\n taskStore,\n params: params as MessageSendParams,\n agent,\n agentId,\n runtimeContext,\n });\n return result;\n\n case 'tasks/get': {\n const result = await handleTaskGet({\n requestId,\n taskStore,\n agentId,\n taskId,\n });\n\n return result;\n }\n case 'tasks/cancel': {\n const result = await handleTaskCancel({\n requestId,\n taskStore,\n agentId,\n taskId,\n });\n\n return result;\n }\n default:\n throw MastraA2AError.methodNotFound(method);\n }\n } catch (error) {\n if (error instanceof MastraA2AError && taskId && !error.taskId) {\n error.taskId = taskId; // Add task ID context if missing\n }\n\n return normalizeError(error, requestId, taskId, logger);\n }\n}\n","import { MastraA2AError } from '@mastra/core/a2a';\n\nimport type { JSONRPCError, JSONRPCResponse, Message, Part } from '@mastra/core/a2a';\nimport type { CoreMessage } from '@mastra/core/llm';\nimport type { IMastraLogger } from '@mastra/core/logger';\n\nexport function normalizeError(\n error: any,\n reqId: number | string | null,\n taskId?: string,\n logger?: IMastraLogger,\n): JSONRPCResponse<null, unknown> {\n let a2aError: MastraA2AError;\n if (error instanceof MastraA2AError) {\n a2aError = error;\n } else if (error instanceof Error) {\n // Generic JS error\n a2aError = MastraA2AError.internalError(error.message, { stack: error.stack });\n } else {\n // Unknown error type\n a2aError = MastraA2AError.internalError('An unknown error occurred.', error);\n }\n\n // Ensure Task ID context is present if possible\n if (taskId && !a2aError.taskId) {\n a2aError.taskId = taskId;\n }\n\n logger?.error(`Error processing request (Task: ${a2aError.taskId ?? 'N/A'}, ReqID: ${reqId ?? 'N/A'}):`, a2aError);\n\n return createErrorResponse(reqId, a2aError.toJSONRPCError());\n}\n\nexport function createErrorResponse(\n id: number | string | null,\n error: JSONRPCError<unknown>,\n): JSONRPCResponse<null, unknown> {\n // For errors, ID should be the same as request ID, or null if that couldn't be determined\n return {\n jsonrpc: '2.0',\n id: id, // Can be null if request ID was invalid/missing\n error: error,\n };\n}\n\nexport function createSuccessResponse<T>(id: number | string | null, result: T): JSONRPCResponse<T> {\n if (!id) {\n // This shouldn't happen for methods that expect a response, but safeguard\n throw MastraA2AError.internalError('Cannot create success response for null ID.');\n }\n\n return {\n jsonrpc: '2.0',\n id: id,\n result: result,\n };\n}\n\nexport function convertToCoreMessage(message: Message): CoreMessage {\n return {\n role: message.role === 'user' ? 'user' : 'assistant',\n content: message.parts.map(msg => convertToCoreMessagePart(msg)),\n };\n}\n\nfunction convertToCoreMessagePart(part: Part) {\n switch (part.kind) {\n case 'text':\n return {\n type: 'text',\n text: part.text,\n } as const;\n case 'file':\n return {\n type: 'file',\n data: 'uri' in part.file ? new URL(part.file.uri) : part.file.bytes,\n mimeType: part.file.mimeType!,\n } as const;\n case 'data':\n throw new Error('Data parts are not supported in core messages');\n }\n}\n","import type {\n Message,\n Task,\n TaskState,\n TaskStatus,\n TaskContext,\n TaskArtifactUpdateEvent,\n Artifact,\n} from '@mastra/core/a2a';\nimport type { IMastraLogger } from '@mastra/core/logger';\nimport type { InMemoryTaskStore } from './store';\n\nfunction isTaskStatusUpdate(update: TaskStatus | TaskArtifactUpdateEvent): update is Omit<TaskStatus, 'timestamp'> {\n return 'state' in update && !('parts' in update);\n}\n\nfunction isArtifactUpdate(update: TaskStatus | TaskArtifactUpdateEvent): update is TaskArtifactUpdateEvent {\n return 'kind' in update && update.kind === 'artifact-update';\n}\n\nexport function applyUpdateToTask(\n current: Task,\n update: Omit<TaskStatus, 'timestamp'> | TaskArtifactUpdateEvent,\n): Task {\n let newTask = structuredClone(current);\n\n if (isTaskStatusUpdate(update)) {\n // Merge status update\n newTask.status = {\n ...newTask.status, // Keep existing properties if not overwritten\n ...update, // Apply updates\n timestamp: new Date().toISOString(),\n };\n } else if (isArtifactUpdate(update)) {\n // Handle artifact update\n if (!newTask.artifacts) {\n newTask.artifacts = [];\n } else {\n // Ensure we're working with a copy of the artifacts array\n newTask.artifacts = [...newTask.artifacts];\n }\n\n const artifact = update.artifact;\n const existingIndex = newTask.artifacts.findIndex(a => a.name === artifact.name);\n const existingArtifact = newTask.artifacts[existingIndex];\n\n if (existingArtifact) {\n if (update.append) {\n // Create a deep copy for modification to avoid mutating original\n const appendedArtifact = JSON.parse(JSON.stringify(existingArtifact)) as Artifact;\n appendedArtifact.parts.push(...artifact.parts);\n if (artifact.metadata) {\n appendedArtifact.metadata = {\n ...(appendedArtifact.metadata || {}),\n ...artifact.metadata,\n };\n }\n if (artifact.description) appendedArtifact.description = artifact.description;\n newTask.artifacts[existingIndex] = appendedArtifact; // Replace with appended version\n } else {\n // Overwrite artifact at index (with a copy of the update)\n newTask.artifacts[existingIndex] = { ...artifact };\n }\n } else {\n newTask.artifacts.push({ ...artifact });\n }\n }\n\n return newTask;\n}\n\nexport async function loadOrCreateTask({\n agentId,\n taskId,\n taskStore,\n message,\n contextId,\n metadata,\n logger,\n}: {\n agentId: string;\n taskId: string;\n taskStore: InMemoryTaskStore;\n message: Message;\n contextId?: string;\n metadata?: Record<string, unknown>;\n logger?: IMastraLogger;\n}): Promise<Task> {\n const data = await taskStore.load({ agentId, taskId });\n\n // Create new task if none exists\n if (!data) {\n const initialTask: Task = {\n id: taskId,\n contextId: contextId || crypto.randomUUID(),\n status: {\n state: 'submitted',\n timestamp: new Date().toISOString(),\n message: undefined,\n },\n artifacts: [],\n history: [message],\n metadata: metadata,\n kind: 'task',\n };\n\n logger?.info(`[Task ${taskId}] Created new task.`);\n await taskStore.save({ agentId, data: initialTask });\n\n return initialTask;\n }\n\n // Handle existing task\n logger?.info(`[Task ${taskId}] Loaded existing task.`);\n\n // Add message to history and prepare updated data\n let updatedData = data;\n updatedData.history = [...(data.history || []), message];\n\n // Handle state transitions\n const { status } = data;\n const finalStates: TaskState[] = ['completed', 'failed', 'canceled'];\n\n if (finalStates.includes(status.state)) {\n logger?.warn(`[Task ${taskId}] Received message for task in final state ${status.state}. Restarting.`);\n updatedData = applyUpdateToTask(updatedData, {\n state: 'submitted',\n message: undefined,\n });\n } else if (status.state === 'input-required') {\n logger?.info(`[Task ${taskId}] Changing state from 'input-required' to 'working'.`);\n updatedData = applyUpdateToTask(updatedData, { state: 'working' });\n } else if (status.state === 'working') {\n logger?.warn(`[Task ${taskId}] Received message while already 'working'. Proceeding.`);\n }\n\n await taskStore.save({ agentId, data: updatedData });\n\n return updatedData;\n}\n\nexport function createTaskContext({\n task,\n userMessage,\n history,\n activeCancellations,\n}: {\n task: Task;\n userMessage: Message;\n history: Message[];\n activeCancellations: Set<string>;\n}): TaskContext {\n return {\n task: structuredClone(task),\n userMessage,\n history: structuredClone(history),\n isCancelled: () => activeCancellations.has(task.id),\n };\n}\n"]}
|