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

推荐订阅源

V
Visual Studio Blog
I
InfoQ
H
Help Net Security
GbyAI
GbyAI
博客园 - 叶小钗
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
Y
Y Combinator Blog
L
LangChain Blog
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
博客园 - Franky
D
Docker
Jina AI
Jina AI
罗磊的独立博客

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: validate tool timeout integers · openclaw/openclaw@6...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

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

22

import {

33

createActionGate,

4+

readPositiveIntegerParam,

45

readNumberParam,

56

readReactionParams,

67

readStringOrNumberParam,

@@ -90,6 +91,18 @@ describe("readNumberParam", () => {

9091

}),

9192

).toBeUndefined();

9293

});

94+
95+

it("throws for invalid present positive integer params", () => {

96+

expect(readPositiveIntegerParam({ timeoutMs: "42" }, "timeoutMs")).toBe(42);

97+

expect(() => readPositiveIntegerParam({ timeoutMs: "42.5" }, "timeoutMs")).toThrow(

98+

"timeoutMs must be a positive integer",

99+

);

100+

expect(() =>

101+

readPositiveIntegerParam({ timeoutMs: 0 }, "timeoutMs", {

102+

message: "timeoutMs must be a positive integer in milliseconds.",

103+

}),

104+

).toThrow("timeoutMs must be a positive integer in milliseconds.");

105+

});

93106

});

94107
95108

