UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

108 lines (107 loc) • 4.57 kB
import { c as normalizeOptionalLowercaseString } from "./string-coerce-CCIiB4H7.mjs"; import { y as sortUniqueStrings } from "./string-normalization-DLmfYZXI.mjs"; import { u as normalizePluginsConfig, y as resolveSelectedContextEnginePluginIdFromConfig } from "./config-state-B1JlHgba.mjs"; import { n as listPotentialConfiguredChannelIds, t as listExplicitlyDisabledChannelIdsForConfig } from "./config-presence-G9kglnWa.mjs"; import { i as passesManifestOwnerBasePolicy } from "./manifest-owner-policy-B8Brw4Zo.mjs"; import { f as resolveConfiguredChannelPluginIds, p as resolveConfiguredChannelPluginIdsAsync, u as listExplicitConfiguredChannelIdsForConfig } from "./channel-presence-policy-6XNqNGJr.mjs"; import { s as loadManifestMetadataSnapshot } from "./manifest-contract-eligibility-DoGGge-2.mjs"; import { t as loadGatewayStartupPluginPlan } from "./gateway-startup-plugin-loader-CvtjWt_C.mjs"; import "./channel-plugin-ids-DZDzcpUB.mjs"; import { t as applyPluginAutoEnable } from "./plugin-auto-enable-CPcwS2II.mjs"; //#region src/plugins/effective-plugin-ids.ts /** Resolves effective plugin ids from config, installed records, and activation metadata. */ function resolveEffectivePluginIds(e) { return resolveEffectivePluginIdsWithChannels(e); } async function resolveEffectivePluginIdsAsync(e) { const t = e.metadataSnapshot?.pluginIds ? void 0 : e.metadataSnapshot; const n = applyPluginAutoEnable({ config: e.config, env: e.env, ...t ? { manifestRegistry: t.manifestRegistry } : {}, ...t?.discovery ? { discovery: t.discovery } : {} }); return resolveEffectivePluginIdsWithChannels(e, { autoEnabled: n, configuredPluginIds: await resolveConfiguredChannelPluginIdsAsync({ config: n.config, activationSourceConfig: e.config, workspaceDir: e.workspaceDir, env: e.env, manifestRecords: t?.plugins, discovery: t?.discovery }) }); } function resolveEffectivePluginIdsWithChannels(e, t) { const n = e.metadataSnapshot?.pluginIds ? void 0 : e.metadataSnapshot; const r = (t?.autoEnabled ?? applyPluginAutoEnable({ config: e.config, env: e.env, ...n ? { manifestRegistry: n.manifestRegistry } : {}, ...n?.discovery ? { discovery: n.discovery } : {} })).config; const i = normalizePluginsConfig(r.plugins); const a = new Set(i.enabled ? i.allow : []); if (i.enabled) { for (const [e, t] of Object.entries(i.entries)) if (t?.enabled === false) a.delete(e); else if (t?.enabled === true && (i.allow.length === 0 || i.allow.includes(e))) a.add(e); for (const e of i.deny) a.delete(e); } const o = resolveSelectedContextEnginePluginIdFromConfig(i, i.slots.contextEngine, i.enabled && i.slots.contextEngine && i.slots.contextEngine !== "legacy" ? (n ?? loadManifestMetadataSnapshot({ config: r, env: e.env, workspaceDir: e.workspaceDir })).plugins : []); if (o) a.add(o); const s = e.config; const c = e.env; const l = n?.discovery; const u = /* @__PURE__ */ new Set([...listExplicitlyDisabledChannelIdsForConfig(r), ...listExplicitlyDisabledChannelIdsForConfig(s)]); const d = [.../* @__PURE__ */ new Set([...listPotentialConfiguredChannelIds(r, c, { includePersistedAuthState: false, discovery: l }), ...listExplicitConfiguredChannelIdsForConfig(s)])].map((e) => normalizeOptionalLowercaseString(e)).filter((e) => { if (!e) return false; return !u.has(e); }).toSorted((e, t) => e.localeCompare(t)); const f = t?.configuredPluginIds ?? resolveConfiguredChannelPluginIds({ config: r, activationSourceConfig: e.config, workspaceDir: e.workspaceDir, env: e.env, manifestRecords: n?.plugins, discovery: n?.discovery }); for (const e of f) a.add(e); const p = normalizePluginsConfig(r.plugins); const m = new Set(d); if (m.size > 0) { const t = n?.plugins ?? loadManifestMetadataSnapshot({ config: r, env: e.env, workspaceDir: e.workspaceDir }).plugins; for (const e of t) { if (e.origin !== "bundled") continue; if (e.channels.some((e) => m.has(normalizeOptionalLowercaseString(e) ?? ""))) { const t = normalizeOptionalLowercaseString(e.id); if (t && passesManifestOwnerBasePolicy({ plugin: { id: t }, normalizedConfig: p, allowRestrictiveAllowlistBypass: true })) a.add(t); } } } for (const t of loadGatewayStartupPluginPlan({ config: r, activationSourceConfig: e.config, workspaceDir: e.workspaceDir, env: e.env, ...n ? { metadataSnapshot: n } : {} }).pluginIds) a.add(t); return sortUniqueStrings(a); } //#endregion export { resolveEffectivePluginIdsAsync as n, resolveEffectivePluginIds as t };