UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

96 lines (95 loc) 4.58 kB
import { m as resolveAgentWorkspaceDir, y as resolveDefaultAgentId } from "./agent-scope-config-DcbEhP0R.js"; import { l as normalizeChannelMeta } from "./bundled-0Ib5Dos0.js"; import "./agent-scope-DbtJyKUL.js"; import { n as isStaticallyChannelConfigured } from "./channel-configured-shared-CChXyXPv.js"; import { r as isChannelVisibleInSetup } from "./channel-meta-BgTks57p.js"; import { r as listChatChannels } from "./chat-meta-tsXGPguN.js"; import { t as applyPluginAutoEnable } from "./plugin-auto-enable-Tv_C18cS.js"; import { t as listManifestChannelContributionIds } from "./manifest-contribution-ids-CfWzbwU-.js"; import { n as listSetupDiscoveryChannelPluginCatalogEntries, r as listTrustedChannelPluginCatalogEntries } from "./trusted-catalog-DHqhhA7d.js"; //#region src/commands/channel-setup/discovery.ts /** Return true when channel metadata should appear in setup/onboarding choices. */ function shouldShowChannelInSetup(meta) { return isChannelVisibleInSetup(meta); } function resolveWorkspaceDir(cfg, workspaceDir) { return workspaceDir ?? resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg)); } /** List channel ids contributed by currently installed manifest-backed plugins. */ function listManifestInstalledChannelIds(params) { const resolvedConfig = applyPluginAutoEnable({ config: params.cfg, env: params.env ?? process.env }).config; const workspaceDir = resolveWorkspaceDir(resolvedConfig, params.workspaceDir); return new Set(listManifestChannelContributionIds({ config: resolvedConfig, workspaceDir, env: params.env ?? process.env, ...params.index ? { index: params.index } : {} }).map((channelId) => channelId)); } /** Return true when a trusted catalog channel is already installed through plugin manifests. */ function isCatalogChannelInstalled(params) { return listManifestInstalledChannelIds(params).has(params.entry.id); } /** Merge configured channels and installable catalog channels into setup display buckets. */ function resolveChannelSetupEntries(params) { const workspaceDir = resolveWorkspaceDir(params.cfg, params.workspaceDir); const manifestInstalledIds = listManifestInstalledChannelIds({ cfg: params.cfg, workspaceDir, env: params.env }); const installedPluginIds = new Set(params.installedPlugins.map((plugin) => plugin.id)); const installedCatalogEntriesSource = listTrustedChannelPluginCatalogEntries({ cfg: params.cfg, workspaceDir, env: params.env }); const installableCatalogEntriesSource = listSetupDiscoveryChannelPluginCatalogEntries({ cfg: params.cfg, workspaceDir, env: params.env }); const installedCatalogEntries = installedCatalogEntriesSource.filter((entry) => !installedPluginIds.has(entry.id) && manifestInstalledIds.has(entry.id) && shouldShowChannelInSetup(entry.meta)).map((entry) => Object.assign({}, entry, { meta: normalizeChannelMeta({ id: entry.id, meta: entry.meta }) })); const installableCatalogEntries = installableCatalogEntriesSource.filter((entry) => !installedPluginIds.has(entry.id) && !manifestInstalledIds.has(entry.id) && !isStaticallyChannelConfigured(params.cfg, entry.id, params.env ?? process.env) && shouldShowChannelInSetup(entry.meta)).map((entry) => Object.assign({}, entry, { meta: normalizeChannelMeta({ id: entry.id, meta: entry.meta }) })); const metaById = /* @__PURE__ */ new Map(); for (const meta of listChatChannels()) metaById.set(meta.id, normalizeChannelMeta({ id: meta.id, meta })); for (const plugin of params.installedPlugins) metaById.set(plugin.id, normalizeChannelMeta({ id: plugin.id, meta: plugin.meta, existing: metaById.get(plugin.id) })); for (const entry of installedCatalogEntries) if (!metaById.has(entry.id)) metaById.set(entry.id, normalizeChannelMeta({ id: entry.id, meta: entry.meta, existing: metaById.get(entry.id) })); for (const entry of installableCatalogEntries) if (!metaById.has(entry.id)) metaById.set(entry.id, normalizeChannelMeta({ id: entry.id, meta: entry.meta, existing: metaById.get(entry.id) })); return { entries: Array.from(metaById, ([id, meta]) => ({ id, meta })).filter((entry) => shouldShowChannelInSetup(entry.meta)), installedCatalogEntries, installableCatalogEntries, installedCatalogById: new Map(installedCatalogEntries.map((entry) => [entry.id, entry])), installableCatalogById: new Map(installableCatalogEntries.map((entry) => [entry.id, entry])) }; } //#endregion export { shouldShowChannelInSetup as i, listManifestInstalledChannelIds as n, resolveChannelSetupEntries as r, isCatalogChannelInstalled as t };