UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

89 lines (88 loc) • 2.78 kB
import { r as createPluginActivationSource, u as normalizePluginsConfig } from "./config-state-B1JlHgba.mjs"; import { _ as withBundledPluginEnablementCompat } from "./installed-plugin-index-DYqse_gE.mjs"; import { i as getCurrentPluginMetadataSnapshot } from "./current-plugin-metadata-snapshot-H0TP3PFt.mjs"; import { t as applyPluginAutoEnable } from "./plugin-auto-enable-CPcwS2II.mjs"; //#region src/plugins/activation-context.ts function withActivatedPluginIds(e) { if (e.pluginIds.length === 0) return e.config; const t = e.config?.plugins?.allow ?? []; const n = t.length > 0 ? new Set(t) : void 0; const r = new Set(t); const i = { ...e.config?.plugins?.entries }; let a = false; for (const t of e.pluginIds) { const e = t.trim(); if (!e) continue; if (n && !n.has(e)) continue; r.add(e); const o = i[e]; const s = o?.enabled !== false; a ||= o?.enabled !== s; i[e] = { ...o, enabled: s }; } if (!a && r.size === t.length && e.config?.plugins?.entries) return e.config; return { ...e.config, plugins: { ...e.config?.plugins, ...r.size > 0 ? { allow: [...r] } : {}, entries: i } }; } function resolveBundledCompatActivationInputs(e) { const t = e.env ?? process.env; const n = e.rawConfig ?? e.resolvedConfig; let r = e.resolvedConfig ?? e.rawConfig; let i = e.autoEnabledReasons; if (e.applyAutoEnable && n !== void 0) { const a = e.manifestRegistry ? void 0 : getCurrentPluginMetadataSnapshot({ config: n, env: t, workspaceDir: e.workspaceDir, allowWorkspaceScopedSnapshot: true }); const o = !e.manifestRegistry && normalizePluginsConfig(n.plugins).loadPaths.length === 0 ? getCurrentPluginMetadataSnapshot({ env: t, workspaceDir: e.workspaceDir, allowWorkspaceScopedSnapshot: true, requireDefaultDiscoveryContext: true }) : void 0; const s = e.manifestRegistry ?? a?.manifestRegistry ?? o?.manifestRegistry; const c = applyPluginAutoEnable({ config: n, env: t, manifestRegistry: s, discovery: e.discovery ?? a?.discovery ?? o?.discovery }); r = c.config; i = c.autoEnabledReasons; } const a = createPluginActivationSource({ config: n }); const o = e.resolveBundledPluginIds({ config: r, workspaceDir: e.workspaceDir, env: t, onlyPluginIds: e.onlyPluginIds, ...e.manifestRegistry ? { manifestRegistry: e.manifestRegistry } : {} }); const s = withBundledPluginEnablementCompat({ config: r, pluginIds: o, env: t, ...e.activation ? { activation: e.activation } : {} }); return { rawConfig: n, config: s, normalized: normalizePluginsConfig(s?.plugins), activationSourceConfig: n, activationSource: a, autoEnabledReasons: i ?? {} }; } //#endregion export { withActivatedPluginIds as n, resolveBundledCompatActivationInputs as t };