fix(plugins): preserve active capability providers

This commit is contained in:
Ayaan Zaidi
2026-03-28 15:46:24 +05:30
parent 8ea5c22985
commit c06dcf6b8b
2 changed files with 41 additions and 1 deletions

View File

@@ -171,7 +171,42 @@ describe("resolvePluginCapabilityProviders", () => {
expectResolvedCapabilityProviderIds(providers, ["openai"]);
expect(mocks.loadPluginManifestRegistry).not.toHaveBeenCalled();
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith(undefined);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
});
it("keeps active capability providers even when cfg is passed", () => {
const active = createEmptyPluginRegistry();
active.speechProviders.push({
pluginId: "microsoft",
pluginName: "microsoft",
source: "test",
provider: {
id: "microsoft",
label: "microsoft",
aliases: ["edge"],
isConfigured: () => true,
synthesize: async () => ({
audioBuffer: Buffer.from("x"),
outputFormat: "mp3",
voiceCompatible: false,
fileExtension: ".mp3",
}),
},
} as never);
mocks.resolveRuntimePluginRegistry.mockImplementation((params?: unknown) =>
params === undefined ? active : createEmptyPluginRegistry(),
);
const providers = resolvePluginCapabilityProviders({
key: "speechProviders",
cfg: { messages: { tts: { provider: "edge" } } } as OpenClawConfig,
});
expectResolvedCapabilityProviderIds(providers, ["microsoft"]);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();
expect(mocks.resolveRuntimePluginRegistry).not.toHaveBeenCalledWith({
config: expect.anything(),
});
});
it.each([

View File

@@ -67,6 +67,11 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
key: K;
cfg?: OpenClawConfig;
}): CapabilityProviderForKey<K>[] {
const activeRegistry = resolveRuntimePluginRegistry();
const activeProviders = activeRegistry?.[params.key] ?? [];
if (activeProviders.length > 0) {
return activeProviders.map((entry) => entry.provider) as CapabilityProviderForKey<K>[];
}
const loadOptions =
params.cfg === undefined
? undefined