
























@@ -117,6 +117,10 @@ function resolveFetchReadabilityEnabled(fetch?: WebFetchConfig): boolean {
117117return true;
118118}
119119120+function resolveFetchUseTrustedEnvProxy(fetch?: WebFetchConfig): boolean {
121+return fetch?.useTrustedEnvProxy === true;
122+}
123+120124function resolveFetchMaxCharsCap(fetch?: WebFetchConfig): number {
121125const raw =
122126fetch && "maxCharsCap" in fetch && typeof fetch.maxCharsCap === "number"
@@ -273,6 +277,7 @@ type WebFetchRuntimeParams = {
273277userAgent: string;
274278readabilityEnabled: boolean;
275279config?: OpenClawConfig;
280+useTrustedEnvProxy: boolean;
276281ssrfPolicy?: {
277282allowRfc2544BenchmarkRange?: boolean;
278283allowIpv6UniqueLocalRange?: boolean;
@@ -392,6 +397,7 @@ async function maybeFetchProviderWebFetchPayload(
392397async function runWebFetch(params: WebFetchRuntimeParams): Promise<Record<string, unknown>> {
393398const allowRfc2544BenchmarkRange = params.ssrfPolicy?.allowRfc2544BenchmarkRange === true;
394399const allowIpv6UniqueLocalRange = params.ssrfPolicy?.allowIpv6UniqueLocalRange === true;
400+const useTrustedEnvProxy = params.useTrustedEnvProxy;
395401const ssrfPolicy: SsrFPolicy | undefined =
396402allowRfc2544BenchmarkRange || allowIpv6UniqueLocalRange
397403 ? {
@@ -400,7 +406,7 @@ async function runWebFetch(params: WebFetchRuntimeParams): Promise<Record<string
400406}
401407 : undefined;
402408const cacheKey = normalizeCacheKey(
403-`fetch:${params.url}:${params.extractMode}:${params.maxChars}${allowRfc2544BenchmarkRange ? ":allow-rfc2544" : ""}${allowIpv6UniqueLocalRange ? ":allow-ipv6-ula" : ""}`,
409+`fetch:${params.url}:${params.extractMode}:${params.maxChars}${allowRfc2544BenchmarkRange ? ":allow-rfc2544" : ""}${allowIpv6UniqueLocalRange ? ":allow-ipv6-ula" : ""}${useTrustedEnvProxy ? ":trusted-env-proxy" : ""}`,
404410);
405411const cached = readCache(FETCH_CACHE, cacheKey);
406412if (cached) {
@@ -428,6 +434,7 @@ async function runWebFetch(params: WebFetchRuntimeParams): Promise<Record<string
428434maxRedirects: params.maxRedirects,
429435timeoutSeconds: params.timeoutSeconds,
430436lookupFn: params.lookupFn,
437+useEnvProxy: useTrustedEnvProxy,
431438policy: ssrfPolicy,
432439init: {
433440headers: {
@@ -661,6 +668,7 @@ export function createWebFetchTool(options?: {
661668 userAgent,
662669 readabilityEnabled,
663670config: options?.config,
671+useTrustedEnvProxy: resolveFetchUseTrustedEnvProxy(fetch),
664672ssrfPolicy: fetch?.ssrfPolicy,
665673lookupFn: options?.lookupFn,
666674 resolveProviderFallback,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。