The Open Framework for Building Agents
fix(eve): align workspace member workflow ids (#4491)
Andrew Barba0b5bb5ba11c3
diff --git a/.changeset/workspace-member-workflow-ids.md b/.changeset/workspace-member-workflow-ids.mdnew file mode 100644index 000000000..ba891a2d2--- /dev/null+++ b/.changeset/workspace-member-workflow-ids.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Workflow tools in an `agents/<name>/` workspace member now compile with the workflow ID that the deployment registers, so calls no longer fail with "is not registered as a workflow in this deployment". Members can also import workflow and step modules from the shared root package, such as `lib/`, and `eve dev` rebuilds when shared modules imported from outside the agent directory change.diff --git a/docs/tools/workflows.mdx b/docs/tools/workflows.mdxindex 5141f885a..2874c5444 100644--- a/docs/tools/workflows.mdx+++ b/docs/tools/workflows.mdx@@ -107,10 +107,12 @@ channel or schedule, use the [channel operations](/docs/channels/custom#channel-or [schedule handler](/docs/schedules#handler-form-run) APIs.Workflow imports resolve `paths` aliases from your application's `tsconfig.json` or-`jsconfig.json`, including when the application is a workspace package. eve includes only-workflow and step modules reachable from the agent's runtime modules. Unrelated workflows-in the host application stay outside the agent bundle. An unresolved workflow import fails-the build with the missing import in the error.+`jsconfig.json`, including when the application is a workspace package. A member of an+[agent workspace](/docs/concepts/project-structure#several-root-agents) can also import+workflow and step modules from the shared root package, such as a root `lib/` directory.+eve includes only workflow and step modules reachable from the agent's runtime modules.+Unrelated workflows in the host application stay outside the agent bundle. An unresolved+workflow import fails the build with the missing import in the error.### Add a runtime-generated workflow tooldiff --git a/packages/eve/src/compiler/load-binding-namespace.test.ts b/packages/eve/src/compiler/load-binding-namespace.test.tsindex 0511f9d1d..111cadcda 100644--- a/packages/eve/src/compiler/load-binding-namespace.test.ts+++ b/packages/eve/src/compiler/load-binding-namespace.test.ts@@ -48,6 +48,7 @@ describe("compiled binding namespace loader", () => {},};const loadNamespace = createCompiledBindingNamespaceLoader({+ appRoot: undefined,bindings,registries: [registry],});@@ -85,6 +86,7 @@ describe("compiled binding namespace loader", () => {owner: { feature: "test", kind: "framework" },});const loadNamespace = createCompiledBindingNamespaceLoader({+ appRoot: undefined,bindings: { first: programmatic("second"), second: programmatic("first") },registries: [registry],});diff --git a/packages/eve/src/compiler/load-binding-namespace.ts b/packages/eve/src/compiler/load-binding-namespace.tsindex b4e3c05f5..6d0018101 100644--- a/packages/eve/src/compiler/load-binding-namespace.ts+++ b/packages/eve/src/compiler/load-binding-namespace.ts@@ -32,6 +32,11 @@ function ancestorMountEntries(mounts: ReadonlyMap<string, ExtensionCompileMount>/** Loads one node's selected bindings with dependency ordering and per-phase caching. */export function createCompiledBindingNamespaceLoader(input: {+ /**+ * Selected app root; application modules stamp Workflow ids relative to it. Required so+ * no caller silently falls back to the package root, which differs in workspace members.+ */+ readonly appRoot: string | undefined;readonly bindings?: Readonly<Record<string, AgentModuleBinding>>;readonly mounts?: ReadonlyMap<string, ExtensionCompileMount>;readonly evaluationId?: string;@@ -66,6 +71,7 @@ export function createCompiledBindingNamespaceLoader(input: {await load(mountSourceId, nextLineage);}return await loadCompiledBindingNamespace({+ appRoot: input.appRoot,binding,loadDependency: (dependencySourceId) => load(dependencySourceId, nextLineage),registries: input.registries,@@ -81,6 +87,7 @@ export function createCompiledBindingNamespaceLoader(input: {}async function loadCompiledBindingNamespace(input: {+ readonly appRoot: string | undefined;readonly binding: AgentModuleBinding;readonly loadDependency: CompiledBindingNamespaceLoader;readonly mounts?: ReadonlyMap<string, ExtensionCompileMount>;@@ -105,6 +112,7 @@ async function loadCompiledBindingNamespace(input: {input.mounts === undefined ? undefined : ancestorMountEntries(input.mounts, mountId),};return await loadAuthoredModuleNamespace(input.binding.backing.sourcePath, {+ appRoot: input.binding.owner.kind === "application" ? input.appRoot : undefined,externalDependencies: input.binding.backing.externalDependencies,extension,});diff --git a/packages/eve/src/compiler/module-lifecycle.ts b/packages/eve/src/compiler/module-lifecycle.tsindex 37166ebf5..88a1af333 100644--- a/packages/eve/src/compiler/module-lifecycle.ts+++ b/packages/eve/src/compiler/module-lifecycle.ts@@ -20,8 +20,10 @@ export class NodeModuleEvaluationContext {mountSourceId?: (binding: AgentModuleBinding) => string | undefined,mounts?: Parameters<typeof createCompiledBindingNamespaceLoader>[0]["mounts"],evaluationId?: string,+ appRoot?: string,) {this.loadNamespace = createCompiledBindingNamespaceLoader({+ appRoot,mountSourceId,mounts,evaluationId,diff --git a/packages/eve/src/compiler/module-map.ts b/packages/eve/src/compiler/module-map.tsindex f0fd40497..db6d0ebf8 100644--- a/packages/eve/src/compiler/module-map.ts+++ b/packages/eve/src/compiler/module-map.ts@@ -160,6 +160,7 @@ export async function createProgrammaticCompiledModuleMap(scope.mounts.map((mount) => [mount.mountId, mount.mountSourceId]),);const loadNamespace = createCompiledBindingNamespaceLoader({+ appRoot: manifest.appRoot,bindings,registries,mountSourceId: (binding) => mountSourceIds.get(bindingMountId(binding) ?? ""),diff --git a/packages/eve/src/compiler/normalize-agent-config.ts b/packages/eve/src/compiler/normalize-agent-config.tsindex f751cf744..6b33a103f 100644--- a/packages/eve/src/compiler/normalize-agent-config.ts+++ b/packages/eve/src/compiler/normalize-agent-config.ts@@ -48,6 +48,7 @@ export async function compileAgentConfig(displayPath: configModulePath,kind: "agent config",loadNamespace: createCompiledBindingNamespaceLoader({+ appRoot: manifest.appRoot,bindings: { [configModule.sourceId]: options.binding },registries: context.registries,}),diff --git a/packages/eve/src/compiler/normalize-manifest.ts b/packages/eve/src/compiler/normalize-manifest.tsindex a3d7a4fab..ec795aee4 100644--- a/packages/eve/src/compiler/normalize-manifest.ts+++ b/packages/eve/src/compiler/normalize-manifest.ts@@ -432,6 +432,7 @@ class AgentGraphCompiler {(binding) => sourceIds.get(bindingMountId(binding) ?? ""),this.mounts,this.evaluationId,+ input.manifest.appRoot,);evaluation.setBindings(Object.fromEntries(diff --git a/packages/eve/src/compiler/resolve-workspace-subagent.ts b/packages/eve/src/compiler/resolve-workspace-subagent.tsindex 8ae2bc38f..ce0510e11 100644--- a/packages/eve/src/compiler/resolve-workspace-subagent.ts+++ b/packages/eve/src/compiler/resolve-workspace-subagent.ts@@ -49,6 +49,7 @@ export async function resolveWorkspaceSubagentDefinition(input: {binding,kind: "agent config",loadNamespace: createCompiledBindingNamespaceLoader({+ appRoot: project.appRoot,bindings: { [configSource.sourceId]: binding },registries: input.registries,}),diff --git a/packages/eve/src/internal/authored-module-loader.integration.test.ts b/packages/eve/src/internal/authored-module-loader.integration.test.tsindex 91aded93f..8e8a2542c 100644--- a/packages/eve/src/internal/authored-module-loader.integration.test.ts+++ b/packages/eve/src/internal/authored-module-loader.integration.test.ts@@ -6,6 +6,7 @@ import { describe, expect, it } from "vitest";import { compileAgentManifest } from "#compiler/normalize-manifest.js";import { discoverAgent } from "#discover/discover-agent.js";+import { resolveDiscoveryProject } from "#discover/project.js";import {bundleAuthoredModuleCode,bundleAuthoredModuleForGeneration,@@ -1499,3 +1500,88 @@ export default defineWorkflowTool({ description: "Probe", inputSchema: { type: ").rejects.toThrow(/build\.externalDependencies|asset import/);});});++describe("workspace member workflow ids", () => {+ const createAppRoot = useTemporaryAppRoots();++ const workflowTool = `import { defineWorkflowTool } from "eve/tools";+export default defineWorkflowTool({ description: "Probe", inputSchema: { type: "object" }, async execute() { "use workflow"; return 1; } });+`;++ // Members have no package.json, so the package root is the workspace root+ // while the app root, which owns workflow ids, is the member directory.+ async function compileMember(files: Record<string, string>) {+ const workspace = await createAppRoot("eve-workspace-member-workflow-ids-", {+ files: {+ "package.json": JSON.stringify({ dependencies: { eve: "*" }, type: "module" }),+ ...files,+ },+ });+ await rm(workspace.agentRoot, { recursive: true });+ const project = await resolveDiscoveryProject(join(workspace.appRoot, "agents", "assistant"));+ const manifest = await compileAgentManifest((await discoverAgent(project)).manifest);+ const generation = await bundleAuthoredModuleMapForGeneration({+ appRoot: project.appRoot,+ manifest,+ moduleMapPath: join(project.appRoot, ".eve", "compile", "module-map.mjs"),+ });+ return { generation, manifest, project };+ }++ it("compiles root and subagent tool ids that match the generation bundle", async () => {+ const { generation, manifest } = await compileMember({+ "agents/assistant/agent/agent.ts": 'export default { model: "openai/gpt-5.4" };\n',+ "agents/assistant/agent/tools/plan.ts": workflowTool,+ "agents/assistant/agent/subagents/reviewer/agent.ts":+ 'export default { description: "Review plans.", model: "openai/gpt-5.4" };\n',+ "agents/assistant/agent/subagents/reviewer/tools/approve.ts": workflowTool,+ });+ const reviewer = manifest.subagents.find((subagent) => subagent.name === "reviewer");+ const toolId = "workflow//./agent/tools/plan//execute";+ const subagentToolId = "workflow//./agent/subagents/reviewer/tools/approve//execute";++ expect(manifest.tools.find((tool) => tool.name === "plan")?.behavior?.handling).toEqual({+ entryPoint: "execute",+ kind: "workflow-tool",+ workflowId: toolId,+ });+ expect(+ reviewer?.agent.tools.find((tool) => tool.name === "approve")?.behavior?.handling,+ ).toEqual({ entryPoint: "execute", kind: "workflow-tool", workflowId: subagentToolId });+ expect(generation.code).toContain(JSON.stringify(toolId));+ expect(generation.code).toContain(JSON.stringify(subagentToolId));+ });++ it("compiles workflow modules from the shared package but not from sibling packages", async () => {+ const { generation, manifest, project } = await compileMember({+ "agents/assistant/agent/agent.ts": 'export default { model: "openai/gpt-5.4" };\n',+ "agents/assistant/agent/tools/plan.ts": `import { defineWorkflowTool } from "eve/tools";+import "../../../../packages/shared/index";+import { run } from "../../../../lib/run";+export default defineWorkflowTool({ description: "Probe", inputSchema: { type: "object" }, execute: run });+`,+ "lib/run.ts":+ 'import { add } from "./steps";\nexport async function run() { "use workflow"; return add(1); }\n',+ "lib/steps.ts": 'export async function add(n) { "use step"; return n + 1; }\n',+ "packages/shared/package.json": JSON.stringify({ name: "shared", version: "1.0.0" }),+ "packages/shared/index.ts": 'export async function other() { "use step"; return 1; }\n',+ });+ const workflowId = "workflow//../../lib/run//run";+ const sharedModule = (name: string) => join(project.appRoot, "..", "..", "lib", name);++ expect(manifest.tools.find((tool) => tool.name === "plan")?.behavior?.handling).toEqual({+ entryPoint: "execute",+ kind: "workflow-tool",+ workflowId,+ });+ expect(generation.code).toContain(JSON.stringify(workflowId));+ expect(generation.authoredWorkflowModules).toEqual({+ directiveModules: [sharedModule("run.ts"), sharedModule("steps.ts")],+ workflowModules: [sharedModule("run.ts")],+ });+ expect(generation.sourceModules).toEqual(+ expect.arrayContaining([sharedModule("run.ts"), sharedModule("steps.ts")]),+ );+ expect(generation.sourceModules.some((id) => id.includes("/packages/shared/"))).toBe(false);+ });+});diff --git a/packages/eve/src/internal/authored-module-loader.ts b/packages/eve/src/internal/authored-module-loader.tsindex 44f1b6438..db566ee4a 100644--- a/packages/eve/src/internal/authored-module-loader.ts+++ b/packages/eve/src/internal/authored-module-loader.ts@@ -60,6 +60,11 @@ export interface ExtensionMountEntry {}export interface AuthoredModuleLoadOptions {+ /**+ * Selected app root that owns authored Workflow ids. A workspace member's app root sits+ * below the shared package root, which still owns dependency resolution.+ */+ readonly appRoot?: string;readonly externalDependencies?: readonly string[];readonly extension?: {readonly mountId: string;@@ -196,7 +201,7 @@ export async function bundleAuthoredModuleCode(},},]),- createAuthoredWorkflowDirectivePlugin({ appRoot: packageRoot }),+ createAuthoredWorkflowDirectivePlugin({ appRoot: options.appRoot ?? packageRoot }),...(mount === undefined ? [] : [createExtensionMountPlugin(mountChain)!]),],sourcemap: "inline",@@ -304,6 +309,8 @@ export async function bundleExtensionDistributionGraph(input: {export interface AuthoredModuleMapBundle {readonly authoredWorkflowModules: AuthoredWorkflowModules;readonly code: string;+ /** Application modules in the graph, including shared workspace modules outside the app root. */+ readonly sourceModules: readonly string[];/** Fingerprint of the sources that also feed the driver and step registry; a change rebuilds the host. */readonly workflowSourceFingerprint: string | undefined;}@@ -398,6 +405,7 @@ export async function bundleAuthoredModuleMapForGeneration(input: {return {authoredWorkflowModules: workflowSources.modules(),code: removeRolldownModuleRegionComments(chunk.code),+ sourceModules: workflowSources.sourceModules().filter((id) => id !== input.moduleMapPath),workflowSourceFingerprint: workflowSources.fingerprint(),};} catch (error) {@@ -452,6 +460,10 @@ class AuthoredWorkflowSourceRecorder {return this.#workflowFunctions.get(id);}+ sourceModules(): readonly string[] {+ return [...this.#sources.keys()].sort();+ }+graphPlugin(): Record<string, unknown> {const imports = this.#imports;return {@@ -659,7 +671,7 @@ function createInFlightModuleLoadKey(): string {const externalDependencies = normalizeExternalDependencies(options.externalDependencies);- return `${modulePath}\0${externalDependencies.join("\0")}\0${options.extension?.mountId ?? ""}\0${options.extension?.evaluationId ?? ""}`;+ return `${modulePath}\0${externalDependencies.join("\0")}\0${options.extension?.mountId ?? ""}\0${options.extension?.evaluationId ?? ""}\0${options.appRoot ?? ""}`;}export function resolveAuthoredTsConfigPath(packageRoot: string): string | false {diff --git a/packages/eve/src/internal/authored-module-map-loader.ts b/packages/eve/src/internal/authored-module-map-loader.tsindex d58a99640..c0d2b39e8 100644--- a/packages/eve/src/internal/authored-module-map-loader.ts+++ b/packages/eve/src/internal/authored-module-map-loader.ts@@ -104,7 +104,7 @@ async function hydrateCompiledModuleMapFromManifest(];for (const node of nodeManifests) {nodes[node.nodeId] = {- modules: await hydrateCompiledNodeScope(node.manifest, (sourcePath) =>+ modules: await hydrateCompiledNodeScope(node.manifest, authoredAppRoot, (sourcePath) =>resolve(authoredAppRoot, relative(manifest.appRoot, sourcePath)),),};@@ -114,6 +114,7 @@ async function hydrateCompiledModuleMapFromManifest(async function hydrateCompiledNodeScope(manifest: CompiledAgentNodeManifest | CompiledAgentResources,+ appRoot: string,resolveSourcePath: (sourcePath: string) => string,): Promise<CompiledModuleMap["nodes"][string]["modules"]> {const modules: CompiledModuleMap["nodes"][string]["modules"] = {};@@ -130,6 +131,7 @@ async function hydrateCompiledNodeScope(): memoizeModuleNamespaceFactories(await loadAuthoredModuleNamespace(resolveSourcePath(binding.backing.sourcePath), {+ appRoot: binding.owner.kind === "application" ? appRoot : undefined,externalDependencies: binding.backing.externalDependencies,extension: (() => {const mountId = resolveExtensionBindingMountId(binding);diff --git a/packages/eve/src/internal/authored-runtime-modules.ts b/packages/eve/src/internal/authored-runtime-modules.tsindex 37ea9a447..36f93d29b 100644--- a/packages/eve/src/internal/authored-runtime-modules.ts+++ b/packages/eve/src/internal/authored-runtime-modules.ts@@ -16,6 +16,7 @@ export interface PreparedAuthoredRuntimeModules {readonly authoredWorkflowModules: AuthoredWorkflowModules;readonly instrumentation: PreparedAuthoredRuntimeInstrumentation;readonly moduleMapCode: string;+ readonly sourceModules: readonly string[];/** Identity of authored sources shared by the workflow driver and step registrations. */readonly workflowSourceFingerprint: string | undefined;}@@ -29,6 +30,7 @@ export async function prepareAuthoredRuntimeModules(input: {const {authoredWorkflowModules,code: moduleMapCode,+ sourceModules,workflowSourceFingerprint,} = await bundleAuthoredModuleMapForGeneration(input);const layout = resolveInstrumentationLayout({ agentRoot: input.manifest.agentRoot });@@ -43,5 +45,11 @@ export async function prepareAuthoredRuntimeModules(input: {);const instrumentation = { kind: "directory", moduleCodeBySlot } as const;- return { authoredWorkflowModules, instrumentation, moduleMapCode, workflowSourceFingerprint };+ return {+ authoredWorkflowModules,+ instrumentation,+ moduleMapCode,+ sourceModules,+ workflowSourceFingerprint,+ };}diff --git a/packages/eve/src/internal/nitro/development-generation.test.ts b/packages/eve/src/internal/nitro/development-generation.test.tsindex ae83c898d..dc70ad0a5 100644--- a/packages/eve/src/internal/nitro/development-generation.test.ts+++ b/packages/eve/src/internal/nitro/development-generation.test.ts@@ -47,7 +47,7 @@ function createGeneration(id: string): DevelopmentGeneration {describe("development generation staging", () => {const compileResult = {- manifest: {},+ manifest: { agentRoot: "/tmp/app/agent" },paths: { moduleMapPath: "/tmp/app/modules.mjs" },project: { appRoot: "/tmp/app" },} as CompileAgentResult;@@ -71,11 +71,21 @@ describe("development generation staging", () => {moduleMapPath: "/tmp/app/modules.mjs",});expect(mocks.stage).toHaveBeenCalledOnce();- preparation.resolve({ authoredWorkflowModules: {} });+ preparation.resolve({+ authoredWorkflowModules: {},+ sourceModules: ["/tmp/app/agent/tools/plan.ts", "/tmp/lib/run.ts"],+ });await Promise.resolve();expect(mocks.materialize).not.toHaveBeenCalled();- staging.resolve(createGeneration("parallel"));- expect(await result).toMatchObject({ fingerprint: "ready" });+ staging.resolve({+ ...createGeneration("parallel"),+ sourceWatchPaths: ["/tmp/app/package.json"],+ });+ // The watcher already covers the agent root, so only shared modules outside it are added.+ expect(await result).toMatchObject({+ fingerprint: "ready",+ sourceWatchPaths: ["/tmp/app/package.json", "/tmp/lib/run.ts"],+ });expect(mocks.rm).not.toHaveBeenCalled();});diff --git a/packages/eve/src/internal/nitro/development-generation.ts b/packages/eve/src/internal/nitro/development-generation.tsindex df318b21f..b3c902790 100644--- a/packages/eve/src/internal/nitro/development-generation.ts+++ b/packages/eve/src/internal/nitro/development-generation.ts@@ -11,6 +11,7 @@ import {type DevelopmentRuntimeArtifactsActivation,type DevelopmentRuntimeArtifactsSnapshot,} from "#internal/nitro/dev-runtime-artifacts.js";+import { isPathInsideOrEqual } from "#internal/nitro/dev-runtime-source-snapshot-local-roots.js";export interface DevelopmentGeneration extends DevelopmentRuntimeArtifactsSnapshot {readonly authoredWorkflowModules?: AuthoredWorkflowModules;@@ -59,18 +60,22 @@ export async function stageDevelopmentGeneration(runtimeAppRoot: snapshot.runtimeAppRoot,});+ const generation = {+ ...snapshot,+ authoredWorkflowModules: prepared.authoredWorkflowModules,+ fingerprint: materialized.fingerprint,+ // The watcher covers the agent root; shared modules imported from elsewhere+ // in the package, such as a workspace's root lib/, need their own entries.+ sourceWatchPaths: [+ ...(snapshot.sourceWatchPaths ?? []),+ ...prepared.sourceModules.filter(+ (path) => !isPathInsideOrEqual(path, compileResult.manifest.agentRoot),+ ),+ ],+ };return prepared.workflowSourceFingerprint === undefined- ? {- ...snapshot,- authoredWorkflowModules: prepared.authoredWorkflowModules,- fingerprint: materialized.fingerprint,- }- : {- ...snapshot,- authoredWorkflowModules: prepared.authoredWorkflowModules,- fingerprint: materialized.fingerprint,- workflowSourceFingerprint: prepared.workflowSourceFingerprint,- };+ ? generation+ : { ...generation, workflowSourceFingerprint: prepared.workflowSourceFingerprint };} catch (error) {try {await rm(snapshot.snapshotRoot, { force: true, recursive: true });diff --git a/packages/eve/src/internal/nitro/host/extension-capability-requirements.ts b/packages/eve/src/internal/nitro/host/extension-capability-requirements.tsindex 6da91a253..73dcf1528 100644--- a/packages/eve/src/internal/nitro/host/extension-capability-requirements.ts+++ b/packages/eve/src/internal/nitro/host/extension-capability-requirements.ts@@ -136,6 +136,8 @@ function createLoadOptions(return {binding,loadNamespace: createCompiledBindingNamespaceLoader({+ // An extension package build has no application to own Workflow ids.+ appRoot: undefined,bindings: { [source.sourceId]: binding },registries: [],}),diff --git a/packages/eve/src/internal/workflow-bundle/workflow-builders.ts b/packages/eve/src/internal/workflow-bundle/workflow-builders.tsindex e7174020b..d61aaa346 100644--- a/packages/eve/src/internal/workflow-bundle/workflow-builders.ts+++ b/packages/eve/src/internal/workflow-bundle/workflow-builders.ts@@ -113,10 +113,19 @@ function isPackageTestFixtureModule(absolutePath: string): boolean {}export function isAuthoredApplicationModule(absolutePath: string, appRoot: string): boolean {+ // Bundler virtual ids such as `\0rolldown/runtime.js` would otherwise resolve against the cwd.+ if (!isAbsolute(absolutePath)) return false;const normalizedRoot = toRealPath(appRoot).replace(/\\/g, "/").replace(/\/$/, "");const normalizedPath = toRealPath(absolutePath).replace(/\\/g, "/");- if (!normalizedPath.startsWith(`${normalizedRoot}/`)) return false;if (isInNodeModules(normalizedPath)) return false;+ if (!normalizedPath.startsWith(`${normalizedRoot}/`)) {+ // An app root without its own package.json, such as a workspace member,+ // shares the enclosing package, so that package's other modules are application code.+ const appPackageRoot = findPackageRoot(normalizedRoot);+ if (appPackageRoot === null || findPackageRoot(dirname(normalizedPath)) !== appPackageRoot) {+ return false;+ }+ }return findPackageJson(normalizedPath)?.name !== EVE_PACKAGE_NAME;}@@ -125,7 +134,23 @@ function authoredRelativePath(absolutePath: string, appRoot: string): string {}function authoredModuleIdBase(absolutePath: string, appRoot: string): string {- return `./${stripJavaScriptExtension(authoredRelativePath(absolutePath, appRoot))}`;+ const idBase = stripJavaScriptExtension(authoredRelativePath(absolutePath, appRoot));+ return idBase.startsWith("../") ? idBase : `./${idBase}`;+}++const packageRootCache = new Map<string, string | null>();++function findPackageRoot(directory: string): string | null {+ const cached = packageRootCache.get(directory);+ if (cached !== undefined) return cached;+ const parent = dirname(directory);+ const packageRoot = existsSync(join(directory, "package.json"))+ ? directory+ : parent === directory+ ? null+ : findPackageRoot(parent);+ packageRootCache.set(directory, packageRoot);+ return packageRoot;}// Bundlers hand back real paths while configuration carries the spelled