fix: normalize bundled plugin version reporting

This commit is contained in:
Peter Steinberger
2026-03-23 18:19:34 -07:00
parent e9905fd696
commit b4bda479a4
5 changed files with 275 additions and 7 deletions

View File

@@ -81,6 +81,63 @@ describe("buildPluginStatusReport", () => {
);
});
it("normalizes bundled plugin versions to the core base release", () => {
loadOpenClawPluginsMock.mockReturnValue({
plugins: [
{
id: "whatsapp",
name: "WhatsApp",
description: "Bundled channel plugin",
version: "2026.3.22",
source: "/tmp/whatsapp/index.ts",
origin: "bundled",
enabled: true,
status: "loaded",
toolNames: [],
hookNames: [],
channelIds: ["whatsapp"],
providerIds: [],
speechProviderIds: [],
mediaUnderstandingProviderIds: [],
imageGenerationProviderIds: [],
webSearchProviderIds: [],
gatewayMethods: [],
cliCommands: [],
services: [],
commands: [],
httpRoutes: 0,
hookCount: 0,
configSchema: false,
},
],
diagnostics: [],
channels: [],
providers: [],
speechProviders: [],
mediaUnderstandingProviders: [],
imageGenerationProviders: [],
webSearchProviders: [],
tools: [],
hooks: [],
typedHooks: [],
channelSetups: [],
httpRoutes: [],
gatewayHandlers: {},
cliRegistrars: [],
services: [],
commands: [],
});
const report = buildPluginStatusReport({
config: {},
env: {
OPENCLAW_VERSION: "2026.3.23-1",
} as NodeJS.ProcessEnv,
});
expect(report.plugins[0]?.version).toBe("2026.3.23");
});
it("builds an inspect report with capability shape and policy", () => {
loadConfigMock.mockReturnValue({
plugins: {

View File

@@ -1,7 +1,9 @@
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js";
import { loadConfig } from "../config/config.js";
import { normalizeOpenClawVersionBase } from "../config/version.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { resolveRuntimeServiceVersion } from "../version.js";
import { inspectBundleLspRuntimeSupport } from "./bundle-lsp.js";
import { inspectBundleMcpRuntimeSupport } from "./bundle-mcp.js";
import { normalizePluginsConfig } from "./config-state.js";
@@ -114,6 +116,20 @@ function buildCompatibilityNoticesForInspect(
const log = createSubsystemLogger("plugins");
function resolveReportedPluginVersion(
plugin: PluginRegistry["plugins"][number],
env: NodeJS.ProcessEnv | undefined,
): string | undefined {
if (plugin.origin !== "bundled") {
return plugin.version;
}
return (
normalizeOpenClawVersionBase(resolveRuntimeServiceVersion(env)) ??
normalizeOpenClawVersionBase(plugin.version) ??
plugin.version
);
}
export function buildPluginStatusReport(params?: {
config?: ReturnType<typeof loadConfig>;
workspaceDir?: string;
@@ -136,6 +152,10 @@ export function buildPluginStatusReport(params?: {
return {
workspaceDir,
...registry,
plugins: registry.plugins.map((plugin) => ({
...plugin,
version: resolveReportedPluginVersion(plugin, params?.env),
})),
};
}