mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 09:33:06 +00:00
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { loadBundledCapabilityRuntimeRegistry } from "./bundled-capability-runtime.js";
|
|
import { BUNDLED_WEB_FETCH_PLUGIN_IDS } from "./bundled-web-fetch-ids.js";
|
|
import { resolveBundledWebFetchPluginId as resolveBundledWebFetchPluginIdFromMap } from "./bundled-web-fetch-provider-ids.js";
|
|
import type { PluginLoadOptions } from "./loader.js";
|
|
import { loadPluginManifestRegistry } from "./manifest-registry.js";
|
|
import type { PluginWebFetchProviderEntry } from "./types.js";
|
|
|
|
type BundledWebFetchProviderEntry = PluginWebFetchProviderEntry & { pluginId: string };
|
|
|
|
let bundledWebFetchProvidersCache: BundledWebFetchProviderEntry[] | null = null;
|
|
|
|
function loadBundledWebFetchProviders(): BundledWebFetchProviderEntry[] {
|
|
if (!bundledWebFetchProvidersCache) {
|
|
bundledWebFetchProvidersCache = loadBundledCapabilityRuntimeRegistry({
|
|
pluginIds: BUNDLED_WEB_FETCH_PLUGIN_IDS,
|
|
pluginSdkResolution: "dist",
|
|
}).webFetchProviders.map((entry) => ({
|
|
pluginId: entry.pluginId,
|
|
...entry.provider,
|
|
}));
|
|
}
|
|
return bundledWebFetchProvidersCache;
|
|
}
|
|
|
|
export function resolveBundledWebFetchPluginIds(params: {
|
|
config?: PluginLoadOptions["config"];
|
|
workspaceDir?: string;
|
|
env?: PluginLoadOptions["env"];
|
|
}): string[] {
|
|
const bundledWebFetchPluginIdSet = new Set<string>(BUNDLED_WEB_FETCH_PLUGIN_IDS);
|
|
return loadPluginManifestRegistry({
|
|
config: params.config,
|
|
workspaceDir: params.workspaceDir,
|
|
env: params.env,
|
|
})
|
|
.plugins.filter(
|
|
(plugin) => plugin.origin === "bundled" && bundledWebFetchPluginIdSet.has(plugin.id),
|
|
)
|
|
.map((plugin) => plugin.id)
|
|
.toSorted((left, right) => left.localeCompare(right));
|
|
}
|
|
|
|
export function listBundledWebFetchProviders(): PluginWebFetchProviderEntry[] {
|
|
return loadBundledWebFetchProviders();
|
|
}
|
|
|
|
export function resolveBundledWebFetchPluginId(providerId: string | undefined): string | undefined {
|
|
return resolveBundledWebFetchPluginIdFromMap(providerId);
|
|
}
|