UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

34 lines (33 loc) • 2.56 kB
import { i as collectNestedErrorCandidates } from "./error-coercion-hDrHOSGy.mjs"; import { t as ExitError } from "./runtime-B-SLYP-m.mjs"; import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs"; import { n as OpenClawStateOwnershipError } from "./sqlite-lifecycle-errors-D8BU4VLa.mjs"; import { u as isSqliteSchemaMismatchError } from "./openclaw-state-db-schema-helpers-nImZNMq_.mjs"; import { r as findStartupMaintenanceRequiredError } from "./startup-maintenance-required-DEn4Krys.mjs"; import { o as isTerminalSqliteIntegrityError } from "./sqlite-integrity-CCmEgO_m.mjs"; import { h as isAgentDatabaseOwnershipMismatchError } from "./agent-database-admission-CL6wHJ_N.mjs"; //#region src/commands/doctor-startup-migration-refusal.ts /** Admission, final reads and in-process restarts share the same terminal refusal facts. */ function isStartupConfigRefusal(e) { return Boolean(findStartupMaintenanceRequiredError(e)) || isAgentDatabaseOwnershipMismatchError(e) || collectNestedErrorCandidates(e).some((e) => e instanceof Error && (e instanceof OpenClawStateOwnershipError || isSqliteSchemaMismatchError(e) || isTerminalSqliteIntegrityError(e) || e.name === "SqliteRepairableForeignKeyError")); } /** Preserve explicit exits and operational failures after the caller's cleanup has settled. */ function rethrowStartupConfigFailure(e) { if (e instanceof ExitError || !isStartupConfigRefusal(e)) throw e; return throwStartupMigrationRefusal(formatErrorMessage(e), e); } function throwStartupMigrationRefusal(e, t) { console.error(e); throw Object.assign(new ExitError(78, e), { cause: t }); } function throwStartupMigrationGuardRejected() { throw new Error("OpenClaw startup migrations were skipped because the selected config changed during startup; refusing to report the gateway ready. Retry startup so the new config can be validated."); } async function refuseStartupMigrationsForLiveGatewayOwner(e) { if (e.VITEST || e.NODE_ENV === "test") return; const { readActiveGatewayLockIdentity: t } = await import("./gateway-lock-C8DzJkpV.mjs"); const n = await t({ env: e }); if (n) throwStartupMigrationRefusal(`Another gateway (pid ${n.pid}) already owns this state directory; refusing to run automatic startup migrations or report the gateway ready. Stop it with "openclaw gateway stop" (or select a different OPENCLAW_STATE_DIR), then retry startup.`); } //#endregion export { throwStartupMigrationGuardRejected as i, refuseStartupMigrationsForLiveGatewayOwner as n, rethrowStartupConfigFailure as r, isStartupConfigRefusal as t };