openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
24 lines (23 loc) • 1.43 kB
JavaScript
import { t as formatCliCommand } from "./command-format-DwEdrDKL.mjs";
import { r as normalizeProviderId } from "./provider-id-D1VImdKk.mjs";
import { r as resolveProviderAuthAliasMap } from "./provider-auth-aliases-CAzJGfWN.mjs";
import { i as resolveManifestProviderAuthChoices } from "./provider-auth-choices-BqebLo6k.mjs";
//#region src/agents/provider-auth-recovery-hint.ts
function normalizeProviderIdForAuth(providerId, aliases) {
const normalized = normalizeProviderId(providerId);
return normalized ? aliases[normalized] ?? normalized : normalized;
}
function buildProviderAuthRecoveryHint(params) {
const aliases = resolveProviderAuthAliasMap(params);
const normalized = normalizeProviderIdForAuth(params.provider, aliases);
const loginCommand = resolveManifestProviderAuthChoices(params).find((candidate) => normalized && normalizeProviderIdForAuth(candidate.providerId, aliases) === normalized) ? formatCliCommand(`openclaw models auth login --provider ${normalized}`) : void 0;
const parts = [];
if (loginCommand) parts.push(`Run \`${loginCommand}\``);
parts.push(`\`${formatCliCommand("openclaw configure")}\``);
if (params.includeEnvVar) parts.push("set an API key env var");
if (parts.length === 1) return `${parts[0]}.`;
if (parts.length === 2) return `${parts[0]} or ${parts[1]}.`;
return `${parts[0]}, ${parts[1]}, or ${parts[2]}.`;
}
//#endregion
export { buildProviderAuthRecoveryHint as t };