UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

67 lines (66 loc) • 3 kB
import { o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs"; import { n as isTruthyEnvValue } from "./env-HehwidXj.mjs"; import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs"; import { i as UPDATE_RUNNER_TIMEOUT_MS } from "./update-run-timeouts-Byb-PlTk.mjs"; import { n as runCommandWithTimeout } from "./exec-runner-Br73vG-X.mjs"; import "./exec-aRIvS9s4.mjs"; import { n as readInstallOwner, t as formatInstallOwnerMessage } from "./install-owner-DDPQXcjQ.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import { a as isServiceRepairDeferred } from "./doctor-service-repair-policy-DAuL0W8-.mjs"; import path from "node:path"; import fs from "node:fs/promises"; //#region 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-B2TVTPGY.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("\n"), "Update"); return false; } //#endregion export { maybeOfferUpdateBeforeDoctor };