openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
4 lines • 2.66 kB
JavaScript
import{o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs";import{n as isTruthyEnvValue}from"./env-fLMEolk5.mjs";import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{i as UPDATE_RUNNER_TIMEOUT_MS}from"./update-run-timeouts-MQiDlYE0.mjs";import{n as runCommandWithTimeout}from"./exec-runner-BiCq-T1F.mjs";import"./exec-c5tqm8tb.mjs";import{n as readInstallOwner,t as formatInstallOwnerMessage}from"./install-owner-BPkbFuTm.mjs";import{t as note}from"./note-e4DtVgg2.mjs";import{a as isServiceRepairDeferred}from"./doctor-service-repair-policy-gYXaFNLg.mjs";import path from"node:path";import fs from"node:fs/promises";
//!src/commands/doctor-update.ts
async function resolveComparablePath(e){return await fs.realpath(e).catch(()=>path.resolve(e))}async function detectOpenClawGitCheckout(e){const t=await runCommandWithTimeout([`git`,`-C`,e,`rev-parse`,`--show-toplevel`],{timeoutMs:5e3}).catch(()=>null);if(!t)return`unknown`;if(t.code!==0){if(normalizeLowercaseStringOrEmpty(t.stderr).includes(`not a git repository`))return`not-git`;return`unknown`}return await resolveComparablePath(t.stdout.trim())===await resolveComparablePath(e)?`git`:`not-git`}async function maybeOfferUpdateBeforeDoctor(e){const t=await readInstallOwner(e.root);if(t){note(formatInstallOwnerMessage(t),`Update`);return false}if(!(!isTruthyEnvValue(process.env.OPENCLAW_UPDATE_IN_PROGRESS)&&e.options.nonInteractive!==true&&e.options.yes!==true&&e.options.repair!==true&&process.stdin.isTTY)||!e.root)return false;const n=await detectOpenClawGitCheckout(e.root);if(n===`git`){if(isServiceRepairDeferred()){note(`Update through the external supervisor's stop/update/finalize/restart workflow. Continuing Doctor without updating OpenClaw.`,`Update`);return false}if(!await e.confirm({message:`Update OpenClaw from git before running doctor?`,initialValue:true}))return false;const{updateCommand:t}=await import(`./update-command-R0C_YNK_.mjs`);let n=false;let r=false;await t({sourceUpdate:{root:e.root},timeout:String(UPDATE_RUNNER_TIMEOUT_MS/1e3),onResult:e=>{r=e.status===`skipped`&&(e.reason===`gateway-readiness-unverified`||e.reason===`still-starting`);n=e.status===`ok`||r}});if(n)e.outro(r?"OpenClaw installed; Gateway readiness remains unverified. Keep recovery backups and check `openclaw gateway status --deep`.":`Update completed (doctor already ran as part of the update).`);return n}if(n===`not-git`)note([`This install is not a git checkout.`,`Run \`${formatCliCommand(`openclaw update`)}\` to update via your package manager (npm/pnpm), then rerun doctor.`].join(`
`),`Update`);return false}export{maybeOfferUpdateBeforeDoctor};