Wait for the CLI to show its ready/welcome state before we type. Handles per-CLI quirks (e.g. Claude's trust dialog, Gemini's keychain init).
(child, cli_name: str, pexpect_mod)
| 416 | |
| 417 | |
| 418 | def _wait_for_ready(child, cli_name: str, pexpect_mod) -> None: |
| 419 | """ |
| 420 | Wait for the CLI to show its ready/welcome state before we type. |
| 421 | Handles per-CLI quirks (e.g. Claude's trust dialog, Gemini's keychain init). |
| 422 | """ |
| 423 | if cli_name == "claude": |
| 424 | _wait_for_claude(child, pexpect_mod) |
| 425 | elif cli_name == "gemini": |
| 426 | _wait_for_gemini(child, pexpect_mod) |
| 427 | else: |
| 428 | patterns_map = { |
| 429 | "qwen": [r">\s*$", r"\$\s*$"], |
| 430 | } |
| 431 | patterns = patterns_map.get(cli_name, []) |
| 432 | patterns.append(pexpect_mod.TIMEOUT) |
| 433 | try: |
| 434 | child.expect(patterns, timeout=CLI_READY_TIMEOUT) |
| 435 | except (pexpect_mod.TIMEOUT, pexpect_mod.EOF): |
| 436 | pass |
| 437 | |
| 438 | time.sleep(0.5) |
| 439 | |
| 440 | |
| 441 | def _wait_for_claude(child, pexpect_mod) -> None: |
no test coverage detected