Skip to content

Commit caf8fa2

Browse files
giodl73-repoGio Della-LiberaCopilot
authored
Revert "Fix bundled channel dist-runtime setup roots" (#82612)
This reverts commit 1bd10cf. Co-authored-by: Gio Della-Libera <giodl@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5808386 commit caf8fa2

6 files changed

Lines changed: 7 additions & 91 deletions

File tree

src/auto-reply/reply/session.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,8 +2036,6 @@ describe("initSessionState reset triggers in WhatsApp groups", () => {
20362036
const storePath = await createStorePath("openclaw-group-activation-backfill-");
20372037
await writeSessionStoreFast(storePath, {
20382038
[sessionKey]: {
2039-
sessionId: "activation-only",
2040-
updatedAt: 0,
20412039
groupActivation: "always",
20422040
},
20432041
});

src/channels/plugins/bundled.shape-guard.test.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ afterEach(() => {
187187
vi.doUnmock("../../plugins/manifest-registry.js");
188188
vi.doUnmock("../../plugins/channel-catalog-registry.js");
189189
vi.doUnmock("../../infra/boundary-file-read.js");
190-
vi.doUnmock("./bundled-root.js");
191190
vi.doUnmock("jiti");
192191
});
193192

@@ -576,63 +575,6 @@ describe("bundled channel entry shape guards", () => {
576575
}
577576
});
578577

579-
it("uses dist-runtime as the boundary root for packaged setup entries", async () => {
580-
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-runtime-root-"));
581-
const pluginDir = path.join(root, "dist-runtime", "extensions", "alpha");
582-
fs.mkdirSync(pluginDir, { recursive: true });
583-
fs.writeFileSync(
584-
path.join(pluginDir, "setup-entry.js"),
585-
[
586-
"export default {",
587-
" kind: 'bundled-channel-setup-entry',",
588-
" loadSetupPlugin() {",
589-
" return {",
590-
" id: 'alpha',",
591-
" meta: { id: 'alpha', label: 'Setup dist-runtime' },",
592-
" capabilities: {},",
593-
" config: {},",
594-
" };",
595-
" },",
596-
"};",
597-
"",
598-
].join("\n"),
599-
"utf8",
600-
);
601-
602-
vi.doMock("./bundled-root.js", () => ({
603-
resolveBundledChannelRootScope: () => ({
604-
packageRoot: root,
605-
cacheKey: `${root}:dist-runtime`,
606-
}),
607-
}));
608-
vi.doMock("../../plugins/bundled-channel-runtime.js", () => ({
609-
listBundledChannelPluginMetadata: () => [alphaChannelMetadata({ includeSetup: true })],
610-
resolveBundledChannelGeneratedPath: (
611-
rootDir: string,
612-
entry: BundledEntrySource | undefined,
613-
pluginDirName?: string,
614-
) =>
615-
path.join(
616-
rootDir,
617-
"dist-runtime",
618-
"extensions",
619-
pluginDirName ?? "alpha",
620-
(entry?.built ?? entry?.source ?? "./index.js").replace(/^\.\//u, ""),
621-
),
622-
}));
623-
624-
try {
625-
const bundled = await importFreshModule<typeof import("./bundled.js")>(
626-
import.meta.url,
627-
"./bundled.js?scope=bundled-dist-runtime-boundary",
628-
);
629-
630-
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup dist-runtime");
631-
} finally {
632-
fs.rmSync(root, { recursive: true, force: true });
633-
}
634-
});
635-
636578
it("loads setup-entry feature plugins without loading the main channel entry", async () => {
637579
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-bundled-setup-only-"));
638580
const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;

src/channels/plugins/bundled.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from "node:path";
22
import type { OpenClawConfig } from "../../config/types.openclaw.js";
33
import { formatErrorMessage } from "../../infra/errors.js";
4-
import { isPathInside } from "../../infra/path-guards.js";
54
import { createSubsystemLogger } from "../../logging/subsystem.js";
65
import type {
76
BundledChannelLegacySessionSurface,
@@ -161,26 +160,20 @@ function resolveBundledChannelBoundaryRoot(params: {
161160
metadata: BundledChannelPluginMetadata;
162161
modulePath: string;
163162
}): string {
164-
const isModuleUnderRoot = (root: string) => isPathInside(path.resolve(root), params.modulePath);
165163
const overrideRoot = params.pluginsDir
166164
? path.resolve(params.pluginsDir, params.metadata.dirName)
167165
: null;
168-
if (overrideRoot && isModuleUnderRoot(overrideRoot)) {
166+
if (
167+
overrideRoot &&
168+
(params.modulePath === overrideRoot ||
169+
params.modulePath.startsWith(`${overrideRoot}${path.sep}`))
170+
) {
169171
return overrideRoot;
170172
}
171173
const distRoot = path.resolve(params.packageRoot, "dist", "extensions", params.metadata.dirName);
172-
if (isModuleUnderRoot(distRoot)) {
174+
if (params.modulePath === distRoot || params.modulePath.startsWith(`${distRoot}${path.sep}`)) {
173175
return distRoot;
174176
}
175-
const distRuntimeRoot = path.resolve(
176-
params.packageRoot,
177-
"dist-runtime",
178-
"extensions",
179-
params.metadata.dirName,
180-
);
181-
if (isModuleUnderRoot(distRuntimeRoot)) {
182-
return distRuntimeRoot;
183-
}
184177
return path.resolve(params.packageRoot, "extensions", params.metadata.dirName);
185178
}
186179

src/commands/doctor-heartbeat-session-target.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe("describeHeartbeatSessionTargetIssues", () => {
6868
const cfg = cfgWithSession("agent:ops:main");
6969
writeStore(cfg, {
7070
"agent:ops:work": {
71-
sessionId: "agent-ops-work",
71+
sessionId: "agent:ops:work",
7272
updatedAt: Date.now(),
7373
},
7474
});

src/plugins/bundled-plugin-metadata.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -631,22 +631,6 @@ describe("bundled plugin metadata", () => {
631631
expectGeneratedPathResolution(tempRoot, path.join("dist", "extensions", "plugin", "index.js"));
632632
});
633633

634-
it("uses dist-runtime generated paths before source fallback when packaged dist is absent", () => {
635-
const tempRoot = createGeneratedPluginTempRoot("openclaw-bundled-plugin-runtime-metadata-");
636-
const pluginRoot = path.join(tempRoot, "extensions", "plugin");
637-
const runtimePluginRoot = path.join(tempRoot, "dist-runtime", "extensions", "plugin");
638-
639-
fs.mkdirSync(pluginRoot, { recursive: true });
640-
fs.mkdirSync(runtimePluginRoot, { recursive: true });
641-
fs.writeFileSync(path.join(pluginRoot, "index.ts"), "export {};\n", "utf8");
642-
fs.writeFileSync(path.join(runtimePluginRoot, "index.js"), "export {};\n", "utf8");
643-
644-
expectGeneratedPathResolution(
645-
tempRoot,
646-
path.join("dist-runtime", "extensions", "plugin", "index.js"),
647-
);
648-
});
649-
650634
it("resolves plugin-local generated entry paths when the plugin dir is provided", () => {
651635
const tempRoot = createGeneratedPluginTempRoot("openclaw-bundled-plugin-metadata-local-");
652636
const pluginRoot = path.join(tempRoot, "extensions", "alpha");

src/plugins/bundled-plugin-metadata.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ function listBundledPluginEntryBaseDirs(params: {
231231
const baseDirs = [
232232
...(params.scanDir ? [path.resolve(params.scanDir, params.pluginDirName ?? "")] : []),
233233
path.resolve(params.rootDir, "dist", "extensions", params.pluginDirName ?? ""),
234-
path.resolve(params.rootDir, "dist-runtime", "extensions", params.pluginDirName ?? ""),
235234
path.resolve(params.rootDir, "extensions", params.pluginDirName ?? ""),
236235
];
237236
return baseDirs.filter((entry, index, all) => all.indexOf(entry) === index);

0 commit comments

Comments
 (0)