The Open Framework for Building Agents
fix(eve): vercel workflow packaging - preserve traced dependencies (#1279)
Andrew Barba4deab71dff8d
diff --git a/.changeset/portable-vercel-workflow-externals.md b/.changeset/portable-vercel-workflow-externals.mdnew file mode 100644index 000000000..0b92c56be--- /dev/null+++ b/.changeset/portable-vercel-workflow-externals.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Keep traced external dependencies resolvable from queue-triggered Vercel workflow functions, including dependency graphs that contain multiple versions of the same package.diff --git a/packages/eve/src/internal/nitro/host/build-application.scenario.test.ts b/packages/eve/src/internal/nitro/host/build-application.scenario.test.tsindex f981510ef..4445f30ea 100644--- a/packages/eve/src/internal/nitro/host/build-application.scenario.test.ts+++ b/packages/eve/src/internal/nitro/host/build-application.scenario.test.ts@@ -56,6 +56,31 @@ const buildNitroMock = vi.fn(async (nitro: Nitro) => {join(outputDir, "functions", "eve", "v1", "health.func"),"dir",);++ if (process.env.VERCEL) {+ const flowFunctionDirectory = join(+ outputDir,+ "functions",+ ".well-known",+ "workflow",+ "v1",+ "flow.func",+ );++ await mkdir(flowFunctionDirectory, { recursive: true });+ await writeFile(+ join(flowFunctionDirectory, ".vc-config.json"),+ `${JSON.stringify(+ {+ experimentalTriggers: [{ topic: "eve-test", type: "queue/v2beta" }],+ maxDuration: "max",+ runtime: "nodejs24.x",+ },+ null,+ 2,+ )}\n`,+ );+ }});const copyPublicAssetsMock = vi.fn(async () => undefined);const createProductionApplicationNitroMock = vi.fn();@@ -425,6 +450,19 @@ describe("buildApplication", () => {const sharedFunctionStats = await lstat(join(appRoot, ".vercel", "output", "functions", "eve", "__server.func"),);+ const flowFunctionDirectory = join(+ appRoot,+ ".vercel",+ "output",+ "functions",+ ".well-known",+ "workflow",+ "v1",+ "flow.func",+ );+ const flowFunctionConfig = JSON.parse(+ await readFile(join(flowFunctionDirectory, ".vc-config.json"), "utf8"),+ ) as Record<string, unknown>;const vercelConfig = JSON.parse(await readFile(join(appRoot, ".vercel", "output", "config.json"), "utf8"),) as {@@ -451,6 +489,14 @@ describe("buildApplication", () => {"utf8",),).resolves.toContain("export default");+ await expect(readFile(join(flowFunctionDirectory, "_runtime.mjs"), "utf8")).resolves.toContain(+ "export default",+ );+ expect(flowFunctionConfig).toMatchObject({+ experimentalTriggers: [{ topic: "eve-test", type: "queue/v2beta" }],+ maxDuration: "max",+ runtime: "nodejs24.x",+ });expect(vercelConfig.routes).toEqual([{ handle: "filesystem" },{ dest: "/eve/__server", src: "/eve/v1/health" },diff --git a/packages/eve/src/internal/nitro/host/build-application.ts b/packages/eve/src/internal/nitro/host/build-application.tsindex 0f9e4ac1c..acfe42cf1 100644--- a/packages/eve/src/internal/nitro/host/build-application.ts+++ b/packages/eve/src/internal/nitro/host/build-application.ts@@ -25,7 +25,10 @@ import {RecoverablePublicationError,} from "#internal/application/output-publication.js";import { stageProductionCompilerArtifacts } from "#internal/application/production-compiler-artifacts.js";-import { normalizeEveVercelFunctionOutput } from "#internal/workflow-bundle/vercel-workflow-output.js";+import {+ materializeVercelWorkflowFunctionOutput,+ normalizeEveVercelFunctionOutput,+} from "#internal/workflow-bundle/vercel-workflow-output.js";import { createProductionApplicationNitro } from "#internal/nitro/host/create-application-nitro.js";import { emitVercelAgentSummary } from "#internal/nitro/host/build-vercel-agent-summary.js";import { tryReadExtensionBuildConfig } from "#internal/nitro/host/build-extension.js";@@ -420,6 +423,11 @@ async function buildApplicationInWorkspace();}await buildNitroOutput(nitro, profiler, "nitro");+ if (isVercelBuild) {+ await measureBuildPhase(profiler, "vercel.workflow-function.materialize", () =>+ materializeVercelWorkflowFunctionOutput(workspace.publication.output.stagedDir),+ );+ }if (servicePrefix !== undefined) {await measureBuildPhase(profiler, "vercel.functions.normalize", () =>normalizeEveVercelFunctionOutput(workspace.publication.output.stagedDir, {diff --git a/packages/eve/src/internal/nitro/host/vercel-build-output-config.ts b/packages/eve/src/internal/nitro/host/vercel-build-output-config.tsindex a1204fabf..637ca3af8 100644--- a/packages/eve/src/internal/nitro/host/vercel-build-output-config.ts+++ b/packages/eve/src/internal/nitro/host/vercel-build-output-config.ts@@ -1,13 +1,13 @@import { resolveInstalledPackageInfo } from "#internal/application/package.js";import { EVE_PACKAGE_NAME } from "#internal/package-name.js";import { createEveWorkflowQueueTrigger } from "#internal/workflow/queue-namespace.js";+import { EVE_WORKFLOW_FLOW_ROUTE_PATH } from "#internal/workflow-bundle/eve-service-route-output.js";import {EVE_PUBLIC_ROUTE_PREFIX_ENV,normalizePublicRoutePrefix,} from "#shared/public-route-prefix.js";-/** Route Nitro's Vercel preset emits as the queue-triggered workflow function. */-export const EVE_WORKFLOW_FLOW_ROUTE_PATH = "/.well-known/workflow/v1/flow";+export { EVE_WORKFLOW_FLOW_ROUTE_PATH };/*** Builds eve's Vercel preset options.diff --git a/packages/eve/src/internal/workflow-bundle/eve-service-route-output.ts b/packages/eve/src/internal/workflow-bundle/eve-service-route-output.tsindex 9304245da..68da31d5e 100644--- a/packages/eve/src/internal/workflow-bundle/eve-service-route-output.ts+++ b/packages/eve/src/internal/workflow-bundle/eve-service-route-output.ts@@ -1,5 +1,8 @@export const EVE_SHARED_SERVER_FUNCTION_PATH = "eve/__server.func";+/** Route Nitro's Vercel preset emits as the queue-triggered workflow function. */+export const EVE_WORKFLOW_FLOW_ROUTE_PATH = "/.well-known/workflow/v1/flow";+const EVE_SHARED_SERVER_ROUTE_DESTINATION = "/eve/__server";const EVE_VERCEL_FUNCTION_PREFIXES = ["eve/", ".well-known/workflow/"] as const;diff --git a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.tsindex 5b76c4d71..fe796b9d3 100644--- a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts+++ b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts@@ -14,6 +14,7 @@ import { dirname, join, relative } from "node:path";import {EVE_SHARED_SERVER_FUNCTION_PATH,+ EVE_WORKFLOW_FLOW_ROUTE_PATH,isEveVercelFunctionPath,normalizeEveVercelRoutes,} from "#internal/workflow-bundle/eve-service-route-output.js";@@ -42,6 +43,38 @@ function isRecord(value: unknown): value is Record<string, unknown> {return value !== null && typeof value === "object" && !Array.isArray(value);}+/**+ * Recreates the queue-triggered flow function from Nitro's completed server+ * output while retaining its route-specific Vercel configuration.+ *+ * Nitro copies function-rule output without preserving relative symlink text,+ * which can turn traced `.nf3` package links into absolute paths inside eve's+ * disposable build workspace. Materializing after Nitro finishes keeps those+ * links relative so the published function remains self-contained.+ */+export async function materializeVercelWorkflowFunctionOutput(outputDir: string): Promise<void> {+ const functionsDir = join(outputDir, "functions");+ const rootServerFunctionPath = await realpath(join(functionsDir, "__server.func"));+ const flowFunctionPath = join(functionsDir, `${EVE_WORKFLOW_FLOW_ROUTE_PATH.slice(1)}.func`);+ const flowFunctionConfig = await readFile(join(flowFunctionPath, ".vc-config.json"));+ const stagingPath = `${flowFunctionPath}.eve-staging`;++ await rm(stagingPath, {+ force: true,+ recursive: true,+ });+ await cp(rootServerFunctionPath, stagingPath, {+ recursive: true,+ verbatimSymlinks: true,+ });+ await writeFile(join(stagingPath, ".vc-config.json"), flowFunctionConfig);+ await rm(flowFunctionPath, {+ force: true,+ recursive: true,+ });+ await rename(stagingPath, flowFunctionPath);+}+/*** Keeps only eve-owned Vercel function output and rewrites eve route function* symlinks to a shared eve-owned server function.diff --git a/packages/eve/test/scenarios/app-runtime-dependencies.scenario.test.ts b/packages/eve/test/scenarios/app-runtime-dependencies.scenario.test.tsindex 4a0c634cf..20be75bbe 100644--- a/packages/eve/test/scenarios/app-runtime-dependencies.scenario.test.ts+++ b/packages/eve/test/scenarios/app-runtime-dependencies.scenario.test.ts@@ -572,7 +572,7 @@ describe("app runtime dependency tracing", () => {["export default {"," build: {",- ' externalDependencies: ["fixture-external-only-dep"],',+ ' externalDependencies: ["fixture-external-only-dep", "fixture-external-wrapper"],'," },",' model: "openai/gpt-5.4-mini",',@@ -588,11 +588,12 @@ describe("app runtime dependency tracing", () => {join(appRoot, "agent", "tools", "use_fixture_dep.ts"),['import fixtureExternalOnlyDep from "fixture-external-only-dep";',+ 'import fixtureExternalWrapper from "fixture-external-wrapper";',"","export default {",' description: "Use the fixture external dependency.",'," execute() {",- " return fixtureExternalOnlyDep;",+ " return { fixtureExternalOnlyDep, fixtureExternalWrapper };"," },","};","",@@ -600,10 +601,16 @@ describe("app runtime dependency tracing", () => {);const packageRoot = join(appRoot, "node_modules", "fixture-external-only-dep");+ const wrapperRoot = join(appRoot, "node_modules", "fixture-external-wrapper");+ const nestedPackageRoot = join(wrapperRoot, "node_modules", "fixture-external-only-dep");- await mkdir(packageRoot, {- recursive: true,- });+ await Promise.all(+ [packageRoot, wrapperRoot, nestedPackageRoot].map((directoryPath) =>+ mkdir(directoryPath, {+ recursive: true,+ }),+ ),+ );await writeFile(join(packageRoot, "package.json"),JSON.stringify(@@ -629,6 +636,58 @@ describe("app runtime dependency tracing", () => {"",].join("\n"),);+ await writeFile(+ join(wrapperRoot, "package.json"),+ JSON.stringify(+ {+ dependencies: {+ "fixture-external-only-dep": "2.0.0",+ },+ exports: {+ ".": "./index.js",+ },+ name: "fixture-external-wrapper",+ type: "module",+ version: "1.0.0",+ },+ null,+ 2,+ ),+ );+ await writeFile(+ join(wrapperRoot, "index.js"),+ [+ 'import fixtureExternalOnlyDep from "fixture-external-only-dep";',+ "",+ "export default fixtureExternalOnlyDep;",+ "",+ ].join("\n"),+ );+ await writeFile(+ join(nestedPackageRoot, "package.json"),+ JSON.stringify(+ {+ exports: {+ ".": "./index.js",+ },+ name: "fixture-external-only-dep",+ type: "module",+ version: "2.0.0",+ },+ null,+ 2,+ ),+ );+ await writeFile(+ join(nestedPackageRoot, "index.js"),+ [+ 'export const label = "fixture-external-only-dep-v2";',+ "export default {",+ " label,",+ "};",+ "",+ ].join("\n"),+ );const outputDir = await buildApplication(appRoot, DEPLOYABLE_BUILD_OPTIONS);const serverModuleDirectory = join(outputDir, "server");@@ -651,6 +710,29 @@ describe("app runtime dependency tracing", () => {).resolves.toContain('"name": "fixture-external-only-dep"');expect(serverModuleSource).toContain('"fixture-external-only-dep"');expect(serverModuleSource).not.toContain('export const label = "fixture-external-only-dep";');++ vi.stubEnv("VERCEL", "1");+ vi.stubEnv("VERCEL_DEPLOYMENT_ID", "");++ const vercelOutputDir = await buildApplication(appRoot, DEPLOYABLE_BUILD_OPTIONS);+ const rootServerFunctionDirectory = join(vercelOutputDir, "functions", "__server.func");+ const workflowFlowFunctionDirectory = join(+ vercelOutputDir,+ "functions",+ ".well-known",+ "workflow",+ "v1",+ "flow.func",+ );++ for (const functionDirectory of [rootServerFunctionDirectory, workflowFlowFunctionDirectory]) {+ await expect(+ readFile(+ join(functionDirectory, "node_modules", "fixture-external-only-dep", "package.json"),+ "utf8",+ ),+ ).resolves.toContain('"name": "fixture-external-only-dep"');+ }}, 30_000);it("rewrites framework tool executors into hosted Vercel output", async () => {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ae30861c3..ccd28989d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -12960,8 +12960,8 @@ packages:sass:optional: true- resolution: {integrity: sha512-N9zEWySuJFw+gR0lhS5863YsvNeudOdqRyFvNb+jMXbeTJOdrjDqkCpDginIZfUm0LzT1t1nCRiDeqQm/8kirQ==}+ resolution: {integrity: sha512-RWVLAWozmVD3AaDmaU3qMGB3v+yNlH5d9qqStI4e/WLlNQVnJ4YErGDbYCIrGFyrHdbF6I6Baf0Ae6c7tFYmSg==}resolution: {integrity: sha512-MEhnD3JMah0mgyivpb9hpRDbOBuXBxI/TVO+OK1h6rC97WM42HsPMR+zzRNQ0C5BqYJTw1nyWiQRD0DucO+pjQ==}@@ -29353,7 +29353,7 @@ snapshots:- '@babel/core'- babel-plugin-macros- [email protected]: {}+ [email protected]: {}dependencies:@@ -29373,7 +29373,7 @@ snapshots:env-runner: 0.1.16h3: 2.0.1-rc.22([email protected]([email protected]))hookable: 6.1.1- nf3: 0.3.17+ nf3: 0.3.23ocache: 0.1.5ofetch: 2.0.0-alpha.3ohash: 2.0.11diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex b45671588..919fa997b 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -83,6 +83,7 @@ minimumReleaseAgeExclude:- crossws- experimental-ai-sdk-code-mode- eve+ - nf3- nitro- rolldown# This release contains the reviewed package-config registry APIs used by the eve CLI.