openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.73 kB
JavaScript
import{a as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import"./transcript-chat-display-projection.canvas-BVwGQyPV.mjs";import{c as t}from"./transcript-chat-display-projection.core-B2Q8dHzN.mjs";import{r as n}from"./transcript-session-transcript-source-pages-BOCIi65D.mjs";import{a as r}from"./transcript-chat-history-budget-CaliLKKU.mjs";import{a as i,c as a,l as o,n as s}from"./transcript-session-history-tail-Db3CHtT1.mjs";async function readSessionHistorySnapshotKernel(c,l){let u,d=!1,f,p,m;if(typeof c.limit!=`number`){u=[];for await(let e of n(l.readers.readSessionMessagesWithSourceAsync.bind(l.readers),c.target,{allowResetArchiveFallback:!0,readOnly:l.readOnly}))u.push(...e.messages),p=e.transcriptPath;m=t(u,{subagentCoordination:l.readers.subagentCoordination,includeCommentaryFallbacks:!0,maxChars:c.maxChars??8e3,resolveCronJobName:l.resolveCronJobName,...l.deferProfileDisplay?{}:{resolveCurrentUserProfileDisplay:l.resolveCurrentUserProfileDisplay}})}else{let e=o(c.cursor),t=await a({entry:c.target.sessionEntry,readScope:c.target,effectiveMaxChars:c.maxChars??8e3,max:c.limit,maxBytes:r(),...e===void 0?{}:{beforeSeq:e},preserveProjectionContext:!0,...l});d=t.windowReset??!1,m=t.projection,u=t.rawMessages,f=t.readPage.totalMessages,p=t.readPage.transcriptPath}let h=u.filter(e),g=s(m.messages,c.limit,d?void 0:c.cursor);if(typeof f==`number`&&f>u.length&&(!c.cursor||(i(h[0])??0)>1)){let e=i(g.messages[0]??h[0]);g.hasMore=!0,typeof e==`number`&&(g.nextCursor=String(e))}return{history:{...g,...d?{windowReset:!0}:{}},rawTranscriptSeq:f??i(h.at(-1))??h.length,turnBoundaryPending:m.turnBoundaryPending,assistantErrorPending:m.assistantErrorPending,transcriptPath:p}}export{readSessionHistorySnapshotKernel};