@@ -11,6 +11,7 @@ import fs from "node:fs";
|
11 | 11 | import os from "node:os"; |
12 | 12 | import path from "node:path"; |
13 | 13 | import { fileURLToPath } from "node:url"; |
| 14 | +import { clampTimerTimeoutMs } from "@openclaw/normalization-core/number-coercion"; |
14 | 15 | import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs"; |
15 | 16 | import { createPnpmRunnerSpawnSpec } from "../pnpm-runner.mjs"; |
16 | 17 | import { readPositiveIntEnv } from "./lib/env-limits.mjs"; |
@@ -253,6 +254,14 @@ function parsePositiveInteger(value: string, label: string) {
|
253 | 254 | return parsed; |
254 | 255 | } |
255 | 256 | |
| 257 | +function resolveTelegramProofTimerTimeoutMs(value: number) { |
| 258 | +return clampTimerTimeoutMs(value) ?? 1; |
| 259 | +} |
| 260 | + |
| 261 | +function parsePositiveTimerMs(value: string, label: string) { |
| 262 | +return resolveTelegramProofTimerTimeoutMs(parsePositiveInteger(value, label)); |
| 263 | +} |
| 264 | + |
256 | 265 | function parseTcpPort(value: string, label: string) { |
257 | 266 | const parsed = parsePositiveInteger(value, label); |
258 | 267 | if (parsed > 65_535) { |
@@ -394,7 +403,7 @@ export function parseArgs(argvInput: string[]): Options {
|
394 | 403 | } else if (arg === "--text") { |
395 | 404 | opts.text = readValue(); |
396 | 405 | } else if (arg === "--timeout-ms") { |
397 | | -opts.timeoutMs = parsePositiveInteger(readValue(), "--timeout-ms"); |
| 406 | +opts.timeoutMs = parsePositiveTimerMs(readValue(), "--timeout-ms"); |
398 | 407 | } else if (arg === "--ttl") { |
399 | 408 | opts.ttl = readValue(); |
400 | 409 | } else if (arg === "--user-driver-script") { |
@@ -747,8 +756,10 @@ export function runCommand(params: {
|
747 | 756 | let timeoutError: Error | null = null; |
748 | 757 | let forceKillAt: number | undefined; |
749 | 758 | let killTimer: NodeJS.Timeout | undefined; |
750 | | -const timeoutMs = params.timeoutMs ?? COMMAND_TIMEOUT_MS; |
751 | | -const timeoutKillGraceMs = params.timeoutKillGraceMs ?? COMMAND_TIMEOUT_KILL_GRACE_MS; |
| 759 | +const timeoutMs = resolveTelegramProofTimerTimeoutMs(params.timeoutMs ?? COMMAND_TIMEOUT_MS); |
| 760 | +const timeoutKillGraceMs = resolveTelegramProofTimerTimeoutMs( |
| 761 | +params.timeoutKillGraceMs ?? COMMAND_TIMEOUT_KILL_GRACE_MS, |
| 762 | +); |
752 | 763 | const clearTimers = () => { |
753 | 764 | clearTimeout(timeout); |
754 | 765 | if (killTimer) { |
@@ -888,11 +899,14 @@ function waitForOutput(
|
888 | 899 | timeoutMs: number, |
889 | 900 | ) { |
890 | 901 | return new Promise<void>((resolve, reject) => { |
| 902 | +const resolvedTimeoutMs = resolveTelegramProofTimerTimeoutMs(timeoutMs); |
891 | 903 | const timeout = setTimeout(() => { |
892 | 904 | reject( |
893 | | -new Error(`${label} did not become ready within ${timeoutMs}ms\n${output().slice(-4000)}`), |
| 905 | +new Error( |
| 906 | +`${label} did not become ready within ${resolvedTimeoutMs}ms\n${output().slice(-4000)}`, |
| 907 | +), |
894 | 908 | ); |
895 | | -}, timeoutMs); |
| 909 | +}, resolvedTimeoutMs); |
896 | 910 | const onData = () => { |
897 | 911 | if (pattern.test(output())) { |
898 | 912 | cleanup(); |
|