@mastra/deployer 1.58.0-alpha.8 → 1.58.0

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.
@@ -43,14 +43,14 @@ Mastra applications can be deployed to cloud providers and serverless platforms.
43
43
 
44
44
  Use this option for auto-scaling, minimal infrastructure management, or when you're already using one of these platforms.
45
45
 
46
- - [Amazon EC2](https://mastra.ai/guides/deployment/amazon-ec2)
47
- - [AWS Lambda](https://mastra.ai/guides/deployment/aws-lambda)
48
- - [Azure App Services](https://mastra.ai/guides/deployment/azure-app-services)
49
- - [Cloudflare](https://mastra.ai/guides/deployment/cloudflare)
50
- - [Digital Ocean](https://mastra.ai/guides/deployment/digital-ocean)
51
- - [Kubernetes](https://mastra.ai/guides/deployment/kubernetes)
52
- - [Netlify](https://mastra.ai/guides/deployment/netlify)
53
- - [Vercel](https://mastra.ai/guides/deployment/vercel)
46
+ - [Amazon EC2](https://mastra.ai/integrations/deploy/amazon-ec2)
47
+ - [AWS Lambda](https://mastra.ai/integrations/deploy/aws-lambda)
48
+ - [Azure App Services](https://mastra.ai/integrations/deploy/azure-app-services)
49
+ - [Cloudflare](https://mastra.ai/integrations/deploy/cloudflare)
50
+ - [Digital Ocean](https://mastra.ai/integrations/deploy/digital-ocean)
51
+ - [Kubernetes](https://mastra.ai/integrations/deploy/kubernetes)
52
+ - [Netlify](https://mastra.ai/integrations/deploy/netlify)
53
+ - [Vercel](https://mastra.ai/integrations/deploy/vercel)
54
54
 
55
55
  ### Sandbox
56
56
 
@@ -72,7 +72,7 @@ Use these guides when adding Mastra to an existing Next.js or Astro application.
72
72
 
73
73
  Mastra workflows run using the built-in execution engine by default. For production workloads requiring managed infrastructure, workflows can also be deployed to specialized platforms like [Inngest](https://www.inngest.com) that provide step memoization, automatic retries, and real-time monitoring.
74
74
 
75
- Visit the [Workflow Runners guide](https://mastra.ai/docs/deployment/workflow-runners) for execution options and the [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest) for setup instructions.
75
+ Visit the [Workflow Runners guide](https://mastra.ai/docs/deployment/workflow-runners) for execution options and the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions.
76
76
 
77
77
  ## Workers
78
78
 
@@ -4,16 +4,16 @@
4
4
 
5
5
  When Mastra is integrated with a web framework, it deploys alongside your application using the framework's standard deployment process. Follow the instructions below to ensure your Mastra integration deploys correctly.
6
6
 
7
- > **Warning:** If you're deploying to a cloud provider, remove any usage of [LibSQLStore](https://mastra.ai/reference/storage/libsql) from your Mastra configuration. LibSQLStore requires filesystem access and isn't compatible with serverless platforms.
7
+ > **Warning:** If you're deploying to a cloud provider, remove any usage of [LibSQLStore](https://mastra.ai/integrations/databases/libsql) from your Mastra configuration. LibSQLStore requires filesystem access and isn't compatible with serverless platforms.
8
8
 
9
9
  Integration guides:
10
10
 
11
- - [With Next.js](https://mastra.ai/guides/getting-started/next-js)
12
- - [With Astro](https://mastra.ai/guides/getting-started/astro)
11
+ - [With Next.js](https://mastra.ai/integrations/frameworks/next-js)
12
+ - [With Astro](https://mastra.ai/integrations/frameworks/astro)
13
13
 
14
14
  ## With Next.js on Vercel
15
15
 
16
- If you've integrated Mastra with Next.js [by following our guide](https://mastra.ai/guides/getting-started/next-js) and plan to deploy to Vercel, add `serverExternalPackages: ["@mastra/*"]` to your `next.config.ts`:
16
+ If you've integrated Mastra with Next.js [by following our guide](https://mastra.ai/integrations/frameworks/next-js) and plan to deploy to Vercel, add `serverExternalPackages: ["@mastra/*"]` to your `next.config.ts`:
17
17
 
18
18
  ```typescript
19
19
  import type { NextConfig } from 'next'
@@ -27,7 +27,7 @@ export default nextConfig
27
27
 
28
28
  ## With Astro on Vercel
29
29
 
30
- If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/guides/getting-started/astro) and plan to deploy to Vercel, add the Vercel adapter and server output to your `astro.config.mjs`:
30
+ If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/integrations/frameworks/astro) and plan to deploy to Vercel, add the Vercel adapter and server output to your `astro.config.mjs`:
31
31
 
32
32
  ```javascript
33
33
  import { defineConfig } from 'astro/config'
@@ -41,7 +41,7 @@ export default defineConfig({
41
41
 
42
42
  ## With Astro on Netlify
43
43
 
44
- If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/guides/getting-started/astro) and plan to deploy to Netlify, add the Netlify adapter and server output to your `astro.config.mjs`:
44
+ If you've integrated Mastra with Astro [by following our guide](https://mastra.ai/integrations/frameworks/astro) and plan to deploy to Netlify, add the Netlify adapter and server output to your `astro.config.mjs`:
45
45
 
46
46
  ```javascript
47
47
  import { defineConfig } from 'astro/config'
@@ -8,10 +8,10 @@ Mastra [workflows](https://mastra.ai/docs/workflows/overview) can be executed us
8
8
 
9
9
  Inngest is a developer platform for running background workflows without managing infrastructure. Mastra workflows can be deployed to Inngest, which provides step memoization, automatic retries, real-time monitoring, and suspend/resume capabilities.
10
10
 
11
- Visit the [Inngest deployment guide](https://mastra.ai/guides/deployment/inngest) for setup instructions and the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest) for a complete implementation.
11
+ Visit the [Inngest deployment guide](https://mastra.ai/integrations/deploy/inngest) for setup instructions and the [Inngest workflow example](https://github.com/mastra-ai/mastra/tree/main/examples/inngest) for a complete implementation.
12
12
 
13
13
  ## Temporal
14
14
 
15
15
  Temporal is a durable execution platform for orchestrating long-running workflows. Mastra workflows can run on Temporal workers, with each `createStep` mapped to a Temporal activity for automatic retries and durable state.
16
16
 
17
- The `@mastra/temporal` package is experimental and not ready for production use. Visit the [Temporal deployment guide](https://mastra.ai/guides/deployment/temporal) for setup instructions.
17
+ The `@mastra/temporal` package is experimental and not ready for production use. Visit the [Temporal deployment guide](https://mastra.ai/integrations/deploy/temporal) for setup instructions.
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_services = require("./services-_ksvysL5.cjs");
3
3
  const require_bundlerOptions = require("./bundlerOptions-CjjAPZYp.cjs");
4
- const require_bundler = require("./bundler-DLXwkS7b.cjs");
4
+ const require_bundler_index = require("./bundler/index.cjs");
5
5
  require("./build-BERX35Pi.cjs");
6
6
  //#region src/deploy/base.ts
7
- var Deployer = class extends require_bundler.Bundler {
7
+ var Deployer = class extends require_bundler_index.Bundler {
8
8
  deps = new require_services.DepsService();
9
9
  constructor(args) {
10
10
  super(args.name, "DEPLOYER");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Bundler","DepsService","FileService","extractMastraOption"],"sources":["../src/deploy/base.ts","../src/build/deployer.ts"],"sourcesContent":["import type { IDeployer } from '@mastra/core/deployer';\n\nimport { Bundler } from '../bundler';\nimport { DepsService } from '../services/deps.js';\nimport { FileService } from '../services/fs.js';\n\nexport abstract class Deployer extends Bundler implements IDeployer {\n deps: DepsService = new DepsService();\n\n constructor(args: { name: string }) {\n super(args.name, 'DEPLOYER');\n\n this.deps.__setLogger(this.logger);\n }\n\n getEnvFiles(): Promise<string[]> {\n const possibleFiles = ['.env.production', '.env.local', '.env'];\n\n try {\n const fileService = new FileService();\n const envFile = fileService.getFirstExistingFile(possibleFiles);\n\n return Promise.resolve([envFile]);\n } catch {}\n\n return Promise.resolve([]);\n }\n\n abstract deploy(outputDirectory: string): Promise<void>;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getDeployerBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('deployer', entryFile, result);\n}\n\nexport async function getDeployer(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['deployer'] | null> {\n const result = await extractMastraOption('deployer', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;AAMA,IAAsB,WAAtB,cAAuCA,gBAAAA,QAA6B;CAClE,OAAoB,IAAIC,iBAAAA,YAAY;CAEpC,YAAY,MAAwB;EAClC,MAAM,KAAK,MAAM,UAAU;EAE3B,KAAK,KAAK,YAAY,KAAK,MAAM;CACnC;CAEA,cAAiC;EAC/B,MAAM,gBAAgB;GAAC;GAAmB;GAAc;EAAM;EAE9D,IAAI;GAEF,MAAM,UAAU,IADQC,iBAAAA,YACE,CAAC,CAAC,qBAAqB,aAAa;GAE9D,OAAO,QAAQ,QAAQ,CAAC,OAAO,CAAC;EAClC,QAAQ,CAAC;EAET,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;AAGF;;;AChBA,eAAsB,YACpB,WACA,WACA,QACoC;CACpC,MAAM,SAAS,MAAMC,uBAAAA,oBAAoB,YAAY,WAAW,WAAW,MAAM;CACjF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
1
+ {"version":3,"file":"index.cjs","names":["Bundler","DepsService","FileService","extractMastraOption"],"sources":["../src/deploy/base.ts","../src/build/deployer.ts"],"sourcesContent":["import type { IDeployer } from '@mastra/core/deployer';\n\nimport { Bundler } from '../bundler';\nimport { DepsService } from '../services/deps.js';\nimport { FileService } from '../services/fs.js';\n\nexport abstract class Deployer extends Bundler implements IDeployer {\n deps: DepsService = new DepsService();\n\n constructor(args: { name: string }) {\n super(args.name, 'DEPLOYER');\n\n this.deps.__setLogger(this.logger);\n }\n\n getEnvFiles(): Promise<string[]> {\n const possibleFiles = ['.env.production', '.env.local', '.env'];\n\n try {\n const fileService = new FileService();\n const envFile = fileService.getFirstExistingFile(possibleFiles);\n\n return Promise.resolve([envFile]);\n } catch {}\n\n return Promise.resolve([]);\n }\n\n abstract deploy(outputDirectory: string): Promise<void>;\n}\n","import type { IMastraLogger } from '@mastra/core/logger';\nimport type { Config } from '@mastra/core/mastra';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getDeployerBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('deployer', entryFile, result);\n}\n\nexport async function getDeployer(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<Config['deployer'] | null> {\n const result = await extractMastraOption('deployer', entryFile, outputDir, logger);\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;AAMA,IAAsB,WAAtB,cAAuCA,sBAAAA,QAA6B;CAClE,OAAoB,IAAIC,iBAAAA,YAAY;CAEpC,YAAY,MAAwB;EAClC,MAAM,KAAK,MAAM,UAAU;EAE3B,KAAK,KAAK,YAAY,KAAK,MAAM;CACnC;CAEA,cAAiC;EAC/B,MAAM,gBAAgB;GAAC;GAAmB;GAAc;EAAM;EAE9D,IAAI;GAEF,MAAM,UAAU,IADQC,iBAAAA,YACE,CAAC,CAAC,qBAAqB,aAAa;GAE9D,OAAO,QAAQ,QAAQ,CAAC,OAAO,CAAC;EAClC,QAAQ,CAAC;EAET,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;AAGF;;;AChBA,eAAsB,YACpB,WACA,WACA,QACoC;CACpC,MAAM,SAAS,MAAMC,uBAAAA,oBAAoB,YAAY,WAAW,WAAW,MAAM;CACjF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as createChildProcessLogger, i as DepsService, o as createPinoStream, r as Deps, t as FileService } from "./services-BRF1RRXB.js";
2
2
  import { n as extractMastraOption } from "./bundlerOptions-NMtZPD7p.js";
3
- import { t as Bundler } from "./bundler-Ct1ToG6x.js";
3
+ import { Bundler } from "./bundler/index.js";
4
4
  import "./build-kZfvpuh9.js";
5
5
  //#region src/deploy/base.ts
6
6
  var Deployer = class extends Bundler {
@@ -2988,6 +2988,54 @@ function toFetchResponse(res) {
2988
2988
  //#endregion
2989
2989
  //#region ../../server-adapters/hono/dist/index.js
2990
2990
  /**
2991
+ * Propagates a client disconnect to the simulated Node response produced by `toReqRes`.
2992
+ *
2993
+ * `fetch-to-node` builds the outgoing body from `res` events but never observes cancellation
2994
+ * of the stream it hands back. When an MCP Streamable HTTP client drops its session, nothing
2995
+ * tells `res` that the socket is gone, so the MCP transport keeps its SSE keep-alive timer
2996
+ * armed. The next keep-alive tick writes into an already-closed stream controller, and because
2997
+ * that write originates in a timer callback the resulting `ERR_INVALID_STATE` is unhandled and
2998
+ * takes down the process.
2999
+ *
3000
+ * Emitting `close` on `res` is the signal the MCP Node transport listens for: it aborts the
3001
+ * request's AbortController, which breaks the write loop and tears down the SSE stream,
3002
+ * clearing the keep-alive timer. No post-disconnect write is ever attempted.
3003
+ */
3004
+ function propagateClientDisconnect(fetchResponse, res) {
3005
+ const upstream = fetchResponse.body;
3006
+ if (!upstream) return fetchResponse;
3007
+ let disconnected = false;
3008
+ const disconnect = () => {
3009
+ if (disconnected) return;
3010
+ disconnected = true;
3011
+ try {
3012
+ res.emit("close");
3013
+ } catch {}
3014
+ reader.read().then(function drain({ done }) {
3015
+ return done ? void 0 : reader.read().then(drain);
3016
+ }, () => {});
3017
+ };
3018
+ const reader = upstream.getReader();
3019
+ const body = new ReadableStream({
3020
+ async pull(controller) {
3021
+ const { done, value } = await reader.read();
3022
+ if (done) {
3023
+ controller.close();
3024
+ return;
3025
+ }
3026
+ controller.enqueue(value);
3027
+ },
3028
+ cancel() {
3029
+ disconnect();
3030
+ }
3031
+ });
3032
+ return new Response(body, {
3033
+ status: fetchResponse.status,
3034
+ statusText: fetchResponse.statusText,
3035
+ headers: fetchResponse.headers
3036
+ });
3037
+ }
3038
+ /**
2991
3039
  * Set up WebSocket-based browser stream endpoint for real-time screencast viewing.
2992
3040
  *
2993
3041
  * Creates a WebSocket route at `/browser/:agentId/stream` that:
@@ -3327,7 +3375,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
3327
3375
  }
3328
3376
  } catch {}
3329
3377
  });
3330
- return await toFetchResponse(res);
3378
+ return propagateClientDisconnect(await toFetchResponse(res), res);
3331
3379
  } else if (route.responseType === "mcp-sse") {
3332
3380
  const { server, ssePath, messagePath } = result;
3333
3381
  try {
@@ -3507,8 +3555,8 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
3507
3555
  });
3508
3556
  }
3509
3557
  async registerCustomApiRoutes() {
3510
- if (!await this.buildCustomRouteHandler()) return;
3511
- const routes = this.customApiRoutes ?? this.mastra.getServer()?.apiRoutes ?? [];
3558
+ const routes = await this.registerSchemaApiRoutes();
3559
+ if (!await this.buildCustomRouteHandler(routes)) return;
3512
3560
  for (const route of routes) {
3513
3561
  const serverRoute = {
3514
3562
  method: route.method,
@@ -4320,6 +4368,9 @@ const getStudioPath = () => {
4320
4368
  if (require("url").pathToFileURL(__filename).href) __dirname = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
4321
4369
  return process.env.MASTRA_STUDIO_PATH || (0, path.join)(__dirname, "studio");
4322
4370
  };
4371
+ function isSchemaApiRoute(route) {
4372
+ return "_mastraSchemaRoute" in route && route._mastraSchemaRoute === true;
4373
+ }
4323
4374
  const DEFAULT_CORS_ALLOW_METHODS = [
4324
4375
  "GET",
4325
4376
  "POST",
@@ -4351,7 +4402,8 @@ function getCorsConfig(serverCors, credentialsDefault) {
4351
4402
  };
4352
4403
  }
4353
4404
  function getRouteCorsConfig(apiRoutes, pathname, method) {
4354
- return ((0, _mastra_server_auth.findMatchingCustomRoute)(pathname, method, apiRoutes)?.route)?.cors;
4405
+ const route = (0, _mastra_server_auth.findMatchingCustomRoute)(pathname, method, apiRoutes)?.route;
4406
+ return route && !isSchemaApiRoute(route) ? route.cors : void 0;
4355
4407
  }
4356
4408
  function getToolExports(tools) {
4357
4409
  try {
@@ -4377,7 +4429,8 @@ async function createHonoServer(mastra, options = { tools: {} }) {
4377
4429
  const apiPrefix = server?.apiPrefix ?? "/api";
4378
4430
  const a2aTaskStore = new _mastra_server_a2a_store.InMemoryTaskStore();
4379
4431
  const processedRoutes = (server?.apiRoutes)?.map((route) => {
4380
- if ("openapi" in route && route.openapi) {
4432
+ if (isSchemaApiRoute(route)) return route;
4433
+ if (route.openapi) {
4381
4434
  const existingMiddleware = route.middleware ? Array.isArray(route.middleware) ? route.middleware : [route.middleware] : [];
4382
4435
  return {
4383
4436
  ...route,