openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
183 lines (182 loc) • 3.95 kB
JavaScript
import { c as normalizeOptionalLowercaseString } from "./string-coerce-CCIiB4H7.mjs";
import { n as listBundledChannelCatalogEntries } from "./bundled-channel-catalog-read-CmfX8BTg.mjs";
//#region src/channels/bundled-channel-ids.generated.ts
const GENERATED_BUNDLED_CHANNEL_IDS = [
{
channelId: "a2a",
order: 75,
label: "A2A"
},
{
channelId: "buzz",
order: 56,
label: "Buzz"
},
{
channelId: "clickclack",
order: 85,
label: "ClickClack"
},
{
channelId: "discord",
label: "Discord"
},
{
channelId: "feishu",
aliases: ["lark"],
order: 35,
label: "Feishu"
},
{
channelId: "googlechat",
aliases: ["gchat", "google-chat"],
order: 55,
label: "Google Chat"
},
{
channelId: "imessage",
aliases: ["imsg"],
label: "iMessage"
},
{
channelId: "irc",
aliases: ["internet-relay-chat"],
label: "IRC"
},
{
channelId: "line",
order: 75,
label: "LINE"
},
{
channelId: "matrix",
order: 70,
label: "Matrix"
},
{
channelId: "mattermost",
order: 65,
label: "Mattermost"
},
{
channelId: "msteams",
aliases: ["teams"],
order: 60,
label: "Microsoft Teams"
},
{
channelId: "nextcloud-talk",
aliases: ["nc", "nc-talk"],
order: 65,
label: "Nextcloud Talk"
},
{
channelId: "nostr",
order: 55,
label: "Nostr"
},
{
channelId: "qa-channel",
order: 999,
configurable: false,
label: "QA Channel"
},
{
channelId: "raft",
order: 72,
label: "Raft"
},
{
channelId: "reef",
label: "Reef"
},
{
channelId: "signal",
label: "Signal"
},
{
channelId: "slack",
label: "Slack"
},
{
channelId: "sms",
order: 88,
label: "SMS"
},
{
channelId: "synology-chat",
order: 90,
label: "Synology Chat"
},
{
channelId: "telegram",
label: "Telegram"
},
{
channelId: "tlon",
order: 90,
label: "Tlon"
},
{
channelId: "twitch",
aliases: ["twitch-chat"],
label: "Twitch"
},
{
channelId: "whatsapp",
label: "WhatsApp"
},
{
channelId: "x",
order: 85,
label: "X (Twitter)"
},
{
channelId: "zalo",
aliases: ["zl"],
order: 80,
label: "Zalo"
},
{
channelId: "zalouser",
aliases: ["zlu"],
order: 85,
label: "Zalo Personal"
}
];
//#endregion
//#region src/channels/ids.ts
const BUNDLED_CHAT_CHANNEL_ENTRIES = GENERATED_BUNDLED_CHANNEL_IDS.filter((e) => e.configurable !== false).map((e) => ({
id: normalizeOptionalLowercaseString(e.channelId) ?? e.channelId,
aliases: e.aliases ?? [],
label: e.label?.trim() || void 0,
order: e.order ?? Number.MAX_SAFE_INTEGER
})).toSorted((e, t) => e.order - t.order || e.id.localeCompare(t.id, "en", { sensitivity: "base" }));
const CHAT_CHANNEL_ID_SET = new Set(BUNDLED_CHAT_CHANNEL_ENTRIES.map((e) => e.id));
/**
* Stable built-in channel order derived from generated bundled channel metadata.
*/
const CHAT_CHANNEL_ORDER = Object.freeze(BUNDLED_CHAT_CHANNEL_ENTRIES.map((e) => e.id));
/**
* Alias retained for callers that still refer to chat channel ordering as channel ids.
*/
const CHANNEL_IDS = CHAT_CHANNEL_ORDER;
const CHAT_CHANNEL_ALIASES = Object.fromEntries(BUNDLED_CHAT_CHANNEL_ENTRIES.flatMap((e) => e.aliases.map((t) => [t, e.id])));
/** Finds the generated operator-facing label for a built-in channel id or alias. */
function findChatChannelLabel(e) {
const t = normalizeOptionalLowercaseString(e);
if (!t) return;
const n = CHAT_CHANNEL_ALIASES[t] ?? t;
return BUNDLED_CHAT_CHANNEL_ENTRIES.find((e) => e.id === n)?.label;
}
function normalizeRuntimeBundledChatChannelId(e) {
return listBundledChannelCatalogEntries().find((t) => t.id === e || t.aliases.includes(e))?.id ?? null;
}
function normalizeChatChannelId(e) {
const t = normalizeOptionalLowercaseString(e);
if (!t) return null;
const n = CHAT_CHANNEL_ALIASES[t] ?? t;
return CHAT_CHANNEL_ID_SET.has(n) ? n : normalizeRuntimeBundledChatChannelId(t);
}
//#endregion
export { normalizeChatChannelId as i, CHAT_CHANNEL_ORDER as n, findChatChannelLabel as r, CHANNEL_IDS as t };