Files
openclaw/src/plugins/bundled-web-fetch.ts
Vincent Koc 38d2faee20 !feat(plugins): add web fetch provider boundary (#59465)
* 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
2026-04-02 20:25:19 +09:00

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);
}