perf(secrets): narrow legacy web search compat providers

This commit is contained in:
Vincent Koc
2026-04-07 11:24:55 +01:00
parent f6124f3e17
commit 5613f5a834
9 changed files with 267 additions and 4 deletions

View File

@@ -0,0 +1,48 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const { loadPluginManifestRegistryMock } = vi.hoisted(() => ({
loadPluginManifestRegistryMock: vi.fn(() => {
throw new Error("manifest registry should stay off the explicit bundled fast path");
}),
}));
vi.mock("./manifest-registry.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("./manifest-registry.js")>();
return {
...actual,
loadPluginManifestRegistry: loadPluginManifestRegistryMock,
};
});
import {
resolveBundledWebFetchProvidersFromPublicArtifacts,
resolveBundledWebSearchProvidersFromPublicArtifacts,
} from "./web-provider-public-artifacts.js";
describe("web provider public artifacts explicit fast path", () => {
beforeEach(() => {
loadPluginManifestRegistryMock.mockClear();
});
it("resolves bundled web search providers by explicit plugin id without manifest scans", () => {
const provider = resolveBundledWebSearchProvidersFromPublicArtifacts({
bundledAllowlistCompat: true,
onlyPluginIds: ["brave"],
})?.[0];
expect(provider?.pluginId).toBe("brave");
expect(provider?.createTool({ config: {} as never })).toBeNull();
expect(loadPluginManifestRegistryMock).not.toHaveBeenCalled();
});
it("resolves bundled web fetch providers by explicit plugin id without manifest scans", () => {
const provider = resolveBundledWebFetchProvidersFromPublicArtifacts({
bundledAllowlistCompat: true,
onlyPluginIds: ["firecrawl"],
})?.[0];
expect(provider?.pluginId).toBe("firecrawl");
expect(provider?.createTool({ config: {} as never })).toBeNull();
expect(loadPluginManifestRegistryMock).not.toHaveBeenCalled();
});
});