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

推荐订阅源

Last Week in AI
Last Week in AI
U
Unit 42
博客园 - 【当耐特】
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
美团技术团队
雷峰网
雷峰网
小众软件
小众软件
G
Google Developers Blog
GbyAI
GbyAI
Jina AI
Jina AI
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Fortinet All Blogs
Vercel News
Vercel News

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
fix: parse ps cpu time formats · openclaw/openclaw@0311171
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -10,13 +10,19 @@ import {

1010

describe("process tree CPU helpers", () => {

1111

it("parses ps CPU time strings", () => {

1212

expect(parsePsCpuTimeMs("00:01")).toBe(1_000);

13+

expect(parsePsCpuTimeMs("00:00.12")).toBe(120);

1314

expect(parsePsCpuTimeMs("01:02")).toBe(62_000);

14-

expect(parsePsCpuTimeMs("01:02:03")).toBe(3_723_000);

15+

expect(parsePsCpuTimeMs("01:02:03.45")).toBe(3_723_450);

16+

expect(parsePsCpuTimeMs("1-02:03:04.5")).toBe(93_784_500);

1517

});

1618
1719

it("rejects malformed ps CPU time strings", () => {

1820

expect(parsePsCpuTimeMs("")).toBeNull();

1921

expect(parsePsCpuTimeMs("nope")).toBeNull();

22+

expect(parsePsCpuTimeMs("1::02")).toBeNull();

23+

expect(parsePsCpuTimeMs("1-02:03")).toBeNull();

24+

expect(parsePsCpuTimeMs("01:60")).toBeNull();

25+

expect(parsePsCpuTimeMs("01:02:60")).toBeNull();

2026

expect(parsePsCpuTimeMs("1:2:3:4")).toBeNull();

2127

});

2228
Original file line numberDiff line numberDiff line change

@@ -41,17 +41,35 @@ function parseNonNegativeNumber(value: unknown): number | null {

4141

}

4242
4343

export function parsePsCpuTimeMs(raw: string): number | null {

44-

const parts = raw.trim().split(":").map(Number);

45-

if (parts.some((part) => !Number.isFinite(part) || part < 0)) {

44+

const match = raw.trim().match(/^(?:(\d+)-)?(\d+):(\d{2}(?:\.\d+)?)(?::(\d{2}(?:\.\d+)?))?$/u);

45+

if (!match) {

4646

return null;

4747

}

48-

if (parts.length === 2) {

49-

return Math.round((parts[0] * 60 + parts[1]) * 1000);

48+

const [, daysRaw, firstRaw, secondRaw, thirdRaw] = match;

49+

if (daysRaw !== undefined && thirdRaw === undefined) {

50+

return null;

51+

}

52+

const days = daysRaw === undefined ? 0 : Number(daysRaw);

53+

const first = Number(firstRaw);

54+

const second = Number(secondRaw);

55+

const third = thirdRaw === undefined ? 0 : Number(thirdRaw);

56+

const values = [days, first, second, third];

57+

if (values.some((part) => !Number.isFinite(part) || part < 0)) {

58+

return null;

59+

}

60+

if (thirdRaw !== undefined && !Number.isInteger(second)) {

61+

return null;

62+

}

63+

if (second >= 60 || (thirdRaw !== undefined && third >= 60)) {

64+

return null;

65+

}

66+

if (daysRaw !== undefined && thirdRaw !== undefined) {

67+

return Math.round((days * 24 * 60 * 60 + first * 60 * 60 + second * 60 + third) * 1000);

5068

}

51-

if (parts.length === 3) {

52-

return Math.round((parts[0] * 60 * 60 + parts[1] * 60 + parts[2]) * 1000);

69+

if (thirdRaw !== undefined) {

70+

return Math.round((first * 60 * 60 + second * 60 + third) * 1000);

5371

}

54-

return null;

72+

return Math.round((first * 60 + second) * 1000);

5573

}

5674
5775

export function parsePsRssBytes(raw: string): number | null {