describe("snake_case aliases", () => {

Original file line numberDiff line numberDiff line change

@@ -206,6 +206,23 @@ export function readNumberParam(

206206

return integer ? Math.trunc(value) : value;

207207

}

208208
209+

export function readPositiveIntegerParam(

210+

params: Record<string, unknown>,

211+

key: string,

212+

options: {

213+

message?: string;

214+

} = {},

215+

): number | undefined {

216+

const value = readNumberParam(params, key, {

217+

positiveInteger: true,

218+

strict: true,

219+

});

220+

if (value === undefined && readParamRaw(params, key) !== undefined) {

221+

throw new ToolInputError(options.message ?? `${key} must be a positive integer`);

222+

}

223+

return value;

224+

}

225+
209226

export function readStringArrayParam(

210227

params: Record<string, unknown>,

211228

key: string,

Original file line numberDiff line numberDiff line change

@@ -200,7 +200,7 @@ const ImageGenerateToolSchema = Type.Object({

200200

}),

201201

),

202202

timeoutMs: Type.Optional(

203-

Type.Number({

203+

Type.Integer({

204204

description: "Provider timeout ms (300000 tends to be a safe amount).",

205205

minimum: 1,

206206

}),

Original file line numberDiff line numberDiff line change

@@ -2,12 +2,12 @@ import type { AgentModelConfig } from "../../config/types.agents-shared.js";

22

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

33

import type { SsrFPolicy } from "../../infra/net/ssrf.js";

44

import type { Model } from "../../llm/types.js";

5-

import { resolveChannelInboundAttachmentRootsForChannel } from "../../media/channel-inbound-roots.js";

6-

import { normalizeInboundPathRoots } from "../../media/inbound-path-policy.js";

75

import {

86

findCapabilityProviderById,

97

resolveCapabilityModelRefForProviders,

108

} from "../../media-generation/capability-model-ref.js";

9+

import { resolveChannelInboundAttachmentRootsForChannel } from "../../media/channel-inbound-roots.js";

10+

import { normalizeInboundPathRoots } from "../../media/inbound-path-policy.js";

1111

import { getDefaultLocalRoots } from "../../media/local-media-access.js";

1212

import { readSnakeCaseParamRaw } from "../../param-key.js";

1313

import { loadCapabilityManifestSnapshot } from "../../plugins/capability-provider-runtime.js";

@@ -22,7 +22,7 @@ import { normalizeModelRef } from "../model-selection.js";

2222

import { normalizeProviderId } from "../provider-id.js";

2323

import {

2424

ToolInputError,

25-

readNumberParam,

25+

readPositiveIntegerParam,

2626

readStringArrayParam,

2727

readStringParam,

2828

} from "./common.js";

@@ -99,17 +99,9 @@ export function applyMusicGenerationModelConfigDefaults(

9999

}

100100
101101

export function readGenerationTimeoutMs(args: Record<string, unknown>): number | undefined {

102-

const timeoutMs = readNumberParam(args, "timeoutMs", {

103-

integer: true,

104-

strict: true,

102+

return readPositiveIntegerParam(args, "timeoutMs", {

103+

message: "timeoutMs must be a positive integer in milliseconds.",

105104

});

106-

if (timeoutMs === undefined) {

107-

return undefined;

108-

}

109-

if (timeoutMs <= 0) {

110-

throw new ToolInputError("timeoutMs must be a positive integer in milliseconds.");

111-

}

112-

return timeoutMs;

113105

}

114106
115107

export function resolveRemoteMediaSsrfPolicy(

Original file line numberDiff line numberDiff line change

@@ -92,6 +92,22 @@ describe("createTtsTool", () => {

9292

expect(requireRecord(result.details, "TTS result details").timeoutMs).toBe(12_345);

9393

});

9494
95+

it("rejects fractional timeout before calling speech generation", async () => {

96+

textToSpeechSpy.mockResolvedValue({

97+

success: true,

98+

audioPath: "/tmp/reply.opus",

99+

provider: "test",

100+

voiceCompatible: true,

101+

});

102+
103+

const tool = createTtsTool();

104+
105+

await expect(tool.execute("call-1", { text: "hello", timeoutMs: 12_345.5 })).rejects.toThrow(

106+

"timeoutMs must be a positive integer in milliseconds.",

107+

);

108+

expect(textToSpeechSpy).not.toHaveBeenCalled();

109+

});

110+
95111

it("passes the active agent id to speech generation", async () => {

96112

textToSpeechSpy.mockResolvedValue({

97113

success: true,

Original file line numberDiff line numberDiff line change

@@ -4,31 +4,23 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";

44

import { textToSpeech } from "../../tts/tts.js";

55

import type { GatewayMessageChannel } from "../../utils/message-channel.js";

66

import type { AnyAgentTool } from "./common.js";

7-

import { ToolInputError, readNumberParam, readStringParam } from "./common.js";

7+

import { readPositiveIntegerParam, readStringParam } from "./common.js";

88
99

const TtsToolSchema = Type.Object({

1010

text: Type.String({ description: "Text to speak." }),

1111

channel: Type.Optional(Type.String({ description: "Channel id; output-format hint." })),

1212

timeoutMs: Type.Optional(

13-

Type.Number({

13+

Type.Integer({

1414

description: "Provider timeout ms.",

1515

minimum: 1,

1616

}),

1717

),

1818

});

1919
2020

function readTtsTimeoutMs(args: Record<string, unknown>): number | undefined {

21-

const timeoutMs = readNumberParam(args, "timeoutMs", {

22-

integer: true,

23-

strict: true,

21+

return readPositiveIntegerParam(args, "timeoutMs", {

22+

message: "timeoutMs must be a positive integer in milliseconds.",

2423

});

25-

if (timeoutMs === undefined) {

26-

return undefined;

27-

}

28-

if (timeoutMs <= 0) {

29-

throw new ToolInputError("timeoutMs must be a positive integer in milliseconds.");

30-

}

31-

return timeoutMs;

3224

}

3325
3426

/**

Original file line numberDiff line numberDiff line change

@@ -203,7 +203,7 @@ const VideoGenerateToolProperties = {

203203

}),

204204

),

205205

timeoutMs: Type.Optional(

206-

Type.Number({

206+

Type.Integer({

207207

description: "Provider timeout ms.",

208208

minimum: 1,

209209

}),