@mastra/deployer-vercel 0.0.0-vnextWorkflows-20250422142014 → 0.0.0-workflow-deno-20250616130925

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.
@@ -9,14 +9,15 @@ export declare class VercelDeployer extends Deployer {
9
9
  projectName: string;
10
10
  token: string;
11
11
  });
12
- writeFiles(outputDirectory: string): void;
13
12
  private getProjectId;
14
13
  private getTeamId;
15
14
  private syncEnv;
16
15
  prepare(outputDirectory: string): Promise<void>;
17
16
  private getEntry;
17
+ private writeVercelJSON;
18
18
  bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
19
+ deploy(): Promise<void>;
20
+ lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
20
21
  }
21
22
 
22
23
  export { }
@@ -9,14 +9,15 @@ export declare class VercelDeployer extends Deployer {
9
9
  projectName: string;
10
10
  token: string;
11
11
  });
12
- writeFiles(outputDirectory: string): void;
13
12
  private getProjectId;
14
13
  private getTeamId;
15
14
  private syncEnv;
16
15
  prepare(outputDirectory: string): Promise<void>;
17
16
  private getEntry;
17
+ private writeVercelJSON;
18
18
  bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
19
+ deploy(): Promise<void>;
20
+ lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
20
21
  }
21
22
 
22
23
  export { }
package/dist/index.cjs CHANGED
@@ -1,6 +1,5 @@
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');
@@ -8,25 +7,6 @@ var deployer = require('@mastra/deployer');
8
7
 
9
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
9
 
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
10
  var process__default = /*#__PURE__*/_interopDefault(process);
31
11
 
32
12
  // src/index.ts
