From f039bbf2aa8d652e12bdb51a68a89f6236232ec8 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Sun, 5 Apr 2026 11:36:04 +0530 Subject: [PATCH] fix: resolve acpx plugin root from shared chunks --- extensions/acpx/src/config.test.ts | 16 ++++++++++++++++ extensions/acpx/src/config.ts | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/extensions/acpx/src/config.test.ts b/extensions/acpx/src/config.test.ts index 9a69e067c9d..472166fa4d7 100644 --- a/extensions/acpx/src/config.test.ts +++ b/extensions/acpx/src/config.test.ts @@ -64,6 +64,22 @@ describe("acpx plugin config parsing", () => { } }); + it("resolves workspace plugin root from dist shared chunks", () => { + const repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), "acpx-root-shared-dist-")); + const workspacePluginRoot = bundledPluginRootAt(repoRoot, "acpx"); + try { + fs.mkdirSync(path.join(repoRoot, "dist"), { recursive: true }); + fs.mkdirSync(workspacePluginRoot, { recursive: true }); + fs.writeFileSync(path.join(workspacePluginRoot, "package.json"), "{}\n", "utf8"); + fs.writeFileSync(path.join(workspacePluginRoot, "openclaw.plugin.json"), "{}\n", "utf8"); + + const moduleUrl = pathToFileURL(path.join(repoRoot, "dist", "register.runtime.js")).href; + expect(resolveAcpxPluginRoot(moduleUrl)).toBe(workspacePluginRoot); + } finally { + fs.rmSync(repoRoot, { recursive: true, force: true }); + } + }); + it("resolves bundled acpx with pinned version by default", () => { const resolved = resolveAcpxPluginConfig({ rawConfig: { diff --git a/extensions/acpx/src/config.ts b/extensions/acpx/src/config.ts index 14e43621e65..e574d6078c2 100644 --- a/extensions/acpx/src/config.ts +++ b/extensions/acpx/src/config.ts @@ -62,11 +62,20 @@ function resolveWorkspaceAcpxPluginRoot(currentRoot: string): string | null { return isAcpxPluginRoot(workspaceRoot) ? workspaceRoot : null; } +function resolveRepoAcpxPluginRoot(currentRoot: string): string | null { + const workspaceRoot = path.join(currentRoot, "extensions", "acpx"); + return isAcpxPluginRoot(workspaceRoot) ? workspaceRoot : null; +} + export function resolveAcpxPluginRoot(moduleUrl: string = import.meta.url): string { const resolvedRoot = resolveNearestAcpxPluginRoot(moduleUrl); // In a live repo checkout, dist/ can be rebuilt out from under the running gateway. // Prefer the stable source plugin root when a built extension is running beside it. - return resolveWorkspaceAcpxPluginRoot(resolvedRoot) ?? resolvedRoot; + return ( + resolveWorkspaceAcpxPluginRoot(resolvedRoot) ?? + resolveRepoAcpxPluginRoot(resolvedRoot) ?? + resolvedRoot + ); } export const ACPX_PLUGIN_ROOT = resolveAcpxPluginRoot();