openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
20 lines (19 loc) • 1.15 kB
JavaScript
import { c as normalizeOptionalLowercaseString } from "./string-coerce-1VuiLaaR.mjs";
import { r as resolveProviderMatch } from "./provider-auth-choice-helpers-gVHdr-sl.mjs";
import { t as resolvePluginProviders } from "./provider-auth-choice.runtime-D6tLrTPx.mjs";
//#region src/commands/auth-choice.apply.api-providers.ts
/** Translate generic api-key/token choices to provider-specific auth choices when possible. */
function normalizeApiKeyTokenProviderAuthChoice(params) {
const normalizedTokenProvider = normalizeOptionalLowercaseString(params.tokenProvider);
if (!normalizedTokenProvider) return params.authChoice;
const kind = params.authChoice === "apiKey" ? "api_key" : params.authChoice === "token" || params.authChoice === "setup-token" ? "token" : void 0;
if (!kind) return params.authChoice;
return resolveProviderMatch(resolvePluginProviders({
config: params.config,
workspaceDir: params.workspaceDir,
env: params.env,
mode: "setup"
}), normalizedTokenProvider)?.auth.find((method) => method.kind === kind)?.wizard?.choiceId ?? params.authChoice;
}
//#endregion
export { normalizeApiKeyTokenProviderAuthChoice as t };