@mastra/deployer 0.10.0 → 0.10.1-alpha.1

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.
@@ -329,6 +329,14 @@ export declare function getAgentExecutionHandler(c: Context): Promise<Response>;
329
329
 
330
330
  export declare function getAgentsHandler(c: Context): Promise<Response & TypedResponse<any, ContentfulStatusCode, "json">>;
331
331
 
332
+ declare function getBundlerOptions(entryFile: string, outputDir: string): Promise<Config['bundler'] | null>;
333
+ export { getBundlerOptions }
334
+ export { getBundlerOptions as getBundlerOptions_alias_1 }
335
+
336
+ export declare function getBundlerOptionsBundler(entryFile: string, result: {
337
+ hasCustomConfig: false;
338
+ }): Promise<RollupBuild>;
339
+
332
340
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
333
341
  export { getDeployer }
334
342
  export { getDeployer as getDeployer_alias_1 }
@@ -651,6 +659,10 @@ export declare function recursiveRemoveNonReferencedNodes(code: string): Promise
651
659
 
652
660
  export declare function removeAllExceptDeployer(): babel_2.PluginObj;
653
661
 
662
+ export declare function removeAllOptionsExceptBundler(result: {
663
+ hasCustomConfig: boolean;
664
+ }): PluginObj<PluginPass>;
665
+
654
666
  export declare function removeAllOptionsExceptServer(result: {
655
667
  hasCustomConfig: boolean;
656
668
  }): PluginObj<PluginPass>;
@@ -661,7 +673,7 @@ export declare function removeAllOptionsExceptTelemetry(result: {
661
673
 
662
674
  export declare function removeAllOptionsFromMastraExcept(result: {
663
675
  hasCustomConfig: boolean;
664
- }, option: 'telemetry' | 'server'): babel_2.PluginObj;
676
+ }, option: 'telemetry' | 'server' | 'bundler'): babel_2.PluginObj;
665
677
 
666
678
  export declare function removeDeployer(): babel_2.PluginObj;
667
679
 
@@ -715,6 +727,8 @@ export declare function streamGenerateHandler(c: Context): Promise<Response | un
715
727
 
716
728
  export declare function streamGenerateHandler_alias_1(c: Context): Promise<Response | undefined>;
717
729
 
