UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.6 kB
import{o as getAsyncWorkSignal}from"./async-work-scope-DBcxYU4O.mjs";import{n as sanitizeTerminalText}from"./safe-text-B_QTgn0s.mjs";import{t as GATEWAY_SERVER_CAPS}from"./server-capabilities-HdXShIdT.mjs";import{a as readActiveGatewayLockIdentity}from"./gateway-lock-CQoO1usb.mjs";import{f as isImplicitLocalGatewayTarget,r as callGateway}from"./call-CVqWsTxX.mjs"; //!src/commands/models/catalog-warnings.ts async function readSelectedGatewayModelCatalog(e,t,n,r){r?.throwIfAborted();const i=await isImplicitLocalGatewayTarget({config:e});const a=Boolean(process.env.OPENCLAW_GATEWAY_PORT?.trim());const o=i&&!a?await readActiveGatewayLockIdentity({requireInspection:true}):void 0;r?.throwIfAborted();if(i&&!a&&!o)return;const s=await callGateway({config:e,method:`models.list`,...t.preparedOnly?{sharedStateMode:`read-only`}:{},...n?{timeoutMs:n}:{},requiredCapabilities:[GATEWAY_SERVER_CAPS.PUBLISHED_MODEL_CATALOG],...o?{localPortOverride:o.port}:{},params:t,signal:r}).catch(e=>{r?.throwIfAborted();throw e});r?.throwIfAborted();return s}function getModelCatalogWarnings(e){return e?.providerOutcomes?.flatMap(e=>e.status===`ready`?(e.unlistedConfiguredModelIds??[]).map(t=>({ref:`${e.provider}/${t}`,status:e.status,message:`Configured model "${sanitizeTerminalText(`${e.provider}/${t}`)}" is not present in the provider's last successful server catalog${e.profileId?` (profile ${sanitizeTerminalText(e.profileId)})`:``}.`,fixHint:`Pull or download it on that server, or fix the configured model name; then run openclaw models list --refresh. The model remains selectable.`})):[{ref:e.provider,status:e.status,message:`${e.status===`auth-rejected`?`Model discovery authentication was rejected`:`Model discovery is unavailable`} for ${sanitizeTerminalText(e.provider)}${e.profileId?` (profile ${sanitizeTerminalText(e.profileId)})`:``}.`,fixHint:e.status===`auth-rejected`?`Open Models in the Control UI to check sign-in and catalog access, then run openclaw models list --refresh.`:`Run openclaw models list --refresh; if it still fails, check the provider in Models in the Control UI.`}])??[]}async function readModelCatalog(e,t,n){return readSelectedGatewayModelCatalog(e,{view:`all`,includeDetails:true,includeDefaultModels:true,preparedOnly:true,...t?{agentId:t}:{}},5e3,n).catch(()=>{n?.throwIfAborted()})}async function runModelCatalogReadCommand(e,t=true){const n=t?getAsyncWorkSignal():void 0;try{n?.throwIfAborted();await e(n)}catch(e){if(!n?.aborted)throw e}}export{runModelCatalogReadCommand as i,readModelCatalog as n,readSelectedGatewayModelCatalog as r,getModelCatalogWarnings as t};