fix(plugins): scope capability provider snapshots

This commit is contained in:
Vincent Koc
2026-04-28 22:19:07 -07:00
parent 2f04731a48
commit 7c7561f5a3
2 changed files with 30 additions and 4 deletions

View File

@@ -101,6 +101,7 @@ function expectBundledCompatLoadPath(params: {
});
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: params.enablementCompat,
onlyPluginIds: ["openai"],
activate: false,
});
}
@@ -400,6 +401,7 @@ describe("resolvePluginCapabilityProviders", () => {
allow: ["openai", "microsoft"],
}),
}),
onlyPluginIds: ["microsoft"],
activate: false,
});
});
@@ -573,6 +575,7 @@ describe("resolvePluginCapabilityProviders", () => {
expectNoResolvedCapabilityProviders(providers);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: expect.anything(),
onlyPluginIds: [],
activate: false,
});
});
@@ -600,7 +603,16 @@ describe("resolvePluginCapabilityProviders", () => {
nativeDocumentInputs: ["pdf"],
},
} as never);
setBundledCapabilityFixture("mediaUnderstandingProviders");
mocks.loadPluginManifestRegistry.mockReturnValue({
plugins: [
{
id: "google",
origin: "bundled",
contracts: { mediaUnderstandingProviders: ["google"] },
},
] as never,
diagnostics: [],
});
mocks.withBundledPluginEnablementCompat.mockReturnValue(compatConfig);
mocks.withBundledPluginVitestCompat.mockReturnValue(compatConfig);
mocks.resolveRuntimePluginRegistry.mockImplementation((params?: unknown) =>
@@ -616,6 +628,7 @@ describe("resolvePluginCapabilityProviders", () => {
});
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: compatConfig,
onlyPluginIds: ["google"],
activate: false,
});
});
@@ -681,6 +694,7 @@ describe("resolvePluginCapabilityProviders", () => {
});
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
config: enablementCompat,
onlyPluginIds: ["google"],
activate: false,
});
});

View File

@@ -226,7 +226,9 @@ export function resolvePluginCapabilityProvider<K extends CapabilityProviderRegi
pluginIds,
});
const loadOptions =
compatConfig === undefined ? undefined : { config: compatConfig, activate: false };
compatConfig === undefined
? { onlyPluginIds: pluginIds, activate: false }
: { config: compatConfig, onlyPluginIds: pluginIds, activate: false };
const registry = resolveRuntimePluginRegistry(loadOptions);
return findProviderById(registry?.[params.key] ?? [], params.providerId);
}
@@ -258,9 +260,19 @@ export function resolvePluginCapabilityProviders<K extends CapabilityProviderReg
return activeProviders.map((entry) => entry.provider) as CapabilityProviderForKey<K>[];
}
}
const compatConfig = resolveCapabilityProviderConfig({ key: params.key, cfg: params.cfg });
const pluginIds = resolveBundledCapabilityCompatPluginIds({
key: params.key,
cfg: params.cfg,
});
const compatConfig = resolveCapabilityProviderConfig({
key: params.key,
cfg: params.cfg,
pluginIds,
});
const loadOptions =
compatConfig === undefined ? undefined : { config: compatConfig, activate: false };
compatConfig === undefined
? { onlyPluginIds: pluginIds, activate: false }
: { config: compatConfig, onlyPluginIds: pluginIds, activate: false };
const registry = resolveRuntimePluginRegistry(loadOptions);
const loadedProviders = registry?.[params.key] ?? [];
if (params.key !== "memoryEmbeddingProviders") {