openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 1.97 kB
JavaScript
import{t as normalizeAnyChannelId}from"./registry-normalize-BP0gv89S.mjs";import"./registry-yecJKTDP.mjs";import{n as getLoadedChannelPlugin}from"./registry-CpNh6QcT.mjs";import"./plugins-DxOycUNJ.mjs";import{r as resolveOutboundChannelPlugin}from"./channel-resolution-DC4uO43j.mjs";
//!src/infra/outbound/delivery-format-prompt.ts
const DELIVERY_FORMAT_LEAD={reply:`The JSON below is generated by OpenClaw. Your visible output for this turn is delivered to this channel; follow its response_format.`,message_tool:`The JSON below is generated by OpenClaw. Text you send to this channel with the message tool is rendered by it; follow its response_format.`};function buildDeliveryFormatPrompt(e){if(!e.channel)return;const t=e.allowBootstrap?resolveOutboundChannelPlugin({channel:e.channel,cfg:e.cfg,agentId:e.agentId,allowBootstrap:true}):getLoadedChannelPlugin(normalizeAnyChannelId(e.channel)??e.channel);const n=t?.agentPrompt?.inboundFormattingHints?.({cfg:e.cfg,accountId:e.accountId?.trim()||void 0});if(!t||!n)return;const r={schema:`openclaw.delivery_format.v1`,channel:t.id,response_format:n};return[`### Delivery Format`,DELIVERY_FORMAT_LEAD[e.via??`reply`],``,"```json",JSON.stringify(r,null,2),"```",``].join(`
`)}async function resolveMessageToolDeliveryFormatPrompt(e){const t=e.channel??await import(`./channel-selection.runtime-CYx6flr7.mjs`).then(({resolveMessageChannelSelection:t})=>t({cfg:e.cfg,agentId:e.agentId})).then(e=>e.channel).catch(()=>void 0);const render=n=>buildDeliveryFormatPrompt({cfg:e.cfg,channel:t,accountId:n,via:`message_tool`,agentId:e.agentId,allowBootstrap:true});if(e.accountId?.trim()||!t)return render(e.accountId);const n=resolveOutboundChannelPlugin({channel:t,cfg:e.cfg,agentId:e.agentId,allowBootstrap:true});const r=new Set((n?.config.listAccountIds(e.cfg)??[]).map(e=>render(e)));r.add(render(void 0));return r.size===1?[...r][0]:void 0}export{resolveMessageToolDeliveryFormatPrompt as n,buildDeliveryFormatPrompt as t};