eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.15 kB
JavaScript
import{applyAgentConfigStringPath}from"./agent-config-string-path.js";import{applyModelSelectionToSource}from"./apply-model-selection.js";async function applyAgentModelSettingsToSource(e,t){let n=e,r=[];if(t.model.kind===`remove`)return{kind:`bail`,reason:"the required `model` property cannot be removed",line:1};if(t.model.kind===`set`){let e=await applyModelSelectionToSource(n,t.model.value);if(e.kind===`bail`)return e;e.nextSource!==n&&r.push(`model`),n=e.nextSource}if(t.reasoning.kind!==`keep`){let e=await applyAgentConfigStringPath(n,[`reasoning`],t.reasoning.kind===`set`?{kind:`set`,value:t.reasoning.value}:{kind:`remove`});if(e.kind===`bail`)return e;e.nextSource!==n&&r.push(`reasoning`),n=e.nextSource}if(t.gatewayServiceTier.kind!==`keep`){let e=await applyAgentConfigStringPath(n,[`modelOptions`,`providerOptions`,`gateway`,`serviceTier`],t.gatewayServiceTier.kind===`set`?{kind:`set`,value:t.gatewayServiceTier.value}:{kind:`remove`,removable:e=>e===`priority`});if(e.kind===`bail`)return e;e.nextSource!==n&&r.push(`fast-mode`),n=e.nextSource}return{kind:`applied`,changed:r,nextSource:n}}export{applyAgentModelSettingsToSource};