UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 2.96 kB
import{b as uniqueStrings}from"./string-normalization-D_oBUpO3.mjs";import{r as normalizeProviderId}from"./provider-id-A-8WTtLA.mjs";import{n as isFeaturedProviderAuthChoiceGroup,t as compareProviderAuthChoiceGroups}from"./provider-auth-choice-order-BnDvRvEY.mjs";import{t as resolveProviderSetupFlowContributions}from"./provider-flow-CRqQwGu7.mjs"; //!src/commands/auth-choice-options.static.ts const CORE_AUTH_CHOICE_OPTIONS=[{value:`custom-api-key`,label:`Custom Provider`,hint:`Any OpenAI or Anthropic compatible endpoint`,groupId:`custom`,groupLabel:`Custom Provider`,groupHint:`Any OpenAI or Anthropic compatible endpoint`}];const GENERIC_PROVIDER_AUTH_CHOICES=[`setup-token`,`token`,`apiKey`];function formatStaticAuthChoiceChoicesForCli(){return[...CORE_AUTH_CHOICE_OPTIONS.map(e=>e.value),...GENERIC_PROVIDER_AUTH_CHOICES,`skip`].join(`|`)} //!src/commands/auth-choice-options.ts function compareOptionLabels(e,t){return e.label.localeCompare(t.label)}function isFeaturedAuthChoiceGroup(e){return isFeaturedProviderAuthChoiceGroup(e.value)}function compareAuthChoiceGroups(e,t){return compareProviderAuthChoiceGroups({id:e.value,label:e.label},{id:t.value,label:t.label})}function formatAuthChoiceChoicesForCli(e){const t=[...formatStaticAuthChoiceChoicesForCli().split(`|`),...resolveProviderSetupFlowContributions({...e,scope:`all`}).map(e=>e.option.value)];return uniqueStrings(t).join(`|`)}function buildAuthChoiceGroups(e){const t=new Map(CORE_AUTH_CHOICE_OPTIONS.map(e=>[e.value,e]));for(const{option:{group:n,...r},providerId:i}of resolveProviderSetupFlowContributions({config:e.config,workspaceDir:e.workspaceDir,env:e.env,scope:`text-inference`}))t.set(r.value,{...r,providerId:i,...n?{groupId:n.id,groupLabel:n.label,...n.hint?{groupHint:n.hint}:{}}:{}});const n=new Set([...e.detectedProviderIds??[]].map(normalizeProviderId));const r=Array.from(t.values()).toSorted(compareOptionLabels).filter(e=>e.assistantVisibility!==`detected-only`||e.providerId!==void 0&&n.has(normalizeProviderId(e.providerId))).filter(t=>e.assistantVisibleOnly!==false?t.assistantVisibility!==`manual-only`:true);const i=/* @__PURE__ */ new Map;for(const e of r){if(!e.groupId||!e.groupLabel)continue;const t=i.get(e.groupId);if(t){t.options.push(e);if(e.providerId)t.providerIds=uniqueStrings([...t.providerIds??[],e.providerId]);continue}const n=e.providerId?[e.providerId]:[];i.set(e.groupId,{value:e.groupId,label:e.groupLabel,...e.groupHint?{hint:e.groupHint}:{},...n.length>0?{providerIds:n}:{},options:[e]})}for(const e of i.values())e.options=e.options.toSorted((e,t)=>{return(e.assistantPriority??0)-(t.assistantPriority??0)||compareOptionLabels(e,t)});return{groups:Array.from(i.values()).toSorted(compareAuthChoiceGroups),skipOption:e.includeSkip?{value:`skip`,label:`Skip for now`}:void 0}}export{GENERIC_PROVIDER_AUTH_CHOICES as a,isFeaturedAuthChoiceGroup as i,compareAuthChoiceGroups as n,formatAuthChoiceChoicesForCli as r,buildAuthChoiceGroups as t};