

























@@ -23,18 +23,22 @@ const DEFAULT_CHUNKED_PAYLOAD_MAX_CHUNKS = 4096;
2323const COMMAND_TIMEOUT_MS = optionalPositiveInteger(
2424process.env.OPENCLAW_TELEGRAM_USER_CREDENTIAL_COMMAND_TIMEOUT_MS?.trim(),
2525120_000,
26+"OPENCLAW_TELEGRAM_USER_CREDENTIAL_COMMAND_TIMEOUT_MS",
2627);
2728const BROKER_TIMEOUT_MS = optionalPositiveInteger(
2829process.env.OPENCLAW_TELEGRAM_USER_CREDENTIAL_BROKER_TIMEOUT_MS?.trim(),
293030_000,
31+"OPENCLAW_TELEGRAM_USER_CREDENTIAL_BROKER_TIMEOUT_MS",
3032);
3133const CHUNKED_PAYLOAD_MAX_BYTES = optionalPositiveInteger(
3234process.env.OPENCLAW_QA_CREDENTIAL_PAYLOAD_MAX_BYTES?.trim(),
3335DEFAULT_CHUNKED_PAYLOAD_MAX_BYTES,
36+"OPENCLAW_QA_CREDENTIAL_PAYLOAD_MAX_BYTES",
3437);
3538const CHUNKED_PAYLOAD_MAX_CHUNKS = optionalPositiveInteger(
3639process.env.OPENCLAW_QA_CREDENTIAL_PAYLOAD_MAX_CHUNKS?.trim(),
3740DEFAULT_CHUNKED_PAYLOAD_MAX_CHUNKS,
41+"OPENCLAW_QA_CREDENTIAL_PAYLOAD_MAX_CHUNKS",
3842);
39434044function usage(): never {
@@ -156,16 +160,17 @@ function optionalString(source: JsonObject, key: string) {
156160return undefined;
157161}
158162159-function optionalPositiveInteger(value: string | undefined, fallback: number) {
160-if (!value) {
163+function optionalPositiveInteger(value: string | undefined, fallback: number, label = "value") {
164+const text = value?.trim();
165+if (!text) {
161166return fallback;
162167}
163-if (!/^\d+$/u.test(value)) {
164-throw new Error(`Expected positive integer, got ${value}.`);
168+if (!/^\d+$/u.test(text)) {
169+throw new Error(`${label} must be a positive integer. Got: ${JSON.stringify(text)}.`);
165170}
166-const parsed = Number(value);
171+const parsed = Number(text);
167172if (!Number.isSafeInteger(parsed) || parsed < 1) {
168-throw new Error(`Expected positive integer, got ${value}.`);
173+throw new Error(`${label} must be a positive integer. Got: ${JSON.stringify(text)}.`);
169174}
170175return parsed;
171176}
@@ -256,12 +261,14 @@ async function resolveConvexLeaseConfig(opts: Map<string, string>) {
256261 process.env.OPENCLAW_QA_CREDENTIAL_LEASE_TTL_MS?.trim() ||
257262 fileEnv.OPENCLAW_QA_CREDENTIAL_LEASE_TTL_MS,
258263 20 * 60 * 1_000,
264+ "OPENCLAW_QA_CREDENTIAL_LEASE_TTL_MS",
259265 ),
260266 heartbeatIntervalMs: optionalPositiveInteger(
261267 opts.get("heartbeat-interval-ms") ||
262268 process.env.OPENCLAW_QA_CREDENTIAL_HEARTBEAT_INTERVAL_MS?.trim() ||
263269 fileEnv.OPENCLAW_QA_CREDENTIAL_HEARTBEAT_INTERVAL_MS,
264270 30_000,
271+ "OPENCLAW_QA_CREDENTIAL_HEARTBEAT_INTERVAL_MS",
265272 ),
266273 ownerId:
267274 opts.get("owner-id") ||
@@ -633,4 +640,4 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
633640await main();
634641}
635642636-export { parseChunkedPayloadMarker };
643+export { optionalPositiveInteger, parseChunkedPayloadMarker };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。