@mastra/deployer 1.54.0-alpha.0 → 1.54.0-alpha.2

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.
Files changed (211) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/analyze-C2q7jxbN.js +1308 -0
  3. package/dist/analyze-C2q7jxbN.js.map +1 -0
  4. package/dist/analyze-DhDZW9TS.cjs +1318 -0
  5. package/dist/analyze-DhDZW9TS.cjs.map +1 -0
  6. package/dist/arktype-aI7TBD0R-BsgjPZ4a.cjs +8 -0
  7. package/dist/arktype-aI7TBD0R-BsgjPZ4a.cjs.map +1 -0
  8. package/dist/arktype-aI7TBD0R-_UZl-wsH.js +8 -0
  9. package/dist/arktype-aI7TBD0R-_UZl-wsH.js.map +1 -0
  10. package/dist/build/analyze/constants.d.ts.map +1 -1
  11. package/dist/build/analyze.cjs +3 -12
  12. package/dist/build/analyze.js +2 -3
  13. package/dist/build/bundler.cjs +6 -24
  14. package/dist/build/bundler.js +2 -3
  15. package/dist/build/index.cjs +29 -101
  16. package/dist/build/index.js +7 -8
  17. package/dist/build-De4AZhfJ.cjs +908 -0
  18. package/dist/build-De4AZhfJ.cjs.map +1 -0
  19. package/dist/build-KCOeHd4N.js +834 -0
  20. package/dist/build-KCOeHd4N.js.map +1 -0
  21. package/dist/bundler/index.cjs +318 -13
  22. package/dist/bundler/index.cjs.map +1 -1
  23. package/dist/bundler/index.js +314 -2
  24. package/dist/bundler/index.js.map +1 -1
  25. package/dist/bundler-BqrDXofn.cjs +792 -0
  26. package/dist/bundler-BqrDXofn.cjs.map +1 -0
  27. package/dist/bundler-D86rFu2J.js +705 -0
  28. package/dist/bundler-D86rFu2J.js.map +1 -0
  29. package/dist/bundlerOptions-aFsEi86t.js +180 -0
  30. package/dist/bundlerOptions-aFsEi86t.js.map +1 -0
  31. package/dist/bundlerOptions-rBmtSyGe.cjs +194 -0
  32. package/dist/bundlerOptions-rBmtSyGe.cjs.map +1 -0
  33. package/dist/core-D0wEgdn3.cjs +790 -0
  34. package/dist/core-D0wEgdn3.cjs.map +1 -0
  35. package/dist/core-DF65PJXc.js +790 -0
  36. package/dist/core-DF65PJXc.js.map +1 -0
  37. package/dist/dist-BauTimif.js +532 -0
  38. package/dist/dist-BauTimif.js.map +1 -0
  39. package/dist/dist-Cv-mAEtr.cjs +532 -0
  40. package/dist/dist-Cv-mAEtr.cjs.map +1 -0
  41. package/dist/docs/SKILL.md +1 -1
  42. package/dist/docs/assets/SOURCE_MAP.json +2 -23
  43. package/dist/docs/references/docs-deployment-cloud-providers.md +1 -0
  44. package/dist/docs/references/docs-deployment-overview.md +1 -0
  45. package/dist/effect-QlVUlMFu-CwFnyS-g.cjs +14 -0
  46. package/dist/effect-QlVUlMFu-CwFnyS-g.cjs.map +1 -0
  47. package/dist/effect-QlVUlMFu-gyLQRCtQ.js +14 -0
  48. package/dist/effect-QlVUlMFu-gyLQRCtQ.js.map +1 -0
  49. package/dist/esm-BX-weMyC.js +4634 -0
  50. package/dist/esm-BX-weMyC.js.map +1 -0
  51. package/dist/esm-D81PZ_wJ.cjs +4634 -0
  52. package/dist/esm-D81PZ_wJ.cjs.map +1 -0
  53. package/dist/index-CLddUTqr-B5mOP6DC.cjs +145 -0
  54. package/dist/index-CLddUTqr-B5mOP6DC.cjs.map +1 -0
  55. package/dist/index-CLddUTqr-CkS6Y_hA.js +140 -0
  56. package/dist/index-CLddUTqr-CkS6Y_hA.js.map +1 -0
  57. package/dist/index.cjs +35 -48
  58. package/dist/index.cjs.map +1 -1
  59. package/dist/index.js +29 -30
  60. package/dist/index.js.map +1 -1
  61. package/dist/rolldown-runtime-emK7D4bc.cjs +35 -0
  62. package/dist/server/index.cjs +3141 -3874
  63. package/dist/server/index.cjs.map +1 -1
  64. package/dist/server/index.d.ts.map +1 -1
  65. package/dist/server/index.js +3131 -3842
  66. package/dist/server/index.js.map +1 -1
  67. package/dist/server/types.d.ts +1 -0
  68. package/dist/server/types.d.ts.map +1 -1
  69. package/dist/services/index.cjs +5 -20
  70. package/dist/services/index.js +2 -3
  71. package/dist/services-BxYMLS9-.cjs +430 -0
  72. package/dist/services-BxYMLS9-.cjs.map +1 -0
  73. package/dist/services-CLi56qqe.js +391 -0
  74. package/dist/services-CLi56qqe.js.map +1 -0
  75. package/dist/sury-CWZTCd75-B85M6878.js +14 -0
  76. package/dist/sury-CWZTCd75-B85M6878.js.map +1 -0
  77. package/dist/sury-CWZTCd75-DTj5HlK_.cjs +14 -0
  78. package/dist/sury-CWZTCd75-DTj5HlK_.cjs.map +1 -0
  79. package/dist/typebox-Dei93FPO-BeuT13_G.cjs +8 -0
  80. package/dist/typebox-Dei93FPO-BeuT13_G.cjs.map +1 -0
  81. package/dist/typebox-Dei93FPO-DovwMlVl.js +8 -0
  82. package/dist/typebox-Dei93FPO-DovwMlVl.js.map +1 -0
  83. package/dist/utils-FVOUvj-I.js +190 -0
  84. package/dist/utils-FVOUvj-I.js.map +1 -0
  85. package/dist/utils-O98BGdnP.cjs +267 -0
  86. package/dist/utils-O98BGdnP.cjs.map +1 -0
  87. package/dist/valibot--1zFm7rT-BqJHja5B.cjs +14 -0
  88. package/dist/valibot--1zFm7rT-BqJHja5B.cjs.map +1 -0
  89. package/dist/valibot--1zFm7rT-Y4Fhea0w.js +14 -0
  90. package/dist/valibot--1zFm7rT-Y4Fhea0w.js.map +1 -0
  91. package/dist/validator/custom-resolver.cjs +71 -73
  92. package/dist/validator/custom-resolver.cjs.map +1 -1
  93. package/dist/validator/custom-resolver.js +70 -71
  94. package/dist/validator/custom-resolver.js.map +1 -1
  95. package/dist/validator/loader.cjs +6 -7
  96. package/dist/validator/loader.cjs.map +1 -1
  97. package/dist/validator/loader.js +8 -4
  98. package/dist/validator/loader.js.map +1 -1
  99. package/dist/zod-Bwrt9trS-2JL6_UI_.cjs +23 -0
  100. package/dist/zod-Bwrt9trS-2JL6_UI_.cjs.map +1 -0
  101. package/dist/zod-Bwrt9trS-rVHICsmp.js +23 -0
  102. package/dist/zod-Bwrt9trS-rVHICsmp.js.map +1 -0
  103. package/package.json +7 -7
  104. package/dist/arktype-aI7TBD0R-K3QZAVE2.js +0 -8
  105. package/dist/arktype-aI7TBD0R-K3QZAVE2.js.map +0 -1
  106. package/dist/arktype-aI7TBD0R-WK5AZZMC.cjs +0 -10
  107. package/dist/arktype-aI7TBD0R-WK5AZZMC.cjs.map +0 -1
  108. package/dist/build/analyze.cjs.map +0 -1
  109. package/dist/build/analyze.js.map +0 -1
  110. package/dist/build/bundler.cjs.map +0 -1
  111. package/dist/build/bundler.js.map +0 -1
  112. package/dist/build/index.cjs.map +0 -1
  113. package/dist/build/index.js.map +0 -1
  114. package/dist/chunk-36AWZH7Z.cjs +0 -252
  115. package/dist/chunk-36AWZH7Z.cjs.map +0 -1
  116. package/dist/chunk-3XIMK24X.cjs +0 -765
  117. package/dist/chunk-3XIMK24X.cjs.map +0 -1
  118. package/dist/chunk-46M65MQG.cjs +0 -95
  119. package/dist/chunk-46M65MQG.cjs.map +0 -1
  120. package/dist/chunk-4ZNTNJ6T.js +0 -6
  121. package/dist/chunk-4ZNTNJ6T.js.map +0 -1
  122. package/dist/chunk-5PORNUPF.js +0 -739
  123. package/dist/chunk-5PORNUPF.js.map +0 -1
  124. package/dist/chunk-743HRNWT.cjs +0 -1546
  125. package/dist/chunk-743HRNWT.cjs.map +0 -1
  126. package/dist/chunk-AEQ7JHDB.cjs +0 -412
  127. package/dist/chunk-AEQ7JHDB.cjs.map +0 -1
  128. package/dist/chunk-E5SBYHQK.js +0 -244
  129. package/dist/chunk-E5SBYHQK.js.map +0 -1
  130. package/dist/chunk-FKKJQUGR.cjs +0 -497
  131. package/dist/chunk-FKKJQUGR.cjs.map +0 -1
  132. package/dist/chunk-FQHUOYYL.js +0 -1514
  133. package/dist/chunk-FQHUOYYL.js.map +0 -1
  134. package/dist/chunk-G7MIMGMX.js +0 -14
  135. package/dist/chunk-G7MIMGMX.js.map +0 -1
  136. package/dist/chunk-HZC3PTK2.cjs +0 -16
  137. package/dist/chunk-HZC3PTK2.cjs.map +0 -1
  138. package/dist/chunk-JZRFRUGM.cjs +0 -158
  139. package/dist/chunk-JZRFRUGM.cjs.map +0 -1
  140. package/dist/chunk-L45X3DJX.js +0 -385
  141. package/dist/chunk-L45X3DJX.js.map +0 -1
  142. package/dist/chunk-PC25XSK7.cjs +0 -8
  143. package/dist/chunk-PC25XSK7.cjs.map +0 -1
  144. package/dist/chunk-PZ5AY32C.js +0 -9
  145. package/dist/chunk-PZ5AY32C.js.map +0 -1
  146. package/dist/chunk-Q7SFCCGT.cjs +0 -11
  147. package/dist/chunk-Q7SFCCGT.cjs.map +0 -1
  148. package/dist/chunk-T4UT2QX7.js +0 -3
  149. package/dist/chunk-T4UT2QX7.js.map +0 -1
  150. package/dist/chunk-UBIDJOJA.js +0 -93
  151. package/dist/chunk-UBIDJOJA.js.map +0 -1
  152. package/dist/chunk-V3EKV6QB.cjs +0 -162
  153. package/dist/chunk-V3EKV6QB.cjs.map +0 -1
  154. package/dist/chunk-WHD2QQ3N.js +0 -783
  155. package/dist/chunk-WHD2QQ3N.js.map +0 -1
  156. package/dist/chunk-WP65JQAT.js +0 -144
  157. package/dist/chunk-WP65JQAT.js.map +0 -1
  158. package/dist/chunk-YO5OFXPN.cjs +0 -819
  159. package/dist/chunk-YO5OFXPN.cjs.map +0 -1
  160. package/dist/chunk-YUBKHO52.js +0 -465
  161. package/dist/chunk-YUBKHO52.js.map +0 -1
  162. package/dist/chunk-YWMYXUHX.cjs +0 -4
  163. package/dist/chunk-YWMYXUHX.cjs.map +0 -1
  164. package/dist/chunk-ZKZOVNT4.js +0 -159
  165. package/dist/chunk-ZKZOVNT4.js.map +0 -1
  166. package/dist/core-XIDAXLRB.js +0 -11866
  167. package/dist/core-XIDAXLRB.js.map +0 -1
  168. package/dist/core-XJNQ4AY6.cjs +0 -12141
  169. package/dist/core-XJNQ4AY6.cjs.map +0 -1
  170. package/dist/default-u_dwuiYb-HGUAHA6N.cjs +0 -9
  171. package/dist/default-u_dwuiYb-HGUAHA6N.cjs.map +0 -1
  172. package/dist/default-u_dwuiYb-MVPTVDCE.js +0 -3
  173. package/dist/default-u_dwuiYb-MVPTVDCE.js.map +0 -1
  174. package/dist/dist-UEE5OLII.cjs +0 -521
  175. package/dist/dist-UEE5OLII.cjs.map +0 -1
  176. package/dist/dist-X75F2Q36.js +0 -515
  177. package/dist/dist-X75F2Q36.js.map +0 -1
  178. package/dist/effect-QlVUlMFu-QNLZLGWO.js +0 -15
  179. package/dist/effect-QlVUlMFu-QNLZLGWO.js.map +0 -1
  180. package/dist/effect-QlVUlMFu-XUD6EH23.cjs +0 -17
  181. package/dist/effect-QlVUlMFu-XUD6EH23.cjs.map +0 -1
  182. package/dist/esm-DFCHSIJZ.cjs +0 -1589
  183. package/dist/esm-DFCHSIJZ.cjs.map +0 -1
  184. package/dist/esm-PXGQ5WB4.js +0 -1542
  185. package/dist/esm-PXGQ5WB4.js.map +0 -1
  186. package/dist/services/index.cjs.map +0 -1
  187. package/dist/services/index.js.map +0 -1
  188. package/dist/sury-CWZTCd75-3KQQJ22C.cjs +0 -17
  189. package/dist/sury-CWZTCd75-3KQQJ22C.cjs.map +0 -1
  190. package/dist/sury-CWZTCd75-DZQHKAZF.js +0 -15
  191. package/dist/sury-CWZTCd75-DZQHKAZF.js.map +0 -1
  192. package/dist/typebox-Dei93FPO-GOYJ5OUT.js +0 -8
  193. package/dist/typebox-Dei93FPO-GOYJ5OUT.js.map +0 -1
  194. package/dist/typebox-Dei93FPO-M7J7E57W.cjs +0 -10
  195. package/dist/typebox-Dei93FPO-M7J7E57W.cjs.map +0 -1
  196. package/dist/valibot--1zFm7rT-NVM3G3TI.cjs +0 -17
  197. package/dist/valibot--1zFm7rT-NVM3G3TI.cjs.map +0 -1
  198. package/dist/valibot--1zFm7rT-ZVGQI7WV.js +0 -15
  199. package/dist/valibot--1zFm7rT-ZVGQI7WV.js.map +0 -1
  200. package/dist/valibot-D_HTw1Gn-UCPEGDL7.cjs +0 -45
  201. package/dist/valibot-D_HTw1Gn-UCPEGDL7.cjs.map +0 -1
  202. package/dist/valibot-D_HTw1Gn-XPR4F6VS.js +0 -43
  203. package/dist/valibot-D_HTw1Gn-XPR4F6VS.js.map +0 -1
  204. package/dist/zod-Bwrt9trS-GN7ZXBMN.js +0 -29
  205. package/dist/zod-Bwrt9trS-GN7ZXBMN.js.map +0 -1
  206. package/dist/zod-Bwrt9trS-OVKARV6W.cjs +0 -31
  207. package/dist/zod-Bwrt9trS-OVKARV6W.cjs.map +0 -1
  208. package/dist/zod-DSgpEGAE-E7YZZ7VC.js +0 -37
  209. package/dist/zod-DSgpEGAE-E7YZZ7VC.js.map +0 -1
  210. package/dist/zod-DSgpEGAE-UNQNGL2W.cjs +0 -39
  211. package/dist/zod-DSgpEGAE-UNQNGL2W.cjs.map +0 -1
