UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

70 lines (69 loc) • 2.52 kB
import { t as createConfiguredProviderCatalogModelIdNormalizer } from "./model-ref-shared-DqE2RqZv.mjs"; import { r as normalizeProviderId } from "./provider-id-b5XGSf9C.mjs"; import { i as normalizeConfiguredProviderCatalogModelRef } from "./provider-model-id-normalization-Yii1-7Le.mjs"; import { a as normalizeProviderCatalogModelIdForConfig } from "./model-input-DrM4DWHG.mjs"; import { n as materializeConfiguredProviderModelRows, r as mergeNormalizedProviderModel, t as getProviderModelId } from "./model-provider-rows-CuCTSqes.mjs"; import { a as normalizeModelCostForCatalog } from "./plugin-model-catalog-repair-B3GKtPvY.mjs"; //#region src/agents/models-config.providers.catalog.ts /** Materializes authored rows and finalizes catalog rows without credential resolution. */ function normalizeProviderModelsForConfig(e, t) { if (!t.models?.length) return t; const n = normalizeProviderId(e); let r = false; const i = []; const a = /* @__PURE__ */ new Map(); for (const e of t.models) { const t = getProviderModelId(e); const o = t ? normalizeProviderCatalogModelIdForConfig(n, normalizeConfiguredProviderCatalogModelRef(t)) : t; const s = o && o !== t ? { ...e, id: o } : e; if (s !== e) r = true; const c = getProviderModelId(s); if (c) { const e = a.get(c); if (e !== void 0) { r = true; const t = i.at(e); if (t) i[e] = mergeNormalizedProviderModel(t, s); continue; } a.set(c, i.length); } i.push(s); } for (const [e, t] of i.entries()) { const n = normalizeModelCostForCatalog(t); if (n !== t) { i[e] = n; r = true; } } return r ? { ...t, models: i } : t; } function normalizeProviderModelMap(e, t) { if (!e) return e; let n = false; const r = {}; for (const [i, a] of Object.entries(e)) { const e = t(i, a); n ||= e !== a; r[i] = e; } return n ? r : e; } /** Resolves authored aliases once, before discovery consumes configured model membership. */ function materializeConfiguredProviderCatalogModels(e, t = {}) { const n = createConfiguredProviderCatalogModelIdNormalizer(t); return normalizeProviderModelMap(e, (e, t) => materializeConfiguredProviderModelRows(t, (t) => n(e, t))); } /** Finalizes emitted rows without applying authored aliases to their identities. */ function normalizeProviderCatalogModelsForConfig(e) { return normalizeProviderModelMap(e, normalizeProviderModelsForConfig); } //#endregion export { normalizeProviderCatalogModelsForConfig as n, materializeConfiguredProviderCatalogModels as t };