wait_any
Wait for any of several text patterns to appear on a terminal screen and return which one matched. Handles conditional prompts, errors, and login prompts in CLI sessions.
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", "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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sid | Yes | ||
| patterns | Yes | ||
| timeout_ms | No |