UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2 kB
import{r as normalizeProviderId}from"./provider-id-A-8WTtLA.mjs";import{t as resolveRuntimeCliBackends}from"./cli-backends.runtime.js";import{a as resolveAuthProfileOrder}from"./order-B8e_5ABM.mjs";import{c as resolveCliRuntimeExecutionProvider}from"./model-runtime-aliases-BFQ__k4Y.mjs";import{i as ensureAuthProfileStoreAsync,r as ensureAuthProfileStore}from"./store-runtime-GNz-2GjY.mjs";import{a as resolveModelAuthMode}from"./model-auth-C99Q9Dp8.mjs"; //!src/agents/embedded-agent-runner/cli-backend-dispatch-eligibility.ts function resolveDispatchProvider(e){const t=new Map(resolveRuntimeCliBackends(`metadata`).map(e=>[normalizeProviderId(e.id),e]));const n=normalizeProviderId(e.provider??``);const r=t.has(n)?n:normalizeProviderId(resolveCliRuntimeExecutionProvider({provider:e.provider??``,cfg:e.config,agentId:e.agentId,modelId:e.model,authProfileId:e.authProfileId,preparedAuthStore:e.preparedAuthStore})??``);return t.get(r)?.subscriptionAuthDispatch?r:void 0}function canDispatchWithAuthStore(e,t,n){const r=e.authProfileId?n.profiles[e.authProfileId.trim()]?.type:void 0;const[i]=resolveAuthProfileOrder({cfg:e.config,store:n,provider:t});const a=r??(i?n.profiles[i]?.type:void 0);const o=a===`api_key`?`api-key`:a===`oauth`||a===`token`?a:resolveModelAuthMode(t,e.config,n,{workspaceDir:e.workspaceDir});return o!==`api-key`&&o!==`mixed`&&o!==`aws-sdk`}function resolveEmbeddedCliBackendDispatchEligibility(e){const t=resolveDispatchProvider(e);if(!t)return;try{if(!canDispatchWithAuthStore(e,t,e.preparedAuthStore??ensureAuthProfileStore(e.agentDir,{config:e.config})))return}catch{}return{provider:t}}async function resolveEmbeddedCliBackendDispatchEligibilityAsync(e){const t=resolveDispatchProvider(e);if(!t)return;try{if(!canDispatchWithAuthStore(e,t,e.preparedAuthStore??await ensureAuthProfileStoreAsync(e.agentDir,{config:e.config})))return}catch{}return{provider:t}}export{resolveEmbeddedCliBackendDispatchEligibilityAsync as n,resolveEmbeddedCliBackendDispatchEligibility as t};