UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 3.1 kB
import{_ as resolvePrimaryStringValue,l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{d as asPositiveFiniteNumber}from"./number-coercion-B3CfI447.mjs";import{l as isRecord}from"./record-coerce-BTbqdJ3-.mjs";import{i as parseModelCatalogRef}from"./model-catalog-refs-eJnrGUHo.mjs";import{i as normalizeTogetherModelId,n as normalizeGooglePreviewModelId}from"./provider-model-id-normalize-DUL6qlR8.mjs"; //!src/config/model-input.ts function resolveAgentModelPrimaryValue(e){return resolvePrimaryStringValue(e)}function resolveAgentModelFallbackValues(e){if(!e||typeof e!==`object`)return[];return Array.isArray(e.fallbacks)?e.fallbacks:[]}function resolveSelectedModelFallbacksOverride(e){if(!e)return;if(typeof e===`string`)return resolvePrimaryStringValue(e)?[]:void 0;if(!Object.hasOwn(e,`fallbacks`))return Object.hasOwn(e,`primary`)&&resolvePrimaryStringValue(e)?[]:void 0;return Array.isArray(e.fallbacks)?e.fallbacks:void 0}function resolveAgentModelTimeoutMsValue(e){if(!e||typeof e!==`object`)return;const t=asPositiveFiniteNumber(e.timeoutMs);return t===void 0?void 0:Math.floor(t)}function toAgentModelListLike(e){if(typeof e===`string`){const t=normalizeOptionalString(e);return t?{primary:t}:void 0}if(!e||typeof e!==`object`)return;return e}const GOOGLE_PROVIDER_IDS=/* @__PURE__ */ new Set([`google`,`google-gemini-cli`,`google-vertex`]);function normalizeProviderCatalogModelIdForConfig(e,t){if(GOOGLE_PROVIDER_IDS.has(e)||t.startsWith(`google/`))return normalizeGooglePreviewModelId(t);return e===`together`?normalizeTogetherModelId(t):t}function normalizeAgentModelRefForConfig(e){const t=e.trim();const n=parseModelCatalogRef(t);if(!n)return t;const{provider:r,modelId:i}=n;return`${r}/${normalizeProviderCatalogModelIdForConfig(r,i)}`}function normalizeAgentModelSelectionForConfig(e){if(typeof e===`string`)return normalizeAgentModelRefForConfig(e);if(!isRecord(e))return e;let t=e;const assign=(e,n)=>{if(n!==t[e])t={...t,[e]:n}};if(typeof e.primary===`string`)assign(`primary`,normalizeAgentModelRefForConfig(e.primary));if(Array.isArray(e.fallbacks)){const t=e.fallbacks;const n=t.map(e=>typeof e===`string`?normalizeAgentModelRefForConfig(e):e);if(n.some((e,n)=>e!==t[n]))assign(`fallbacks`,n)}return t}function mergeAgentModelEntryForConfig(e,t){if(!isRecord(e)||!isRecord(t))return t;const n=isRecord(e.params)?e.params:void 0;const r=isRecord(t.params)?t.params:void 0;return{...e,...t,...n||r?{params:{...n,...r}}:void 0}}function normalizeAgentModelMapForConfig(e){let t=false;const n={};for(const[r,i]of Object.entries(e)){const e=normalizeAgentModelRefForConfig(r);if(e!==r||Object.hasOwn(n,e))t=true;n[e]=mergeAgentModelEntryForConfig(n[e],i)}return t?n:e}export{normalizeProviderCatalogModelIdForConfig as a,resolveAgentModelTimeoutMsValue as c,normalizeAgentModelSelectionForConfig as i,resolveSelectedModelFallbacksOverride as l,normalizeAgentModelMapForConfig as n,resolveAgentModelFallbackValues as o,normalizeAgentModelRefForConfig as r,resolveAgentModelPrimaryValue as s,mergeAgentModelEntryForConfig as t,toAgentModelListLike as u};