fix: validate web fetch max chars · openclaw/openclaw@44dc29f
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ import { extractReadableContent } from "../../web-fetch/content-extractors.runti
|
15 | 15 | import { resolveWebProviderConfig } from "../../web/provider-runtime-shared.js"; |
16 | 16 | import { stringEnum } from "../schema/string-enum.js"; |
17 | 17 | import type { AnyAgentTool } from "./common.js"; |
18 | | -import { jsonResult, readNumberParam, readStringParam } from "./common.js"; |
| 18 | +import { jsonResult, readPositiveIntegerParam, readStringParam } from "./common.js"; |
19 | 19 | import { |
20 | 20 | extractBasicHtmlContent, |
21 | 21 | htmlToMarkdown, |
@@ -59,7 +59,7 @@ const WebFetchSchema = Type.Object({
|
59 | 59 | }), |
60 | 60 | ), |
61 | 61 | maxChars: Type.Optional( |
62 | | -Type.Number({ |
| 62 | +Type.Integer({ |
63 | 63 | description: "Max chars returned; truncates.", |
64 | 64 | minimum: 100, |
65 | 65 | }), |
@@ -674,7 +674,7 @@ export function createWebFetchTool(options?: {
|
674 | 674 | const params = args as Record<string, unknown>; |
675 | 675 | const url = readStringParam(params, "url", { required: true }); |
676 | 676 | const extractMode = readStringParam(params, "extractMode") === "text" ? "text" : "markdown"; |
677 | | -const maxChars = readNumberParam(params, "maxChars", { integer: true }); |
| 677 | +const maxChars = readPositiveIntegerParam(params, "maxChars"); |
678 | 678 | const maxCharsCap = resolveFetchMaxCharsCap(executionFetch); |
679 | 679 | const result = await runWebFetch({ |
680 | 680 | url, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。