@cortexkit/opencode-anthropic-auth 1.12.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +0,0 @@
1
- import{mkdir as N,readFile as h,writeFile as C}from"node:fs/promises";import{tmpdir as b}from"node:os";import{dirname as L,join as q}from"node:path";var M="OPENCODE_ANTHROPIC_AUTH_SIDEBAR_STATE_FILE",f=q(b(),"opencode-anthropic-auth"),k=q(f,"sidebar-state.json");function B(){return process.env[M]||k}var $={main:{quota:null},fallbacks:[],activeId:void 0,route:"main",relay:null,fastMode:!1,lastUpdated:0};function Y(J){return J!==null&&typeof J==="object"&&!Array.isArray(J)}function R(J){if(!Y(J))return{...$};let Q={quota:null};if(Y(J.main)){let x=J.main;if(Q.quota=Y(x.quota)?x.quota:null,typeof x.quotaBackedOff==="boolean")Q.quotaBackedOff=x.quotaBackedOff;if(typeof x.quotaBackoffUntil==="number")Q.quotaBackoffUntil=x.quotaBackoffUntil;if(typeof x.refreshBackedOff==="boolean")Q.refreshBackedOff=x.refreshBackedOff;if(typeof x.refreshBackoffUntil==="number")Q.refreshBackoffUntil=x.refreshBackoffUntil}let W=Array.isArray(J.fallbacks)?J.fallbacks.filter(Y).filter((x)=>typeof x.id==="string").map((x)=>({id:x.id,label:typeof x.label==="string"?x.label:void 0,quota:Y(x.quota)?x.quota:null,enabled:typeof x.enabled==="boolean"?x.enabled:!1,needsReauth:typeof x.needsReauth==="boolean"?x.needsReauth:!1})):[],X=null;if(Y(J.relay)){let x=J.relay;if(typeof x.enabled==="boolean"&&typeof x.transport==="string")X={enabled:x.enabled,transport:x.transport}}let Z;if(Y(J.cacheKeep)){let x=J.cacheKeep;if(typeof x.enabled==="boolean")Z={enabled:x.enabled,window:typeof x.window==="string"?x.window:void 0,trackedSessions:typeof x.trackedSessions==="number"?x.trackedSessions:void 0}}return{main:Q,fallbacks:W,activeId:typeof J.activeId==="string"?J.activeId:void 0,route:typeof J.route==="string"?J.route:$.route,relay:X,fastMode:typeof J.fastMode==="boolean"?J.fastMode:$.fastMode,cacheKeep:Z,lastUpdated:typeof J.lastUpdated==="number"?J.lastUpdated:0}}var z=Promise.resolve();async function P(){try{let J=await h(B(),"utf8");return R(JSON.parse(J))}catch{return $}}async function S(J,Q=B()){return z=z.then(async()=>{await N(L(Q),{recursive:!0}),await C(Q,JSON.stringify(J),"utf8")}).catch(()=>{}),z}async function _(){return z}function T(J){let Q=J.activeId;if(Q&&Q!=="main"){let W=J.fallbacks?.find((X)=>X.enabled&&X.id===Q);if(W)return{id:W.id,name:W.label??W.id,quota:W.quota}}return{id:"main",name:"main",quota:J.main?.quota??null}}function u(J){let Q=J?.five_hour?.usedPercent??null,W=J?.seven_day?.usedPercent??null;if(Q==null&&W==null)return{fiveHourUsedPercent:Q,sevenDayUsedPercent:W,text:null};return{fiveHourUsedPercent:Q,sevenDayUsedPercent:W,text:`5h: ${Q==null?"—":`${Math.round(Q)}%`} 7d: ${W==null?"—":`${Math.round(W)}%`}`}}var E=18000000,m=604800000,p=300000,I=0.01,U=1;function y(J,Q,W){if(!J.resetsAt)return null;let X=new Date(J.resetsAt).getTime();if(!Number.isFinite(X))return null;let Z=X-Q,x=W-Z;if(x<p)return null;if(x<Q*I)return null;if(x>=Q)return null;let V=J.usedPercent,G=Math.min(Math.max(x/Q*100,0),100),j=V-G,H=Math.abs(j)<U?"on-pace":j>0?"deficit":"reserve",K=null;if(V>0){let O=x*100/V,g=Z+O;if(g<X)K=new Date(g).toISOString()}return{pacePercent:G,deltaPercent:j,state:H,runsOutAt:K}}
2
- export{B as zb,$ as Ab,R as Bb,P as Cb,S as Db,_ as Eb,T as Fb,u as Gb,E as Hb,m as Ib,y as Jb};