The Open Framework for Building Agents
perf(eve): build a single Nitro app on Vercel (#1229)
Rihan Arfan3c5330646897
diff --git a/.changeset/single-vercel-nitro-build.md b/.changeset/single-vercel-nitro-build.mdnew file mode 100644index 000000000..9f8b0e91c--- /dev/null+++ b/.changeset/single-vercel-nitro-build.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Vercel builds now run a single Nitro build. The workflow flow function is emitted through Nitro's per-route `functionRules` (queue trigger, `maxDuration: "max"`, precondition guard) instead of a second standalone Nitro build that was copied and retargeted into the output, making `eve build` on Vercel roughly twice as fast.diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdxindex 73e18ef12..9d14879a2 100644--- a/docs/channels/slack.mdx+++ b/docs/channels/slack.mdx@@ -40,7 +40,6 @@ export default slackChannel({If eve cannot find an authenticated Vercel session, `eve channels add slack` asks whether to set up Vercel Connect or use portable environment credentials. The portable option adds the required names to `.env.example`. Before deploying, appropriate values must be supplied to your runtime environment.-### DeployDeploy once the trigger destination and channel file are ready:diff --git a/packages/eve/src/internal/application/build-workspace.ts b/packages/eve/src/internal/application/build-workspace.tsindex 4283356cf..0fb60ac1e 100644--- a/packages/eve/src/internal/application/build-workspace.ts+++ b/packages/eve/src/internal/application/build-workspace.ts@@ -16,7 +16,6 @@ export interface ApplicationBuildWorkspace {};readonly nitro: {readonly buildDir: string;- readonly surfaceOutputDir: string;};readonly publication: {readonly output: {@@ -59,7 +58,6 @@ export async function createApplicationBuildWorkspace(},nitro: {buildDir: join(rootDir, "nitro"),- surfaceOutputDir: join(rootDir, "nitro-output"),},publication: {output: {diff --git a/packages/eve/src/internal/application/paths.ts b/packages/eve/src/internal/application/paths.tsindex faf94058c..1fe87b050 100644--- a/packages/eve/src/internal/application/paths.ts+++ b/packages/eve/src/internal/application/paths.ts@@ -3,7 +3,6 @@ import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";import { join, resolve } from "node:path";import { workflowEntryReference } from "#execution/workflow-runtime.js";-import type { NitroBuildSurface } from "#internal/nitro/host/types.js";import {resolveInstalledPackageInfo,resolvePackageRoot,@@ -45,33 +44,14 @@ export function isVercelBuildEnvironment(): boolean {/*** Resolves the programmatic Nitro build directory for an app.*/-export function resolveNitroBuildDirectory(- appRoot: string,- surface: NitroBuildSurface = "all",-): string {- const rootDirectory = join(appRoot, ".eve", "nitro");-- if (surface === "all") {- return rootDirectory;- }-- return join(rootDirectory, surface);+export function resolveNitroBuildDirectory(appRoot: string): string {+ return join(appRoot, ".eve", "nitro");}export function resolveApplicationHostArtifactsDirectory(appRoot: string): string {return join(appRoot, ".eve", "host");}-/**- * Resolves the staged Nitro output directory for one isolated build surface.- */-export function resolveNitroSurfaceOutputDirectory(- appRoot: string,- surface: Exclude<NitroBuildSurface, "all">,-): string {- return join(appRoot, ".eve", "nitro-output", surface);-}-/*** Resolves the package-owned Workflow DevKit bundle directory for a target app.*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 124e5d2eb..f981510ef 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@@ -68,8 +68,6 @@ const resolveDiscoveryProjectMock = vi.fn(async (appRoot: string) => ({layout: "nested" as const,}));const runVercelBuildPrewarmMock = vi.fn(async () => undefined);-const workflowBuilderBuildVercelOutputMock = vi.fn(async (_options: unknown) => undefined);-const workflowBuilderConstructors: unknown[] = [];vi.mock("nitro/builder", () => ({build: buildNitroMock,@@ -94,18 +92,6 @@ vi.mock("./vercel-build-prewarm.js", () => ({runVercelBuildPrewarm: runVercelBuildPrewarmMock,}));-vi.mock("../../workflow-bundle/builder.js", () => ({- WorkflowBundleBuilder: class WorkflowBundleBuilder {- constructor(options: unknown) {- workflowBuilderConstructors.push(options);- }-- async buildVercelOutput(options: unknown): Promise<void> {- await workflowBuilderBuildVercelOutputMock(options);- }- },-}));-const createScratchDirectory = useTemporaryDirectories();const DEPLOYABLE_BUILD_OPTIONS = { skipVercelSandboxPrewarm: false } as const;@@ -177,7 +163,6 @@ describe("buildApplication", () => {beforeEach(() => {vi.resetModules();vi.clearAllMocks();- workflowBuilderConstructors.length = 0;});afterEach(() => {@@ -223,7 +208,6 @@ describe("buildApplication", () => {2,)}\n`,);- expect(workflowBuilderBuildVercelOutputMock).not.toHaveBeenCalled();expect(runVercelBuildPrewarmMock).not.toHaveBeenCalled();await expect(readFile(join(appRoot, ".eve", "compile", "compiled-agent-manifest.json"), "utf8"),@@ -265,7 +249,7 @@ describe("buildApplication", () => {expect(profile.phases).toEqual(expect.arrayContaining([expect.objectContaining({ name: "host.prepare" }),- expect.objectContaining({ name: "nitro.all.bundle" }),+ expect.objectContaining({ name: "nitro.bundle" }),expect.objectContaining({ name: "output.publish" }),expect.objectContaining({ name: "workspace.remove" }),]),@@ -384,27 +368,17 @@ describe("buildApplication", () => {await expect(readFile(summaryPath, "utf8")).resolves.toBe("last-good-summary\n");});- it("builds isolated Vercel Nitro surfaces and stitches workflow functions", async () => {+ it("builds one Vercel Nitro output and normalizes eve functions", async () => {vi.stubEnv("VERCEL", "1");const appRoot = await createScratchDirectory("eve-build-application-vercel-");const profilePath = join(appRoot, ".eve", "profiles", "vercel-build.json");- const stableFlowOutputDir = join(appRoot, ".eve", "nitro-output", "flow");- const staleFlowOutputPath = join(stableFlowOutputDir, "stale-flow.txt");prepareProductionApplicationHostMock.mockImplementationOnce(prepareHostBuildWorkspace);createProductionApplicationNitroMock.mockImplementation(async (_preparedHost: PreparedApplicationHost, options: { outputDir: string }) =>createNitroStub(options.outputDir),);- await mkdir(stableFlowOutputDir, { recursive: true });- await Promise.all([- writeFile(- join(stableFlowOutputDir, "eve-cache.json"),- `${JSON.stringify({ eveVersion: "old" })}\n`,- ),- writeFile(staleFlowOutputPath, "stale\n"),- mkdir(join(appRoot, ".vercel", "output"), { recursive: true }),- ]);+ await mkdir(join(appRoot, ".vercel", "output"), { recursive: true });await writeFile(join(appRoot, ".vercel", "output", "config.json"),`${JSON.stringify(@@ -437,20 +411,14 @@ describe("buildApplication", () => {});expect(outputDir).toBe(join(appRoot, ".vercel", "output"));- expect(createProductionApplicationNitroMock).toHaveBeenCalledTimes(2);- expect(createProductionApplicationNitroMock.mock.calls.map((call) => call[1]?.surface)).toEqual(- ["app", "flow"],- );- const flowOutputDir = createProductionApplicationNitroMock.mock.calls.find(- (call) => call[1]?.surface === "flow",- )?.[1]?.outputDir;- expect(flowOutputDir).toEqual(expect.stringContaining(join(appRoot, ".eve", "builds")));- expect(workflowBuilderConstructors).toHaveLength(1);- expect(workflowBuilderBuildVercelOutputMock).toHaveBeenCalledWith({- flowNitroOutputDir: flowOutputDir,- outputDir: expect.stringContaining(join(appRoot, ".eve", "builds")),- runtime: "nodejs24.x",- });+ expect(createProductionApplicationNitroMock).toHaveBeenCalledTimes(1);+ expect(createProductionApplicationNitroMock).toHaveBeenCalledWith(+ expect.objectContaining({ appRoot }),+ {+ buildDir: expect.stringContaining(join(appRoot, ".eve", "builds")),+ outputDir: expect.stringContaining(join(appRoot, ".eve", "builds")),+ },+ );const nestedFunctionStats = await lstat(join(appRoot, ".vercel", "output", "functions", "eve", "v1", "health.func"),);@@ -491,7 +459,6 @@ describe("buildApplication", () => {src: "^/eve/v1/session/(?<sessionId>[^/]+)/stream$",},]);- await expect(readFile(staleFlowOutputPath, "utf8")).resolves.toBe("stale\n");expect(runVercelBuildPrewarmMock).toHaveBeenCalledWith(expect.objectContaining({appRoot,@@ -533,20 +500,18 @@ describe("buildApplication", () => {expect(outputDir).toBe(join(appRoot, ".vercel", "output"));expect(runVercelBuildPrewarmMock).not.toHaveBeenCalled();- expect(workflowBuilderBuildVercelOutputMock).toHaveBeenCalledTimes(1);+ expect(buildNitroMock).toHaveBeenCalledTimes(1);});it("normalizes eve function output behind a non-Next host service", async () => {vi.stubEnv("VERCEL", "1");const appRoot = await createScratchDirectory("eve-build-application-vercel-nuxt-");- const flowOutputDir = join(appRoot, ".eve", "nitro-output", "flow");prepareProductionApplicationHostMock.mockImplementationOnce(prepareHostBuildWorkspace);createProductionApplicationNitroMock.mockImplementation(async (_preparedHost: PreparedApplicationHost, options: { outputDir: string }) =>createNitroStub(options.outputDir),);- await mkdir(flowOutputDir, { recursive: true });await writeFile(join(appRoot, "vercel.json"),`${JSON.stringify(@@ -705,40 +670,36 @@ describe("buildApplication", () => {});});- it("builds isolated Vercel Nitro surfaces from legacy root service config", async () => {+ it("normalizes eve function output from legacy root service config", async () => {vi.stubEnv("VERCEL", "1");const appRoot = await createScratchDirectory("eve-build-application-vercel-root-config-");- const flowOutputDir = join(appRoot, ".eve", "nitro-output", "flow");prepareProductionApplicationHostMock.mockImplementationOnce(prepareHostBuildWorkspace);createProductionApplicationNitroMock.mockImplementation(async (_preparedHost: PreparedApplicationHost, options: { outputDir: string }) =>createNitroStub(options.outputDir),);- await Promise.all([- mkdir(flowOutputDir, { recursive: true }),- writeFile(- join(appRoot, "vercel.json"),- `${JSON.stringify(- {- experimentalServices: {- eve: {- entrypoint: ".",- framework: "eve",- routePrefix: "/_eve_internal/eve",- },- web: {- entrypoint: ".",- framework: "nextjs",- routePrefix: "/",- },+ await writeFile(+ join(appRoot, "vercel.json"),+ `${JSON.stringify(+ {+ experimentalServices: {+ eve: {+ entrypoint: ".",+ framework: "eve",+ routePrefix: "/_eve_internal/eve",+ },+ web: {+ entrypoint: ".",+ framework: "nextjs",+ routePrefix: "/",},},- null,- 2,- )}\n`,- ),- ]);+ },+ null,+ 2,+ )}\n`,+ );const { buildApplication } = await import("#internal/nitro/host/build-application.js");const outputDir = await buildApplication(appRoot, DEPLOYABLE_BUILD_OPTIONS);diff --git a/packages/eve/src/internal/nitro/host/build-application.ts b/packages/eve/src/internal/nitro/host/build-application.tsindex d5f77e2ac..0f9e4ac1c 100644--- a/packages/eve/src/internal/nitro/host/build-application.ts+++ b/packages/eve/src/internal/nitro/host/build-application.ts@@ -4,7 +4,7 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";import { build as buildNitro, copyPublicAssets, prepare, prerender } from "nitro/builder";import type { Nitro } from "nitro/types";-import { resolvePackageRoot, resolvePackageSourceFilePath } from "#internal/application/package.js";+import { resolvePackageSourceFilePath } from "#internal/application/package.js";import {prepareEveVersionedCacheDirectory,writeEveVersionedCacheMetadata,@@ -25,7 +25,6 @@ import {RecoverablePublicationError,} from "#internal/application/output-publication.js";import { stageProductionCompilerArtifacts } from "#internal/application/production-compiler-artifacts.js";-import { WorkflowBundleBuilder } from "#internal/workflow-bundle/builder.js";import { 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";@@ -33,11 +32,7 @@ import { tryReadExtensionBuildConfig } from "#internal/nitro/host/build-extensioimport { copyHostMiddlewareFunctions } from "#internal/nitro/host/copy-host-middleware.js";import { prepareProductionApplicationHost } from "#internal/nitro/host/prepare-application-host.js";import { runVercelBuildPrewarm } from "#internal/nitro/host/vercel-build-prewarm.js";-import type {- ApplicationBuildOptions,- NitroBuildSurface,- PreparedApplicationHost,-} from "#internal/nitro/host/types.js";+import type { ApplicationBuildOptions } from "#internal/nitro/host/types.js";import { findClosestVercelOutputDirectory } from "#shared/vercel-output-directory.js";import { toErrorMessage } from "#shared/errors.js";import { resolveDiscoveryProject } from "#discover/project.js";@@ -269,20 +264,6 @@ async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(}}-async function readVercelServerRuntime(outputDir: string): Promise<string | undefined> {- try {- const config = JSON.parse(- await readFile(join(outputDir, "functions", "__server.func", ".vc-config.json"), "utf8"),- ) as {- runtime?: string;- };-- return config.runtime;- } catch {- return undefined;- }-}-async function resolveVercelOutputConfigRoot(outputDirectory: string): Promise<string> {const projectRoot = dirname(dirname(outputDirectory));@@ -308,33 +289,6 @@ async function resolveVercelOutputConfigRoot(outputDirectory: string): Promise<sreturn projectRoot;}-async function emitVercelWorkflowFunctions(input: {- agentName: string;- appRoot: string;- compiledArtifactsBootstrapPath: string;- flowNitroOutputDir: string;- outputDir: string;- publicRoutePrefix: string | undefined;- workflowBuildDir: string;-}): Promise<void> {- const builder = new WorkflowBundleBuilder({- agentName: input.agentName,- appRoot: input.appRoot,- compiledArtifactsBootstrapPath: input.compiledArtifactsBootstrapPath,- outDir: input.workflowBuildDir,- publicRoutePrefix: input.publicRoutePrefix,- rootDir: resolvePackageRoot(),- watch: false,- });- const runtime = await readVercelServerRuntime(input.outputDir);-- await builder.buildVercelOutput({- flowNitroOutputDir: input.flowNitroOutputDir,- outputDir: input.outputDir,- runtime,- });-}-async function buildNitroOutput(nitro: Nitro,profiler: ApplicationBuildProfiler | undefined,@@ -356,28 +310,6 @@ async function buildNitroOutput(return outputDirectory;}-async function buildVercelNitroSurface(- preparedHost: PreparedApplicationHost,- workspace: ApplicationBuildWorkspace,- surface: Exclude<NitroBuildSurface, "all">,- profiler: ApplicationBuildProfiler | undefined,-): Promise<string> {- const phasePrefix = `nitro.${surface}`;- const nitro = await measureBuildPhase(profiler, `${phasePrefix}.create`, () =>- createProductionApplicationNitro(preparedHost, {- buildDir: join(workspace.nitro.buildDir, surface),- outputDir: join(workspace.nitro.surfaceOutputDir, surface),- surface,- }),- );-- try {- return await buildNitroOutput(nitro, profiler, phasePrefix);- } finally {- await measureBuildPhase(profiler, `${phasePrefix}.close`, () => nitro.close());- }-}-/*** Builds the production Nitro output for an eve application.*/@@ -447,60 +379,28 @@ async function buildApplicationInWorkspace(const preparedHost = await measureBuildPhase(profiler, "host.prepare", () =>prepareProductionApplicationHost(workspace),);-- if (!process.env.VERCEL) {- const nitro = await measureBuildPhase(profiler, "nitro.all.create", () =>- createProductionApplicationNitro(preparedHost, {- buildDir: workspace.nitro.buildDir,- outputDir: workspace.publication.output.stagedDir,- surface: "all",- }),- );-- try {- await buildNitroOutput(nitro, profiler, "nitro.all");- await measureBuildPhase(profiler, "agent-summary.emit", () =>- emitVercelAgentSummary({- manifest: preparedHost.compileResult.manifest,- outputPath: workspace.publication.summary.stagedPath,- }),- );- await measureBuildPhase(profiler, "compiler-artifacts.stage", () =>- stageProductionCompilerArtifacts({- compilerArtifactsRoot: workspace.compiler.artifactsDir,- outputDir: workspace.publication.output.stagedDir,- }),- );- } finally {- await measureBuildPhase(profiler, "nitro.all.close", () => nitro.close());- }-- await measureBuildPhase(profiler, "output.publish", () =>- publishCompletedApplicationBuild(workspace),- );- return workspace.publication.output.finalDir;- }-- const servicePrefix = await measureBuildPhase(profiler, "vercel.service-prefix.resolve", () =>- resolveCoDeployedEveServicePrefixForVercelFunctionOutput(- preparedHost.appRoot,- preparedHost.compileResult.project.agentRoot,- ),- );- const nitro = await measureBuildPhase(profiler, "nitro.app.create", () =>+ const isVercelBuild = Boolean(process.env.VERCEL);++ const servicePrefix = isVercelBuild+ ? await measureBuildPhase(profiler, "vercel.service-prefix.resolve", () =>+ resolveCoDeployedEveServicePrefixForVercelFunctionOutput(+ preparedHost.appRoot,+ preparedHost.compileResult.project.agentRoot,+ ),+ )+ : undefined;+ const nitro = await measureBuildPhase(profiler, "nitro.create", () =>createProductionApplicationNitro(preparedHost, {- buildDir: join(workspace.nitro.buildDir, "app"),+ buildDir: workspace.nitro.buildDir,outputDir: workspace.publication.output.stagedDir,- surface: "app",+ publicRoutePrefix: options.publicRoutePrefix,}),);try {- await buildNitroOutput(nitro, profiler, "nitro.app");- // Run sandbox prewarm before emitting the workflow functions so a- // prewarm failure aborts the build before we spend time bundling- // function output that we would never deploy.- if (!options.skipVercelSandboxPrewarm) {+ // Run sandbox prewarm before bundling so a prewarm failure aborts the+ // build before we spend time producing output we would never deploy.+ if (isVercelBuild && !options.skipVercelSandboxPrewarm) {await measureBuildPhase(profiler, "sandbox.prewarm", () =>runVercelBuildPrewarm({appRoot: preparedHost.appRoot,@@ -519,23 +419,7 @@ async function buildApplicationInWorkspace(}),);}- const flowNitroOutputDir = await buildVercelNitroSurface(- preparedHost,- workspace,- "flow",- profiler,- );- await measureBuildPhase(profiler, "workflow.emit", () =>- emitVercelWorkflowFunctions({- agentName: preparedHost.compileResult.manifest.config.name,- appRoot: preparedHost.appRoot,- compiledArtifactsBootstrapPath: preparedHost.compiledArtifacts.bootstrapPath,- flowNitroOutputDir,- outputDir: workspace.publication.output.stagedDir,- publicRoutePrefix: options.publicRoutePrefix,- workflowBuildDir: workspace.workflow.buildDir,- }),- );+ await buildNitroOutput(nitro, profiler, "nitro");if (servicePrefix !== undefined) {await measureBuildPhase(profiler, "vercel.functions.normalize", () =>normalizeEveVercelFunctionOutput(workspace.publication.output.stagedDir, {@@ -558,8 +442,16 @@ async function buildApplicationInWorkspace(outputPath: workspace.publication.summary.stagedPath,}),);+ if (!isVercelBuild) {+ await measureBuildPhase(profiler, "compiler-artifacts.stage", () =>+ stageProductionCompilerArtifacts({+ compilerArtifactsRoot: workspace.compiler.artifactsDir,+ outputDir: workspace.publication.output.stagedDir,+ }),+ );+ }} finally {- await measureBuildPhase(profiler, "nitro.app.close", () => nitro.close());+ await measureBuildPhase(profiler, "nitro.close", () => nitro.close());}await measureBuildPhase(profiler, "output.publish", () =>diff --git a/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts b/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.tsindex 0f0526259..49b28b4f4 100644--- a/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts+++ b/packages/eve/src/internal/nitro/host/configure-nitro-routes.test.ts@@ -171,7 +171,7 @@ describe("Nitro route configuration", () => {it("registers package-owned route files through file-url virtual handlers", async () => {const nitro = createNitroStub();- await configureProductionNitroRoutes(nitro, createPreparedHost(), "app");+ await configureProductionNitroRoutes(nitro, createPreparedHost());const healthHandler = nitro.options.handlers.find((handler) => handler.route === EVE_HEALTH_ROUTE_PATH && handler.method === "GET",@@ -188,11 +188,7 @@ describe("Nitro route configuration", () => {it("bakes the agent name into the home page route", async () => {const nitro = createNitroStub();- await configureProductionNitroRoutes(- nitro,- createPreparedHost({ agentName: "support-agent" }),- "app",- );+ await configureProductionNitroRoutes(nitro, createPreparedHost({ agentName: "support-agent" }));const homeHandler = nitro.options.handlers.find((handler) => handler.route === "/" && handler.method === "GET",@@ -207,7 +203,7 @@ describe("Nitro route configuration", () => {it("registers the health route for HEAD so load balancers probing with HEAD see 200", async () => {const nitro = createNitroStub();- await configureProductionNitroRoutes(nitro, createPreparedHost(), "app");+ await configureProductionNitroRoutes(nitro, createPreparedHost());const healthMethods = nitro.options.handlers.filter((handler) => handler.route === EVE_HEALTH_ROUTE_PATH)@@ -317,7 +313,7 @@ describe("Nitro route configuration", () => {const prodNitro = createNitroStub({ dev: false });await configureDevelopmentNitroRoutes(devNitro, createPreparedHost());- await configureProductionNitroRoutes(prodNitro, createPreparedHost(), "app");+ await configureProductionNitroRoutes(prodNitro, createPreparedHost());expect(devNitro.options.handlers).toContainEqual({handler: "#eve-route/eve/v1/dev/runtime-artifacts",@@ -341,7 +337,7 @@ describe("Nitro route configuration", () => {const prodNitro = createNitroStub({ dev: false });await configureDevelopmentNitroRoutes(devNitro, createPreparedHost());- await configureProductionNitroRoutes(prodNitro, createPreparedHost(), "app");+ await configureProductionNitroRoutes(prodNitro, createPreparedHost());expect(devNitro.options.handlers).toContainEqual({handler: `#nitro/virtual/eve-channel/GET ${EVE_INFO_ROUTE_PATH}`,@@ -384,7 +380,6 @@ describe("Nitro route configuration", () => {workflowBuildDir,workflowWorld: "@workflow/world-postgres",}),- "all",);const workflowHandlerSource = readWriteFileSourceMatching("/workflow/workflows-handler.mjs");@@ -410,7 +405,6 @@ describe("Nitro route configuration", () => {workflowBuildDir,workflowWorld: "@workflow/world-postgres",}),- "all",);const workflowHandlerSource = readWriteFileSourceMatching("/workflow/workflows-handler.mjs");@@ -436,7 +430,6 @@ describe("Nitro route configuration", () => {await configureProductionNitroRoutes(nitro,createPreparedHost({ appRoot: root, workflowBuildDir }),- "all",);const workflowHandlerSource = readWriteFileSourceMatching("/workflow/workflows-handler.mjs");diff --git a/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts b/packages/eve/src/internal/nitro/host/configure-nitro-routes.tsindex d4f5123df..fd9487c00 100644--- a/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts+++ b/packages/eve/src/internal/nitro/host/configure-nitro-routes.ts@@ -32,19 +32,8 @@ import {computeChannelRouteRegistrations,registerChannelVirtualHandlers,} from "#internal/nitro/host/channel-routes.js";-import type { NitroBuildSurface, PreparedApplicationHost } from "#internal/nitro/host/types.js";--function includesApplicationRoutes(surface: NitroBuildSurface): boolean {- return surface === "all" || surface === "app";-}--function includesWorkflowBundles(surface: NitroBuildSurface): boolean {- return includesWorkflowRoute(surface);-}--function includesWorkflowRoute(surface: NitroBuildSurface): boolean {- return surface === "all" || surface === "flow";-}+import type { PreparedApplicationHost } from "#internal/nitro/host/types.js";+import { EVE_WORKFLOW_FLOW_ROUTE_PATH } from "#internal/nitro/host/vercel-build-output-config.js";function registerHandler(nitro: Nitro,@@ -362,7 +351,7 @@ async function registerWorkflowRoute(bundleName: "workflows",bundlePath: workflowBundlePath,directHandlers,- route: "/.well-known/workflow/v1/flow",+ route: EVE_WORKFLOW_FLOW_ROUTE_PATH,runtimeImportSpecifier,workflowWorldPluginPath: preparedHost.compiledArtifacts.workflowWorldPluginPath,});@@ -415,45 +404,38 @@ export async function configureDevelopmentNitroRoutes(}/**- * Wires the subset of eve's package-owned endpoints that belong to the given- * build surface into a production Nitro host.+ * Wires eve's package-owned app, channel, and Workflow SDK endpoints into the+ * production Nitro host.*/export async function configureProductionNitroRoutes(nitro: Nitro,preparedHost: PreparedApplicationHost,- surface: NitroBuildSurface,): Promise<void> {- if (includesWorkflowBundles(surface)) {- const builder = new WorkflowBundleBuilder({- agentName: preparedHost.compileResult.manifest.config.name,- appRoot: preparedHost.appRoot,- compiledArtifactsBootstrapPath: preparedHost.compiledArtifacts.bootstrapPath,- outDir: preparedHost.workflowBuildDir,- rootDir: resolvePackageRoot(),- watch: false,+ const builder = new WorkflowBundleBuilder({+ agentName: preparedHost.compileResult.manifest.config.name,+ appRoot: preparedHost.appRoot,+ compiledArtifactsBootstrapPath: preparedHost.compiledArtifacts.bootstrapPath,+ outDir: preparedHost.workflowBuildDir,+ rootDir: resolvePackageRoot(),+ watch: false,+ });+ const syncWorkflowArtifacts = async () => {+ await builder.build({+ nitroStepOutfile: join(resolveNitroWorkflowBuildDirectory(nitro), "steps.mjs"),});- const syncWorkflowArtifacts = async () => {- await builder.build({- nitroStepOutfile: join(resolveNitroWorkflowBuildDirectory(nitro), "steps.mjs"),- });- };- await registerWorkflowArtifactBuildHook(nitro, syncWorkflowArtifacts);- }+ };+ await registerWorkflowArtifactBuildHook(nitro, syncWorkflowArtifacts);- if (includesApplicationRoutes(surface)) {- registerApplicationRoutes(nitro, preparedHost, createProductionNitroArtifactsConfig());- }+ registerApplicationRoutes(nitro, preparedHost, createProductionNitroArtifactsConfig());- if (includesWorkflowRoute(surface)) {- const workflowBundlePath = join(preparedHost.workflowBuildDir, "workflows.mjs");- const hasConfiguredWorkflowWorld =- preparedHost.compileResult.manifest.config.experimental?.workflow?.world !== undefined;- const directHandlers =- !isVercelBuildEnvironment() && hasConfiguredWorkflowWorld- ? [createWorkflowDirectHandlerEntry(preparedHost, workflowBundlePath)]- : [];- await registerWorkflowRoute(nitro, preparedHost, workflowBundlePath, directHandlers);- }+ const workflowBundlePath = join(preparedHost.workflowBuildDir, "workflows.mjs");+ const hasConfiguredWorkflowWorld =+ preparedHost.compileResult.manifest.config.experimental?.workflow?.world !== undefined;+ const directHandlers =+ !isVercelBuildEnvironment() && hasConfiguredWorkflowWorld+ ? [createWorkflowDirectHandlerEntry(preparedHost, workflowBundlePath)]+ : [];+ await registerWorkflowRoute(nitro, preparedHost, workflowBundlePath, directHandlers);nitro.routing.sync();}diff --git a/packages/eve/src/internal/nitro/host/create-application-nitro.scenario.test.ts b/packages/eve/src/internal/nitro/host/create-application-nitro.scenario.test.tsindex 3e16e0cab..0aaaec38d 100644--- a/packages/eve/src/internal/nitro/host/create-application-nitro.scenario.test.ts+++ b/packages/eve/src/internal/nitro/host/create-application-nitro.scenario.test.ts@@ -24,10 +24,13 @@ import {} from "#internal/application/package.js";import { resolveNitroBuildDirectory } from "#internal/application/paths.js";import type {- NitroBuildSurface,PreparedApplicationHost,PreparedDevelopmentApplicationHost,} from "#internal/nitro/host/types.js";+import {+ createEveVercelOptions,+ EVE_WORKFLOW_FLOW_ROUTE_PATH,+} from "#internal/nitro/host/vercel-build-output-config.js";import { applyWorkflowTransform } from "#internal/workflow-bundle/workflow-builders.js";const configureDevelopmentNitroRoutes = vi.fn(async () => undefined);@@ -128,7 +131,7 @@ function createPreparedHost(): PreparedDevelopmentApplicationHost {diagnostics: [],manifest: {channels: [],- config: {},+ config: { name: "weather-agent" },sandbox: null,subagents: [],},@@ -166,14 +169,10 @@ function createPreparedHost(): PreparedDevelopmentApplicationHost {};}-function createProductionOptions(- preparedHost: PreparedApplicationHost,- surface: NitroBuildSurface,-) {+function createProductionOptions(preparedHost: PreparedApplicationHost) {return {- buildDir: resolveNitroBuildDirectory(preparedHost.appRoot, surface),+ buildDir: resolveNitroBuildDirectory(preparedHost.appRoot),outputDir: join(preparedHost.appRoot, ".output"),- surface,};}@@ -210,10 +209,7 @@ describe("application Nitro creation", () => {const { createProductionApplicationNitro } =await import("#internal/nitro/host/create-application-nitro.js");const preparedHost = createPreparedHost();- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));const rollupBeforeHooks = nitroStub.hookHandlers.get("rollup:before") ?? [];const originalTransform = vi.fn((code: string, id: string) => `${code}:${id}:transformed`);@@ -340,7 +336,7 @@ describe("application Nitro creation", () => {});});- it("sets the eve framework version on Vercel app-surface build output config", async () => {+ it("sets the eve framework version and flow function rules on Vercel build output config", async () => {vi.stubEnv("VERCEL", "1");const nitroStub = createNitroStub();createNitroMock.mockResolvedValueOnce(nitroStub.nitro);@@ -348,25 +344,27 @@ describe("application Nitro creation", () => {const { createProductionApplicationNitro } =await import("#internal/nitro/host/create-application-nitro.js");const preparedHost = createPreparedHost();- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "app"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));expect(createNitroMock).toHaveBeenCalledWith(expect.objectContaining({preset: "vercel",- vercel: {- config: {- version: 3,- framework: {- slug: "eve",- version: resolveInstalledPackageInfo().version,- },- },- },+ vercel: createEveVercelOptions({ agentName: "weather-agent", enabled: true }),}),);++ const vercelOptions = createNitroMock.mock.calls[0]?.[0].vercel;+ expect(vercelOptions?.config).toEqual({+ version: 3,+ framework: {+ slug: "eve",+ version: resolveInstalledPackageInfo().version,+ },+ });+ expect(vercelOptions?.functionRules[EVE_WORKFLOW_FLOW_ROUTE_PATH]).toMatchObject({+ maxDuration: "max",+ experimentalTriggers: [expect.objectContaining({ type: "queue/v2beta" })],+ });});it("enables websockets without overriding the Vercel entry format", async () => {@@ -388,10 +386,7 @@ describe("application Nitro creation", () => {};preparedHost.compileResult.manifest.channels = [websocketChannel];- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "app"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));const nitroOptions = createNitroMock.mock.calls[0]?.[0];expect(nitroOptions).toMatchObject({@@ -400,15 +395,9 @@ describe("application Nitro creation", () => {},preset: "vercel",});- expect(nitroOptions?.vercel).toEqual({- config: {- version: 3,- framework: {- slug: "eve",- version: resolveInstalledPackageInfo().version,- },- },- });+ expect(nitroOptions?.vercel).toEqual(+ createEveVercelOptions({ agentName: "weather-agent", enabled: true }),+ );});it("clears Nitro build cache output from a different eve version", async () => {@@ -436,10 +425,7 @@ describe("application Nitro creation", () => {const { createProductionApplicationNitro } =await import("#internal/nitro/host/create-application-nitro.js");- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));await expect(readFile(staleBuildOutputPath, "utf8")).rejects.toThrow();await expect(readFile(join(nitroBuildDir, "eve-cache.json"), "utf8")).resolves.toBe(@@ -462,10 +448,7 @@ describe("application Nitro creation", () => {const { createProductionApplicationNitro } = await import("./create-application-nitro.js");const preparedHost = createPreparedHost();- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));const rollupBeforeHooks = nitroStub.hookHandlers.get("rollup:before") ?? [];const config = {@@ -513,13 +496,8 @@ describe("application Nitro creation", () => {});it("merges framework and configured hosted dependencies", async () => {- const allNitroStub = createNitroStub();- const appNitroStub = createNitroStub();- const flowNitroStub = createNitroStub();- createNitroMock- .mockResolvedValueOnce(allNitroStub.nitro)- .mockResolvedValueOnce(appNitroStub.nitro)- .mockResolvedValueOnce(flowNitroStub.nitro);+ const nitroStub = createNitroStub();+ createNitroMock.mockResolvedValueOnce(nitroStub.nitro);const { createProductionApplicationNitro } =await import("#internal/nitro/host/create-application-nitro.js");@@ -531,29 +509,16 @@ describe("application Nitro creation", () => {},} as typeof preparedHost.compileResult.manifest.config;- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "app"),+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));++ const traceDeps = createNitroMock.mock.calls[0]?.[0].traceDeps;+ expect(traceDeps).toEqual(+ expect.arrayContaining(["@napi-rs/keyring", "sharp", "fixture-external"]),);- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "flow"),+ expect(traceDeps.filter((dependencyName: string) => dependencyName === "sharp")).toHaveLength(+ 1,);-- for (const call of createNitroMock.mock.calls.slice(0, 3)) {- const traceDeps = call[0].traceDeps;- expect(traceDeps).toEqual(- expect.arrayContaining(["@napi-rs/keyring", "sharp", "fixture-external"]),- );- expect(traceDeps.filter((dependencyName: string) => dependencyName === "sharp")).toHaveLength(- 1,- );- expect(traceDeps).not.toContain("eve");- }+ expect(traceDeps).not.toContain("eve");});it("traces configured hosted dependencies from subagent configs", async () => {@@ -589,10 +554,7 @@ describe("application Nitro creation", () => {};preparedHost.compileResult.manifest.subagents = [subagent];- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));const traceDeps = createNitroMock.mock.calls[0]?.[0].traceDeps;expect(traceDeps).toEqual(expect.arrayContaining(["subagent-external", "sharp"]));@@ -609,10 +571,7 @@ describe("application Nitro creation", () => {await import("#internal/nitro/host/create-application-nitro.js");const preparedHost = createPreparedHost();- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));expect(createNitroMock.mock.calls[0]?.[0].traceDeps).toEqual(["@napi-rs/keyring"]);});@@ -630,11 +589,8 @@ describe("application Nitro creation", () => {const workflowHost = createPreparedHost();workflowHost.compileResult.manifest.workflowTool = {};- await createProductionApplicationNitro(directHost, createProductionOptions(directHost, "all"));- await createProductionApplicationNitro(- workflowHost,- createProductionOptions(workflowHost, "all"),- );+ await createProductionApplicationNitro(directHost, createProductionOptions(directHost));+ await createProductionApplicationNitro(workflowHost, createProductionOptions(workflowHost));const directPlugins = createNitroMock.mock.calls[0]?.[0].plugins as string[];const workflowPlugins = createNitroMock.mock.calls[1]?.[0].plugins as string[];@@ -657,10 +613,7 @@ describe("application Nitro creation", () => {await import("#internal/nitro/host/create-application-nitro.js");const productionHost = createPreparedHost();- await createProductionApplicationNitro(- productionHost,- createProductionOptions(productionHost, "all"),- );+ await createProductionApplicationNitro(productionHost, createProductionOptions(productionHost));await createDevelopmentApplicationNitro(createPreparedHost());const productionPlugins = createNitroMock.mock.calls[0]?.[0].plugins as string[];@@ -688,10 +641,7 @@ describe("application Nitro creation", () => {},} as typeof preparedHost.compileResult.manifest.config;- await createProductionApplicationNitro(- preparedHost,- createProductionOptions(preparedHost, "all"),- );+ await createProductionApplicationNitro(preparedHost, createProductionOptions(preparedHost));const traceDeps = createNitroMock.mock.calls[0]?.[0].traceDeps;expect(traceDeps).toEqual(@@ -746,7 +696,7 @@ describe("application Nitro creation", () => {const preparedHost = createPreparedHost();preparedHost.workflowBuildDir = workflowBuildDir;await createProductionApplicationNitro(preparedHost, {- ...createProductionOptions(preparedHost, "all"),+ ...createProductionOptions(preparedHost),buildDir: nitroBuildDir,});diff --git a/packages/eve/src/internal/nitro/host/create-application-nitro.ts b/packages/eve/src/internal/nitro/host/create-application-nitro.tsindex f5a6191d0..08cae87b3 100644--- a/packages/eve/src/internal/nitro/host/create-application-nitro.ts+++ b/packages/eve/src/internal/nitro/host/create-application-nitro.ts@@ -31,7 +31,6 @@ import {import { addNitroRoutingImportSpecifierPlugin } from "#internal/nitro/host/nitro-routing-import-specifier-plugin.js";import { registerScheduleTaskHandlers } from "#internal/nitro/host/schedule-task-routes.js";import type {- NitroBuildSurface,PreparedApplicationHost,PreparedDevelopmentApplicationHost,} from "#internal/nitro/host/types.js";@@ -85,18 +84,6 @@ function resolveProductionNitroPreset(): "vercel" | undefined {return process.env.VERCEL ? "vercel" : undefined;}-function includesApplicationSurface(surface: NitroBuildSurface): boolean {- return surface === "all" || surface === "app";-}--function includesWorkflowSurface(surface: NitroBuildSurface): boolean {- return surface === "all" || surface === "flow";-}--function includesWorkflowStepRegistrations(surface: NitroBuildSurface): boolean {- return includesWorkflowSurface(surface);-}-/** Whether any agent needs the dynamic Workflow sandbox runtime. */function manifestEnablesWorkflow(manifest: CompiledAgentManifest): boolean {const nodes = [manifest, ...manifest.subagents.map((subagent) => subagent.agent)];@@ -692,17 +679,14 @@ function createApplicationNitroPlugins(preparedHost: PreparedApplicationHost): sfunction configureSharedApplicationNitro(nitro: Nitro,preparedHost: PreparedApplicationHost,- surface: NitroBuildSurface,): void {addNitroRoutingImportSpecifierPlugin(nitro);- if (includesWorkflowSurface(surface)) {- const workflowAliases = resolveWorkflowAliases();- for (const [specifier, resolvedPath] of Object.entries(workflowAliases)) {- nitro.options.alias[specifier] = resolvedPath;- }- addWorkflowModuleSideEffectsPlugin(nitro, preparedHost.workflowBuildDir);- patchWorkflowTransformExcludePath(nitro, preparedHost.workflowBuildDir);+ const workflowAliases = resolveWorkflowAliases();+ for (const [specifier, resolvedPath] of Object.entries(workflowAliases)) {+ nitro.options.alias[specifier] = resolvedPath;}+ addWorkflowModuleSideEffectsPlugin(nitro, preparedHost.workflowBuildDir);+ patchWorkflowTransformExcludePath(nitro, preparedHost.workflowBuildDir);addDynamicToolTransformPlugin(nitro);@@ -773,7 +757,10 @@ export async function createDevelopmentApplicationNitro(rootDir: preparedHost.appRoot,serverDir: false,traceDeps: bundler.tracedAppDependencies,- vercel: createEveVercelOptions(false),+ vercel: createEveVercelOptions({+ agentName: preparedHost.compileResult.manifest.config.name,+ enabled: false,+ }),watchOptions: createDevelopmentWatchOptions(preparedHost.appRoot),},{ watch: true },@@ -781,7 +768,7 @@ export async function createDevelopmentApplicationNitro(await writeEveVersionedCacheMetadata(nitroBuildDir);const stepEntrypointPath = join(nitro.options.buildDir, "workflow", "steps.mjs");- configureSharedApplicationNitro(nitro, preparedHost, "all");+ configureSharedApplicationNitro(nitro, preparedHost);const clearStepTransformCaches = configureNitroStepPlugins(nitro, stepEntrypointPath);nitro.hooks.hook("dev:reload", () => {for (const clearCache of clearStepTransformCaches) {@@ -798,15 +785,19 @@ export async function createDevelopmentApplicationNitro(interface ProductionApplicationNitroOptions {readonly buildDir: string;readonly outputDir: string;- readonly surface: NitroBuildSurface;+ /**+ * Agent's resolved public route prefix, baked into the Vercel flow+ * function's environment for callback-URL minting behind a per-agent mount.+ */+ readonly publicRoutePrefix?: string;}/**- * Creates a build-mode Nitro host for one production surface. `surface`- * narrows which route groups are registered ("all" for self-hosted output;- * "app"/"flow" for the separately bundled Vercel functions), and `buildDir`/- * `outputDir` place all bundler state inside the invocation-owned build- * workspace.+ * Creates a build-mode Nitro host for one production build. Every route group+ * (application, workflow, schedules) is registered in the same host; on Vercel+ * the workflow flow route additionally becomes its own queue-triggered function+ * through the preset's `functionRules`. `buildDir`/`outputDir` place all+ * bundler state inside the invocation-owned build workspace.*/export async function createProductionApplicationNitro(preparedHost: PreparedApplicationHost,@@ -825,37 +816,30 @@ export async function createProductionApplicationNitro(buildDir: options.buildDir,dev: false,features: {- websocket:- includesApplicationSurface(options.surface) &&- manifestHasWebSocketChannel(preparedHost.compileResult.manifest),+ websocket: manifestHasWebSocketChannel(preparedHost.compileResult.manifest),},output: { dir: options.outputDir },preset,plugins: nitroPlugins,publicAssets: [],- scanDirs: includesWorkflowStepRegistrations(options.surface)- ? [resolvePackageSourceDirectoryPath("src/execution")]- : undefined,+ scanDirs: [resolvePackageSourceDirectoryPath("src/execution")],rolldownConfig: bundler.nitroRolldownConfig,rollupConfig: bundler.nitroRollupConfig,rootDir: preparedHost.appRoot,serverDir: false,traceDeps: bundler.tracedAppDependencies,- vercel: createEveVercelOptions(- preset === "vercel" && includesApplicationSurface(options.surface),- ),+ vercel: createEveVercelOptions({+ agentName: preparedHost.compileResult.manifest.config.name,+ enabled: preset === "vercel",+ publicRoutePrefix: options.publicRoutePrefix,+ }),});await writeEveVersionedCacheMetadata(options.buildDir);- configureSharedApplicationNitro(nitro, preparedHost, options.surface);- if (includesWorkflowStepRegistrations(options.surface)) {- configureNitroStepPlugins(nitro, join(preparedHost.workflowBuildDir, "steps.mjs"));- }+ configureSharedApplicationNitro(nitro, preparedHost);+ configureNitroStepPlugins(nitro, join(preparedHost.workflowBuildDir, "steps.mjs"));- if (- includesApplicationSurface(options.surface) &&- preparedHost.scheduleRegistrations.length > 0- ) {+ if (preparedHost.scheduleRegistrations.length > 0) {applyEveCronHandlerRoute(nitro);const artifactsConfig = createProductionNitroArtifactsConfig();registerScheduleTaskHandlers(nitro, {@@ -867,9 +851,7 @@ export async function createProductionApplicationNitro(});}- await configureProductionNitroRoutes(nitro, preparedHost, options.surface);- if (includesWorkflowStepRegistrations(options.surface)) {- await addNitroStepNoExternals(nitro, join(preparedHost.workflowBuildDir, "steps.mjs"));- }+ await configureProductionNitroRoutes(nitro, preparedHost);+ await addNitroStepNoExternals(nitro, join(preparedHost.workflowBuildDir, "steps.mjs"));return nitro;}diff --git a/packages/eve/src/internal/nitro/host/types.ts b/packages/eve/src/internal/nitro/host/types.tsindex 1df636db1..bb7a1bc3c 100644--- a/packages/eve/src/internal/nitro/host/types.ts+++ b/packages/eve/src/internal/nitro/host/types.ts@@ -7,11 +7,6 @@ import type { DevelopmentGeneration } from "#internal/nitro/development-generatiimport type { DevelopmentHostWorkspace } from "#internal/nitro/host/dev-host-workspace.js";import type { DevelopmentWorkspaceExtension } from "#internal/nitro/host/dev-workspace-extensions.js";-/**- * Route surface included in one programmatic Nitro host build.- */-export type NitroBuildSurface = "all" | "app" | "flow";-/** Options for one production application build. */export interface ApplicationBuildOptions {/** Absolute path for an optional machine-readable profile of a successful build. */diff --git a/packages/eve/src/internal/nitro/host/vercel-build-output-config.test.ts b/packages/eve/src/internal/nitro/host/vercel-build-output-config.test.tsindex b4746556b..68a4ad2a2 100644--- a/packages/eve/src/internal/nitro/host/vercel-build-output-config.test.ts+++ b/packages/eve/src/internal/nitro/host/vercel-build-output-config.test.ts@@ -2,22 +2,72 @@ import { describe, expect, it } from "vitest";import { resolveInstalledPackageInfo } from "#internal/application/package.js";import { EVE_PACKAGE_NAME } from "#internal/package-name.js";-import { createEveVercelOptions } from "#internal/nitro/host/vercel-build-output-config.js";+import {+ createEveVercelOptions,+ EVE_WORKFLOW_FLOW_ROUTE_PATH,+} from "#internal/nitro/host/vercel-build-output-config.js";+import { deriveEveWorkflowQueueTopic } from "#internal/workflow/queue-namespace.js";describe("createEveVercelOptions", () => {it("returns undefined when the Vercel build output is disabled", () => {- expect(createEveVercelOptions(false)).toBeUndefined();+ expect(createEveVercelOptions({ agentName: "test-agent", enabled: false })).toBeUndefined();});it("emits both framework slug and version so the proxy keeps the framework object", () => {- expect(createEveVercelOptions(true)).toEqual({- config: {- version: 3,- framework: {- slug: EVE_PACKAGE_NAME,- version: resolveInstalledPackageInfo().version,+ expect(createEveVercelOptions({ agentName: "test-agent", enabled: true })?.config).toEqual({+ version: 3,+ framework: {+ slug: EVE_PACKAGE_NAME,+ version: resolveInstalledPackageInfo().version,+ },+ });+ });++ it("declares the queue-triggered workflow flow function through functionRules", () => {+ const options = createEveVercelOptions({ agentName: "test-agent", enabled: true });++ expect(options?.functionRules).toEqual({+ [EVE_WORKFLOW_FLOW_ROUTE_PATH]: {+ maxDuration: "max",+ experimentalTriggers: [+ {+ type: "queue/v2beta",+ topic: deriveEveWorkflowQueueTopic("test-agent"),+ consumer: "default",+ retryAfterSeconds: 5,+ initialDelaySeconds: 0,+ },+ ],+ environment: {+ WORKFLOW_PRECONDITION_GUARD: "1",},},});});++ it("omits the public route prefix from the flow environment when none is set", () => {+ for (const publicRoutePrefix of [undefined, ""]) {+ const options = createEveVercelOptions({+ agentName: "test-agent",+ enabled: true,+ publicRoutePrefix,+ });+ expect(options?.functionRules[EVE_WORKFLOW_FLOW_ROUTE_PATH].environment).not.toHaveProperty(+ "EVE_PUBLIC_ROUTE_PREFIX",+ );+ }+ });++ it("bakes the normalized public route prefix into the flow function environment", () => {+ const options = createEveVercelOptions({+ agentName: "test-agent",+ enabled: true,+ publicRoutePrefix: "eve/agents/support/",+ });++ expect(options?.functionRules[EVE_WORKFLOW_FLOW_ROUTE_PATH].environment).toEqual({+ WORKFLOW_PRECONDITION_GUARD: "1",+ EVE_PUBLIC_ROUTE_PREFIX: "/eve/agents/support",+ });+ });});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 d1669e50c..a1204fabf 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,11 +1,46 @@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_PUBLIC_ROUTE_PREFIX_ENV,+ normalizePublicRoutePrefix,+} from "#shared/public-route-prefix.js";-export function createEveVercelOptions(enabled: boolean) {- if (!enabled) {+/** Route Nitro's Vercel preset emits as the queue-triggered workflow function. */+export const EVE_WORKFLOW_FLOW_ROUTE_PATH = "/.well-known/workflow/v1/flow";++/**+ * Builds eve's Vercel preset options.+ *+ * The flow route's `functionRules` entry makes Nitro emit a dedicated+ * `flow.func` from the same build output, carrying the agent's queue trigger,+ * an extended execution window, and the environment the deployed workflow+ * runtime needs. Every other function setting (runtime, memory, streaming) is+ * inherited from the base server function config.+ */+export function createEveVercelOptions(input: {+ agentName: string;+ enabled: boolean;+ publicRoutePrefix?: string;+}) {+ if (!input.enabled) {return undefined;}+ const environment: Record<string, string> = {+ // Reject replay decisions made from an event log that missed a+ // concurrent wake.+ WORKFLOW_PRECONDITION_GUARD: "1",+ };++ // Bake the agent's public mount into the flow function so callback-URL+ // minting inside the deployed workflow runtime resolves a routable path+ // when a multi-agent host proxies the agent behind a prefix.+ const publicRoutePrefix = normalizePublicRoutePrefix(input.publicRoutePrefix);+ if (publicRoutePrefix !== undefined) {+ environment[EVE_PUBLIC_ROUTE_PREFIX_ENV] = publicRoutePrefix;+ }+return {config: {version: 3 as const,@@ -14,5 +49,12 @@ export function createEveVercelOptions(enabled: boolean) {version: resolveInstalledPackageInfo().version,},},+ functionRules: {+ [EVE_WORKFLOW_FLOW_ROUTE_PATH]: {+ maxDuration: "max" as const,+ experimentalTriggers: [createEveWorkflowQueueTrigger(input.agentName)],+ environment,+ },+ },};}diff --git a/packages/eve/src/internal/workflow-bundle/builder-support.ts b/packages/eve/src/internal/workflow-bundle/builder-support.tsindex f01767fa3..ec1cefd2b 100644--- a/packages/eve/src/internal/workflow-bundle/builder-support.ts+++ b/packages/eve/src/internal/workflow-bundle/builder-support.ts@@ -21,11 +21,6 @@ export interface WorkflowBundleBuilderOptions {appRoot: string;compiledArtifactsBootstrapPath: string;outDir: string;- /**- * The agent's resolved public route prefix, baked into every emitted Vercel- * workflow function's environment for callback-URL minting.- */- publicRoutePrefix?: string;rootDir: string;watch: boolean;/** Test-harness-only: also scans `src/internal/testing/`. */diff --git a/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts b/packages/eve/src/internal/workflow-bundle/builder.scenario.test.tsindex 3982fa7a7..cd05adf91 100644--- a/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts+++ b/packages/eve/src/internal/workflow-bundle/builder.scenario.test.ts@@ -322,211 +322,6 @@ describe("WorkflowBundleBuilder", () => {}});- it("rebuilds workflow artifacts before emitting Vercel output", async () => {- const rootDir = resolvePackageRoot();- const tempRoot = await mkdtemp(join(tmpdir(), "eve-workflow-bundle-vercel-"));- const outDir = join(tempRoot, "workflow-build");- const outputDir = join(tempRoot, "vercel-output");- const flowNitroOutputDir = join(tempRoot, "flow-output");-- class BuildTrackingWorkflowBundleBuilder extends InspectableWorkflowBundleBuilder {- buildCalls = 0;-- override async build(): Promise<void> {- this.buildCalls += 1;- await mkdir(this.outDir, { recursive: true });- await writeFile(join(this.outDir, "manifest.json"), "{}\n");- }- }-- try {- const flowFunctionDir = join(flowNitroOutputDir, "functions", "__server.func");- const staleWebhookFunctionDir = join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "webhook",- "[token].func",- );- const staleStepFunctionDir = join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "step.func",- );- await Promise.all([- mkdir(join(outputDir, "functions", "__server.func"), { recursive: true }),- mkdir(flowFunctionDir, { recursive: true }),- mkdir(staleWebhookFunctionDir, { recursive: true }),- mkdir(staleStepFunctionDir, { recursive: true }),- ]);- await Promise.all([- writeFile(- join(outputDir, "functions", "__server.func", "index.js"),- 'module.exports = { marker: "server" };\n',- ),- writeFile(join(flowFunctionDir, "index.js"), 'export const marker = "flow";\n'),- writeFile(join(staleWebhookFunctionDir, "index.js"), 'export const marker = "stale";\n'),- writeFile(- join(flowFunctionDir, "package.json"),- `${JSON.stringify(- {- dependencies: { rolldown: "1.0.0-rc.18" },- name: "traced-node-modules-flow",- private: true,- type: "module",- version: "1.0.0",- },- null,- 2,- )}\n`,- ),- writeFile(- join(flowFunctionDir, ".vc-config.json"),- `${JSON.stringify(- {- environment: {- EVE_EXISTING_FLAG: "kept",- WORKFLOW_PRECONDITION_GUARD: "0",- },- handler: "index.js",- launcherType: "Nodejs",- runtime: "nodejs24.x",- shouldAddHelpers: false,- supportsResponseStreaming: true,- },- null,- 2,- )}\n`,- ),- writeFile(join(staleStepFunctionDir, "index.js"), 'export const marker = "stale-step";\n'),- ]);-- const builder = new BuildTrackingWorkflowBundleBuilder({- agentName: "test-agent",- appRoot: "/tmp/eve-app",- compiledArtifactsBootstrapPath: "/tmp/compiled-artifacts-bootstrap.js",- outDir,- rootDir,- watch: false,- });-- await builder.buildVercelOutput({- flowNitroOutputDir,- outputDir,- runtime: "nodejs24.x",- });-- const generatedFlowFunctionDir = join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- );- const flowConfig = JSON.parse(- await readFile(join(generatedFlowFunctionDir, ".vc-config.json"), "utf8"),- ) as { environment?: Record<string, unknown> };-- expect(builder.buildCalls).toBe(1);- expect(flowConfig.environment).toEqual({- EVE_EXISTING_FLAG: "kept",- NODE_OPTIONS: "--experimental-require-module",- WORKFLOW_PRECONDITION_GUARD: "1",- });- const generatedFlowFunctionSource = await readFile(- join(outputDir, "functions", ".well-known", "workflow", "v1", "flow.func", "index.js"),- "utf8",- );- expect(generatedFlowFunctionSource).toContain("/.well-known/workflow/v1/flow");- expect(- await readFile(- join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- "__eve_nitro_handler__.js",- ),- "utf8",- ),- ).toContain('marker = "flow"');- await expect(- readFile(- join(outputDir, "functions", ".well-known", "workflow", "v1", "flow.func", "index.js"),- "utf8",- ),- ).resolves.not.toContain("loadAuthoredModuleNamespace");- await expect(- readFile(- join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- ".vc-config.json",- ),- "utf8",- ),- ).resolves.toContain('"__eve746573742d6167656e74_wkf_workflow_*"');- await expect(- readFile(- join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- ".vc-config.json",- ),- "utf8",- ),- ).resolves.toContain('"maxDuration": "max"');- await expect(- readFile(- join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- ".vc-config.json",- ),- "utf8",- ),- ).resolves.toContain('"supportsResponseStreaming": true');- await expect(- readFile(- join(- outputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- "package.json",- ),- "utf8",- ),- ).resolves.toContain('"rolldown": "1.0.0-rc.18"');- await expect(readFile(join(staleStepFunctionDir, "index.js"), "utf8")).rejects.toThrow();- await expect(readFile(join(staleWebhookFunctionDir, "index.js"), "utf8")).rejects.toThrow();- } finally {- await rm(tempRoot, { force: true, recursive: true });- }- });-it("fails the driver build when a node builtin reaches the workflow body", async () => {const tempRoot = await mkdtemp(join(tmpdir(), "eve-workflow-bundle-node-leak-"));const outDir = join(tempRoot, "workflow-build");diff --git a/packages/eve/src/internal/workflow-bundle/builder.ts b/packages/eve/src/internal/workflow-bundle/builder.tsindex fe5990a2e..0547510ff 100644--- a/packages/eve/src/internal/workflow-bundle/builder.ts+++ b/packages/eve/src/internal/workflow-bundle/builder.ts@@ -1,5 +1,5 @@import { Buffer } from "node:buffer";-import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";+import { mkdir, readFile, writeFile } from "node:fs/promises";import { dirname, join, relative, resolve } from "node:path";import {@@ -35,24 +35,18 @@ import {import { buildSingleRolldownChunk } from "#internal/bundler/nitro-rolldown.js";import { writeNitroStepEntrypoint } from "#internal/workflow-bundle/nitro-step-entry.js";import {- copyNitroFunctionDirectory,- createWorkflowFunctionEnvironment,- retargetNitroFunctionDirectoryToWorkflowRoute,WORKFLOW_BUILDER_DEFERRED_PACKAGES,WORKFLOW_STEP_EXTERNAL_PACKAGES,} from "#internal/workflow-bundle/vercel-workflow-output.js";import {detectWorkflowPatterns,- createEveWorkflowQueueTrigger,type WorkflowManifest,} from "#internal/workflow-bundle/workflow-builders.js";import { deriveEveWorkflowQueueNamespace } from "#internal/workflow/queue-namespace.js";export class WorkflowBundleBuilder {- readonly #agentName: string;readonly #compiledArtifactsBootstrapPath: string;readonly #outDir: string;- readonly #publicRoutePrefix?: string;readonly #queueNamespace: string;protected readonly config: WorkflowBundleBuilderConfig;readonly #discoveredEntries = new WeakMap<readonly string[], WorkflowBundleDiscoveredEntries>();@@ -72,10 +66,8 @@ export class WorkflowBundleBuilder {workingDir: options.rootDir,};- this.#agentName = options.agentName;this.#compiledArtifactsBootstrapPath = options.compiledArtifactsBootstrapPath;this.#outDir = options.outDir;- this.#publicRoutePrefix = options.publicRoutePrefix;this.#queueNamespace = deriveEveWorkflowQueueNamespace(options.agentName);}@@ -357,149 +349,9 @@ export class WorkflowBundleBuilder {return manifestJson;}- async buildVercelOutput(options: {- flowNitroOutputDir: string;- outputDir: string;- runtime?: string;- }): Promise<void> {- await this.build();-- const stagedWorkflowGeneratedDir = join(- this.#outDir,- "vercel-build-output",- "functions",- ".well-known",- "workflow",- "v1",- );- const stagedFlowFunctionDir = join(stagedWorkflowGeneratedDir, "flow.func");- const workflowGeneratedDir = join(- options.outputDir,- "functions",- ".well-known",- "workflow",- "v1",- );- const nitroFlowServerFunctionDir = join(- options.flowNitroOutputDir,- "functions",- "__server.func",- );- const nitroFlowFunctionDir = join(- options.flowNitroOutputDir,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- );- const flowFunctionDir = join(workflowGeneratedDir, "flow.func");- const staleStepFunctionDir = join(workflowGeneratedDir, "step.func");- const staleWebhookFunctionDir = join(workflowGeneratedDir, "webhook", "[token].func");-- await copyNitroFunctionDirectory({- fallbackPath: nitroFlowServerFunctionDir,- sourcePath: nitroFlowFunctionDir,- targetPath: stagedFlowFunctionDir,- });-- await Promise.all([- this.#patchVercelFunctionConfig(stagedFlowFunctionDir, {- experimentalTriggers: [createEveWorkflowQueueTrigger(this.#agentName)],- maxDuration: "max",- runtime: options.runtime ?? null,- shouldAddHelpers: false,- }),- cp(join(this.#outDir, "manifest.json"), join(stagedWorkflowGeneratedDir, "manifest.json")),- ]);- await retargetNitroFunctionDirectoryToWorkflowRoute({- functionDirectoryPath: stagedFlowFunctionDir,- workflowRoutePath: "/.well-known/workflow/v1/flow",- });-- await Promise.all([- rm(flowFunctionDir, {- force: true,- recursive: true,- }),- rm(staleStepFunctionDir, {- force: true,- recursive: true,- }),- rm(staleWebhookFunctionDir, {- force: true,- recursive: true,- }),- ]);- await mkdir(workflowGeneratedDir, { recursive: true });- await Promise.all([- cp(stagedFlowFunctionDir, flowFunctionDir, { recursive: true }),- cp(- join(stagedWorkflowGeneratedDir, "manifest.json"),- join(workflowGeneratedDir, "manifest.json"),- ),- ]);- }-async #getBuildInputFiles(): Promise<string[]> {return await this.getInputFiles();}-- async #patchVercelFunctionConfig(- directoryPath: string,- patch: {- experimentalTriggers?: readonly unknown[];- maxDuration?: number | "max";- runtime?: string | null;- shouldAddHelpers?: boolean;- shouldAddSourcemapSupport?: boolean;- },- ): Promise<void> {- const configPath = join(directoryPath, ".vc-config.json");- const baseConfig = await this.#readVercelFunctionConfig(configPath);- const nextConfig: Record<string, unknown> = {- ...baseConfig,- };- nextConfig.environment = createWorkflowFunctionEnvironment({- environment: baseConfig.environment,- publicRoutePrefix: this.#publicRoutePrefix,- });-- if (patch.runtime !== null) {- nextConfig.runtime = patch.runtime;- }-- if (patch.maxDuration !== undefined) {- nextConfig.maxDuration = patch.maxDuration;- }-- if (patch.shouldAddHelpers !== undefined) {- nextConfig.shouldAddHelpers = patch.shouldAddHelpers;- }-- if (patch.shouldAddSourcemapSupport !== undefined) {- nextConfig.shouldAddSourcemapSupport = patch.shouldAddSourcemapSupport;- }-- if (patch.experimentalTriggers !== undefined) {- nextConfig.experimentalTriggers = [...patch.experimentalTriggers];- }-- await writeFile(configPath, `${JSON.stringify(nextConfig, null, 2)}\n`);- }-- async #readVercelFunctionConfig(configPath: string): Promise<Record<string, unknown>> {- try {- const parsed = JSON.parse(await readFile(configPath, "utf8"));- if (parsed !== null && typeof parsed === "object") {- return parsed as Record<string, unknown>;- }- } catch {- // fall through- }-- return {};- }}async function addStepRegistrationsImport(diff --git a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.scenario.test.ts b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.scenario.test.tsdeleted file mode 100644index fbd92e9cf..000000000--- a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.scenario.test.ts+++ /dev/null@@ -1,429 +0,0 @@-import { lstat, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";-import { createRequire } from "node:module";-import { join } from "node:path";--import { afterEach, describe, expect, it } from "vitest";--import { resolvePackageRoot } from "#internal/application/package.js";-import {- copyNitroFunctionDirectory,- emitBundledWorkflowFunctionDirectory,- retargetNitroFunctionDirectoryToWorkflowRoute,-} from "#internal/workflow-bundle/vercel-workflow-output.js";--const temporaryDirectories: string[] = [];--afterEach(async () => {- delete (globalThis as Record<string, unknown>).__workflowStandalonePluginLoaded;- delete (globalThis as Record<string, unknown>).__workflowStandaloneImportMetaPluginLoaded;- delete (globalThis as Record<string, unknown>).__workflowStandaloneCommonJsPluginLoaded;-- await Promise.all(- temporaryDirectories.splice(0).map((directoryPath) =>- rm(directoryPath, {- force: true,- recursive: true,- }),- ),- );-});--describe("copyNitroFunctionDirectory", () => {- it("prefers the route-specific Nitro function directory when it exists", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-copy-source-"));- temporaryDirectories.push(root);-- const sourcePath = join(root, "functions", ".well-known", "workflow", "v1", "step.func");- const fallbackPath = join(root, "functions", "__server.func");- const targetPath = join(root, "staged", "step.func");-- await Promise.all([- mkdir(sourcePath, { recursive: true }),- mkdir(fallbackPath, { recursive: true }),- mkdir(targetPath, { recursive: true }),- ]);-- await Promise.all([- writeFile(join(sourcePath, "index.mjs"), 'export const marker = "route-source";\n'),- writeFile(join(fallbackPath, "index.mjs"), 'export const marker = "server-fallback";\n'),- writeFile(join(targetPath, "stale.txt"), "remove-me\n"),- ]);-- await copyNitroFunctionDirectory({- fallbackPath,- sourcePath,- targetPath,- });-- await expect(readFile(join(targetPath, "index.mjs"), "utf8")).resolves.toContain(- "route-source",- );- await expect(readFile(join(targetPath, "stale.txt"), "utf8")).rejects.toThrow();- });-- it("falls back to Nitro's __server function when the route path is missing", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-copy-fallback-"));- temporaryDirectories.push(root);-- const sourcePath = join(root, "functions", ".well-known", "workflow", "v1", "step.func");- const fallbackPath = join(root, "functions", "__server.func");- const targetPath = join(root, "staged", "step.func");-- await mkdir(fallbackPath, { recursive: true });- await writeFile(join(fallbackPath, "index.mjs"), 'export const marker = "server-fallback";\n');-- await copyNitroFunctionDirectory({- fallbackPath,- sourcePath,- targetPath,- });-- await expect(readFile(join(targetPath, "index.mjs"), "utf8")).resolves.toContain(- "server-fallback",- );- });-- it("materializes traced node_modules symlinks into concrete files", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-copy-linked-"));- temporaryDirectories.push(root);-- const sourcePath = join(root, "functions", ".well-known", "workflow", "v1", "step.func");- const fallbackPath = join(root, "functions", "__server.func");- const targetPath = join(root, "staged", "step.func");- const tracedPackagePath = join(fallbackPath, "node_modules", ".nf3", "[email protected]");- const linkedPackagePath = join(sourcePath, "node_modules", "rolldown");-- await Promise.all([- mkdir(sourcePath, { recursive: true }),- mkdir(join(sourcePath, "node_modules"), { recursive: true }),- mkdir(tracedPackagePath, { recursive: true }),- ]);- await writeFile(join(tracedPackagePath, "package.json"), '{ "name": "rolldown" }\n');- await symlink(tracedPackagePath, linkedPackagePath);-- await copyNitroFunctionDirectory({- fallbackPath,- sourcePath,- targetPath,- });-- const copiedPackagePath = join(targetPath, "node_modules", "rolldown");- await expect(readFile(join(copiedPackagePath, "package.json"), "utf8")).resolves.toContain(- '"name": "rolldown"',- );- const copiedStats = await lstat(copiedPackagePath);- expect(copiedStats.isSymbolicLink()).toBe(false);- });-});--describe("retargetNitroFunctionDirectoryToWorkflowRoute", () => {- it("rewrites the configured handler to target one workflow route", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-retarget-"));- temporaryDirectories.push(root);-- const functionDirectoryPath = join(- root,- "functions",- ".well-known",- "workflow",- "v1",- "step.func",- );-- await mkdir(functionDirectoryPath, { recursive: true });- await Promise.all([- writeFile(join(functionDirectoryPath, "index.js"), 'export const marker = "nitro";\n'),- writeFile(- join(functionDirectoryPath, ".vc-config.json"),- `${JSON.stringify(- {- handler: "index.js",- launcherType: "Nodejs",- },- null,- 2,- )}\n`,- ),- ]);-- await retargetNitroFunctionDirectoryToWorkflowRoute({- functionDirectoryPath,- workflowRoutePath: "/.well-known/workflow/v1/step",- });-- await expect(readFile(join(functionDirectoryPath, "index.js"), "utf8")).resolves.toContain(- "/.well-known/workflow/v1/step",- );- await expect(- readFile(join(functionDirectoryPath, "__eve_nitro_handler__.js"), "utf8"),- ).resolves.toContain('marker = "nitro"');- });-- it("uses index.mjs when .vc-config.json has no handler", async () => {- const root = await mkdtemp(- join(resolvePackageRoot(), ".eve-vercel-workflow-retarget-fallback-"),- );- temporaryDirectories.push(root);-- const functionDirectoryPath = join(- root,- "functions",- ".well-known",- "workflow",- "v1",- "flow.func",- );-- await mkdir(functionDirectoryPath, { recursive: true });- await writeFile(join(functionDirectoryPath, "index.mjs"), "export default { fetch() {} };\n");-- await retargetNitroFunctionDirectoryToWorkflowRoute({- functionDirectoryPath,- workflowRoutePath: "/.well-known/workflow/v1/flow",- });-- await expect(readFile(join(functionDirectoryPath, "index.mjs"), "utf8")).resolves.toContain(- "/.well-known/workflow/v1/flow",- );- await expect(- readFile(join(functionDirectoryPath, "__eve_nitro_handler__.mjs"), "utf8"),- ).resolves.toContain("export default");- });-});--describe("emitBundledWorkflowFunctionDirectory", () => {- it("bundles one standalone flow handler without Nitro's authored-module loader", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-standalone-"));- temporaryDirectories.push(root);-- const bundlePath = join(root, "workflow-build", "workflows.mjs");- const targetPath = join(root, "functions", ".well-known", "workflow", "v1", "flow.func");-- await mkdir(join(root, "workflow-build"), { recursive: true });- await writeFile(- bundlePath,- [- "const workflowCode = `standalone-flow-marker",- "//# sourceMappingURL=data:application/json;base64,ZmFrZQ==",- "`;",- 'export const POST = async (req) => new Response(workflowCode + ":" + req.url);',- "",- ].join("\n"),- );-- await emitBundledWorkflowFunctionDirectory({- bundlePath,- targetPath,- });-- const require = createRequire(import.meta.url);- const emittedHandler = require(join(targetPath, "index.js")) as (- request:- | {- headers?: Record<string, string>;- method?: string;- url: string;- }- | {- req: {- headers?: Record<string, string>;- method?: string;- url: string;- };- },- ) => Promise<Response>;- const directRequestResponse = await emittedHandler({- url: "https://example.com/.well-known/workflow/v1/flow",- });- const wrappedRequestResponse = await emittedHandler({- req: {- url: "https://example.com/.well-known/workflow/v1/flow?wrapped=1",- },- });- const relativeRequestResponse = await emittedHandler({- headers: {- host: "example.com",- "x-forwarded-proto": "https",- },- method: "POST",- url: "/.well-known/workflow/v1/flow?relative=1",- });-- await expect(readFile(join(targetPath, "index.js"), "utf8")).resolves.toContain(- "standalone-flow-marker",- );- await expect(readFile(join(targetPath, "index.js"), "utf8")).resolves.not.toContain(- "loadAuthoredModuleNamespace",- );- await expect(readFile(join(targetPath, "index.js"), "utf8")).resolves.toContain(- "sourceMappingURL=data:application/json;base64,ZmFrZQ==",- );- await expect(directRequestResponse.text()).resolves.toContain(- ":https://example.com/.well-known/workflow/v1/flow",- );- await expect(wrappedRequestResponse.text()).resolves.toContain(- ":https://example.com/.well-known/workflow/v1/flow?wrapped=1",- );- await expect(relativeRequestResponse.text()).resolves.toContain(- ":https://example.com/.well-known/workflow/v1/flow?relative=1",- );- await expect(readFile(join(targetPath, "package.json"), "utf8")).resolves.toContain(- '"type": "commonjs"',- );- const config = JSON.parse(await readFile(join(targetPath, ".vc-config.json"), "utf8")) as {- environment?: Record<string, unknown>;- handler?: unknown;- supportsResponseStreaming?: unknown;- };- expect(config.handler).toBe("index.js");- expect(config.supportsResponseStreaming).toBe(true);- expect(config.environment).toEqual({- NODE_OPTIONS: "--experimental-require-module",- WORKFLOW_PRECONDITION_GUARD: "1",- });- });-- it("bundles optional plugin imports into the standalone workflow handler", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-standalone-"));- temporaryDirectories.push(root);-- const bundlePath = join(root, "workflow-build", "workflows.mjs");- const pluginPath = join(root, "workflow-build", "plugin.mjs");- const targetPath = join(root, "functions", ".well-known", "workflow", "v1", "flow.func");-- await mkdir(join(root, "workflow-build"), { recursive: true });- await Promise.all([- writeFile(- bundlePath,- [- 'export const POST = async () => new Response(String(globalThis.__workflowStandalonePluginLoaded ?? "missing"));',- "",- ].join("\n"),- ),- writeFile(- pluginPath,- ['(globalThis).__workflowStandalonePluginLoaded = "yes";', ""].join("\n"),- ),- ]);-- await emitBundledWorkflowFunctionDirectory({- bundlePath,- pluginPaths: [pluginPath],- targetPath,- });-- const require = createRequire(import.meta.url);- const emittedHandler = require(join(targetPath, "index.js")) as (request: {- url: string;- }) => Promise<Response>;- const response = await emittedHandler({- url: "https://example.com/.well-known/workflow/v1/flow",- });-- expect((globalThis as Record<string, unknown>).__workflowStandalonePluginLoaded).toBe("yes");- await expect(response.text()).resolves.toBe("yes");- });-- it("loads plugin modules as ESM so import.meta.url remains available", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-standalone-"));- temporaryDirectories.push(root);-- const bundlePath = join(root, "workflow-build", "workflows.mjs");- const pluginPath = join(root, "workflow-build", "plugin.mjs");- const targetPath = join(root, "functions", ".well-known", "workflow", "v1", "flow.func");-- await mkdir(join(root, "workflow-build"), { recursive: true });- await Promise.all([- writeFile(- bundlePath,- [- 'export const POST = async () => new Response(String(globalThis.__workflowStandaloneImportMetaPluginLoaded ?? "missing"));',- "",- ].join("\n"),- ),- writeFile(- pluginPath,- [- 'import { createRequire } from "node:module";',- "const require = createRequire(import.meta.url);",- '(globalThis).__workflowStandaloneImportMetaPluginLoaded = require("node:path").sep;',- "",- ].join("\n"),- ),- ]);-- await emitBundledWorkflowFunctionDirectory({- bundlePath,- pluginPaths: [pluginPath],- targetPath,- });-- const require = createRequire(import.meta.url);- const emittedHandler = require(join(targetPath, "index.js")) as (request: {- url: string;- }) => Promise<Response>;- const response = await emittedHandler({- url: "https://example.com/.well-known/workflow/v1/flow",- });-- await expect(- readFile(join(targetPath, "__eve_workflow_plugin_0.mjs"), "utf8"),- ).resolves.toBeTruthy();- expect((globalThis as Record<string, unknown>).__workflowStandaloneImportMetaPluginLoaded).toBe(- "/",- );- await expect(response.text()).resolves.toBe("/");- });-- it("supports bundled CommonJS plugin dependencies that require Node builtins", async () => {- const root = await mkdtemp(join(resolvePackageRoot(), ".eve-vercel-workflow-standalone-"));- temporaryDirectories.push(root);-- const bundlePath = join(root, "workflow-build", "workflows.mjs");- const pluginPath = join(root, "workflow-build", "plugin.mjs");- const commonJsDependencyPath = join(root, "workflow-build", "builtin-loader.cjs");- const targetPath = join(root, "functions", ".well-known", "workflow", "v1", "flow.func");-- await mkdir(join(root, "workflow-build"), { recursive: true });- await Promise.all([- writeFile(- bundlePath,- [- 'export const POST = async () => new Response(String(globalThis.__workflowStandaloneCommonJsPluginLoaded ?? "missing"));',- "",- ].join("\n"),- ),- writeFile(- commonJsDependencyPath,- ['const fs = require("node:fs");', "module.exports = typeof fs.readFile;", ""].join("\n"),- ),- writeFile(- pluginPath,- [- 'import builtinLoader from "./builtin-loader.cjs";',- "(globalThis).__workflowStandaloneCommonJsPluginLoaded = builtinLoader;",- "",- ].join("\n"),- ),- ]);-- await emitBundledWorkflowFunctionDirectory({- bundlePath,- pluginPaths: [pluginPath],- targetPath,- });-- const require = createRequire(import.meta.url);- const emittedHandler = require(join(targetPath, "index.js")) as (request: {- url: string;- }) => Promise<Response>;- const response = await emittedHandler({- url: "https://example.com/.well-known/workflow/v1/flow",- });-- expect((globalThis as Record<string, unknown>).__workflowStandaloneCommonJsPluginLoaded).toBe(- "function",- );- await expect(response.text()).resolves.toBe("function");- });-});diff --git a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.test.ts b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.test.tsdeleted file mode 100644index e19502cd8..000000000--- a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.test.ts+++ /dev/null@@ -1,24 +0,0 @@-import { describe, expect, it } from "vitest";--import { createWorkflowFunctionEnvironment } from "#internal/workflow-bundle/vercel-workflow-output.js";--describe("createWorkflowFunctionEnvironment", () => {- it("omits the public route prefix when the build input does not carry one", () => {- expect(createWorkflowFunctionEnvironment()).not.toHaveProperty("EVE_PUBLIC_ROUTE_PREFIX");- expect(createWorkflowFunctionEnvironment({ publicRoutePrefix: "" })).not.toHaveProperty(- "EVE_PUBLIC_ROUTE_PREFIX",- );- });-- it("bakes the normalized public route prefix from the build input", () => {- expect(- createWorkflowFunctionEnvironment({- environment: { EXISTING: "1" },- publicRoutePrefix: "eve/agents/support/",- }),- ).toMatchObject({- EVE_PUBLIC_ROUTE_PREFIX: "/eve/agents/support",- EXISTING: "1",- });- });-});diff --git a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.tsindex f06d6d654..5b76c4d71 100644--- a/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts+++ b/packages/eve/src/internal/workflow-bundle/vercel-workflow-output.ts@@ -10,18 +10,13 @@ import {writeFile,} from "node:fs/promises";import type { Dirent } from "node:fs";-import { basename, dirname, extname, join, relative } from "node:path";+import { dirname, join, relative } from "node:path";-import { buildSingleRolldownChunk } from "#internal/bundler/nitro-rolldown.js";import {EVE_SHARED_SERVER_FUNCTION_PATH,isEveVercelFunctionPath,normalizeEveVercelRoutes,} from "#internal/workflow-bundle/eve-service-route-output.js";-import {- EVE_PUBLIC_ROUTE_PREFIX_ENV,- normalizePublicRoutePrefix,-} from "#shared/public-route-prefix.js";// just-bash and microsandbox are optional peer dependencies (the// opt-in local sandbox engines) loaded lazily from the application's@@ -43,88 +38,10 @@ export const WORKFLOW_STEP_EXTERNAL_PACKAGES = [*/export const WORKFLOW_BUILDER_DEFERRED_PACKAGES = ["@chat-adapter/slack", "chat"] as const;-const WORKFLOW_FUNCTION_NODE_OPTIONS = "--experimental-require-module";-const WORKFLOW_PRECONDITION_GUARD_ENABLED = "1";--/**- * Builds the environment block every generated Vercel workflow function needs.- *- * When the build input carries the agent's resolved public route prefix, it- * is baked into the function environment under- * {@link EVE_PUBLIC_ROUTE_PREFIX_ENV} so callback-URL minting inside the- * deployed workflow functions knows the agent's public mount.- */-export function createWorkflowFunctionEnvironment(- input: { environment?: unknown; publicRoutePrefix?: string } = {},-): Record<string, unknown> {- const nextEnvironment: Record<string, unknown> = {};-- if (isRecord(input.environment)) {- Object.assign(nextEnvironment, input.environment);- }-- const publicRoutePrefix = normalizePublicRoutePrefix(input.publicRoutePrefix);- if (publicRoutePrefix !== undefined) {- nextEnvironment[EVE_PUBLIC_ROUTE_PREFIX_ENV] = publicRoutePrefix;- }-- // Reject replay decisions made from an event log that missed a concurrent wake.- nextEnvironment.WORKFLOW_PRECONDITION_GUARD = WORKFLOW_PRECONDITION_GUARD_ENABLED;- nextEnvironment.NODE_OPTIONS = WORKFLOW_FUNCTION_NODE_OPTIONS;- return nextEnvironment;-}-function isRecord(value: unknown): value is Record<string, unknown> {return value !== null && typeof value === "object" && !Array.isArray(value);}-/**- * Creates an empty staging directory for one emitted Vercel function.- */-export async function prepareVercelFunctionDirectory(path: string): Promise<void> {- await rm(path, {- force: true,- recursive: true,- });- await mkdir(path, { recursive: true });-}--async function resolveNitroFunctionDirectory(input: {- fallbackPath: string;- sourcePath: string;-}): Promise<string> {- try {- return await realpath(input.sourcePath);- } catch {- return await realpath(input.fallbackPath);- }-}--/**- * Copies a Nitro-bundled Vercel function directory into one standalone- * workflow function directory.- *- * Nitro may emit route functions as symlinks back to `__server.func`. This- * helper dereferences the source path first, then copies concrete files so the- * generated workflow functions do not rely on symlinks.- */-export async function copyNitroFunctionDirectory(input: {- fallbackPath: string;- sourcePath: string;- targetPath: string;-}): Promise<void> {- const sourcePath = await resolveNitroFunctionDirectory({- fallbackPath: input.fallbackPath,- sourcePath: input.sourcePath,- });-- await prepareVercelFunctionDirectory(input.targetPath);- await cp(sourcePath, input.targetPath, {- dereference: true,- recursive: true,- });-}-/*** Keeps only eve-owned Vercel function output and rewrites eve route function* symlinks to a shared eve-owned server function.@@ -307,351 +224,3 @@ async function pruneNonEveVercelRoutes(function normalizeVercelOutputPath(path: string): string {return path.replaceAll("\\", "/");}--/**- * Bundles one package-owned workflow handler into a standalone Vercel function- * directory without inheriting Nitro's hosted server chunks.- */-export async function emitBundledWorkflowFunctionDirectory(input: {- bundlePath: string;- pluginPaths?: readonly string[];- publicRoutePrefix?: string;- targetPath: string;-}): Promise<void> {- await prepareVercelFunctionDirectory(input.targetPath);-- const pluginModulePaths = await emitBundledWorkflowPluginModules({- pluginPaths: input.pluginPaths ?? [],- targetPath: input.targetPath,- });- const entrypointId = join(dirname(input.bundlePath), "__eve_workflow_function_entry.js");- const outputFile = await buildSingleRolldownChunk(- `Vercel workflow function for "${input.bundlePath}"`,- {- cwd: dirname(input.bundlePath),- input: entrypointId,- platform: "node",- plugins: [- createVirtualModulePlugin({- id: entrypointId,- moduleType: "js",- source: createWorkflowFunctionEntrypointSource({- bundlePath: input.bundlePath,- pluginModulePaths,- }),- }),- ],- output: {- comments: false,- format: "cjs",- sourcemap: false,- },- },- );-- await Promise.all([- writeFile(join(input.targetPath, "index.js"), outputFile.code),- writeFile(- join(input.targetPath, "package.json"),- `${JSON.stringify({ type: "commonjs" }, null, 2)}\n`,- ),- writeFile(- join(input.targetPath, ".vc-config.json"),- `${JSON.stringify(- {- environment: createWorkflowFunctionEnvironment({- publicRoutePrefix: input.publicRoutePrefix,- }),- handler: "index.js",- launcherType: "Nodejs",- supportsResponseStreaming: true,- },- null,- 2,- )}\n`,- ),- ]);-}--async function emitBundledWorkflowPluginModules(input: {- pluginPaths: readonly string[];- targetPath: string;-}): Promise<string[]> {- return await Promise.all(- input.pluginPaths.map(async (pluginPath, index) => {- const outputFile = await buildSingleRolldownChunk(`workflow plugin for "${pluginPath}"`, {- input: pluginPath,- platform: "node",- output: {- comments: false,- format: "esm",- sourcemap: false,- },- });-- const emittedPluginFilename = `__eve_workflow_plugin_${index}.mjs`;- await writeFile(join(input.targetPath, emittedPluginFilename), outputFile.code);- return `./${emittedPluginFilename}`;- }),- );-}--function createVirtualModulePlugin(input: {- id: string;- moduleType: "js";- source: string;-}): Record<string, unknown> {- return {- name: "eve-virtual-module",- resolveId(source: string) {- return source === input.id ? input.id : undefined;- },- load(id: string) {- return id === input.id- ? {- code: input.source,- moduleType: input.moduleType,- }- : undefined;- },- };-}--function toRelativeImportPath(input: { fromDirectoryPath: string; toFilePath: string }): string {- const relativePath = relative(input.fromDirectoryPath, input.toFilePath).replaceAll("\\", "/");-- if (relativePath.startsWith(".")) {- return relativePath;- }-- return `./${relativePath}`;-}--function normalizeImportSpecifierPath(path: string): string {- return path.replaceAll("\\", "/");-}--function createWorkflowFunctionEntrypointSource(input: {- bundlePath: string;- pluginModulePaths: readonly string[];-}): string {- const normalizedPluginModulePaths = input.pluginModulePaths.map((pluginPath) =>- normalizeImportSpecifierPath(pluginPath),- );- const hasWorkflowPlugins = normalizedPluginModulePaths.length > 0;-- return [- `const { POST } = require(${JSON.stringify(`./${basename(input.bundlePath)}`)});`,- ...(hasWorkflowPlugins- ? [- `const workflowPluginModulePaths = ${JSON.stringify(normalizedPluginModulePaths)};`,- "",- "let workflowPluginPromise;",- "",- "async function loadWorkflowPlugins() {",- " if (workflowPluginPromise == null) {",- " workflowPluginPromise = (async () => {",- " for (const pluginPath of workflowPluginModulePaths) {",- " await import(pluginPath);",- " }",- " })();",- " }",- " return await workflowPluginPromise;",- "}",- ]- : []),- "",- 'const DEFAULT_WORKFLOW_REQUEST_ORIGIN = "https://workflow.invalid";',- "",- "function getHeader(headers, name) {",- " if (headers === null || headers === undefined) {",- " return undefined;",- " }",- ' if (typeof headers.get === "function") {',- " const value = headers.get(name);",- ' return typeof value === "string" && value.length > 0 ? value : undefined;',- " }",- ' if (typeof headers !== "object") {',- " return undefined;",- " }",- " const record = headers;",- " const lowerName = name.toLowerCase();",- " for (const [key, value] of Object.entries(record)) {",- " if (key.toLowerCase() !== lowerName || value === undefined) {",- " continue;",- " }",- " if (Array.isArray(value)) {",- ' return value.find((item) => typeof item === "string" && item.length > 0);',- " }",- ' return typeof value === "string" && value.length > 0 ? value : undefined;',- " }",- " return undefined;",- "}",- "",- "function createHeaders(headers) {",- " const normalized = new Headers();",- " if (headers === null || headers === undefined) {",- " return normalized;",- " }",- " if (headers instanceof Headers) {",- " return headers;",- " }",- ' if (typeof headers.forEach === "function" && typeof headers.entries === "function") {',- " for (const [key, value] of headers.entries()) {",- " normalized.append(key, value);",- " }",- " return normalized;",- " }",- " for (const [key, value] of Object.entries(headers)) {",- " if (value === undefined) {",- " continue;",- " }",- " if (Array.isArray(value)) {",- " for (const item of value) {",- " normalized.append(key, String(item));",- " }",- " continue;",- " }",- " normalized.set(key, String(value));",- " }",- " return normalized;",- "}",- "",- "function toAbsoluteWorkflowUrl(request) {",- ' const url = typeof request?.url === "string" ? request.url : "/";',- " if (/^https?:\\/\\//.test(url)) {",- " return url;",- " }",- ' const host = getHeader(request?.headers, "x-forwarded-host") ?? getHeader(request?.headers, "host");',- ' const protocolHeader = getHeader(request?.headers, "x-forwarded-proto");',- ' const protocol = protocolHeader === "http" || protocolHeader === "https" ? protocolHeader : "https";',- ' const origin = typeof host === "string" && host.length > 0 ? protocol + "://" + host : DEFAULT_WORKFLOW_REQUEST_ORIGIN;',- " return new URL(url, origin).toString();",- "}",- "",- "function normalizeWorkflowRequest(request) {",- " if (request instanceof Request) {",- " if (/^https?:\\/\\//.test(request.url)) {",- " return request;",- " }",- " return new Request(toAbsoluteWorkflowUrl(request), request);",- " }",- ' const method = typeof request?.method === "string" ? request.method : "GET";',- " const headers = createHeaders(request?.headers);",- " const init = {",- " headers,",- " method,",- " };",- ' if (method !== "GET" && method !== "HEAD") {',- ' const body = request?.body ?? (request !== null && typeof request === "object" && typeof request.pipe === "function" ? request : undefined);',- " if (body !== undefined) {",- " init.body = body;",- ' init.duplex = "half";',- " }",- " }",- " return new Request(toAbsoluteWorkflowUrl(request), init);",- "}",- "",- "module.exports = async function handleWorkflowFunctionRequest(requestContext) {",- " const request =",- ' requestContext !== null && typeof requestContext === "object" && "req" in requestContext',- " ? requestContext.req",- " : requestContext;",- ...(hasWorkflowPlugins ? [" await loadWorkflowPlugins();"] : []),- " return await POST(normalizeWorkflowRequest(request));",- "};",- "",- ].join("\n");-}--function createRoutedNitroEntrypoint(input: {- delegateImportPath: string;- workflowRoutePath: string;-}): string {- return [- `import nitroHandler from ${JSON.stringify(input.delegateImportPath)};`,- "",- "function invokeNitroHandler(request, context) {",- ' if (typeof nitroHandler === "function") {',- " return nitroHandler(request, context);",- " }",- "",- ' if (nitroHandler !== null && typeof nitroHandler === "object" && "fetch" in nitroHandler) {',- " const fetch = nitroHandler.fetch;",- ' if (typeof fetch === "function") {',- " return fetch.call(nitroHandler, request, context);",- " }",- " }",- "",- ' throw new TypeError("Expected Nitro handler to export a function or an object with fetch(request, context).");',- "}",- "",- `const workflowRoutePath = ${JSON.stringify(input.workflowRoutePath)};`,- "",- "function rewriteRequestToWorkflowRoute(request) {",- " const sourceUrl = new URL(request.url);",- " const routedUrl = new URL(workflowRoutePath, sourceUrl);",- " routedUrl.search = sourceUrl.search;",- " return new Request(routedUrl, request);",- "}",- "",- "export default {",- " fetch(request, context) {",- " return invokeNitroHandler(rewriteRequestToWorkflowRoute(request), context);",- " },",- "};",- "",- ].join("\n");-}--async function readVercelHandlerPath(functionDirectoryPath: string): Promise<string> {- try {- const parsed = JSON.parse(- await readFile(join(functionDirectoryPath, ".vc-config.json"), "utf8"),- ) as {- handler?: unknown;- };- if (typeof parsed.handler === "string" && parsed.handler.length > 0) {- return parsed.handler;- }- } catch {- // fall through- }-- return "index.mjs";-}--/**- * Rewrites one copied Nitro function directory so its handler always dispatches- * to a concrete workflow route path.- *- * Queue-triggered workflow functions do not guarantee a request URL that- * matches Nitro's original route table. This helper keeps Nitro's traced- * output intact but swaps the entrypoint with a small URL-rewriting adapter.- */-export async function retargetNitroFunctionDirectoryToWorkflowRoute(input: {- functionDirectoryPath: string;- workflowRoutePath: string;-}): Promise<void> {- const handlerPath = await readVercelHandlerPath(input.functionDirectoryPath);- const handlerFilePath = join(input.functionDirectoryPath, handlerPath);- const handlerDirectoryPath = dirname(handlerFilePath);- const handlerExtension = extname(handlerPath);- const delegatedHandlerFilePath = join(- handlerDirectoryPath,- `__eve_nitro_handler__${handlerExtension.length > 0 ? handlerExtension : ".mjs"}`,- );- const delegatedHandlerImportPath = toRelativeImportPath({- fromDirectoryPath: handlerDirectoryPath,- toFilePath: delegatedHandlerFilePath,- });-- await rename(handlerFilePath, delegatedHandlerFilePath);- await writeFile(- handlerFilePath,- createRoutedNitroEntrypoint({- delegateImportPath: delegatedHandlerImportPath,- workflowRoutePath: input.workflowRoutePath,- }),- );-}diff --git a/packages/eve/src/internal/workflow-bundle/workflow-builders.ts b/packages/eve/src/internal/workflow-bundle/workflow-builders.tsindex 2fff154f5..926ed1221 100644--- a/packages/eve/src/internal/workflow-bundle/workflow-builders.ts+++ b/packages/eve/src/internal/workflow-bundle/workflow-builders.ts@@ -4,8 +4,6 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";import { STABLE_WORKFLOW_NAMES } from "#execution/workflow-runtime.js";import { EVE_PACKAGE_NAME } from "#internal/package-name.js";-import { deriveEveWorkflowQueueTopic } from "#internal/workflow/queue-namespace.js";-import { transformWorkflowDirectives } from "./workflow-transformer.js";export type WorkflowManifest = {@@ -32,16 +30,6 @@ export type WorkflowManifest = {};};-export function createEveWorkflowQueueTrigger(agentName: string) {- return {- type: "queue/v2beta" as const,- topic: deriveEveWorkflowQueueTopic(agentName),- consumer: "default",- retryAfterSeconds: 5,- initialDelaySeconds: 0,- };-}-type PackageInfo = {dir: string;exports?: unknown;diff --git a/packages/eve/src/internal/workflow/queue-namespace.ts b/packages/eve/src/internal/workflow/queue-namespace.tsindex 8a660ec8a..23bf6b6e5 100644--- a/packages/eve/src/internal/workflow/queue-namespace.ts+++ b/packages/eve/src/internal/workflow/queue-namespace.ts@@ -19,6 +19,17 @@ export function deriveEveWorkflowQueueTopic(agentName: string): string {return `${deriveEveWorkflowQueuePrefix(agentName)}*`;}+/** Builds the Vercel queue trigger that invokes an eve agent's flow function. */+export function createEveWorkflowQueueTrigger(agentName: string) {+ return {+ type: "queue/v2beta" as const,+ topic: deriveEveWorkflowQueueTopic(agentName),+ consumer: "default",+ retryAfterSeconds: 5,+ initialDelaySeconds: 0,+ };+}+/** Installs the agent-scoped namespace used by Workflow runtime operations. */export function installEveWorkflowQueueNamespace(agentName: string): string {const namespace = deriveEveWorkflowQueueNamespace(agentName);