openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.94 kB
JavaScript
import{n as cloneConfigWithResolutionFacts}from"./resolution-facts-DYKtoyes.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{n as createHistoricalWebhookPinMigration}from"./legacy-webhook-pins-Cbp2UHL2.mjs";
//!src/plugins/doctor-compatibility-migration.ts
function applyPluginDoctorCompatibilitySequence(e,t){let n=e;const r=[];const i=[];for(const{pluginId:e,normalizeCompatibilityConfig:a,transform:o}of t){if(!a)continue;const t=cloneConfigWithResolutionFacts(n);try{const e=a({cfg:t});const s={...e,config:e?.changes.length?e.config:n,changes:e?.changes??[]};const c=o?o(s):s;if(c?.changes.length){n=c.config;r.push(...c.changes)}i.push(...c?.warnings??[])}catch(t){i.push(`Plugin "${e}" config repair failed: ${formatErrorMessage(t)}. Its config was preserved; run \`openclaw doctor --fix\` after repairing the plugin.`)}}return{config:n,changes:r,...i.length?{warnings:i}:{}}}function applyResolvedPluginDoctorCompatibilityMigrations(e,t,n){const r=n.historicalWebhookListeners?createHistoricalWebhookPinMigration(n.env,n.historicalWebhookCompletion,n.historicalWebhookListeners===`preserve-configured`):void 0;const i=r?r({config:e,changes:[]},void 0,n):{config:e,changes:[]};const a=applyPluginDoctorCompatibilitySequence(i.config,t.map(e=>{if(!n.isDeferred(e.pluginId))n.onInspectedPlugin?.(e.pluginId,e.rules.length>0||Boolean(e.normalizeCompatibilityConfig)||e.providerRenames.length>0);return{pluginId:e.pluginId,normalizeCompatibilityConfig:e.normalizeCompatibilityConfig,transform:r?t=>{if(e.historicalWebhookNormalizer)t.historicalWebhookAccountIds=e.historicalWebhookNormalizer({cfg:cloneConfigWithResolutionFacts(t.config)}).historicalWebhookAccountIds;return r(t,e.historicalWebhookListener,{...n,pluginId:e.pluginId,origin:e.origin})}:void 0}}));return{...a,changes:[...i.changes,...a.changes]}}export{applyResolvedPluginDoctorCompatibilityMigrations as n,applyPluginDoctorCompatibilitySequence as t};