fix(acpx): resolve plugin manifest from bundled runtime

This commit is contained in:
Peter Steinberger
2026-05-05 01:21:34 +01:00
parent 44a10ceea2
commit b156829505
2 changed files with 14 additions and 2 deletions

View File

@@ -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<string, unknown>;
};
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`);
}

View File

@@ -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(