





















@@ -12,6 +12,7 @@ import type { ConfigFileSnapshot, OpenClawConfig } from "./types.js";
1212const mockLoadConfig = vi.hoisted(() => vi.fn<() => OpenClawConfig>());
1313const mockReadConfigFileSnapshot = vi.hoisted(() => vi.fn<() => Promise<ConfigFileSnapshot>>());
1414const mockLoadPluginManifestRegistry = vi.hoisted(() => vi.fn());
15+const mockGetCurrentPluginMetadataSnapshot = vi.hoisted(() => vi.fn());
15161617let readBestEffortRuntimeConfigSchema: typeof import("./runtime-schema.js").readBestEffortRuntimeConfigSchema;
1718let loadGatewayRuntimeConfigSchema: typeof import("./runtime-schema.js").loadGatewayRuntimeConfigSchema;
@@ -33,6 +34,11 @@ vi.mock("../plugins/plugin-registry.js", () => ({
3334mockLoadPluginManifestRegistry(...args),
3435}));
353637+vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({
38+getCurrentPluginMetadataSnapshot: (...args: unknown[]) =>
39+mockGetCurrentPluginMetadataSnapshot(...args),
40+}));
41+3642function makeSnapshot(params: { valid: boolean; config?: OpenClawConfig }): ConfigFileSnapshot {
3743return {
3844path: "/tmp/openclaw.json",
@@ -182,7 +188,7 @@ describe("readBestEffortRuntimeConfigSchema", () => {
182188expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
183189expect.objectContaining({
184190config: { plugins: { entries: { demo: { enabled: true } } } },
185-cache: false,
191+cache: true,
186192}),
187193);
188194expect(channelProps?.telegram).toBeTruthy();
@@ -198,7 +204,7 @@ describe("readBestEffortRuntimeConfigSchema", () => {
198204expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
199205expect.objectContaining({
200206config: { plugins: { enabled: true } },
201-cache: false,
207+cache: true,
202208}),
203209);
204210expect(channelProps?.telegram).toBeTruthy();
@@ -223,10 +229,62 @@ describe("loadGatewayRuntimeConfigSchema", () => {
223229expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
224230expect.objectContaining({
225231config: { plugins: { entries: { demo: { enabled: true } } } },
226-cache: false,
232+cache: true,
233+}),
234+);
235+expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty(
236+"bundledChannelConfigCollector",
237+);
238+expect(channelProps?.telegram).toBeTruthy();
239+expect(channelProps?.matrix).toBeTruthy();
240+});
241+242+it("reuses the current gateway plugin metadata snapshot for config schema requests", () => {
243+mockGetCurrentPluginMetadataSnapshot.mockReturnValueOnce({
244+manifestRegistry: {
245+diagnostics: [],
246+plugins: [
247+{
248+id: "telegram",
249+name: "Telegram",
250+description: "Telegram plugin",
251+origin: "bundled",
252+channels: ["telegram"],
253+},
254+{
255+id: "matrix",
256+name: "Matrix",
257+description: "Matrix plugin",
258+origin: "workspace",
259+channels: ["matrix"],
260+channelConfigs: {
261+matrix: {
262+schema: {
263+type: "object",
264+properties: {
265+homeserver: { type: "string" },
266+},
267+},
268+},
269+},
270+},
271+],
272+},
273+});
274+275+const result = loadGatewayRuntimeConfigSchema();
276+const schema = result.schema as { properties?: Record<string, unknown> };
277+const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
278+const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
279+280+expect(mockGetCurrentPluginMetadataSnapshot).toHaveBeenCalledWith(
281+expect.objectContaining({
282+config: { plugins: { entries: { demo: { enabled: true } } } },
227283}),
228284);
285+expect(mockLoadPluginManifestRegistry).not.toHaveBeenCalled();
229286expect(channelProps?.telegram).toBeTruthy();
287+expect(JSON.stringify(channelProps?.telegram)).toContain("botToken");
230288expect(channelProps?.matrix).toBeTruthy();
231289});
232290@@ -246,7 +304,8 @@ describe("loadGatewayRuntimeConfigSchema", () => {
246304247305expect(mockLoadPluginManifestRegistry).toHaveBeenCalledTimes(3);
248306for (const call of mockLoadPluginManifestRegistry.mock.calls) {
249-expect(call[0]).toMatchObject({ cache: false });
307+expect(call[0]).toMatchObject({ cache: true });
308+expect(call[0]).not.toHaveProperty("bundledChannelConfigCollector");
250309}
251310expect(getActivePluginRegistry()).toBe(activeRegistry);
252311expect(getActivePluginRegistryKey()).toBe("startup-registry");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。