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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
J
Java Code Geeks
C
Check Point Blog
Last Week in AI
Last Week in AI
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
IT之家
IT之家
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
U
Unit 42
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ

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(browser): centralize snapshot numeric parsing · openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import { describe, expect, it } from "vitest";

22

import type { ResolvedBrowserProfile } from "../config.js";

3+

import { DEFAULT_AI_SNAPSHOT_MAX_CHARS } from "../constants.js";

34

import { resolveSnapshotPlan } from "./agent.snapshot.plan.js";

45
56

function profile(driver: "existing-session" | "openclaw"): ResolvedBrowserProfile {

@@ -68,6 +69,70 @@ describe("resolveSnapshotPlan", () => {

6869

expect(plan.timeoutMs).toBe(2_147_483_647);

6970

});

7071
72+

it("parses snapshot numeric query options as strict integers", () => {

73+

const plan = resolveSnapshotPlan({

74+

profile: profile("openclaw"),

75+

query: {

76+

limit: "25",

77+

maxChars: "5000",

78+

depth: "2",

79+

timeoutMs: "12345",

80+

},

81+

hasPlaywright: true,

82+

});

83+
84+

expect(plan.limit).toBe(25);

85+

expect(plan.resolvedMaxChars).toBe(5000);

86+

expect(plan.depth).toBe(2);

87+

expect(plan.timeoutMs).toBe(12345);

88+

});

89+
90+

it("accepts structured numeric snapshot query options from proxy dispatch", () => {

91+

const plan = resolveSnapshotPlan({

92+

profile: profile("openclaw"),

93+

query: {

94+

limit: 25,

95+

maxChars: 5000,

96+

depth: 2,

97+

timeoutMs: 12345,

98+

},

99+

hasPlaywright: true,

100+

});

101+
102+

expect(plan.limit).toBe(25);

103+

expect(plan.resolvedMaxChars).toBe(5000);

104+

expect(plan.depth).toBe(2);

105+

expect(plan.timeoutMs).toBe(12345);

106+

});

107+
108+

it("rejects loose snapshot numeric query tokens", () => {

109+

const plan = resolveSnapshotPlan({

110+

profile: profile("openclaw"),

111+

query: {

112+

limit: "0x10",

113+

maxChars: "1.5",

114+

depth: "1e0",

115+

timeoutMs: "1000ms",

116+

},

117+

hasPlaywright: true,

118+

});

119+
120+

expect(plan.limit).toBeUndefined();

121+

expect(plan.resolvedMaxChars).toBe(DEFAULT_AI_SNAPSHOT_MAX_CHARS);

122+

expect(plan.depth).toBeUndefined();

123+

expect(plan.timeoutMs).toBeUndefined();

124+

});

125+
126+

it("keeps maxChars zero as an explicit uncapped snapshot request", () => {

127+

const plan = resolveSnapshotPlan({

128+

profile: profile("openclaw"),

129+

query: { maxChars: "0" },

130+

hasPlaywright: true,

131+

});

132+
133+

expect(plan.resolvedMaxChars).toBeUndefined();

134+

});

135+
71136

it("ignores non-positive timeoutMs values", () => {

72137

expect(

73138

resolveSnapshotPlan({

Original file line numberDiff line numberDiff line change

@@ -1,7 +1,8 @@

11

import {

2-

normalizeOptionalString,

3-

readStringValue,

4-

} from "openclaw/plugin-sdk/string-coerce-runtime";

2+

parseStrictNonNegativeInteger,

3+

parseStrictPositiveInteger,

4+

} from "openclaw/plugin-sdk/number-runtime";

5+

import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";

56

import type { ResolvedBrowserProfile } from "../config.js";

67

import {

78

DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH,

@@ -14,7 +15,7 @@ import {

1415

shouldUsePlaywrightForScreenshot,

1516

} from "../profile-capabilities.js";

1617

import { normalizeBrowserTimerDelayMs } from "../timer-delay.js";

17-

import { toBoolean, toNumber, toStringOrEmpty } from "./utils.js";

18+

import { toBoolean, toStringOrEmpty } from "./utils.js";

1819
1920

type BrowserSnapshotPlan = {

2021

format: "ai" | "aria";

@@ -49,25 +50,25 @@ export function resolveSnapshotPlan(params: {

4950

explicitFormat,

5051

mode,

5152

});

52-

const limitRaw = readStringValue(params.query.limit);

53+

const limit = parseStrictPositiveInteger(params.query.limit);

5354

const hasMaxChars = Object.hasOwn(params.query, "maxChars");

54-

const maxCharsRaw = readStringValue(params.query.maxChars);

55-

const limit = Number.isFinite(Number(limitRaw)) ? Number(limitRaw) : undefined;

56-

const maxChars =

57-

Number.isFinite(Number(maxCharsRaw)) && Number(maxCharsRaw) > 0

58-

? Math.floor(Number(maxCharsRaw))

59-

: undefined;

55+

const maxCharsRaw = parseStrictNonNegativeInteger(params.query.maxChars);

56+

const maxChars = maxCharsRaw !== undefined && maxCharsRaw > 0 ? maxCharsRaw : undefined;

6057

const resolvedMaxChars =

6158

format === "ai"

6259

? hasMaxChars

63-

? maxChars

60+

? maxCharsRaw === undefined

61+

? mode === "efficient"

62+

? DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS

63+

: DEFAULT_AI_SNAPSHOT_MAX_CHARS

64+

: maxChars

6465

: mode === "efficient"

6566

? DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS

6667

: DEFAULT_AI_SNAPSHOT_MAX_CHARS

6768

: undefined;

6869

const interactiveRaw = toBoolean(params.query.interactive);

6970

const compactRaw = toBoolean(params.query.compact);

70-

const depthRaw = toNumber(params.query.depth);

71+

const depthRaw = parseStrictNonNegativeInteger(params.query.depth);

7172

const refsModeRaw = toStringOrEmpty(params.query.refs).trim();

7273

const refsMode: "aria" | "role" | undefined =

7374

refsModeRaw === "aria" ? "aria" : refsModeRaw === "role" ? "role" : undefined;

@@ -77,11 +78,9 @@ export function resolveSnapshotPlan(params: {

7778

depthRaw ?? (mode === "efficient" ? DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH : undefined);

7879

const selectorValue = normalizeOptionalString(toStringOrEmpty(params.query.selector));

7980

const frameSelectorValue = normalizeOptionalString(toStringOrEmpty(params.query.frame));

80-

const timeoutMsRaw = toNumber(params.query.timeoutMs);

81+

const timeoutMsRaw = parseStrictPositiveInteger(params.query.timeoutMs);

8182

const timeoutMs =

82-

timeoutMsRaw !== undefined && Number.isFinite(timeoutMsRaw) && timeoutMsRaw > 0

83-

? normalizeBrowserTimerDelayMs(timeoutMsRaw)

84-

: undefined;

83+

timeoutMsRaw !== undefined ? normalizeBrowserTimerDelayMs(timeoutMsRaw) : undefined;

8584
8685

return {

8786

format,