@mastra/deployer-vercel 0.0.0-error-handler-fix-20251020202607 → 0.0.0-esbuild-bundle-worker-20260807182016

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +1626 -4
  2. package/LICENSE.md +15 -0
  3. package/README.md +1 -1
  4. package/dist/index.cjs +175 -125
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +10 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +150 -118
  9. package/dist/index.js.map +1 -1
  10. package/dist/routes.d.ts +16 -0
  11. package/dist/routes.d.ts.map +1 -0
  12. package/dist/studio/assets/CommitMono-400-Regular-DzkyLZ26.woff2 +0 -0
  13. package/dist/studio/assets/CommitMono-700-Regular-DmOSN4kd.woff2 +0 -0
  14. package/dist/studio/assets/MonaSans-VariableFont_wdth-wght-CX-7s9jm.ttf +0 -0
  15. package/dist/studio/assets/babel-lWBcy2sH.js +16 -0
  16. package/dist/studio/assets/bash-atvbtKCR.js +1 -0
  17. package/dist/studio/assets/core-uJnW0DDG.js +12 -0
  18. package/dist/studio/assets/engine-compile-BkERmzkH.js +137 -0
  19. package/dist/studio/assets/engine-javascript-CSIo_1eZ.js +1 -0
  20. package/dist/studio/assets/estree-Dd9JfUIE.js +44 -0
  21. package/dist/studio/assets/github-dark-DHJKELXO.js +1 -0
  22. package/dist/studio/assets/github-light-DAi9KRSo.js +1 -0
  23. package/dist/studio/assets/index-BWC9t29j.js +2 -0
  24. package/dist/studio/assets/index-yUiD89B4.js +1 -0
  25. package/dist/studio/assets/javascript-ySlJ1b_l.js +1 -0
  26. package/dist/studio/assets/json-BQoSv7ci.js +1 -0
  27. package/dist/studio/assets/jsx-BAng5TT0.js +1 -0
  28. package/dist/studio/assets/livekit-client.esm-CKIgC2IJ.js +39 -0
  29. package/dist/studio/assets/main-D0m4O3FR.js +768 -0
  30. package/dist/studio/assets/markdown-UIAJJxZW.js +1 -0
  31. package/dist/studio/assets/preload-helper-PPVm8Dsz.js +1 -0
  32. package/dist/studio/assets/python-DhUJRlN_.js +1 -0
  33. package/dist/studio/assets/shell-CjFT_Tl9.js +1 -0
  34. package/dist/studio/assets/standalone-Dfz2oS5J.js +29 -0
  35. package/dist/studio/assets/style-B7CpWlks.css +1 -0
  36. package/dist/studio/assets/tsx-B6W0miNI.js +1 -0
  37. package/dist/studio/assets/typescript-Dj6nwHGl.js +1 -0
  38. package/dist/studio/index.html +100 -0
  39. package/dist/studio/mastra.svg +17 -0
  40. package/dist/studio/routes-manifest.json +27 -0
  41. package/dist/types.d.ts +1 -0
  42. package/dist/types.d.ts.map +1 -1
  43. package/package.json +22 -17
package/LICENSE.md CHANGED
@@ -1,3 +1,18 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
1
16
  # Apache License 2.0
2
17
 
3
18
  Copyright (c) 2025 Kepler Software, Inc.
package/README.md CHANGED
@@ -21,7 +21,7 @@ pnpm add @mastra/deployer-vercel
21
21
  The Vercel deployer is used as part of the Mastra framework:
22
22
 
