UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.85 kB
import{n as getDeferredPluginMigrationConfigFacts}from"./deferred-plugin-migration-config-D1j_2i5D.mjs";import{r as validateConfigObjectRawWithPlugins}from"./validation-CGAl0yU4.mjs";import{s as readConfigFileSnapshot}from"./io.runtime-BvSeVFIY.mjs";import{i as resolveConfigIncludeWriteBoundary,r as replaceConfigFile}from"./mutate-DcH8aT_4.mjs";import"./config-DkZ8y8Gv.mjs";import{n as preparePluginDoctorContractModules}from"./doctor-contract-preparation-qRvs5BHm.mjs";import{a as migrateLegacyConfig,i as restoreDoctorConfigEnvRefs,r as prepareDoctorConfigReferenceSource}from"./config-flow-steps-BNUk0fFW.mjs";import{n as containsAuthoredInclude}from"./include-migration-ownership-KASn2yVx.mjs"; //!src/commands/doctor/legacy-config-repair.ts function planLegacyConfigForUpdateChannel(e,t={},n){const r=containsAuthoredInclude(e.parsed);const i=migrateLegacyConfig(e.sourceConfig,{sourceConfigBeforeMigrations:e.sourceConfigBeforeMigrations,context:{authoredRaw:e.parsed,resolvedRaw:e.sourceConfig}},n);const a=getDeferredPluginMigrationConfigFacts(e.sourceConfig);if(!i.config&&!i.warnings?.length)return;const o=i.sourceConfig??i.config??e.sourceConfig;const s=i.config&&!i.partiallyValid&&!a?.length?{ok:true,config:i.config}:validateConfigObjectRawWithPlugins(i.config??o,{semanticValidation:n});if(!s.ok)return;if(r&&!resolveConfigIncludeWriteBoundary({snapshot:e,nextConfig:o}))return;return{snapshot:e,config:s.config,nextConfig:o,changes:i.changes,...i.warnings?.length?{warnings:i.warnings}:{},includeIdentity:{includeFileHashesForWrite:{...t.includeFileHashesForWrite},includeFileTargetsForWrite:{...t.includeFileTargetsForWrite}}}}async function repairLegacyConfigForUpdateChannel(e){await preparePluginDoctorContractModules({config:e.configSnapshot.sourceConfig,surfaces:[`configRepair`]});const t=e.plan??planLegacyConfigForUpdateChannel(e.configSnapshot);if(!t)return{snapshot:e.configSnapshot,repaired:false};const n=t.warnings?.length?{warnings:t.warnings}:{};if(t.changes.length===0)return{snapshot:e.configSnapshot,repaired:false,...n};if(e.plan&&containsAuthoredInclude(t.snapshot.parsed)){const e=t.snapshot.includedPaths??[];if(e.length===0||e.some(e=>!t.includeIdentity.includeFileHashesForWrite?.[e]||!t.includeIdentity.includeFileTargetsForWrite?.[e]))throw new Error(`Legacy config plan is missing include write identities.`)}await replaceConfigFile({sourceConfig:restoreDoctorConfigEnvRefs(t.nextConfig,prepareDoctorConfigReferenceSource(t.snapshot)),baseHash:t.snapshot.hash,writeOptions:{...e.plan?t.includeIdentity:e.configWriteOptions,expectedConfigPath:t.snapshot.path,auditOrigin:`doctor`,allowConfigSizeDrop:true,skipOutputLogs:e.jsonMode}});const r=await readConfigFileSnapshot();return{snapshot:r,repaired:r.valid,...n}}export{repairLegacyConfigForUpdateChannel as n,planLegacyConfigForUpdateChannel as t};