fix: preserve gateway-bindable loader compatibility

This commit is contained in:
Peter Steinberger
2026-04-06 15:25:22 +01:00
parent c78defdc2f
commit fa67ab2358
3 changed files with 97 additions and 35 deletions

View File

@@ -43,6 +43,7 @@ import {
listImportedRuntimePluginIds,
setActivePluginRegistry,
} from "./runtime.js";
import type { PluginSdkResolutionPreference } from "./sdk-alias.js";
let cachedBundledTelegramDir = "";
let cachedBundledMemoryDir = "";
const BUNDLED_TELEGRAM_PLUGIN_BODY = `module.exports = {
@@ -1779,7 +1780,41 @@ module.exports = { id: "throws-after-import", register() {} };`,
loadVariant: () =>
loadOpenClawPlugins({
...options,
pluginSdkResolution: "workspace" as const,
pluginSdkResolution: "workspace" as PluginSdkResolutionPreference,
}),
};
},
},
{
name: "does not reuse cached registries across gateway subagent binding modes",
setup: () => {
useNoBundledPlugins();
const plugin = writePlugin({
id: "cache-gateway-shared",
filename: "cache-gateway-shared.cjs",
body: `module.exports = { id: "cache-gateway-shared", register() {} };`,
});
const options = {
workspaceDir: plugin.dir,
config: {
plugins: {
allow: ["cache-gateway-shared"],
load: {
paths: [plugin.file],
},
},
},
};
return {
loadFirst: () => loadOpenClawPlugins(options),
loadVariant: () =>
loadOpenClawPlugins({
...options,
runtimeOptions: {
allowGatewaySubagentBinding: true,
},
}),
};
},
@@ -1788,34 +1823,6 @@ module.exports = { id: "throws-after-import", register() {} };`,
expectCacheMissThenHit(setup());
});
it("reuses cached registry across gateway subagent binding modes", () => {
useNoBundledPlugins();
const plugin = writePlugin({
id: "cache-gateway-shared",
filename: "cache-gateway-shared.cjs",
body: `module.exports = { id: "cache-gateway-shared", register() {} };`,
});
const options = {
workspaceDir: plugin.dir,
config: {
plugins: {
allow: ["cache-gateway-shared"],
load: {
paths: [plugin.file],
},
},
},
};
const first = loadOpenClawPlugins(options);
const second = loadOpenClawPlugins({
...options,
runtimeOptions: { allowGatewaySubagentBinding: true },
});
expect(second).toBe(first);
});
it("evicts least recently used registries when the loader cache exceeds its cap", () => {
useNoBundledPlugins();
const plugin = writePlugin({