UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

42 lines (41 loc) • 1.83 kB
import { r as normalizeProviderId } from "./provider-id-b5XGSf9C.mjs"; import { a as normalizeOptionalAgentRuntimeId, r as isDefaultAgentRuntimeId } from "./agent-runtime-id-D8s1CaYB.mjs"; import "./model-selection-C2A4Wyix.mjs"; import { t as resolveCompatibleAgentRuntimeForProvider } from "./session-runtime-compat-C_CO9LR_.mjs"; //#region src/auto-reply/reply/directive-handling.model-runtime.ts /** Preserves compatible runtime pins and validates explicit runtime selections. */ function resolveModelRuntimeDirective(e) { const t = e.rawRuntime?.trim(); const n = t || e.sessionEntry?.agentRuntimeOverride?.trim(); if (!n) return { kind: "unchanged" }; const r = normalizeOptionalAgentRuntimeId(n); if (isDefaultAgentRuntimeId(r)) return { kind: t ? "clear" : "unchanged" }; const i = normalizeProviderId(e.provider); const a = resolveCompatibleAgentRuntimeForProvider({ provider: i, runtime: r, cfg: e.cfg }); if (a) return t ? { kind: "set", runtime: a } : { kind: "unchanged" }; if (!t) return { kind: "clear" }; return { kind: "invalid", runtime: n, errorText: `Runtime "${n}" is not supported for ${i || e.provider}.` }; } /** Applies a validated runtime choice, clearing consent with an incompatible or reset pin. */ function applyModelRuntimeDirective(e, t) { if (t.kind !== "clear" && t.kind !== "set") return { updated: false }; const n = t.kind === "set" ? t.runtime : void 0; const r = e.agentRuntimeOverride !== n || e.nativeRuntimeConsent !== void 0 && e.nativeRuntimeConsent !== n; if (t.kind === "clear") delete e.agentRuntimeOverride; if (r || t.kind === "clear") delete e.nativeRuntimeConsent; if (t.kind === "set") e.agentRuntimeOverride = t.runtime; return { updated: r }; } //#endregion export { resolveModelRuntimeDirective as n, applyModelRuntimeDirective as t };