diff --git a/src/version.ts b/src/version.ts index e254dd91fe..e6062633ca 100644 --- a/src/version.ts +++ b/src/version.ts @@ -12,6 +12,16 @@ function readVersionFromPackageJson(): string | null { } } +function readVersionFromBuildInfo(): string | null { + try { + const require = createRequire(import.meta.url); + const info = require("../build-info.json") as { version?: string }; + return info.version ?? null; + } catch { + return null; + } +} + // Single source of truth for the current OpenClaw version. // - Embedded/bundled builds: injected define or env var. // - Dev/npm builds: package.json. @@ -19,4 +29,5 @@ export const VERSION = (typeof __OPENCLAW_VERSION__ === "string" && __OPENCLAW_VERSION__) || process.env.OPENCLAW_BUNDLED_VERSION || readVersionFromPackageJson() || + readVersionFromBuildInfo() || "0.0.0";