UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

46 lines (45 loc) • 3.87 kB
import { i as isNewerSqliteWriterVersion, r as describeRunningOpenClawBuild, t as SqliteSchemaVersionError } from "./sqlite-user-version-C02a4KwH.mjs"; import { c as OPENCLAW_DATABASE_SCHEMA_DOCS_URL } from "./openclaw-state-db-contract-DfPjvL0M.mjs"; import { t as VERSION } from "./version-GlxUMdxI.mjs"; import { r as isSqliteSnapshotCapacityError } from "./sqlite-snapshot-capacity-error-DlgtEr8c.mjs"; import { i as SqliteReadOnlyInspectionContentionError } from "./sqlite-readonly-worker-session-CnCHtSE5.mjs"; //#region src/state/openclaw-database-preflight.messages.ts /** Fatal refusal when persisted schemas were written by a newer build. */ var OpenClawDatabaseSchemaPreflightError = class extends SqliteSchemaVersionError { constructor(e, t = {}) { const n = t.operation ?? "gateway-startup"; super(formatIncompatibleDatabaseSchemas(e, n)); this.incompatibleDatabases = e; this.name = "OpenClawDatabaseSchemaPreflightError"; } }; function formatIncompatibleDatabase(e) { const t = e.agentId ? ` for agent ${e.agentId}` : ""; const n = isNewerSqliteWriterVersion(e.writerAppVersion) ? `It was written by OpenClaw ${e.writerAppVersion}; it is newer than this Gateway (${VERSION}).` : `writer build ${e.writerAppVersion ?? "unknown"}.`; return `${e.kind} database${t} ${e.path} uses schema ${e.foundVersion}; this build supports ${e.supportedVersion}; ${n}`; } function formatIncompatibleDatabaseSchemas(e, t) { return `${t === "doctor" ? "Doctor refused to continue" : t === "gateway-restart" ? "Gateway refused restart" : "Gateway refused startup"} because ${e.length} OpenClaw database schema(s) are newer than this build. ${e.map(formatIncompatibleDatabase).join(" ")} Refused by ${describeRunningOpenClawBuild()}. ` + (e.some((e) => isNewerSqliteWriterVersion(e.writerAppVersion)) ? "Use the newer install that supports these schemas, or run openclaw update to update this Gateway service before restarting. To use an older build, stop the service and restore your pre-upgrade backup created with openclaw backup create. " : "Run a build at least as new as the writer that supports these schemas, or stop the service and restore your pre-upgrade backup created with openclaw backup create. ") + `See ${OPENCLAW_DATABASE_SCHEMA_DOCS_URL}.`; } function formatIndeterminateDatabaseReadiness(e, t, n) { const r = e.toSorted((e, t) => e.path.localeCompare(t.path)).map((e) => { const r = t !== "doctor" ? "" : n.get(e) instanceof SqliteReadOnlyInspectionContentionError ? " Wait a moment for write activity to settle, then retry the inspection." : isSqliteSnapshotCapacityError(n.get(e)) ? " Free snapshot disk space or quota, then retry the inspection." : " Stop OpenClaw processes, then restore the affected database from a verified backup."; return `${e.kind}${e.agentId ? ` ${e.agentId}` : ""} ${e.path}: ${e.reason}${r}`; }); return `${t === "doctor" ? "Doctor could not complete repair" : t === "gateway-startup" ? "Gateway refused startup" : "Gateway refused restart"} because persisted database readiness could not be verified:\n${r.join("\n")}${t === "doctor" ? "" : "\nStop the Gateway and other OpenClaw processes, run openclaw doctor --fix, then retry."}`; } function describeDeferredStateSchemaPublication(e, t, n, r) { return { kind: "state", path: t, foundVersion: n, contentVersion: r, ...e ? { runId: e.runId, publishAfterMs: e.publishAfterMs } : {}, message: e ? `Schema content applied; version publication deferred until update run ${e.runId} finishes and its five-minute grace expires (or the running driver is abandoned for 30 minutes).` : "Schema content applied; version publication will complete on the next writable database open." }; } //#endregion export { describeDeferredStateSchemaPublication as n, formatIndeterminateDatabaseReadiness as r, OpenClawDatabaseSchemaPreflightError as t };