openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines • 3.73 kB
JavaScript
import{o as preparePluginMetadataMachineStateAsync}from"./installed-plugin-index-record-state-Dlesa-xK.mjs";import{l as withPluginMetadataSnapshotScope}from"./current-plugin-metadata-snapshot-CYi8VAby.mjs";import{n as isChannelConfigMetadataKey}from"./config-metadata-RS-_hyk8.mjs";import{t as getBootstrapChannelPlugin}from"./bootstrap-registry-BEa1DI8x.mjs";import{r as collectDoctorConfigRepairPluginIds,s as listPluginDoctorLegacyConfigRules}from"./doctor-contract-registry-DTv7VdR4.mjs";import{n as preparePluginDoctorContractModules}from"./doctor-contract-preparation-qRvs5BHm.mjs";import{a as loadBundledChannelDoctorContractApi}from"./channel-legacy-config-migrate-CgDU_wO0.mjs";import{t as listDoctorConfiguredChannelIds}from"./configured-channel-ids-fKSHMbv6.mjs";import{c as findLegacySystemAgentOwnerIssue}from"./legacy-config-migrations-BjWfZbO1.mjs";import{t as findLegacyConfigIssues}from"./legacy-BynMAFZa.mjs";
//!src/channels/plugins/legacy-config.ts
function collectConfiguredChannelIds(e){if(!e||typeof e!==`object`)return[];const t=e.channels;if(!t||typeof t!==`object`||Array.isArray(t))return[];return Object.keys(t).map(e=>e.trim()).filter(e=>e&&!isChannelConfigMetadataKey(e))}function shouldIncludeLegacyRuleForTouchedPaths(e,t){if(!t||t.length===0)return true;return t.some(t=>{const n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return false;return true})}function collectRelevantChannelIdsForTouchedPaths(e){const t=collectConfiguredChannelIds(e.raw);const n=e.excludedChannelIds?.size?t.filter(t=>!e.excludedChannelIds?.has(t)):t;if(!e.touchedPaths||e.touchedPaths.length===0)return n;const r=/* @__PURE__ */ new Set;for(const t of e.touchedPaths){const[e,i]=t;if(e!==`channels`)continue;if(!i)return n;const a=i.trim();if(!a||isChannelConfigMetadataKey(a))continue;r.add(a)}return n.filter(e=>r.has(e))}function collectChannelLegacyConfigRules(e,t,n){const r=collectRelevantChannelIdsForTouchedPaths({raw:e,touchedPaths:t,excludedChannelIds:n});const i=[];const a=[];for(const e of r){const t=loadBundledChannelDoctorContractApi(e)?.legacyConfigRules;if(Array.isArray(t)){i.push(...t);continue}const n=getBootstrapChannelPlugin(e);if(n?.doctor?.legacyConfigRules?.length){i.push(...n.doctor.legacyConfigRules);continue}if(n)continue;a.push(e)}if(a.length>0)i.push(...listPluginDoctorLegacyConfigRules({config:e,pluginIds:a}));const o=/* @__PURE__ */ new Set;return i.filter(e=>{if(!shouldIncludeLegacyRuleForTouchedPaths(e.path,t))return false;const n=`${e.path.join(`.`)}::${e.message}`;if(o.has(n))return false;o.add(n);return true})}
//!src/commands/doctor/shared/legacy-config-issues.ts
function collectPluginLegacyConfigRules(e,t){const n=new Set(listDoctorConfiguredChannelIds(e,{configEntryPolicy:`raw`}));const r=collectDoctorConfigRepairPluginIds(e,t).filter(e=>!n.has(e));if(r.length===0)return[];return listPluginDoctorLegacyConfigRules({config:e,pluginIds:r})}function findDoctorLegacyConfigIssues(e,t,n){return findLegacyConfigIssues(e,t,[...collectChannelLegacyConfigRules(e,n),...collectPluginLegacyConfigRules(e,n)])}async function addDoctorLegacyIssues(e,t){if(!e.exists)return e;if(!t)(await preparePluginMetadataMachineStateAsync({}))();const n=e.sourceConfig??e.config??{};const collect=async()=>{await preparePluginDoctorContractModules({config:n,pluginIds:collectDoctorConfigRepairPluginIds(n),surfaces:[`configRepair`]});const t=e.parsed??n;const r=findDoctorLegacyConfigIssues(n,t);const i=findLegacySystemAgentOwnerIssue(e.sourceConfigBeforeMigrations??n);if(i)r.push(i);return r.length===0?e:{...e,legacyIssues:r}};return t?withPluginMetadataSnapshotScope(t,collect,{config:n}):collect()}export{findDoctorLegacyConfigIssues as n,addDoctorLegacyIssues as t};