openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
38 lines (37 loc) • 2.14 kB
JavaScript
import { a as coerceSecretRef, c as isLegacySecretRefEnvMarker, f as normalizeSecretInputString } from "./types.secrets-DsPRn9Dz.mjs";
import { n as normalizeSecretInput } from "./normalize-secret-input-DBJvdk-L.mjs";
//#region src/web/provider-runtime-shared.ts
function resolveWebProviderConfig(cfg, kind) {
const webConfig = cfg?.tools?.web;
if (!webConfig || typeof webConfig !== "object") return;
const toolConfig = webConfig[kind];
if (!toolConfig || typeof toolConfig !== "object") return;
return toolConfig;
}
function readWebProviderEnvValue(envVars, processEnv = process.env) {
for (const envVar of envVars) {
const value = normalizeSecretInput(processEnv[envVar]);
if (value) return value;
}
}
function providerRequiresCredential(provider) {
return provider.requiresCredential !== false;
}
function hasWebProviderEntryCredential(params) {
if (!providerRequiresCredential(params.provider)) return true;
const rawValue = params.provider.getConfiguredCredentialValue?.(params.config);
if (isLegacySecretRefEnvMarker(rawValue)) return false;
const configuredRef = coerceSecretRef(rawValue);
if (configuredRef && configuredRef.source !== "env") return true;
if (configuredRef ? "" : normalizeSecretInput(normalizeSecretInputString(rawValue))) return true;
if (params.provider.authProviderId && params.resolveProviderAuthValue?.(params.provider.authProviderId)) return true;
if (params.resolveEnvValue(configuredRef?.source === "env" ? configuredRef.id : void 0)) return true;
const fallbackRawValue = params.provider.getConfiguredCredentialFallback?.(params.config)?.value;
if (isLegacySecretRefEnvMarker(fallbackRawValue)) return false;
const fallbackRef = coerceSecretRef(fallbackRawValue);
if (fallbackRef && fallbackRef.source !== "env") return true;
if (fallbackRef ? "" : normalizeSecretInput(normalizeSecretInputString(fallbackRawValue))) return true;
return Boolean(fallbackRef?.source === "env" ? params.resolveEnvValue(fallbackRef.id) : void 0);
}
//#endregion
export { resolveWebProviderConfig as i, providerRequiresCredential as n, readWebProviderEnvValue as r, hasWebProviderEntryCredential as t };