The Open Framework for Building Agents
fix(eve): fix scaffolding logic for adding a web channel (#835)
OwenKephart02698fd52a87
diff --git a/.changeset/fix-vercel-services-scaffold.md b/.changeset/fix-vercel-services-scaffold.mdnew file mode 100644index 000000000..5c5dc8004--- /dev/null+++ b/.changeset/fix-vercel-services-scaffold.md@@ -0,0 +1,10 @@+---+"eve": patch+---++Fix Vercel deploys for the Next.js web channel. `eve` no longer scaffolds a+`vercel.json` `experimentalServices` block, which the Vercel platform now+rejects (it requires the `services` key and a stricter schema). For Next.js the+block was also redundant — `withEve()` generates the eve service and+`/eve/v1/*` routes into the Build Output at build time — so the scaffold now+writes a minimal `vercel.json`.diff --git a/packages/eve/src/cli/commands/channels.integration.test.ts b/packages/eve/src/cli/commands/channels.integration.test.tsindex 0eb9edb9b..6cdfa2e36 100644--- a/packages/eve/src/cli/commands/channels.integration.test.ts+++ b/packages/eve/src/cli/commands/channels.integration.test.ts@@ -315,10 +315,12 @@ describe("runChannelsAddCommand", () => {const nextConfig = await readFile(join(projectRoot, "next.config.ts"), "utf8");expect(nextConfig).toContain("export default withEve(nextConfig);");// configureVercelServices stays pinned on for this command (R5): the- // scaffold writes the services config even in an unlinked directory.- await expect(readFile(join(projectRoot, "vercel.json"), "utf8")).resolves.toContain(- "experimentalServices",- );+ // scaffold writes a minimal vercel.json even in an unlinked directory.+ // withEve() owns eve service generation, so no services block is written.+ const vercelJson = JSON.parse(+ await readFile(join(projectRoot, "vercel.json"), "utf8"),+ ) as Record<string, unknown>;+ expect(vercelJson).toEqual({ $schema: "https://openapi.vercel.sh/vercel.json" });await expect(readFile(join(projectRoot, "agent/channels/web.ts"), "utf8")).rejects.toThrow();await expect(readFile(join(projectRoot, "package.json"), "utf8")).resolves.not.toContain("@vercel/connect",diff --git a/packages/eve/src/setup/scaffold/index.integration.test.ts b/packages/eve/src/setup/scaffold/index.integration.test.tsindex 0e75d6ba1..b1b62256f 100644--- a/packages/eve/src/setup/scaffold/index.integration.test.ts+++ b/packages/eve/src/setup/scaffold/index.integration.test.ts@@ -210,23 +210,13 @@ describe("ensureChannel", () => {await expect(readFile(join(projectRoot, "pnpm-workspace.yaml"), "utf8")).resolves.toBe(PNPM_WORKSPACE_CONTENT,);+ // withEve() generates the eve service + /eve/v1/* routes into+ // .vercel/output/config.json at build time, so the scaffold only writes a+ // minimal vercel.json rather than a services block the platform rejects.await expect(readFile(join(projectRoot, "vercel.json"), "utf8")).resolves.toBe(`${JSON.stringify({$schema: "https://openapi.vercel.sh/vercel.json",- experimentalServices: {- web: {- entrypoint: ".",- framework: "nextjs",- routePrefix: "/",- },- eve: {- buildCommand: "eve build",- entrypoint: ".",- framework: "eve",- routePrefix: "/_eve_internal/eve",- },- },},null,2,@@ -345,18 +335,15 @@ describe("ensureChannel", () => {);});- test("preserves existing Vercel configuration when adding Web Chat services", async () => {+ test("preserves existing Vercel configuration when adding Web Chat", async () => {const projectRoot = await createTempDir();await writeFile(join(projectRoot, "package.json"),`${JSON.stringify({ name: "demo", type: "module" }, null, 2)}\n`,"utf8",);- await writeFile(- join(projectRoot, "vercel.json"),- `${JSON.stringify({ regions: ["iad1"], experimentalServices: { worker: { entrypoint: "worker.ts" } } }, null, 2)}\n`,- "utf8",- );+ const existingVercelJson = `${JSON.stringify({ regions: ["iad1"], rewrites: [] }, null, 2)}\n`;+ await writeFile(join(projectRoot, "vercel.json"), existingVercelJson, "utf8");await ensureChannel({projectRoot,@@ -364,16 +351,12 @@ describe("ensureChannel", () => {webPackageVersions: TEST_WEB_PACKAGE_VERSIONS,});- await expect(- readFile(join(projectRoot, "vercel.json"), "utf8").then((value) => JSON.parse(value)),- ).resolves.toMatchObject({- regions: ["iad1"],- experimentalServices: {- worker: { entrypoint: "worker.ts" },- web: { framework: "nextjs" },- eve: { framework: "eve" },- },- });+ // withEve() owns eve service generation, so the scaffold leaves an existing+ // vercel.json completely untouched — no injected services block, no $schema+ // rewrite, no reformatting of a file the user manages.+ await expect(readFile(join(projectRoot, "vercel.json"), "utf8")).resolves.toBe(+ existingVercelJson,+ );});test("scaffolds Web Chat without Vercel Services for preview-only targets", async () => {diff --git a/packages/eve/src/setup/scaffold/update/channels.ts b/packages/eve/src/setup/scaffold/update/channels.tsindex 32decc4c6..914255b18 100644--- a/packages/eve/src/setup/scaffold/update/channels.ts+++ b/packages/eve/src/setup/scaffold/update/channels.ts@@ -1,4 +1,4 @@-import { readFile, readdir, writeFile } from "node:fs/promises";+import { readFile, readdir } from "node:fs/promises";import { basename, join, resolve } from "node:path";import type { PackageManagerKind } from "../../package-manager.js";@@ -59,19 +59,6 @@ const SUPPORTED_NEXT_CONFIG_PATHS = [const WEB_COMPETING_NEXT_CONFIG_PATHS = SUPPORTED_NEXT_CONFIG_PATHS.filter((path) => path !== WEB_NEXT_CONFIG_PATH,);-const WEB_DEFAULT_VERCEL_SERVICES = {- web: {- entrypoint: ".",- framework: "nextjs",- routePrefix: "/",- },- eve: {- buildCommand: "eve build",- entrypoint: ".",- framework: "eve",- routePrefix: "/_eve_internal/eve",- },-} satisfies Record<string, Record<string, string>>;declare const slackConnectorSlugBrand: unique symbol;@@ -391,58 +378,30 @@ function renderWebAppTemplate(content: string, appName: string): string {.replaceAll("__EVE_INIT_WITH_EVE_OPTIONS__", "");}-function withWebVercelServices(source: string): string {- const parsed: unknown = JSON.parse(source);- if (!isJsonObject(parsed)) {- throw new Error(`${WEB_VERCEL_JSON_PATH} must contain a JSON object.`);- }-- const existingServices = parsed.experimentalServices;- if (existingServices !== undefined && !isJsonObject(existingServices)) {- throw new Error(`${WEB_VERCEL_JSON_PATH} experimentalServices must contain a JSON object.`);- }-- const next = {- ...parsed,- $schema: typeof parsed.$schema === "string" ? parsed.$schema : WEB_VERCEL_JSON_SCHEMA,- experimentalServices: {- ...existingServices,- web: existingServices?.web ?? WEB_DEFAULT_VERCEL_SERVICES.web,- eve: existingServices?.eve ?? WEB_DEFAULT_VERCEL_SERVICES.eve,- },- };-- if (JSON.stringify(parsed) === JSON.stringify(next)) {- return source;- }-- return `${JSON.stringify(next, null, 2)}\n`;-}--async function ensureWebVercelServices(filePath: string): Promise<"skipped" | "written"> {- if (!(await pathExists(filePath))) {- await writeTextFile(- filePath,- `${JSON.stringify(- {- $schema: WEB_VERCEL_JSON_SCHEMA,- experimentalServices: WEB_DEFAULT_VERCEL_SERVICES,- },- null,- 2,- )}\n`,- { force: true },- );- return "written";- }-- const current = await readFile(filePath, "utf8");- const next = withWebVercelServices(current);- if (next === current) {+/**+ * Ensure the Next.js web channel has a minimal `vercel.json`.+ *+ * The eve service and its `/eve/v1/*` routes are generated by `withEve()` into+ * `.vercel/output/config.json` at build time — which reads `vercel.json`'s+ * `services`, not a scaffolded block — so the scaffold intentionally writes no+ * services entry. Emitting one only risks a `services` schema that today's+ * Vercel platform rejects before the build ever runs.+ *+ * When a `vercel.json` already exists it is left untouched: `withEve()` owns the+ * eve service, so the scaffold has nothing to add to a file the user manages.+ */+async function ensureWebVercelJson(filePath: string): Promise<"skipped" | "written"> {+ if (await pathExists(filePath)) {return "skipped";}- await writeFile(filePath, next, "utf8");+ await writeTextFile(+ filePath,+ `${JSON.stringify({ $schema: WEB_VERCEL_JSON_SCHEMA }, null, 2)}\n`,+ {+ force: true,+ },+ );return "written";}@@ -535,7 +494,7 @@ async function ensureWebChannel(if (configureVercelServices) {const vercelJsonPath = join(options.projectRoot, WEB_VERCEL_JSON_PATH);- const vercelJsonResult = await ensureWebVercelServices(vercelJsonPath);+ const vercelJsonResult = await ensureWebVercelJson(vercelJsonPath);if (vercelJsonResult === "written") {filesWritten.push(vercelJsonPath);} else {