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:
Liu Xiaopai
2026-03-03 15:41:52 +08:00
committed by GitHub
parent b1b41eb443
commit ae29842158
7 changed files with 48 additions and 17 deletions

View File

@@ -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