UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

4 lines • 2.55 kB
import{S as resolveIsConfigReadOnly}from"./paths-D_FOvGon.mjs";import{n as createMergePatch}from"./merge-patch-CKGPHlQC.mjs";import{n as resolveConfigWidePluginManifestRegistry}from"./io.plugin-metadata-B_ulgGTA.mjs";import{s as readConfigFileSnapshot}from"./io.runtime-BvSeVFIY.mjs";import"./config-DkZ8y8Gv.mjs";import{t as redactConfigObject}from"./redact-snapshot-B-h1qJ6D.mjs";import{n as preparePluginDoctorContractModules}from"./doctor-contract-preparation-qRvs5BHm.mjs";import{i as restoreDoctorConfigEnvRefs}from"./config-flow-steps-BNUk0fFW.mjs";import{t as buildRuntimeConfigSchemaFromRegistry}from"./runtime-schema-Bs3owTmg.mjs"; //!src/flows/doctor-external-config.ts async function reportDoctorExternalConfigRepairs(e){const t=await readConfigFileSnapshot({observe:false});await preparePluginDoctorContractModules({config:e.cfg,surfaces:[`configRepair`]});const n=restoreDoctorConfigEnvRefs(e.cfg,e.configResult.referenceSource,e.configResult.explicitSetPaths);const r=e.externalConfigRepairsPending?restoreDoctorConfigEnvRefs(e.cfgForPersistence,e.configResult.referenceSource):e.configResult.referenceSource?.authored??t.sourceConfigBeforeMigrations??t.sourceConfig;const i=createMergePatch(r,n);const a=resolveConfigWidePluginManifestRegistry({config:e.cfg,env:e.env??process.env});const{uiHints:o}=buildRuntimeConfigSchemaFromRegistry(a,e.cfg);e.runtime.log([`Config repairs pending in externally managed ${t.path}; no config files were changed.`,`Apply this merge patch in the external deployment source (null removes a key; arrays replace the whole array). For $include-owned keys, edit the included source. Redacted values must be supplied externally, not copied from this report.`,JSON.stringify(redactConfigObject(i,o),null,2)].join(` `));e.externalConfigRepairsPending=true;e.configResult.shouldWriteConfig=false;delete e.configResult.pendingChangePanels;delete e.configResult.retiredModelRefConfig;e.cfg=t.config;e.cfgForPersistence=structuredClone(t.config)}async function validateDoctorExternalConfigForStartup(e){if(!resolveIsConfigReadOnly())return true;const t=await readConfigFileSnapshot({observe:false});if(t.valid&&t.legacyIssues.length===0)return true;for(const n of[...t.issues,...t.legacyIssues])e.error(`- ${n.path||`<root>`}: ${n.message}`);e.error(`Gateway startup requires the pending config repairs. Apply the reported edits in the external source for ${t.path}, then redeploy. No config files were changed.`);return false}export{reportDoctorExternalConfigRepairs,validateDoctorExternalConfigForStartup};