UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

68 lines (67 loc) • 2.81 kB
import { t as quoteCliArg } from "./quote-cli-arg-J7A9UE6m.mjs"; import { n as resolveBunGlobalInstallOwner } from "./detect-package-manager-CKgXb1er.mjs"; import { n as inspectBunCliLauncher, o as resolveBunGlobalBinDir, r as installBunCliLauncher, t as getBunCliLauncherPathIssue } from "./bun-cli-launcher-CpBg5TXY.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import fs from "node:fs"; import path from "node:path"; //#region src/commands/doctor-bun-cli-launcher.ts function hasPersistentNode() { for (const e of (process.env.PATH ?? "").split(path.delimiter)) { const t = path.resolve(e || ".", "node"); try { fs.accessSync(t, fs.constants.X_OK); if (!fs.statSync(t).isFile()) continue; if (/^bun-node-(?:[0-9a-f]+|[0-9]+-(?:[0-9a-f]+|debug)(?:-[0-9a-f]{16})?)$/u.test(path.basename(path.dirname(t))) && fs.realpathSync(t) === fs.realpathSync(process.execPath)) continue; return true; } catch {} } return false; } async function noteBunCliLauncherIssues(e) { if (!e.root || !process.versions.bun || process.platform === "win32" || e.prompter.repairMode.updateInProgress || hasPersistentNode()) return; const t = resolveBunGlobalInstallOwner(e.root); if (!t) return; const n = path.join(e.root, "openclaw.mjs"); const r = getBunCliLauncherPathIssue({ bunPath: process.execPath, entryPath: n }); if (r) { const e = `${quoteCliArg(process.execPath)} ${quoteCliArg(n)}`; note(`${r}. Run ${e} instead.`, "Bun CLI launcher"); return; } try { const n = resolveBunGlobalBinDir({ bunPath: process.execPath, cwd: t.globalProjectRoot, env: { ...process.env, BUN_INSTALL_GLOBAL_DIR: t.globalProjectRoot, ...t.bunInstall ? { BUN_INSTALL: t.bunInstall } : {} } }); const r = { packageRoot: e.root, bunPath: process.execPath, binDir: n }; const i = inspectBunCliLauncher(r); if (i.state === "current") return; if (i.state === "conflict") { note(`The openclaw command at ${i.path} belongs to another installation. Resolve the conflicting command before repairing this Bun installation.`, "Bun CLI launcher"); return; } note(`The Bun CLI launcher is ${i.state}: ${i.path}. The openclaw command needs a launcher that uses this installation's Bun executable.`, "Bun CLI launcher"); if (!await e.prompter.confirmAutoFix({ message: "Repair the openclaw command for this Bun installation?", initialValue: false })) return; const a = installBunCliLauncher(r); note(`Repaired the Bun CLI launcher: ${a.path}`, "Bun CLI launcher"); } catch (e) { note(`Could not repair the Bun CLI launcher: ${e instanceof Error ? e.message : String(e)}. Run Doctor with --fix through this package's Bun entry point after resolving the problem.`, "Bun CLI launcher"); } } //#endregion export { noteBunCliLauncherIssues };