refactor(web-tools): share URL allowlist resolver

This commit is contained in:
Peter Steinberger
2026-02-17 00:29:38 +00:00
parent 64fc82844e
commit a6466f2576
3 changed files with 18 additions and 22 deletions

View File

@@ -13,6 +13,7 @@ import {
normalizeCacheKey,
readCache,
readResponseText,
resolveWebUrlAllowlist,
resolveCacheTtlMs,
resolveTimeoutSeconds,
withTimeout,
@@ -79,17 +80,7 @@ type WebSearchConfig = NonNullable<OpenClawConfig["tools"]>["web"] extends infer
type WebConfig = NonNullable<OpenClawConfig["tools"]>["web"];
export function resolveUrlAllowlist(web?: WebConfig): string[] | undefined {
if (!web || typeof web !== "object") {
return undefined;
}
if (!("urlAllowlist" in web)) {
return undefined;
}
const allowlist = web.urlAllowlist;
if (!Array.isArray(allowlist)) {
return undefined;
}
return allowlist.length > 0 ? allowlist : undefined;
return resolveWebUrlAllowlist(web);
}
export function filterResultsByAllowlist(