Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): deploy declarative agent workspaces (#1926)

OwenKephart6e630b407bb2
diff --git a/.changeset/declarative-agent-collections.md b/.changeset/declarative-agent-collections.md
new file mode 100644
index 000000000..a6f2f157f
--- /dev/null
+++ b/.changeset/declarative-agent-collections.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Deploy conventional `agents/<name>/agent/` workspaces as inferred peer Vercel services at `/<name>/eve/v1/*`, with no generated `vercel.json` step.
diff --git a/docs/guides/deployment/vercel.mdx b/docs/guides/deployment/vercel.mdx
index c95871bee..df2ac98d4 100644
--- a/docs/guides/deployment/vercel.mdx
+++ b/docs/guides/deployment/vercel.mdx
@@ -51,6 +51,22 @@ See [Sandbox](../../sandbox) for resource limits, network policy, and lifecycle
## Deploy the agent
+A project containing only several independently addressed root agents can use eve's hostless workspace layout:
+
+```text
+my-project/
+├── package.json
+└── agents/
+ ├── support/
+ │ └── agent/
+ └── research/
+ └── agent/
+```
+
+An `agents/` directory marks the project as a workspace. eve validates and discovers only direct `agents/<name>/agent/` children. Their directory names become their public identities, exposed at `/<name>/eve/v1/*`. Run `eve dev`, `eve info`, and `eve eval` from an individual child directory; run project-level build, link, and deploy commands from the workspace root. The workspace root is the project package; child agent directories do not define packages or build scripts.
+
+With no authored `vercel.json#services`, `eve build` derives the complete Vercel Services graph on every build. If `vercel.json` declares `services`, that authored graph is authoritative instead; use `vercel build` to build and validate the complete project. This supports heterogeneous projects with frontends, private APIs, bindings, and other non-eve services without generated configuration files.
+
Deploy the linked project to production:
```bash
@@ -77,8 +93,8 @@ Vercel uses the generated output to configure these services:
Check the health route and connect the development TUI:
```bash
-curl https://your_agent.vercel.app/eve/v1/health
-eve dev https://your_agent.vercel.app
+curl https://your_agent.vercel.app/support/eve/v1/health
+eve dev https://your_agent.vercel.app/support
```
Set `VERCEL_AUTOMATION_BYPASS_SECRET` locally before connecting if the deployment uses Deployment Protection.
diff --git a/packages/eve/src/cli/commands/build.ts b/packages/eve/src/cli/commands/build.ts
index ead5dff85..a590d9cd1 100644
--- a/packages/eve/src/cli/commands/build.ts
+++ b/packages/eve/src/cli/commands/build.ts
@@ -1,10 +1,11 @@
import { resolve } from "node:path";
import type { Command } from "#compiled/commander/index.js";
-import { applicationCommand, type CliApplicationContext } from "#cli/application-command.js";
+import type { CliApplicationContext } from "#cli/application-command.js";
import { resolveInternalVercelServiceOutput } from "#cli/vercel-service-output.js";
import { createCliTheme, renderCliTaggedLine } from "#cli/ui/output.js";
import type { ApplicationBuildOptions } from "#internal/nitro/host/types.js";
+import { resolveEveProjectContext } from "#internal/project-context.js";
import {
EVE_PUBLIC_ROUTE_PREFIX_ENV,
normalizePublicRoutePrefix,
@@ -30,7 +31,12 @@ export function registerBuildCommand(input: {
}): void {
const theme = createCliTheme();
- applicationCommand(input.program.command("build"), input.applicationContext)
+ input.program
+ .command("build")
+ .hook("preAction", async () => {
+ const context = await resolveEveProjectContext(input.applicationContext.root);
+ if (context.kind !== "workspace") await input.applicationContext.resolve();
+ })
.description("Build the current eve application.")
.option("--profile <path>", "Write best-effort timing and output-size profile JSON to a file")
.option(
@@ -42,6 +48,25 @@ export function registerBuildCommand(input: {
await loadDevelopmentEnvironmentFiles(input.applicationContext.root);
+ const projectContext = await resolveEveProjectContext(input.applicationContext.root);
+ if (projectContext.kind === "workspace") {
+ if (options.profile !== undefined || options.skipSandboxPrewarm === true) {
+ throw new Error(
+ "Workspace builds do not support --profile or --skip-sandbox-prewarm. Run those options from an individual agent directory.",
+ );
+ }
+ const { buildAgentWorkspace } = await import("#internal/vercel/build-agent-workspace.js");
+ const outputDir = await buildAgentWorkspace(projectContext.workspace);
+ input.logger.log(
+ renderCliTaggedLine(theme, {
+ message: `built output at ${outputDir}`,
+ tag: "build",
+ tone: "success",
+ }),
+ );
+ return;
+ }
+
const buildHost =
input.buildHost ?? (await import("#internal/nitro/host.js")).buildApplication;
const profileOutputPath =
diff --git a/packages/eve/src/cli/commands/deploy.integration.test.ts b/packages/eve/src/cli/commands/deploy.integration.test.ts
index c00c12571..8f37b83cd 100644
--- a/packages/eve/src/cli/commands/deploy.integration.test.ts
+++ b/packages/eve/src/cli/commands/deploy.integration.test.ts
@@ -8,6 +8,7 @@ import { createFakePrompter } from "#internal/testing/fake-prompter.js";
import { packageInstallResult } from "#internal/testing/package-process.js";
import type { DeployProjectDeps } from "#setup/boxes/deploy-project.js";
import type { DeploymentInfo } from "#setup/project-resolution.js";
+import { isEveProject } from "#setup/scaffold/index.js";
import { runDeployCommand, type DeployCliLogger } from "./deploy.js";
@@ -24,6 +25,13 @@ class TestLogger implements DeployCliLogger {
}
}
+async function createWorkspaceProject(): Promise<string> {
+ const projectRoot = await mkdtemp(join(tmpdir(), "eve-deploy-workspace-"));
+ await mkdir(join(projectRoot, "agents/support/agent"), { recursive: true });
+ await writeFile(join(projectRoot, "package.json"), JSON.stringify({ private: true }), "utf8");
+ return projectRoot;
+}
+
async function createAgentProject(): Promise<string> {
const projectRoot = await mkdtemp(join(tmpdir(), "eve-deploy-command-"));
await mkdir(join(projectRoot, "agent"), { recursive: true });
@@ -63,6 +71,34 @@ afterEach(() => {
});
describe("runDeployCommand", () => {
+ test("refuses a directory without an eve agent", async () => {
+ const projectRoot = await mkdtemp(join(tmpdir(), "eve-deploy-empty-"));
+ const logger = new TestLogger();
+
+ await runDeployCommand(logger, projectRoot, {
+ isEveProject,
+ hasInteractiveTerminal: () => true,
+ });
+
+ expect(logger.errors).toEqual([
+ "No eve agent in this directory. Run `eve init <name>`, then run this command from inside the new project.",
+ ]);
+ expect(process.exitCode).toBe(1);
+ });
+
+ test("refuses to deploy one member of a workspace", async () => {
+ const projectRoot = await createWorkspaceProject();
+ const logger = new TestLogger();
+
+ await runDeployCommand(logger, join(projectRoot, "agents/support"), {
+ isEveProject,
+ hasInteractiveTerminal: () => true,
+ });
+
+ expect(logger.errors[0]).toContain("workspace root");
+ expect(process.exitCode).toBe(1);
+ });
+
test("points an unlinked non-interactive run at eve link", async () => {
const projectRoot = await createAgentProject();
const logger = new TestLogger();
diff --git a/packages/eve/src/cli/commands/deploy.ts b/packages/eve/src/cli/commands/deploy.ts
index 9fb0c3cff..f74af514d 100644
--- a/packages/eve/src/cli/commands/deploy.ts
+++ b/packages/eve/src/cli/commands/deploy.ts
@@ -1,7 +1,8 @@
+import { isEveProject } from "#setup/scaffold/index.js";
import { runDeployFlow, type DeployFlowDeps } from "#setup/flows/deploy.js";
import { createPrompter, type Prompter } from "#setup/prompter.js";
-import { hasInteractiveTerminal } from "./preconditions.js";
+import { hasInteractiveTerminal, validateWorkspaceProjectCommand } from "./preconditions.js";
import {
isNonInteractiveProjectCommand,
runNonInteractiveLink,
@@ -16,12 +17,14 @@ export interface DeployCliLogger {
export interface DeployCommandDependencies {
createPrompter?: () => Prompter;
hasInteractiveTerminal(): boolean;
+ isEveProject?: typeof isEveProject;
/** Test seam into the flow's detection and box effects. */
flowDeps?: Partial<DeployFlowDeps>;
}
const defaultDependencies: DeployCommandDependencies = {
hasInteractiveTerminal,
+ isEveProject,
};
/**
@@ -37,6 +40,17 @@ export async function runDeployCommand(
dependencies: DeployCommandDependencies = defaultDependencies,
options: VercelProjectCliOptions & { yes?: boolean } = {},
): Promise<void> {
+ if (
+ !(await validateWorkspaceProjectCommand({
+ appRoot,
+ isEveProject: dependencies.isEveProject,
+ logger,
+ workspaceMemberMessage: (workspace) =>
+ `This agent belongs to the workspace at ${workspace.root}. Run \`eve deploy\` from the workspace root to deploy every peer agent together.`,
+ }))
+ ) {
+ return;
+ }
if (isNonInteractiveProjectCommand(options)) {
if (options.yes !== true) {
logger.error(
@@ -49,7 +63,6 @@ export async function runDeployCommand(
if (!(await runNonInteractiveLink({ logger, appRoot, options }))) return;
}
}
-
const prompter = dependencies.createPrompter?.() ?? createPrompter();
prompter.intro("Deploy your eve agent to Vercel");
try {
diff --git a/packages/eve/src/cli/commands/link.integration.test.ts b/packages/eve/src/cli/commands/link.integration.test.ts
index 34d7816a6..fd159c96d 100644
--- a/packages/eve/src/cli/commands/link.integration.test.ts
+++ b/packages/eve/src/cli/commands/link.integration.test.ts
@@ -9,6 +9,7 @@ import type { ApplyAiGatewayCredentialDeps } from "#setup/boxes/apply-ai-gateway
import type { LinkProjectDeps } from "#setup/boxes/link-project.js";
import type { ResolveProvisioningDeps } from "#setup/boxes/resolve-provisioning.js";
import type { LinkFlowDeps } from "#setup/flows/link.js";
+import { isEveProject } from "#setup/scaffold/index.js";
import { runLinkCommand, type LinkCliLogger } from "./link.js";
@@ -25,6 +26,13 @@ class TestLogger implements LinkCliLogger {
}
}
+async function createWorkspaceProject(): Promise<string> {
+ const projectRoot = await mkdtemp(join(tmpdir(), "eve-link-workspace-"));
+ await mkdir(join(projectRoot, "agents/support/agent"), { recursive: true });
+ await writeFile(join(projectRoot, "package.json"), JSON.stringify({ private: true }), "utf8");
+ return projectRoot;
+}
+
async function createAgentProject(): Promise<string> {
const projectRoot = await mkdtemp(join(tmpdir(), "eve-link-command-"));
await mkdir(join(projectRoot, "agent"), { recursive: true });
@@ -107,6 +115,34 @@ afterEach(() => {
});
describe("runLinkCommand", () => {
+ test("refuses a directory without an eve agent", async () => {
+ const projectRoot = await mkdtemp(join(tmpdir(), "eve-link-empty-"));
+ const logger = new TestLogger();
+
+ await runLinkCommand(logger, projectRoot, {
+ isEveProject,
+ hasInteractiveTerminal: () => true,
+ });
+
+ expect(logger.errors).toEqual([
+ "No eve agent in this directory. Run `eve init <name>`, then run this command from inside the new project.",
+ ]);
+ expect(process.exitCode).toBe(1);
+ });
+
+ test("refuses to link one member of a workspace", async () => {
+ const projectRoot = await createWorkspaceProject();
+ const logger = new TestLogger();
+
+ await runLinkCommand(logger, join(projectRoot, "agents/support"), {
+ isEveProject,
+ hasInteractiveTerminal: () => true,
+ });
+
+ expect(logger.errors[0]).toContain("workspace root");
+ expect(process.exitCode).toBe(1);
+ });
+
test("refuses without an interactive terminal", async () => {
const projectRoot = await createAgentProject();
const logger = new TestLogger();
diff --git a/packages/eve/src/cli/commands/link.ts b/packages/eve/src/cli/commands/link.ts
index 30db88a83..36cde7583 100644
--- a/packages/eve/src/cli/commands/link.ts
+++ b/packages/eve/src/cli/commands/link.ts
@@ -1,7 +1,8 @@
+import { isEveProject } from "#setup/scaffold/index.js";
import { runLinkFlow, type LinkFlowDeps } from "#setup/flows/link.js";
import { createPrompter, type Prompter } from "#setup/prompter.js";
-import { hasInteractiveTerminal } from "./preconditions.js";
+import { hasInteractiveTerminal, validateWorkspaceProjectCommand } from "./preconditions.js";
import {
isNonInteractiveProjectCommand,
runNonInteractiveLink,
@@ -16,12 +17,14 @@ export interface LinkCliLogger {
export interface LinkCommandDependencies {
createPrompter?: () => Prompter;
hasInteractiveTerminal(): boolean;
+ isEveProject?: typeof isEveProject;
/** Test seam into the flow's detection and box effects. */
flowDeps?: Partial<LinkFlowDeps>;
}
const defaultDependencies: LinkCommandDependencies = {
hasInteractiveTerminal,
+ isEveProject,
};
/**
@@ -38,6 +41,17 @@ export async function runLinkCommand(
dependencies: LinkCommandDependencies = defaultDependencies,
options: VercelProjectCliOptions = {},
): Promise<void> {
+ if (
+ !(await validateWorkspaceProjectCommand({
+ appRoot,
+ isEveProject: dependencies.isEveProject,
+ logger,
+ workspaceMemberMessage: (workspace) =>
+ `This agent belongs to the workspace at ${workspace.root}. Run \`eve link\` from the workspace root.`,
+ }))
+ ) {
+ return;
+ }
if (isNonInteractiveProjectCommand(options)) {
await runNonInteractiveLink({ logger, appRoot, options });
return;
diff --git a/packages/eve/src/cli/commands/preconditions.ts b/packages/eve/src/cli/commands/preconditions.ts
index ac9f2eae8..9a1c7cb2c 100644
--- a/packages/eve/src/cli/commands/preconditions.ts
+++ b/packages/eve/src/cli/commands/preconditions.ts
@@ -1,3 +1,7 @@
+import type { EveProjectContext } from "#internal/project-context.js";
+import { resolveEveProjectContext } from "#internal/project-context.js";
+import { isEveProject } from "#setup/scaffold/index.js";
+
/**
* Refusal shown by agent-scoped commands (`eve link`, `eve deploy`,
* `eve channels …`) when the working directory holds no eve agent.
@@ -5,6 +9,36 @@
export const NOT_AN_AGENT_MESSAGE =
"No eve agent in this directory. Run `eve init <name>`, then run this command from inside the new project.";
+interface ProjectCommandLogger {
+ error(message: string): void;
+}
+
+/** Validate that a Vercel project command targets a workspace root or an eve app. */
+export async function validateWorkspaceProjectCommand(input: {
+ readonly appRoot: string;
+ readonly isEveProject?: typeof isEveProject;
+ readonly logger: ProjectCommandLogger;
+ readonly workspaceMemberMessage: (
+ workspace: Extract<EveProjectContext, { kind: "workspace" }>["workspace"],
+ ) => string;
+}): Promise<boolean> {
+ const projectContext = await resolveEveProjectContext(input.appRoot);
+ if (projectContext.kind === "workspace-member") {
+ input.logger.error(input.workspaceMemberMessage(projectContext.workspace));
+ process.exitCode = 1;
+ return false;
+ }
+ if (
+ projectContext.kind === "standalone" &&
+ !(await (input.isEveProject ?? isEveProject)(input.appRoot))
+ ) {
+ input.logger.error(NOT_AN_AGENT_MESSAGE);
+ process.exitCode = 1;
+ return false;
+ }
+ return true;
+}
+
/** True when stdin and stdout are both TTYs — the default interactivity gate. */
export function hasInteractiveTerminal(): boolean {
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
diff --git a/packages/eve/src/internal/agent-workspace.ts b/packages/eve/src/internal/agent-workspace.ts
index aa4b1caed..91d6548f4 100644
--- a/packages/eve/src/internal/agent-workspace.ts
+++ b/packages/eve/src/internal/agent-workspace.ts
@@ -61,7 +61,8 @@ export async function resolveAgentWorkspace(
/** Load a workspace that the caller has already identified as workspace-shaped. */
export async function loadAgentWorkspace(root: string): Promise<AgentWorkspace> {
const workspace = await resolveAgentWorkspace(root);
- if (workspace === undefined)
+ if (workspace === undefined) {
throw new Error("An eve agent workspace requires an agents/ directory.");
+ }
return workspace;
}
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.ts
index bf60c3c28..858aa1abf 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
@@ -440,6 +440,7 @@ describe("buildApplication", () => {
{
buildDir: expect.stringContaining(join(appRoot, ".eve", "builds")),
outputDir: expect.stringContaining(join(appRoot, ".eve", "builds")),
+ publicRoutePrefix: "/_eve_internal/eve",
},
);
const nestedFunctionStats = await lstat(
diff --git a/packages/eve/src/internal/nitro/host/build-application.ts b/packages/eve/src/internal/nitro/host/build-application.ts
index 2c51e8718..afdeca0cd 100644
--- a/packages/eve/src/internal/nitro/host/build-application.ts
+++ b/packages/eve/src/internal/nitro/host/build-application.ts
@@ -40,7 +40,7 @@ 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";
-import { resolveCoDeployedEveServicePrefix } from "#internal/vercel/vercel-service-config-operations.js";
+import { resolveEveServicePrefixByRoot } from "#internal/vercel/vercel-service-config-operations.js";
import { parseVercelServicesConfig } from "#internal/vercel/vercel-services-config.js";
import { createDiskRuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
import { isObject } from "#shared/guards.js";
@@ -100,7 +100,7 @@ async function writeOptionalApplicationBuildProfile(input: {
}
}
-async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(
+async function resolveEveServicePrefixForVercelFunctionOutput(
appRoot: string,
agentRoot: string,
): Promise<string | undefined> {
@@ -114,7 +114,7 @@ async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(
JSON.parse(await readFile(configPath, "utf8")) as unknown,
configPath,
);
- const servicePrefix = resolveCoDeployedEveServicePrefix({
+ const servicePrefix = resolveEveServicePrefixByRoot({
appRoots,
configRoot: await resolveVercelOutputConfigRoot(outputDirectory),
config,
@@ -146,7 +146,7 @@ async function resolveCoDeployedEveServicePrefixForVercelFunctionOutput(
? currentDir
: await resolveVercelOutputConfigRoot(dirname(configPath));
- const servicePrefix = resolveCoDeployedEveServicePrefix({
+ const servicePrefix = resolveEveServicePrefixByRoot({
appRoots,
configRoot,
config,
@@ -288,17 +288,27 @@ async function buildApplicationInWorkspace(
const servicePrefix = isVercelBuild
? await measureBuildPhase(profiler, "vercel.service-prefix.resolve", () =>
- resolveCoDeployedEveServicePrefixForVercelFunctionOutput(
+ resolveEveServicePrefixForVercelFunctionOutput(
preparedHost.appRoot,
preparedHost.compileResult.project.agentRoot,
),
)
: undefined;
+ if (
+ options.publicRoutePrefix !== undefined &&
+ servicePrefix !== undefined &&
+ options.publicRoutePrefix !== servicePrefix
+ ) {
+ throw new Error(
+ `EVE_PUBLIC_ROUTE_PREFIX ${JSON.stringify(options.publicRoutePrefix)} conflicts with the configured Vercel service prefix ${JSON.stringify(servicePrefix)}.`,
+ );
+ }
+ const publicRoutePrefix = options.publicRoutePrefix ?? servicePrefix;
const nitro = await measureBuildPhase(profiler, "nitro.create", () =>
createProductionApplicationNitro(preparedHost, {
buildDir: workspace.nitro.buildDir,
outputDir: workspace.publication.output.stagedDir,
- publicRoutePrefix: options.publicRoutePrefix,
+ publicRoutePrefix,
}),
);
@@ -341,7 +351,7 @@ async function buildApplicationInWorkspace(
if (vercelServiceOutput !== undefined) {
await measureBuildPhase(profiler, "vercel.service-crons.normalize", () =>
normalizeVercelServiceCrons({
- publicRoutePrefix: options.publicRoutePrefix,
+ publicRoutePrefix,
serviceOutputDirectory: workspace.publication.output.stagedDir,
}),
);
diff --git a/packages/eve/src/internal/vercel/build-agent-workspace.integration.test.ts b/packages/eve/src/internal/vercel/build-agent-workspace.integration.test.ts
new file mode 100644
index 000000000..4bb1c56fb
--- /dev/null
+++ b/packages/eve/src/internal/vercel/build-agent-workspace.integration.test.ts
@@ -0,0 +1,88 @@
+import { access, mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+import { describe, expect, it, vi } from "vitest";
+
+vi.mock("#shared/resolve-eve-binary.js", () => ({
+ resolveEveBinaryPath: (root: string) => join(root, "node_modules", "eve", "bin", "eve.js"),
+}));
+
+import { loadAgentWorkspace } from "#internal/agent-workspace.js";
+import { buildAgentWorkspace } from "#internal/vercel/build-agent-workspace.js";
+
+async function createWorkspace(): Promise<string> {
+ const root = await mkdtemp(join(tmpdir(), "eve-workspace-build-"));
+ await writeFile(
+ join(root, "package.json"),
+ JSON.stringify({ packageManager: "[email protected]", private: true }),
+ );
+ await Promise.all([
+ mkdir(join(root, "agents", "support", "agent"), { recursive: true }),
+ mkdir(join(root, "agents", "research", "agent"), { recursive: true }),
+ ]);
+ return root;
+}
+
+describe("buildAgentWorkspace", () => {
+ it("emits peer services and canonical public routes", async () => {
+ const root = await createWorkspace();
+ const workspace = await loadAgentWorkspace(root);
+ expect(workspace).toBeDefined();
+
+ const output = await buildAgentWorkspace(workspace);
+ const config = JSON.parse(await readFile(join(output, "config.json"), "utf8"));
+
+ expect(config.routes).toEqual([
+ {
+ destination: { service: "eve-research", type: "service" },
+ src: "^/research/eve/v1/(.*)$",
+ },
+ {
+ destination: { service: "eve-support", type: "service" },
+ src: "^/support/eve/v1/(.*)$",
+ },
+ ]);
+ await expect(
+ access(join(root, ".eve", "vercel-services", "eve-support")),
+ ).resolves.toBeUndefined();
+
+ expect(config.services["eve-support"]).toEqual({
+ buildCommand:
+ "cd '../../../agents/support' && export EVE_INTERNAL_BUILD_OUTPUT_DIRECTORY='../../.eve/vercel-services/eve-support/.vercel/output' && export EVE_INTERNAL_HOST_BUILD_OUTPUT_DIRECTORY='../../.vercel/output' && export EVE_PUBLIC_ROUTE_PREFIX='/support' && node 'node_modules/eve/bin/eve.js' build",
+ framework: "eve",
+ root: ".eve/vercel-services/eve-support",
+ routePrefix: "/support",
+ routes: [
+ {
+ src: "^/support/eve/v1/(.*)$",
+ transforms: [{ args: "/eve/v1/$1", op: "set", type: "request.path" }],
+ },
+ ],
+ });
+ });
+
+ it("keeps digit-bearing public names while encoding the generated service name", async () => {
+ const root = await createWorkspace();
+ await mkdir(join(root, "agents", "support2", "agent"), { recursive: true });
+ const workspace = await loadAgentWorkspace(root);
+ const output = await buildAgentWorkspace(workspace);
+ const config = JSON.parse(await readFile(join(output, "config.json"), "utf8"));
+ const supportServiceName = Object.keys(config.services).find((name) =>
+ name.startsWith("eve-support-"),
+ );
+
+ expect(supportServiceName).toMatch(/^eve-support-[a-z]+$/);
+ expect(config.routes).toContainEqual({
+ destination: { service: supportServiceName, type: "service" },
+ src: "^/support2/eve/v1/(.*)$",
+ });
+ });
+
+ it("refuses to assemble an authored graph", async () => {
+ const root = await createWorkspace();
+ await writeFile(join(root, "vercel.json"), JSON.stringify({ services: {} }));
+ const workspace = await loadAgentWorkspace(root);
+ await expect(buildAgentWorkspace(workspace)).rejects.toThrow(/Run `vercel build`/);
+ });
+});
diff --git a/packages/eve/src/internal/vercel/build-agent-workspace.ts b/packages/eve/src/internal/vercel/build-agent-workspace.ts
new file mode 100644
index 000000000..df8208d60
--- /dev/null
+++ b/packages/eve/src/internal/vercel/build-agent-workspace.ts
@@ -0,0 +1,60 @@
+import { mkdir, rm, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+
+import type { AgentWorkspace } from "#internal/agent-workspace.js";
+import { assembleEveVercelServices } from "#internal/vercel/assemble-eve-services.js";
+import { quoteVercelShellArgument, toVercelRelativePath } from "#internal/vercel/build-command.js";
+import { readVercelJsonFile } from "#internal/vercel/vercel-services-config.js";
+import { resolveEveBinaryPath } from "#shared/resolve-eve-binary.js";
+
+const VERCEL_BUILD_OUTPUT_VERSION = 3;
+
+/** Emit the inferred Vercel Services project for a strict hostless workspace. */
+export async function buildAgentWorkspace(workspace: AgentWorkspace): Promise<string> {
+ const config = await readVercelJsonFile(join(workspace.root, "vercel.json"));
+ if (
+ config.services !== undefined ||
+ config.experimentalServices !== undefined ||
+ config.experimentalServicesV2 !== undefined
+ ) {
+ throw new Error(
+ "This project defines its Vercel service graph in vercel.json. Run `vercel build` to build the complete project, or run `eve build` from an individual agent directory.",
+ );
+ }
+
+ const agents = workspace.members.map((member) => ({
+ agent: {
+ appRoot: member.appRoot,
+ buildCommand: `node ${quoteVercelShellArgument(
+ toVercelRelativePath(member.appRoot, resolveEveBinaryPath(member.appRoot)),
+ )} build`,
+ name: member.name,
+ publicRoutePrefix: `/${member.name}`,
+ },
+ target: {
+ hostOutputDirectory: join(workspace.root, ".vercel", "output"),
+ projectRoot: workspace.root,
+ },
+ }));
+ const assembled = assembleEveVercelServices({ agents });
+
+ const outputDirectory = join(workspace.root, ".vercel", "output");
+ await rm(outputDirectory, { force: true, recursive: true });
+ await mkdir(outputDirectory, { recursive: true });
+ await Promise.all(
+ assembled.rootDirectories.map((rootDirectory) => mkdir(rootDirectory, { recursive: true })),
+ );
+ await writeFile(
+ join(outputDirectory, "config.json"),
+ `${JSON.stringify(
+ {
+ version: VERCEL_BUILD_OUTPUT_VERSION,
+ routes: assembled.routes,
+ services: assembled.services,
+ },
+ null,
+ 2,
+ )}\n`,
+ );
+ return outputDirectory;
+}
diff --git a/packages/eve/src/internal/vercel/eve-service-contribution.test.ts b/packages/eve/src/internal/vercel/eve-service-contribution.test.ts
index 920fe6ab7..c8355cd8d 100644
--- a/packages/eve/src/internal/vercel/eve-service-contribution.test.ts
+++ b/packages/eve/src/internal/vercel/eve-service-contribution.test.ts
@@ -1,44 +1,28 @@
import { describe, expect, it } from "vitest";
import { createEveServiceName } from "#internal/vercel/eve-service-contribution.js";
-import { resolveCoDeployedEveServicePrefix } from "#internal/vercel/vercel-service-config-operations.js";
+import { resolveEveServicePrefixByRoot } from "#internal/vercel/vercel-service-config-operations.js";
import { isValidVercelServiceName } from "#internal/vercel/vercel-service-name.js";
-describe("resolveCoDeployedEveServicePrefix", () => {
- it("resolves the matching eve service only when it is co-deployed with a host", () => {
+describe("resolveEveServicePrefixByRoot", () => {
+ it("resolves stable and legacy services by application root", () => {
expect(
- resolveCoDeployedEveServicePrefix({
+ resolveEveServicePrefixByRoot({
appRoots: ["/project/agents/support"],
config: {
services: {
eve: { framework: "eve", root: "agents/support", routePrefix: "/support" },
- web: { framework: "nextjs", root: "." },
},
},
configRoot: "/project",
}),
).toBe("/support");
expect(
- resolveCoDeployedEveServicePrefix({
- appRoots: ["/project/agents/support"],
- config: {
- services: {
- eve: { framework: "eve", root: "agents/support", routePrefix: "/support" },
- },
- },
- configRoot: "/project",
- }),
- ).toBeUndefined();
- });
-
- it("supports legacy service collections", () => {
- expect(
- resolveCoDeployedEveServicePrefix({
+ resolveEveServicePrefixByRoot({
appRoots: ["/project/agent"],
config: {
experimentalServices: {
eve: { entrypoint: "agent", framework: "eve", mount: { path: "/agent" } },
- web: { framework: "nextjs" },
},
},
configRoot: "/project",
@@ -48,7 +32,7 @@ describe("resolveCoDeployedEveServicePrefix", () => {
it("ignores malformed legacy service collections", () => {
expect(
- resolveCoDeployedEveServicePrefix({
+ resolveEveServicePrefixByRoot({
appRoots: ["/project/agent"],
config: {
experimentalServices: null,
diff --git a/packages/eve/src/internal/vercel/vercel-service-config-operations.ts b/packages/eve/src/internal/vercel/vercel-service-config-operations.ts
index ddf5d01fb..88505bf33 100644
--- a/packages/eve/src/internal/vercel/vercel-service-config-operations.ts
+++ b/packages/eve/src/internal/vercel/vercel-service-config-operations.ts
@@ -62,21 +62,23 @@ function resolveServiceRoot(configRoot: string, service: VercelServiceConfig): s
return typeof root === "string" && root.trim().length > 0 ? resolve(configRoot, root) : undefined;
}
-/** Resolve the mounted prefix for an eve service co-deployed with a host service. */
-export function resolveCoDeployedEveServicePrefix(input: {
+function resolveServiceCollection(
+ config: VercelServicesConfig,
+): readonly VercelServiceConfig[] | undefined {
+ return (
+ parseLegacyServiceCollection(config.experimentalServices) ??
+ parseLegacyServiceCollection(config.experimentalServicesV2) ??
+ createServiceConfigList(config.services)
+ );
+}
+
+/** Resolve the mounted prefix for the eve service matching an application root. */
+export function resolveEveServicePrefixByRoot(input: {
readonly appRoots: readonly string[];
readonly config: VercelServicesConfig;
readonly configRoot: string;
}): string | undefined {
- const services =
- parseLegacyServiceCollection(input.config.experimentalServices) ??
- parseLegacyServiceCollection(input.config.experimentalServicesV2) ??
- createServiceConfigList(input.config.services);
- if (services === undefined || !services.some((service) => service.framework !== "eve")) {
- return undefined;
- }
-
- for (const service of services) {
+ for (const service of resolveServiceCollection(input.config) ?? []) {
const prefix = resolveServicePrefix(service);
if (
service.framework === "eve" &&
diff --git a/packages/eve/test/scenarios/hostless-agent-workspace.scenario.test.ts b/packages/eve/test/scenarios/hostless-agent-workspace.scenario.test.ts
new file mode 100644
index 000000000..4abcbd479
--- /dev/null
+++ b/packages/eve/test/scenarios/hostless-agent-workspace.scenario.test.ts
@@ -0,0 +1,66 @@
+import { access, readFile } from "node:fs/promises";
+import { createRequire } from "node:module";
+import { join } from "node:path";
+
+import { describe, expect, it } from "vitest";
+
+import { useScenarioApp } from "../../src/internal/testing/scenario-app.js";
+import { runPnpmCommand } from "../../src/internal/testing/run-pnpm-command.js";
+
+const require = createRequire(import.meta.url);
+const vercelManifest = require("vercel/package.json") as { version: string };
+const scenarioApp = useScenarioApp();
+
+describe("hostless agent workspace", () => {
+ it("assembles every direct child as a peer Vercel service", async () => {
+ const app = await scenarioApp({
+ files: {
+ "agents/research/agent/agent.mjs": `import { defineAgent } from "eve";\nexport default defineAgent({ model: "openai/gpt-5.4" });\n`,
+ "agents/research/agent/instructions.md": "You are the research agent.\n",
+ "agents/support/agent/agent.mjs": `import { defineAgent } from "eve";\nexport default defineAgent({ model: "openai/gpt-5.4" });\n`,
+ "agents/support/agent/instructions.md": "You are the support agent.\n",
+ ".vercel/project.json": `${JSON.stringify(
+ {
+ orgId: "team_eve_scenario",
+ projectId: "prj_eve_collection_scenario",
+ projectName: "hostless-agent-workspace",
+ settings: {
+ buildCommand: "pnpm exec eve build",
+ framework: null,
+ outputDirectory: null,
+ rootDirectory: null,
+ },
+ },
+ null,
+ 2,
+ )}\n`,
+ "pnpm-workspace.yaml": "minimumReleaseAge: 0\n",
+ },
+ dependencies: { vercel: vercelManifest.version },
+ installDependencies: true,
+ name: "hostless-agent-workspace",
+ });
+ await runPnpmCommand({ args: ["exec", "vercel", "build", "--yes"], cwd: app.appRoot });
+
+ const outputRoot = join(app.appRoot, ".vercel", "output");
+ const config = JSON.parse(await readFile(join(outputRoot, "config.json"), "utf8"));
+ expect(config.routes).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ destination: { service: "eve-support", type: "service" },
+ src: "^/support/eve/v1/(.*)$",
+ }),
+ expect.objectContaining({
+ destination: { service: "eve-research", type: "service" },
+ src: "^/research/eve/v1/(.*)$",
+ }),
+ ]),
+ );
+ await expect(
+ access(join(outputRoot, "services", "eve-support", "functions", "__server.func")),
+ ).resolves.toBeUndefined();
+ await expect(
+ access(join(outputRoot, "services", "eve-research", "functions", "__server.func")),
+ ).resolves.toBeUndefined();
+ }, 240_000);
+});