


























@@ -203,7 +203,7 @@ describe("resolvePluginCapabilityProviders", () => {
203203expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
204204});
205205206-it("keeps active capability providers even when cfg is passed", () => {
206+it("keeps active capability providers when cfg compat has no extra providers", () => {
207207const active = createEmptyPluginRegistry();
208208active.speechProviders.push({
209209pluginId: "microsoft",
@@ -233,11 +233,80 @@ describe("resolvePluginCapabilityProviders", () => {
233233234234expectResolvedCapabilityProviderIds(providers, ["microsoft"]);
235235expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
236-expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalledWith({
236+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
237237config: expect.anything(),
238238});
239239});
240240241+it("merges active and allowlisted bundled capability providers when cfg is passed", () => {
242+const active = createEmptyPluginRegistry();
243+active.speechProviders.push({
244+pluginId: "openai",
245+pluginName: "openai",
246+source: "test",
247+provider: {
248+id: "openai",
249+label: "openai",
250+isConfigured: () => true,
251+synthesize: async () => ({
252+audioBuffer: Buffer.from("x"),
253+outputFormat: "mp3",
254+voiceCompatible: false,
255+fileExtension: ".mp3",
256+}),
257+},
258+} as never);
259+const loaded = createEmptyPluginRegistry();
260+loaded.speechProviders.push({
261+pluginId: "microsoft",
262+pluginName: "microsoft",
263+source: "test",
264+provider: {
265+id: "microsoft",
266+label: "microsoft",
267+aliases: ["edge"],
268+isConfigured: () => true,
269+synthesize: async () => ({
270+audioBuffer: Buffer.from("x"),
271+outputFormat: "mp3",
272+voiceCompatible: false,
273+fileExtension: ".mp3",
274+}),
275+},
276+} as never);
277+mocks.loadPluginManifestRegistry.mockReturnValue({
278+plugins: [
279+{
280+id: "microsoft",
281+origin: "bundled",
282+contracts: { speechProviders: ["microsoft"] },
283+},
284+] as never,
285+diagnostics: [],
286+});
287+mocks.resolveRuntimePluginRegistry.mockImplementation((params?: unknown) =>
288+params === undefined ? active : loaded,
289+);
290+291+const providers = resolvePluginCapabilityProviders({
292+key: "speechProviders",
293+cfg: {
294+plugins: { allow: ["openai", "microsoft"] },
295+messages: { tts: { provider: "edge" } },
296+} as OpenClawConfig,
297+});
298+299+expectResolvedCapabilityProviderIds(providers, ["openai", "microsoft"]);
300+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
301+expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
302+config: expect.objectContaining({
303+plugins: expect.objectContaining({
304+allow: ["openai", "microsoft"],
305+}),
306+}),
307+});
308+});
309+241310it.each([
242311["memoryEmbeddingProviders", "memoryEmbeddingProviders"],
243312["speechProviders", "speechProviders"],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。