@mastra/deployer-vercel 0.12.4-alpha.0 → 0.12.5-alpha.0
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/CHANGELOG.md +20 -0
- package/README.md +9 -6
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/deployer-vercel
|
|
2
2
|
|
|
3
|
+
## 0.12.5-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat(deployer-vercel): add params for vc-config.json ([#8339](https://github.com/mastra-ai/mastra/pull/8339))
|
|
8
|
+
|
|
9
|
+
- Breaking change to move the agent.streamVNext/generateVNext implementation to the default stream/generate. The old stream/generate have now been moved to streamLegacy and generateLegacy ([#8097](https://github.com/mastra-ai/mastra/pull/8097))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`989a4db`](https://github.com/mastra-ai/mastra/commit/989a4dbbaf07a2794d0e1863714c6d10f1244d6b), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`d41aee5`](https://github.com/mastra-ai/mastra/commit/d41aee526d124e35f42720a08e64043229193679), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
|
|
12
|
+
- @mastra/core@0.20.0-alpha.0
|
|
13
|
+
- @mastra/deployer@0.20.0-alpha.0
|
|
14
|
+
|
|
15
|
+
## 0.12.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`4a70ccc`](https://github.com/mastra-ai/mastra/commit/4a70ccc5cfa12ae9c2b36545a5814cd98e5a0ead), [`0992b8b`](https://github.com/mastra-ai/mastra/commit/0992b8bf0f4f1ba7ad9940883ec4bb8d867d3105), [`283bea0`](https://github.com/mastra-ai/mastra/commit/283bea07adbaf04a27fa3ad2df611095e0825195)]:
|
|
20
|
+
- @mastra/core@0.19.1
|
|
21
|
+
- @mastra/deployer@0.19.1
|
|
22
|
+
|
|
3
23
|
## 0.12.4-alpha.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,9 +25,10 @@ import { Mastra } from '@mastra/core';
|
|
|
25
25
|
import { VercelDeployer } from '@mastra/deployer-vercel';
|
|
26
26
|
|
|
27
27
|
const deployer = new VercelDeployer({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// Optional per-function overrides (written to .vc-config.json)
|
|
29
|
+
maxDuration: 600,
|
|
30
|
+
memory: 1536,
|
|
31
|
+
regions: ['sfo1', 'iad1'],
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
const mastra = new Mastra({
|
|
@@ -40,9 +41,11 @@ const mastra = new Mastra({
|
|
|
40
41
|
|
|
41
42
|
### Constructor Options
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- `
|
|
44
|
+
High‑value overrides written to `.vercel/output/functions/index.func/.vc-config.json`:
|
|
45
|
+
|
|
46
|
+
- `maxDuration?: number` — Function execution timeout (seconds)
|
|
47
|
+
- `memory?: number` — Function memory (MB)
|
|
48
|
+
- `regions?: string[]` — Regions (e.g. `['sfo1','iad1']`)
|
|
46
49
|
|
|
47
50
|
## Project Structure
|
|
48
51
|
|
package/dist/index.cjs
CHANGED
|
@@ -12,9 +12,11 @@ var process__default = /*#__PURE__*/_interopDefault(process);
|
|
|
12
12
|
|
|
13
13
|
// src/index.ts
|
|
14
14
|
var VercelDeployer = class extends deployer.Deployer {
|
|
15
|
-
|
|
15
|
+
vcConfigOverrides = {};
|
|
16
|
+
constructor(options = {}) {
|
|
16
17
|
super({ name: "VERCEL" });
|
|
17
18
|
this.outputDir = path.join(".vercel", "output", "functions", "index.func");
|
|
19
|
+
this.vcConfigOverrides = { ...options };
|
|
18
20
|
}
|
|
19
21
|
async prepare(outputDirectory) {
|
|
20
22
|
await super.prepare(outputDirectory);
|
|
@@ -108,19 +110,17 @@ export const HEAD = handle(app);
|
|
|
108
110
|
path.join(outputDirectory, this.outputDir)
|
|
109
111
|
);
|
|
110
112
|
const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
);
|
|
113
|
+
const vcConfig = {
|
|
114
|
+
handler: "index.mjs",
|
|
115
|
+
launcherType: "Nodejs",
|
|
116
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
117
|
+
shouldAddHelpers: true
|
|
118
|
+
};
|
|
119
|
+
const { maxDuration, memory, regions } = this.vcConfigOverrides;
|
|
120
|
+
if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
|
|
121
|
+
if (typeof memory === "number") vcConfig.memory = memory;
|
|
122
|
+
if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
|
|
123
|
+
fs.writeFileSync(path.join(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
|
|
124
124
|
await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
|
|
125
125
|
overwrite: true
|
|
126
126
|
});
|
|
@@ -135,7 +135,7 @@ export const HEAD = handle(app);
|
|
|
135
135
|
if (hasLibsql) {
|
|
136
136
|
this.logger.error(
|
|
137
137
|
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
138
|
-
|
|
138
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
139
139
|
);
|
|
140
140
|
process__default.default.exit(1);
|
|
141
141
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","writeFileSync","process","move"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","writeFileSync","process","move"],"mappings":";;;;;;;;;;;;;AAOO,IAAM,cAAA,GAAN,cAA6BA,iBAAA,CAAS;AAAA,EACnC,oBAAuC,EAAC;AAAA,EAEhD,WAAA,CAAY,OAAA,GAAiC,EAAC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AC/F,SAAA,EAAW;AAAA,KACZ,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,MAAM,MAAA,GAAwB;AAC5B,IAAA,IAAA,CAAK,MAAA,EAAQ,KAAK,+EAA+E,CAAA;AAAA,EACnG;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAEvD,IAAA,MAAM,SAAA,GAAa,MAAM,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,QACV,CAAA;AAAA,2DAAA;AAAA,OAEF;AACA,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';\nimport type { VcConfig, VcConfigOverrides, VercelDeployerOptions } from './types';\n\nexport class VercelDeployer extends Deployer {\n private vcConfigOverrides: VcConfigOverrides = {};\n\n constructor(options: VercelDeployerOptions = {}) {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\n\n // Store all overrides centrally\n this.vcConfigOverrides = { ...options };\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n\n this.writeVercelJSON(join(outputDirectory, this.outputDir, '..', '..'));\n }\n\n private getEntry(): string {\n return `\nimport { handle } from 'hono/vercel'\nimport { mastra } from '#mastra';\nimport { createHonoServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { evaluate } from '@mastra/core/eval';\nimport { AvailableHooks, registerHook } from '@mastra/core/hooks';\nimport { TABLE_EVALS } from '@mastra/core/storage';\nimport { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';\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\nif (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\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(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n\n const vcConfig: VcConfig = {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n };\n\n // Merge supported overrides\n const { maxDuration, memory, regions } = this.vcConfigOverrides;\n if (typeof maxDuration === 'number') vcConfig.maxDuration = maxDuration;\n if (typeof memory === 'number') vcConfig.memory = memory;\n if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;\n\n writeFileSync(join(outputDirectory, this.outputDir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));\n\n await move(join(outputDirectory, '.vercel', 'output'), join(process.cwd(), '.vercel', 'output'), {\n overwrite: true,\n });\n\n return result;\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.');\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger.error(\n `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency. \n\t\t\t\tUse other Mastra Storage options instead e.g @mastra/pg`,\n );\n process.exit(1);\n }\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
import type { VercelDeployerOptions } from './types.js';
|
|
2
3
|
export declare class VercelDeployer extends Deployer {
|
|
3
|
-
|
|
4
|
+
private vcConfigOverrides;
|
|
5
|
+
constructor(options?: VercelDeployerOptions);
|
|
4
6
|
prepare(outputDirectory: string): Promise<void>;
|
|
5
7
|
private getEntry;
|
|
6
8
|
private writeVercelJSON;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAA+B,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAElF,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,OAAO,CAAC,iBAAiB,CAAyB;gBAEtC,OAAO,GAAE,qBAA0B;IAQzC,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,OAAO,CAAC,QAAQ;IAkEhB,OAAO,CAAC,eAAe;IAejB,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAiCV,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAazG"}
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,11 @@ import { move } from 'fs-extra/esm';
|
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
var VercelDeployer = class extends Deployer {
|
|
9
|
-
|
|
9
|
+
vcConfigOverrides = {};
|
|
10
|
+
constructor(options = {}) {
|
|
10
11
|
super({ name: "VERCEL" });
|
|
11
12
|
this.outputDir = join(".vercel", "output", "functions", "index.func");
|
|
13
|
+
this.vcConfigOverrides = { ...options };
|
|
12
14
|
}
|
|
13
15
|
async prepare(outputDirectory) {
|
|
14
16
|
await super.prepare(outputDirectory);
|
|
@@ -102,19 +104,17 @@ export const HEAD = handle(app);
|
|
|
102
104
|
join(outputDirectory, this.outputDir)
|
|
103
105
|
);
|
|
104
106
|
const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)
|
|
117
|
-
);
|
|
107
|
+
const vcConfig = {
|
|
108
|
+
handler: "index.mjs",
|
|
109
|
+
launcherType: "Nodejs",
|
|
110
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
111
|
+
shouldAddHelpers: true
|
|
112
|
+
};
|
|
113
|
+
const { maxDuration, memory, regions } = this.vcConfigOverrides;
|
|
114
|
+
if (typeof maxDuration === "number") vcConfig.maxDuration = maxDuration;
|
|
115
|
+
if (typeof memory === "number") vcConfig.memory = memory;
|
|
116
|
+
if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;
|
|
117
|
+
writeFileSync(join(outputDirectory, this.outputDir, ".vc-config.json"), JSON.stringify(vcConfig, null, 2));
|
|
118
118
|
await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
|
|
119
119
|
overwrite: true
|
|
120
120
|
});
|
|
@@ -129,7 +129,7 @@ export const HEAD = handle(app);
|
|
|
129
129
|
if (hasLibsql) {
|
|
130
130
|
this.logger.error(
|
|
131
131
|
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
132
|
-
|
|
132
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
133
133
|
);
|
|
134
134
|
process.exit(1);
|
|
135
135
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version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AA,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,2DAAA;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';\nimport type { VcConfig, VcConfigOverrides, VercelDeployerOptions } from './types';\n\nexport class VercelDeployer extends Deployer {\n private vcConfigOverrides: VcConfigOverrides = {};\n\n constructor(options: VercelDeployerOptions = {}) {\n super({ name: 'VERCEL' });\n this.outputDir = join('.vercel', 'output', 'functions', 'index.func');\n\n // Store all overrides centrally\n this.vcConfigOverrides = { ...options };\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n\n this.writeVercelJSON(join(outputDirectory, this.outputDir, '..', '..'));\n }\n\n private getEntry(): string {\n return `\nimport { handle } from 'hono/vercel'\nimport { mastra } from '#mastra';\nimport { createHonoServer, getToolExports } from '#server';\nimport { tools } from '#tools';\nimport { evaluate } from '@mastra/core/eval';\nimport { AvailableHooks, registerHook } from '@mastra/core/hooks';\nimport { TABLE_EVALS } from '@mastra/core/storage';\nimport { scoreTracesWorkflow } from '@mastra/core/scores/scoreTraces';\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\nif (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\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(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n const nodeVersion = process.version?.split('.')?.[0]?.replace('v', '') ?? '22';\n\n const vcConfig: VcConfig = {\n handler: 'index.mjs',\n launcherType: 'Nodejs',\n runtime: `nodejs${nodeVersion}.x`,\n shouldAddHelpers: true,\n };\n\n // Merge supported overrides\n const { maxDuration, memory, regions } = this.vcConfigOverrides;\n if (typeof maxDuration === 'number') vcConfig.maxDuration = maxDuration;\n if (typeof memory === 'number') vcConfig.memory = memory;\n if (Array.isArray(regions) && regions.length > 0) vcConfig.regions = regions;\n\n writeFileSync(join(outputDirectory, this.outputDir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));\n\n await move(join(outputDirectory, '.vercel', 'output'), join(process.cwd(), '.vercel', 'output'), {\n overwrite: true,\n });\n\n return result;\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.');\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger.error(\n `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency. \n\t\t\t\tUse other Mastra Storage options instead e.g @mastra/pg`,\n );\n process.exit(1);\n }\n }\n}\n"]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type VcConfig = {
|
|
2
|
+
handler: string;
|
|
3
|
+
launcherType: 'Nodejs';
|
|
4
|
+
runtime: string;
|
|
5
|
+
shouldAddHelpers: boolean;
|
|
6
|
+
maxDuration?: number;
|
|
7
|
+
memory?: number;
|
|
8
|
+
regions?: string[];
|
|
9
|
+
};
|
|
10
|
+
export type VcConfigOverrides = Pick<VcConfig, 'maxDuration' | 'memory' | 'regions'>;
|
|
11
|
+
export interface VercelDeployerOptions extends VcConfigOverrides {
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAC;AAErF,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
30
30
|
"fs-extra": "^11.3.2",
|
|
31
|
-
"@mastra/deployer": "^0.
|
|
31
|
+
"@mastra/deployer": "^0.20.0-alpha.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "^7.52.8",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"tsup": "^8.5.0",
|
|
39
39
|
"typescript": "^5.8.3",
|
|
40
40
|
"vitest": "^3.2.4",
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@internal/types-builder": "0.0.
|
|
41
|
+
"@internal/lint": "0.0.44",
|
|
42
|
+
"@mastra/core": "0.20.0-alpha.0",
|
|
43
|
+
"@internal/types-builder": "0.0.19"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://mastra.ai",
|
|
46
46
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@mastra/core": ">=0.18.1-0 <0.
|
|
55
|
+
"@mastra/core": ">=0.18.1-0 <0.21.0-0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsup --silent --config tsup.config.ts",
|