Skip to content

Commit a917c99

Browse files
steipeteampagent
andauthored
fix(runtime): classify Node releases consistently across install and launch (#124812)
* fix(runtime): align Node release version guards Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * test(runtime): include Node version helper in source fixture * fix(install): align Node release checks across boundaries Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix: keep node version guard legacy-compatible Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * test(runtime): exercise legacy launcher preflight * fix(installer): validate installed Node release versions Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix(installer): compare Node version parts numerically Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * test(installer): cover 17-digit Node major --------- Co-authored-by: Amp <[email protected]>
1 parent 9a947e4 commit a917c99

29 files changed

Lines changed: 376 additions & 188 deletions

‎.github/actions/setup-node-env/dependency-fingerprint.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const INSTALL_INPUT_FILES = [
3939
".pnpmfile.cjs",
4040
"pnpmfile.cjs",
4141
".github/actions/setup-node-env/dependency-fingerprint.mjs",
42+
"node-version.mjs",
4243
"scripts/postinstall-bundled-plugins.mjs",
4344
"scripts/lib/package-dist-imports.mjs",
4445
"scripts/preinstall-package-manager-warning.mjs",

‎Dockerfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ RUN corepack enable
7272
WORKDIR /app
7373

7474
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
75+
COPY node-version.mjs ./
7576
COPY openclaw.mjs ./
7677
COPY ui/package.json ./ui/package.json
7778
COPY patches ./patches
@@ -249,6 +250,7 @@ COPY --from=runtime-assets --chown=node:node /app/node_modules ./node_modules
249250
COPY --from=runtime-assets --chown=node:node /app/package.json .
250251
COPY --from=runtime-assets --chown=node:node /app/pnpm-workspace.yaml .
251252
COPY --from=runtime-assets --chown=node:node /app/patches ./patches
253+
COPY --from=runtime-assets --chown=node:node /app/node-version.mjs .
252254
COPY --from=runtime-assets --chown=node:node /app/openclaw.mjs .
253255
COPY --from=runtime-assets --chown=node:node /app/src/agents/templates ./src/agents/templates
254256
COPY --from=runtime-assets --chown=node:node /app/${OPENCLAW_BUNDLED_PLUGIN_DIR} ./${OPENCLAW_BUNDLED_PLUGIN_DIR}

‎docs/install/installer.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OpenClaw ships three installer scripts, served from `openclaw.ai`.
1515
| [`install-cli.sh`](#install-clish) | macOS / Linux / WSL | Installs Node + OpenClaw into a local prefix (`~/.openclaw`) via npm or git. No root required. |
1616
| [`install.ps1`](#installps1) | Windows (PowerShell) | Installs Node if needed, installs OpenClaw via npm (default) or git, can run onboarding. |
1717

18-
All three support Node **22.22.3+, 24.15+, or 25.9+**. On macOS and Linux, fresh installs provision Node 26; on Windows, winget/Chocolatey/Scoop install the supported Node LTS line, and the portable fallback downloads Node 26.
18+
All three support Node **22.22.3+, 24.15+, or 25.9+**. On macOS and Linux, `install.sh` provisions Node 26 when needed, while the rootless `install-cli.sh` downloads Node 24.15.0 (Node 22.22.3 on ARMv7). On Windows, winget/Chocolatey/Scoop install the supported Node LTS line, and the portable fallback downloads Node 26.
1919

2020
## Quick commands
2121

‎node-version.d.mts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type NodeReleaseVersion = {
2+
major: number;
3+
minor: number;
4+
patch: number;
5+
};
6+
7+
export function parseNodeReleaseVersion(value: unknown): NodeReleaseVersion | null;
8+
export function isNodeVersionAtLeast(
9+
version: NodeReleaseVersion | null,
10+
minimum: NodeReleaseVersion,
11+
): boolean;
12+
export function isSupportedOpenClawNodeVersion(value: unknown): boolean;
13+
export const OPENCLAW_PROCESS_NODE_VERSION_CHECK: string;

‎node-version.mjs‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Zero-dependency Node release-version contract shared by source and packaged entry points.
2+
const NODE_RELEASE_VERSION_RE =
3+
/^v?((?:0|[1-9]\d*))\.((?:0|[1-9]\d*))\.((?:0|[1-9]\d*))(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
4+
5+
const NODE_RELEASE_FLOORS = [
6+
{ major: 22, minor: 22, patch: 3 },
7+
{ major: 24, minor: 15, patch: 0 },
8+
{ major: 25, minor: 9, patch: 0 },
9+
];
10+
const HIGHEST_RELEASE_FLOOR = NODE_RELEASE_FLOORS[NODE_RELEASE_FLOORS.length - 1];
11+
12+
/** Parses an anchored release SemVer, allowing a leading v and valid build metadata. */
13+
export function parseNodeReleaseVersion(value) {
14+
if (typeof value !== "string") {
15+
return null;
16+
}
17+
const match = NODE_RELEASE_VERSION_RE.exec(value.trim());
18+
if (!match) {
19+
return null;
20+
}
21+
const version = {
22+
major: Number(match[1]),
23+
minor: Number(match[2]),
24+
patch: Number(match[3]),
25+
};
26+
return Object.values(version).every(Number.isSafeInteger) ? version : null;
27+
}
28+
29+
export function isNodeVersionAtLeast(version, minimum) {
30+
if (!version) {
31+
return false;
32+
}
33+
if (version.major !== minimum.major) {
34+
return version.major > minimum.major;
35+
}
36+
if (version.minor !== minimum.minor) {
37+
return version.minor > minimum.minor;
38+
}
39+
return version.patch >= minimum.patch;
40+
}
41+
42+
/** Checks OpenClaw's supported release lines. Node 23 remains unsupported. */
43+
export function isSupportedOpenClawNodeVersion(value) {
44+
const version = parseNodeReleaseVersion(value);
45+
if (!version) {
46+
return false;
47+
}
48+
const minimum = NODE_RELEASE_FLOORS.find((floor) => floor.major === version.major);
49+
return minimum
50+
? isNodeVersionAtLeast(version, minimum)
51+
: version.major > HIGHEST_RELEASE_FLOOR.major;
52+
}
53+
54+
function renderProcessNodeVersionCheck() {
55+
const patternSource = JSON.stringify(NODE_RELEASE_VERSION_RE.source);
56+
const releaseFloors = JSON.stringify(NODE_RELEASE_FLOORS);
57+
return `((value) => {
58+
if (typeof value !== "string") return false;
59+
const match = new RegExp(${patternSource}, "u").exec(value.trim());
60+
if (!match) return false;
61+
const version = { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) };
62+
if (!Object.values(version).every(Number.isSafeInteger)) return false;
63+
const floors = ${releaseFloors};
64+
const minimum = floors.find((floor) => floor.major === version.major);
65+
const atLeast = (floor) =>
66+
version.major > floor.major ||
67+
(version.major === floor.major &&
68+
(version.minor > floor.minor ||
69+
(version.minor === floor.minor && version.patch >= floor.patch)));
70+
return minimum ? atLeast(minimum) : version.major > floors[floors.length - 1].major;
71+
})(process.versions.node)`;
72+
}
73+
74+
// Worker bootstrap runs before OpenClaw is transferred. Carry the canonical
75+
// release policy as a self-contained expression instead of a second parser.
76+
export const OPENCLAW_PROCESS_NODE_VERSION_CHECK = renderProcessNodeVersionCheck();

‎openclaw.mjs‎

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,12 @@ import module from "node:module";
77
import os from "node:os";
88
import path from "node:path";
99
import { fileURLToPath } from "node:url";
10+
import { isSupportedOpenClawNodeVersion } from "./node-version.mjs";
1011

11-
const MIN_NODE_22 = { major: 22, minor: 22, patch: 3 };
12-
const MIN_NODE_24 = { major: 24, minor: 15, patch: 0 };
13-
const MIN_NODE_25 = { major: 25, minor: 9, patch: 0 };
1412
const RECOMMENDED_NODE_MAJOR = 26;
1513
const SUPPORTED_NODE_RANGE = ">=22.22.3 <23, >=24.15.0 <25, or >=25.9.0";
1614
const COMPILE_CACHE_DISABLED_RESPAWNED_ENV = "OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED";
1715

18-
const parseNodeVersion = (rawVersion) => {
19-
const [majorRaw = "0", minorRaw = "0", patchRaw = "0"] = rawVersion.split(".");
20-
return {
21-
major: Number(majorRaw),
22-
minor: Number(minorRaw),
23-
patch: Number(patchRaw),
24-
};
25-
};
26-
27-
const isAtLeastNodeVersion = (version, minimum) => {
28-
if (version.major !== minimum.major) {
29-
return version.major > minimum.major;
30-
}
31-
if (version.minor !== minimum.minor) {
32-
return version.minor > minimum.minor;
33-
}
34-
return version.patch >= minimum.patch;
35-
};
36-
37-
const isSupportedNodeVersion = (version) => {
38-
if (version.major === MIN_NODE_22.major) {
39-
return isAtLeastNodeVersion(version, MIN_NODE_22);
40-
}
41-
if (version.major === MIN_NODE_24.major) {
42-
return isAtLeastNodeVersion(version, MIN_NODE_24);
43-
}
44-
if (version.major === MIN_NODE_25.major) {
45-
return isAtLeastNodeVersion(version, MIN_NODE_25);
46-
}
47-
return version.major > MIN_NODE_25.major;
48-
};
49-
5016
const ensureSupportedRuntimeVersion = () => {
5117
if (process.versions.bun) {
5218
// Bun >=1.4 (Rust rewrite) ships node:sqlite; feature-probe instead of
@@ -66,7 +32,7 @@ const ensureSupportedRuntimeVersion = () => {
6632
);
6733
process.exit(1);
6834
}
69-
if (isSupportedNodeVersion(parseNodeVersion(process.versions.node))) {
35+
if (isSupportedOpenClawNodeVersion(process.versions.node)) {
7036
return;
7137
}
7238

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"files": [
3030
"CHANGELOG.md",
3131
"LICENSE",
32+
"node-version.mjs",
3233
"openclaw.mjs",
3334
"pnpm-workspace.yaml",
3435
"README.md",

‎scripts/check-duplicates.mts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const targets = [
2121
"test",
2222
"skills",
2323
"config",
24+
"node-version.mjs",
2425
"openclaw.mjs",
2526
"tsdown.ai.config.ts",
2627
"tsdown.config.ts",

‎scripts/docker/cleanup-smoke/Dockerfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN --mount=type=cache,id=openclaw-cleanup-smoke-apt-cache,target=/var/cache/apt
1515
WORKDIR /repo
1616
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
1717
COPY openclaw.mjs ./
18+
COPY node-version.mjs ./
1819
COPY ui/package.json ./ui/package.json
1920
COPY packages ./packages
2021
COPY extensions ./extensions

‎scripts/install-cli.sh‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ MIN_NODE_22_VERSION="22.22.3"
7676
MIN_NODE_24_VERSION="24.15.0"
7777
MIN_NODE_25_VERSION="25.9.0"
7878
SUPPORTED_NODE_VERSION_LABEL="Node 22.22.3+, Node 24.15.0+, or Node 25.9.0+"
79+
NODE_RELEASE_VERSION_CORE=""
7980
APK_NODE_BIN_DIR="/usr/bin"
8081
NPM_LOGLEVEL="${OPENCLAW_NPM_LOGLEVEL:-error}"
8182
INSTALL_METHOD="${OPENCLAW_INSTALL_METHOD:-npm}"
@@ -508,10 +509,10 @@ linked_node_is_usable() {
508509

509510
current_version="$("$(node_bin)" -v 2>/dev/null || echo "")"
510511
required_version="$(required_node_version)"
511-
if ! node_version_is_supported "$current_version"; then
512+
if ! node_release_version_is_supported "$current_version"; then
512513
return 1
513514
fi
514-
if ! semver_at_least "$current_version" "$required_version"; then
515+
if ! semver_at_least "$NODE_RELEASE_VERSION_CORE" "$required_version"; then
515516
return 1
516517
fi
517518
candidate_bin="$(node_dir)/bin"
@@ -590,6 +591,32 @@ semver_at_least() {
590591
((version_patch >= required_patch))
591592
}
592593

594+
node_release_version_is_supported() {
595+
local version="$1"
596+
local major minor patch
597+
598+
NODE_RELEASE_VERSION_CORE=""
599+
while [[ "$version" == [[:space:]]* ]]; do version="${version#?}"; done
600+
while [[ "$version" == *[[:space:]] ]]; do version="${version%?}"; done
601+
if [[ ! "$version" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
602+
return 1
603+
fi
604+
major="${BASH_REMATCH[1]}"
605+
minor="${BASH_REMATCH[2]}"
606+
patch="${BASH_REMATCH[3]}"
607+
for part in "$major" "$minor" "$patch"; do
608+
if ((${#part} > 16)) || ((${#part} == 16 && 10#$part > 9007199254740991)); then
609+
return 1
610+
fi
611+
done
612+
613+
NODE_RELEASE_VERSION_CORE="${major}.${minor}.${patch}"
614+
node_version_is_supported "$NODE_RELEASE_VERSION_CORE"
615+
}
616+
617+
# Download labels are plain numeric Node distribution versions. Installed
618+
# runtimes use node_release_version_is_supported, which accepts canonical
619+
# release labels with a leading v or build metadata.
593620
node_version_is_supported() {
594621
local version="${1#v}"
595622
local major minor patch

0 commit comments

Comments
 (0)