openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.52 kB
JavaScript
import{l as normalizeProviderModelIdWithRuntime,o as normalizeModelRef}from"./model-ref-shared-T-aCqInj.mjs";import{C as allowsPluginModelNormalization,i as buildModelAliasIndex,y as resolveModelRefFromString}from"./model-selection-shared-CIOFxJ36.mjs";import"./model-selection-CNHinoVN.mjs";
//!src/agents/command/model-ref.ts
const OVERRIDE_VALUE_MAX_LENGTH=256;function normalizeExplicitOverrideInput(e,t){const n=e.trim();const r=t===`provider`?`Provider`:`Model`;if(!n)throw new Error(`${r} override must be non-empty.`);if(n.length>OVERRIDE_VALUE_MAX_LENGTH)throw new Error(`${r} override exceeds ${String(OVERRIDE_VALUE_MAX_LENGTH)} characters.`);if(/\p{Cc}/u.test(n))throw new Error(`${r} override contains invalid control characters.`);return n}function normalizeAgentCommandModelRef(e,t,n,r){return normalizeModelRef(t,n,{...r,allowPluginNormalization:allowsPluginModelNormalization({cfg:e,provider:t,model:n})})}function parseAgentCommandModelRef(e,t,n,r,i){const a=resolveModelRefFromString({cfg:e,agentId:t,raw:n,defaultProvider:r,aliasIndex:buildModelAliasIndex({cfg:e,agentId:t,defaultProvider:r,...i,allowPluginNormalization:false}),...i,allowPluginNormalization:false})?.ref;if(!a||!allowsPluginModelNormalization({cfg:e,...a}))return a??null;return{provider:a.provider,model:normalizeProviderModelIdWithRuntime({provider:a.provider,context:{provider:a.provider,modelId:a.model}})??a.model}}export{normalizeExplicitOverrideInput as n,parseAgentCommandModelRef as r,normalizeAgentCommandModelRef as t};