fix(acpx): resolve plugin manifest from bundled runtime · openclaw/openclaw@b156829
steipete
·
2026-05-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import fsSync from "node:fs"; |
1 | 2 | import fs from "node:fs/promises"; |
2 | 3 | import { createRequire } from "node:module"; |
3 | 4 | import path from "node:path"; |
| 5 | +import { resolveAcpxPluginRoot } from "./config.js"; |
4 | 6 | import type { ResolvedAcpxPluginConfig } from "./config.js"; |
5 | 7 | |
6 | 8 | const CODEX_ACP_PACKAGE = "@zed-industries/codex-acp"; |
@@ -16,10 +18,13 @@ type PackageManifest = {
|
16 | 18 | dependencies?: Record<string, unknown>; |
17 | 19 | }; |
18 | 20 | |
19 | | -const selfManifest = requireFromHere("../package.json") as PackageManifest; |
| 21 | +function readSelfManifest(): PackageManifest { |
| 22 | +const manifestPath = path.join(resolveAcpxPluginRoot(import.meta.url), "package.json"); |
| 23 | +return JSON.parse(fsSync.readFileSync(manifestPath, "utf8")) as PackageManifest; |
| 24 | +} |
20 | 25 | |
21 | 26 | function readManifestDependencyVersion(packageName: string): string { |
22 | | -const version = selfManifest.dependencies?.[packageName]; |
| 27 | +const version = readSelfManifest().dependencies?.[packageName]; |
23 | 28 | if (typeof version !== "string" || version.trim() === "") { |
24 | 29 | throw new Error(`Missing ${packageName} dependency version in @openclaw/acpx manifest`); |
25 | 30 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -119,6 +119,13 @@ describe("embedded acpx plugin config", () => {
|
119 | 119 | expect(server.args?.length).toBeGreaterThan(0); |
120 | 120 | }); |
121 | 121 | |
| 122 | +it("resolves the plugin root from shared dist chunk paths", () => { |
| 123 | +const moduleUrl = new URL("../../../dist/extensions/acpx/service-shared.js", import.meta.url) |
| 124 | +.href; |
| 125 | + |
| 126 | +expect(resolveAcpxPluginRoot(moduleUrl)).toBe(path.resolve("extensions/acpx")); |
| 127 | +}); |
| 128 | + |
122 | 129 | it("keeps the runtime json schema in sync with the manifest config schema", () => { |
123 | 130 | const pluginRoot = resolveAcpxPluginRoot(); |
124 | 131 | const manifest = JSON.parse( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。