openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
67 lines (66 loc) • 2.73 kB
JavaScript
import { _ as resolveDefaultAgentId, f as resolveAgentWorkspaceDir } from "./agent-scope-config-DmXgFGKP.mjs";
import "./agent-scope-BwB8YH6y.mjs";
import { c as normalizeChannelMeta } from "./bundled-BnH1gY8j.mjs";
import { r as isChannelVisibleInSetup } from "./channel-meta-CbOcOgly.mjs";
import { r as listChatChannels } from "./chat-meta-CsbrDHrF.mjs";
import { i as listTrustedChannelPluginCatalogEntries, n as listManifestInstalledChannelIds, r as listSetupDiscoveryChannelPluginCatalogEntries } from "./trusted-catalog-BsRi13Hw.mjs";
import { t as isStaticallyChannelConfigured } from "./channel-configured-shared-CNtbUAAM.mjs";
//#region src/commands/channel-setup/discovery.ts
function shouldShowChannelInSetup(e) {
return isChannelVisibleInSetup(e);
}
function resolveWorkspaceDir(e, t) {
return t ?? resolveAgentWorkspaceDir(e, resolveDefaultAgentId(e));
}
/** Return true when a trusted catalog channel is already installed through plugin manifests. */
function isCatalogChannelInstalled(e) {
return listManifestInstalledChannelIds(e).has(e.entry.id);
}
/** Merge configured channels and installable catalog channels into setup display buckets. */
function resolveChannelSetupEntries(e) {
const t = resolveWorkspaceDir(e.cfg, e.workspaceDir);
const n = listManifestInstalledChannelIds({
cfg: e.cfg,
workspaceDir: t,
env: e.env
});
const r = new Set(e.installedPlugins.map((e) => e.id));
const i = listTrustedChannelPluginCatalogEntries({
cfg: e.cfg,
workspaceDir: t,
env: e.env
});
const a = listSetupDiscoveryChannelPluginCatalogEntries({
cfg: e.cfg,
workspaceDir: t,
env: e.env
});
const catalogEntries = (t, i) => t.filter((t) => !r.has(t.id) && n.has(t.id) === i && (i || !isStaticallyChannelConfigured(e.cfg, t.id, e.env ?? process.env)) && shouldShowChannelInSetup(t.meta)).map((e) => Object.assign({}, e, { meta: normalizeChannelMeta({
id: e.id,
meta: e.meta
}) }));
const o = catalogEntries(i, true);
const s = catalogEntries(a, false);
const c = new Map(listChatChannels().map((e) => [e.id, normalizeChannelMeta({
id: e.id,
meta: e
})]));
for (const t of e.installedPlugins) c.set(t.id, normalizeChannelMeta({
id: t.id,
meta: t.meta,
existing: c.get(t.id)
}));
for (const e of [...o, ...s]) if (!c.has(e.id)) c.set(e.id, e.meta);
return {
entries: Array.from(c, ([e, t]) => ({
id: e,
meta: t
})).filter((e) => shouldShowChannelInSetup(e.meta)),
installedCatalogEntries: o,
installableCatalogEntries: s,
installedCatalogById: new Map(o.map((e) => [e.id, e])),
installableCatalogById: new Map(s.map((e) => [e.id, e]))
};
}
//#endregion
export { resolveChannelSetupEntries as n, shouldShowChannelInSetup as r, isCatalogChannelInstalled as t };