@mastra/deployer-cloud 0.24.0-alpha.0 → 1.0.0-beta.0
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 +18 -62
- package/README.md +0 -1
- package/dist/index.cjs +11 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -50
- package/dist/index.js.map +1 -1
- package/dist/utils/logger.d.ts +2 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/package.json +9 -13
- package/versions.json +1 -1
- package/templates/instrumentation-template.js +0 -69
package/CHANGELOG.md
CHANGED
|
@@ -1,82 +1,38 @@
|
|
|
1
1
|
# @mastra/deployer-cloud
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 1.0.0-beta.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
|
|
8
|
-
|
|
9
|
-
- Updated dependencies [[`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc), [`2437a90`](https://github.com/mastra-ai/mastra/commit/2437a90d94a0ff94fa8dd42d2558d73c124972d3), [`6d7e90d`](https://github.com/mastra-ai/mastra/commit/6d7e90db09713e6250f4d6c3d3cff1b4740e50f9), [`23c2614`](https://github.com/mastra-ai/mastra/commit/23c26140fdbf04b8c59e8d7d52106d67dad962ec), [`f78b908`](https://github.com/mastra-ai/mastra/commit/f78b9080e11af765969b36b4a619761056030840), [`23c2614`](https://github.com/mastra-ai/mastra/commit/23c26140fdbf04b8c59e8d7d52106d67dad962ec), [`3e6c29a`](https://github.com/mastra-ai/mastra/commit/3e6c29a8924f63da4def2cf95180f671b3b2c89c), [`139588d`](https://github.com/mastra-ai/mastra/commit/139588df7755c9111a3060f72a789c1a8c95e091), [`186b29b`](https://github.com/mastra-ai/mastra/commit/186b29bd51ac1dcc24ad3825fdb7207a6d6391a6), [`4e92a19`](https://github.com/mastra-ai/mastra/commit/4e92a19aef1bd7f608482b366b1e46873a9dc6c7), [`e365eda`](https://github.com/mastra-ai/mastra/commit/e365eda45795b43707310531cac1e2ce4e5a0712), [`dbb705e`](https://github.com/mastra-ai/mastra/commit/dbb705e61999ec655b912ea8b5d77ae4792989a7)]:
|
|
10
|
-
- @mastra/deployer@0.24.0-alpha.0
|
|
11
|
-
- @mastra/loggers@0.10.19-alpha.0
|
|
12
|
-
- @mastra/core@0.24.0-alpha.0
|
|
13
|
-
|
|
14
|
-
## 0.23.3
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
5
|
+
### Major Changes
|
|
17
6
|
|
|
18
|
-
-
|
|
19
|
-
- @mastra/deployer@0.23.3
|
|
20
|
-
- @mastra/core@0.23.3
|
|
7
|
+
- Moving scorers under the eval domain, api method consistency, prebuilt evals, scorers require ids. ([#9589](https://github.com/mastra-ai/mastra/pull/9589))
|
|
21
8
|
|
|
22
|
-
|
|
9
|
+
- Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
|
|
23
10
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- Updated dependencies [[`b55bbce`](https://github.com/mastra-ai/mastra/commit/b55bbce89404d35fdd967012dd503fae343d4c2d), [`d6cb18e`](https://github.com/mastra-ai/mastra/commit/d6cb18e189fd0ac95d4934cf0d6f2866876d1a2e), [`d0ecff7`](https://github.com/mastra-ai/mastra/commit/d0ecff793d5cd50408cd8d1d113f02e28d897a3d), [`e84a959`](https://github.com/mastra-ai/mastra/commit/e84a9592bfdec4f1c9fdf108c9d4ea4e2ee8f7e3), [`e742d37`](https://github.com/mastra-ai/mastra/commit/e742d371f24ef8059670cc05e9aee308eac068b9)]:
|
|
27
|
-
- @mastra/deployer@0.23.3-alpha.0
|
|
28
|
-
- @mastra/core@0.23.3-alpha.0
|
|
29
|
-
|
|
30
|
-
## 0.23.2
|
|
11
|
+
- Experimental auth -> auth ([#9660](https://github.com/mastra-ai/mastra/pull/9660))
|
|
31
12
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- Updated dependencies [[`f57a81e`](https://github.com/mastra-ai/mastra/commit/f57a81e6ce644e45bf1c9618778cc54c50a84ad4), [`17e5a4e`](https://github.com/mastra-ai/mastra/commit/17e5a4e828a8ebc6148c76b42a139c0f9bf7e25f), [`2afd345`](https://github.com/mastra-ai/mastra/commit/2afd3450825b76e41f7973baddf13867ea042e40), [`fc79af3`](https://github.com/mastra-ai/mastra/commit/fc79af3915d1c456729cbd753673b0c0564340d8), [`eefc89e`](https://github.com/mastra-ai/mastra/commit/eefc89ee69f05bb71661473a807fc7dc03d56f17), [`60bd45d`](https://github.com/mastra-ai/mastra/commit/60bd45de021f0dfbe6583928f6da5169cb5585ba), [`a30093d`](https://github.com/mastra-ai/mastra/commit/a30093de98c1836dcd5dfddf09649010712b8c95), [`0fe7adb`](https://github.com/mastra-ai/mastra/commit/0fe7adb0f20f59a6bb41f235d01f8b7a880ea6e7), [`a42e496`](https://github.com/mastra-ai/mastra/commit/a42e49686a7486e2e9e9397fa98e5ff7a71dc1b0), [`3670db7`](https://github.com/mastra-ai/mastra/commit/3670db7e8e798f9d65fac5bfb732134a1f26ba7b), [`e40d4d0`](https://github.com/mastra-ai/mastra/commit/e40d4d0a0971b4505e7c9de73c656066c7565653), [`fc843ff`](https://github.com/mastra-ai/mastra/commit/fc843ff4d1d149317b6324553ce5ad7972062a78), [`ff16f9b`](https://github.com/mastra-ai/mastra/commit/ff16f9b9dbc701b26b6c4e9872f759f3880f9327), [`35e6cf7`](https://github.com/mastra-ai/mastra/commit/35e6cf722fef16ea0301eb9cf5a32fe9ccb12d22), [`30f92b5`](https://github.com/mastra-ai/mastra/commit/30f92b5b3aa224289f2f0eff56babcfa7a87b772), [`30a2e36`](https://github.com/mastra-ai/mastra/commit/30a2e369485e0e59c4faa1d83c5635c2260b304c)]:
|
|
35
|
-
- @mastra/core@0.23.2
|
|
36
|
-
- @mastra/deployer@0.23.2
|
|
13
|
+
- Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
37
14
|
|
|
38
|
-
|
|
15
|
+
- Mark as stable ([`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc))
|
|
39
16
|
|
|
40
|
-
|
|
17
|
+
- Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
|
|
18
|
+
Made the return format of all methods that return db messages consistent. It's always `{ messages: MastraDBMessage[] }` now, and messages can be converted after that using `@mastra/ai-sdk/ui`'s `toAISdkV4/5Messages()` function
|
|
41
19
|
|
|
42
|
-
-
|
|
43
|
-
- @mastra/core@0.23.2-alpha.1
|
|
44
|
-
- @mastra/deployer@0.23.2-alpha.1
|
|
20
|
+
- Remove legacy evals from Mastra ([#9491](https://github.com/mastra-ai/mastra/pull/9491))
|
|
45
21
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Patch Changes
|
|
49
|
-
|
|
50
|
-
- Updated dependencies [[`17e5a4e`](https://github.com/mastra-ai/mastra/commit/17e5a4e828a8ebc6148c76b42a139c0f9bf7e25f), [`2afd345`](https://github.com/mastra-ai/mastra/commit/2afd3450825b76e41f7973baddf13867ea042e40), [`eefc89e`](https://github.com/mastra-ai/mastra/commit/eefc89ee69f05bb71661473a807fc7dc03d56f17), [`0fe7adb`](https://github.com/mastra-ai/mastra/commit/0fe7adb0f20f59a6bb41f235d01f8b7a880ea6e7), [`a42e496`](https://github.com/mastra-ai/mastra/commit/a42e49686a7486e2e9e9397fa98e5ff7a71dc1b0), [`3670db7`](https://github.com/mastra-ai/mastra/commit/3670db7e8e798f9d65fac5bfb732134a1f26ba7b), [`fc843ff`](https://github.com/mastra-ai/mastra/commit/fc843ff4d1d149317b6324553ce5ad7972062a78), [`30f92b5`](https://github.com/mastra-ai/mastra/commit/30f92b5b3aa224289f2f0eff56babcfa7a87b772)]:
|
|
51
|
-
- @mastra/deployer@0.23.2-alpha.0
|
|
52
|
-
- @mastra/core@0.23.2-alpha.0
|
|
53
|
-
|
|
54
|
-
## 0.23.1
|
|
55
|
-
|
|
56
|
-
### Patch Changes
|
|
57
|
-
|
|
58
|
-
- Fix peerdependencies ([`eb7c1c8`](https://github.com/mastra-ai/mastra/commit/eb7c1c8c592d8fb16dfd250e337d9cdc73c8d5de))
|
|
59
|
-
|
|
60
|
-
- Updated dependencies [[`eb7c1c8`](https://github.com/mastra-ai/mastra/commit/eb7c1c8c592d8fb16dfd250e337d9cdc73c8d5de)]:
|
|
61
|
-
- @mastra/deployer@0.23.1
|
|
62
|
-
- @mastra/loggers@0.10.18
|
|
63
|
-
- @mastra/core@0.23.1
|
|
22
|
+
### Minor Changes
|
|
64
23
|
|
|
65
|
-
|
|
24
|
+
- Update peer dependencies to match core package version bump (1.0.0) ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
66
25
|
|
|
67
26
|
### Patch Changes
|
|
68
27
|
|
|
69
|
-
-
|
|
70
|
-
- @mastra/core@0.23.0
|
|
71
|
-
- @mastra/deployer@0.23.0
|
|
28
|
+
- Removed "instrumentation.mjs" from deployment. Observability no longer requires this file. ([#9771](https://github.com/mastra-ai/mastra/pull/9771))
|
|
72
29
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Patch Changes
|
|
30
|
+
- Use a shared `getAllToolPaths()` method from the bundler to discover tool paths. ([#9204](https://github.com/mastra-ai/mastra/pull/9204))
|
|
76
31
|
|
|
77
|
-
- Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`
|
|
78
|
-
- @mastra/
|
|
79
|
-
- @mastra/
|
|
32
|
+
- Updated dependencies [[`77ff370`](https://github.com/mastra-ai/mastra/commit/77ff370186ba77955620c465fd2e95360e1947ea), [`39c9743`](https://github.com/mastra-ai/mastra/commit/39c97432d084294f8ba85fbf3ef28098ff21459e), [`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`5540775`](https://github.com/mastra-ai/mastra/commit/5540775f68685e19ddb6972ad73297f117656f59), [`0491e7c`](https://github.com/mastra-ai/mastra/commit/0491e7c9b714cb0ba22187ee062147ec2dd7c712), [`f6f4903`](https://github.com/mastra-ai/mastra/commit/f6f4903397314f73362061dc5a3e8e7c61ea34aa), [`0e8ed46`](https://github.com/mastra-ai/mastra/commit/0e8ed467c54d6901a6a365f270ec15d6faadb36c), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`2f897df`](https://github.com/mastra-ai/mastra/commit/2f897df208508f46f51b7625e5dd20c37f93e0e3), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`aaa40e7`](https://github.com/mastra-ai/mastra/commit/aaa40e788628b319baa8e889407d11ad626547fa), [`1521d71`](https://github.com/mastra-ai/mastra/commit/1521d716e5daedc74690c983fbd961123c56756b), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`2ef1f3c`](https://github.com/mastra-ai/mastra/commit/2ef1f3cc1f9785998197571478821326b2a528ee), [`8940859`](https://github.com/mastra-ai/mastra/commit/89408593658199b4ad67f7b65e888f344e64a442), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`e629310`](https://github.com/mastra-ai/mastra/commit/e629310f1a73fa236d49ec7a1d1cceb6229dc7cc), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`71c8d6c`](https://github.com/mastra-ai/mastra/commit/71c8d6c161253207b2b9588bdadb7eed604f7253), [`6179a9b`](https://github.com/mastra-ai/mastra/commit/6179a9ba36ffac326de3cc3c43cdc8028d37c251), [`00f4921`](https://github.com/mastra-ai/mastra/commit/00f4921dd2c91a1e5446799599ef7116a8214a1a), [`ca8041c`](https://github.com/mastra-ai/mastra/commit/ca8041cce0379fda22ed293a565bcb5b6ddca68a), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`a8f1494`](https://github.com/mastra-ai/mastra/commit/a8f1494f4bbdc2770bcf327d4c7d869e332183f1), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`a854ede`](https://github.com/mastra-ai/mastra/commit/a854ede62bf5ac0945a624ac48913dd69c73aabf), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`3defc80`](https://github.com/mastra-ai/mastra/commit/3defc80cf2b88a1b7fc1cc4ddcb91e982a614609), [`16153fe`](https://github.com/mastra-ai/mastra/commit/16153fe7eb13c99401f48e6ca32707c965ee28b9), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`bc94344`](https://github.com/mastra-ai/mastra/commit/bc943444a1342d8a662151b7bce1df7dae32f59c), [`87f9f96`](https://github.com/mastra-ai/mastra/commit/87f9f96c772117fb868c9ea17a9eda664d41a35e), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`903f67d`](https://github.com/mastra-ai/mastra/commit/903f67d184504a273893818c02b961f5423a79ad), [`2a90c55`](https://github.com/mastra-ai/mastra/commit/2a90c55a86a9210697d5adaab5ee94584b079adc), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`9e0a85d`](https://github.com/mastra-ai/mastra/commit/9e0a85d11d02ca5918463ab5c2ec55d4eebf3769), [`96d35f6`](https://github.com/mastra-ai/mastra/commit/96d35f61376bc2b1bf148648a2c1985bd51bef55), [`5cbe88a`](https://github.com/mastra-ai/mastra/commit/5cbe88aefbd9f933bca669fd371ea36bf939ac6d), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`d78b38d`](https://github.com/mastra-ai/mastra/commit/d78b38d898fce285260d3bbb4befade54331617f), [`e41f852`](https://github.com/mastra-ai/mastra/commit/e41f852a3068be9c65818d9ab2218bae06ed0237), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`c710c16`](https://github.com/mastra-ai/mastra/commit/c710c1652dccfdc4111c8412bca7a6bb1d48b441), [`354ad0b`](https://github.com/mastra-ai/mastra/commit/354ad0b7b1b8183ac567f236a884fc7ede6d7138), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`398fde3`](https://github.com/mastra-ai/mastra/commit/398fde3f39e707cda79372cdae8f9870e3b57c8d), [`dfe3f8c`](https://github.com/mastra-ai/mastra/commit/dfe3f8c7376ffe159236819e19ca522143c1f972), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`0d7618b`](https://github.com/mastra-ai/mastra/commit/0d7618bc650bf2800934b243eca5648f4aeed9c2), [`7b763e5`](https://github.com/mastra-ai/mastra/commit/7b763e52fc3eaf699c2a99f2adf418dd46e4e9a5), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`3697853`](https://github.com/mastra-ai/mastra/commit/3697853deeb72017d90e0f38a93c1e29221aeca0), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac), [`b2e45ec`](https://github.com/mastra-ai/mastra/commit/b2e45eca727a8db01a81ba93f1a5219c7183c839), [`d6d49f7`](https://github.com/mastra-ai/mastra/commit/d6d49f7b8714fa19a52ff9c7cf7fb7e73751901e), [`a534e95`](https://github.com/mastra-ai/mastra/commit/a534e9591f83b3cc1ebff99c67edf4cda7bf81d3), [`9d0e7fe`](https://github.com/mastra-ai/mastra/commit/9d0e7feca8ed98de959f53476ee1456073673348), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`3f2faf2`](https://github.com/mastra-ai/mastra/commit/3f2faf2e2d685d6c053cc5af1bf9fedf267b2ce5), [`22f64bc`](https://github.com/mastra-ai/mastra/commit/22f64bc1d37149480b58bf2fefe35b79a1e3e7d5), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`6c7ffcd`](https://github.com/mastra-ai/mastra/commit/6c7ffcdf9a5b0a4435eb3f934c22c05b9e2fedb3), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`bda6370`](https://github.com/mastra-ai/mastra/commit/bda637009360649aaf579919e7873e33553c273e), [`d7acd8e`](https://github.com/mastra-ai/mastra/commit/d7acd8e987b5d7eff4fd98b0906c17c06a2e83d5), [`056d075`](https://github.com/mastra-ai/mastra/commit/056d075598761a47c4f6f48c0ba8f793ca915c7f), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`4a8cade`](https://github.com/mastra-ai/mastra/commit/4a8cade69b4616da04d78e6f76649b52d843997e), [`735d8c1`](https://github.com/mastra-ai/mastra/commit/735d8c1c0d19fbc09e6f8b66cf41bc7655993838), [`acf322e`](https://github.com/mastra-ai/mastra/commit/acf322e0f1fd0189684cf529d91c694bea918a45), [`c942802`](https://github.com/mastra-ai/mastra/commit/c942802a477a925b01859a7b8688d4355715caaa), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`cc34739`](https://github.com/mastra-ai/mastra/commit/cc34739c34b6266a91bea561119240a7acf47887), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`2b8893c`](https://github.com/mastra-ai/mastra/commit/2b8893cb108ef9acb72ee7835cd625610d2c1a4a), [`8e5c75b`](https://github.com/mastra-ai/mastra/commit/8e5c75bdb1d08a42d45309a4c72def4b6890230f), [`e59e0d3`](https://github.com/mastra-ai/mastra/commit/e59e0d32afb5fcf2c9f3c00c8f81f6c21d3a63fa), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019), [`1176e03`](https://github.com/mastra-ai/mastra/commit/1176e03a0db4b8f5b0a85afbaf45d3cc7ab2d94a)]:
|
|
33
|
+
- @mastra/deployer@1.0.0-beta.0
|
|
34
|
+
- @mastra/core@1.0.0-beta.0
|
|
35
|
+
- @mastra/loggers@1.0.0-beta.0
|
|
80
36
|
|
|
81
37
|
## 0.22.2
|
|
82
38
|
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -76,9 +76,9 @@ function getAuthEntrypoint() {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const serverConfig = mastra.getServer()
|
|
79
|
-
if (serverConfig && serverConfig.
|
|
80
|
-
const auth = serverConfig.
|
|
81
|
-
serverConfig.
|
|
79
|
+
if (serverConfig && serverConfig.auth) {
|
|
80
|
+
const auth = serverConfig.auth
|
|
81
|
+
serverConfig.auth = new MastraCloudAuth(auth)
|
|
82
82
|
}
|
|
83
83
|
`;
|
|
84
84
|
}
|
|
@@ -142,7 +142,7 @@ var RedisTransport = class extends logger$1.LoggerTransport {
|
|
|
142
142
|
await closeLogger();
|
|
143
143
|
cb(err);
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
listLogs(_args) {
|
|
146
146
|
return Promise.resolve({
|
|
147
147
|
logs: [],
|
|
148
148
|
total: 0,
|
|
@@ -151,7 +151,7 @@ var RedisTransport = class extends logger$1.LoggerTransport {
|
|
|
151
151
|
hasMore: false
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
listLogsByRunId(_args) {
|
|
155
155
|
return Promise.resolve({
|
|
156
156
|
logs: [],
|
|
157
157
|
total: 0,
|
|
@@ -322,11 +322,6 @@ var CloudDeployer = class extends deployer.Deployer {
|
|
|
322
322
|
}
|
|
323
323
|
async deploy(_outputDirectory) {
|
|
324
324
|
}
|
|
325
|
-
async writeInstrumentationFile(outputDirectory) {
|
|
326
|
-
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
327
|
-
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
328
|
-
await esm.copy(path.join(__dirname, "../templates", "instrumentation-template.js"), instrumentationFile);
|
|
329
|
-
}
|
|
330
325
|
async writePackageJson(outputDirectory, dependencies) {
|
|
331
326
|
const versions = await esm.readJSON(path.join(path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../versions.json"));
|
|
332
327
|
for (const [pkgName, version] of Object.entries(versions || {})) {
|
|
@@ -343,7 +338,8 @@ var CloudDeployer = class extends deployer.Deployer {
|
|
|
343
338
|
const currentCwd = process.cwd();
|
|
344
339
|
process.chdir(mastraDir);
|
|
345
340
|
const mastraEntryFile = getMastraEntryFile(mastraDir);
|
|
346
|
-
const
|
|
341
|
+
const mastraAppDir = path.join(mastraDir, MASTRA_DIRECTORY);
|
|
342
|
+
const discoveredTools = this.getAllToolPaths(mastraAppDir);
|
|
347
343
|
await this._bundle(
|
|
348
344
|
this.getEntry(),
|
|
349
345
|
mastraEntryFile,
|
|
@@ -351,7 +347,7 @@ var CloudDeployer = class extends deployer.Deployer {
|
|
|
351
347
|
outputDirectory,
|
|
352
348
|
projectRoot: mastraDir
|
|
353
349
|
},
|
|
354
|
-
|
|
350
|
+
discoveredTools
|
|
355
351
|
);
|
|
356
352
|
process.chdir(currentCwd);
|
|
357
353
|
}
|
|
@@ -366,10 +362,8 @@ import { mastra } from '#mastra';
|
|
|
366
362
|
import { MultiLogger } from '@mastra/core/logger';
|
|
367
363
|
import { PinoLogger } from '@mastra/loggers';
|
|
368
364
|
import { HttpTransport } from '@mastra/loggers/http';
|
|
369
|
-
import { evaluate } from '@mastra/core/eval';
|
|
370
|
-
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
371
365
|
import { LibSQLStore, LibSQLVector } from '@mastra/libsql';
|
|
372
|
-
import { scoreTracesWorkflow } from '@mastra/core/
|
|
366
|
+
import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
|
|
373
367
|
const startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();
|
|
374
368
|
const createNodeServerStartTime = Date.now();
|
|
375
369
|
|
|
@@ -416,50 +410,18 @@ if (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {
|
|
|
416
410
|
const { MastraStorage } = await import('@mastra/core/storage');
|
|
417
411
|
logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)
|
|
418
412
|
const storage = new LibSQLStore({
|
|
413
|
+
id: 'mastra-cloud-storage-libsql',
|
|
419
414
|
url: process.env.MASTRA_STORAGE_URL,
|
|
420
415
|
authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,
|
|
421
416
|
})
|
|
422
417
|
const vector = new LibSQLVector({
|
|
418
|
+
id: 'mastra-cloud-storage-libsql-vector',
|
|
423
419
|
connectionUrl: process.env.MASTRA_STORAGE_URL,
|
|
424
420
|
authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,
|
|
425
421
|
})
|
|
426
422
|
|
|
427
423
|
await storage.init()
|
|
428
424
|
mastra?.setStorage(storage)
|
|
429
|
-
|
|
430
|
-
mastra?.memory?.setStorage(storage)
|
|
431
|
-
mastra?.memory?.setVector(vector)
|
|
432
|
-
|
|
433
|
-
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
434
|
-
evaluate({
|
|
435
|
-
agentName,
|
|
436
|
-
input,
|
|
437
|
-
metric,
|
|
438
|
-
output,
|
|
439
|
-
runId,
|
|
440
|
-
globalRunId: runId,
|
|
441
|
-
instructions,
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
445
|
-
if (mastra?.storage) {
|
|
446
|
-
await mastra.storage.insert({
|
|
447
|
-
tableName: MastraStorage.TABLE_EVALS,
|
|
448
|
-
record: {
|
|
449
|
-
input: traceObject.input,
|
|
450
|
-
output: traceObject.output,
|
|
451
|
-
result: JSON.stringify(traceObject.result),
|
|
452
|
-
agent_name: traceObject.agentName,
|
|
453
|
-
metric_name: traceObject.metricName,
|
|
454
|
-
instructions: traceObject.instructions,
|
|
455
|
-
test_info: null,
|
|
456
|
-
global_run_id: traceObject.globalRunId,
|
|
457
|
-
run_id: traceObject.runId,
|
|
458
|
-
created_at: new Date().toISOString(),
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
425
|
}
|
|
464
426
|
|
|
465
427
|
if (mastra?.getStorage()) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/auth.ts","../src/utils/constants.ts","../src/utils/logger.ts","../src/utils/execa.ts","../src/utils/deps.ts","../src/utils/file.ts","../src/utils/report.ts","../src/index.ts"],"names":["os","createClient","LoggerTransport","resolve","PinoLogger","Transform","execa","fs","join","error","MastraError","FileService","Deployer","dirname","fileURLToPath","copy","readJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,iBAAA,GAAoB;AAClC,EAAA,OAAO;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,EAaC,OAAA,CAAQ,IAAI,oBAAA,GAAuB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,oBAAoB,QAAQ,EAAE;AAAA,QAAA,EAClG,OAAA,CAAQ,IAAI,kBAAA,GAAqB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,kBAAkB,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AA0BxG;ACvCO,IAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,KAAA,KAAU,MAAA;AACpC,IAAM,OAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAA,IAAW,EAAA;AAC/C,IAAM,UAAA,GAAqB,OAAA,CAAQ,GAAA,CAAI,UAAA,IAAc,EAAA;AACrD,IAAM,QAAA,GAAmB,OAAA,CAAQ,GAAA,CAAI,QAAA,IAAY,EAAA;AACjD,IAAM,SAAA,GAAoB,OAAA,CAAQ,GAAA,CAAI,SAAA,IAAa,EAAA;AACnD,IAAM,aAAA,GAAwB,OAAA,CAAQ,GAAA,CAAI,aAAA,IAAiB,wBAAA;AAG3D,IAAM,eAAA,GAA0B,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB,EAAA;AAC/D,IAAM,gBAAA,GAA2B,OAA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;AAAA;AAAA,aAAA,EAUN,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAWT,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EAItB;AACF","file":"index.cjs","sourcesContent":["export function getAuthEntrypoint() {\n return `\n import { MastraAuthProvider } from '@mastra/core/server';\n\n class MastraCloudAuth extends MastraAuthProvider {\n constructor (auth) {\n super()\n this.auth = auth\n }\n\n async authenticateToken (...args) {\n if (typeof args[0] === 'string') {\n const token = args[0].replace('Bearer ', '');\n const validTokens = [];\n ${process.env.PLAYGROUND_JWT_TOKEN ? `validTokens.push('${process.env.PLAYGROUND_JWT_TOKEN}');` : ''}\n ${process.env.BUSINESS_JWT_TOKEN ? `validTokens.push('${process.env.BUSINESS_JWT_TOKEN}');` : ''}\n \n if (validTokens.includes(token)) {\n return { id: 'business-api' }\n }\n }\n return this.auth.authenticateToken(...args)\n }\n\n async authorizeUser (...args) {\n if (args[1] && args[1].path === '/api') {\n return true\n }\n if (args[0] && args[0].id === 'business-api') {\n return true\n }\n return this.auth.authorizeUser(...args)\n }\n }\n\n const serverConfig = mastra.getServer()\n if (serverConfig && serverConfig.experimental_auth) {\n const auth = serverConfig.experimental_auth\n serverConfig.experimental_auth = new MastraCloudAuth(auth)\n }\n `;\n}\n","import os from 'os';\n\nexport const LOCAL = process.env.LOCAL === 'true';\nexport const TEAM_ID: string = process.env.TEAM_ID ?? '';\nexport const PROJECT_ID: string = process.env.PROJECT_ID ?? '';\nexport const BUILD_ID: string = process.env.BUILD_ID ?? '';\nexport const BUILD_URL: string = process.env.BUILD_URL ?? '';\nexport const LOG_REDIS_URL: string = process.env.LOG_REDIS_URL ?? 'redis://localhost:6379';\nexport const BUSINESS_JWT_TOKEN: string = process.env.BUSINESS_JWT_TOKEN ?? '';\nexport const PLAYGROUND_JWT_TOKEN: string = process.env.PLAYGROUND_JWT_TOKEN ?? '';\nexport const USER_IP_ADDRESS: string = process.env.USER_IP_ADDRESS ?? '';\nexport const MASTRA_DIRECTORY: string = process.env.MASTRA_DIRECTORY ?? 'src/mastra';\nexport const PROJECT_ENV_VARS: Record<string, string> = safelyParseJson(process.env.PROJECT_ENV_VARS ?? '{}');\n\nexport const PROJECT_ROOT = LOCAL ? os.tmpdir() + '/project' : (process.env.PROJECT_ROOT ?? '/project');\n\nexport function safelyParseJson(json: string) {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n}\n","import type { TransformCallback } from 'stream';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { createClient } from 'redis';\nimport { BUILD_ID, LOG_REDIS_URL, PROJECT_ID, TEAM_ID } from './constants.js';\n\nconst redisClient = createClient({\n url: LOG_REDIS_URL,\n});\n\nclass RedisTransport extends LoggerTransport {\n _transform(chunk: any, _encoding: string, callback: TransformCallback): void {\n chunk = chunk.toString();\n const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;\n const ttl = 2 * 24 * 60 * 60; // 2 days in seconds\n const logData = typeof chunk === 'string' ? chunk : JSON.stringify(chunk);\n\n // Don't block the event loop - process logs asynchronously\n process.nextTick(async () => {\n try {\n // Connect to Redis if not already connected\n if (!redisClient.isOpen) {\n await redisClient.connect().catch(err => {\n console.error('Redis connection error:', err);\n });\n }\n\n // Use pipeline to batch Redis operations\n const pipeline = redisClient.multi();\n pipeline.rPush(logKey, logData);\n pipeline.expire(logKey, ttl);\n await pipeline.exec();\n } catch (err) {\n console.error('Redis logging error:', err);\n }\n });\n\n // Immediately pass through the chunk without waiting\n callback(null, chunk);\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null | undefined) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n async _flush(): Promise<void> {\n // // Ensure the pipeline is closed and flushed\n // redisClient.quit().catch(err => {\n // console.error('Redis connection error:', err);\n // });\n // callback();\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n\n async _destroy(err: Error, cb: Function) {\n await closeLogger();\n cb(err);\n }\n\n getLogs(_args: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n\n getLogsByRunId(_args?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n}\n\nexport const transport = new RedisTransport();\n\nexport const closeLogger = async () => {\n if (redisClient.isOpen) {\n setTimeout(async () => {\n await redisClient.quit();\n }, 10);\n }\n};\n\nexport const logger = new PinoLogger({\n level: 'info',\n transports: {\n redis: transport,\n },\n});\n","import { Transform } from 'stream';\nimport { execa } from 'execa';\nimport { PROJECT_ENV_VARS, PROJECT_ROOT } from './constants.js';\nimport { logger } from './logger.js';\n\nexport const createPinoStream = () => {\n return new Transform({\n transform(chunk, encoding, callback) {\n // Convert Buffer/string to string and trim whitespace\n const line = chunk.toString().trim();\n\n if (line) {\n // Log each line through Pino\n logger.info(line);\n }\n\n // Pass through the original data\n callback(null, chunk);\n },\n });\n};\n\nexport async function runWithExeca({\n cmd,\n args,\n cwd = process.cwd(),\n env = PROJECT_ENV_VARS,\n}: {\n cmd: string;\n args: string[];\n cwd?: string;\n env?: Record<string, string>;\n}): Promise<{ stdout?: string; stderr?: string; success: boolean; error?: Error }> {\n const pinoStream = createPinoStream();\n\n try {\n const subprocess = execa(cmd, args, {\n cwd,\n env: {\n ...process.env,\n ...env,\n },\n });\n\n // Pipe stdout and stderr through the Pino stream\n subprocess.stdout?.pipe(pinoStream);\n subprocess.stderr?.pipe(pinoStream);\n\n const { stdout, stderr, exitCode } = await subprocess;\n return { stdout, stderr, success: exitCode === 0 };\n } catch (error) {\n logger.error(`Process failed: ${error}`);\n return { success: false, error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\n\nexport function runWithChildProcess(cmd: string, args: string[]): { stdout?: string; stderr?: string } {\n const pinoStream = createPinoStream();\n\n try {\n const { stdout, stderr } = require('child_process').spawnSync(cmd, args, {\n cwd: PROJECT_ROOT,\n encoding: 'utf8',\n shell: true,\n env: {\n ...process.env,\n ...PROJECT_ENV_VARS,\n },\n maxBuffer: 1024 * 1024 * 10, // 10MB buffer\n });\n\n if (stdout) {\n pinoStream.write(stdout);\n }\n if (stderr) {\n pinoStream.write(stderr);\n }\n\n pinoStream.end();\n return { stdout, stderr };\n } catch (error) {\n logger.error('Process failed' + error);\n pinoStream.end();\n return {};\n }\n}\n","import * as fs from 'fs';\nimport { join, resolve } from 'path';\n\nimport { MastraError } from '@mastra/core/error';\nimport { runWithExeca } from './execa.js';\nimport { logger } from './logger.js';\n\nconst MEMOIZED = new Map();\n\nfunction findLockFile(dir: string): string | null {\n const lockFiles = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock'];\n for (const file of lockFiles) {\n if (fs.existsSync(join(dir, file))) {\n return file;\n }\n }\n const parentDir = resolve(dir, '..');\n if (parentDir !== dir) {\n return findLockFile(parentDir);\n }\n return null;\n}\n\nexport function detectPm({ path }: { path: string }): string {\n const cached = MEMOIZED.get(path);\n if (cached) {\n return cached;\n }\n\n const lockFile = findLockFile(path);\n let pm: string = 'npm';\n switch (lockFile) {\n case 'pnpm-lock.yaml':\n pm = 'pnpm';\n break;\n case 'package-lock.json':\n pm = 'npm';\n break;\n case 'yarn.lock':\n pm = 'yarn';\n break;\n case 'bun.lock':\n pm = 'bun';\n break;\n default:\n pm = 'npm';\n }\n\n MEMOIZED.set(path, pm);\n return pm;\n}\n\nexport async function installNodeVersion({ path }: { path: string }) {\n let nvmrcExists = false;\n let nodeVersionExists = false;\n\n try {\n fs.accessSync(join(path, '.nvmrc'));\n nvmrcExists = true;\n } catch {\n // File does not exist\n }\n\n try {\n fs.accessSync(join(path, '.node-version'));\n nodeVersionExists = true;\n } catch {\n // File does not exist\n }\n\n if (nvmrcExists || nodeVersionExists) {\n logger.info('Node version file found, installing specified Node.js version...');\n const { success, error } = await runWithExeca({\n cmd: 'n',\n args: ['auto'],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'NODE_FAIL_INSTALL_SPECIFIED_VERSION',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n }\n}\n\nexport async function installDeps({ path, pm }: { path: string; pm?: string }) {\n pm = pm ?? detectPm({ path });\n logger.info(`Installing dependencies with ${pm} in ${path}`);\n const args = ['install'];\n const { success, error } = await runWithExeca({ cmd: pm, args, cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_INSTALL_DEPS',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runInstallCommand({ path, installCommand }: { path: string; installCommand: string }) {\n logger.info(`Running install command ${installCommand} in workspace with ${path}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', installCommand], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_CUSTOM_INSTALL_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runScript({ scriptName, path, args }: { scriptName: string; path: string; args?: string[] }) {\n const pm = detectPm({ path });\n logger.info(`Running script ${scriptName} in workspace with ${pm}`);\n const { success, error } = await runWithExeca({\n cmd: pm,\n args: pm === 'npm' ? ['run', scriptName, ...(args ?? [])] : [scriptName, ...(args ?? [])],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_SCRIPT',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runBuildCommand({ command, path }: { command: string; path: string }) {\n logger.info(`Running build command ${command}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', command], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { join } from 'path';\nimport { MastraError } from '@mastra/core/error';\nimport { FileService } from '@mastra/deployer';\n\nimport { MASTRA_DIRECTORY } from './constants.js';\n\nexport function getMastraEntryFile(mastraDir: string) {\n try {\n const fileService = new FileService();\n return fileService.getFirstExistingFile([\n join(mastraDir, MASTRA_DIRECTORY, 'index.ts'),\n join(mastraDir, MASTRA_DIRECTORY, 'index.js'),\n ]);\n } catch (error) {\n throw new MastraError(\n {\n id: 'MASTRA_ENTRY_FILE_NOT_FOUND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { PROJECT_ID, BUILD_ID, BUILD_URL, USER_IP_ADDRESS } from './constants.js';\n\nexport function successEntrypoint() {\n return `\n if (process.env.CI !== 'true') {\n await fetch('${process.env.REPORTER_API_URL}', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Bearer ${process.env.REPORTER_API_URL_AUTH_TOKEN}',\n },\n body: JSON.stringify(${JSON.stringify({\n projectId: PROJECT_ID,\n buildId: BUILD_ID,\n status: 'success',\n url: BUILD_URL,\n userIpAddress: USER_IP_ADDRESS,\n })}),\n }).catch(err => {\n console.error('Failed to report build status to monitoring service', {\n error: err,\n });\n })\n }\n `;\n}\n","import { fileURLToPath } from 'node:url';\nimport { join, dirname } from 'path';\nimport { Deployer } from '@mastra/deployer';\nimport { copy, readJSON } from 'fs-extra/esm';\n\nimport { getAuthEntrypoint } from './utils/auth.js';\nimport { MASTRA_DIRECTORY, BUILD_ID, PROJECT_ID, TEAM_ID } from './utils/constants.js';\nimport { installDeps } from './utils/deps.js';\nimport { getMastraEntryFile } from './utils/file.js';\nimport { successEntrypoint } from './utils/report.js';\n\nexport class CloudDeployer extends Deployer {\n constructor() {\n super({ name: 'cloud' });\n }\n\n async deploy(_outputDirectory: string): Promise<void> {}\n async writeInstrumentationFile(outputDirectory: string) {\n const instrumentationFile = join(outputDirectory, 'instrumentation.mjs');\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n await copy(join(__dirname, '../templates', 'instrumentation-template.js'), instrumentationFile);\n }\n async writePackageJson(outputDirectory: string, dependencies: Map<string, string>) {\n const versions = (await readJSON(join(dirname(fileURLToPath(import.meta.url)), '../versions.json'))) as\n | Record<string, string>\n | undefined;\n for (const [pkgName, version] of Object.entries(versions || {})) {\n dependencies.set(pkgName, version);\n }\n\n return super.writePackageJson(outputDirectory, dependencies);\n }\n\n async lint() {}\n\n protected async installDependencies(outputDirectory: string, _rootDir = process.cwd()) {\n await installDeps({ path: join(outputDirectory, 'output'), pm: 'npm' });\n }\n\n async bundle(mastraDir: string, outputDirectory: string): Promise<void> {\n const currentCwd = process.cwd();\n process.chdir(mastraDir);\n\n const mastraEntryFile = getMastraEntryFile(mastraDir);\n\n const defaultToolsPath = join(mastraDir, MASTRA_DIRECTORY, 'tools');\n\n await this._bundle(\n this.getEntry(),\n mastraEntryFile,\n {\n outputDirectory,\n projectRoot: mastraDir,\n },\n [defaultToolsPath],\n );\n process.chdir(currentCwd);\n }\n\n getAuthEntrypoint() {\n return getAuthEntrypoint();\n }\n\n private getEntry(): string {\n return `\nimport { createNodeServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { mastra } from '#mastra';\nimport { MultiLogger } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { HttpTransport } from '@mastra/loggers/http';\nimport { evaluate } from '@mastra/core/eval';\nimport { AvailableHooks, registerHook } from '@mastra/core/hooks';\nimport { LibSQLStore, LibSQLVector } from '@mastra/libsql';\nimport { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';\nconst startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();\nconst createNodeServerStartTime = Date.now();\n\nconsole.log(JSON.stringify({\n message: \"Server starting\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\nconst transports = {}\nif (process.env.CI !== 'true') {\n if (process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT) {\n transports.default = new HttpTransport({\n url: process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT,\n headers: {\n Authorization: 'Bearer ' + process.env.BUSINESS_JWT_TOKEN,\n },\n });\n }\n}\n\nconst logger = new PinoLogger({\n name: 'MastraCloud',\n transports,\n level: 'debug',\n});\nconst existingLogger = mastra?.getLogger();\nconst combinedLogger = existingLogger ? new MultiLogger([logger, existingLogger]) : logger;\n\nmastra.setLogger({ logger: combinedLogger });\n\nif (mastra?.storage) {\n mastra.storage.init()\n}\n\nif (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {\n const { MastraStorage } = await import('@mastra/core/storage');\n logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)\n const storage = new LibSQLStore({\n url: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n const vector = new LibSQLVector({\n connectionUrl: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n\n await storage.init()\n mastra?.setStorage(storage)\n\n mastra?.memory?.setStorage(storage)\n mastra?.memory?.setVector(vector)\n\n registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {\n evaluate({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId: runId,\n instructions,\n });\n });\n registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {\n if (mastra?.storage) {\n await mastra.storage.insert({\n tableName: MastraStorage.TABLE_EVALS,\n record: {\n input: traceObject.input,\n output: traceObject.output,\n result: JSON.stringify(traceObject.result),\n agent_name: traceObject.agentName,\n metric_name: traceObject.metricName,\n instructions: traceObject.instructions,\n test_info: null,\n global_run_id: traceObject.globalRunId,\n run_id: traceObject.runId,\n created_at: new Date().toISOString(),\n },\n });\n }\n });\n}\n\nif (mastra?.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\n${getAuthEntrypoint()}\n\nawait createNodeServer(mastra, { playground: false, swaggerUI: false, tools: getToolExports(tools) });\n\n${successEntrypoint()}\n\nconsole.log(JSON.stringify({\n message: \"Server started\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n operation_durationMs: Date.now() - createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\n\nconsole.log(JSON.stringify({\n message: \"Runner Initialized\",\n type: \"READINESS\",\n startTime,\n durationMs: Date.now() - startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/auth.ts","../src/utils/constants.ts","../src/utils/logger.ts","../src/utils/execa.ts","../src/utils/deps.ts","../src/utils/file.ts","../src/utils/report.ts","../src/index.ts"],"names":["os","createClient","LoggerTransport","resolve","PinoLogger","Transform","execa","fs","join","error","MastraError","FileService","Deployer","readJSON","dirname","fileURLToPath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,iBAAA,GAAoB;AAClC,EAAA,OAAO;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,EAaC,OAAA,CAAQ,IAAI,oBAAA,GAAuB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,oBAAoB,QAAQ,EAAE;AAAA,QAAA,EAClG,OAAA,CAAQ,IAAI,kBAAA,GAAqB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,kBAAkB,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AA0BxG;ACvCO,IAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,KAAA,KAAU,MAAA;AACpC,IAAM,OAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAA,IAAW,EAAA;AAC/C,IAAM,UAAA,GAAqB,OAAA,CAAQ,GAAA,CAAI,UAAA,IAAc,EAAA;AACrD,IAAM,QAAA,GAAmB,OAAA,CAAQ,GAAA,CAAI,QAAA,IAAY,EAAA;AACjD,IAAM,SAAA,GAAoB,OAAA,CAAQ,GAAA,CAAI,SAAA,IAAa,EAAA;AACnD,IAAM,aAAA,GAAwB,OAAA,CAAQ,GAAA,CAAI,aAAA,IAAiB,wBAAA;AAG3D,IAAM,eAAA,GAA0B,OAAA,CAAQ,GAAA,CAAI,eAAA,IAAmB,EAAA;AAC/D,IAAM,gBAAA,GAA2B,OAAA,CAAQ,GAAA,CAAI,gBAAA,IAAoB,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A;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,MAAM,UAAU,CAAA;AAAA,EAC1B;AAAA,EAEA,iBAAA,GAAoB;AAClB,IAAA,OAAO,iBAAA,EAAkB;AAAA,EAC3B;AAAA,EAEQ,QAAA,GAAmB;AACzB,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAmBI,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA,EAoDtB,mBAAmB;;AAAA;;AAAA,EAInB,mBAAmB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAUN,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAWT,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EAItB;AACF","file":"index.cjs","sourcesContent":["export function getAuthEntrypoint() {\n return `\n import { MastraAuthProvider } from '@mastra/core/server';\n\n class MastraCloudAuth extends MastraAuthProvider {\n constructor (auth) {\n super()\n this.auth = auth\n }\n\n async authenticateToken (...args) {\n if (typeof args[0] === 'string') {\n const token = args[0].replace('Bearer ', '');\n const validTokens = [];\n ${process.env.PLAYGROUND_JWT_TOKEN ? `validTokens.push('${process.env.PLAYGROUND_JWT_TOKEN}');` : ''}\n ${process.env.BUSINESS_JWT_TOKEN ? `validTokens.push('${process.env.BUSINESS_JWT_TOKEN}');` : ''}\n \n if (validTokens.includes(token)) {\n return { id: 'business-api' }\n }\n }\n return this.auth.authenticateToken(...args)\n }\n\n async authorizeUser (...args) {\n if (args[1] && args[1].path === '/api') {\n return true\n }\n if (args[0] && args[0].id === 'business-api') {\n return true\n }\n return this.auth.authorizeUser(...args)\n }\n }\n\n const serverConfig = mastra.getServer()\n if (serverConfig && serverConfig.auth) {\n const auth = serverConfig.auth\n serverConfig.auth = new MastraCloudAuth(auth)\n }\n `;\n}\n","import os from 'os';\n\nexport const LOCAL = process.env.LOCAL === 'true';\nexport const TEAM_ID: string = process.env.TEAM_ID ?? '';\nexport const PROJECT_ID: string = process.env.PROJECT_ID ?? '';\nexport const BUILD_ID: string = process.env.BUILD_ID ?? '';\nexport const BUILD_URL: string = process.env.BUILD_URL ?? '';\nexport const LOG_REDIS_URL: string = process.env.LOG_REDIS_URL ?? 'redis://localhost:6379';\nexport const BUSINESS_JWT_TOKEN: string = process.env.BUSINESS_JWT_TOKEN ?? '';\nexport const PLAYGROUND_JWT_TOKEN: string = process.env.PLAYGROUND_JWT_TOKEN ?? '';\nexport const USER_IP_ADDRESS: string = process.env.USER_IP_ADDRESS ?? '';\nexport const MASTRA_DIRECTORY: string = process.env.MASTRA_DIRECTORY ?? 'src/mastra';\nexport const PROJECT_ENV_VARS: Record<string, string> = safelyParseJson(process.env.PROJECT_ENV_VARS ?? '{}');\n\nexport const PROJECT_ROOT = LOCAL ? os.tmpdir() + '/project' : (process.env.PROJECT_ROOT ?? '/project');\n\nexport function safelyParseJson(json: string) {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n}\n","import type { TransformCallback } from 'stream';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { createClient } from 'redis';\nimport { BUILD_ID, LOG_REDIS_URL, PROJECT_ID, TEAM_ID } from './constants.js';\n\nconst redisClient = createClient({\n url: LOG_REDIS_URL,\n});\n\nclass RedisTransport extends LoggerTransport {\n _transform(chunk: any, _encoding: string, callback: TransformCallback): void {\n chunk = chunk.toString();\n const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;\n const ttl = 2 * 24 * 60 * 60; // 2 days in seconds\n const logData = typeof chunk === 'string' ? chunk : JSON.stringify(chunk);\n\n // Don't block the event loop - process logs asynchronously\n process.nextTick(async () => {\n try {\n // Connect to Redis if not already connected\n if (!redisClient.isOpen) {\n await redisClient.connect().catch(err => {\n console.error('Redis connection error:', err);\n });\n }\n\n // Use pipeline to batch Redis operations\n const pipeline = redisClient.multi();\n pipeline.rPush(logKey, logData);\n pipeline.expire(logKey, ttl);\n await pipeline.exec();\n } catch (err) {\n console.error('Redis logging error:', err);\n }\n });\n\n // Immediately pass through the chunk without waiting\n callback(null, chunk);\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null | undefined) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n async _flush(): Promise<void> {\n // // Ensure the pipeline is closed and flushed\n // redisClient.quit().catch(err => {\n // console.error('Redis connection error:', err);\n // });\n // callback();\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n\n async _destroy(err: Error, cb: Function) {\n await closeLogger();\n cb(err);\n }\n\n listLogs(_args: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n\n listLogsByRunId(_args?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n}\n\nexport const transport = new RedisTransport();\n\nexport const closeLogger = async () => {\n if (redisClient.isOpen) {\n setTimeout(async () => {\n await redisClient.quit();\n }, 10);\n }\n};\n\nexport const logger = new PinoLogger({\n level: 'info',\n transports: {\n redis: transport,\n },\n});\n","import { Transform } from 'stream';\nimport { execa } from 'execa';\nimport { PROJECT_ENV_VARS, PROJECT_ROOT } from './constants.js';\nimport { logger } from './logger.js';\n\nexport const createPinoStream = () => {\n return new Transform({\n transform(chunk, encoding, callback) {\n // Convert Buffer/string to string and trim whitespace\n const line = chunk.toString().trim();\n\n if (line) {\n // Log each line through Pino\n logger.info(line);\n }\n\n // Pass through the original data\n callback(null, chunk);\n },\n });\n};\n\nexport async function runWithExeca({\n cmd,\n args,\n cwd = process.cwd(),\n env = PROJECT_ENV_VARS,\n}: {\n cmd: string;\n args: string[];\n cwd?: string;\n env?: Record<string, string>;\n}): Promise<{ stdout?: string; stderr?: string; success: boolean; error?: Error }> {\n const pinoStream = createPinoStream();\n\n try {\n const subprocess = execa(cmd, args, {\n cwd,\n env: {\n ...process.env,\n ...env,\n },\n });\n\n // Pipe stdout and stderr through the Pino stream\n subprocess.stdout?.pipe(pinoStream);\n subprocess.stderr?.pipe(pinoStream);\n\n const { stdout, stderr, exitCode } = await subprocess;\n return { stdout, stderr, success: exitCode === 0 };\n } catch (error) {\n logger.error(`Process failed: ${error}`);\n return { success: false, error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\n\nexport function runWithChildProcess(cmd: string, args: string[]): { stdout?: string; stderr?: string } {\n const pinoStream = createPinoStream();\n\n try {\n const { stdout, stderr } = require('child_process').spawnSync(cmd, args, {\n cwd: PROJECT_ROOT,\n encoding: 'utf8',\n shell: true,\n env: {\n ...process.env,\n ...PROJECT_ENV_VARS,\n },\n maxBuffer: 1024 * 1024 * 10, // 10MB buffer\n });\n\n if (stdout) {\n pinoStream.write(stdout);\n }\n if (stderr) {\n pinoStream.write(stderr);\n }\n\n pinoStream.end();\n return { stdout, stderr };\n } catch (error) {\n logger.error('Process failed' + error);\n pinoStream.end();\n return {};\n }\n}\n","import * as fs from 'fs';\nimport { join, resolve } from 'path';\n\nimport { MastraError } from '@mastra/core/error';\nimport { runWithExeca } from './execa.js';\nimport { logger } from './logger.js';\n\nconst MEMOIZED = new Map();\n\nfunction findLockFile(dir: string): string | null {\n const lockFiles = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock'];\n for (const file of lockFiles) {\n if (fs.existsSync(join(dir, file))) {\n return file;\n }\n }\n const parentDir = resolve(dir, '..');\n if (parentDir !== dir) {\n return findLockFile(parentDir);\n }\n return null;\n}\n\nexport function detectPm({ path }: { path: string }): string {\n const cached = MEMOIZED.get(path);\n if (cached) {\n return cached;\n }\n\n const lockFile = findLockFile(path);\n let pm: string = 'npm';\n switch (lockFile) {\n case 'pnpm-lock.yaml':\n pm = 'pnpm';\n break;\n case 'package-lock.json':\n pm = 'npm';\n break;\n case 'yarn.lock':\n pm = 'yarn';\n break;\n case 'bun.lock':\n pm = 'bun';\n break;\n default:\n pm = 'npm';\n }\n\n MEMOIZED.set(path, pm);\n return pm;\n}\n\nexport async function installNodeVersion({ path }: { path: string }) {\n let nvmrcExists = false;\n let nodeVersionExists = false;\n\n try {\n fs.accessSync(join(path, '.nvmrc'));\n nvmrcExists = true;\n } catch {\n // File does not exist\n }\n\n try {\n fs.accessSync(join(path, '.node-version'));\n nodeVersionExists = true;\n } catch {\n // File does not exist\n }\n\n if (nvmrcExists || nodeVersionExists) {\n logger.info('Node version file found, installing specified Node.js version...');\n const { success, error } = await runWithExeca({\n cmd: 'n',\n args: ['auto'],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'NODE_FAIL_INSTALL_SPECIFIED_VERSION',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n }\n}\n\nexport async function installDeps({ path, pm }: { path: string; pm?: string }) {\n pm = pm ?? detectPm({ path });\n logger.info(`Installing dependencies with ${pm} in ${path}`);\n const args = ['install'];\n const { success, error } = await runWithExeca({ cmd: pm, args, cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_INSTALL_DEPS',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runInstallCommand({ path, installCommand }: { path: string; installCommand: string }) {\n logger.info(`Running install command ${installCommand} in workspace with ${path}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', installCommand], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_CUSTOM_INSTALL_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runScript({ scriptName, path, args }: { scriptName: string; path: string; args?: string[] }) {\n const pm = detectPm({ path });\n logger.info(`Running script ${scriptName} in workspace with ${pm}`);\n const { success, error } = await runWithExeca({\n cmd: pm,\n args: pm === 'npm' ? ['run', scriptName, ...(args ?? [])] : [scriptName, ...(args ?? [])],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_SCRIPT',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runBuildCommand({ command, path }: { command: string; path: string }) {\n logger.info(`Running build command ${command}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', command], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { join } from 'path';\nimport { MastraError } from '@mastra/core/error';\nimport { FileService } from '@mastra/deployer';\n\nimport { MASTRA_DIRECTORY } from './constants.js';\n\nexport function getMastraEntryFile(mastraDir: string) {\n try {\n const fileService = new FileService();\n return fileService.getFirstExistingFile([\n join(mastraDir, MASTRA_DIRECTORY, 'index.ts'),\n join(mastraDir, MASTRA_DIRECTORY, 'index.js'),\n ]);\n } catch (error) {\n throw new MastraError(\n {\n id: 'MASTRA_ENTRY_FILE_NOT_FOUND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { PROJECT_ID, BUILD_ID, BUILD_URL, USER_IP_ADDRESS } from './constants.js';\n\nexport function successEntrypoint() {\n return `\n if (process.env.CI !== 'true') {\n await fetch('${process.env.REPORTER_API_URL}', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Bearer ${process.env.REPORTER_API_URL_AUTH_TOKEN}',\n },\n body: JSON.stringify(${JSON.stringify({\n projectId: PROJECT_ID,\n buildId: BUILD_ID,\n status: 'success',\n url: BUILD_URL,\n userIpAddress: USER_IP_ADDRESS,\n })}),\n }).catch(err => {\n console.error('Failed to report build status to monitoring service', {\n error: err,\n });\n })\n }\n `;\n}\n","import { fileURLToPath } from 'node:url';\nimport { join, dirname } from 'path';\nimport { Deployer } from '@mastra/deployer';\nimport { readJSON } from 'fs-extra/esm';\n\nimport { getAuthEntrypoint } from './utils/auth.js';\nimport { MASTRA_DIRECTORY, BUILD_ID, PROJECT_ID, TEAM_ID } from './utils/constants.js';\nimport { installDeps } from './utils/deps.js';\nimport { getMastraEntryFile } from './utils/file.js';\nimport { successEntrypoint } from './utils/report.js';\n\nexport class CloudDeployer extends Deployer {\n constructor() {\n super({ name: 'cloud' });\n }\n\n async deploy(_outputDirectory: string): Promise<void> {}\n async writePackageJson(outputDirectory: string, dependencies: Map<string, string>) {\n const versions = (await readJSON(join(dirname(fileURLToPath(import.meta.url)), '../versions.json'))) as\n | Record<string, string>\n | undefined;\n for (const [pkgName, version] of Object.entries(versions || {})) {\n dependencies.set(pkgName, version);\n }\n\n return super.writePackageJson(outputDirectory, dependencies);\n }\n\n async lint() {}\n\n protected async installDependencies(outputDirectory: string, _rootDir = process.cwd()) {\n await installDeps({ path: join(outputDirectory, 'output'), pm: 'npm' });\n }\n\n async bundle(mastraDir: string, outputDirectory: string): Promise<void> {\n const currentCwd = process.cwd();\n process.chdir(mastraDir);\n\n const mastraEntryFile = getMastraEntryFile(mastraDir);\n\n const mastraAppDir = join(mastraDir, MASTRA_DIRECTORY);\n\n // Use the getAllToolPaths method to prepare tools paths\n const discoveredTools = this.getAllToolPaths(mastraAppDir);\n\n await this._bundle(\n this.getEntry(),\n mastraEntryFile,\n {\n outputDirectory,\n projectRoot: mastraDir,\n },\n discoveredTools,\n );\n process.chdir(currentCwd);\n }\n\n getAuthEntrypoint() {\n return getAuthEntrypoint();\n }\n\n private getEntry(): string {\n return `\nimport { createNodeServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { mastra } from '#mastra';\nimport { MultiLogger } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { HttpTransport } from '@mastra/loggers/http';\nimport { LibSQLStore, LibSQLVector } from '@mastra/libsql';\nimport { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\nconst startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();\nconst createNodeServerStartTime = Date.now();\n\nconsole.log(JSON.stringify({\n message: \"Server starting\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\nconst transports = {}\nif (process.env.CI !== 'true') {\n if (process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT) {\n transports.default = new HttpTransport({\n url: process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT,\n headers: {\n Authorization: 'Bearer ' + process.env.BUSINESS_JWT_TOKEN,\n },\n });\n }\n}\n\nconst logger = new PinoLogger({\n name: 'MastraCloud',\n transports,\n level: 'debug',\n});\nconst existingLogger = mastra?.getLogger();\nconst combinedLogger = existingLogger ? new MultiLogger([logger, existingLogger]) : logger;\n\nmastra.setLogger({ logger: combinedLogger });\n\nif (mastra?.storage) {\n mastra.storage.init()\n}\n\nif (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {\n const { MastraStorage } = await import('@mastra/core/storage');\n logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)\n const storage = new LibSQLStore({\n id: 'mastra-cloud-storage-libsql',\n url: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n const vector = new LibSQLVector({\n id: 'mastra-cloud-storage-libsql-vector',\n connectionUrl: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n\n await storage.init()\n mastra?.setStorage(storage)\n}\n\nif (mastra?.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\n${getAuthEntrypoint()}\n\nawait createNodeServer(mastra, { playground: false, swaggerUI: false, tools: getToolExports(tools) });\n\n${successEntrypoint()}\n\nconsole.log(JSON.stringify({\n message: \"Server started\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n operation_durationMs: Date.now() - createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\n\nconsole.log(JSON.stringify({\n message: \"Runner Initialized\",\n type: \"READINESS\",\n startTime,\n durationMs: Date.now() - startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n`;\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Deployer } from '@mastra/deployer';
|
|
|
2
2
|
export declare class CloudDeployer extends Deployer {
|
|
3
3
|
constructor();
|
|
4
4
|
deploy(_outputDirectory: string): Promise<void>;
|
|
5
|
-
writeInstrumentationFile(outputDirectory: string): Promise<void>;
|
|
6
5
|
writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
|
|
7
6
|
lint(): Promise<void>;
|
|
8
7
|
protected installDependencies(outputDirectory: string, _rootDir?: string): Promise<void>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C,qBAAa,aAAc,SAAQ,QAAQ;;IAKnC,MAAM,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C,qBAAa,aAAc,SAAQ,QAAQ;;IAKnC,MAAM,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC/C,gBAAgB,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAW3E,IAAI;cAEM,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,SAAgB;IAI/E,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvE,iBAAiB;IAIjB,OAAO,CAAC,QAAQ;CA4GjB"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
2
|
import { join, dirname, resolve } from 'path';
|
|
3
3
|
import { Deployer, FileService } from '@mastra/deployer';
|
|
4
|
-
import {
|
|
4
|
+
import { readJSON } from 'fs-extra/esm';
|
|
5
5
|
import os from 'os';
|
|
6
6
|
import * as fs from 'fs';
|
|
7
7
|
import { MastraError } from '@mastra/core/error';
|
|
@@ -50,9 +50,9 @@ function getAuthEntrypoint() {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const serverConfig = mastra.getServer()
|
|
53
|
-
if (serverConfig && serverConfig.
|
|
54
|
-
const auth = serverConfig.
|
|
55
|
-
serverConfig.
|
|
53
|
+
if (serverConfig && serverConfig.auth) {
|
|
54
|
+
const auth = serverConfig.auth
|
|
55
|
+
serverConfig.auth = new MastraCloudAuth(auth)
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
58
|
}
|
|
@@ -116,7 +116,7 @@ var RedisTransport = class extends LoggerTransport {
|
|
|
116
116
|
await closeLogger();
|
|
117
117
|
cb(err);
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
listLogs(_args) {
|
|
120
120
|
return Promise.resolve({
|
|
121
121
|
logs: [],
|
|
122
122
|
total: 0,
|
|
@@ -125,7 +125,7 @@ var RedisTransport = class extends LoggerTransport {
|
|
|
125
125
|
hasMore: false
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
listLogsByRunId(_args) {
|
|
129
129
|
return Promise.resolve({
|
|
130
130
|
logs: [],
|
|
131
131
|
total: 0,
|
|
@@ -296,11 +296,6 @@ var CloudDeployer = class extends Deployer {
|
|
|
296
296
|
}
|
|
297
297
|
async deploy(_outputDirectory) {
|
|
298
298
|
}
|
|
299
|
-
async writeInstrumentationFile(outputDirectory) {
|
|
300
|
-
const instrumentationFile = join(outputDirectory, "instrumentation.mjs");
|
|
301
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
302
|
-
await copy(join(__dirname, "../templates", "instrumentation-template.js"), instrumentationFile);
|
|
303
|
-
}
|
|
304
299
|
async writePackageJson(outputDirectory, dependencies) {
|
|
305
300
|
const versions = await readJSON(join(dirname(fileURLToPath(import.meta.url)), "../versions.json"));
|
|
306
301
|
for (const [pkgName, version] of Object.entries(versions || {})) {
|
|
@@ -317,7 +312,8 @@ var CloudDeployer = class extends Deployer {
|
|
|
317
312
|
const currentCwd = process.cwd();
|
|
318
313
|
process.chdir(mastraDir);
|
|
319
314
|
const mastraEntryFile = getMastraEntryFile(mastraDir);
|
|
320
|
-
const
|
|
315
|
+
const mastraAppDir = join(mastraDir, MASTRA_DIRECTORY);
|
|
316
|
+
const discoveredTools = this.getAllToolPaths(mastraAppDir);
|
|
321
317
|
await this._bundle(
|
|
322
318
|
this.getEntry(),
|
|
323
319
|
mastraEntryFile,
|
|
@@ -325,7 +321,7 @@ var CloudDeployer = class extends Deployer {
|
|
|
325
321
|
outputDirectory,
|
|
326
322
|
projectRoot: mastraDir
|
|
327
323
|
},
|
|
328
|
-
|
|
324
|
+
discoveredTools
|
|
329
325
|
);
|
|
330
326
|
process.chdir(currentCwd);
|
|
331
327
|
}
|
|
@@ -340,10 +336,8 @@ import { mastra } from '#mastra';
|
|
|
340
336
|
import { MultiLogger } from '@mastra/core/logger';
|
|
341
337
|
import { PinoLogger } from '@mastra/loggers';
|
|
342
338
|
import { HttpTransport } from '@mastra/loggers/http';
|
|
343
|
-
import { evaluate } from '@mastra/core/eval';
|
|
344
|
-
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
345
339
|
import { LibSQLStore, LibSQLVector } from '@mastra/libsql';
|
|
346
|
-
import { scoreTracesWorkflow } from '@mastra/core/
|
|
340
|
+
import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
|
|
347
341
|
const startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();
|
|
348
342
|
const createNodeServerStartTime = Date.now();
|
|
349
343
|
|
|
@@ -390,50 +384,18 @@ if (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {
|
|
|
390
384
|
const { MastraStorage } = await import('@mastra/core/storage');
|
|
391
385
|
logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)
|
|
392
386
|
const storage = new LibSQLStore({
|
|
387
|
+
id: 'mastra-cloud-storage-libsql',
|
|
393
388
|
url: process.env.MASTRA_STORAGE_URL,
|
|
394
389
|
authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,
|
|
395
390
|
})
|
|
396
391
|
const vector = new LibSQLVector({
|
|
392
|
+
id: 'mastra-cloud-storage-libsql-vector',
|
|
397
393
|
connectionUrl: process.env.MASTRA_STORAGE_URL,
|
|
398
394
|
authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,
|
|
399
395
|
})
|
|
400
396
|
|
|
401
397
|
await storage.init()
|
|
402
398
|
mastra?.setStorage(storage)
|
|
403
|
-
|
|
404
|
-
mastra?.memory?.setStorage(storage)
|
|
405
|
-
mastra?.memory?.setVector(vector)
|
|
406
|
-
|
|
407
|
-
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
408
|
-
evaluate({
|
|
409
|
-
agentName,
|
|
410
|
-
input,
|
|
411
|
-
metric,
|
|
412
|
-
output,
|
|
413
|
-
runId,
|
|
414
|
-
globalRunId: runId,
|
|
415
|
-
instructions,
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
419
|
-
if (mastra?.storage) {
|
|
420
|
-
await mastra.storage.insert({
|
|
421
|
-
tableName: MastraStorage.TABLE_EVALS,
|
|
422
|
-
record: {
|
|
423
|
-
input: traceObject.input,
|
|
424
|
-
output: traceObject.output,
|
|
425
|
-
result: JSON.stringify(traceObject.result),
|
|
426
|
-
agent_name: traceObject.agentName,
|
|
427
|
-
metric_name: traceObject.metricName,
|
|
428
|
-
instructions: traceObject.instructions,
|
|
429
|
-
test_info: null,
|
|
430
|
-
global_run_id: traceObject.globalRunId,
|
|
431
|
-
run_id: traceObject.runId,
|
|
432
|
-
created_at: new Date().toISOString(),
|
|
433
|
-
},
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
399
|
}
|
|
438
400
|
|
|
439
401
|
if (mastra?.getStorage()) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/auth.ts","../src/utils/constants.ts","../src/utils/logger.ts","../src/utils/execa.ts","../src/utils/deps.ts","../src/utils/file.ts","../src/utils/report.ts","../src/index.ts"],"names":["resolve","join","MastraError"],"mappings":";;;;;;;;;;;;;;;;AAAO,SAAS,iBAAA,GAAoB;AAClC,EAAA,OAAO;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,EAaC,OAAA,CAAQ,IAAI,oBAAA,GAAuB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,oBAAoB,QAAQ,EAAE;AAAA,QAAA,EAClG,OAAA,CAAQ,IAAI,kBAAA,GAAqB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,kBAAkB,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AA0BxG;ACvCO,IAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,KAAA,KAAU,MAAA;AACpC,IAAM,OAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAA,IAAW,EAAA;AAC/C,IAAM,UAAA,GAAqB,OAAA,CAAQ,GAAA,CAAI,UAAA,IAAc,EAAA;AACrD,IAAM,QAAA,GAAmB,O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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA,EAoFtB,mBAAmB;;AAAA;;AAAA,EAInB,mBAAmB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAUN,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAWT,OAAO,CAAA;AAAA,gBAAA,EACJ,UAAU,CAAA;AAAA,cAAA,EACZ,QAAQ,CAAA;AAAA;AAAA;AAAA,CAAA;AAAA,EAItB;AACF","file":"index.js","sourcesContent":["export function getAuthEntrypoint() {\n return `\n import { MastraAuthProvider } from '@mastra/core/server';\n\n class MastraCloudAuth extends MastraAuthProvider {\n constructor (auth) {\n super()\n this.auth = auth\n }\n\n async authenticateToken (...args) {\n if (typeof args[0] === 'string') {\n const token = args[0].replace('Bearer ', '');\n const validTokens = [];\n ${process.env.PLAYGROUND_JWT_TOKEN ? `validTokens.push('${process.env.PLAYGROUND_JWT_TOKEN}');` : ''}\n ${process.env.BUSINESS_JWT_TOKEN ? `validTokens.push('${process.env.BUSINESS_JWT_TOKEN}');` : ''}\n \n if (validTokens.includes(token)) {\n return { id: 'business-api' }\n }\n }\n return this.auth.authenticateToken(...args)\n }\n\n async authorizeUser (...args) {\n if (args[1] && args[1].path === '/api') {\n return true\n }\n if (args[0] && args[0].id === 'business-api') {\n return true\n }\n return this.auth.authorizeUser(...args)\n }\n }\n\n const serverConfig = mastra.getServer()\n if (serverConfig && serverConfig.experimental_auth) {\n const auth = serverConfig.experimental_auth\n serverConfig.experimental_auth = new MastraCloudAuth(auth)\n }\n `;\n}\n","import os from 'os';\n\nexport const LOCAL = process.env.LOCAL === 'true';\nexport const TEAM_ID: string = process.env.TEAM_ID ?? '';\nexport const PROJECT_ID: string = process.env.PROJECT_ID ?? '';\nexport const BUILD_ID: string = process.env.BUILD_ID ?? '';\nexport const BUILD_URL: string = process.env.BUILD_URL ?? '';\nexport const LOG_REDIS_URL: string = process.env.LOG_REDIS_URL ?? 'redis://localhost:6379';\nexport const BUSINESS_JWT_TOKEN: string = process.env.BUSINESS_JWT_TOKEN ?? '';\nexport const PLAYGROUND_JWT_TOKEN: string = process.env.PLAYGROUND_JWT_TOKEN ?? '';\nexport const USER_IP_ADDRESS: string = process.env.USER_IP_ADDRESS ?? '';\nexport const MASTRA_DIRECTORY: string = process.env.MASTRA_DIRECTORY ?? 'src/mastra';\nexport const PROJECT_ENV_VARS: Record<string, string> = safelyParseJson(process.env.PROJECT_ENV_VARS ?? '{}');\n\nexport const PROJECT_ROOT = LOCAL ? os.tmpdir() + '/project' : (process.env.PROJECT_ROOT ?? '/project');\n\nexport function safelyParseJson(json: string) {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n}\n","import type { TransformCallback } from 'stream';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { createClient } from 'redis';\nimport { BUILD_ID, LOG_REDIS_URL, PROJECT_ID, TEAM_ID } from './constants.js';\n\nconst redisClient = createClient({\n url: LOG_REDIS_URL,\n});\n\nclass RedisTransport extends LoggerTransport {\n _transform(chunk: any, _encoding: string, callback: TransformCallback): void {\n chunk = chunk.toString();\n const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;\n const ttl = 2 * 24 * 60 * 60; // 2 days in seconds\n const logData = typeof chunk === 'string' ? chunk : JSON.stringify(chunk);\n\n // Don't block the event loop - process logs asynchronously\n process.nextTick(async () => {\n try {\n // Connect to Redis if not already connected\n if (!redisClient.isOpen) {\n await redisClient.connect().catch(err => {\n console.error('Redis connection error:', err);\n });\n }\n\n // Use pipeline to batch Redis operations\n const pipeline = redisClient.multi();\n pipeline.rPush(logKey, logData);\n pipeline.expire(logKey, ttl);\n await pipeline.exec();\n } catch (err) {\n console.error('Redis logging error:', err);\n }\n });\n\n // Immediately pass through the chunk without waiting\n callback(null, chunk);\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null | undefined) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n async _flush(): Promise<void> {\n // // Ensure the pipeline is closed and flushed\n // redisClient.quit().catch(err => {\n // console.error('Redis connection error:', err);\n // });\n // callback();\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n\n async _destroy(err: Error, cb: Function) {\n await closeLogger();\n cb(err);\n }\n\n getLogs(_args: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n\n getLogsByRunId(_args?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n}\n\nexport const transport = new RedisTransport();\n\nexport const closeLogger = async () => {\n if (redisClient.isOpen) {\n setTimeout(async () => {\n await redisClient.quit();\n }, 10);\n }\n};\n\nexport const logger = new PinoLogger({\n level: 'info',\n transports: {\n redis: transport,\n },\n});\n","import { Transform } from 'stream';\nimport { execa } from 'execa';\nimport { PROJECT_ENV_VARS, PROJECT_ROOT } from './constants.js';\nimport { logger } from './logger.js';\n\nexport const createPinoStream = () => {\n return new Transform({\n transform(chunk, encoding, callback) {\n // Convert Buffer/string to string and trim whitespace\n const line = chunk.toString().trim();\n\n if (line) {\n // Log each line through Pino\n logger.info(line);\n }\n\n // Pass through the original data\n callback(null, chunk);\n },\n });\n};\n\nexport async function runWithExeca({\n cmd,\n args,\n cwd = process.cwd(),\n env = PROJECT_ENV_VARS,\n}: {\n cmd: string;\n args: string[];\n cwd?: string;\n env?: Record<string, string>;\n}): Promise<{ stdout?: string; stderr?: string; success: boolean; error?: Error }> {\n const pinoStream = createPinoStream();\n\n try {\n const subprocess = execa(cmd, args, {\n cwd,\n env: {\n ...process.env,\n ...env,\n },\n });\n\n // Pipe stdout and stderr through the Pino stream\n subprocess.stdout?.pipe(pinoStream);\n subprocess.stderr?.pipe(pinoStream);\n\n const { stdout, stderr, exitCode } = await subprocess;\n return { stdout, stderr, success: exitCode === 0 };\n } catch (error) {\n logger.error(`Process failed: ${error}`);\n return { success: false, error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\n\nexport function runWithChildProcess(cmd: string, args: string[]): { stdout?: string; stderr?: string } {\n const pinoStream = createPinoStream();\n\n try {\n const { stdout, stderr } = require('child_process').spawnSync(cmd, args, {\n cwd: PROJECT_ROOT,\n encoding: 'utf8',\n shell: true,\n env: {\n ...process.env,\n ...PROJECT_ENV_VARS,\n },\n maxBuffer: 1024 * 1024 * 10, // 10MB buffer\n });\n\n if (stdout) {\n pinoStream.write(stdout);\n }\n if (stderr) {\n pinoStream.write(stderr);\n }\n\n pinoStream.end();\n return { stdout, stderr };\n } catch (error) {\n logger.error('Process failed' + error);\n pinoStream.end();\n return {};\n }\n}\n","import * as fs from 'fs';\nimport { join, resolve } from 'path';\n\nimport { MastraError } from '@mastra/core/error';\nimport { runWithExeca } from './execa.js';\nimport { logger } from './logger.js';\n\nconst MEMOIZED = new Map();\n\nfunction findLockFile(dir: string): string | null {\n const lockFiles = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock'];\n for (const file of lockFiles) {\n if (fs.existsSync(join(dir, file))) {\n return file;\n }\n }\n const parentDir = resolve(dir, '..');\n if (parentDir !== dir) {\n return findLockFile(parentDir);\n }\n return null;\n}\n\nexport function detectPm({ path }: { path: string }): string {\n const cached = MEMOIZED.get(path);\n if (cached) {\n return cached;\n }\n\n const lockFile = findLockFile(path);\n let pm: string = 'npm';\n switch (lockFile) {\n case 'pnpm-lock.yaml':\n pm = 'pnpm';\n break;\n case 'package-lock.json':\n pm = 'npm';\n break;\n case 'yarn.lock':\n pm = 'yarn';\n break;\n case 'bun.lock':\n pm = 'bun';\n break;\n default:\n pm = 'npm';\n }\n\n MEMOIZED.set(path, pm);\n return pm;\n}\n\nexport async function installNodeVersion({ path }: { path: string }) {\n let nvmrcExists = false;\n let nodeVersionExists = false;\n\n try {\n fs.accessSync(join(path, '.nvmrc'));\n nvmrcExists = true;\n } catch {\n // File does not exist\n }\n\n try {\n fs.accessSync(join(path, '.node-version'));\n nodeVersionExists = true;\n } catch {\n // File does not exist\n }\n\n if (nvmrcExists || nodeVersionExists) {\n logger.info('Node version file found, installing specified Node.js version...');\n const { success, error } = await runWithExeca({\n cmd: 'n',\n args: ['auto'],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'NODE_FAIL_INSTALL_SPECIFIED_VERSION',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n }\n}\n\nexport async function installDeps({ path, pm }: { path: string; pm?: string }) {\n pm = pm ?? detectPm({ path });\n logger.info(`Installing dependencies with ${pm} in ${path}`);\n const args = ['install'];\n const { success, error } = await runWithExeca({ cmd: pm, args, cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_INSTALL_DEPS',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runInstallCommand({ path, installCommand }: { path: string; installCommand: string }) {\n logger.info(`Running install command ${installCommand} in workspace with ${path}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', installCommand], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_CUSTOM_INSTALL_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runScript({ scriptName, path, args }: { scriptName: string; path: string; args?: string[] }) {\n const pm = detectPm({ path });\n logger.info(`Running script ${scriptName} in workspace with ${pm}`);\n const { success, error } = await runWithExeca({\n cmd: pm,\n args: pm === 'npm' ? ['run', scriptName, ...(args ?? [])] : [scriptName, ...(args ?? [])],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_SCRIPT',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runBuildCommand({ command, path }: { command: string; path: string }) {\n logger.info(`Running build command ${command}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', command], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { join } from 'path';\nimport { MastraError } from '@mastra/core/error';\nimport { FileService } from '@mastra/deployer';\n\nimport { MASTRA_DIRECTORY } from './constants.js';\n\nexport function getMastraEntryFile(mastraDir: string) {\n try {\n const fileService = new FileService();\n return fileService.getFirstExistingFile([\n join(mastraDir, MASTRA_DIRECTORY, 'index.ts'),\n join(mastraDir, MASTRA_DIRECTORY, 'index.js'),\n ]);\n } catch (error) {\n throw new MastraError(\n {\n id: 'MASTRA_ENTRY_FILE_NOT_FOUND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { PROJECT_ID, BUILD_ID, BUILD_URL, USER_IP_ADDRESS } from './constants.js';\n\nexport function successEntrypoint() {\n return `\n if (process.env.CI !== 'true') {\n await fetch('${process.env.REPORTER_API_URL}', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Bearer ${process.env.REPORTER_API_URL_AUTH_TOKEN}',\n },\n body: JSON.stringify(${JSON.stringify({\n projectId: PROJECT_ID,\n buildId: BUILD_ID,\n status: 'success',\n url: BUILD_URL,\n userIpAddress: USER_IP_ADDRESS,\n })}),\n }).catch(err => {\n console.error('Failed to report build status to monitoring service', {\n error: err,\n });\n })\n }\n `;\n}\n","import { fileURLToPath } from 'node:url';\nimport { join, dirname } from 'path';\nimport { Deployer } from '@mastra/deployer';\nimport { copy, readJSON } from 'fs-extra/esm';\n\nimport { getAuthEntrypoint } from './utils/auth.js';\nimport { MASTRA_DIRECTORY, BUILD_ID, PROJECT_ID, TEAM_ID } from './utils/constants.js';\nimport { installDeps } from './utils/deps.js';\nimport { getMastraEntryFile } from './utils/file.js';\nimport { successEntrypoint } from './utils/report.js';\n\nexport class CloudDeployer extends Deployer {\n constructor() {\n super({ name: 'cloud' });\n }\n\n async deploy(_outputDirectory: string): Promise<void> {}\n async writeInstrumentationFile(outputDirectory: string) {\n const instrumentationFile = join(outputDirectory, 'instrumentation.mjs');\n const __dirname = dirname(fileURLToPath(import.meta.url));\n\n await copy(join(__dirname, '../templates', 'instrumentation-template.js'), instrumentationFile);\n }\n async writePackageJson(outputDirectory: string, dependencies: Map<string, string>) {\n const versions = (await readJSON(join(dirname(fileURLToPath(import.meta.url)), '../versions.json'))) as\n | Record<string, string>\n | undefined;\n for (const [pkgName, version] of Object.entries(versions || {})) {\n dependencies.set(pkgName, version);\n }\n\n return super.writePackageJson(outputDirectory, dependencies);\n }\n\n async lint() {}\n\n protected async installDependencies(outputDirectory: string, _rootDir = process.cwd()) {\n await installDeps({ path: join(outputDirectory, 'output'), pm: 'npm' });\n }\n\n async bundle(mastraDir: string, outputDirectory: string): Promise<void> {\n const currentCwd = process.cwd();\n process.chdir(mastraDir);\n\n const mastraEntryFile = getMastraEntryFile(mastraDir);\n\n const defaultToolsPath = join(mastraDir, MASTRA_DIRECTORY, 'tools');\n\n await this._bundle(\n this.getEntry(),\n mastraEntryFile,\n {\n outputDirectory,\n projectRoot: mastraDir,\n },\n [defaultToolsPath],\n );\n process.chdir(currentCwd);\n }\n\n getAuthEntrypoint() {\n return getAuthEntrypoint();\n }\n\n private getEntry(): string {\n return `\nimport { createNodeServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { mastra } from '#mastra';\nimport { MultiLogger } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { HttpTransport } from '@mastra/loggers/http';\nimport { evaluate } from '@mastra/core/eval';\nimport { AvailableHooks, registerHook } from '@mastra/core/hooks';\nimport { LibSQLStore, LibSQLVector } from '@mastra/libsql';\nimport { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';\nconst startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();\nconst createNodeServerStartTime = Date.now();\n\nconsole.log(JSON.stringify({\n message: \"Server starting\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\nconst transports = {}\nif (process.env.CI !== 'true') {\n if (process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT) {\n transports.default = new HttpTransport({\n url: process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT,\n headers: {\n Authorization: 'Bearer ' + process.env.BUSINESS_JWT_TOKEN,\n },\n });\n }\n}\n\nconst logger = new PinoLogger({\n name: 'MastraCloud',\n transports,\n level: 'debug',\n});\nconst existingLogger = mastra?.getLogger();\nconst combinedLogger = existingLogger ? new MultiLogger([logger, existingLogger]) : logger;\n\nmastra.setLogger({ logger: combinedLogger });\n\nif (mastra?.storage) {\n mastra.storage.init()\n}\n\nif (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {\n const { MastraStorage } = await import('@mastra/core/storage');\n logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)\n const storage = new LibSQLStore({\n url: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n const vector = new LibSQLVector({\n connectionUrl: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n\n await storage.init()\n mastra?.setStorage(storage)\n\n mastra?.memory?.setStorage(storage)\n mastra?.memory?.setVector(vector)\n\n registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {\n evaluate({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId: runId,\n instructions,\n });\n });\n registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {\n if (mastra?.storage) {\n await mastra.storage.insert({\n tableName: MastraStorage.TABLE_EVALS,\n record: {\n input: traceObject.input,\n output: traceObject.output,\n result: JSON.stringify(traceObject.result),\n agent_name: traceObject.agentName,\n metric_name: traceObject.metricName,\n instructions: traceObject.instructions,\n test_info: null,\n global_run_id: traceObject.globalRunId,\n run_id: traceObject.runId,\n created_at: new Date().toISOString(),\n },\n });\n }\n });\n}\n\nif (mastra?.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\n${getAuthEntrypoint()}\n\nawait createNodeServer(mastra, { playground: false, swaggerUI: false, tools: getToolExports(tools) });\n\n${successEntrypoint()}\n\nconsole.log(JSON.stringify({\n message: \"Server started\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n operation_durationMs: Date.now() - createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\n\nconsole.log(JSON.stringify({\n message: \"Runner Initialized\",\n type: \"READINESS\",\n startTime,\n durationMs: Date.now() - startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/auth.ts","../src/utils/constants.ts","../src/utils/logger.ts","../src/utils/execa.ts","../src/utils/deps.ts","../src/utils/file.ts","../src/utils/report.ts","../src/index.ts"],"names":["resolve","join","MastraError"],"mappings":";;;;;;;;;;;;;;;;AAAO,SAAS,iBAAA,GAAoB;AAClC,EAAA,OAAO;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,QAAA,EAaC,OAAA,CAAQ,IAAI,oBAAA,GAAuB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,oBAAoB,QAAQ,EAAE;AAAA,QAAA,EAClG,OAAA,CAAQ,IAAI,kBAAA,GAAqB,CAAA,kBAAA,EAAqB,QAAQ,GAAA,CAAI,kBAAkB,QAAQ,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,CAAA;AA0BxG;ACvCO,IAAM,KAAA,GAAQ,OAAA,CAAQ,GAAA,CAAI,KAAA,KAAU,MAAA;AACpC,IAAM,OAAA,GAAkB,OAAA,CAAQ,GAAA,CAAI,OAAA,IAAW,EAAA;AAC/C,IAAM,UAAA,GAAqB,OAAA,CAAQ,GAAA,CAAI,UAAA,IAAc,EAAA;AACrD,IAAM,QAAA,GAAmB,OAAA,CAAQ,GAAA,CAAI,QAAA,IAAY,EAAA;AACjD,IAAM,SAAA,GAAoB,OAAA,CAAQ,GAAA,CAAI,SAAA,IAAa,EAAA;AACnD,IAAM,aAAA,GA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AuthEntrypoint() {\n return `\n import { MastraAuthProvider } from '@mastra/core/server';\n\n class MastraCloudAuth extends MastraAuthProvider {\n constructor (auth) {\n super()\n this.auth = auth\n }\n\n async authenticateToken (...args) {\n if (typeof args[0] === 'string') {\n const token = args[0].replace('Bearer ', '');\n const validTokens = [];\n ${process.env.PLAYGROUND_JWT_TOKEN ? `validTokens.push('${process.env.PLAYGROUND_JWT_TOKEN}');` : ''}\n ${process.env.BUSINESS_JWT_TOKEN ? `validTokens.push('${process.env.BUSINESS_JWT_TOKEN}');` : ''}\n \n if (validTokens.includes(token)) {\n return { id: 'business-api' }\n }\n }\n return this.auth.authenticateToken(...args)\n }\n\n async authorizeUser (...args) {\n if (args[1] && args[1].path === '/api') {\n return true\n }\n if (args[0] && args[0].id === 'business-api') {\n return true\n }\n return this.auth.authorizeUser(...args)\n }\n }\n\n const serverConfig = mastra.getServer()\n if (serverConfig && serverConfig.auth) {\n const auth = serverConfig.auth\n serverConfig.auth = new MastraCloudAuth(auth)\n }\n `;\n}\n","import os from 'os';\n\nexport const LOCAL = process.env.LOCAL === 'true';\nexport const TEAM_ID: string = process.env.TEAM_ID ?? '';\nexport const PROJECT_ID: string = process.env.PROJECT_ID ?? '';\nexport const BUILD_ID: string = process.env.BUILD_ID ?? '';\nexport const BUILD_URL: string = process.env.BUILD_URL ?? '';\nexport const LOG_REDIS_URL: string = process.env.LOG_REDIS_URL ?? 'redis://localhost:6379';\nexport const BUSINESS_JWT_TOKEN: string = process.env.BUSINESS_JWT_TOKEN ?? '';\nexport const PLAYGROUND_JWT_TOKEN: string = process.env.PLAYGROUND_JWT_TOKEN ?? '';\nexport const USER_IP_ADDRESS: string = process.env.USER_IP_ADDRESS ?? '';\nexport const MASTRA_DIRECTORY: string = process.env.MASTRA_DIRECTORY ?? 'src/mastra';\nexport const PROJECT_ENV_VARS: Record<string, string> = safelyParseJson(process.env.PROJECT_ENV_VARS ?? '{}');\n\nexport const PROJECT_ROOT = LOCAL ? os.tmpdir() + '/project' : (process.env.PROJECT_ROOT ?? '/project');\n\nexport function safelyParseJson(json: string) {\n try {\n return JSON.parse(json);\n } catch {\n return {};\n }\n}\n","import type { TransformCallback } from 'stream';\nimport type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport { LoggerTransport } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { createClient } from 'redis';\nimport { BUILD_ID, LOG_REDIS_URL, PROJECT_ID, TEAM_ID } from './constants.js';\n\nconst redisClient = createClient({\n url: LOG_REDIS_URL,\n});\n\nclass RedisTransport extends LoggerTransport {\n _transform(chunk: any, _encoding: string, callback: TransformCallback): void {\n chunk = chunk.toString();\n const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;\n const ttl = 2 * 24 * 60 * 60; // 2 days in seconds\n const logData = typeof chunk === 'string' ? chunk : JSON.stringify(chunk);\n\n // Don't block the event loop - process logs asynchronously\n process.nextTick(async () => {\n try {\n // Connect to Redis if not already connected\n if (!redisClient.isOpen) {\n await redisClient.connect().catch(err => {\n console.error('Redis connection error:', err);\n });\n }\n\n // Use pipeline to batch Redis operations\n const pipeline = redisClient.multi();\n pipeline.rPush(logKey, logData);\n pipeline.expire(logKey, ttl);\n await pipeline.exec();\n } catch (err) {\n console.error('Redis logging error:', err);\n }\n });\n\n // Immediately pass through the chunk without waiting\n callback(null, chunk);\n }\n\n _write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean {\n if (typeof callback === 'function') {\n this._transform(chunk, encoding || 'utf8', callback);\n return true;\n }\n\n this._transform(chunk, encoding || 'utf8', (error: Error | null | undefined) => {\n if (error) console.error('Transform error in write:', error);\n });\n return true;\n }\n\n async _flush(): Promise<void> {\n // // Ensure the pipeline is closed and flushed\n // redisClient.quit().catch(err => {\n // console.error('Redis connection error:', err);\n // });\n // callback();\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n\n async _destroy(err: Error, cb: Function) {\n await closeLogger();\n cb(err);\n }\n\n listLogs(_args: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{ logs: BaseLogMessage[]; total: number; page: number; perPage: number; hasMore: boolean }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n\n listLogsByRunId(_args?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: Record<string, any>;\n returnPaginationResults?: boolean;\n page?: number;\n perPage?: number;\n }): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n }> {\n return Promise.resolve({\n logs: [],\n total: 0,\n page: _args?.page ?? 1,\n perPage: _args?.perPage ?? 100,\n hasMore: false,\n });\n }\n}\n\nexport const transport = new RedisTransport();\n\nexport const closeLogger = async () => {\n if (redisClient.isOpen) {\n setTimeout(async () => {\n await redisClient.quit();\n }, 10);\n }\n};\n\nexport const logger = new PinoLogger({\n level: 'info',\n transports: {\n redis: transport,\n },\n});\n","import { Transform } from 'stream';\nimport { execa } from 'execa';\nimport { PROJECT_ENV_VARS, PROJECT_ROOT } from './constants.js';\nimport { logger } from './logger.js';\n\nexport const createPinoStream = () => {\n return new Transform({\n transform(chunk, encoding, callback) {\n // Convert Buffer/string to string and trim whitespace\n const line = chunk.toString().trim();\n\n if (line) {\n // Log each line through Pino\n logger.info(line);\n }\n\n // Pass through the original data\n callback(null, chunk);\n },\n });\n};\n\nexport async function runWithExeca({\n cmd,\n args,\n cwd = process.cwd(),\n env = PROJECT_ENV_VARS,\n}: {\n cmd: string;\n args: string[];\n cwd?: string;\n env?: Record<string, string>;\n}): Promise<{ stdout?: string; stderr?: string; success: boolean; error?: Error }> {\n const pinoStream = createPinoStream();\n\n try {\n const subprocess = execa(cmd, args, {\n cwd,\n env: {\n ...process.env,\n ...env,\n },\n });\n\n // Pipe stdout and stderr through the Pino stream\n subprocess.stdout?.pipe(pinoStream);\n subprocess.stderr?.pipe(pinoStream);\n\n const { stdout, stderr, exitCode } = await subprocess;\n return { stdout, stderr, success: exitCode === 0 };\n } catch (error) {\n logger.error(`Process failed: ${error}`);\n return { success: false, error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\n\nexport function runWithChildProcess(cmd: string, args: string[]): { stdout?: string; stderr?: string } {\n const pinoStream = createPinoStream();\n\n try {\n const { stdout, stderr } = require('child_process').spawnSync(cmd, args, {\n cwd: PROJECT_ROOT,\n encoding: 'utf8',\n shell: true,\n env: {\n ...process.env,\n ...PROJECT_ENV_VARS,\n },\n maxBuffer: 1024 * 1024 * 10, // 10MB buffer\n });\n\n if (stdout) {\n pinoStream.write(stdout);\n }\n if (stderr) {\n pinoStream.write(stderr);\n }\n\n pinoStream.end();\n return { stdout, stderr };\n } catch (error) {\n logger.error('Process failed' + error);\n pinoStream.end();\n return {};\n }\n}\n","import * as fs from 'fs';\nimport { join, resolve } from 'path';\n\nimport { MastraError } from '@mastra/core/error';\nimport { runWithExeca } from './execa.js';\nimport { logger } from './logger.js';\n\nconst MEMOIZED = new Map();\n\nfunction findLockFile(dir: string): string | null {\n const lockFiles = ['pnpm-lock.yaml', 'package-lock.json', 'yarn.lock', 'bun.lock'];\n for (const file of lockFiles) {\n if (fs.existsSync(join(dir, file))) {\n return file;\n }\n }\n const parentDir = resolve(dir, '..');\n if (parentDir !== dir) {\n return findLockFile(parentDir);\n }\n return null;\n}\n\nexport function detectPm({ path }: { path: string }): string {\n const cached = MEMOIZED.get(path);\n if (cached) {\n return cached;\n }\n\n const lockFile = findLockFile(path);\n let pm: string = 'npm';\n switch (lockFile) {\n case 'pnpm-lock.yaml':\n pm = 'pnpm';\n break;\n case 'package-lock.json':\n pm = 'npm';\n break;\n case 'yarn.lock':\n pm = 'yarn';\n break;\n case 'bun.lock':\n pm = 'bun';\n break;\n default:\n pm = 'npm';\n }\n\n MEMOIZED.set(path, pm);\n return pm;\n}\n\nexport async function installNodeVersion({ path }: { path: string }) {\n let nvmrcExists = false;\n let nodeVersionExists = false;\n\n try {\n fs.accessSync(join(path, '.nvmrc'));\n nvmrcExists = true;\n } catch {\n // File does not exist\n }\n\n try {\n fs.accessSync(join(path, '.node-version'));\n nodeVersionExists = true;\n } catch {\n // File does not exist\n }\n\n if (nvmrcExists || nodeVersionExists) {\n logger.info('Node version file found, installing specified Node.js version...');\n const { success, error } = await runWithExeca({\n cmd: 'n',\n args: ['auto'],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'NODE_FAIL_INSTALL_SPECIFIED_VERSION',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n }\n}\n\nexport async function installDeps({ path, pm }: { path: string; pm?: string }) {\n pm = pm ?? detectPm({ path });\n logger.info(`Installing dependencies with ${pm} in ${path}`);\n const args = ['install'];\n const { success, error } = await runWithExeca({ cmd: pm, args, cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_INSTALL_DEPS',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runInstallCommand({ path, installCommand }: { path: string; installCommand: string }) {\n logger.info(`Running install command ${installCommand} in workspace with ${path}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', installCommand], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_CUSTOM_INSTALL_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runScript({ scriptName, path, args }: { scriptName: string; path: string; args?: string[] }) {\n const pm = detectPm({ path });\n logger.info(`Running script ${scriptName} in workspace with ${pm}`);\n const { success, error } = await runWithExeca({\n cmd: pm,\n args: pm === 'npm' ? ['run', scriptName, ...(args ?? [])] : [scriptName, ...(args ?? [])],\n cwd: path,\n });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_SCRIPT',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n\nexport async function runBuildCommand({ command, path }: { command: string; path: string }) {\n logger.info(`Running build command ${command}`);\n const { success, error } = await runWithExeca({ cmd: 'sh', args: ['-c', command], cwd: path });\n if (!success) {\n throw new MastraError(\n {\n id: 'FAIL_BUILD_COMMAND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { join } from 'path';\nimport { MastraError } from '@mastra/core/error';\nimport { FileService } from '@mastra/deployer';\n\nimport { MASTRA_DIRECTORY } from './constants.js';\n\nexport function getMastraEntryFile(mastraDir: string) {\n try {\n const fileService = new FileService();\n return fileService.getFirstExistingFile([\n join(mastraDir, MASTRA_DIRECTORY, 'index.ts'),\n join(mastraDir, MASTRA_DIRECTORY, 'index.js'),\n ]);\n } catch (error) {\n throw new MastraError(\n {\n id: 'MASTRA_ENTRY_FILE_NOT_FOUND',\n category: 'USER',\n domain: 'DEPLOYER',\n },\n error,\n );\n }\n}\n","import { PROJECT_ID, BUILD_ID, BUILD_URL, USER_IP_ADDRESS } from './constants.js';\n\nexport function successEntrypoint() {\n return `\n if (process.env.CI !== 'true') {\n await fetch('${process.env.REPORTER_API_URL}', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Bearer ${process.env.REPORTER_API_URL_AUTH_TOKEN}',\n },\n body: JSON.stringify(${JSON.stringify({\n projectId: PROJECT_ID,\n buildId: BUILD_ID,\n status: 'success',\n url: BUILD_URL,\n userIpAddress: USER_IP_ADDRESS,\n })}),\n }).catch(err => {\n console.error('Failed to report build status to monitoring service', {\n error: err,\n });\n })\n }\n `;\n}\n","import { fileURLToPath } from 'node:url';\nimport { join, dirname } from 'path';\nimport { Deployer } from '@mastra/deployer';\nimport { readJSON } from 'fs-extra/esm';\n\nimport { getAuthEntrypoint } from './utils/auth.js';\nimport { MASTRA_DIRECTORY, BUILD_ID, PROJECT_ID, TEAM_ID } from './utils/constants.js';\nimport { installDeps } from './utils/deps.js';\nimport { getMastraEntryFile } from './utils/file.js';\nimport { successEntrypoint } from './utils/report.js';\n\nexport class CloudDeployer extends Deployer {\n constructor() {\n super({ name: 'cloud' });\n }\n\n async deploy(_outputDirectory: string): Promise<void> {}\n async writePackageJson(outputDirectory: string, dependencies: Map<string, string>) {\n const versions = (await readJSON(join(dirname(fileURLToPath(import.meta.url)), '../versions.json'))) as\n | Record<string, string>\n | undefined;\n for (const [pkgName, version] of Object.entries(versions || {})) {\n dependencies.set(pkgName, version);\n }\n\n return super.writePackageJson(outputDirectory, dependencies);\n }\n\n async lint() {}\n\n protected async installDependencies(outputDirectory: string, _rootDir = process.cwd()) {\n await installDeps({ path: join(outputDirectory, 'output'), pm: 'npm' });\n }\n\n async bundle(mastraDir: string, outputDirectory: string): Promise<void> {\n const currentCwd = process.cwd();\n process.chdir(mastraDir);\n\n const mastraEntryFile = getMastraEntryFile(mastraDir);\n\n const mastraAppDir = join(mastraDir, MASTRA_DIRECTORY);\n\n // Use the getAllToolPaths method to prepare tools paths\n const discoveredTools = this.getAllToolPaths(mastraAppDir);\n\n await this._bundle(\n this.getEntry(),\n mastraEntryFile,\n {\n outputDirectory,\n projectRoot: mastraDir,\n },\n discoveredTools,\n );\n process.chdir(currentCwd);\n }\n\n getAuthEntrypoint() {\n return getAuthEntrypoint();\n }\n\n private getEntry(): string {\n return `\nimport { createNodeServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { mastra } from '#mastra';\nimport { MultiLogger } from '@mastra/core/logger';\nimport { PinoLogger } from '@mastra/loggers';\nimport { HttpTransport } from '@mastra/loggers/http';\nimport { LibSQLStore, LibSQLVector } from '@mastra/libsql';\nimport { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\nconst startTime = process.env.RUNNER_START_TIME ? new Date(process.env.RUNNER_START_TIME).getTime() : Date.now();\nconst createNodeServerStartTime = Date.now();\n\nconsole.log(JSON.stringify({\n message: \"Server starting\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\nconst transports = {}\nif (process.env.CI !== 'true') {\n if (process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT) {\n transports.default = new HttpTransport({\n url: process.env.BUSINESS_API_RUNNER_LOGS_ENDPOINT,\n headers: {\n Authorization: 'Bearer ' + process.env.BUSINESS_JWT_TOKEN,\n },\n });\n }\n}\n\nconst logger = new PinoLogger({\n name: 'MastraCloud',\n transports,\n level: 'debug',\n});\nconst existingLogger = mastra?.getLogger();\nconst combinedLogger = existingLogger ? new MultiLogger([logger, existingLogger]) : logger;\n\nmastra.setLogger({ logger: combinedLogger });\n\nif (mastra?.storage) {\n mastra.storage.init()\n}\n\nif (process.env.MASTRA_STORAGE_URL && process.env.MASTRA_STORAGE_AUTH_TOKEN) {\n const { MastraStorage } = await import('@mastra/core/storage');\n logger.info('Using Mastra Cloud Storage: ' + process.env.MASTRA_STORAGE_URL)\n const storage = new LibSQLStore({\n id: 'mastra-cloud-storage-libsql',\n url: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n const vector = new LibSQLVector({\n id: 'mastra-cloud-storage-libsql-vector',\n connectionUrl: process.env.MASTRA_STORAGE_URL,\n authToken: process.env.MASTRA_STORAGE_AUTH_TOKEN,\n })\n\n await storage.init()\n mastra?.setStorage(storage)\n}\n\nif (mastra?.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\n${getAuthEntrypoint()}\n\nawait createNodeServer(mastra, { playground: false, swaggerUI: false, tools: getToolExports(tools) });\n\n${successEntrypoint()}\n\nconsole.log(JSON.stringify({\n message: \"Server started\",\n operation: 'builder.createNodeServer',\n operation_startTime: createNodeServerStartTime,\n operation_durationMs: Date.now() - createNodeServerStartTime,\n type: \"READINESS\",\n startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n\n\nconsole.log(JSON.stringify({\n message: \"Runner Initialized\",\n type: \"READINESS\",\n startTime,\n durationMs: Date.now() - startTime,\n metadata: {\n teamId: \"${TEAM_ID}\",\n projectId: \"${PROJECT_ID}\",\n buildId: \"${BUILD_ID}\",\n },\n}));\n`;\n }\n}\n"]}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class RedisTransport extends LoggerTransport {
|
|
|
7
7
|
_write(chunk: any, encoding?: string, callback?: (error?: Error | null) => void): boolean;
|
|
8
8
|
_flush(): Promise<void>;
|
|
9
9
|
_destroy(err: Error, cb: Function): Promise<void>;
|
|
10
|
-
|
|
10
|
+
listLogs(_args: {
|
|
11
11
|
fromDate?: Date;
|
|
12
12
|
toDate?: Date;
|
|
13
13
|
logLevel?: LogLevel;
|
|
@@ -22,7 +22,7 @@ declare class RedisTransport extends LoggerTransport {
|
|
|
22
22
|
perPage: number;
|
|
23
23
|
hasMore: boolean;
|
|
24
24
|
}>;
|
|
25
|
-
|
|
25
|
+
listLogsByRunId(_args?: {
|
|
26
26
|
fromDate?: Date;
|
|
27
27
|
toDate?: Date;
|
|
28
28
|
logLevel?: LogLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,cAAM,cAAe,SAAQ,eAAe;IAC1C,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAA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AO,CAAC;QAClC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAUvG,eAAe,CAAC,KAAK,CAAC,EAAE;QACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;QAClC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QACV,IAAI,EAAE,cAAc,EAAE,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CASH;AAED,eAAO,MAAM,SAAS,gBAAuB,CAAC;AAE9C,eAAO,MAAM,WAAW,qBAMvB,CAAC;AAEF,eAAO,MAAM,MAAM,YAKjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-cloud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"CHANGELOG.md",
|
|
9
|
-
"templates",
|
|
10
9
|
"versions.json"
|
|
11
10
|
],
|
|
12
11
|
"main": "dist/index.js",
|
|
@@ -31,8 +30,8 @@
|
|
|
31
30
|
"fs-extra": "^11.3.2",
|
|
32
31
|
"pino": "^9.7.0",
|
|
33
32
|
"redis": "^5.8.3",
|
|
34
|
-
"@mastra/deployer": "^0.
|
|
35
|
-
"@mastra/loggers": "0.
|
|
33
|
+
"@mastra/deployer": "^1.0.0-beta.0",
|
|
34
|
+
"@mastra/loggers": "1.0.0-beta.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@manypkg/get-packages": "^3.1.0",
|
|
@@ -42,11 +41,12 @@
|
|
|
42
41
|
"tsup": "^8.5.0",
|
|
43
42
|
"typescript": "^5.8.3",
|
|
44
43
|
"vitest": "^3.2.4",
|
|
45
|
-
"@internal/
|
|
46
|
-
"@internal/
|
|
44
|
+
"@internal/lint": "0.0.53",
|
|
45
|
+
"@internal/types-builder": "0.0.28",
|
|
46
|
+
"@mastra/core": "1.0.0-beta.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@mastra/core": ">=0.
|
|
49
|
+
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
@@ -57,12 +57,8 @@
|
|
|
57
57
|
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://mastra.ai",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"publish-branch": [
|
|
63
|
-
"main",
|
|
64
|
-
"0.x"
|
|
65
|
-
]
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=22.13.0"
|
|
66
62
|
},
|
|
67
63
|
"scripts": {
|
|
68
64
|
"build": "tsup --silent --config tsup.config.ts",
|
package/versions.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"@mastra/
|
|
1
|
+
{"@mastra/loggers":"1.0.0-beta.0","@mastra/libsql":"1.0.0-beta.0"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { MastraCloudExporter } from '@mastra/cloud';
|
|
2
|
-
import {
|
|
3
|
-
NodeSDK,
|
|
4
|
-
getNodeAutoInstrumentations,
|
|
5
|
-
ATTR_SERVICE_NAME,
|
|
6
|
-
resourceFromAttributes,
|
|
7
|
-
ParentBasedSampler,
|
|
8
|
-
TraceIdRatioBasedSampler,
|
|
9
|
-
AlwaysOnSampler,
|
|
10
|
-
AlwaysOffSampler,
|
|
11
|
-
OTLPHttpExporter,
|
|
12
|
-
} from '@mastra/core/telemetry/otel-vendor';
|
|
13
|
-
|
|
14
|
-
import { telemetry } from './telemetry-config.mjs';
|
|
15
|
-
|
|
16
|
-
function getSampler(config) {
|
|
17
|
-
if (!config.sampling) {
|
|
18
|
-
return new AlwaysOnSampler();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!config.enabled) {
|
|
22
|
-
return new AlwaysOffSampler();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
switch (config.sampling.type) {
|
|
26
|
-
case 'ratio':
|
|
27
|
-
return new TraceIdRatioBasedSampler(config.sampling.probability);
|
|
28
|
-
case 'always_on':
|
|
29
|
-
return new AlwaysOnSampler();
|
|
30
|
-
case 'always_off':
|
|
31
|
-
return new AlwaysOffSampler();
|
|
32
|
-
case 'parent_based':
|
|
33
|
-
const rootSampler = new TraceIdRatioBasedSampler(config.sampling.root?.probability || 1.0);
|
|
34
|
-
return new ParentBasedSampler({ root: rootSampler });
|
|
35
|
-
default:
|
|
36
|
-
return new AlwaysOnSampler();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function getExporter(config) {
|
|
41
|
-
if (config.export?.type === 'otlp') {
|
|
42
|
-
return new OTLPHttpExporter({
|
|
43
|
-
url: config.export.endpoint,
|
|
44
|
-
headers: config.export.headers,
|
|
45
|
-
});
|
|
46
|
-
} else if (config.export?.type === 'custom') {
|
|
47
|
-
return config.export.exporter;
|
|
48
|
-
} else {
|
|
49
|
-
console.info('Using default Mastra Cloud Exporter');
|
|
50
|
-
return new MastraCloudExporter({
|
|
51
|
-
endpoint: process.env.BUSINESS_API_TRACE_ENDPOINT,
|
|
52
|
-
accessToken: process.env.BUSINESS_JWT_TOKEN,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const sampler = getSampler(telemetry);
|
|
58
|
-
const exporter = await getExporter(telemetry);
|
|
59
|
-
|
|
60
|
-
const sdk = new NodeSDK({
|
|
61
|
-
resource: resourceFromAttributes({
|
|
62
|
-
[ATTR_SERVICE_NAME]: telemetry.serviceName || 'default-service',
|
|
63
|
-
}),
|
|
64
|
-
sampler,
|
|
65
|
-
traceExporter: exporter,
|
|
66
|
-
instrumentations: [getNodeAutoInstrumentations()],
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
sdk.start();
|