openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines • 2.78 kB
JavaScript
import{l as isRecord}from"../record-coerce-BTbqdJ3-.mjs";import{i as routeLogsToStderr}from"../console-BHJbJ-IX.mjs";import{a as withArtifactPreservingStateReads}from"../artifact-preserving-state-reads-CWuQPqxe.mjs";import{r as validateConfigObjectRawWithPlugins}from"../validation-CGAl0yU4.mjs";import{t as createConfigIO}from"../io.factory-y6nIrp_4.mjs";import{n as preparePluginDoctorContractModules}from"../doctor-contract-preparation-qRvs5BHm.mjs";import{i as restoreDoctorConfigEnvRefs,r as prepareDoctorConfigReferenceSource}from"../config-flow-steps-BNUk0fFW.mjs";import{n as containsAuthoredInclude}from"../include-migration-ownership-KASn2yVx.mjs";import{n as collectConfigSecretProviderErrors}from"../config-cli-validation-DGKbpwAX.mjs";import{t as planLegacyConfigForUpdateChannel}from"../legacy-config-repair-D_AyTa-j.mjs";import{n as collectConfigWriteChangedPaths}from"../config-change-paths-DKaL23st.mjs";import{createHash}from"node:crypto";
//!src/infra/update-config-projection.ts
async function projectUpdateConfig(){return await withArtifactPreservingStateReads(async()=>{const e=await createConfigIO({observe:false,pluginValidation:`core-only`,shellEnvFallback:`defer`,suppressFutureVersionWarning:true}).readConfigFileSnapshot();if(!e.exists||e.readError||e.issues.some(e=>e.errorCode===`CONFIG_SOURCE_INVALID`||e.errorCode===`CONFIG_READ_FAILED`)||e.raw===null||!isRecord(e.parsed))throw new Error(`Cannot read deployment config; repair the authored config before deploying.`);const t=validateConfigObjectRawWithPlugins(e.sourceConfig,{semanticValidation:`strict`});let n;if(!t.ok){await preparePluginDoctorContractModules({config:e.sourceConfig,surfaces:[`configRepair`],artifactPreservingReadOnly:true});n=planLegacyConfigForUpdateChannel(e,{},`strict`)}const r=n?{ok:true,config:n.config}:t;const i=r.ok?await collectConfigSecretProviderErrors({config:r.config}):r.issues;if(i.length)throw new Error(`Deployment config remains invalid at: ${i.map(e=>e.path||`<root>`).join(`, `)}. Run openclaw doctor --fix and correct remaining errors.`);if(n?.changes.length&&containsAuthoredInclude(e.parsed))throw new Error(`Deployment config projection does not write $include files; run Doctor first.`);const a=n?.changes.length?restoreDoctorConfigEnvRefs(n.nextConfig,prepareDoctorConfigReferenceSource(e)):e.parsed;return{configPath:e.path,originalSha256:createHash(`sha256`).update(e.raw).digest(`hex`),config:a,changedPaths:[...collectConfigWriteChangedPaths(e.parsed,a,[])].toSorted(),changes:n?.changes??[]}})}
//!src/infra/update-config-projection.worker.ts
routeLogsToStderr();try{process.stdout.write(`${JSON.stringify(await projectUpdateConfig())}\n`)}catch(e){process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`);process.exitCode=1}export{};