@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.
- package/.turbo/turbo-build.log +41 -0
- package/CHANGELOG.md +897 -0
- package/LICENSE +44 -0
- package/README.md +159 -0
- package/dist/_tsup-dts-rollup.d.cts +360 -0
- package/dist/_tsup-dts-rollup.d.ts +360 -0
- package/dist/build/analyze.cjs +367 -0
- package/dist/build/analyze.d.cts +1 -0
- package/dist/build/analyze.d.ts +1 -0
- package/dist/build/analyze.js +2 -0
- package/dist/build/bundler.cjs +353 -0
- package/dist/build/bundler.d.cts +2 -0
- package/dist/build/bundler.d.ts +2 -0
- package/dist/build/bundler.js +2 -0
- package/dist/build/index.cjs +1146 -0
- package/dist/build/index.d.cts +10 -0
- package/dist/build/index.d.ts +10 -0
- package/dist/build/index.js +5 -0
- package/dist/bundler/index.cjs +999 -0
- package/dist/bundler/index.d.cts +1 -0
- package/dist/bundler/index.d.ts +1 -0
- package/dist/bundler/index.js +5 -0
- package/dist/chunk-3ONBKVC4.js +113 -0
- package/dist/chunk-AXS5WSIK.js +290 -0
- package/dist/chunk-DTSFVNIF.js +260 -0
- package/dist/chunk-JMH7HCD6.js +274 -0
- package/dist/chunk-SGK37ZWD.js +254 -0
- package/dist/chunk-YNXJO2XU.js +69 -0
- package/dist/index.cjs +1229 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +131 -0
- package/dist/server/index.cjs +4930 -0
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +4923 -0
- package/dist/templates/instrumentation-template.js +86 -0
- package/eslint.config.js +6 -0
- package/global.d.ts +0 -0
- package/package.json +112 -0
- package/public/templates/instrumentation-template.js +86 -0
- package/src/build/analyze.ts +279 -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 +135 -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 +144 -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 +209 -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 +114 -0
- package/src/server/handlers/utils.ts +15 -0
- package/src/server/handlers/vector.ts +149 -0
- package/src/server/handlers/workflows.ts +119 -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.d.cts
ADDED
|
@@ -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';
|
package/dist/index.d.ts
ADDED
|
@@ -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 };
|