@@ -40,32 +20,6 @@ var VercelDeployer = class extends deployer.Deployer {
40
20
  this.projectName = projectName;
41
21
  this.token = token;
42
22
  }
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
23
  getProjectId({ dir }) {
70
24
  const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
71
25
  try {
@@ -128,48 +82,115 @@ var VercelDeployer = class extends deployer.Deployer {
128
82
  }
129
83
  async prepare(outputDirectory) {
130
84
  await super.prepare(outputDirectory);
131
- await this.writeFiles(outputDirectory);
132
85
  }
133
86
  getEntry() {
134
87
  return `
135
88
  import { handle } from 'hono/vercel'
136
89
  import { mastra } from '#mastra';
137
90
  import { createHonoServer } from '#server';
91
+ import { evaluate } from '@mastra/core/eval';
92
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
93
+ import { TABLE_EVALS } from '@mastra/core/storage';
94
+ import { checkEvalStorageFields } from '@mastra/core/utils';
95
+
96
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
97
+ evaluate({
98
+ agentName,
99
+ input,
100
+ metric,
101
+ output,
102
+ runId,
103
+ globalRunId: runId,
104
+ instructions,
105
+ });
106
+ });
107
+
108
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
109
+ const storage = mastra.getStorage();
110
+ if (storage) {
111
+ // Check for required fields
112
+ const logger = mastra?.getLogger();
113
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
114
+ if (!areFieldsValid) return;
115
+
116
+ await storage.insert({
117
+ tableName: TABLE_EVALS,
118
+ record: {
119
+ input: traceObject.input,
120
+ output: traceObject.output,
121
+ result: JSON.stringify(traceObject.result || {}),
122
+ agent_name: traceObject.agentName,
123
+ metric_name: traceObject.metricName,
124
+ instructions: traceObject.instructions,
125
+ test_info: null,
126
+ global_run_id: traceObject.globalRunId,
127
+ run_id: traceObject.runId,
128
+ created_at: new Date().toISOString(),
129
+ },
130
+ });
131
+ }
132
+ });
138
133
 
139
134
  const app = await createHonoServer(mastra);
140
135
 
141
136
  export const GET = handle(app);
142
137
  export const POST = handle(app);
138
+ export const PUT = handle(app);
139
+ export const DELETE = handle(app);
140
+ export const OPTIONS = handle(app);
141
+ export const HEAD = handle(app);
143
142
  `;
144
143
  }
145
- async bundle(entryFile, outputDirectory, toolsPaths) {
146
- return this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
144
+ writeVercelJSON(outputDirectory, files = ["./*"]) {
145
+ fs.writeFileSync(
146
+ path.join(outputDirectory, this.outputDir, "vercel.json"),
147
+ JSON.stringify(
148
+ {
149
+ version: 2,
150
+ installCommand: "npm install --omit=dev",
151
+ builds: [
152
+ {
153
+ src: "index.mjs",
154
+ use: "@vercel/node",
155
+ config: { includeFiles: files }
156
+ }
157
+ ],
158
+ routes: [
159
+ {
160
+ src: "/(.*)",
161
+ dest: "index.mjs"
162
+ }
163
+ ]
164
+ },
165
+ null,
166
+ 2
167
+ )
168
+ );
147
169
  }
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"
170
+ async bundle(entryFile, outputDirectory, toolsPaths) {
171
+ const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
172
+ const files = fs.readdirSync(path.join(outputDirectory, this.outputDir), {
173
+ recursive: true
167
174
  });
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");
175
+ const filesWithoutNodeModules = files.filter(
176
+ (file) => typeof file === "string" && !file.startsWith("node_modules")
177
+ );
178
+ this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
179
+ return result;
180
+ }
181
+ async deploy() {
182
+ this.logger?.info("Deploying to Vercel failed. Please use the Vercel dashboard to deploy.");
183
+ }
184
+ async lint(entryFile, outputDirectory, toolsPaths) {
185
+ await super.lint(entryFile, outputDirectory, toolsPaths);
186
+ await super.lint(entryFile, outputDirectory, toolsPaths);
187
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
188
+ if (hasLibsql) {
189
+ this.logger.error(
190
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
191
+ Use other Mastra Storage options instead e.g @mastra/pg`
192
+ );
193
+ process__default.default.exit(1);
173
194
  }
174
195
  }
175
196
  };
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import * as child_process from 'child_process';
2
- import { writeFileSync, readFileSync } from 'fs';
1
+ import { readFileSync, writeFileSync, readdirSync } from 'fs';
3
2
  import { join } from 'path';
4
3
  import process from 'process';
5
4
  import { Deployer } from '@mastra/deployer';
@@ -15,32 +14,6 @@ var VercelDeployer = class extends Deployer {
15
14
  this.projectName = projectName;
16
15
  this.token = token;
17
16
  }
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
17
  getProjectId({ dir }) {
45
18
  const projectJsonPath = join(dir, "output", ".vercel", "project.json");
46
19
  try {
@@ -103,48 +76,115 @@ var VercelDeployer = class extends Deployer {
103
76
  }
104
77
  async prepare(outputDirectory) {
105
78
  await super.prepare(outputDirectory);
106
- await this.writeFiles(outputDirectory);
107
79
  }
108
80
  getEntry() {
109
81
  return `
110
82
  import { handle } from 'hono/vercel'
111
83
  import { mastra } from '#mastra';
112
84
  import { createHonoServer } from '#server';
85
+ import { evaluate } from '@mastra/core/eval';
86
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
87
+ import { TABLE_EVALS } from '@mastra/core/storage';
88
+ import { checkEvalStorageFields } from '@mastra/core/utils';
89
+
90
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
91
+ evaluate({
92
+ agentName,
93
+ input,
94
+ metric,
95
+ output,
96
+ runId,
97
+ globalRunId: runId,
98
+ instructions,
99
+ });
100
+ });
101
+
102
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
103
+ const storage = mastra.getStorage();
104
+ if (storage) {
105
+ // Check for required fields
106
+ const logger = mastra?.getLogger();
107
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
108
+ if (!areFieldsValid) return;
109
+
110
+ await storage.insert({
111
+ tableName: TABLE_EVALS,
112
+ record: {
113
+ input: traceObject.input,
114
+ output: traceObject.output,
115
+ result: JSON.stringify(traceObject.result || {}),
116
+ agent_name: traceObject.agentName,
117
+ metric_name: traceObject.metricName,
118
+ instructions: traceObject.instructions,
119
+ test_info: null,
120
+ global_run_id: traceObject.globalRunId,
121
+ run_id: traceObject.runId,
122
+ created_at: new Date().toISOString(),
123
+ },
124
+ });
125
+ }
126
+ });
113
127
 
114
128
  const app = await createHonoServer(mastra);
115
129
 
116
130
  export const GET = handle(app);
117
131
  export const POST = handle(app);
132
+ export const PUT = handle(app);
133
+ export const DELETE = handle(app);
134
+ export const OPTIONS = handle(app);
135
+ export const HEAD = handle(app);
118
136
  `;
119
137
  }
120
- async bundle(entryFile, outputDirectory, toolsPaths) {
121
- return this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
138
+ writeVercelJSON(outputDirectory, files = ["./*"]) {
139
+ writeFileSync(
140
+ join(outputDirectory, this.outputDir, "vercel.json"),
141
+ JSON.stringify(
142
+ {
143
+ version: 2,
144
+ installCommand: "npm install --omit=dev",
145
+ builds: [
146
+ {
147
+ src: "index.mjs",
148
+ use: "@vercel/node",
149
+ config: { includeFiles: files }
150
+ }
151
+ ],
152
+ routes: [
153
+ {
154
+ src: "/(.*)",
155
+ dest: "index.mjs"
156
+ }
157
+ ]
158
+ },
159
+ null,
160
+ 2
161
+ )
162
+ );
122
163
  }
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"
164
+ async bundle(entryFile, outputDirectory, toolsPaths) {
165
+ const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
166
+ const files = readdirSync(join(outputDirectory, this.outputDir), {
167
+ recursive: true
142
168
  });
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");
169
+ const filesWithoutNodeModules = files.filter(
170
+ (file) => typeof file === "string" && !file.startsWith("node_modules")
171
+ );
172
+ this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
173
+ return result;
174
+ }
175
+ async deploy() {
176
+ this.logger?.info("Deploying to Vercel failed. Please use the Vercel dashboard to deploy.");
177
+ }
178
+ async lint(entryFile, outputDirectory, toolsPaths) {
179
+ await super.lint(entryFile, outputDirectory, toolsPaths);
180
+ await super.lint(entryFile, outputDirectory, toolsPaths);
181
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
182
+ if (hasLibsql) {
183
+ this.logger.error(
184
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
185
+ Use other Mastra Storage options instead e.g @mastra/pg`
186
+ );
187
+ process.exit(1);
148
188
  }
149
189
  }
150
190
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-vnextWorkflows-20250422142014",
3
+ "version": "0.0.0-workflow-deno-20250616130925",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,18 +27,20 @@
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
29
  "fs-extra": "^11.3.0",
30
- "@mastra/core": "0.0.0-vnextWorkflows-20250422142014",
31
- "@mastra/deployer": "0.0.0-vnextWorkflows-20250422142014"
30
+ "@mastra/deployer": "0.0.0-workflow-deno-20250616130925"
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/node": "^20.19.0",
35
+ "eslint": "^9.28.0",
36
+ "tsup": "^8.5.0",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^3.2.3",
39
+ "@internal/lint": "0.0.0-workflow-deno-20250616130925",
40
+ "@mastra/core": "0.0.0-workflow-deno-20250616130925"
41
+ },
42
+ "peerDependencies": {
43
+ "@mastra/core": "^0.10.1-alpha.0"
42
44
  },
43
45
  "scripts": {
44
46
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",