UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

70 lines (69 loc) • 2.49 kB
import { t as normalizeAnyChannelId } from "./registry-normalize-guW5_4yo.mjs"; import "./registry-BB86xKJa.mjs"; import { n as getLoadedChannelPlugin } from "./registry-ByqVE5S3.mjs"; import "./plugins-BoMiRtiY.mjs"; import { r as resolveOutboundChannelPlugin } from "./channel-resolution-DjtSMYUG.mjs"; //#region 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." }; /** Renders the delivering channel's formatting contract; only delivered runs bootstrap. */ 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("\n"); } /** * Renders the contract for message-tool sends from a run without a reply route. * Callers add it only once the run's final tool surface includes `message`. */ async function resolveMessageToolDeliveryFormatPrompt(e) { const t = e.channel ?? await import("./channel-selection.runtime.js").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; } //#endregion export { resolveMessageToolDeliveryFormatPrompt as n, buildDeliveryFormatPrompt as t };