@mastra/deployer-vercel 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-type-testing-20260120105120

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/LICENSE.md CHANGED
@@ -1,46 +1,15 @@
1
- # Elastic License 2.0 (ELv2)
1
+ # Apache License 2.0
2
2
 
3
- Copyright (c) 2025 Mastra AI, Inc.
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
4
 
5
- **Acceptance**
6
- By using the software, you agree to all of the terms and conditions below.
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
7
8
 
8
- **Copyright License**
9
- The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
10
 
11
- **Limitations**
12
- You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
13
-
14
- You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
15
-
16
- You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
17
-
18
- **Patents**
19
- The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
20
-
21
- **Notices**
22
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
23
-
24
- If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
25
-
26
- **No Other Rights**
27
- These terms do not imply any licenses other than those expressly granted in these terms.
28
-
29
- **Termination**
30
- If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
31
-
32
- **No Liability**
33
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
34
-
35
- **Definitions**
36
- The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
37
-
38
- _you_ refers to the individual or entity agreeing to these terms.
39
-
40
- _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
41
-
42
- _your licenses_ are all the licenses granted to you for the software under these terms.
43
-
44
- _use_ means anything you do with the software requiring one of your licenses.
45
-
46
- _trademark_ means trademarks, service marks, and similar rights.
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
package/README.md CHANGED
@@ -21,13 +21,14 @@ 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({
28
- teamSlug: 'your-team-slug',
29
- projectName: 'your-project-name',
30
- token: 'your-vercel-token',
28
+ // Optional per-function overrides (written to .vc-config.json)
29
+ maxDuration: 600,
30
+ memory: 1536,
31
+ regions: ['sfo1', 'iad1'],
31
32
  });
32
33
 
