






















@@ -657,10 +657,10 @@ describe("resolvePluginCapabilityProviders", () => {
657657});
658658});
659659660-it("does not load bundled capability providers when plugins are globally disabled", () => {
660+it("uses active capability providers when plugins are globally disabled", () => {
661661const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
662-const loaded = createEmptyPluginRegistry();
663-loaded.mediaUnderstandingProviders.push({
662+const active = createEmptyPluginRegistry();
663+active.mediaUnderstandingProviders.push({
664664pluginId: "openai",
665665pluginName: "openai",
666666source: "test",
@@ -669,20 +669,99 @@ describe("resolvePluginCapabilityProviders", () => {
669669capabilities: ["image"],
670670},
671671} as never);
672-mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
672+mocks.resolveRuntimePluginRegistry.mockReturnValue(active);
673673674-expectNoResolvedCapabilityProviders(
675-resolvePluginCapabilityProviders({
676-key: "mediaUnderstandingProviders",
677- cfg,
678-}),
679-);
674+const providers = resolvePluginCapabilityProviders({
675+key: "mediaUnderstandingProviders",
676+ cfg,
677+});
680678679+expectResolvedCapabilityProviderIds(providers, ["openai"]);
681680expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
682681expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
683682expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
684683expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
685-expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
684+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
685+});
686+687+it("loads bundled speech providers through compat when plugins are globally disabled", () => {
688+const cfg = {
689+plugins: { enabled: false },
690+messages: { tts: { provider: "mistral" } },
691+} as OpenClawConfig;
692+const allowlistCompat = {
693+ ...cfg,
694+plugins: {
695+enabled: false,
696+allow: ["microsoft"],
697+},
698+} as OpenClawConfig;
699+const compatConfig = {
700+ ...cfg,
701+plugins: {
702+enabled: true,
703+allow: ["microsoft"],
704+entries: { microsoft: { enabled: true } },
705+},
706+} as OpenClawConfig;
707+const loaded = createEmptyPluginRegistry();
708+loaded.speechProviders.push({
709+pluginId: "microsoft",
710+pluginName: "microsoft",
711+source: "test",
712+provider: {
713+id: "microsoft",
714+label: "microsoft",
715+aliases: ["edge"],
716+isConfigured: () => true,
717+synthesize: async () => ({
718+audioBuffer: Buffer.from("x"),
719+outputFormat: "mp3",
720+voiceCompatible: false,
721+fileExtension: ".mp3",
722+}),
723+},
724+} as never);
725+mocks.loadPluginManifestRegistry.mockReturnValue({
726+plugins: [
727+{
728+id: "microsoft",
729+origin: "bundled",
730+contracts: { speechProviders: ["microsoft"] },
731+},
732+] as never,
733+diagnostics: [],
734+});
735+mocks.withBundledPluginEnablementCompat.mockReturnValue(compatConfig);
736+mocks.withBundledPluginVitestCompat.mockReturnValue(compatConfig);
737+mocks.resolveRuntimePluginRegistry.mockImplementation((params?: unknown) =>
738+params === undefined ? undefined : loaded,
739+);
740+741+const providers = resolvePluginCapabilityProviders({
742+key: "speechProviders",
743+ cfg,
744+});
745+746+expectResolvedCapabilityProviderIds(providers, ["microsoft"]);
747+expect(mocks.loadPluginManifestRegistry).toHaveBeenCalledWith({
748+config: cfg,
749+env: process.env,
750+});
751+expect(mocks.withBundledPluginAllowlistCompat).toHaveBeenCalledWith({
752+config: cfg,
753+pluginIds: ["microsoft"],
754+});
755+expect(mocks.withBundledPluginEnablementCompat).toHaveBeenCalledWith({
756+config: allowlistCompat,
757+pluginIds: ["microsoft"],
758+});
759+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
760+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
761+config: compatConfig,
762+onlyPluginIds: ["microsoft"],
763+activate: false,
764+});
686765});
687766688767it.each([
@@ -845,8 +924,21 @@ describe("resolvePluginCapabilityProviders", () => {
845924});
846925});
847926848-it("does not load targeted bundled capability providers when plugins are globally disabled", () => {
927+it("loads targeted bundled capability providers through compat when plugins are globally disabled", () => {
849928const cfg = { plugins: { enabled: false, allow: ["custom-plugin"] } } as OpenClawConfig;
929+const allowlistCompat = {
930+plugins: {
931+enabled: false,
932+allow: ["custom-plugin", "google"],
933+},
934+} as OpenClawConfig;
935+const enablementCompat = {
936+plugins: {
937+enabled: true,
938+allow: ["custom-plugin", "google"],
939+entries: { google: { enabled: true } },
940+},
941+};
850942const loaded = createEmptyPluginRegistry();
851943loaded.memoryEmbeddingProviders.push({
852944pluginId: "google",
@@ -857,19 +949,47 @@ describe("resolvePluginCapabilityProviders", () => {
857949create: async () => ({ provider: null }),
858950},
859951} as never);
860-mocks.resolveRuntimePluginRegistry.mockReturnValue(loaded);
952+mocks.loadPluginManifestRegistry.mockReturnValue({
953+plugins: [
954+{
955+id: "google",
956+origin: "bundled",
957+contracts: { memoryEmbeddingProviders: ["gemini"] },
958+},
959+{
960+id: "openai",
961+origin: "bundled",
962+contracts: { memoryEmbeddingProviders: ["openai"] },
963+},
964+] as never,
965+diagnostics: [],
966+});
967+mocks.withBundledPluginEnablementCompat.mockReturnValue(enablementCompat);
968+mocks.withBundledPluginVitestCompat.mockReturnValue(enablementCompat);
969+mocks.resolveRuntimePluginRegistry.mockImplementation((params?: unknown) =>
970+params === undefined ? undefined : loaded,
971+);
861972862973const provider = resolvePluginCapabilityProvider({
863974key: "memoryEmbeddingProviders",
864975providerId: "gemini",
865976 cfg,
866977});
867978868-expect(provider).toBeUndefined();
869-expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
870-expect(mocks.withBundledPluginAllowlistCompat).not.toHaveBeenCalled();
871-expect(mocks.withBundledPluginEnablementCompat).not.toHaveBeenCalled();
872-expect(mocks.withBundledPluginVitestCompat).not.toHaveBeenCalled();
873-expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalled();
979+expect(provider?.id).toBe("gemini");
980+expect(mocks.withBundledPluginAllowlistCompat).toHaveBeenCalledWith({
981+config: cfg,
982+pluginIds: ["google"],
983+});
984+expect(mocks.withBundledPluginEnablementCompat).toHaveBeenCalledWith({
985+config: allowlistCompat,
986+pluginIds: ["google"],
987+});
988+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
989+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
990+config: enablementCompat,
991+onlyPluginIds: ["google"],
992+activate: false,
993+});
874994});
875995});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。