UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

38 lines (37 loc) • 1.42 kB
import { coerceSecretRef, normalizeSecretInputString, readProviderEnvValue, resolveNonEnvSecretRefApiKeyMarker } from "openclaw/plugin-sdk/secret-input"; import { resolveProviderWebSearchPluginConfig } from "openclaw/plugin-sdk/provider-web-search-config-contract"; import "openclaw/plugin-sdk/secret-ref-readonly"; //#region extensions/xai/src/tool-auth-shared.ts function readConfiguredOrManagedApiKey(value) { const literal = normalizeSecretInputString(value); if (literal) return literal; const ref = coerceSecretRef(value); return ref ? resolveNonEnvSecretRefApiKeyMarker(ref.source) : void 0; } function resolveFallbackXaiAuth(cfg) { const pluginApiKey = readConfiguredOrManagedApiKey(resolveProviderWebSearchPluginConfig(cfg, "xai")?.apiKey); if (pluginApiKey) return { apiKey: pluginApiKey, source: "plugins.entries.xai.config.webSearch.apiKey" }; } //#endregion //#region extensions/xai/provider-discovery.ts const PROVIDER_ID = "xai"; function resolveXaiSyntheticAuth(config) { const apiKey = resolveFallbackXaiAuth(config)?.apiKey || readProviderEnvValue(["XAI_API_KEY"]); return apiKey ? { apiKey, source: "xAI plugin config", mode: "api-key" } : void 0; } const xaiProviderDiscovery = { id: PROVIDER_ID, label: "xAI", docsPath: "/providers/xai", auth: [], resolveSyntheticAuth: ({ config }) => resolveXaiSyntheticAuth(config) }; //#endregion export { xaiProviderDiscovery as default };