33
34
  const mastra = new Mastra({
@@ -40,9 +41,11 @@ const mastra = new Mastra({
40
41
 
41
42
  ### Constructor Options
42
43
 
43
- - `teamSlug` (required): Your Vercel team slug
44
- - `projectName`: Name of your Vercel project (will be created if it doesn't exist)
45
- - `token`: Your Vercel API token (required for authentication)
44
+ High‑value overrides written to `.vercel/output/functions/index.func/.vc-config.json`:
45
+
46
+ - `maxDuration?: number` Function execution timeout (seconds)
47
+ - `memory?: number` — Function memory (MB)
48
+ - `regions?: string[]` — Regions (e.g. `['sfo1','iad1']`)
46
49
 
47
50
  ## Project Structure
48
51
 
package/dist/index.cjs CHANGED
@@ -12,9 +12,11 @@ var process__default = /*#__PURE__*/_interopDefault(process);
12
12
 
13
13
  // src/index.ts
14
14
  var VercelDeployer = class extends deployer.Deployer {
15
- constructor() {
15
+ vcConfigOverrides = {};
16
+ constructor(options = {}) {
16
17
  super({ name: "VERCEL" });
17
18
  this.outputDir = path.join(".vercel", "output", "functions", "index.func");
19
+ this.vcConfigOverrides = { ...options };
18
20
  }
19
21
  async prepare(outputDirectory) {
20
22
  await super.prepare(outputDirectory);
@@ -24,56 +26,21 @@ var VercelDeployer = class extends deployer.Deployer {
24
26
  return `
25
27
  import { handle } from 'hono/vercel'
26
28
  import { mastra } from '#mastra';
27
- import { createHonoServer } from '#server';
28
- import { evaluate } from '@mastra/core/eval';
29
- import { AvailableHooks, registerHook } from '@mastra/core/hooks';
30
- import { TABLE_EVALS } from '@mastra/core/storage';
31
- import { checkEvalStorageFields } from '@mastra/core/utils';
29
+ import { createHonoServer, getToolExports } from '#server';
30
+ import { tools } from '#tools';
31
+ import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
32
32
 
33
- registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
34
- evaluate({
35
- agentName,
36
- input,
37
- metric,
38
- output,
39
- runId,
40
- globalRunId: runId,
41
- instructions,
42
- });
43
- });
33
+ if (mastra.getStorage()) {
34
+ mastra.__registerInternalWorkflow(scoreTracesWorkflow);
35
+ }
44
36
 
45
- registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
46
- const storage = mastra.getStorage();
47
- if (storage) {
48
- // Check for required fields
49
- const logger = mastra?.getLogger();
50
- const areFieldsValid = checkEvalStorageFields(traceObject, logger);
51
- if (!areFieldsValid) return;
52
-
53
- await storage.insert({
54
- tableName: TABLE_EVALS,
55
- record: {
56
- input: traceObject.input,
57
- output: traceObject.output,
58
- result: JSON.stringify(traceObject.result || {}),
59
- agent_name: traceObject.agentName,
60
- metric_name: traceObject.metricName,
61
- instructions: traceObject.instructions,
62
- test_info: null,
63
- global_run_id: traceObject.globalRunId,
64
- run_id: traceObject.runId,
65
- created_at: new Date().toISOString(),
66
- },
67
- });
68
- }
69
- });
70
-
71
- const app = await createHonoServer(mastra);
37
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
72
38
 
73
39
  export const GET = handle(app);
74
40
  export const POST = handle(app);
75
41
  export const PUT = handle(app);
76
42
  export const DELETE = handle(app);
43
+ export const PATCH = handle(app);
77
44
  export const OPTIONS = handle(app);
78
45
  export const HEAD = handle(app);
79
46
  `;
@@ -92,28 +59,26 @@ export const HEAD = handle(app);
92
59
  })
93
60
  );
94
61
  }
95
- async bundle(entryFile, outputDirectory, toolsPaths) {
62
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
96
63
  const result = await this._bundle(
97
64
  this.getEntry(),
98
65
  entryFile,
99
- outputDirectory,
66
+ { outputDirectory, projectRoot },
100
67
  toolsPaths,
101
68
  path.join(outputDirectory, this.outputDir)
102
69
  );
103
70
  const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
104
- fs.writeFileSync(
105
- path.join(outputDirectory, this.outputDir, ".vc-config.json"),
106
- JSON.stringify(
107
- {
108
- handler: "index.mjs",
109
- launcherType: "Nodejs",
110
- runtime: `nodejs${nodeVersion}.x`,
111
- shouldAddHelpers: true
112
- },
113
- null,
114
- 2
115
- )
116
- );
71
+ const vcConfig = {
72
+ handler: "index.mjs",
73
+ launcherType: "Nodejs",
74
+ runtime: `nodejs${nodeVersion}.x`,
75
+ shouldAddHelpers: true
76
+ };
77
+ const { maxDuration, memory, regions } = this.vcConfigOverrides;
78
+ if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
79
+ if (typeof memory === "number") vcConfig.memory = memory;
80
+ if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
81
+ fs.writeFileSync(path.join(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
117
82
  await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
118
83
  overwrite: true
119
84
  });
@@ -128,7 +93,7 @@ export const HEAD = handle(app);
128
93
  if (hasLibsql) {
129
94
  this.logger.error(
130
95
  `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
131
- Use other Mastra Storage options instead e.g @mastra/pg`
96
+ Use other Mastra Storage options instead e.g @mastra/pg`
132
97
  );
133
98
  process__default.default.exit(1);
134
99
  }
@@ -136,3 +101,5 @@ export const HEAD = handle(app);
136
101
  };
137
102
 
138
103
  exports.VercelDeployer = VercelDeployer;
104
+ //# sourceMappingURL=index.cjs.map
105
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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,EA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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 'node:fs';\nimport { join } from 'node:path';\nimport process from 'node: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 { 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 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"]}
package/dist/index.d.ts CHANGED
@@ -1 +1,16 @@
1
- export { VercelDeployer } from './_tsup-dts-rollup.js';
1
+ import { Deployer } from '@mastra/deployer';
2
+ import type { VercelDeployerOptions } from './types.js';
3
+ export declare class VercelDeployer extends Deployer {
4
+ private vcConfigOverrides;
5
+ constructor(options?: VercelDeployerOptions);
6
+ prepare(outputDirectory: string): Promise<void>;
7
+ private getEntry;
8
+ private writeVercelJSON;
9
+ bundle(entryFile: string, outputDirectory: string, { toolsPaths, projectRoot }: {
10
+ toolsPaths: (string | string[])[];
11
+ projectRoot: string;
12
+ }): Promise<void>;
13
+ deploy(): Promise<void>;
14
+ lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,cAAe,SAAQ,QAAQ;IAC1C,OAAO,CAAC,iBAAiB,CAAyB;gBAEtC,OAAO,GAAE,qBAA0B;IAQzC,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,OAAO,CAAC,QAAQ;IAwBhB,OAAO,CAAC,eAAe;IAejB,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAiCV,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAazG"}
package/dist/index.js CHANGED
@@ -6,9 +6,11 @@ import { move } from 'fs-extra/esm';
6
6
 
7
7
  // src/index.ts
8
8
  var VercelDeployer = class extends Deployer {
9
- constructor() {
9
+ vcConfigOverrides = {};
10
+ constructor(options = {}) {
10
11
  super({ name: "VERCEL" });
11
12
  this.outputDir = join(".vercel", "output", "functions", "index.func");
13
+ this.vcConfigOverrides = { ...options };
12
14
  }
13
15
  async prepare(outputDirectory) {
14
16
  await super.prepare(outputDirectory);
@@ -18,56 +20,21 @@ var VercelDeployer = class extends Deployer {
18
20
  return `
19
21
  import { handle } from 'hono/vercel'
20
22
  import { mastra } from '#mastra';
21
- import { createHonoServer } from '#server';
22
- import { evaluate } from '@mastra/core/eval';
23
- import { AvailableHooks, registerHook } from '@mastra/core/hooks';
24
- import { TABLE_EVALS } from '@mastra/core/storage';
25
- import { checkEvalStorageFields } from '@mastra/core/utils';
23
+ import { createHonoServer, getToolExports } from '#server';
24
+ import { tools } from '#tools';
25
+ import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
26
26
 
27
- registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
28
- evaluate({
29
- agentName,
30
- input,
31
- metric,
32
- output,
33
- runId,
34
- globalRunId: runId,
35
- instructions,
36
- });
37
- });
27
+ if (mastra.getStorage()) {
28
+ mastra.__registerInternalWorkflow(scoreTracesWorkflow);
29
+ }
38
30
 
39
- registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
40
- const storage = mastra.getStorage();
41
- if (storage) {
42
- // Check for required fields
43
- const logger = mastra?.getLogger();
44
- const areFieldsValid = checkEvalStorageFields(traceObject, logger);
45
- if (!areFieldsValid) return;
46
-
47
- await storage.insert({
48
- tableName: TABLE_EVALS,
49
- record: {
50
- input: traceObject.input,
51
- output: traceObject.output,
52
- result: JSON.stringify(traceObject.result || {}),
53
- agent_name: traceObject.agentName,
54
- metric_name: traceObject.metricName,
55
- instructions: traceObject.instructions,
56
- test_info: null,
57
- global_run_id: traceObject.globalRunId,
58
- run_id: traceObject.runId,
59
- created_at: new Date().toISOString(),
60
- },
61
- });
62
- }
63
- });
64
-
65
- const app = await createHonoServer(mastra);
31
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
66
32
 
67
33
  export const GET = handle(app);
68
34
  export const POST = handle(app);
69
35
  export const PUT = handle(app);
70
36
  export const DELETE = handle(app);
37
+ export const PATCH = handle(app);
71
38
  export const OPTIONS = handle(app);
72
39
  export const HEAD = handle(app);
73
40
  `;
@@ -86,28 +53,26 @@ export const HEAD = handle(app);
86
53
  })
87
54
  );
88
55
  }
89
- async bundle(entryFile, outputDirectory, toolsPaths) {
56
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
90
57
  const result = await this._bundle(
91
58
  this.getEntry(),
92
59
  entryFile,
93
- outputDirectory,
60
+ { outputDirectory, projectRoot },
94
61
  toolsPaths,
95
62
  join(outputDirectory, this.outputDir)
96
63
  );
97
64
  const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
98
- writeFileSync(
99
- join(outputDirectory, this.outputDir, ".vc-config.json"),
100
- JSON.stringify(
101
- {
102
- handler: "index.mjs",
103
- launcherType: "Nodejs",
104
- runtime: `nodejs${nodeVersion}.x`,
105
- shouldAddHelpers: true
106
- },
107
- null,
108
- 2
109
- )
110
- );
65
+ const vcConfig = {
66
+ handler: "index.mjs",
67
+ launcherType: "Nodejs",
68
+ runtime: `nodejs${nodeVersion}.x`,
69
+ shouldAddHelpers: true
70
+ };
71
+ const { maxDuration, memory, regions } = this.vcConfigOverrides;
72
+ if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
73
+ if (typeof memory === "number") vcConfig.memory = memory;
74
+ if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
75
+ writeFileSync(join(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
111
76
  await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
112
77
  overwrite: true
113
78
  });
@@ -122,7 +87,7 @@ export const HEAD = handle(app);
122
87
  if (hasLibsql) {
123
88
  this.logger.error(
124
89
  `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
125
- Use other Mastra Storage options instead e.g @mastra/pg`
90
+ Use other Mastra Storage options instead e.g @mastra/pg`
126
91
  );
127
92
  process.exit(1);
128
93
  }
@@ -130,3 +95,5 @@ export const HEAD = handle(app);
130
95
  };
131
96
 
132
97
  export { VercelDeployer };
98
+ //# sourceMappingURL=index.js.map
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAOO,IAAM,cAAA,GAAN,cAA6B,QAAA,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,GAAY,IAAA,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,gBAAgB,IAAA,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,CAAA;AAAA,EAqBT;AAAA,EAEQ,gBAAgB,eAAA,EAAyB;AAC/C,IAAA,aAAA;AAAA,MACE,IAAA,CAAK,iBAAiB,aAAa,CAAA;AAAA,MACnC,KAAK,SAAA,CAAU;AAAA,QACb,OAAA,EAAS,CAAA;AAAA,QACT,MAAA,EAAQ;AAAA,UACN;AAAA,YACE,GAAA,EAAK,OAAA;AAAA,YACL,IAAA,EAAM;AAAA;AACR;AACF,OACD;AAAA,KACH;AAAA,E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IAAA,CAAK,OAAA,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,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport process from 'node: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 { 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 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"]}
@@ -0,0 +1,13 @@
1
+ export type VcConfig = {
2
+ handler: string;
3
+ launcherType: 'Nodejs';
4
+ runtime: string;
5
+ shouldAddHelpers: boolean;
6
+ maxDuration?: number;
7
+ memory?: number;
8
+ regions?: string[];
9
+ };
10
+ export type VcConfigOverrides = Pick<VcConfig, 'maxDuration' | 'memory' | 'regions'>;
11
+ export interface VercelDeployerOptions extends VcConfigOverrides {
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAErF,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;CAAG"}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-tsconfig-compile-20250703214351",
3
+ "version": "0.0.0-type-testing-20260120105120",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "CHANGELOG.md"
8
9
  ],
9
10
  "main": "dist/index.js",
10
11
  "types": "dist/index.d.ts",
@@ -15,7 +16,7 @@
15
16
  "default": "./dist/index.js"
16
17
  },
