@mastra/deployer-vercel 0.0.0-revert-schema-20250416221206 → 0.0.0-scorers-api-v2-20250801171841

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/dist/index.cjs CHANGED
@@ -1,177 +1,141 @@
1
1
  'use strict';
2
2
 
3
- var child_process = require('child_process');
4
3
  var fs = require('fs');
5
4
  var path = require('path');
6
5
  var process = require('process');
7
6
  var deployer = require('@mastra/deployer');
7
+ var esm = require('fs-extra/esm');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
30
11
  var process__default = /*#__PURE__*/_interopDefault(process);
31
12
 
32
13
  // src/index.ts
33
14
  var VercelDeployer = class extends deployer.Deployer {
34
- teamSlug;
35
- projectName;
36
- token;
37
- constructor({ teamSlug, projectName, token }) {
15
+ constructor() {
38
16
  super({ name: "VERCEL" });
39
- this.teamSlug = teamSlug;
40
- this.projectName = projectName;
41
- this.token = token;
42
- }
43
- writeFiles(outputDirectory) {
44
- fs.writeFileSync(
45
- path.join(outputDirectory, this.outputDir, "vercel.json"),
46
- JSON.stringify(
47
- {
48
- version: 2,
49
- installCommand: "npm install --omit=dev",
50
- builds: [
51
- {
52
- src: "index.mjs",
53
- use: "@vercel/node",
54
- config: { includeFiles: ["**"] }
55
- }
56
- ],
57
- routes: [
58
- {
59
- src: "/(.*)",
60
- dest: "index.mjs"
61
- }
62
- ]
63
- },
64
- null,
65
- 2
66
- )
67
- );
68
- }
69
- getProjectId({ dir }) {
70
- const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
71
- try {
72
- const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
73
- return projectJson.projectId;
74
- } catch {
75
- throw new Error("Could not find project ID. Make sure the project has been deployed first.");
76
- }
77
- }
78
- async getTeamId() {
79
- const response = await fetch(`https://api.vercel.com/v2/teams`, {
80
- headers: {
81
- Authorization: `Bearer ${this.token}`
82
- }
83
- });
84
- const res = await response.json();
85
- const teams = res.teams;
86
- return teams.find((team) => team.slug === this.teamSlug)?.id;
87
- }
88
- async syncEnv(envVars, { outputDirectory }) {
89
- console.log("Syncing environment variables...");
90
- const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
91
- if (!key || !value) {
92
- throw new Error(`Invalid environment variable format: ${key || value}`);
93
- }
94
- return {
95
- key,
96
- value,
97
- target: ["production", "preview", "development"],
98
- type: "plain"
99
- };
100
- });
101
- try {
102
- const projectId = this.getProjectId({ dir: outputDirectory });
103
- const teamId = await this.getTeamId();
104
- const response = await fetch(
105
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
106
- {
107
- method: "POST",
108
- headers: {
109
- Authorization: `Bearer ${this.token}`,
110
- "Content-Type": "application/json"
111
- },
112
- body: JSON.stringify(vercelEnvVars)
113
- }
114
- );
115
- if (!response.ok) {
116
- const error = await response.json();
117
- throw new Error(`Failed to sync environment variables: ${error.message}`);
118
- }
119
- console.log("\u2713 Successfully synced environment variables");
120
- } catch (error) {
121
- if (error instanceof Error) {
122
- console.error("Failed to sync environment variables:", error.message);
123
- } else {
124
- console.error("Failed to sync environment variables:", error);
125
- }
126
- throw error;
127
- }
17
+ this.outputDir = path.join(".vercel", "output", "functions", "index.func");
128
18
  }
129
19
  async prepare(outputDirectory) {
130
20
  await super.prepare(outputDirectory);
131
- await this.writeFiles(outputDirectory);
21
+ this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
132
22
  }
133
23
  getEntry() {
134
24
  return `
135
25
  import { handle } from 'hono/vercel'
136
26
  import { mastra } from '#mastra';
137
- import { createHonoServer } from '#server';
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';
138
33
 
139
- const app = await createHonoServer(mastra);
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) });
140
73
 
141
74
  export const GET = handle(app);
142
75
  export const POST = handle(app);
76
+ export const PUT = handle(app);
77
+ export const DELETE = handle(app);
78
+ export const OPTIONS = handle(app);
79
+ export const HEAD = handle(app);
143
80
  `;
144
81
  }
