(command: string)
| 320 | * not sleep inside pipelines, subshells, or scripts (those are fine). |
| 321 | */ |
| 322 | export function detectBlockedSleepPattern(command: string): string | null { |
| 323 | const parts = splitCommand_DEPRECATED(command); |
| 324 | if (parts.length === 0) return null; |
| 325 | const first = parts[0]?.trim() ?? ''; |
| 326 | // Bare `sleep N` or `sleep N.N` as the first subcommand. |
| 327 | // Float durations (sleep 0.5) are allowed — those are legit pacing, not polls. |
| 328 | const m = /^sleep\s+(\d+)\s*$/.exec(first); |
| 329 | if (!m) return null; |
| 330 | const secs = parseInt(m[1]!, 10); |
| 331 | if (secs < 2) return null; // sub-2s sleeps are fine (rate limiting, pacing) |
| 332 | |
| 333 | // `sleep N` alone → "what are you waiting for?" |
| 334 | // `sleep N && check` → "use Monitor { command: check }" |
| 335 | const rest = parts.slice(1).join(' ').trim(); |
| 336 | return rest ? `sleep ${secs} followed by: ${rest}` : `standalone sleep ${secs}`; |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * Checks if a command contains tools that shouldn't run in sandbox |
no test coverage detected