@mastra/deployer 0.0.0-commonjs-20250227130920

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 (86) hide show
  1. package/.turbo/turbo-build.log +41 -0
  2. package/CHANGELOG.md +897 -0
  3. package/LICENSE +44 -0
  4. package/README.md +159 -0
  5. package/dist/_tsup-dts-rollup.d.cts +360 -0
  6. package/dist/_tsup-dts-rollup.d.ts +360 -0
  7. package/dist/build/analyze.cjs +367 -0
  8. package/dist/build/analyze.d.cts +1 -0
  9. package/dist/build/analyze.d.ts +1 -0
  10. package/dist/build/analyze.js +2 -0
  11. package/dist/build/bundler.cjs +353 -0
  12. package/dist/build/bundler.d.cts +2 -0
  13. package/dist/build/bundler.d.ts +2 -0
  14. package/dist/build/bundler.js +2 -0
  15. package/dist/build/index.cjs +1146 -0
  16. package/dist/build/index.d.cts +10 -0
  17. package/dist/build/index.d.ts +10 -0
  18. package/dist/build/index.js +5 -0
  19. package/dist/bundler/index.cjs +999 -0
  20. package/dist/bundler/index.d.cts +1 -0
  21. package/dist/bundler/index.d.ts +1 -0
  22. package/dist/bundler/index.js +5 -0
  23. package/dist/chunk-3ONBKVC4.js +113 -0
  24. package/dist/chunk-AXS5WSIK.js +290 -0
  25. package/dist/chunk-DTSFVNIF.js +260 -0
  26. package/dist/chunk-JMH7HCD6.js +274 -0
  27. package/dist/chunk-SGK37ZWD.js +254 -0
  28. package/dist/chunk-YNXJO2XU.js +69 -0
  29. package/dist/index.cjs +1229 -0
  30. package/dist/index.d.cts +6 -0
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.js +131 -0
  33. package/dist/server/index.cjs +4930 -0
  34. package/dist/server/index.d.cts +2 -0
  35. package/dist/server/index.d.ts +2 -0
  36. package/dist/server/index.js +4923 -0
  37. package/dist/templates/instrumentation-template.js +86 -0
  38. package/eslint.config.js +6 -0
  39. package/global.d.ts +0 -0
  40. package/package.json +112 -0
  41. package/public/templates/instrumentation-template.js +86 -0
  42. package/src/build/analyze.ts +279 -0
  43. package/src/build/babel/fix-libsql.ts +41 -0
  44. package/src/build/babel/get-deployer.ts +54 -0
  45. package/src/build/babel/get-telemetry-config.ts +62 -0
  46. package/src/build/babel/remove-deployer.ts +43 -0
  47. package/src/build/bundle.ts +139 -0
  48. package/src/build/bundler.ts +135 -0
  49. package/src/build/deployer.ts +67 -0
  50. package/src/build/deps.ts +149 -0
  51. package/src/build/env.ts +76 -0
  52. package/src/build/fs.ts +66 -0
  53. package/src/build/index.ts +7 -0
  54. package/src/build/isNodeBuiltin.ts +7 -0
  55. package/src/build/plugins/fix-libsql.ts +69 -0
  56. package/src/build/plugins/hono-alias.ts +17 -0
  57. package/src/build/plugins/pino.ts +93 -0
  58. package/src/build/plugins/remove-deployer.ts +37 -0
  59. package/src/build/plugins/telemetry-fix.ts +54 -0
  60. package/src/build/telemetry.ts +76 -0
  61. package/src/build/utils.ts +12 -0
  62. package/src/build/watcher.ts +43 -0
  63. package/src/bundler/index.ts +144 -0
  64. package/src/deploy/base.ts +30 -0
  65. package/src/deploy/index.ts +2 -0
  66. package/src/deploy/log.ts +61 -0
  67. package/src/index.ts +3 -0
  68. package/src/server/handlers/agents.ts +209 -0
  69. package/src/server/handlers/client.ts +36 -0
  70. package/src/server/handlers/error.ts +29 -0
  71. package/src/server/handlers/logs.ts +53 -0
  72. package/src/server/handlers/memory.ts +196 -0
  73. package/src/server/handlers/prompt.ts +128 -0
  74. package/src/server/handlers/root.ts +6 -0
  75. package/src/server/handlers/telemetry.ts +48 -0
  76. package/src/server/handlers/tools.ts +114 -0
  77. package/src/server/handlers/utils.ts +15 -0
  78. package/src/server/handlers/vector.ts +149 -0
  79. package/src/server/handlers/workflows.ts +119 -0
  80. package/src/server/index.ts +1355 -0
  81. package/src/server/openapi.json +434 -0
  82. package/src/server/openapi.script.js +22 -0
  83. package/src/server/types.ts +4 -0
  84. package/src/server/welcome.ts +105 -0
  85. package/tsconfig.json +5 -0
  86. package/vitest.config.ts +8 -0