730
+ export declare function streamWorkflowHandler(c: Context): Promise<Response>;
731
+
718
732
  declare type TransitiveDependencyResult = {
719
733
  resolutions: Record<string, string>;
720
734
  usedWorkspacePackages: Set<string>;
@@ -329,6 +329,14 @@ export declare function getAgentExecutionHandler(c: Context): Promise<Response>;
329
329
 
330
330
  export declare function getAgentsHandler(c: Context): Promise<Response & TypedResponse<any, ContentfulStatusCode, "json">>;
331
331
 
332
+ declare function getBundlerOptions(entryFile: string, outputDir: string): Promise<Config['bundler'] | null>;
333
+ export { getBundlerOptions }
334
+ export { getBundlerOptions as getBundlerOptions_alias_1 }
335
+
336
+ export declare function getBundlerOptionsBundler(entryFile: string, result: {
337
+ hasCustomConfig: false;
338
+ }): Promise<RollupBuild>;
339
+
332
340
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
333
341
  export { getDeployer }
334
342
  export { getDeployer as getDeployer_alias_1 }
@@ -651,6 +659,10 @@ export declare function recursiveRemoveNonReferencedNodes(code: string): Promise
651
659
 
652
660
  export declare function removeAllExceptDeployer(): babel_2.PluginObj;
653
661
 
662
+ export declare function removeAllOptionsExceptBundler(result: {
663
+ hasCustomConfig: boolean;
664
+ }): PluginObj<PluginPass>;
665
+
654
666
  export declare function removeAllOptionsExceptServer(result: {
655
667
  hasCustomConfig: boolean;
656
668
  }): PluginObj<PluginPass>;
@@ -661,7 +673,7 @@ export declare function removeAllOptionsExceptTelemetry(result: {
661
673
 
662
674
  export declare function removeAllOptionsFromMastraExcept(result: {
663
675
  hasCustomConfig: boolean;
664
- }, option: 'telemetry' | 'server'): babel_2.PluginObj;
676
+ }, option: 'telemetry' | 'server' | 'bundler'): babel_2.PluginObj;
665
677
 
666
678
  export declare function removeDeployer(): babel_2.PluginObj;
667
679
 
@@ -715,6 +727,8 @@ export declare function streamGenerateHandler(c: Context): Promise<Response | un
715
727
 
716
728
  export declare function streamGenerateHandler_alias_1(c: Context): Promise<Response | undefined>;
717
729
 
730
+ export declare function streamWorkflowHandler(c: Context): Promise<Response>;
731
+
718
732
  declare type TransitiveDependencyResult = {
719
733
  resolutions: Record<string, string>;
720
734
  usedWorkspacePackages: Set<string>;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkHHZDRBPV_cjs = require('../chunk-HHZDRBPV.cjs');
3
+ var chunkOJY5LJPT_cjs = require('../chunk-OJY5LJPT.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "analyzeBundle", {
8
8
  enumerable: true,
9
- get: function () { return chunkHHZDRBPV_cjs.analyzeBundle; }
9
+ get: function () { return chunkOJY5LJPT_cjs.analyzeBundle; }
10
10
  });
@@ -1 +1 @@
1
- export { analyzeBundle } from '../chunk-EHPJDSR3.js';
1
+ export { analyzeBundle } from '../chunk-W46BY5GT.js';
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkWHD7NHLX_cjs = require('../chunk-WHD7NHLX.cjs');
4
- var chunk3R6WDRBB_cjs = require('../chunk-3R6WDRBB.cjs');
5
- var chunkHHZDRBPV_cjs = require('../chunk-HHZDRBPV.cjs');
3
+ var chunkYHCVXGZM_cjs = require('../chunk-YHCVXGZM.cjs');
4
+ var chunkWK63QOD5_cjs = require('../chunk-WK63QOD5.cjs');
5
+ var chunkOJY5LJPT_cjs = require('../chunk-OJY5LJPT.cjs');
6
6
  var chunkIMGVLBV7_cjs = require('../chunk-IMGVLBV7.cjs');
7
7
  var chunk4VC5Z4YR_cjs = require('../chunk-4VC5Z4YR.cjs');
8
8
 
@@ -10,23 +10,27 @@ var chunk4VC5Z4YR_cjs = require('../chunk-4VC5Z4YR.cjs');
10
10
 
11
11
  Object.defineProperty(exports, "createWatcher", {
12
12
  enumerable: true,
13
- get: function () { return chunkWHD7NHLX_cjs.createWatcher; }
13
+ get: function () { return chunkYHCVXGZM_cjs.createWatcher; }
14
14
  });
15
15
  Object.defineProperty(exports, "getServerOptions", {
16
16
  enumerable: true,
17
- get: function () { return chunkWHD7NHLX_cjs.getServerOptions; }
17
+ get: function () { return chunkYHCVXGZM_cjs.getServerOptions; }
18
18
  });
19
19
  Object.defineProperty(exports, "getWatcherInputOptions", {
20
20
  enumerable: true,
21
- get: function () { return chunkWHD7NHLX_cjs.getInputOptions; }
21
+ get: function () { return chunkYHCVXGZM_cjs.getInputOptions; }
22
22
  });
23
23
  Object.defineProperty(exports, "writeTelemetryConfig", {
24
24
  enumerable: true,
25
- get: function () { return chunk3R6WDRBB_cjs.writeTelemetryConfig; }
25
+ get: function () { return chunkWK63QOD5_cjs.writeTelemetryConfig; }
26
26
  });
27
27
  Object.defineProperty(exports, "analyzeBundle", {
28
28
  enumerable: true,
29
- get: function () { return chunkHHZDRBPV_cjs.analyzeBundle; }
29
+ get: function () { return chunkOJY5LJPT_cjs.analyzeBundle; }
30
+ });
31
+ Object.defineProperty(exports, "getBundlerOptions", {
32
+ enumerable: true,
33
+ get: function () { return chunkOJY5LJPT_cjs.getBundlerOptions; }
30
34
  });
31
35
  Object.defineProperty(exports, "createBundler", {
32
36
  enumerable: true,
@@ -7,3 +7,4 @@ export { FileService_alias_1 as FileService } from '../_tsup-dts-rollup.cjs';
7
7
  export { Deps_alias_1 as Deps } from '../_tsup-dts-rollup.cjs';
8
8
  export { writeTelemetryConfig } from '../_tsup-dts-rollup.cjs';
9
9
  export { getServerOptions } from '../_tsup-dts-rollup.cjs';
10
+ export { getBundlerOptions_alias_1 as getBundlerOptions } from '../_tsup-dts-rollup.cjs';
@@ -7,3 +7,4 @@ export { FileService_alias_1 as FileService } from '../_tsup-dts-rollup.js';
7
7
  export { Deps_alias_1 as Deps } from '../_tsup-dts-rollup.js';
8
8
  export { writeTelemetryConfig } from '../_tsup-dts-rollup.js';
9
9
  export { getServerOptions } from '../_tsup-dts-rollup.js';
10
+ export { getBundlerOptions_alias_1 as getBundlerOptions } from '../_tsup-dts-rollup.js';
@@ -1,5 +1,5 @@
1
- export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-U5VNUAES.js';
2
- export { writeTelemetryConfig } from '../chunk-TUMXQX4H.js';
3
- export { analyzeBundle } from '../chunk-EHPJDSR3.js';
1
+ export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-5ZQI6XPC.js';
2
+ export { writeTelemetryConfig } from '../chunk-O3VM5GJZ.js';
3
+ export { analyzeBundle, getBundlerOptions } from '../chunk-W46BY5GT.js';
4
4
  export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-AOSWYZKN.js';
5
5
  export { Deps, FileService } from '../chunk-UV4RQQ3R.js';
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkBQAYAQTU_cjs = require('../chunk-BQAYAQTU.cjs');
3
+ var chunkPJB6TDF7_cjs = require('../chunk-PJB6TDF7.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Bundler", {
8
8
  enumerable: true,
9
- get: function () { return chunkBQAYAQTU_cjs.Bundler; }
9
+ get: function () { return chunkPJB6TDF7_cjs.Bundler; }
10
10
  });
@@ -1 +1 @@
1
- export { Bundler } from '../chunk-YU2QBGOU.js';
1
+ export { Bundler } from '../chunk-DGNRILK6.js';
@@ -1,5 +1,4 @@
1
- import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-TUMXQX4H.js';
2
- import { aliasHono } from './chunk-EHPJDSR3.js';
1
+ import { aliasHono, recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-W46BY5GT.js';
3
2
  import { getInputOptions } from './chunk-AOSWYZKN.js';
4
3
  import { tsConfigPaths } from './chunk-WVBUOQT6.js';
5
4
  import { watch, rollup } from 'rollup';
@@ -1,5 +1,5 @@
1
- import { writeTelemetryConfig } from './chunk-TUMXQX4H.js';
2
- import { analyzeBundle } from './chunk-EHPJDSR3.js';
1
+ import { writeTelemetryConfig } from './chunk-O3VM5GJZ.js';
2
+ import { analyzeBundle } from './chunk-W46BY5GT.js';
3
3
  import { createBundler, getInputOptions } from './chunk-AOSWYZKN.js';
4
4
  import { DepsService, FileService } from './chunk-UV4RQQ3R.js';
5
5
  import { existsSync } from 'node:fs';
@@ -9,6 +9,7 @@ import { fileURLToPath } from 'node:url';
9
9
  import { MastraBundler } from '@mastra/core/bundler';
10
10
  import virtual from '@rollup/plugin-virtual';
11
11
  import fsExtra, { emptyDir, ensureDir, copy, readJSON } from 'fs-extra/esm';
12
+ import { globby } from 'globby';
12
13
  import resolveFrom from 'resolve-from';
13
14
  import slugify from '@sindresorhus/slugify';
14
15
  import { findWorkspaces, findWorkspacesRoot } from 'find-workspaces';
@@ -203,22 +204,25 @@ var Bundler = class extends MastraBundler {
203
204
  async getToolsInputOptions(toolsPaths) {
204
205
  const inputs = {};
205
206
  for (const toolPath of toolsPaths) {
206
- if (await fsExtra.pathExists(toolPath)) {
207
- const fileService = new FileService();
208
- const entryFile = fileService.getFirstExistingFile([
209
- join(toolPath, "index.ts"),
210
- join(toolPath, "index.js"),
211
- toolPath
212
- // if toolPath itself is a file
213
- ]);
214
- if (!entryFile || (await stat(entryFile)).isDirectory()) {
215
- this.logger.warn(`No entry file found in ${toolPath}, skipping...`);
216
- continue;
207
+ const expandedPaths = await globby(toolPath, {});
208
+ for (const path of expandedPaths) {
209
+ if (await fsExtra.pathExists(path)) {
210
+ const fileService = new FileService();
211
+ const entryFile = fileService.getFirstExistingFile([
212
+ join(path, "index.ts"),
213
+ join(path, "index.js"),
214
+ path
215
+ // if path itself is a file
216
+ ]);
217
+ if (!entryFile || (await stat(entryFile)).isDirectory()) {
218
+ this.logger.warn(`No entry file found in ${path}, skipping...`);
219
+ continue;
220
+ }
221
+ const uniqueToolID = crypto.randomUUID();
222
+ inputs[`tools/${uniqueToolID}`] = entryFile;
223
+ } else {
224
+ this.logger.warn(`Tool path ${path} does not exist, skipping...`);
217
225
  }
218
- const uniqueToolID = crypto.randomUUID();
219
- inputs[`tools/${uniqueToolID}`] = entryFile;
220
- } else {
221
- this.logger.warn(`Tool path ${toolPath} does not exist, skipping...`);
222
226
  }
223
227
  }
224
228
  return inputs;
@@ -0,0 +1,99 @@
1
+ import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-W46BY5GT.js';
2
+ import * as babel from '@babel/core';
3
+ import { rollup } from 'rollup';
4
+ import esbuild from 'rollup-plugin-esbuild';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+
7
+ // src/build/babel/remove-all-options-telemetry.ts
8
+ function removeAllOptionsExceptTelemetry(result) {
9
+ return removeAllOptionsFromMastraExcept(result, "telemetry");
10
+ }
11
+
12
+ // src/build/telemetry.ts
13
+ function getTelemetryBundler(entryFile, result) {
14
+ return rollup({
15
+ logLevel: "silent",
16
+ input: {
17
+ "telemetry-config": entryFile
18
+ },
19
+ treeshake: "smallest",
20
+ plugins: [
21
+ // transpile typescript to something we understand
22
+ esbuild({
23
+ target: "node20",
24
+ platform: "node",
25
+ minify: false
26
+ }),
27
+ commonjs({
28
+ extensions: [".js", ".ts"],
29
+ strictRequires: "strict",
30
+ transformMixedEsModules: true,
31
+ ignoreTryCatch: false
32
+ }),
33
+ {
34
+ name: "get-telemetry-config",
35
+ transform(code, id) {
36
+ if (id !== entryFile) {
37
+ return;
38
+ }
39
+ return new Promise((resolve, reject) => {
40
+ babel.transform(
41
+ code,
42
+ {
43
+ babelrc: false,
44
+ configFile: false,
45
+ filename: id,
46
+ plugins: [removeAllOptionsExceptTelemetry(result)]
47
+ },
48
+ (err, result2) => {
49
+ if (err) {
50
+ return reject(err);
51
+ }
52
+ resolve({
53
+ code: result2.code,
54
+ map: result2.map
55
+ });
56
+ }
57
+ );
58
+ });
59
+ }
60
+ },
61
+ // let esbuild remove all unused imports
62
+ esbuild({
63
+ target: "node20",
64
+ platform: "node",
65
+ minify: false
66
+ }),
67
+ {
68
+ name: "cleanup",
69
+ transform(code, id) {
70
+ if (id !== entryFile) {
71
+ return;
72
+ }
73
+ return recursiveRemoveNonReferencedNodes(code);
74
+ }
75
+ },
76
+ // let esbuild remove all unused imports
77
+ esbuild({
78
+ target: "node20",
79
+ platform: "node",
80
+ minify: false
81
+ })
82
+ ]
83
+ });
84
+ }
85
+ async function writeTelemetryConfig(entryFile, outputDir) {
86
+ const result = {
87
+ hasCustomConfig: false
88
+ };
89
+ const bundle = await getTelemetryBundler(entryFile, result);
90
+ const { output } = await bundle.write({
91
+ dir: outputDir,
92
+ format: "es",
93
+ entryFileNames: "[name].mjs"
94
+ });
95
+ const externals = output[0].imports.filter((x) => !x.startsWith("./"));
96
+ return { ...result, externalDependencies: externals };
97
+ }
98
+
99
+ export { writeTelemetryConfig };