openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.06 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Qt as t,Xt as n}from"./control-ui-connection-Bfj9beF_.js";import{eg as r,rg as i,tg as a}from"./control-ui-boot-shared-DFTSUQQ0.js";import{i as o,n as s,o as c,r as l,t as u}from"./request-usage-snapshot-CNCWyRVt.js";function d(e){return i(e)?r(`usage`):n(e,`request failed`)}async function f(e,t,n){let{gateway:r,gatewaySnapshot:i,agentId:a,date:c}=n,u={...o(c),scope:`family`,timeZone:`local`,agentId:a},f={gateway:r,gatewaySnapshot:i,query:u,result:null,loadedAtMs:null,error:null};if(i.phase!==`connected`||!i.client)return f;try{let n=r.snapshot;if(!t.shouldRun()||n.phase!==`connected`||n.client!==i.client||n.hello!==i.hello||e.agentSelection.state.scopeId!==u.agentId)return f;let a=await s(i.client,{...u,...l,agentId:u.agentId??void 0},t.signal);return a.ok?{...f,result:a.value,gatewaySnapshot:n,loadedAtMs:Date.now()}:{...f,gatewaySnapshot:n,error:d(a.error.cause)}}catch(e){return{...f,error:d(e)}}}function p(){return(p=e((()=>{t(),a(),c(),u()})))()}p();export{f as loadUsageRouteData};