timeoutSecondsFromMessage function
Extracts the effective timeout in whole seconds from a shell timeout
error message (timeout: 0:00:30 — the shape both LocalShell and the
WASI sandbox emit), or null when no parseable duration is present.
Sub-second caps round up to 1 so the text never claims "after 0s".
Implementation
int? timeoutSecondsFromMessage(String message) {
final match = RegExp(
r'timeout:\s*(\d+):(\d{1,2}):(\d{1,2})',
).firstMatch(message);
if (match == null) return null;
final seconds =
int.parse(match.group(1)!) * 3600 +
int.parse(match.group(2)!) * 60 +
int.parse(match.group(3)!);
return seconds > 0 ? seconds : 1;
}