23
23
  ```typescript
24
- import { Mastra } from '@mastra/core';
24
+ import { Mastra } from '@mastra/core/mastra';
25
25
  import { VercelDeployer } from '@mastra/deployer-vercel';
26
26
 
27
27
  const deployer = new VercelDeployer({
package/dist/index.cjs CHANGED
@@ -1,81 +1,117 @@
1
- 'use strict';
2
-
3
- var fs = require('fs');
4
- var path = require('path');
5
- var process = require('process');
6
- var deployer = require('@mastra/deployer');
7
- var esm = require('fs-extra/esm');
8
-
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
-
11
- var process__default = /*#__PURE__*/_interopDefault(process);
12
-
13
- // src/index.ts
14
- var VercelDeployer = class extends deployer.Deployer {
15
- vcConfigOverrides = {};
16
- constructor(options = {}) {
17
- super({ name: "VERCEL" });
18
- this.outputDir = path.join(".vercel", "output", "functions", "index.func");
19
- this.vcConfigOverrides = { ...options };
20
- }
21
- async prepare(outputDirectory) {
22
- await super.prepare(outputDirectory);
23
- this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
24
- }
25
- getEntry() {
26
- return `
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let fs = require("fs");
25
+ let path = require("path");
26
+ let process = require("process");
27
+ process = __toESM(process, 1);
28
+ let url = require("url");
29
+ let _mastra_deployer = require("@mastra/deployer");
30
+ let _mastra_deployer_build = require("@mastra/deployer/build");
31
+ let fs_extra_esm = require("fs-extra/esm");
32
+ //#region src/routes.ts
33
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34
+ function getVercelRoutes({ studio, studioRouteRoots = [] }) {
35
+ if (!studio) return [{
36
+ src: "/(.*)",
37
+ dest: "/"
38
+ }];
39
+ const spaRoots = studioRouteRoots.map(escapeRegExp).join("|");
40
+ return [
41
+ {
42
+ src: "^/$",
43
+ dest: "/index.html"
44
+ },
45
+ ...spaRoots ? [{
46
+ src: `^/(?:${spaRoots})(?:/.*)?$`,
47
+ dest: "/index.html"
48
+ }] : [],
49
+ { handle: "filesystem" },
50
+ {
51
+ src: "/(.*)",
52
+ dest: "/"
53
+ }
54
+ ];
55
+ }
56
+ //#endregion
57
+ //#region src/index.ts
58
+ var VercelDeployer = class extends _mastra_deployer.Deployer {
59
+ vcConfigOverrides = {};
60
+ studio;
61
+ constructor(options = {}) {
62
+ super({ name: "VERCEL" });
63
+ this.outputDir = (0, path.join)(".vercel", "output", "functions", "index.func");
64
+ this.studio = options.studio ?? false;
65
+ const { studio, ...overrides } = options;
66
+ this.vcConfigOverrides = { ...overrides };
67
+ }
68
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
69
+ return {
70
+ ...await super.getUserBundlerOptions(mastraEntryFile, outputDirectory),
71
+ externals: true
72
+ };
73
+ }
74
+ async prepare(outputDirectory) {
75
+ await super.prepare(outputDirectory);
76
+ const studioSource = (0, path.join)((0, path.dirname)((0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href))), "dist", "studio");
77
+ this.writeVercelJSON((0, path.join)(outputDirectory, this.outputDir, "..", ".."), this.studio ? this.readStudioRouteRoots(studioSource) : []);
78
+ if (this.studio) {
79
+ const staticDir = (0, path.join)(outputDirectory, ".vercel", "output", "static");
80
+ try {
81
+ await (0, fs_extra_esm.copy)(studioSource, staticDir, { overwrite: true });
82
+ } catch (err) {
83
+ throw new Error(`Failed to copy studio assets from "${studioSource}" to "${staticDir}": ${err instanceof Error ? err.message : err}`);
84
+ }
85
+ this.injectStudioConfig(staticDir);
86
+ }
87
+ }
88
+ /**
89
+ * Studio's top-level route segments, emitted by the Studio build alongside index.html.
90
+ * The Vercel route table needs them explicitly: custom `registerApiRoute()` paths are mounted
91
+ * at the root of the server, so the function has to own every path Studio doesn't claim.
92
+ */
93
+ readStudioRouteRoots(studioSource) {
94
+ const manifestPath = (0, path.join)(studioSource, "routes-manifest.json");
95
+ try {
96
+ const roots = JSON.parse((0, fs.readFileSync)(manifestPath, "utf-8"));
97
+ if (!Array.isArray(roots) || roots.some((root) => typeof root !== "string")) throw new Error("expected an array of route segments");
98
+ return roots;
99
+ } catch (err) {
100
+ throw new Error(`Failed to read studio routes manifest at "${manifestPath}": ${err instanceof Error ? err.message : err}`);
101
+ }
102
+ }
103
+ getEntry() {
104
+ return `
27
105
  import { handle } from 'hono/vercel'
28
106
  import { mastra } from '#mastra';
29
107
  import { createHonoServer, getToolExports } from '#server';
30
108
  import { tools } from '#tools';
31
- import { evaluate } from '@mastra/core/eval';
32
- import { AvailableHooks, registerHook } from '@mastra/core/hooks';
33
- import { TABLE_EVALS } from '@mastra/core/storage';
34
- import { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';
35
- import { checkEvalStorageFields } from '@mastra/core/utils';
36
-
37
- registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
38
- evaluate({
39
- agentName,
40
- input,
41
- metric,
42
- output,
43
- runId,
44
- globalRunId: runId,
45
- instructions,
46
- });
47
- });
109
+ import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
48
110
 
49
111
  if (mastra.getStorage()) {
50
112
  mastra.__registerInternalWorkflow(scoreTracesWorkflow);
51
113
  }
52
114
 
53
- registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
54
- const storage = mastra.getStorage();
55
- if (storage) {
56
- // Check for required fields
57
- const logger = mastra?.getLogger();
58
- const areFieldsValid = checkEvalStorageFields(traceObject, logger);
59
- if (!areFieldsValid) return;
60
-
61
- await storage.insert({
62
- tableName: TABLE_EVALS,
63
- record: {
64
- input: traceObject.input,
65
- output: traceObject.output,
66
- result: JSON.stringify(traceObject.result || {}),
67
- agent_name: traceObject.agentName,
68
- metric_name: traceObject.metricName,
69
- instructions: traceObject.instructions,
70
- test_info: null,
71
- global_run_id: traceObject.globalRunId,
72
- run_id: traceObject.runId,
73
- created_at: new Date().toISOString(),
74
- },
75
- });
76
- }
77
- });
78
-
79
115
  const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
80
116
 
81
117
  export const GET = handle(app);
@@ -86,62 +122,76 @@ export const PATCH = handle(app);
86
122
  export const OPTIONS = handle(app);
87
123
  export const HEAD = handle(app);
88
124
  `;
89
- }
90
- writeVercelJSON(outputDirectory) {
91
- fs.writeFileSync(
92
- path.join(outputDirectory, "config.json"),
93
- JSON.stringify({
94
- version: 3,
95
- routes: [
96
- {
97
- src: "/(.*)",
98
- dest: "/"
99
- }
100
- ]
101
- })
102
- );
103
- }
104
- async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
105
- const result = await this._bundle(
106
- this.getEntry(),
107
- entryFile,
108
- { outputDirectory, projectRoot },
109
- toolsPaths,
110
- path.join(outputDirectory, this.outputDir)
111
- );
112
- const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
113
- const vcConfig = {
114
- handler: "index.mjs",
115
- launcherType: "Nodejs",
116
- runtime: `nodejs${nodeVersion}.x`,
117
- shouldAddHelpers: true
118
- };
119
- const { maxDuration, memory, regions } = this.vcConfigOverrides;
120
- if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
121
- if (typeof memory === "number") vcConfig.memory = memory;
122
- if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
123
- fs.writeFileSync(path.join(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
124
- await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
125
- overwrite: true
126
- });
127
- return result;
128
- }
129
- async deploy() {
130
- this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
131
- }
132
- async lint(entryFile, outputDirectory, toolsPaths) {
133
- await super.lint(entryFile, outputDirectory, toolsPaths);
134
- const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
135
- if (hasLibsql) {
136
- this.logger.error(
137
- `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
138
- Use other Mastra Storage options instead e.g @mastra/pg`
139
- );
140
- process__default.default.exit(1);
141
- }
142
- }
125
+ }
126
+ injectStudioConfig(staticDir) {
127
+ const indexPath = (0, path.join)(staticDir, "index.html");
128
+ let html = (0, fs.readFileSync)(indexPath, "utf-8");
129
+ /**
130
+ * Use window.location expressions so the SPA constructs the correct same-origin endpoint.
131
+ * Port uses a ternary: window.location.port is '' for default ports (80/443), and the SPA falls back to 4111 for empty strings, so we return the default port explicitly instead.
132
+ */
133
+ html = (0, _mastra_deployer_build.injectStudioHtmlConfig)(html, {
134
+ host: `window.location.hostname`,
135
+ port: `(window.location.port || (window.location.protocol === 'https:' ? '443' : '80'))`,
136
+ protocol: `window.location.protocol.replace(':', '')`,
137
+ apiPrefix: `'/api'`,
138
+ basePath: "",
139
+ hideCloudCta: `'true'`,
140
+ templates: `'false'`,
141
+ cloudApiEndpoint: `''`,
142
+ experimentalFeatures: `'false'`,
143
+ telemetryDisabled: `''`,
144
+ requestContextPresets: `''`,
145
+ experimentalUI: `'false'`,
146
+ agentSignals: process.default.env.MASTRA_AGENT_SIGNALS === "false" ? `'false'` : `'true'`,
147
+ signalsUI: process.default.env.MASTRA_SIGNALS_UI === "true" ? `'true'` : `'false'`,
148
+ organizationId: `'${(0, _mastra_deployer_build.escapeStudioHtmlValue)(process.default.env.MASTRA_ORGANIZATION_ID || "")}'`,
149
+ platformProjectId: `'${(0, _mastra_deployer_build.escapeStudioHtmlValue)(process.default.env.MASTRA_PLATFORM_PROJECT_ID || "")}'`,
150
+ platformObservabilityEndpoint: `'${(0, _mastra_deployer_build.escapeStudioHtmlValue)(process.default.env.MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT || "")}'`
151
+ });
152
+ (0, fs.writeFileSync)(indexPath, html);
153
+ }
154
+ writeVercelJSON(outputDirectory, studioRouteRoots) {
155
+ (0, fs.writeFileSync)((0, path.join)(outputDirectory, "config.json"), JSON.stringify({
156
+ version: 3,
157
+ routes: getVercelRoutes({
158
+ studio: this.studio,
159
+ studioRouteRoots
160
+ })
161
+ }));
162
+ }
163
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
164
+ const result = await this._bundle(this.getEntry(), entryFile, {
165
+ outputDirectory,
166
+ projectRoot
167
+ }, toolsPaths, (0, path.join)(outputDirectory, this.outputDir));
168
+ const vcConfig = {
169
+ handler: "index.mjs",
170
+ launcherType: "Nodejs",
171
+ runtime: `nodejs${process.default.version?.split(".")?.[0]?.replace("v", "") ?? "22"}.x`,
172
+ shouldAddHelpers: true
173
+ };
174
+ const { maxDuration, memory, regions } = this.vcConfigOverrides;
175
+ if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
176
+ if (typeof memory === "number") vcConfig.memory = memory;
177
+ if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
178
+ (0, fs.writeFileSync)((0, path.join)(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
179
+ await (0, fs_extra_esm.move)((0, path.join)(outputDirectory, ".vercel", "output"), (0, path.join)(process.default.cwd(), ".vercel", "output"), { overwrite: true });
180
+ return result;
181
+ }
182
+ async deploy() {
183
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
184
+ }
185
+ async lint(entryFile, outputDirectory, toolsPaths) {
186
+ await super.lint(entryFile, outputDirectory, toolsPaths);
187
+ if (await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`) {
188
+ this.logger.error(`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
189
+ Use other Mastra Storage options instead e.g @mastra/pg`);
190
+ process.default.exit(1);
191
+ }
192
+ }
143
193
  };
144
-
194
+ //#endregion
145
195
  exports.VercelDeployer = VercelDeployer;
146
- //# sourceMappingURL=index.cjs.map
196
+
147
197
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","writeFileSync","process","move"],"mappings":";;;;;;;;;;;;;AAOO,IAAM,cAAA,GAAN,cAA6BA,iBAAA,CAAS;AAAA,EACnC,oBAAuC,EAAC;AAAA,EAEhD,WAAA,CAAY,OAAA,GAAiC,EAAC,EAAG;AAC/C,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,QAAA,EAAU,CAAA;AACxB,IAAA,IAAA,CAAK,SAAA,GAAYC,SAAA,CAAK,SAAA,EAAW,QAAA,EAAU,aAAa,YAAY,CAAA;AAGpE,IAAA,IAAA,CAAK,iBAAA,GAAoB,EAAE,GAAG,OAAA,EAAQ;AAAA,EACxC;AAAA,EAEA,MAAM,QAAQ,eAAA,EAAwC;AACpD,IAAA,MAAM,KAAA,CAAM,QAAQ,eAAe,CAAA;AAEnC,IAAA,IAAA,CAAK,gBAAgBA,SAAA,CAAK,eAAA,EAAiB,KAAK,SAAA,EAAW,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACxE;AAAA,EAEQ,QAAA,GAAmB;AACzB,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;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A,CAAM,QAAQ,OAAO,CAAA,IAAK,QAAQ,MAAA,GAAS,CAAA,WAAY,OAAA,GAAU,OAAA;AAErE,IAAAD,gBAAA,CAAcD,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAA,EAAW,iBAAiB,CAAA,EAAG,IAAA,CAAK,SAAA,CAAU,QAAA,EAAU,IAAA,EAAM,CAAC,CAAC,CAAA;AAEzG,IAAA,MAAMG,QAAA,CAAKH,SAAA,CAAK,eAAA,EAAiB,SAAA,EAAW,QAAQ,CAAA,EAAGA,SAAA,CAAKE,wBAAA,CAAQ,GAAA,EAAI,EAAG,SAAA,EAAW,QAAQ,CAAA,EAAG;AAAA,MAC/F,SAAA,EAAW;AAAA,KACZ,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,MAAM,MAAA,GAAwB;AAC5B,IAAA,IAAA,CAAK,MAAA,EAAQ,KAAK,+EAA+E,CAAA;AAAA,EACnG;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAEvD,IAAA,MAAM,SAAA,GAAa,MAAM,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,QACV,CAAA;AAAA,2DAAA;AAAA,OAEF;AACA,MAAAA,wBAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["import { writeFileSync } from 'fs';\nimport { join } from 'path';\nimport process from 'process';\nimport { Deployer } from '@mastra/deployer';\nimport { move } from 'fs-extra/esm';\nimport type { VcConfig, VcConfigOverrides, VercelDeployerOptions } from './types';\n\nexport class VercelDeployer extends Deployer {\n private vcConfigOverrides: VcConfigOverrides = {};\n\n constructor(options: VercelDeployerOptions = {}) {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\n\n // Store all overrides centrally\n this.vcConfigOverrides = { ...options };\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n\n this.writeVercelJSON(join(outputDirectory, this.outputDir, '..', '..'));\n }\n\n private getEntry(): string {\n return `\nimport { handle } from 'hono/vercel'\nimport { mastra } from '#mastra';\nimport { createHonoServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { evaluate } from '@mastra/core/eval';\nimport { AvailableHooks, registerHook } from '@mastra/core/hooks';\nimport { TABLE_EVALS } from '@mastra/core/storage';\nimport { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';\nimport { checkEvalStorageFields } from '@mastra/core/utils';\n\nregisterHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {\n evaluate({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId: runId,\n instructions,\n });\n});\n\nif (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\nregisterHook(AvailableHooks.ON_EVALUATION, async traceObject => {\n const storage = mastra.getStorage();\n if (storage) {\n // Check for required fields\n const logger = mastra?.getLogger();\n const areFieldsValid = checkEvalStorageFields(traceObject, logger);\n if (!areFieldsValid) return;\n\n await storage.insert({\n tableName: TABLE_EVALS,\n record: {\n input: traceObject.input,\n output: traceObject.output,\n result: JSON.stringify(traceObject.result || {}),\n agent_name: traceObject.agentName,\n metric_name: traceObject.metricName,\n instructions: traceObject.instructions,\n test_info: null,\n global_run_id: traceObject.globalRunId,\n run_id: traceObject.runId,\n created_at: new Date().toISOString(),\n },\n });\n }\n});\n\nconst app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\nexport const GET = handle(app);\nexport const POST = handle(app);\nexport const PUT = handle(app);\nexport const DELETE = handle(app);\nexport const PATCH = handle(app);\nexport const OPTIONS = handle(app);\nexport const HEAD = handle(app);\n`;\n }\n\n private writeVercelJSON(outputDirectory: string) {\n writeFileSync(\n join(outputDirectory, 'config.json'),\n JSON.stringify({\n version: 3,\n routes: [\n {\n src: '/(.*)',\n dest: '/',\n },\n ],\n }),\n );\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n\n const vcConfig: VcConfig = {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n };\n\n // Merge supported overrides\n const { maxDuration, memory, regions } = this.vcConfigOverrides;\n if (typeof maxDuration === 'number') vcConfig.maxDuration = maxDuration;\n if (typeof memory === 'number') vcConfig.memory = memory;\n if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;\n\n writeFileSync(join(outputDirectory, this.outputDir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));\n\n await move(join(outputDirectory, '.vercel', 'output'), join(process.cwd(), '.vercel', 'output'), {\n overwrite: true,\n });\n\n return result;\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.');\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger.error(\n `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency. \n\t\t\t\tUse other Mastra Storage options instead e.g @mastra/pg`,\n );\n process.exit(1);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.cjs","names":["Deployer"],"sources":["../src/routes.ts","../src/index.ts"],"sourcesContent":["type VercelRoutesOptions = {\n studio: boolean;\n /** Studio's top-level route segments, read from the Studio build's routes-manifest.json. */\n studioRouteRoots?: string[];\n};\n\nconst escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\nexport function getVercelRoutes({ studio, studioRouteRoots = [] }: VercelRoutesOptions) {\n if (!studio) {\n return [{ src: '/(.*)', dest: '/' }];\n }\n\n // Studio owns a known set of SPA paths; everything else belongs to the server function.\n // The function has to be the catch-all because custom `registerApiRoute()` paths are mounted\n // at the root of the server (never under `apiPrefix`), so the CDN cannot tell them apart from\n // an unknown path — an SPA catch-all would swallow every one of them.\n const spaRoots = studioRouteRoots.map(escapeRegExp).join('|');\n\n return [\n { src: '^/$', dest: '/index.html' },\n ...(spaRoots ? [{ src: `^/(?:${spaRoots})(?:/.*)?$`, dest: '/index.html' }] : []),\n { handle: 'filesystem' as const },\n { src: '/(.*)', dest: '/' },\n ];\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\nimport type { Config } from '@mastra/core/mastra';\nimport { Deployer } from '@mastra/deployer';\nimport { escapeStudioHtmlValue, injectStudioHtmlConfig } from '@mastra/deployer/build';\nimport { copy, move } from 'fs-extra/esm';\nimport { getVercelRoutes } from './routes';\nimport type { VcConfig, VcConfigOverrides, VercelDeployerOptions } from './types';\n\nexport class VercelDeployer extends Deployer {\n private vcConfigOverrides: VcConfigOverrides = {};\n private studio: boolean;\n\n constructor(options: VercelDeployerOptions = {}) {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\n this.studio = options.studio ?? false;\n\n const { studio, ...overrides } = options;\n this.vcConfigOverrides = { ...overrides };\n }\n\n protected async getUserBundlerOptions(\n mastraEntryFile: string,\n outputDirectory: string,\n ): Promise<NonNullable<Config['bundler']>> {\n const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n\n // Always force externals: true for Vercel deployments.\n // Vercel serverless functions resolve dependencies from node_modules,\n // so bundling them inline serves no purpose. Bundling inline can also cause\n // circular module evaluation deadlocks when dynamic imports produce chunks\n // that depend back on the entry module via static imports, resulting in\n // \"Detected unsettled top-level await\" errors (Node.js exit code 13).\n // See: https://github.com/mastra-ai/mastra/issues/14860\n return {\n ...bundlerOptions,\n externals: true,\n };\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n\n const studioSource = join(dirname(__dirname), 'dist', 'studio');\n\n this.writeVercelJSON(\n join(outputDirectory, this.outputDir, '..', '..'),\n this.studio ? this.readStudioRouteRoots(studioSource) : [],\n );\n\n if (this.studio) {\n const staticDir = join(outputDirectory, '.vercel', 'output', 'static');\n\n try {\n await copy(studioSource, staticDir, { overwrite: true });\n } catch (err) {\n throw new Error(\n `Failed to copy studio assets from \"${studioSource}\" to \"${staticDir}\": ${err instanceof Error ? err.message : err}`,\n );\n }\n\n this.injectStudioConfig(staticDir);\n }\n }\n\n /**\n * Studio's top-level route segments, emitted by the Studio build alongside index.html.\n * The Vercel route table needs them explicitly: custom `registerApiRoute()` paths are mounted\n * at the root of the server, so the function has to own every path Studio doesn't claim.\n */\n private readStudioRouteRoots(studioSource: string): string[] {\n const manifestPath = join(studioSource, 'routes-manifest.json');\n\n try {\n const roots = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n if (!Array.isArray(roots) || roots.some(root => typeof root !== 'string')) {\n throw new Error('expected an array of route segments');\n }\n return roots;\n } catch (err) {\n throw new Error(\n `Failed to read studio routes manifest at \"${manifestPath}\": ${err instanceof Error ? err.message : err}`,\n );\n }\n }\n\n private getEntry(): string {\n return `\nimport { handle } from 'hono/vercel'\nimport { mastra } from '#mastra';\nimport { createHonoServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\nif (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n}\n\nconst app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\nexport const GET = handle(app);\nexport const POST = handle(app);\nexport const PUT = handle(app);\nexport const DELETE = handle(app);\nexport const PATCH = handle(app);\nexport const OPTIONS = handle(app);\nexport const HEAD = handle(app);\n`;\n }\n\n private injectStudioConfig(staticDir: string) {\n const indexPath = join(staticDir, 'index.html');\n let html = readFileSync(indexPath, 'utf-8');\n\n /**\n * Use window.location expressions so the SPA constructs the correct same-origin endpoint.\n * Port uses a ternary: window.location.port is '' for default ports (80/443), and the SPA falls back to 4111 for empty strings, so we return the default port explicitly instead.\n */\n html = injectStudioHtmlConfig(html, {\n host: `window.location.hostname`,\n port: `(window.location.port || (window.location.protocol === 'https:' ? '443' : '80'))`,\n protocol: `window.location.protocol.replace(':', '')`,\n apiPrefix: `'/api'`,\n basePath: '',\n hideCloudCta: `'true'`,\n templates: `'false'`,\n cloudApiEndpoint: `''`,\n experimentalFeatures: `'false'`,\n telemetryDisabled: `''`,\n requestContextPresets: `''`,\n experimentalUI: `'false'`,\n agentSignals: process.env.MASTRA_AGENT_SIGNALS === 'false' ? `'false'` : `'true'`,\n signalsUI: process.env.MASTRA_SIGNALS_UI === 'true' ? `'true'` : `'false'`,\n organizationId: `'${escapeStudioHtmlValue(process.env.MASTRA_ORGANIZATION_ID || '')}'`,\n platformProjectId: `'${escapeStudioHtmlValue(process.env.MASTRA_PLATFORM_PROJECT_ID || '')}'`,\n platformObservabilityEndpoint: `'${escapeStudioHtmlValue(process.env.MASTRA_PLATFORM_OBSERVABILITY_ENDPOINT || '')}'`,\n });\n\n writeFileSync(indexPath, html);\n }\n\n private writeVercelJSON(outputDirectory: string, studioRouteRoots: string[]) {\n writeFileSync(\n join(outputDirectory, 'config.json'),\n JSON.stringify({ version: 3, routes: getVercelRoutes({ studio: this.studio, studioRouteRoots }) }),\n );\n }\n\n async bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n\n const vcConfig: VcConfig = {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n };\n\n // Merge supported overrides\n const { maxDuration, memory, regions } = this.vcConfigOverrides;\n if (typeof maxDuration === 'number') vcConfig.maxDuration = maxDuration;\n if (typeof memory === 'number') vcConfig.memory = memory;\n if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;\n\n writeFileSync(join(outputDirectory, this.outputDir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));\n\n await move(join(outputDirectory, '.vercel', 'output'), join(process.cwd(), '.vercel', 'output'), {\n overwrite: true,\n });\n\n return result;\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.');\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger.error(\n `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency. \n\t\t\t\tUse other Mastra Storage options instead e.g @mastra/pg`,\n );\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,gBAAgB,UAAkB,MAAM,QAAQ,uBAAuB,MAAM;AAEnF,SAAgB,gBAAgB,EAAE,QAAQ,mBAAmB,CAAC,KAA0B;CACtF,IAAI,CAAC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AAW,QAAQ,IAAA,GAAA,KAAA,KAAA,CAAQ,QAAA,QAAQ,IAAI,GAAG,WAAW,QAAQ,GAAG,EAC/F,WAAW,KACb,CAAC;EAED,OAAO;CACT;CAEA,MAAM,SAAwB;EAC5B,KAAK,QAAQ,KAAK,+EAA+E;CACnG;CAEA,MAAM,KAAK,WAAmB,iBAAyB,YAAkD;EACvG,MAAM,MAAM,KAAK,WAAW,iBAAiB,UAAU;EAIvD,IAFmB,MAAM,KAAK,KAAK,kBAAkB,CAAC,gBAAgB,CAAC,MAAO,MAE/D;GACb,KAAK,OAAO,MACV;4DAEF;GACA,QAAA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
+ import type { Config } from '@mastra/core/mastra';
1
2
  import { Deployer } from '@mastra/deployer';
2
3
  import type { VercelDeployerOptions } from './types.js';
3
4
  export declare class VercelDeployer extends Deployer {
4
5
  private vcConfigOverrides;
6
+ private studio;
5
7
  constructor(options?: VercelDeployerOptions);
8
+ protected getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<NonNullable<Config['bundler']>>;
6
9
  prepare(outputDirectory: string): Promise<void>;
10
+ /**
11
+ * Studio's top-level route segments, emitted by the Studio build alongside index.html.
12
+ * The Vercel route table needs them explicitly: custom `registerApiRoute()` paths are mounted
13
+ * at the root of the server, so the function has to own every path Studio doesn't claim.
14
+ */
15
+ private readStudioRouteRoots;
7
16
  private getEntry;
17
+ private injectStudioConfig;
8
18
  private writeVercelJSON;
9
19
  bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
10
20
  toolsPaths: (string | string[])[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAA+B,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElF,qBAAa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