145
- async bundle(entryFile, outputDirectory) {
146
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
82
+ writeVercelJSON(outputDirectory) {
83
+ fs.writeFileSync(
84
+ path.join(outputDirectory, "config.json"),
85
+ JSON.stringify({
86
+ version: 3,
87
+ routes: [
88
+ {
89
+ src: "/(.*)",
90
+ dest: "/"
91
+ }
92
+ ]
93
+ })
94
+ );
147
95
  }
148
- async deploy(outputDirectory) {
149
- const envVars = await this.loadEnvVars();
150
- const commandArgs = [
151
- "--scope",
152
- this.teamSlug,
153
- "--cwd",
154
- path.join(outputDirectory, this.outputDir),
155
- "--token",
156
- this.token,
157
- "deploy",
158
- "--yes",
159
- ...this.projectName ? ["--name", this.projectName] : []
160
- ];
161
- child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
162
- cwd: path.join(outputDirectory, this.outputDir),
163
- env: {
164
- PATH: process__default.default.env.PATH
165
- },
166
- stdio: "inherit"
96
+ async bundle(entryFile, outputDirectory, toolsPaths) {
97
+ const result = await this._bundle(
98
+ this.getEntry(),
99
+ entryFile,
100
+ outputDirectory,
101
+ toolsPaths,
102
+ path.join(outputDirectory, this.outputDir)
103
+ );
104
+ const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
105
+ fs.writeFileSync(
106
+ path.join(outputDirectory, this.outputDir, ".vc-config.json"),
107
+ JSON.stringify(
108
+ {
109
+ handler: "index.mjs",
110
+ launcherType: "Nodejs",
111
+ runtime: `nodejs${nodeVersion}.x`,
112
+ shouldAddHelpers: true
113
+ },
114
+ null,
115
+ 2
116
+ )
117
+ );
118
+ await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
119
+ overwrite: true
167
120
  });
168
- this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
169
- if (envVars.size > 0) {
170
- await this.syncEnv(envVars, { outputDirectory });
171
- } else {
172
- this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
121
+ return result;
122
+ }
123
+ async deploy() {
124
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
125
+ }
126
+ async lint(entryFile, outputDirectory, toolsPaths) {
127
+ await super.lint(entryFile, outputDirectory, toolsPaths);
128
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
129
+ if (hasLibsql) {
130
+ this.logger.error(
131
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
132
+ Use other Mastra Storage options instead e.g @mastra/pg`
133
+ );
134
+ process__default.default.exit(1);
173
135
  }
174
136
  }
175
137
  };
176
138
 
177
139
  exports.VercelDeployer = VercelDeployer;
140
+ //# sourceMappingURL=index.cjs.map
141
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","writeFileSync","process","move"],"mappings":";;;;;;;;;;;;;AAMO,IAAM,cAAA,GAAN,cAA6BA,iBAAA,CAAS;AAAA,EAC3C,WAAA,GAAc;AACZ,IAAA,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O,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 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[]): 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[]): 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[]): Promise<void>;
8
+ deploy(): Promise<void>;
9
+ lint(entryFile: string, outputDirectory: string, toolsPaths: 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;IA4DhB,OAAO,CAAC,eAAe;IAejB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BvF,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAa5F"}
package/dist/index.js CHANGED
@@ -1,152 +1,135 @@
1
- import * as child_process from 'child_process';
2
- import { writeFileSync, readFileSync } from 'fs';
1
+ import { writeFileSync } from 'fs';
3
2
  import { join } from 'path';
4
3
  import process from 'process';
5
4
  import { Deployer } from '@mastra/deployer';
5
+ import { move } from 'fs-extra/esm';
6
6
 
7
7
  // src/index.ts
8
8
  var VercelDeployer = class extends Deployer {
9
- teamSlug;
10
- projectName;
11
- token;
12
- constructor({ teamSlug, projectName, token }) {
9
+ constructor() {
13
10
  super({ name: "VERCEL" });
14
- this.teamSlug = teamSlug;
15
- this.projectName = projectName;
16
- this.token = token;
17
- }
18
- writeFiles(outputDirectory) {
19
- writeFileSync(
20
- join(outputDirectory, this.outputDir, "vercel.json"),
21
- JSON.stringify(
22
- {
23
- version: 2,
24
- installCommand: "npm install --omit=dev",
25
- builds: [
26
- {
27
- src: "index.mjs",
28
- use: "@vercel/node",
29
- config: { includeFiles: ["**"] }
30
- }
31
- ],
32
- routes: [
33
- {
34
- src: "/(.*)",
35
- dest: "index.mjs"
36
- }
37
- ]
38
- },
39
- null,
40
- 2
41
- )
42
- );
43
- }
44
- getProjectId({ dir }) {
45
- const projectJsonPath = join(dir, "output", ".vercel", "project.json");
46
- try {
47
- const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
48
- return projectJson.projectId;
49
- } catch {
50
- throw new Error("Could not find project ID. Make sure the project has been deployed first.");
51
- }
52
- }
53
- async getTeamId() {
54
- const response = await fetch(`https://api.vercel.com/v2/teams`, {
55
- headers: {
56
- Authorization: `Bearer ${this.token}`
57
- }
58
- });
59
- const res = await response.json();
60
- const teams = res.teams;
61
- return teams.find((team) => team.slug === this.teamSlug)?.id;
62
- }
63
- async syncEnv(envVars, { outputDirectory }) {
64
- console.log("Syncing environment variables...");
65
- const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
66
- if (!key || !value) {
67
- throw new Error(`Invalid environment variable format: ${key || value}`);
68
- }
69
- return {
70
- key,
71
- value,
72
- target: ["production", "preview", "development"],
73
- type: "plain"
74
- };
75
- });
76
- try {
77
- const projectId = this.getProjectId({ dir: outputDirectory });
78
- const teamId = await this.getTeamId();
79
- const response = await fetch(
80
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
81
- {
82
- method: "POST",
83
- headers: {
84
- Authorization: `Bearer ${this.token}`,
85
- "Content-Type": "application/json"
86
- },
87
- body: JSON.stringify(vercelEnvVars)
88
- }
89
- );
90
- if (!response.ok) {
91
- const error = await response.json();
92
- throw new Error(`Failed to sync environment variables: ${error.message}`);
93
- }
94
- console.log("\u2713 Successfully synced environment variables");
95
- } catch (error) {
96
- if (error instanceof Error) {
97
- console.error("Failed to sync environment variables:", error.message);
98
- } else {
99
- console.error("Failed to sync environment variables:", error);
100
- }
101
- throw error;
102
- }
11
+ this.outputDir = join(".vercel", "output", "functions", "index.func");
103
12
  }
