@mastra/deployer-vercel 0.0.0-storage-20250225005900 → 0.0.0-stream-vnext-usage-20250908171242

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 ADDED
@@ -0,0 +1,15 @@
1
+ # Apache License 2.0
2
+
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
+
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
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
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
@@ -25,8 +25,9 @@ import { Mastra } from '@mastra/core';
25
25
  import { VercelDeployer } from '@mastra/deployer-vercel';
26
26
 
27
27
  const deployer = new VercelDeployer({
28
- scope: 'your-team-id',
28
+ teamSlug: 'your-team-slug',
29
29
  projectName: 'your-project-name',
30
+ token: 'your-vercel-token',
30
31
  });
31
32
 
32
33
  const mastra = new Mastra({
@@ -39,8 +40,9 @@ const mastra = new Mastra({
39
40
 
40
41
  ### Constructor Options
41
42
 
42
- - `scope` (required): Your Vercel team ID or username
43
+ - `teamSlug` (required): Your Vercel team slug
43
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
46
 
45
47
  ## Project Structure
46
48
 
package/dist/index.cjs ADDED
@@ -0,0 +1,142 @@
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
+ constructor() {
16
+ super({ name: "VERCEL" });
17
+ this.outputDir = path.join(".vercel", "output", "functions", "index.func");
18
+ }
19
+ async prepare(outputDirectory) {
20
+ await super.prepare(outputDirectory);
21
+ this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
22
+ }
23
+ getEntry() {
24
+ return `
25
+ import { handle } from 'hono/vercel'
26
+ import { mastra } from '#mastra';
27
+ import { createHonoServer, getToolExports } from '#server';
28
+ import { tools } from '#tools';
29
+ import { evaluate } from '@mastra/core/eval';
30
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
31
+ import { TABLE_EVALS } from '@mastra/core/storage';
32
+ import { checkEvalStorageFields } from '@mastra/core/utils';
33
+
34
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
35
+ evaluate({
36
+ agentName,
37
+ input,
38
+ metric,
39
+ output,
40
+ runId,
41
+ globalRunId: runId,
42
+ instructions,
43
+ });
44
+ });
45
+
46
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
47
+ const storage = mastra.getStorage();
48
+ if (storage) {
49
+ // Check for required fields
50
+ const logger = mastra?.getLogger();
51
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
52
+ if (!areFieldsValid) return;
53
+
54
+ await storage.insert({
55
+ tableName: TABLE_EVALS,
56
+ record: {
57
+ input: traceObject.input,
58
+ output: traceObject.output,
59
+ result: JSON.stringify(traceObject.result || {}),
60
+ agent_name: traceObject.agentName,
61
+ metric_name: traceObject.metricName,
62
+ instructions: traceObject.instructions,
63
+ test_info: null,
64
+ global_run_id: traceObject.globalRunId,
65
+ run_id: traceObject.runId,
66
+ created_at: new Date().toISOString(),
67
+ },
68
+ });
69
+ }
70
+ });
71
+
72
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
73
+
74
+ export const GET = handle(app);
75
+ export const POST = handle(app);
76
+ export const PUT = handle(app);
77
+ export const DELETE = handle(app);
78
+ export const PATCH = handle(app);
79
+ export const OPTIONS = handle(app);
80
+ export const HEAD = handle(app);
81
+ `;
82
+ }
83
+ writeVercelJSON(outputDirectory) {
84
+ fs.writeFileSync(
85
+ path.join(outputDirectory, "config.json"),
86
+ JSON.stringify({
87
+ version: 3,
88
+ routes: [
89
+ {
90
+ src: "/(.*)",
91
+ dest: "/"
92
+ }
93
+ ]
94
+ })
95
+ );
96
+ }
97
+ async bundle(entryFile, outputDirectory, toolsPaths) {
98
+ const result = await this._bundle(
99
+ this.getEntry(),
100
+ entryFile,
101
+ outputDirectory,
102
+ toolsPaths,
103
+ path.join(outputDirectory, this.outputDir)
104
+ );
105
+ const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
106
+ fs.writeFileSync(
107
+ path.join(outputDirectory, this.outputDir, ".vc-config.json"),
108
+ JSON.stringify(
109
+ {
110
+ handler: "index.mjs",
111
+ launcherType: "Nodejs",
112
+ runtime: `nodejs${nodeVersion}.x`,
113
+ shouldAddHelpers: true
114
+ },
115
+ null,
116
+ 2
117
+ )
118
+ );
119
+ await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
120
+ overwrite: true
121
+ });
122
+ return result;
123
+ }
124
+ async deploy() {
125
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
126
+ }
127
+ async lint(entryFile, outputDirectory, toolsPaths) {
128
+ await super.lint(entryFile, outputDirectory, toolsPaths);
129
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
130
+ if (hasLibsql) {
131
+ this.logger.error(
132
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
133
+ Use other Mastra Storage options instead e.g @mastra/pg`
134
+ );
135
+ process__default.default.exit(1);
136
+ }
137
+ }
138
+ };
139
+
140
+ exports.VercelDeployer = VercelDeployer;
141
+ //# sourceMappingURL=index.cjs.map
142
+ //# source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B,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,+DAAA;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';\n\nexport class VercelDeployer extends Deployer {\n constructor() {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\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 { 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\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(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n outputDirectory,\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n writeFileSync(\n join(outputDirectory, this.outputDir, '.vc-config.json'),\n JSON.stringify(\n {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n },\n null,\n 2,\n ),\n );\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 Use 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,11 @@
1
- export { VercelDeployer } from './_tsup-dts-rollup.js';
1
+ import { Deployer } from '@mastra/deployer';
2
+ export declare class VercelDeployer extends Deployer {
3
+ constructor();
4
+ prepare(outputDirectory: string): Promise<void>;
5
+ private getEntry;
6
+ private writeVercelJSON;
7
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
8
+ deploy(): Promise<void>;
9
+ lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
10
+ }
11
+ //# 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;AAG5C,qBAAa,cAAe,SAAQ,QAAQ;;IAMpC,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,OAAO,CAAC,QAAQ;IA6DhB,OAAO,CAAC,eAAe;IAejB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BpG,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
@@ -1,144 +1,136 @@
1
- import { Deployer } from '@mastra/deployer';
2
- import '@mastra/deployer/build';
3
- import '@rollup/plugin-virtual';
4
- import * as child_process from 'child_process';
5
- import { writeFileSync, readFileSync } from 'fs';
1
+ import { writeFileSync } from 'fs';
6
2
  import { join } from 'path';
7
3
  import process from 'process';
4
+ import { Deployer } from '@mastra/deployer';
5
+ import { move } from 'fs-extra/esm';
8
6
 
9
7
  // src/index.ts
10
8
  var VercelDeployer = class extends Deployer {
11
- teamId;
12
- projectName;
13
- token;
14
- constructor({ teamId, projectName, token }) {
9
+ constructor() {
15
10
  super({ name: "VERCEL" });
16
- this.teamId = teamId;
17
- this.projectName = projectName;
18
- this.token = token;
19
- }
20
- writeFiles(outputDirectory) {
21
- writeFileSync(
22
- join(outputDirectory, this.outputDir, "vercel.json"),
23
- JSON.stringify(
24
- {
25
- version: 2,
26
- installCommand: "npm install --omit=dev",
27
- builds: [
28
- {
29
- src: "index.mjs",
30
- use: "@vercel/node",
31
- config: { includeFiles: ["**"] }
32
- }
33
- ],
34
- routes: [
35
- {
36
- src: "/(.*)",
37
- dest: "index.mjs"
38
- }
39
- ]
40
- },
41
- null,
42
- 2
43
- )
44
- );
45
- }
46
- getProjectId({ dir }) {
47
- const projectJsonPath = join(dir, ".vercel", "project.json");
48
- try {
49
- const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
50
- return projectJson.projectId;
51
- } catch (error) {
52
- throw new Error("Could not find project ID. Make sure the project has been deployed first.");
53
- }
54
- }
55
- async syncEnv(envVars) {
56
- console.log("Syncing environment variables...");
57
- const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
58
- if (!key || !value) {
59
- throw new Error(`Invalid environment variable format: ${key || value}`);
60
- }
61
- return {
62
- key,
63
- value,
64
- target: ["production", "preview", "development"],
65
- type: "plain"
66
- };
67
- });
68
- try {
69
- const projectId = this.getProjectId({ dir: process.cwd() });
70
- const response = await fetch(
71
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${this.teamId}&upsert=true`,
72
- {
73
- method: "POST",
74
- headers: {
75
- Authorization: `Bearer ${this.token}`,
76
- "Content-Type": "application/json"
77
- },
78
- body: JSON.stringify(vercelEnvVars)
79
- }
80
- );
81
- if (!response.ok) {
82
- const error = await response.json();
83
- throw new Error(`Failed to sync environment variables: ${error.message}`);
84
- }
85
- console.log("\u2713 Successfully synced environment variables");
86
- } catch (error) {
87
- if (error instanceof Error) {
88
- console.error("Failed to sync environment variables:", error.message);
89
- } else {
90
- console.error("Failed to sync environment variables:", error);
91
- }
92
- throw error;
93
- }
11
+ this.outputDir = join(".vercel", "output", "functions", "index.func");
94
12
  }
95
13
  async prepare(outputDirectory) {
96
14
  await super.prepare(outputDirectory);
97
- await this.writeFiles(outputDirectory);
15
+ this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
98
16
  }
99
17
  getEntry() {
100
18
  return `
101
19
  import { handle } from 'hono/vercel'
102
20
  import { mastra } from '#mastra';
103
- import { createHonoServer } from '#server';
21
+ import { createHonoServer, getToolExports } from '#server';
22
+ import { tools } from '#tools';
23
+ import { evaluate } from '@mastra/core/eval';
24
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
25
+ import { TABLE_EVALS } from '@mastra/core/storage';
26
+ import { checkEvalStorageFields } from '@mastra/core/utils';
104
27
 
105
- const app = await createHonoServer(mastra);
28
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
29
+ evaluate({
30
+ agentName,
31
+ input,
32
+ metric,
33
+ output,
34
+ runId,
35
+ globalRunId: runId,
36
+ instructions,
37
+ });
38
+ });
39
+
40
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
41
+ const storage = mastra.getStorage();
42
+ if (storage) {
43
+ // Check for required fields
44
+ const logger = mastra?.getLogger();
45
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
46
+ if (!areFieldsValid) return;
47
+
48
+ await storage.insert({
49
+ tableName: TABLE_EVALS,
50
+ record: {
51
+ input: traceObject.input,
52
+ output: traceObject.output,
53
+ result: JSON.stringify(traceObject.result || {}),
54
+ agent_name: traceObject.agentName,
55
+ metric_name: traceObject.metricName,
56
+ instructions: traceObject.instructions,
57
+ test_info: null,
58
+ global_run_id: traceObject.globalRunId,
59
+ run_id: traceObject.runId,
60
+ created_at: new Date().toISOString(),
61
+ },
62
+ });
63
+ }
64
+ });
65
+
66
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
106
67
 
107
68
  export const GET = handle(app);
108
69
  export const POST = handle(app);
70
+ export const PUT = handle(app);
71
+ export const DELETE = handle(app);
72
+ export const PATCH = handle(app);
73
+ export const OPTIONS = handle(app);
74
+ export const HEAD = handle(app);
109
75
  `;
110
76
  }
111
- async bundle(entryFile, outputDirectory) {
112
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
77
+ writeVercelJSON(outputDirectory) {
78
+ writeFileSync(
79
+ join(outputDirectory, "config.json"),
80
+ JSON.stringify({
81
+ version: 3,
82
+ routes: [
83
+ {
84
+ src: "/(.*)",
85
+ dest: "/"
86
+ }
87
+ ]
88
+ })
89
+ );
113
90
  }
114
- async deploy(outputDirectory) {
115
- const envVars = await this.loadEnvVars();
116
- const commandArgs = [
117
- "--scope",
118
- this.teamId,
119
- "--cwd",
120
- join(outputDirectory, this.outputDir),
121
- "--token",
122
- this.token,
123
- "deploy",
124
- "--yes",
125
- ...this.projectName ? ["--name", this.projectName] : []
126
- ];
127
- child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
128
- cwd: join(outputDirectory, this.outputDir),
129
- env: {
130
- // ...this.env,
131
- PATH: process.env.PATH
132
- },
133
- stdio: "inherit"
91
+ async bundle(entryFile, outputDirectory, toolsPaths) {
92
+ const result = await this._bundle(
93
+ this.getEntry(),
94
+ entryFile,
95
+ outputDirectory,
96
+ toolsPaths,
97
+ join(outputDirectory, this.outputDir)
98
+ );
99
+ const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
100
+ writeFileSync(
101
+ join(outputDirectory, this.outputDir, ".vc-config.json"),
102
+ JSON.stringify(
103
+ {
104
+ handler: "index.mjs",
105
+ launcherType: "Nodejs",
106
+ runtime: `nodejs${nodeVersion}.x`,
107
+ shouldAddHelpers: true
108
+ },
109
+ null,
110
+ 2
111
+ )
112
+ );
113
+ await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
114
+ overwrite: true
134
115
  });
135
- this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
136
- if (envVars.size > 0) {
137
- await this.syncEnv(envVars);
138
- } else {
139
- this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
116
+ return result;
117
+ }
118
+ async deploy() {
119
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
120
+ }
121
+ async lint(entryFile, outputDirectory, toolsPaths) {
122
+ await super.lint(entryFile, outputDirectory, toolsPaths);
123
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
124
+ if (hasLibsql) {
125
+ this.logger.error(
126
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
127
+ Use other Mastra Storage options instead e.g @mastra/pg`
128
+ );
129
+ process.exit(1);
140
130
  }
141
131
  }
142
132
  };
143
133
 
144
134
  export { VercelDeployer };
135
+ //# sourceMappingURL=index.js.map
136
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAMO,IAAM,cAAA,GAAN,cAA6B,QAAA,CAAS;AAAA,EAC3C,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,QAAA,EAAU,CAAA;AACxB,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA,CAAK,SAAA,EAAW,QAAA,EAAU,aAAa,YAAY,CAAA;AAAA,EACtE;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;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A,UACT,YAAA,EAAc,QAAA;AAAA,UACd,OAAA,EAAS,SAAS,WAAW,CAAA,EAAA,CAAA;AAAA,UAC7B,gBAAA,EAAkB;AAAA,SACpB;AAAA,QACA,IAAA;AAAA,QACA;AAAA;AACF,KACF;AAEA,IAAA,MAAM,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,SAAA,EAAW,QAAQ,CAAA,EAAG,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,+DAAA;AAAA,OAEF;AACA,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import { writeFileSync } from 'fs';\nimport { join } from 'path';\nimport process from 'process';\nimport { Deployer } from '@mastra/deployer';\nimport { move } from 'fs-extra/esm';\n\nexport class VercelDeployer extends Deployer {\n constructor() {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\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 { 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\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(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n outputDirectory,\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n writeFileSync(\n join(outputDirectory, this.outputDir, '.vc-config.json'),\n JSON.stringify(\n {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n },\n null,\n 2,\n ),\n );\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 Use other Mastra Storage options instead e.g @mastra/pg`,\n );\n process.exit(1);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,37 +1,63 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-storage-20250225005900",
3
+ "version": "0.0.0-stream-vnext-usage-20250908171242",
4
4
  "description": "",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "CHANGELOG.md"
9
+ ],
6
10
  "main": "dist/index.js",
7
11
  "types": "dist/index.d.ts",
8
12
  "exports": {
9
13
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.cjs"
21
+ }
12
22
  },
13
23
  "./package.json": "./package.json"
14
24
  },
15
25
  "keywords": [],
16
26
  "author": "",
17
- "license": "ISC",
27
+ "license": "Apache-2.0",
18
28
  "dependencies": {
19
29
  "@rollup/plugin-virtual": "^3.0.2",
20
- "fs-extra": "^11.2.0",
21
- "@mastra/core": "^0.0.0-storage-20250225005900",
22
- "@mastra/deployer": "^0.0.0-storage-20250225005900"
30
+ "fs-extra": "^11.3.1",
31
+ "@mastra/deployer": "0.0.0-stream-vnext-usage-20250908171242"
23
32
  },
24
33
  "devDependencies": {
25
- "@microsoft/api-extractor": "^7.49.2",
26
- "@types/node": "^22.13.1",
27
- "tsup": "^8.0.1",
28
- "typescript": "^5.7.3",
29
- "vercel": "^39.3.0",
30
- "vitest": "^3.0.4"
34
+ "@microsoft/api-extractor": "^7.52.8",
35
+ "@types/fs-extra": "^11.0.4",
36
+ "@types/node": "^20.19.0",
37
+ "eslint": "^9.30.1",
38
+ "tsup": "^8.5.0",
39
+ "typescript": "^5.8.3",
40
+ "vitest": "^3.2.4",
41
+ "@internal/lint": "0.0.0-stream-vnext-usage-20250908171242",
42
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242",
43
+ "@internal/types-builder": "0.0.0-stream-vnext-usage-20250908171242"
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"
53
+ },
54
+ "peerDependencies": {
55
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242"
31
56
  },
32
57
  "scripts": {
33
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
34
- "build:watch": "pnpm build --watch",
35
- "test": "vitest run"
58
+ "build": "tsup --silent --config tsup.config.ts",
59
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
60
+ "test": "vitest run",
61
+ "lint": "eslint ."
36
62
  }
37
63
  }
@@ -1,19 +0,0 @@
1
-
2
- 
3
- > @mastra/deployer-vercel@0.1.5-alpha.1 build /Users/ward/projects/mastra/mastra/deployers/vercel
4
- > tsup src/index.ts --format esm --experimental-dts --clean --treeshake
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.3.6
9
- TSC Build start
10
- TSC ⚡️ Build success in 1574ms
11
- DTS Build start
12
- CLI Target: es2022
13
- Analysis will use the bundled TypeScript version 5.7.3
14
- Writing package typings: /Users/ward/projects/mastra/mastra/deployers/vercel/dist/_tsup-dts-rollup.d.ts
15
- DTS ⚡️ Build success in 1368ms
16
- CLI Cleaning output folder
17
- ESM Build start
18
- ESM dist/index.js 4.08 KB
19
- ESM ⚡️ Build success in 119ms
package/LICENSE DELETED
@@ -1,44 +0,0 @@
1
- Elastic License 2.0 (ELv2)
2
-
3
- **Acceptance**
4
- By using the software, you agree to all of the terms and conditions below.
5
-
6
- **Copyright License**
7
- 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
8
-
9
- **Limitations**
10
- 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.
11
-
12
- 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.
13
-
14
- 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.
15
-
16
- **Patents**
17
- 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.
18
-
19
- **Notices**
20
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
-
22
- If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
-
24
- **No Other Rights**
25
- These terms do not imply any licenses other than those expressly granted in these terms.
26
-
27
- **Termination**
28
- 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.
29
-
30
- **No Liability**
31
- 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.
32
-
33
- **Definitions**
34
- 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.
35
-
36
- _you_ refers to the individual or entity agreeing to these terms.
37
-
38
- _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.
39
-
40
- _your licenses_ are all the licenses granted to you for the software under these terms.
41
-
42
- _use_ means anything you do with the software requiring one of your licenses.
43
-
44
- _trademark_ means trademarks, service marks, and similar rights.
@@ -1,21 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare class VercelDeployer extends Deployer {
4
- private teamId;
5
- private projectName;
6
- private token;
7
- constructor({ teamId, projectName, token }: {
8
- teamId: string;
9
- projectName: string;
10
- token: string;
11
- });
12
- writeFiles(outputDirectory: string): void;
13
- private getProjectId;
14
- private syncEnv;
15
- prepare(outputDirectory: string): Promise<void>;
16
- private getEntry;
17
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
18
- deploy(outputDirectory: string): Promise<void>;
19
- }
20
-
21
- export { }