Revert "Fix bundled channel dist-runtime setup roots" (#82612)

This reverts commit 1bd10cfee6.

Co-authored-by: Gio Della-Libera <giodl@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Gio Della-Libera
2026-05-16 07:07:39 -07:00
committed by GitHub
parent 58083866d0
commit caf8fa2ebf
6 changed files with 7 additions and 91 deletions

View File

@@ -2036,8 +2036,6 @@ describe("initSessionState reset triggers in WhatsApp groups", () => {
const storePath = await createStorePath("openclaw-group-activation-backfill-");
await writeSessionStoreFast(storePath, {
[sessionKey]: {
sessionId: "activation-only",
updatedAt: 0,
groupActivation: "always",
},
});

View File

@@ -187,7 +187,6 @@ afterEach(() => {
vi.doUnmock("../../plugins/manifest-registry.js");
vi.doUnmock("../../plugins/channel-catalog-registry.js");
vi.doUnmock("../../infra/boundary-file-read.js");
vi.doUnmock("./bundled-root.js");
vi.doUnmock("jiti");
});
@@ -576,63 +575,6 @@ describe("bundled channel entry shape guards", () => {
}
});
it("uses dist-runtime as the boundary root for packaged setup entries", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-runtime-root-"));
const pluginDir = path.join(root, "dist-runtime", "extensions", "alpha");
fs.mkdirSync(pluginDir, { recursive: true });
fs.writeFileSync(
path.join(pluginDir, "setup-entry.js"),
[
"export default {",
" kind: 'bundled-channel-setup-entry',",
" loadSetupPlugin() {",
" return {",
" id: 'alpha',",
" meta: { id: 'alpha', label: 'Setup dist-runtime' },",
" capabilities: {},",
" config: {},",
" };",
" },",
"};",
"",
].join("\n"),
"utf8",
);
vi.doMock("./bundled-root.js", () => ({
resolveBundledChannelRootScope: () => ({
packageRoot: root,
cacheKey: `${root}:dist-runtime`,
}),
}));
vi.doMock("../../plugins/bundled-channel-runtime.js", () => ({
listBundledChannelPluginMetadata: () => [alphaChannelMetadata({ includeSetup: true })],
resolveBundledChannelGeneratedPath: (
rootDir: string,
entry: BundledEntrySource | undefined,
pluginDirName?: string,
) =>
path.join(
rootDir,
"dist-runtime",
"extensions",
pluginDirName ?? "alpha",
(entry?.built ?? entry?.source ?? "./index.js").replace(/^\.\//u, ""),
),
}));
try {
const bundled = await importFreshModule<typeof import("./bundled.js")>(
import.meta.url,
"./bundled.js?scope=bundled-dist-runtime-boundary",
);
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup dist-runtime");
} finally {
fs.rmSync(root, { recursive: true, force: true });
}
});
it("loads setup-entry feature plugins without loading the main channel entry", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-setup-only-"));
const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;

View File

@@ -1,7 +1,6 @@
import path from "node:path";
import type { OpenClawConfig } from "../../config/types.openclaw.js";
import { formatErrorMessage } from "../../infra/errors.js";
import { isPathInside } from "../../infra/path-guards.js";
import { createSubsystemLogger } from "../../logging/subsystem.js";
import type {
BundledChannelLegacySessionSurface,
@@ -161,26 +160,20 @@ function resolveBundledChannelBoundaryRoot(params: {
metadata: BundledChannelPluginMetadata;
modulePath: string;
}): string {
const isModuleUnderRoot = (root: string) => isPathInside(path.resolve(root), params.modulePath);
const overrideRoot = params.pluginsDir
? path.resolve(params.pluginsDir, params.metadata.dirName)
: null;
if (overrideRoot && isModuleUnderRoot(overrideRoot)) {
if (
overrideRoot &&
(params.modulePath === overrideRoot ||
params.modulePath.startsWith(`${overrideRoot}${path.sep}`))
) {
return overrideRoot;
}
const distRoot = path.resolve(params.packageRoot, "dist", "extensions", params.metadata.dirName);
if (isModuleUnderRoot(distRoot)) {
if (params.modulePath === distRoot || params.modulePath.startsWith(`${distRoot}${path.sep}`)) {
return distRoot;
}
const distRuntimeRoot = path.resolve(
params.packageRoot,
"dist-runtime",
"extensions",
params.metadata.dirName,
);
if (isModuleUnderRoot(distRuntimeRoot)) {
return distRuntimeRoot;
}
return path.resolve(params.packageRoot, "extensions", params.metadata.dirName);
}

View File

@@ -68,7 +68,7 @@ describe("describeHeartbeatSessionTargetIssues", () => {
const cfg = cfgWithSession("agent:ops:main");
writeStore(cfg, {
"agent:ops:work": {
sessionId: "agent-ops-work",
sessionId: "agent:ops:work",
updatedAt: Date.now(),
},
});

View File

@@ -631,22 +631,6 @@ describe("bundled plugin metadata", () => {
expectGeneratedPathResolution(tempRoot, path.join("dist", "extensions", "plugin", "index.js"));
});
it("uses dist-runtime generated paths before source fallback when packaged dist is absent", () => {
const tempRoot = createGeneratedPluginTempRoot("openclaw-bundled-plugin-runtime-metadata-");
const pluginRoot = path.join(tempRoot, "extensions", "plugin");
const runtimePluginRoot = path.join(tempRoot, "dist-runtime", "extensions", "plugin");
fs.mkdirSync(pluginRoot, { recursive: true });
fs.mkdirSync(runtimePluginRoot, { recursive: true });
fs.writeFileSync(path.join(pluginRoot, "index.ts"), "export {};\n", "utf8");
fs.writeFileSync(path.join(runtimePluginRoot, "index.js"), "export {};\n", "utf8");
expectGeneratedPathResolution(
tempRoot,
path.join("dist-runtime", "extensions", "plugin", "index.js"),
);
});
it("resolves plugin-local generated entry paths when the plugin dir is provided", () => {
const tempRoot = createGeneratedPluginTempRoot("openclaw-bundled-plugin-metadata-local-");
const pluginRoot = path.join(tempRoot, "extensions", "alpha");

View File

@@ -231,7 +231,6 @@ function listBundledPluginEntryBaseDirs(params: {
const baseDirs = [
...(params.scanDir ? [path.resolve(params.scanDir, params.pluginDirName ?? "")] : []),
path.resolve(params.rootDir, "dist", "extensions", params.pluginDirName ?? ""),
path.resolve(params.rootDir, "dist-runtime", "extensions", params.pluginDirName ?? ""),
path.resolve(params.rootDir, "extensions", params.pluginDirName ?? ""),
];
return baseDirs.filter((entry, index, all) => all.indexOf(entry) === index);