




















@@ -9,11 +9,17 @@ import {
99} from "./package-state-probes.js";
10101111const listChannelCatalogEntriesMock = vi.hoisted(() => vi.fn());
12+const isBundledSourceOverlayPathMock = vi.hoisted(() =>
13+vi.fn((_params: { sourcePath: string }) => false),
14+);
1215const tempDirs: string[] = [];
13161417vi.mock("../../plugins/channel-catalog-registry.js", () => ({
1518listChannelCatalogEntries: listChannelCatalogEntriesMock,
1619}));
20+vi.mock("../../plugins/bundled-source-overlays.js", () => ({
21+isBundledSourceOverlayPath: isBundledSourceOverlayPathMock,
22+}));
17231824function makeBundledChannelCatalogEntry(params: {
1925pluginId: string;
@@ -43,6 +49,8 @@ function removeTempDirs() {
4349beforeEach(() => {
4450removeTempDirs();
4551listChannelCatalogEntriesMock.mockReset();
52+isBundledSourceOverlayPathMock.mockReset();
53+isBundledSourceOverlayPathMock.mockReturnValue(false);
4654});
47554856afterEach(() => {
@@ -161,6 +169,51 @@ describe("channel package-state probes", () => {
161169).toBe(true);
162170});
163171172+it("preserves source overlay precedence over packaged package-state probes", () => {
173+const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-package-state-overlay-"));
174+tempDirs.push(root);
175+const sourceRoot = path.join(root, "extensions", "matrix");
176+const builtRoot = path.join(root, "dist", "extensions", "matrix");
177+fs.mkdirSync(sourceRoot, { recursive: true });
178+fs.mkdirSync(builtRoot, { recursive: true });
179+fs.writeFileSync(
180+path.join(sourceRoot, "auth-presence.js"),
181+"module.exports.hasAnyMatrixAuth = () => true;\n",
182+"utf8",
183+);
184+fs.writeFileSync(
185+path.join(builtRoot, "auth-presence.js"),
186+"module.exports.hasAnyMatrixAuth = () => false;\n",
187+"utf8",
188+);
189+isBundledSourceOverlayPathMock.mockImplementation(
190+({ sourcePath }: { sourcePath: string }) => path.resolve(sourcePath) === sourceRoot,
191+);
192+193+listChannelCatalogEntriesMock.mockReturnValue([
194+{
195+pluginId: "matrix",
196+origin: "bundled",
197+rootDir: sourceRoot,
198+channel: {
199+id: "matrix",
200+persistedAuthState: {
201+specifier: "./auth-presence",
202+exportName: "hasAnyMatrixAuth",
203+},
204+},
205+} satisfies PluginChannelCatalogEntry,
206+]);
207+208+expect(
209+hasBundledChannelPackageState({
210+metadataKey: "persistedAuthState",
211+channelId: "matrix",
212+cfg: {},
213+}),
214+).toBe(true);
215+});
216+164217it("tries dist-runtime package-state probes before falling back to source", () => {
165218const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-package-state-runtime-"));
166219tempDirs.push(root);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。