wait_any
Wait for any of several terminal screen patterns at once, then return which one matched with its index and the final screen snapshot. Timeouts and dead child sessions return a result instead of an error.
Instructions
Wait for ANY of patterns to appear on screen (pexpect expect([...]) style).
Race several possible outcomes at once — e.g. patterns=[">>> ", "Error",
"Password:"] — and learn WHICH happened. Patterns are scanned in list order
each poll, so the earliest in the list wins a same-poll tie (put the most
specific first). Screen lines are right-padded with spaces — end-anchored
patterns never match; use unanchored markers. Returns {"ok", "index",
"matched", "alive", "exited", "text", "json"} where index is the 0-based
position of the matched pattern. Timeout is not an error: the call returns
ok=true with index=-1 and matched=false plus the final screen snapshot.
On a detect_child_exit session whose child died first, index is -1,
matched is false and exited is true — the wait returned at once rather
than running to timeout_ms.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sid | Yes | ||
| patterns | Yes | ||
| timeout_ms | No |