refactor: centralize delivery/path/media/version lifecycle

This commit is contained in:
Peter Steinberger
2026-03-02 04:04:02 +00:00
parent f4f094fc3b
commit c0bf42f2a8
19 changed files with 616 additions and 152 deletions

View File

@@ -71,6 +71,21 @@ export function resolveVersionFromModuleUrl(moduleUrl: string): string | null {
);
}
export function resolveBinaryVersion(params: {
moduleUrl: string;
injectedVersion?: string;
bundledVersion?: string;
fallback?: string;
}): string {
return (
firstNonEmpty(params.injectedVersion) ||
resolveVersionFromModuleUrl(params.moduleUrl) ||
firstNonEmpty(params.bundledVersion) ||
params.fallback ||
"0.0.0"
);
}
export type RuntimeVersionEnv = {
[key: string]: string | undefined;
};
@@ -91,8 +106,8 @@ export function resolveRuntimeServiceVersion(
// Single source of truth for the current OpenClaw version.
// - Embedded/bundled builds: injected define or env var.
// - Dev/npm builds: package.json.
export const VERSION =
(typeof __OPENCLAW_VERSION__ === "string" && __OPENCLAW_VERSION__) ||
process.env.OPENCLAW_BUNDLED_VERSION ||
resolveVersionFromModuleUrl(import.meta.url) ||
"0.0.0";
export const VERSION = resolveBinaryVersion({
moduleUrl: import.meta.url,
injectedVersion: typeof __OPENCLAW_VERSION__ === "string" ? __OPENCLAW_VERSION__ : undefined,
bundledVersion: process.env.OPENCLAW_BUNDLED_VERSION,
});