mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 10:42:43 +00:00
Gateway: fix stale self version in status output (#32655)
Merged via squash.
Prepared head SHA: b9675d1f90
Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -90,13 +90,28 @@ export type RuntimeVersionEnv = {
|
||||
[key: string]: string | undefined;
|
||||
};
|
||||
|
||||
export const RUNTIME_SERVICE_VERSION_FALLBACK = "unknown";
|
||||
|
||||
export function resolveUsableRuntimeVersion(version: string | undefined): string | undefined {
|
||||
const trimmed = version?.trim();
|
||||
// "0.0.0" is the resolver's hard fallback when module metadata cannot be read.
|
||||
// Prefer explicit service/package markers in that edge case.
|
||||
if (!trimmed || trimmed === "0.0.0") {
|
||||
return undefined;
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function resolveRuntimeServiceVersion(
|
||||
env: RuntimeVersionEnv = process.env as RuntimeVersionEnv,
|
||||
fallback = "dev",
|
||||
fallback = RUNTIME_SERVICE_VERSION_FALLBACK,
|
||||
): string {
|
||||
const runtimeVersion = resolveUsableRuntimeVersion(VERSION);
|
||||
|
||||
return (
|
||||
firstNonEmpty(
|
||||
env["OPENCLAW_VERSION"],
|
||||
runtimeVersion,
|
||||
env["OPENCLAW_SERVICE_VERSION"],
|
||||
env["npm_package_version"],
|
||||
) ?? fallback
|
||||
|
||||
Reference in New Issue
Block a user