@@ -0,0 +1,6 @@
1
+ export { Deps } from './_tsup-dts-rollup.cjs';
2
+ export { FileService } from './_tsup-dts-rollup.cjs';
3
+ export { getDeployer } from './_tsup-dts-rollup.cjs';
4
+ export { Deployer } from './_tsup-dts-rollup.cjs';
5
+ export { createChildProcessLogger } from './_tsup-dts-rollup.cjs';
6
+ export { createPinoStream } from './_tsup-dts-rollup.cjs';
@@ -0,0 +1,6 @@
1
+ export { Deps } from './_tsup-dts-rollup.js';
2
+ export { FileService } from './_tsup-dts-rollup.js';
3
+ export { getDeployer } from './_tsup-dts-rollup.js';
4
+ export { Deployer } from './_tsup-dts-rollup.js';
5
+ export { createChildProcessLogger } from './_tsup-dts-rollup.js';
6
+ export { createPinoStream } from './_tsup-dts-rollup.js';
package/dist/index.js ADDED
@@ -0,0 +1,131 @@
1
+ import { FileService } from './chunk-SGK37ZWD.js';
2
+ export { FileService } from './chunk-SGK37ZWD.js';
3
+ import { Bundler } from './chunk-3ONBKVC4.js';
4
+ import { Deps } from './chunk-AXS5WSIK.js';
5
+ export { Deps, createChildProcessLogger, createPinoStream } from './chunk-AXS5WSIK.js';
6
+ import './chunk-JMH7HCD6.js';
7
+ import './chunk-DTSFVNIF.js';
8
+ import './chunk-YNXJO2XU.js';
9
+ import * as babel from '@babel/core';
10
+ import babel__default from '@babel/core';
11
+ import { rollup } from 'rollup';
12
+ import esbuild from 'rollup-plugin-esbuild';
13
+
14
+ // src/deploy/base.ts
15
+ var Deployer = class extends Bundler {
16
+ deps = new Deps();
17
+ constructor(args) {
18
+ super(args.name, "DEPLOYER");
19
+ this.deps.__setLogger(this.logger);
20
+ }
21
+ getEnvFiles() {
22
+ const possibleFiles = [".env.production", ".env"];
23
+ try {
24
+ const fileService = new FileService();
25
+ const envFile = fileService.getFirstExistingFile(possibleFiles);
26
+ return Promise.resolve([envFile]);
27
+ } catch {
28
+ }
29
+ return Promise.resolve([]);
30
+ }
31
+ };
32
+ function removeAllExceptDeployer() {
33
+ let mastraClass = null;
34
+ const t = babel__default.types;
35
+ return {
36
+ name: "remove-all-except-deployer",
37
+ visitor: {
38
+ ExportNamedDeclaration: {
39
+ // remove all exports
40
+ exit(path) {
41
+ path.remove();
42
+ }
43
+ },
44
+ ImportDeclaration(path) {
45
+ if ((path.node.source.value === "@mastra/core" || path.node.source.value === "@mastra/core/mastra") && path.node.specifiers) {
46
+ mastraClass = path.node.specifiers.find(
47
+ // @ts-ignore - no need to type
48
+ (p) => p.imported?.name === "Mastra"
49
+ )?.local?.name ?? null;
50
+ }
51
+ },
52
+ NewExpression(path) {
53
+ if (mastraClass && path.node.callee.name === mastraClass) {
54
+ const deployer = path.node.arguments[0]?.properties?.find(
55
+ // @ts-ignore
56
+ (prop) => prop.key.name === "deployer"
57
+ );
58
+ const programPath = path.scope.getProgramParent().path;
59
+ if (!deployer || !programPath) {
60
+ return;
61
+ }
62
+ const exportDeclaration = t.exportNamedDeclaration(
63
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier("deployer"), deployer.value)]),
64
+ []
65
+ );
66
+ programPath.node.body.push(exportDeclaration);
67
+ }
68
+ }
69
+ }
70
+ };
71
+ }
72
+
73
+ // src/build/deployer.ts
74
+ async function getDeployer(entryFile, outputDir) {
75
+ const bundle = await rollup({
76
+ input: {
77
+ deployer: entryFile
78
+ },
79
+ treeshake: true,
80
+ plugins: [
81
+ // transpile typescript to something we understand
82
+ esbuild({
83
+ target: "node20",
84
+ platform: "node",
85
+ minify: false
86
+ }),
87
+ {
88
+ name: "get-deployer",
89
+ transform(code, id) {
90
+ if (!this.getModuleInfo(id)?.isEntry) {
91
+ return;
92
+ }
93
+ return new Promise((resolve, reject) => {
94
+ babel.transform(
95
+ code,
96
+ {
97
+ babelrc: false,
98
+ configFile: false,
99
+ filename: id,
100
+ plugins: [removeAllExceptDeployer]
101
+ },
102
+ (err, result) => {
103
+ if (err) {
104
+ return reject(err);
105
+ }
106
+ resolve({
107
+ code: result.code,
108
+ map: result.map
109
+ });
110
+ }
111
+ );
112
+ });
113
+ }
114
+ },
115
+ // let esbuild remove all unused imports
116
+ esbuild({
117
+ target: "node20",
118
+ platform: "node",
119
+ minify: false
120
+ })
121
+ ]
122
+ });
123
+ await bundle.write({
124
+ dir: outputDir,
125
+ format: "es",
126
+ entryFileNames: "[name].mjs"
127
+ });
128
+ return (await import(`file:${outputDir}/deployer.mjs`)).deployer;
129
+ }
130
+
131
+ export { Deployer, getDeployer };