104
13
  async prepare(outputDirectory) {
105
14
  await super.prepare(outputDirectory);
106
- await this.writeFiles(outputDirectory);
15
+ this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
107
16
  }
108
17
  getEntry() {
109
18
  return `
110
19
  import { handle } from 'hono/vercel'
111
20
  import { mastra } from '#mastra';
112
- 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';
113
27
 
114
- 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) });
115
67
 
116
68
  export const GET = handle(app);
117
69
  export const POST = handle(app);
70
+ export const PUT = handle(app);
71
+ export const DELETE = handle(app);
72
+ export const OPTIONS = handle(app);
73
+ export const HEAD = handle(app);
118
74
  `;
119
75
  }
120
- async bundle(entryFile, outputDirectory) {
121
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
76
+ writeVercelJSON(outputDirectory) {
77
+ writeFileSync(
78
+ join(outputDirectory, "config.json"),
79
+ JSON.stringify({
80
+ version: 3,
81
+ routes: [
82
+ {
83
+ src: "/(.*)",
84
+ dest: "/"
85
+ }
86
+ ]
87
+ })
88
+ );
122
89
  }
123
- async deploy(outputDirectory) {
124
- const envVars = await this.loadEnvVars();
125
- const commandArgs = [
126
- "--scope",
127
- this.teamSlug,
128
- "--cwd",
129
- join(outputDirectory, this.outputDir),
130
- "--token",
131
- this.token,
132
- "deploy",
133
- "--yes",
134
- ...this.projectName ? ["--name", this.projectName] : []
135
- ];
136
- child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
137
- cwd: join(outputDirectory, this.outputDir),
138
- env: {
139
- PATH: process.env.PATH
140
- },
141
- stdio: "inherit"
90
+ async bundle(entryFile, outputDirectory, toolsPaths) {
91
+ const result = await this._bundle(
92
+ this.getEntry(),
93
+ entryFile,
94
+ outputDirectory,
95
+ toolsPaths,
96
+ join(outputDirectory, this.outputDir)
97
+ );
98
+ const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
99
+ writeFileSync(
100
+ join(outputDirectory, this.outputDir, ".vc-config.json"),
101
+ JSON.stringify(
102
+ {
103
+ handler: "index.mjs",
104
+ launcherType: "Nodejs",
105
+ runtime: `nodejs${nodeVersion}.x`,
106
+ shouldAddHelpers: true
107
+ },
108
+ null,
109
+ 2
110
+ )
111
+ );
112
+ await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
113
+ overwrite: true
142
114
  });
143
- this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
144
- if (envVars.size > 0) {
145
- await this.syncEnv(envVars, { outputDirectory });
146
- } else {
147
- this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
115
+ return result;
116
+ }
117
+ async deploy() {
118
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
119
+ }
120
+ async lint(entryFile, outputDirectory, toolsPaths) {
121
+ await super.lint(entryFile, outputDirectory, toolsPaths);
122
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
123
+ if (hasLibsql) {
124
+ this.logger.error(
125
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
126
+ Use other Mastra Storage options instead e.g @mastra/pg`
127
+ );
128
+ process.exit(1);
148
129
  }
149
130
  }
150
131
  };
151
132
 
152
133
  export { VercelDeployer };
134
+ //# sourceMappingURL=index.js.map
135
+ //# 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;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;;A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,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,EAAqC;AAC1F,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 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[]): 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[]): 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-revert-schema-20250416221206",
3
+ "version": "0.0.0-scorers-api-v2-20250801171841",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,26 +23,29 @@
23
23
  },
24
24
  "keywords": [],
25
25
  "author": "",
26
- "license": "Elastic-2.0",
26
+ "license": "Apache-2.0",
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
29
  "fs-extra": "^11.3.0",
30
- "@mastra/core": "0.0.0-revert-schema-20250416221206",
31
- "@mastra/deployer": "0.0.0-revert-schema-20250416221206"
30
+ "@mastra/deployer": "0.0.0-scorers-api-v2-20250801171841"
32
31
  },
33
32
  "devDependencies": {
34
- "@microsoft/api-extractor": "^7.52.1",
35
- "@types/node": "^20.17.27",
36
- "eslint": "^9.23.0",
37
- "tsup": "^8.4.0",
38
- "typescript": "^5.8.2",
39
- "vercel": "^39.4.2",
40
- "vitest": "^3.0.9",
41
- "@internal/lint": "0.0.2"
33
+ "@microsoft/api-extractor": "^7.52.8",
34
+ "@types/fs-extra": "^11.0.4",
35
+ "@types/node": "^20.19.0",
36
+ "eslint": "^9.30.1",
37
+ "tsup": "^8.5.0",
38
+ "typescript": "^5.8.3",
39
+ "vitest": "^3.2.4",
40
+ "@internal/lint": "0.0.0-scorers-api-v2-20250801171841",
41
+ "@mastra/core": "0.0.0-scorers-api-v2-20250801171841"
42
+ },
43
+ "peerDependencies": {
44
+ "@mastra/core": "0.0.0-scorers-api-v2-20250801171841"
42
45
  },
43
46
  "scripts": {
44
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
45
- "build:watch": "pnpm build --watch",
47
+ "build": "tsup --silent --config tsup.config.ts",
48
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
46
49
  "test": "vitest run",
47
50
  "lint": "eslint ."
48
51
  }
@@ -1,22 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare class VercelDeployer extends Deployer {
4
- private teamSlug;
5
- private projectName;
6
- private token;
7
- constructor({ teamSlug, projectName, token }: {
8
- teamSlug: string;
9
- projectName: string;
10
- token: string;
11
- });
12
- writeFiles(outputDirectory: string): void;
13
- private getProjectId;
14
- private getTeamId;
15
- private syncEnv;
16
- prepare(outputDirectory: string): Promise<void>;
17
- private getEntry;
18
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
20
- }
21
-
22
- export { }
@@ -1,22 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare class VercelDeployer extends Deployer {
4
- private teamSlug;
5
- private projectName;
6
- private token;
7
- constructor({ teamSlug, projectName, token }: {
8
- teamSlug: string;
9
- projectName: string;
10
- token: string;
11
- });
12
- writeFiles(outputDirectory: string): void;
13
- private getProjectId;
14
- private getTeamId;
15
- private syncEnv;
16
- prepare(outputDirectory: string): Promise<void>;
17
- private getEntry;
18
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
20
- }
21
-
22
- export { }
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export { VercelDeployer } from './_tsup-dts-rollup.cjs';