openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
37 lines (36 loc) • 1.36 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { a as resolveProviderOnboardAuthFlags } from "./provider-auth-choices-BfC_56hU.mjs";
//#region src/commands/onboard-non-interactive/local/auth-choice-inference.ts
/**
* Infers a non-interactive auth choice from explicit CLI flags.
*
* This keeps setup deterministic when users provide API-key flags without also
* passing `--auth`, including plugin-defined provider auth flags.
*/
function hasStringValue(e) {
return typeof e === "string" ? Boolean(normalizeOptionalString(e)) : Boolean(e);
}
/** Infers auth choice from plugin and custom provider API-key flags. */
function inferAuthChoiceFromFlags(e, t) {
const n = resolveProviderOnboardAuthFlags({
config: t?.config,
workspaceDir: t?.workspaceDir,
env: t?.env,
includeUntrustedWorkspacePlugins: false
}).filter(({ optionKey: t }) => hasStringValue(e[t])).map((e) => ({
optionKey: e.optionKey,
authChoice: e.authChoice,
label: e.cliFlag
}));
if (hasStringValue(e.customBaseUrl) || hasStringValue(e.customModelId) || hasStringValue(e.customApiKey)) n.push({
optionKey: "customBaseUrl",
authChoice: "custom-api-key",
label: "--custom-base-url/--custom-model-id/--custom-api-key"
});
return {
choice: n[0]?.authChoice,
matches: n
};
}
//#endregion
export { inferAuthChoiceFromFlags as t };