mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:40:43 +00:00
fix(plugins): preserve source activation config
This commit is contained in:
@@ -4,7 +4,10 @@ import JSON5 from "json5";
|
||||
import { resolveConfigPath } from "../config/paths.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { configMayNeedPluginAutoEnable } from "../config/plugin-auto-enable.shared.js";
|
||||
import { getRuntimeConfigSnapshot } from "../config/runtime-snapshot.js";
|
||||
import {
|
||||
getRuntimeConfigSnapshot,
|
||||
getRuntimeConfigSourceSnapshot,
|
||||
} from "../config/runtime-snapshot.js";
|
||||
import type { OpenClawConfig } from "../config/types.js";
|
||||
import { resolveBundledPluginsDir } from "../plugins/bundled-dir.js";
|
||||
import {
|
||||
@@ -66,6 +69,10 @@ function readFacadeBoundaryConfigSafely(): {
|
||||
cacheKey?: string;
|
||||
} {
|
||||
try {
|
||||
const sourceSnapshot = getRuntimeConfigSourceSnapshot();
|
||||
if (sourceSnapshot) {
|
||||
return { rawConfig: sourceSnapshot };
|
||||
}
|
||||
const runtimeSnapshot = getRuntimeConfigSnapshot();
|
||||
if (runtimeSnapshot) {
|
||||
return { rawConfig: runtimeSnapshot };
|
||||
|
||||
@@ -5,6 +5,10 @@ import { clearRuntimeConfigSnapshot, setRuntimeConfigSnapshot } from "../config/
|
||||
import { createPluginActivationSource, normalizePluginsConfig } from "../plugins/config-state.js";
|
||||
import { clearPluginDiscoveryCache } from "../plugins/discovery.js";
|
||||
import { clearPluginManifestRegistryCache } from "../plugins/manifest-registry.js";
|
||||
import {
|
||||
resetFacadeActivationCheckRuntimeStateForTest,
|
||||
resolveBundledPluginPublicSurfaceAccess as resolveActivationCheckBundledPluginPublicSurfaceAccess,
|
||||
} from "./facade-activation-check.runtime.js";
|
||||
import {
|
||||
__testing,
|
||||
canLoadActivatedBundledPluginPublicSurface,
|
||||
@@ -34,6 +38,7 @@ afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
clearRuntimeConfigSnapshot();
|
||||
resetFacadeRuntimeStateForTest();
|
||||
resetFacadeActivationCheckRuntimeStateForTest();
|
||||
clearPluginDiscoveryCache();
|
||||
clearPluginManifestRegistryCache();
|
||||
vi.doUnmock("../plugins/manifest-registry.js");
|
||||
@@ -381,4 +386,52 @@ describe("plugin-sdk facade runtime", () => {
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("prefers the source runtime snapshot for facade activation checks", () => {
|
||||
const dir = createTempDirSync("openclaw-facade-source-snapshot-");
|
||||
fs.mkdirSync(path.join(dir, "demo"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(dir, "demo", "runtime-api.js"),
|
||||
'export const marker = "source-snapshot";\n',
|
||||
"utf8",
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(dir, "demo", "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
id: "demo",
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = dir;
|
||||
setRuntimeConfigSnapshot(
|
||||
{
|
||||
plugins: {},
|
||||
},
|
||||
{
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
resolveActivationCheckBundledPluginPublicSurfaceAccess({
|
||||
dirName: "demo",
|
||||
artifactBasename: "runtime-api.js",
|
||||
location: {
|
||||
modulePath: path.join(dir, "demo", "runtime-api.js"),
|
||||
boundaryRoot: dir,
|
||||
},
|
||||
sourceExtensionsRoot: dir,
|
||||
resolutionKey: "source-snapshot-demo",
|
||||
}),
|
||||
).toEqual({
|
||||
allowed: true,
|
||||
pluginId: "demo",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user