const e=16e3,t=32e3;function n(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=Math.floor(e);return t>0?t:null}function r(e){let t=(()=>{let t=e.cfg?.models?.providers?.[e.provider];return n((Array.isArray(t?.models)?t.models:[]).find(t=>t?.id===e.modelId)?.contextWindow)})(),r=n(e.modelContextWindow),i=t?{tokens:t,source:`modelsConfig`}:r?{tokens:r,source:`model`}:{tokens:Math.floor(e.defaultTokens),source:`default`},a=n(e.cfg?.agents?.defaults?.contextTokens);return a&&a<i.tokens?{tokens:a,source:`agentContextTokens`}:i}function i(e){let t=Math.max(1,Math.floor(e.warnBelowTokens??32e3)),n=Math.max(1,Math.floor(e.hardMinTokens??16e3)),r=Math.max(0,Math.floor(e.info.tokens));return{...e.info,tokens:r,shouldWarn:r>0&&r<t,shouldBlock:r>0&&r<n}}export{r as i,t as n,i as r,e as t};
