UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

46 lines (45 loc) • 2.32 kB
import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs"; import { r as logVerbose } from "./globals-CgepmiqE.mjs"; import { n as getAcpSessionManager } from "./manager-CDGCO__f.mjs"; import { n as readAcpSessionEntryAsync } from "./session-meta-read-BC53uDBL.mjs"; import "./session-meta-CupK_5Fp.mjs"; import { t as notifyPreparedAgentRunStart } from "./agent-run-start-Cf0O0aGQ.mjs"; import { a as listSessionBindingsBySessionAsync, t as getSessionBindingService } from "./session-binding-service-Bn-zGfS9.mjs"; //#region src/auto-reply/reply/dispatch-acp-manager.runtime.ts /** Runtime ACP manager dependencies and stale-binding cleanup used by reply dispatch. */ const ACP_STALE_BINDING_UNBIND_REASON = "acp-session-init-failed"; /** Prepare transcript evidence before offering synchronous reply completion ownership. */ 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-CWMMMqBX.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)}`); } } //#endregion export { getAcpSessionManager, listSessionBindingsBySessionAsync, maybeUnbindStaleBoundConversations, prepareAcpDispatchStart, readAcpSessionEntryAsync };