perf(secrets): complete bundled web provider artifacts

This commit is contained in:
Vincent Koc
2026-04-06 23:14:41 +01:00
parent c4e9189dd3
commit 7dd23a59db
5 changed files with 74 additions and 30 deletions

View File

@@ -0,0 +1 @@
export { createMiniMaxWebSearchProvider } from "./src/minimax-web-search-provider.js";

View File

@@ -0,0 +1 @@
export { createOllamaWebSearchProvider } from "./src/web-search-provider.js";

View File

@@ -0,0 +1,44 @@
import { describe, expect, it } from "vitest";
import { resolveManifestContractPluginIds } from "./manifest-registry.js";
import {
resolveBundledWebFetchProvidersFromPublicArtifacts,
resolveBundledWebSearchProvidersFromPublicArtifacts,
} from "./web-provider-public-artifacts.js";
describe("web provider public artifacts", () => {
it("covers every bundled web search provider declared in manifests", () => {
const providers = resolveBundledWebSearchProvidersFromPublicArtifacts({
bundledAllowlistCompat: true,
});
expect(providers).not.toBeNull();
expect(
providers
?.map((entry) => entry.pluginId)
.toSorted((left, right) => left.localeCompare(right)),
).toEqual(
resolveManifestContractPluginIds({
contract: "webSearchProviders",
origin: "bundled",
}),
);
});
it("covers every bundled web fetch provider declared in manifests", () => {
const providers = resolveBundledWebFetchProvidersFromPublicArtifacts({
bundledAllowlistCompat: true,
});
expect(providers).not.toBeNull();
expect(
providers
?.map((entry) => entry.pluginId)
.toSorted((left, right) => left.localeCompare(right)),
).toEqual(
resolveManifestContractPluginIds({
contract: "webFetchProviders",
origin: "bundled",
}),
);
});
});

View File

@@ -160,7 +160,7 @@ function resolveBundledManifestRecordsByPluginId(params: {
export function resolveBundledWebSearchProvidersFromPublicArtifacts(
params: BundledWebProviderPublicArtifactParams,
): PluginWebSearchProviderEntry[] {
): PluginWebSearchProviderEntry[] | null {
const pluginIds = resolveBundledCandidatePluginIds({
contract: "webSearchProviders",
configKey: "webSearch",
@@ -183,32 +183,31 @@ export function resolveBundledWebSearchProvidersFromPublicArtifacts(
for (const pluginId of pluginIds) {
const record = recordsByPluginId.get(pluginId);
if (!record) {
continue;
return null;
}
const mod = tryLoadBundledPublicArtifactModule({
dirName: path.basename(record.rootDir),
artifactCandidates: WEB_SEARCH_ARTIFACT_CANDIDATES,
});
if (!mod) {
continue;
return null;
}
providers.push(
...collectProviderFactories({
mod,
suffix: "WebSearchProvider",
isProvider: isWebSearchProviderPlugin,
}).map((provider) => ({
...provider,
pluginId,
})),
);
const loadedProviders = collectProviderFactories({
mod,
suffix: "WebSearchProvider",
isProvider: isWebSearchProviderPlugin,
});
if (loadedProviders.length === 0) {
return null;
}
providers.push(...loadedProviders.map((provider) => ({ ...provider, pluginId })));
}
return providers;
}
export function resolveBundledWebFetchProvidersFromPublicArtifacts(
params: BundledWebProviderPublicArtifactParams,
): PluginWebFetchProviderEntry[] {
): PluginWebFetchProviderEntry[] | null {
const pluginIds = resolveBundledCandidatePluginIds({
contract: "webFetchProviders",
configKey: "webFetch",
@@ -231,25 +230,24 @@ export function resolveBundledWebFetchProvidersFromPublicArtifacts(
for (const pluginId of pluginIds) {
const record = recordsByPluginId.get(pluginId);
if (!record) {
continue;
return null;
}
const mod = tryLoadBundledPublicArtifactModule({
dirName: path.basename(record.rootDir),
artifactCandidates: WEB_FETCH_ARTIFACT_CANDIDATES,
});
if (!mod) {
continue;
return null;
}
providers.push(
...collectProviderFactories({
mod,
suffix: "WebFetchProvider",
isProvider: isWebFetchProviderPlugin,
}).map((provider) => ({
...provider,
pluginId,
})),
);
const loadedProviders = collectProviderFactories({
mod,
suffix: "WebFetchProvider",
isProvider: isWebFetchProviderPlugin,
});
if (loadedProviders.length === 0) {
return null;
}
providers.push(...loadedProviders.map((provider) => ({ ...provider, pluginId })));
}
return providers;
}

View File

@@ -272,7 +272,7 @@ function resolveBundledWebSearchProviders(params: {
bundledAllowlistCompat: true,
onlyPluginIds: [params.configuredBundledPluginId],
});
if (bundled.length > 0) {
if (bundled && bundled.length > 0) {
return bundled;
}
return resolvePluginWebSearchProviders({
@@ -289,7 +289,7 @@ function resolveBundledWebSearchProviders(params: {
env,
bundledAllowlistCompat: true,
});
if (bundled.length > 0) {
if (bundled && bundled.length > 0) {
return bundled;
}
return resolvePluginWebSearchProviders({
@@ -319,7 +319,7 @@ function resolveBundledWebFetchProviders(params: {
bundledAllowlistCompat: true,
onlyPluginIds: [params.configuredBundledPluginId],
});
if (bundled.length > 0) {
if (bundled && bundled.length > 0) {
return bundled;
}
return resolvePluginWebFetchProviders({
@@ -335,7 +335,7 @@ function resolveBundledWebFetchProviders(params: {
env,
bundledAllowlistCompat: true,
});
if (bundled.length > 0) {
if (bundled && bundled.length > 0) {
return bundled;
}
return resolvePluginWebFetchProviders({