UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

41 lines (40 loc) • 2.45 kB
import { n as sanitizeTerminalText } from "./safe-text-C80HAQ2e.mjs"; import { o as isDefaultInstallIdentity } from "./paths-DAcAg5aV.mjs"; import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs"; import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import { n as formatForeignLaunchdJobs, r as repairForeignLaunchdJob, t as findForeignLaunchdJobs } from "./launchd-foreign-jobs-BHyHjyeW.mjs"; import { t as readGatewayForcedRestartSummary } from "./restart-storm-B83OT9uT.mjs"; import { a as isServiceRepairDeferred, l as shouldManageGatewayService, s as resolveServiceRepairPolicy } from "./doctor-service-repair-policy-DAuL0W8-.mjs"; //#region src/commands/doctor-foreign-launchd-jobs.ts /** Reports foreign launchd jobs; only explicit Doctor repair may remove lifecycle jobs. */ async function noteMacForeignLaunchdJobs(e, t, n = process.env) { if (process.platform !== "darwin") return; let r; try { r = await findForeignLaunchdJobs(n); } catch (e) { note(`Could not inspect foreign launchd jobs: ${sanitizeTerminalText(formatErrorMessage(e))}. No jobs were removed.`, "Foreign launchd jobs (macOS)"); return; } if (r.length === 0) return; const i = [formatForeignLaunchdJobs(r)]; const a = readGatewayForcedRestartSummary(n); if (a.count > 0) i.push(`${a.count} external forced Gateway restart(s) in the last ${Math.round(a.windowMs / 6e4)} minutes. Listed lifecycle jobs may be responsible; this is not proof of attribution.`); const o = r.filter((e) => e.safeToRemove); if (o.length > 0) i.push(`Run ${formatCliCommand("openclaw doctor --fix", n)} to remove confirmed stray Gateway lifecycle jobs.`); note(i.join("\n"), "Foreign launchd jobs (macOS)"); if (e.repair !== true || o.length === 0) return; if (!isDefaultInstallIdentity(n) || isServiceRepairDeferred(resolveServiceRepairPolicy(n)) || !await shouldManageGatewayService(n)) { t.log("Foreign launchd job repair skipped: this Doctor invocation does not own service repair or an update is in progress. No jobs were removed."); return; } for (const e of o) try { const r = await repairForeignLaunchdJob(e, n); t.log(r.removed ? r.detail : `Removal not confirmed for launchd job ${e.label}: ${r.detail}`); } catch (n) { t.log(`Removal not confirmed for launchd job ${e.label}: ${sanitizeTerminalText(formatErrorMessage(n))}`); } } //#endregion export { noteMacForeignLaunchdJobs };