openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
67 lines (66 loc) • 3.17 kB
JavaScript
import { r as createLazyRuntimeModule } from "./lazy-runtime-zGjszCtt.mjs";
import { t as warnPluginSdkDeprecation } from "./sdk-deprecation-D5N9acnu.mjs";
import "./errors-C4nx2HUe.mjs";
import "./registry-C2WH06NS.mjs";
import { n as finalizeInboundContextForSdk, r as isFinalizedInboundContext } from "./inbound-context-0zDtB0Zn.mjs";
import { t as hasExplicitCommandContextText } from "./context-text-D9JfaJrk.mjs";
//#region src/plugin-sdk/acpx.ts
const loadDispatchAcpRuntime = createLazyRuntimeModule(() => import("./dispatch-acp.runtime.js"));
/**
* Dispatch a plugin reply hook through ACP when the event targets an ACP-bound session.
* Returns a handled result only when ACP consumes the reply; otherwise callers continue normal delivery.
*/
async function tryDispatchAcpReplyHook(e, t) {
const n = isFinalizedInboundContext(e.ctx) ? e.ctx : finalizeInboundContextForSdk(e.ctx);
if (e.sendPolicy === "deny" && !e.suppressUserDelivery && !hasExplicitCommandContextText(n) && !e.isTailDispatch) return;
const r = await loadDispatchAcpRuntime();
const i = await r.shouldBypassAcpDispatchForCommand(n, t.cfg);
if (e.sendPolicy === "deny" && !e.suppressUserDelivery && !i && !e.isTailDispatch) return;
if (!e.shouldSendToolSummariesAsync || !e.shouldSendFullToolDetailsAsync) warnPluginSdkDeprecation({
family: "reply-visibility",
method: "tryDispatchAcpReplyHook boolean visibility inputs",
replacement: "shouldSendToolSummariesAsync and shouldSendFullToolDetailsAsync predicates"
});
const a = e.shouldSendFullToolDetailsAsync ? void 0 : e.shouldSendFullToolDetails;
const o = await r.tryDispatchAcpReply({
ctx: n,
cfg: t.cfg,
dispatcher: t.dispatcher,
runId: e.runId,
sessionKey: e.sessionKey,
toolsAllow: e.toolsAllow,
images: e.images,
abortSignal: t.abortSignal,
inboundAudio: e.inboundAudio,
sessionTtsAuto: e.sessionTtsAuto,
ttsChannel: e.ttsChannel,
suppressUserDelivery: e.suppressUserDelivery,
suppressReplyLifecycle: e.suppressReplyLifecycle === true || e.sendPolicy === "deny",
sourceReplyDeliveryMode: e.sourceReplyDeliveryMode,
shouldRouteToOriginating: e.shouldRouteToOriginating,
originatingChannel: e.originatingChannel,
originatingTo: e.originatingTo,
originatingAccountId: e.originatingAccountId,
originatingThreadId: e.originatingThreadId,
originatingChatType: e.originatingChatType,
shouldSendToolSummaries: async () => e.shouldSendToolSummariesAsync ? await e.shouldSendToolSummariesAsync() : e.shouldSendToolSummaries,
shouldSendFullToolDetails: async () => e.shouldSendFullToolDetailsAsync ? await e.shouldSendFullToolDetailsAsync() : a === true,
bypassForCommand: i,
onReplyStart: t.onReplyStart,
onAgentRunStart: t.onAgentRunStart,
onPreparedAgentRunStart: t.onPreparedAgentRunStart,
turnAdoption: t.turnAdoption,
userTurnTranscriptRecorder: t.userTurnTranscriptRecorder,
prepareAssistantTranscriptMessage: t.prepareAssistantTranscriptMessage,
recordProcessed: t.recordProcessed,
markIdle: t.markIdle
});
if (!o) return;
return {
handled: true,
queuedFinal: o.queuedFinal,
counts: o.counts
};
}
//#endregion
export { tryDispatchAcpReplyHook as t };