openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
35 lines (34 loc) • 2.09 kB
JavaScript
import { n as resolveOpenClawPackageRootSync } from "./openclaw-root-CfYY-fyD.js";
import { a as OPENCLAW_DATABASE_SCHEMA_DOCS_URL } from "./openclaw-state-db-contract-DYCYxE4w.js";
import { c as resolveRuntimeServiceCommit, t as VERSION } from "./version-v1kuAkGj.js";
//#region src/infra/sqlite-user-version.ts
const SQLITE_SCHEMA_VERSION_ERROR_NAME = "SqliteSchemaVersionError";
var SqliteSchemaVersionError = class extends Error {
constructor(..._args) {
super(..._args);
this.name = SQLITE_SCHEMA_VERSION_ERROR_NAME;
}
};
function isSqliteSchemaVersionError(error) {
return error instanceof SqliteSchemaVersionError || error instanceof Error && error.name === SQLITE_SCHEMA_VERSION_ERROR_NAME;
}
function readSqliteUserVersion(db) {
const row = db.prepare("PRAGMA user_version").get();
return Number(row?.user_version ?? 0);
}
/**
* Name the refusing build from immutable loaded metadata, plus its install root.
* The path remains actionable when multiple installs share a version or build.
*/
function describeRunningOpenClawBuild() {
const commit = resolveRuntimeServiceCommit();
const root = resolveOpenClawPackageRootSync({ moduleUrl: import.meta.url });
const identity = commit ? `OpenClaw ${VERSION} (${commit})` : `OpenClaw ${VERSION}`;
return root ? `${identity} installed at ${root}` : identity;
}
function createNewerSqliteSchemaVersionError(databaseLabel, pathname, schemaVersion, supportedVersion) {
return new SqliteSchemaVersionError(`This OpenClaw build cannot open your existing data.
${databaseLabel} ${pathname} uses newer schema version ${schemaVersion}; this build supports ${supportedVersion}.\nRefused by ${describeRunningOpenClawBuild()}.\nUse a build that supports schema ${schemaVersion} or newer with this state directory. To start fresh with this build, point OPENCLAW_STATE_DIR at a separate directory.\nSee ${OPENCLAW_DATABASE_SCHEMA_DOCS_URL}.`);
}
//#endregion
export { readSqliteUserVersion as a, isSqliteSchemaVersionError as i, createNewerSqliteSchemaVersionError as n, describeRunningOpenClawBuild as r, SqliteSchemaVersionError as t };