UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

62 lines (61 loc) • 2.53 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import "./src-H3RMXyFL.mjs"; import { t as expectDefined } from "./expect-DDakjvvQ.mjs"; import { s as resolveBundledPluginsDir } from "./bundled-dir-BKvdAqkP.mjs"; import { n as listBundledChannelCatalogEntries } from "./bundled-channel-catalog-read-CmfX8BTg.mjs"; import { n as CHAT_CHANNEL_ORDER } from "./ids-BRSWrLzE.mjs"; import { t as buildManifestChannelMeta } from "./channel-meta-CbOcOgly.mjs"; //#region src/channels/chat-meta-shared.ts const CHAT_CHANNEL_ID_SET = new Set(CHAT_CHANNEL_ORDER); function buildChatChannelMetaById() { const e = /* @__PURE__ */ new Map(); for (const t of listBundledChannelCatalogEntries()) { const n = normalizeOptionalString(t.id); if (!n || !CHAT_CHANNEL_ID_SET.has(n)) continue; const r = t.channel; const i = normalizeOptionalString(r.label); if (!i) throw new Error(`Missing label for bundled chat channel "${n}"`); e.set(n, buildManifestChannelMeta({ id: n, channel: r, label: i, selectionLabel: normalizeOptionalString(r.selectionLabel) || i, docsPath: normalizeOptionalString(r.docsPath) || `/channels/${n}`, docsLabel: normalizeOptionalString(r.docsLabel), blurb: normalizeOptionalString(r.blurb) || "", detailLabel: normalizeOptionalString(r.detailLabel), systemImage: normalizeOptionalString(r.systemImage), arrayFieldMode: "non-empty" })); } return Object.freeze(Object.fromEntries(e)); } //#endregion //#region src/channels/chat-meta.ts let chatChannelMetaCache; function getChatChannelMetaById() { const e = resolveBundledPluginsDir(process.env) ?? ""; if (chatChannelMetaCache?.cacheKey !== e) chatChannelMetaCache = { cacheKey: e, metaById: buildChatChannelMetaById() }; return chatChannelMetaCache.metaById; } function listChatChannels() { const e = getChatChannelMetaById(); return CHAT_CHANNEL_ORDER.map((t) => e[t]).filter((e) => Boolean(e)); } /** Drift-tolerant lookup: undefined when the id is missing from the bundled catalog. */ function findChatChannelMeta(e) { return getChatChannelMetaById()[e]; } /** * Returns metadata for one built-in chat channel id. * Shipped plugin-SDK contract: callers pass bundled ids, so absence is an invariant * violation; drift-tolerant core paths use findChatChannelMeta instead. */ function getChatChannelMeta(e) { return expectDefined(findChatChannelMeta(e), `chat channel meta for ${e}`); } //#endregion export { getChatChannelMeta as n, listChatChannels as r, findChatChannelMeta as t };