UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

79 lines (78 loc) • 3.72 kB
import { y as sortUniqueStrings } from "./string-normalization-DLmfYZXI.mjs"; import { i as readBundledDiscoveryModeMemoized } from "./bundled-discovery-state-Bb0zCvZZ.mjs"; import { u as normalizePluginsConfig } from "./config-state-B1JlHgba.mjs"; import { h as isBundledProviderCompatContract, i as isInstalledPluginEnabled, t as createInstalledPluginEnabledPredicate } from "./installed-plugin-index-DYqse_gE.mjs"; import { i as resolveChannelConfigRecord, n as hasMeaningfulChannelConfigShallow } from "./channel-config-activation-BzEa8FnN.mjs"; import { p as resolvePluginMetadataSnapshot } from "./plugin-metadata-snapshot-By9ySblt.mjs"; import { a as resolveManifestOwnerBasePolicyBlock } from "./manifest-owner-policy-B8Brw4Zo.mjs"; //#region src/plugins/manifest-contract-eligibility.ts /** Enforces owner-specific policy while preserving bundled speech/global compatibility. */ function isManifestPluginOwnerAllowedByControlPlanePolicy(e) { if (!e.config?.plugins) return true; const t = e.config; const n = e.normalizedConfig ?? normalizePluginsConfig(t.plugins); const r = n.enabled ? n : { ...n, enabled: true }; const i = resolveManifestOwnerBasePolicyBlock({ plugin: e.plugin, normalizedConfig: r, allowRestrictiveAllowlistBypass: e.plugin.origin === "bundled" && e.allowRestrictiveAllowlistBypass === true }); if (i !== "not-in-allowlist") return i === null; if (e.plugin.origin !== "bundled") return false; if ((e.plugin.channels ?? [e.plugin.id]).some((e) => { const n = resolveChannelConfigRecord(t, e); return n?.enabled !== false && hasMeaningfulChannelConfigShallow(n, e); })) return true; return e.allowBundledProviderCompat === true && readBundledDiscoveryModeMemoized(e.env) === "compat"; } function isManifestPluginAvailableForControlPlane(e) { if (!isManifestPluginOwnerAllowedByControlPlanePolicy(e)) return false; if (e.plugin.origin === "bundled") return true; if (e.isInstalledPluginEnabled) return e.isInstalledPluginEnabled(e.plugin.id); return isInstalledPluginEnabled(e.snapshot.index, e.plugin.id, e.config, e.env); } function hasManifestContractValue(e) { const t = e.plugin.contracts?.[e.contract] ?? []; return t.length > 0 && (!e.value || t.includes(e.value)); } function listAvailableManifestContractPlugins(e) { const t = normalizePluginsConfig(e.config?.plugins); const n = createInstalledPluginEnabledPredicate(e.snapshot.index.plugins, e.config, e.env); return e.snapshot.plugins.filter((r) => hasManifestContractValue({ plugin: r, contract: e.contract, value: e.value }) && isManifestPluginAvailableForControlPlane({ snapshot: e.snapshot, plugin: r, config: e.config, normalizedConfig: t, isInstalledPluginEnabled: n, env: e.env, allowBundledProviderCompat: isBundledProviderCompatContract(e.contract) })); } function listAvailableManifestContractValues(e) { return sortUniqueStrings(listAvailableManifestContractPlugins(e).flatMap((t) => t.contracts?.[e.contract] ?? [])); } function loadManifestContractSnapshot(e) { const t = loadManifestMetadataSnapshot(e); return { index: t.index, plugins: t.plugins, byPluginId: t.byPluginId }; } function loadManifestMetadataSnapshot(e) { return resolvePluginMetadataSnapshot({ config: e.config, env: e.env ?? process.env, ...e.workspaceDir ? { workspaceDir: e.workspaceDir } : {}, allowWorkspaceScopedCurrent: e.workspaceDir === void 0 }); } //#endregion export { listAvailableManifestContractValues as a, listAvailableManifestContractPlugins as i, isManifestPluginAvailableForControlPlane as n, loadManifestContractSnapshot as o, isManifestPluginOwnerAllowedByControlPlanePolicy as r, loadManifestMetadataSnapshot as s, hasManifestContractValue as t };