@@ -1,765 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkJZRFRUGM_cjs = require('./chunk-JZRFRUGM.cjs');
4
- var path = require('path');
5
- var url = require('url');
6
- var rollupPlugin = require('@optimize-lodash/rollup-plugin');
7
- var alias = require('@rollup/plugin-alias');
8
- var commonjs = require('@rollup/plugin-commonjs');
9
- var json = require('@rollup/plugin-json');
10
- var nodeResolve = require('@rollup/plugin-node-resolve');
11
- var rollup = require('rollup');
12
- var originalEsbuild = require('rollup-plugin-esbuild');
13
- var originalEsmShim = require('@rollup/plugin-esm-shim');
14
- var promises = require('fs/promises');
15
- var fs = require('fs');
16
- var esm = require('fs-extra/esm');
17
- var localPkg = require('local-pkg');
18
- var core = require('@babel/core');
19
- var stripJsonComments = require('strip-json-comments');
20
- var typescriptPaths = require('typescript-paths');
21
-
22
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
-
24
- var path__default = /*#__PURE__*/_interopDefault(path);
25
- var alias__default = /*#__PURE__*/_interopDefault(alias);
26
- var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
27
- var json__default = /*#__PURE__*/_interopDefault(json);
28
- var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
29
- var originalEsbuild__default = /*#__PURE__*/_interopDefault(originalEsbuild);
30
- var originalEsmShim__default = /*#__PURE__*/_interopDefault(originalEsmShim);
31
- var fs__default = /*#__PURE__*/_interopDefault(fs);
32
- var stripJsonComments__default = /*#__PURE__*/_interopDefault(stripJsonComments);
33
-
34
- function esbuild(options = {}) {
35
- return originalEsbuild__default.default({
36
- target: "node20",
37
- platform: "node",
38
- minify: false,
39
- ...options
40
- });
41
- }
42
- var FilenameDeclarationRegex = /(?:const|let|var)\s+__filename/;
43
- var DirnameDeclarationRegex = /(?:const|let|var)\s+__dirname/;
44
- function esmShim() {
45
- const original = originalEsmShim__default.default();
46
- return {
47
- name: "esm-shim",
48
- renderChunk(code, chunk, opts, meta) {
49
- const hasFilename = code.includes("__filename");
50
- const hasDirname = code.includes("__dirname");
51
- const userDeclaredFilename = hasFilename && FilenameDeclarationRegex.test(code);
52
- const userDeclaredDirname = hasDirname && DirnameDeclarationRegex.test(code);
53
- if (userDeclaredFilename || userDeclaredDirname) {
54
- return null;
55
- }
56
- if (typeof original.renderChunk === "function") {
57
- return original.renderChunk.call(this, code, chunk, opts, meta);
58
- }
59
- return null;
60
- }
61
- };
62
- }
63
-
64
- // src/build/plugins/local-storage-detector.ts
65
- var LOCAL_HOST_PATTERNS = [
66
- {
67
- pattern: /\bfile:\.{1,2}\/[^\s'"`]+\.(?:db|sqlite)\b/gi,
68
- hint: "LibSQL/SQLite file path relative to the build host"
69
- },
70
- {
71
- pattern: /\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\/\/[^/\s'"`]*localhost\b/gi,
72
- hint: "localhost in a connection string"
73
- },
74
- {
75
- pattern: /\b(?:postgres(?:ql)?|mysql|mongodb|redis|libsql):\/\/[^/\s'"`]*127\.0\.0\.1\b/g,
76
- hint: "127.0.0.1 in a connection string"
77
- }
78
- ];
79
- var MASTRA_BUILD_DIR = /[\\/]\.mastra[\\/]\.build[\\/]/;
80
- var PROCESS_ENV_DOT = /\bprocess\.env\.([A-Z_][A-Z0-9_]*)\b/g;
81
- var PROCESS_ENV_BRACKET = /\bprocess\.env\[['"]([A-Z_][A-Z0-9_]*)['"]\]/g;
82
- var LEGACY_LOCAL_PATHS_FILE = "preflight-local-paths.json";
83
- var PREFLIGHT_METADATA_FILE = "preflight-metadata.json";
84
- function collectEnvRefs(code) {
85
- const refs = /* @__PURE__ */ new Set();
86
- for (const m of code.matchAll(PROCESS_ENV_DOT)) refs.add(m[1]);
87
- for (const m of code.matchAll(PROCESS_ENV_BRACKET)) refs.add(m[1]);
88
- return refs;
89
- }
90
- function isAstNode(v) {
91
- return typeof v === "object" && v !== null && typeof v.type === "string";
92
- }
93
- function walkAst(node, visit) {
94
- visit(node);
95
- for (const value of Object.values(node)) {
96
- if (Array.isArray(value)) {
97
- for (const item of value) {
98
- if (isAstNode(item)) walkAst(item, visit);
99
- }
100
- } else if (isAstNode(value)) {
101
- walkAst(value, visit);
102
- }
103
- }
104
- }
105
- function findFirstEnvRef(node) {
106
- let found;
107
- walkAst(node, (n) => {
108
- if (found !== void 0) return;
109
- if (n.type !== "MemberExpression") return;
110
- const object = n.object;
111
- if (!object || object.type !== "MemberExpression" || object.object?.type !== "Identifier" || object.object.name !== "process" || object.property?.type !== "Identifier" || object.property.name !== "env") {
112
- return;
113
- }
114
- const property = n.property;
115
- if (property?.type === "Identifier" && !n.computed) {
116
- found = property.name;
117
- } else if (property?.type === "Literal" && typeof property.value === "string") {
118
- found = property.value;
119
- }
120
- });
121
- return found;
122
- }
123
- function findGuardedValues(ast, values) {
124
- const stringLiterals = [];
125
- const guardedLiterals = /* @__PURE__ */ new Map();
126
- walkAst(ast, (node) => {
127
- if (node.type === "Literal" && typeof node.value === "string") {
128
- stringLiterals.push(node);
129
- return;
130
- }
131
- if (node.type === "LogicalExpression" && (node.operator === "||" || node.operator === "??")) {
132
- const right = node.right;
133
- if (right?.type === "Literal" && typeof right.value === "string") {
134
- const envName = findFirstEnvRef(node.left);
135
- if (envName) guardedLiterals.set(right, envName);
136
- }
137
- }
138
- });
139
- const result = /* @__PURE__ */ new Map();
140
- for (const value of values) {
141
- const containing = stringLiterals.filter((lit) => lit.value.includes(value));
142
- if (containing.length === 0) continue;
143
- const guards = containing.map((lit) => guardedLiterals.get(lit));
144
- const first = guards[0];
145
- if (first !== void 0 && guards.every((g) => g === first)) {
146
- result.set(value, first);
147
- }
148
- }
149
- return result;
150
- }
151
- function localStorageDetector(rootDir) {
152
- const userModuleMatches = /* @__PURE__ */ new Map();
153
- const userModuleEnvRefs = /* @__PURE__ */ new Map();
154
- let normalizedRoot;
155
- if (rootDir) {
156
- let root = rootDir.replace(/\\/g, "/");
157
- while (root.endsWith("/")) root = root.slice(0, -1);
158
- normalizedRoot = root + "/";
159
- }
160
- return {
161
- name: "mastra-local-storage-detector",
162
- transform(_code, id) {
163
- if (id.includes("node_modules")) return null;
164
- if (MASTRA_BUILD_DIR.test(id)) return null;
165
- if (normalizedRoot && !id.replace(/\\/g, "/").startsWith(normalizedRoot)) return null;
166
- const refs = collectEnvRefs(_code);
167
- if (refs.size > 0) {
168
- userModuleEnvRefs.set(id, refs);
169
- }
170
- const matches = [];
171
- for (const { pattern, hint } of LOCAL_HOST_PATTERNS) {
172
- const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : pattern.flags + "g");
173
- for (const m of _code.matchAll(re)) {
174
- matches.push({ value: m[0], hint });
175
- }
176
- }
177
- if (matches.length > 0) {
178
- try {
179
- const ast = this.parse(_code);
180
- const guarded = findGuardedValues(ast, new Set(matches.map((m) => m.value)));
181
- for (const match of matches) {
182
- const guardedBy = guarded.get(match.value);
183
- if (guardedBy) match.guardedBy = guardedBy;
184
- }
185
- } catch {
186
- }
187
- userModuleMatches.set(id, matches);
188
- }
189
- return null;
190
- },
191
- generateBundle(_, bundle) {
192
- const detections = [];
193
- const seen = /* @__PURE__ */ new Set();
194
- const userEnvRefs = /* @__PURE__ */ new Set();
195
- for (const chunk of Object.values(bundle)) {
196
- if (chunk.type !== "chunk") continue;
197
- for (const [moduleId, moduleInfo] of Object.entries(chunk.modules)) {
198
- if (moduleInfo.renderedLength === 0) continue;
199
- for (const ref of userModuleEnvRefs.get(moduleId) ?? []) {
200
- userEnvRefs.add(ref);
201
- }
202
- const matches = userModuleMatches.get(moduleId);
203
- if (!matches) continue;
204
- for (const { value, hint, guardedBy } of matches) {
205
- const key = `${hint}::${value}`;
206
- if (seen.has(key)) continue;
207
- seen.add(key);
208
- detections.push({ value, hint, module: moduleId, ...guardedBy ? { guardedBy } : {} });
209
- }
210
- }
211
- }
212
- const metadata = {
213
- version: 1,
214
- localPaths: detections,
215
- userEnvRefs: [...userEnvRefs].sort()
216
- };
217
- this.emitFile({
218
- type: "asset",
219
- fileName: PREFLIGHT_METADATA_FILE,
220
- source: JSON.stringify(metadata)
221
- });
222
- this.emitFile({
223
- type: "asset",
224
- fileName: LEGACY_LOCAL_PATHS_FILE,
225
- source: JSON.stringify(detections.map(({ value, hint, module }) => ({ value, hint, module })))
226
- });
227
- }
228
- };
229
- }
230
- function toParentDirectoryUrl(parentPath) {
231
- let fsPath = parentPath.startsWith("file://") ? url.fileURLToPath(parentPath) : parentPath;
232
- try {
233
- if (fs.statSync(fsPath).isFile()) {
234
- fsPath = path.dirname(fsPath);
235
- }
236
- } catch {
237
- }
238
- return url.pathToFileURL(fsPath).href;
239
- }
240
- async function getPackageRootPath(packageName, parentPath) {
241
- let rootPath;
242
- try {
243
- let options = void 0;
244
- if (parentPath) {
245
- options = {
246
- paths: [toParentDirectoryUrl(parentPath)]
247
- };
248
- }
249
- const pkg = await localPkg.getPackageInfo(packageName, options);
250
- rootPath = pkg?.rootPath ?? null;
251
- } catch {
252
- rootPath = null;
253
- }
254
- return rootPath;
255
- }
256
- async function readPackageMetadata(rootPath, requestedPackageName) {
257
- try {
258
- const pkgJson = await esm.readJSON(`${rootPath}/package.json`);
259
- const version = pkgJson.version;
260
- const actualPackageName = pkgJson.name;
261
- const packageSpec = version && actualPackageName && requestedPackageName && requestedPackageName !== actualPackageName ? `npm:${actualPackageName}@${version}` : void 0;
262
- return { rootPath, version, packageSpec };
263
- } catch {
264
- return { rootPath };
265
- }
266
- }
267
- async function getPackageMetadata(packageName, parentPath) {
268
- const requestedPackageName = chunkJZRFRUGM_cjs.getPackageName(packageName);
269
- const packageNames = [...new Set([packageName, requestedPackageName].filter(Boolean))];
270
- let firstRootPath = null;
271
- for (const name of packageNames) {
272
- const rootPath = await getPackageRootPath(name, parentPath);
273
- firstRootPath ??= rootPath;
274
- if (!rootPath) {
275
- continue;
276
- }
277
- const metadata = await readPackageMetadata(rootPath, requestedPackageName ?? null);
278
- if (metadata.version || metadata.packageSpec) {
279
- return metadata;
280
- }
281
- }
282
- return { rootPath: firstRootPath };
283
- }
284
-
285
- // src/build/plugins/node-modules-extension-resolver.ts
286
- async function getPackageJSON(pkgName, importer) {
287
- const pkgRoot = await getPackageRootPath(pkgName, importer);
288
- if (!pkgRoot) {
289
- throw new Error(`Package ${pkgName} not found`);
290
- }
291
- const pkgJSON = JSON.parse(await promises.readFile(path.join(pkgRoot, "package.json"), "utf-8"));
292
- return pkgJSON;
293
- }
294
- function nodeModulesExtensionResolver() {
295
- const nodeResolvePlugin = nodeResolve__default.default();
296
- return {
297
- name: "node-modules-extension-resolver",
298
- async resolveId(id, importer, options) {
299
- if (!importer || !chunkJZRFRUGM_cjs.isBareModuleSpecifier(id) || chunkJZRFRUGM_cjs.isExternalProtocolImport(id) || path.isAbsolute(id)) {
300
- return null;
301
- }
302
- const parts = id.split("/");
303
- const isScoped = id.startsWith("@");
304
- if (isScoped && parts.length === 2 || !isScoped && parts.length === 1) {
305
- return null;
306
- }
307
- const pkgName = chunkJZRFRUGM_cjs.getPackageName(id);
308
- if (!pkgName) {
309
- return null;
310
- }
311
- try {
312
- const packageJSON = await getPackageJSON(pkgName, importer);
313
- if (!!packageJSON.exports) {
314
- return null;
315
- }
316
- const packageRoot = await getPackageRootPath(pkgName, importer);
317
- const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);
318
- if (!nodeResolved?.id) {
319
- return null;
320
- }
321
- let filePath = nodeResolved.id;
322
- if (nodeResolved.resolvedBy === "commonjs--resolver") {
323
- filePath = filePath.substring(1).split("?")[0];
324
- }
325
- const resolvedImportPath = filePath.replace(packageRoot, pkgName);
326
- return {
327
- id: resolvedImportPath,
328
- external: true
329
- };
330
- } catch (err) {
331
- console.error(err);
332
- return null;
333
- }
334
- }
335
- };
336
- }
337
-
338
- // src/build/plugins/protocol-external-resolver.ts
339
- function protocolExternalResolver({ exclude = ["node:"] } = {}) {
340
- return {
341
- name: "protocol-external-resolver",
342
- resolveId(id) {
343
- if (!chunkJZRFRUGM_cjs.isExternalProtocolImport(id, exclude)) {
344
- return null;
345
- }
346
- return {
347
- id,
348
- external: true
349
- };
350
- }
351
- };
352
- }
353
- function removeDeployer() {
354
- function removeDeployerFromObject(objectExpr, scope) {
355
- const deployerProp = objectExpr.properties.find(
356
- (prop) => core.types.isObjectProperty(prop) && core.types.isIdentifier(prop.key) && prop.key.name === "deployer"
357
- );
358
- if (deployerProp) {
359
- objectExpr.properties = objectExpr.properties.filter((prop) => prop !== deployerProp);
360
- if (core.types.isIdentifier(deployerProp.value)) {
361
- const deployerBinding = scope.getBinding(deployerProp.value.name);
362
- if (deployerBinding) {
363
- deployerBinding.path?.parentPath?.remove();
364
- }
365
- }
366
- }
367
- return deployerProp;
368
- }
369
- return {
370
- name: "remove-deployer",
371
- visitor: {
372
- NewExpression(path2, state) {
373
- const varDeclaratorPath = path2.findParent((path3) => core.types.isVariableDeclarator(path3.node));
374
- if (!varDeclaratorPath) {
375
- return;
376
- }
377
- const parentNode = path2.parentPath.node;
378
- if (!core.types.isVariableDeclarator(parentNode) || !core.types.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
379
- return;
380
- }
381
- if (!state.hasReplaced) {
382
- state.hasReplaced = true;
383
- const newMastraObj = core.types.cloneNode(path2.node);
384
- if (core.types.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.length) {
385
- const objectArg = newMastraObj.arguments[0];
386
- let foundDeployer = false;
387
- const directDeployer = removeDeployerFromObject(objectArg, state.file.scope);
388
- if (directDeployer) {
389
- foundDeployer = true;
390
- }
391
- for (const prop of objectArg.properties) {
392
- if (core.types.isSpreadElement(prop) && core.types.isIdentifier(prop.argument)) {
393
- const spreadBinding = state.file.scope.getBinding(prop.argument.name);
394
- if (spreadBinding?.path && core.types.isVariableDeclarator(spreadBinding.path.node)) {
395
- const init = spreadBinding.path.node.init;
396
- if (core.types.isObjectExpression(init)) {
397
- const spreadDeployer = removeDeployerFromObject(init, state.file.scope);
398
- if (spreadDeployer) {
399
- foundDeployer = true;
400
- }
401
- }
402
- }
403
- }
404
- }
405
- if (foundDeployer) {
406
- path2.replaceWith(newMastraObj);
407
- }
408
- }
409
- }
410
- }
411
- }
412
- };
413
- }
414
-
415
- // src/build/plugins/remove-deployer.ts
416
- function removeDeployer2(mastraEntry, options) {
417
- return {
418
- name: "remove-deployer",
419
- transform(code, id) {
420
- if (id !== mastraEntry) {
421
- return;
422
- }
423
- return core.transformAsync(code, {
424
- babelrc: false,
425
- configFile: false,
426
- filename: id,
427
- plugins: [removeDeployer],
428
- sourceMaps: options?.sourcemap
429
- }).then((result) => ({
430
- code: result.code,
431
- map: result.map
432
- }));
433
- }
434
- };
435
- }
436
-
437
- // src/build/plugins/subpath-externals-resolver.ts
438
- function subpathExternalsResolver(externals) {
439
- return {
440
- name: "subpath-externals-resolver",
441
- resolveId(id) {
442
- if (id.startsWith(".") || id.startsWith("/")) {
443
- return null;
444
- }
445
- const isPartOfExternals = externals.some((external) => chunkJZRFRUGM_cjs.isDependencyPartOfPackage(id, external));
446
- if (isPartOfExternals) {
447
- return {
448
- id,
449
- external: true
450
- };
451
- }
452
- }
453
- };
454
- }
455
- var PLUGIN_NAME = "tsconfig-paths";
456
- var JS_IMPORT_SOURCE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
457
- function hasPaths(tsConfigPath) {
458
- try {
459
- const content = fs__default.default.readFileSync(tsConfigPath, "utf8");
460
- const config = JSON.parse(stripJsonComments__default.default(content));
461
- return !!(config.compilerOptions?.paths && Object.keys(config.compilerOptions.paths).length > 0 || typeof config.extends === "string" && config.extends.length > 0 || Array.isArray(config.extends) && config.extends.length > 0);
462
- } catch {
463
- return false;
464
- }
465
- }
466
- function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
467
- const handlerCache = /* @__PURE__ */ new Map();
468
- function resolveJsImportToSourceFile(moduleName) {
469
- if (fs__default.default.existsSync(moduleName)) {
470
- return moduleName;
471
- }
472
- const parsed = path__default.default.parse(moduleName);
473
- if (parsed.ext !== ".js") {
474
- return moduleName;
475
- }
476
- for (const extension of JS_IMPORT_SOURCE_EXTENSIONS) {
477
- const candidate = path__default.default.join(parsed.dir, `${parsed.name}${extension}`);
478
- if (fs__default.default.existsSync(candidate)) {
479
- return candidate;
480
- }
481
- }
482
- return moduleName;
483
- }
484
- function findTsConfigForFile(filePath) {
485
- let currentDir = path__default.default.dirname(filePath);
486
- const root = path__default.default.parse(currentDir).root;
487
- while (currentDir !== root) {
488
- const tsConfigPath2 = path__default.default.join(currentDir, "tsconfig.json");
489
- if (fs__default.default.existsSync(tsConfigPath2)) {
490
- if (hasPaths(tsConfigPath2)) {
491
- return tsConfigPath2;
492
- }
493
- }
494
- const tsConfigBasePath = path__default.default.join(currentDir, "tsconfig.base.json");
495
- if (fs__default.default.existsSync(tsConfigBasePath)) {
496
- if (hasPaths(tsConfigBasePath)) {
497
- return tsConfigBasePath;
498
- }
499
- }
500
- currentDir = path__default.default.dirname(currentDir);
501
- }
502
- return null;
503
- }
504
- function getHandlerForFile(filePath) {
505
- if (tsConfigPath && typeof tsConfigPath === "string") {
506
- if (!handlerCache.has(tsConfigPath)) {
507
- handlerCache.set(
508
- tsConfigPath,
509
- typescriptPaths.createHandler({
510
- log: () => {
511
- },
512
- tsConfigPath,
513
- respectCoreModule,
514
- falllback: (moduleName) => fs__default.default.existsSync(moduleName)
515
- })
516
- );
517
- }
518
- return handlerCache.get(tsConfigPath);
519
- }
520
- const configPath = findTsConfigForFile(filePath);
521
- if (!configPath) {
522
- return null;
523
- }
524
- if (!handlerCache.has(configPath)) {
525
- handlerCache.set(
526
- configPath,
527
- typescriptPaths.createHandler({
528
- log: () => {
529
- },
530
- tsConfigPath: configPath,
531
- respectCoreModule,
532
- falllback: (moduleName) => fs__default.default.existsSync(moduleName)
533
- })
534
- );
535
- }
536
- return handlerCache.get(configPath);
537
- }
538
- function resolveAlias(request, importer) {
539
- const dynamicHandler = getHandlerForFile(importer);
540
- if (!dynamicHandler) {
541
- return null;
542
- }
543
- const resolved = dynamicHandler(request, path.normalize(importer));
544
- return resolved;
545
- }
546
- return {
547
- name: PLUGIN_NAME,
548
- resolveId: {
549
- order: "pre",
550
- async handler(request, importer, options) {
551
- if (!importer || request.startsWith("\0") || importer.charCodeAt(0) === 0) {
552
- return null;
553
- }
554
- if (!path__default.default.isAbsolute(importer)) {
555
- importer = path__default.default.resolve(process.cwd(), importer);
556
- }
557
- const moduleName = resolveAlias(request, importer);
558
- if (!moduleName) {
559
- const resolved2 = await this.resolve(request, importer, { skipSelf: true, ...options });
560
- if (!resolved2) {
561
- return null;
562
- }
563
- if (localResolve) {
564
- const importerInfo = this.getModuleInfo(importer);
565
- const importerPluginMeta = importerInfo?.meta?.[PLUGIN_NAME];
566
- if (!request.startsWith("./") && !request.startsWith("../") && importerPluginMeta?.resolved) {
567
- return {
568
- ...resolved2,
569
- external: !request.startsWith("hono/") && request !== "hono"
570
- };
571
- }
572
- }
573
- return {
574
- ...resolved2,
575
- meta: {
576
- ...resolved2.meta || {}
577
- }
578
- };
579
- }
580
- const resolvedModuleName = resolveJsImportToSourceFile(moduleName);
581
- if (!path__default.default.extname(resolvedModuleName)) {
582
- const resolved2 = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });
583
- if (!resolved2) {
584
- return null;
585
- }
586
- return {
587
- ...resolved2,
588
- meta: {
589
- ...resolved2.meta,
590
- [PLUGIN_NAME]: {
591
- resolved: true
592
- }
593
- }
594
- };
595
- }
596
- const resolved = await this.resolve(resolvedModuleName, importer, { skipSelf: true, ...options });
597
- if (!resolved) {
598
- return null;
599
- }
600
- return {
601
- ...resolved,
602
- meta: {
603
- ...resolved.meta,
604
- [PLUGIN_NAME]: {
605
- resolved: true
606
- }
607
- }
608
- };
609
- }
610
- }
611
- };
612
- }
613
-
614
- // src/build/bundler.ts
615
- function mastraInternalAliasPlugin(entryFile) {
616
- const normalizedEntryFile = chunkJZRFRUGM_cjs.slash(entryFile);
617
- return alias__default.default({
618
- entries: [
619
- {
620
- find: /^\#server$/,
621
- replacement: chunkJZRFRUGM_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")))
622
- },
623
- {
624
- find: /^\@mastra\/server\/(.*)/,
625
- replacement: `@mastra/server/$1`,
626
- customResolver: (id) => {
627
- if (id.startsWith("@mastra/server")) {
628
- return {
629
- id: url.fileURLToPath(undefined(id))
630
- };
631
- }
632
- }
633
- },
634
- { find: /^\#mastra$/, replacement: normalizedEntryFile }
635
- ]
636
- });
637
- }
638
- function mastraToolsAliasPlugin() {
639
- return {
640
- name: "tools-rewriter",
641
- resolveId(id) {
642
- if (id === "#tools") {
643
- return {
644
- id: "./tools.mjs",
645
- external: true
646
- };
647
- }
648
- }
649
- };
650
- }
651
- async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = { "process.env.NODE_ENV": JSON.stringify("production") }, {
652
- sourcemap = false,
653
- isDev = false,
654
- projectRoot,
655
- workspaceRoot = void 0,
656
- enableEsmShim = true,
657
- externalsPreset = false
658
- }) {
659
- const nodeResolvePlugin = nodeResolve__default.default(chunkJZRFRUGM_cjs.getNodeResolveOptions(platform));
660
- const externalsCopy = new Set(analyzedBundleInfo.externalDependencies.keys());
661
- const externals = externalsPreset ? [] : Array.from(externalsCopy);
662
- return {
663
- logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
664
- treeshake: "smallest",
665
- preserveSymlinks: true,
666
- external: externals,
667
- plugins: [
668
- protocolExternalResolver(),
669
- subpathExternalsResolver(externals),
670
- {
671
- name: "alias-optimized-deps",
672
- resolveId(id) {
673
- if (!analyzedBundleInfo.dependencies.has(id)) {
674
- return null;
675
- }
676
- const filename = analyzedBundleInfo.dependencies.get(id);
677
- const absolutePath = path.join(workspaceRoot || projectRoot, filename);
678
- if (isDev) {
679
- return {
680
- id: process.platform === "win32" ? url.pathToFileURL(absolutePath).href : absolutePath,
681
- external: true
682
- };
683
- }
684
- return {
685
- id: absolutePath,
686
- external: false
687
- };
688
- }
689
- },
690
- mastraInternalAliasPlugin(entryFile),
691
- tsConfigPaths(),
692
- mastraToolsAliasPlugin(),
693
- esbuild({
694
- platform,
695
- define: env
696
- }),
697
- rollupPlugin.optimizeLodashImports({
698
- include: "**/*.{js,ts,mjs,cjs}"
699
- }),
700
- externalsPreset ? null : commonjs__default.default({
701
- extensions: [".js", ".ts"],
702
- transformMixedEsModules: true,
703
- esmExternals(id) {
704
- return externals.includes(id);
705
- }
706
- }),
707
- enableEsmShim ? esmShim() : void 0,
708
- externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,
709
- // for debugging
710
- // {
711
- // name: 'logger',
712
- // //@ts-expect-error
713
- // resolveId(id, ...args) {
714
- // console.log({ id, args });
715
- // },
716
- // // @ts-expect-error
717
- // transform(code, id) {
718
- // if (code.includes('class Duplexify ')) {
719
- // console.log({ duplex: id });
720
- // }
721
- // },
722
- // },
723
- json__default.default(),
724
- localStorageDetector(workspaceRoot || projectRoot),
725
- removeDeployer2(entryFile, { sourcemap }),
726
- // treeshake unused imports
727
- esbuild({
728
- include: entryFile,
729
- platform
730
- })
731
- ].filter(Boolean)
732
- };
733
- }
734
- async function createBundler(inputOptions, outputOptions) {
735
- const bundler = await rollup.rollup(inputOptions);
736
- return {
737
- write: () => {
738
- return bundler.write({
739
- ...outputOptions,
740
- format: "esm",
741
- entryFileNames: "[name].mjs",
742
- chunkFileNames: "[name].mjs"
743
- });
744
- },
745
- close: () => {
746
- return bundler.close();
747
- }
748
- };
749
- }
750
-
751
- exports.createBundler = createBundler;
752
- exports.esbuild = esbuild;
753
- exports.esmShim = esmShim;
754
- exports.getInputOptions = getInputOptions;
755
- exports.getPackageMetadata = getPackageMetadata;
756
- exports.getPackageRootPath = getPackageRootPath;
757
- exports.mastraInternalAliasPlugin = mastraInternalAliasPlugin;
758
- exports.mastraToolsAliasPlugin = mastraToolsAliasPlugin;
759
- exports.nodeModulesExtensionResolver = nodeModulesExtensionResolver;
760
- exports.protocolExternalResolver = protocolExternalResolver;
761
- exports.removeDeployer = removeDeployer2;
762
- exports.subpathExternalsResolver = subpathExternalsResolver;
763
- exports.tsConfigPaths = tsConfigPaths;
764
- //# sourceMappingURL=chunk-3XIMK24X.cjs.map
765
- //# sourceMappingURL=chunk-3XIMK24X.cjs.map