mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 03:01:02 +00:00
perf(secrets): complete bundled web provider artifacts
This commit is contained in:
1
extensions/minimax/web-search-provider.ts
Normal file
1
extensions/minimax/web-search-provider.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { createMiniMaxWebSearchProvider } from "./src/minimax-web-search-provider.js";
|
||||
1
extensions/ollama/web-search-provider.ts
Normal file
1
extensions/ollama/web-search-provider.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { createOllamaWebSearchProvider } from "./src/web-search-provider.js";
|
||||
44
src/plugins/web-provider-public-artifacts.test.ts
Normal file
44
src/plugins/web-provider-public-artifacts.test.ts
Normal 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",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user