openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.79 kB
JavaScript
import{t as _usingCtx}from"./usingCtx-CUVyQ_FT.mjs";import{t as CLIENT_CREDENTIAL_CUTOVER_SCHEMA_VERSION}from"./openclaw-state-db-contract-G6fQNIi2.mjs";import{s as resolveOpenClawStateSqlitePath}from"./openclaw-state-db.paths-CbgXfEg1.mjs";import{a as isStatePostgres}from"./openclaw-state-db-engine-DiCia3Ut.mjs";import{r as openClientCredentialCustody}from"./client-credential-store-BZeU9erm.mjs";import{t as preparePostgresClientCredentials}from"./startup-client-credentials-l-WUdRDm.mjs";import fs from"node:fs";
//!src/commands/doctor-client-credentials.ts
async function prepareDoctorClientCredentials(e){if(!isStatePostgres()||!fs.existsSync(resolveOpenClawStateSqlitePath()))return true;if(e.schemas.pendingMigrations?.some(e=>e.kind===`state`&&e.foundVersion<29)){if(e.maintenanceActive)await preparePostgresClientCredentials(process.env,e.runtime);return true}let t;try{var n=_usingCtx();t=n.u(openClientCredentialCustody(process.env,{readOnly:true,migration:true}))!==void 0}catch(e){n.e=e}finally{n.d()}if(t){if(e.maintenanceActive)await preparePostgresClientCredentials(process.env,e.runtime);return true}e.runtime.log(`Local client credentials are missing. Repair gives clients on this host new identities, so they must re-pair. Paired remote devices keep working; their pairing records stay in PostgreSQL.`);if(!(e.maintenanceActive&&(e.options.repair===true||e.options.yes===true)&&(e.options.yes===true||await e.prompter.confirmRuntimeRepair({message:`Create new local client identities?`,initialValue:false,requiresInteractiveConfirmation:true})))){e.runtime.log(`Local credentials were not repaired. Run openclaw doctor --fix --yes.`);return false}await preparePostgresClientCredentials(process.env,e.runtime,true);return true}export{prepareDoctorClientCredentials};