From b15682950588382cffdf067258a491d6debe3b77 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 5 May 2026 01:21:34 +0100 Subject: [PATCH] fix(acpx): resolve plugin manifest from bundled runtime --- extensions/acpx/src/codex-auth-bridge.ts | 9 +++++++-- extensions/acpx/src/config.test.ts | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/acpx/src/codex-auth-bridge.ts b/extensions/acpx/src/codex-auth-bridge.ts index 30668a16af4..2b98ea46369 100644 --- a/extensions/acpx/src/codex-auth-bridge.ts +++ b/extensions/acpx/src/codex-auth-bridge.ts @@ -1,6 +1,8 @@ +import fsSync from "node:fs"; import fs from "node:fs/promises"; import { createRequire } from "node:module"; import path from "node:path"; +import { resolveAcpxPluginRoot } from "./config.js"; import type { ResolvedAcpxPluginConfig } from "./config.js"; const CODEX_ACP_PACKAGE = "@zed-industries/codex-acp"; @@ -16,10 +18,13 @@ type PackageManifest = { dependencies?: Record; }; -const selfManifest = requireFromHere("../package.json") as PackageManifest; +function readSelfManifest(): PackageManifest { + const manifestPath = path.join(resolveAcpxPluginRoot(import.meta.url), "package.json"); + return JSON.parse(fsSync.readFileSync(manifestPath, "utf8")) as PackageManifest; +} function readManifestDependencyVersion(packageName: string): string { - const version = selfManifest.dependencies?.[packageName]; + const version = readSelfManifest().dependencies?.[packageName]; if (typeof version !== "string" || version.trim() === "") { throw new Error(`Missing ${packageName} dependency version in @openclaw/acpx manifest`); } diff --git a/extensions/acpx/src/config.test.ts b/extensions/acpx/src/config.test.ts index bf451d52fe0..f4bd6640710 100644 --- a/extensions/acpx/src/config.test.ts +++ b/extensions/acpx/src/config.test.ts @@ -119,6 +119,13 @@ describe("embedded acpx plugin config", () => { expect(server.args?.length).toBeGreaterThan(0); }); + it("resolves the plugin root from shared dist chunk paths", () => { + const moduleUrl = new URL("../../../dist/extensions/acpx/service-shared.js", import.meta.url) + .href; + + expect(resolveAcpxPluginRoot(moduleUrl)).toBe(path.resolve("extensions/acpx")); + }); + it("keeps the runtime json schema in sync with the manifest config schema", () => { const pluginRoot = resolveAcpxPluginRoot(); const manifest = JSON.parse(