openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.73 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Gl as t,Qi as n,Xi as r,Yi as i,hu as a,ql as o,uu as s}from"./control-ui-core-3P365fbR.js";import{_a as c,ba as l,ct as u,lt as d,st as f}from"./control-ui-boot-shared-DoKu-5Ju.js";import{n as p,t as m}from"./en-settings-CTjRjKt9.js";import{a as h,n as g,o as _}from"./usage-qkiTcEi1.js";function v(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 y(e){return n(e)?i(`model providers`):t(e,`request failed`)}function b(e){return e.then(e=>({ok:!0,result:e}),e=>({ok:!1,error:e}))}async function x(e,t){let n=(n=!1)=>b(u(e,{agentId:t.agentId,...n?{refresh:!0}:{},...t.signal?{signal:t.signal}:{}})),r=b(l(e,t)),i=t.refresh?r.then(()=>n(!0)):void 0,o=i?i.then(e=>e.ok?e:n()):n(),[s,c,f]=await Promise.all([r,o,i??Promise.resolve(void 0)]);return{authStatus:s.ok&&Array.isArray(s.result?.providers)?s.result:null,providerOutcomes:c.ok?c.result.providerOutcomes??[]:[],catalogError:f&&!f.ok?y(f.error):c.ok?d(c.result,a(`modelProviders.defaults.discoverFailed`)):y(c.error),providerUsage:null,costByProvider:null,updatedAt:Date.now(),error:s.ok?s.result.unavailable?.message??null:y(s.error)}}function S(e,t){return _(e,{signal:t})}function C(e,t){return g(e,{startDate:v(29),endDate:v(0),scope:`family`,timeZone:`local`},{signal:t}).then(e=>e?.aggregates?.byProvider??null).catch(e=>{if(t.aborted)throw e;return null})}var w;function T(){return(T=e((()=>{s(),m(),o(),r(),c(),f(),h(),p(),w={authStatus:null,providerOutcomes:[],catalogError:null,providerUsage:null,costByProvider:null,updatedAt:null,error:null}})))()}export{x as a,S as i,T as n,C as r,w as t};