惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
小众软件
小众软件
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
J
Java Code Geeks
WordPress大学
WordPress大学
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(numbers): share non-negative finite guard · open...
vincentkoc · 2026-06-23 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -11,6 +11,7 @@ import { patchSessionEntry } from "../../config/sessions/session-accessor.js";

1111

import { resolveMaintenanceConfigFromInput } from "../../config/sessions/store-maintenance.js";

1212

import type { OpenClawConfig } from "../../config/types.openclaw.js";

1313

import { createLazyImportLoader } from "../../shared/lazy-promise.js";

14+

import { resolveNonNegativeNumber } from "../../shared/number-coercion.js";

1415

import { clearCliSession, setCliSessionBinding, setCliSessionId } from "../cli-session.js";

1516

import { DEFAULT_CONTEXT_TOKENS } from "../defaults.js";

1617

import { isCliProvider } from "../model-selection.js";

@@ -29,10 +30,6 @@ async function getContextModule() {

2930

return await contextModuleLoader.load();

3031

}

3132
32-

function resolveNonNegativeNumber(value: number | undefined): number | undefined {

33-

return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;

34-

}

35-
3633

function resolvePositiveInteger(value: number | undefined): number | undefined {

3734

if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {

3835

return undefined;

Original file line numberDiff line numberDiff line change

@@ -18,6 +18,7 @@ import {

1818

import { updateSessionEntry } from "../../config/sessions/session-accessor.js";

1919

import type { OpenClawConfig } from "../../config/types.openclaw.js";

2020

import { logVerbose } from "../../globals.js";

21+

import { resolveNonNegativeNumber } from "../../shared/number-coercion.js";

2122

import { estimateUsageCost, resolveModelCostConfig } from "../../utils/usage-format.js";

2223
2324

function applyCliSessionIdToSessionPatch(

@@ -67,10 +68,6 @@ function applyCliSessionIdToSessionPatch(

6768

return patch;

6869

}

6970
70-

function resolveNonNegativeNumber(value: number | undefined): number | undefined {

71-

return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;

72-

}

73-
7471

function resolveNonNegativeTokenCount(value: number | undefined): number | undefined {

7572

const resolved = resolveNonNegativeNumber(value);

7673

return resolved === undefined ? undefined : Math.floor(resolved);

Original file line numberDiff line numberDiff line change

@@ -39,6 +39,7 @@ import { createDiagnosticMessageLifecycle } from "../../logging/message-lifecycl

3939

import { isCommandLaneTaskTimeoutError } from "../../process/command-queue.js";

4040

import { CommandLane } from "../../process/lanes.js";

4141

import { createLazyImportLoader } from "../../shared/lazy-promise.js";

42+

import { resolveNonNegativeNumber } from "../../shared/number-coercion.js";

4243

import { resolveCronSkillsSnapshot } from "../../skills/runtime/cron-snapshot.js";

4344

import type { SkillSnapshot } from "../../skills/types.js";

4445

import {

@@ -175,10 +176,6 @@ function hasConfiguredAuthProfiles(cfg: OpenClawConfig): boolean {

175176

);

176177

}

177178
178-

function resolveNonNegativeNumber(value: number | undefined): number | undefined {

179-

return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;

180-

}

181-
182179

function isCronNestedLaneTaskTimeoutError(err: unknown): boolean {

183180

return isCommandLaneTaskTimeoutError(err, CommandLane.CronNested);

184181

}

Original file line numberDiff line numberDiff line change

@@ -91,6 +91,7 @@ import {

9191

isWorkspaceRelativeAvatarPath,

9292

resolveAvatarMime,

9393

} from "../shared/avatar-policy.js";

94+

import { resolveNonNegativeNumber } from "../shared/number-coercion.js";

9495

import { normalizeSessionDeliveryFields } from "../utils/delivery-context.shared.js";

9596

import type { ModelCostConfig } from "../utils/usage-format.js";

9697

import { estimateUsageCost, resolveModelCostConfig } from "../utils/usage-format.js";

@@ -274,10 +275,6 @@ function resolvePositiveNumber(value: number | null | undefined): number | undef

274275

return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;

275276

}

276277
277-

function resolveNonNegativeNumber(value: number | null | undefined): number | undefined {

278-

return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;

279-

}

280-
281278

type SessionCompactionCheckpointEntry = NonNullable<SessionEntry["compactionCheckpoints"]>[number];

282279
283280

function isProjectableCompactionCheckpoint(

Original file line numberDiff line numberDiff line change

@@ -1,2 +1,6 @@

11

/** Shared numeric coercion facade for legacy imports inside core. */

22

export * from "@openclaw/normalization-core/number-coercion";

3+
4+

export function resolveNonNegativeNumber(value: number | null | undefined): number | undefined {

5+

return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;

6+

}