UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 3.31 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./control-ui-connection-D5QrEAFW.css"])))=>i.map(i=>d[i]); import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{ja as t,lu as n,uu as r,wa as i,xa as a}from"./control-ui-connection-Bfj9beF_.js";import{Ag as o,BT as s,Gl as c,H as l,Jg as u,Kl as d,Lg as f,Mg as p,Og as m,Pg as h,Qg as g,V as _,Xg as v,Yg as y,bD as b,qg as x,vD as S}from"./control-ui-boot-shared-DFTSUQQ0.js";function C(e,t){let r=t.map(({key:t,agentId:n})=>d(e,{sessionKey:t,agentId:n}));return n(async()=>{let{deleteStoredChatSnapshot:e}=await import(`./control-ui-connection-Bfj9beF_.js`).then(e=>(e.s(),e.c));return{deleteStoredChatSnapshot:e}},__vite__mapDeps([0]),import.meta.url).then(({deleteStoredChatSnapshot:e})=>Promise.all(r.map(t=>e(t))).then(()=>void 0))}function w(){return(w=e((()=>{c(),r()})))()}function T(e,n){let r=h(e);if(n.length===0)return{gatewayOwner:r.gatewayOwner,retirements:[],storageFailed:!1};let i=t();if(!i)return{gatewayOwner:r.gatewayOwner,retirements:n.flatMap(e=>e.key.trim()?[{scope:{sessionKey:e.key,agentId:e.agentId},minimumRevision:e.retireBeforeRevision,retireBeforeRevision:e.retireBeforeRevision}]:[]),storageFailed:!0};let a=[],c=[],l=!1;try{let e=p(i,r);for(let t of n){if(!t.key.trim())return{gatewayOwner:r.gatewayOwner,retirements:a,storageFailed:!0};let n={sessionKey:t.key,agentId:t.agentId},o=s(n),d=e.sessions[o],f=d?.draftRevision??0,p=y(i,r.key,o,f).latestAttempt,m=t.retireBeforeRevision;f<t.retireBeforeRevision&&(m=u(Math.max(p,t.retireBeforeRevision)),v(i,r.key,o,m),l||=!!d?.draft||!!d?.queue?.length,e.sessions[o]={draftRevision:m,updatedAt:Date.now()},c.push({storeSessionKey:o,revision:m})),a.push({scope:n,minimumRevision:m,retireBeforeRevision:t.retireBeforeRevision})}if(c.length===0)return{gatewayOwner:r.gatewayOwner,retirements:a,storageFailed:!1};f(i,r,e);let t=p(i,r);for(let{storeSessionKey:e,revision:n}of c){let o=t.sessions[e];if(o?.draftRevision!==n||o.draft||o.queue?.length)return{gatewayOwner:r.gatewayOwner,retirements:a,storageFailed:!0};g(i,r.key,e,n)}return l&&o(),{gatewayOwner:r.gatewayOwner,retirements:a,storageFailed:!1}}catch{return{gatewayOwner:r.gatewayOwner,retirements:a,storageFailed:!0}}}function E(){return(E=e((()=>{x(),m()})))()}async function D(e,t,n){try{if(t.client&&!t.client.recoveryScopeReady&&t.isCurrent()){let n=()=>{},r;await new Promise((i,a)=>{r=setTimeout(()=>a(Error(`Draft recovery scope unavailable`)),1e4);let o=()=>{(t.client?.recoveryScopeReady||!t.isCurrent())&&i()};n=e.gateway.subscribe(o),o()}).finally(()=>{clearTimeout(r),n()})}if(!t.client||!t.isCurrent())throw Error(`Draft cleanup connection changed`);let{recoveryScope:r,recoveryScopeReady:i}=t.client,a=T({settings:{gatewayUrl:t.gatewayUrl},client:t.client},n),o=a.retirements.map(e=>({scopeKey:`chat:v3:${s(e.scope)}`,minimumRevision:e.minimumRevision,retireBeforeRevision:e.retireBeforeRevision})),[,c]=await Promise.all([C({...t,settings:{gatewayUrl:t.gatewayUrl}},n),i&&r?l({gatewayOwner:a.gatewayOwner,recoveryScope:r},o):`storage-failed`]);if(a.storageFailed||c===`storage-failed`)throw Error(`Draft storage cleanup failed`)}catch{b({message:i(`sessionsView.draftCleanupFailed`)})}}function O(){return(O=e((()=>{a(),w(),S(),_(),E(),m()})))()}O();export{D as retireDeletedComposerDrafts};