From 8b7914199791b3ffb39b208b76ba6d1d591c21b1 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Wed, 15 Apr 2026 11:43:22 +0530 Subject: [PATCH] fix(update): infer legacy bundled sidecars --- src/infra/update-global.test.ts | 23 +++++++++++++++++++++++ src/infra/update-global.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/infra/update-global.test.ts b/src/infra/update-global.test.ts index 8a9e2bd8b5d..d5674fa5889 100644 --- a/src/infra/update-global.test.ts +++ b/src/infra/update-global.test.ts @@ -421,4 +421,27 @@ describe("update global helpers", () => { ); }); }); + + it("verifies legacy sidecars for installed bundled plugins without inventory", async () => { + await withTempDir({ prefix: "openclaw-update-global-legacy-plugin-" }, async (packageRoot) => { + await fs.writeFile( + path.join(packageRoot, "package.json"), + JSON.stringify({ name: "openclaw", version: "1.0.0" }), + "utf-8", + ); + const matrixPackageJson = path.join( + packageRoot, + "dist", + "extensions", + "matrix", + "package.json", + ); + await fs.mkdir(path.dirname(matrixPackageJson), { recursive: true }); + await fs.writeFile(matrixPackageJson, JSON.stringify({ name: "@openclaw/matrix" }), "utf-8"); + + await expect(collectInstalledGlobalPackageErrors({ packageRoot })).resolves.toContain( + `missing bundled runtime sidecar ${MATRIX_HELPER_API}`, + ); + }); + }); }); diff --git a/src/infra/update-global.ts b/src/infra/update-global.ts index e87f22fdeee..2722611b542 100644 --- a/src/infra/update-global.ts +++ b/src/infra/update-global.ts @@ -3,6 +3,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { NPM_UPDATE_COMPAT_SIDECAR_PATHS } from "../../scripts/lib/npm-update-compat-sidecars.mjs"; +import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../plugins/runtime-sidecar-paths.js"; import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js"; import { pathExists } from "../utils.js"; import { @@ -110,12 +111,36 @@ async function collectInstalledPackageDistErrors(packageRoot: string): Promise `missing bundled runtime sidecar ${relativePath}`, }); } +async function collectLegacyInstalledPackageDistPaths(packageRoot: string): Promise { + const expectedFiles = new Set(NPM_UPDATE_COMPAT_SIDECAR_PATHS); + await Promise.all( + BUNDLED_RUNTIME_SIDECAR_PATHS.map(async (relativePath) => { + const pluginRoot = resolveBundledPluginRoot(relativePath); + if (pluginRoot === null) { + return; + } + if ( + (await pathExists(path.join(packageRoot, pluginRoot, "package.json"))) || + (await pathExists(path.join(packageRoot, pluginRoot, "openclaw.plugin.json"))) + ) { + expectedFiles.add(relativePath); + } + }), + ); + return [...expectedFiles].toSorted((left, right) => left.localeCompare(right)); +} + +function resolveBundledPluginRoot(relativePath: string): string | null { + const match = /^dist\/extensions\/[^/]+/u.exec(relativePath); + return match ? match[0] : null; +} + async function collectInstalledPathErrors(params: { packageRoot: string; expectedFiles: string[];