UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

43 lines (42 loc) • 2.65 kB
import { S as resolveIsConfigReadOnly } from "./paths-DAcAg5aV.mjs"; import { n as createMergePatch } from "./merge-patch-D-7aajuy.mjs"; import { n as resolveConfigWidePluginManifestRegistry } from "./io.plugin-metadata-CBwzHw3m.mjs"; import { s as readConfigFileSnapshot } from "./io.runtime-DsJ2dLCQ.mjs"; import "./config-CMA-J084.mjs"; import { t as redactConfigObject } from "./redact-snapshot-HHllfRSn.mjs"; import { i as restoreDoctorConfigEnvRefs } from "./config-flow-steps-ETwvCUK9.mjs"; import { t as buildRuntimeConfigSchemaFromRegistry } from "./runtime-schema-XjYfZSYY.mjs"; //#region src/flows/doctor-external-config.ts /** Report the candidate without granting the authority of a committed config write. */ async function reportDoctorExternalConfigRepairs(e) { const t = await readConfigFileSnapshot({ observe: false }); 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("\n")); 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; } //#endregion export { reportDoctorExternalConfigRepairs, validateDoctorExternalConfigForStartup };