@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.
@@ -1,5 +1,5 @@
1
1
  import { tsConfigPaths, removeDeployer } from './chunk-WVBUOQT6.js';
2
- import commonjs from '@rollup/plugin-commonjs';
2
+ import commonjs2 from '@rollup/plugin-commonjs';
3
3
  import json from '@rollup/plugin-json';
4
4
  import nodeResolve from '@rollup/plugin-node-resolve';
5
5
  import virtual from '@rollup/plugin-virtual';
@@ -11,6 +11,8 @@ import { builtinModules } from 'node:module';
11
11
  import { join, dirname } from 'node:path';
12
12
  import { spawn as spawn$1 } from 'node:child_process';
13
13
  import { writeFile } from 'node:fs/promises';
14
+ import * as babel from '@babel/core';
15
+ import babel__default from '@babel/core';
14
16
 
15
17
  function isNodeBuiltin(dep) {
16
18
  const [pkg] = dep.split("/");
@@ -65,6 +67,230 @@ function validate(file) {
65
67
  }
66
68
  );
67
69
  }
70
+ function removeAllOptionsFromMastraExcept(result, option) {
71
+ const t = babel__default.types;
72
+ return {
73
+ name: "remove-all-except-" + option + "-config",
74
+ visitor: {
75
+ ExportNamedDeclaration: {
76
+ // remove all exports
77
+ exit(path) {
78
+ path.remove();
79
+ }
80
+ },
81
+ NewExpression(path, state) {
82
+ const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
83
+ if (!varDeclaratorPath) {
84
+ return;
85
+ }
86
+ const parentNode = path.parentPath.node;
87
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
88
+ return;
89
+ }
90
+ let mastraArgs = t.objectExpression([]);
91
+ if (t.isObjectExpression(path.node.arguments[0])) {
92
+ mastraArgs = path.node.arguments[0];
93
+ }
94
+ let telemetry = mastraArgs.properties.find(
95
+ // @ts-ignore
96
+ (prop) => prop.key.name === option
97
+ );
98
+ let telemetryValue = t.objectExpression([]);
99
+ const programPath = path.scope.getProgramParent().path;
100
+ if (!programPath) {
101
+ return;
102
+ }
103
+ if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {
104
+ result.hasCustomConfig = true;
105
+ telemetryValue = telemetry.value;
106
+ if (t.isIdentifier(telemetry.value) && telemetry.value.name === option) {
107
+ const telemetryBinding = state.file.scope.getBinding(option);
108
+ if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
109
+ const id = path.scope.generateUidIdentifier(option);
110
+ telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
111
+ telemetryValue = id;
112
+ }
113
+ }
114
+ }
115
+ const exportDeclaration = t.exportNamedDeclaration(
116
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), telemetryValue)]),
117
+ []
118
+ );
119
+ programPath.node.body.push(exportDeclaration);
120
+ }
121
+ }
122
+ };
123
+ }
124
+
125
+ // src/build/babel/remove-all-options-bundler.ts
126
+ function removeAllOptionsExceptBundler(result) {
127
+ return removeAllOptionsFromMastraExcept(result, "bundler");
128
+ }
129
+ function removeNonReferencedNodes() {
130
+ const t = babel__default.types;
131
+ return {
132
+ name: "remove-non-referenced-nodes",
133
+ visitor: {
134
+ Program(path) {
135
+ const scope = path.scope;
136
+ const currentBody = path.get("body");
137
+ const filteredBody = currentBody.filter((childPath) => {
138
+ if (childPath.isExportDeclaration()) {
139
+ return true;
140
+ }
141
+ if (childPath.isVariableDeclaration()) {
142
+ return childPath.node.declarations.some((decl) => {
143
+ if (!t.isIdentifier(decl.id)) {
144
+ return false;
145
+ }
146
+ const name = decl.id.name;
147
+ const binding = scope.getBinding(name);
148
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
149
+ });
150
+ }
151
+ if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
152
+ if (!t.isIdentifier(childPath.node.id)) {
153
+ return false;
154
+ }
155
+ const name = childPath.node.id.name;
156
+ const binding = scope.getBinding(name);
157
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
158
+ }
159
+ if (childPath.isImportDeclaration()) {
160
+ return childPath.node.specifiers.some((specifier) => {
161
+ const importedName = specifier.local.name;
162
+ const binding = scope.getBinding(importedName);
163
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
164
+ });
165
+ }
166
+ return false;
167
+ });
168
+ path.set(
169
+ "body",
170
+ filteredBody.map((p) => p.node)
171
+ );
172
+ }
173
+ }
174
+ };
175
+ }
176
+
177
+ // src/build/plugins/remove-unused-references.ts
178
+ function recursiveRemoveNonReferencedNodes(code) {
179
+ return new Promise(async (resolve, reject) => {
180
+ babel.transform(
181
+ code,
182
+ {
183
+ babelrc: false,
184
+ configFile: false,
185
+ plugins: [removeNonReferencedNodes()]
186
+ },
187
+ (err, result) => {
188
+ if (err) {
189
+ return reject(err);
190
+ }
191
+ if (result && result.code !== code) {
192
+ return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
193
+ }
194
+ resolve({
195
+ code: result.code,
196
+ map: result.map
197
+ });
198
+ }
199
+ );
200
+ });
201
+ }
202
+
203
+ // src/build/bundlerOptions.ts
204
+ function getBundlerOptionsBundler(entryFile, result) {
205
+ return rollup({
206
+ logLevel: "silent",
207
+ input: {
208
+ "bundler-config": entryFile
209
+ },
210
+ treeshake: "smallest",
211
+ plugins: [
212
+ tsConfigPaths(),
213
+ // transpile typescript to something we understand
214
+ esbuild({
215
+ target: "node20",
216
+ platform: "node",
217
+ minify: false
218
+ }),
219
+ commonjs2({
220
+ extensions: [".js", ".ts"],
221
+ strictRequires: "strict",
222
+ transformMixedEsModules: true,
223
+ ignoreTryCatch: false
224
+ }),
225
+ {
226
+ name: "get-bundler-config",
227
+ transform(code, id) {
228
+ if (id !== entryFile) {
229
+ return;
230
+ }
231
+ return new Promise((resolve, reject) => {
232
+ babel.transform(
233
+ code,
234
+ {
235
+ babelrc: false,
236
+ configFile: false,
237
+ filename: id,
238
+ plugins: [removeAllOptionsExceptBundler(result)]
239
+ },
240
+ (err, result2) => {
241
+ if (err) {
242
+ return reject(err);
243
+ }
244
+ resolve({
245
+ code: result2.code,
246
+ map: result2.map
247
+ });
248
+ }
249
+ );
250
+ });
251
+ }
252
+ },
253
+ // let esbuild remove all unused imports
254
+ esbuild({
255
+ target: "node20",
256
+ platform: "node",
257
+ minify: false
258
+ }),
259
+ {
260
+ name: "cleanup",
261
+ transform(code, id) {
262
+ if (id !== entryFile) {
263
+ return;
264
+ }
265
+ return recursiveRemoveNonReferencedNodes(code);
266
+ }
267
+ },
268
+ // let esbuild remove all unused imports
269
+ esbuild({
270
+ target: "node20",
271
+ platform: "node",
272
+ minify: false
273
+ })
274
+ ]
275
+ });
276
+ }
277
+ async function getBundlerOptions(entryFile, outputDir) {
278
+ const result = {
279
+ hasCustomConfig: false
280
+ };
281
+ const bundle = await getBundlerOptionsBundler(entryFile, result);
282
+ await bundle.write({
283
+ dir: outputDir,
284
+ format: "es",
285
+ entryFileNames: "[name].mjs"
286
+ });
287
+ if (result.hasCustomConfig) {
288
+ return (await import(`file:${outputDir}/bundler-config.mjs`)).bundler;
289
+ }
290
+ return null;
291
+ }
292
+
293
+ // src/build/analyze.ts
68
294
  var globalExternals = [
69
295
  "pino",
70
296
  "pino-pretty",
@@ -136,7 +362,7 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
136
362
  platform,
137
363
  minify: false
138
364
  }),