17
18
  "require": {
18
- "types": "./dist/index.d.cts",
19
+ "types": "./dist/index.d.ts",
19
20
  "default": "./dist/index.cjs"
20
21
  }
21
22
  },
@@ -23,29 +24,42 @@
23
24
  },
24
25
  "keywords": [],
25
26
  "author": "",
26
- "license": "Elastic-2.0",
27
+ "license": "Apache-2.0",
27
28
  "dependencies": {
28
- "@rollup/plugin-virtual": "^3.0.2",
29
- "fs-extra": "^11.3.0",
30
- "@mastra/deployer": "0.0.0-tsconfig-compile-20250703214351"
29
+ "fs-extra": "^11.3.3",
30
+ "@mastra/deployer": "0.0.0-type-testing-20260120105120"
31
31
  },
32
32
  "devDependencies": {
33
- "@microsoft/api-extractor": "^7.52.8",
34
33
  "@types/fs-extra": "^11.0.4",
35
- "@types/node": "^20.19.0",
36
- "eslint": "^9.29.0",
34
+ "@types/node": "22.13.17",
35
+ "@vitest/coverage-v8": "4.0.12",
36
+ "@vitest/ui": "4.0.12",
37
+ "eslint": "^9.37.0",
37
38
  "tsup": "^8.5.0",
38
- "typescript": "^5.8.3",
39
- "vitest": "^3.2.4",
40
- "@internal/lint": "0.0.0-tsconfig-compile-20250703214351",
41
- "@mastra/core": "0.0.0-tsconfig-compile-20250703214351"
39
+ "typescript": "^5.9.3",
40
+ "vitest": "4.0.16",
41
+ "@internal/lint": "0.0.0-type-testing-20260120105120",
42
+ "@internal/types-builder": "0.0.0-type-testing-20260120105120",
43
+ "@mastra/core": "0.0.0-type-testing-20260120105120"
44
+ },
45
+ "homepage": "https://mastra.ai",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/mastra-ai/mastra.git",
49
+ "directory": "deployers/vercel"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/mastra-ai/mastra/issues"
42
53
  },
43
54
  "peerDependencies": {
44
- "@mastra/core": "0.0.0-tsconfig-compile-20250703214351"
55
+ "@mastra/core": "0.0.0-type-testing-20260120105120"
56
+ },
57
+ "engines": {
58
+ "node": ">=22.13.0"
45
59
  },
46
60
  "scripts": {
47
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
48
- "build:watch": "pnpm build --watch",
61
+ "build": "tsup --silent --config tsup.config.ts",
62
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
49
63
  "test": "vitest run",
50
64
  "lint": "eslint ."
51
65
  }
@@ -1,13 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare class VercelDeployer extends Deployer {
4
- constructor();
5
- prepare(outputDirectory: string): Promise<void>;
6
- private getEntry;
7
- private writeVercelJSON;
8
- bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
9
- deploy(): Promise<void>;
10
- lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
11
- }
12
-
13
- export { }
@@ -1,13 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare class VercelDeployer extends Deployer {
4
- constructor();
5
- prepare(outputDirectory: string): Promise<void>;
6
- private getEntry;
7
- private writeVercelJSON;
8
- bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
9
- deploy(): Promise<void>;
10
- lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
11
- }
12
-
13
- export { }
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export { VercelDeployer } from './_tsup-dts-rollup.cjs';