@mastra/deployer 0.0.0-storage-20250225005900
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/.turbo/turbo-build.log +30 -0
- package/CHANGELOG.md +855 -0
- package/LICENSE +44 -0
- package/README.md +159 -0
- package/dist/_tsup-dts-rollup.d.ts +360 -0
- package/dist/build/analyze.d.ts +1 -0
- package/dist/build/analyze.js +2 -0
- package/dist/build/bundler.d.ts +2 -0
- package/dist/build/bundler.js +2 -0
- package/dist/build/index.d.ts +10 -0
- package/dist/build/index.js +5 -0
- package/dist/bundler/index.d.ts +1 -0
- package/dist/bundler/index.js +5 -0
- package/dist/chunk-AXS5WSIK.js +290 -0
- package/dist/chunk-BTUQ6UBB.js +254 -0
- package/dist/chunk-IHPQAB7O.js +113 -0
- package/dist/chunk-KXS4XYEJ.js +251 -0
- package/dist/chunk-SESHBX76.js +267 -0
- package/dist/chunk-YNXJO2XU.js +69 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +131 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +4907 -0
- package/dist/templates/instrumentation-template.js +86 -0
- package/eslint.config.js +6 -0
- package/global.d.ts +0 -0
- package/package.json +84 -0
- package/public/templates/instrumentation-template.js +86 -0
- package/src/build/analyze.ts +271 -0
- package/src/build/babel/fix-libsql.ts +41 -0
- package/src/build/babel/get-deployer.ts +54 -0
- package/src/build/babel/get-telemetry-config.ts +62 -0
- package/src/build/babel/remove-deployer.ts +43 -0
- package/src/build/bundle.ts +139 -0
- package/src/build/bundler.ts +126 -0
- package/src/build/deployer.ts +67 -0
- package/src/build/deps.ts +149 -0
- package/src/build/env.ts +76 -0
- package/src/build/fs.ts +66 -0
- package/src/build/index.ts +7 -0
- package/src/build/isNodeBuiltin.ts +7 -0
- package/src/build/plugins/fix-libsql.ts +69 -0
- package/src/build/plugins/hono-alias.ts +17 -0
- package/src/build/plugins/pino.ts +93 -0
- package/src/build/plugins/remove-deployer.ts +37 -0
- package/src/build/plugins/telemetry-fix.ts +54 -0
- package/src/build/telemetry.ts +76 -0
- package/src/build/utils.ts +12 -0
- package/src/build/watcher.ts +43 -0
- package/src/bundler/index.ts +145 -0
- package/src/deploy/base.ts +30 -0
- package/src/deploy/index.ts +2 -0
- package/src/deploy/log.ts +61 -0
- package/src/index.ts +3 -0
- package/src/server/handlers/agents.ts +210 -0
- package/src/server/handlers/client.ts +36 -0
- package/src/server/handlers/error.ts +29 -0
- package/src/server/handlers/logs.ts +53 -0
- package/src/server/handlers/memory.ts +196 -0
- package/src/server/handlers/prompt.ts +128 -0
- package/src/server/handlers/root.ts +6 -0
- package/src/server/handlers/telemetry.ts +48 -0
- package/src/server/handlers/tools.ts +107 -0
- package/src/server/handlers/utils.ts +15 -0
- package/src/server/handlers/vector.ts +149 -0
- package/src/server/handlers/workflows.ts +104 -0
- package/src/server/index.ts +1355 -0
- package/src/server/openapi.json +434 -0
- package/src/server/openapi.script.js +22 -0
- package/src/server/types.ts +4 -0
- package/src/server/welcome.ts +105 -0
- package/tsconfig.json +5 -0
- package/vitest.config.ts +8 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { FileService } from './chunk-BTUQ6UBB.js';
|
|
2
|
+
export { FileService } from './chunk-BTUQ6UBB.js';
|
|
3
|
+
import { Bundler } from './chunk-IHPQAB7O.js';
|
|
4
|
+
import { Deps } from './chunk-AXS5WSIK.js';
|
|
5
|
+
export { Deps, createChildProcessLogger, createPinoStream } from './chunk-AXS5WSIK.js';
|
|
6
|
+
import './chunk-SESHBX76.js';
|
|
7
|
+
import './chunk-KXS4XYEJ.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 };
|