openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 1.8 kB
JavaScript
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Eo as t,Oo as n,Un as r,Vn as i,bs as a,cr as o,lr as s,sr as c,xs as l}from"./control-ui-core-Rwzhj6nO.js";import{ws as u,xs as d}from"./control-ui-boot-shared-CXVvK2AW.js";import{c as f,r as p,s as m}from"./usage-y60JDuyp.js";function h(e){let t=new Date;return t.setDate(t.getDate()-e),`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function g(e){return s(e)?c(`model providers`):t(e,`request failed`)}function _(e){return e.then(e=>({ok:!0,result:e}),e=>({ok:!1,error:e}))}async function v(e,t){let n=n=>_(r(e,{agentId:t.agentId,...n,...t.signal?{signal:t.signal}:{}})),i=t.refresh?n({refresh:!0}):void 0,a=i?i.then(e=>e.ok?e:n({preparedOnly:!0})):n({preparedOnly:!0}),[o,s,c,d]=await Promise.all([_(u(e,t)),a,i??Promise.resolve(void 0),e.request(`config.get`,{},{signal:t.signal}).then(e=>l(e)).catch(()=>null)]);return{authStatus:o.ok&&Array.isArray(o.result?.providers)?o.result:null,models:s.ok?s.result.models:null,providerOutcomes:s.ok?s.result.providerOutcomes??[]:[],catalogError:c&&!c.ok?g(c.error):s.ok?null:g(s.error),config:d,providerUsage:null,costByProvider:null,updatedAt:Date.now(),error:o.ok?o.result.unavailable?.message??null:g(o.error)}}function y(e,t){return f(e,{signal:t})}function b(e,t){return p(e,{startDate:h(29),endDate:h(0),scope:`family`,timeZone:`local`},{signal:t}).then(e=>e?.aggregates?.byProvider??null).catch(e=>{if(t.aborted)throw e;return null})}var x;function S(){return(S=e((()=>{a(),n(),o(),d(),i(),m(),x={authStatus:null,models:null,providerOutcomes:[],catalogError:null,config:null,providerUsage:null,costByProvider:null,updatedAt:null,error:null}})))()}export{v as a,y as i,S as n,b as r,x as t};
//# sourceMappingURL=load-Bbhf1Rrb.js.map