
























@@ -1,4 +1,5 @@
11import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
2+import type { PluginLookUpTable } from "../plugins/plugin-lookup-table.js";
23import type { PluginRegistry } from "../plugins/registry.js";
34import type { PluginRuntimeGatewayRequestScope } from "../plugins/runtime/gateway-request-scope.js";
45import type { PluginRuntime } from "../plugins/runtime/types.js";
@@ -108,6 +109,47 @@ const createRegistry = (diagnostics: PluginDiagnostic[]): PluginRegistry => ({
108109 diagnostics,
109110});
110111112+function createLookUpTableForTest(params: {
113+manifestRegistry?: PluginLookUpTable["manifestRegistry"];
114+pluginIds?: readonly string[];
115+}): PluginLookUpTable {
116+return {
117+key: "test",
118+index: {
119+version: 1,
120+hostContractVersion: "test",
121+compatRegistryVersion: "test",
122+migrationVersion: 1,
123+policyHash: "test",
124+generatedAtMs: 1,
125+installRecords: {},
126+plugins: [],
127+diagnostics: [],
128+},
129+registryDiagnostics: [],
130+manifestRegistry: params.manifestRegistry ?? { plugins: [], diagnostics: [] },
131+plugins: [],
132+diagnostics: [],
133+byPluginId: new Map(),
134+normalizePluginId: (pluginId) => pluginId,
135+owners: {
136+channels: new Map(),
137+channelConfigs: new Map(),
138+providers: new Map(),
139+modelCatalogProviders: new Map(),
140+cliBackends: new Map(),
141+setupProviders: new Map(),
142+commandAliases: new Map(),
143+contracts: new Map(),
144+},
145+startup: {
146+channelPluginIds: [],
147+configuredDeferredChannelPluginIds: [],
148+pluginIds: params.pluginIds ?? [],
149+},
150+};
151+}
152+111153type ServerPluginsModule = typeof import("./server-plugins.js");
112154type ServerPluginBootstrapModule = typeof import("./server-plugin-bootstrap.js");
113155type PluginRuntimeModule = typeof import("../plugins/runtime/index.js");
@@ -372,6 +414,30 @@ describe("loadGatewayPlugins", () => {
372414);
373415});
374416417+test("reuses a provided lookup table for startup scope and auto-enable manifests", async () => {
418+loadOpenClawPlugins.mockReturnValue(createRegistry([]));
419+const manifestRegistry = { plugins: [], diagnostics: [] };
420+421+loadGatewayPluginsForTest({
422+pluginLookUpTable: createLookUpTableForTest({
423+ manifestRegistry,
424+pluginIds: ["telegram"],
425+}),
426+});
427+428+expect(loadPluginLookUpTable).not.toHaveBeenCalled();
429+expect(applyPluginAutoEnable).toHaveBeenCalledWith({
430+config: {},
431+env: process.env,
432+ manifestRegistry,
433+});
434+expect(loadOpenClawPlugins).toHaveBeenCalledWith(
435+expect.objectContaining({
436+onlyPluginIds: ["telegram"],
437+}),
438+);
439+});
440+375441test("pins the initial startup channel registry against later active-registry churn", async () => {
376442const startupRegistry = createRegistry([]);
377443loadOpenClawPlugins.mockReturnValue(startupRegistry);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。