UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.92 kB
import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{a as listSessionBindingsBySessionAsync,t as getSessionBindingService}from"./session-binding-service-TO5btU7E.mjs";import{r as logVerbose}from"./globals-l9I53ZKA.mjs";import{n as getAcpSessionManager}from"./manager-CpIPv3ym.mjs";import{n as readAcpSessionEntryAsync}from"./session-meta-read-hVOPXzGo.mjs";import"./session-meta-skdU9pJ4.mjs";import{t as notifyPreparedAgentRunStart}from"./agent-run-start-yFzndQ4_.mjs"; //!src/auto-reply/reply/dispatch-acp-manager.runtime.ts const ACP_STALE_BINDING_UNBIND_REASON=`acp-session-init-failed`;async function prepareAcpDispatchStart(e){const{agentId:t,sessionKey:n,storePath:r}=e.scope;const i=(e.onPreparedAgentRunStart||e.onAgentRunStart)&&e.sessionId?await(await import(`./session-transcript-watermark-D2CbCEx4.mjs`)).readSessionTranscriptStartAsync({agentId:t,sessionKey:n,storePath:r,sessionId:e.sessionId}):null;return()=>{const t=notifyPreparedAgentRunStart(e,{runId:e.runId,options:{completionSource:`reply-dispatch`,getResult:e.getResult},transcriptStart:i});return t===`reply-dispatch`?t:void 0}}async function maybeUnbindStaleBoundConversations(e){if(e.error.code!==`ACP_SESSION_INIT_FAILED`||!/(ACP (session )?metadata is missing|missing ACP metadata|Session is not ACP-enabled|Resource not found)/i.test(e.error.message))return;try{const t=await getSessionBindingService().unbind({targetSessionKey:e.targetSessionKey,reason:ACP_STALE_BINDING_UNBIND_REASON});if(t.length>0)logVerbose(`dispatch-acp: removed ${t.length} stale bound conversation(s) for ${e.targetSessionKey} after ${e.error.code}: ${e.error.message}`)}catch(t){logVerbose(`dispatch-acp: failed to unbind stale bound conversations for ${e.targetSessionKey}: ${formatErrorMessage(t)}`)}}export{getAcpSessionManager,listSessionBindingsBySessionAsync,maybeUnbindStaleBoundConversations,prepareAcpDispatchStart,readAcpSessionEntryAsync};