UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.29 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{wa as t,xa as n}from"./control-ui-connection-Bfj9beF_.js";import{Sd as r,xd as i}from"./control-ui-boot-shared-DFTSUQQ0.js";import{n as a,t as o}from"./chat-english-BpQpBjX1.js";async function s({client:e,sessionKey:n,sessionId:i,agentId:a,isCurrent:o}){let s=[],c=new Map,l=(t,r=1e3)=>e.request(`chat.history`,{sessionKey:n,agentId:a,limit:r,maxChars:5e5,offset:t}),u=0,d;for(;;){let e=await l(u);if(!o()||i&&e.sessionId!==i||d&&(e.sessionId!==d.sessionId||e.totalMessages!==d.totalMessages))throw Error(t(`sessionsView.copyTranscriptChanged`));d??=e;let n=new Map,a=(e.messages??[]).filter(e=>{let t=r(e);if(!t)return!0;let i=(n.get(t)??0)+1;return n.set(t,i),i>(c.get(t)??0)});for(let[e,t]of n)c.set(e,Math.max(t,c.get(e)??0));if(s.push(a),!e.hasMore)break;if(e.nextOffset===void 0||e.nextOffset<=u)throw Error(t(`sessionsView.copyTranscriptChanged`));u=e.nextOffset}if(s.length>1){let e=await l(0,1);if(!o()||e.sessionId!==d.sessionId||e.totalMessages!==d.totalMessages||e.deltaCursor!==d.deltaCursor||e.sessionInfo?.activeLeafEntryId!==d.sessionInfo?.activeLeafEntryId)throw Error(t(`sessionsView.copyTranscriptChanged`))}return s.toReversed().flat()}function c(){return(c=e((()=>{n(),o(),i(),a()})))()}export{s as n,c as t};