UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.72 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{t as captureRuntimeConfigAsyncReader}from"./io.runtime-BvSeVFIY.mjs";import"./config-DkZ8y8Gv.mjs";import{r as PlatformMessageNotDispatchedError}from"./deliver-types-QUMIGH6t.mjs";import{t as loadChannelOutboundAdapter}from"./load-C6oS1MN6.mjs"; //!src/cli/send-runtime/channel-outbound-send.ts function resolveRuntimeReplyToId(e){const t=e.replyToMessageId??e.replyToId;return t==null?void 0:normalizeOptionalString(String(t))}async function sendChannelOutboundMessage(e,t,n,r={}){const i=await loadChannelOutboundAdapter(e);const a=r.cfg??await captureRuntimeConfigAsyncReader()();const o=r.messageThreadId??r.threadId??r.threadTs??void 0;const s=resolveRuntimeReplyToId(r);const buildContext=()=>({cfg:a,to:t,text:n,mediaUrl:r.mediaUrl,mediaAccess:r.mediaAccess,mediaLocalRoots:r.mediaLocalRoots,mediaReadFile:r.mediaReadFile,accountId:r.accountId,threadId:o,replyToId:s,silent:r.silent,forceDocument:r.forceDocument,formatting:r.formatting??(r.textMode===`html`?{parseMode:`HTML`}:void 0),gifPlayback:r.gifPlayback,gatewayClientScopes:r.gatewayClientScopes,deliveryQueueId:r.deliveryQueueId,deliveryPartIndex:r.deliveryPartIndex,deliveryPartCount:r.deliveryPartCount,onPlatformSendDispatch:r.onPlatformSendDispatch});const c=Boolean(r.mediaUrl);if(r.blocks&&i?.sendPayload)return await i.sendPayload({...buildContext(),payload:{text:n,channelData:{[e]:{blocks:r.blocks}}}});if(c&&i?.sendMedia)return await i.sendMedia(buildContext());if(!i?.sendText){const t=`${e} outbound adapter is unavailable.`;throw new PlatformMessageNotDispatchedError(t,{cause:new Error(t)})}return await i.sendText(buildContext())}export{sendChannelOutboundMessage};