UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

57 lines (56 loc) • 1.76 kB
import { l as normalizeProviderModelIdWithRuntime, o as normalizeModelRef } from "./model-ref-shared-DqE2RqZv.mjs"; import { O as allowsPluginModelNormalization, i as buildModelAliasIndex, y as resolveModelRefFromString } from "./model-selection-shared-9Kz63Hhm.mjs"; import "./model-selection-C2A4Wyix.mjs"; //#region 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 }; } //#endregion export { normalizeExplicitOverrideInput as n, parseAgentCommandModelRef as r, normalizeAgentCommandModelRef as t };