@mastra/deployer-vercel 0.0.0-support-monorepos-20250415183219 → 0.0.0-vector-query-sources-20250516172905

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;
18
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
17
+ private writeVercelJSON;
18
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
19
  deploy(outputDirectory: string): 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;
18
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
17
+ private writeVercelJSON;
18
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
19
  deploy(outputDirectory: string): Promise<void>;
20
+ lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
20
21
  }
21
22
 
22
23
  export { }
package/dist/index.cjs CHANGED
@@ -40,32 +40,6 @@ var VercelDeployer = class extends deployer.Deployer {
40
40
  this.projectName = projectName;
41
41
  this.token = token;
42
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
43
  getProjectId({ dir }) {
70
44
  const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
71
45
  try {
@@ -128,22 +102,106 @@ var VercelDeployer = class extends deployer.Deployer {
128
102
  }
129
103
  async prepare(outputDirectory) {
130
104
  await super.prepare(outputDirectory);
131
- await this.writeFiles(outputDirectory);
132
105
  }
133
106
  getEntry() {
134
107
  return `
135
108
  import { handle } from 'hono/vercel'
136
109
  import { mastra } from '#mastra';
137
110
  import { createHonoServer } from '#server';
111
+ import { evaluate } from '@mastra/core/eval';
112
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
113
+ import { TABLE_EVALS } from '@mastra/core/storage';
114
+ import { checkEvalStorageFields } from '@mastra/core/utils';
115
+
116
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
117
+ evaluate({
118
+ agentName,
119
+ input,
120
+ metric,
121
+ output,
122
+ runId,
123
+ globalRunId: runId,
124
+ instructions,
125
+ });
126
+ });
127
+
128
+ if (mastra.getStorage()) {
129
+ // start storage init in the background
130
+ mastra.getStorage().init();
131
+ }
132
+
133
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
134
+ const storage = mastra.getStorage();
135
+ if (storage) {
136
+ // Check for required fields
137
+ const logger = mastra?.getLogger();
138
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
139
+ if (!areFieldsValid) return;
140
+
141
+ await storage.insert({
142
+ tableName: TABLE_EVALS,
143
+ record: {
144
+ input: traceObject.input,
145
+ output: traceObject.output,
146
+ result: JSON.stringify(traceObject.result || {}),
147
+ agent_name: traceObject.agentName,
148
+ metric_name: traceObject.metricName,
149
+ instructions: traceObject.instructions,
150
+ test_info: null,
151
+ global_run_id: traceObject.globalRunId,
152
+ run_id: traceObject.runId,
153
+ created_at: new Date().toISOString(),
154
+ },
155
+ });
156
+ }
157
+ });
138
158
 
139
159
  const app = await createHonoServer(mastra);
140
160
 
141
161
  export const GET = handle(app);
142
162
  export const POST = handle(app);
163
+ export const PUT = handle(app);
164
+ export const DELETE = handle(app);
165
+ export const OPTIONS = handle(app);
166
+ export const HEAD = handle(app);
143
167
  `;
144
168
  }
145
- async bundle(entryFile, outputDirectory) {
146
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
169
+ writeVercelJSON(outputDirectory, files = ["./*"]) {
170
+ fs.writeFileSync(
171
+ path.join(outputDirectory, this.outputDir, "vercel.json"),
172
+ JSON.stringify(
173
+ {
174
+ version: 2,
175
+ installCommand: "npm install --omit=dev",
176
+ builds: [
177
+ {
178
+ src: "index.mjs",
179
+ use: "@vercel/node",
180
+ config: { includeFiles: files }
181
+ }
182
+ ],
183
+ routes: [
184
+ {
185
+ src: "/(.*)",
186
+ dest: "index.mjs"
187
+ }
188
+ ]
189
+ },
190
+ null,
191
+ 2
192
+ )
193
+ );
194
+ }
195
+ async bundle(entryFile, outputDirectory, toolsPaths) {
196
+ const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
197
+ const files = fs.readdirSync(path.join(outputDirectory, this.outputDir), {
198
+ recursive: true
199
+ });
200
+ const filesWithoutNodeModules = files.filter(
201
+ (file) => typeof file === "string" && !file.startsWith("node_modules")
202
+ );
203
+ this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
204
+ return result;
147
205
  }
148
206
  async deploy(outputDirectory) {
149
207
  const envVars = await this.loadEnvVars();
@@ -172,6 +230,18 @@ export const POST = handle(app);
172
230
  this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
173
231
  }
174
232
  }
233
+ async lint(entryFile, outputDirectory, toolsPaths) {
234
+ await super.lint(entryFile, outputDirectory, toolsPaths);
235
+ await super.lint(entryFile, outputDirectory, toolsPaths);
236
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
237
+ if (hasLibsql) {
238
+ this.logger.error(
239
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
240
+ Use other Mastra Storage options instead e.g @mastra/pg`
241
+ );
242
+ process__default.default.exit(1);
243
+ }
244
+ }
175
245
  };
176
246
 
177
247
  exports.VercelDeployer = VercelDeployer;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as child_process from 'child_process';
2
- import { writeFileSync, readFileSync } from 'fs';
2
+ import { readFileSync, writeFileSync, readdirSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import process from 'process';
5
5
  import { Deployer } from '@mastra/deployer';
@@ -15,32 +15,6 @@ var VercelDeployer = class extends Deployer {
15
15
  this.projectName = projectName;
16
16
  this.token = token;
17
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
18
  getProjectId({ dir }) {
45
19
  const projectJsonPath = join(dir, "output", ".vercel", "project.json");
46
20
  try {
@@ -103,22 +77,106 @@ var VercelDeployer = class extends Deployer {
103
77
  }
104
78
  async prepare(outputDirectory) {
105
79
  await super.prepare(outputDirectory);
106
- await this.writeFiles(outputDirectory);
107
80
  }
108
81
  getEntry() {
109
82
  return `
110
83
  import { handle } from 'hono/vercel'
111
84
  import { mastra } from '#mastra';
112
85
  import { createHonoServer } from '#server';
86
+ import { evaluate } from '@mastra/core/eval';
87
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
88
+ import { TABLE_EVALS } from '@mastra/core/storage';
89
+ import { checkEvalStorageFields } from '@mastra/core/utils';
90
+
91
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
92
+ evaluate({
93
+ agentName,
94
+ input,
95
+ metric,
96
+ output,
97
+ runId,
98
+ globalRunId: runId,
99
+ instructions,
100
+ });
101
+ });
102
+
103
+ if (mastra.getStorage()) {
104
+ // start storage init in the background
105
+ mastra.getStorage().init();
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
+ });
113
133
 
114
134
  const app = await createHonoServer(mastra);
115
135
 
116
136
  export const GET = handle(app);
117
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);
118
142
  `;
119
143
  }
120
- async bundle(entryFile, outputDirectory) {
121
- return this._bundle(this.getEntry(), entryFile, outputDirectory);
144
+ writeVercelJSON(outputDirectory, files = ["./*"]) {
145
+ writeFileSync(
146
+ 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
+ );
169
+ }
170
+ async bundle(entryFile, outputDirectory, toolsPaths) {
171
+ const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
172
+ const files = readdirSync(join(outputDirectory, this.outputDir), {
173
+ recursive: true
174
+ });
175
+ const filesWithoutNodeModules = files.filter(
176
+ (file) => typeof file === "string" && !file.startsWith("node_modules")
177
+ );
178
+ this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
179
+ return result;
122
180
  }
123
181
  async deploy(outputDirectory) {
124
182
  const envVars = await this.loadEnvVars();
@@ -147,6 +205,18 @@ export const POST = handle(app);
147
205
  this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
148
206
  }
149
207
  }
208
+ async lint(entryFile, outputDirectory, toolsPaths) {
209
+ await super.lint(entryFile, outputDirectory, toolsPaths);
210
+ await super.lint(entryFile, outputDirectory, toolsPaths);
211
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
212
+ if (hasLibsql) {
213
+ this.logger.error(
214
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
215
+ Use other Mastra Storage options instead e.g @mastra/pg`
216
+ );
217
+ process.exit(1);
218
+ }
219
+ }
150
220
  };
151
221
 
152
222
  export { VercelDeployer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-support-monorepos-20250415183219",
3
+ "version": "0.0.0-vector-query-sources-20250516172905",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,18 +27,18 @@
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
29
  "fs-extra": "^11.3.0",
30
- "@mastra/core": "0.8.3",
31
- "@mastra/deployer": "0.0.0-support-monorepos-20250415183219"
30
+ "@mastra/core": "0.0.0-vector-query-sources-20250516172905",
31
+ "@mastra/deployer": "0.0.0-vector-query-sources-20250516172905"
32
32
  },
33
33
  "devDependencies": {
34
- "@microsoft/api-extractor": "^7.52.1",
34
+ "@microsoft/api-extractor": "^7.52.5",
35
35
  "@types/node": "^20.17.27",
36
36
  "eslint": "^9.23.0",
37
37
  "tsup": "^8.4.0",
38
38
  "typescript": "^5.8.2",
39
39
  "vercel": "^39.4.2",
40
- "vitest": "^3.0.9",
41
- "@internal/lint": "0.0.2"
40
+ "vitest": "^3.1.2",
41
+ "@internal/lint": "0.0.0-vector-query-sources-20250516172905"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",