UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

45 lines (44 loc) • 1.48 kB
import { t as ExitError } from "./runtime-B-SLYP-m.mjs"; import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs"; import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs"; import { r as isTerminalInteractive } from "./terminal-interactivity-B_L_vZTP.mjs"; //#region src/cli/invalid-config-recovery.ts /** Offer a consent-gated doctor repair, then retry the failed operation once. */ async function offerInvalidConfigRecovery(e) { const t = formatCliCommand("openclaw doctor --fix"); const printCommand = () => { e.runtime.error(`Run "${t}" to repair the config, then retry.`); }; if (!isTerminalInteractive()) { printCommand(); return false; } const { promptYesNo: n } = await import("./prompt-D5h12jkR.mjs"); if (!await n(`Run "${t}" now?`, true)) { printCommand(); return false; } try { if (e.runDoctor) await e.runDoctor(); else { const { doctorCommand: t } = await import("./doctor-B7yUF_kQ.mjs"); await t(e.runtime, { repair: true }); } } catch (n) { if (n instanceof ExitError) throw n; e.runtime.error(`Failed to run "${t}": ${formatErrorMessage(n)}`); return false; } try { await e.retry(); return true; } catch (n) { const { isInvalidConfigError: r } = await import("./io.invalid-config-DHUoEji6.mjs"); if (!r(n)) throw n; e.runtime.error(`Config is still invalid after "${t}":`); e.runtime.error(formatErrorMessage(n)); return false; } } //#endregion export { offerInvalidConfigRecovery };