openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.75 kB
JavaScript
import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";import{t as createChatHistoryRecoveryProjection}from"./chat-display-projection.core-Cc0urtjV.mjs";import{m as prepareSessionHistorySubagentFacts,t as createSessionActorTranscriptReader}from"./session-transcript-memory-reader-DHqE4Ev8.mjs";import{n as projectChatHistoryWithReplies}from"./chat-history-reply-messages-BjVkJUZo.mjs";
//!src/gateway/cli-session-history.process-held.ts
async function readProcessHeldCliHistory(e,t,n){const r=await readProcessHeldCliHistoryQuery({kind:`rpc`,params:e},t,n);if(r.kind!==`rpc`)throw new Error(`Unexpected process-held history page`);return r.page}async function readProcessHeldCliHistoryMessage(e,t){const n=await readProcessHeldCliHistoryQuery({kind:`rpc-message`,params:e},void 0,t);if(n.kind!==`rpc-message`)throw new Error(`Unexpected process-held history message`);return n.result}async function readProcessHeldCliHistoryQuery(e,t,n){const r=structuredClone(e);const i=r.params;i.encodeResponse=false;if(!n)throw new Error(`Process-held history requires a memory session actor`);if(i.entry)i.entry.incognito=true;const{runProcessHeldHistoryTask:a}=await import(`./session-transcript-worker-runtime-CvMUuZTx.mjs`);const o=createSessionActorTranscriptReader(n);const s={agentId:i.sessionAgentId,sessionId:i.sessionId,sessionKey:i.canonicalKey,storePath:i.storePath,sessionEntry:i.entry};const assertCurrent=()=>{t?.throwIfAborted();n.assertCurrent()};const c=await a(r,async(e,{signal:t})=>{t.throwIfAborted();assertCurrent();const n=e;const r=n.kind===`page`?await o.readSessionMessagesPageWithStatsAsync(s,n.options,t):n.kind===`around`?await o.readSessionMessagesAroundIdWithStatsAsync(s,n.options,t):await o.readSessionMessageByIdAsync(s,n.messageId,n.options,t);t.throwIfAborted();if(r===void 0)throw new Error(`Unsupported process-held history request`);assertCurrent();const i=`messages`in r?r.messages:r.message===void 0?[]:[r.message];return{input:{result:r,facts:prepareSessionHistorySubagentFacts(o.subagentCoordination,e=>{for(const t of i)createChatHistoryRecoveryProjection({subagentCoordination:e}).append([t])})},timeoutMs:6e4}},t);assertCurrent();if(c.kind===`rpc-message`)return c;const l=c.page;const[{createCurrentUserProfileMessageProjector:u},{resolveCurrentUserProfileDisplay:d},{getUserProfileDisplay:f}]=await Promise.all([import(`./chat-display-projection.core-BSVyW8c9.mjs`),import(`./current-user-profile-display-CT6WzLG4.mjs`),import(`./user-profile-list-WMi8xepn.mjs`)]);const p=u(e=>d(e,f));l.messages=await projectChatHistoryWithReplies(l.messages.filter(e=>Boolean(asOptionalRecord(e))),e=>e.map(p));assertCurrent();return{kind:`rpc`,page:l}}export{readProcessHeldCliHistory,readProcessHeldCliHistoryMessage};