139
- commonjs({
365
+ commonjs2({
140
366
  strictRequires: "debug",
141
367
  ignoreTryCatch: false,
142
368
  transformMixedEsModules: true,
@@ -173,11 +399,12 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
173
399
  }
174
400
  return depsToOptimize;
175
401
  }
176
- async function bundleExternals(depsToOptimize, outputDir, logger) {
402
+ async function bundleExternals(depsToOptimize, outputDir, logger, customExternals) {
177
403
  logger.info("Optimizing dependencies...");
178
404
  logger.debug(
179
405
  `${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
180
406
  );
407
+ const allExternals = [...globalExternals, ...customExternals || []];
181
408
  const reverseVirtualReferenceMap = /* @__PURE__ */ new Map();
182
409
  const virtualDependencies = /* @__PURE__ */ new Map();
183
410
  for (const [dep, exports] of depsToOptimize.entries()) {
@@ -213,7 +440,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
213
440
  ),
214
441
  // this dependency breaks the build, so we need to exclude it
215
442
  // TODO actually fix this so we don't need to exclude it
216
- external: globalExternals,
443
+ external: allExternals,
217
444
  treeshake: "smallest",
218
445
  plugins: [
219
446
  virtual(
@@ -225,7 +452,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
225
452
  {}
226
453
  )
227
454
  ),
228
- commonjs({
455
+ commonjs2({
229
456
  strictRequires: "strict",
230
457
  transformMixedEsModules: true,
231
458
  ignoreTryCatch: false
@@ -250,7 +477,7 @@ async function bundleExternals(depsToOptimize, outputDir, logger) {
250
477
  const moduleResolveMap = {};
251
478
  const filteredChunks = output.filter((o) => o.type === "chunk");
252
479
  for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
253
- for (const external of globalExternals) {
480
+ for (const external of allExternals) {
254
481
  const importer = findExternalImporter(o, external, filteredChunks);
255
482
  if (importer) {
256
483
  const fullPath = join(outputDir, importer.fileName);
@@ -309,13 +536,15 @@ async function validateOutput({
309
536
  async function analyzeBundle(entry, mastraEntry, outputDir, platform, logger) {
310
537
  const isVirtualFile = entry.includes("\n") || !existsSync(entry);
311
538
  const depsToOptimize = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
539
+ const customExternals = (await getBundlerOptions(mastraEntry, outputDir))?.externals;
312
540
  const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
313
541
  depsToOptimize,
314
542
  outputDir,
315
- logger
543
+ logger,
544
+ customExternals
316
545
  );
317
546
  const result = await validateOutput({ output, reverseVirtualReferenceMap, usedExternals, outputDir }, logger);
318
547
  return result;
319
548
  }
320
549
 
321
- export { aliasHono, analyzeBundle };
550
+ export { aliasHono, analyzeBundle, getBundlerOptions, recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept };
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
4
+ var babel = require('@babel/core');
5
+ var rollup = require('rollup');
6
+ var esbuild = require('rollup-plugin-esbuild');
7
+ var commonjs = require('@rollup/plugin-commonjs');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
30
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
31
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
32
+
33
+ // src/build/babel/remove-all-options-telemetry.ts
34
+ function removeAllOptionsExceptTelemetry(result) {
35
+ return chunkOJY5LJPT_cjs.removeAllOptionsFromMastraExcept(result, "telemetry");
36
+ }
37
+
38
+ // src/build/telemetry.ts
39
+ function getTelemetryBundler(entryFile, result) {
40
+ return rollup.rollup({
41
+ logLevel: "silent",
42
+ input: {
43
+ "telemetry-config": entryFile
44
+ },
45
+ treeshake: "smallest",
46
+ plugins: [
47
+ // transpile typescript to something we understand
48
+ esbuild__default.default({
49
+ target: "node20",
50
+ platform: "node",
51
+ minify: false
52
+ }),
53
+ commonjs__default.default({
54
+ extensions: [".js", ".ts"],
55
+ strictRequires: "strict",
56
+ transformMixedEsModules: true,
57
+ ignoreTryCatch: false
58
+ }),
59
+ {
60
+ name: "get-telemetry-config",
61
+ transform(code, id) {
62
+ if (id !== entryFile) {
63
+ return;
64
+ }
65
+ return new Promise((resolve, reject) => {
66
+ babel__namespace.transform(
67
+ code,
68
+ {
69
+ babelrc: false,
70
+ configFile: false,
71
+ filename: id,
72
+ plugins: [removeAllOptionsExceptTelemetry(result)]
73
+ },
74
+ (err, result2) => {
75
+ if (err) {
76
+ return reject(err);
77
+ }
78
+ resolve({
79
+ code: result2.code,
80
+ map: result2.map
81
+ });
82
+ }
83
+ );
84
+ });
85
+ }
86
+ },
87
+ // let esbuild remove all unused imports
88
+ esbuild__default.default({
89
+ target: "node20",
90
+ platform: "node",
91
+ minify: false
92
+ }),
93
+ {
94
+ name: "cleanup",
95
+ transform(code, id) {
96
+ if (id !== entryFile) {
97
+ return;
98
+ }
99
+ return chunkOJY5LJPT_cjs.recursiveRemoveNonReferencedNodes(code);
100
+ }
101
+ },
102
+ // let esbuild remove all unused imports
103
+ esbuild__default.default({
104
+ target: "node20",
105
+ platform: "node",
106
+ minify: false
107
+ })
108
+ ]
109
+ });
110
+ }
111
+ async function writeTelemetryConfig(entryFile, outputDir) {
112
+ const result = {
113
+ hasCustomConfig: false
114
+ };
115
+ const bundle = await getTelemetryBundler(entryFile, result);
116
+ const { output } = await bundle.write({
117
+ dir: outputDir,
118
+ format: "es",
119
+ entryFileNames: "[name].mjs"
120
+ });
121
+ const externals = output[0].imports.filter((x) => !x.startsWith("./"));
122
+ return { ...result, externalDependencies: externals };
123
+ }
124
+
125
+ exports.writeTelemetryConfig = writeTelemetryConfig;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk3R6WDRBB_cjs = require('./chunk-3R6WDRBB.cjs');
4
- var chunkHHZDRBPV_cjs = require('./chunk-HHZDRBPV.cjs');
3
+ var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
5
4
  var chunkIMGVLBV7_cjs = require('./chunk-IMGVLBV7.cjs');
6
5
  var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
7
6
  var rollup = require('rollup');
@@ -49,7 +48,7 @@ async function getInputOptions2(entryFile, platform, env) {
49
48
  // @ts-ignore
50
49
  (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
51
50
  );
52
- inputOptions.plugins.push(chunkHHZDRBPV_cjs.aliasHono());
51
+ inputOptions.plugins.push(chunkOJY5LJPT_cjs.aliasHono());
53
52
  }
54
53
  return inputOptions;
55
54
  }
@@ -68,7 +67,7 @@ async function createWatcher(inputOptions, outputOptions) {
68
67
 
69
68
  // src/build/babel/remove-all-options-server.ts
70
69
  function removeAllOptionsExceptServer(result) {
71
- return chunk3R6WDRBB_cjs.removeAllOptionsFromMastraExcept(result, "server");
70
+ return chunkOJY5LJPT_cjs.removeAllOptionsFromMastraExcept(result, "server");
72
71
  }
73
72
  function getServerOptionsBundler(entryFile, result) {
74
73
  return rollup.rollup({
@@ -131,7 +130,7 @@ function getServerOptionsBundler(entryFile, result) {
131
130
  if (id !== entryFile) {
132
131
  return;
133
132
  }
134
- return chunk3R6WDRBB_cjs.recursiveRemoveNonReferencedNodes(code);
133
+ return chunkOJY5LJPT_cjs.recursiveRemoveNonReferencedNodes(code);
135
134
  }
136
135
  },
137
136
  // let esbuild remove all unused imports
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkBQAYAQTU_cjs = require('./chunk-BQAYAQTU.cjs');
4
- var chunk3R6WDRBB_cjs = require('./chunk-3R6WDRBB.cjs');
3
+ var chunkPJB6TDF7_cjs = require('./chunk-PJB6TDF7.cjs');
4
+ var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
5
5
  var chunk4VC5Z4YR_cjs = require('./chunk-4VC5Z4YR.cjs');
6
6
  var babel = require('@babel/core');
7
7
  var rollup = require('rollup');
@@ -33,7 +33,7 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
33
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
34
 
35
35
  // src/deploy/base.ts
36
- var Deployer = class extends chunkBQAYAQTU_cjs.Bundler {
36
+ var Deployer = class extends chunkPJB6TDF7_cjs.Bundler {
37
37
  deps = new chunk4VC5Z4YR_cjs.DepsService();
38
38
  constructor(args) {
39
39
  super(args.name, "DEPLOYER");
@@ -148,7 +148,7 @@ function getDeployerBundler(entryFile, result) {
148
148
  if (id !== entryFile) {
149
149
  return;
150
150
  }
151
- return chunk3R6WDRBB_cjs.recursiveRemoveNonReferencedNodes(code);
151
+ return chunkOJY5LJPT_cjs.recursiveRemoveNonReferencedNodes(code);
152
152
  }
153
153
  },
154
154
  // let esbuild remove all unused imports
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Bundler } from './chunk-YU2QBGOU.js';
2
- import { recursiveRemoveNonReferencedNodes } from './chunk-TUMXQX4H.js';
1
+ import { Bundler } from './chunk-DGNRILK6.js';
2
+ import { recursiveRemoveNonReferencedNodes } from './chunk-W46BY5GT.js';
3
3
  import { DepsService, FileService } from './chunk-UV4RQQ3R.js';
4
4
  export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-UV4RQQ3R.js';
5
5
  import * as babel from '@babel/core';
@@ -4180,16 +4180,16 @@ function watchWorkflowHandler(c2) {
4180
4180
  workflowId,
4181
4181
  runId
4182
4182
  });
4183
+ const reader = result.getReader();
4183
4184
  stream4.onAbort(() => {
4184
- if (!result.locked) {
4185
- return result.cancel();
4186
- }
4185
+ void reader.cancel("request aborted");
4187
4186
  });
4188
- for await (const chunk of result) {
4189
- await stream4.write(chunk.toString() + "");
4187
+ let chunkResult;
4188
+ while ((chunkResult = await reader.read()) && !chunkResult.done) {
4189
+ await stream4.write(JSON.stringify(chunkResult.value) + "");
4190
4190
  }
4191
4191
  } catch (err) {
4192
- console.log(err);
4192
+ mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
4193
4193
  }
4194
4194
  },
4195
4195
  async (err) => {
@@ -4200,6 +4200,46 @@ function watchWorkflowHandler(c2) {
4200
4200
  return handleError(error, "Error watching workflow");
4201
4201
  }
4202
4202
  }
4203
+ async function streamWorkflowHandler(c2) {
4204
+ try {
4205
+ const mastra = c2.get("mastra");
4206
+ const logger2 = mastra.getLogger();
4207
+ const workflowId = c2.req.param("workflowId");
4208
+ const runtimeContext = c2.get("runtimeContext");
4209
+ const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
4210
+ const runId = c2.req.query("runId");
4211
+ return streaming.stream(
4212
+ c2,
4213
+ async (stream4) => {
4214
+ try {
4215
+ const result = workflows.streamWorkflowHandler({
4216
+ mastra,
4217
+ workflowId,
4218
+ runId,
4219
+ inputData,
4220
+ runtimeContext,
4221
+ runtimeContextFromRequest
4222
+ });
4223
+ const reader = result.stream.getReader();
4224
+ stream4.onAbort(() => {
4225
+ void reader.cancel("request aborted");
4226
+ });
4227
+ let chunkResult;
4228
+ while ((chunkResult = await reader.read()) && !chunkResult.done) {
4229
+ await stream4.write(JSON.stringify(chunkResult.value) + "");
4230
+ }
4231
+ } catch (err) {
4232
+ console.log(err);
4233
+ }
4234
+ },
4235
+ async (err) => {
4236
+ logger2.error("Error in workflow stream: " + err?.message);
4237
+ }
4238
+ );
4239
+ } catch (error) {
4240
+ return handleError(error, "Error streaming workflow");
4241
+ }
4242
+ }
4203
4243
  async function resumeAsyncWorkflowHandler(c2) {
4204
4244
  try {
4205
4245
  const mastra = c2.get("mastra");
@@ -5501,7 +5541,7 @@ async function createHonoServer(mastra, options = {}) {
5501
5541
  executeAgentToolHandler
5502
5542
  );
5503
5543
  app.post(
5504
- "/api/mcp/:serverId/mcp",
5544
+ "/api/servers/:serverId/mcp",
5505
5545
  bodyLimit.bodyLimit(bodyLimitOptions),
5506
5546
  h({
5507
5547
  description: "Send a message to an MCP server using Streamable HTTP",
@@ -5528,8 +5568,8 @@ async function createHonoServer(mastra, options = {}) {
5528
5568
  }),
5529
5569
  getMcpServerMessageHandler
5530
5570
  );
5531
- const mcpSseBasePath = "/api/mcp/:serverId/sse";
5532
- const mcpSseMessagePath = "/api/mcp/:serverId/messages";
5571
+ const mcpSseBasePath = "/api/servers/:serverId/sse";
5572
+ const mcpSseMessagePath = "/api/servers/:serverId/messages";
5533
5573
  app.get(
5534
5574
  mcpSseBasePath,
5535
5575
  h({
@@ -6286,7 +6326,7 @@ async function createHonoServer(mastra, options = {}) {
6286
6326
  {
6287
6327
  name: "runId",
6288
6328
  in: "query",
6289
- required: false,
6329
+ required: true,
6290
6330
  schema: { type: "string" }
6291
6331
  }
6292
6332
  ],
@@ -6299,6 +6339,53 @@ async function createHonoServer(mastra, options = {}) {
6299
6339
  }),
6300
6340
  watchLegacyWorkflowHandler
6301
6341
  );
6342
+ app.post(
6343
+ "/api/workflows/:workflowId/stream",
6344
+ h({
6345
+ description: "Stream workflow in real-time",
6346
+ parameters: [
6347
+ {
6348
+ name: "workflowId",
6349
+ in: "path",
6350
+ required: true,
6351
+ schema: { type: "string" }
6352
+ },
6353
+ {
6354
+ name: "runId",
6355
+ in: "query",
6356
+ required: false,
6357
+ schema: { type: "string" }
6358
+ }
6359
+ ],
6360
+ requestBody: {
6361
+ required: true,
6362
+ content: {
6363
+ "application/json": {
6364
+ schema: {
6365
+ type: "object",
6366
+ properties: {
6367
+ inputData: { type: "object" },
6368
+ runtimeContext: {
6369
+ type: "object",
6370
+ description: "Runtime context for the workflow execution"
6371
+ }
6372
+ }
6373
+ }
6374
+ }
6375
+ }
6376
+ },
6377
+ responses: {
6378
+ 200: {
6379
+ description: "vNext workflow run started"
6380
+ },
6381
+ 404: {
6382
+ description: "vNext workflow not found"
6383
+ }
6384
+ },
6385
+ tags: ["vNextWorkflows"]
6386
+ }),
6387
+ streamWorkflowHandler
6388
+ );
6302
6389
  app.get(
6303
6390
  "/api/workflows",
6304
6391
  h({
@@ -7011,7 +7098,7 @@ async function createNodeServer(mastra, options = {}) {
7011
7098
  {
7012
7099
  fetch: app.fetch,
7013
7100
  port,
7014
- hostname: serverOptions?.host
7101
+ hostname: serverOptions?.host ?? "localhost"
7015
7102
  },
7016
7103
  () => {
7017
7104
  const logger2 = mastra.getLogger();