




















@@ -13,6 +13,7 @@ UPDATE_BASELINE_VERSION="${OPENCLAW_INSTALL_UPDATE_BASELINE:-latest}"
1313UPDATE_BASELINE_TAG_URL="${OPENCLAW_INSTALL_UPDATE_BASELINE_TAG_URL:-}"
1414UPDATE_EXPECT_VERSION="${OPENCLAW_INSTALL_UPDATE_EXPECT_VERSION:-}"
1515UPDATE_TAG_URL="${OPENCLAW_INSTALL_UPDATE_TAG_URL:-}"
16+SELF_UPDATE_WARNING_FIXED_VERSION="${OPENCLAW_INSTALL_SELF_UPDATE_WARNING_FIXED_VERSION:-2026.5.25}"
1617FRESHNESS_VERSION="${OPENCLAW_INSTALL_FRESHNESS_VERSION:-latest}"
1718# npm min-release-age is days; 10000 keeps the control failure independent of normal release cadence.
1819FRESHNESS_MIN_RELEASE_AGE="${OPENCLAW_INSTALL_FRESHNESS_MIN_RELEASE_AGE:-10000}"
@@ -120,6 +121,75 @@ is_self_swapped_package_process_exit() {
120121 [[ "$stderr" == *"/node_modules/openclaw/dist/"* ]]
121122}
122123124+is_version_before() {
125+local candidate="$1"
126+local floor="$2"
127+ node - "$candidate" "$floor" <<'NODE'
128+const [, , candidate, floor] = process.argv;
129+function parse(version) {
130+ const [core, prerelease = ""] = String(version).split("-", 2);
131+ return {
132+ core: core.split(".").map((part) => Number.parseInt(part, 10) || 0),
133+ prerelease: prerelease ? prerelease.split(".") : [],
134+ };
135+}
136+function comparePrerelease(left, right) {
137+ if (left.length === 0 && right.length === 0) {
138+ return 0;
139+ }
140+ if (left.length === 0) {
141+ return 1;
142+ }
143+ if (right.length === 0) {
144+ return -1;
145+ }
146+ for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
147+ const l = left[index];
148+ const r = right[index];
149+ if (l === undefined) {
150+ return -1;
151+ }
152+ if (r === undefined) {
153+ return 1;
154+ }
155+ const ln = Number.parseInt(l, 10);
156+ const rn = Number.parseInt(r, 10);
157+ const lNumeric = String(ln) === l;
158+ const rNumeric = String(rn) === r;
159+ if (lNumeric && rNumeric && ln !== rn) {
160+ return ln < rn ? -1 : 1;
161+ }
162+ if (lNumeric !== rNumeric) {
163+ return lNumeric ? -1 : 1;
164+ }
165+ if (l !== r) {
166+ return l < r ? -1 : 1;
167+ }
168+ }
169+ return 0;
170+}
171+const left = parse(candidate);
172+const right = parse(floor);
173+for (let index = 0; index < Math.max(left.core.length, right.core.length); index += 1) {
174+ const l = left.core[index] ?? 0;
175+ const r = right.core[index] ?? 0;
176+ if (l < r) {
177+ process.exit(0);
178+ }
179+ if (l > r) {
180+ process.exit(1);
181+ }
182+}
183+const prereleaseOrder = comparePrerelease(left.prerelease, right.prerelease);
184+process.exit(prereleaseOrder < 0 ? 0 : 1);
185+NODE
186+}
187+188+allow_legacy_update_warning() {
189+ [[ "${OPENCLAW_INSTALL_ALLOW_LEGACY_UPDATE_WARNING:-0}" == "1" ]] && return 0
190+ is_version_before "$UPDATE_BASELINE_VERSION" "$SELF_UPDATE_WARNING_FIXED_VERSION"
191+}
192+123193npm_install_global() {
124194local label="$1"
125195shift
@@ -268,11 +338,20 @@ run_update_smoke() {
268338local update_status
269339local update_stderr_file
270340local update_stderr
341+local update_env=(
342+ env
343+ npm_config_omit=optional
344+ NPM_CONFIG_OMIT=optional
345+ OPENCLAW_ALLOW_ROOT=1
346+ )
347+if allow_legacy_update_warning; then
348+ update_env+=(OPENCLAW_UPDATE_IN_PROGRESS=1)
349+fi
271350 update_stderr_file="$(mktemp)"
272351set +e
273352 UPDATE_JSON="$(
274353 run_with_heartbeat "openclaw update" \
275- env npm_config_omit=optional NPM_CONFIG_OMIT=optional OPENCLAW_ALLOW_ROOT=1 \
354+ "${update_env[@]}" \
276355 openclaw update --tag "$UPDATE_TAG_URL" --yes --json 2>"$update_stderr_file"
277356 )"
278357 update_status=$?
@@ -283,6 +362,12 @@ run_update_smoke() {
283362if [[ -n "$update_stderr" ]]; then
284363printf "%s\n" "$update_stderr" >&2
285364fi
365+if [[ "$update_stderr" == *"config was written by version"* ]] && allow_legacy_update_warning; then
366+echo "WARN: legacy baseline emitted a self-update version-skew warning; fixed baselines must not" >&2
367+elif [[ "$update_stderr" == *"config was written by version"* ]]; then
368+echo "ERROR: openclaw update emitted a self-update version-skew warning" >&2
369+return 1
370+fi
286371if [[ "$update_status" -ne 0 ]]; then
287372if is_self_swapped_package_process_exit "$update_stderr"; then
288373echo "WARN: legacy updater process exited after self-swap; validating update JSON and installed CLI" >&2
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。