Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

Fix dev snapshots for hoisted extension subagents (#3540)

e0-gh-vercel-connect[bot]f240baacc9aa
diff --git a/.changeset/quiet-crabs-fix.md b/.changeset/quiet-crabs-fix.md
new file mode 100644
index 000000000..fa7219ea7
--- /dev/null
+++ b/.changeset/quiet-crabs-fix.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Fix local development snapshots for extension subagents mounted from hoisted workspace dependencies.
diff --git a/packages/eve/src/internal/nitro/dev-runtime-artifacts.integration.test.ts b/packages/eve/src/internal/nitro/dev-runtime-artifacts.integration.test.ts
index 5f460a158..76377cab2 100644
--- a/packages/eve/src/internal/nitro/dev-runtime-artifacts.integration.test.ts
+++ b/packages/eve/src/internal/nitro/dev-runtime-artifacts.integration.test.ts
@@ -658,7 +658,7 @@ describe("development runtime artifact snapshots", () => {
paths: { compileDirectoryPath },
project: { appRoot },
} as CompileAgentResult),
- ).rejects.toThrow("outside runtime app root");
+ ).rejects.toThrow("outside runtime snapshot source root");
await expect(readdir(join(appRoot, ".eve", "dev-runtime", "snapshots"))).resolves.toEqual([]);
});
@@ -997,6 +997,100 @@ describe("development runtime artifact snapshots", () => {
await expect(realpath(snapshotMountPath)).resolves.toBe(await realpath(packageRoot));
});
+ it("rewrites hoisted extension subagent roots into source snapshots", async () => {
+ const workspaceRoot = await createScratchDirectory(
+ "eve-dev-runtime-hoisted-extension-subagent-",
+ );
+ const appRoot = join(workspaceRoot, "agents", "support");
+ const agentRoot = join(appRoot, "agent");
+ const packageRoot = join(workspaceRoot, "node_modules", "@acme", "crm");
+ const extensionRoot = join(packageRoot, "dist", "extension");
+ const reviewerRoot = join(extensionRoot, "subagents", "reviewer");
+ const compileDirectoryPath = join(appRoot, ".eve", "compile");
+ const manifestPath = join(compileDirectoryPath, "compiled-agent-manifest.json");
+
+ await mkdir(agentRoot, { recursive: true });
+ await mkdir(reviewerRoot, { recursive: true });
+ await mkdir(compileDirectoryPath, { recursive: true });
+ await writeFile(join(workspaceRoot, "pnpm-workspace.yaml"), "packages:\n - agents/*\n");
+ await writeFile(
+ join(workspaceRoot, "package.json"),
+ JSON.stringify({
+ dependencies: { "@acme/crm": "1.0.0" },
+ private: true,
+ }),
+ );
+ await writeFile(
+ join(packageRoot, "package.json"),
+ JSON.stringify({ name: "@acme/crm", version: "1.0.0" }),
+ );
+ await writeFile(join(reviewerRoot, "agent.ts"), "export const review = true;\n");
+ const compiledManifest = {
+ agentRoot,
+ appRoot,
+ extensionMounts: [{ sourceRoot: extensionRoot }],
+ subagents: [
+ {
+ agent: {
+ agentRoot: reviewerRoot,
+ appRoot: extensionRoot,
+ extensionMounts: [{ sourceRoot: extensionRoot }],
+ },
+ },
+ ],
+ };
+ await writeFile(manifestPath, `${JSON.stringify(compiledManifest, null, 2)}\n`);
+
+ const snapshot = await stageDevelopmentRuntimeArtifactsSnapshot({
+ manifest: compiledManifest,
+ paths: { compileDirectoryPath },
+ project: { appRoot },
+ } as CompileAgentResult);
+ const rewrittenManifest = JSON.parse(
+ await readFile(
+ join(snapshot.runtimeAppRoot, ".eve", "compile", "compiled-agent-manifest.json"),
+ "utf8",
+ ),
+ ) as {
+ subagents: Array<{ agent: { agentRoot: string; appRoot: string } }>;
+ };
+
+ expect(rewrittenManifest.subagents[0]?.agent).toMatchObject({
+ agentRoot: join(
+ snapshot.snapshotSourceRoot,
+ "node_modules",
+ "@acme",
+ "crm",
+ "dist",
+ "extension",
+ "subagents",
+ "reviewer",
+ ),
+ appRoot: join(
+ snapshot.snapshotSourceRoot,
+ "node_modules",
+ "@acme",
+ "crm",
+ "dist",
+ "extension",
+ ),
+ });
+ expect(
+ existsSync(
+ join(
+ snapshot.snapshotSourceRoot,
+ "node_modules",
+ "@acme",
+ "crm",
+ "dist",
+ "extension",
+ "subagents",
+ "reviewer",
+ ),
+ ),
+ ).toBe(true);
+ });
+
it("mounts workspace packages nested inside the app root without copying them", async () => {
const appRoot = await createScratchDirectory("eve-dev-runtime-nested-workspace-");
const agentRoot = join(appRoot, "agent");
diff --git a/packages/eve/src/internal/nitro/dev-runtime-artifacts.ts b/packages/eve/src/internal/nitro/dev-runtime-artifacts.ts
index d0f6a915f..c36d59c53 100644
--- a/packages/eve/src/internal/nitro/dev-runtime-artifacts.ts
+++ b/packages/eve/src/internal/nitro/dev-runtime-artifacts.ts
@@ -128,7 +128,7 @@ export async function stageDevelopmentRuntimeArtifactsSnapshot(
"compile",
"compiled-agent-manifest.json",
),
- runtimeAppRoot: sourceSnapshotPlan.runtimeAppRoot,
+ snapshotSourceRoot: sourceSnapshotPlan.snapshotSourceRoot,
});
await writeFile(
join(snapshotRoot, DEV_RUNTIME_ARTIFACTS_GENERATION_METADATA),
@@ -466,11 +466,17 @@ function rewriteManifestRoots(input: {
const rewritten: Record<string, unknown> = {};
for (const [key, value] of Object.entries(input.value)) {
if (typeof value === "string" && (key === "appRoot" || key === "agentRoot")) {
- rewritten[key] = rewritePathWithinAppRoot({
- appRoot: input.appRoot,
- path: value,
- runtimeAppRoot: input.runtimeAppRoot,
- });
+ rewritten[key] = isPathInsideOrEqual(value, input.appRoot)
+ ? rewritePathWithinAppRoot({
+ appRoot: input.appRoot,
+ path: value,
+ runtimeAppRoot: input.runtimeAppRoot,
+ })
+ : rewritePathWithinSourceRoot({
+ path: value,
+ snapshotSourceRoot: input.snapshotSourceRoot,
+ sourceRoot: input.sourceRoot,
+ });
continue;
}
@@ -615,18 +621,18 @@ async function restoreDevelopmentRuntimeArtifactsActivation(input: {
async function validateSnapshotCompiledManifestRoots(input: {
readonly manifestPath: string;
- readonly runtimeAppRoot: string;
+ readonly snapshotSourceRoot: string;
}): Promise<void> {
const manifest = JSON.parse(await readFile(input.manifestPath, "utf8")) as unknown;
const rootPaths = collectManifestRootPaths(manifest);
for (const path of rootPaths) {
- if (isPathInsideOrEqual(path, input.runtimeAppRoot)) {
+ if (isPathInsideOrEqual(path, input.snapshotSourceRoot)) {
continue;
}
throw new Error(
- `Development runtime snapshot manifest root "${path}" is outside runtime app root "${input.runtimeAppRoot}".`,
+ `Development runtime snapshot manifest root "${path}" is outside runtime snapshot source root "${input.snapshotSourceRoot}".`,
);
}
}