UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.82 kB
import{l as resolveSessionStorePathCore}from"./paths-CcxgiC3g.mjs";import{i as readSessionEntryReadOnlyInWorker}from"./session-entry-read-runtime-kAgwDw0B.mjs";import"./sessions-DQD7zQ95.mjs";import{n as resolveAcpSessionCwd}from"./session-identifiers-C_PL7ld9.mjs";import{t as persistAcpTurnTranscript}from"./transcript-persistence-C1ciA1Zv.mjs"; //!src/auto-reply/reply/dispatch-acp-transcript.runtime.ts async function persistAcpDispatchTranscript(e){const t=e.promptText.trim();const n=e.finalText.trim();if(!t&&!n)return;const r=e.agentId;const i=resolveSessionStorePathCore(e.cfg.session?.store,{agentId:r});const a=await readSessionEntryReadOnlyInWorker({agentId:r,sessionKey:e.sessionKey,storePath:i});const o=a?.sessionId;if(!o)throw new Error(`unknown ACP session key: ${e.sessionKey}`);if(e.expectedSessionId&&o!==e.expectedSessionId)throw new Error(`ACP transcript session changed before the turn could be persisted.`);const s=await persistAcpTurnTranscript({body:t,transcriptBody:t,finalText:n,terminalOutcome:e.terminalOutcome,sessionId:o,expectedSessionId:e.expectedSessionId,sessionKey:e.sessionKey,sessionEntry:a,storePath:i,sessionAgentId:r,threadId:e.threadId,sessionCwd:resolveAcpSessionCwd(e.meta)??process.cwd(),config:e.cfg,userTurnTranscriptRecorder:e.userTurnTranscriptRecorder,prepareAssistantTranscriptMessage:e.prepareAssistantTranscriptMessage,assistantIdempotencyKey:e.assistantIdempotencyKey});if(s.kind===`session-rebound`)throw new Error(`ACP transcript session changed before the turn could be persisted.`);return s.assistantTranscript&&e.assistantIdempotencyKey?{agentId:r,sessionId:o,sessionKey:e.sessionKey,storePath:i,messageId:s.assistantTranscript.messageId,anchor:s.assistantTranscript.anchor,idempotencyKey:e.assistantIdempotencyKey}:void 0}export{persistAcpDispatchTranscript};